6 oillamp(const oillamp
&);
7 virtual void Save(outputfile
&) const;
8 virtual void Load(inputfile
&);
9 virtual truth
GetInhabitedByGenie() const { return InhabitedByGenie
; }
10 virtual void SetInhabitedByGenie(truth What
) { InhabitedByGenie
= What
; }
11 virtual truth
Apply(character
*);
12 virtual truth
IsAppliable(ccharacter
*) const { return true; }
14 truth InhabitedByGenie
;
22 truth
oillamp::Apply(character
* Applier
)
24 if(Applier
->IsPlayer())
25 ADD_MESSAGE("You rub %s.", CHAR_NAME(DEFINITE
));
27 if(GetInhabitedByGenie())
29 genie
* Genie
= genie::Spawn();
31 truth FoundPlace
= false;
34 Genie
->SetTeam(Applier
->GetTeam());
36 Genie
->SetTeam(game::GetTeam(MONSTER_TEAM
));
38 /* First try to create a genie nearby (10 tries - if all of them fail then stop trying) */
40 for(int c
= 0; c
< 10 && !FoundPlace
; ++c
)
42 TryToCreate
= Applier
->GetPos() + game::GetMoveVector(RAND() % DIRECTION_COMMAND_KEYS
);
44 if(GetArea()->IsValidPos(TryToCreate
) && Genie
->CanMoveOn(GetNearLSquare(TryToCreate
)) && Genie
->IsFreeForMe(GetNearLSquare(TryToCreate
)))
46 Genie
->PutTo(TryToCreate
);
48 SetInhabitedByGenie(false);
55 Genie
->GetLSquareUnder()->AddSmoke(gas::Spawn(SMOKE
, 1000));
58 ADD_MESSAGE("You see a puff of smoke, and %s appears. \"For centuries I have been imprisoned in this lamp. But at last you have freed me! As a reward, I will kill you.\"", Genie
->CHAR_NAME(INDEFINITE
));
61 if(Applier
->IsPlayer())
63 ADD_MESSAGE("You see a puff of smoke, and %s appears. \"For centuries I have been imprisoned in this lamp. But at last you have freed me! I am deeply grateful. You deserve a generous reward. I may serve you for 1001 nights or grant you a wish. It's your choice.\"", Genie
->CHAR_NAME(INDEFINITE
));
65 if(game::TruthQuestion(CONST_S("Do you want to wish? [Y/n]"), YES
))
67 ADD_MESSAGE("You may wish for an item.");
69 "%s appears from nothing and the genie flies happily away!",
70 "Two %s appear from nothing and the genie flies happily away!");
74 Applier
->EditAP(-1000);
80 meleeweapon
* Weapon
= meleeweapon::Spawn(TWO_HANDED_SCIMITAR
, NO_MATERIALS
);
81 Weapon
->InitMaterials(MAKE_MATERIAL(ARCANITE
), MAKE_MATERIAL(ARCANITE
), true);
82 Genie
->SetRightWielded(Weapon
);
83 ADD_MESSAGE("%s wishes for a two-handed scimitar. Suddenly %s appears from nothing and %s wields it.", Genie
->CHAR_NAME(DEFINITE
), Genie
->GetMainWielded()->CHAR_NAME(INDEFINITE
), Genie
->CHAR_NAME(DEFINITE
));
87 if(Applier
->IsPlayer())
88 ADD_MESSAGE("You feel that it is warmer.");
94 if(Applier
->IsPlayer())
95 ADD_MESSAGE("Nothing happens.");
97 Applier
->EditAP(-1000);
103 void oillamp::Save(outputfile
& SaveFile
) const
105 item::Save(SaveFile
);
106 SaveFile
<< InhabitedByGenie
;
111 void oillamp::Load(inputfile
& SaveFile
)
113 item::Load(SaveFile
);
114 SaveFile
>> InhabitedByGenie
;
121 if(!game::IsLoading())
122 InhabitedByGenie
= RAND_2
;
127 oillamp::oillamp(const oillamp
& Lamp
) : mybase(Lamp
), InhabitedByGenie(false)