This repository has been archived by the owner on Sep 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
actor.h
1344 lines (1159 loc) · 34.8 KB
/
actor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//-----------------------------------------------------------------------------
//
// $Logfile:: /Quake 2 Engine/Sin/code/game/actor.h $
// $Revision:: 90 $
// $Author:: Jimdose $
// $Date:: 1/29/99 7:02p $
//
// Copyright (C) 1998 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// $Log:: /Quake 2 Engine/Sin/code/game/actor.h $
//
// 90 1/29/99 7:02p Jimdose
// added 2015 changes
//
// 89 11/09/98 6:23p Markd
// Added turnspeed event
//
// 88 11/08/98 7:07p Markd
// added nochatter command
//
// 87 11/08/98 6:57p Jimdose
// reordered some variables in archive and unarchive so that they match the
// order they're defined in the class
//
// 86 11/07/98 3:34p Markd
// Added nodeathfade command
//
// 85 11/06/98 8:25p Jimdose
// made visiondistance adjustable from script
//
// 84 10/27/98 9:41p Jimdose
// made gun orienting functions virtual
//
// 83 10/27/98 7:53p Jimdose
// added IfEnemyWithinEvent
//
// 82 10/27/98 1:50a Markd
// Made Chatter a virtual void function
//
// 81 10/26/98 2:19p Markd
// Added last_jump_time
//
// 80 10/25/98 11:52p Jimdose
// added EXPORT_TEMPLATE
//
// 79 10/25/98 4:43a Markd
// Added animal events
//
// 78 10/24/98 3:10p Markd
// Put in eyeoffset command
//
// 77 10/22/98 9:29p Aldie
// Added support for deathgib animations
//
// 76 10/20/98 2:37a Markd
// Added additional JumpTo methods
//
// 75 10/20/98 12:44a Markd
// Added setSize and setHealth
//
// 74 10/17/98 11:02p Markd
// Added ifcanshoot
//
// 73 10/17/98 4:59p Markd
// Added Attackmode event
//
// 72 10/16/98 7:19p Markd
// Added a bunch of new events
//
// 71 10/16/98 1:41a Jimdose
// Added goto command for actors. This helps the all too common mistake of
// typing "local.self goto label"
//
// 70 10/14/98 5:22p Markd
// Added jumpto and jumpto function
//
// 69 10/14/98 2:17a Markd
// Added in ifcanmeleeattack event
//
// 68 10/14/98 1:27a Markd
// Added HasWeapon method
//
// 67 10/13/98 9:11p Markd
// Externed Actor_AttackEntity Actor_AttackPlayer
//
// 66 10/11/98 5:01p Markd
// Added variables to keep track of drowning and lack of oxygen
//
// 65 10/11/98 12:32a Markd
// Added AirMove
//
// 64 10/10/98 7:59p Markd
// Added painthreshold and snd_pain_taunt
//
// 63 10/10/98 6:08p Markd
// Added FleeAndRemove, FindFlee, fixed max_ainode bug
//
// 62 10/10/98 1:25a Jimdose
// Did some bulletproofing against possible NULL actorthread
// Prethink kills actors with NULL threads
// added SetVariable for setting thread variables safely
// stateStack is now properly archived without destroying its contents
//
// 61 10/06/98 5:26p Markd
// Made MakeEnemy and DoAction take the force parameter
//
// 60 10/06/98 12:14p Markd
// Added ForceAction
//
// 59 10/05/98 10:33p Markd
// Added nostrafe and canstrafe
//
// 58 10/05/98 2:25a Jimdose
// Made archive functions properly handle NULL behaviors
//
// 57 10/04/98 10:26p Markd
// Added AttackFinishedEvent
//
// 56 10/03/98 7:27p Markd
// working on swimming character and redid some weapon aiming stuff
//
// 55 10/01/98 8:01p Markd
// Added melee variables
//
// 54 9/30/98 1:18p Markd
// Added actor melee variables
//
// 53 9/29/98 5:58p Markd
// put in archive and unarchive
//
// 52 9/24/98 7:10p Jimdose
// Added MyGunAngles
//
// 51 9/22/98 5:11p Jimdose
// made the anim variables public
//
// 50 9/22/98 5:31a Jimdose
// Added attackmode
//
// 49 9/22/98 1:58a Jimdose
// Added lastmove and forwardspeed
// Regrouped functions by functionality
//
// 48 9/19/98 6:16p Jimdose
// Added AttackPlayer
//
// 47 9/18/98 10:55p Jimdose
// Added inanimate actor type
// started work on swimming monsters
// added showinfo
//
// 46 9/14/98 5:26p Jimdose
// ProcessScript now allows events to be passed in
//
// 45 8/26/98 11:13p Jimdose
// Began strafe support
//
// 44 8/24/98 6:56p Jimdose
// Added crouching pain and death animations
// Added path
// Moved hueristics for path finding to actor
//
// 43 8/19/98 3:59p Jimdose
// Added IfNearEvent and CopyStateEvent
//
// 42 8/19/98 2:30p Jimdose
// Can no longer alias "alert" to "idle" so I've added a hasalert variable
//
// 41 8/14/98 11:34p Jimdose
// added seenenemy
//
// 40 8/14/98 6:24p Jimdose
// Got rid of decelleration for steering
//
// 39 8/07/98 7:57p Markd
// Added ForwardToBehavior event
//
// 38 8/07/98 6:02p Jimdose
// Added NotifyBehavior
//
// 37 8/06/98 6:59p Jimdose
// Added IfEnemyVisible
//
// 36 8/05/98 7:19p Jimdose
// Added definestate, ignoresounds, respondtosounds, respondtoall
// Added StateInfo
//
// 35 7/29/98 6:32p Jimdose
// Added MonsterStart
//
// 34 7/26/98 11:43a Jimdose
// Added EnemyCanSeeMeFrom
//
// 33 7/26/98 3:49a Jimdose
// Modified aim based on skill
//
// 32 7/25/98 2:12a Jimdose
// Made trig a TouchFieldPtr
//
// 31 7/24/98 3:10p Jimdose
// Removed ignore enemies stuff
//
// 30 7/22/98 7:03p Aldie
// Remove useless bodies
//
// 29 7/14/98 11:49p Jimdose
// Made PopState return whether a new state was popped off the stack
//
// 28 7/08/98 12:58p Jimdose
// added min and max for crouch and stand sizes
//
// 27 7/08/98 12:56p Jimdose
// added crouchsize and standsize
//
// 26 7/07/98 11:37p Jimdose
// Replaced priority-based system with full script-based state system
//
// 25 7/06/98 1:06p Jimdose
// working on ai
//
// 24 7/06/98 1:06p Jimdose
// working on ai
//
// 23 6/30/98 6:49p Aldie
// Added Gib event
//
// 22 6/30/98 6:00p Jimdose
// Added more states and state detection code.
// Added range detection
// added health level detection
//
// 21 6/25/98 8:11p Jimdose
// Added global actor scripts
//
// 20 6/19/98 9:29p Jimdose
// Added GetGunOrientation
//
// 19 6/19/98 5:53p Jimdose
// Added InFOV
//
// 18 6/18/98 8:45p Jimdose
// Removed string based SetBehavior and PushState functions
//
// 17 6/17/98 1:16a Jimdose
// Moved setOwner to Item.
// Added EV_Item_Pickup
//
// 16 6/13/98 8:22p Jimdose
// Added some enemy visibility functions for FindCover
//
// 15 6/11/98 12:44a Jimdose
// behaviors now get info from the script at startup
//
// 14 6/10/98 10:25p Jimdose
// Added priority based state system
//
// 13 6/09/98 4:24p Jimdose
// worked on ai
//
// 12 6/04/98 10:48p Jimdose
// Fixed a bunch of things that got broken just in time for E3. Paths and
// scripting actually work now.
//
// 11 6/03/98 5:44p Jimdose
// Fixed spelling of behavior. :)
//
// 10 5/27/98 5:11a Jimdose
// working on ai
//
// 9 5/25/98 6:47p Jimdose
// Made animateframe, prethink and posthink into functions built into the base
// entity class
//
// 8 5/25/98 5:31p Jimdose
// Pathnodes are no longer a subclass of Entity. This was done to save on
// edicts
//
// 7 5/25/98 1:06a Jimdose
// Added chatter
//
// 6 5/24/98 1:02a Jimdose
// Added monster hearing
//
// 5 5/23/98 6:29p Jimdose
// changed waitfordoor to a float
//
// 4 5/22/98 9:39p Jimdose
// Worked on ai
//
// 3 5/20/98 6:38p Jimdose
// working on ai
//
// 2 5/18/98 8:15p Jimdose
// Created file
//
// DESCRIPTION:
// Base class for character AI.
//
#ifndef __ACTOR_H__
#define __ACTOR_H__
#include "g_local.h"
#include "weapon.h"
#include "sentient.h"
#include "container.h"
#include "stack.h"
#include "navigate.h"
#include "behavior.h"
#include "scriptmaster.h"
#include "prioritystack.h"
extern Event EV_Actor_Start;
extern Event EV_Actor_Dead;
extern Event EV_Actor_PopAnim;
extern Event EV_Actor_LookAt;
extern Event EV_Actor_TurnTo;
extern Event EV_Actor_FinishedBehavior;
extern Event EV_Actor_NotifyBehavior;
extern Event EV_Actor_FinishedMove;
extern Event EV_Actor_FinishedAnim;
extern Event EV_Actor_WalkTo;
extern Event EV_Actor_RunTo;
extern Event EV_Actor_Anim;
extern Event EV_Actor_Attack;
extern Event EV_Actor_InPain;
extern Event EV_Actor_Gib;
extern Event EV_Actor_ForwardToBehavior;
extern Event EV_Actor_Aim;
extern Event EV_Actor_MeleeRange;
extern Event EV_Actor_MeleeDamage;
extern Event EV_Actor_AttackFinished;
extern Event EV_Actor_Attack;
extern Event EV_Actor_AttackPlayer;
typedef enum
{
RANGE_MELEE,
RANGE_NEAR,
RANGE_MID,
RANGE_FAR
} range_t;
typedef enum
{
ON_SIGHT,
ON_ATTACK
};
typedef enum
{
IGNORE,
ATTACK,
FLEE,
} reaction_t;
typedef enum
{
LIKES, // Will not fire at, even if attacked
TOLERATES, // Will attack when attacked
HATES, // Will attack on sight
WARY, // Will flee when attacked
FEARS, // Will flee on sight
NUM_DISPOSITIONS
} disposition_t;
typedef enum
{
IS_INANIMATE,
IS_MONSTER,
IS_ENEMY,
IS_CIVILIAN,
IS_FRIEND,
IS_ANIMAL,
NUM_ACTORTYPES
} actortype_t;
#define AI_CANWALK 0x00000001
#define AI_CANSWIM 0x00000002
#define AI_CANFLY 0x00000004
#define WEAK_WEIGHT 0.5
#define WEAK_HEALTH 20
#define STRONGER_WEIGHT 0.9
#define VISIBLE_WEIGHT 0.5
#define NEWENEMY_WEIGHT 0.75 // if he's a new enemy
//#define DAMAGE_WEIGHT 0.5 // If he's done a lot of damage to you
//#define WEAPON_WEIGHT 1.5 // How much the weapon influences you
class EXPORT_FROM_DLL StateInfo : public Class
{
public:
CLASS_PROTOTYPE( StateInfo );
StateInfo();
str action;
str response;
qboolean ignore;
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void StateInfo::Archive
(
Archiver &arc
)
{
Class::Archive( arc );
arc.WriteString( action );
arc.WriteString( response );
arc.WriteBoolean( ignore );
}
inline EXPORT_FROM_DLL void StateInfo::Unarchive
(
Archiver &arc
)
{
Class::Unarchive( arc );
arc.ReadString( &action );
arc.ReadString( &response );
arc.ReadBoolean( &ignore );
}
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL Container<StateInfo *>;
#endif
class EXPORT_FROM_DLL ActorState : public Class
{
public:
CLASS_PROTOTYPE( ActorState );
str name;
str anim;
Event *animDoneEvent;
Behavior *behavior;
PathPtr path;
int thread;
ThreadMarker marker;
Container<StateInfo *> actionList;
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
};
inline EXPORT_FROM_DLL void ActorState::Archive
(
Archiver &arc
)
{
int i, num;
Class::Archive( arc );
arc.WriteString( name );
arc.WriteString( anim );
arc.WriteEvent( *animDoneEvent );
//FIXME
arc.WriteBoolean( behavior != NULL );
if ( behavior )
{
arc.WriteObject( behavior );
}
arc.WriteSafePointer( path );
arc.WriteInteger( thread );
arc.WriteObject( &marker );
num = actionList.NumObjects();
arc.WriteInteger( num );
for ( i = 1; i <= num; i++ )
{
arc.WriteObject( actionList.ObjectAt( i ) );
}
}
inline EXPORT_FROM_DLL void ActorState::Unarchive
(
Archiver &arc
)
{
Event * ev;
int i, num;
Class::Unarchive( arc );
arc.ReadString( &name );
arc.ReadString( &anim );
ev = new Event;
arc.ReadEvent( ev );
animDoneEvent = ev;
//FIXME
behavior = NULL;
if ( arc.ReadBoolean() )
{
behavior = ( Behavior * )arc.ReadObject();
}
arc.ReadSafePointer( &path );
arc.ReadInteger( &thread );
arc.ReadObject( &marker );
actionList.FreeObjectList();
arc.ReadInteger( &num );
for ( i = 1; i <= num; i++ )
{
StateInfo * info;
info = new StateInfo;
arc.ReadObject( info );
actionList.AddObject( info );
}
}
//
// Exported templated classes must be explicitly instantiated
//
#ifdef EXPORT_TEMPLATE
template class EXPORT_FROM_DLL Container<EntityPtr>;
template class EXPORT_FROM_DLL Stack<ActorState *>;
#endif
class EXPORT_FROM_DLL Actor : public Sentient
{
public:
str newanim;
Event *newanimevent;
int newanimnum;
str spawngroup;
int movement;
stepmoveresult_t lastmove;
float forwardspeed;
actortype_t actortype;
int attackmode;
Vector standsize_min;
Vector standsize_max;
Vector crouchsize_min;
Vector crouchsize_max;
str state;
str animname;
Container<StateInfo *> actionList;
int numonstack;
Stack<ActorState *> stateStack;
BehaviorPtr behavior;
str currentBehavior;
PathPtr path;
Container<EntityPtr> targetList;
Container<EntityPtr> nearbyList;
Container<EntityPtr> enemyList;
EntityPtr currentEnemy;
qboolean seenEnemy;
range_t enemyRange;
EntityPtr lastEnemy;
float fov;
float fovdot;
float vision_distance;
Vector startpos;
Vector move;
Vector movedir;
float movespeed;
Vector movevelocity;
float totallen;
float turnspeed;
Vector animdir;
float chattime;
float nextsoundtime;
qboolean hasalert;
PathNodePtr movegoal;
PathNodePtr soundnode;
ThreadPtr thread;
ThreadPtr actorthread;
str actorscript;
str actorstart;
TouchFieldPtr trig;
qboolean has_melee;
float melee_damage;
float melee_range;
float aim;
float pain_threshold;
qboolean checkStrafe;
float next_drown_time;
float air_finished;
float attack_range;
float shots_per_attack;
qboolean deathgib;
str kill_thread;
Vector eyeoffset;
float last_jump_time;
qboolean nodeathfade;
qboolean nochatter;
CLASS_PROTOTYPE( Actor );
// Initialization functions
Actor();
~Actor();
void Start( Event *ev );
// Vision functions
range_t Range( Entity *ent );
qboolean InFOV( Vector pos );
qboolean InFOV( Entity *ent );
qboolean CanSeeFOV( Entity *ent );
qboolean CanSeeFrom( Vector pos, Entity *ent );
qboolean CanSee( Entity *ent );
int EnemyCanSeeMeFrom( Vector pos );
qboolean CanSeeEnemyFrom( Vector pos );
// Weapon functions
qboolean WeaponReady( void );
void Attack( Event *ev );
virtual Vector GunPosition( void );
virtual Vector MyGunAngles( Vector muzzlepos, qboolean firing );
virtual void GetGunOrientation( Vector muzzlepos, Vector *forward, Vector *right, Vector *up );
virtual qboolean CanShootFrom( Vector pos, Entity *ent, qboolean usecurrentangles );
virtual qboolean CanShoot( Entity *ent, qboolean usecurrentangles );
// Actor type script commands
void FriendEvent( Event *ev );
void CivilianEvent( Event *ev );
void EnemyEvent( Event *ev );
void InanimateEvent( Event *ev );
void MonsterEvent( Event *ev );
void AnimalEvent( Event *ev );
// Enemy management
qboolean HasEnemies( void );
qboolean IsEnemy( Entity *ent );
void MakeEnemy( Entity *ent, qboolean force = false );
qboolean Likes( Entity *ent );
qboolean Hates( Entity *ent );
// Targeting functions
qboolean GetVisibleTargets( void );
void TargetEnemies( Event *ev );
Entity *BestTarget( void );
Sentient *NearFriend( void );
qboolean CloseToEnemy( Vector pos, float howclose );
float AttackRange( void );
float MinimumAttackRange( void );
// State control functions
void EnableState( str action );
void DisableState( str action );
StateInfo *SetResponse( str action, str response, qboolean ignore = false );
const char *GetResponse( str action, qboolean force = false );
StateInfo *GetState( str action );
// State stack management
void ClearStateStack( void );
qboolean PopState( void );
void PushState( const char *newstate, ScriptThread *newthread = NULL, ThreadMarker *marker = NULL );
// State control script commands
void DefineStateEvent( Event *ev );
void CopyStateEvent( Event *ev );
void IgnoreAllEvent( Event *ev );
void IgnoreEvent( Event *ev );
void RespondToAllEvent( Event *ev );
void RespondToEvent( Event *ev );
void ClearStateEvent( Event *ev );
void StateDoneEvent( Event *ev );
void SetStateEvent( Event *ev );
// Thread management
void SetupThread( void );
qboolean DoAction( str name, qboolean force = false );
qboolean ForceAction( str name );
void ProcessScript( ScriptThread *thread, Event *ev = NULL );
void StartMove( Event *ev );
ScriptVariable *SetVariable( const char *name, float value );
ScriptVariable *SetVariable( const char *name, int value );
ScriptVariable *SetVariable( const char *name, const char *text );
ScriptVariable *SetVariable( const char *name, str &text );
ScriptVariable *SetVariable( const char *name, Entity *ent );
ScriptVariable *SetVariable( const char *name, Vector &vec );
// Thread based script commands
void SetScript( Event *ev );
void SetThread( Event *ev );
// Behavior management
void EndBehavior( void );
void SetBehaviorEvent( Event *ev );
void SetBehavior( Behavior *newbehavior, Event *argevent = NULL, ScriptThread *thread = NULL );
void FinishedBehavior( Event *ev );
void NotifyBehavior( Event *ev );
void ForwardBehaviorEvent( Event *ev );
// Path and node management
void SetPath( Path *newpath );
void ReserveNodeEvent( Event *ev );
void ReleaseNodeEvent( Event *ev );
// Animation control functions
void ChangeAnim( void );
qboolean SetAnim( str anim, Event *ev = NULL );
qboolean SetAnim( str anim, Event &ev );
void Anim( Event *ev );
// Script commands
void CrouchSize( Event *ev );
void SetFov( Event *ev );
void SetVisionDistance( Event *ev );
void LookAt( Event *ev );
void TurnToEvent( Event *ev );
void IdleEvent( Event *ev );
void WalkTo( Event *ev );
void RunTo( Event *ev );
void AttackEntity( Event *ev );
void AttackPlayer( Event *ev );
void JumpToEvent( Event *ev );
void GotoEvent( Event *ev );
// Script conditionals
void IfEnemyVisibleEvent( Event *ev );
void IfNearEvent( Event *ev );
void IfCanHideAtEvent( Event *ev );
void IfCanStrafeAttackEvent( Event *ev );
void IfCanMeleeAttackEvent( Event *ev );
void IfCanShootEvent( Event *ev );
void IfEnemyWithinEvent( Event *ev );
// Sound reaction functions
void IgnoreSoundsEvent( Event *ev );
void RespondToSoundsEvent( Event *ev );
void InvestigateWeaponSound( Event *ev );
void InvestigateMovementSound( Event *ev );
void InvestigatePainSound( Event *ev );
void InvestigateDeathSound( Event *ev );
void InvestigateBreakingSound( Event *ev );
void InvestigateDoorSound( Event *ev );
void InvestigateMutantSound( Event *ev );
void InvestigateVoiceSound( Event *ev );
void InvestigateMachineSound( Event *ev );
void InvestigateRadioSound( Event *ev );
// Pain and death related functions
void Pain( Event *ev );
void Dead( Event *ev );
void Killed( Event *ev );
void GibEvent( Event *ev );
void RemoveUselessBody( Event *ev );
// Movement functions
void ForwardSpeedEvent( Event *ev );
void SwimEvent( Event *ev );
void FlyEvent( Event *ev );
void NotLandEvent( Event *ev );
qboolean CanMoveTo( Vector pos );
void Accelerate( Vector steering );
void CalcMove( void );
void setAngles( Vector ang );
stepmoveresult_t WaterMove( void );
stepmoveresult_t AirMove( void );
stepmoveresult_t TryMove( void );
void CheckWater( void );
virtual void setSize( Vector min, Vector max );
// Debug functions
void ShowInfo( void );
// General functions
virtual void Chatter( const char *sound, float chance = 10, float volume = 1.0f, int channel = CHAN_VOICE );
void ActivateEvent( Event *ev );
void UseEvent( Event *ev );
void Prethink( void );
virtual void Archive( Archiver &arc );
virtual void Unarchive( Archiver &arc );
void SetAim( Event *ev );
void SetMeleeRange( Event *ev );
void SetMeleeDamage( Event *ev );
void MeleeEvent( Event *ev );
void AttackFinishedEvent( Event *ev );
void CanStrafeEvent( Event *ev );
void NoStrafeEvent( Event *ev );
void SetPainThresholdEvent( Event *ev );
void SetKillThreadEvent( Event *ev );
void AttackRangeEvent( Event *ev );
void AttackModeEvent( Event *ev );
void ShotsPerAttackEvent( Event *ev );
void ClearEnemyEvent( Event *ev );
void SetHealth( Event *ev );
void ClearEnemies( void );
void EyeOffset( Event *ev );
void NoDeathFadeEvent( Event *ev );
void NoChatterEvent( Event *ev );
void TurnSpeedEvent( Event *ev );
qboolean HasWeapon( void );
float JumpTo( PathNode * goal, float speed );
float JumpTo( Entity * goal, float speed );
float JumpTo( Vector targ, float speed );
};
inline EXPORT_FROM_DLL void Actor::Archive
(
Archiver &arc
)
{
int i, num;
Stack<ActorState *> tempStack;
ActorState *s;
Sentient::Archive( arc );
arc.WriteString( newanim );
arc.WriteEvent( *newanimevent );
arc.WriteInteger( newanimnum );
arc.WriteString( spawngroup );
arc.WriteInteger( movement );
// cast as stepmoveresult_t on read
arc.WriteInteger( ( int )lastmove );
arc.WriteFloat( forwardspeed );
// cast as actortype_t on read
arc.WriteInteger( ( int )actortype );
arc.WriteInteger( attackmode );
arc.WriteVector( standsize_min );
arc.WriteVector( standsize_max );
arc.WriteVector( crouchsize_min );
arc.WriteVector( crouchsize_max );
arc.WriteString( state );
arc.WriteString( animname );
num = actionList.NumObjects();
arc.WriteInteger( num );
for ( i = 1; i <= num; i++ )
{
arc.WriteObject( actionList.ObjectAt( i ) );
}
arc.WriteInteger( numonstack );
// We have to push all the states onto another stack in order to
// save them out in the proper order and to restore them after
// saving the game.
for( i = 1; i <= numonstack; i++ )
{
tempStack.Push( stateStack.Pop() );
}
// put them back on the stateStack as we write them out.
for( i = 1; i <= numonstack; i++ )
{
s = tempStack.Pop();
stateStack.Push( s );
arc.WriteObject( s );
}
// FIXME
arc.WriteBoolean( behavior != NULL );
if ( behavior )
{
arc.WriteObject( behavior );
}
arc.WriteString( currentBehavior );
arc.WriteSafePointer( path );
num = targetList.NumObjects();
arc.WriteInteger( num );
for ( i = 1; i <= num; i++ )
{
arc.WriteSafePointer( targetList.ObjectAt( i ) );
}
num = nearbyList.NumObjects();
arc.WriteInteger( num );
for ( i = 1; i <= num; i++ )
{
arc.WriteSafePointer( nearbyList.ObjectAt( i ) );
}
num = enemyList.NumObjects();
arc.WriteInteger( num );
for ( i = 1; i <= num; i++ )
{
arc.WriteSafePointer( enemyList.ObjectAt( i ) );
}
arc.WriteSafePointer( currentEnemy );
arc.WriteBoolean( seenEnemy );
// cast as range_t on read
arc.WriteInteger( ( int )enemyRange );
arc.WriteSafePointer( lastEnemy );
arc.WriteFloat( fov );
arc.WriteFloat( fovdot );
arc.WriteFloat( vision_distance );
arc.WriteVector( startpos );
arc.WriteVector( move );
arc.WriteVector( movedir );
arc.WriteFloat( movespeed );
arc.WriteVector( movevelocity );
arc.WriteFloat( totallen );
arc.WriteFloat( turnspeed );
arc.WriteVector( animdir );
arc.WriteFloat( chattime );
arc.WriteFloat( nextsoundtime );
arc.WriteBoolean( hasalert );
arc.WriteSafePointer( movegoal );
arc.WriteSafePointer( soundnode );
arc.WriteSafePointer( thread );
arc.WriteSafePointer( actorthread );
arc.WriteString( actorscript );
arc.WriteString( actorstart );
arc.WriteSafePointer( trig );
arc.WriteBoolean( has_melee );
arc.WriteFloat( melee_damage );
arc.WriteFloat( melee_range );
arc.WriteFloat( aim );
arc.WriteFloat( pain_threshold );
arc.WriteBoolean( checkStrafe );
arc.WriteFloat( next_drown_time );
arc.WriteFloat( air_finished );
arc.WriteFloat( attack_range );
arc.WriteFloat( shots_per_attack );
arc.WriteBoolean( deathgib );
arc.WriteString( kill_thread );
arc.WriteVector( eyeoffset );
arc.WriteFloat( last_jump_time );
arc.WriteBoolean( nodeathfade );
arc.WriteBoolean( nochatter );
}
inline EXPORT_FROM_DLL void Actor::Unarchive
(
Archiver &arc
)
{
Event * ev;
int i, num, temp;
Sentient::Unarchive( arc );
arc.ReadString( &newanim );
ev = new Event;
arc.ReadEvent( ev );
newanimevent = ev;
arc.ReadInteger( &newanimnum );
arc.ReadString( &spawngroup );
arc.ReadInteger( &movement );
// cast as stepmoveresult_t on read
temp = arc.ReadInteger();
lastmove = ( stepmoveresult_t )temp;
arc.ReadFloat( &forwardspeed );
// cast as actortype_t on read
temp = arc.ReadInteger();
actortype = ( actortype_t )temp;
arc.ReadInteger( &attackmode );