Accelerating Rockets
Author: Errorabove[ScI]Source: https://www.insideqc.com/qctut/qctut-81.shtml
We are going to make a mod to make those rockets gradually speed up... I know that this is a simple task, but this is for beginners. Lets get started now, shall we?
[Step 1]
Get a clean source... or at least one that doesn't have a modified rocket launcher code and look really carefully at it, because you may not need this tutorial at all if you stare long enough at the code. If you still want to try out my way of doing this technical marvel, then proceed
[Step 2]
Open the weapons.qc file and take a peak at the W_FireRocket (); function. Next you need to find where it says this :
missile.velocity = missile.velocity * 1000;
This is just telling the rocket to fly at a speed of 1000 at the desired angle.
[Step 3]
Replace that 1000 with a 200... that's more of a good starting speed for your rockets...
[Step 4]
Now you need to find this little bit of code :
missile.nextthink = time + 5;
missile.think = SUB_Remove;
This is telling the rocket to call the function SUB_Remove ();, which makes the rocket go BYE BYE, in 5 seconds after the launching.
[Step 5]
Since we don't want the rocket to disappear and we want it to speed up a bit, change that thingy to this new code :
missile.nextthink = time + 0.01;
missile.think = RocketSpeedChange;
This calls my new function to speed up the rocket in 0.01 seconds after the rocket is launched.
[Step 6]
Notice that there is a new function called RocketSpeedChange (); that needs to be created. Now, I could let you make one... but I'm a nice guy. Here ya go :
.float rspeed; // counter for how many times the rocket changes speed
void() RocketSpeedChange =
{
if (self.rspeed < 10) // 10 is the max speed changes
{
self.velocity = self.velocity * 2; // up the speed by 2x
self.rspeed = self.rspeed + 1; // up the counter to tell it to stop
self.nextthink = time + 0.5; // redo this function
}
};
There ya go.... that's all... HAVE FUN!
Tags: tutorial, quakec, qc, insideqc, weapon