Forum

Rocket Aiming

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Rocket Aiming

Postby redrum » Thu Sep 06, 2007 7:42 pm

Lets say I wanted to fire a rocket into the ground.
How would I change this code?

Code: Select all
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: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby Sajt » Thu Sep 06, 2007 8:05 pm

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.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby redrum » Fri Sep 07, 2007 2:22 pm

Thanks!
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby redrum » Sun Sep 16, 2007 4:20 pm

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: Select all
if (self.health < 10 && (self.??????) )


I can't figure out the launch the rocket part.
Welcome to the Overlook Hotel: The-Overlook-Hotel.game-server.cc
User avatar
redrum
 
Posts: 410
Joined: Wed Mar 28, 2007 11:35 pm
Location: Long Island, New York

Postby Lardarse » Sun Sep 16, 2007 4:35 pm

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.
User avatar
Lardarse
 
Posts: 266
Joined: Sat Nov 05, 2005 1:58 pm
Location: Bristol, UK

Postby Orion » Sun Sep 16, 2007 7:04 pm

Here's the correct code:

Code: Select all
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.
User avatar
Orion
 
Posts: 476
Joined: Fri Jan 12, 2007 6:32 pm
Location: Brazil

Postby Preach » Sun Sep 16, 2007 7:56 pm

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?
Preach
 
Posts: 122
Joined: Thu Nov 25, 2004 7:20 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest