Files
source-sdk-2013/sp/src/game/server/hl2/npc_BaseZombie.h
Blixibon dc7f20acc8 Mapbase v2.0; bulk commit
- Added custom map compile tools (vbsp, vvis, vrad)
- Changed blink fix (shouldn't change anything in-game)
- Added auto-completion to ent_create, npc_create, and the main set of "npc_" debug commands
- Added ent_create_aimed, an ent_create equivalent of npc_create_aimed
- Made hunters start using the "vs. player" melee animation against smaller NPCs that look weird with the "stab" attack
- Added "explosion_sparks" convar, which fixes broken code for giving explosions sparks (disabled by default because of how different it looks)
- Made interaction code capable of being dispatched on any entity, not just combat characters
- Added npc_barnacle_ignite convar, which lets barnacles be ignited by flares
- Fixed certain NPCs getting out of the way for the player when they hate them
- Fixed auto-generated "speak" scene responses not using parameters that work on real VCDs
- Made "stop_on_nonidle" capable of being used in any mod, not just HL2 episodic mods
- Selectable color for ragdoll boogie/point_ragdollboogie
- Fixed PickupWeaponInstant not firing weapon pickup outputs
- Introduced inputs and keyvalues for "lerping" to math_counter_advanced
- Fixed ClearConsole on logic_console
- logic_convar should now detect client convars correctly
- New NormalizeAngles input on math_vector
- logic_modelinfo LookupActivity input
- math_generate fixed and expanded to be more like math_counter
- Added a WIP game logging system for playtesting maps
- Introduced logic_playerinfo, an entity that can read a player's name or ID
- Fixed some new filters not working with filter_multi
- Added radius pickup spawnflag to func_physbox
- Added "Preserve name" spawnflag to weapons
- Added cc_achievement_debug message for when an achievement doesn't exist
- Made npc_combine_s not speak while in logic_choreographed_scenes
- Fixed zombie torsos/legs/headcrabs not being serverside when zombie is forced to server ragdoll
- Expanded and cleaned up npc_zombie_custom
- Fixed func_commandredirects not cleaning up correctly and sometimes crashing the game
- Allowed player squad commands to go through +USE-held objects
- Added a bunch of I/O/KV to trigger_waterydeath for better configuration
- Changed save comment system to use the chapter title from world properties, and the ability to suppress the title popup that normally results from it
- Adjusted game_convar_mod for MP planning
- Removed the func_precipitation custom particle/splash code for now, as it was causing problems
- Fixed env_global_light not accepting lightcolor
- Added "Additional Buttons" to player_speedmod
- Added save comment to RPC
- Added env_projectedtexture attenuation
- Added scripted_sequence OnPreIdleSequence
- Added OnCrab to zombies
- Added skill_changed game event (may need further testing)
- Added a fix for viewmodels flipping under extreme FOV values
- Added code that allows mappers to change the skin on shotgunners without it usually flipping back randomly
- Fixed a very, very, very major shader performance issue
- New SetAbsOrigin/Angles inputs on all entities, analogous to SetLocalOrigin/Angles
- Code improvements for I/O involving angles
- logic_entity_position improvements/fixes, including a new OutAngles output that outputs the angles on position calls
- Alternate collision/player avoidance spawnflag obsoletion enforcement disabled
- Enable/DisableHazardLights inputs on the EP2 jalopy, equivalent to the keyvalue
- Miscellaneous shader formatting adjustments and fixes
- Fixed AlwaysDrawOff on env_projectedtexture not being a valid input
2019-12-14 04:20:02 +00:00

300 lines
9.1 KiB
C++

//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef NPC_BASEZOMBIE_H
#define NPC_BASEZOMBIE_H
#ifdef _WIN32
#pragma once
#endif
#include "ai_basenpc.h"
#include "ai_blended_movement.h"
#include "soundenvelope.h"
#include "ai_behavior_actbusy.h"
#define ZOM_ATTN_FOOTSTEP ATTN_IDLE
#define ENVELOPE_CONTROLLER (CSoundEnvelopeController::GetController())
#define ZOMBIE_MELEE_REACH 55
extern int AE_ZOMBIE_ATTACK_RIGHT;
extern int AE_ZOMBIE_ATTACK_LEFT;
extern int AE_ZOMBIE_ATTACK_BOTH;
extern int AE_ZOMBIE_SWATITEM;
extern int AE_ZOMBIE_STARTSWAT;
extern int AE_ZOMBIE_STEP_LEFT;
extern int AE_ZOMBIE_STEP_RIGHT;
extern int AE_ZOMBIE_SCUFF_LEFT;
extern int AE_ZOMBIE_SCUFF_RIGHT;
extern int AE_ZOMBIE_ATTACK_SCREAM;
extern int AE_ZOMBIE_GET_UP;
extern int AE_ZOMBIE_POUND;
#define ZOMBIE_BODYGROUP_HEADCRAB 1 // The crab on our head
// Pass these to claw attack so we know where to draw the blood.
#define ZOMBIE_BLOOD_LEFT_HAND 0
#define ZOMBIE_BLOOD_RIGHT_HAND 1
#define ZOMBIE_BLOOD_BOTH_HANDS 2
#define ZOMBIE_BLOOD_BITE 3
#ifdef MAPBASE
#define SF_ZOMBIE_NO_TORSO ( 1 << 15 )
#endif
enum HeadcrabRelease_t
{
RELEASE_NO,
RELEASE_IMMEDIATE, // release the headcrab right now!
RELEASE_SCHEDULED, // release the headcrab through the AI schedule.
RELEASE_VAPORIZE, // just destroy the crab.
RELEASE_RAGDOLL, // release a dead crab
RELEASE_RAGDOLL_SLICED_OFF // toss the crab up a bit
};
//=========================================================
// schedules
//=========================================================
enum
{
SCHED_ZOMBIE_CHASE_ENEMY = LAST_SHARED_SCHEDULE,
SCHED_ZOMBIE_MOVE_SWATITEM,
SCHED_ZOMBIE_SWATITEM,
SCHED_ZOMBIE_ATTACKITEM,
SCHED_ZOMBIE_RELEASECRAB,
SCHED_ZOMBIE_MOVE_TO_AMBUSH,
SCHED_ZOMBIE_WAIT_AMBUSH,
SCHED_ZOMBIE_WANDER_MEDIUM, // medium range wandering behavior.
SCHED_ZOMBIE_WANDER_FAIL,
SCHED_ZOMBIE_WANDER_STANDOFF,
SCHED_ZOMBIE_MELEE_ATTACK1,
SCHED_ZOMBIE_POST_MELEE_WAIT,
LAST_BASE_ZOMBIE_SCHEDULE,
};
//=========================================================
// tasks
//=========================================================
enum
{
TASK_ZOMBIE_DELAY_SWAT = LAST_SHARED_TASK,
TASK_ZOMBIE_GET_PATH_TO_PHYSOBJ,
TASK_ZOMBIE_SWAT_ITEM,
TASK_ZOMBIE_DIE,
TASK_ZOMBIE_RELEASE_HEADCRAB,
TASK_ZOMBIE_WAIT_POST_MELEE,
LAST_BASE_ZOMBIE_TASK,
};
//=========================================================
// Zombie conditions
//=========================================================
enum Zombie_Conds
{
COND_ZOMBIE_CAN_SWAT_ATTACK = LAST_SHARED_CONDITION,
COND_ZOMBIE_RELEASECRAB,
COND_ZOMBIE_LOCAL_MELEE_OBSTRUCTION,
LAST_BASE_ZOMBIE_CONDITION,
};
typedef CAI_BlendingHost< CAI_BehaviorHost<CAI_BaseNPC> > CAI_BaseZombieBase;
//=========================================================
//=========================================================
abstract_class CNPC_BaseZombie : public CAI_BaseZombieBase
{
DECLARE_CLASS( CNPC_BaseZombie, CAI_BaseZombieBase );
public:
CNPC_BaseZombie( void );
~CNPC_BaseZombie( void );
void Spawn( void );
void Precache( void );
void StartTouch( CBaseEntity *pOther );
bool CreateBehaviors();
float MaxYawSpeed( void );
bool OverrideMoveFacing( const AILocalMoveGoal_t &move, float flInterval );
Class_T Classify( void );
Disposition_t IRelationType( CBaseEntity *pTarget );
void HandleAnimEvent( animevent_t *pEvent );
void OnStateChange( NPC_STATE OldState, NPC_STATE NewState );
void KillMe( void )
{
m_iHealth = 5;
OnTakeDamage( CTakeDamageInfo( this, this, m_iHealth * 2, DMG_GENERIC ) );
}
int MeleeAttack1Conditions ( float flDot, float flDist );
virtual float GetClawAttackRange() const { return ZOMBIE_MELEE_REACH; }
// No range attacks
int RangeAttack1Conditions ( float flDot, float flDist ) { return( 0 ); }
virtual float GetHitgroupDamageMultiplier( int iHitGroup, const CTakeDamageInfo &info );
void TraceAttack( const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr, CDmgAccumulator *pAccumulator );
int OnTakeDamage_Alive( const CTakeDamageInfo &info );
virtual float GetReactionDelay( CBaseEntity *pEnemy ) { return 0.0; }
virtual int SelectSchedule ( void );
virtual int SelectFailSchedule( int failedSchedule, int failedTask, AI_TaskFailureCode_t taskFailCode );
virtual void BuildScheduleTestBits( void );
virtual int TranslateSchedule( int scheduleType );
virtual Activity NPC_TranslateActivity( Activity baseAct );
void StartTask( const Task_t *pTask );
void RunTask( const Task_t *pTask );
void GatherConditions( void );
void PrescheduleThink( void );
virtual void Event_Killed( const CTakeDamageInfo &info );
virtual bool BecomeRagdoll( const CTakeDamageInfo &info, const Vector &forceVector );
void StopLoopingSounds();
virtual void OnScheduleChange( void );
virtual void PoundSound();
// Custom damage/death
bool ShouldIgnite( const CTakeDamageInfo &info );
bool ShouldIgniteZombieGib( void );
virtual bool IsChopped( const CTakeDamageInfo &info );
virtual bool IsSquashed( const CTakeDamageInfo &info ) { return false; }
virtual void DieChopped( const CTakeDamageInfo &info );
virtual void Ignite( float flFlameLifetime, bool bNPCOnly = true, float flSize = 0.0f, bool bCalledByLevelDesigner = false );
void CopyRenderColorTo( CBaseEntity *pOther );
virtual bool ShouldBecomeTorso( const CTakeDamageInfo &info, float flDamageThreshold );
virtual HeadcrabRelease_t ShouldReleaseHeadcrab( const CTakeDamageInfo &info, float flDamageThreshold );
// Headcrab releasing/breaking apart
void RemoveHead( void );
virtual void SetZombieModel( void ) { };
virtual void BecomeTorso( const Vector &vecTorsoForce, const Vector &vecLegsForce );
virtual bool CanBecomeLiveTorso() { return false; }
virtual bool HeadcrabFits( CBaseAnimating *pCrab );
void ReleaseHeadcrab( const Vector &vecOrigin, const Vector &vecVelocity, bool fRemoveHead, bool fRagdollBody, bool fRagdollCrab = false );
void SetHeadcrabSpawnLocation( int iCrabAttachment, CBaseAnimating *pCrab );
// Slumping/sleeping
bool IsSlumped( void );
bool IsGettingUp( void );
// Swatting physics objects
int GetSwatActivity( void );
bool FindNearestPhysicsObject( int iMaxMass );
float DistToPhysicsEnt( void );
virtual bool CanSwatPhysicsObjects( void ) { return true; }
// Returns whether we must be very near our enemy to attack them.
virtual bool MustCloseToAttack(void) { return true; }
virtual CBaseEntity *ClawAttack( float flDist, int iDamage, QAngle &qaViewPunch, Vector &vecVelocityPunch, int BloodOrigin );
// Sounds & sound envelope
virtual bool ShouldPlayFootstepMoan( void );
virtual void PainSound( const CTakeDamageInfo &info ) = 0;
virtual void AlertSound( void ) = 0;
virtual void IdleSound( void ) = 0;
virtual void AttackSound( void ) = 0;
virtual void AttackHitSound( void ) = 0;
virtual void AttackMissSound( void ) = 0;
virtual void FootstepSound( bool fRightFoot ) = 0;
virtual void FootscuffSound( bool fRightFoot ) = 0;
// make a sound Alyx can hear when in darkness mode
void MakeAISpookySound( float volume, float duration = 0.5 );
virtual bool CanPlayMoanSound();
virtual void MoanSound( envelopePoint_t *pEnvelope, int iEnvelopeSize );
bool ShouldPlayIdleSound( void ) { return false; }
virtual const char *GetMoanSound( int nSound ) = 0;
virtual const char *GetHeadcrabClassname( void ) = 0;
virtual const char *GetLegsModel( void ) = 0;
virtual const char *GetTorsoModel( void ) = 0;
virtual const char *GetHeadcrabModel( void ) = 0;
virtual Vector BodyTarget( const Vector &posSrc, bool bNoisy );
virtual Vector HeadTarget( const Vector &posSrc );
virtual float GetAutoAimRadius();
virtual void TranslateNavGoal( CBaseEntity *pEnemy, Vector &chasePosition );
bool OnInsufficientStopDist( AILocalMoveGoal_t *pMoveGoal, float distClear, AIMoveResult_t *pResult );
virtual bool AllowedToIgnite( void ) { return true; }
public:
CAI_ActBusyBehavior m_ActBusyBehavior;
protected:
CSoundPatch *m_pMoanSound;
bool m_fIsTorso; // is this is a half-zombie?
bool m_fIsHeadless; // is this zombie headless
float m_flNextFlinch;
bool m_bHeadShot; // Used to determine the survival of our crab beyond our death.
//
// Zombies catch on fire if they take too much burn damage in a given time period.
//
float m_flBurnDamage; // Keeps track of how much burn damage we've incurred in the last few seconds.
float m_flBurnDamageResetTime; // Time at which we reset the burn damage.
EHANDLE m_hPhysicsEnt;
#ifdef MAPBASE
COutputEHANDLE m_OnSwattedProp;
COutputEHANDLE m_OnCrab;
#endif
float m_flNextMoanSound;
float m_flNextSwat;
float m_flNextSwatScan;
float m_crabHealth;
float m_flMoanPitch;
EHANDLE m_hObstructor;
static int g_numZombies; // counts total number of existing zombies.
int m_iMoanSound; // each zombie picks one of the 4 and keeps it.
static int ACT_ZOM_SWATLEFTMID;
static int ACT_ZOM_SWATRIGHTMID;
static int ACT_ZOM_SWATLEFTLOW;
static int ACT_ZOM_SWATRIGHTLOW;
static int ACT_ZOM_RELEASECRAB;
static int ACT_ZOM_FALL;
DECLARE_DATADESC();
DEFINE_CUSTOM_AI;
private:
bool m_bIsSlumped;
};
#endif // NPC_BASEZOMBIE_H