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 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 |
// ============================================================================ // JBKickerTriggerable // Copyright 2007 by Wormbo <wormbo@online.de> // $Id: JBKickerTriggerable.uc,v 1.3 2007-05-18 16:39:04 wormbo Exp $ // // A triggerable xKicker with several additional features: // // - can be trigger-toggled or trigger-controlled on/off // // - defines directions "in front" and "behind" by its location and rotation: // * can ignore touches if touching actor is behind // * can mirror the kick direction if the touching actor is behind // // - can cause damage to kicked actors // // - can play a sound on the kicked actor // ============================================================================ class JBKickerTriggerable extends xKicker placeable; // ============================================================================ // Imports // ============================================================================ #exec texture import file=Textures\JBKickerTriggerable.pcx mips=0 masked=1 group=Icons // ============================================================================ // Properties // ============================================================================ var(xKicker) bool bInitiallyEnabled; var(xKicker) bool bOnlyKickIfInFront; var(xKicker) bool bMirrorKickIfBehind; var(xKicker) Sound KickSound; var(xKicker) int KickDamage; var(xKicker) class<DamageType> KickDamageType; var(xKicker) class<Actor> KickEffectClass; var(xKicker) color KickScreenFlash; // ============================================================================ // Variables // ============================================================================ var bool bEnabled; var Volume AssociatedVolume; // ============================================================================ // state Initializing // // Perform initialization of AssociatedVolume and bEnabled and check initially // touching actors of the volume and own collision. // ============================================================================ auto state Initializing { Begin: foreach AllActors(class'Volume', AssociatedVolume) { if (AssociatedVolume.AssociatedActor == Self) break; } if (AssociatedVolume != None && AssociatedVolume.AssociatedActor == Self) { if (bCollideActors) { log(Name $ " - Disabling bCollideActors because associated to volume " $ AssociatedVolume, 'Warning'); SetCollision(False, False, False); } } else { AssociatedVolume = None; if (!bCollideActors) log(Name $ " - Not colliding and not associated to any volume.", 'Warning'); } bEnabled = bInitiallyEnabled; if (bEnabled) CheckTouching(); } // ============================================================================ // state TriggerToggle // // Trigger toogles the enabled status. // ============================================================================ state() TriggerToggle extends Initializing { event Trigger(Actor Other, Pawn EventInstigator) { bEnabled = !bEnabled; if (bEnabled) CheckTouching(); } } // ============================================================================ // state TriggerControl // // Trigger inverts the initial enabled status, Untrigger resets. // ============================================================================ state() TriggerControl extends Initializing { event Trigger(Actor Other, Pawn EventInstigator) { if (bEnabled == bInitiallyEnabled) { bEnabled = !bInitiallyEnabled; if (bEnabled ) CheckTouching(); } } event Untrigger(Actor Other, Pawn EventInstigator) { if (bEnabled != bInitiallyEnabled) { bEnabled = bInitiallyEnabled; if (bEnabled) CheckTouching(); } } } // ============================================================================ // Reset // // Resets the enabled status. // ============================================================================ function Reset() { if (bEnabled != bInitiallyEnabled) { bEnabled = bInitiallyEnabled; if (bEnabled) CheckTouching(); } } // ============================================================================ // Touch // // Remembers the actor for kicking in PostTouch() if enabled and optionally if // actor is in front of this kicker. Also causes the specified trigger event. // ============================================================================ event Touch(Actor Other) { if (bEnabled && (!bOnlyKickIfInFront || vector(Rotation) dot (Other.Location - Location) > 0)) Super.Touch(Other); } // ============================================================================ // PostTouch // // Kicks the actor and optionally damages it and plays a sound. // ============================================================================ event PostTouch(Actor Other) { local bool bWasFalling; local vector Push, KickNormal, KickAreaWidth, KickAreaHeight, KickDir, Flash, EffectLocation; local float PMag; bWasFalling = Other.Physics == PHYS_Falling; GetAxes(Rotation, KickNormal, KickAreaWidth, KickAreaHeight); KickDir = KickVelocity; if (bMirrorKickIfBehind && KickNormal dot (Other.Location - Location) < 0) { KickDir -= 2 * KickNormal * (KickNormal dot KickDir); KickNormal *= -1; } if (bKillVelocity) { Push = -Other.Velocity; } else { Push = KickNormal * (KickNormal dot -Other.Velocity); } if (Push.Z < 0 && Push.Z + Other.Velocity.Z < 0) { Push.Z = -Velocity.Z; } if (bRandomize){ PMag = VSize(KickDir); Push += PMag * Normal(KickDir + 0.5 * PMag * VRand()); } else { Push += KickDir; } if (Pawn(Other) != None && Pawn(Other).Controller != None) { Pawn(Other).bNoJumpAdjust = True; Pawn(Other).Controller.SetFall(); } if (Other.Physics == PHYS_Karma || Other.Physics == PHYS_KarmaRagdoll) { if (!Other.KIsAwake()) Other.KWake(); Other.KAddImpulse(Push * Other.Mass, vect(0,0,0)); } else { Other.SetPhysics(PHYS_Falling); Other.Velocity += Push; } if (KickDamage > 0 && KickDamageType != None) { Other.TakeDamage(KickDamage, Other.Instigator, Other.Location - vector(Rotation) * Other.CollisionRadius, vect(0,0,0), KickDamageType); } if (Other != None) { if (KickScreenFlash.A > 0 && Pawn(Other) != None && PlayerController(Pawn(Other).Controller) != None && !PlayerController(Pawn(Other).Controller).bBehindView) { Flash.X = KickScreenFlash.R; Flash.Y = KickScreenFlash.G; Flash.Z = KickScreenFlash.B; PlayerController(Pawn(Other).Controller).ClientFlash(float(KickScreenFlash.A) / 255.0, Flash * 3.9215686); // Flash * 1000 / 255 } if (KickEffectClass != None) { KickDir = Other.Location - Location; EffectLocation = Location; EffectLocation += KickAreaWidth * FClamp(KickAreaWidth dot KickDir, -CollisionRadius, CollisionRadius); EffectLocation += KickAreaHeight * FClamp(KickAreaHeight dot KickDir, -CollisionHeight, CollisionHeight); Spawn(KickEffectClass, Other,, EffectLocation, rotator(KickNormal)); } if (KickSound != None) Other.PlaySound(KickSound,, TransientSoundVolume,, TransientSoundRadius); } } // ============================================================================ // CheckTouching // // Kick all actors touching this kicker or its associated volume. // ============================================================================ function CheckTouching() { local Actor A; if (AssociatedVolume != None) { foreach AssociatedVolume.TouchingActors(class'Actor', A) { Touch(A); } } else if (bCollideActors) { foreach TouchingActors(class'Actor', A) { Touch(A); } } while (PendingTouch != None) { PostTouch(PendingTouch); if (PendingTouch != None) { A = PendingTouch; PendingTouch = PendingTouch.PendingTouch; A.PendingTouch = None; } } } // ============================================================================ // Default values // ============================================================================ defaultproperties { bDirectional = True bInitiallyEnabled = True DrawScale = 0.5 Texture = Texture'JBKickerTriggerable' } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |