Well to do a little extension on the original tutorial provided by Valve I thought I'd share a little more exploration that I'd done with modding. For this I decided to alter the RPG to fire all three missiles and track them all. Not all that more advanced than changing the fire speed but it's a step up.
For this one we'll have to open the same file hl>Source Files>HL2 DLL>weapon_rpg.cpp
if you haven't already change the #define RPG_SPEED back to 1500
Then scroll down to CWeaponRPG:rimaryAttack. Now since I'm obviously not the programmer who originally made this code I want to note any changes I make, in this case I'm going to surround any changes I make with /*CP*/ in this case it's my initials, I suggest you do the same this will allow you to quickly search for any changes you made later and will make it clear to others what you changed if you release your source code.
Ok so we want to comment out the first two statements, so the start of the code should look like so:
I added my own comment as well as my signature tags, I also opted to simply comment out the code rather than remove it. We change this so that we can fire RPG's while others are in the air. Now if you were to compile this now we'd have the basic concept achieved we can fire three rockets in quick succession and have them all track the laser pointer. The problem here is that when an RPG explodes the RPG reloads we want to stop this behavior. To do this we need to go down a little further to the callback function CWeaponRPG::NotifyRocketDied here we need to comment out the reload though we need to leave the begining portion.
There we go, you now have modified the RPG to fire without reloading. I hope to figure out soon how to change the RPG over to a system that forces a reload after 3 shots, as if you were to stand on a pile of RPG's you could continue firing constantly. To test I recommend d1_cannals_13, take the boat and face down the helicopter with your improved RPG.
(A note this is not 100% correct, and has a possible bug in that there will be no entity handles in the RPG weapon structure for any but the last missile fired, it is also possible that this will cause a memory leak due to improper tracking of the entities, on the other hand it works for now so have fun with it, just don't use it in any official mods.)
For this one we'll have to open the same file hl>Source Files>HL2 DLL>weapon_rpg.cpp
if you haven't already change the #define RPG_SPEED back to 1500
Then scroll down to CWeaponRPG:rimaryAttack. Now since I'm obviously not the programmer who originally made this code I want to note any changes I make, in this case I'm going to surround any changes I make with /*CP*/ in this case it's my initials, I suggest you do the same this will allow you to quickly search for any changes you made later and will make it clear to others what you changed if you release your source code.
Ok so we want to comment out the first two statements, so the start of the code should look like so:
Code:
/*CP*/
//We now allow 3 missiles to be fired at any time
// Can't have an active missile out
//if ( m_hMissile != NULL )
//return;
/*CP*/
I added my own comment as well as my signature tags, I also opted to simply comment out the code rather than remove it. We change this so that we can fire RPG's while others are in the air. Now if you were to compile this now we'd have the basic concept achieved we can fire three rockets in quick succession and have them all track the laser pointer. The problem here is that when an RPG explodes the RPG reloads we want to stop this behavior. To do this we need to go down a little further to the callback function CWeaponRPG::NotifyRocketDied here we need to comment out the reload though we need to leave the begining portion.
Code:
m_hMissile = NULL;
/*CP*/
//we no longer reload if there is any ammo left
//Reload();
/*CP*/
There we go, you now have modified the RPG to fire without reloading. I hope to figure out soon how to change the RPG over to a system that forces a reload after 3 shots, as if you were to stand on a pile of RPG's you could continue firing constantly. To test I recommend d1_cannals_13, take the boat and face down the helicopter with your improved RPG.
(A note this is not 100% correct, and has a possible bug in that there will be no entity handles in the RPG weapon structure for any but the last missile fired, it is also possible that this will cause a memory leak due to improper tracking of the entities, on the other hand it works for now so have fun with it, just don't use it in any official mods.)