ScummVM API documentation
spriteai.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 /*
23  * This code is based on the CRAB engine
24  *
25  * Copyright (c) Arvind Raja Yadav
26  *
27  * Licensed under MIT
28  *
29  */
30 
31 #ifndef CRAB_SPRITEAI_H
32 #define CRAB_SPRITEAI_H
33 
34 #include "crab/ai/movement.h"
35 #include "crab/PathfindingAgent.h"
36 
37 namespace Crab {
38 
39 // class PathfindingAgent;
40 namespace pyrodactyl {
41 namespace ai {
42 
43 // States of a fighting sprite
44 enum AIFightState {
45  FIGHTSTATE_GETNEXTMOVE,
46  FIGHTSTATE_GETINRANGE,
47  FIGHTSTATE_EXECUTEMOVE,
48  FIGHTSTATE_CANTFIGHT
49 };
50 
51 // States of a fleeing sprite
52 enum AIFleeState {
53  FLEESTATE_GETNEARESTEXIT,
54  FLEESTATE_RUNTOEXIT,
55  FLEESTATE_DISAPPEAR,
56  FLEESTATE_CANTFLEE
57 };
58 
59 struct SpriteAIData {
60  // Data required for fighting
61  struct FightData {
62  // The state of the sprite
63  AIFightState _state;
64 
65  // Used to count down the time NPCs wait before their next move
66  // Usually varies per move which is why we don't load target for it
67  Timer _delay;
68 
69  // The list of moves that can be performed while attacking
70  Common::Array<uint> _attack;
71 
72  FightData() {
73  _state = FIGHTSTATE_GETNEXTMOVE;
74  }
75  } _fight;
76 
77  // The pattern a peaceful sprite walks in
78  MovementSet _walk;
79 
80  // Data required to flee
81  struct FleeData {
82  AIFleeState _state;
83 
84  FleeData() {
85  _state = FLEESTATE_GETNEARESTEXIT;
86  }
87  } _flee;
88 
89  // The next location the sprite has to reach
90  // PLAYER: Used for adventure game style point-n-click movement
91  // AI: Used for path-finding (usually to the player's location)
92  struct Destination : public Vector2i {
93  // Are we trying to reach the destination?
94  bool _active;
95 
96  Destination() {
97  _active = false;
98  }
99  } _dest;
100 
101  SpriteAIData() {}
102 
103  void dest(const int &x, const int &y, const bool &active = true) {
104  _dest.x = x;
105  _dest.y = y;
106  _dest._active = active;
107  }
108 
109  void dest(const Vector2i &v, const bool &active = true) {
110  dest(v.x, v.y, active);
111  }
112 };
113 } // End of namespace ai
114 } // End of namespace pyrodactyl
115 
116 } // End of namespace Crab
117 
118 #endif // CRAB_SPRITEAI_H
Definition: spriteai.h:59
Definition: moveeffect.h:37
Definition: timer.h:43
Definition: movement.h:42