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 float ForwardDot2DTo(const Vector& targetOrigin);
1302 bool CanSeeNoFOV(Entity *ent);
1303 bool CanSeeFOV(Entity *ent);
1304 bool CanSeeEnemyFOV(int iMaxFovDirtyTime, int iMaxSightDirtyTime);
1305 bool CanShoot(Entity *ent);
1306 virtual bool CanSeeFrom(vec3_t pos, Entity *ent);
1307 bool CanSeeEnemy(int iMaxDirtyTime);
1308 bool CanShootEnemy(int iMaxDirtyTime);
1309 void ShowInfo(void);
1310 virtual void ShowInfo(float fDot, float fDist) override;
1311 void DefaultPain(Event *ev);
1312 void HandlePain(Event *ev);
1313 void EventPain(Event *ev);
1314 void DefaultKilled(Event *ev, bool bPlayDeathAnim);
1315 void HandleKilled(Event *ev, bool bPlayDeathAnim);
1316 void DispatchEventKilled(Event *ev, bool bPlayDeathAnim);
1317 void EventKilled(Event *ev);
1318 void EventBeDead(Event *ev);
1319 void DeathEmbalm(Event *ev);
1320 void DeathSinkStart(Event *ev);
1321 bool NoticeShot(Sentient *pShooter, Sentient *pTarget, float fDist);
1322 bool NoticeFootstep(Sentient *pPedestrian);
1323 bool NoticeVoice(Sentient *pVocallist);
1324 void ClearLookEntity(void);
1325 void LookAt(const Vector &vec);
1326 void LookAt(Listener *l);
1327 void ForwardLook(void);
1328 void LookAtLookEntity(void);
1329 void IdleLook(void);
1330 void IdleLook(vec3_t dir);
1331 void SetDesiredLookDir(vec3_t dir);
1332 void SetDesiredLookAnglesRelative(vec3_t ang);
1333 void EventLookAt(Event *ev);
1334 void EventEyesLookAt(Event *ev);
1335 void NoPoint(void);
1336 void IdlePoint(void);
1337 void ClearPointEntity(void);
1338 void PointAt(const Vector &vec);
1339 void PointAt(Listener *l);
1340 void EventPointAt(Event *ev);
1341 void ClearTurnEntity(void);
1342 void TurnTo(const Vector &vec);
1343 void TurnTo(Listener *l);
1344 void IdleTurn(void);
1345 void EventTurnTo(Event *ev);
1346 void EventSetTurnDoneError(Event *ev);
1347 void EventGetTurnDoneError(Event *ev);
1348 void LookAround(float fFovAdd);
1349 bool SoundSayAnim(const_str name, byte bLevelSayAnim);
1350 void EventSetAnim(Event *ev);
1351 void EventIdleSayAnim(Event *ev);
1352 void EventSayAnim(Event *ev);
1353 void EventSetSayAnim(Event *ev);
1354 void EventSetMotionAnim(Event *ev);
1355 void EventSetAimMotionAnim(Event *ev);
1356 void EventSetActionAnim(Event *ev);
1357 void EventUpperAnim(Event *ev);
1358 void EventSetUpperAnim(Event *ev);
1359 void EventEndActionAnim(Event *ev);
1360 void EventDamagePuff(Event *ev);
1361 void SafeSetOrigin(vec3_t newOrigin);
1362 void DoMove(void);
1363 void AnimFinished(int slot, bool stop);
1364 virtual void AnimFinished(int slot) override;
1365 void PlayAnimation(Event *ev);
1366 void PlayScriptedAnimation(Event *ev);
1367 void PlayNoclipAnimation(Event *ev);
1368 void PlayAttachedAnimation(Event *ev); // Added in 2.0
1369 void MoveDest(float fMoveSpeed);
1370 void MovePath(float fMoveSpeed);
1371 void MovePathGoal(float fMoveSpeed);
1372 void Dumb(Event *ev);
1373 void PhysicsOn(Event *ev);
1374 void PhysicsOff(Event *ev);
1375 void EventStart(Event *ev);
1376 void EventGetMood(Event *ev);
1377 void EventSetMood(Event *ev);
1378 void EventGetAngleYawSpeed(Event *ev);
1379 void EventSetAngleYawSpeed(Event *ev);
1380 void EventSetAimTarget(Event *ev);
1381 void UpdateAngles(void);
1382 void SetLeashHome(Vector vHome);
1383 void AimAtTargetPos(void);
1384 void AimAtAimNode(void);
1385 void AimAtEnemyBehavior(void);
1386 void FaceMotion(void);
1387 void FaceDirectionDuringMotion(vec3_t vLook);
1388 float PathDistanceAlongVector(vec3_t vDir);
1389 void FaceEnemyOrMotion(int iTimeIntoMove);
1390 static int NextUpdateTime(int iLastUpdateTime, int iUpdatePeriod);
1391 void ResetBoneControllers(void);
1392 void UpdateBoneControllers(void);
1393 void ReadyToFire(Event *ev);
1394 void EventGetSight(Event *ev);
1395 void EventSetSight(Event *ev);
1396 void EventGetHearing(Event *ev);
1397 void EventSetHearing(Event *ev);
1398 void ClearPatrolCurrentNode(void);
1399 void NextPatrolCurrentNode(void);
1400 void SetPatrolCurrentNode(Vector &vec);
1401 void SetPatrolCurrentNode(Listener *l);
1402 void EventSetPatrolPath(Event *ev);
1403 void EventGetPatrolPath(Event *ev);
1404 void EventSetPatrolWaitTrigger(Event *ev);
1405 void EventGetPatrolWaitTrigger(Event *ev);
1406 void ShowInfo_PatrolCurrentNode(void);
1407 bool MoveOnPathWithSquad(void);
1408 bool MoveToWaypointWithPlayer(void);
1409 bool PatrolNextNodeExists(void);
1410 void UpdatePatrolCurrentNode(void);
1411 bool MoveToPatrolCurrentNode(void);
1412 void ClearAimNode(void);
1413 void SetAimNode(const Vector &vec);
1414 void SetAimNode(Listener *l);
1415 void ShowInfo_AimNode(void);
1416 void EventSetAccuracy(Event *ev);
1417 void EventGetAccuracy(Event *ev);
1418 int GetThinkType(const_str csName);
1419 void SetThink(eThinkState state, eThinkNum think);
1420 void SetThinkIdle(eThinkNum think_idle);
1421 void SetThinkState(eThinkState state, eThinkLevel level);
1422 void EndCurrentThinkState(void);
1423 void ClearThinkStates(void);
1424 int CurrentThink(void) const;
1425 bool IsAttacking(void) const;
1426 void EventGetFov(Event *ev);
1427 void EventSetFov(Event *ev);
1428 void EventSetDestIdle(Event *ev);
1429 void EventSetDestIdle2(Event *ev);
1430 void EventSetTypeIdle(Event *ev);
1431 void EventGetTypeIdle(Event *ev);
1432 void EventSetTypeAttack(Event *ev);
1433 void EventGetTypeAttack(Event *ev);
1434 void EventSetTypeDisguise(Event *ev);
1435 void EventGetTypeDisguise(Event *ev);
1436 void EventSetDisguiseLevel(Event *ev);
1437 void EventGetDisguiseLevel(Event *ev);
1438 void EventSetTypeGrenade(Event *ev);
1439 void EventGetTypeGrenade(Event *ev);
1440 void EventSetMinDistance(Event *ev);
1441 void EventGetMinDistance(Event *ev);
1442 void EventSetMaxDistance(Event *ev);
1443 void EventGetMaxDistance(Event *ev);
1444 void EventGetLeash(Event *ev);
1445 void EventSetLeash(Event *ev);
1446 void EventGetInterval(Event *ev);
1447 void EventSetInterval(Event *ev);
1448 void EventDistToEnemy(Event *ev);
1449 void EventGetRunAnim(Event *ev);
1450 void EventGetWalkAnim(Event *ev);
1451 void EventGetAnimName(Event *ev);
1452 void EventSetAnimName(Event *ev);
1453 void EventSetDisguiseRange(Event *ev);
1454 void EventGetDisguiseRange(Event *ev);
1455 void EventSetDisguisePeriod(Event *ev);
1456 void EventGetDisguisePeriod(Event *ev);
1457 void EventSetDisguiseAcceptThread(Event *ev);
1458 void EventGetDisguiseAcceptThread(Event *ev);
1459 void EventAttackPlayer(Event *ev);
1460 void ForceAttackPlayer(void);
1461 void EventSetAlarmNode(Event *ev);
1462 void EventGetAlarmNode(Event *ev);
1463 void EventSetPreAlarmThread(Event *ev); // Added in 2.30
1464 void EventSetAlarmThread(Event *ev);
1465 void EventGetAlarmThread(Event *ev);
1466 void EventSetSoundAwareness(Event *ev);
1467 void EventGetSoundAwareness(Event *ev);
1468 void EventSetGrenadeAwareness(Event *ev);
1469 void EventGetGrenadeAwareness(Event *ev);
1470 str ThinkName(void) const;
1471 str ThinkStateName(void) const;
1472 void EventSetTurret(Event *ev);
1473 void EventGetTurret(Event *ev);
1474 void EventEnableEnemy(Event *ev);
1475 void EventEnablePain(Event *ev);
1476 void EventActivate(Event *ev);
1477 void EventGetAmmoGrenade(Event *ev);
1478 void EventSetAmmoGrenade(Event *ev);
1479 void EventInterruptPoint(Event *ev);
1480 // Added in 2.0
1481 //====
1482 void EventGetVisibilityThreshold(Event *ev);
1483 void EventSetVisibilityThreshold(Event *ev);
1484 void EventSetDefaultVisibilityThreshold(Event *ev);
1485 void EventGetSuppressChance(Event *ev);
1486 void EventSetSuppressChance(Event *ev);
1487 //====
1488 void EventAnimScript(Event *ev);
1489 void EventAnimScript_Scripted(Event *ev);
1490 void EventAnimScript_Noclip(Event *ev);
1491 void EventAnimScript_Attached(Event *ev);
1492 void EventReload_mg42(Event *ev);
1493 void SetPathWithLeash(Vector vDestPos, const char *description, int iMaxDirtyTime);
1494 void SetPathWithLeash(SimpleEntity *pDestNode, const char *description, int iMaxDirtyTime);
1495 void FindPathAwayWithLeash(vec3_t vAwayFrom, vec3_t vDirPreferred, float fMinSafeDist);
1496 void FindPathNearWithLeash(vec3_t vNearbyTo, float fCloseDistSquared);
1497 bool CanMovePathWithLeash(void) const;
1498 bool MovePathWithLeash(void);
1499 bool ShortenPathToAttack(float fMinDist);
1500 void StrafeToAttack(float fDist, vec3_t vDir);
1501 virtual Vector GunTarget(bool bNoCollision, const vec3_t position, const vec3_t forward) override;
1502 virtual qboolean setModel(void) override;
1503 void EventSetHeadModel(Event *ev);
1504 void EventGetHeadModel(Event *ev);
1505 void EventSetHeadSkin(Event *ev);
1506 void EventGetHeadSkin(Event *ev);
1507 void EventSetNoIdle(Event *ev);
1508 void EventGetNoIdle(Event *ev);
1509 void EventGetEnemy(Event *ev);
1510 void EventSetMaxNoticeTimeScale(Event *ev);
1511 void EventGetMaxNoticeTimeScale(Event *ev);
1512 void EventSetFixedLeash(Event *ev);
1513 void EventGetFixedLeash(Event *ev);
1514 void Holster(void);
1515 void HolsterOffHand(void); // Added in 2.0
1516 void Unholster(void);
1517 void UnholsterOffHand(void); // Added in 2.0
1518 void EventHolster(Event *ev);
1519 void EventUnholster(Event *ev);
1520 void EventSoundDone(Event *ev);
1521 void EventSound(Event *ev);
1522 void EventIsEnemyVisible(Event *ev);
1523 void EventGetEnemyVisibleChangeTime(Event *ev);
1524 void EventGetLastEnemyVisibleTime(Event *ev);
1525 void EventSetFallHeight(Event *ev);
1526 void EventGetFallHeight(Event *ev);
1527 void EventCanMoveTo(Event *ev);
1528 void EventMoveDir(Event *ev);
1529 void EventIntervalDir(Event *ev);
1530 void EventResetLeash(Event *ev);
1531 void EventTether(Event *ev);
1532 void EventGetThinkState(Event *ev);
1533 void EventGetEnemyShareRange(Event *ev);
1534 void EventSetEnemyShareRange(Event *ev);
1535 void EventGetKickDir(Event *ev);
1536 void EventGetNoLongPain(Event *ev);
1537 void EventSetNoLongPain(Event *ev);
1538 void EventGetFavoriteEnemy(Event *ev);
1539 void EventSetFavoriteEnemy(Event *ev);
1540 void EventFindEnemy(Event *ev); // Added in 2.0
1541 void EventGetMumble(Event *ev);
1542 void EventSetMumble(Event *ev);
1543 void EventGetBreathSteam(Event *ev);
1544 void EventSetBreathSteam(Event *ev);
1545 void EventSetNextBreathTime(Event *ev);
1546 void EventCalcGrenadeToss2(Event *ev);
1547 void EventCalcGrenadeToss(Event *ev);
1548 void EventGetNoSurprise(Event *ev);
1549 void EventSetNoSurprise(Event *ev);
1550 void EventGetSilent(Event *ev);
1551 void EventSetSilent(Event *ev);
1552 void EventGetAvoidPlayer(Event *ev);
1553 void EventSetAvoidPlayer(Event *ev);
1554 void EventGetLookAroundAngle(Event *ev);
1555 void EventSetLookAroundAngle(Event *ev);
1556 void EventHasCompleteLookahead(Event *ev);
1557 void EventPathDist(Event *ev);
1558 void EventCanShootEnemyFrom(Event *ev);
1559 void EventCanShoot(Event *ev);
1560 void EventSetInReload(Event *ev);
1561 void EventGetInReload(Event *ev);
1562 void EventSetReloadCover(Event *ev);
1563 void EventBreakSpecial(Event *ev);
1564 void GetVoiceType(Event *ev);
1565 void SetVoiceType(Event *ev);
1566 void ResolveVoiceType(void);
1567 void EventSetBalconyHeight(Event *ev);
1568 void EventGetBalconyHeight(Event *ev);
1569 // Added in 2.0
1570 //====
1571 void EventSetIgnoreBadPlace(Event *ev);
1572 void EventGetIgnoreBadPlace(Event *ev);
1573 void EventEnableEnemySwitch(Event *ev);
1574 void EventDisableEnemySwitch(Event *ev);
1575 void EventSetRunAnimRate(Event *ev);
1576 void EventGetRunAnimRate(Event *ev);
1577 void Landed(Event *ev);
1578 bool IsOnFloor(void);
1579 //====
1580 // Added in 2.30
1581 //====
1582 void GetNationality(Event *ev);
1583 void SetNationality(Event *ev);
1584 void EventWriteStats(Event *ev);
1585 void EventCuriousOff(Event *ev);
1586 void EventCuriousOn(Event *ev);
1587 //====
1588 PathNode *FindSniperNodeAndSetPath(bool *pbTryAgain);
1589 void Remove(Event *ev);
1590 void DontFaceWall(void);
1591 bool AvoidingFacingWall(void) const;
1592 void EndStates(void);
1593 void ClearStates(void);
1594 void CheckUnregister(void);
1595 void BecomeCorpse(void);
1596 virtual void PathnodeClaimRevoked(PathNode *node) override;
1597 void SetPathToNotBlockSentient(Sentient *pOther);
1598 void EventSetMoveDoneRadius(Event *ev);
1599 void EventGetMoveDoneRadius(Event *ev); // Added in 2.0
1600 virtual void ClearEnemies(void) override;
1601 bool EnemyIsDisguised(void);
1602 virtual void setOriginEvent(Vector org) override;
1603 virtual void DumpAnimInfo(void) override;
1604 static void ArchiveStatic(Archiver &arc);
1605 virtual void Archive(Archiver& arc) override;
1606 virtual bool AutoArchiveModel(void) override;
1607 virtual bool IsDisabled() const override; // Added in 2.30
1608};
1609
1610#define SAVE_FLAG_NEW_ANIM (1 << 0)
1611#define SAVE_FLAG_FORWARD_SPEED (1 << 1)
1612#define SAVE_FLAG_BEHAVIOR (1 << 2)
1613#define SAVE_FLAG_PATH (1 << 3)
1614#define SAVE_FLAG_NOISE (1 << 4)
1615#define SAVE_FLAG_SCRIPT_THREAD (1 << 5)
1616#define SAVE_FLAG_ACTOR_THREAD (1 << 6)
1617#define SAVE_FLAG_KILL_THREAD (1 << 7)
1618#define SAVE_FLAG_STATE (1 << 8)
1619#define SAVE_FLAG_IDLE_THREAD (1 << 7)
1620#define SAVE_FLAG_PARTS (1 << 10)
1621#define SAVE_FLAG_TRIGGER (1 << 11)
1622#define SAVE_FLAG_STATE_FLAGS (1 << 12)
1623#define SAVE_FLAG_COMMAND (1 << 13)
1624#define SAVE_FLAG_STAGE (1 << 14)
1625#define SAVE_FLAG_NUM_OF_SPAWNS (1 << 15)
1626#define SAVE_FLAG_SPAWN_PARENT (1 << 16)
1627#define SAVE_FLAG_DIALOG (1 << 17)
1628#define SAVE_FLAG_SAVED_STUFF (1 << 18)
1629#define SAVE_FLAG_LAST_ANIM_EVENT (1 << 19)
1630#define SAVE_FLAG_PICKUP_ENT (1 << 20)
1631#define SAVE_FLAG_PAIN (1 << 21)
1632#define SAVE_FLAG_SPAWN_ITEMS (1 << 22)
1633
1634/*
1635===============
1636Actor::TransitionState
1637
1638===============
1639*/
1640inline void Actor::TransitionState(int iNewState, int iPadTime)
1641{
1642 m_State = iNewState;
1643 m_iStateTime = level.inttime + iPadTime;
1644}
1645
1646/*
1647===============
1648Actor::NextUpdateTime
1649
1650Returns next update time.
1651===============
1652*/
1653inline int Actor::NextUpdateTime(int iLastUpdateTime, int iUpdatePeriod)
1654{
1655 int i = iLastUpdateTime;
1656
1657 do {
1658 i += iUpdatePeriod;
1659 } while (i < level.inttime);
1660
1661 return i;
1662}
1663
1664/*
1665===============
1666Actor::InFOV
1667
1668Returns true if pos is within fov.
1669===============
1670*/
1671inline bool Actor::InFOV(Vector pos)
1672{
1673 return InFOV(pos, m_fFov, m_fFovDot);
1674}
1675
1676/*
1677===============
1678Actor::InFOV
1679
1680Returns true if ent is within fov.
1681===============
1682*/
1683inline bool Actor::InFOV(Entity *ent)
1684{
1685 if (ent == m_Enemy) {
1686 return EnemyInFOV(0);
1687 } else {
1688 return InFOV(ent->centroid);
1689 }
1690}
1691
1692inline bool Actor::CanSeeNoFOV(Entity *ent)
1693{
1694 bool bCanSee;
1695
1696 if (ent == m_Enemy) {
1697 return CanSeeEnemy(0);
1698 }
1699
1700 bCanSee = false;
1701
1702 if (gi.AreasConnected(edict->r.areanum, ent->edict->r.areanum)) {
1703 bCanSee = CanSee(ent, 0, 0, false);
1704 }
1705
1706 return bCanSee;
1707}
1708
1709inline bool Actor::CanSeeFOV(Entity *ent)
1710{
1711 bool bCanSee;
1712
1713 if (ent == m_Enemy) {
1714 return CanSeeEnemyFOV(0, 0);
1715 }
1716
1717 bCanSee = false;
1718
1719 if (InFOV(ent) && AreasConnected(ent)) {
1720 bCanSee = CanSee(ent, 0, 0, false);
1721 }
1722
1723 return bCanSee;
1724}
1725
1726inline bool Actor::CanSeeEnemyFOV(int iMaxFovDirtyTime, int iMaxSightDirtyTime)
1727{
1728 return EnemyInFOV(iMaxFovDirtyTime) && CanSeeEnemy(iMaxSightDirtyTime);
1729}
1730
1731/*
1732===============
1733Actor::AimAtTargetPos
1734
1735Aim at mTargetPos.
1736===============
1737*/
1738inline void Actor::AimAtTargetPos(void)
1739{
1740 Vector v, v2;
1741
1742 v = mTargetPos - EyePosition();
1743 v2 = v;
1744 v2[2] += 16;
1745
1746 SetDesiredLookDir(v2);
1747
1748 m_DesiredGunDir[0] = 360.0f - v.toPitch();
1749 m_DesiredGunDir[1] = v.toYaw();
1750 m_DesiredGunDir[2] = 0;
1751
1752 SetDesiredYaw(m_DesiredGunDir[1]);
1753}
1754
1755/*
1756===============
1757Actor::AimAtAimNode
1758
1759Aim at m_aimNode.
1760===============
1761*/
1762inline void Actor::AimAtAimNode(void)
1763{
1764 mTargetPos = m_aimNode->centroid;
1765
1766 AimAtTargetPos();
1767}
1768
1769/*
1770===============
1771Actor::IgnoreSoundSet
1772
1773Make actor ignore iType sound.
1774===============
1775*/
1776inline void Actor::IgnoreSoundSet(int iType)
1777{
1778 m_iIgnoreSoundsMask |= 1 << iType;
1779}
1780
1781/*
1782===============
1783Actor::IgnoreSoundSetAll
1784
1785Make actor ignore all types of sound.
1786===============
1787*/
1788inline void Actor::IgnoreSoundSetAll(void)
1789{
1790 m_iIgnoreSoundsMask = 0xffff;
1791}
1792
1793/*
1794===============
1795Actor::IgnoreSoundClear
1796
1797Don't ignore iType of sound.
1798===============
1799*/
1800inline void Actor::IgnoreSoundClear(int iType)
1801{
1802 m_iIgnoreSoundsMask &= ~(1 << iType);
1803}
1804
1805/*
1806===============
1807Actor::IgnoreSoundClearAll
1808
1809Make actor ignore no type of sound.
1810===============
1811*/
1812inline void Actor::IgnoreSoundClearAll(void)
1813{
1814 m_iIgnoreSoundsMask = 0;
1815}
1816
1817/*
1818===============
1819Actor::IgnoreSoundClearAll
1820
1821returns true if actor should ignore iType of sound.
1822===============
1823*/
1824inline bool Actor::IgnoreSound(int iType)
1825{
1826 return (m_iIgnoreSoundsMask >> iType) & 1;
1827}
1828
1829/*
1830===============
1831Actor::CurrentThink
1832
1833Current think.
1834===============
1835*/
1836inline int Actor::CurrentThink(void) const
1837{
1838 return m_Think[m_ThinkLevel];
1839}
1840
1841/*
1842===============
1843Actor::IsAttacking
1844
1845Returns true if actor is in attack state.
1846===============
1847*/
1848inline bool Actor::IsAttacking(void) const
1849{
1850 return m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_ATTACK;
1851}
1852
1853inline void Actor::ArchiveStatic(Archiver& arc)
1854{
1855 for (int i = 0; i < MAX_BODYQUEUE; i++) {
1856 arc.ArchiveSafePointer(&mBodyQueue[i]);
1857 }
1858
1859 arc.ArchiveInteger(&mCurBody);
1860}
1861
1862inline void Actor::Archive(Archiver& arc)
1863{
1864 int i;
1865
1866 SimpleActor::Archive(arc);
1867
1868 for (i = 0; i < NUM_THINKSTATES; i++) {
1869 ArchiveEnum(m_ThinkMap[i], eThinkNum);
1870 }
1871
1872 for (i = 0; i < NUM_THINKLEVELS; i++) {
1873 ArchiveEnum(m_ThinkStates[i], eThinkState);
1874 ArchiveEnum(m_Think[i], eThinkNum);
1875 }
1876
1877 ArchiveEnum(m_ThinkLevel, eThinkLevel);
1878 ArchiveEnum(m_ThinkState, eThinkState);
1879 arc.ArchiveInteger(&m_State);
1880 arc.ArchiveInteger(&m_iStateTime);
1881 arc.ArchiveBool(&m_bLockThinkState);
1882 arc.ArchiveBool(&m_bDirtyThinkState);
1883
1884 arc.ArchiveBool(&m_bAnimating);
1885
1886 arc.ArchiveBool(&m_bIgnoreBadPlace);
1887 arc.ArchiveInteger(&m_iBadPlaceIndex);
1888
1889 arc.ArchiveInteger(&mVoiceType);
1890 arc.ArchiveBool(&m_bSilent);
1891
1892 arc.ArchiveBool(&m_bNoSurprise);
1893 arc.ArchiveBool(&m_bMumble);
1894 arc.ArchiveBool(&m_bBreathSteam);
1895 arc.ArchiveBool(&m_bIsCurious);
1896
1897 Director.ArchiveString(arc, m_csHeadModel);
1898 Director.ArchiveString(arc, m_csHeadSkin);
1899 Director.ArchiveString(arc, m_csWeapon);
1900 Director.ArchiveString(arc, m_csLoadOut);
1901
1902 arc.ArchiveSafePointer(&m_FavoriteEnemy);
1903 arc.ArchiveInteger(&m_iEnemyCheckTime);
1904 arc.ArchiveInteger(&m_iEnemyChangeTime);
1905 arc.ArchiveInteger(&m_iEnemyVisibleCheckTime);
1906 arc.ArchiveInteger(&m_iEnemyVisibleChangeTime);
1907 arc.ArchiveInteger(&m_iLastEnemyVisibleTime);
1908 arc.ArchiveFloat(&m_fVisibilityAlpha);
1909 arc.ArchiveFloat(&m_fVisibilityThreshold);
1910 arc.ArchiveInteger(&m_iEnemyFovCheckTime);
1911 arc.ArchiveInteger(&m_iEnemyFovChangeTime);
1912 arc.ArchiveVector(&m_vLastEnemyPos);
1913 arc.ArchiveInteger(&m_iLastEnemyPosChangeTime);
1914 arc.ArchiveFloat(&m_fMaxShareDistSquared);
1915 arc.ArchiveInteger(&m_iCanShootCheckTime);
1916 arc.ArchiveBool(&m_bCanShootEnemy);
1917 arc.ArchiveBool(&m_bHasVisibilityThreshold);
1918 arc.ArchiveBool(&m_bDesiredEnableEnemy);
1919 arc.ArchiveBool(&m_bEnableEnemy);
1920 arc.ArchiveBool(&m_bEnablePain);
1921 arc.ArchiveBool(&m_bNoLongPain);
1922 arc.ArchiveBool(&m_bNewEnemy);
1923 arc.ArchiveBool(&m_bEnemyIsDisguised);
1924 arc.ArchiveBool(&m_bEnemyVisible);
1925 arc.ArchiveBool(&m_bEnemyInFOV);
1926 arc.ArchiveBool(&m_bForceAttackPlayer);
1927 arc.ArchiveBool(&m_bAutoAvoidPlayer);
1928
1929 arc.ArchiveBool(&m_bNoIdleAfterAnim);
1930 Director.ArchiveString(arc, m_csAnimScript);
1931 arc.ArchiveBool(&m_bAnimScriptSet);
1932 arc.ArchiveInteger(&m_AnimMode);
1933 arc.ArchiveFloat(&m_fRunAnimRate);
1934 arc.ArchiveFloat(&m_fDfwRequestedYaw);
1935 arc.ArchiveFloat(&m_fDfwDerivedYaw);
1936 arc.ArchiveVector(&m_vDfwPos);
1937 arc.ArchiveFloat(&m_fDfwTime);
1938 arc.ArchiveInteger(&m_iGunPositionCheckTime);
1939 arc.ArchiveVector(&m_vGunPosition);
1940
1941 arc.ArchiveInteger(&m_iWallDodgeTimeout);
1942 arc.ArchiveFloat(&m_PrevObstacleNormal[0]);
1943 arc.ArchiveFloat(&m_PrevObstacleNormal[1]);
1944 arc.ArchiveChar(&m_WallDir);
1945 arc.ArchiveFloat(&m_fMoveDoneRadiusSquared);
1946
1947 arc.ArchiveBool(&m_bFaceEnemy);
1948 arc.ArchiveBool(&m_bDoPhysics);
1949 arc.ArchiveBool(&m_bPatrolWaitTrigger);
1950 arc.ArchiveBool(&m_bBecomeRunner);
1951 arc.ArchiveBool(&m_bScriptGoalValid);
1952 arc.ArchiveVector(&m_vScriptGoal);
1953 arc.ArchiveInteger(&m_iNextWatchStepTime);
1954
1955 arc.ArchiveSafePointer(&m_patrolCurrentNode);
1956 Director.ArchiveString(arc, m_csPatrolCurrentAnim);
1957 arc.ArchiveInteger(&m_iSquadStandTime);
1958 arc.ArchiveFloat(&m_fInterval);
1959 arc.ArchiveInteger(&m_iIntervalDirTime);
1960 arc.ArchiveVector(&m_vIntervalDir);
1961 arc.ArchiveShort(&m_sCurrentPathNodeIndex);
1962 arc.ArchiveInteger(&m_PainState);
1963
1964 arc.ArchiveInteger(&m_iCuriousTime);
1965 arc.ArchiveInteger(&m_iCuriousLevel);
1966 arc.ArchiveInteger(&m_iCuriousAnimHint);
1967 arc.ArchiveInteger(&m_iNextDisguiseTime);
1968 arc.ArchiveInteger(&m_iDisguisePeriod);
1969 arc.ArchiveFloat(&m_fMaxDisguiseDistSquared);
1970 arc.ArchiveInteger(&m_iEnemyShowPapersTime);
1971
1972 m_DisguiseAcceptThread.Archive(arc);
1973 arc.ArchiveInteger(&m_iDisguiseLevel);
1974 arc.ArchiveSafePointer(&m_AlarmNode);
1975 m_AlarmThread.Archive(arc);
1976 m_PreAlarmThread.Archive(arc);
1977
1978 arc.ArchiveInteger(&m_iSuppressChance);
1979 arc.ArchiveInteger(&m_iRunHomeTime);
1980 arc.ArchiveBool(&m_bTurretNoInitialCover);
1981 arc.ArchiveInteger(&m_iPotentialCoverCount);
1982
1983 for (i = 0; i < MAX_COVER_NODES; i++) {
1984 arc.ArchiveObjectPointer((Class **)&m_pPotentialCoverNode[i]);
1985 }
1986
1987 arc.ArchiveObjectPointer((Class **)&m_pCoverNode);
1988
1989 Director.ArchiveString(arc, m_csSpecialAttack);
1990 arc.ArchiveBool(&m_bInReload);
1991 arc.ArchiveBool(&m_bNeedReload);
1992 arc.ArchiveBool(&mbBreakSpecialAttack);
1993
1994 arc.ArchiveBool(&m_bGrenadeBounced);
1995 arc.ArchiveSafePointer(&m_pGrenade);
1996 arc.ArchiveVector(&m_vGrenadePos);
1997 arc.ArchiveInteger(&m_iFirstGrenadeTime);
1998 ArchiveEnum(m_eGrenadeState, eGrenadeState);
1999 ArchiveEnum(m_eGrenadeMode, eGrenadeTossMode);
2000 arc.ArchiveVector(&m_vGrenadeVel);
2001 arc.ArchiveVector(&m_vKickDir);
2002
2003 arc.ArchiveFloat(&m_fNoticeTimeScale);
2004 arc.ArchiveFloat(&m_fMaxNoticeTimeScale);
2005 m_PotentialEnemies.Archive(arc);
2006
2007 arc.ArchiveFloat(&m_fSight);
2008 arc.ArchiveFloat(&m_fHearing);
2009 arc.ArchiveFloat(&m_fSoundAwareness);
2010 arc.ArchiveFloat(&m_fGrenadeAwareness);
2011 arc.ArchiveInteger(&m_iIgnoreSoundsMask);
2012
2013 arc.ArchiveFloat(&m_fFov);
2014 arc.ArchiveFloat(&m_fFovDot);
2015 arc.ArchiveInteger(&m_iEyeUpdateTime);
2016 arc.ArchiveVector(&m_vEyeDir);
2017 arc.ArchiveInteger(&m_iNextLookTime);
2018 arc.ArchiveFloat(&m_fLookAroundFov);
2019 arc.ArchiveSafePointer(&m_pLookEntity);
2020 arc.ArchiveInteger(&m_iLookFlags);
2021 arc.ArchiveSafePointer(&m_pPointEntity);
2022 arc.ArchiveSafePointer(&m_pTurnEntity);
2023 arc.ArchiveFloat(&m_fTurnDoneError);
2024 arc.ArchiveFloat(&m_fAngleYawSpeed);
2025 arc.ArchiveSafePointer(&m_aimNode);
2026 arc.ArchiveInteger(&m_eDontFaceWallMode);
2027 arc.ArchiveInteger(&m_iLastFaceDecideTime);
2028
2029 arc.ArchiveBool(&m_bHeadAnglesAchieved);
2030 arc.ArchiveBool(&m_bLUpperArmAnglesAchieved);
2031 arc.ArchiveBool(&m_bTorsoAnglesAchieved);
2032 arc.ArchiveFloat(&m_fHeadMaxTurnSpeed);
2033 arc.ArchiveVec3(m_vHeadDesiredAngles);
2034 arc.ArchiveFloat(&m_fLUpperArmTurnSpeed);
2035 arc.ArchiveVec3(m_vLUpperArmDesiredAngles);
2036 arc.ArchiveFloat(&m_fTorsoMaxTurnSpeed);
2037 arc.ArchiveFloat(&m_fTorsoCurrentTurnSpeed);
2038 arc.ArchiveVec3(m_vTorsoDesiredAngles);
2039
2040 arc.ArchiveVector(&m_vHome);
2041 arc.ArchiveSafePointer(&m_pTetherEnt);
2042
2043 arc.ArchiveFloat(&m_fMinDistance);
2044 arc.ArchiveFloat(&m_fMinDistanceSquared);
2045 arc.ArchiveFloat(&m_fMaxDistance);
2046 arc.ArchiveFloat(&m_fMaxDistanceSquared);
2047
2048 arc.ArchiveFloat(&m_fLeash);
2049 arc.ArchiveFloat(&m_fLeashSquared);
2050 arc.ArchiveBool(&m_bFixedLeash);
2051
2052 byte length;
2053
2054 if (arc.Saving()) {
2055 if (m_pFallPath) {
2056 length = m_pFallPath->length;
2057 } else {
2058 length = 0;
2059 }
2060 }
2061 arc.ArchiveByte(&length);
2062
2063 if (arc.Loading() && length) {
2064 m_pFallPath =
2065 (FallPath *)gi.Malloc((sizeof(FallPath::pos)) * length + (sizeof(FallPath) - sizeof(FallPath::pos)));
2066 m_pFallPath->length = length;
2067 }
2068
2069 if (length) {
2070 arc.ArchiveByte(&m_pFallPath->currentPos);
2071 arc.ArchiveByte(&m_pFallPath->loop);
2072
2073 for (i = 0; i < length; i++) {
2074 arc.ArchiveVec3(m_pFallPath->pos[i]);
2075 }
2076 }
2077
2078 arc.ArchiveFloat(&m_fBalconyHeight);
2079 arc.ArchiveBool(&m_bNoPlayerCollision);
2080
2081 for (i = 0; i < MAX_ORIGIN_HISTORY; i++) {
2082 arc.ArchiveVec2(m_vOriginHistory[i]);
2083 }
2084
2085 arc.ArchiveInteger(&m_iCurrentHistory);
2086
2087 arc.ArchiveBool(&m_bEnemySwitch);
2088 arc.ArchiveInteger(&m_iNationality);
2089
2090 // set the model
2091 setModel();
2092}
2093
2094/*
2095===============
2096Actor::SetDesiredLookDir
2097
2098Change desired look direction.
2099===============
2100*/
2101inline void Actor::SetDesiredLookDir(vec3_t dir)
2102{
2103 m_bHasDesiredLookAngles = true;
2104 vectoangles(dir, m_DesiredLookAngles);
2105
2106 m_DesiredLookAngles[1] = m_DesiredLookAngles[1] - angles[1];
2107 m_DesiredLookAngles[1] = AngleNormalize180(m_DesiredLookAngles[1]);
2108 m_DesiredLookAngles[0] = AngleNormalize180(m_DesiredLookAngles[0]);
2109}
2110
2111/*
2112===============
2113Actor::SetDesiredLookAnglesRelative
2114
2115Change desired look angles relatively.
2116===============
2117*/
2118inline void Actor::SetDesiredLookAnglesRelative(vec3_t ang)
2119{
2120 m_bHasDesiredLookAngles = true;
2121 m_DesiredLookAngles[0] = AngleNormalize180(ang[0]);
2122 m_DesiredLookAngles[1] = AngleNormalize180(ang[1]);
2123 m_DesiredLookAngles[2] = AngleNormalize180(ang[2]);
2124}
2125
2126/*
2127===============
2128Actor::ForwardLook
2129===============
2130*/
2131inline void Actor::ForwardLook(void)
2132{
2133 m_bHasDesiredLookAngles = false;
2134}
2135
2136inline bool Actor::EnemyIsDisguised(void)
2137{
2138 if (!m_bEnemyIsDisguised && !m_Enemy->m_bIsDisguised) {
2139 return false;
2140 }
2141
2142 if (m_bForceAttackPlayer) {
2143 return false;
2144 }
2145
2146 if (m_ThinkState == THINKSTATE_ATTACK) {
2147 return false;
2148 }
2149
2150 return true;
2151}
2152
2153inline bool Actor::AvoidingFacingWall(void) const
2154{
2155 return m_eDontFaceWallMode > 5 && m_eDontFaceWallMode <= 8;
2156}
2157
2158#if 0
2159
2160// Set destination to node with duck or cover set. Class will find a path to that node, or a closer one.
2161class FindCoverMovement : public StandardMovement
2162 {
2163 public:
2164 Actor *self;
2165
2166 inline qboolean validpath
2167 (
2168 PathNode *node,
2169 int i
2170 )
2171
2172 {
2173 pathway_t *path;
2174 PathNode *n;
2175
2176 path = &node->Child[ i ];
2177
2178 if ( !StandardMovement::validpath( node, i ) )
2179 {
2180 return false;
2181 }
2182
2183 n = AI_GetNode( path->node );
2184 if ( !n || self->CloseToEnemy( n->origin, 128 ) )
2185 {
2186 return false;
2187 }
2188
2189 return true;
2190 }
2191
2192 inline qboolean done
2193 (
2194 PathNode *node,
2195 PathNode *end
2196 )
2197
2198 {
2199 if ( node == end )
2200 {
2201 return true;
2202 }
2203
2204 //if ( node->reject )
2205 if ( node->reject || !( node->nodeflags & ( AI_DUCK | AI_COVER ) ) )
2206 {
2207 return false;
2208 }
2209
2210 if ( self )
2211 {
2212 node->reject = self->CanSeeEnemyFrom( node->origin );
2213 return !node->reject;
2214 }
2215
2216 return false;
2217 }
2218 };
2219
2220// Set destination to node with flee set. Class will find a path to that node, or a closer one.
2221class FindFleeMovement : public StandardMovement
2222 {
2223 public:
2224 Actor *self;
2225
2226 inline qboolean validpath
2227 (
2228 PathNode *node,
2229 int i
2230 )
2231
2232 {
2233 pathway_t *path;
2234 PathNode *n;
2235
2236 path = &node->Child[ i ];
2237
2238 if ( !StandardMovement::validpath( node, i ) )
2239 {
2240 return false;
2241 }
2242
2243 n = AI_GetNode( path->node );
2244 if ( !n || self->CloseToEnemy( n->origin, 128 ) )
2245 {
2246 return false;
2247 }
2248
2249 return true;
2250 }
2251
2252 inline qboolean done
2253 (
2254 PathNode *node,
2255 PathNode *end
2256 )
2257
2258 {
2259 if ( node == end )
2260 {
2261 return true;
2262 }
2263
2264 //if ( node->reject )
2265 if ( node->reject || !( node->nodeflags & AI_FLEE ) )
2266 {
2267 return false;
2268 }
2269
2270 if ( self )
2271 {
2272 node->reject = self->CanSeeEnemyFrom( node->origin );
2273 return !node->reject;
2274 }
2275
2276 return false;
2277 }
2278 };
2279
2280class FindEnemyMovement : public StandardMovement
2281 {
2282 public:
2283 Actor *self;
2284
2285 inline qboolean done
2286 (
2287 PathNode *node,
2288 PathNode *end
2289 )
2290
2291 {
2292 if ( node == end )
2293 {
2294 return true;
2295 }
2296
2297 if ( node->reject )
2298 {
2299 return false;
2300 }
2301
2302 if ( self )
2303 {
2304 if ( self->currentEnemy )
2305 {
2306 node->reject = !self->CanShootFrom( node->origin, self->currentEnemy, false );
2307 }
2308 else
2309 {
2310 node->reject = false;
2311 }
2312
2313 return !node->reject;
2314 }
2315
2316 return false;
2317 }
2318 };
2319
2320typedef PathFinder<FindCoverMovement> FindCoverPath;
2321typedef PathFinder<FindFleeMovement> FindFleePath;
2322typedef PathFinder<FindEnemyMovement> FindEnemyPath;
2323#endif
2324
2325/*void AI_TargetPlayer( void );
2326
2327class SpinningPlant : public Actor
2328 {
2329 public:
2330 Mover *spinner_model;
2331 Mover *spinner_clip;
2332
2333 CLASS_PROTOTYPE( SpinningPlant );
2334
2335 SpinningPlant();
2336 ~SpinningPlant();
2337
2338 void GetClip( Event *ev );
2339 };
2340*/
Definition actorenemy.h:99
Definition actor.h:586
Definition archive.h:87
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