View previous topic :: View next topic |
Author |
Message |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Thu Sep 06, 2007 7:42 pm Post subject: Rocket Aiming |
|
|
Lets say I wanted to fire a rocket into the ground.
How would I change this code?
Code: | void() W_FireRocket =
{
if (deathmatch != 4)
self.currentammo = self.ammo_rockets = self.ammo_rockets - 1;
sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
msg_entity = self;
WriteByte (MSG_ONE, SVC_SMALLKICK);
newmis = spawn ();
newmis.owner = self;
newmis.movetype = MOVETYPE_FLYMISSILE;
newmis.solid = SOLID_BBOX;
// set newmis speed
makevectors (self.v_angle);
newmis.velocity = aim(self, 1000);
newmis.velocity = newmis.velocity * 1000;
newmis.angles = vectoangles(newmis.velocity);
newmis.touch = T_MissileTouch;
newmis.voided = 0;
// set newmis duration
newmis.nextthink = time + 5;
newmis.think = SUB_Remove;
newmis.classname = "rocket";
setmodel (newmis, "progs/missile.mdl");
setsize (newmis, '0 0 0', '0 0 0');
setorigin (newmis, self.origin + v_forward*8 + '0 0 16');
}; |
_________________ Welcome to the Overlook Hotel 69.113.123.178:27500 |
|
Back to top |
|
 |
Sajt
Joined: 16 Oct 2004 Posts: 1026
|
Posted: Thu Sep 06, 2007 8:05 pm Post subject: |
|
|
Change
makevectors (self.v_angle);
newmis.velocity = aim(self, 1000);
newmis.velocity = newmis.velocity * 1000;
to:
v_forward = '0 0 -1';
newmis.velocity = '0 0 -1000'; _________________ F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe. |
|
Back to top |
|
 |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Fri Sep 07, 2007 2:22 pm Post subject: |
|
|
Thanks! _________________ Welcome to the Overlook Hotel 69.113.123.178:27500 |
|
Back to top |
|
 |
redrum

Joined: 28 Mar 2007 Posts: 367 Location: Long Island, New York
|
Posted: Sun Sep 16, 2007 4:20 pm Post subject: |
|
|
In PlayerPostThink, I want to add a line of code that says:
if (my health is less than 10 and I launch a rocket)
How would I do this?
Code: | if (self.health < 10 && (self.??????) ) |
I can't figure out the launch the rocket part. _________________ Welcome to the Overlook Hotel 69.113.123.178:27500 |
|
Back to top |
|
 |
Lardarse

Joined: 05 Nov 2005 Posts: 243 Location: Bristol, UK
|
Posted: Sun Sep 16, 2007 4:35 pm Post subject: |
|
|
Better way to add the check is when you fire the rocket (which is in the rocket firing function), and then check for low health there. |
|
Back to top |
|
 |
Orion

Joined: 12 Jan 2007 Posts: 413 Location: Brazil
|
Posted: Sun Sep 16, 2007 7:04 pm Post subject: |
|
|
Here's the correct code:
Code: |
if (self.health < 10 && self.weapon == IT_ROCKET_LAUNCHER && self.button0)
|
This says: If my health is less than 10 AND my current weapon is the rocket launcher AND I'm pressing the fire button, then I'll do the function in this statement. _________________ There's no signature here. Stop looking for one. |
|
Back to top |
|
 |
Preach
Joined: 25 Nov 2004 Posts: 122
|
Posted: Sun Sep 16, 2007 7:56 pm Post subject: |
|
|
Won't that return true even after the frame that the rocket has been fired, so long as the player holds the fire button down? |
|
Back to top |
|
 |
|