Posted by: Twilight Suzuka
Date posted: Feb 20 2005 User Rating: 3 out of 5.0 | Number of views: 2366 Number of comments: 6 | Description: Remember HL1's cross bow bolt exploded when it hit? Get that, in HL2. |
Most of the coding for re-adding this effect is already in the code. We just need to re-activate it.
1. Open up weapon_crossbow.cpp
2. Add this to the includes:
2. Go to the function:
| | | | CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) |
3. Go down inside this function until you find:
| | | | if ( g_pGameRules->IsMultiplayer() ) |
4. Uncomment this line:
| | | | ExplosionCreate( GetAbsOrigin(), GetAbsAngles(), GetOwnerEntity(), 50, 200, SF_ENVEXPLOSION_NOSPARKS | SF_ENVEXPLOSION_NODLIGHTS | SF_ENVEXPLOSION_NOSMOKE, 0.0f, this); |
Congrats! Your Xbow bolts will now make an explosion effect when they hit something. However, we also need to make a damaging effect.
5. Add under the explosion effect:
| | | | RadiusDamage ( CTakeDamageInfo( this, GetOwnerEntity(), 50, DMG_BLAST ), GetAbsOrigin(), 200, CLASS_NONE, NULL ); |
EXTRA: How about we also spawn an energy ball when it hits?
6. Add these includes:
| | | #include "prop_combine_ball.h" #include "npc_combine.h"
|
7. Go back down to your function, and make a random vector for it to bounce off of:
| | | Vector vecVelocity; vecVelocity.x = random->RandomFloat( -1000.0f, 1000.0f ); vecVelocity.y = random->RandomFloat( -1000.0f, 1000.0f ); vecVelocity.z = random->RandomFloat( -1000.0f, 1000.0f );
|
8. Now, give it a random lifetime, and a random radius of damage.
| | | float lifetime = random->RandomFloat( 1.0, 4.0); int radi = random->RandomInt( 1, 10);
|
9. Add the energy ball spawn, and normalize the random's.
| | | CreateCombineBall( GetAbsOrigin(), vecVelocity, radi * 100.0, 20.0, lifetime, pOwner );
|
10. Wrap it all up, compile it, and your done. |
|
User Comments
Showing comments 1-6
Hey, Good Tutorial!
But i think there is something not right.
4. Uncomment this line:
CODE ExplosionCreate( GetAbsOrigin(), GetAbsAngles(), GetOwnerEntity(), 50, 200, SF_ENVEXPLOSION_NOSPARKS | SF_ENVEXPLOSION_NODLIGHTS | SF_ENVEXPLOSION_NOSMOKE, 0.0f, this);
That line doesnt seem to exist. I only see this one
if ( g_pGameRules->IsMultiplayer() ) { // SetThink( &CCrossbowBolt::ExplodeThink ); // SetNextThink( gpGlobals->curtime + 0.1f ); } }Edited by Unknown on Mar 19 2005, 10:03:05
|
|
I meant add not uncomment. You should also probably replace pOwner with GetOwner() |
|
|
Ahhh.. lol I'll try thatEdited by Unknown on Mar 20 2005, 16:02:09
|
|
|
Ok it works now and you dont have to replace pOwner with GetOwner() |
|
A cool addition:
in BoltTouch(), find where the code that handles what to do with the bolt when it hits the world. Instead of setting the Think() function to the time-delayed remove, you set it to a Detonate function. just like the commented out code:
SetThink(&CCrossbowBolt::ExplodeThink); SetNextThink(gpGlobals->curtime+1.0f);
Then define your ExplodeThink() function to do the explosion and then remove the arrow from the world. Then you get a time-delayed detonating arrow.Edited by hopper on Mar 28 2005, 12:36:42
|
|
From what I can tell, you need to #include "explode.h" and the others after the else in:
| | | #ifdef CLIENT_DLL #include "c_hl2mp_player.h" #include "c_te_effect_dispatch.h" #else |
It wouldn't work for me otherwise.
Also (if anyone's still reading this) the combineball segment of modding seems to not be able to find pOwner or GetOwner()
Maybe I'm just retarded, but if anyone knows the answer, please post. Thanks. |
|
You must register to post a comment. If you have already registered, you must login.
|
296 Approved Articless
5 Pending Articles
3940 Registered Members
0 People Online (14 guests)
|
|