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
15 #include "ivancommon.h"
32 class glterrainprototype
;
33 class olterrainprototype
;
34 template <class type
> class databasecreator
;
37 typedef glterrain
* (*glterrainspawner
)(int, int);
38 typedef olterrain
* (*olterrainspawner
)(int, int);
40 struct lterraindatabase
: public databasebase
42 void PostProcess() { }
44 truth UsesLongArticle
;
46 truth UsesLongAdjectiveArticle
;
47 festring NameSingular
;
51 fearray
<sLong
> MainMaterialConfig
;
52 fearray
<sLong
> SecondaryMaterialConfig
;
53 fearray
<sLong
> MaterialConfigChances
;
54 sLong MaterialConfigChanceSum
;
64 truth HasSecondaryMaterial
;
66 int BorderTilePriority
;
69 class lterrain
: public object
72 lterrain() : LSquareUnder(0) { }
73 virtual ~lterrain () {}
75 virtual void Load(inputfile
&);
76 virtual truth
Open(character
*) { return false; }
77 virtual truth
Close(character
*) { return false; }
79 virtual truth
CanBeOpened() const { return false; }
80 virtual truth
AcceptsOffers() const { return false; }
81 virtual truth
ReceiveVomit(character
*, liquid
*) { return false; }
82 virtual truth
CanBeOpenedByAI() { return false; }
83 virtual truth
Polymorph(character
*) { return false; }
84 virtual truth
DipInto(item
*, character
*) { return false; }
85 virtual truth
IsDipDestination() const { return false; }
86 virtual truth
TryKey(item
*, character
*) { return false; }
87 truth
CanBeSeenByPlayer() const;
88 truth
CanBeSeenBy(character
*) const;
89 virtual cfestring
& GetSitMessage() const = 0;
90 virtual truth
SitOn(character
*);
91 virtual square
* GetSquareUnderEntity(int = 0) const;
92 void SetLSquareUnder(lsquare
* What
) { LSquareUnder
= What
; }
93 lsquare
* GetLSquareUnder() const { return LSquareUnder
; }
94 level
* GetLevel() const;
95 lsquare
* GetNearLSquare(v2
) const;
96 lsquare
* GetNearLSquare(int, int) const;
97 virtual void CalculateAll() { CalculateEmitation(); }
98 virtual void SignalEmitationIncrease(col24
);
99 virtual void SignalEmitationDecrease(col24
);
100 virtual truth
HasKeyHole() const { return CanBeOpened(); }
101 virtual truth
IsOnGround() const { return true; }
102 room
* GetRoom() const;
103 virtual void SignalRustLevelChange();
104 virtual void TryToRust(sLong
);
105 virtual void ReceiveAcid(material
*, sLong
) { }
106 void InitMaterials(material
*, truth
= true);
107 void SetMainMaterial(material
*, int = 0);
108 void ChangeMainMaterial(material
*, int = 0);
109 virtual void GenerateMaterials();
110 virtual void InitMaterials(const materialscript
*, const materialscript
*, truth
);
111 virtual const fearray
<sLong
>& GetMainMaterialConfig() const = 0;
112 virtual void SurviveEffect(character
*) { }
113 virtual void RestoreHP() { }
114 virtual void AddLocationDescription(festring
&) const;
116 void Initialize(int, int);
117 virtual void PostConstruct() { }
118 virtual void InstallDataBase(int) = 0;
119 lsquare
* LSquareUnder
;
122 struct glterraindatabase
: public lterraindatabase
124 typedef glterrainprototype prototype
;
125 void InitDefaults(const prototype
*, int);
126 truth
AllowRandomInstantiation() const { return true; }
127 const prototype
* ProtoType
;
130 class glterrainprototype
133 friend class databasecreator
<glterrain
>;
135 glterrainprototype(const glterrainprototype
*, glterrainspawner
, cchar
*);
136 virtual ~glterrainprototype () {}
138 glterrain
* Spawn(int Config
= 0, int SpecialFlags
= 0) const { return Spawner(Config
, SpecialFlags
); }
139 glterrain
* SpawnAndLoad(inputfile
&) const;
140 cchar
* GetClassID() const { return ClassID
; }
141 int GetIndex() const { return Index
; }
142 const glterrainprototype
* GetBase() const { return Base
; }
143 int CreateSpecialConfigurations(glterraindatabase
**, int Configs
, int) { return Configs
; }
144 const glterraindatabase
* ChooseBaseForConfig(glterraindatabase
** TempConfig
, int, int) { return *TempConfig
; }
145 const glterraindatabase
*const* GetConfigData() const { return ConfigData
; }
146 int GetConfigSize() const { return ConfigSize
; }
149 const glterrainprototype
* Base
;
150 glterraindatabase
** ConfigData
;
151 glterraindatabase
** ConfigTable
[CONFIG_TABLE_SIZE
];
153 glterrainspawner Spawner
;
160 class glterrain
: public lterrain
, public gterrain
163 friend class databasecreator
<glterrain
>;
164 typedef glterrainprototype prototype
;
165 typedef glterraindatabase database
;
167 virtual ~glterrain () {}
169 virtual void Save(outputfile
&) const;
170 virtual void Load(inputfile
&);
171 virtual int GetEntryDifficulty() const { return 1; }
172 int GetType() const { return GetProtoType()->GetIndex(); }
173 const database
* GetDataBase() const { return DataBase
; }
174 DATA_BASE_VALUE(const prototype
*, ProtoType
);
175 DATA_BASE_VALUE(int, Config
);
176 DATA_BASE_TRUTH(UsesLongArticle
);
177 DATA_BASE_VALUE(cfestring
&, Adjective
);
178 DATA_BASE_TRUTH(UsesLongAdjectiveArticle
);
179 DATA_BASE_VALUE(cfestring
&, NameSingular
);
180 DATA_BASE_VALUE(cfestring
&, NamePlural
);
181 DATA_BASE_VALUE(cfestring
&, PostFix
);
182 DATA_BASE_VALUE(int, ArticleMode
);
183 virtual DATA_BASE_VALUE(const fearray
<sLong
>&, MainMaterialConfig
);
184 DATA_BASE_VALUE(const fearray
<sLong
>&, SecondaryMaterialConfig
);
185 virtual DATA_BASE_VALUE(const fearray
<sLong
>&, MaterialConfigChances
);
186 virtual DATA_BASE_VALUE(sLong
, MaterialConfigChanceSum
);
187 DATA_BASE_VALUE(int, OKVisualEffects
);
188 virtual DATA_BASE_VALUE_WITH_PARAMETER(col16
, MaterialColorB
, int);
189 virtual DATA_BASE_VALUE_WITH_PARAMETER(col16
, MaterialColorC
, int);
190 virtual DATA_BASE_VALUE_WITH_PARAMETER(col16
, MaterialColorD
, int);
191 virtual DATA_BASE_VALUE(cfestring
&, SitMessage
);
192 DATA_BASE_TRUTH(ShowMaterial
);
193 DATA_BASE_VALUE(int, Walkability
);
194 DATA_BASE_TRUTH(UseBorderTiles
);
195 DATA_BASE_VALUE(int, BorderTilePriority
);
196 virtual int GetAttachedGod() const;
197 virtual int GetTheoreticalWalkability() const { return DataBase
->Walkability
; }
198 void Draw(blitdata
&) const;
199 virtual truth
IsAnimated() const;
201 virtual void InstallDataBase(int);
202 virtual int GetGraphicsContainerIndex() const;
203 virtual const prototype
* FindProtoType() const { return &ProtoType
; }
204 virtual v2
GetBitmapPos(int) const;
205 v2
GetBorderBitmapPos(v2
, int) const;
206 virtual void ModifyAnimationFrames(int&) const;
207 static const prototype ProtoType
;
208 const database
* DataBase
;
211 struct olterraindatabase
: public lterraindatabase
213 typedef olterrainprototype prototype
;
214 void InitDefaults(const prototype
*, int);
215 truth
AllowRandomInstantiation() const;
216 const prototype
* ProtoType
;
219 festring RestMessage
;
224 fearray
<contentscript
<item
> > LeftOverItems
;
225 truth CreateDivineConfigurations
;
226 truth CanBeDestroyed
;
228 truth CreateLockConfigurations
;
229 truth IsAlwaysTransparent
;
230 truth ShowThingsUnder
;
232 truth CreateWindowConfigurations
;
233 truth IsSafeToCreateDoor
;
236 class olterrainprototype
239 friend class databasecreator
<olterrain
>;
241 olterrainprototype(const olterrainprototype
*, olterrainspawner
, cchar
*);
242 virtual ~olterrainprototype () {}
244 olterrain
* Spawn(int Config
= 0, int SpecialFlags
= 0) const { return Spawner(Config
, SpecialFlags
); }
245 olterrain
* SpawnAndLoad(inputfile
&) const;
246 cchar
* GetClassID() const { return ClassID
; }
247 int GetIndex() const { return Index
; }
248 const olterrainprototype
* GetBase() const { return Base
; }
249 int CreateSpecialConfigurations(olterraindatabase
**, int, int);
250 const olterraindatabase
* ChooseBaseForConfig(olterraindatabase
** TempConfig
, int, int) { return *TempConfig
; }
251 const olterraindatabase
*const* GetConfigData() const { return ConfigData
; }
252 int GetConfigSize() const { return ConfigSize
; }
255 const olterrainprototype
* Base
;
256 olterraindatabase
** ConfigData
;
257 olterraindatabase
** ConfigTable
[CONFIG_TABLE_SIZE
];
259 olterrainspawner Spawner
;
266 class olterrain
: public lterrain
, public oterrain
269 friend class databasecreator
<olterrain
>;
270 typedef olterrainprototype prototype
;
271 typedef olterraindatabase database
;
273 virtual ~olterrain () {}
275 virtual void Save(outputfile
&) const;
276 virtual void Load(inputfile
&);
277 virtual truth
Enter(truth
) const;
278 virtual void BeKicked(character
*, int, int);
279 virtual truth
IsDoor() const { return false; }
280 virtual truth
HasEatEffect() const { return false; }
281 virtual truth
HasDrinkEffect() const { return false; }
282 virtual truth
Eat(character
*) { return false; }
283 virtual truth
Drink(character
*) { return false; }
284 virtual void Lock() { }
285 virtual truth
IsLocked() const { return false; }
286 virtual void CreateBoobyTrap() { }
287 virtual void HasBeenHitByItem(character
*, item
*, int) { }
288 virtual void Break();
289 int GetHP() const { return HP
; }
290 void EditHP(int What
) { HP
+= What
; }
291 virtual void ReceiveDamage(character
*, int, int);
292 int GetType() const { return GetProtoType()->GetIndex(); }
293 const database
* GetDataBase() const { return DataBase
; }
294 void ShowRestMessage(character
*) const;
295 DATA_BASE_VALUE(const prototype
*, ProtoType
);
296 DATA_BASE_VALUE(int, Config
);
297 DATA_BASE_TRUTH(UsesLongArticle
);
298 DATA_BASE_VALUE(cfestring
&, Adjective
);
299 DATA_BASE_TRUTH(UsesLongAdjectiveArticle
);
300 DATA_BASE_VALUE(cfestring
&, NameSingular
);
301 DATA_BASE_VALUE(cfestring
&, NamePlural
);
302 DATA_BASE_VALUE(cfestring
&, PostFix
);
303 DATA_BASE_VALUE(int, ArticleMode
);
304 virtual DATA_BASE_VALUE(const fearray
<sLong
>&, MainMaterialConfig
);
305 DATA_BASE_VALUE(const fearray
<sLong
>&, SecondaryMaterialConfig
);
306 virtual DATA_BASE_VALUE(const fearray
<sLong
>&, MaterialConfigChances
);
307 virtual DATA_BASE_VALUE(sLong
, MaterialConfigChanceSum
);
308 DATA_BASE_VALUE(int, OKVisualEffects
);
309 virtual DATA_BASE_VALUE_WITH_PARAMETER(col16
, MaterialColorB
, int);
310 virtual DATA_BASE_VALUE_WITH_PARAMETER(col16
, MaterialColorC
, int);
311 virtual DATA_BASE_VALUE_WITH_PARAMETER(col16
, MaterialColorD
, int);
312 virtual DATA_BASE_VALUE(cfestring
&, SitMessage
);
313 DATA_BASE_TRUTH(ShowMaterial
);
314 DATA_BASE_VALUE(cfestring
&, DigMessage
);
315 truth
CanBeDestroyed() const;
316 DATA_BASE_VALUE(int, RestModifier
);
317 DATA_BASE_VALUE(cfestring
&, RestMessage
);
318 DATA_BASE_TRUTH(IsUpLink
);
319 DATA_BASE_VALUE(sLong
, StorageVolume
);
320 DATA_BASE_VALUE(int, HPModifier
);
321 DATA_BASE_TRUTH(IsSafeToCreateDoor
);
322 DATA_BASE_VALUE_WITH_PARAMETER(v2
, OpenBitmapPos
, int);
323 DATA_BASE_TRUTH(UseBorderTiles
);
324 DATA_BASE_VALUE(int, BorderTilePriority
);
325 virtual DATA_BASE_VALUE(int, Walkability
);
326 DATA_BASE_TRUTH(IsAlwaysTransparent
);
327 DATA_BASE_TRUTH(CreateWindowConfigurations
);
328 DATA_BASE_VALUE(v2
, WindowBitmapPos
);
329 DATA_BASE_VALUE(const fearray
<contentscript
<item
> >&, LeftOverItems
);
330 DATA_BASE_TRUTH(IsWall
);
331 virtual void SetAttachedArea(int) { }
332 virtual void SetAttachedEntry(int) { }
333 virtual int GetAttachedArea () const { return 0; }
334 virtual int GetAttachedEntry () const { return 0; }
335 virtual void SetText(cfestring
&) { }
336 virtual festring
GetText() const;
337 virtual void SetItemsInside(const fearray
<contentscript
<item
> >&, int) { }
338 int GetStrengthValue() const;
339 virtual void SignalVolumeAndWeightChange() { HP
= CalculateMaxHP(); }
340 int CalculateMaxHP();
341 virtual int GetAttachedGod() const;
342 void SetConfig(int, int = 0);
343 god
* GetMasterGod() const;
344 virtual truth
IsTransparent() const;
345 virtual void Draw(blitdata
&) const;
346 virtual int GetTheoreticalWalkability() const { return DataBase
->Walkability
; }
347 virtual void BeDestroyed() { Break(); }
348 virtual void ReceiveAcid(material
*, sLong
);
349 virtual void SignalRustLevelChange();
350 virtual truth
IsFountainWithWater() const { return false; }
351 truth
ShowThingsUnder() const;
352 truth
WillBeDestroyedBy(ccharacter
*) const;
353 virtual void PreProcessForBone() { }
354 virtual void PostProcessForBone() { }
355 virtual void FinalProcessForBone() { }
356 virtual void RestoreHP() { HP
= CalculateMaxHP(); }
357 virtual truth
IsAnimated() const;
358 virtual truth
VomitingIsDangerous(ccharacter
*) const { return false; }
359 virtual void AddSpecialCursors() { }
360 virtual truth
IsWard() const { return false; }
362 virtual v2
GetBitmapPos(int) const;
363 v2
GetBorderBitmapPos(v2
, int) const;
364 virtual void ModifyAnimationFrames(int&) const;
365 virtual void InstallDataBase(int);
366 virtual int GetGraphicsContainerIndex() const;
367 virtual const prototype
* FindProtoType() const { return &ProtoType
; }
368 static const prototype ProtoType
;
369 const database
* DataBase
;
373 #ifdef __FILE_OF_STATIC_LTERRAIN_PROTOTYPE_DEFINITIONS__
374 #define LTERRAIN_PROTO(name, base, protobase)\
375 template<> const protobase##prototype\
376 name##sysbase::ProtoType(&base::ProtoType,\
377 (protobase##spawner)(&name##sysbase::Spawn),\
380 #define LTERRAIN_PROTO(name, base, protobase)
383 #define LTERRAIN(name, base, protobase)\
385 typedef sysbase<name, base, protobase##prototype> name##sysbase;\
386 LTERRAIN_PROTO(name, base, protobase)\
387 class name : public name##sysbase
389 #define GLTERRAIN(name, base) LTERRAIN(name, base, glterrain)
390 #define OLTERRAIN(name, base) LTERRAIN(name, base, olterrain)