#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "schedule.h"
#include "animation.h"
#include "nodes.h"
#include "squadmonster.h"
#include "soundent.h"
#include "game.h"
In order to get an explosion into the otherwise feeble houndeye, we must add one additional import:
#include "explode.h"
Pretty self explanatory, right?SonicAttack()
, it should be located around line 93 and should look like:
void SonicAttack( void );
Now, in order to alter this function in the new entity class (discussed later), you must add the virtual tag to this function so that it can be over ridden. It should now resemble this:
virtual void SonicAttack( void );
Now to making our very own houndeye. First, you should probably jump down to the bottom of the file for this part, so as to keep it separated from the rest of the code and easier to find. In order to make our new class, you must extend the old CHoundeye
class and declare it to override the SonicAttack()
function and link it to its own entity name. The code should look something like this:
class CAHoundeye : public CHoundeye
{
public :
virtual void SonicAttack( void );
};
LINK_ENTITY_TO_CLASS( monster_houndeye_atomic, CAHoundeye );
That was probably the hardest part to this. The next step is to begin the definition of your new SonicAttack()
function It should look pretty much the same as this:
void CAHoundeye :: SonicAttack( void )
Then for its definition, you first must copy and paste the original SonicAttack()
code for the new SonicAttack()
Function. This code can be found at approximately line 560 and goes to about line 670. Don't worry about the size, there are a lot of braces and we are only concerned with a small portion of the entire block. After you paste the code in, you need to find the section in which damage is dealt to the player/entity. It should look like:
if (flAdjustedDamage > 0 )
{
pEntity->TakeDamage ( pev, pev, flAdjustedDamage, DMG_SONIC | DMG_ALWAYSGIB );
}
What's great about this is that you don't have to recalculate the area of effect, as the sonic attack itself has already done that for you. So all we must add is the explosion. And that goes right after the TakeDamage call, like this:
ExplosionCreate( pEntity->Center(), Vector(0,0,0), edict(), (int)(3 * flAdjustedDamage), true);
The function parameters are as follows:
( const Vector & center, const Vector & angles, edict_t *pOwner, int magnitude, BOOL doDamage )
All of the parameters are pretty self explanatory. Because of the nature of this function, angles is unused and has no effect on the outcome. The edict()
function returns an edict_s
, which carries various information pertinent to the houndeye itself. The edict_s
definition can be found in engine/edict.h.if ( !FClassnameIs(pEntity->pev, "monster_houndeye") )
This is how it determines whether or not the entity in question is a houndeye. Now, to include our new friend to this, we must add a new condition. The final condition should look like this:
if ( !FClassnameIs(pEntity->pev, "monster_houndeye") && !FClassnameIs(pEntity->pev, "monster_houndeye_atomic") )
There, you now have a brand new Atomic Houndeye that won't hurt itself or other houndeyes with its sonic attack. Now onto the FGD.@PointClass base(Monster) size(-16 -16 0, 16 16 36) = monster_houndeye : "Houndeye"
becomes:
@PointClass base(Monster) size(-16 -16 0, 16 16 36) = monster_houndeye_atomic : "Atomic Houndeye"
And there you have it, save the changes to the FGD, load it into Hammer and you're ready to go. You may want to play around with the actual magnitude of the blast, but I found 3x its normal damage is a good number - just watch out for 'em in packs.
SonicAttack()
to virtual, otherwise your new houndeye will still call the old houndeye SonicAttack
.
You must log in to post a comment. You can login or register a new account.