2 ITEM(backpack
, materialcontainer
)
5 virtual truth
Apply(character
*);
6 virtual truth
IsAppliable(ccharacter
*) const { return true; }
7 virtual truth
ReceiveDamage(character
*, int, int, int);
8 virtual truth
IsExplosive() const;
9 virtual sLong
GetTotalExplosivePower() const;
10 virtual void SpillFluid(character
*, liquid
*, int = 0);
12 virtual void AddPostFix(festring
& String
, int) const { AddContainerPostFix(String
); }
20 truth
backpack::IsExplosive() const { return GetSecondaryMaterial() && GetSecondaryMaterial()->IsExplosive(); }
24 sLong
backpack::GetTotalExplosivePower() const { return GetSecondaryMaterial() ? GetSecondaryMaterial()->GetTotalExplosivePower() : 0; }
28 truth
backpack::Apply(character
* Terrorist
)
32 if(Terrorist
->IsPlayer())
33 ADD_MESSAGE("You light your %s. It explodes!", CHAR_NAME(UNARTICLED
));
34 else if(Terrorist
->CanBeSeenByPlayer())
35 ADD_MESSAGE("%s lights %s. It explodes!", Terrorist
->CHAR_NAME(DEFINITE
), CHAR_NAME(INDEFINITE
));
36 else if(GetSquareUnder()->CanBeSeenByPlayer(true))
37 ADD_MESSAGE("Something explodes!");
41 Terrorist
->DexterityAction(5);
42 Terrorist
->GetLevel()->Explosion(Terrorist
, CONST_S("kamikazed @k"), Terrorist
->GetLSquareUnder()->GetPos(), GetSecondaryMaterial()->GetTotalExplosivePower());
45 else if(Terrorist
->IsPlayer())
46 ADD_MESSAGE("You are not able to explode yourself with this crummy %s!", CHAR_NAME(UNARTICLED
));
53 truth
backpack::ReceiveDamage(character
* Damager
, int Damage
, int Type
, int)
55 if(Type
& (FIRE
|ENERGY
) && Damage
&& IsExplosive() && (Damage
> 25 || !(RAND() % (50 / Damage
))))
57 festring DeathMsg
= CONST_S("killed by an explosion of ");
58 AddName(DeathMsg
, INDEFINITE
);
61 DeathMsg
<< " caused @bk";
63 if(GetSquareUnder()->CanBeSeenByPlayer(true))
64 ADD_MESSAGE("%s explodes!", GetExtendedDescription().CStr());
66 lsquare
* Square
= GetLSquareUnder();
69 Square
->GetLevel()->Explosion(Damager
, DeathMsg
, Square
->GetPos(), GetSecondaryMaterial()->GetTotalExplosivePower());
78 void backpack::SpillFluid(character
* Spiller
, liquid
* Liquid
, int SquareIndex
)
80 if(!Liquid
->IsExplosive())
82 GetSecondaryMaterial()->AddWetness(Liquid
->GetVolume() * 25);
84 if(CanBeSeenByPlayer())
85 ADD_MESSAGE("%s gets wet.", CHAR_NAME(DEFINITE
));
88 item::SpillFluid(Spiller
, Liquid
, SquareIndex
);