ScummVM API documentation
combat_logic.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 ULTIMA3_LOGIC_COMBAT_LOGIC_H
23#define ULTIMA3_LOGIC_COMBAT_LOGIC_H
24
25#include "common/array.h"
26#include "common/str.h"
27#include "ultima/ultima3/data/arena.h"
28#include "ultima/ultima3/logic/logic.h"
29
30namespace Ultima {
31namespace Ultima3 {
32
39 enum Type {
40 PRINT, // Adds text to the message window
41 SOUND, // Plays a sound effect
42 OVERLAY, // Shows a tile over the arena for a moment
43 FLASH_SLOT, // Inverts a party member's panel for a moment
44 FLASH_VIEW, // Inverts the arena for a moment
45 SHOW // Brings what's shown up to date with the fight
46 };
47
48 Type _type;
49 int _arg1 = 0, _arg2 = 0, _arg3 = 0;
50 Common::String _text;
51
52 CombatEvent(Type type, int a = 0, int b = 0, int c = 0) : _type(type), _arg1(a), _arg2(b), _arg3(c) {}
53 CombatEvent(const Common::String &text) : _type(PRINT), _text(text) {}
54};
55
59class CombatLogic : public Logic {
60private:
61 // What's drawn on the arena, which lags behind the real state while the
62 // events for a command are being played
63 byte _shown[Data::ARENA_SIZE * Data::ARENA_SIZE] = {};
64
66 bool _slayUsed = false;
67
68 void print(const Common::String &text);
69 void sound(int effect, int arg1 = 0, int arg2 = 0);
70 void overlay(int x, int y, int tile);
71 void flashSlot(int slot);
72 void show();
73
77 const char *chooseArena();
78
82 static int rollBelow(int limit);
83
88 bool isExodusFight() const;
89
94 Common::String monsterName(bool heading) const;
95
99 void startFight();
100
101 int monsterAt(int x, int y) const;
102 bool canMonsterMoveTo(int x, int y) const;
103
108 int shoot(int x, int y, int dx, int dy, int tile);
109
114 void playerHit(int slot, int monster);
115 void damageMonster(int slot, int monster, int damage);
116
122 int findTarget(int monster, int &target, int &stepX, int &stepY, int &toX, int &toY) const;
123
124 void monsterTurn(int monster);
125 void monsterAttack(int slot, int tile);
126 void monsterPoison(int slot);
127 void monsterSteal(int slot);
128 void monsterBreath(int monster, int stepX, int stepY);
129 void damagePlayer(int slot, int tile);
130 void killPlayer(int slot);
131
132public:
133 Data::Arena _arena;
134
135 // The tile number of the monsters being fought
136 byte _monsterClass = 0;
137
138 // Where the party was when the fight began
139 byte _savedLocation = 0;
140
141 int _combatant = 0;
142
146 void begin(int creature);
147
152 void beginDungeon(byte monsterClass);
153
157 void syncShown();
158
162 byte shownTile(int x, int y) const {
163 return _shown[y * Data::ARENA_SIZE + x];
164 }
165
170 return _events;
171 }
172
173 bool allMonstersDead() const;
174
179
183 int negateTurns() const;
184
185 void decrementHold();
186
187 void endHold();
188
193 bool movePlayer(int slot, int dx, int dy);
194
198 void playerAttack(int slot, Direction dir);
199
204
209 void castProjectile(int slot, int damage, Direction dir);
210
214 void castGroupDamage(int slot, int damage);
215
219 void castDrain();
220
225 bool castSlay(int slot, byte monsterClass);
226};
227
228} // namespace Ultima3
229} // namespace Ultima
230
231#endif
Definition: array.h:52
Definition: str.h:59
Definition: combat_logic.h:59
byte shownTile(int x, int y) const
Definition: combat_logic.h:162
bool castSlay(int slot, byte monsterClass)
void castGroupDamage(int slot, int damage)
Common::Array< CombatEvent > & events()
Definition: combat_logic.h:169
bool movePlayer(int slot, int dx, int dy)
void playerAttack(int slot, Direction dir)
void begin(int creature)
void beginDungeon(byte monsterClass)
void castProjectile(int slot, int damage, Direction dir)
Definition: logic.h:43
Definition: combat_logic.h:38
Definition: arena.h:43