My Second Mod

Cunbelin

Newbie
Joined
Aug 3, 2003
Messages
281
Reaction score
0
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::primaryAttack. 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.)
 
I've been messing around with the crossbow.

I found an amazing physics discovery; too much tension creates sparks.

Does the crossbow use metal strings? Weird.
Maybe my physics perception is stuffed?

http://www.beyond3d.com/forum/viewtopic.php?t=18654

EDIT:
I'm an idiot. It's the bolt's friction against the bow.
I changed the speed to be slower and the friction isn't that bad.
Less sparks.
 
Nice.

The first thing I did with the original HL was make the crossbow fully-auto with a 50-round clip.
 
Here's something else you may find interesting.

d2_prison_010000.jpg


You create a marker and then when you shoot the rocket/grenade seeks the marker.
You can also manouver the rocket in the air like a waypoint system.
 
well, the first change to the code I did was making a command to upgrade the gravity gun.

I feel like writing about it, and since you wrote about how you made your mod, I will do that too.

First, I looked at the cfg to see what command is associated with button "g", then searched the source code for it and found it in one line in client.cpp

Code:
static ConCommand physswap("phys_swap", CC_Player_PhysSwap, "Automatically swaps the current weapon for the physcannon and back again." );

After taking a few mins to look at this and trace what the hell ConCommand is .. I made a new one right below it
Code:
//Hasan
static ConCommand physup("phys_up", CC_Player_PhysUpgrade, "Upgrades the Manipulater." );

right above it, there was a function called
CC_Player_PhysSwap
so I copied it and hacked it
Code:
//Hasan- attempt to force ggun upgrade
void CC_Player_PhysUpgrade( void )
{
	CBasePlayer *pPlayer = ToBasePlayer( UTIL_GetCommandClient() );

	if ( pPlayer )
	{
		CBaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon();

		if ( pWeapon )
		{
			// Tell the client to stop selecting weapons
			engine->ClientCommand( UTIL_GetCommandClient()->edict(), "cancelselect" );

			const char *strWeaponName = pWeapon->GetName();

			if ( !Q_stricmp( strWeaponName, "weapon_physcannon" ) )
			{
				PhysCannonBeginUpgrade( pWeapon );
			}
		}
	}
}
First I needed to check whether the current wepoan is the g-gun. code is already there.
then I need to upgrade tis gun ...
PhysCannonBeginUpgrade( pWeapon ) is a two-line function, at first I tried to write these two lines on my own, but I got errors about CWeaponPhysCannon not defined and the like.
after struggling for some time, I came across this function somehow, and decided to use it. and it worked.
it's better anyways, my casting was bad (c-style) .. so .. heh!

got it workign anywas, it looks kinda ugly (I think) havn't fully tested it. it probably needs some eye candy or something :/
 
Back
Top