Legacy:VitalOverdose/QuickVehicleSpawner
Overview
I made this actor mainly for testing vehicles on DeathMatch levels but I've now added some code to be able to use it in Onslaught Levels.Its subclassed from Triggers because it was far less complicated than trying to modify a normal VehicleFactory just to do a simple spawning task.
Properties
- You can make a list of vehicles to spawn.
- If used in an ONS level the QuickVehicleFactory will work independent of what ONSPowerNodes are controlled.
- It take its team from the nearest power core;
- Spawns vehicles as they are destroyed.
TheScript
<Uscript>
//-----------------------------------------------------------
// QuickVehicleFactory - Easy To use alternative vehicle factory
// By VitalOverdose http://www.vitaloverdose.com
// updated oct 2007
//-----------------------------------------------------------
class QuickVehicleFactory extends Triggers
placeable;
var vehicle SpawnedVehicle;
var() float spawndelay; // float variable for the spawn Delay
var() byte TeamNumber;
var() bool bLoopList;
var() array< class<Vehicle> > VehicleClassList; // Vehicle to Be spawned
var array< class<Vehicle> > CurrentList; // Vehicle to Be spawned
//generic function : overwriting : added simulated
// set bAllowVehicles to true
// or search for the nearest powercore
simulated function PostBeginPlay()
{
if (!Level.Game.bAllowVehicles)
Level.Game.bAllowVehicles = True;// changes the bAllowVehicles value
CurrentList = VehicleClassList;
settimer(spawndelay,false);
super.postbeginplay(); // copy's any function related code from parent class
}
//Generic Event : overwriting
//Code has been added here to spawn a vehicle if this actor is triggered
event Trigger(Actor Other,Pawn EventInstigator)
{
settimer(spawndelay,false); // activates timer to run 1 time in (spawndelay) seconds super.Trigger(other,EventInstigator); // copy's any function related code from parent class
}
//custom function
// this function uses an iterator to search the level for onspowercores
// it then uses VSize() to work out which one is closest and then assigns the
// team number of that core to any vehicles that it spawns
simulated function findClosetCore()
{
local float closest;
local ONSPowercore FoundONSPowerCore;
closest = 100000;
foreach DynamicActors(Class'ONSPowerCore', FoundONSPowerCore) // { if ((FoundONSPowerCore.IsA('onspowercoreBlue')) || (FoundONSPowerCore.IsA('onspowercorered'))) if ( Vsize(FoundONSPowerCore.location - location) < closest) { TeamNumber = FoundONSPowerCore.DefenderTeamIndex; closest = Vsize(FoundONSPowerCore.location - location); log ("closest powercore was "$FoundONSPowerCore$" and team number :"$TeamNumber); } } }
//custom function
// here the vehicle is spawned and the class is subtracted from the current list
simulated function spwnvec()
{
local class<vehicle> spawnvecclass; // Vehicle to Be spawned
spawnvecclass = CurrentList[0]; SpawnedVehicle = spawn(spawnvecclass,self,,location,rotation); // spawn Vehicle & store Ref in SpawnedVehicle SpawnedVehicle.Team=TeamNumber; CurrentList.Remove(0,1);
}
//generic function : overwriting
// this event is called when the spawed vehicle has been destroyed
event LostChild( Actor Other )
{
settimer(spawndelay,false);
}
// Generic function : overwriting
// the timer is used to set a delay for the spawning.
// if there are no more vehicles to spawn and bloop is set to true then the currentList is // repopulated from the original VehicleClassList
simulated function timer()
{
if (CurrentList.length > 0) spwnvec(); else if (bLoopList) { CurrentList = VehicleClassList; spwnvec(); }
super.timer();
}
</uscript>
Download
This script can be downloaded in .uc or .u format:QuickVehicleFactory.uc,mylevel.u.