//************************************************************************** //** //** ## ## ## ## ## #### #### ### ### //** ## ## ## ## ## ## ## ## ## ## #### #### //** ## ## ## ## ## ## ## ## ## ## ## ## ## ## //** ## ## ######## ## ## ## ## ## ## ## ### ## //** ### ## ## ### ## ## ## ## ## ## //** # ## ## # #### #### ## ## //** //** $Id: Health.vc 2619 2007-08-11 10:36:55Z 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 Health : Inventory; int PrevHealth; int LowHealth; string LowHealthMessage; //========================================================================== // // TryPickup // //========================================================================== bool TryPickup(EntityEx Toucher) { if (Toucher.bIsPlayer) { PrevHealth = Toucher.Health; int max = MaxAmount; if (!max) { max = PlayerEx(Toucher.Player).GetMaxHealth(); } if (Toucher.Player.Health >= max) { // You should be able to pick up health bonuses even at // full health. if (bAlwaysPickup) { GoAwayAndDie(); return true; } return false; } Toucher.Player.Health += Amount; if (Toucher.Player.Health > max) { Toucher.Player.Health = max; } Toucher.Health = Toucher.Player.Health; GoAwayAndDie(); return true; } else { PrevHealth = 0x7fffffff; if (Toucher.GiveBody(Amount) || bAlwaysPickup) { GoAwayAndDie(); return true; } return false; } } //========================================================================== // // GetPickupMessage // //========================================================================== string GetPickupMessage() { if (PrevHealth < LowHealth && LowHealthMessage) { return LowHealthMessage; } return ::GetPickupMessage(); } defaultproperties { Amount = 1; MaxAmount = 0; PickupSound = 'misc/health_pkup'; }