3 * Iter Vehemens ad Necem (IVAN)
4 * Copyright (C) Timo Kiviluoto
5 * Released under the GNU General
8 * See LICENSING which should be included
9 * along with this file for more details
16 #include "ivancommon.h"
42 template <class type
> struct fearray
;
44 struct nodepointerstorer
46 nodepointerstorer(node
* Node
) : Node(Node
) { }
47 bool operator<(const nodepointerstorer
&) const;
57 typedef std::priority_queue
<nodepointerstorer
> nodequeue
;
58 typedef std::vector
<item
*> itemvector
;
59 typedef std::vector
<character
*> charactervector
;
60 typedef std::vector
<emitter
> emittervector
;
61 typedef std::vector
<feuLong
> sunemittervector
;
62 typedef character
* (*characterspawner
)(int, int);
66 node(int x
, int y
, lsquare
* Square
) : Square(Square
), Pos(x
, y
) { }
67 void CalculateNextNodes();
73 sLong TotalDistanceEstimate
;
77 static node
*** NodeMap
;
78 static int RequiredWalkability
;
79 static ccharacter
* SpecialMover
;
81 static uChar
** WalkabilityMap
;
82 static int XSize
, YSize
;
83 static nodequeue
* NodeQueue
;
100 beamdata(character
*, cfestring
&, int, feuLong
);
101 beamdata(character
*, cfestring
&, v2
, col16
, int, int, int, feuLong
);
109 feuLong SpecialParameters
;
112 inline beamdata::beamdata
117 feuLong SpecialParameters
121 Direction(Direction
),
122 SpecialParameters(SpecialParameters
)
125 inline beamdata::beamdata
134 feuLong SpecialParameters
139 BeamColor(BeamColor
),
140 BeamEffect(BeamEffect
),
141 Direction(Direction
),
143 SpecialParameters(SpecialParameters
)
147 maze (int x
, int y
) : MazeXSize(x
+2), MazeYSize(y
+2) { MazeVector
.resize(MazeXSize
*MazeYSize
); }
149 void InitializeMaze ();
150 std::vector
<truth
> MazeKernel
; // returns only the mazey bit in the middle (the kernel), without the exterior walls. The kernel size is the input size of maze - 2 for each dimension.
151 void CarveMaze (int, int); // Carves the maze
152 void StripMazeHusk (); // Removes the husk (skin and shell), and populates MazeKernel with the kernel.
153 const uint MazeXSize
; // XSize of the MazeVector
154 const uint MazeYSize
; // YSize of the MazeVector
156 std::vector
<truth
> MazeVector
; // Consists of the outer buffer (empty, called the skin) and the shell wall (next layer in, all full). Together they comprise the husk.
159 class level
: public area
166 v2
GetRandomSquare(ccharacter
* = 0, int = 0, const rect
* = 0) const;
167 void GenerateMonsters();
168 lsquare
* GetLSquare(v2 Pos
) const { return Map
[Pos
.X
][Pos
.Y
]; }
169 lsquare
* GetLSquare(int x
, int y
) const { return Map
[x
][y
]; }
170 void GenerateTunnel(int, int, int, int, truth
);
171 void ExpandPossibleRoute(int, int, int, int, truth
);
172 void ExpandStillPossibleRoute(int, int, int, int, truth
);
173 void Save(outputfile
&) const;
174 void Load(inputfile
&);
176 int GetIdealPopulation() const { return IdealPopulation
; }
177 double GetDifficulty() const { return Difficulty
; }
178 void GenerateNewMonsters(int, truth
= true);
179 void AttachPos(int, int);
180 void AttachPos(v2 Pos
) { AttachPos(Pos
.X
, Pos
.Y
); }
181 void CreateItems(int);
182 truth
MakeRoom(const roomscript
*);
183 void ParticleTrail(v2
, v2
);
184 festring
GetLevelMessage() { return LevelMessage
; }
185 void SetLevelMessage(cfestring
& What
) { LevelMessage
= What
; }
186 void SetLevelScript(const levelscript
* What
) { LevelScript
= What
; }
187 truth
IsOnGround() const;
188 truth
EarthquakesAffectTunnels() const;
189 const levelscript
* GetLevelScript() const { return LevelScript
; }
190 int GetLOSModifier() const;
191 room
* GetRoom(int) const;
192 void SetRoom(int, room
*);
194 void Explosion(character
*, cfestring
&, v2
, int, truth
= true);
195 truth
CollectCreatures(charactervector
&, character
*, truth
);
196 void ApplyLSquareScript(const squarescript
*);
197 virtual void Draw(truth
) const;
198 v2
GetEntryPos(ccharacter
*, int) const;
199 void GenerateRectangularRoom(std::vector
<v2
>&, std::vector
<v2
>&, std::vector
<v2
>&, const roomscript
*, room
*, v2
, v2
);
201 static void (level::*GetBeam(int))(beamdata
&);
202 void ParticleBeam(beamdata
&);
203 void LightningBeam(beamdata
&);
204 void ShieldBeam(beamdata
&);
205 dungeon
* GetDungeon() const { return Dungeon
; }
206 void SetDungeon(dungeon
* What
) { Dungeon
= What
; }
207 int GetIndex() const { return Index
; }
208 void SetIndex(int What
) { Index
= What
; }
209 truth
DrawExplosion(const explosion
*) const;
210 int TriggerExplosions(int);
211 lsquare
*** GetMap() const { return Map
; }
212 v2
GetNearestFreeSquare(ccharacter
*, v2
, truth
= true) const;
213 v2
FreeSquareSeeker(ccharacter
*, v2
, v2
, int, truth
) const;
214 v2
GetFreeAdjacentSquare(ccharacter
*, v2
, truth
) const;
215 static void (level::*GetBeamEffectVisualizer(int))(const fearray
<lsquare
*>&, col16
) const;
216 void ParticleVisualizer(const fearray
<lsquare
*>&, col16
) const;
217 void LightningVisualizer(const fearray
<lsquare
*>&, col16
) const;
218 truth
PreProcessForBone();
219 truth
PostProcessForBone();
220 void FinalProcessForBone();
221 truth
GenerateDungeon(int);
222 truth
GenerateDesert();
223 truth
GenerateJungle();
224 truth
GenerateSteppe();
225 truth
GenerateLeafyForest();
226 truth
GenerateEvergreenForest();
227 truth
GenerateTundra();
228 truth
GenerateGlacier();
229 void CreateTunnelNetwork(int, int, int, int, v2
);
230 void SetWalkability(v2 Pos
, int What
) { WalkabilityMap
[Pos
.X
][Pos
.Y
] = What
; }
231 node
* FindRoute(v2
, v2
, const std::set
<v2
>&, int, ccharacter
* = 0);
232 void AddToAttachQueue(v2
);
233 void CollectEverything(itemvector
&, charactervector
&);
234 void CreateGlobalRain(liquid
*, v2
);
235 void CheckSunLight();
236 col24
GetSunLightEmitation() const { return SunLightEmitation
; }
237 void InitSquarePartEmitationTicks();
238 col24
GetAmbientLuminance() const { return AmbientLuminance
; }
239 void ForceEmitterNoxify(const emittervector
&) const;
240 void ForceEmitterEmitation(const emittervector
&, const sunemittervector
&, feuLong
= 0) const;
242 void EnableGlobalRain();
243 void DisableGlobalRain();
245 lsquare
** GetSquareStack() const { return SquareStack
; }
246 col24
GetNightAmbientLuminance() const { return NightAmbientLuminance
; }
247 int DetectMaterial(cmaterial
*);
249 void CalculateLuminances();
250 int AddRadiusToSquareStack(v2
, sLong
) const;
251 olterrain
* GetRandomFountainWithWater(olterrain
*) const;
252 int GetEnchantmentMinusChance() { return EnchantmentMinusChance
; }
253 int GetEnchantmentPlusChance() { return EnchantmentPlusChance
; }
255 spawnresult
SpawnMonsters(characterspawner
, team
*, v2
, int = 0, int = 1, truth
= false);
256 void AddSpecialCursors();
257 void GasExplosion(gas
* GasMaterial
, lsquare
* Square
, character
* Terrorist
=0);
259 // check for special levels
260 truth
IsGCIvanLevel () const;
262 truth IsUTVesanaLevel () const;
263 truth IsGCEnnerLevel () const;
264 truth IsGCElpuriLevel () const; // also nicknamed "dark level"
265 truth IsGCOreeLevel () const;
266 truth IsSolicitusLevel () const;
267 truth IsAlienQueenLevel () const;
271 truth
GenerateLanterns(int, int, int) const;
272 truth
GenerateWindows(int, int) const;
273 void CreateRoomSquare(glterrain
*, olterrain
*, int, int, int, int) const;
275 void EmitSunBeam(v2
, feuLong
, int) const;
276 void ChangeSunLight();
277 void EmitSunLight(v2
);
279 const levelscript
* LevelScript
;
280 festring LevelMessage
;
281 std::vector
<v2
> Door
;
282 std::vector
<room
*> Room
;
284 int MonsterGenerationInterval
;
288 std::vector
<explosion
*> ExplosionQueue
;
289 std::vector
<truth
> PlayerHurt
;
291 uChar
** WalkabilityMap
;
292 std::vector
<v2
> AttachQueue
;
293 liquid
* GlobalRainLiquid
;
295 col24 SunLightEmitation
;
296 v2 SunLightDirection
;
297 col24 AmbientLuminance
;
298 static feuLong NextExplosionID
;
299 lsquare
** SquareStack
;
300 col24 NightAmbientLuminance
;
301 int EnchantmentMinusChance
;
302 int EnchantmentPlusChance
;
305 outputfile
& operator<<(outputfile
&, const level
*);
306 inputfile
& operator>>(inputfile
&, level
*&);