SpatialFear.SFDamageProtection

00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
//=============================================================================
// Spatial Fear
// Class: SFDamageProtection
// Description: Subclass of SFPickup, implements an intellegent damage protection
//              item. Subclasses of SFDamageProtection should do the model and
//              sound loading/importing.
//
// Created by: Markus Nuebel
//=============================================================================

class SFDamageProtection extends SFPickup;

var (SpatialFear) int	HealingAmount; // Health reservoir of the vest. Default: 20
var (SpatialFear) int	MaxHealing; // Maximum health, the vest can carry. Default: 20
var float m_fFireProtection; // Amount of fire protection (in percent), lowers any fire damage by this value. Default: 0.2 (20 percent)
var float m_fChemicalProtection; // Amount of chemical protection (in percent), lowers any chemical damage by this value. Default: 0.2 (20 percent)
var float m_fBallisticProtection; // Amount of shot protection (in percent), lowers any shot by this value. Default: 0.2 (20 percent)
var float m_fRadioactiveProtection; // Amount of radioactive protection (in percent), lowers any radioactive damage by this value. Default: 0.2 (20 percent)
var float m_fMaxProtection; // Maximum amount of protection that a type can provide. Default: 0.5

// Refills the vest. Called from a MedStation
function int refill(int nAmout)
{
	local int nRest;

	// Item is again available
	if(0 >= HealingAmount)
		SFHUD(SFPlayer(Owner).myHUD).InsertIntoBelt(Self);

	// Refill
	HealingAmount += nAmout;

	// Do not give more than the maximum
	if(MaxHealing < HealingAmount)
	{
		nRest = HealingAmount-MaxHealing; 
		HealingAmount = MaxHealing;
	}
	else
		nRest = 0;

	return nRest;
}



// Calculates the current damage based on the current protection settings
function float calcDamage(float fDamage, string damageType)
{
	local float fResult;

	// Some inits
	fResult = fDamage;

	//class'SFUtils'.static.sfLogEx(5, "SFDamageProtection - calcDamage: Damage " $ fDamage $ " Type" $ damageType);

	if("shot" == DamageType)
		fDamage *= (1.0f-m_fBallisticProtection);
	if("Burned" == DamageType)
		fDamage *= (1.0f-m_fFireProtection);
	if("Corroded" == DamageType)
		fDamage *= (1.0f-m_fChemicalProtection);
	if("Radiation" == DamageType)
		fDamage *= (1.0f-m_fRadioactiveProtection);

	//class'SFUtils'.static.sfLogEx(15, "SFDamageProtection - calcDamage: newDamage " $ fDamage);

	return fDamage;
} 

// Upgrade the vest, returns true, if upgrade was sucessful,
// false, if maximum is already reached 
function bool upgrade(float fProtection, string DamageType)
{
	local SFPlayer	oPlayer;
	local SFHUD		oHUD;

	// Get access to player
	oPlayer	= SFPlayer(Owner);
	if(None == oPlayer)
		return false;
	// Get access to our HUD
	oHUD	= SFHUD(oPlayer.myHUD);
	if(None == oHUD)
		return false;

	if("shot" == DamageType)
	{
		if(m_fBallisticProtection+fProtection <= m_fMaxProtection)
		{
			m_fBallisticProtection+=fProtection;
			return true;
		}
		else
	}
	if("Burned" == DamageType)
	{
		if(m_fFireProtection+fProtection <= m_fMaxProtection)
		{
			m_fFireProtection+=fProtection; 
			oHUD.m_winFireUpgrade.show();
			return true;
		}
	}
	if("Corroded" == DamageType)
	{
		if(m_fChemicalProtection+fProtection <= m_fMaxProtection)
		{
			m_fChemicalProtection+=fProtection; 
			oHUD.m_winChemicalUpgrade.show();
			return true;
		}
	}
	if("Radiation" == DamageType)
	{
		if(m_fRadioactiveProtection+fProtection <= m_fMaxProtection)
		{
			m_fRadioactiveProtection+=fProtection; 
			oHUD.m_winRAdUpgrade.show();
			return true;
		}
	}

	return false;
}

// Checks, if the upgrade needs a refillment
function bool needRefill()
{
	return (HealingAmount < MaxHealing);
}

// Calculates the necessary health refill amount
function int getRefillAmount()
{
	return (MaxHealing-HealingAmount);
}

function Activate()
{
	// Call to base class
	Super.Activate();

	// Remove from item belt
	SFHUD(SFPlayer(Owner).myHUD).removeFromActiveItemBelt(Self);

}

defaultproperties
{
     HealingAmount=20
     MaxHealing=20
     m_fFireProtection=0.200000
     m_fChemicalProtection=0.200000
     m_fBallisticProtection=0.200000
     m_fRadioactiveProtection=0.200000
     m_fMaxProtection=0.750000
}

class file time: 12/7/2003 3:58:24 PM - creation time: 12/7/2003 4:03:44 PM
Created with UnCodeX