Flying spawnpoint example

If you liked this item, please rate it up on Steam Workshop page.

Author: Hijong park

Last revision: 31 May, 2022 at 12:43 UTC

File size: 3.16 MB

On Steam Workshop

Description:

This is a lazy proof-of-concept vehicle that turns airplane into a moving spawnpoint.

select TRANSPORT PLANE in the vehicle slot and start the game.

when you or the bot is driving TRANSPORT PLANE, some soldiers will be spawned from the plane as Airborne Troopers.

You are also spawned from the plane, if you don’t want that, simply add ‘actor.isBot’ if statement at line 19.

behaviour("vehiclespawnpoint")
function vehiclespawnpoint:Start()
self.vehicle = self.gameObject.GetComponent(Vehicle)
GameEvents.onActorSpawn.AddListener(self, "OnActorSpawn")
self.spawn=0
self.maxspawn=8
end

function vehiclespawnpoint:Update()
if self.spawn>0 then
self.spawn=self.spawn-Time.deltaTime*2
if self.spawn<0 then
self.spawn=0
end
end
end

function vehiclespawnpoint:OnActorSpawn(actor)
if not self.vehicle.isDead and not self.vehicle.isBurning and self.vehicle.altitude>15 and self.vehicle.hasDriver and actor.team==self.vehicle.driver.team and self.spawn<self.maxspawn then
local nodes=false

for i=1,#ActorManager.capturePoints do
if nodes==false and Vector3.distance(Vector3(self.vehicle.transform.position.x,0,self.vehicle.transform.position.z),Vector3(ActorManager.capturePoints.transform.position.x,0,ActorManager.capturePoints.transform.position.z))<300 then
nodes=true
end
end

if nodes==true then
self.spawn=self.spawn+1
actor.TeleportTo(self.targets.spawnpoint.transform.position,self.targets.spawnpoint.transform.rotation)

if actor.isBot then
local sqds={actor}
Squad.Create(sqds)
local atkpoint=1
for i = 2, #ActorManager.capturePoints do
if Vector3.Distance(self.vehicle.transform.position,ActorManager.capturePoints.transform.position) < Vector3.Distance(self.vehicle.transform.position,ActorManager.capturePoints[atkpoint].transform.position) then
atkpoint = i
end
end
actor.squad.AssignOrder(Order.Create(OrderType.Attack, ActorManager.capturePoints[atkpoint], ActorManager.capturePoints[atkpoint]))
end

end
end
end