| Home Page | Recent Changes | Preferences

VitalOverdose/SFX Ejecting

UT2004 :: Actor >> Emitter >>SFX_Ejecting (Package: custom)

by VitalOverdose

Part of Vital'sPMT

Overview

This custom emitter is designed to have 20 'active' particles that can eject drivers from vehicles on contact

Global Variables

TotalParticles - Internal variable not available to the mapper.

TimerFrequency - Rate at which the particles are scanned.

ScanSize - The radius of the scan to perform at each particle.

Var              int                                                 TotalParticles;
Var ()         int                                                 ActiveEmitterNumb;
Var ()         int                                                 TimerFrequency;
Var ()         float                                           ScanSize;
Var ()         int                                                DamageToPawn;
Var ()         int                                                 DamageToVec;
Var ()         int                                                 DamageToMonster;
Var ()         Class<DamageType>      TheDamageType;

PostBeginPlay()

In this function the Super.PostBeginPlay() command has been put before the modified code so we get anything from the parent class gets dealt with right away and leaves the rest of the function free for whatever code we need to add to it.

We are using the PostBeginPlay() function to check some of the data entered by the mapper before we start scanning the particle locations.

  • First the MaxParticles on the active emitter is checked to see if it is higher than the Limit of 20. if it is it gets set to 20.
  • The ScanSize Radius is checked to see it hasn't been set to low. If it is then it gets set to 64.
  • Then the TimerFrequency is checked to see if it lower < then 0.1 if it is, it gets set to 0.1.
  • Finally the Timer is set on a continuous loop to be called every TimerFrequency seconds.
Simulated Function PostBeginPlay()
{
 Super.PostBeginPlay();

 If ( Emitters[ActiveEmitterNumb].MaxParticles > 20)
    {
     Destroyed();
    }
 If (ScanSize < 1 )
    {
     ScanSize=64;
    }
 If (TimerFrequency<0.1)
    {
     TimerFrequency = 0.1;
    }

SetTimer( TimerFrequency , True );
}

Timer()

The Timer function is rather like an alarm clock. We can set it to go off after a certain amount of time. Whats really handy about this is we can also set it to run continuously which means any code we put inside it will get called every TimerFrequency seconds.

The reason for using Timer() rather than Tick() is to give the mapper some type of control over the amount of cpu strain that scanning the particles may cause.

  • fist a local variable of type pawn is made to store the valid ref of any pawn that the iterator finds when scanning.
  • A local variable of type Int is created to use as a counter in the for next loop that will cycle though the emitted particles currently being scanned.
  • If a valid pawn gets found its valid actor ref is first stored in the variable FoundPawn and then used to set the property bEjectDriver = True which will cause the driver to be ejected.
Simulated Function Timer()
{
 Local Vehicle        foundvec;
 Local Int            Counter;

 for ( Counter=0 ; Counter < Emitters[0].Particles.Length ; Counter++ )
     {
      foreach visiblecollidingActors(Class'vehicle', foundvec , ScanSize , Emitters[ActiveEmitterNumb].Particles[Counter].Location )
              {
              if (foundvec.driver != None)
                 {
                  foundvec.bEjectDriver==true;
                 }
              }
     }
}

Full script

here is the completed script ;-

 /////////////////////////////////////////////////////////////////////
// SFX_Ejecting by VitalOverdose
// Feb 2006.
// Http://Vitaloverdose.zapto.org
///////////////////////////////////////////////////////////////////////

Class SFX_Ejecting extends Trigger
Placeable;

Var () Int                            VecDamage;             // Mapper can set in unrealEd.
Var () Int                            DriverDamage;          // Mapper can set in unrealEd.
Var () float                          EjectSpeedmultiplyer;  // Mapper can set in unrealEd.
Var () sound                          EjectSoundFx;          // Mapper can set in unrealEd.
Var () Sound                          ValidContactSoundFx;   // Mapper can set in unrealEd.
Var () Class< Damagetype >            DriverDamageType;      // Mapper can set in unrealEd.
Var () Class< DamageType >            VecDamageType;         // Mapper can set in unrealEd.
Var () Array< Class< Emitter > >      DriverTagFxPool;       // Mapper can set in unrealEd.
Var () Array< Class< Emitter > >      AmbiantFxPool;         // Mapper can set in unrealEd.
Var () Array< Class< Emitter > >      ValidContactFxPool;    // Mapper can set in unrealEd.

Function PostBeginPlay()
{
if (AmbiantFxPool.length != 0 )
    SpawnFx(self,AmbiantFxPool);
super.postbeginplay;
}

Function Touch( Actor Other)
{
 if ( (Other.IsA('onsVehicle')) && (onsVehicle(Other).Driver != None) )
    {
     if (ValidContactFxPool != none.length > 0)
         spawnFX(self,ValidContactFxPool);

     EjectAndTag( OnsVehicle(Other));
     if (ValidContactSoundFx!=None)
         Playsound(ValidContactSoundFx);
    }
 Super.touch(other)
}

Function EjectAndTag( OnsVehicle Vec )
{
 Local Actor       EjectedDriver;

 Vec.EjectMomentum *= EjectSpeedmultiplyer;
 EjectedDriver      = Vec.Driver;
 Vec.EjectDriver();
 if ( EjectedDriver != None )
    {
     if ( DriverTagFxPool.length != 0)
          spawnfx(EjectedDriver,DriverTagFxPool);

     if ( EjectSoundFx != none )
          Vec.PlaySound( EjectSoundFx );

     if ( DriverDamage > 1)
          EjectedDriver.TakeDamage(DriverDamage , Instigator , EjectedDriver.Location , vect(0,0,10000),DriverDamagetype ) ;

     if ( VecDamage > 1 )
          Vec.TakeDamage(VecDamage , Instigator , vec.Location , vect(0,0,10000),VecDamagetype ) ;
    }
}

function SpawnFx (actor ActorPos,array< class< emitter> > SpawnPool)
{
 Local Emitter           SpawnedTagFX;
 Local int               PickedNumb;
 Local Class< Emitter >  PickedTagFxClass;

 PickedNumb       = Rand(SpawnPool.Length-1)+1;
 PickedTagFxClass = SpawnPool[PickedNumb];
 while (SpawnedTagFx == none)
       {
        SpawnedTagFX     = Spawn(PickedTagFxClass,ActorPos,,ActorPos.Location ,ActorPos.Rotation );
       }
 SpawnedTagFX.setbase(ActorPos);
}

Related Topcs

Custom

Discussion

Category Custom Class

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