Welcome, Guest! Login | Register

Egon Secondary Fire: Vampire [Print this Article]
Posted by: ScoBra7
Date posted: Apr 07 2003
User Rating: N/A
Number of views: 4827
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
 CODE  
#define DMG_MORTAR (1 << 23)
and add this
 CODE  
#define DMG_VAMPIRE    (1 << 24)   // Hit by vampire
Save cbase.h.

Open client.cpp and in void ClientPrecache( void ) add
 CODE  
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
 CODE  
 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
 CODE  
 if (bitsDamage & DMG_SHOCK)
  {
   bitsDamage &= ~DMG_SHOCK;
   ffound = TRUE;
  }
and add
 CODE  
 if (bitsDamage & DMG_ VAMPIRE)
  {
   bitsDamage &= ~ DMG_ VAMPIRE;
   ffound = TRUE;
  }
Save player.cpp.

Open egon.cpp and find class CEgon : public CBasePlayerWeapon add
 CODE  
void SecondaryAttack(void);
Now create the Secondary Attack function, after void CEgon::PrimaryAttack( void ):
 CODE  
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
 CODE  
 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
 CODE  
 pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgEgonNarrow, vecDir, &tr, DMG_ENERGYBEAM );
with
 CODE  
 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.

Rate This Article
This article has not yet been rated.

You have to register to rate this article.
User Comments Showing comments 1-2

Posted By: mgetz on Feb 17 2004 at 13:28:44
how can i make the beam just like the primary fire, but red instead of purple?

Posted By: Bryan on Mar 15 2004 at 04:26:37
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.

Latest Articles
3rd person View in Multiplayer
Half-Life 2 | Coding | Client Side Tutorials
How to enable it in HL2DM

By: cct | Nov 13 2006

Making a Camera
Half-Life 2 | Level Design
This camera is good for when you join a map, it gives you a view of the map before you join a team

By: slackiller | Mar 05 2006

Making a camera , Part 2
Half-Life 2 | Level Design
these cameras are working monitors that turn on when a button is pushed.

By: slackiller | Mar 04 2006

Storing weapons on ladder
Half-Life 2 | Coding | Snippets
like Raven Sheild or BF2

By: British_Bomber | Dec 24 2005

Implementation of a string lookup table
Half-Life 2 | Coding | Snippets
A string lookup table is a set of functions that is used to convert strings to pre-defined values

By: deathz0rz | Nov 13 2005


Latest Comments
knock knock
General | News
By: MIFUNE | Dec 31 2017
 
knock knock
General | News
By: omega | Dec 22 2016
 
knock knock
General | News
By: MIFUNE | Oct 10 2015
 
New HL HUD Message System
Half-Life | Coding | Shared Tutorials
By: chbrules | Dec 31 2011
 
knock knock
General | News
By: Whistler | Nov 05 2011
 
Particle Engine tutorial part 4
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 18 2010
 
Particle Engine tutorial part 2
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Particle Engine tutorial part 3
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Game Movement Series #2: Analog Jumping and Floating
Half-Life 2 | Coding | Shared Tutorials
By: mars3554 | Oct 26 2009
 
Particle Engine tutorial part 5
Half-Life | Coding | Client Side Tutorials
By: Deadpool | Aug 02 2009
 

Site Info
297 Approved Articless
8 Pending Articles
3940 Registered Members
0 People Online (3 guests)
About - Credits - Contact Us

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!