1 /*
2  *
3  *  Iter Vehemens ad Necem (IVAN)
4  *  Copyright (C) Timo Kiviluoto
5  *  Released under the GNU General
6  *  Public License
7  *
8  *  See LICENSING which should be included
9  *  along with this file for more details
10  *
11  */
12 
13 #ifndef __GOD_H__
14 #define __GOD_H__
15 
16 #include "ivandef.h"
17 
18 class outputfile;
19 class inputfile;
20 class god;
21 class liquid;
22 class team;
23 struct materialdatabase;
24 
25 typedef god* (*godspawner)();
26 
27 class godprototype
28 {
29  public:
30   godprototype(godspawner, cchar*);
Spawn()31   god* Spawn() const { return Spawner(); }
32   god* SpawnAndLoad(inputfile&) const;
GetClassID()33   cchar* GetClassID() const { return ClassID; }
GetIndex()34   int GetIndex() const { return Index; }
35  private:
36   int Index;
37   godspawner Spawner;
38   cchar* ClassID;
39 };
40 
41 class god
42 {
43  public:
44   typedef godprototype prototype;
45   god();
46   virtual ~god() = default;
47   virtual void Pray();
48   virtual cchar* GetName() const = 0;
49   virtual cchar* GetDescription() const = 0;
50   cchar* GetLastKnownRelation() const;
51   cchar* GetPersonalPronoun() const;
52   cchar* GetObjectPronoun() const;
53   virtual int GetAlignment() const = 0;
54   festring GetCompleteDescription() const;
55   void ApplyDivineTick();
56   void AdjustRelation(god*, int, truth);
57   void AdjustRelation(int);
58   void AdjustTimer(long);
59   void Save(outputfile&) const;
60   void Load(inputfile&);
SetRelation(int Value)61   void SetRelation(int Value) { Relation = Value; }
SetTimer(long Value)62   void SetTimer(long Value) { Timer = Value; }
63   truth ReceiveOffer(item*);
64   virtual int GetBasicAlignment() const;
GetRelation()65   int GetRelation() const { return Relation; }
66   cfestring PrintRelation() const;
SetIsKnown(truth What)67   void SetIsKnown(truth What) { Known = What; }
IsKnown()68   truth IsKnown() const { return Known; }
PlayerKickedAltar()69   void PlayerKickedAltar() { AdjustRelation(-100); }
PlayerKickedFriendsAltar()70   void PlayerKickedFriendsAltar() { AdjustRelation(-50); }
71   virtual truth PlayerVomitedOnAltar(liquid*);
72   character* CreateAngel(team*, int = 0);
73   virtual col16 GetColor() const = 0;
74   virtual col16 GetEliteColor() const = 0;
75   virtual const prototype* GetProtoType() const = 0;
GetType()76   int GetType() const { return GetProtoType()->GetIndex(); }
ForceGiveBodyPart()77   virtual truth ForceGiveBodyPart() const { return false; }
HealRegeneratingBodyParts()78   virtual truth HealRegeneratingBodyParts() const { return false; }
79   virtual truth LikesMaterial(const materialdatabase*, ccharacter*) const;
80   truth TryToAttachBodyPart(character*);
81   truth TryToHardenBodyPart(character*);
MutatesBodyParts()82   virtual truth MutatesBodyParts() const { return false; }
83   virtual int GetSex() const = 0;
84   void SignalRandomAltarGeneration(const std::vector<v2>&);
LikesVomit()85   virtual truth LikesVomit() const { return false; }
86  protected:
87   virtual void PrayGoodEffect() = 0;
88   virtual void PrayBadEffect() = 0;
89   int Relation, LastPray;
90   festring fsLastKnownRelation;
91   long Timer;
92   truth Known;
93 };
94 
95 #ifdef __FILE_OF_STATIC_GOD_PROTOTYPE_DEFINITIONS__
96 #define GOD_PROTO(name)\
97 template<> const godprototype\
98   name##sysbase::ProtoType(reinterpret_cast<godspawner>(&name##sysbase::Spawn), #name);
99 #else
100 #define GOD_PROTO(name)
101 #endif
102 
103 #define GOD(name, base)\
104 class name;\
105 typedef simplesysbase<name, base, godprototype> name##sysbase;\
106 GOD_PROTO(name)\
107 class name : public name##sysbase
108 
109 #endif
110