2 ITEM(scrollofhardenmaterial
, scroll
)
5 virtual void FinishReading(character
*);
13 void scrollofhardenmaterial::FinishReading(character
* Reader
)
19 if(!Reader
->SelectFromPossessions(Item
, CONST_S("What item do you wish to harden?"), NO_MULTI_SELECT
|SELECT_PAIR
, &item::CanBeHardened
))
21 ADD_MESSAGE("You notice you haven't got anything to harden.");
26 if(game::TruthQuestion(CONST_S("Really cancel read? [y/N]"))) return;
30 if(!Item
[0]->IsMaterialChangeable())
32 ADD_MESSAGE("You cast the spell, but the magic is not powerful enough to affect %s!", Item
[0]->CHAR_NAME(DEFINITE
|(Item
.size() == 1 ? 0 : PLURAL
)));
36 if(Item
[0]->HandleInPairs() && Item
.size() == 1)
38 ADD_MESSAGE("Only one %s will be altered.", Item
[0]->CHAR_NAME(UNARTICLED
));
40 if(!game::TruthQuestion(CONST_S("Still continue? [y/N]")))
44 msgsystem::EnterBigMessageMode();
47 ADD_MESSAGE("Suddenly your %s is consumed in roaring magical flames.", Item
[0]->CHAR_NAME(UNARTICLED
));
49 ADD_MESSAGE("Suddenly your %s are consumed in roaring magical flames.", Item
[0]->CHAR_NAME(PLURAL
));
51 int Config
= Item
[0]->GetMainMaterial()->GetHardenedMaterial(Item
[0]);
55 /* Should not be possible */
58 ADD_MESSAGE("But it is already as hard as it can get.");
60 ADD_MESSAGE("But they are already as hard as they can get.");
62 msgsystem::LeaveBigMessageMode();
66 material
* TempMaterial
= MAKE_MATERIAL(Config
);
67 int Intelligence
= Reader
->GetAttribute(INTELLIGENCE
);
69 if(TempMaterial
->GetIntelligenceRequirement() > Intelligence
&& !game::WizardModeIsActive())
72 ADD_MESSAGE("But your mind is not yet strong enough to harden %s.", Item
.size() == 1 ? "it" : "them");
73 msgsystem::LeaveBigMessageMode();
77 for(int NewConfig
= TempMaterial
->GetHardenedMaterial(Item
[0]), c
= 1;
79 NewConfig
= TempMaterial
->GetHardenedMaterial(Item
[0]), ++c
)
81 material
* NewMaterial
= MAKE_MATERIAL(NewConfig
);
83 if(NewMaterial
->GetIntelligenceRequirement()
84 <= Intelligence
- c
* 5)
87 TempMaterial
= NewMaterial
;
93 material
* MainMaterial
= Item
[0]->GetMainMaterial();
94 material
* SecondaryMaterial
= Item
[0]->GetSecondaryMaterial();
98 ADD_MESSAGE("As the fire dies out it looks much harder.");
100 if(SecondaryMaterial
&& SecondaryMaterial
->IsSameAs(MainMaterial
))
101 Item
[0]->ChangeSecondaryMaterial(TempMaterial
->SpawnMore());
103 Item
[0]->ChangeMainMaterial(TempMaterial
);
107 ADD_MESSAGE("As the fire dies out they look much harder.");
109 if(SecondaryMaterial
&& SecondaryMaterial
->IsSameAs(MainMaterial
))
110 for(uInt c
= 0; c
< Item
.size(); ++c
)
111 Item
[c
]->ChangeSecondaryMaterial(TempMaterial
->SpawnMore());
113 Item
[0]->ChangeMainMaterial(TempMaterial
);
115 for(uInt c
= 1; c
< Item
.size(); ++c
)
116 Item
[c
]->ChangeMainMaterial(TempMaterial
->SpawnMore());
119 msgsystem::LeaveBigMessageMode();
125 Reader
->EditExperience(INTELLIGENCE
, 300, 1 << 12);