| Home Page | Recent Changes

VitalOverdose/Wormhole

UT2004 :: Actor >> Trigger >> Wormhole (Package: custom)

by VitalOverdose

Part of Vital'sPMT

//=============================================================================
// Wormhole By vitaloverdose, Feb 2006, 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
// Direct Download the Mod in zipped format Http://promappingtools.zapto.org
//=============================================================================

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;
 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 );
    }
}
 

Related topics

VitalOverdose/VehicleTeleporter

VitalOverdose/RandomRelocator

 
 

Discussion


Category Custom Class

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In