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
) {
16 Index
= protocontainer
<room
>::Add(this);
20 void room::Save (outputfile
&SaveFile
) const {
21 SaveFile
<< (uShort
)GetType();
22 SaveFile
<< Pos
<< Size
<< Index
<< DivineMaster
<< MasterID
;
26 void room::Load (inputfile
&SaveFile
) {
27 SaveFile
>> Pos
>> Size
>> Index
>> DivineMaster
>> MasterID
;
31 void room::FinalProcessForBone () {
33 boneidmap::iterator BI
= game::GetBoneCharacterIDMap().find(MasterID
);
35 if (BI
!= game::GetBoneCharacterIDMap().end()) MasterID
= BI
->second
; else MasterID
= 0;
40 room
*roomprototype::SpawnAndLoad (inputfile
&SaveFile
) const {
41 room
*Room
= Spawner();
48 void room::DestroyTerrain (character
*Who
) {
49 if (Who
&& MasterIsActive()) Who
->Hostility(GetMaster());
50 if (Who
&& Who
->IsPlayer() && DivineMaster
) game::GetGod(DivineMaster
)->AdjustRelation(GetGodRelationAdjustment());
54 /* returns true if player agrees to continue */
55 truth
room::CheckDestroyTerrain (character
*Infidel
) {
56 if (!MasterIsActive() || Infidel
== GetMaster() || GetMaster()->GetRelation(Infidel
) == HOSTILE
) return true;
57 ADD_MESSAGE("%s might not like this.", GetMaster()->CHAR_NAME(DEFINITE
));
58 if (game::TruthQuestion(CONST_S("Are you sure you want to do this? [y/N]"))) {
59 DestroyTerrain(Infidel
);
66 truth
room::MasterIsActive () const {
67 character
*Master
= GetMaster();
69 return Master
&& Master
->IsEnabled() && Master
->IsConscious();
73 truth
room::CheckKickSquare (ccharacter
*Kicker
, const lsquare
*LSquare
) const {
74 if (!AllowKick(Kicker
, LSquare
)) {
75 ADD_MESSAGE("That would be vandalism.");
76 if (!game::TruthQuestion(CONST_S("Do you still want to do this? [y/N]"))) return false;
82 character
*room::GetMaster () const {
83 feuLong Tick
= game::GetTick();
85 if (LastMasterSearchTick
== Tick
) return Master
;
86 LastMasterSearchTick
= Tick
;
87 return Master
= game::SearchCharacter(MasterID
);
91 truth
room::WardIsActive () const {
92 olterrain
*PossibleWard
= GetWard();
94 if (!PossibleWard
) return false;
95 return PossibleWard
->IsWard(); //if it is broken, then it will return zero hopefully
99 olterrain
*room::GetWard () const {
100 feuLong Tick
= game::GetTick();
102 if (LastWardSearchTick
== Tick
) {
105 LastWardSearchTick
= Tick
;
107 std::vector
<olterrain
*> Found
;
108 olterrain
*OLTerrain
;
109 v2 RoomPos
= /*Room->*/GetPos();
110 v2 RoomSize
= /*Room->*/GetSize();
112 for (int x
= RoomPos
.X
; x
< (RoomPos
.X
+ RoomSize
.X
); ++x
) {
113 for (int y
= RoomPos
.Y
; y
< ( RoomPos
.Y
+ RoomSize
.Y
); ++y
) {
114 OLTerrain
= game::GetCurrentLevel()->GetLSquare(x
,y
)->GetOLTerrain();
115 if (OLTerrain
&& OLTerrain
->IsWard()) return OLTerrain
;
123 truth
room::IsOKToTeleportInto () const {
124 return !WardIsActive();
128 truth
room::IsOKToDestroyWalls (ccharacter
*Infidel
) const {
129 return !MasterIsActive() || Infidel
== GetMaster() || GetMaster()->GetRelation(Infidel
) == HOSTILE
;