CLIVAN: copied muntuo (not all critters yet)
[k8-i-v-a-n.git] / src / game / room.h
blobc97770014ce6ffc0fbbdda2a9e5c9a27f48af5c6
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 __ROOM_H__
14 #define __ROOM_H__
16 #include "v2.h"
18 class room;
19 class item;
20 class olterrain;
21 class lsquare;
22 class festring;
23 class outputfile;
24 class inputfile;
25 class character;
27 typedef room* (*roomspawner)();
29 class roomprototype
31 public:
32 roomprototype(roomspawner, cchar*);
33 room* Spawn() const { return Spawner(); }
34 room* SpawnAndLoad(inputfile&) const;
35 cchar* GetClassID() const { return ClassID; }
36 int GetIndex() const { return Index; }
37 private:
38 int Index;
39 roomspawner Spawner;
40 cchar* ClassID;
43 class room
45 public:
46 typedef roomprototype prototype;
47 room() : LastMasterSearchTick(0), MasterID(0), LastWardSearchTick(0) { }
48 virtual ~room() { }
49 virtual void Save(outputfile&) const;
50 virtual void Load(inputfile&);
51 virtual void Enter(character*) { }
52 v2 GetPos() const { return Pos; }
53 void SetPos(v2 What) { Pos = What; }
54 v2 GetSize() const { return Size; }
55 void SetSize(v2 What) { Size = What; }
56 void SetIndex(int What) { Index = What; }
57 int GetIndex() const { return Index; }
58 character* GetMaster() const;
59 void SetMasterID(uLong What) { MasterID = What; }
60 virtual truth PickupItem(character*, item*, int) { return true; }
61 virtual truth DropItem(character*, item*, int) { return true; }
62 int GetDivineMaster() const { return DivineMaster; }
63 void SetDivineMaster(int What) { DivineMaster = What; }
64 virtual void KickSquare(character*, lsquare*) { }
65 virtual truth ConsumeItem(character*, item*, int) { return true; }
66 virtual truth AllowDropGifts() const { return true; }
67 virtual truth Drink(character*) const { return true; }
68 virtual truth HasDrinkHandler() const { return false; }
69 virtual truth Dip(character*) const { return true; }
70 virtual truth HasDipHandler() const { return false; }
71 virtual void TeleportSquare(character*, lsquare*) { }
72 virtual const prototype* GetProtoType() const = 0;
73 int GetType() const { return GetProtoType()->GetIndex(); }
74 virtual void DestroyTerrain(character*);
75 virtual truth AllowSpoil(citem*) const { return true; }
76 virtual truth CheckDestroyTerrain(character*);
77 virtual int GetGodRelationAdjustment() const { return -50; }
78 virtual truth AllowKick(ccharacter*, const lsquare*) const { return true; }
79 truth MasterIsActive() const;
80 truth CheckKickSquare(ccharacter*, const lsquare*) const;
81 virtual void HostileAction(character*) const { }
82 virtual truth AllowAltarPolymorph() const { return true; }
83 virtual truth AllowFoodSearch() const { return true; }
84 virtual void ReceiveVomit(character*) { }
85 virtual truth IsOKToDestroyWalls(ccharacter*) const;
86 virtual void AddItemEffect(item*) { };
87 void FinalProcessForBone();
88 void SetFlags(uLong What) { Flags = What; }
89 truth DontGenerateMonsters() const { return Flags & NO_MONSTER_GENERATION; }
90 olterrain* GetWard() const;
91 truth WardIsActive() const;
92 virtual truth IsOKToTeleportInto() const;
93 protected:
94 mutable character* Master;
95 mutable uLong LastMasterSearchTick;
96 v2 Pos;
97 v2 Size;
98 uLong MasterID;
99 int Index;
100 int DivineMaster;
101 uLong Flags;
102 mutable olterrain* Ward;
103 mutable ulong LastWardSearchTick;
106 #ifdef __FILE_OF_STATIC_ROOM_PROTOTYPE_DEFINITIONS__
107 #define ROOM_PROTO(name)\
108 template<> const roomprototype\
109 name##sysbase::ProtoType((roomspawner)(&name##sysbase::Spawn), #name);
110 #else
111 #define ROOM_PROTO(name)
112 #endif
114 #define ROOM(name, base)\
115 class name;\
116 typedef simplesysbase<name, base, roomprototype> name##sysbase;\
117 ROOM_PROTO(name)\
118 class name : public name##sysbase
120 #endif