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