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 |
/****************************************************************************** LightningTraceHelper Creation date: 2013-09-09 16:17 Last change: $Id$ Copyright © 2013, Wormbo Website: http://www.koehler-homepage.de/Wormbo/ Feel free to reuse this code. Send me a note if you found it helpful or want to report bugs/provide improvements. Please ask for permission first, if you intend to make money off reused code. ******************************************************************************/ class LightningTraceHelper extends Actor; struct THitInfo { var float HitDistance; var Actor HitActor; var vector HitLocation, HitNormal; }; var array<Actor> Hits; // Collects all actors a trace from start to end would hit, but ignores world geometry. static function array<THitInfo> TraceHits(Actor Requester, vector Start, vector End, float TraceRadius) { local LightningTraceHelper Helper; local vector CurrentLocation, NextLocation, TraceDir, TraceExtent; local float CurrentPos, NextPos, TraceLength, TraceStep; local array<THitInfo> HitInfos; local THitInfo HitInfo; local int i, j; Helper = Requester.Spawn(default.Class, None, '', Start); if (Helper != None) { Helper.SetCollisionSize(TraceRadius * 1.2, TraceRadius * 1.2); Helper.SetCollision(True, False, False); TraceDir = End - Start; TraceLength = VSize(TraceDir); TraceDir /= TraceLength; TraceExtent = vect(1,1,1) * TraceRadius; TraceStep = TraceLength / int(TraceLength / 1000.0 + 1) + 1; //log("Trace helper " $ Start @ End @ TraceDir @ TraceLength @ TraceStep); CurrentPos = 0; CurrentLocation = Start; do { NextPos = FMin(CurrentPos + TraceStep, TraceLength); NextLocation = Start + TraceDir * NextPos; //log("Trace step " $ CurrentPos @ CurrentLocation @ NextPos @ NextLocation); Helper.Move(NextLocation - CurrentLocation); for (i = 0; i < Helper.Hits.Length; i++) { if (Helper.Hits[i] != None && Helper.Hits[i] != Requester && !Helper.Hits[i].TraceThisActor(HitInfo.HitLocation, HitInfo.HitNormal, NextLocation, CurrentLocation, TraceExtent)) { HitInfo.HitActor = Helper.Hits[i]; HitInfo.HitDistance = (HitInfo.HitLocation - Start) dot TraceDir; //log("Trace hit " $ HitInfo.HitActor @ HitInfo.HitDistance @ HitInfo.HitLocation @ HitInfo.HitNormal); // ensure the hits are ordered by distance for (j = HitInfos.Length; j > 0 && HitInfos[j - 1].HitDistance > HitInfo.HitDistance; j--) { // move on, nothing to see here } HitInfos.Insert(j, 1); HitInfos[j] = HitInfo; } else { //log("Trace miss " $ Helper.Hits[i]); } } Helper.Hits.Length = 0; CurrentPos = NextPos; CurrentLocation = NextLocation; } until (NextPos >= TraceLength); Helper.Destroy(); } return HitInfos; } function FellOutOfWorld(eKillZType KillType); // don't care function Touch(Actor Other) { //log("Trace candidate " $ Other); Hits[Hits.Length] = Other; } //============================================================================= // Default values //============================================================================= defaultproperties { bProjTarget = False bCollideActors = False bCollideWorld = False bIgnoreEncroachers = True bIgnoreOutOfWorld = True RemoteRole = ROLE_None bAcceptsProjectors = False bHidden = True } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |