fix for https://github.com/Attnam/ivan/issues/119
[k8-i-v-a-n.git] / src / game / items / item_ullrbone.cpp
blob8f1960236b6983f82033b6b77d1676573a45e3bc
1 #ifdef HEADER_PHASE
2 ITEM(ullrbone, item)
4 public:
5 ullrbone() : TimesUsed(0), Charges(12) {}
6 virtual truth Zap (character *, v2, int);
7 virtual void ChargeFully (character *) { TimesUsed = 0; }
8 virtual truth IsZappable (const character *) const { return true; }
9 virtual truth IsChargeable (const character*) const { return true; }
10 virtual truth HitEffect (character *, character *, v2, int, int, truth);
11 virtual void Be () {}
12 virtual void AddInventoryEntry (const character *, festring &, int, truth) const;
13 virtual truth ReceiveDamage (character *, int, int, int);
14 virtual truth AllowAlphaEverywhere () const { return true; }
15 protected:
16 int TimesUsed;
17 int Charges;
18 virtual int GetClassAnimationFrames () const { return 32; }
19 virtual col16 GetOutlineColor (int) const;
20 virtual alpha GetOutlineAlpha (int) const;
24 #else
28 col16 ullrbone::GetOutlineColor (int) const { return MakeRGB16(210, 210, 210); }
32 truth ullrbone::HitEffect (character *Enemy, character *Hitter, v2 HitPos, int BodyPartIndex, int Direction, truth BlockedByArmour) {
33 truth BaseSuccess = item::HitEffect(Enemy, Hitter, HitPos, BodyPartIndex, Direction, BlockedByArmour);
34 if (Enemy->IsEnabled() && (RAND() & 1)) {
35 if (Enemy->IsPlayer() || Hitter->IsPlayer() || Enemy->CanBeSeenByPlayer() || Hitter->CanBeSeenByPlayer())
36 ADD_MESSAGE("A burst of %s bone of Ullr's unholy energy fries %s.", Hitter->CHAR_POSSESSIVE_PRONOUN, Enemy->CHAR_DESCRIPTION(DEFINITE));
37 return Enemy->ReceiveBodyPartDamage(Hitter, 3 + (RAND() & 3), ENERGY, BodyPartIndex, Direction) || BaseSuccess;
39 return BaseSuccess;
44 truth ullrbone::Zap (character *Zapper, v2, int Direction) {
45 if (Charges > TimesUsed) {
46 ADD_MESSAGE("BANG! You zap %s!", CHAR_NAME(DEFINITE));
47 Zapper->EditExperience(PERCEPTION, 150, 1 << 10);
48 beamdata Beam(
49 Zapper,
50 CONST_S("killed by ") + GetName(INDEFINITE),
51 Zapper->GetPos(),
52 YELLOW,
53 BEAM_LIGHTNING,
54 Direction,
55 50,
58 (GetLevel()->*level::GetBeam(PARTICLE_BEAM))(Beam);
59 ++TimesUsed;
60 } else {
61 ADD_MESSAGE("Click!");
63 return true;
68 void ullrbone::AddInventoryEntry (const character *Viewer, festring& Entry, int, truth ShowSpecialInfo) const {
69 // never piled
70 AddName(Entry, INDEFINITE);
71 if (ShowSpecialInfo) {
72 Entry << " [" << GetWeight() << "g, DAM " << GetBaseMinDamage() << '-' << GetBaseMaxDamage();
73 Entry << ", " << GetBaseToHitValueDescription();
74 if (!IsBroken()) Entry << ", " << GetStrengthValueDescription();
75 int CWeaponSkillLevel = Viewer->GetCWeaponSkillLevel(this);
76 int SWeaponSkillLevel = Viewer->GetSWeaponSkillLevel(this);
77 if (CWeaponSkillLevel || SWeaponSkillLevel) Entry << ", skill " << CWeaponSkillLevel << '/' << SWeaponSkillLevel;
78 if (TimesUsed == 1) Entry << ", used 1 time";
79 else if (TimesUsed) Entry << ", used " << TimesUsed << " times";
80 Entry << ']';
86 truth ullrbone::ReceiveDamage (character *Damager, int Damage, int Type, int) {
87 if (TimesUsed != 12 && Type & (PHYSICAL_DAMAGE|FIRE|ENERGY) && Damage && (Damage > 50 || !(RAND() % (100 / Damage)))) {
88 festring DeathMsg = CONST_S("killed by an explosion of ");
89 AddName(DeathMsg, INDEFINITE);
90 if (Damager) DeathMsg << " caused @bk";
91 if (GetSquareUnder()->CanBeSeenByPlayer(true)) ADD_MESSAGE("%s explodes!", GetExtendedDescription().CStr());
92 lsquare *Square = GetLSquareUnder();
93 RemoveFromSlot();
94 SendToHell();
95 Square->GetLevel()->Explosion(Damager, DeathMsg, Square->GetPos(), (6-TimesUsed)*50);
96 return true;
98 return false;
103 alpha ullrbone::GetOutlineAlpha (int Frame) const {
104 Frame &= 31;
105 return 50+(Frame*(31-Frame)>>1);
107 #endif