ScummVM API documentation
ai.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef HDB_AI_H
23#define HDB_AI_H
24
25#define STARS_MONKEYSTONE_7 0xfe257d // magic value in the config file for the unlocking of the Monkeystone secret #7
26#define STARS_MONKEYSTONE_7_FAKE 0x11887e // fake value that means it hasn't been unlocked
27#define STARS_MONKEYSTONE_14 0x3341fe // <same> for the Monkeystone #14
28#define STARS_MONKEYSTONE_14_FAKE 0x1cefd0 // fake value that means it hasn't been unlocked
29#define STARS_MONKEYSTONE_21 0x77ace3 // <same> for the Monkeystone #21
30#define STARS_MONKEYSTONE_21_FAKE 0x3548fe // fake value that means it hasn't been unlocked
31
32namespace HDB {
33
34enum {
35 kMaxAnimFrames = 8,
36 kMaxAnimTFrames = 16,
37 kMaxDeathFrames = 12,
38 kMaxLevel2Ents = 60,
39 kMaxInventory = 10,
40 kMaxDeliveries = 5,
41 kMaxWaypoints = 10,
42 kMaxActions = 20,
43 kMaxTeleporters = 20,
44 kMaxAutoActions = 30,
45 kMaxLuaEnts = 50,
46 kMaxCallbacks = 20,
47 kMaxFairystones = 5,
48 kMaxGatePuddles = 8,
49 kMaxBridges = 10,
50 kDelay5Seconds = 5 * kGameFPS,
51 kPlayerMoveSpeed = 4,
52 kEnemyMoveSpeed = 2,
53 kPushMoveSpeed = (kPlayerMoveSpeed >> 1),
54 kPlayerTouchPWait = 16,
55 kMaxCineGfx = 10,
56 kRunToggleDelay = 2,
57 kMsgDelay = 3,
58 kYouGotX = -1,
59 kNumSaveSlots = 8,
60 kAutoSaveSlot = 0
61};
62
63enum AIType {
64 AI_NONE,
65 AI_GUY,
66 AI_DOLLY,
67 AI_SPACEDUDE,
68 AI_SERGEANT,
69 AI_SCIENTIST,
70 AI_WORKER,
71 AI_DEADWORKER,
72 AI_ACCOUNTANT,
73 AI_RAILRIDER,
74 AI_RAILRIDER_ON,
75 AI_VORTEXIAN,
76 AI_CHICKEN,
77 AI_GEM_ATTACK,
78 AI_SLUG_ATTACK,
79
80 AI_LASER,
81 AI_LASERBEAM,
82 AI_DIVERTER,
83 AI_FOURFIRER,
84 AI_OMNIBOT,
85 AI_TURNBOT,
86 AI_SHOCKBOT,
87 AI_RIGHTBOT,
88 AI_PUSHBOT,
89 AI_LISTENBOT,
90 AI_MAINTBOT,
91 AI_OMNIBOT_MISSILE,
92 AI_DEADEYE,
93 AI_MEERKAT,
94 AI_FATFROG,
95 AI_GOODFAIRY,
96 AI_BADFAIRY,
97 AI_ICEPUFF,
98 AI_BUZZFLY,
99 AI_DRAGON,
100 AI_GATEPUDDLE,
101
102 AI_CRATE,
103 AI_LIGHTBARREL,
104 AI_HEAVYBARREL,
105 AI_BOOMBARREL,
106 AI_FROGSTATUE,
107
108 AI_MAGIC_EGG,
109 AI_ICE_BLOCK,
110
111 ITEM_CELL,
112 ITEM_ENV_WHITE,
113 ITEM_ENV_RED,
114 ITEM_ENV_BLUE,
115 ITEM_ENV_GREEN,
116 ITEM_TRANSCEIVER,
117 ITEM_CLUB,
118 ITEM_ROBOSTUNNER,
119 ITEM_SLUGSLINGER,
120 ITEM_MONKEYSTONE,
121 ITEM_GEM_WHITE,
122 ITEM_GEM_BLUE,
123 ITEM_GEM_RED,
124 ITEM_GEM_GREEN,
125 ITEM_GOO_CUP,
126 ITEM_TEACUP,
127 ITEM_COOKIE,
128 ITEM_BURGER,
129 ITEM_PDA,
130 ITEM_BOOK,
131 ITEM_CLIPBOARD,
132 ITEM_NOTE,
133 ITEM_KEYCARD_WHITE,
134 ITEM_KEYCARD_BLUE,
135 ITEM_KEYCARD_RED,
136 ITEM_KEYCARD_GREEN,
137 ITEM_KEYCARD_PURPLE,
138 ITEM_KEYCARD_BLACK,
139 ITEM_CABKEY,
140 ITEM_DOLLYTOOL1,
141 ITEM_DOLLYTOOL2,
142 ITEM_DOLLYTOOL3,
143 ITEM_DOLLYTOOL4,
144 ITEM_SEED,
145 ITEM_SODA,
146 ITEM_ROUTER,
147 ITEM_SLICER,
148 ITEM_CHICKEN,
149 ITEM_PACKAGE,
150
151 INFO_FAIRY_SRC,
152 INFO_FAIRY_SRC2,
153 INFO_FAIRY_SRC3,
154 INFO_FAIRY_SRC4,
155 INFO_FAIRY_SRC5,
156 INFO_FAIRY_DEST,
157 INFO_FAIRY_DEST2,
158 INFO_FAIRY_DEST3,
159 INFO_FAIRY_DEST4,
160 INFO_FAIRY_DEST5,
161 INFO_TRIGGER,
162 INFO_SET_MUSIC,
163 INFO_PROMOTE,
164 INFO_DEMOTE,
165 INFO_LUA,
166 INFO_HERE,
167 INFO_ARROW_TURN,
168 INFO_ARROW_STOP,
169 INFO_ARROW_4WAY,
170 INFO_TELEPORTER1,
171 INFO_TELEPORTER2,
172 INFO_TELEPORTER3,
173 INFO_TELEPORTER4,
174 INFO_TELEPORTER5,
175 INFO_TELEPORTER6,
176 INFO_TELEPORTER7,
177 INFO_TELEPORTER8,
178 INFO_TELEPORTER9,
179 INFO_TELEPORTER10,
180 INFO_TELEPORTER11,
181 INFO_TELEPORTER12,
182 INFO_TELEPORTER13,
183 INFO_TELEPORTER14,
184 INFO_TELEPORTER15,
185 INFO_TELEPORTER16,
186 INFO_TELEPORTER17,
187 INFO_TELEPORTER18,
188 INFO_TELEPORTER19,
189 INFO_TELEPORTER20,
190 INFO_LEVELEXIT,
191 INFO_ACTION1,
192 INFO_ACTION2,
193 INFO_ACTION3,
194 INFO_ACTION4,
195 INFO_ACTION5,
196 INFO_ACTION6,
197 INFO_ACTION7,
198 INFO_ACTION8,
199 INFO_ACTION9,
200 INFO_ACTION10,
201 INFO_ACTION11,
202 INFO_ACTION12,
203 INFO_ACTION13,
204 INFO_ACTION14,
205 INFO_ACTION15,
206 INFO_ACTION16,
207 INFO_ACTION17,
208 INFO_ACTION18,
209 INFO_ACTION19,
210 INFO_ACTION20,
211 INFO_ACTION_AUTO,
212
213 INFO_QMARK,
214 INFO_DEBUG,
215 END_AI_TYPES
216
217};
218
219enum AIDir {
220 DIR_NONE,
221 DIR_UP,
222 DIR_DOWN,
223 DIR_LEFT,
224 DIR_RIGHT
225};
226
227enum Death {
228 DEATH_NORMAL,
229 DEATH_FRIED,
230 DEATH_DROWNED,
231 DEATH_GRABBED,
232 DEATH_SHOCKED,
233 DEATH_PANICZONE,
234 DEATH_PLUMMET
235};
236
237enum AIState {
238 STATE_NONE,
239 STATE_STANDDOWN,
240 STATE_STANDUP,
241 STATE_STANDLEFT,
242 STATE_STANDRIGHT,
243 STATE_BLINK,
244 STATE_MOVEUP,
245 STATE_MOVEDOWN,
246 STATE_MOVELEFT,
247 STATE_MOVERIGHT,
248 STATE_DYING,
249 STATE_DEAD,
250 STATE_HORRIBLE1,
251 STATE_HORRIBLE2,
252 STATE_HORRIBLE3,
253 STATE_HORRIBLE4,
254 STATE_GOODJOB,
255 STATE_PLUMMET,
256
257 STATE_PUSHUP, // these are only used for the player
258 STATE_PUSHDOWN,
259 STATE_PUSHLEFT,
260 STATE_PUSHRIGHT,
261 STATE_GRABUP, // player grabbing something
262 STATE_GRABDOWN,
263 STATE_GRABLEFT,
264 STATE_GRABRIGHT,
265 STATE_ATK_CLUB_UP, // player attacking frames
266 STATE_ATK_CLUB_DOWN,
267 STATE_ATK_CLUB_LEFT,
268 STATE_ATK_CLUB_RIGHT,
269 STATE_ATK_STUN_DOWN,
270 STATE_ATK_STUN_UP,
271 STATE_ATK_STUN_LEFT,
272 STATE_ATK_STUN_RIGHT,
273 STATE_ATK_SLUG_DOWN,
274 STATE_ATK_SLUG_UP,
275 STATE_ATK_SLUG_LEFT,
276 STATE_ATK_SLUG_RIGHT,
277
278 STATE_FLOATING, // floating in stuff (can walk on)
279 STATE_FLOATDOWN,
280 STATE_FLOATUP,
281 STATE_FLOATLEFT,
282 STATE_FLOATRIGHT,
283 STATE_MELTED, // melted into slag (can walk on)
284 STATE_SLIDING, // sliding across a floor
285 STATE_SHOCKING, // for Shockbot floor-shock anim
286 STATE_EXPLODING, // boom barrel explosion!
287
288 STATE_USEDOWN, // crazy maintenance bot!
289 STATE_USEUP,
290 STATE_USELEFT,
291 STATE_USERIGHT,
292
293 STATE_MEER_MOVE, // for the Meerkat
294 STATE_MEER_APPEAR,
295 STATE_MEER_BITE,
296 STATE_MEER_DISAPPEAR,
297 STATE_MEER_LOOK,
298
299 STATE_ICEP_PEEK, // for the Icepuff
300 STATE_ICEP_APPEAR,
301 STATE_ICEP_THROWDOWN,
302 STATE_ICEP_THROWRIGHT,
303 STATE_ICEP_THROWLEFT,
304 STATE_ICEP_DISAPPEAR,
305
306 STATE_LICKDOWN, // for the Fatfrog
307 STATE_LICKLEFT,
308 STATE_LICKRIGHT,
309
310 STATE_DIVERTER_BL, // for Diverters
311 STATE_DIVERTER_BR,
312 STATE_DIVERTER_TL,
313 STATE_DIVERTER_TR,
314
315 STATE_KISSRIGHT, // for Dolly
316 STATE_KISSLEFT,
317 STATE_ANGRY,
318 STATE_PANIC,
319 STATE_LAUGH,
320 STATE_DOLLYUSERIGHT,
321
322 STATE_YELL, // for Sarge
323
324 STATE_ENDSTATES
325};
326
327enum AnimSpeed {
328 ANIM_SLOW,
329 ANIM_NORMAL,
330 ANIM_FAST
331};
332
333enum CineType {
334 C_NO_COMMAND,
335 C_STOPCINE,
336 C_LOCKPLAYER,
337 C_UNLOCKPLAYER,
338 C_SETCAMERA,
339 C_MOVECAMERA,
340 C_WAIT,
341 C_WAITUNTILDONE,
342 C_MOVEENTITY,
343 C_DIALOG,
344 C_ANIMENTITY,
345 C_RESETCAMERA,
346 C_SETENTITY,
347 C_STARTMAP,
348 C_MOVEPIC,
349 C_MOVEMASKEDPIC,
350 C_DRAWPIC,
351 C_DRAWMASKEDPIC,
352 C_FADEIN,
353 C_FADEOUT,
354 C_SPAWNENTITY,
355 C_PLAYSOUND,
356 C_CLEAR_FG,
357 C_SET_FG,
358 C_SET_BG,
359 C_FUNCTION,
360 C_ENTITYFACE,
361 C_USEENTITY,
362 C_REMOVEENTITY,
363 C_SETANIMFRAME,
364 C_TEXTOUT,
365 C_CENTERTEXTOUT,
366 C_PLAYVOICE,
367
368 C_ENDLIST
369};
370
371enum CallbackType {
372 NO_FUNCTION,
373 AI_BARREL_EXPLOSION_END,
374 CALLBACK_DOOR_OPEN_CLOSE,
375 CALLBACK_AUTODOOR_OPEN_CLOSE,
376
377 CALLBACK_END
378};
379
381 AIState state;
382 const char *name;
383};
384
385// Struct for Function Table Lookup for SaveGames
386typedef void(*FuncPtr)(AIEntity *, int, int);
387
388struct AIEntity {
389 AIType type;
390 AIState state;
391 AIDir dir;
392
393 Tile *draw; // Current frame to draw
394
395 FuncPtr aiInit; // func ptr to init routine
396 FuncPtr aiInit2; // func ptr to init2 routine - graphic init only (this for LoadGame functionality)
397 FuncPtr aiAction; // func ptr to action routine
398 FuncPtr aiUse; // func ptr to use routine
399 FuncPtr aiDraw; // func ptr to extra drawing routine (only for special stuff) - pass in mapx, mapy
400
401 char luaFuncInit[32]; // Lua function for Init (always called after entity's init). These are ptrs into the map header.
402 char luaFuncAction[32]; // Lua function for Action
403 char luaFuncUse[32]; // Lua function for Use
404 int16 level; // which floor level we're on
405 int16 value1, value2; // extra values we might need
406 AIDir dir2; // this is from TED
407
408 int16 x, y;
409 int16 drawXOff, drawYOff; // might need a drawing offset
410 int16 onScreen; // FLAG: is this entity onscreen?
411 int16 moveSpeed; // movement speed of this entity
412 int16 xVel, yVel; // movement values
413 int16 tileX, tileY;
414 int16 goalX, goalY; // where we're trying to go - TILE COORDS
415 int16 touchpX, touchpY, touchpTile, touchpWait; // ACTION index a touchplate is using, which you're on
416 int32 stunnedWait; // if we're stunned, this is the delay before being normal again
417 int16 sequence; // to use for specially-coded sequences
418 char entityName[32]; // the name of the entity, as registered by the Lua init function for the entity
419 char printedName[32]; // the name of the entity/item, the way it should be printed
420
421 int16 animFrame; // which frame we're on
422 int16 animDelay; // changes every frame; based on anim_cycle at start
423 int16 animCycle; // delay between frame animations
424
425 union {
426 uint16 blinkFrames;
427 int16 int1;
428 };
429 Tile *blinkGfx[kMaxAnimFrames];
430
431 union {
432 uint16 special1Frames;
433 int16 int2;
434 };
435 Tile *special1Gfx[kMaxAnimFrames];
436
437 int16 standdownFrames;
438 Tile *standdownGfx[kMaxAnimFrames];
439
440 int16 standupFrames;
441 Tile *standupGfx[kMaxAnimFrames];
442
443 int16 standleftFrames;
444 Tile *standleftGfx[kMaxAnimFrames];
445
446 int16 standrightFrames;
447 Tile *standrightGfx[kMaxAnimFrames];
448
449 int16 moveupFrames;
450 Tile *moveupGfx[kMaxAnimFrames];
451
452 int16 movedownFrames;
453 Tile *movedownGfx[kMaxAnimFrames];
454
455 int16 moveleftFrames;
456 Tile *moveleftGfx[kMaxAnimFrames];
457
458 int16 moverightFrames;
459 Tile *moverightGfx[kMaxAnimFrames];
460
461 void reset() {
462 luaFuncInit[0] = 0;
463 luaFuncAction[0] = 0;
464 luaFuncUse[0] = 0;
465 entityName[0] = 0;
466 printedName[0] = 0;
467
468 type = AI_NONE;
469 state = STATE_NONE;
470 dir = DIR_NONE;
471
472 draw = nullptr;
473
474 aiInit = aiInit2 = nullptr;
475 aiAction = nullptr;
476 aiUse = nullptr;
477 aiDraw = nullptr;
478
479 level = 0;
480 value1 = value2 = 0;
481 dir2 = DIR_NONE;
482
483 x = y = 0;
484 drawXOff = drawYOff = 0;
485 onScreen = 0;
486 moveSpeed = 0;
487 xVel = yVel = 0;
488 tileX = tileY = 0;
489 goalX = goalY = 0;
490 touchpX = touchpY = touchpTile = touchpWait = 0;
491 stunnedWait = 0;
492 sequence = 0;
493
494 animCycle = 0;
495 animDelay = 0;
496 animFrame = 0;
497
498 blinkFrames = 0;
499 for (int i = 0; i < kMaxAnimFrames; i++) {
500 blinkGfx[i] = nullptr;
501 }
502
503 special1Frames = 0;
504 for (int i = 0; i < kMaxAnimFrames; i++) {
505 special1Gfx[i] = nullptr;
506 }
507
508 standdownFrames = 0;
509 for (int i = 0; i < kMaxAnimFrames; i++) {
510 standdownGfx[i] = nullptr;
511 }
512
513 standupFrames = 0;
514 for (int i = 0; i < kMaxAnimFrames; i++) {
515 standupGfx[i] = nullptr;
516 }
517
518 standleftFrames = 0;
519 for (int i = 0; i < kMaxAnimFrames; i++) {
520 standleftGfx[i] = nullptr;
521 }
522
523 standrightFrames = 0;
524 for (int i = 0; i < kMaxAnimFrames; i++) {
525 standrightGfx[i] = nullptr;
526 }
527
528 movedownFrames = 0;
529 for (int i = 0; i < kMaxAnimFrames; i++) {
530 movedownGfx[i] = nullptr;
531 }
532
533 moveupFrames = 0;
534 for (int i = 0; i < kMaxAnimFrames; i++) {
535 moveupGfx[i] = nullptr;
536 }
537
538 moveleftFrames = 0;
539 for (int i = 0; i < kMaxAnimFrames; i++) {
540 moveleftGfx[i] = nullptr;
541 }
542
543 moverightFrames = 0;
544 for (int i = 0; i < kMaxAnimFrames; i++) {
545 moverightGfx[i] = nullptr;
546 }
547 }
548
549 AIEntity() {
550 reset();
551 }
552
553 ~AIEntity() {
554 }
555
556 void save(Common::OutSaveFile *out);
557 void load(Common::InSaveFile *in);
558};
559
561 AIType type;
562 const char *luaName;
563 AIStateDef *stateDef;
564 FuncPtr initFunc;
565 FuncPtr initFunc2;
566};
567
568extern AIEntTypeInfo aiEntList[];
569
571 uint16 x;
572 uint16 y;
573 Tile *draw;
574 AIEntity *e;
575 FuncPtr aiDraw;
576 uint32 stunnedWait;
577
578 AIEntLevel2() : x(0), y(0), draw(nullptr), e(nullptr), aiDraw(nullptr), stunnedWait(0) {}
579};
580
582 uint16 x, y;
583 uint16 start, end;
584 int16 vel;
585 uint16 animCycle;
586 uint16 animFrame;
587 bool killAuto; // Keep it alive if its an Auto?
588 bool inMap;
589 Tile *gfxList[kMaxAnimTFrames];
590
591 AnimTarget() : x(0), y(0), start(0), end(0), vel(0), animCycle(0), animFrame(0), killAuto(false), inMap(false) {
592 for (int i = 0; i < kMaxAnimTFrames; i++) {
593 gfxList[i] = nullptr;
594 }
595 }
596};
597
598struct InvEnt {
599 uint16 keep;
600 AIEntity ent;
601
602 void reset() {
603 keep = 0;
604 ent.reset();
605 }
606
607 InvEnt() {
608 reset();
609 }
610};
611
612struct DlvEnt {
613 char itemTextName[32];
614 char itemGfxName[32];
615 Tile *itemGfx;
616
617 char destTextName[32];
618 char destGfxName[32];
619 Tile *destGfx;
620
621 char id[32];
622
623 DlvEnt() : itemGfx(nullptr), destGfx(nullptr) {
624 itemTextName[0] = 0;
625 itemGfxName[0] = 0;
626 destTextName[0] = 0;
627 destGfxName[0] = 0;
628 }
629
630 ~DlvEnt() {
631 itemGfx = nullptr;
632 destGfx = nullptr;
633 }
634};
635
636struct Waypoint {
637 int x, y, level;
638
639 void reset() {
640 x = 0;
641 y = 0;
642 level = 0;
643 }
644
645 Waypoint() {
646 reset();
647 }
648};
649
650struct LuaT {
651 uint16 x, y;
652 uint16 value1, value2;
653 char luaFuncInit[32];
654 char luaFuncAction[32];
655 char luaFuncUse[32];
656
657 LuaT() {
658 clear();
659 }
660
661 void clear() {
662 x = 0;
663 y = 0;
664 value1 = 0;
665 value2 = 0;
666 for (uint i = 0; i < ARRAYSIZE(luaFuncInit); i++) luaFuncInit[i] = 0;
667 for (uint i = 0; i < ARRAYSIZE(luaFuncAction); i++) luaFuncAction[i] = 0;
668 for (uint i = 0; i < ARRAYSIZE(luaFuncUse); i++) luaFuncUse[i] = 0;
669 }
670};
671
673 uint16 x1, y1;
674 uint16 x2, y2;
675 char luaFuncInit[32];
676 char luaFuncUse[32];
677 char entityName[32];
678
679 ActionInfo() {
680 clear();
681 }
682
683 void clear() {
684 x1 = 0;
685 y1 = 0;
686 x2 = 0;
687 y2 = 0;
688 for (uint i = 0; i < ARRAYSIZE(luaFuncInit); i++) luaFuncInit[i] = 0;
689 for (uint i = 0; i < ARRAYSIZE(luaFuncUse); i++) luaFuncUse[i] = 0;
690 for (uint i = 0; i < ARRAYSIZE(entityName); i++) entityName[i] = 0;
691 }
692};
693
694struct TeleInfo {
695 uint16 x1, y1;
696 uint16 x2, y2;
697 AIDir dir1;
698 AIDir dir2;
699 uint16 level1, level2;
700 uint16 usable1, usable2;
701 uint16 anim1, anim2;
702 char luaFuncUse1[32];
703 char luaFuncUse2[32];
704
705 TeleInfo() {
706 clear();
707 }
708
709 void clear() {
710 x1 = 0;
711 y1 = 0;
712 x2 = 0;
713 y2 = 0;
714 dir1 = DIR_NONE;
715 dir2 = DIR_NONE;
716 level1 = 0;
717 level2 = 0;
718 usable1 = 0;
719 usable2 = 0;
720 anim1 = 0;
721 anim2 = 0;
722 for (uint i = 0; i < ARRAYSIZE(luaFuncUse1); i++) luaFuncUse1[i] = 0;
723 for (uint i = 0; i < ARRAYSIZE(luaFuncUse2); i++) luaFuncUse2[i] = 0;
724 }
725};
726
728 uint16 x, y, level, usable, anim;
729 AIDir dir;
730
731 SingleTele() : x(0), y(0), level(0), usable(0), anim(0), dir(DIR_NONE) {}
732};
733
735 uint16 x, y;
736 bool activated;
737 char luaFuncInit[32];
738 char luaFuncUse[32];
739 char entityName[32];
740
741 AutoAction() {
742 clear();
743 }
744
745 void clear() {
746 x = 0;
747 y = 0;
748 activated = false;
749 for (uint i = 0; i < ARRAYSIZE(luaFuncInit); i++) luaFuncInit[i] = 0;
750 for (uint i = 0; i < ARRAYSIZE(luaFuncUse); i++) luaFuncUse[i] = 0;
751 for (uint i = 0; i < ARRAYSIZE(entityName); i++) entityName[i] = 0;
752 }
753};
754
755struct ArrowPath {
756 uint16 type;
757 AIDir dir;
758 uint16 tileX, tileY;
759
760 ArrowPath() : type(0), dir(DIR_NONE), tileX(0), tileY(0) {}
761};
762
763struct HereT {
764 uint16 x, y;
765 char entName[32];
766};
767
768struct Trigger {
769 char id[32];
770 uint16 x, y;
771 uint16 value1, value2;
772 char luaFuncInit[32];
773 char luaFuncUse[32];
774
775 Trigger() : x(0), y(0), value1(0), value2(0) {
776 id[0] = 0;
777 luaFuncInit[0] = 0;
778 luaFuncUse[0] = 0;
779 }
780};
781
783 CallbackType type;
784 void(*function)(int x, int y);
785};
786
787struct Callback {
788 CallbackType type;
789 uint16 x, y;
790 uint16 delay;
791
792 Callback() {
793 clear();
794 }
795
796 void clear() {
797 type = NO_FUNCTION;
798 x = 0;
799 y = 0;
800 delay = 0;
801 }
802};
803
805 uint16 srcX, srcY;
806 uint16 destX, destY;
807
808 Fairystone() : srcX(0), srcY(0), destX(0), destY(0) {}
809};
810
811struct Bridge {
812 uint16 x, y;
813 AIDir dir;
814 uint16 delay;
815 uint16 anim;
816
817 void reset() {
818 x = 0;
819 y = 0;
820 dir = DIR_NONE;
821 delay = 0;
822 anim = 0;
823 }
824
825 Bridge() {
826 reset();
827 }
828};
829
831 CineType cmdType;
832 double x, y;
833 double x2, y2;
834 double xv, yv;
835 int start, end;
836 uint32 delay;
837 int speed;
838 const char *title;
839 const char *string;
840 const char *id;
841 AIEntity *e;
842 Picture *pic;
843
844 CineCommand() : cmdType(C_NO_COMMAND), x(0.0), y(0.0), x2(0.0), y2(0.0), xv(0.0), yv(0.0),
845 start(0), end(0), delay(0), speed(0), title(nullptr), string(nullptr), id(nullptr), e(nullptr), pic(nullptr) {}
846};
847
848struct CineBlit {
849 double x, y;
850 Picture *pic;
851 const char *name;
852 const char *id;
853 bool masked;
854
855 CineBlit() : x(0), y(0), pic(nullptr), name(nullptr), id(nullptr), masked(false) {}
856};
857
858#define onEvenTile(x, y) ( !(x & 31) && !(y & 31) )
859#define hitPlayer(x, y) ( e->onScreen && g_hdb->_ai->checkPlayerCollision( x, y, 4 ) && !g_hdb->_ai->playerDead() )
860#define cycleFrames( e, max ) \
861 { \
862 if ( e->animDelay-- < 1 ) \
863 { \
864 e->animDelay = e->animCycle; \
865 e->animFrame++; \
866 if ( e->animFrame >= max ) \
867 e->animFrame = 0; \
868 } \
869 }
870#define spawnBlocking(x, y, level) g_hdb->_ai->spawn(AI_NONE, DIR_NONE, x, y, nullptr, nullptr, nullptr, DIR_NONE, level, 0, 0, 0)
871
872class AI {
873public:
874 AI();
875 ~AI();
876
877 void init();
878 void clearPersistent();
879 void restartSystem();
880 const char *funcLookUp(FuncPtr function);
881 FuncPtr funcLookUp(const char *function);
882 void save(Common::OutSaveFile *out);
883 void loadSaveFile(Common::InSaveFile *in);
884 void initAnimInfo();
885
886 // Entity Functions
887 AIEntity *spawn(AIType type, AIDir dir, int x, int y, const char *funcInit, const char *funcAction, const char *funcUse, AIDir dir2, int level, int value1, int value2, int callInit);
888 bool cacheEntGfx(AIEntity *e, bool initFlag);
889 void stopEntity(AIEntity *e);
890 AIEntity *locateEntity(const char *luaName);
891 AIEntity *findEntity(int x, int y);
892 AIEntity *findEntityIgnore(int x, int y, AIEntity *ignore);
893 AIEntity *findEntityType(AIType type, int x, int y);
894 void getEntityXY(const char *entName, int *x, int *y);
895 bool useLuaEntity(const char *initName);
896 void removeLuaEntity(const char *initName);
897 void animLuaEntity(const char *initName, AIState st);
898 void setLuaAnimFrame(const char *initName, AIState st, int frame);
899 int checkForTouchplate(int x, int y);
900 void removeEntity(AIEntity *e);
901 void setEntityGoal(AIEntity *e, int x, int y);
902 void initAllEnts();
903 void killPlayer(Death method);
904 void stunEnemy(AIEntity *e, int time);
905 int metalOrFleshSND(AIEntity *e);
906 int tileDistance(AIEntity *e1, AIEntity *e2) {
907 return abs(e1->tileX - e2->tileX) + abs(e1->tileY - e2->tileY);
908 }
909
910 void animateEntity(AIEntity *e);
911 void animEntFrames(AIEntity *e);
912 void drawEnts(int x, int y, int w, int h);
913 void drawLevel2Ents();
914 void animGrabbing();
915 void entityFace(const char *luaName, int dir);
916
917 void moveEnts();
918
919 bool findPath(AIEntity *e);
920 AIEntity *legalMove(int tileX, int tileY, int level, int *result);
921 AIEntity *legalMoveOverWater(int tileX, int tileY, int level, int *result);
922 AIEntity *legalMoveOverWaterIgnore(int tileX, int tileY, int level, int *result, AIEntity *ignore);
923 void addAnimateTarget(int x, int y, int start, int end, AnimSpeed speed, bool killAuto, bool inMap, const char *tileName);
924 void animateTargets();
925
926 void addBridgeExtend(int x, int y, int bridgeType);
927 void animateBridges();
928 void addToFairystones(int index, int tileX, int tileY, int sourceOrDest);
929 int checkFairystones(int tileX, int tileY);
930 void getFairystonesSrc(int index, int *tileX, int *tileY) {
931 *tileX = _fairystones[index].srcX;
932 *tileY = _fairystones[index].srcY;
933 }
934
935 AIEntity *playerCollision(int topBorder, int bottomBorder, int leftBorder, int rightBorder);
936 bool checkPlayerTileCollision(int x, int y);
937 bool checkPlayerCollision(int x, int y, int border);
938 void clearDiverters();
939 void laserScan();
940
941 // List functions
942 void addToActionList(int actionIndex, int x, int y, char *funcLuaInit, char *funcLuaUse);
943 bool checkActionList(AIEntity *e, int x, int y, bool lookAndGrab);
944 void addToHereList(const char *entName, int x, int y);
945 HereT *findHere(int x, int y);
946 void addToAutoList(int x, int y, const char *luaFuncInit, const char *luaFuncUse);
947 void autoDeactivate(int x, int y);
948 bool activateAction(AIEntity *e, int x, int y, int targetX, int targetY);
949 bool checkAutoList(AIEntity *e, int x, int y);
950 bool autoActive(int x, int y);
951 void addCallback(CallbackType type, int x, int y, int delay);
952 void processCallbackList();
953 void addToLuaList(int x, int y, int value1, int value2, char *luaFuncInit, char *luaFuncAction, char *luaFuncUse);
954 bool checkLuaList(AIEntity *e, int x, int y);
955 bool luaExistAtXY(int x, int y);
956 void addToTeleportList(int teleIndex, int x, int y, int dir, int level, int anim, int usable, const char *luaFuncUse);
957 bool checkTeleportList(AIEntity *e, int x, int y);
958 bool findTeleporterDest(int tileX, int tileY, SingleTele *info);
959 void addToPathList(int x, int y, int type, AIDir dir);
960 ArrowPath *findArrowPath(int x, int y);
961 void addToTriggerList(char *luaFuncInit, char *luaFuncUse, int x, int y, int value1, int value2, char *id);
962 bool checkTriggerList(char *entName, int x, int y);
963 void killTrigger(const char *id);
964
965 void floatEntity(AIEntity *e, AIState state);
966 bool checkFloating(int x, int y);
967
968 bool getTableEnt(AIType type);
969 bool walkThroughEnt(AIType type);
970 void getItemSound(AIType type);
971 void lookAtEntity(AIEntity *e);
972
973 // Player Functions
974
975 void movePlayer(uint16 buttons);
976 void playerUse();
977 void setPlayerWeapon(AIType w, Tile *gfx) {
978 _weaponSelected = w;
979 _weaponGfx = gfx;
980 }
981 AIType getPlayerWeapon() {
982 return _weaponSelected;
983 }
984 Tile *getPlayerWeaponGfx() {
985 return _weaponGfx;
986 }
987 Tile *getPlayerWeaponSelGfx() {
988 return _weaponSelGfx;
989 }
990
991 AIEntity *getPlayer() {
992 if (!_player)
993 return &_dummyPlayer;
994 return _player;
995 }
996
997 void getPlayerXY(int *x, int *y) {
998 if (_player) {
999 *x = _player->x;
1000 *y = _player->y;
1001 } else {
1002 *x = *y = 0;
1003 }
1004 }
1005
1006 void setPlayerXY(int x, int y) {
1007 if (_player) {
1008 _player->x = x;
1009 _player->tileX = x / kTileWidth;
1010 _player->y = y;
1011 _player->tileY = y / kTileHeight;
1012 _player->xVel = _player->yVel = 0;
1013 }
1014 }
1015
1016 void assignPlayer(AIEntity *p) {
1017 _player = p;
1018 }
1019
1020 bool playerDead() {
1021 return _playerDead;
1022 }
1023
1024 bool playerOnIce() {
1025 return _playerOnIce;
1026 }
1027
1028 bool playerLocked() {
1029 return _playerLock;
1030 }
1031
1032 void setPlayerLock(bool status) {
1033 _playerLock = status;
1034 }
1035
1036 void setPlayerInvisible(bool status) {
1037 _playerInvisible = status;
1038 }
1039
1040 bool playerRunning() {
1041 return _playerRunning;
1042 }
1043
1044 void togglePlayerRunning() {
1045 _playerRunning = !_playerRunning;
1046 }
1047
1048 // Cinematic Functions
1049 bool cinematicsActive() {
1050 return _cineActive;
1051 }
1052 bool cineAbortable() {
1053 return _cineAbortable;
1054 }
1055 void processCines();
1056 void cineCleanup();
1057 void cineAbort();
1058 void cineAddToBlitList(const char *id, Picture *pic, int x, int y, bool masked);
1059 Picture *cineFindInBlitList(const char *name);
1060 void cineRemoveFromBlitList(const char *name);
1061 void cineAddToFreeList(Picture *pic);
1062 void cineFreeGfx();
1063 void cineStart(bool abortable, const char *abortFunc);
1064 void cineStop(const char *funcNext);
1065 void cineStartMap(const char *mapName);
1066 void cineLockPlayer();
1067 void cineUnlockPlayer();
1068 void cineSetCamera(int x, int y);
1069 void cineResetCamera();
1070 void cineMoveCamera(int x, int y, int speed);
1071 void cineWait(int seconds);
1072 void cineWaitUntilDone();
1073 void cineSetEntity(const char *entName, int x, int y, int level);
1074 void cineMoveEntity(const char *entName, int x, int y, int level, int speed);
1075 void cineSpawnEntity(AIType t, AIDir d, int x, int y, const char *func_init, const char *func_action,
1076 const char *func_use, AIDir d2, int level, int value1, int value2);
1077 void cineRemoveEntity(const char *entName);
1078 void cineAnimEntity(const char *entName, AIState state, int loop);
1079 void cineSetAnimFrame(const char *entName, AIState state, int frame);
1080 void cineEntityFace(const char *luaName, double dir);
1081 void cineDialog(const char *title, const char *string, int seconds);
1082 void cineTextOut(const char *text, int x, int y, int timer);
1083 void cineCenterTextOut(const char *text, int y, int timer);
1084 void cineDrawPic(const char *id, const char *pic, int x, int y);
1085 void cineDrawMaskedPic(const char *id, const char *pic, int x, int y);
1086 void cineMovePic(const char *id, const char *pic, int x1, int y1, int x2, int y2, int speed);
1087 void cineMoveMaskedPic(const char *id, const char *pic, int x1, int y1, int x2, int y2, int speed);
1088 void cineUse(const char *entName);
1089 void cinePlaySound(int index);
1090 void cinePlayVoice(int index, int actor);
1091 void cineFadeIn(bool isBlack, int steps);
1092 void cineFadeOut(bool isBlack, int steps);
1093 void cineClearForeground(int x, int y);
1094 void cineSetBackground(int x, int y, int index);
1095 void cineSetForeground(int x, int y, int index);
1096 void cineFunction(const char *func);
1097
1098 // Waypoint & Movement Functions
1099 void lookAtXY(int x, int y);
1100 void addWaypoint(int px, int py, int x, int y, int level);
1101 void removeFirstWaypoint();
1102 void clearWaypoints();
1103 bool traceStraightPath(int x1, int y1, int *x2, int *y2, int *lvl);
1104 Tile *getStandFrameDir(AIEntity *e);
1105 void drawWayPoints();
1106 int waypointsLeft() {
1107 return _numWaypoints;
1108 }
1109
1110 // Inventory Functions
1111 bool addToInventory(AIEntity *e);
1112 void purgeInventory();
1113 void clearInventory();
1114 int getInvAmount() {
1115 return _numInventory;
1116 }
1117 int getGemAmount() {
1118 return _numGems;
1119 }
1120 int getMonkeystoneAmount() {
1121 return _numMonkeystones;
1122 }
1123 int getGooCupAmount() {
1124 return _numGooCups;
1125 }
1126 void setGemAmount(int amt) {
1127 _numGems = amt;
1128 }
1129 int getInvMax() {
1130 return _numInventory;
1131 }
1132 AIType getInvItemType(int which) {
1133 return _inventory[which].ent.type;
1134 }
1135 Tile *getInvItemGfx(int which) {
1136 return _inventory[which].ent.standdownGfx[0];
1137 }
1138
1139 AIEntity *getInvItem(int which);
1140 int queryInventory(const char *string);
1141 bool removeInvItem(const char *string, int amount);
1142 int queryInventoryType(AIType which);
1143 int queryInventoryTypeSlot(AIType which);
1144 bool removeInvItemType(AIType which, int amount);
1145 bool addItemToInventory(AIType type, int amount, const char *funcInit, const char *funcAction, const char *funcUse);
1146 void keepInvItem(AIType type);
1147 void printYouGotMsg(const char *name);
1148
1149 // Delivery Functions
1150 void newDelivery(const char *itemTextName, const char *itemGfxName, const char *destTextName, const char *destGfxName, const char *id);
1151 int getDeliveriesAmount() {
1152 return _numDeliveries;
1153 }
1154 DlvEnt *getDeliveryItem(int which) {
1155 return &_deliveries[which];
1156 }
1157 bool completeDelivery(const char *id);
1158
1159 // Gate Puddles
1160 int _gatePuddles;
1161 void addGatePuddle(int amount) {
1162 _gatePuddles += amount;
1163 }
1164 int getGatePuddles() {
1165 return _gatePuddles;
1166 }
1167
1168 // Platform-Specific Constants
1169 int _youGotY;
1170
1171 // Player Variables
1172 bool _playerDead;
1173 bool _playerInvisible; // While on RailRider for example
1174 bool _playerOnIce;
1175 bool _playerEmerging;
1176 bool _playerRunning;
1177
1178 uint16 _pushupFrames;
1179 Tile *_pushupGfx[kMaxAnimFrames];
1180
1181 uint16 _pushdownFrames;
1182 Tile *_pushdownGfx[kMaxAnimFrames];
1183
1184 uint16 _pushleftFrames;
1185 Tile *_pushleftGfx[kMaxAnimFrames];
1186
1187 uint16 _pushrightFrames;
1188 Tile *_pushrightGfx[kMaxAnimFrames];
1189
1190 Tile *_getGfx[5]; // only 1 frame in each direction (+1 for DIR_NONE at start)
1191
1192 uint16 _dyingFrames;
1193 Tile *_dyingGfx[kMaxDeathFrames];
1194
1195 Tile *_goodjobGfx; // only 1 frame
1196
1197 uint16 _horrible1Frames;
1198 Tile *_horrible1Gfx[kMaxDeathFrames];
1199 uint16 _horrible2Frames;
1200 Tile *_horrible2Gfx[kMaxDeathFrames];
1201 uint16 _horrible3Frames;
1202 Tile *_horrible3Gfx[kMaxDeathFrames];
1203 uint16 _horrible4Frames;
1204 Tile *_horrible4Gfx[kMaxDeathFrames];
1205 uint16 _plummetFrames;
1206 Tile *_plummetGfx[kMaxDeathFrames];
1207
1208 uint16 _clubUpFrames;
1209 Picture *_clubUpGfx[kMaxAnimFrames];
1210 uint16 _clubDownFrames;
1211 Picture *_clubDownGfx[kMaxAnimFrames];
1212 uint16 _clubLeftFrames;
1213 Picture *_clubLeftGfx[kMaxAnimFrames];
1214 uint16 _clubRightFrames;
1215 Picture *_clubRightGfx[kMaxAnimFrames];
1216
1217 uint16 _stunUpFrames;
1218 Tile *_stunUpGfx[kMaxAnimFrames];
1219 uint16 _stunDownFrames;
1220 Tile *_stunDownGfx[kMaxAnimFrames];
1221 uint16 _stunLeftFrames;
1222 Tile *_stunLeftGfx[kMaxAnimFrames];
1223 uint16 _stunRightFrames;
1224 Tile *_stunRightGfx[kMaxAnimFrames];
1225 Tile *_stunLightningGfx[kMaxAnimFrames];
1226 Tile *_stunnedGfx[kMaxAnimFrames];
1227
1228 uint16 _slugUpFrames;
1229 Tile *_slugUpGfx[kMaxAnimFrames];
1230 uint16 _slugDownFrames;
1231 Tile *_slugDownGfx[kMaxAnimFrames];
1232 uint16 _slugLeftFrames;
1233 Tile *_slugLeftGfx[kMaxAnimFrames];
1234 uint16 _slugRightFrames;
1235 Tile *_slugRightGfx[kMaxAnimFrames];
1236
1237 uint16 _slugAttackFrames;
1238 Picture *_slugAttackGfx[kMaxAnimFrames];
1239
1240 Tile *_weaponSelGfx;
1241 Tile *_weaponGfx;
1242 AIType _weaponSelected;
1243
1244 // Player Resources and Deliveries
1245
1246 int _numGems;
1247 int _numGooCups;
1248 int _numMonkeystones;
1249
1250 // Special Tiles that are usable
1251 // These variables hold the tile-indices set
1252 // in ai-init.cpp
1253
1254 int _useSwitchOff; // the door opening switch
1255 int _useSwitchOn; // state, when opened
1256 int _useHolderEmpty; // cell holding switch
1257 int _useHolderFull; // state, when full
1258 int _useSwitch2Off; // another switch
1259 int _useSwitch2On; // state, when opened
1260 int _useMailsorter; // mailsorter entity
1261 int _useAskcomp; // askcomp entitiy
1262 int _useTeleporter; // teleporter entity
1263 int _useHandswitchOn; // 2-sided handswitch
1264 int _useHandswitchOff; // 2-sided handswitch
1265
1266 int _targetDoorN; // horz SILVER door
1267 int _targetDoorP; // horz BLUE door
1268 int _targetDoorS; // horz RED door
1269 int _targetDoorNv; // vert SILVER door
1270 int _targetDoorPv; // vert BLUE door
1271 int _targetDoorSv; // vert RED door
1272
1273 int _targetDoor2N; // horz SILVER door
1274 int _targetDoor2P; // horz BLUE door
1275 int _targetDoor2S; // horz RED door
1276 int _targetDoor2Nv; // vert SILVER door
1277 int _targetDoor2Pv; // vert BLUE door
1278 int _targetDoor2Sv; // vert RED door
1279
1280 int _target2DoorN; // horz SILVER door
1281 int _target2DoorP; // horz BLUE door
1282 int _target2DoorS; // horz RED door
1283 int _target2DoorNv; // vert SILVER door
1284 int _target2DoorPv; // vert BLUE door
1285 int _target2DoorSv; // vert RED door
1286
1287 int _target3DoorN; // horz SILVER door
1288 int _target3DoorP; // horz BLUE door
1289 int _target3DoorS; // horz RED door
1290 int _target3DoorNv; // vert SILVER door
1291 int _target3DoorPv; // vert BLUE door
1292 int _target3DoorSv; // vert RED door
1293
1294 int _targetBridgeU; // bridge extending UP
1295 int _targetBridgeD; // bridge extending DOWN
1296 int _targetBridgeL; // bridge extending LEFT
1297 int _targetBridgeR; // bridge extending RIGHT
1298
1299 int _targetBridgeMidLR; // bridge grating plank LEFT/RIGHT
1300 int _targetBridgeMidUD; // bridge grating plank UP/DOWN
1301 int _touchplateOn; // touchplate ON
1302 int _touchplateOff;
1303 int _templeTouchpOn; // touchplate ON
1304 int _templeTouchpOff;
1305 int _blockpole; // blockpole
1306
1307 int _kcHolderWhiteOff; // keycard holders
1308 int _kcHolderWhiteOn;
1309 int _kcHolderBlueOff;
1310 int _kcHolderBlueOn;
1311 int _kcHolderRedOff;
1312 int _kcHolderRedOn;
1313 int _kcHolderGreenOff;
1314 int _kcHolderGreenOn;
1315 int _kcHolderPurpleOff;
1316 int _kcHolderPurpleOn;
1317 int _kcHolderBlackOff;
1318 int _kcHolderBlackOn;
1319
1320 AIEntLevel2 _entsLevel2[kMaxLevel2Ents];
1321 int _numLevel2Ents;
1322
1323 InvEnt _inventory[kMaxInventory];
1324 int _numInventory;
1325
1326 DlvEnt _deliveries[kMaxDeliveries];
1327 int _numDeliveries;
1328
1329 Waypoint _waypoints[kMaxWaypoints];
1330 int _numWaypoints;
1331 Tile *_waypointGfx[4]; // Animating waypoint gfx
1332 Tile *_debugQMark;
1333
1334 LuaT _luaList[kMaxLuaEnts];
1335 int _numLuaList;
1336
1337 ActionInfo _actions[kMaxActions];
1338
1339 TeleInfo _teleporters[kMaxTeleporters];
1340 int _numTeleporters;
1341 // Virtual Player
1342 AIEntity _dummyPlayer, _dummyLaser;
1343 bool _laserRescan, _laserOnScreen;
1344
1345 AutoAction _autoActions[kMaxAutoActions];
1346
1347 Callback _callbacks[kMaxCallbacks];
1348
1349 Fairystone _fairystones[kMaxFairystones];
1350
1351 Bridge _bridges[kMaxBridges];
1352 int _numBridges;
1353
1354 Common::Array<ArrowPath *> *_arrowPaths;
1355 Common::Array<HereT *> *_hereList;
1356 Common::Array<Trigger *> *_triggerList;
1357
1358 // Cinematic Variables
1360
1361 Picture *_cineFreeList[kMaxCineGfx];
1362 int _numCineFreeList;
1363
1364 CineBlit *_cineBlitList[kMaxCineGfx];
1365 int _numCineBlitList;
1366
1367 int _stunAnim;
1368 uint32 _stunTimer;
1369
1370 // Bots Gfx
1371
1372 Picture *_icepSnowballGfxDown; // ICEPUFF's snowball moving down
1373 Picture *_icepSnowballGfxLeft; // ICEPUFF's snowball moving left
1374 Picture *_icepSnowballGfxRight; // ICEPUFF's snowball moving right
1375
1376 Tile *_tileFroglickMiddleUD;
1377 Tile *_tileFroglickWiggleUD[3];
1378 Tile *_tileFroglickMiddleLR;
1379 Tile *_tileFroglickWiggleLeft[3];
1380 Tile *_tileFroglickWiggleRight[3];
1381
1382 Picture *_gfxDragonAsleep;
1383 Picture *_gfxDragonFlap[2];
1384 Picture *_gfxDragonBreathe[3];
1385
1386 Tile *_gfxLaserbeamUD[4];
1387 Tile *_gfxLaserbeamUDTop[4];
1388 Tile *_gfxLaserbeamUDBottom[4];
1389 Tile *_gfxLaserbeamLR[4];
1390 Tile *_gfxLaserbeamLRLeft[4];
1391 Tile *_gfxLaserbeamLRRight[4];
1392
1393private:
1394
1395 // Action Functions
1396
1397 // Checks for the existence of a closed/open door
1398 bool isClosedDoor(int x, int y);
1399 bool isOpenDoor(int x, int y);
1400
1401 // MAIN FUNCTION : handles all animation of targeted tiles & changing the state of the "switch"
1402 bool useTarget(int x, int y, int targetX, int targetY, int newTile, int *worked);
1403
1404 // Black Door Switch
1405 bool useSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile);
1406 bool useSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY, int offTile);
1407 bool useSwitch2(AIEntity *e, int x, int y, int targetX, int targetY);
1408
1409 // Colored Keycard Switch
1410 bool useLockedSwitch(AIEntity *e, int x, int y, int targetX, int targetY, int onTile, AIType item, const char *keyerror);
1411 bool useLockedSwitchOn(AIEntity *e, int x, int y, int targetX, int targetY, int offTile, AIType item);
1412
1413 // Purple Cell Holder Switch
1414 bool useCellHolder(AIEntity *e, int x, int y, int targetX, int targetY);
1415
1416 // Touchplate
1417 bool useTouchplate(AIEntity *e, int x, int y, int targetX, int targetY, int type);
1418 bool useTouchplateOn(AIEntity *e, int x, int y, int targetX, int targetY, int type);
1419
1420 // Normal Door
1421 bool useDoorOpenClose(AIEntity *e, int x, int y);
1422 bool useAutoDoorOpenClose(AIEntity *e, int x, int y);
1423
1424 // Any Type Door
1425 bool useDoorOpenCloseBot(AIEntity *e, int x, int y);
1426
1429 Common::Array<AnimTarget *> _animTargets;
1430 AIEntity *_player;
1431
1432 // Cinematics Variables
1433 bool _cineAbortable;
1434 bool _cineAborted;
1435 const char *_cineAbortFunc;
1436 bool _cineActive;
1437 bool _playerLock;
1438 bool _cameraLock;
1439 double _cameraX, _cameraY;
1440
1441};
1442
1443const char *AIType2Str(AIType v);
1444const char *AIState2Str(AIState v);
1445
1446} // End of Namespace
1447
1448#endif // !HDB_AI_H
Definition: array.h:52
Definition: savefile.h:54
Definition: stream.h:745
Definition: ai.h:872
Definition: gfx.h:235
Definition: gfx.h:257
#define ARRAYSIZE(x)
Definition: util.h:114
Definition: ai.h:570
Definition: ai.h:560
Definition: ai.h:388
Definition: ai.h:380
Definition: ai.h:672
Definition: ai.h:581
Definition: ai.h:755
Definition: ai.h:734
Definition: ai.h:811
Definition: ai.h:782
Definition: ai.h:787
Definition: ai.h:848
Definition: ai.h:830
Definition: ai.h:612
Definition: ai.h:804
Definition: ai.h:763
Definition: ai.h:598
Definition: ai.h:650
Definition: ai.h:727
Definition: ai.h:694
Definition: ai.h:768
Definition: ai.h:636