//=========================================================
// Monster's Anim Events Go Here
//=========================================================
#define ZOMBIE_AE_ATTACK_RIGHT 0x01
#define ZOMBIE_AE_ATTACK_LEFT 0x02
#define ZOMBIE_AE_ATTACK_BOTH 0x03
Just add these ones:
// headcrab jumps from zombie
#define ZOMBIE_AE_CRAB1 0x04
#define ZOMBIE_AE_CRAB2 0x05
#define ZOMBIE_AE_CRAB3 0x06
// headcrab jumps from zombie
Those just define the animation events used in the model for this, now just a few lines lower (after ZOMBIE_FLINCH_DELAY), add this:
#define ZOMBIE_CRAB "monster_headcrab" // headcrab jumps from zombie
That defines the ZOMBIE_CRAB, which will be used later to spawn a headcrab of all things.void SpawnCrab(void); // headcrab jumps from zombie
Now plop this piece of code at the end of the file:
//=========================================================
// Spawn Headcrab - headcrab jumps from zombie
//=========================================================
void CZombie :: SpawnCrab( void )
{
CBaseEntity *pCrab = CBaseEntity::Create( ZOMBIE_CRAB, pev->origin, pev->angles, edict() ); // create the crab
pCrab->pev->spawnflags |= SF_MONSTER_FALL_TO_GROUND; // make the crab fall
}
That top line just spawns a crab (notice the ZOMBIE_CRAB), and that second line makes the crab fall to the ground.// headcrab jumps from zombie
case ZOMBIE_AE_CRAB1:
{
ALERT( at_console, "Crab1 spawned!\n" );
pev->body = 1; // set the head to a skull
SpawnCrab(); // spawn a headcrab
}
break;
case ZOMBIE_AE_CRAB2:
{
ALERT( at_console, "Crab2 spawned!\n" );
pev->body = 1; // set the head to a skull
SpawnCrab(); // spawn a headcrab
}
break;
case ZOMBIE_AE_CRAB3:
{
ALERT( at_console, "Crab3 spawned!\n" );
pev->body = 1; // set the head to a skull
SpawnCrab(); // spawn a headcrab
}
break;
// headcrab jumps from zombie
The 'pev->body = 1' line sets the body to the skull found in the modified zombie model, and the 'SpawnCrab()' simply calls that function.UTIL_PrecacheOther( ZOMBIE_CRAB ); // headcrab jumps from zombie
Now compile it and run a test map, you may notice that the crab will only spawn when it isn't a headshot kill, makes the effect more realistic. Well, enjoy beheading those zombies!
$bodygroup body
{
studio "Zom3_Template_Biped(White_Suit)1"
studio "skullhead"
}
If you open up normal zombies .QC file, you'll notice this bit isn't there. What this does it make the two bodygroups that the new zombie has. The new one here is skullhead, which 'pev->body = 1' is linked to, while 'pev->body = 0' would be the White_Suit.
$sequence dieheadshot "dieheadshot" X fps 20 ACT_DIE_HEADSHOT 1 { event 2001 19 }
$sequence dieheadshot2 "dieheadshot2" fps 22 ACT_DIE_GUTSHOT 1 { event 2001 18 }
$sequence diesimple "diesimple" X fps 20 ACT_DIESIMPLE 1 { event 2001 13 } { event 4 8 }
$sequence diebackward "diebackward" fps 18 ACT_DIEBACKWARD 1 { event 2001 10 } { event 5 2 }
$sequence dieforward "dieforward" X fps 18 ACT_DIEFORWARD 1 { event 2001 21 } { event 6 18 }
Those are the zombie's death animations. The only relevent parts here are the { event ## ##}.$sequence diesimple "diesimple" X fps 20 ACT_DIESIMPLE 1 { event 2001 13 } { event 4 8 }
------------cpp file------------
#define ZOMBIE_AE_CRAB1 0x04
As you can see, event 4 is called on frame 8. Event 4 is refered to in zombie.cpp as 0x04 with the name ZOMBIE_AE_CRAB1 (where the code is called).
$sequence dieheadshot "dieheadshot" X fps 20 ACT_DIE_HEADSHOT 1 { event 2001 19 }
$sequence dieheadshot2 "dieheadshot2" fps 22 ACT_DIE_GUTSHOT 1 { event 2001 18 }
As you can see here, there are no new events for these two, this is what makes it so the crab won't jump off when its a headshot or a gutshot.You must log in to post a comment. You can login or register a new account.