Inside3D!
     

Rocket Aiming

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
redrum



Joined: 28 Mar 2007
Posts: 367
Location: Long Island, New York

PostPosted: Thu Sep 06, 2007 7:42 pm    Post subject: Rocket Aiming Reply with quote

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
View user's profile Send private message Send e-mail
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Thu Sep 06, 2007 8:05 pm    Post subject: Reply with quote

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
View user's profile Send private message
redrum



Joined: 28 Mar 2007
Posts: 367
Location: Long Island, New York

PostPosted: Fri Sep 07, 2007 2:22 pm    Post subject: Reply with quote

Thanks!
_________________
Welcome to the Overlook Hotel 69.113.123.178:27500
Back to top
View user's profile Send private message Send e-mail
redrum



Joined: 28 Mar 2007
Posts: 367
Location: Long Island, New York

PostPosted: Sun Sep 16, 2007 4:20 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Lardarse



Joined: 05 Nov 2005
Posts: 243
Location: Bristol, UK

PostPosted: Sun Sep 16, 2007 4:35 pm    Post subject: Reply with quote

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
View user's profile Send private message
Orion



Joined: 12 Jan 2007
Posts: 414
Location: Brazil

PostPosted: Sun Sep 16, 2007 7:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
Preach



Joined: 25 Nov 2004
Posts: 122

PostPosted: Sun Sep 16, 2007 7:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group