Advertisement
Guest User

npc_fireantlion.h

a guest
Nov 24th, 2011
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.29 KB | None | 0 0
  1. //========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7.  
  8. #ifndef NPC_fireantlion_H
  9. #define NPC_fireantlion_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13.  
  14. #include "ai_blended_movement.h"
  15. #include "soundent.h"
  16. #include "ai_behavior_follow.h"
  17. #include "ai_behavior_assault.h"
  18.  
  19. class CantlionTemplateMaker;
  20.  
  21. #define fireantlion_FOLLOW_DISTANCE 350
  22. #define fireantlion_FOLLOW_DISTANCE_SQR (fireantlion_FOLLOW_DISTANCE*fireantlion_FOLLOW_DISTANCE)
  23. #define fireantlion_SKIN_COUNT 4
  24.  
  25. class CNPC_fireantlion;
  26.  
  27. // fireantlion follow behavior
  28. class CAI_fireantlionFollowBehavior : public CAI_FollowBehavior
  29. {
  30. typedef CAI_FollowBehavior BaseClass;
  31.  
  32. public:
  33.  
  34. CAI_fireantlionFollowBehavior()
  35. : BaseClass( AIF_ANTLION )
  36. {
  37. }
  38.  
  39. bool FarFromFollowTarget( void )
  40. {
  41. return ( GetFollowTarget() && (GetAbsOrigin() - GetFollowTarget()->GetAbsOrigin()).LengthSqr() > fireantlion_FOLLOW_DISTANCE_SQR );
  42. }
  43.  
  44. bool ShouldFollow( void )
  45. {
  46. if ( GetFollowTarget() == NULL )
  47. return false;
  48.  
  49. if ( GetEnemy() != NULL )
  50. return false;
  51.  
  52. return true;
  53. }
  54. };
  55.  
  56. //
  57. // fireantlion class
  58. //
  59.  
  60. enum fireantlionMoveState_e
  61. {
  62. fireantlion_MOVE_FREE,
  63. fireantlion_MOVE_FOLLOW,
  64. fireantlion_MOVE_FIGHT_TO_GOAL,
  65. };
  66.  
  67. #define SF_fireantlion_BURROW_ON_ELUDED ( 1 << 16 )
  68. #define SF_fireantlion_USE_GROUNDCHECKS ( 1 << 17 )
  69. #define SF_fireantlion_WORKER ( 1 << 18 ) // Use the "worker" model
  70.  
  71. typedef CAI_BlendingHost< CAI_BehaviorHost<CAI_BlendedNPC> > CAI_BasefireantlionBase;
  72.  
  73. class CNPC_fireantlion : public CAI_BasefireantlionBase
  74. {
  75. public:
  76.  
  77. DECLARE_CLASS( CNPC_fireantlion, CAI_BasefireantlionBase );
  78.  
  79. CNPC_fireantlion( void );
  80.  
  81. virtual float InnateRange1MinRange( void ) { return 50*12; }
  82. virtual float InnateRange1MaxRange( void ) { return 250*12; }
  83.  
  84. bool IsWorker( void ) const { return HasSpawnFlags( SF_fireantlion_WORKER ); } // NOTE: IsfireantlionWorker function must agree!
  85.  
  86. float GetIdealAccel( void ) const;
  87. float MaxYawSpeed( void );
  88. bool FInViewCone( CBaseEntity *pEntity );
  89. bool FInViewCone( const Vector &vecSpot );
  90.  
  91. void Activate( void );
  92. void HandleAnimEvent( animevent_t *pEvent );
  93. void StartTask( const Task_t *pTask );
  94. void RunTask( const Task_t *pTask );
  95. void IdleSound( void );
  96. void PainSound( const CTakeDamageInfo &info );
  97. void Precache( void );
  98. void Spawn( void );
  99. int OnTakeDamage_Alive( const CTakeDamageInfo &info );
  100. void TraceAttack( const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr );
  101. void BuildScheduleTestBits( void );
  102. void GatherConditions( void );
  103. void PrescheduleThink( void );
  104. void ZapThink( void );
  105. void BurrowUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  106. bool CreateVPhysics();
  107.  
  108. bool IsJumpLegal( const Vector &startPos, const Vector &apex, const Vector &endPos ) const;
  109. bool HandleInteraction( int interactionType, void *data, CBaseCombatCharacter *sender = NULL );
  110. bool QuerySeeEntity( CBaseEntity *pEntity, bool bOnlyHateOrFearIfNPC = false );
  111. bool ShouldPlayIdleSound( void );
  112. bool OverrideMoveFacing( const AILocalMoveGoal_t &move, float flInterval );
  113. bool IsValidEnemy(CBaseEntity *pEnemy);
  114. bool QueryHearSound( CSound *pSound );
  115. bool IsLightDamage( const CTakeDamageInfo &info );
  116. bool CreateBehaviors( void );
  117. bool ShouldHearBugbait( void ) { return ( m_bIgnoreBugbait == false ); }
  118. int SelectSchedule( void );
  119.  
  120. void Touch( CBaseEntity *pOther );
  121.  
  122. virtual int RangeAttack1Conditions( float flDot, float flDist );
  123. virtual int MeleeAttack1Conditions( float flDot, float flDist );
  124. virtual int MeleeAttack2Conditions( float flDot, float flDist );
  125. virtual int GetSoundInterests( void ) { return (BaseClass::GetSoundInterests())|(SOUND_DANGER|SOUND_PHYSICS_DANGER|SOUND_THUMPER|SOUND_BUGBAIT); }
  126. virtual bool IsHeavyDamage( const CTakeDamageInfo &info );
  127.  
  128. Class_T Classify( void ) { return CLASS_fireantlion; }
  129.  
  130. void Event_Killed( const CTakeDamageInfo &info );
  131. bool FValidateHintType ( CAI_Hint *pHint );
  132. void GatherEnemyConditions( CBaseEntity *pEnemy );
  133.  
  134. bool IsAllied( void );
  135. bool ShouldGib( const CTakeDamageInfo &info );
  136. bool CorpseGib( const CTakeDamageInfo &info );
  137.  
  138. float GetMaxJumpSpeed() const { return 1024.0f; }
  139.  
  140. void SetFightTarget( CBaseEntity *pTarget );
  141. void InputFightToPosition( inputdata_t &inputdata );
  142. void InputStopFightToPosition( inputdata_t &inputdata );
  143. void InputJumpAtTarget( inputdata_t &inputdata );
  144.  
  145. void SetFollowTarget( CBaseEntity *pTarget );
  146. int TranslateSchedule( int scheduleType );
  147.  
  148. virtual Activity NPC_TranslateActivity( Activity baseAct );
  149.  
  150. bool ShouldResumeFollow( void );
  151. bool ShouldAbandonFollow( void );
  152.  
  153. void SetMoveState( fireantlionMoveState_e state );
  154. int ChooseMoveSchedule( void );
  155.  
  156. DECLARE_DATADESC();
  157.  
  158. bool m_bStartBurrowed;
  159. float m_flNextJumpPushTime;
  160.  
  161. void SetParentSpawnerName( const char *szName ) { m_strParentSpawner = MAKE_STRING( szName ); }
  162. const char *GetParentSpawnerName( void ) { return STRING( m_strParentSpawner ); }
  163.  
  164. virtual void StopLoopingSounds( void );
  165. bool AllowedToBePushed( void );
  166.  
  167. virtual Vector BodyTarget( const Vector &posSrc, bool bNoisy = true );
  168. virtual float GetAutoAimRadius() { return 36.0f; }
  169.  
  170. void ClearBurrowPoint( const Vector &origin );
  171.  
  172. void Flip( bool bZapped = false );
  173.  
  174. bool CanBecomeRagdoll();
  175.  
  176. virtual void NotifyDeadFriend( CBaseEntity *pFriend );
  177.  
  178. private:
  179.  
  180. inline CBaseEntity *EntityToWatch( void );
  181. void UpdateHead( void );
  182.  
  183. bool FindChasePosition( const Vector &targetPos, Vector &result );
  184. bool GetGroundPosition( const Vector &testPos, Vector &result );
  185. bool GetPathToSoundFleePoint( int soundType );
  186. inline bool IsFlipped( void );
  187.  
  188. void Burrow( void );
  189. void Unburrow( void );
  190.  
  191. void InputUnburrow( inputdata_t &inputdata );
  192. void InputBurrow( inputdata_t &inputdata );
  193. void InputBurrowAway( inputdata_t &inputdata );
  194. void InputDisableJump( inputdata_t &inputdata );
  195. void InputEnableJump( inputdata_t &inputdata );
  196. void InputIgnoreBugbait( inputdata_t &inputdata );
  197. void InputHearBugbait( inputdata_t &inputdata );
  198.  
  199. bool FindBurrow( const Vector &origin, float distance, int type, bool excludeNear = true );
  200. void CreateDust( bool placeDecal = true );
  201.  
  202. bool ValidBurrowPoint( const Vector &point );
  203. bool CheckLanding( void );
  204. bool Alone( void );
  205. bool CheckAlertRadius( void );
  206. bool ShouldJump( void );
  207.  
  208. void MeleeAttack( float distance, float damage, QAngle& viewPunch, Vector& shove );
  209. void SetWings( bool state );
  210. void StartJump( void );
  211. void LockJumpNode( void );
  212.  
  213. bool IsUnusableNode(int iNodeID, CAI_Hint *pHint);
  214.  
  215. bool OnObstructionPreSteer( AILocalMoveGoal_t *pMoveGoal, float distClear, AIMoveResult_t *pResult );
  216.  
  217. void ManageFleeCapabilities( bool bEnable );
  218.  
  219. int SelectFailSchedule( int failedSchedule, int failedTask, AI_TaskFailureCode_t taskFailCode );
  220. bool IsFirmlyOnGround( void );
  221. void CascadePush( const Vector &vecForce );
  222.  
  223. virtual bool CanRunAScriptedNPCInteraction( bool bForced = false );
  224.  
  225. virtual void Ignite ( float flFlameLifetime, bool bNPCOnly, float flSize, bool bCalledByLevelDesigner );
  226. virtual bool GetSpitVector( const Vector &vecStartPos, const Vector &vecTarget, Vector *vecOut );
  227. virtual bool InnateWeaponLOSCondition( const Vector &ownerPos, const Vector &targetPos, bool bSetConditions );
  228. virtual bool FCanCheckAttacks( void );
  229.  
  230. bool SeenEnemyWithinTime( float flTime );
  231. void DelaySquadAttack( float flDuration );
  232.  
  233. #if HL2_EPISODIC
  234. void DoPoisonBurst();
  235. #endif
  236.  
  237. float m_flIdleDelay;
  238. float m_flBurrowTime;
  239. float m_flJumpTime;
  240. float m_flAlertRadius;
  241.  
  242. float m_flPounceTime;
  243. int m_iUnBurrowAttempts;
  244. int m_iContext; //for FValidateHintType context
  245.  
  246. Vector m_vecSaveSpitVelocity; // Saved when we start to attack and used if we failed to get a clear shot once we release
  247.  
  248. CAI_fireantlionFollowBehavior m_FollowBehavior;
  249. CAI_AssaultBehavior m_AssaultBehavior;
  250.  
  251. fireantlionMoveState_e m_MoveState;
  252.  
  253. COutputEvent m_OnReachFightGoal; //Reached our scripted destination to fight to
  254. COutputEvent m_OnUnBurrowed; //Unburrowed
  255.  
  256. Vector m_vecSavedJump;
  257. Vector m_vecLastJumpAttempt;
  258.  
  259. float m_flIgnoreSoundTime; // Sound time to ignore if earlier than
  260. float m_flNextAcknowledgeTime; // Next time an fireantlion can make an acknowledgement noise
  261. float m_flSuppressFollowTime; // Amount of time to suppress our follow time
  262. float m_flObeyFollowTime; // A range of time the fireantlions must be obedient
  263.  
  264. Vector m_vecHeardSound;
  265. bool m_bHasHeardSound;
  266. bool m_bAgitatedSound; //Playing agitated sound?
  267. bool m_bWingsOpen; //Are the wings open?
  268. bool m_bIgnoreBugbait; //If the fireantlion should ignore bugbait sounds
  269. string_t m_strParentSpawner; //Name of our spawner
  270.  
  271. EHANDLE m_hFollowTarget;
  272. EHANDLE m_hFightGoalTarget;
  273. float m_flEludeDistance; //Distance until the fireantlion will consider himself "eluded" if so flagged
  274. bool m_bLeapAttack;
  275. bool m_bDisableJump;
  276. float m_flTimeDrown;
  277. float m_flTimeDrownSplash;
  278. bool m_bDontExplode; // Suppresses worker poison burst when drowning, failing to unburrow, etc.
  279. bool m_bLoopingStarted;
  280. bool m_bSuppressUnburrowEffects; // Don't kick up dust when spawning
  281. #if HL2_EPISODIC
  282. bool m_bHasDoneAirAttack; ///< only allowed to apply this damage once per glide
  283. #endif
  284.  
  285. bool m_bForcedStuckJump;
  286. int m_nBodyBone;
  287.  
  288. // Used to trigger a heavy damage interrupt if sustained damage is taken
  289. int m_nSustainedDamage;
  290. float m_flLastDamageTime;
  291. float m_flZapDuration;
  292.  
  293. protected:
  294. int m_poseHead_Yaw, m_poseHead_Pitch;
  295. virtual void PopulatePoseParameters( void );
  296.  
  297. private:
  298.  
  299. HSOUNDSCRIPTHANDLE m_hFootstep;
  300.  
  301. DEFINE_CUSTOM_AI;
  302.  
  303. //==================================================
  304. // fireantlionConditions
  305. //==================================================
  306.  
  307. enum
  308. {
  309. COND_fireantlion_FLIPPED = LAST_SHARED_CONDITION,
  310. COND_fireantlion_ON_NPC,
  311. COND_fireantlion_CAN_JUMP,
  312. COND_fireantlion_FOLLOW_TARGET_TOO_FAR,
  313. COND_fireantlion_RECEIVED_ORDERS,
  314. COND_fireantlion_IN_WATER,
  315. COND_fireantlion_CAN_JUMP_AT_TARGET,
  316. COND_fireantlion_SQUADMATE_KILLED
  317. };
  318.  
  319. //==================================================
  320. // fireantlionSchedules
  321. //==================================================
  322.  
  323. enum
  324. {
  325. SCHED_fireantlion_CHASE_ENEMY_BURROW = LAST_SHARED_SCHEDULE,
  326. SCHED_fireantlion_JUMP,
  327. SCHED_fireantlion_RUN_TO_BURROW_IN,
  328. SCHED_fireantlion_BURROW_IN,
  329. SCHED_fireantlion_BURROW_WAIT,
  330. SCHED_fireantlion_BURROW_OUT,
  331. SCHED_fireantlion_WAIT_FOR_UNBORROW_TRIGGER,
  332. SCHED_fireantlion_WAIT_FOR_CLEAR_UNBORROW,
  333. SCHED_fireantlion_WAIT_UNBORROW,
  334. SCHED_fireantlion_FLEE_THUMPER,
  335. SCHED_fireantlion_CHASE_BUGBAIT,
  336. SCHED_fireantlion_FLIP,
  337. SCHED_fireantlion_DISMOUNT_NPC,
  338. SCHED_fireantlion_RUN_TO_FIGHT_GOAL,
  339. SCHED_fireantlion_RUN_TO_FOLLOW_GOAL,
  340. SCHED_fireantlion_BUGBAIT_IDLE_STAND,
  341. SCHED_fireantlion_BURROW_AWAY,
  342. SCHED_fireantlion_FLEE_PHYSICS_DANGER,
  343. SCHED_fireantlion_POUNCE,
  344. SCHED_fireantlion_POUNCE_MOVING,
  345. SCHED_fireantlion_DROWN,
  346. SCHED_fireantlion_WORKER_RANGE_ATTACK1,
  347. SCHED_fireantlion_WORKER_RUN_RANDOM,
  348. SCHED_fireantlion_TAKE_COVER_FROM_ENEMY,
  349. SCHED_fireantlion_ZAP_FLIP,
  350. SCHED_fireantlion_WORKER_FLANK_RANDOM,
  351. SCHED_fireantlion_TAKE_COVER_FROM_SAVEPOSITION
  352. };
  353.  
  354. //==================================================
  355. // fireantlionTasks
  356. //==================================================
  357.  
  358. enum
  359. {
  360. TASK_fireantlion_SET_CHARGE_GOAL = LAST_SHARED_TASK,
  361. TASK_fireantlion_FIND_BURROW_IN_POINT,
  362. TASK_fireantlion_FIND_BURROW_OUT_POINT,
  363. TASK_fireantlion_BURROW,
  364. TASK_fireantlion_UNBURROW,
  365. TASK_fireantlion_VANISH,
  366. TASK_fireantlion_BURROW_WAIT,
  367. TASK_fireantlion_CHECK_FOR_UNBORROW,
  368. TASK_fireantlion_JUMP,
  369. TASK_fireantlion_WAIT_FOR_TRIGGER,
  370. TASK_fireantlion_GET_THUMPER_ESCAPE_PATH,
  371. TASK_fireantlion_GET_PATH_TO_BUGBAIT,
  372. TASK_fireantlion_FACE_BUGBAIT,
  373. TASK_fireantlion_DISMOUNT_NPC,
  374. TASK_fireantlion_REACH_FIGHT_GOAL,
  375. TASK_fireantlion_GET_PHYSICS_DANGER_ESCAPE_PATH,
  376. TASK_fireantlion_FACE_JUMP,
  377. TASK_fireantlion_DROWN,
  378. TASK_fireantlion_GET_PATH_TO_RANDOM_NODE,
  379. TASK_fireantlion_FIND_COVER_FROM_SAVEPOSITION,
  380. };
  381. };
  382.  
  383.  
  384. //-----------------------------------------------------------------------------
  385. // Purpose: Shield
  386. //-----------------------------------------------------------------------------
  387. class CfireantlionRepellant : public CPointEntity
  388. {
  389. DECLARE_DATADESC();
  390. public:
  391. DECLARE_CLASS( CfireantlionRepellant, CPointEntity );
  392. ~CfireantlionRepellant();
  393.  
  394. public:
  395. void Spawn( void );
  396. void InputEnable( inputdata_t &inputdata );
  397. void InputDisable( inputdata_t &inputdata );
  398. float GetRadius( void );
  399. void SetRadius( float flRadius ) { m_flRepelRadius = flRadius; }
  400.  
  401. static bool IsPositionRepellantFree( Vector vDesiredPos );
  402.  
  403. void OnRestore( void );
  404.  
  405. private:
  406.  
  407. float m_flRepelRadius;
  408. bool m_bEnabled;
  409. };
  410.  
  411. extern bool Isfireantlion( CBaseEntity *pEntity );
  412. extern bool IsfireantlionWorker( CBaseEntity *pEntity );
  413.  
  414. #ifdef HL2_EPISODIC
  415. extern float fireantlionWorkerBurstRadius( void );
  416. #endif // HL2_EPISODIC
  417.  
  418. #endif // NPC_fireantlion_H
  419.  
  420.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement