Posted by: ScoBra7
Date posted: Apr 07 2003 User Rating: 4.5 out of 5.0 | Number of views: 3197 Number of comments: 1 | Description: The headless chicken run! |
This tutorial will show you how to create new bullet types. Also the new bullet will cause the target player to lose all weapons, including the crowbar. Look at them running like headless chickens to find something to hit back with!
First we are going to define the new bullet type. Open weapons.h and find | | | typedef enum { BULLET_NONE = 0, BULLET_PLAYER_9MM, // glock BULLET_PLAYER_MP5, // mp5 BULLET_PLAYER_357, // python BULLET_PLAYER_BUCKSHOT, // shotgun BULLET_PLAYER_CROWBAR, // crowbar swipe
BULLET_MONSTER_9MM, BULLET_MONSTER_MP5, BULLET_MONSTER_12MM, } Bullet; | add the following after BULLET_MONSTER_12MM, Save weapons.h
Open cbase.h and find| | | | #define DMG_MORTAR (1 << 23) | and add this| | | | #define DMG_BUTTER_FINGERS (1 << 24) // Hit by butter fingers bullet | Save cbase.h.
Open combat.cpp and in the function void CBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker ) find | | | else switch(iBulletType) { default: case BULLET_PLAYER_9MM: pEntity->TraceAttack(pevAttacker, gSkillData.plrDmg9MM, vecDir, &tr, DMG_BULLET); break; |
Now add after this:| | | case BULLET_PLAYER_9MM_BF: { pEntity->TraceAttack(pevAttacker, gSkillData.plrDmg9MM, vecDir, &tr, DMG_BUTTER_FINGERS); break; } | Save combat.cpp.
Open client.cpp and in void ClientPrecache( void ) add | | | | PRECACHE_SOUND("ambience/warn1.wav"); | Save client.cpp.
Next open player.cpp. In void CBasePlayer :: TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) after the switch statement add| | | if(bitsDamageType == DMG_BUTTER_FINGERS) { RemoveAllItems( FALSE ); //Play sound EMIT_SOUND(ENT(pev), CHAN_BODY, "ambience/warn1.wav", 1, ATTN_NORM); } |
When hit by a Butter Finger bullet the victim’s weapons will be remove, we leave the suite (FALSE parameter of RemoveAllItems), take some damage and he / she will hear a sound.
In the function int CBasePlayer :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) find | | | if (bitsDamage & DMG_SHOCK) { bitsDamage &= ~DMG_SHOCK; ffound = TRUE; } | and add| | | if (bitsDamage & DMG_BUTTER_FINGERS) { bitsDamage &= ~ DMG_BUTTER_FINGERS; ffound = TRUE; } | Save player.cpp.
We will implement this for the Glock, but you can do so for any weapons that use the FireBullets. So open hl_wpn_glock.cpp and in the function void CGlock::GlockFire( float flSpread , float flCycleTime, BOOL fUseAutoAim ) find | | | | m_pPlayer->FireBullets( 1, vecSrc, vecAiming, Vector( flSpread, flSpread, flSpread ), 8192, BULLET_PLAYER_9MM, 0 ); | and replace with | | | | m_pPlayer->FireBullets( 1, vecSrc, vecAiming, Vector( flSpread, flSpread, flSpread ), 8192, fUseAutoAim ? BULLET_PLAYER_9MM : BULLET_PLAYER_9MM_BF, 0 ); | Save hl_wpn_glock.cpp.
The secondary fire for the Glock set fUseAutoAim to false, so we can use it to determine if Primary or Secondary fire was used. Thus Primary fire will use normal bullets while secondary fire will use the Butter Finger bullets. There are different ways to implement this for the Glock.
That's all, Enjoy! That’s all folks. You can e-mail me at scobra@ananzi.co.za for comments and questions. |
|
User Comments
Showing comments 1-1
"Open combat.cpp and in the function void CBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker ) find...."
The code you specify to look for is in CBaseEntity::FireBulletsPlayer(...) not CBaseEntity::FireBullets(...). Also, you code you add there doesn't need to be held in braces, since it's just a single line.Edited by Exomoto on Nov 14 2005, 22:20:51
|
|
You must register to post a comment. If you have already registered, you must login.
|
296 Approved Articless
5 Pending Articles
3940 Registered Members
4 People Online (26 guests)
|
|