Posted by: ScoBra7
Date posted: Apr 07 2003 User Rating: N/A | Number of views: 5632 Number of comments: 2 | Description: Suck 'em dry! |
This tutorial will show you how to create new damage type for the Egon. This damage type, Vampire, will suck the victim’s life and add it to yours.
First we are going to define the new damage type. Open cbase.h and find | | #define DMG_MORTAR (1 << 23) | and add this | | #define DMG_VAMPIRE (1 << 24) // Hit by vampire | Save cbase.h.
Open client.cpp and in void ClientPrecache( void ) add | | PRECACHE_SOUND("ambience/biotone.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_VAMPIRE) { bool bSound = false; int iDamage = (int)flDamage; for(int i = 0; i < iDamage; i++) { if(!bSound) { bSound = true; EMIT_SOUND(ENT(pev), CHAN_BODY, "ambience/biotone.wav", 1, ATTN_NORM); } if(pevAttacker->health < pevAttacker->max_health) { pevAttacker->health++; } else if(pevAttacker->armorvalue < 100.00) { pevAttacker->armorvalue++; } } } |
This will add the amount of damage you cause to your health until it is 100% and then to your armor until it is 100%. After that you will just cause damage. The victim will hear a sound when hit.
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_ VAMPIRE) { bitsDamage &= ~ DMG_ VAMPIRE; ffound = TRUE; } | Save player.cpp.
Open egon.cpp and find class CEgon : public CBasePlayerWeapon add | | void SecondaryAttack(void); | Now create the Secondary Attack function, after void CEgon::PrimaryAttack( void ): | | void CEgon::SecondaryAttack(void) { m_fireMode = FIRE_NARROW; Attack(); }
|
The secondary attack fires a narrow beam.
In void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) find | | case FIRE_NARROW: if ( pev->dmgtime < gpGlobals->time ) { // Narrow mode only does damage to the entity it hits ClearMultiDamage(); if (pEntity->pev->takedamage) { pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgEgonNarrow, vecDir, &tr, DMG_ENERGYBEAM ); } | and replace | | pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgEgonNarrow, vecDir, &tr, DMG_ENERGYBEAM ); | with | | pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgEgonNarrow, vecDir, &tr, DMG_VAMPIRE ); |
That’s all folks. You can e-mail me at scobra@ananzi.co.za for comments and questions. |
|
User Comments
Showing comments 1-2
how can i make the beam just like the primary fire, but red instead of purple? |
|
if you mean primary fire then place it under class CEgon::PrimaryAttack(void) |
|
You must register to post a comment. If you have already registered, you must login.
|
297 Approved Articless
8 Pending Articles
3940 Registered Members
0 People Online (3 guests)
|
|