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

Engine.SeqEvent_TakeDamage


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
/**
 * Activated when a certain amount of damage is taken.  Allows the designer to define how much and
 * which types of damage should be be required (or ignored).
 * Originator: the actor that was damaged
 * Instigator: the actor that did the damaging
 * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved.
 */
class SeqEvent_TakeDamage extends SequenceEvent;

/** Damage must exceed this value to be counted */
var() float MinDamageAmount;

/** Total amount of damage to take before activating the event */
var() float DamageThreshold;

/** Types of damage that are counted */
var() array<class<DamageType> > DamageTypes<AllowAbstract>;

/** Types of damage that are ignored */
var() array<class<DamageType> > IgnoreDamageTypes<AllowAbstract>;

/** Current damage amount */
var float CurrentDamage;

/**
 * Searches DamageTypes[] for the specified damage type.
 *
 * Default case is to return true for no damage types listed.  This makes workflow a lot faster as you do not need to
 * add a damage type each time you use this event.
 */
final function bool IsValidDamageType(class<DamageType> inDamageType)
{
	local int Idx;
	local bool bValidDamageType;
	// if any damage types are specified, then verify the inDamageType is a child of at least one
	if (DamageTypes.Length > 0)
	{
		bValidDamageType = FALSE;
		for (Idx = 0; Idx < DamageTypes.Length; Idx++)
		{
			if (ClassIsChildOf(inDamageType,DamageTypes[Idx]))
			{
				bValidDamageType = TRUE;
				// no need to keep looking
				break;
			}
		}
		if (!bValidDamageType)
		{
			return FALSE;
		}
	}
	// check to see if the damage type is an ignored type
	if (IgnoreDamageTypes.Length > 0)
	{
		for (Idx = 0; Idx < IgnoreDamageTypes.Length; Idx++)
		{
			if (ClassIsChildOf(inDamageType,IgnoreDamageTypes[Idx]))
			{
				// should be ignored
				return FALSE;
			}
		}
	}
	return TRUE;
}

/**
 * Applies the damage and checks for activation of the event.
 */
final function HandleDamage(Actor inOriginator, Actor inInstigator, class<DamageType> inDamageType, int inAmount)
{
	local SeqVar_Float FloatVar;
	local bool bAlreadyActivatedThisTick;

	if (inOriginator != None &&
		bEnabled &&
		inAmount >= MinDamageAmount &&
		IsValidDamageType(inDamageType) &&
		(!bPlayerOnly ||
		 (inInstigator!= None && inInstigator.IsPlayerOwned())))
	{
		CurrentDamage += inAmount;

		if (CurrentDamage >= DamageThreshold)
		{
			bAlreadyActivatedThisTick = (bActive && ActivationTime ~= GetWorldInfo().TimeSeconds);
			if (CheckActivate(inOriginator,inInstigator,false))
			{
				// write to any variables that want to know the exact damage taken
				foreach LinkedVariables(class'SeqVar_Float', FloatVar, "Damage Taken")
				{
					//@hack carry over damage from multiple hits in the same tick
					//since Kismet doesn't currently support multiple activations in the same tick
					if (bAlreadyActivatedThisTick)
					{
						FloatVar.FloatValue += CurrentDamage;
					}
					else
					{
						FloatVar.FloatValue = CurrentDamage;
					}
				}
				// reset the damage counter on activation
				if (DamageThreshold <= 0.f)
				{
					CurrentDamage = 0.f;
				}
				else
				{
					CurrentDamage -= DamageThreshold;
				}
			}
		}
	}
}

function Reset()
{
	Super.Reset();

	CurrentDamage = 0.f;
}

defaultproperties
{
   DamageThreshold=100.000000
   VariableLinks(1)=(ExpectedType=Class'Engine.SeqVar_Float',LinkDesc="Damage Taken",bWriteable=True,MinVars=1,MaxVars=255)
   ObjClassVersion=3
   ObjName="Take Damage"
   ObjCategory="Actor"
   Name="Default__SeqEvent_TakeDamage"
   ObjectArchetype=SequenceEvent'Engine.Default__SequenceEvent'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: tr 31-1-2018 17:18:30.000 - Creation time: sk 18-3-2018 10:01:13.905 - Created with UnCodeX