nonhumans separation
[k8-i-v-a-n.git] / src / game / level.h
blobe82ae6fa6a2a931b9fd48615c66432c8b64a659f
1 /*
3 * Iter Vehemens ad Necem (IVAN)
4 * Copyright (C) Timo Kiviluoto
5 * Released under the GNU General
6 * Public License
8 * See LICENSING which should be included
9 * along with this file for more details
13 #ifndef __LEVEL_H__
14 #define __LEVEL_H__
16 #include <vector>
17 #include <queue>
18 #include <set>
20 #include "area.h"
21 #include "square.h"
22 #include "ivandef.h"
24 class levelscript;
25 class roomscript;
26 class squarescript;
27 class glterrain;
28 class olterrain;
29 class dungeon;
30 class lsquare;
31 class room;
32 class item;
33 class liquid;
34 class gas;
35 class level;
36 class material;
37 class team;
38 struct node;
39 struct emitter;
40 template <class type> struct fearray;
42 struct nodepointerstorer
44 nodepointerstorer(node* Node) : Node(Node) { }
45 bool operator<(const nodepointerstorer&) const;
46 node* Node;
49 struct spawnresult
51 ccharacter* Pioneer;
52 int Seen;
55 typedef std::priority_queue<nodepointerstorer> nodequeue;
56 typedef std::vector<item*> itemvector;
57 typedef std::vector<character*> charactervector;
58 typedef std::vector<emitter> emittervector;
59 typedef std::vector<feuLong> sunemittervector;
60 typedef character* (*characterspawner)(int, int);
62 struct node
64 node(int x, int y, lsquare* Square) : Square(Square), Pos(x, y) { }
65 void CalculateNextNodes();
66 lsquare* Square;
67 node* Last;
68 v2 Pos;
69 sLong Distance;
70 sLong Remaining;
71 sLong TotalDistanceEstimate;
72 sLong Diagonals;
73 truth InNodeQueue;
74 truth Processed;
75 static node*** NodeMap;
76 static int RequiredWalkability;
77 static ccharacter* SpecialMover;
78 static v2 To;
79 static uChar** WalkabilityMap;
80 static int XSize, YSize;
81 static nodequeue* NodeQueue;
84 struct explosion
86 character* Terrorist;
87 festring DeathMsg;
88 v2 Pos;
89 feuLong ID;
90 int Strength;
91 int RadiusSquare;
92 int Size;
93 truth HurtNeutrals;
96 struct beamdata
98 beamdata(character*, cfestring&, int, feuLong);
99 beamdata(character*, cfestring&, v2, col16, int, int, int, feuLong);
100 character* Owner;
101 festring DeathMsg;
102 v2 StartPos;
103 col16 BeamColor;
104 int BeamEffect;
105 int Direction;
106 int Range;
107 feuLong SpecialParameters;
110 inline beamdata::beamdata
112 character* Owner,
113 cfestring& DeathMsg,
114 int Direction,
115 feuLong SpecialParameters
117 Owner(Owner),
118 DeathMsg(DeathMsg),
119 Direction(Direction),
120 SpecialParameters(SpecialParameters)
123 inline beamdata::beamdata
125 character* Owner,
126 cfestring& DeathMsg,
127 v2 StartPos,
128 col16 BeamColor,
129 int BeamEffect,
130 int Direction,
131 int Range,
132 feuLong SpecialParameters
134 Owner(Owner),
135 DeathMsg(DeathMsg),
136 StartPos(StartPos),
137 BeamColor(BeamColor),
138 BeamEffect(BeamEffect),
139 Direction(Direction),
140 Range(Range),
141 SpecialParameters(SpecialParameters)
144 class level : public area
146 public:
147 level();
148 virtual ~level();
149 void Generate(int);
150 v2 GetRandomSquare(ccharacter* = 0, int = 0, const rect* = 0) const;
151 void GenerateMonsters();
152 lsquare* GetLSquare(v2 Pos) const { return Map[Pos.X][Pos.Y]; }
153 lsquare* GetLSquare(int x, int y) const { return Map[x][y]; }
154 void GenerateTunnel(int, int, int, int, truth);
155 void ExpandPossibleRoute(int, int, int, int, truth);
156 void ExpandStillPossibleRoute(int, int, int, int, truth);
157 void Save(outputfile&) const;
158 void Load(inputfile&);
159 void FiatLux();
160 int GetIdealPopulation() const { return IdealPopulation; }
161 double GetDifficulty() const { return Difficulty; }
162 void GenerateNewMonsters(int, truth = true);
163 void AttachPos(int, int);
164 void AttachPos(v2 Pos) { AttachPos(Pos.X, Pos.Y); }
165 void CreateItems(int);
166 truth MakeRoom(const roomscript*);
167 void ParticleTrail(v2, v2);
168 festring GetLevelMessage() { return LevelMessage; }
169 void SetLevelMessage(cfestring& What) { LevelMessage = What; }
170 void SetLevelScript(const levelscript* What) { LevelScript = What; }
171 truth IsOnGround() const;
172 const levelscript* GetLevelScript() const { return LevelScript; }
173 int GetLOSModifier() const;
174 room* GetRoom(int) const;
175 void SetRoom(int, room*);
176 void AddRoom(room*);
177 void Explosion(character*, cfestring&, v2, int, truth = true);
178 truth CollectCreatures(charactervector&, character*, truth);
179 void ApplyLSquareScript(const squarescript*);
180 virtual void Draw(truth) const;
181 v2 GetEntryPos(ccharacter*, int) const;
182 void GenerateRectangularRoom(std::vector<v2>&, std::vector<v2>&, std::vector<v2>&, const roomscript*, room*, v2, v2);
183 void Reveal();
184 static void (level::*GetBeam(int))(beamdata&);
185 void ParticleBeam(beamdata&);
186 void LightningBeam(beamdata&);
187 void ShieldBeam(beamdata&);
188 dungeon* GetDungeon() const { return Dungeon; }
189 void SetDungeon(dungeon* What) { Dungeon = What; }
190 int GetIndex() const { return Index; }
191 void SetIndex(int What) { Index = What; }
192 truth DrawExplosion(const explosion*) const;
193 int TriggerExplosions(int);
194 lsquare*** GetMap() const { return Map; }
195 v2 GetNearestFreeSquare(ccharacter*, v2, truth = true) const;
196 v2 FreeSquareSeeker(ccharacter*, v2, v2, int, truth) const;
197 v2 GetFreeAdjacentSquare(ccharacter*, v2, truth) const;
198 static void (level::*GetBeamEffectVisualizer(int))(const fearray<lsquare*>&, col16) const;
199 void ParticleVisualizer(const fearray<lsquare*>&, col16) const;
200 void LightningVisualizer(const fearray<lsquare*>&, col16) const;
201 truth PreProcessForBone();
202 truth PostProcessForBone();
203 void FinalProcessForBone();
204 void GenerateDungeon(int);
205 void GenerateDesert();
206 void GenerateJungle();
207 void GenerateSteppe();
208 void GenerateLeafyForest();
209 void GenerateEvergreenForest();
210 void GenerateTundra();
211 void GenerateGlacier();
212 void CreateTunnelNetwork(int, int, int, int, v2);
213 void SetWalkability(v2 Pos, int What) { WalkabilityMap[Pos.X][Pos.Y] = What; }
214 node* FindRoute(v2, v2, const std::set<v2>&, int, ccharacter* = 0);
215 void AddToAttachQueue(v2);
216 void CollectEverything(itemvector&, charactervector&);
217 void CreateGlobalRain(liquid*, v2);
218 void CheckSunLight();
219 col24 GetSunLightEmitation() const { return SunLightEmitation; }
220 void InitSquarePartEmitationTicks();
221 col24 GetAmbientLuminance() const { return AmbientLuminance; }
222 void ForceEmitterNoxify(const emittervector&) const;
223 void ForceEmitterEmitation(const emittervector&, const sunemittervector&, feuLong = 0) const;
224 void UpdateLOS();
225 void EnableGlobalRain();
226 void DisableGlobalRain();
227 void InitLastSeen();
228 lsquare** GetSquareStack() const { return SquareStack; }
229 col24 GetNightAmbientLuminance() const { return NightAmbientLuminance; }
230 int DetectMaterial(cmaterial*);
231 void BlurMemory();
232 void CalculateLuminances();
233 int AddRadiusToSquareStack(v2, sLong) const;
234 olterrain* GetRandomFountainWithWater(olterrain*) const;
235 int GetEnchantmentMinusChance() { return EnchantmentMinusChance; }
236 int GetEnchantmentPlusChance() { return EnchantmentPlusChance; }
237 void Amnesia(int);
238 spawnresult SpawnMonsters(characterspawner, team*, v2, int = 0, int = 1, truth = false);
239 void AddSpecialCursors();
240 void GasExplosion(gas*, lsquare*);
241 protected:
242 truth GenerateLanterns(int, int, int) const;
243 truth GenerateWindows(int, int) const;
244 void CreateRoomSquare(glterrain*, olterrain*, int, int, int, int) const;
245 void EmitSunBeams();
246 void EmitSunBeam(v2, feuLong, int) const;
247 void ChangeSunLight();
248 void EmitSunLight(v2);
249 lsquare*** Map;
250 const levelscript* LevelScript;
251 festring LevelMessage;
252 std::vector<v2> Door;
253 std::vector<room*> Room;
254 int IdealPopulation;
255 int MonsterGenerationInterval;
256 double Difficulty;
257 dungeon* Dungeon;
258 int Index;
259 std::vector<explosion*> ExplosionQueue;
260 std::vector<truth> PlayerHurt;
261 node*** NodeMap;
262 uChar** WalkabilityMap;
263 std::vector<v2> AttachQueue;
264 liquid* GlobalRainLiquid;
265 v2 GlobalRainSpeed;
266 col24 SunLightEmitation;
267 v2 SunLightDirection;
268 col24 AmbientLuminance;
269 static feuLong NextExplosionID;
270 lsquare** SquareStack;
271 col24 NightAmbientLuminance;
272 int EnchantmentMinusChance;
273 int EnchantmentPlusChance;
276 outputfile& operator<<(outputfile&, const level*);
277 inputfile& operator>>(inputfile&, level*&);
279 #endif