Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

Gameplay.MPConsumable


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
class MPConsumable extends MPActor;

var() Name			idleAnim					"An animation to play.";
var() float			respawnTime					"The amount of time it takes this consumable to respawn after being consumed.  -1 means it won't respawn.";
var() float			energyChange				"Change the player's energy by this amount when consumed.";
var() float			healthChange				"Change the player's health by this amount when consumed.";
var() float			speedScaleChange			"Scale the player's speed by this amount when consumed.";

// Stats
var(Stats) class<Stat>	consumeStat				"The stat awarded for consuming this consumable.";


// PostBeginPlay
simulated function PostBeginPlay()
{
	Super.PostBeginPlay();

	if (DrawType == DT_Mesh && hasAnim(idleAnim))
		LoopAnim(idleAnim);

}

function registerStats(StatTracker tracker)
{
	Super.registerStats(tracker);

	tracker.registerStat(consumeStat);
}

function onConsumed(Character c)
{
}

singular function Touch(Actor Other)
{
	local Character c;

	c = Character(Other);

	if (c == None || bHidden)
		return;

	consume(c);
}

function consume(Character c)
{
	awardStat(consumeStat, c);
	if (energyChange != 0)
		c.changeEnergy(energyChange);
	if (healthChange != 0)
		c.changeHealth(healthChange);
	if (speedScaleChange != 1.0)
		c.unifiedSetVelocity(c.unifiedGetVelocity() * speedScaleChange);

	onConsumed(c);
	GotoState('Consumed');
}

// Available state
auto simulated state Available
{
	function CheckTouching()
	{
		local Character c;

		ForEach TouchingActors(class'Character',c)
		{
			consume(c);
			return;
		}
	}

Begin:
	// After setting to its home location, see if anyone is touching it
	CheckTouching();
}

// Locked state
// When a consumable is consumed, it is invisible for a certain period of time
state Consumed
{
	function BeginState()
	{
		if (respawnTime >= 0)
			SetTimer(respawnTime, false);
		bHidden = true;
	}

	function Timer()
	{
		SetTimer(0, false);
		GotoState('Available');
	}

	function EndState()
	{
		bHidden = false;
	}
}

defaultproperties
{
	DrawType					= DT_StaticMesh
	StaticMesh					= StaticMesh'MPGameObjects.Ball'
	Physics						= PHYS_None
    bUseCylinderCollision		= false	
	bCollideActors				= true
	bCollideWorld				= true
	bStatic						= false
	bBlockActors				= false
	bBlockPlayers				= false

	bRotateToDesired			= false
	bHardAttach					= true
	bBlockKarma					= false

    bDynamicLight=true
    LightHue=40
    LightBrightness=200
    LightType=LT_Steady
    LightEffect=LE_QuadraticNonIncidence
    LightRadius=10

	respawnTime					= 20
	energyChange				= 0
	healthChange				= 0
	speedScaleChange			= 1.0
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: ne 5.9.2004 15:53:18.000 - Creation time: st 23.5.2018 00:10:45.887 - Created with UnCodeX