OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
actor.h
1/*
2===========================================================================
3Copyright (C) 2015 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23// actor.h: Base class for character AI.
24
25#pragma once
26
27#include "g_local.h"
28#include "simpleactor.h"
29#include "actorenemy.h"
30#include "level.h"
31#include "game.h"
32#include "gamescript.h"
33#include "scriptmaster.h"
34#include "grenadehint.h"
35#include "parm.h"
36
37//
38// Export these events for AISpawnPoint (since 2.30)
39//
40extern Event EV_Actor_SetGun;
41extern Event EV_Actor_SetGun2;
42extern Event EV_Actor_GetGun;
43extern Event EV_Actor_GetSight;
44extern Event EV_Actor_SetSight;
45extern Event EV_Actor_SetSight2;
46extern Event EV_Actor_GetHearing;
47extern Event EV_Actor_SetHearing;
48extern Event EV_Actor_SetHearing2;
49extern Event EV_Actor_GetFov;
50extern Event EV_Actor_SetFov;
51extern Event EV_Actor_SetFov2;
52extern Event EV_Actor_SetTypeIdle;
53extern Event EV_Actor_SetTypeIdle2;
54extern Event EV_Actor_GetTypeIdle;
55extern Event EV_Actor_SetTypeAttack;
56extern Event EV_Actor_SetTypeAttack2;
57extern Event EV_Actor_GetTypeAttack;
58extern Event EV_Actor_SetTypeDisguise;
59extern Event EV_Actor_SetTypeDisguise2;
60extern Event EV_Actor_GetTypeDisguise;
61extern Event EV_Actor_SetDisguiseLevel;
62extern Event EV_Actor_SetDisguiseLevel2;
63extern Event EV_Actor_GetDisguiseLevel;
64extern Event EV_Actor_SetTypeGrenade;
65extern Event EV_Actor_SetTypeGrenade2;
66extern Event EV_Actor_GetTypeGrenade;
67extern Event EV_Actor_SetPatrolPath;
68extern Event EV_Actor_SetPatrolPath2;
69extern Event EV_Actor_GetPatrolPath;
70extern Event EV_Actor_SetPatrolWaitTrigger;
71extern Event EV_Actor_SetPatrolWaitTrigger2;
72extern Event EV_Actor_GetPatrolWaitTrigger;
73extern Event EV_Actor_SetAlarmNode;
74extern Event EV_Actor_SetAlarmNode2;
75extern Event EV_Actor_GetAlarmNode;
76extern Event EV_Actor_SetAccuracy;
77extern Event EV_Actor_SetAccuracy2;
78extern Event EV_Actor_GetAccuracy;
79extern Event EV_Actor_SetMinDistance;
80extern Event EV_Actor_SetMinDistance2;
81extern Event EV_Actor_GetMinDistance;
82extern Event EV_Actor_SetMaxDistance;
83extern Event EV_Actor_SetMaxDistance2;
84extern Event EV_Actor_GetMaxDistance;
85extern Event EV_Actor_GetLeash;
86extern Event EV_Actor_SetLeash;
87extern Event EV_Actor_SetLeash2;
88extern Event EV_Actor_GetInterval;
89extern Event EV_Actor_SetInterval;
90extern Event EV_Actor_SetInterval2;
91extern Event EV_Actor_SetDisguiseRange;
92extern Event EV_Actor_SetDisguiseRange2;
93extern Event EV_Actor_GetDisguiseRange;
94extern Event EV_Actor_SetDisguisePeriod;
95extern Event EV_Actor_SetDisguisePeriod2;
96extern Event EV_Actor_GetDisguisePeriod;
97extern Event EV_Actor_SetGrenadeAwareness;
98extern Event EV_Actor_SetGrenadeAwareness2;
99extern Event EV_Actor_GetGrenadeAwareness;
100extern Event EV_Actor_SetTurret;
101extern Event EV_Actor_SetTurret2;
102extern Event EV_Actor_GetTurret;
103extern Event EV_Actor_SetSoundAwareness;
104extern Event EV_Actor_SetSoundAwareness2;
105extern Event EV_Actor_GetSoundAwareness;
106extern Event EV_Actor_SetGrenadeAwareness;
107extern Event EV_Actor_SetGrenadeAwareness2;
108extern Event EV_Actor_SetAmmoGrenade;
109extern Event EV_Actor_SetAmmoGrenade2;
110extern Event EV_Actor_GetAmmoGrenade;
111extern Event EV_Actor_GetMaxNoticeTimeScale;
112extern Event EV_Actor_SetMaxNoticeTimeScale;
113extern Event EV_Actor_SetMaxNoticeTimeScale2;
114extern Event EV_Actor_GetFixedLeash;
115extern Event EV_Actor_SetFixedLeash;
116extern Event EV_Actor_SetFixedLeash2;
117extern Event EV_Actor_GetEnemyShareRange;
118extern Event EV_Actor_SetEnemyShareRange;
119extern Event EV_Actor_SetEnemyShareRange2;
120extern Event EV_Actor_SetWeapon;
121extern Event EV_Actor_GetWeapon;
122extern Event EV_Actor_GetVoiceType;
123extern Event EV_Actor_SetVoiceType;
124extern Event EV_Actor_SetVoiceType2;
125extern Event EV_Actor_GetFavoriteEnemy;
126extern Event EV_Actor_SetFavoriteEnemy;
127extern Event EV_Actor_SetFavoriteEnemy2;
128extern Event EV_Actor_SetBalconyHeight;
129extern Event EV_Actor_SetBalconyHeight2;
130extern Event EV_Actor_GetBalconyHeight;
131extern Event EV_Actor_GetNoSurprise;
132extern Event EV_Actor_SetNoSurprise;
133extern Event EV_Actor_SetNoSurprise2;
134extern Event EV_Actor_DeathEmbalm;
135
136// Bones used by actor
137
138//#define ACTOR_MOUTH_TAG 0
139#define ACTOR_HEAD_TAG 0
140#define ACTOR_TORSO_TAG 1
141
142// Dialog stuff
143
144#define LIP_SYNC_HZ 20.0
145
146#define MAX_DIALOG_PARAMETERS_LENGTH 100
147
148#define MAX_DIALOG_PARM_LENGTH 64
149#define MAX_DIALOG_PARMS 10
150
151#define DIALOG_PARM_TYPE_NONE 0
152#define DIALOG_PARM_TYPE_PLAYERHAS 1
153#define DIALOG_PARM_TYPE_PLAYERHASNOT 2
154#define DIALOG_PARM_TYPE_HAS 3
155#define DIALOG_PARM_TYPE_HASNOT 4
156#define DIALOG_PARM_TYPE_DEPENDS 5
157#define DIALOG_PARM_TYPE_DEPENDSNOT 6
158
159typedef struct {
160 byte type;
161 char parm[MAX_DIALOG_PARM_LENGTH];
163
164typedef struct DialogNode_s {
165 char alias_name[MAX_ALIAS_NAME_LENGTH];
166 int random_flag;
167 int number_of_parms;
168 float random_percent;
169 DialogParm_t parms[MAX_DIALOG_PARMS];
170 struct DialogNode_s *next;
171} DialogNode_t;
172
173typedef enum {
174 IS_INANIMATE,
175 IS_MONSTER,
176 IS_ENEMY,
177 IS_CIVILIAN,
178 IS_FRIEND,
179 IS_ANIMAL,
180 NUM_ACTORTYPES
181} actortype_t;
182
183// Stimuli types
184
185#define STIMULI_ALL -1
186#define STIMULI_NONE 0
187#define STIMULI_SIGHT (1 << 0)
188#define STIMULI_SOUND (1 << 1)
189#define STIMULI_PAIN (1 << 2)
190#define STIMULI_SCRIPT (1 << 3)
191
192#define MAX_INACTIVE_TIME 30.0
193
194// State flags
195
196#define STATE_FLAG_IN_PAIN (1 << 0)
197#define STATE_FLAG_MELEE_HIT (1 << 1)
198#define STATE_FLAG_TOUCHED (1 << 2)
199#define STATE_FLAG_ACTIVATED (1 << 3)
200#define STATE_FLAG_USED (1 << 4)
201#define STATE_FLAG_TWITCH (1 << 5)
202#define STATE_FLAG_BLOCKED_HIT (1 << 6)
203#define STATE_FLAG_SMALL_PAIN (1 << 7)
204#define STATE_FLAG_OTHER_DIED (1 << 8)
205#define STATE_FLAG_STUCK (1 << 9)
206#define STATE_FLAG_NO_PATH (1 << 10)
207
208// Actor modes
209
210#define ACTOR_MODE_NONE 0
211#define ACTOR_MODE_IDLE 1
212#define ACTOR_MODE_AI 2
213#define ACTOR_MODE_SCRIPT 3
214#define ACTOR_MODE_TALK 4
215
216// Pain types
217
218#define PAIN_SMALL 0
219#define PAIN_BIG 1
220
221typedef struct {
222 EntityPtr ent;
223 unsigned int state_flags;
224} part_t;
225
226// Actor flags
227
228#define ACTOR_FLAG_NOISE_HEARD 0
229#define ACTOR_FLAG_INVESTIGATING 1
230#define ACTOR_FLAG_DEATHGIB 2
231#define ACTOR_FLAG_DEATHFADE 3
232#define ACTOR_FLAG_NOCHATTER 4
233#define ACTOR_FLAG_INACTIVE 5
234#define ACTOR_FLAG_ANIM_DONE 6
235#define ACTOR_FLAG_STATE_DONE_TIME_VALID 7
236#define ACTOR_FLAG_AI_ON 8
237#define ACTOR_FLAG_LAST_CANSEEENEMY 9
238#define ACTOR_FLAG_LAST_CANSEEENEMY_NOFOV 10
239#define ACTOR_FLAG_DIALOG_PLAYING 11
240#define ACTOR_FLAG_ALLOW_TALK 12
241#define ACTOR_FLAG_DAMAGE_ONCE_ON 13
242#define ACTOR_FLAG_DAMAGE_ONCE_DAMAGED 14
243#define ACTOR_FLAG_BOUNCE_OFF 15
244#define ACTOR_FLAG_NOTIFY_OTHERS_AT_DEATH 16
245#define ACTOR_FLAG_HAS_THING1 17
246#define ACTOR_FLAG_HAS_THING2 18
247#define ACTOR_FLAG_HAS_THING3 19
248#define ACTOR_FLAG_HAS_THING4 20
249#define ACTOR_FLAG_LAST_ATTACK_HIT 21
250#define ACTOR_FLAG_STARTED 22
251#define ACTOR_FLAG_ALLOW_HANGBACK 23
252#define ACTOR_FLAG_USE_GRAVITY 24
253#define ACTOR_FLAG_SPAWN_FAILED 25
254#define ACTOR_FLAG_FADING_OUT 26
255#define ACTOR_FLAG_DEATHSHRINK 27
256#define ACTOR_FLAG_DEATHSINK 28
257#define ACTOR_FLAG_STAYSOLID 29
258#define ACTOR_FLAG_STUNNED 30
259#define ACTOR_FLAG_ALLOW_FALL 31
260#define ACTOR_FLAG_FINISHED 32
261#define ACTOR_FLAG_IN_LIMBO 33
262#define ACTOR_FLAG_CAN_WALK_ON_OTHERS 34
263#define ACTOR_FLAG_PUSHABLE 35
264#define ACTOR_FLAG_LAST_TRY_TALK 36
265#define ACTOR_FLAG_ATTACKABLE_BY_ACTORS 37
266#define ACTOR_FLAG_TARGETABLE 38
267#define ACTOR_FLAG_ATTACK_ACTORS 39
268#define ACTOR_FLAG_IMMORTAL 40
269#define ACTOR_FLAG_TURNING_HEAD 41
270#define ACTOR_FLAG_DIE_COMPLETELY 42
271#define ACTOR_FLAG_BLEED_AFTER_DEATH 43
272#define ACTOR_FLAG_IGNORE_STUCK_WARNING 44
273#define ACTOR_FLAG_IGNORE_OFF_GROUND_WARNING 45
274#define ACTOR_FLAG_ALLOWED_TO_KILL 46
275#define ACTOR_FLAG_TOUCH_TRIGGERS 47
276#define ACTOR_FLAG_IGNORE_WATER 48
277#define ACTOR_FLAG_NEVER_IGNORE_SOUNDS 49
278#define ACTOR_FLAG_SIMPLE_PATHFINDING 50
279#define ACTOR_FLAG_HAVE_MOVED 51
280#define ACTOR_FLAG_NO_PAIN_SOUNDS 52
281#define ACTOR_FLAG_UPDATE_BOSS_HEALTH 53
282#define ACTOR_FLAG_IGNORE_PAIN_FROM_ACTORS 54
283#define ACTOR_FLAG_DAMAGE_ALLOWED 55
284#define ACTOR_FLAG_ALWAYS_GIVE_WATER 56
285
286// Look flags
287
288#define LOOK_FLAG_EYE (1 << 0)
289
290// The last actor_flag number and this one (ACTOR_FLAG_MAX) should match
291
292#define ACTOR_FLAG_MAX 56
293
294#define MAX_ORIGIN_HISTORY 4
295#define MAX_COVER_NODES 16
296#define MAX_BODYQUEUE 5
297
298typedef enum {
299 AI_GREN_TOSS_NONE,
300 AI_GREN_TOSS_THROW,
301 AI_GREN_TOSS_ROLL,
302 AI_GREN_TOSS_HINT,
303 AI_GREN_KICK
304} eGrenadeTossMode;
305
306typedef enum {
307 AI_GRENSTATE_FLEE,
308 AI_GRENSTATE_THROW_ACQUIRE,
309 AI_GRENSTATE_THROW,
310 AI_GRENSTATE_KICK_ACQUIRE,
311 AI_GRENSTATE_KICK,
312 AI_GRENSTATE_MARTYR_ACQUIRE,
313 AI_GRENSTATE_MARTYR,
314 AI_GRENSTATE_UNK,
315 AI_GRENSTATE_FLEE_SUCCESS, //fled the grenade successfully, I'm safe
316 AI_GRENSTATE_FLEE_FAIL, //failed to flee, I'm gonna get hurt or die :'(
317} eGrenadeState;
318
319typedef struct {
320 byte length;
321 byte currentPos;
322 byte loop;
323 float startTime;
324 vec3_t pos[1];
325} FallPath;
326
327enum eThinkState {
328 THINKSTATE_VOID,
329 THINKSTATE_IDLE,
330 THINKSTATE_PAIN,
331 THINKSTATE_KILLED,
332 THINKSTATE_ATTACK,
333 THINKSTATE_CURIOUS,
334 THINKSTATE_DISGUISE,
335 THINKSTATE_BADPLACE, // Added in 2.0
336 THINKSTATE_GRENADE,
337 THINKSTATE_NOCLIP,
338 NUM_THINKSTATES,
339};
340
341enum eThinkNum {
342 THINK_VOID,
343 THINK_TURRET,
344 THINK_COVER,
345 THINK_PATROL,
346 THINK_RUNNER,
347 THINK_PAIN,
348 THINK_KILLED,
349 THINK_MOVETO,
350 THINK_IDLE,
351 THINK_CURIOUS,
352 THINK_DISGUISE_SALUTE,
353 THINK_DISGUISE_SENTRY,
354 THINK_DISGUISE_OFFICER,
355 THINK_DISGUISE_ROVER,
356 THINK_DISGUISE_NONE,
357 THINK_ALARM,
358 THINK_GRENADE,
359 THINK_MACHINEGUNNER,
360 THINK_DOG_IDLE,
361 THINK_DOG_ATTACK,
362 THINK_DOG_CURIOUS,
363 THINK_DOG_GRENADE,
364 THINK_ANIM,
365 THINK_ANIM_CURIOUS,
366 THINK_AIM,
367 THINK_BALCONY_IDLE,
368 THINK_BALCONY_CURIOUS,
369 THINK_BALCONY_ATTACK,
370 THINK_BALCONY_DISGUISE,
371 THINK_BALCONY_GRENADE,
372 THINK_BALCONY_PAIN,
373 THINK_BALCONY_KILLED,
374 THINK_WEAPONLESS,
375 THINK_NOCLIP,
376 THINK_DEAD,
377 THINK_BADPLACE, // Added in 2.0
378 THINK_RUN_AND_SHOOT, // Added in 2.30
379 NUM_THINKS,
380};
381
382enum eThinkLevel {
383 THINKLEVEL_IDLE,
384 THINKLEVEL_PAIN,
385 THINKLEVEL_KILLED,
386 THINKLEVEL_NOCLIP,
387 NUM_THINKLEVELS
388};
389
390enum eActorNationality {
391 ACTOR_NATIONALITY_DEFAULT,
392 ACTOR_NATIONALITY_AMERICAN,
393 ACTOR_NATIONALITY_GERMAN,
394 ACTOR_NATIONALITY_ITALIAN,
395 ACTOR_NATIONALITY_BRITISH,
396 ACTOR_NATIONALITY_RUSSIAN,
397};
398
399//
400// Actor states
401//
402enum eActorState {
403 ACTOR_STATE_DISGUISE = 0,
404 ACTOR_STATE_TURRET = 100,
405 ACTOR_STATE_BALCONY_ATTACK = 200,
406 ACTOR_STATE_COVER = 300,
407 ACTOR_STATE_PAIN = 500,
408 ACTOR_STATE_ALARM = 600,
409 ACTOR_STATE_KILLED = 700,
410 ACTOR_STATE_BALCONY_KILLED = 800,
411 ACTOR_STATE_WEAPONLESS = 900,
412 ACTOR_STATE_ANIMATION = 1000,
413 ACTOR_STATE_CURIOUS = 1100,
414 ACTOR_STATE_MACHINE_GUNNER = 1200,
415 // Added in 2.30
416 ACTOR_STATE_RUN_AND_SHOOT = 1300,
417};
418
419//
420// Disguise think state
421//
422enum eActorState_Disguise {
423 ACTOR_STATE_DISGUISE_START = ACTOR_STATE_DISGUISE,
424 ACTOR_STATE_DISGUISE_WAIT = ACTOR_STATE_DISGUISE_START,
425 ACTOR_STATE_DISGUISE_PAPERS,
426 ACTOR_STATE_DISGUISE_ACCEPT,
427 ACTOR_STATE_DISGUISE_ENEMY,
428 ACTOR_STATE_DISGUISE_HALT,
429 ACTOR_STATE_DISGUISE_DENY,
430};
431
432//
433// Turret think state
434//
435enum eActorState_Turret {
436 ACTOR_STATE_TURRET_START = ACTOR_STATE_TURRET,
437 ACTOR_STATE_TURRET_COMBAT = ACTOR_STATE_TURRET_START,
438 ACTOR_STATE_TURRET_REACQUIRE,
439 ACTOR_STATE_TURRET_TAKE_SNIPER_NODE,
440 ACTOR_STATE_TURRET_SNIPER_NODE,
441 ACTOR_STATE_TURRET_RUN_HOME,
442 ACTOR_STATE_TURRET_RUN_AWAY,
443 ACTOR_STATE_TURRET_CHARGE,
444 ACTOR_STATE_TURRET_GRENADE,
445 ACTOR_STATE_TURRET_INTRO_AIM,
446 ACTOR_STATE_TURRET_FAKE_ENEMY,
447 ACTOR_STATE_TURRET_COVER_INSTEAD,
448 ACTOR_STATE_TURRET_BECOME_COVER,
449 ACTOR_STATE_TURRET_WAIT,
450 ACTOR_STATE_TURRET_SHOOT, // Added in 2.0
451 ACTOR_STATE_TURRET_RETARGET_SUPPRESS, // Added in 2.0
452 ACTOR_STATE_TURRET_RETARGET_SNIPER_NODE,
453 ACTOR_STATE_TURRET_RETARGET_STEP_SIDE_SMALL,
454 ACTOR_STATE_TURRET_RETARGET_PATH_EXACT,
455 ACTOR_STATE_TURRET_RETARGET_PATH_NEAR,
456 ACTOR_STATE_TURRET_RETARGET_STEP_SIDE_MEDIUM,
457 ACTOR_STATE_TURRET_RETARGET_STEP_SIDE_LARGE,
458 ACTOR_STATE_TURRET_RETARGET_STEP_FACE_MEDIUM,
459 ACTOR_STATE_TURRET_RETARGET_STEP_FACE_LARGE,
460 ACTOR_STATE_TURRET_NUM_STATES
461};
462
463//
464// Balcony attack think state
465//
466enum eActorState_BalconyAttack {
467 ACTOR_STATE_BALCONY_ATTACK_START = ACTOR_STATE_BALCONY_ATTACK,
468 ACTOR_STATE_BALCONY_ATTACK_FIND_ENEMY = ACTOR_STATE_BALCONY_ATTACK_START,
469 ACTOR_STATE_BALCONY_ATTACK_TARGET,
470 ACTOR_STATE_BALCONY_ATTACK_SHOOT
471};
472
473//
474// Balcony cover think state
475//
476enum eActorState_Cover {
477 ACTOR_STATE_COVER_START = ACTOR_STATE_COVER,
478 ACTOR_STATE_COVER_NEW_ENEMY = ACTOR_STATE_COVER_START,
479 ACTOR_STATE_COVER_FIND_COVER,
480 ACTOR_STATE_COVER_TAKE_COVER,
481 ACTOR_STATE_COVER_FINISH_RELOADING,
482 ACTOR_STATE_COVER_SPECIAL_ATTACK,
483 ACTOR_STATE_COVER_FIND_ENEMY,
484 ACTOR_STATE_COVER_SEARCH_NODE,
485 ACTOR_STATE_COVER_TARGET,
486 ACTOR_STATE_COVER_HIDE,
487 ACTOR_STATE_COVER_SHOOT,
488 ACTOR_STATE_COVER_GRENADE,
489 ACTOR_STATE_COVER_HUNT_ENEMY,
490 ACTOR_STATE_COVER_LOOP,
491 ACTOR_STATE_COVER_FAKE_ENEMY,
492};
493
494//
495// Pain think state
496//
497enum eActorState_Pain {
498 ACTOR_STATE_PAIN_START = ACTOR_STATE_PAIN,
499 ACTOR_STATE_PAIN_INITIAL = ACTOR_STATE_PAIN_START,
500 ACTOR_STATE_PAIN_MAIN
501};
502
503//
504// Alarm think state
505//
506enum eActorState_Alarm {
507 ACTOR_STATE_ALARM_START = ACTOR_STATE_ALARM,
508 ACTOR_STATE_ALARM_IDLE = ACTOR_STATE_ALARM_START,
509 ACTOR_STATE_ALARM_MOVE
510};
511
512//
513// Killed think state
514//
515enum eActorState_Killed {
516 ACTOR_STATE_KILLED_START = ACTOR_STATE_KILLED,
517 ACTOR_STATE_KILLED_BEGIN = ACTOR_STATE_KILLED_START,
518 ACTOR_STATE_KILLED_END
519};
520
521//
522// Balcony killed think state
523//
524enum eActorState_BalconyKilled {
525 ACTOR_STATE_BALCONY_KILLED_START = ACTOR_STATE_BALCONY_KILLED,
526 ACTOR_STATE_BALCONY_KILLED_BEGIN = ACTOR_STATE_BALCONY_KILLED_START,
527 ACTOR_STATE_BALCONY_KILLED_INTRO,
528 ACTOR_STATE_BALCONY_KILLED_LOOP,
529 ACTOR_STATE_BALCONY_KILLED_LOOP_END,
530 ACTOR_STATE_BALCONY_KILLED_OUTTRO,
531 ACTOR_STATE_BALCONY_KILLED_END,
532 ACTOR_STATE_BALCONY_KILLED_NORMAL,
533};
534
535//
536// Weaponless think state
537//
538enum eActorState_WeaponLess {
539 ACTOR_STATE_WEAPONLESS_START = ACTOR_STATE_WEAPONLESS,
540 ACTOR_STATE_WEAPONLESS_NORMAL = ACTOR_STATE_WEAPONLESS_START,
541 ACTOR_STATE_WEAPONLESS_GRENADE,
542 ACTOR_STATE_WEAPONLESS_LOOP
543};
544
545//
546// Animation think state
547//
548enum eActorState_Animation {
549 ACTOR_STATE_ANIMATION_START = ACTOR_STATE_ANIMATION,
550 ACTOR_STATE_ANIMATION_INITIAL = ACTOR_STATE_ANIMATION_START,
551 ACTOR_STATE_ANIMATION_MAIN,
552};
553
554//
555// Curious think state
556//
557enum eActorState_Curious {
558 ACTOR_STATE_CURIOUS_START = ACTOR_STATE_CURIOUS,
559 ACTOR_STATE_CURIOUS_BEGIN = ACTOR_STATE_CURIOUS_START,
560 ACTOR_STATE_CURIOUS_RUNNING
561};
562
563//
564// Machine gunner think state
565//
566enum eActorState_MachineGunner {
567 ACTOR_STATE_MACHINE_GUNNER_START = ACTOR_STATE_MACHINE_GUNNER,
568 ACTOR_STATE_MACHINE_GUNNER_READY = ACTOR_STATE_MACHINE_GUNNER_START,
569 ACTOR_STATE_MACHINE_GUNNER_RELOADING
570};
571
572//
573// Run and shoot think state
574//
575enum eActorState_RunAndShoot {
576 ACTOR_STATE_RUN_AND_SHOOT_START = ACTOR_STATE_RUN_AND_SHOOT,
577 ACTOR_STATE_RUN_AND_SHOOT_RUN = ACTOR_STATE_RUN_AND_SHOOT_START,
578 ACTOR_STATE_RUN_AND_SHOOT_RUNNING
579};
580
581class Actor;
582typedef SafePtr<Actor> ActorPtr;
583
584class Actor : public SimpleActor
585{
586 struct GlobalFuncs_t {
587 void (Actor::*ThinkState)(void);
588 void (Actor::*BeginState)(void);
589 void (Actor::*ResumeState)(void);
590 void (Actor::*EndState)(void);
591 void (Actor::*SuspendState)(void);
592 void (Actor::*RestartState)(void);
593 void (Actor::*FinishedAnimation)(void);
594 void (Actor::*PostShoot)(void);
595 void (Actor::*Pain)(Event *ev);
596 void (Actor::*Killed)(Event *ev, bool bPlayDeathAnim);
597 bool (Actor::*PassesTransitionConditions)(void);
598 void (Actor::*ShowInfo)(void);
599 void (Actor::*PathnodeClaimRevoked)(void);
600 void (Actor::*ReceiveAIEvent)(
601 vec3_t event_origin, int iType, Entity *originator, float fDistSquared, float fMaxDistSquared
602 );
603 bool (*IsState)(int state);
604 };
605
606public:
607 /* GlobalFuncs: contains different funcs needed for each actor think
608 * think is basically a mode for the actor
609 * when m_ThinkLevel changes, new think value is inside m_Think
610 * to access current think : m_Think[m_ThinkLevel]
611 * to access GlobalFuncs related to current think
612 * GlobalFuncs[m_Think[m_ThinkLevel]];
613 **/
614 static GlobalFuncs_t GlobalFuncs[NUM_THINKS];
615 /* const string array containig think names */
616 static const_str m_csThinkNames[NUM_THINKS];
617 /* const string array containig think state names */
618 static const_str m_csThinkStateNames[NUM_THINKSTATES];
619 /* map contating every think value for each thinkstate */
620 eThinkNum m_ThinkMap[NUM_THINKSTATES];
621 /* think state for every think level */
622 eThinkState m_ThinkStates[NUM_THINKLEVELS];
623 /* think value for every think level */
624 eThinkNum m_Think[NUM_THINKLEVELS];
625 /* current think level
626 * think levels are more like priorities
627 * highest level is used.
628 **/
629 eThinkLevel m_ThinkLevel;
630 /* current think state*/
631 eThinkState m_ThinkState;
632 /* current state (different than think state) */
633 int m_State;
634 /* current state change time */
635 int m_iStateTime;
636 /* should lock think state ? */
637 bool m_bLockThinkState;
638 /* think state changed */
639 bool m_bDirtyThinkState;
640 /* debug state for m_State */
641 const char *m_pszDebugState;
642 /* currently animating ( used in G_RunFrame ) */
643 bool m_bAnimating;
644 /* 2.0: ignore bad place? */
645 bool m_bIgnoreBadPlace;
646 /* 2.0: bad place index? (0=none) */
647 int m_iBadPlaceIndex;
648 /* char refereing to voice type, chec gAmericanVoices and gGermanVoices */
649 int mVoiceType;
650 /* check EV_Actor_GetSilent, EV_Actor_SetSilent and EV_Actor_SetSilent2 */
651 bool m_bSilent;
652 /* check EV_Actor_GetNoSurprise, EV_Actor_SetNoSurprise and EV_Actor_SetNoSurprise2 */
653 bool m_bNoSurprise;
654 /* actor can mumble ? */
655 bool m_bMumble;
656 /* actor is allowed to have steamy breath */
657 bool m_bBreathSteam;
658 /* const string of head model */
659 const_str m_csHeadModel;
660 /* const string of head skin */
661 const_str m_csHeadSkin;
662 /* const string of weapon model */
663 const_str m_csWeapon;
664 /* const string of REAL weapon model (check Actor::EventGiveWeapon) */
665 const_str m_csLoadOut;
666 /* favorite enemy */
667 SentientPtr m_FavoriteEnemy;
668 /* last time enemy was checked */
669 int m_iEnemyCheckTime;
670 /* last time enemy was changed */
671 int m_iEnemyChangeTime;
672 /* last time a visible(CanSee) enemy was checked */
673 int m_iEnemyVisibleCheckTime;
674 /* last time a visible(CanSee) enemy was changed */
675 int m_iEnemyVisibleChangeTime;
676 /* last time a visible(CanSee) enemy was seen */
677 int m_iLastEnemyVisibleTime;
678 /* 2.0: visibility alpha */
679 float m_fVisibilityAlpha;
680 /* 2.0: max visibility threshold */
681 float m_fVisibilityThreshold;
682 /* last time a visible(CanSee + infov) enemy was checked */
683 int m_iEnemyFovCheckTime;
684 /* last time a visible(CanSee + infov) enemy was changed */
685 int m_iEnemyFovChangeTime;
686 /* last known enemy position. */
687 Vector m_vLastEnemyPos;
688 /* last time enemy position was changed. */
689 int m_iLastEnemyPosChangeTime;
690 /* check EV_Actor_GetEnemyShareRange and EV_Actor_SetEnemyShareRange */
691 float m_fMaxShareDistSquared;
692 /* can actor shoot enemy ? */
693 bool m_bCanShootEnemy;
694 /* 2.0: does it has visibility threshold set? */
695 bool m_bHasVisibilityThreshold;
696 /* last time m_bCanShootEnemy was changed */
697 int m_iCanShootCheckTime;
698 /* desired enable enemy(changed from script) */
699 bool m_bDesiredEnableEnemy;
700 /* enable enemy (change from code only, Actor::UpdateEnableEnemy) */
701 bool m_bEnableEnemy;
702 /* can take pain ? */
703 bool m_bEnablePain;
704 /* allow long pain ? */
705 bool m_bNoLongPain;
706 /* last set enemy is new ? */
707 bool m_bNewEnemy;
708 /* is enemy disguised ? */
709 bool m_bEnemyIsDisguised;
710 /* is enemy visible (CanSee) ? */
711 bool m_bEnemyVisible;
712 /* is enemy in fov (CanSee) ? */
713 bool m_bEnemyInFOV;
714 /* attack player even if disguised. */
715 bool m_bForceAttackPlayer;
716 /* actor should avoud player (Actor::IdleThink) (get out of the players way) */
717 bool m_bAutoAvoidPlayer;
718 /* actor will not go into idle after playing an animation */
719 bool m_bNoIdleAfterAnim;
720 /* is anim script set ? */
721 bool m_bAnimScriptSet;
722 /* const string of anim script path */
723 const_str m_csAnimScript;
724 /* anim mode */
725 int m_AnimMode;
726 /* 2.0: the run anim rate */
727 float m_fRunAnimRate;
728 /* Don't Face Wall request yaw. */
729 float m_fDfwRequestedYaw;
730 /* Don't Face Wall derived yaw. */
731 float m_fDfwDerivedYaw;
732 /* Don't Face Wall derived position. */
733 Vector m_vDfwPos;
734 /* Don't Face Wall time. */
735 float m_fDfwTime;
736 /* last time GunPostiton() was called */
737 int m_iGunPositionCheckTime;
738 /* gun position */
739 Vector m_vGunPosition;
740 int m_iWallDodgeTimeout;
741 vec2_t m_PrevObstacleNormal;
742 char m_WallDir;
743 /* EV_Actor_SetMoveDoneRadius */
744 float m_fMoveDoneRadiusSquared;
745 /* last time origin was changed */
746 int m_iOriginTime;
747 /* should I face enemy ? */
748 bool m_bFaceEnemy;
749 /* physics on/off ? */
750 bool m_bDoPhysics;
751 /* should become runner/patrol guy */
752 bool m_bBecomeRunner;
753 /* If true, patrol guys and running men wait until triggered to move */
754 bool m_bPatrolWaitTrigger;
755 bool m_bScriptGoalValid;
756 Vector m_vScriptGoal;
757 int m_iNextWatchStepTime;
758 /* current patrol node */
759 SafePtr<SimpleEntity> m_patrolCurrentNode;
760 /* current patrol anim */
761 const_str m_csPatrolCurrentAnim;
762 int m_iSquadStandTime;
763 /* distance AI tries to keep between squadmates while moving. */
764 float m_fInterval;
765 int m_iIntervalDirTime;
766 /* the direction the AI would like to move to maintain its interval */
767 Vector m_vIntervalDir;
768 short m_sCurrentPathNodeIndex;
769 /* current pain state(similar to m_State) */
770 int m_PainState;
771 /* last time actor switched to curious state. */
772 int m_iCuriousTime;
773 /* Current level of curiousity. It's value is from PriorityForEventType() */
774 int m_iCuriousLevel;
775 int m_iCuriousAnimHint;
776 /* next time to check for state change to disguise. PassesTransitionConditions_Disguise() */
777 int m_iNextDisguiseTime;
778 /* EV_Actor_SetDisguisePeriod */
779 int m_iDisguisePeriod;
780 /* EV_Actor_SetDisguiseRange */
781 float m_fMaxDisguiseDistSquared;
782 /* next time enemy should show papers */
783 int m_iEnemyShowPapersTime;
784 /* the thread for actor when accepting papers */
785 ScriptThreadLabel m_DisguiseAcceptThread;
786 /* disguise level of the actor, might be 1 or 2 */
787 int m_iDisguiseLevel;
788 /* node for actor to raise alaram against player. */
789 SafePtr<SimpleEntity> m_AlarmNode;
790 /* alarm thread for actor */
791 ScriptThreadLabel m_AlarmThread;
792 /* 2.30: pre-alarm thread for actor */
793 ScriptThreadLabel m_PreAlarmThread;
794 /* 2.0: Suppress chance */
795 int m_iSuppressChance;
796 /* used for turret actot to run back to home Turret_SelectState() */
797 int m_iRunHomeTime;
798 /* no cover path for initial turret state */
799 bool m_bTurretNoInitialCover;
800 /* potential cover nodes */
801 PathNode *m_pPotentialCoverNode[MAX_COVER_NODES];
802 /* potential cover node count */
803 int m_iPotentialCoverCount;
804 /* current cover node */
805 PathNode *m_pCoverNode;
806 /* special cover node attack script. */
807 const_str m_csSpecialAttack;
808 /* actor is reloading */
809 bool m_bInReload;
810 /* actor needs reloading */
811 bool m_bNeedReload;
812 /* should break(stop) special attack ? */
813 bool mbBreakSpecialAttack;
814 /* 2.30: is the AI curious? */
815 bool m_bIsCurious;
816 /* grenade has bounced ? (usually means actor should flee) */
817 bool m_bGrenadeBounced;
818 /* current grenade */
819 SafePtr<Entity> m_pGrenade;
820 /* grenade position */
821 Vector m_vGrenadePos;
822 /* first time grenade was noticed */
823 int m_iFirstGrenadeTime;
824 /* grenade state */
825 eGrenadeState m_eGrenadeState;
826 /* grenade mode */
827 eGrenadeTossMode m_eGrenadeMode;
828 /* grenade velocity */
829 Vector m_vGrenadeVel;
830 /* grenade kick direction */
831 Vector m_vKickDir;
832 /* falling path */
833 FallPath *m_pFallPath;
834 /* minimum height a balcony guy must fall to do special balcony death */
835 float m_fBalconyHeight;
836 /* actor should not collide with player */
837 bool m_bNoPlayerCollision;
838 /* multiplier in time to notice an enemy */
839 float m_fNoticeTimeScale;
840 /* max multiplier in time to notice an enemy */
841 float m_fMaxNoticeTimeScale;
842 /* set of potential enemies */
843 ActorEnemySet m_PotentialEnemies;
844 /* vision distance of the actor */
845 float m_fSight;
846 /* hearing radius of the actor */
847 float m_fHearing;
848 /* EV_Actor_GetSoundAwareness */
849 float m_fSoundAwareness;
850 /* EV_Actor_GetGrenadeAwareness */
851 float m_fGrenadeAwareness;
852 /* mask of AI_EVENT* bits for the actor to ignore. */
853 int m_iIgnoreSoundsMask;
854 /* fov angle of the actor */
855 float m_fFov;
856 /* used for infov check */
857 float m_fFovDot;
858 /* eye update time */
859 int m_iEyeUpdateTime;
860 /* eye direction */
861 Vector m_vEyeDir;
862 /* next time to look around */
863 int m_iNextLookTime;
864 /* fov angle for look around */
865 float m_fLookAroundFov;
866 /* entity to look at */
867 SafePtr<SimpleEntity> m_pLookEntity;
868 /* look flags(should be a bool) */
869 int m_iLookFlags;
870 /* entity to point at */
871 SafePtr<SimpleEntity> m_pPointEntity;
872 /* entity to turn to */
873 SafePtr<SimpleEntity> m_pTurnEntity;
874 /* allowed error(difference) in angles after doing turnto command */
875 float m_fTurnDoneError;
876 /* turn speed of the actor */
877 float m_fAngleYawSpeed;
878 /* node to aim at */
879 SafePtr<SimpleEntity> m_aimNode;
880 /* dont face wall mode */
881 int m_eDontFaceWallMode;
882 int m_iLastFaceDecideTime;
883 /* origin history */
884 vec2_t m_vOriginHistory[MAX_ORIGIN_HISTORY];
885 /* current origin history index */
886 int m_iCurrentHistory;
887 bool m_bHeadAnglesAchieved;
888 bool m_bLUpperArmAnglesAchieved;
889 bool m_bTorsoAnglesAchieved;
890 bool align3;
891 /* max head turn speed */
892 float m_fHeadMaxTurnSpeed;
893 /* desired head angles */
894 vec3_t m_vHeadDesiredAngles;
895 /* up arm turn speed */
896 float m_fLUpperArmTurnSpeed;
897 /* upper arm desired angles */
898 vec3_t m_vLUpperArmDesiredAngles;
899 /* max torso turn speed */
900 float m_fTorsoMaxTurnSpeed;
901 /* currnet torso turn speed */
902 float m_fTorsoCurrentTurnSpeed;
903 /* desired torso angles */
904 vec3_t m_vTorsoDesiredAngles;
905 /* global body queue */
906 static SafePtr<Actor> mBodyQueue[MAX_BODYQUEUE];
907 /* current body queue index */
908 static int mCurBody;
909 /* leash home */
910 Vector m_vHome;
911 /* tether entity */
912 SafePtr<SimpleEntity> m_pTetherEnt;
913 /* minimum distance actor tries to keep between itself and the player */
914 float m_fMinDistance;
915 /* square of minimum distance actor tries to keep between itself and the player */
916 float m_fMinDistanceSquared;
917 /* maximum distance actor tries to allow between itself and the player */
918 float m_fMaxDistance;
919 /* square of maximum distance actor tries to allow between itself and the player */
920 float m_fMaxDistanceSquared;
921 /* maximum distance actor will wander from its leash home */
922 float m_fLeash;
923 /* square of maximum distance actor will wander from its leash home */
924 float m_fLeashSquared;
925 /* if true, leash will not change. */
926 bool m_bFixedLeash;
927 /* 2.0: if true, enemy switch will be disabled. */
928 bool m_bEnemySwitch;
929 /* 2.30: the nationality index. */
930 int m_iNationality;
931
932public:
933 CLASS_PROTOTYPE(Actor);
934
935protected:
936 void MoveTo(Event *ev);
937 void WalkTo(Event *ev);
938 void RunTo(Event *ev);
939 void CrouchTo(Event *ev);
940 void CrawlTo(Event *ev);
941 void AimAt(Event *ev);
942 void DefaultRestart(void);
943 void SuspendState(void);
944 void ResumeState(void);
945 void BeginState(void);
946 void EndState(int level);
947 void RestartState(void);
948
949public:
950 Actor();
951 ~Actor();
952
953 virtual void setContentsSolid(void) override;
954 void InitThinkStates(void);
955 void UpdateEyeOrigin(void);
956 bool RequireThink(void);
957 void UpdateEnemy(int iMaxDirtyTime);
958 void UpdateEnemyInternal(void);
959 void DetectSmokeGrenades(void);
960 void SetEnemy(Sentient *pEnemy, bool bForceConfirmed);
961 void SetEnemyPos(Vector vPos);
962 static void ResetBodyQueue(void);
963 void AddToBodyQue(void);
964 Vector GetAntiBunchPoint(void);
965 static void InitVoid(GlobalFuncs_t *func);
966 virtual const char *DumpCallTrace(const char *pszFmt, ...) const override;
967 static void Init(void);
968 void FixAIParameters(void);
969 bool AttackEntryAnimation(void);
970 void CheckForThinkStateTransition(void);
971 bool CheckForTransition(eThinkState state, eThinkLevel level);
972 bool PassesTransitionConditions_Grenade(void);
973 bool PassesTransitionConditions_BadPlace(void); // Added in 2.0
974 bool PassesTransitionConditions_Attack(void);
975 bool PassesTransitionConditions_Disguise(void);
976 bool PassesTransitionConditions_Curious(void);
977 bool PassesTransitionConditions_Idle(void);
978 void UpdateEnableEnemy(void);
979 void ThinkStateTransitions(void);
980 void TransitionState(int iNewState, int iPadTime = 0);
981 void ChangeAnim(void);
982 void UpdateSayAnim(void);
983 void UpdateUpperAnim(void);
984 void UpdateAnim(void);
985 virtual void StoppedWaitFor(const_str name, bool bDeleting) override;
986 static void InitTurret(GlobalFuncs_t *func);
987 void Begin_Turret(void);
988 void End_Turret(void);
989 void Suspend_Turret(void);
990 void Think_Turret(void);
991 void FinishedAnimation_Turret(void);
992 void ReceiveAIEvent_Turret(
993 vec3_t event_origin, int iType, Entity *originator, float fDistSquared, float fMaxDistSquared
994 );
995 void InterruptPoint_Turret(void);
996 void PathnodeClaimRevoked_Turret(void);
997 bool Turret_IsRetargeting(void) const;
998 bool Turret_DecideToSelectState(void);
999 void Turret_SelectState(void);
1000 bool Turret_CheckRetarget(void);
1001 bool Turret_TryToBecomeCoverGuy(void);
1002 void Turret_BeginRetarget(void);
1003 void Turret_NextRetarget(void);
1004 void Turret_SideStep(int iStepSize, vec3_t vDir);
1005 void State_Turret_Combat(void);
1006 void State_Turret_Reacquire(void);
1007 void State_Turret_TakeSniperNode(void);
1008 void State_Turret_SniperNode(void);
1009 bool State_Turret_RunHome(bool bAttackOnFail);
1010 void State_Turret_RunAway(void);
1011 void State_Turret_Charge(void);
1012 void State_Turret_Grenade(void);
1013 void State_Turret_FakeEnemy(void);
1014 void State_Turret_Wait(void);
1015 void State_Turret_Shoot(void); // Added in 2.0
1016 void State_Turret_Retarget_Suppress(void); // Added in 2.0
1017 void State_Turret_Retarget_Sniper_Node(void);
1018 void State_Turret_Retarget_Step_Side_Small(void);
1019 void State_Turret_Retarget_Path_Exact(void);
1020 void State_Turret_Retarget_Path_Near(void);
1021 void State_Turret_Retarget_Step_Side_Medium(void);
1022 void State_Turret_Retarget_Step_Side_Large(void);
1023 void State_Turret_Retarget_Step_Face_Medium(void);
1024 void State_Turret_Retarget_Step_Face_Large(void);
1025 static void InitCover(GlobalFuncs_t *func);
1026 bool Cover_IsValid(PathNode *node);
1027 bool Cover_SetPath(PathNode *node);
1028 void Cover_FindCover(bool bCheckAll);
1029 void Begin_Cover(void);
1030 void End_Cover(void);
1031 void Suspend_Cover(void);
1032 void Think_Cover(void);
1033 void FinishedAnimation_Cover(void);
1034 void PathnodeClaimRevoked_Cover(void);
1035 void State_Cover_NewEnemy(void);
1036 void State_Cover_FindCover(void);
1037 void State_Cover_TakeCover(void);
1038 void State_Cover_FinishReloading(void);
1039 void State_Cover_SpecialAttack(void);
1040 void State_Cover_Target(void);
1041 void State_Cover_Hide(void);
1042 void State_Cover_Shoot(void);
1043 void State_Cover_Grenade(void);
1044 void State_Cover_FindEnemy(void);
1045 void State_Cover_SearchNode(void);
1046 void State_Cover_HuntEnemy(void);
1047 void State_Cover_FakeEnemy(void);
1048 static void InitPatrol(GlobalFuncs_t *func);
1049 void Begin_Patrol(void);
1050 void End_Patrol(void);
1051 void Resume_Patrol(void);
1052 void Think_Patrol(void);
1053 void ShowInfo_Patrol(void);
1054 void IdleThink(void);
1055 static void InitRunner(GlobalFuncs_t *func);
1056 void Begin_Runner(void);
1057 void End_Runner(void);
1058 void Resume_Runner(void);
1059 void Think_Runner(void);
1060 void ShowInfo_Runner(void);
1061 static void InitAlarm(GlobalFuncs_t *func);
1062 void Begin_Alarm(void);
1063 void End_Alarm(void);
1064 void State_Alarm_StartThread(void);
1065 void State_Alarm_Move(void);
1066 void State_Alarm_Idle(void);
1067 void Think_Alarm(void);
1068 void FinishedAnimation_Alarm(void);
1069 static void InitNoClip(GlobalFuncs_t *func);
1070 bool IsNoClipState(int state);
1071 void Think_NoClip(void);
1072 bool ValidGrenadePath(const Vector &vFrom, const Vector &vTo, Vector &vVel);
1073 static Vector CalcThrowVelocity(const Vector& vFrom, const Vector& vTo);
1074 Vector CanThrowGrenade(const Vector &vFrom, const Vector &vTo);
1075 static Vector CalcRollVelocity(const Vector& vFrom, const Vector& vTo);
1076 Vector CanRollGrenade(const Vector &vFrom, const Vector &vTo);
1077 bool CanTossGrenadeThroughHint(
1078 GrenadeHint *pHint,
1079 const Vector &vFrom,
1080 const Vector &vTo,
1081 bool bDesperate,
1082 Vector *pvVel,
1083 eGrenadeTossMode *peMode
1084 );
1085 static Vector GrenadeThrowPoint(const Vector& vFrom, const Vector& vDelta, const_str csAnim);
1086 Vector CalcKickVelocity(Vector &vDelta, float fDist) const;
1087 bool CanKickGrenade(Vector &vFrom, Vector &vTo, Vector &vFace, Vector *pvVel);
1088 bool GrenadeWillHurtTeamAt(const Vector &vTo);
1089 bool CanGetGrenadeFromAToB(
1090 const Vector &vFrom, const Vector &vTo, bool bDesperate, Vector *pvVel, eGrenadeTossMode *peMode
1091 );
1092 bool DecideToThrowGrenade(const Vector &vTo, Vector *pvVel, eGrenadeTossMode *peMode, bool bDesperate);
1093 void Grenade_EventFire(Event *ev);
1094 void GenericGrenadeTossThink(void);
1095 static void InitGrenade(GlobalFuncs_t *func);
1096 bool Grenade_Acquire(eGrenadeState eNextState, const_str csReturnAnim);
1097 void Grenade_Flee(void);
1098 void Grenade_ThrowAcquire(void);
1099 void Grenade_Throw(void);
1100 void Grenade_KickAcquire(void);
1101 void Grenade_Kick(void);
1102 void Grenade_MartyrAcquire(void);
1103 void Grenade_Martyr(void);
1104 void Grenade_Wait(void);
1105 void Grenade_NextThinkState(void);
1106 void Grenade_EventAttach(Event *ev);
1107 void Grenade_EventDetach(Event *ev);
1108 void Begin_Grenade(void);
1109 void End_Grenade(void);
1110 void Resume_Grenade(void);
1111 void Think_Grenade(void);
1112 void FinishedAnimation_Grenade(void);
1113 static void InitCurious(GlobalFuncs_t *func);
1114 void SetCuriousAnimHint(int iAnimHint);
1115 void Begin_Curious(void);
1116 void End_Curious(void);
1117 void Resume_Curious(void);
1118 void Suspend_Curious(void);
1119 void Think_Curious(void);
1120 void FinishedAnimation_Curious(void);
1121 void LookAtCuriosity(void);
1122 void TimeOutCurious(void);
1123 void State_Disguise_Wait(void);
1124 void State_Disguise_Papers(void);
1125 void State_Disguise_Fake_Papers(void);
1126 void State_Disguise_Enemy(void);
1127 void State_Disguise_Halt(void);
1128 void State_Disguise_Accept(void);
1129 void State_Disguise_Deny(void);
1130 static void InitDisguiseSalute(GlobalFuncs_t *func);
1131 void Begin_DisguiseSalute(void);
1132 void End_DisguiseSalute(void);
1133 void Resume_DisguiseSalute(void);
1134 void Suspend_DisguiseSalute(void);
1135 void Think_DisguiseSalute(void);
1136 void FinishedAnimation_DisguiseSalute(void);
1137 static void InitDisguiseSentry(GlobalFuncs_t *func);
1138 void Begin_DisguiseSentry(void);
1139 void End_DisguiseSentry(void);
1140 void Resume_DisguiseSentry(void);
1141 void Suspend_DisguiseSentry(void);
1142 void Think_DisguiseSentry(void);
1143 static void InitDisguiseOfficer(GlobalFuncs_t *func);
1144 void Begin_DisguiseOfficer(void);
1145 void End_DisguiseOfficer(void);
1146 void Resume_DisguiseOfficer(void);
1147 void Suspend_DisguiseOfficer(void);
1148 void Think_DisguiseOfficer(void);
1149 static void InitDisguiseRover(GlobalFuncs_t *func);
1150 void Begin_DisguiseRover(void);
1151 void End_DisguiseRover(void);
1152 void Resume_DisguiseRover(void);
1153 void Suspend_DisguiseRover(void);
1154 void Think_DisguiseRover(void);
1155 static void InitDisguiseNone(GlobalFuncs_t *func);
1156 static void InitIdle(GlobalFuncs_t *func);
1157 void Begin_Idle(void);
1158 void Think_Idle(void);
1159 static void InitMachineGunner(GlobalFuncs_t *func);
1160 void Begin_MachineGunner(void);
1161 void End_MachineGunner(void);
1162 void BecomeTurretGuy(void);
1163 void ThinkHoldGun_TurretGun(void); // Added in 2.0
1164 void Think_MachineGunner_TurretGun(void); // Added in 2.0
1165 void Think_MachineGunner(void);
1166 void FinishedAnimation_MachineGunner(void);
1167 bool MachineGunner_CanSee(Entity *ent, float fov, float vision_distance);
1168 static void InitDogIdle(GlobalFuncs_t *func);
1169 static void InitDogAttack(GlobalFuncs_t *func);
1170 static void InitDogCurious(GlobalFuncs_t *func);
1171 void Begin_Dog(void);
1172 void End_Dog(void);
1173 void Think_Dog_Idle(void);
1174 void Think_Dog_Attack(void);
1175 void Think_Dog_Curious(void);
1176 static void InitAnim(GlobalFuncs_t *func);
1177 void Begin_Anim(void);
1178 void Think_Anim(void);
1179 void FinishedAnimation_Anim(void);
1180 void ShowInfo_Anim(void);
1181 static void InitAnimCurious(GlobalFuncs_t *func);
1182 void Begin_AnimCurious(void);
1183 void Think_AnimCurious(void);
1184 void FinishedAnimation_AnimCurious(void);
1185 static void InitAim(GlobalFuncs_t *func);
1186 void Begin_Aim(void);
1187 void Think_Aim(void);
1188 void ShowInfo_Aim(void);
1189 static void InitBalconyIdle(GlobalFuncs_t *func);
1190 static void InitBalconyCurious(GlobalFuncs_t *func);
1191 static void InitBalconyAttack(GlobalFuncs_t *func);
1192 static void InitBalconyDisguise(GlobalFuncs_t *func);
1193 static void InitBalconyGrenade(GlobalFuncs_t *func);
1194 static void InitBalconyPain(GlobalFuncs_t *func);
1195 static void InitBalconyKilled(GlobalFuncs_t *func);
1196 void Pain_Balcony(Event *ev);
1197 void Killed_Balcony(Event *ev, bool bPlayDeathAnim);
1198 void Think_BalconyAttack(void);
1199 void Begin_BalconyAttack(void);
1200 void FinishedAnimation_BalconyAttack(void);
1201 void State_Balcony_PostShoot(void);
1202 void State_Balcony_FindEnemy(void);
1203 void State_Balcony_Target(void);
1204 void State_Balcony_Shoot(void);
1205 void Begin_BalconyKilled(void);
1206 void End_BalconyKilled(void);
1207 void Think_BalconyKilled(void);
1208 void FinishedAnimation_BalconyKilled(void);
1209 bool CalcFallPath(void);
1210 static void InitPain(GlobalFuncs_t *func);
1211 void Begin_Pain(void);
1212 void Think_Pain(void);
1213 void FinishedAnimation_Pain(void);
1214 static void InitDead(GlobalFuncs_t *func);
1215 static void InitKilled(GlobalFuncs_t *func);
1216 void Begin_Killed(void);
1217 void Think_Killed(void);
1218 void FinishedAnimation_Killed(void);
1219 static void InitWeaponless(GlobalFuncs_t *func);
1220 void Begin_Weaponless(void);
1221 void Suspend_Weaponless(void);
1222 void Think_Weaponless(void);
1223 void FinishedAnimation_Weaponless(void);
1224 void State_Weaponless_Normal(void);
1225 void State_Weaponless_Grenade(void);
1226 static void InitBadPlace(GlobalFuncs_t *func);
1227 // Added in 2.0
1228 //====
1229 void Begin_BadPlace(void);
1230 void End_BadPlace(void);
1231 void Think_BadPlace(void);
1232 //====
1233 // Added in 2.30
1234 //====
1235 static void InitRunAndShoot(GlobalFuncs_t *func);
1236 void Begin_RunAndShoot(void);
1237 void End_RunAndShoot(void);
1238 void Resume_RunAndShoot(void);
1239 void Think_RunAndShoot(void);
1240 void ShowInfo_RunAndShoot(void);
1241 void State_RunAndShoot_Running(void);
1242 bool RunAndShoot_MoveToPatrolCurrentNode(void);
1243 //====
1244 virtual void Think(void) override;
1245 void PostThink(bool bDontFaceWall);
1246 virtual void SetMoveInfo(mmove_t *mm) override;
1247 virtual void GetMoveInfo(mmove_t *mm) override;
1248 void DoFailSafeMove(vec3_t dest);
1249 void TouchStuff(mmove_t *mm);
1250 void ExtractConstraints(mmove_t *mm);
1251 void EventGiveWeaponInternal(Event *ev);
1252 void EventGiveWeapon(Event *ev);
1253 void EventGetWeapon(Event *ev);
1254 void FireWeapon(Event *ev);
1255 bool FriendlyInLineOfFire(Entity *other); // Added in 2.0
1256 Vector VirtualEyePosition(); // Added in 2.0
1257 virtual bool CanTarget(void) override;
1258 virtual bool IsImmortal(void) override;
1259 static bool IsVoidState(int state);
1260 static bool IsIdleState(int state);
1261 static bool IsCuriousState(int state);
1262 static bool IsDisguiseState(int state);
1263 static bool IsAttackState(int state);
1264 static bool IsGrenadeState(int state);
1265 static bool IsBadPlaceState(int state); // Added in 2.0
1266 static bool IsPainState(int state);
1267 static bool IsKilledState(int state);
1268 static bool IsMachineGunnerState(int state);
1269 static bool IsDogState(int state);
1270 void IgnoreSoundSet(int iType);
1271 void IgnoreSoundSetAll(void);
1272 void IgnoreSoundClear(int iType);
1273 void IgnoreSoundClearAll(void);
1274 bool IgnoreSound(int iType);
1275 void EventShareEnemy(Event *ev);
1276 void EventShareGrenade(Event *ev);
1277 void ReceiveAIEvent(vec3_t event_origin, int iType, Entity *originator, float fDistSquared, float fMaxDistSquared);
1278 void DefaultReceiveAIEvent(
1279 vec3_t event_origin, int iType, Entity *originator, float fDistSquared, float fMaxDistSquared
1280 );
1281 int PriorityForEventType(int iType);
1282 void CuriousSound(int iType, vec3_t sound_origin, float fDistSquared, float fMaxDistSquared);
1283 void WeaponSound(int iType, vec3_t sound_origin, float fDistSquared, float fMaxDistSquared, Entity *originator);
1284 void FootstepSound(vec3_t sound_origin, float fDistSquared, float fMaxDistSquared, Entity *originator);
1285 void VoiceSound(int iType, vec3_t sound_origin, float fDistSquared, float fMaxDistSquared, Entity *originator);
1286 void GrenadeNotification(Entity *originator);
1287 void SetGrenade(Entity *pGrenade);
1288 void UpdateBadPlaces(void); // Added in 2.0
1289 void NotifySquadmateKilled(Sentient *pSquadMate, Sentient *pAttacker);
1290 void RaiseAlertnessForEventType(int iType);
1291 void RaiseAlertness(float fAmount);
1292 virtual bool CanSee(Entity *e1, float fov, float vision_distance, bool bNoEnts) override;
1293 using Sentient::CanSee;
1294 virtual Vector GunPosition(void) override;
1295 bool WithinVisionDistance(Entity *ent) const;
1296 bool InFOV(Vector pos, float check_fov, float check_fovdot);
1297 bool EnemyInFOV(int iMaxDirtyTime);
1298 bool InFOV(Vector pos);
1299 bool InFOV(Entity *ent);
1300 bool CanSeeNoFOV(Entity *ent);
1301 bool CanSeeFOV(Entity *ent);
1302 bool CanSeeEnemyFOV(int iMaxFovDirtyTime, int iMaxSightDirtyTime);
1303 bool CanShoot(Entity *ent);
1304 virtual bool CanSeeFrom(vec3_t pos, Entity *ent);
1305 bool CanSeeEnemy(int iMaxDirtyTime);
1306 bool CanShootEnemy(int iMaxDirtyTime);
1307 void ShowInfo(void);
1308 virtual void ShowInfo(float fDot, float fDist) override;
1309 void DefaultPain(Event *ev);
1310 void HandlePain(Event *ev);
1311 void EventPain(Event *ev);
1312 void DefaultKilled(Event *ev, bool bPlayDeathAnim);
1313 void HandleKilled(Event *ev, bool bPlayDeathAnim);
1314 void DispatchEventKilled(Event *ev, bool bPlayDeathAnim);
1315 void EventKilled(Event *ev);
1316 void EventBeDead(Event *ev);
1317 void DeathEmbalm(Event *ev);
1318 void DeathSinkStart(Event *ev);
1319 bool NoticeShot(Sentient *pShooter, Sentient *pTarget, float fDist);
1320 bool NoticeFootstep(Sentient *pPedestrian);
1321 bool NoticeVoice(Sentient *pVocallist);
1322 void ClearLookEntity(void);
1323 void LookAt(const Vector &vec);
1324 void LookAt(Listener *l);
1325 void ForwardLook(void);
1326 void LookAtLookEntity(void);
1327 void IdleLook(void);
1328 void IdleLook(vec3_t dir);
1329 void SetDesiredLookDir(vec3_t dir);
1330 void SetDesiredLookAnglesRelative(vec3_t ang);
1331 void EventLookAt(Event *ev);
1332 void EventEyesLookAt(Event *ev);
1333 void NoPoint(void);
1334 void IdlePoint(void);
1335 void ClearPointEntity(void);
1336 void PointAt(const Vector &vec);
1337 void PointAt(Listener *l);
1338 void EventPointAt(Event *ev);
1339 void ClearTurnEntity(void);
1340 void TurnTo(const Vector &vec);
1341 void TurnTo(Listener *l);
1342 void IdleTurn(void);
1343 void EventTurnTo(Event *ev);
1344 void EventSetTurnDoneError(Event *ev);
1345 void EventGetTurnDoneError(Event *ev);
1346 void LookAround(float fFovAdd);
1347 bool SoundSayAnim(const_str name, byte bLevelSayAnim);
1348 void EventSetAnim(Event *ev);
1349 void EventIdleSayAnim(Event *ev);
1350 void EventSayAnim(Event *ev);
1351 void EventSetSayAnim(Event *ev);
1352 void EventSetMotionAnim(Event *ev);
1353 void EventSetAimMotionAnim(Event *ev);
1354 void EventSetActionAnim(Event *ev);
1355 void EventUpperAnim(Event *ev);
1356 void EventSetUpperAnim(Event *ev);
1357 void EventEndActionAnim(Event *ev);
1358 void EventDamagePuff(Event *ev);
1359 void SafeSetOrigin(vec3_t newOrigin);
1360 void DoMove(void);
1361 void AnimFinished(int slot, bool stop);
1362 virtual void AnimFinished(int slot) override;
1363 void PlayAnimation(Event *ev);
1364 void PlayScriptedAnimation(Event *ev);
1365 void PlayNoclipAnimation(Event *ev);
1366 void PlayAttachedAnimation(Event *ev); // Added in 2.0
1367 void MoveDest(float fMoveSpeed);
1368 void MovePath(float fMoveSpeed);
1369 void MovePathGoal(float fMoveSpeed);
1370 void Dumb(Event *ev);
1371 void PhysicsOn(Event *ev);
1372 void PhysicsOff(Event *ev);
1373 void EventStart(Event *ev);
1374 void EventGetMood(Event *ev);
1375 void EventSetMood(Event *ev);
1376 void EventGetAngleYawSpeed(Event *ev);
1377 void EventSetAngleYawSpeed(Event *ev);
1378 void EventSetAimTarget(Event *ev);
1379 void UpdateAngles(void);
1380 void SetLeashHome(Vector vHome);
1381 void AimAtTargetPos(void);
1382 void AimAtAimNode(void);
1383 void AimAtEnemyBehavior(void);
1384 void FaceMotion(void);
1385 void FaceDirectionDuringMotion(vec3_t vLook);
1386 float PathDistanceAlongVector(vec3_t vDir);
1387 void FaceEnemyOrMotion(int iTimeIntoMove);
1388 static int NextUpdateTime(int iLastUpdateTime, int iUpdatePeriod);
1389 void ResetBoneControllers(void);
1390 void UpdateBoneControllers(void);
1391 void ReadyToFire(Event *ev);
1392 void EventGetSight(Event *ev);
1393 void EventSetSight(Event *ev);
1394 void EventGetHearing(Event *ev);
1395 void EventSetHearing(Event *ev);
1396 void ClearPatrolCurrentNode(void);
1397 void NextPatrolCurrentNode(void);
1398 void SetPatrolCurrentNode(Vector &vec);
1399 void SetPatrolCurrentNode(Listener *l);
1400 void EventSetPatrolPath(Event *ev);
1401 void EventGetPatrolPath(Event *ev);
1402 void EventSetPatrolWaitTrigger(Event *ev);
1403 void EventGetPatrolWaitTrigger(Event *ev);
1404 void ShowInfo_PatrolCurrentNode(void);
1405 bool MoveOnPathWithSquad(void);
1406 bool MoveToWaypointWithPlayer(void);
1407 bool PatrolNextNodeExists(void);
1408 void UpdatePatrolCurrentNode(void);
1409 bool MoveToPatrolCurrentNode(void);
1410 void ClearAimNode(void);
1411 void SetAimNode(const Vector &vec);
1412 void SetAimNode(Listener *l);
1413 void ShowInfo_AimNode(void);
1414 void EventSetAccuracy(Event *ev);
1415 void EventGetAccuracy(Event *ev);
1416 int GetThinkType(const_str csName);
1417 void SetThink(eThinkState state, eThinkNum think);
1418 void SetThinkIdle(eThinkNum think_idle);
1419 void SetThinkState(eThinkState state, eThinkLevel level);
1420 void EndCurrentThinkState(void);
1421 void ClearThinkStates(void);
1422 int CurrentThink(void) const;
1423 bool IsAttacking(void) const;
1424 void EventGetFov(Event *ev);
1425 void EventSetFov(Event *ev);
1426 void EventSetDestIdle(Event *ev);
1427 void EventSetDestIdle2(Event *ev);
1428 void EventSetTypeIdle(Event *ev);
1429 void EventGetTypeIdle(Event *ev);
1430 void EventSetTypeAttack(Event *ev);
1431 void EventGetTypeAttack(Event *ev);
1432 void EventSetTypeDisguise(Event *ev);
1433 void EventGetTypeDisguise(Event *ev);
1434 void EventSetDisguiseLevel(Event *ev);
1435 void EventGetDisguiseLevel(Event *ev);
1436 void EventSetTypeGrenade(Event *ev);
1437 void EventGetTypeGrenade(Event *ev);
1438 void EventSetMinDistance(Event *ev);
1439 void EventGetMinDistance(Event *ev);
1440 void EventSetMaxDistance(Event *ev);
1441 void EventGetMaxDistance(Event *ev);
1442 void EventGetLeash(Event *ev);
1443 void EventSetLeash(Event *ev);
1444 void EventGetInterval(Event *ev);
1445 void EventSetInterval(Event *ev);
1446 void EventDistToEnemy(Event *ev);
1447 void EventGetRunAnim(Event *ev);
1448 void EventGetWalkAnim(Event *ev);
1449 void EventGetAnimName(Event *ev);
1450 void EventSetAnimName(Event *ev);
1451 void EventSetDisguiseRange(Event *ev);
1452 void EventGetDisguiseRange(Event *ev);
1453 void EventSetDisguisePeriod(Event *ev);
1454 void EventGetDisguisePeriod(Event *ev);
1455 void EventSetDisguiseAcceptThread(Event *ev);
1456 void EventGetDisguiseAcceptThread(Event *ev);
1457 void EventAttackPlayer(Event *ev);
1458 void ForceAttackPlayer(void);
1459 void EventSetAlarmNode(Event *ev);
1460 void EventGetAlarmNode(Event *ev);
1461 void EventSetPreAlarmThread(Event *ev); // Added in 2.30
1462 void EventSetAlarmThread(Event *ev);
1463 void EventGetAlarmThread(Event *ev);
1464 void EventSetSoundAwareness(Event *ev);
1465 void EventGetSoundAwareness(Event *ev);
1466 void EventSetGrenadeAwareness(Event *ev);
1467 void EventGetGrenadeAwareness(Event *ev);
1468 str ThinkName(void) const;
1469 str ThinkStateName(void) const;
1470 void EventSetTurret(Event *ev);
1471 void EventGetTurret(Event *ev);
1472 void EventEnableEnemy(Event *ev);
1473 void EventEnablePain(Event *ev);
1474 void EventActivate(Event *ev);
1475 void EventGetAmmoGrenade(Event *ev);
1476 void EventSetAmmoGrenade(Event *ev);
1477 void EventInterruptPoint(Event *ev);
1478 // Added in 2.0
1479 //====
1480 void EventGetVisibilityThreshold(Event *ev);
1481 void EventSetVisibilityThreshold(Event *ev);
1482 void EventSetDefaultVisibilityThreshold(Event *ev);
1483 void EventGetSuppressChance(Event *ev);
1484 void EventSetSuppressChance(Event *ev);
1485 //====
1486 void EventAnimScript(Event *ev);
1487 void EventAnimScript_Scripted(Event *ev);
1488 void EventAnimScript_Noclip(Event *ev);
1489 void EventAnimScript_Attached(Event *ev);
1490 void EventReload_mg42(Event *ev);
1491 void SetPathWithLeash(Vector vDestPos, const char *description, int iMaxDirtyTime);
1492 void SetPathWithLeash(SimpleEntity *pDestNode, const char *description, int iMaxDirtyTime);
1493 void FindPathAwayWithLeash(vec3_t vAwayFrom, vec3_t vDirPreferred, float fMinSafeDist);
1494 void FindPathNearWithLeash(vec3_t vNearbyTo, float fCloseDistSquared);
1495 bool CanMovePathWithLeash(void) const;
1496 bool MovePathWithLeash(void);
1497 bool ShortenPathToAttack(float fMinDist);
1498 void StrafeToAttack(float fDist, vec3_t vDir);
1499 virtual Vector GunTarget(bool bNoCollision, const vec3_t position, const vec3_t forward) override;
1500 virtual qboolean setModel(void) override;
1501 void EventSetHeadModel(Event *ev);
1502 void EventGetHeadModel(Event *ev);
1503 void EventSetHeadSkin(Event *ev);
1504 void EventGetHeadSkin(Event *ev);
1505 void EventSetNoIdle(Event *ev);
1506 void EventGetNoIdle(Event *ev);
1507 void EventGetEnemy(Event *ev);
1508 void EventSetMaxNoticeTimeScale(Event *ev);
1509 void EventGetMaxNoticeTimeScale(Event *ev);
1510 void EventSetFixedLeash(Event *ev);
1511 void EventGetFixedLeash(Event *ev);
1512 void Holster(void);
1513 void HolsterOffHand(void); // Added in 2.0
1514 void Unholster(void);
1515 void UnholsterOffHand(void); // Added in 2.0
1516 void EventHolster(Event *ev);
1517 void EventUnholster(Event *ev);
1518 void EventSoundDone(Event *ev);
1519 void EventSound(Event *ev);
1520 void EventIsEnemyVisible(Event *ev);
1521 void EventGetEnemyVisibleChangeTime(Event *ev);
1522 void EventGetLastEnemyVisibleTime(Event *ev);
1523 void EventSetFallHeight(Event *ev);
1524 void EventGetFallHeight(Event *ev);
1525 void EventCanMoveTo(Event *ev);
1526 void EventMoveDir(Event *ev);
1527 void EventIntervalDir(Event *ev);
1528 void EventResetLeash(Event *ev);
1529 void EventTether(Event *ev);
1530 void EventGetThinkState(Event *ev);
1531 void EventGetEnemyShareRange(Event *ev);
1532 void EventSetEnemyShareRange(Event *ev);
1533 void EventGetKickDir(Event *ev);
1534 void EventGetNoLongPain(Event *ev);
1535 void EventSetNoLongPain(Event *ev);
1536 void EventGetFavoriteEnemy(Event *ev);
1537 void EventSetFavoriteEnemy(Event *ev);
1538 void EventFindEnemy(Event *ev); // Added in 2.0
1539 void EventGetMumble(Event *ev);
1540 void EventSetMumble(Event *ev);
1541 void EventGetBreathSteam(Event *ev);
1542 void EventSetBreathSteam(Event *ev);
1543 void EventSetNextBreathTime(Event *ev);
1544 void EventCalcGrenadeToss2(Event *ev);
1545 void EventCalcGrenadeToss(Event *ev);
1546 void EventGetNoSurprise(Event *ev);
1547 void EventSetNoSurprise(Event *ev);
1548 void EventGetSilent(Event *ev);
1549 void EventSetSilent(Event *ev);
1550 void EventGetAvoidPlayer(Event *ev);
1551 void EventSetAvoidPlayer(Event *ev);
1552 void EventGetLookAroundAngle(Event *ev);
1553 void EventSetLookAroundAngle(Event *ev);
1554 void EventHasCompleteLookahead(Event *ev);
1555 void EventPathDist(Event *ev);
1556 void EventCanShootEnemyFrom(Event *ev);
1557 void EventCanShoot(Event *ev);
1558 void EventSetInReload(Event *ev);
1559 void EventGetInReload(Event *ev);
1560 void EventSetReloadCover(Event *ev);
1561 void EventBreakSpecial(Event *ev);
1562 void GetVoiceType(Event *ev);
1563 void SetVoiceType(Event *ev);
1564 void ResolveVoiceType(void);
1565 void EventSetBalconyHeight(Event *ev);
1566 void EventGetBalconyHeight(Event *ev);
1567 // Added in 2.0
1568 //====
1569 void EventSetIgnoreBadPlace(Event *ev);
1570 void EventGetIgnoreBadPlace(Event *ev);
1571 void EventEnableEnemySwitch(Event *ev);
1572 void EventDisableEnemySwitch(Event *ev);
1573 void EventSetRunAnimRate(Event *ev);
1574 void EventGetRunAnimRate(Event *ev);
1575 void Landed(Event *ev);
1576 bool IsOnFloor(void);
1577 //====
1578 // Added in 2.30
1579 //====
1580 void GetNationality(Event *ev);
1581 void SetNationality(Event *ev);
1582 void EventWriteStats(Event *ev);
1583 void EventCuriousOff(Event *ev);
1584 void EventCuriousOn(Event *ev);
1585 //====
1586 PathNode *FindSniperNodeAndSetPath(bool *pbTryAgain);
1587 void Remove(Event *ev);
1588 void DontFaceWall(void);
1589 bool AvoidingFacingWall(void) const;
1590 void EndStates(void);
1591 void ClearStates(void);
1592 void CheckUnregister(void);
1593 void BecomeCorpse(void);
1594 virtual void PathnodeClaimRevoked(PathNode *node) override;
1595 void SetPathToNotBlockSentient(Sentient *pOther);
1596 void EventSetMoveDoneRadius(Event *ev);
1597 void EventGetMoveDoneRadius(Event *ev); // Added in 2.0
1598 virtual void ClearEnemies(void) override;
1599 bool EnemyIsDisguised(void);
1600 virtual void setOriginEvent(Vector org) override;
1601 virtual void DumpAnimInfo(void) override;
1602 static void ArchiveStatic(Archiver &arc);
1603 virtual void Archive(Archiver& arc) override;
1604 virtual bool AutoArchiveModel(void) override;
1605 virtual bool IsDisabled() const override; // Added in 2.30
1606};
1607
1608#define SAVE_FLAG_NEW_ANIM (1 << 0)
1609#define SAVE_FLAG_FORWARD_SPEED (1 << 1)
1610#define SAVE_FLAG_BEHAVIOR (1 << 2)
1611#define SAVE_FLAG_PATH (1 << 3)
1612#define SAVE_FLAG_NOISE (1 << 4)
1613#define SAVE_FLAG_SCRIPT_THREAD (1 << 5)
1614#define SAVE_FLAG_ACTOR_THREAD (1 << 6)
1615#define SAVE_FLAG_KILL_THREAD (1 << 7)
1616#define SAVE_FLAG_STATE (1 << 8)
1617#define SAVE_FLAG_IDLE_THREAD (1 << 7)
1618#define SAVE_FLAG_PARTS (1 << 10)
1619#define SAVE_FLAG_TRIGGER (1 << 11)
1620#define SAVE_FLAG_STATE_FLAGS (1 << 12)
1621#define SAVE_FLAG_COMMAND (1 << 13)
1622#define SAVE_FLAG_STAGE (1 << 14)
1623#define SAVE_FLAG_NUM_OF_SPAWNS (1 << 15)
1624#define SAVE_FLAG_SPAWN_PARENT (1 << 16)
1625#define SAVE_FLAG_DIALOG (1 << 17)
1626#define SAVE_FLAG_SAVED_STUFF (1 << 18)
1627#define SAVE_FLAG_LAST_ANIM_EVENT (1 << 19)
1628#define SAVE_FLAG_PICKUP_ENT (1 << 20)
1629#define SAVE_FLAG_PAIN (1 << 21)
1630#define SAVE_FLAG_SPAWN_ITEMS (1 << 22)
1631
1632/*
1633===============
1634Actor::TransitionState
1635
1636===============
1637*/
1638inline void Actor::TransitionState(int iNewState, int iPadTime)
1639{
1640 m_State = iNewState;
1641 m_iStateTime = level.inttime + iPadTime;
1642}
1643
1644/*
1645===============
1646Actor::NextUpdateTime
1647
1648Returns next update time.
1649===============
1650*/
1651inline int Actor::NextUpdateTime(int iLastUpdateTime, int iUpdatePeriod)
1652{
1653 int i = iLastUpdateTime;
1654
1655 do {
1656 i += iUpdatePeriod;
1657 } while (i < level.inttime);
1658
1659 return i;
1660}
1661
1662/*
1663===============
1664Actor::InFOV
1665
1666Returns true if pos is within fov.
1667===============
1668*/
1669inline bool Actor::InFOV(Vector pos)
1670{
1671 return InFOV(pos, m_fFov, m_fFovDot);
1672}
1673
1674/*
1675===============
1676Actor::InFOV
1677
1678Returns true if ent is within fov.
1679===============
1680*/
1681inline bool Actor::InFOV(Entity *ent)
1682{
1683 if (ent == m_Enemy) {
1684 return EnemyInFOV(0);
1685 } else {
1686 return InFOV(ent->centroid);
1687 }
1688}
1689
1690inline bool Actor::CanSeeNoFOV(Entity *ent)
1691{
1692 bool bCanSee;
1693
1694 if (ent == m_Enemy) {
1695 return CanSeeEnemy(0);
1696 }
1697
1698 bCanSee = false;
1699
1700 if (gi.AreasConnected(edict->r.areanum, ent->edict->r.areanum)) {
1701 bCanSee = CanSee(ent, 0, 0, false);
1702 }
1703
1704 return bCanSee;
1705}
1706
1707inline bool Actor::CanSeeFOV(Entity *ent)
1708{
1709 bool bCanSee;
1710
1711 if (ent == m_Enemy) {
1712 return CanSeeEnemyFOV(0, 0);
1713 }
1714
1715 bCanSee = false;
1716
1717 if (InFOV(ent) && AreasConnected(ent)) {
1718 bCanSee = CanSee(ent, 0, 0, false);
1719 }
1720
1721 return bCanSee;
1722}
1723
1724inline bool Actor::CanSeeEnemyFOV(int iMaxFovDirtyTime, int iMaxSightDirtyTime)
1725{
1726 return EnemyInFOV(iMaxFovDirtyTime) && CanSeeEnemy(iMaxSightDirtyTime);
1727}
1728
1729/*
1730===============
1731Actor::AimAtTargetPos
1732
1733Aim at mTargetPos.
1734===============
1735*/
1736inline void Actor::AimAtTargetPos(void)
1737{
1738 Vector v, v2;
1739
1740 v = mTargetPos - EyePosition();
1741 v2 = v;
1742 v2[2] += 16;
1743
1744 SetDesiredLookDir(v2);
1745
1746 m_DesiredGunDir[0] = 360.0f - v.toPitch();
1747 m_DesiredGunDir[1] = v.toYaw();
1748 m_DesiredGunDir[2] = 0;
1749
1750 SetDesiredYaw(m_DesiredGunDir[1]);
1751}
1752
1753/*
1754===============
1755Actor::AimAtAimNode
1756
1757Aim at m_aimNode.
1758===============
1759*/
1760inline void Actor::AimAtAimNode(void)
1761{
1762 mTargetPos = m_aimNode->centroid;
1763
1764 AimAtTargetPos();
1765}
1766
1767/*
1768===============
1769Actor::IgnoreSoundSet
1770
1771Make actor ignore iType sound.
1772===============
1773*/
1774inline void Actor::IgnoreSoundSet(int iType)
1775{
1776 m_iIgnoreSoundsMask |= 1 << iType;
1777}
1778
1779/*
1780===============
1781Actor::IgnoreSoundSetAll
1782
1783Make actor ignore all types of sound.
1784===============
1785*/
1786inline void Actor::IgnoreSoundSetAll(void)
1787{
1788 m_iIgnoreSoundsMask = 0xffff;
1789}
1790
1791/*
1792===============
1793Actor::IgnoreSoundClear
1794
1795Don't ignore iType of sound.
1796===============
1797*/
1798inline void Actor::IgnoreSoundClear(int iType)
1799{
1800 m_iIgnoreSoundsMask &= ~(1 << iType);
1801}
1802
1803/*
1804===============
1805Actor::IgnoreSoundClearAll
1806
1807Make actor ignore no type of sound.
1808===============
1809*/
1810inline void Actor::IgnoreSoundClearAll(void)
1811{
1812 m_iIgnoreSoundsMask = 0;
1813}
1814
1815/*
1816===============
1817Actor::IgnoreSoundClearAll
1818
1819returns true if actor should ignore iType of sound.
1820===============
1821*/
1822inline bool Actor::IgnoreSound(int iType)
1823{
1824 return (m_iIgnoreSoundsMask >> iType) & 1;
1825}
1826
1827/*
1828===============
1829Actor::CurrentThink
1830
1831Current think.
1832===============
1833*/
1834inline int Actor::CurrentThink(void) const
1835{
1836 return m_Think[m_ThinkLevel];
1837}
1838
1839/*
1840===============
1841Actor::IsAttacking
1842
1843Returns true if actor is in attack state.
1844===============
1845*/
1846inline bool Actor::IsAttacking(void) const
1847{
1848 return m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_ATTACK;
1849}
1850
1851inline void Actor::ArchiveStatic(Archiver& arc)
1852{
1853 for (int i = 0; i < MAX_BODYQUEUE; i++) {
1854 arc.ArchiveSafePointer(&mBodyQueue[i]);
1855 }
1856
1857 arc.ArchiveInteger(&mCurBody);
1858}
1859
1860inline void Actor::Archive(Archiver& arc)
1861{
1862 int i;
1863
1864 SimpleActor::Archive(arc);
1865
1866 for (i = 0; i < NUM_THINKSTATES; i++) {
1867 ArchiveEnum(m_ThinkMap[i], eThinkNum);
1868 }
1869
1870 for (i = 0; i < NUM_THINKLEVELS; i++) {
1871 ArchiveEnum(m_ThinkStates[i], eThinkState);
1872 ArchiveEnum(m_Think[i], eThinkNum);
1873 }
1874
1875 ArchiveEnum(m_ThinkLevel, eThinkLevel);
1876 ArchiveEnum(m_ThinkState, eThinkState);
1877 arc.ArchiveInteger(&m_State);
1878 arc.ArchiveInteger(&m_iStateTime);
1879 arc.ArchiveBool(&m_bLockThinkState);
1880 arc.ArchiveBool(&m_bDirtyThinkState);
1881
1882 arc.ArchiveBool(&m_bAnimating);
1883
1884 arc.ArchiveBool(&m_bIgnoreBadPlace);
1885 arc.ArchiveInteger(&m_iBadPlaceIndex);
1886
1887 arc.ArchiveInteger(&mVoiceType);
1888 arc.ArchiveBool(&m_bSilent);
1889
1890 arc.ArchiveBool(&m_bNoSurprise);
1891 arc.ArchiveBool(&m_bMumble);
1892 arc.ArchiveBool(&m_bBreathSteam);
1893 arc.ArchiveBool(&m_bIsCurious);
1894
1895 Director.ArchiveString(arc, m_csHeadModel);
1896 Director.ArchiveString(arc, m_csHeadSkin);
1897 Director.ArchiveString(arc, m_csWeapon);
1898 Director.ArchiveString(arc, m_csLoadOut);
1899
1900 arc.ArchiveSafePointer(&m_FavoriteEnemy);
1901 arc.ArchiveInteger(&m_iEnemyCheckTime);
1902 arc.ArchiveInteger(&m_iEnemyChangeTime);
1903 arc.ArchiveInteger(&m_iEnemyVisibleCheckTime);
1904 arc.ArchiveInteger(&m_iEnemyVisibleChangeTime);
1905 arc.ArchiveInteger(&m_iLastEnemyVisibleTime);
1906 arc.ArchiveFloat(&m_fVisibilityAlpha);
1907 arc.ArchiveFloat(&m_fVisibilityThreshold);
1908 arc.ArchiveInteger(&m_iEnemyFovCheckTime);
1909 arc.ArchiveInteger(&m_iEnemyFovChangeTime);
1910 arc.ArchiveVector(&m_vLastEnemyPos);
1911 arc.ArchiveInteger(&m_iLastEnemyPosChangeTime);
1912 arc.ArchiveFloat(&m_fMaxShareDistSquared);
1913 arc.ArchiveInteger(&m_iCanShootCheckTime);
1914 arc.ArchiveBool(&m_bCanShootEnemy);
1915 arc.ArchiveBool(&m_bHasVisibilityThreshold);
1916 arc.ArchiveBool(&m_bDesiredEnableEnemy);
1917 arc.ArchiveBool(&m_bEnableEnemy);
1918 arc.ArchiveBool(&m_bEnablePain);
1919 arc.ArchiveBool(&m_bNoLongPain);
1920 arc.ArchiveBool(&m_bNewEnemy);
1921 arc.ArchiveBool(&m_bEnemyIsDisguised);
1922 arc.ArchiveBool(&m_bEnemyVisible);
1923 arc.ArchiveBool(&m_bEnemyInFOV);
1924 arc.ArchiveBool(&m_bForceAttackPlayer);
1925 arc.ArchiveBool(&m_bAutoAvoidPlayer);
1926
1927 arc.ArchiveBool(&m_bNoIdleAfterAnim);
1928 Director.ArchiveString(arc, m_csAnimScript);
1929 arc.ArchiveBool(&m_bAnimScriptSet);
1930 arc.ArchiveInteger(&m_AnimMode);
1931 arc.ArchiveFloat(&m_fRunAnimRate);
1932 arc.ArchiveFloat(&m_fDfwRequestedYaw);
1933 arc.ArchiveFloat(&m_fDfwDerivedYaw);
1934 arc.ArchiveVector(&m_vDfwPos);
1935 arc.ArchiveFloat(&m_fDfwTime);
1936 arc.ArchiveInteger(&m_iGunPositionCheckTime);
1937 arc.ArchiveVector(&m_vGunPosition);
1938
1939 arc.ArchiveInteger(&m_iWallDodgeTimeout);
1940 arc.ArchiveFloat(&m_PrevObstacleNormal[0]);
1941 arc.ArchiveFloat(&m_PrevObstacleNormal[1]);
1942 arc.ArchiveChar(&m_WallDir);
1943 arc.ArchiveFloat(&m_fMoveDoneRadiusSquared);
1944
1945 arc.ArchiveBool(&m_bFaceEnemy);
1946 arc.ArchiveBool(&m_bDoPhysics);
1947 arc.ArchiveBool(&m_bPatrolWaitTrigger);
1948 arc.ArchiveBool(&m_bBecomeRunner);
1949 arc.ArchiveBool(&m_bScriptGoalValid);
1950 arc.ArchiveVector(&m_vScriptGoal);
1951 arc.ArchiveInteger(&m_iNextWatchStepTime);
1952
1953 arc.ArchiveSafePointer(&m_patrolCurrentNode);
1954 Director.ArchiveString(arc, m_csPatrolCurrentAnim);
1955 arc.ArchiveInteger(&m_iSquadStandTime);
1956 arc.ArchiveFloat(&m_fInterval);
1957 arc.ArchiveInteger(&m_iIntervalDirTime);
1958 arc.ArchiveVector(&m_vIntervalDir);
1959 arc.ArchiveShort(&m_sCurrentPathNodeIndex);
1960 arc.ArchiveInteger(&m_PainState);
1961
1962 arc.ArchiveInteger(&m_iCuriousTime);
1963 arc.ArchiveInteger(&m_iCuriousLevel);
1964 arc.ArchiveInteger(&m_iCuriousAnimHint);
1965 arc.ArchiveInteger(&m_iNextDisguiseTime);
1966 arc.ArchiveInteger(&m_iDisguisePeriod);
1967 arc.ArchiveFloat(&m_fMaxDisguiseDistSquared);
1968 arc.ArchiveInteger(&m_iEnemyShowPapersTime);
1969
1970 m_DisguiseAcceptThread.Archive(arc);
1971 arc.ArchiveInteger(&m_iDisguiseLevel);
1972 arc.ArchiveSafePointer(&m_AlarmNode);
1973 m_AlarmThread.Archive(arc);
1974 m_PreAlarmThread.Archive(arc);
1975
1976 arc.ArchiveInteger(&m_iSuppressChance);
1977 arc.ArchiveInteger(&m_iRunHomeTime);
1978 arc.ArchiveBool(&m_bTurretNoInitialCover);
1979 arc.ArchiveInteger(&m_iPotentialCoverCount);
1980
1981 for (i = 0; i < MAX_COVER_NODES; i++) {
1982 arc.ArchiveObjectPointer((Class **)&m_pPotentialCoverNode[i]);
1983 }
1984
1985 arc.ArchiveObjectPointer((Class **)&m_pCoverNode);
1986
1987 Director.ArchiveString(arc, m_csSpecialAttack);
1988 arc.ArchiveBool(&m_bInReload);
1989 arc.ArchiveBool(&m_bNeedReload);
1990 arc.ArchiveBool(&mbBreakSpecialAttack);
1991
1992 arc.ArchiveBool(&m_bGrenadeBounced);
1993 arc.ArchiveSafePointer(&m_pGrenade);
1994 arc.ArchiveVector(&m_vGrenadePos);
1995 arc.ArchiveInteger(&m_iFirstGrenadeTime);
1996 ArchiveEnum(m_eGrenadeState, eGrenadeState);
1997 ArchiveEnum(m_eGrenadeMode, eGrenadeTossMode);
1998 arc.ArchiveVector(&m_vGrenadeVel);
1999 arc.ArchiveVector(&m_vKickDir);
2000
2001 arc.ArchiveFloat(&m_fNoticeTimeScale);
2002 arc.ArchiveFloat(&m_fMaxNoticeTimeScale);
2003 m_PotentialEnemies.Archive(arc);
2004
2005 arc.ArchiveFloat(&m_fSight);
2006 arc.ArchiveFloat(&m_fHearing);
2007 arc.ArchiveFloat(&m_fSoundAwareness);
2008 arc.ArchiveFloat(&m_fGrenadeAwareness);
2009 arc.ArchiveInteger(&m_iIgnoreSoundsMask);
2010
2011 arc.ArchiveFloat(&m_fFov);
2012 arc.ArchiveFloat(&m_fFovDot);
2013 arc.ArchiveInteger(&m_iEyeUpdateTime);
2014 arc.ArchiveVector(&m_vEyeDir);
2015 arc.ArchiveInteger(&m_iNextLookTime);
2016 arc.ArchiveFloat(&m_fLookAroundFov);
2017 arc.ArchiveSafePointer(&m_pLookEntity);
2018 arc.ArchiveInteger(&m_iLookFlags);
2019 arc.ArchiveSafePointer(&m_pPointEntity);
2020 arc.ArchiveSafePointer(&m_pTurnEntity);
2021 arc.ArchiveFloat(&m_fTurnDoneError);
2022 arc.ArchiveFloat(&m_fAngleYawSpeed);
2023 arc.ArchiveSafePointer(&m_aimNode);
2024 arc.ArchiveInteger(&m_eDontFaceWallMode);
2025 arc.ArchiveInteger(&m_iLastFaceDecideTime);
2026
2027 arc.ArchiveBool(&m_bHeadAnglesAchieved);
2028 arc.ArchiveBool(&m_bLUpperArmAnglesAchieved);
2029 arc.ArchiveBool(&m_bTorsoAnglesAchieved);
2030 arc.ArchiveFloat(&m_fHeadMaxTurnSpeed);
2031 arc.ArchiveVec3(m_vHeadDesiredAngles);
2032 arc.ArchiveFloat(&m_fLUpperArmTurnSpeed);
2033 arc.ArchiveVec3(m_vLUpperArmDesiredAngles);
2034 arc.ArchiveFloat(&m_fTorsoMaxTurnSpeed);
2035 arc.ArchiveFloat(&m_fTorsoCurrentTurnSpeed);
2036 arc.ArchiveVec3(m_vTorsoDesiredAngles);
2037
2038 arc.ArchiveVector(&m_vHome);
2039 arc.ArchiveSafePointer(&m_pTetherEnt);
2040
2041 arc.ArchiveFloat(&m_fMinDistance);
2042 arc.ArchiveFloat(&m_fMinDistanceSquared);
2043 arc.ArchiveFloat(&m_fMaxDistance);
2044 arc.ArchiveFloat(&m_fMaxDistanceSquared);
2045
2046 arc.ArchiveFloat(&m_fLeash);
2047 arc.ArchiveFloat(&m_fLeashSquared);
2048 arc.ArchiveBool(&m_bFixedLeash);
2049
2050 byte length;
2051
2052 if (arc.Saving()) {
2053 if (m_pFallPath) {
2054 length = m_pFallPath->length;
2055 } else {
2056 length = 0;
2057 }
2058 }
2059 arc.ArchiveByte(&length);
2060
2061 if (arc.Loading() && length) {
2062 m_pFallPath =
2063 (FallPath *)gi.Malloc((sizeof(FallPath::pos)) * length + (sizeof(FallPath) - sizeof(FallPath::pos)));
2064 m_pFallPath->length = length;
2065 }
2066
2067 if (length) {
2068 arc.ArchiveByte(&m_pFallPath->currentPos);
2069 arc.ArchiveByte(&m_pFallPath->loop);
2070
2071 for (i = 0; i < length; i++) {
2072 arc.ArchiveVec3(m_pFallPath->pos[i]);
2073 }
2074 }
2075
2076 arc.ArchiveFloat(&m_fBalconyHeight);
2077 arc.ArchiveBool(&m_bNoPlayerCollision);
2078
2079 for (i = 0; i < MAX_ORIGIN_HISTORY; i++) {
2080 arc.ArchiveVec2(m_vOriginHistory[i]);
2081 }
2082
2083 arc.ArchiveInteger(&m_iCurrentHistory);
2084
2085 arc.ArchiveBool(&m_bEnemySwitch);
2086 arc.ArchiveInteger(&m_iNationality);
2087
2088 // set the model
2089 setModel();
2090}
2091
2092/*
2093===============
2094Actor::SetDesiredLookDir
2095
2096Change desired look direction.
2097===============
2098*/
2099inline void Actor::SetDesiredLookDir(vec3_t dir)
2100{
2101 m_bHasDesiredLookAngles = true;
2102 vectoangles(dir, m_DesiredLookAngles);
2103
2104 m_DesiredLookAngles[1] = m_DesiredLookAngles[1] - angles[1];
2105 m_DesiredLookAngles[1] = AngleNormalize180(m_DesiredLookAngles[1]);
2106 m_DesiredLookAngles[0] = AngleNormalize180(m_DesiredLookAngles[0]);
2107}
2108
2109/*
2110===============
2111Actor::SetDesiredLookAnglesRelative
2112
2113Change desired look angles relatively.
2114===============
2115*/
2116inline void Actor::SetDesiredLookAnglesRelative(vec3_t ang)
2117{
2118 m_bHasDesiredLookAngles = true;
2119 m_DesiredLookAngles[0] = AngleNormalize180(ang[0]);
2120 m_DesiredLookAngles[1] = AngleNormalize180(ang[1]);
2121 m_DesiredLookAngles[2] = AngleNormalize180(ang[2]);
2122}
2123
2124/*
2125===============
2126Actor::ForwardLook
2127===============
2128*/
2129inline void Actor::ForwardLook(void)
2130{
2131 m_bHasDesiredLookAngles = false;
2132}
2133
2134inline bool Actor::EnemyIsDisguised(void)
2135{
2136 if (!m_bEnemyIsDisguised && !m_Enemy->m_bIsDisguised) {
2137 return false;
2138 }
2139
2140 if (m_bForceAttackPlayer) {
2141 return false;
2142 }
2143
2144 if (m_ThinkState == THINKSTATE_ATTACK) {
2145 return false;
2146 }
2147
2148 return true;
2149}
2150
2151inline bool Actor::AvoidingFacingWall(void) const
2152{
2153 return m_eDontFaceWallMode > 5 && m_eDontFaceWallMode <= 8;
2154}
2155
2156#if 0
2157
2158// Set destination to node with duck or cover set. Class will find a path to that node, or a closer one.
2159class FindCoverMovement : public StandardMovement
2160 {
2161 public:
2162 Actor *self;
2163
2164 inline qboolean validpath
2165 (
2166 PathNode *node,
2167 int i
2168 )
2169
2170 {
2171 pathway_t *path;
2172 PathNode *n;
2173
2174 path = &node->Child[ i ];
2175
2176 if ( !StandardMovement::validpath( node, i ) )
2177 {
2178 return false;
2179 }
2180
2181 n = AI_GetNode( path->node );
2182 if ( !n || self->CloseToEnemy( n->origin, 128 ) )
2183 {
2184 return false;
2185 }
2186
2187 return true;
2188 }
2189
2190 inline qboolean done
2191 (
2192 PathNode *node,
2193 PathNode *end
2194 )
2195
2196 {
2197 if ( node == end )
2198 {
2199 return true;
2200 }
2201
2202 //if ( node->reject )
2203 if ( node->reject || !( node->nodeflags & ( AI_DUCK | AI_COVER ) ) )
2204 {
2205 return false;
2206 }
2207
2208 if ( self )
2209 {
2210 node->reject = self->CanSeeEnemyFrom( node->origin );
2211 return !node->reject;
2212 }
2213
2214 return false;
2215 }
2216 };
2217
2218// Set destination to node with flee set. Class will find a path to that node, or a closer one.
2219class FindFleeMovement : public StandardMovement
2220 {
2221 public:
2222 Actor *self;
2223
2224 inline qboolean validpath
2225 (
2226 PathNode *node,
2227 int i
2228 )
2229
2230 {
2231 pathway_t *path;
2232 PathNode *n;
2233
2234 path = &node->Child[ i ];
2235
2236 if ( !StandardMovement::validpath( node, i ) )
2237 {
2238 return false;
2239 }
2240
2241 n = AI_GetNode( path->node );
2242 if ( !n || self->CloseToEnemy( n->origin, 128 ) )
2243 {
2244 return false;
2245 }
2246
2247 return true;
2248 }
2249
2250 inline qboolean done
2251 (
2252 PathNode *node,
2253 PathNode *end
2254 )
2255
2256 {
2257 if ( node == end )
2258 {
2259 return true;
2260 }
2261
2262 //if ( node->reject )
2263 if ( node->reject || !( node->nodeflags & AI_FLEE ) )
2264 {
2265 return false;
2266 }
2267
2268 if ( self )
2269 {
2270 node->reject = self->CanSeeEnemyFrom( node->origin );
2271 return !node->reject;
2272 }
2273
2274 return false;
2275 }
2276 };
2277
2278class FindEnemyMovement : public StandardMovement
2279 {
2280 public:
2281 Actor *self;
2282
2283 inline qboolean done
2284 (
2285 PathNode *node,
2286 PathNode *end
2287 )
2288
2289 {
2290 if ( node == end )
2291 {
2292 return true;
2293 }
2294
2295 if ( node->reject )
2296 {
2297 return false;
2298 }
2299
2300 if ( self )
2301 {
2302 if ( self->currentEnemy )
2303 {
2304 node->reject = !self->CanShootFrom( node->origin, self->currentEnemy, false );
2305 }
2306 else
2307 {
2308 node->reject = false;
2309 }
2310
2311 return !node->reject;
2312 }
2313
2314 return false;
2315 }
2316 };
2317
2318typedef PathFinder<FindCoverMovement> FindCoverPath;
2319typedef PathFinder<FindFleeMovement> FindFleePath;
2320typedef PathFinder<FindEnemyMovement> FindEnemyPath;
2321#endif
2322
2323/*void AI_TargetPlayer( void );
2324
2325class SpinningPlant : public Actor
2326 {
2327 public:
2328 Mover *spinner_model;
2329 Mover *spinner_clip;
2330
2331 CLASS_PROTOTYPE( SpinningPlant );
2332
2333 SpinningPlant();
2334 ~SpinningPlant();
2335
2336 void GetClip( Event *ev );
2337 };
2338*/
Definition actorenemy.h:99
Definition actor.h:585
Definition archive.h:86
Definition entity.h:203
Definition listener.h:246
Definition grenadehint.h:31
Definition listener.h:450
Definition navigate.h:153
Definition safeptr.h:160
Definition gamescript.h:165
Definition simpleentity.h:42
Definition vector.h:61
Definition str.h:77
Definition actor.h:164
Definition actor.h:159
Definition actor.h:319
Definition actor.h:221
Definition puff.c:88