item classes moved to separate files
[k8-i-v-a-n.git] / src / game / items / item_charmlyre.cpp
blobbd260bb132152dbad132b6d00ef9a004196eba09
1 #ifdef HEADER_PHASE
2 ITEM(charmlyre, item)
4 public:
5 charmlyre();
6 virtual truth Apply(character*);
7 virtual truth IsAppliable(ccharacter*) const { return true; }
8 virtual void Load(inputfile&);
9 virtual void Save(outputfile&) const;
10 virtual void FinalProcessForBone();
11 protected:
12 virtual col16 GetMaterialColorB(int) const;
13 feuLong LastUsed;
17 #else
21 col16 charmlyre::GetMaterialColorB(int) const { return MakeRGB16(150, 130, 110); }
25 truth charmlyre::Apply (character *Charmer) {
26 if (LastUsed && game::GetTick()-LastUsed < 10000) {
27 if (Charmer->IsPlayer()) {
28 if (Charmer->CanHear()) ADD_MESSAGE("You produce a highly alluring sound.");
29 else ADD_MESSAGE("You try to play something with the %s, but it is hard when you can't hear.", CHAR_NAME(DEFINITE));
30 } else if (Charmer->CanBeSeenByPlayer()) {
31 if (PLAYER->CanHear()) ADD_MESSAGE("%s plays %s and produces a highly alluring sound.", Charmer->CHAR_NAME(DEFINITE), CHAR_NAME(DEFINITE));
32 else ADD_MESSAGE("%s plays %s.", Charmer->CHAR_NAME(DEFINITE), CHAR_NAME(DEFINITE));
33 } else if (PLAYER->CanHear()) ADD_MESSAGE("You hear a lyre playing.");
34 } else {
35 LastUsed = game::GetTick();
36 if (Charmer->IsPlayer()) {
37 if (Charmer->CanHear()) ADD_MESSAGE("You produce a mesmerizing sound.");
38 else ADD_MESSAGE("You try to play something with the %s, but it is hard when you can't hear.", CHAR_NAME(DEFINITE));
39 } else if (Charmer->CanBeSeenByPlayer()) {
40 if (PLAYER->CanHear()) ADD_MESSAGE("%s plays %s and produces a mesmerizing sound.", Charmer->CHAR_NAME(DEFINITE), CHAR_NAME(DEFINITE));
41 else ADD_MESSAGE("%s plays %s.", Charmer->CHAR_NAME(DEFINITE), CHAR_NAME(DEFINITE));
43 for (int d = 0; d < Charmer->GetNeighbourSquares(); ++d) {
44 square *Square = Charmer->GetNeighbourSquare(d);
45 if (Square) {
46 character *Char = Square->GetCharacter();
47 if (Char) {
48 if (Char->CanHear()) {
49 if (Char->CanTameWithLyre(Charmer)) {
50 if (Char->GetTeam() == Charmer->GetTeam()) ADD_MESSAGE("%s seems to be very happy.", Char->CHAR_NAME(DEFINITE));
51 else if (Char->GetRelation(Charmer) == HOSTILE) ADD_MESSAGE("%s stops fighting.", Char->CHAR_NAME(DEFINITE));
52 else ADD_MESSAGE("%s seems to be very friendly towards you.", Char->CHAR_NAME(DEFINITE));
53 Char->ChangeTeam(Charmer->GetTeam());
54 } else {
55 ADD_MESSAGE("%s resists its charming call.", Char->CHAR_NAME(DEFINITE));
57 } else {
58 ADD_MESSAGE("%s seems not affected.", Char->CHAR_NAME(DEFINITE));
64 Charmer->EditAP(-1000);
65 game::CallForAttention(GetPos(), 100);
66 return true;
71 void charmlyre::Save(outputfile& SaveFile) const
73 item::Save(SaveFile);
74 SaveFile << LastUsed;
79 void charmlyre::Load(inputfile& SaveFile)
81 item::Load(SaveFile);
82 SaveFile >> LastUsed;
87 charmlyre::charmlyre()
89 LastUsed = 0;
94 void charmlyre::FinalProcessForBone()
96 item::FinalProcessForBone();
97 LastUsed = 0;
99 #endif