# SpatialFear.SFSmartVestUpgrade

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 |
    //=============================================================================
    // Spatial Fear
    // Class: SFSmartVestUpgrade
    // Description: Subclass of SFPickup, implements an upgrade module for the
    //				smart vest. These can be collected as active items and when
    //				activated add their amount of damage protection to the smart
    //				vest.
    //				Remark: The smart vest has an upper limit on the upgradable
    //				damage protection, so the player cannot get invunerable
    //
    // Created by: Markus Nuebel
    //=============================================================================

    class SFSmartVestUpgrade extends SFPickup;

    var bool	m_bUsed; // Private: Upgrade has already been used? Default: false

    // Style of damage protection
    enum EDamageProtection
    {
    	DP_None,
    	DP_Gravity,
    	DP_Ballistic,	// shot
    	DP_Chemical,	// Corroded
    	DP_Fire,		// Burned
    	DP_Radiation,	// Radiation
    };

    var (SpatialFear) EDamageProtection	ProtectionType; // Kind of damage protection, this upgrade protects against. Defautl: DP_None.
    var (SpatialFear) float	ProtectionAmount; // A value between 0.0 and 0.5. This is the additional percentage of damage protection the vest provides against a type of damage. 0.1 means 10 percent. Normally the smart vest will sum up damage protections to an upper limit of .5 (50%). Default: 0.1

    // Converts from enum to sting, since we cannot pass an
    // enum to another function
    function string getDamageType()
    {
    	switch(ProtectionType)
    	{
    	case DP_Ballistic:
    		return "shot";
    		break;
    	case DP_Fire:
    		return "Burned";
    		break;
    	case DP_Chemical:
    		return "Corroded";
    		break;
    	case DP_Radiation:
    		return "Radiation";
    		break;
    	}

    	return "unknown";
    }

    // Called when the upgrade is activated
    // Upgrades the configured proteciton type of the smart vest with
    // the configured amount of protection
    function Activate()
    {

    	local SFPlayer	oPlayer;

    	// Get the player reference
    	oPlayer	= SFPlayer(Owner);
    	if(None == oPlayer)
    		return;

    	// Check, if the player already owns the SmartVest
    	if(None == oPlayer.m_oSmartVest)
    		return;

    	// Upgrade the vest
    	oPlayer.m_oSmartVest.upgrade(ProtectionAmount, getDamageType());

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

    	// Mark as used
    	m_bUsed=true;
    }

    state Activated
    {
    	function Endstate()
    	{
    		bActive = false;
    	}

    	function BeginState()
    	{
    		PlaySound(ActivateSound,,4.0);

    		// Upgrade already done, remove item from belt
    		SFHUD(SFPlayer(Owner).myHUD).removeFromActiveItemBelt(Self);

    		UsedUp();
    	}

    Begin:
    }

    state DeActivated
    {
    Begin:
    }

    defaultproperties
    {
         ProtectionAmount=0.100000
         bIsActiveItem=True
         bActivatable=True
         CollisionRadius=13.000000
         CollisionHeight=5.000000
    }

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