ScummVM API documentation
map_dungeon.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 ULTIMA1_DATA_MAP_DUNGEON_H
23#define ULTIMA1_DATA_MAP_DUNGEON_H
24
25#include "common/serializer.h"
26
27namespace Ultima {
28namespace Ultima1 {
29namespace Data {
30
31constexpr int DUNGEON_WIDTH = 11;
32constexpr int DUNGEON_HEIGHT = 11;
33constexpr int DUNGEON_FLOORS = 10;
34// Number of distinct monster "slots" filled in when a level is generated
35constexpr int DUNGEON_MONSTER_SLOTS = 5;
36
37// No monster is present in a cell. Real monster Ids are 0-24 (5 tiers of
38// 5 types, tier = (dungeonLevel - 1) / 2), so this can't use 0 like the
39// _itemId sentinel does
40constexpr int16 DUNGEON_NO_MONSTER = -1;
41
42// Disguised monster Ids that don't block movement/view like a normal
43// monster would - a mimic looks (and is named) like a chest, an
44// invisible seeker isn't visibly drawn at all, and a gelatinous cube
45// fills the passage but can still be seen/moved past
46constexpr int UMONS_GELATINOUS_CUBE = 9;
47constexpr int UMONS_MIMIC = 11;
48constexpr int UMONS_INVISIBLE_SEEKER = 20;
49
50// Monster Ids with a special effect on a successful melee hit (see
51// DungeonLogic::dungeonMonsterAttack)
52constexpr int UMONS_THIEF = 2;
53constexpr int UMONS_GREMLIN = 16;
54constexpr int UMONS_MIND_WHIPPER = 21;
55
56// Dungeon monster names, indexed by DungeonCell::_monsterId (0-24)
57constexpr int DUNGEON_MONSTER_COUNT = 25;
58extern const char *UNDERWORLD_MONSTERS[];
59
60enum DungeonTileId {
61 DTILE_HALLWAY = 0,
62 DTILE_WALL = 1,
63 DTILE_SECRET_DOOR = 2,
64 DTILE_DOOR = 3,
65 DTILE_CHEST = 4,
66 DTILE_COFFIN = 5,
67 DTILE_LADDER_DOWN = 6,
68 DTILE_LADDER_UP = 7,
69 DTILE_BEAMS = 8
70};
71
72// Values of DungeonCell::_itemId. Shares numbering with DungeonTileId's
73// chest/coffin, since the original stores the same tile Id in both places
74enum DungeonItemId {
75 DITEM_NONE = 0,
76 DITEM_CHEST = DTILE_CHEST,
77 DITEM_COFFIN = DTILE_COFFIN
78};
79
81 DungeonTileId _tileNum;
82 int16 _monsterId;
83 int16 _itemId;
84 int16 _monsterHp;
85};
86
87struct MapDungeon {
88private:
89 uint16 _randomSeed = 0;
90 // Tracks which of the 5 monster slots have already been filled while
91 // generating the current level
92 bool _monsterSlotUsed[DUNGEON_MONSTER_SLOTS] = {};
93
97 void clear();
98
102 void setRandomSeed();
103
109 byte getRandomNumber(int minVal, int maxVal);
110
116 void dungeonSpawnMonster();
117
118public:
119 DungeonCell _cells[DUNGEON_HEIGHT][DUNGEON_WIDTH];
120
121public:
122 MapDungeon();
123
128
133 void killMonster(int x, int y);
134
141 void spawnMonsterAt(int x, int y);
142
143 void synchronize(Common::Serializer &s);
144};
145
146} // namespace Data
147} // namespace Ultima1
148} // namespace Ultima
149
150#endif
Definition: serializer.h:80
Definition: map_dungeon.h:80
Definition: map_dungeon.h:87
void spawnMonsterAt(int x, int y)