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
13 /* Compiled through roomset.cpp */
15 roomprototype::roomprototype(roomspawner Spawner
, cchar
* ClassID
) : Spawner(Spawner
), ClassID(ClassID
) { Index
= protocontainer
<room
>::Add(this); }
17 void room::Save(outputfile
& SaveFile
) const
19 SaveFile
<< (uShort
)GetType();
20 SaveFile
<< Pos
<< Size
<< Index
<< DivineMaster
<< MasterID
;
23 void room::Load(inputfile
& SaveFile
)
25 SaveFile
>> Pos
>> Size
>> Index
>> DivineMaster
>> MasterID
;
28 room
* roomprototype::SpawnAndLoad(inputfile
& SaveFile
) const
30 room
* Room
= Spawner();
35 void room::DestroyTerrain(character
* Who
)
37 if(Who
&& MasterIsActive())
38 Who
->Hostility(GetMaster());
40 if(Who
&& Who
->IsPlayer() && DivineMaster
)
41 game::GetGod(DivineMaster
)->AdjustRelation(GetGodRelationAdjustment());
44 /* returns true if player agrees to continue */
46 truth
room::CheckDestroyTerrain(character
* Infidel
)
48 if(!MasterIsActive() || Infidel
== GetMaster() || GetMaster()->GetRelation(Infidel
) == HOSTILE
)
51 ADD_MESSAGE("%s might not like this.", GetMaster()->CHAR_NAME(DEFINITE
));
53 if(game::TruthQuestion(CONST_S("Are you sure you want to do this? [y/N]")))
55 DestroyTerrain(Infidel
);
62 truth
room::MasterIsActive() const
64 character
* Master
= GetMaster();
65 return Master
&& Master
->IsEnabled() && Master
->IsConscious();
68 truth
room::CheckKickSquare(ccharacter
* Kicker
, const lsquare
* LSquare
) const
70 if(!AllowKick(Kicker
, LSquare
))
72 ADD_MESSAGE("That would be vandalism.");
74 if(!game::TruthQuestion(CONST_S("Do you still want to do this? [y/N]")))
80 character
* room::GetMaster() const
82 uLong Tick
= game::GetTick();
84 if(LastMasterSearchTick
== Tick
)
88 LastMasterSearchTick
= Tick
;
89 return Master
= game::SearchCharacter(MasterID
);
94 truth
room::WardIsActive () const {
95 olterrain
* PossibleWard
= GetWard();
96 if (!PossibleWard
) return false;
97 return PossibleWard
->IsWard(); //if it is broken, then it will return zero hopefully
101 olterrain
*room::GetWard() const {
102 uLong Tick
= game::GetTick();
104 if (LastWardSearchTick
== Tick
) {
107 LastWardSearchTick
= Tick
;
109 std::vector
<olterrain
*> Found
;
110 olterrain
*OLTerrain
;
111 v2 RoomPos
= /*Room->*/GetPos();
112 v2 RoomSize
= /*Room->*/GetSize();
114 for(int x
= RoomPos
.X
; x
< (RoomPos
.X
+ RoomSize
.X
); ++x
) {
115 for(int y
= RoomPos
.Y
; y
< ( RoomPos
.Y
+ RoomSize
.Y
); ++y
) {
116 OLTerrain
= game::GetCurrentLevel()->GetLSquare(x
,y
)->GetOLTerrain();
117 if(OLTerrain
&& OLTerrain
->IsWard()) return OLTerrain
;
125 truth
room::IsOKToTeleportInto() const {
126 return !WardIsActive();
130 truth
room::IsOKToDestroyWalls(ccharacter
* Infidel
) const
132 return !MasterIsActive() || Infidel
== GetMaster() || GetMaster()->GetRelation(Infidel
) == HOSTILE
;
135 void room::FinalProcessForBone()
139 boneidmap::iterator BI
= game::GetBoneCharacterIDMap().find(MasterID
);
141 if(BI
!= game::GetBoneCharacterIDMap().end())
142 MasterID
= BI
->second
;