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
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef HDB_AI_H
#define HDB_AI_H
#include "common/system.h"
namespace HDB {
enum {
kMaxAnimFrames = 8,
kMaxAnimTFrames = 16,
kMaxDeathFrames = 12,
kMaxLevel2Ents = 60,
kMaxInventory = 10,
kMaxDeliveries = 5,
kMaxWaypoints = 10,
kMaxActions = 20,
kMaxAutoActions = 30,
kPlayerMoveSpeed = 4,
kEnemyMoveSpeed = 2,
kPushMoveSpeed = (kPlayerMoveSpeed >> 1)
};
enum AIType {
AI_NONE,
AI_GUY,
AI_DOLLY,
AI_SPACEDUDE,
AI_SERGEANT,
AI_SCIENTIST,
AI_WORKER,
AI_DEADWORKER,
AI_ACCOUNTANT,
AI_RAILRIDER,
AI_RAILRIDER_ON,
AI_VORTEXIAN,
AI_CHICKEN,
AI_GEM_ATTACK,
AI_SLUG_ATTACK,
AI_LASER,
AI_LASERBEAM,
AI_DIVERTER,
AI_FOURFIRER,
AI_OMNIBOT,
AI_TURNBOT,
AI_SHOCKBOT,
AI_RIGHTBOT,
AI_PUSHBOT,
AI_LISTENBOT,
AI_MAINTBOT,
AI_OMNIBOT_MISSILE,
AI_DEADEYE,
AI_MEERKAT,
AI_FATFROG,
AI_GOODFAIRY,
AI_BADFAIRY,
AI_ICEPUFF,
AI_BUZZFLY,
AI_DRAGON,
AI_GATEPUDDLE,
AI_CRATE,
AI_LIGHTBARREL,
AI_HEAVYBARREL,
AI_BOOMBARREL,
AI_FROGSTATUE,
AI_MAGIC_EGG,
AI_ICE_BLOCK,
ITEM_CELL,
ITEM_ENV_WHITE,
ITEM_ENV_RED,
ITEM_ENV_BLUE,
ITEM_ENV_GREEN,
ITEM_TRANSCEIVER,
ITEM_CLUB,
ITEM_ROBOSTUNNER,
ITEM_SLUGSLINGER,
ITEM_MONKEYSTONE,
ITEM_GEM_WHITE,
ITEM_GEM_BLUE,
ITEM_GEM_RED,
ITEM_GEM_GREEN,
ITEM_GOO_CUP,
ITEM_TEACUP,
ITEM_COOKIE,
ITEM_BURGER,
ITEM_PDA,
ITEM_BOOK,
ITEM_CLIPBOARD,
ITEM_NOTE,
ITEM_KEYCARD_WHITE,
ITEM_KEYCARD_BLUE,
ITEM_KEYCARD_RED,
ITEM_KEYCARD_GREEN,
ITEM_KEYCARD_PURPLE,
ITEM_KEYCARD_BLACK,
ITEM_CABKEY,
ITEM_DOLLYTOOL1,
ITEM_DOLLYTOOL2,
ITEM_DOLLYTOOL3,
ITEM_DOLLYTOOL4,
ITEM_SEED,
ITEM_SODA,
ITEM_ROUTER,
ITEM_SLICER,
ITEM_CHICKEN,
ITEM_PACKAGE,
INFO_FAIRY_SRC,
INFO_FAIRY_SRC2,
INFO_FAIRY_SRC3,
INFO_FAIRY_SRC4,
INFO_FAIRY_SRC5,
INFO_FAIRY_DEST,
INFO_FAIRY_DEST2,
INFO_FAIRY_DEST3,
INFO_FAIRY_DEST4,
INFO_FAIRY_DEST5,
INFO_TRIGGER,
INFO_SET_MUSIC,
INFO_PROMOTE,
INFO_DEMOTE,
INFO_LUA,
INFO_HERE,
INFO_ARROW_TURN,
INFO_ARROW_STOP,
INFO_ARROW_4WAY,
INFO_TELEPORTER1,
INFO_TELEPORTER2,
INFO_TELEPORTER3,
INFO_TELEPORTER4,
INFO_TELEPORTER5,
INFO_TELEPORTER6,
INFO_TELEPORTER7,
INFO_TELEPORTER8,
INFO_TELEPORTER9,
INFO_TELEPORTER10,
INFO_TELEPORTER11,
INFO_TELEPORTER12,
INFO_TELEPORTER13,
INFO_TELEPORTER14,
INFO_TELEPORTER15,
INFO_TELEPORTER16,
INFO_TELEPORTER17,
INFO_TELEPORTER18,
INFO_TELEPORTER19,
INFO_TELEPORTER20,
INFO_LEVELEXIT,
INFO_ACTION1,
INFO_ACTION2,
INFO_ACTION3,
INFO_ACTION4,
INFO_ACTION5,
INFO_ACTION6,
INFO_ACTION7,
INFO_ACTION8,
INFO_ACTION9,
INFO_ACTION10,
INFO_ACTION11,
INFO_ACTION12,
INFO_ACTION13,
INFO_ACTION14,
INFO_ACTION15,
INFO_ACTION16,
INFO_ACTION17,
INFO_ACTION18,
INFO_ACTION19,
INFO_ACTION20,
INFO_ACTION_AUTO,
INFO_QMARK,
INFO_DEBUG,
END_AI_TYPES
};
enum AIDir {
DIR_NONE,
DIR_UP,
DIR_DOWN,
DIR_LEFT,
DIR_RIGHT
};
enum Death {
DEATH_NORMAL,
DEATH_FRIED,
DEATH_DROWNED,
DEATH_GRABBED,
DEATH_SHOCKED,
DEATH_PANICZONE,
DEATH_PLUMMET
};
enum AIState {
STATE_NONE,
STATE_STANDDOWN,
STATE_STANDUP,
STATE_STANDLEFT,
STATE_STANDRIGHT,
STATE_BLINK,
STATE_MOVEUP,
STATE_MOVEDOWN,
STATE_MOVELEFT,
STATE_MOVERIGHT,
STATE_DYING,
STATE_DEAD,
STATE_HORRIBLE1,
STATE_HORRIBLE2,
STATE_HORRIBLE3,
STATE_HORRIBLE4,
STATE_GOODJOB,
STATE_PLUMMET,
STATE_PUSHUP, // these are only used for the player
STATE_PUSHDOWN,
STATE_PUSHLEFT,
STATE_PUSHRIGHT,
STATE_GRABUP, // player grabbing something
STATE_GRABDOWN,
STATE_GRABLEFT,
STATE_GRABRIGHT,
STATE_ATK_CLUB_UP, // player attacking frames
STATE_ATK_CLUB_DOWN,
STATE_ATK_CLUB_LEFT,
STATE_ATK_CLUB_RIGHT,
STATE_ATK_STUN_DOWN,
STATE_ATK_STUN_UP,
STATE_ATK_STUN_LEFT,
STATE_ATK_STUN_RIGHT,
STATE_ATK_SLUG_DOWN,
STATE_ATK_SLUG_UP,
STATE_ATK_SLUG_LEFT,
STATE_ATK_SLUG_RIGHT,
STATE_FLOATING, // floating in stuff (can walk on)
STATE_FLOATDOWN,
STATE_FLOATUP,
STATE_FLOATLEFT,
STATE_FLOATRIGHT,
STATE_MELTED, // melted into slag (can walk on)
STATE_SLIDING, // sliding across a floor
STATE_SHOCKING, // for Shockbot floor-shock anim
STATE_EXPLODING, // boom barrel explosion!
STATE_USEDOWN, // crazy maintenance bot!
STATE_USEUP,
STATE_USELEFT,
STATE_USERIGHT,
STATE_MEER_MOVE, // for the Meerkat
STATE_MEER_APPEAR,
STATE_MEER_BITE,
STATE_MEER_DISAPPEAR,
STATE_MEER_LOOK,
STATE_ICEP_PEEK, // for the Icepuff
STATE_ICEP_APPEAR,
STATE_ICEP_THROWDOWN,
STATE_ICEP_THROWRIGHT,
STATE_ICEP_THROWLEFT,
STATE_ICEP_DISAPPEAR,
STATE_LICKDOWN, // for the Fatfrog
STATE_LICKLEFT,
STATE_LICKRIGHT,
STATE_DIVERTER_BL, // for Diverters
STATE_DIVERTER_BR,
STATE_DIVERTER_TL,
STATE_DIVERTER_TR,
STATE_KISSRIGHT, // for Dolly
STATE_KISSLEFT,
STATE_ANGRY,
STATE_PANIC,
STATE_LAUGH,
STATE_DOLLYUSERIGHT,
STATE_YELL, // for Sarge
STATE_ENDSTATES
};
enum AnimSpeed {
ANIM_SLOW,
ANIM_NORMAL,
ANIM_FAST
};
enum CineType {
C_NO_COMMAND,
C_STOPCINE,
C_LOCKPLAYER,
C_UNLOCKPLAYER,
C_SETCAMERA,
C_MOVECAMERA,
C_WAIT,
C_WAITUNTILDONE,
C_MOVEENTITY,
C_DIALOG,
C_ANIMENTITY,
C_RESETCAMERA,
C_SETENTITY,
C_STARTMAP,
C_MOVEPIC,
C_MOVEMASKEDPIC,
C_DRAWPIC,
C_DRAWMASKEDPIC,
C_FADEIN,
C_FADEOUT,
C_SPAWNENTITY,
C_PLAYSOUND,
C_CLEAR_FG,
C_SET_FG,
C_SET_BG,
C_FUNCTION,
C_ENTITYFACE,
C_USEENTITY,
C_REMOVEENTITY,
C_SETANIMFRAME,
C_TEXTOUT,
C_CENTERTEXTOUT,
C_PLAYVOICE,
C_ENDLIST
};
struct AIStateDef {
AIState state;
const char name[64];
};
struct AIEntity {
AIType type;
AIState state;
AIDir dir;
Tile *draw; // Current frame to draw
void (*aiInit)(AIEntity *e); // func ptr to init routine
void (*aiInit2)(AIEntity *e); // func ptr to init2 routine - graphic init only (this for LoadGame functionality)
void (*aiAction)(AIEntity *e); // func ptr to action routine
void (*aiUse)(AIEntity *e); // func ptr to use routine
void (*aiDraw)(AIEntity *e, int x, int y); // func ptr to extra drawing routine (only for special stuff) - pass in mapx, mapy
char luaFuncInit[32]; // Lua function for Init (always called after entity's init). These are ptrs into the map header.
char luaFuncAction[32]; // Lua function for Action
char luaFuncUse[32]; // Lua function for Use
uint16 level; // which floor level we're on
uint16 value1, value2; // extra values we might need
AIDir dir2; // this is from TED
uint16 x, y;
uint16 drawXOff, drawYOff; // might need a drawing offset
uint16 onScreen; // FLAG: is this entity onscreen?
uint16 moveSpeed; // movement speed of this entity
int16 xVel, yVel; // movement values
uint16 tileX, tileY;
uint16 goalX, goalY; // where we're trying to go - TILE COORDS
uint16 touchpX, touchpY, touchpTile, touchpWait; // ACTION index a touchplate is using, which you're on
uint32 stunnedWait; // if we're stunned, this is the delay before being normal again
uint16 sequence; // to use for specially-coded sequences
char entityName[32]; // the name of the entity, as registered by the Lua init function for the entity
char printedName[32]; // the name of the entity/item, the way it should be printed
uint16 animFrame; // which frame we're on
uint16 animDelay; // changes every frame; based on anim_cycle at start
uint16 animCycle; // delay between frame animations
union {
uint16 blinkFrames;
uint16 int1;
};
Tile *blinkGfx[kMaxAnimFrames];
union {
uint16 special1Frames;
uint16 int2;
};
Tile *special1Gfx[kMaxAnimFrames];
uint16 standdownFrames;
Tile *standdownGfx[kMaxAnimFrames];
uint16 standupFrames;
Tile *standupGfx[kMaxAnimFrames];
uint16 standleftFrames;
Tile *standleftGfx[kMaxAnimFrames];
uint16 standrightFrames;
Tile *standrightGfx[kMaxAnimFrames];
uint16 moveupFrames;
Tile *moveupGfx[kMaxAnimFrames];
uint16 movedownFrames;
Tile *movedownGfx[kMaxAnimFrames];
uint16 moveleftFrames;
Tile *moveleftGfx[kMaxAnimFrames];
uint16 moverightFrames;
Tile *moverightGfx[kMaxAnimFrames];
AIEntity() : luaFuncInit(""), luaFuncAction(""), luaFuncUse(""), entityName(""), printedName("") {
type = AI_NONE;
state = STATE_NONE;
dir = DIR_NONE;
draw = NULL;
aiInit = aiInit2 = NULL;
aiAction = NULL;
aiUse = NULL;
aiDraw = NULL;
level = 0;
value1 = value2 = 0;
dir2 = DIR_NONE;
x = y = 0;
drawXOff = drawYOff = 0;
onScreen = 0;
moveSpeed = 0;
xVel = yVel = 0;
tileX = tileY = 0;
goalX = goalY = 0;
touchpX = touchpY = touchpTile = touchpWait = 0;
stunnedWait = 0;
sequence = 0;
animCycle = 0;
animDelay = 0;
animFrame = 0;
blinkFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
blinkGfx[i] = new Tile;
}
special1Frames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
special1Gfx[i] = new Tile;
}
standdownFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
standdownGfx[i] = new Tile;
}
standupFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
standupGfx[i] = new Tile;
}
standleftFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
standleftGfx[i] = new Tile;
}
standrightFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
standrightGfx[i] = new Tile;
}
movedownFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
movedownGfx[i] = new Tile;
}
moveupFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
moveupGfx[i] = new Tile;
}
moveleftFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
moveleftGfx[i] = new Tile;
}
moverightFrames = 0;
for (int i = 0; i < kMaxAnimFrames; i++) {
moverightGfx[i] = new Tile;
}
}
};
struct AIEntTypeInfo {
AIType type;
const char *luaName;
AIStateDef *stateDef;
void (*initFunc)(AIEntity *e);
void (*initFunc2)(AIEntity *e);
};
extern AIEntTypeInfo aiEntList[];
struct AIEntLevel2 {
uint16 x;
uint16 y;
Tile *draw;
AIEntity *e;
void(*aiDraw)(AIEntity *e, int x, int y);
uint32 stunnedWait;
AIEntLevel2() : x(0), y(0), draw(NULL), e(NULL), aiDraw(NULL), stunnedWait(0) {}
};
struct AnimTarget {
uint16 x, y;
uint16 start, end;
int16 vel;
uint16 animCycle;
uint16 animFrame;
bool killAuto; // Keep it alive if its an Auto?
bool inMap;
Tile *gfxList[kMaxAnimTFrames];
AnimTarget() : x(0), y(0), start(0), end(0), vel(0), animCycle(0), animFrame(0), killAuto(false), inMap(false) {
for (int i = 0; i < kMaxAnimTFrames;i++) {
gfxList[i] = new Tile;
}
}
};
struct InvEnt {
uint16 keep;
AIEntity *ent;
InvEnt() : keep(0), ent(NULL) {}
};
struct Waypoint {
int x, y, level;
Waypoint() : x(0), y(0), level(0) {}
};
struct ActionInfo {
uint16 x1, y1;
uint16 x2, y2;
char luaFuncInit[32];
char luaFuncUse[32];
char entityName[32];
ActionInfo() : x1(0), y1(0), x2(0), y2(0), luaFuncInit(""), luaFuncUse(""), entityName("") {}
};
struct AutoAction {
uint16 x, y;
bool activated;
char luaFuncInit[32];
char luaFuncUse[32];
char entityName[32];
AutoAction() : x(0), y(0), activated(false), luaFuncInit(""), luaFuncUse(""), entityName("") {}
};
struct CineCommand {
CineType cmdType;
double x, y;
double x2, y2;
double xv, yv;
int start, end;
uint32 delay;
int speed;
char title[32];
char string[32];
char *id;
AIEntity *e;
CineCommand() : cmdType(C_NO_COMMAND), x(0.0), y(0.0), x2(0.0), y2(0.0), xv(0.0), yv(0.0),
start(0), end(0), delay(0), speed(0), title(""), string(""), id(NULL), e(NULL) {}
};
#define onEvenTile(x, y) ( !(x & 31) && !(y & 31) )
class AI {
public:
AI();
~AI();
bool init();
void clearPersistent();
void restartSystem();
void initAnimInfo();
// Entity Functions
AIEntity *spawn(AIType type, AIDir dir, int x, int y, char *funcInit, char *funcAction, char *funcUse, AIDir dir2, int level, int value1, int value2, int callInit);
bool cacheEntGfx(AIEntity *e, bool init);
void stopEntity(AIEntity *e);
AIEntity *locateEntity(const char *luaName);
AIEntity *findEntity(int x, int y);
void removeEntity(AIEntity *e);
void setEntityGoal(AIEntity *e, int x, int y);
void initAllEnts();
void killPlayer(Death method);
void animateEntity(AIEntity *e);
void animEntFrames(AIEntity *e);
void animLuaEntity(const char *initName, AIState st);
void drawEnts(int x, int y, int w, int h);
void animGrabbing();
int checkForTouchplate(int x, int y);
void addAnimateTarget(int x, int y, int start, int end, AnimSpeed speed, bool killAuto, bool inMap, const char *tileName);
void animateTargets();
// List functions
void addToActionList(int actionIndex, int x, int y, char *funcLuaInit, char *funcLuaUse);
bool checkActionList(AIEntity *e, int x, int y, bool lookAndGrab);
void addToAutoList(int x, int y, const char *luaFuncInt, const char *luaFuncUse);
void autoDeactivate(int x, int y);
bool activateAction(AIEntity *e, int x, int y, int targetX, int targetY);
bool checkAutoList(AIEntity *e, int x, int y);
bool autoActive(int x, int y);
bool checkFloating(int x, int y);
bool getTableEnt(AIType type);
bool walkThroughEnt(AIType type);
void getItemSound(AIType type);
void lookAtEntity(AIEntity *e);
// Player Functions
AIEntity *getPlayer() {
if (!_player)
return &_dummyPlayer;
return _player;
}
void getPlayerXY(int *x, int *y) {
if (_player) {
*x = _player->x;
*y = _player->y;
} else {
*x = *y = 0;
}
}
void setPlayerXY(int x, int y) {
if (_player) {
_player->x = x;
_player->tileX = x / kTileWidth;
_player->y = y;
_player->tileY = y / kTileHeight;
_player->xVel = _player->yVel = 0;
}
}
void assignPlayer(AIEntity *p) {
_player = p;
}
bool playerDead() {
return _playerDead;
}
bool playerOnIce() {
return _playerOnIce;
}
bool playerLocked() {
return _playerLock;
}
void setPlayerLock(bool status) {
_playerLock = status;
}
void setPlayerInvisible(bool status) {
_playerInvisible = status;
}
bool playerRunning() {
return _playerRunning;
}
void togglePlayerRunning() {
_playerRunning = !_playerRunning;
}
// Cinematic Functions
void processCines();
void cineStart(bool abortable, const char *abortFunc);
void cineLockPlayer();
void cineUnlockPlayer();
void cineSetCamera(int x, int y);
void cineResetCamera();
void cineMoveCamera(int x, int y, int speed);
void cineWait(int seconds);
void cineWaitUntilDone();
void cineSetEntity(const char *entName, int x, int y, int level);
void cineMoveEntity(const char *entName, int x, int y, int level, int speed);
void cineEntityFace(const char *luaName, double dir);
void cineUse(const char *entName);
void cineFadeIn(bool isBlack, int steps);
void cineFadeOut(bool isBlack, int steps);
void cineClearForeground(int x, int y);
void cineSetBackground(int x, int y, int index);
void cineSetForeground(int x, int y, int index);
// Waypoint & Movement Functions
void lookAtXY(int x, int y);
void addWaypoint(int px, int py, int x, int y, int level);
void removeFirstWaypoint();
void clearWaypoints();
Tile *getStandFrameDir(AIEntity *e);
// Inventory Functions
bool addToInventory(AIEntity *e);
void clearInventory();
// Player Variables
bool _playerDead;
bool _playerInvisible; // While on RailRider for example
bool _playerOnIce;
bool _playerEmerging;
bool _playerRunning;
uint16 _pushupFrames;
Tile *_pushupGfx[kMaxAnimFrames];
uint16 _pushdownFrames;
Tile *_pushdownGfx[kMaxAnimFrames];
uint16 _pushleftFrames;
Tile *_pushleftGfx[kMaxAnimFrames];
uint16 _pushrightFrames;
Tile *_pushrightGfx[kMaxAnimFrames];
Tile *_getGfx[5]; // only 1 frame in each direction (+1 for DIR_NONE at start)
uint16 _dyingFrames;
Tile *_dyingGfx[kMaxDeathFrames];
Tile *_goodjobGfx; // only 1 frame
uint16 _horrible1Frames;
Tile *_horrible1Gfx[kMaxDeathFrames];
uint16 _horrible2Frames;
Tile *_horrible2Gfx[kMaxDeathFrames];
uint16 _horrible3Frames;
Tile *_horrible3Gfx[kMaxDeathFrames];
uint16 _horrible4Frames;
Tile *_horrible4Gfx[kMaxDeathFrames];
uint16 _plummetFrames;
Tile *_plummetGfx[kMaxDeathFrames];
uint16 _clubUpFrames;
Picture *_clubUpGfx[kMaxAnimFrames];
uint16 _clubDownFrames;
Picture *_clubDownGfx[kMaxAnimFrames];
uint16 _clubLeftFrames;
Picture *_clubLeftGfx[kMaxAnimFrames];
uint16 _clubRightFrames;
Picture *_clubRightGfx[kMaxAnimFrames];
uint16 _stunUpFrames;
Tile *_stunUpGfx[kMaxAnimFrames];
uint16 _stunDownFrames;
Tile *_stunDownGfx[kMaxAnimFrames];
uint16 _stunLeftFrames;
Tile *_stunLeftGfx[kMaxAnimFrames];
uint16 _stunRightFrames;
Tile *_stunRightGfx[kMaxAnimFrames];
Tile *_stunLightningGfx[kMaxAnimFrames];
Tile *_stunnedGfx[kMaxAnimFrames];
uint16 _slugUpFrames;
Tile *_slugUpGfx[kMaxAnimFrames];
uint16 _slugDownFrames;
Tile *_slugDownGfx[kMaxAnimFrames];
uint16 _slugLeftFrames;
Tile *_slugLeftGfx[kMaxAnimFrames];
uint16 _slugRightFrames;
Tile *_slugRightGfx[kMaxAnimFrames];
uint16 _slugAttackFrames;
Picture *_slugAttackGfx[kMaxAnimFrames];
// Player Resources and Deliveries
int _numGems;
int _numGooCups;
int _numMonkeystones;
// Special Tiles that are usable
// These variables hold the tile-indices set
// in ai-init.cpp
int _useSwitchOff; // the door opening switch
int _useSwitchOn; // state, when opened
int _useHolderEmpty; // cell holding switch
int _useHolderFull; // state, when full
int _useSwitch2Off; // another switch
int _useSwitch2On; // state, when opened
int _useMailsorter; // mailsorter entity
int _useAskcomp; // askcomp entitiy
int _useTeleporter; // teleporter entity
int _useHandswitchOn; // 2-sided handswitch
int _useHandswitchOff; // 2-sided handswitch
int _targetDoorN; // horz SILVER door
int _targetDoorP; // horz BLUE door
int _targetDoorS; // horz RED door
int _targetDoorNv; // vert SILVER door
int _targetDoorPv; // vert BLUE door
int _targetDoorSv; // vert RED door
int _targetDoor2N; // horz SILVER door
int _targetDoor2P; // horz BLUE door
int _targetDoor2S; // horz RED door
int _targetDoor2Nv; // vert SILVER door
int _targetDoor2Pv; // vert BLUE door
int _targetDoor2Sv; // vert RED door
int _target2DoorN; // horz SILVER door
int _target2DoorP; // horz BLUE door
int _target2DoorS; // horz RED door
int _target2DoorNv; // vert SILVER door
int _target2DoorPv; // vert BLUE door
int _target2DoorSv; // vert RED door
int _target3DoorN; // horz SILVER door
int _target3DoorP; // horz BLUE door
int _target3DoorS; // horz RED door
int _target3DoorNv; // vert SILVER door
int _target3DoorPv; // vert BLUE door
int _target3DoorSv; // vert RED door
int _targetBridgeU; // bridge extending UP
int _targetBridgeD; // bridge extending DOWN
int _targetBridgeL; // bridge extending LEFT
int _targetBridgeR; // bridge extending RIGHT
int _targetBridgeMidLR; // bridge grating plank LEFT/RIGHT
int _targetBridgeMidUD; // bridge grating plank UP/DOWN
int _touchplateOn; // touchplate ON
int _touchplateOff;
int _templeTouchpOn; // touchplate ON
int _templeTouchpOff;
int _blockpole; // blockpole
int _kcHolderWhiteOff; // keycard holders
int _kcHolderWhiteOn;
int _kcHolderBlueOff;
int _kcHolderBlueOn;
int _kcHolderRedOff;
int _kcHolderRedOn;
int _kcHolderGreenOff;
int _kcHolderGreenOn;
int _kcHolderPurpleOff;
int _kcHolderPurpleOn;
int _kcHolderBlackOff;
int _kcHolderBlackOn;
AIEntLevel2 _entsLevel2[kMaxLevel2Ents];
int _numLevel2Ents;
InvEnt _inventory[kMaxInventory];
int _numInventory;
Waypoint _waypoints[kMaxWaypoints];
int _numWaypoints;
Tile *_waypointGfx[4]; // Animating waypoint gfx
ActionInfo _actions[kMaxActions];
AutoAction _autoActions[kMaxAutoActions];
// Virtual Player
AIEntity _dummyPlayer;
// Cinematic Variables
Common::Array<CineCommand *> _cine;
private:
// Action Functions
// Black Door Switch
bool useSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile);
bool useSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY, int offTile);
bool useSwitch2(AIEntity *e, int x, int y, int targetX, int targetY);
// Colored Keycard Switch
bool useLockedSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile, AIType item, const char *keyerror);
bool useLockedSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY, int offTile, AIType item);
// Purple Cell Holder Switch
bool useCellHolder(AIEntity *e, int x, int y, int targetX, int targetY);
// Touchplate
bool useTouchplate(AIEntity *e, int x, int y, int targetX, int targetY, int type);
bool useTouchplateOn(AIEntity *e, int x, int y, int targetX, int targetY, int type);
// Normal Door
bool useDoorOpenClose(AIEntity *e, int x, int y);
bool useAutoDoorOpenClose(AIEntity *e, int x, int y);
// Any Type Door
bool useDoorOpenCloseBot(AIEntity *e, int x, int y);
Common::Array<AIEntity *> *_ents;
Common::Array<AIEntity *> *_floats;
Common::Array<AnimTarget *> *_animTargets;
AIEntity *_player;
// Cinematics Variables
bool _cineAbortable;
bool _cineAborted;
const char *_cineAbortFunc;
bool _cineActive;
bool _playerLock;
bool _cameraLock;
double _cameraX, _cameraY;
};
} // End of Namespace
#endif // !HDB_AI_H
|