Legacy:VitalOverdose/JumpingTeleporter

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to navigation Jump to search
UT2004 :: Actor >> Trigger >> xKicker >> JumpingTeleporter (Package: custom)

by VitalOverdose

OverView

This custom xkicker actor will fire ( + HardAttach a nice trail effect) a Pawn and then depending if the Pawn went in the right direction, it will then capture and teleport (with optional sound/Emitter fx) him.

Usage

There is only 1 actor to this teleport system as any actor that has it collision switched off can be a TeleportExit as long as its 'TagName' matches the one specified by the mapper in the JumpingTeleporter properties. Path nodes are ideal for TeleportExits.

If you link more than one actor to the the JumpingTeleporter then one will be picked at random at the time of teleportation. This is so you can add a JumpingTeleporter to existing maps very quickly as most maps have pathnodes/ RoadPathNodes already set out in suitable places for most pawns to be teleported to.

Note

Remember you don't HAVE to use multiple spawn locations If you use 1 JumpingTeleporter and 1 spawn location it should be no more difficult to visualize than using a standard teleporter system.

The Script

<uscript> //============================================================================= // Jumping Teleporter By vitaloverdose, Updated Nov 2007 // http://www.Vitaloverdose.com // This is part of the 'Vitals Pro Mapping Tools' Mod // Full class list http://wiki.beyondunreal.com/wiki/Vital's_Pro_Mapping_Tools //=============================================================================

class JumpingTeleporter extends xkicker placeable;

Var() Bool bPlaySpawnEffect; Var Bool bRescanTeleportExits; Var Bool bScanning; Var Bool bTracking;

Var() Array < Class< Emitter > > TrailFxPool; Var() Array < Class< Emitter > > TeleportFxPool; Var() Array < Class< Emitter > > MaterialiseFxPool; Var Array < Actor > TeleportExits;

Var() Name TeleportExitTag; // mapper can set the Tag name for tp points

Var() Float TimerFrequency; Var() Float TelEntryScanRadius;

Var() Vector TeleportEntryOffset;

Var() Sound TeleportSound; Var() sound MaterialiseSound;

Var Int RescanFrequency; Var Int TimeTillRescan;

Function PostBeginPlay() { // Run the first Scan for TeleportExits ScanTeleportExit(); TeleportEntryOffset += Location;

if ( RescanFrequency!= 0 ) // checks to see if the mapper wants Rescaning

    settimer(0.1,true);                       // if so then set the timer to repete

TeleportExits.Insert( 0,1 ); // creates blanks space for first TeleportExits vector loction; super.PostBeginPlay(); // adds function related code form parent }

Simulated function ScanTeleportExit() {

Local Actor FoundTeleportExit;
if ( TeleportExits.Length != 0 )
    TeleportExits.Remove( 0,TeleportExits.Length );
foreach AllActors( Class'Actor' , TeleportExits[0], TeleportExitTag )
        TeleportExits.Insert( 0,1 );
if ( RescanFrequency != 0)
    TimeTillRescan=RescanFrequency;

}

Function Touch(Actor Other) {

local Emitter SpawnedTrail;
if (((other.IsA('Pawn'))&&(!other.isa('Vehicle'))) && (TrailFxPool.length != 0))
   {
    SpawnedTrail = Spawn( TrailFxPool[rand(TrailFxPool.length-1)+1] ,self ,,other.Location ,other.rotation );
   if (SpawnedTrail!=None)
      {
       SpawnedTrail.SetBase(other);
       bScanning=true;
      }
}

Super.Touch(Other); }

Function Timer() {

local Emitter FoundEmitter;
local Emitter SpawnedEmitter;
if ( bTracking == true )
   {
   foreach RadiusActors(class'Emitter',FoundEmitter,TelEntryScanRadius,TeleportEntryOffset)
        {
         if (FoundEmitter.Owner == self)
            {
             TeleportActor( Pawn(FoundEmitter.Base) );
             FoundEmitter.destroyed();
             if ( TeleportFxPool.length > 0 )
                 SpawnedEmitter=Spawn( TeleportFxPool[rand(TeleportFxPool.length-1)+1],self , ,Pawn(FoundEmitter.Base).Location);
             if ( TeleportSound != None )
                 Playsound( TeleportSound );                        //some sound FX
             bTracking = false;                      // switches the flag for tacking off
            }
        }
   }
if ( RescanFrequency != 0 )
   {
    TimeTillRescan -= 0.1;
    if (TimeTillRescan < 0 )
       {
        ScanTeleportExit();
        TimeTillRescan = RescanFrequency;
       }
   }

super.Timer(); }

Simulated Function TeleportActor(Pawn TeleportExitActor) {

local float    ExtraHeight;
local Int      PickedNumb;
local vector   NewOffsetPosition;
 If ( BPlaySpawnEffect == true )
      TeleportExitActor.PlayTelePortEffect( False,True );       // Spawns fx if needed
PickedNumb         = FindSafeSpawnLoc(ExtraHeight);
NewOffsetPosition    = TeleportExits[PickedNumb].Location;
NewOffsetPosition.z += ExtraHeight;
TeleportExitActor.SetLocation( NewOffsetPosition );
TeleportExitActor.SetRotation( TeleportExits[PickedNumb].Rotation );
TeleportExitActor.OldRotYaw = TeleportExitActor.Rotation.Yaw;
If ( BPlaySpawnEffect == true )
    TeleportExitActor.PlayTelePortEffect( False,True );         // Spawns fx if needed
}

// this function checks for Pawns being to close to the Spawn point // this way no one should get telefraged. Function Int FindSafeSpawnLoc(out float ExtraHeight) {

Local Pawn         FoundPawn;
Local Int          Counter;
Local int          PickedRNDNo;
Local array<int>   Templist;
Templist.Length  = TeleportExits.Length;
while( FoundPawn == None )
     {
      for ( Counter = 0 ; Counter < TeleportExits.Length ; Counter++ )
           Templist[Counter]=Counter;
      for ( Counter=0 ; Counter < TeleportExits.Length ; Counter++ )  // pick Numbs @Random from list
          {                                               //  Numbs in sequential order
           PickedRNDNo = Rand(Templist.Length -1)+1; //RND No based on the Length of the list.
           foreach radiusActors( Class'Pawn' , FoundPawn , TelEntryScanRadius , TeleportExits[PickedRNDNo].Location + (Vect( 0,0,1) * ExtraHeight))
                                {
                                 if ( FoundPawn.bCollideActors == True )
                                      PickedRNDNo = -10;
                                  TempList.remove( PickedRNDNo ,1 );
                                 }
          }
      ExtraHeight += 90;
     }

return PickedRNDNo; } </uscript>

Related Topics


Discussion