Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
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 00160 00161 00162 00163 |
/** * 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-2011 Epic Games, Inc. All Rights Reserved. */ class SeqEvent_TakeDamage extends SequenceEvent native(Sequence); /** Damage must exceed this value to be counted */ var() float MinDamageAmount<autocomment=true>; /** 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; /** Should the damage counter be reset if this event is toggled? */ var() bool bResetDamageOnToggle; /** * 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. */ function HandleDamage(Actor inOriginator, Actor inInstigator, class<DamageType> inDamageType, int inAmount) { local SeqVar_Float FloatVar; local bool bAlreadyActivatedThisTick; PublishLinkedVariableValues(); 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; } /** * Return the version number for this class. Child classes should increment this method by calling Super then adding * a individual class version to the result. When a class is first created, the number should be 0; each time one of the * link arrays is modified (VariableLinks, OutputLinks, InputLinks, etc.), the number that is added to the result of * Super.GetObjClassVersion() should be incremented by 1. * * @return the version number for this specific class. */ static event int GetObjClassVersion() { return Super.GetObjClassVersion() + 2; } event Toggled() { if (bResetDamageOnToggle) { CurrentDamage = 0.f; } Super.Toggled(); } defaultproperties { ObjName="Take Damage" ObjCategory="Actor" DamageThreshold=100.f VariableLinks(1)=(ExpectedType=class'SeqVar_Float',LinkDesc="Damage Taken",bWriteable=true) bResetDamageOnToggle=TRUE } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |