2016-06-04 15:24:23 +02:00
/***
*
* Copyright ( c ) 1996 - 2002 , Valve LLC . All rights reserved .
*
* This product contains software technology licensed from Id
* Software , Inc . ( " Id Technology " ) . Id Technology ( c ) 1996 Id Software , Inc .
* All Rights Reserved .
*
* This source code contains proprietary and confidential information of
* Valve LLC and its suppliers . Access to this code is restricted to
* persons who have executed a written SDK license with Valve . Any access ,
* use or distribution of this code by or to any unlicensed person is illegal .
*
* * * */
//=========================================================
// hgrunt
//=========================================================
//=========================================================
// Hit groups!
//=========================================================
/*
1 - Head
2 - Stomach
3 - Gun
*/
# include "extdll.h"
# include "plane.h"
# include "util.h"
# include "cbase.h"
# include "monsters.h"
# include "schedule.h"
# include "animation.h"
# include "squadmonster.h"
# include "weapons.h"
# include "talkmonster.h"
# include "soundent.h"
# include "effects.h"
# include "customentity.h"
int g_fGruntQuestion ; // true if an idle grunt asked a question. Cleared when someone answers.
extern DLL_GLOBAL int g_iSkillLevel ;
//=========================================================
// monster-specific DEFINE's
//=========================================================
# define GRUNT_CLIP_SIZE 36 // how many bullets in a clip? - NOTE: 3 round burst sound, so keep as 3 * x!
# define GRUNT_VOL 0.35 // volume of grunt sounds
# define GRUNT_ATTN ATTN_NORM // attenutation of grunt sentences
# define HGRUNT_LIMP_HEALTH 20
# define HGRUNT_DMG_HEADSHOT ( DMG_BULLET | DMG_CLUB ) // damage types that can kill a grunt with a single headshot.
# define HGRUNT_NUM_HEADS 2 // how many grunt heads are there?
2016-07-31 15:48:50 +02:00
# define HGRUNT_MINIMUM_HEADSHOT_DAMAGE 15 // must do at least this much damage in one shot to head to score a headshot kill
# define HGRUNT_SENTENCE_VOLUME (float)0.35 // volume of grunt sentences
2016-06-04 15:24:23 +02:00
# define HGRUNT_9MMAR ( 1 << 0)
# define HGRUNT_HANDGRENADE ( 1 << 1)
2016-07-31 15:48:50 +02:00
# define HGRUNT_GRENADELAUNCHER ( 1 << 2)
2016-06-04 15:24:23 +02:00
# define HGRUNT_SHOTGUN ( 1 << 3)
# define HEAD_GROUP 1
# define HEAD_GRUNT 0
2016-07-31 15:48:50 +02:00
# define HEAD_COMMANDER 1
# define HEAD_SHOTGUN 2
2016-06-04 15:24:23 +02:00
# define HEAD_M203 3
# define GUN_GROUP 2
# define GUN_MP5 0
# define GUN_SHOTGUN 1
# define GUN_NONE 2
//=========================================================
// Monster's Anim Events Go Here
//=========================================================
# define HGRUNT_AE_RELOAD ( 2 )
# define HGRUNT_AE_KICK ( 3 )
# define HGRUNT_AE_BURST1 ( 4 )
# define HGRUNT_AE_BURST2 ( 5 )
# define HGRUNT_AE_BURST3 ( 6 )
# define HGRUNT_AE_GREN_TOSS ( 7 )
2016-07-31 15:48:50 +02:00
# define HGRUNT_AE_GREN_LAUNCH ( 8 )
2016-06-04 15:24:23 +02:00
# define HGRUNT_AE_GREN_DROP ( 9 )
2016-07-31 15:48:50 +02:00
# define HGRUNT_AE_CAUGHT_ENEMY ( 10 ) // grunt established sight with an enemy (player only) that had previously eluded the squad.
# define HGRUNT_AE_DROP_GUN ( 11 ) // grunt (probably dead) is dropping his mp5.
2016-06-04 15:24:23 +02:00
//=========================================================
// monster-specific schedule types
//=========================================================
enum
{
SCHED_GRUNT_SUPPRESS = LAST_COMMON_SCHEDULE + 1 ,
SCHED_GRUNT_ESTABLISH_LINE_OF_FIRE , // move to a location to set up an attack against the enemy. (usually when a friendly is in the way).
SCHED_GRUNT_COVER_AND_RELOAD ,
SCHED_GRUNT_SWEEP ,
SCHED_GRUNT_FOUND_ENEMY ,
SCHED_GRUNT_REPEL ,
SCHED_GRUNT_REPEL_ATTACK ,
SCHED_GRUNT_REPEL_LAND ,
SCHED_GRUNT_WAIT_FACE_ENEMY ,
SCHED_GRUNT_TAKECOVER_FAILED , // special schedule type that forces analysis of conditions and picks the best possible schedule to recover from this type of failure.
2016-06-25 18:33:39 +02:00
SCHED_GRUNT_ELOF_FAIL
2016-06-04 15:24:23 +02:00
} ;
//=========================================================
// monster-specific tasks
//=========================================================
enum
{
TASK_GRUNT_FACE_TOSS_DIR = LAST_COMMON_TASK + 1 ,
TASK_GRUNT_SPEAK_SENTENCE ,
2016-06-25 18:33:39 +02:00
TASK_GRUNT_CHECK_FIRE
2016-06-04 15:24:23 +02:00
} ;
//=========================================================
// monster-specific conditions
//=========================================================
# define bits_COND_GRUNT_NOFIRE ( bits_COND_SPECIAL1 )
class CHGrunt : public CSquadMonster
{
public :
void Spawn ( void ) ;
void Precache ( void ) ;
2016-07-31 15:48:50 +02:00
void SetYawSpeed ( void ) ;
int Classify ( void ) ;
int ISoundMask ( void ) ;
2016-06-04 15:24:23 +02:00
void HandleAnimEvent ( MonsterEvent_t * pEvent ) ;
2016-07-31 15:48:50 +02:00
BOOL FCanCheckAttacks ( void ) ;
BOOL CheckMeleeAttack1 ( float flDot , float flDist ) ;
BOOL CheckRangeAttack1 ( float flDot , float flDist ) ;
BOOL CheckRangeAttack2 ( float flDot , float flDist ) ;
void CheckAmmo ( void ) ;
void SetActivity ( Activity NewActivity ) ;
void StartTask ( Task_t * pTask ) ;
void RunTask ( Task_t * pTask ) ;
2016-06-04 15:24:23 +02:00
void DeathSound ( void ) ;
void PainSound ( void ) ;
2016-07-31 15:48:50 +02:00
void IdleSound ( void ) ;
2016-06-04 15:24:23 +02:00
Vector GetGunPosition ( void ) ;
2016-07-31 15:48:50 +02:00
void Shoot ( void ) ;
void Shotgun ( void ) ;
void PrescheduleThink ( void ) ;
2016-06-04 15:24:23 +02:00
void GibMonster ( void ) ;
void SpeakSentence ( void ) ;
2016-06-25 18:33:39 +02:00
int Save ( CSave & save ) ;
2016-06-04 15:24:23 +02:00
int Restore ( CRestore & restore ) ;
2016-07-31 15:48:50 +02:00
CBaseEntity * Kick ( void ) ;
Schedule_t * GetSchedule ( void ) ;
Schedule_t * GetScheduleOfType ( int Type ) ;
2016-06-04 15:24:23 +02:00
void TraceAttack ( entvars_t * pevAttacker , float flDamage , Vector vecDir , TraceResult * ptr , int bitsDamageType ) ;
int TakeDamage ( entvars_t * pevInflictor , entvars_t * pevAttacker , float flDamage , int bitsDamageType ) ;
2016-07-31 15:48:50 +02:00
int IRelationship ( CBaseEntity * pTarget ) ;
2016-06-04 15:24:23 +02:00
BOOL FOkToSpeak ( void ) ;
void JustSpoke ( void ) ;
2016-06-25 18:33:39 +02:00
CUSTOM_SCHEDULES
2016-06-04 15:24:23 +02:00
static TYPEDESCRIPTION m_SaveData [ ] ;
// checking the feasibility of a grenade toss is kind of costly, so we do it every couple of seconds,
// not every server frame.
float m_flNextGrenadeCheck ;
float m_flNextPainTime ;
float m_flLastEnemySightTime ;
2016-07-31 15:48:50 +02:00
Vector m_vecTossVelocity ;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
BOOL m_fThrowGrenade ;
BOOL m_fStanding ;
BOOL m_fFirstEncounter ; // only put on the handsign show in the squad's first encounter.
int m_cClipSize ;
2016-06-04 15:24:23 +02:00
int m_voicePitch ;
2016-07-31 15:48:50 +02:00
int m_iBrassShell ;
int m_iShotgunShell ;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
int m_iSentence ;
2016-06-04 15:24:23 +02:00
static const char * pGruntSentences [ ] ;
} ;
2016-06-25 18:33:39 +02:00
LINK_ENTITY_TO_CLASS ( monster_human_grunt , CHGrunt )
2016-06-04 15:24:23 +02:00
2016-06-25 18:33:39 +02:00
TYPEDESCRIPTION CHGrunt : : m_SaveData [ ] =
2016-06-04 15:24:23 +02:00
{
DEFINE_FIELD ( CHGrunt , m_flNextGrenadeCheck , FIELD_TIME ) ,
DEFINE_FIELD ( CHGrunt , m_flNextPainTime , FIELD_TIME ) ,
2016-07-31 15:48:50 +02:00
//DEFINE_FIELD( CHGrunt, m_flLastEnemySightTime, FIELD_TIME ), // don't save, go to zero
2016-06-04 15:24:23 +02:00
DEFINE_FIELD ( CHGrunt , m_vecTossVelocity , FIELD_VECTOR ) ,
DEFINE_FIELD ( CHGrunt , m_fThrowGrenade , FIELD_BOOLEAN ) ,
DEFINE_FIELD ( CHGrunt , m_fStanding , FIELD_BOOLEAN ) ,
DEFINE_FIELD ( CHGrunt , m_fFirstEncounter , FIELD_BOOLEAN ) ,
DEFINE_FIELD ( CHGrunt , m_cClipSize , FIELD_INTEGER ) ,
DEFINE_FIELD ( CHGrunt , m_voicePitch , FIELD_INTEGER ) ,
2016-07-31 15:48:50 +02:00
//DEFINE_FIELD( CShotgun, m_iBrassShell, FIELD_INTEGER ),
//DEFINE_FIELD( CShotgun, m_iShotgunShell, FIELD_INTEGER ),
2016-06-04 15:24:23 +02:00
DEFINE_FIELD ( CHGrunt , m_iSentence , FIELD_INTEGER ) ,
} ;
2016-06-25 18:33:39 +02:00
IMPLEMENT_SAVERESTORE ( CHGrunt , CSquadMonster )
2016-06-04 15:24:23 +02:00
2016-06-25 18:33:39 +02:00
const char * CHGrunt : : pGruntSentences [ ] =
2016-06-04 15:24:23 +02:00
{
" HG_GREN " , // grenade scared grunt
" HG_ALERT " , // sees player
" HG_MONSTER " , // sees monster
" HG_COVER " , // running to cover
" HG_THROW " , // about to throw grenade
" HG_CHARGE " , // running out to get the enemy
" HG_TAUNT " , // say rude things
} ;
2017-06-29 15:56:03 +02:00
typedef enum
2016-06-04 15:24:23 +02:00
{
HGRUNT_SENT_NONE = - 1 ,
HGRUNT_SENT_GREN = 0 ,
HGRUNT_SENT_ALERT ,
HGRUNT_SENT_MONSTER ,
HGRUNT_SENT_COVER ,
HGRUNT_SENT_THROW ,
HGRUNT_SENT_CHARGE ,
2016-06-25 18:33:39 +02:00
HGRUNT_SENT_TAUNT
2016-06-04 15:24:23 +02:00
} HGRUNT_SENTENCE_TYPES ;
//=========================================================
// Speak Sentence - say your cued up sentence.
//
// Some grunt sentences (take cover and charge) rely on actually
// being able to execute the intended action. It's really lame
// when a grunt says 'COVER ME' and then doesn't move. The problem
// is that the sentences were played when the decision to TRY
// to move to cover was made. Now the sentence is played after
// we know for sure that there is a valid path. The schedule
// may still fail but in most cases, well after the grunt has
// started moving.
//=========================================================
2016-07-31 15:48:50 +02:00
void CHGrunt : : SpeakSentence ( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( m_iSentence = = HGRUNT_SENT_NONE )
2016-06-04 15:24:23 +02:00
{
// no sentence cued up.
return ;
}
2016-07-31 15:48:50 +02:00
if ( FOkToSpeak ( ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
SENTENCEG_PlayRndSz ( ENT ( pev ) , pGruntSentences [ m_iSentence ] , HGRUNT_SENTENCE_VOLUME , GRUNT_ATTN , 0 , m_voicePitch ) ;
2016-06-04 15:24:23 +02:00
JustSpoke ( ) ;
}
}
//=========================================================
// IRelationship - overridden because Alien Grunts are
// Human Grunt's nemesis.
//=========================================================
2016-07-31 15:48:50 +02:00
int CHGrunt : : IRelationship ( CBaseEntity * pTarget )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( FClassnameIs ( pTarget - > pev , " monster_alien_grunt " ) | | ( FClassnameIs ( pTarget - > pev , " monster_gargantua " ) ) )
2016-06-04 15:24:23 +02:00
{
return R_NM ;
}
return CSquadMonster : : IRelationship ( pTarget ) ;
}
//=========================================================
// GibMonster - make gun fly through the air.
//=========================================================
2016-07-31 15:48:50 +02:00
void CHGrunt : : GibMonster ( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
Vector vecGunPos ;
Vector vecGunAngles ;
2016-06-04 15:24:23 +02:00
2023-04-24 00:57:25 +02:00
if ( GetBodygroup ( GUN_GROUP ) ! = GUN_NONE )
2016-06-25 18:33:39 +02:00
{
// throw a gun if the grunt has one
2016-06-04 15:24:23 +02:00
GetAttachment ( 0 , vecGunPos , vecGunAngles ) ;
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
CBaseEntity * pGun ;
2016-07-31 15:48:50 +02:00
if ( FBitSet ( pev - > weapons , HGRUNT_SHOTGUN ) )
2016-06-04 15:24:23 +02:00
{
pGun = DropItem ( " weapon_shotgun " , vecGunPos , vecGunAngles ) ;
}
else
{
pGun = DropItem ( " weapon_9mmAR " , vecGunPos , vecGunAngles ) ;
}
2016-07-31 15:48:50 +02:00
if ( pGun )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
pGun - > pev - > velocity = Vector ( RANDOM_FLOAT ( - 100 , 100 ) , RANDOM_FLOAT ( - 100 , 100 ) , RANDOM_FLOAT ( 200 , 300 ) ) ;
pGun - > pev - > avelocity = Vector ( 0 , RANDOM_FLOAT ( 200 , 400 ) , 0 ) ;
2016-06-04 15:24:23 +02:00
}
2016-07-31 15:48:50 +02:00
if ( FBitSet ( pev - > weapons , HGRUNT_GRENADELAUNCHER ) )
2016-06-04 15:24:23 +02:00
{
pGun = DropItem ( " ammo_ARgrenades " , vecGunPos , vecGunAngles ) ;
if ( pGun )
{
2016-07-31 15:48:50 +02:00
pGun - > pev - > velocity = Vector ( RANDOM_FLOAT ( - 100 , 100 ) , RANDOM_FLOAT ( - 100 , 100 ) , RANDOM_FLOAT ( 200 , 300 ) ) ;
pGun - > pev - > avelocity = Vector ( 0 , RANDOM_FLOAT ( 200 , 400 ) , 0 ) ;
2016-06-04 15:24:23 +02:00
}
}
}
2016-07-31 15:48:50 +02:00
CBaseMonster : : GibMonster ( ) ;
2016-06-04 15:24:23 +02:00
}
//=========================================================
// ISoundMask - Overidden for human grunts because they
// hear the DANGER sound that is made by hand grenades and
// other dangerous items.
//=========================================================
2016-07-31 15:48:50 +02:00
int CHGrunt : : ISoundMask ( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
return bits_SOUND_WORLD |
bits_SOUND_COMBAT |
bits_SOUND_PLAYER |
2016-06-04 15:24:23 +02:00
bits_SOUND_DANGER ;
}
//=========================================================
// someone else is talking - don't speak
//=========================================================
2016-07-31 15:48:50 +02:00
BOOL CHGrunt : : FOkToSpeak ( void )
2016-06-04 15:24:23 +02:00
{
2016-06-25 18:33:39 +02:00
// if someone else is talking, don't speak
2016-07-31 15:48:50 +02:00
if ( gpGlobals - > time < = CTalkMonster : : g_talkWaitTime )
2016-06-04 15:24:23 +02:00
return FALSE ;
2016-07-31 15:48:50 +02:00
if ( pev - > spawnflags & SF_MONSTER_GAG )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( m_MonsterState ! = MONSTERSTATE_COMBAT )
2016-06-04 15:24:23 +02:00
{
// no talking outside of combat if gagged.
return FALSE ;
}
}
// if player is not in pvs, don't speak
2016-07-31 15:48:50 +02:00
//if( FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) )
2016-06-25 18:33:39 +02:00
// return FALSE;
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
return TRUE ;
}
//=========================================================
//=========================================================
2016-07-31 15:48:50 +02:00
void CHGrunt : : JustSpoke ( void )
2016-06-04 15:24:23 +02:00
{
2019-10-13 13:49:25 +02:00
CTalkMonster : : g_talkWaitTime = gpGlobals - > time + RANDOM_FLOAT ( 1.5f , 2.0f ) ;
2016-06-04 15:24:23 +02:00
m_iSentence = HGRUNT_SENT_NONE ;
}
//=========================================================
// PrescheduleThink - this function runs after conditions
// are collected and before scheduling code is run.
//=========================================================
2016-07-31 15:48:50 +02:00
void CHGrunt : : PrescheduleThink ( void )
2016-06-04 15:24:23 +02:00
{
2017-06-29 15:56:03 +02:00
if ( InSquad ( ) & & m_hEnemy ! = 0 )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( HasConditions ( bits_COND_SEE_ENEMY ) )
2016-06-04 15:24:23 +02:00
{
// update the squad's last enemy sighting time.
MySquadLeader ( ) - > m_flLastEnemySightTime = gpGlobals - > time ;
}
else
{
2019-10-13 13:49:25 +02:00
if ( gpGlobals - > time - MySquadLeader ( ) - > m_flLastEnemySightTime > 5.0f )
2016-06-04 15:24:23 +02:00
{
// been a while since we've seen the enemy
MySquadLeader ( ) - > m_fEnemyEluded = TRUE ;
}
}
}
}
//=========================================================
// FCanCheckAttacks - this is overridden for human grunts
// because they can throw/shoot grenades when they can't see their
// target and the base class doesn't check attacks if the monster
// cannot see its enemy.
//
// !!!BUGBUG - this gets called before a 3-round burst is fired
// which means that a friendly can still be hit with up to 2 rounds.
// ALSO, grenades will not be tossed if there is a friendly in front,
// this is a bad bug. Friendly machine gun fire avoidance
// will unecessarily prevent the throwing of a grenade as well.
//=========================================================
2016-07-31 15:48:50 +02:00
BOOL CHGrunt : : FCanCheckAttacks ( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( ! HasConditions ( bits_COND_ENEMY_TOOFAR ) )
2016-06-04 15:24:23 +02:00
{
return TRUE ;
}
else
{
return FALSE ;
}
}
//=========================================================
// CheckMeleeAttack1
//=========================================================
2016-07-31 15:48:50 +02:00
BOOL CHGrunt : : CheckMeleeAttack1 ( float flDot , float flDist )
2016-06-04 15:24:23 +02:00
{
2017-06-29 15:56:03 +02:00
CBaseMonster * pEnemy = 0 ;
2016-06-04 15:24:23 +02:00
2017-06-29 15:56:03 +02:00
if ( m_hEnemy ! = 0 )
2016-06-04 15:24:23 +02:00
{
pEnemy = m_hEnemy - > MyMonsterPointer ( ) ;
2016-07-31 15:48:50 +02:00
if ( ! pEnemy )
2016-06-04 15:24:23 +02:00
{
return FALSE ;
}
2019-11-16 09:54:30 +01:00
if ( flDist < = 64.0f & & flDot > = 0.7f & &
pEnemy - > Classify ( ) ! = CLASS_ALIEN_BIOWEAPON & &
pEnemy - > Classify ( ) ! = CLASS_PLAYER_BIOWEAPON )
{
return TRUE ;
}
2016-06-04 15:24:23 +02:00
}
return FALSE ;
}
//=========================================================
// CheckRangeAttack1 - overridden for HGrunt, cause
// FCanCheckAttacks() doesn't disqualify all attacks based
// on whether or not the enemy is occluded because unlike
// the base class, the HGrunt can attack when the enemy is
// occluded (throw grenade over wall, etc). We must
// disqualify the machine gun attack if the enemy is occluded.
//=========================================================
2016-07-31 15:48:50 +02:00
BOOL CHGrunt : : CheckRangeAttack1 ( float flDot , float flDist )
2016-06-04 15:24:23 +02:00
{
2019-10-13 13:49:25 +02:00
if ( ! HasConditions ( bits_COND_ENEMY_OCCLUDED ) & & flDist < = 2048.0f & & flDot > = 0.5f & & NoFriendlyFire ( ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
TraceResult tr ;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
if ( ! m_hEnemy - > IsPlayer ( ) & & flDist < = 64 )
2016-06-04 15:24:23 +02:00
{
// kick nonclients, but don't shoot at them.
return FALSE ;
}
Vector vecSrc = GetGunPosition ( ) ;
// verify that a bullet fired from the gun will hit the enemy before the world.
2016-07-31 15:48:50 +02:00
UTIL_TraceLine ( vecSrc , m_hEnemy - > BodyTarget ( vecSrc ) , ignore_monsters , ignore_glass , ENT ( pev ) , & tr ) ;
2016-06-04 15:24:23 +02:00
2019-10-13 13:49:25 +02:00
if ( tr . flFraction = = 1.0f )
2016-06-04 15:24:23 +02:00
{
return TRUE ;
}
}
return FALSE ;
}
//=========================================================
// CheckRangeAttack2 - this checks the Grunt's grenade
// attack.
//=========================================================
2016-07-31 15:48:50 +02:00
BOOL CHGrunt : : CheckRangeAttack2 ( float flDot , float flDist )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( ! FBitSet ( pev - > weapons , ( HGRUNT_HANDGRENADE | HGRUNT_GRENADELAUNCHER ) ) )
2016-06-04 15:24:23 +02:00
{
return FALSE ;
}
// if the grunt isn't moving, it's ok to check.
2016-07-31 15:48:50 +02:00
if ( m_flGroundSpeed ! = 0 )
2016-06-04 15:24:23 +02:00
{
m_fThrowGrenade = FALSE ;
return m_fThrowGrenade ;
}
// assume things haven't changed too much since last time
2016-07-31 15:48:50 +02:00
if ( gpGlobals - > time < m_flNextGrenadeCheck )
2016-06-04 15:24:23 +02:00
{
return m_fThrowGrenade ;
}
2016-07-31 15:48:50 +02:00
if ( ! FBitSet ( m_hEnemy - > pev - > flags , FL_ONGROUND ) & & m_hEnemy - > pev - > waterlevel = = 0 & & m_vecEnemyLKP . z > pev - > absmax . z )
2016-06-04 15:24:23 +02:00
{
//!!!BUGBUG - we should make this check movetype and make sure it isn't FLY? Players who jump a lot are unlikely to
// be grenaded.
// don't throw grenades at anything that isn't on the ground!
m_fThrowGrenade = FALSE ;
return m_fThrowGrenade ;
}
2016-06-25 18:33:39 +02:00
2016-06-04 15:24:23 +02:00
Vector vecTarget ;
2016-07-31 15:48:50 +02:00
if ( FBitSet ( pev - > weapons , HGRUNT_HANDGRENADE ) )
2016-06-04 15:24:23 +02:00
{
// find feet
2016-07-31 15:48:50 +02:00
if ( RANDOM_LONG ( 0 , 1 ) )
2016-06-04 15:24:23 +02:00
{
// magically know where they are
vecTarget = Vector ( m_hEnemy - > pev - > origin . x , m_hEnemy - > pev - > origin . y , m_hEnemy - > pev - > absmin . z ) ;
}
else
{
// toss it to where you last saw them
vecTarget = m_vecEnemyLKP ;
}
// vecTarget = m_vecEnemyLKP + (m_hEnemy->BodyTarget( pev->origin ) - m_hEnemy->pev->origin);
// estimate position
// vecTarget = vecTarget + m_hEnemy->pev->velocity * 2;
}
else
{
// find target
// vecTarget = m_hEnemy->BodyTarget( pev->origin );
2016-07-31 15:48:50 +02:00
vecTarget = m_vecEnemyLKP + ( m_hEnemy - > BodyTarget ( pev - > origin ) - m_hEnemy - > pev - > origin ) ;
2016-06-04 15:24:23 +02:00
// estimate position
2016-07-31 15:48:50 +02:00
if ( HasConditions ( bits_COND_SEE_ENEMY ) )
vecTarget = vecTarget + ( ( vecTarget - pev - > origin ) . Length ( ) / gSkillData . hgruntGrenadeSpeed ) * m_hEnemy - > pev - > velocity ;
2016-06-04 15:24:23 +02:00
}
// are any of my squad members near the intended grenade impact area?
2016-07-31 15:48:50 +02:00
if ( InSquad ( ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( SquadMemberInRange ( vecTarget , 256 ) )
2016-06-04 15:24:23 +02:00
{
// crap, I might blow my own guy up. Don't throw a grenade and don't check again for a while.
m_flNextGrenadeCheck = gpGlobals - > time + 1 ; // one full second.
m_fThrowGrenade = FALSE ;
}
}
2016-06-25 18:33:39 +02:00
2019-10-13 13:49:25 +02:00
if ( ( vecTarget - pev - > origin ) . Length2D ( ) < = 256.0f )
2016-06-04 15:24:23 +02:00
{
// crap, I don't want to blow myself up
m_flNextGrenadeCheck = gpGlobals - > time + 1 ; // one full second.
m_fThrowGrenade = FALSE ;
return m_fThrowGrenade ;
}
2016-07-31 15:48:50 +02:00
if ( FBitSet ( pev - > weapons , HGRUNT_HANDGRENADE ) )
2016-06-04 15:24:23 +02:00
{
Vector vecToss = VecCheckToss ( pev , GetGunPosition ( ) , vecTarget , 0.5 ) ;
2016-07-31 15:48:50 +02:00
if ( vecToss ! = g_vecZero )
2016-06-04 15:24:23 +02:00
{
m_vecTossVelocity = vecToss ;
// throw a hand grenade
m_fThrowGrenade = TRUE ;
// don't check again for a while.
m_flNextGrenadeCheck = gpGlobals - > time ; // 1/3 second.
}
else
{
// don't throw
m_fThrowGrenade = FALSE ;
// don't check again for a while.
2019-10-13 13:49:25 +02:00
m_flNextGrenadeCheck = gpGlobals - > time + 1.0f ; // one full second.
2016-06-04 15:24:23 +02:00
}
}
else
{
Vector vecToss = VecCheckThrow ( pev , GetGunPosition ( ) , vecTarget , gSkillData . hgruntGrenadeSpeed , 0.5 ) ;
2016-07-31 15:48:50 +02:00
if ( vecToss ! = g_vecZero )
2016-06-04 15:24:23 +02:00
{
m_vecTossVelocity = vecToss ;
// throw a hand grenade
m_fThrowGrenade = TRUE ;
// don't check again for a while.
2019-10-13 13:49:25 +02:00
m_flNextGrenadeCheck = gpGlobals - > time + 0.3f ; // 1/3 second.
2016-06-04 15:24:23 +02:00
}
else
{
// don't throw
m_fThrowGrenade = FALSE ;
// don't check again for a while.
2019-10-13 13:49:25 +02:00
m_flNextGrenadeCheck = gpGlobals - > time + 1.0f ; // one full second.
2016-06-04 15:24:23 +02:00
}
}
return m_fThrowGrenade ;
}
//=========================================================
// TraceAttack - make sure we're not taking it in the helmet
//=========================================================
2016-07-31 15:48:50 +02:00
void CHGrunt : : TraceAttack ( entvars_t * pevAttacker , float flDamage , Vector vecDir , TraceResult * ptr , int bitsDamageType )
2016-06-04 15:24:23 +02:00
{
// check for helmet shot
2016-07-31 15:48:50 +02:00
if ( ptr - > iHitgroup = = 11 )
2016-06-04 15:24:23 +02:00
{
// make sure we're wearing one
2023-04-24 00:57:25 +02:00
if ( GetBodygroup ( HEAD_GROUP ) = = HEAD_GRUNT & & ( bitsDamageType & ( DMG_BULLET | DMG_SLASH | DMG_BLAST | DMG_CLUB ) ) )
2016-06-04 15:24:23 +02:00
{
// absorb damage
flDamage - = 20 ;
2016-07-31 15:48:50 +02:00
if ( flDamage < = 0 )
2016-06-04 15:24:23 +02:00
{
UTIL_Ricochet ( ptr - > vecEndPos , 1.0 ) ;
2019-10-13 13:49:25 +02:00
flDamage = 0.01f ;
2016-06-04 15:24:23 +02:00
}
}
// it's head shot anyways
ptr - > iHitgroup = HITGROUP_HEAD ;
}
CSquadMonster : : TraceAttack ( pevAttacker , flDamage , vecDir , ptr , bitsDamageType ) ;
}
//=========================================================
// TakeDamage - overridden for the grunt because the grunt
// needs to forget that he is in cover if he's hurt. (Obviously
// not in a safe place anymore).
//=========================================================
2016-07-31 15:48:50 +02:00
int CHGrunt : : TakeDamage ( entvars_t * pevInflictor , entvars_t * pevAttacker , float flDamage , int bitsDamageType )
2016-06-04 15:24:23 +02:00
{
Forget ( bits_MEMORY_INCOVER ) ;
2016-07-31 15:48:50 +02:00
return CSquadMonster : : TakeDamage ( pevInflictor , pevAttacker , flDamage , bitsDamageType ) ;
2016-06-04 15:24:23 +02:00
}
//=========================================================
// SetYawSpeed - allows each sequence to have a different
// turn rate associated with it.
//=========================================================
2016-07-31 15:48:50 +02:00
void CHGrunt : : SetYawSpeed ( void )
2016-06-04 15:24:23 +02:00
{
int ys ;
2016-07-31 15:48:50 +02:00
switch ( m_Activity )
2016-06-04 15:24:23 +02:00
{
case ACT_IDLE :
2016-07-31 15:48:50 +02:00
ys = 150 ;
2016-06-04 15:24:23 +02:00
break ;
case ACT_RUN :
ys = 150 ;
break ;
case ACT_WALK :
ys = 180 ;
break ;
case ACT_RANGE_ATTACK1 :
ys = 120 ;
break ;
case ACT_RANGE_ATTACK2 :
ys = 120 ;
break ;
case ACT_MELEE_ATTACK1 :
ys = 120 ;
break ;
case ACT_MELEE_ATTACK2 :
ys = 120 ;
break ;
case ACT_TURN_LEFT :
case ACT_TURN_RIGHT :
ys = 180 ;
break ;
case ACT_GLIDE :
case ACT_FLY :
ys = 30 ;
break ;
default :
ys = 90 ;
break ;
}
pev - > yaw_speed = ys ;
}
2016-07-31 15:48:50 +02:00
void CHGrunt : : IdleSound ( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( FOkToSpeak ( ) & & ( g_fGruntQuestion | | RANDOM_LONG ( 0 , 1 ) ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( ! g_fGruntQuestion )
2016-06-04 15:24:23 +02:00
{
// ask question or make statement
2016-07-31 15:48:50 +02:00
switch ( RANDOM_LONG ( 0 , 2 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
case 0 :
// check in
SENTENCEG_PlayRndSz ( ENT ( pev ) , " HG_CHECK " , HGRUNT_SENTENCE_VOLUME , ATTN_NORM , 0 , m_voicePitch ) ;
2016-06-04 15:24:23 +02:00
g_fGruntQuestion = 1 ;
break ;
2016-07-31 15:48:50 +02:00
case 1 :
// question
SENTENCEG_PlayRndSz ( ENT ( pev ) , " HG_QUEST " , HGRUNT_SENTENCE_VOLUME , ATTN_NORM , 0 , m_voicePitch ) ;
2016-06-04 15:24:23 +02:00
g_fGruntQuestion = 2 ;
break ;
2016-07-31 15:48:50 +02:00
case 2 :
// statement
SENTENCEG_PlayRndSz ( ENT ( pev ) , " HG_IDLE " , HGRUNT_SENTENCE_VOLUME , ATTN_NORM , 0 , m_voicePitch ) ;
2016-06-04 15:24:23 +02:00
break ;
}
}
else
{
2016-07-31 15:48:50 +02:00
switch ( g_fGruntQuestion )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
case 1 :
// check in
SENTENCEG_PlayRndSz ( ENT ( pev ) , " HG_CLEAR " , HGRUNT_SENTENCE_VOLUME , ATTN_NORM , 0 , m_voicePitch ) ;
2016-06-04 15:24:23 +02:00
break ;
2016-07-31 15:48:50 +02:00
case 2 :
// question
SENTENCEG_PlayRndSz ( ENT ( pev ) , " HG_ANSWER " , HGRUNT_SENTENCE_VOLUME , ATTN_NORM , 0 , m_voicePitch ) ;
2016-06-04 15:24:23 +02:00
break ;
}
g_fGruntQuestion = 0 ;
}
JustSpoke ( ) ;
}
}
//=========================================================
// CheckAmmo - overridden for the grunt because he actually
// uses ammo! (base class doesn't)
//=========================================================
2016-07-31 15:48:50 +02:00
void CHGrunt : : CheckAmmo ( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( m_cAmmoLoaded < = 0 )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
SetConditions ( bits_COND_NO_AMMO_LOADED ) ;
2016-06-04 15:24:23 +02:00
}
}
//=========================================================
// Classify - indicates this monster's place in the
// relationship table.
//=========================================================
2016-07-31 15:48:50 +02:00
int CHGrunt : : Classify ( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
return CLASS_HUMAN_MILITARY ;
2016-06-04 15:24:23 +02:00
}
//=========================================================
//=========================================================
2016-07-31 15:48:50 +02:00
CBaseEntity * CHGrunt : : Kick ( void )
2016-06-04 15:24:23 +02:00
{
TraceResult tr ;
UTIL_MakeVectors ( pev - > angles ) ;
Vector vecStart = pev - > origin ;
2019-10-13 13:49:25 +02:00
vecStart . z + = pev - > size . z * 0.5f ;
2016-07-31 15:48:50 +02:00
Vector vecEnd = vecStart + ( gpGlobals - > v_forward * 70 ) ;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
UTIL_TraceHull ( vecStart , vecEnd , dont_ignore_monsters , head_hull , ENT ( pev ) , & tr ) ;
2016-06-25 18:33:39 +02:00
2016-07-31 15:48:50 +02:00
if ( tr . pHit )
2016-06-04 15:24:23 +02:00
{
CBaseEntity * pEntity = CBaseEntity : : Instance ( tr . pHit ) ;
return pEntity ;
}
return NULL ;
}
//=========================================================
// GetGunPosition return the end of the barrel
//=========================================================
2016-07-31 15:48:50 +02:00
Vector CHGrunt : : GetGunPosition ( )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( m_fStanding )
2016-06-04 15:24:23 +02:00
{
return pev - > origin + Vector ( 0 , 0 , 60 ) ;
}
else
{
return pev - > origin + Vector ( 0 , 0 , 48 ) ;
}
}
//=========================================================
// Shoot
//=========================================================
2016-07-31 15:48:50 +02:00
void CHGrunt : : Shoot ( void )
2016-06-04 15:24:23 +02:00
{
2017-06-29 15:56:03 +02:00
if ( m_hEnemy = = 0 )
2016-06-04 15:24:23 +02:00
{
return ;
}
Vector vecShootOrigin = GetGunPosition ( ) ;
Vector vecShootDir = ShootAtEnemy ( vecShootOrigin ) ;
2016-07-31 15:48:50 +02:00
UTIL_MakeVectors ( pev - > angles ) ;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
Vector vecShellVelocity = gpGlobals - > v_right * RANDOM_FLOAT ( 40 , 90 ) + gpGlobals - > v_up * RANDOM_FLOAT ( 75 , 200 ) + gpGlobals - > v_forward * RANDOM_FLOAT ( - 40 , 40 ) ;
EjectBrass ( vecShootOrigin - vecShootDir * 24 , vecShellVelocity , pev - > angles . y , m_iBrassShell , TE_BOUNCE_SHELL ) ;
FireBullets ( 1 , vecShootOrigin , vecShootDir , VECTOR_CONE_10DEGREES , 2048 , BULLET_MONSTER_MP5 ) ; // shoot +-5 degrees
2016-06-04 15:24:23 +02:00
pev - > effects | = EF_MUZZLEFLASH ;
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
m_cAmmoLoaded - - ; // take away a bullet!
Vector angDir = UTIL_VecToAngles ( vecShootDir ) ;
SetBlending ( 0 , angDir . x ) ;
}
//=========================================================
// Shoot
//=========================================================
2016-07-31 15:48:50 +02:00
void CHGrunt : : Shotgun ( void )
2016-06-04 15:24:23 +02:00
{
2017-06-29 15:56:03 +02:00
if ( m_hEnemy = = 0 )
2016-06-04 15:24:23 +02:00
{
return ;
}
Vector vecShootOrigin = GetGunPosition ( ) ;
Vector vecShootDir = ShootAtEnemy ( vecShootOrigin ) ;
2016-07-31 15:48:50 +02:00
UTIL_MakeVectors ( pev - > angles ) ;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
Vector vecShellVelocity = gpGlobals - > v_right * RANDOM_FLOAT ( 40 , 90 ) + gpGlobals - > v_up * RANDOM_FLOAT ( 75 , 200 ) + gpGlobals - > v_forward * RANDOM_FLOAT ( - 40 , 40 ) ;
EjectBrass ( vecShootOrigin - vecShootDir * 24 , vecShellVelocity , pev - > angles . y , m_iShotgunShell , TE_BOUNCE_SHOTSHELL ) ;
FireBullets ( gSkillData . hgruntShotgunPellets , vecShootOrigin , vecShootDir , VECTOR_CONE_15DEGREES , 2048 , BULLET_PLAYER_BUCKSHOT , 0 ) ; // shoot +-7.5 degrees
2016-06-04 15:24:23 +02:00
pev - > effects | = EF_MUZZLEFLASH ;
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
m_cAmmoLoaded - - ; // take away a bullet!
Vector angDir = UTIL_VecToAngles ( vecShootDir ) ;
SetBlending ( 0 , angDir . x ) ;
}
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//=========================================================
2016-07-31 15:48:50 +02:00
void CHGrunt : : HandleAnimEvent ( MonsterEvent_t * pEvent )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
Vector vecShootDir ;
Vector vecShootOrigin ;
2016-06-04 15:24:23 +02:00
switch ( pEvent - > event )
{
case HGRUNT_AE_DROP_GUN :
2016-06-25 18:33:39 +02:00
{
2023-04-24 00:55:43 +02:00
if ( GetBodygroup ( GUN_GROUP ) ! = GUN_NONE )
2016-06-04 15:24:23 +02:00
{
2023-04-24 00:55:43 +02:00
Vector vecGunPos ;
Vector vecGunAngles ;
GetAttachment ( 0 , vecGunPos , vecGunAngles ) ;
// switch to body group with no gun.
SetBodygroup ( GUN_GROUP , GUN_NONE ) ;
// now spawn a gun.
if ( FBitSet ( pev - > weapons , HGRUNT_SHOTGUN ) )
{
DropItem ( " weapon_shotgun " , vecGunPos , vecGunAngles ) ;
}
else
{
DropItem ( " weapon_9mmAR " , vecGunPos , vecGunAngles ) ;
}
if ( FBitSet ( pev - > weapons , HGRUNT_GRENADELAUNCHER ) )
{
DropItem ( " ammo_ARgrenades " , BodyTarget ( pev - > origin ) , vecGunAngles ) ;
}
2016-06-04 15:24:23 +02:00
}
2016-06-25 18:33:39 +02:00
}
2016-06-04 15:24:23 +02:00
break ;
case HGRUNT_AE_RELOAD :
2016-07-31 15:48:50 +02:00
EMIT_SOUND ( ENT ( pev ) , CHAN_WEAPON , " hgrunt/gr_reload1.wav " , 1 , ATTN_NORM ) ;
2016-06-04 15:24:23 +02:00
m_cAmmoLoaded = m_cClipSize ;
2016-07-31 15:48:50 +02:00
ClearConditions ( bits_COND_NO_AMMO_LOADED ) ;
2016-06-04 15:24:23 +02:00
break ;
case HGRUNT_AE_GREN_TOSS :
{
UTIL_MakeVectors ( pev - > angles ) ;
2016-07-31 15:48:50 +02:00
// CGrenade::ShootTimed( pev, pev->origin + gpGlobals->v_forward * 34 + Vector( 0, 0, 32 ), m_vecTossVelocity, 3.5 );
2016-06-04 15:24:23 +02:00
CGrenade : : ShootTimed ( pev , GetGunPosition ( ) , m_vecTossVelocity , 3.5 ) ;
m_fThrowGrenade = FALSE ;
m_flNextGrenadeCheck = gpGlobals - > time + 6 ; // wait six seconds before even looking again to see if a grenade can be thrown.
// !!!LATER - when in a group, only try to throw grenade if ordered.
}
2016-06-25 18:33:39 +02:00
break ;
2016-06-04 15:24:23 +02:00
case HGRUNT_AE_GREN_LAUNCH :
{
2016-07-31 15:48:50 +02:00
EMIT_SOUND ( ENT ( pev ) , CHAN_WEAPON , " weapons/glauncher.wav " , 0.8 , ATTN_NORM ) ;
2016-06-04 15:24:23 +02:00
CGrenade : : ShootContact ( pev , GetGunPosition ( ) , m_vecTossVelocity ) ;
m_fThrowGrenade = FALSE ;
2016-07-31 15:48:50 +02:00
if ( g_iSkillLevel = = SKILL_HARD )
2019-10-13 13:49:25 +02:00
m_flNextGrenadeCheck = gpGlobals - > time + RANDOM_FLOAT ( 2.0f , 5.0f ) ; // wait a random amount of time before shooting again
2016-06-04 15:24:23 +02:00
else
2019-10-13 13:49:25 +02:00
m_flNextGrenadeCheck = gpGlobals - > time + 6.0f ; // wait six seconds before even looking again to see if a grenade can be thrown.
2016-06-04 15:24:23 +02:00
}
2016-06-25 18:33:39 +02:00
break ;
2016-06-04 15:24:23 +02:00
case HGRUNT_AE_GREN_DROP :
{
UTIL_MakeVectors ( pev - > angles ) ;
CGrenade : : ShootTimed ( pev , pev - > origin + gpGlobals - > v_forward * 17 - gpGlobals - > v_right * 27 + gpGlobals - > v_up * 6 , g_vecZero , 3 ) ;
}
2016-06-25 18:33:39 +02:00
break ;
2016-06-04 15:24:23 +02:00
case HGRUNT_AE_BURST1 :
{
2016-07-31 15:48:50 +02:00
if ( FBitSet ( pev - > weapons , HGRUNT_9MMAR ) )
2016-06-04 15:24:23 +02:00
{
Shoot ( ) ;
// the first round of the three round burst plays the sound and puts a sound in the world sound list.
2016-07-31 15:48:50 +02:00
if ( RANDOM_LONG ( 0 , 1 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
EMIT_SOUND ( ENT ( pev ) , CHAN_WEAPON , " hgrunt/gr_mgun1.wav " , 1 , ATTN_NORM ) ;
2016-06-04 15:24:23 +02:00
}
else
{
2016-07-31 15:48:50 +02:00
EMIT_SOUND ( ENT ( pev ) , CHAN_WEAPON , " hgrunt/gr_mgun2.wav " , 1 , ATTN_NORM ) ;
2016-06-04 15:24:23 +02:00
}
}
else
{
2016-07-31 15:48:50 +02:00
Shotgun ( ) ;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
EMIT_SOUND ( ENT ( pev ) , CHAN_WEAPON , " weapons/sbarrel1.wav " , 1 , ATTN_NORM ) ;
2016-06-04 15:24:23 +02:00
}
2016-07-31 15:48:50 +02:00
CSoundEnt : : InsertSound ( bits_SOUND_COMBAT , pev - > origin , 384 , 0.3 ) ;
2016-06-04 15:24:23 +02:00
}
2016-06-25 18:33:39 +02:00
break ;
2016-06-04 15:24:23 +02:00
case HGRUNT_AE_BURST2 :
case HGRUNT_AE_BURST3 :
Shoot ( ) ;
break ;
case HGRUNT_AE_KICK :
{
CBaseEntity * pHurt = Kick ( ) ;
2016-07-31 15:48:50 +02:00
if ( pHurt )
2016-06-04 15:24:23 +02:00
{
// SOUND HERE!
UTIL_MakeVectors ( pev - > angles ) ;
pHurt - > pev - > punchangle . x = 15 ;
pHurt - > pev - > velocity = pHurt - > pev - > velocity + gpGlobals - > v_forward * 100 + gpGlobals - > v_up * 50 ;
pHurt - > TakeDamage ( pev , pev , gSkillData . hgruntDmgKick , DMG_CLUB ) ;
}
}
2016-06-25 18:33:39 +02:00
break ;
2016-06-04 15:24:23 +02:00
case HGRUNT_AE_CAUGHT_ENEMY :
{
2016-07-31 15:48:50 +02:00
if ( FOkToSpeak ( ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
SENTENCEG_PlayRndSz ( ENT ( pev ) , " HG_ALERT " , HGRUNT_SENTENCE_VOLUME , GRUNT_ATTN , 0 , m_voicePitch ) ;
JustSpoke ( ) ;
2016-06-04 15:24:23 +02:00
}
}
2017-12-10 17:05:13 +01:00
break ;
2016-06-04 15:24:23 +02:00
default :
CSquadMonster : : HandleAnimEvent ( pEvent ) ;
break ;
}
}
//=========================================================
// Spawn
//=========================================================
2016-07-31 15:48:50 +02:00
void CHGrunt : : Spawn ( )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
Precache ( ) ;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
SET_MODEL ( ENT ( pev ) , " models/hgrunt.mdl " ) ;
UTIL_SetSize ( pev , VEC_HUMAN_HULL_MIN , VEC_HUMAN_HULL_MAX ) ;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
pev - > solid = SOLID_SLIDEBOX ;
2016-06-04 15:24:23 +02:00
pev - > movetype = MOVETYPE_STEP ;
m_bloodColor = BLOOD_COLOR_RED ;
pev - > effects = 0 ;
2016-07-31 15:48:50 +02:00
pev - > health = gSkillData . hgruntHealth ;
2016-06-04 15:24:23 +02:00
m_flFieldOfView = 0.2 ; // indicates the width of this monster's forward view cone ( as a dotproduct result )
m_MonsterState = MONSTERSTATE_NONE ;
2016-07-31 15:48:50 +02:00
m_flNextGrenadeCheck = gpGlobals - > time + 1 ;
2016-06-04 15:24:23 +02:00
m_flNextPainTime = gpGlobals - > time ;
2016-07-31 15:48:50 +02:00
m_iSentence = HGRUNT_SENT_NONE ;
2016-06-04 15:24:23 +02:00
m_afCapability = bits_CAP_SQUAD | bits_CAP_TURN_HEAD | bits_CAP_DOORS_GROUP ;
m_fEnemyEluded = FALSE ;
m_fFirstEncounter = TRUE ; // this is true when the grunt spawns, because he hasn't encountered an enemy yet.
2016-07-31 15:48:50 +02:00
m_HackedGunPos = Vector ( 0 , 0 , 55 ) ;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
if ( pev - > weapons = = 0 )
2016-06-04 15:24:23 +02:00
{
// initialize to original values
pev - > weapons = HGRUNT_9MMAR | HGRUNT_HANDGRENADE ;
// pev->weapons = HGRUNT_SHOTGUN;
// pev->weapons = HGRUNT_9MMAR | HGRUNT_GRENADELAUNCHER;
}
2016-07-31 15:48:50 +02:00
if ( FBitSet ( pev - > weapons , HGRUNT_SHOTGUN ) )
2016-06-04 15:24:23 +02:00
{
SetBodygroup ( GUN_GROUP , GUN_SHOTGUN ) ;
2016-07-31 15:48:50 +02:00
m_cClipSize = 8 ;
2016-06-04 15:24:23 +02:00
}
else
{
2016-07-31 15:48:50 +02:00
m_cClipSize = GRUNT_CLIP_SIZE ;
2016-06-04 15:24:23 +02:00
}
2016-07-31 15:48:50 +02:00
m_cAmmoLoaded = m_cClipSize ;
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
if ( RANDOM_LONG ( 0 , 99 ) < 80 )
2016-06-04 15:24:23 +02:00
pev - > skin = 0 ; // light skin
else
pev - > skin = 1 ; // dark skin
2016-07-31 15:48:50 +02:00
if ( FBitSet ( pev - > weapons , HGRUNT_SHOTGUN ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
SetBodygroup ( HEAD_GROUP , HEAD_SHOTGUN ) ;
2016-06-04 15:24:23 +02:00
}
2016-07-31 15:48:50 +02:00
else if ( FBitSet ( pev - > weapons , HGRUNT_GRENADELAUNCHER ) )
2016-06-04 15:24:23 +02:00
{
SetBodygroup ( HEAD_GROUP , HEAD_M203 ) ;
pev - > skin = 1 ; // alway dark skin
}
CTalkMonster : : g_talkWaitTime = 0 ;
MonsterInit ( ) ;
}
//=========================================================
// Precache - precaches all resources this monster needs
//=========================================================
2016-07-31 15:48:50 +02:00
void CHGrunt : : Precache ( )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
PRECACHE_MODEL ( " models/hgrunt.mdl " ) ;
2016-06-04 15:24:23 +02:00
PRECACHE_SOUND ( " hgrunt/gr_mgun1.wav " ) ;
PRECACHE_SOUND ( " hgrunt/gr_mgun2.wav " ) ;
PRECACHE_SOUND ( " hgrunt/gr_die1.wav " ) ;
PRECACHE_SOUND ( " hgrunt/gr_die2.wav " ) ;
PRECACHE_SOUND ( " hgrunt/gr_die3.wav " ) ;
PRECACHE_SOUND ( " hgrunt/gr_pain1.wav " ) ;
PRECACHE_SOUND ( " hgrunt/gr_pain2.wav " ) ;
PRECACHE_SOUND ( " hgrunt/gr_pain3.wav " ) ;
PRECACHE_SOUND ( " hgrunt/gr_pain4.wav " ) ;
PRECACHE_SOUND ( " hgrunt/gr_pain5.wav " ) ;
PRECACHE_SOUND ( " hgrunt/gr_reload1.wav " ) ;
PRECACHE_SOUND ( " weapons/glauncher.wav " ) ;
PRECACHE_SOUND ( " weapons/sbarrel1.wav " ) ;
2016-07-31 15:48:50 +02:00
PRECACHE_SOUND ( " zombie/claw_miss2.wav " ) ; // because we use the basemonster SWIPE animation event
2016-06-04 15:24:23 +02:00
// get voice pitch
2016-07-31 15:48:50 +02:00
if ( RANDOM_LONG ( 0 , 1 ) )
m_voicePitch = 109 + RANDOM_LONG ( 0 , 7 ) ;
2016-06-04 15:24:23 +02:00
else
m_voicePitch = 100 ;
2016-07-31 15:48:50 +02:00
m_iBrassShell = PRECACHE_MODEL ( " models/shell.mdl " ) ; // brass shell
m_iShotgunShell = PRECACHE_MODEL ( " models/shotgunshell.mdl " ) ;
}
2016-06-04 15:24:23 +02:00
//=========================================================
// start task
//=========================================================
2016-07-31 15:48:50 +02:00
void CHGrunt : : StartTask ( Task_t * pTask )
2016-06-04 15:24:23 +02:00
{
m_iTaskStatus = TASKSTATUS_RUNNING ;
2016-07-31 15:48:50 +02:00
switch ( pTask - > iTask )
2016-06-04 15:24:23 +02:00
{
case TASK_GRUNT_CHECK_FIRE :
2016-07-31 15:48:50 +02:00
if ( ! NoFriendlyFire ( ) )
2016-06-04 15:24:23 +02:00
{
SetConditions ( bits_COND_GRUNT_NOFIRE ) ;
}
TaskComplete ( ) ;
break ;
case TASK_GRUNT_SPEAK_SENTENCE :
SpeakSentence ( ) ;
TaskComplete ( ) ;
break ;
case TASK_WALK_PATH :
case TASK_RUN_PATH :
// grunt no longer assumes he is covered if he moves
Forget ( bits_MEMORY_INCOVER ) ;
2016-07-31 15:48:50 +02:00
CSquadMonster : : StartTask ( pTask ) ;
2016-06-04 15:24:23 +02:00
break ;
case TASK_RELOAD :
m_IdealActivity = ACT_RELOAD ;
break ;
case TASK_GRUNT_FACE_TOSS_DIR :
break ;
case TASK_FACE_IDEAL :
case TASK_FACE_ENEMY :
2016-07-31 15:48:50 +02:00
CSquadMonster : : StartTask ( pTask ) ;
if ( pev - > movetype = = MOVETYPE_FLY )
2016-06-04 15:24:23 +02:00
{
m_IdealActivity = ACT_GLIDE ;
}
break ;
default :
2016-07-31 15:48:50 +02:00
CSquadMonster : : StartTask ( pTask ) ;
2016-06-04 15:24:23 +02:00
break ;
}
}
//=========================================================
// RunTask
//=========================================================
2016-07-31 15:48:50 +02:00
void CHGrunt : : RunTask ( Task_t * pTask )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
switch ( pTask - > iTask )
2016-06-04 15:24:23 +02:00
{
case TASK_GRUNT_FACE_TOSS_DIR :
{
// project a point along the toss vector and turn to face that point.
MakeIdealYaw ( pev - > origin + m_vecTossVelocity * 64 ) ;
ChangeYaw ( pev - > yaw_speed ) ;
2016-07-31 15:48:50 +02:00
if ( FacingIdeal ( ) )
2016-06-04 15:24:23 +02:00
{
m_iTaskStatus = TASKSTATUS_COMPLETE ;
}
break ;
}
default :
{
2016-07-31 15:48:50 +02:00
CSquadMonster : : RunTask ( pTask ) ;
2016-06-04 15:24:23 +02:00
break ;
}
}
}
//=========================================================
// PainSound
//=========================================================
2016-07-31 15:48:50 +02:00
void CHGrunt : : PainSound ( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( gpGlobals - > time > m_flNextPainTime )
2016-06-04 15:24:23 +02:00
{
#if 0
2016-07-31 15:48:50 +02:00
if ( RANDOM_LONG ( 0 , 99 ) < 5 )
2016-06-04 15:24:23 +02:00
{
// pain sentences are rare
2016-07-31 15:48:50 +02:00
if ( FOkToSpeak ( ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
SENTENCEG_PlayRndSz ( ENT ( pev ) , " HG_PAIN " , HGRUNT_SENTENCE_VOLUME , ATTN_NORM , 0 , PITCH_NORM ) ;
2016-06-04 15:24:23 +02:00
JustSpoke ( ) ;
return ;
}
}
2016-06-25 18:33:39 +02:00
# endif
2016-07-31 15:48:50 +02:00
switch ( RANDOM_LONG ( 0 , 6 ) )
2016-06-04 15:24:23 +02:00
{
case 0 :
2016-07-31 15:48:50 +02:00
EMIT_SOUND ( ENT ( pev ) , CHAN_VOICE , " hgrunt/gr_pain3.wav " , 1 , ATTN_NORM ) ;
2016-06-04 15:24:23 +02:00
break ;
case 1 :
2016-07-31 15:48:50 +02:00
EMIT_SOUND ( ENT ( pev ) , CHAN_VOICE , " hgrunt/gr_pain4.wav " , 1 , ATTN_NORM ) ;
2016-06-04 15:24:23 +02:00
break ;
case 2 :
2016-07-31 15:48:50 +02:00
EMIT_SOUND ( ENT ( pev ) , CHAN_VOICE , " hgrunt/gr_pain5.wav " , 1 , ATTN_NORM ) ;
2016-06-04 15:24:23 +02:00
break ;
case 3 :
2016-07-31 15:48:50 +02:00
EMIT_SOUND ( ENT ( pev ) , CHAN_VOICE , " hgrunt/gr_pain1.wav " , 1 , ATTN_NORM ) ;
2016-06-04 15:24:23 +02:00
break ;
case 4 :
2016-07-31 15:48:50 +02:00
EMIT_SOUND ( ENT ( pev ) , CHAN_VOICE , " hgrunt/gr_pain2.wav " , 1 , ATTN_NORM ) ;
2016-06-04 15:24:23 +02:00
break ;
}
m_flNextPainTime = gpGlobals - > time + 1 ;
}
}
//=========================================================
// DeathSound
//=========================================================
2016-07-31 15:48:50 +02:00
void CHGrunt : : DeathSound ( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
switch ( RANDOM_LONG ( 0 , 2 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
case 0 :
EMIT_SOUND ( ENT ( pev ) , CHAN_VOICE , " hgrunt/gr_die1.wav " , 1 , ATTN_IDLE ) ;
2016-06-04 15:24:23 +02:00
break ;
case 1 :
2016-07-31 15:48:50 +02:00
EMIT_SOUND ( ENT ( pev ) , CHAN_VOICE , " hgrunt/gr_die2.wav " , 1 , ATTN_IDLE ) ;
2016-06-04 15:24:23 +02:00
break ;
case 2 :
2016-07-31 15:48:50 +02:00
EMIT_SOUND ( ENT ( pev ) , CHAN_VOICE , " hgrunt/gr_die3.wav " , 1 , ATTN_IDLE ) ;
2016-06-04 15:24:23 +02:00
break ;
}
}
//=========================================================
// AI Schedules Specific to this monster
//=========================================================
//=========================================================
// GruntFail
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntFail [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_STOP_MOVING , 0 } ,
{ TASK_SET_ACTIVITY , ( float ) ACT_IDLE } ,
{ TASK_WAIT , ( float ) 2 } ,
{ TASK_WAIT_PVS , ( float ) 0 } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntFail [ ] =
2016-06-04 15:24:23 +02:00
{
{
tlGruntFail ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntFail ) ,
2016-06-04 15:24:23 +02:00
bits_COND_CAN_RANGE_ATTACK1 |
bits_COND_CAN_RANGE_ATTACK2 |
bits_COND_CAN_MELEE_ATTACK1 |
bits_COND_CAN_MELEE_ATTACK2 ,
0 ,
" Grunt Fail "
} ,
} ;
//=========================================================
// Grunt Combat Fail
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntCombatFail [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_STOP_MOVING , 0 } ,
{ TASK_SET_ACTIVITY , ( float ) ACT_IDLE } ,
{ TASK_WAIT_FACE_ENEMY , ( float ) 2 } ,
{ TASK_WAIT_PVS , ( float ) 0 } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntCombatFail [ ] =
2016-06-04 15:24:23 +02:00
{
{
tlGruntCombatFail ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntCombatFail ) ,
bits_COND_CAN_RANGE_ATTACK1 |
2016-06-04 15:24:23 +02:00
bits_COND_CAN_RANGE_ATTACK2 ,
0 ,
" Grunt Combat Fail "
} ,
} ;
//=========================================================
// Victory dance!
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntVictoryDance [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_STOP_MOVING , ( float ) 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_WAIT , ( float ) 1.5 } ,
{ TASK_GET_PATH_TO_ENEMY_CORPSE , ( float ) 0 } ,
{ TASK_WALK_PATH , ( float ) 0 } ,
{ TASK_WAIT_FOR_MOVEMENT , ( float ) 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_PLAY_SEQUENCE , ( float ) ACT_VICTORY_DANCE } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntVictoryDance [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGruntVictoryDance ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntVictoryDance ) ,
2016-06-04 15:24:23 +02:00
bits_COND_NEW_ENEMY |
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE ,
0 ,
" GruntVictoryDance "
} ,
} ;
//=========================================================
// Establish line of fire - move to a position that allows
// the grunt to attack.
//=========================================================
Task_t tlGruntEstablishLineOfFire [ ] =
{
2016-07-31 15:48:50 +02:00
{ TASK_SET_FAIL_SCHEDULE , ( float ) SCHED_GRUNT_ELOF_FAIL } ,
{ TASK_GET_PATH_TO_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_SPEAK_SENTENCE , ( float ) 0 } ,
{ TASK_RUN_PATH , ( float ) 0 } ,
{ TASK_WAIT_FOR_MOVEMENT , ( float ) 0 } ,
2016-06-04 15:24:23 +02:00
} ;
Schedule_t slGruntEstablishLineOfFire [ ] =
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGruntEstablishLineOfFire ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntEstablishLineOfFire ) ,
bits_COND_NEW_ENEMY |
bits_COND_ENEMY_DEAD |
bits_COND_CAN_RANGE_ATTACK1 |
bits_COND_CAN_MELEE_ATTACK1 |
bits_COND_CAN_RANGE_ATTACK2 |
bits_COND_CAN_MELEE_ATTACK2 |
2016-06-04 15:24:23 +02:00
bits_COND_HEAR_SOUND ,
bits_SOUND_DANGER ,
" GruntEstablishLineOfFire "
} ,
} ;
//=========================================================
// GruntFoundEnemy - grunt established sight with an enemy
// that was hiding from the squad.
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntFoundEnemy [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_STOP_MOVING , 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_PLAY_SEQUENCE_FACE_ENEMY , ( float ) ACT_SIGNAL1 } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntFoundEnemy [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGruntFoundEnemy ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntFoundEnemy ) ,
2016-06-04 15:24:23 +02:00
bits_COND_HEAR_SOUND ,
bits_SOUND_DANGER ,
" GruntFoundEnemy "
} ,
} ;
//=========================================================
// GruntCombatFace Schedule
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntCombatFace1 [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_STOP_MOVING , 0 } ,
{ TASK_SET_ACTIVITY , ( float ) ACT_IDLE } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_WAIT , ( float ) 1.5 } ,
{ TASK_SET_SCHEDULE , ( float ) SCHED_GRUNT_SWEEP } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntCombatFace [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGruntCombatFace1 ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntCombatFace1 ) ,
bits_COND_NEW_ENEMY |
bits_COND_ENEMY_DEAD |
bits_COND_CAN_RANGE_ATTACK1 |
2016-06-04 15:24:23 +02:00
bits_COND_CAN_RANGE_ATTACK2 ,
0 ,
" Combat Face "
} ,
} ;
//=========================================================
// Suppressing fire - don't stop shooting until the clip is
// empty or grunt gets hurt.
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntSignalSuppress [ ] =
{
{ TASK_STOP_MOVING , 0 } ,
{ TASK_FACE_IDEAL , ( float ) 0 } ,
{ TASK_PLAY_SEQUENCE_FACE_ENEMY , ( float ) ACT_SIGNAL2 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntSignalSuppress [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGruntSignalSuppress ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntSignalSuppress ) ,
bits_COND_ENEMY_DEAD |
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE |
bits_COND_HEAR_SOUND |
bits_COND_GRUNT_NOFIRE |
2016-06-04 15:24:23 +02:00
bits_COND_NO_AMMO_LOADED ,
bits_SOUND_DANGER ,
" SignalSuppress "
} ,
} ;
2016-07-31 15:48:50 +02:00
Task_t tlGruntSuppress [ ] =
{
{ TASK_STOP_MOVING , 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntSuppress [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGruntSuppress ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntSuppress ) ,
bits_COND_ENEMY_DEAD |
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE |
bits_COND_HEAR_SOUND |
bits_COND_GRUNT_NOFIRE |
2016-06-04 15:24:23 +02:00
bits_COND_NO_AMMO_LOADED ,
bits_SOUND_DANGER ,
" Suppress "
} ,
} ;
//=========================================================
// grunt wait in cover - we don't allow danger or the ability
// to attack to break a grunt's run to cover schedule, but
// when a grunt is in cover, we do want them to attack if they can.
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntWaitInCover [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_STOP_MOVING , ( float ) 0 } ,
{ TASK_SET_ACTIVITY , ( float ) ACT_IDLE } ,
{ TASK_WAIT_FACE_ENEMY , ( float ) 1 } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntWaitInCover [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGruntWaitInCover ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntWaitInCover ) ,
bits_COND_NEW_ENEMY |
bits_COND_HEAR_SOUND |
bits_COND_CAN_RANGE_ATTACK1 |
bits_COND_CAN_RANGE_ATTACK2 |
bits_COND_CAN_MELEE_ATTACK1 |
2016-06-04 15:24:23 +02:00
bits_COND_CAN_MELEE_ATTACK2 ,
bits_SOUND_DANGER ,
" GruntWaitInCover "
} ,
} ;
//=========================================================
// run to cover.
// !!!BUGBUG - set a decent fail schedule here.
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntTakeCover1 [ ] =
{
{ TASK_STOP_MOVING , ( float ) 0 } ,
{ TASK_SET_FAIL_SCHEDULE , ( float ) SCHED_GRUNT_TAKECOVER_FAILED } ,
{ TASK_WAIT , ( float ) 0.2 } ,
{ TASK_FIND_COVER_FROM_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_SPEAK_SENTENCE , ( float ) 0 } ,
{ TASK_RUN_PATH , ( float ) 0 } ,
{ TASK_WAIT_FOR_MOVEMENT , ( float ) 0 } ,
{ TASK_REMEMBER , ( float ) bits_MEMORY_INCOVER } ,
{ TASK_SET_SCHEDULE , ( float ) SCHED_GRUNT_WAIT_FACE_ENEMY } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntTakeCover [ ] =
2016-06-04 15:24:23 +02:00
{
{
tlGruntTakeCover1 ,
ARRAYSIZE ( tlGruntTakeCover1 ) ,
0 ,
0 ,
" TakeCover "
} ,
} ;
//=========================================================
// drop grenade then run to cover.
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntGrenadeCover1 [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_STOP_MOVING , ( float ) 0 } ,
{ TASK_FIND_COVER_FROM_ENEMY , ( float ) 99 } ,
{ TASK_FIND_FAR_NODE_COVER_FROM_ENEMY , ( float ) 384 } ,
{ TASK_PLAY_SEQUENCE , ( float ) ACT_SPECIAL_ATTACK1 } ,
{ TASK_CLEAR_MOVE_WAIT , ( float ) 0 } ,
{ TASK_RUN_PATH , ( float ) 0 } ,
{ TASK_WAIT_FOR_MOVEMENT , ( float ) 0 } ,
{ TASK_SET_SCHEDULE , ( float ) SCHED_GRUNT_WAIT_FACE_ENEMY } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntGrenadeCover [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGruntGrenadeCover1 ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntGrenadeCover1 ) ,
2016-06-04 15:24:23 +02:00
0 ,
0 ,
" GrenadeCover "
} ,
} ;
//=========================================================
// drop grenade then run to cover.
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntTossGrenadeCover1 [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_RANGE_ATTACK2 , ( float ) 0 } ,
{ TASK_SET_SCHEDULE , ( float ) SCHED_TAKE_COVER_FROM_ENEMY } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntTossGrenadeCover [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGruntTossGrenadeCover1 ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntTossGrenadeCover1 ) ,
2016-06-04 15:24:23 +02:00
0 ,
0 ,
" TossGrenadeCover "
} ,
} ;
//=========================================================
// hide from the loudest sound source (to run from grenade)
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntTakeCoverFromBestSound [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_SET_FAIL_SCHEDULE , ( float ) SCHED_COWER } , // duck and cover if cannot move from explosion
{ TASK_STOP_MOVING , ( float ) 0 } ,
{ TASK_FIND_COVER_FROM_BEST_SOUND , ( float ) 0 } ,
{ TASK_RUN_PATH , ( float ) 0 } ,
{ TASK_WAIT_FOR_MOVEMENT , ( float ) 0 } ,
{ TASK_REMEMBER , ( float ) bits_MEMORY_INCOVER } ,
{ TASK_TURN_LEFT , ( float ) 179 } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntTakeCoverFromBestSound [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGruntTakeCoverFromBestSound ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntTakeCoverFromBestSound ) ,
2016-06-04 15:24:23 +02:00
0 ,
0 ,
" GruntTakeCoverFromBestSound "
} ,
} ;
//=========================================================
// Grunt reload schedule
//=========================================================
Task_t tlGruntHideReload [ ] =
{
2016-07-31 15:48:50 +02:00
{ TASK_STOP_MOVING , ( float ) 0 } ,
{ TASK_SET_FAIL_SCHEDULE , ( float ) SCHED_RELOAD } ,
{ TASK_FIND_COVER_FROM_ENEMY , ( float ) 0 } ,
{ TASK_RUN_PATH , ( float ) 0 } ,
{ TASK_WAIT_FOR_MOVEMENT , ( float ) 0 } ,
{ TASK_REMEMBER , ( float ) bits_MEMORY_INCOVER } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_PLAY_SEQUENCE , ( float ) ACT_RELOAD } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntHideReload [ ] =
2016-06-04 15:24:23 +02:00
{
{
tlGruntHideReload ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntHideReload ) ,
bits_COND_HEAVY_DAMAGE |
2016-06-04 15:24:23 +02:00
bits_COND_HEAR_SOUND ,
bits_SOUND_DANGER ,
" GruntHideReload "
}
} ;
//=========================================================
// Do a turning sweep of the area
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntSweep [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_TURN_LEFT , ( float ) 179 } ,
{ TASK_WAIT , ( float ) 1 } ,
{ TASK_TURN_LEFT , ( float ) 179 } ,
{ TASK_WAIT , ( float ) 1 } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntSweep [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGruntSweep ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntSweep ) ,
bits_COND_NEW_ENEMY |
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE |
bits_COND_CAN_RANGE_ATTACK1 |
bits_COND_CAN_RANGE_ATTACK2 |
2016-06-04 15:24:23 +02:00
bits_COND_HEAR_SOUND ,
2016-07-31 15:48:50 +02:00
bits_SOUND_WORLD | // sound flags
bits_SOUND_DANGER |
2016-06-04 15:24:23 +02:00
bits_SOUND_PLAYER ,
" Grunt Sweep "
} ,
} ;
//=========================================================
// primary range attack. Overriden because base class stops attacking when the enemy is occluded.
// grunt's grenade toss requires the enemy be occluded.
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntRangeAttack1A [ ] =
{
{ TASK_STOP_MOVING , ( float ) 0 } ,
{ TASK_PLAY_SEQUENCE_FACE_ENEMY , ( float ) ACT_CROUCH } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntRangeAttack1A [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGruntRangeAttack1A ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntRangeAttack1A ) ,
bits_COND_NEW_ENEMY |
bits_COND_ENEMY_DEAD |
bits_COND_HEAVY_DAMAGE |
bits_COND_ENEMY_OCCLUDED |
bits_COND_HEAR_SOUND |
bits_COND_GRUNT_NOFIRE |
2016-06-04 15:24:23 +02:00
bits_COND_NO_AMMO_LOADED ,
bits_SOUND_DANGER ,
" Range Attack1A "
} ,
} ;
//=========================================================
// primary range attack. Overriden because base class stops attacking when the enemy is occluded.
// grunt's grenade toss requires the enemy be occluded.
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntRangeAttack1B [ ] =
{
{ TASK_STOP_MOVING , ( float ) 0 } ,
{ TASK_PLAY_SEQUENCE_FACE_ENEMY , ( float ) ACT_IDLE_ANGRY } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_GRUNT_CHECK_FIRE , ( float ) 0 } ,
{ TASK_RANGE_ATTACK1 , ( float ) 0 } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntRangeAttack1B [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGruntRangeAttack1B ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntRangeAttack1B ) ,
bits_COND_NEW_ENEMY |
bits_COND_ENEMY_DEAD |
bits_COND_HEAVY_DAMAGE |
bits_COND_ENEMY_OCCLUDED |
bits_COND_NO_AMMO_LOADED |
bits_COND_GRUNT_NOFIRE |
2016-06-04 15:24:23 +02:00
bits_COND_HEAR_SOUND ,
bits_SOUND_DANGER ,
" Range Attack1B "
} ,
} ;
//=========================================================
// secondary range attack. Overriden because base class stops attacking when the enemy is occluded.
// grunt's grenade toss requires the enemy be occluded.
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntRangeAttack2 [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_STOP_MOVING , ( float ) 0 } ,
{ TASK_GRUNT_FACE_TOSS_DIR , ( float ) 0 } ,
{ TASK_PLAY_SEQUENCE , ( float ) ACT_RANGE_ATTACK2 } ,
{ TASK_SET_SCHEDULE , ( float ) SCHED_GRUNT_WAIT_FACE_ENEMY } , // don't run immediately after throwing grenade.
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntRangeAttack2 [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGruntRangeAttack2 ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntRangeAttack2 ) ,
2016-06-04 15:24:23 +02:00
0 ,
0 ,
" RangeAttack2 "
} ,
} ;
//=========================================================
// repel
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntRepel [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_STOP_MOVING , ( float ) 0 } ,
{ TASK_FACE_IDEAL , ( float ) 0 } ,
{ TASK_PLAY_SEQUENCE , ( float ) ACT_GLIDE } ,
2016-06-04 15:24:23 +02:00
} ;
Schedule_t slGruntRepel [ ] =
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGruntRepel ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntRepel ) ,
bits_COND_SEE_ENEMY |
bits_COND_NEW_ENEMY |
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE |
2016-06-04 15:24:23 +02:00
bits_COND_HEAR_SOUND ,
2016-07-31 15:48:50 +02:00
bits_SOUND_DANGER |
bits_SOUND_COMBAT |
2016-06-04 15:24:23 +02:00
bits_SOUND_PLAYER ,
" Repel "
} ,
} ;
//=========================================================
// repel
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntRepelAttack [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_STOP_MOVING , ( float ) 0 } ,
{ TASK_FACE_ENEMY , ( float ) 0 } ,
{ TASK_PLAY_SEQUENCE , ( float ) ACT_FLY } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntRepelAttack [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGruntRepelAttack ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntRepelAttack ) ,
2016-06-04 15:24:23 +02:00
bits_COND_ENEMY_OCCLUDED ,
0 ,
" Repel Attack "
} ,
} ;
//=========================================================
// repel land
//=========================================================
2016-07-31 15:48:50 +02:00
Task_t tlGruntRepelLand [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{ TASK_STOP_MOVING , ( float ) 0 } ,
{ TASK_PLAY_SEQUENCE , ( float ) ACT_LAND } ,
{ TASK_GET_PATH_TO_LASTPOSITION , ( float ) 0 } ,
{ TASK_RUN_PATH , ( float ) 0 } ,
{ TASK_WAIT_FOR_MOVEMENT , ( float ) 0 } ,
{ TASK_CLEAR_LASTPOSITION , ( float ) 0 } ,
2016-06-04 15:24:23 +02:00
} ;
2016-07-31 15:48:50 +02:00
Schedule_t slGruntRepelLand [ ] =
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
{
2016-06-04 15:24:23 +02:00
tlGruntRepelLand ,
2016-07-31 15:48:50 +02:00
ARRAYSIZE ( tlGruntRepelLand ) ,
bits_COND_SEE_ENEMY |
bits_COND_NEW_ENEMY |
bits_COND_LIGHT_DAMAGE |
bits_COND_HEAVY_DAMAGE |
2016-06-04 15:24:23 +02:00
bits_COND_HEAR_SOUND ,
2016-07-31 15:48:50 +02:00
bits_SOUND_DANGER |
bits_SOUND_COMBAT |
2016-06-04 15:24:23 +02:00
bits_SOUND_PLAYER ,
" Repel Land "
} ,
} ;
DEFINE_CUSTOM_SCHEDULES ( CHGrunt )
{
slGruntFail ,
slGruntCombatFail ,
slGruntVictoryDance ,
slGruntEstablishLineOfFire ,
slGruntFoundEnemy ,
slGruntCombatFace ,
slGruntSignalSuppress ,
slGruntSuppress ,
slGruntWaitInCover ,
slGruntTakeCover ,
slGruntGrenadeCover ,
slGruntTossGrenadeCover ,
slGruntTakeCoverFromBestSound ,
slGruntHideReload ,
slGruntSweep ,
slGruntRangeAttack1A ,
slGruntRangeAttack1B ,
slGruntRangeAttack2 ,
slGruntRepel ,
slGruntRepelAttack ,
slGruntRepelLand ,
} ;
2016-06-25 18:33:39 +02:00
IMPLEMENT_CUSTOM_SCHEDULES ( CHGrunt , CSquadMonster )
2016-06-04 15:24:23 +02:00
//=========================================================
// SetActivity
//=========================================================
2016-07-31 15:48:50 +02:00
void CHGrunt : : SetActivity ( Activity NewActivity )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
int iSequence = ACTIVITY_NOT_AVAILABLE ;
2017-06-29 15:56:03 +02:00
//void *pmodel = GET_MODEL_PTR( ENT( pev ) );
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
switch ( NewActivity )
2016-06-04 15:24:23 +02:00
{
case ACT_RANGE_ATTACK1 :
// grunt is either shooting standing or shooting crouched
2016-07-31 15:48:50 +02:00
if ( FBitSet ( pev - > weapons , HGRUNT_9MMAR ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( m_fStanding )
2016-06-04 15:24:23 +02:00
{
// get aimable sequence
iSequence = LookupSequence ( " standing_mp5 " ) ;
}
else
{
// get crouching shoot
iSequence = LookupSequence ( " crouching_mp5 " ) ;
}
}
else
{
2016-07-31 15:48:50 +02:00
if ( m_fStanding )
2016-06-04 15:24:23 +02:00
{
// get aimable sequence
iSequence = LookupSequence ( " standing_shotgun " ) ;
}
else
{
// get crouching shoot
iSequence = LookupSequence ( " crouching_shotgun " ) ;
}
}
break ;
case ACT_RANGE_ATTACK2 :
// grunt is going to a secondary long range attack. This may be a thrown
// grenade or fired grenade, we must determine which and pick proper sequence
2016-07-31 15:48:50 +02:00
if ( pev - > weapons & HGRUNT_HANDGRENADE )
2016-06-04 15:24:23 +02:00
{
// get toss anim
iSequence = LookupSequence ( " throwgrenade " ) ;
}
else
{
// get launch anim
iSequence = LookupSequence ( " launchgrenade " ) ;
}
break ;
case ACT_RUN :
2016-07-31 15:48:50 +02:00
if ( pev - > health < = HGRUNT_LIMP_HEALTH )
2016-06-04 15:24:23 +02:00
{
// limp!
2016-07-31 15:48:50 +02:00
iSequence = LookupActivity ( ACT_RUN_HURT ) ;
2016-06-04 15:24:23 +02:00
}
else
{
2016-07-31 15:48:50 +02:00
iSequence = LookupActivity ( NewActivity ) ;
2016-06-04 15:24:23 +02:00
}
break ;
case ACT_WALK :
2016-07-31 15:48:50 +02:00
if ( pev - > health < = HGRUNT_LIMP_HEALTH )
2016-06-04 15:24:23 +02:00
{
// limp!
2016-07-31 15:48:50 +02:00
iSequence = LookupActivity ( ACT_WALK_HURT ) ;
2016-06-04 15:24:23 +02:00
}
else
{
2016-07-31 15:48:50 +02:00
iSequence = LookupActivity ( NewActivity ) ;
2016-06-04 15:24:23 +02:00
}
break ;
case ACT_IDLE :
if ( m_MonsterState = = MONSTERSTATE_COMBAT )
{
NewActivity = ACT_IDLE_ANGRY ;
}
2016-07-31 15:48:50 +02:00
iSequence = LookupActivity ( NewActivity ) ;
2016-06-04 15:24:23 +02:00
break ;
default :
2016-07-31 15:48:50 +02:00
iSequence = LookupActivity ( NewActivity ) ;
2016-06-04 15:24:23 +02:00
break ;
}
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
m_Activity = NewActivity ; // Go ahead and set this so it doesn't keep trying when the anim is not present
// Set to the desired anim, or default anim if the desired is not present
2016-07-31 15:48:50 +02:00
if ( iSequence > ACTIVITY_NOT_AVAILABLE )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( pev - > sequence ! = iSequence | | ! m_fSequenceLoops )
2016-06-04 15:24:23 +02:00
{
pev - > frame = 0 ;
}
2016-07-31 15:48:50 +02:00
pev - > sequence = iSequence ; // Set to the reset anim (if it's there)
ResetSequenceInfo ( ) ;
2016-06-04 15:24:23 +02:00
SetYawSpeed ( ) ;
}
else
{
// Not available try to get default anim
2016-07-31 15:48:50 +02:00
ALERT ( at_console , " %s has no sequence for act:%d \n " , STRING ( pev - > classname ) , NewActivity ) ;
pev - > sequence = 0 ; // Set to the reset anim (if it's there)
2016-06-04 15:24:23 +02:00
}
}
//=========================================================
// Get Schedule!
//=========================================================
2016-07-31 15:48:50 +02:00
Schedule_t * CHGrunt : : GetSchedule ( void )
2016-06-04 15:24:23 +02:00
{
// clear old sentence
m_iSentence = HGRUNT_SENT_NONE ;
// flying? If PRONE, barnacle has me. IF not, it's assumed I am rapelling.
2016-07-31 15:48:50 +02:00
if ( pev - > movetype = = MOVETYPE_FLY & & m_MonsterState ! = MONSTERSTATE_PRONE )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( pev - > flags & FL_ONGROUND )
2016-06-04 15:24:23 +02:00
{
// just landed
pev - > movetype = MOVETYPE_STEP ;
2016-07-31 15:48:50 +02:00
return GetScheduleOfType ( SCHED_GRUNT_REPEL_LAND ) ;
2016-06-04 15:24:23 +02:00
}
else
{
// repel down a rope,
2016-07-31 15:48:50 +02:00
if ( m_MonsterState = = MONSTERSTATE_COMBAT )
return GetScheduleOfType ( SCHED_GRUNT_REPEL_ATTACK ) ;
2016-06-04 15:24:23 +02:00
else
2016-07-31 15:48:50 +02:00
return GetScheduleOfType ( SCHED_GRUNT_REPEL ) ;
2016-06-04 15:24:23 +02:00
}
}
// grunts place HIGH priority on running away from danger sounds.
2016-07-31 15:48:50 +02:00
if ( HasConditions ( bits_COND_HEAR_SOUND ) )
2016-06-04 15:24:23 +02:00
{
CSound * pSound ;
pSound = PBestSound ( ) ;
ASSERT ( pSound ! = NULL ) ;
2016-07-31 15:48:50 +02:00
if ( pSound )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( pSound - > m_iType & bits_SOUND_DANGER )
2016-06-04 15:24:23 +02:00
{
// dangerous sound nearby!
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
//!!!KELLY - currently, this is the grunt's signal that a grenade has landed nearby,
// and the grunt should find cover from the blast
// good place for "SHIT!" or some other colorful verbal indicator of dismay.
// It's not safe to play a verbal order here "Scatter", etc cause
// this may only affect a single individual in a squad.
2016-07-31 15:48:50 +02:00
if ( FOkToSpeak ( ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
SENTENCEG_PlayRndSz ( ENT ( pev ) , " HG_GREN " , HGRUNT_SENTENCE_VOLUME , GRUNT_ATTN , 0 , m_voicePitch ) ;
2016-06-04 15:24:23 +02:00
JustSpoke ( ) ;
}
return GetScheduleOfType ( SCHED_TAKE_COVER_FROM_BEST_SOUND ) ;
}
/*
2016-07-31 15:48:50 +02:00
if ( ! HasConditions ( bits_COND_SEE_ENEMY ) & & ( pSound - > m_iType & ( bits_SOUND_PLAYER | bits_SOUND_COMBAT ) ) )
2016-06-04 15:24:23 +02:00
{
MakeIdealYaw ( pSound - > m_vecOrigin ) ;
}
*/
}
}
2016-07-31 15:48:50 +02:00
switch ( m_MonsterState )
2016-06-04 15:24:23 +02:00
{
case MONSTERSTATE_COMBAT :
{
2016-06-13 16:29:45 +02:00
// dead enemy
2016-07-31 15:48:50 +02:00
if ( HasConditions ( bits_COND_ENEMY_DEAD ) )
2016-06-04 15:24:23 +02:00
{
// call base class, all code to handle dead enemies is centralized there.
2016-07-31 15:48:50 +02:00
return CBaseMonster : : GetSchedule ( ) ;
2016-06-04 15:24:23 +02:00
}
2016-06-13 16:29:45 +02:00
// new enemy
2016-07-31 15:48:50 +02:00
if ( HasConditions ( bits_COND_NEW_ENEMY ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( InSquad ( ) )
2016-06-04 15:24:23 +02:00
{
MySquadLeader ( ) - > m_fEnemyEluded = FALSE ;
2016-07-31 15:48:50 +02:00
if ( ! IsLeader ( ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
return GetScheduleOfType ( SCHED_TAKE_COVER_FROM_ENEMY ) ;
2016-06-04 15:24:23 +02:00
}
else
{
//!!!KELLY - the leader of a squad of grunts has just seen the player or a
// monster and has made it the squad's enemy. You
// can check pev->flags for FL_CLIENT to determine whether this is the player
// or a monster. He's going to immediately start
// firing, though. If you'd like, we can make an alternate "first sight"
// schedule where the leader plays a handsign anim
// that gives us enough time to hear a short sentence or spoken command
// before he starts pluggin away.
2016-07-31 15:48:50 +02:00
if ( FOkToSpeak ( ) ) // && RANDOM_LONG( 0, 1 ) )
2016-06-04 15:24:23 +02:00
{
2017-06-29 15:56:03 +02:00
if ( ( m_hEnemy ! = 0 ) & & m_hEnemy - > IsPlayer ( ) )
2016-06-04 15:24:23 +02:00
// player
2016-07-31 15:48:50 +02:00
SENTENCEG_PlayRndSz ( ENT ( pev ) , " HG_ALERT " , HGRUNT_SENTENCE_VOLUME , GRUNT_ATTN , 0 , m_voicePitch ) ;
2017-06-29 15:56:03 +02:00
else if ( ( m_hEnemy ! = 0 ) & &
2016-07-31 15:48:50 +02:00
( m_hEnemy - > Classify ( ) ! = CLASS_PLAYER_ALLY ) & &
( m_hEnemy - > Classify ( ) ! = CLASS_HUMAN_PASSIVE ) & &
( m_hEnemy - > Classify ( ) ! = CLASS_MACHINE ) )
2016-06-04 15:24:23 +02:00
// monster
2016-07-31 15:48:50 +02:00
SENTENCEG_PlayRndSz ( ENT ( pev ) , " HG_MONST " , HGRUNT_SENTENCE_VOLUME , GRUNT_ATTN , 0 , m_voicePitch ) ;
2016-06-04 15:24:23 +02:00
JustSpoke ( ) ;
}
2016-07-31 15:48:50 +02:00
if ( HasConditions ( bits_COND_CAN_RANGE_ATTACK1 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
return GetScheduleOfType ( SCHED_GRUNT_SUPPRESS ) ;
2016-06-04 15:24:23 +02:00
}
else
{
2016-07-31 15:48:50 +02:00
return GetScheduleOfType ( SCHED_GRUNT_ESTABLISH_LINE_OF_FIRE ) ;
2016-06-04 15:24:23 +02:00
}
}
}
}
2016-06-13 16:29:45 +02:00
// no ammo
2016-07-31 15:48:50 +02:00
else if ( HasConditions ( bits_COND_NO_AMMO_LOADED ) )
2016-06-04 15:24:23 +02:00
{
//!!!KELLY - this individual just realized he's out of bullet ammo.
// He's going to try to find cover to run to and reload, but rarely, if
// none is available, he'll drop and reload in the open here.
2016-07-31 15:48:50 +02:00
return GetScheduleOfType ( SCHED_GRUNT_COVER_AND_RELOAD ) ;
2016-06-04 15:24:23 +02:00
}
2016-06-13 16:29:45 +02:00
// damaged just a little
2016-07-31 15:48:50 +02:00
else if ( HasConditions ( bits_COND_LIGHT_DAMAGE ) )
2016-06-04 15:24:23 +02:00
{
// if hurt:
// 90% chance of taking cover
// 10% chance of flinch.
2016-07-31 15:48:50 +02:00
int iPercent = RANDOM_LONG ( 0 , 99 ) ;
2016-06-04 15:24:23 +02:00
2017-06-29 15:56:03 +02:00
if ( iPercent < = 90 & & m_hEnemy ! = 0 )
2016-06-04 15:24:23 +02:00
{
// only try to take cover if we actually have an enemy!
//!!!KELLY - this grunt was hit and is going to run to cover.
2016-07-31 15:48:50 +02:00
if ( FOkToSpeak ( ) ) // && RANDOM_LONG( 0, 1 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
//SENTENCEG_PlayRndSz( ENT( pev ), "HG_COVER", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch );
2016-06-04 15:24:23 +02:00
m_iSentence = HGRUNT_SENT_COVER ;
//JustSpoke();
}
return GetScheduleOfType ( SCHED_TAKE_COVER_FROM_ENEMY ) ;
}
else
{
return GetScheduleOfType ( SCHED_SMALL_FLINCH ) ;
}
}
2016-06-13 16:29:45 +02:00
// can kick
2016-07-31 15:48:50 +02:00
else if ( HasConditions ( bits_COND_CAN_MELEE_ATTACK1 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
return GetScheduleOfType ( SCHED_MELEE_ATTACK1 ) ;
2016-06-04 15:24:23 +02:00
}
2016-06-13 16:29:45 +02:00
// can grenade launch
2016-07-31 15:48:50 +02:00
else if ( FBitSet ( pev - > weapons , HGRUNT_GRENADELAUNCHER ) & & HasConditions ( bits_COND_CAN_RANGE_ATTACK2 ) & & OccupySlot ( bits_SLOTS_HGRUNT_GRENADE ) )
2016-06-04 15:24:23 +02:00
{
// shoot a grenade if you can
return GetScheduleOfType ( SCHED_RANGE_ATTACK2 ) ;
}
2016-06-13 16:29:45 +02:00
// can shoot
2016-07-31 15:48:50 +02:00
else if ( HasConditions ( bits_COND_CAN_RANGE_ATTACK1 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( InSquad ( ) )
2016-06-04 15:24:23 +02:00
{
// if the enemy has eluded the squad and a squad member has just located the enemy
// and the enemy does not see the squad member, issue a call to the squad to waste a
// little time and give the player a chance to turn.
2016-07-31 15:48:50 +02:00
if ( MySquadLeader ( ) - > m_fEnemyEluded & & ! HasConditions ( bits_COND_ENEMY_FACING_ME ) )
2016-06-04 15:24:23 +02:00
{
MySquadLeader ( ) - > m_fEnemyEluded = FALSE ;
2016-07-31 15:48:50 +02:00
return GetScheduleOfType ( SCHED_GRUNT_FOUND_ENEMY ) ;
2016-06-04 15:24:23 +02:00
}
}
2016-07-31 15:48:50 +02:00
if ( OccupySlot ( bits_SLOTS_HGRUNT_ENGAGE ) )
2016-06-04 15:24:23 +02:00
{
// try to take an available ENGAGE slot
return GetScheduleOfType ( SCHED_RANGE_ATTACK1 ) ;
}
2016-07-31 15:48:50 +02:00
else if ( HasConditions ( bits_COND_CAN_RANGE_ATTACK2 ) & & OccupySlot ( bits_SLOTS_HGRUNT_GRENADE ) )
2016-06-04 15:24:23 +02:00
{
// throw a grenade if can and no engage slots are available
return GetScheduleOfType ( SCHED_RANGE_ATTACK2 ) ;
}
else
{
// hide!
return GetScheduleOfType ( SCHED_TAKE_COVER_FROM_ENEMY ) ;
}
}
2016-06-13 16:29:45 +02:00
// can't see enemy
2016-07-31 15:48:50 +02:00
else if ( HasConditions ( bits_COND_ENEMY_OCCLUDED ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( HasConditions ( bits_COND_CAN_RANGE_ATTACK2 ) & & OccupySlot ( bits_SLOTS_HGRUNT_GRENADE ) )
2016-06-04 15:24:23 +02:00
{
//!!!KELLY - this grunt is about to throw or fire a grenade at the player. Great place for "fire in the hole" "frag out" etc
2016-07-31 15:48:50 +02:00
if ( FOkToSpeak ( ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
SENTENCEG_PlayRndSz ( ENT ( pev ) , " HG_THROW " , HGRUNT_SENTENCE_VOLUME , GRUNT_ATTN , 0 , m_voicePitch ) ;
2016-06-04 15:24:23 +02:00
JustSpoke ( ) ;
}
return GetScheduleOfType ( SCHED_RANGE_ATTACK2 ) ;
}
2016-07-31 15:48:50 +02:00
else if ( OccupySlot ( bits_SLOTS_HGRUNT_ENGAGE ) )
2016-06-04 15:24:23 +02:00
{
//!!!KELLY - grunt cannot see the enemy and has just decided to
// charge the enemy's position.
2016-07-31 15:48:50 +02:00
if ( FOkToSpeak ( ) ) // && RANDOM_LONG( 0, 1 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
//SENTENCEG_PlayRndSz( ENT( pev ), "HG_CHARGE", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch );
2016-06-04 15:24:23 +02:00
m_iSentence = HGRUNT_SENT_CHARGE ;
//JustSpoke();
}
return GetScheduleOfType ( SCHED_GRUNT_ESTABLISH_LINE_OF_FIRE ) ;
}
else
{
//!!!KELLY - grunt is going to stay put for a couple seconds to see if
// the enemy wanders back out into the open, or approaches the
// grunt's covered position. Good place for a taunt, I guess?
2016-07-31 15:48:50 +02:00
if ( FOkToSpeak ( ) & & RANDOM_LONG ( 0 , 1 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
SENTENCEG_PlayRndSz ( ENT ( pev ) , " HG_TAUNT " , HGRUNT_SENTENCE_VOLUME , GRUNT_ATTN , 0 , m_voicePitch ) ;
2016-06-04 15:24:23 +02:00
JustSpoke ( ) ;
}
return GetScheduleOfType ( SCHED_STANDOFF ) ;
}
}
2016-07-31 15:48:50 +02:00
if ( HasConditions ( bits_COND_SEE_ENEMY ) & & ! HasConditions ( bits_COND_CAN_RANGE_ATTACK1 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
return GetScheduleOfType ( SCHED_GRUNT_ESTABLISH_LINE_OF_FIRE ) ;
2016-06-04 15:24:23 +02:00
}
}
2016-06-13 16:29:45 +02:00
break ;
default :
break ;
2016-06-04 15:24:23 +02:00
}
2016-06-25 18:33:39 +02:00
2016-06-04 15:24:23 +02:00
// no special cases here, call the base class
2016-07-31 15:48:50 +02:00
return CSquadMonster : : GetSchedule ( ) ;
2016-06-04 15:24:23 +02:00
}
//=========================================================
//=========================================================
2016-07-31 15:48:50 +02:00
Schedule_t * CHGrunt : : GetScheduleOfType ( int Type )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
switch ( Type )
2016-06-04 15:24:23 +02:00
{
case SCHED_TAKE_COVER_FROM_ENEMY :
{
2016-07-31 15:48:50 +02:00
if ( InSquad ( ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( g_iSkillLevel = = SKILL_HARD & & HasConditions ( bits_COND_CAN_RANGE_ATTACK2 ) & & OccupySlot ( bits_SLOTS_HGRUNT_GRENADE ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( FOkToSpeak ( ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
SENTENCEG_PlayRndSz ( ENT ( pev ) , " HG_THROW " , HGRUNT_SENTENCE_VOLUME , GRUNT_ATTN , 0 , m_voicePitch ) ;
2016-06-04 15:24:23 +02:00
JustSpoke ( ) ;
}
return slGruntTossGrenadeCover ;
}
else
{
2016-07-31 15:48:50 +02:00
return & slGruntTakeCover [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
}
else
{
2016-07-31 15:48:50 +02:00
if ( RANDOM_LONG ( 0 , 1 ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
return & slGruntTakeCover [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
else
{
2016-07-31 15:48:50 +02:00
return & slGruntGrenadeCover [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
}
}
case SCHED_TAKE_COVER_FROM_BEST_SOUND :
{
2016-07-31 15:48:50 +02:00
return & slGruntTakeCoverFromBestSound [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
case SCHED_GRUNT_TAKECOVER_FAILED :
{
2016-07-31 15:48:50 +02:00
if ( HasConditions ( bits_COND_CAN_RANGE_ATTACK1 ) & & OccupySlot ( bits_SLOTS_HGRUNT_ENGAGE ) )
2016-06-04 15:24:23 +02:00
{
return GetScheduleOfType ( SCHED_RANGE_ATTACK1 ) ;
}
2016-07-31 15:48:50 +02:00
return GetScheduleOfType ( SCHED_FAIL ) ;
2016-06-04 15:24:23 +02:00
}
break ;
case SCHED_GRUNT_ELOF_FAIL :
{
// human grunt is unable to move to a position that allows him to attack the enemy.
2016-07-31 15:48:50 +02:00
return GetScheduleOfType ( SCHED_TAKE_COVER_FROM_ENEMY ) ;
2016-06-04 15:24:23 +02:00
}
break ;
case SCHED_GRUNT_ESTABLISH_LINE_OF_FIRE :
{
2016-07-31 15:48:50 +02:00
return & slGruntEstablishLineOfFire [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
break ;
case SCHED_RANGE_ATTACK1 :
{
// randomly stand or crouch
2016-07-31 15:48:50 +02:00
if ( RANDOM_LONG ( 0 , 9 ) = = 0 )
m_fStanding = RANDOM_LONG ( 0 , 1 ) ;
if ( m_fStanding )
return & slGruntRangeAttack1B [ 0 ] ;
2016-06-04 15:24:23 +02:00
else
2016-07-31 15:48:50 +02:00
return & slGruntRangeAttack1A [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
case SCHED_RANGE_ATTACK2 :
{
2016-07-31 15:48:50 +02:00
return & slGruntRangeAttack2 [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
case SCHED_COMBAT_FACE :
{
2016-07-31 15:48:50 +02:00
return & slGruntCombatFace [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
case SCHED_GRUNT_WAIT_FACE_ENEMY :
{
2016-07-31 15:48:50 +02:00
return & slGruntWaitInCover [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
case SCHED_GRUNT_SWEEP :
{
2016-07-31 15:48:50 +02:00
return & slGruntSweep [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
case SCHED_GRUNT_COVER_AND_RELOAD :
{
2016-07-31 15:48:50 +02:00
return & slGruntHideReload [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
case SCHED_GRUNT_FOUND_ENEMY :
{
2016-07-31 15:48:50 +02:00
return & slGruntFoundEnemy [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
case SCHED_VICTORY_DANCE :
{
2016-07-31 15:48:50 +02:00
if ( InSquad ( ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
if ( ! IsLeader ( ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
return & slGruntFail [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
}
2016-07-31 15:48:50 +02:00
return & slGruntVictoryDance [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
case SCHED_GRUNT_SUPPRESS :
{
2016-07-31 15:48:50 +02:00
if ( m_hEnemy - > IsPlayer ( ) & & m_fFirstEncounter )
2016-06-04 15:24:23 +02:00
{
m_fFirstEncounter = FALSE ; // after first encounter, leader won't issue handsigns anymore when he has a new enemy
2016-07-31 15:48:50 +02:00
return & slGruntSignalSuppress [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
else
{
2016-07-31 15:48:50 +02:00
return & slGruntSuppress [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
}
case SCHED_FAIL :
{
2017-06-29 15:56:03 +02:00
if ( m_hEnemy ! = 0 )
2016-06-04 15:24:23 +02:00
{
// grunt has an enemy, so pick a different default fail schedule most likely to help recover.
2016-07-31 15:48:50 +02:00
return & slGruntCombatFail [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
2016-07-31 15:48:50 +02:00
return & slGruntFail [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
case SCHED_GRUNT_REPEL :
{
2016-07-31 15:48:50 +02:00
if ( pev - > velocity . z > - 128 )
2016-06-04 15:24:23 +02:00
pev - > velocity . z - = 32 ;
2016-07-31 15:48:50 +02:00
return & slGruntRepel [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
case SCHED_GRUNT_REPEL_ATTACK :
{
2016-07-31 15:48:50 +02:00
if ( pev - > velocity . z > - 128 )
2016-06-04 15:24:23 +02:00
pev - > velocity . z - = 32 ;
2016-07-31 15:48:50 +02:00
return & slGruntRepelAttack [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
case SCHED_GRUNT_REPEL_LAND :
{
2016-07-31 15:48:50 +02:00
return & slGruntRepelLand [ 0 ] ;
2016-06-04 15:24:23 +02:00
}
default :
{
2016-07-31 15:48:50 +02:00
return CSquadMonster : : GetScheduleOfType ( Type ) ;
2016-06-04 15:24:23 +02:00
}
}
}
//=========================================================
// CHGruntRepel - when triggered, spawns a monster_human_grunt
// repelling down a line.
//=========================================================
class CHGruntRepel : public CBaseMonster
{
public :
void Spawn ( void ) ;
void Precache ( void ) ;
void EXPORT RepelUse ( CBaseEntity * pActivator , CBaseEntity * pCaller , USE_TYPE useType , float value ) ;
int m_iSpriteTexture ; // Don't save, precache
} ;
2016-06-25 18:33:39 +02:00
LINK_ENTITY_TO_CLASS ( monster_grunt_repel , CHGruntRepel )
2016-06-04 15:24:23 +02:00
void CHGruntRepel : : Spawn ( void )
{
2016-07-31 15:48:50 +02:00
Precache ( ) ;
2016-06-04 15:24:23 +02:00
pev - > solid = SOLID_NOT ;
SetUse ( & CHGruntRepel : : RepelUse ) ;
}
void CHGruntRepel : : Precache ( void )
{
UTIL_PrecacheOther ( " monster_human_grunt " ) ;
m_iSpriteTexture = PRECACHE_MODEL ( " sprites/rope.spr " ) ;
}
2016-07-31 15:48:50 +02:00
void CHGruntRepel : : RepelUse ( CBaseEntity * pActivator , CBaseEntity * pCaller , USE_TYPE useType , float value )
2016-06-04 15:24:23 +02:00
{
TraceResult tr ;
2016-07-31 15:48:50 +02:00
UTIL_TraceLine ( pev - > origin , pev - > origin + Vector ( 0 , 0 , - 4096.0 ) , dont_ignore_monsters , ENT ( pev ) , & tr ) ;
2016-06-04 15:24:23 +02:00
/*
2016-07-31 15:48:50 +02:00
if ( tr . pHit & & Instance ( tr . pHit ) - > pev - > solid ! = SOLID_BSP )
2016-06-04 15:24:23 +02:00
return NULL ;
*/
CBaseEntity * pEntity = Create ( " monster_human_grunt " , pev - > origin , pev - > angles ) ;
2016-07-31 15:48:50 +02:00
CBaseMonster * pGrunt = pEntity - > MyMonsterPointer ( ) ;
2016-06-04 15:24:23 +02:00
pGrunt - > pev - > movetype = MOVETYPE_FLY ;
pGrunt - > pev - > velocity = Vector ( 0 , 0 , RANDOM_FLOAT ( - 196 , - 128 ) ) ;
pGrunt - > SetActivity ( ACT_GLIDE ) ;
// UNDONE: position?
pGrunt - > m_vecLastPosition = tr . vecEndPos ;
CBeam * pBeam = CBeam : : BeamCreate ( " sprites/rope.spr " , 10 ) ;
2016-07-31 15:48:50 +02:00
pBeam - > PointEntInit ( pev - > origin + Vector ( 0 , 0 , 112 ) , pGrunt - > entindex ( ) ) ;
2016-06-04 15:24:23 +02:00
pBeam - > SetFlags ( BEAM_FSOLID ) ;
pBeam - > SetColor ( 255 , 255 , 255 ) ;
pBeam - > SetThink ( & CBaseEntity : : SUB_Remove ) ;
2019-10-13 13:49:25 +02:00
pBeam - > pev - > nextthink = gpGlobals - > time + - 4096.0f * tr . flFraction / pGrunt - > pev - > velocity . z + 0.5f ;
2016-06-04 15:24:23 +02:00
UTIL_Remove ( this ) ;
}
//=========================================================
// DEAD HGRUNT PROP
//=========================================================
class CDeadHGrunt : public CBaseMonster
{
public :
void Spawn ( void ) ;
2016-07-31 15:48:50 +02:00
int Classify ( void ) { return CLASS_HUMAN_MILITARY ; }
2016-06-04 15:24:23 +02:00
void KeyValue ( KeyValueData * pkvd ) ;
2016-07-31 15:48:50 +02:00
int m_iPose ; // which sequence to display -- temporary, don't need to save
2017-06-29 15:56:03 +02:00
static const char * m_szPoses [ 3 ] ;
2016-06-04 15:24:23 +02:00
} ;
2017-06-29 15:56:03 +02:00
const char * CDeadHGrunt : : m_szPoses [ ] = { " deadstomach " , " deadside " , " deadsitting " } ;
2016-06-04 15:24:23 +02:00
void CDeadHGrunt : : KeyValue ( KeyValueData * pkvd )
{
2016-07-31 15:48:50 +02:00
if ( FStrEq ( pkvd - > szKeyName , " pose " ) )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
m_iPose = atoi ( pkvd - > szValue ) ;
2016-06-04 15:24:23 +02:00
pkvd - > fHandled = TRUE ;
}
else
CBaseMonster : : KeyValue ( pkvd ) ;
}
2016-06-25 18:33:39 +02:00
LINK_ENTITY_TO_CLASS ( monster_hgrunt_dead , CDeadHGrunt )
2016-06-04 15:24:23 +02:00
//=========================================================
// ********** DeadHGrunt SPAWN **********
//=========================================================
2016-07-31 15:48:50 +02:00
void CDeadHGrunt : : Spawn ( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
PRECACHE_MODEL ( " models/hgrunt.mdl " ) ;
SET_MODEL ( ENT ( pev ) , " models/hgrunt.mdl " ) ;
2016-06-04 15:24:23 +02:00
pev - > effects = 0 ;
pev - > yaw_speed = 8 ;
pev - > sequence = 0 ;
m_bloodColor = BLOOD_COLOR_RED ;
pev - > sequence = LookupSequence ( m_szPoses [ m_iPose ] ) ;
2016-07-31 15:48:50 +02:00
if ( pev - > sequence = = - 1 )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
ALERT ( at_console , " Dead hgrunt with bad pose \n " ) ;
2016-06-04 15:24:23 +02:00
}
// Corpses have less health
2016-07-31 15:48:50 +02:00
pev - > health = 8 ;
2016-06-04 15:24:23 +02:00
// map old bodies onto new bodies
switch ( pev - > body )
{
2016-07-31 15:48:50 +02:00
case 0 :
// Grunt with Gun
2016-06-04 15:24:23 +02:00
pev - > body = 0 ;
pev - > skin = 0 ;
SetBodygroup ( HEAD_GROUP , HEAD_GRUNT ) ;
SetBodygroup ( GUN_GROUP , GUN_MP5 ) ;
break ;
2016-07-31 15:48:50 +02:00
case 1 :
// Commander with Gun
2016-06-04 15:24:23 +02:00
pev - > body = 0 ;
pev - > skin = 0 ;
SetBodygroup ( HEAD_GROUP , HEAD_COMMANDER ) ;
SetBodygroup ( GUN_GROUP , GUN_MP5 ) ;
break ;
2016-07-31 15:48:50 +02:00
case 2 :
// Grunt no Gun
2016-06-04 15:24:23 +02:00
pev - > body = 0 ;
pev - > skin = 0 ;
SetBodygroup ( HEAD_GROUP , HEAD_GRUNT ) ;
SetBodygroup ( GUN_GROUP , GUN_NONE ) ;
break ;
2016-07-31 15:48:50 +02:00
case 3 :
// Commander no Gun
2016-06-04 15:24:23 +02:00
pev - > body = 0 ;
pev - > skin = 0 ;
SetBodygroup ( HEAD_GROUP , HEAD_COMMANDER ) ;
SetBodygroup ( GUN_GROUP , GUN_NONE ) ;
break ;
}
MonsterInitDead ( ) ;
}