The three virtues of a programmer: Laziness, Impatience, and Hubris. – Larry Wall
Legacy:VitalOverdose/Wormhole
From Unreal Wiki, The Unreal Engine Documentation Site
< Legacy:VitalOverdose
Revision as of 13:24, 8 December 2007 by 84-45-226-149.no-dns-yet.enta.net (Talk)
//============================================================================= // Wormhole By vitaloverdose, Feb 2006, http://www.Vitaloverdose.com //============================================================================= class Wormhole Extends Trigger placeable; var Array<Actor> TpAct; Var () Array< Class< Emitter > > VecTagFxPool; Var () Array< Class< Emitter > > AmbiantFxPool; Var () Array< Class< Emitter > > TeleportFxPool_Vec; Var () Array< Class< Emitter > > TeleportFxPool_Self; Var () Sound TeleportSound; Var () Emitter SpawnedAmbiantFx; var () Emitter SpawnedVecFx; Var () bool bScanDest; var () bool bPlayTelePortEffect; Var () float ReScanDelay; Var () float SafeSpawnlocScanRadius; Var () Vector ActualBoostForce; Function PostBeginPlay() { ScanTpAct(); SpawnFx( Self.Location , AmbiantFxPool , Self ); If ( ( bScanDest == False ) && ( (AmbiantFxpool.Length <= 0 ) || ( ReScanDelay <= 0 )) ) Return; SetTimer(ReScanDelay,True); } Simulated Function ScanTpAct() { Local Actor FoundTelPoint; if (TpAct.Length>0) TpAct.Remove(0,TpAct.Length); foreach AllActors( Class'Actor' , FoundTelPoint,'TP' ) { TpAct.Insert(0,1); TpAct[0] = FoundTelPoint; } } Function Touch( Actor Other) { if (Other.IsA('Vehicle')) Vectel(vehicle(Other)); else if ( Other.IsA('pawn')) TPort(Pawn(Other)); } Simulated function TPort( Pawn TPPawn ) { local actor SafeSpawnactor; SafeSpawnactor=FindSafeSpawnLoc(SafeSpawnlocScanRadius); TPPawn.SetLocation( SafeSpawnactor.Location); TPPawn.SetRotation( SafeSpawnactor.Rotation ); TPPawn.OldRotYaw = TPPawn.Rotation.Yaw; } Simulated Function Vectel(Pawn PTele) { Local EPhysics Entryphysics; Local Vehicle Teleporting; local Rotator OldRot; Local Rotator NewRot; local actor SafeSpawnactor; Teleporting = Vehicle(pTele); NewRot = Teleporting.Rotation; EntryPhysics = Teleporting.Physics; ActualBoostForce = Teleporting.Velocity * 500; Teleporting.SetPhysics(PHYS_None); SafeSpawnactor=FindSafeSpawnLoc(SafeSpawnlocScanRadius); if ( SafeSpawnactor != none ) { Teleporting.SetLocation(SafeSpawnactor.location); oldRot = Teleporting.Rotation; NewRot.Yaw = SafeSpawnactor.Rotation.Yaw + Teleporting.Rotation.Yaw - Self.Rotation.Yaw; posttel(Teleporting , Newrot , EntryPhysics ); } } function Timer() { ScanTpAct(); } Simulated Function SpawnFx( Vector SpawnPos ,Array< Class< Emitter > > FxSpawnpool, Actor Hardattachedto ) { Local int PickedNumb; local Class<Emitter> ChosenFxClass< SEMI > local Emitter SpawnedFx; if ( FxSpawnpool.Length <= 0 ) { PickedNumb = FxSpawnpool.Length; PickedNumb = Rand(PickedNumb); ChosenFxClass = FxSpawnpool[PickedNumb]; } SpawnedFx = Spawn( ChosenFxClass , self , , SpawnPos , Rotation ); if ( (SpawnedFx != none ) && ( Hardattachedto != none ) ) SpawnedFx.SetBase( Hardattachedto ); } Function actor FindSafeSpawnLoc( float ScanRadius ) { local pawn Foundpawn; local Array<Actor> TempTpAct; Local Int Counter; Local int PickedRNDNo; local actor SafeSpawnactor; TempTpAct.Length = tpact.Length; TempTpAct = TpAct; for ( Counter=0;Counter<tpact.Length;Counter++) //here i want to pick Numbs at Random from a list { //First west up the Numbs in sequential order and then PickedRNDNo = Rand( tempTpAct.Length -1 )+1; //pick a RND No based on the Length of the list.Once Picked SafeSpawnactor = tempTpAct[PickedRNDNo]; //the Numb is removed from the list and anOther Numb is pick tempTpAct.remove( PickedRNDNo ,1 ); //is Picked based on the new Length of the list foreach radiusActors( Class'pawn' , Foundpawn , ScanRadius , SafeSpawnactor.location ) if ( ( Foundpawn != Self ) && ( Foundpawn.bCollideActors == True ) ) SafeSpawnactor =none; return SafeSpawnactor; } } Simulated function Posttel( Pawn Teleporting , Rotator Newrot , EPhysics EntryPhysics ) { local Vector PointOfBoostFoce; local Actor RotRelation;; Teleporting.SetPhysics( EntryPhysics ); Teleporting.Controller.moveTimer = -1.0; Teleporting.SetmoveTarget( Self ); Teleporting.Controller.SetRotation( NewRot ); Teleporting.SetRotation( NewRot ); if ( Teleporting.IsA('ONSChopperCraft') || Teleporting.IsA('ONSHoverCraft') || Teleporting.IsA('ONSPlaneCraft')) Teleporting.KSetStayUpright( true , true ); if ( bDirectional ) RotRelation = Self; else RotRelation = Teleporting; Vehicle(Teleporting).KAddImpulse( ActualBoostForce >> RotRelation.rotation , PointOfBoostFoce >> RotRelation.rotation ); if ( TeleportSound != None ) PlaySound( TeleportSound ); }