| Home Page | Recent Changes | Preferences

VitalOverdose/TouringMover

UT2004 :: Actor >> Mover >> Touring (Package: custom)

This mover is designed to simulate some sort of transporter for pawns or vehicles.

It's designed to move the same way as a mover in 'loop' state with an added 'unloading' stop. Like a mover in loop state, it moves from key 0, through all its keys, then from the last key straight to key 0 again. The key that is designated as unloading stop marks the far end of the mover's journey, its fully open state.

The Mover is in 'Touring' state by default and starts at keyframe 0.

The Mover goes through all the keyframes (first-last) and then finally before stopping it moves to key frame 0. The idea is the the last key frame should be quite close to the first (keynum[0]). This works well if you have your transporter perform a large loop when moving.

Properties

Unloading

You can specify at which keyframe you would like the mover to stop for unloading also the length of time for the Unloading.

Events

There is a dynamic array which can store events to trigger at certain keyframes. It's a dynamic array inside another dynamic array which mean you can call as many events as you like.

Sounds

The usual sounds and events will reposition themselves around the unloading key frame.

IE. if we had 6 keyframes and number 3 was the unloading keyframe then opened events and sounds would happen on keynum3 and all closing events and sounds after the unloading time has elapsed

Script

// By VitalOverdose 2006
// A Touring Mover Class- for pawn/vec transport
// initialste = Touring
// mover starts pos 0 ,
// advances through the keyframes then goes to pos 0 before stopping
// Mover has an 'unload' point(onKeyframe) for cargo or passengers to unload
// unloadtime can be specified

Class Touring Extends mover;

struct                       E_Events
{
 Var() Array< Name >         ExtraEvent;        // event to call (dynamicArray)
};

Var() Array< E_Events >           TheExtraEvents;      //  dynamicArray for the events
var(unload)      Int              unloadatkeyframe;    //  Which Keyframe to Pause at
var(unload)      Float            unloadtime;          //  Time for the pause;
var              Bool             BUnloading;          //  unloading (mover stationary)
var(MoverSounds) sound            keyframesound;

Function PostBeginPlay()
{
if ( bActAsClientMover && Level.NetMode == NM_DedicatedServer )
   {
    SetTimer( 0, false );                          // bit or netpay magic
    SetPhysics( PHYS_None );                       
    GotoState('ServerIdle');
   }
}

State () Touring
{

Function Bool SelfTriggered()
{
return False;
}

Event Trigger( Actor Other, Pawn EventInstigator )
{
 Disable ('Trigger');
 Enable ('UnTrigger');
 SavedTrigger = Other;
 Instigator = EventInstigator;

 if ( SavedTrigger != None )
    {
     SavedTrigger.BeginEvent();
    }

 bOpening = true;
 AmbientSound = moveAmbientSound;
 GotoState( 'touring', 'StartMoving' );
}

Event UnTrigger( Actor Other, Pawn EventInstigator )
{
 Disable ('UnTrigger');
 Enable ('Trigger');
 SavedTrigger = Other;  Instigator = EventInstigator;
 GotoState( 'touring', 'Stopping' );
}

Event KeyFrameReached()
{
 Local Int I;
 if (keyframesound!=None) PlaySound( keyframesound, SLOT_None, SoundVolume  / 255.0, false, SoundRadius, SoundPitch / 64.0);
 if (TheExtraEvents[keynum].ExtraEvent.Length>0)
    {
    For (i=0;I<TheExtraEvents[keynum].ExtraEvent.Length;I++)  //loops through all the events for this
        {                                                     // keyframe
         triggerEvent(TheExtraEvents[keynum].ExtraEvent[i],Self,Instigator);  //triggers the event
        }
    }
}

Function BeginState()                                     // flags 
{
 bOpening  = False;
 bDelaying = False;
}

///////////////////////////////////////          state lable :StartMoving
StartMoving:                                    // gets run once per move cycle
///////////
TriggerEvent(OpeningEvent, Self, Instigator);  // Triggers Opening event
if ( Follower != None ) Follower.DoOpen();     // Calls DoOpen() on an followers
if (OpeningSound!=none)                        // If there is an opening sound..
   {
   MakeNoise(1.0);                             // attract nearby bot attention
   PlaySound( OpeningSound, SLOT_None, SoundVolume / 255.0, false, SoundRadius, SoundPitch / 64.0);
   }                                          // plays the opening soun
AmbientSound = MoveAmbientSound;              // plays ambiant sound

////////////////////////////
Running:
///////
FinishInterPolation();                              // Finish Last Interpolation
InterPolateTo( (KeyNum + 1) % NumKeys, moveTime );  // Begin new interpolation
if (keynum==0) GotoState('touring','Returned');     // Check if current Keynum is there First keynum
Else
If ( (keynum!=-1) &&( unloadatkeyframe == Keynum )) // check if current key num is unloading keynum
   {                                                //
   GotoState( 'touring', 'unloading' );             // if so goto STATE touring STATECODE Lable 'unloading'
   }
Else
{
GotoState( 'touring', 'Running' );                  // if not loop to STATE touring STATECODE Lable 'running'
}

Unloading:                                        //// code for unloading
//////////
bUnloading=true;                                  // bUnloading flag
FinishInterPolation();                            // finishes the last interpolation
FinishedOpening();                                // calls FinishedOpening()
TriggerEvent(OpenedEvent, Self, Instigator);      // closed event called
PlaySound( OpenedSound, SLOT_None, SoundVolume  / 255.0, false, SoundRadius, SoundPitch / 64.0);
sleep(unloadtime);                                // pauses code for the time(unloadtime)
TriggerEvent(closingEvent, Self, Instigator);     // calls TriggerEvent(closingEvent)
PlaySound( ClosingSound, SLOT_None, SoundVolume / 255.0, false, SoundRadius, SoundPitch / 64.0);
if ( Follower != None ) Follower.DoClose();
AmbientSound = MoveAmbientSound;
GotoState( 'touring', 'Running' );                // returns to state 'Running'

////////////////////////////
Returned:                                        // state code lable when Mover Returns
/////////
FinishInterPolation();                           // finishes the last interpolation
FinishedClosing();                               // calls finished FinishedClosing()
TriggerEvent(closedEvent, Self, Instigator);     // calls TriggerEvent(closingEvent)
PlaySound( closedSound, SLOT_None, SoundVolume / 255.0, false, SoundRadius, SoundPitch / 64.0);
UnTriggerEvent(Event, Self, Instigator);         // calls untrigger
}

DefaultProperties
{
unloadatkeyframe=-1;     // to avoid keyfram 0 being the default
initialState="Touring"   // start in touring state
bBlockKarma=true;        // to BlockVecs
}

Note:

At the moment there is a slight problem with using movers to transport vehicles these are caused when ;-

quote:"two clients (carrier and carried vehicle) feeding the server two different directions where to move things."-xyx. atari forums.

But i have worked out a way around that and will be posting a tutorial soon.

Download

here is alink to a .uc file for this class.

[Download this Script]

Related pages

Discussion


Category Custom Class

Category Tutorial

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

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