Once I get that upgrade to 36-hour days, I will tackle that. – Mychaeel

Legacy:VitalOverdose/RandomRelocator

From Unreal Wiki, The Unreal Engine Documentation Site
< Legacy:VitalOverdose
Revision as of 05:25, 14 September 2011 by Vitaloverdose (Talk | contribs) (Download and Embed)

Jump to: navigation, search
UT2004 :: Actor >> Trigger >> RandomRelocator (Package: custom) - works online.

by VitalOverdose;

Overview

  • Unlike the normal teleporter system the RandomRelocator only needs one teleporter actor to work.
  • The player [Pawn | pawn] can be teleported to the position of any pathnode(usually but you can use any actor as a teleport exit point as long as it has a tag name matching a name specified in the random relocator properties in this class by the mapper.
  • If more than one pathnode has the same tag name 'TelPointName' the RandomRelocator will pick one at random. This can really help to make very linear flowing maps to be less predictable.
  • The Pathnodes are scanned at the start of gameplay to get their locations but they also get re-scanned every 'ScanRate' seconds. If any actor with a matching tag name moves then the new location will be recored. This way you can have moving teleport exit points as teleport points don't have to be pathnodes, any actor will do.

Note:

This actor is invisible during gametime so depending on how you want to use this actor it might be a good idea to have some sort of emitter or Static mesh as an indicator to let people know where it is.

TheScript

//=============================================================================
// RandomRelocator By vitaloverdose, Feb 2006, http://www.Vitaloverdose.com
// Full class list http://wiki.beyondunreal.com/wiki/Vital's_Pro_Mapping_Tools
//=============================================================================
class RandomRelocator  Extends triggers
Placeable;
 
Var Array <Actor>  TpAct; // a dynamic array to hold the vector locations of all the possible teleport exit points.
 
Var () Bool          BPlaySpawnEffect;
Var () Float         ScanRate;
Var () name          TelPointName;
 
Function PostBeginPlay()
{
If ((ScanRate<0.1) && (ScanRate>0))     // enforces min and max defaults for the scanrate                 
    {                                                        
     Destroy();
     log("reScanTime must be >  0.1 not "$ScanRate);
    }
 ScanTpAct();                                         // scans for pathnodes with tags that match TelPointName;
 SetTimer(ReScanTime,True);                           // 
Super.PostBeginPlay()
}
 
Function Timer()
{
 ScanTpAct();
}
 
simulated Function Touch( Actor Other )
{
 local int pickedTport;                                
 
 if (tpact.length  > 1)
     pickedTport = rand(tpact.length-1)+1; // picks a random number based on the amount of tp locationes being stored in the dynamic array
 
 if ((other.isa('Pawn')) && (!other.isa('vehicle')))
      TPort( tpact[pickedTport], pawn(other));                // qualifies the actor touching us
 
 Super.Touch(other);  // adds any code from the parent function of the same name at this point
}
 
Simulated Function ScanTpAct()    // scans for pathnodes that have tag names the same as TelPointName
{                                 // and stores thier vector locations in a dynamic array.
 Local Actor FoundTelPoint;
 
 If ( TpAct.Length > 0 )
      TpAct.Remove( 0,TpAct.Length );
 
 foreach AllActors( Class'Actor' , FoundTelPoint, TelPointName )  // an iterator looks though all
   {                                      //  actor classes in the map to find matching tag names 
    TpAct.Insert( 0,1 );
    TpAct[0] = FoundTelPoint;
   }
}
 
Simulated Function  TPort( Actor TelPoint,Pawn TPPawn) // this function teleports the vehicle
{
 TPPawn.SetLocation( TelPoint.Location);
 TPPawn.SetRotation( TelPoint.Rotation );
 TPPawn.OldRotYaw  = TPPawn.Rotation.Yaw;
}

Download and Embed

mylevel.u

Like any resource saved to the mylevel package the you wont have to include any extra files with your map when distributing it. This will improve your chances of people uploading your map to thier server as no one likes extra files.

Also like any other resource saved to the my level package if you dont place a Vehicle booster in your map after importing the mylevel.u file and then save your map the next time you open it up you wont find the ONSVehicleBooster available in your class tree anymore. This is not a problem , just import the mylevel.u file again and your good to go.. ;)

Related Topics