cosmetix
[k8-i-v-a-n.git] / src / game / items / scroll_scrollofhardenmaterial.cpp
blobe64d65800845d1e6304d5929b5a0c57ef6bed89c
1 #ifdef HEADER_PHASE
2 ITEM(scrollofhardenmaterial, scroll)
4 public:
5 virtual void FinishReading(character*);
6 };
9 #else
13 void scrollofhardenmaterial::FinishReading(character* Reader)
15 for(;;)
17 itemvector Item;
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.");
22 return;
25 if (Item.empty()) {
26 if(game::TruthQuestion(CONST_S("Really cancel read? [y/N]"))) return;
27 continue;
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)));
33 break;
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]")))
41 continue;
44 msgsystem::EnterBigMessageMode();
46 if(Item.size() == 1)
47 ADD_MESSAGE("Suddenly your %s is consumed in roaring magical flames.", Item[0]->CHAR_NAME(UNARTICLED));
48 else
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]);
53 if(!Config)
55 /* Should not be possible */
57 if(Item.size() == 1)
58 ADD_MESSAGE("But it is already as hard as it can get.");
59 else
60 ADD_MESSAGE("But they are already as hard as they can get.");
62 msgsystem::LeaveBigMessageMode();
63 break;
66 material* TempMaterial = MAKE_MATERIAL(Config);
67 int Intelligence = Reader->GetAttribute(INTELLIGENCE);
69 if(TempMaterial->GetIntelligenceRequirement() > Intelligence && !game::WizardModeIsActive())
71 delete TempMaterial;
72 ADD_MESSAGE("But your mind is not yet strong enough to harden %s.", Item.size() == 1 ? "it" : "them");
73 msgsystem::LeaveBigMessageMode();
74 continue;
77 for(int NewConfig = TempMaterial->GetHardenedMaterial(Item[0]), c = 1;
78 NewConfig;
79 NewConfig = TempMaterial->GetHardenedMaterial(Item[0]), ++c)
81 material* NewMaterial = MAKE_MATERIAL(NewConfig);
83 if(NewMaterial->GetIntelligenceRequirement()
84 <= Intelligence - c * 5)
86 delete TempMaterial;
87 TempMaterial = NewMaterial;
89 else
90 break;
93 material* MainMaterial = Item[0]->GetMainMaterial();
94 material* SecondaryMaterial = Item[0]->GetSecondaryMaterial();
96 if(Item.size() == 1)
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);
105 else
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();
120 break;
123 RemoveFromSlot();
124 SendToHell();
125 Reader->EditExperience(INTELLIGENCE, 300, 1 << 12);
127 #endif