//************************************************************************** //** //** ## ## ## ## ## #### #### ### ### //** ## ## ## ## ## ## ## ## ## ## #### #### //** ## ## ## ## ## ## ## ## ## ## ## ## ## ## //** ## ## ######## ## ## ## ## ## ## ## ### ## //** ### ## ## ### ## ## ## ## ## ## //** # ## ## # #### #### ## ## //** //** $Id: BasicArmor.vc 2625 2007-08-11 15:22:38Z dj_jl $ //** //** Copyright (C) 1999-2006 Jānis Legzdiņš //** //** This program is free software; you can redistribute it and/or //** modify it under the terms of the GNU General Public License //** as published by the Free Software Foundation; either version 2 //** of the License, or (at your option) any later version. //** //** This program is distributed in the hope that it will be useful, //** but WITHOUT ANY WARRANTY; without even the implied warranty of //** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //** GNU General Public License for more details. //** //************************************************************************** class BasicArmor : Armor; float SavePercent; //========================================================================== // // CreateCopy // //========================================================================== Inventory CreateCopy(EntityEx Toucher) { // I don't see why we need this, but for compatibility purposes it's // here. BasicArmor Copy = Spawn(BasicArmor); Copy.Amount = Amount; Copy.MaxAmount = MaxAmount; Copy.SavePercent = SavePercent ? SavePercent : 1.0 / 3.0; Copy.IconName = IconName; GoAwayAndDie(); return Copy; } //========================================================================== // // HandlePickup // //========================================================================== bool HandlePickup(Inventory Item) { if (Item.Class == Class) { // You shouldn't be picking up BasicArmor anyway. return true; } if (Inventory) { return Inventory.HandlePickup(Item); } return false; } //========================================================================== // // AbsorbDamage // //========================================================================== void AbsorbDamage(int damage, name DmgType, out int NewDamage) { if (DmgType != 'Drowning') { int saved = ftoi(itof(damage) * SavePercent); if (Amount <= saved) { saved = Amount; } Amount -= saved; NewDamage -= saved; if (Amount == 0) { // armor is used up SavePercent = 0.0; // Try to use some inventory armor EntityEx(Owner).AutoUseArmor(); } damage = NewDamage; } if (Inventory) { Inventory.AbsorbDamage(damage, DmgType, NewDamage); } } defaultproperties { bKeepDepleted = true; }