Page 1 of 1
Spawn delay
Posted: Tue Mar 24, 2015 12:39 pm
by ZoomV
So I have this map I'm working on, but at the beginning of the map I need to spawn a significant number of AI from a rather cramped command post, which leads to a ton of crowding. I am wondering if its possible to string out the spawn so its not spawning so many AI all at once at the beginning of the map.
I noticed the setspawndelay property in the LUA but for the life of me, I can't seem to figure out what it's parameters are and do.
Re: Spawn delay
Posted: Tue Mar 24, 2015 2:05 pm
by jedimoose32
This isn't 100% for sure, but...
http://www.gametoast.com/viewtopic.php?p=511805#p511805
It makes sense given how a lot of other callbacks are set up in this game. Maybe try tweaking the values to (20.0, 0.2) or something like that and see what happens.
Re: Spawn delay
Posted: Tue Mar 24, 2015 3:21 pm
by razac920
I don't know about that function in particular, but there is an easy enough workaround if that doesn't work:
Simply move part of each teams' characters onto local teams (which cannot spawn), and after a timer goes off move them back (so they can spawn).
Re: Spawn delay
Posted: Tue Mar 24, 2015 10:28 pm
by ZoomV
razac920 wrote:I don't know about that function in particular, but there is an easy enough workaround if that doesn't work:
Simply move part of each teams' characters onto local teams (which cannot spawn), and after a timer goes off move them back (so they can spawn).
Can you elaborate?
Re: Spawn delay
Posted: Tue Mar 24, 2015 10:52 pm
by razac920
Sure, start with some code like this:
Code: Select all
local temp = GetTeamSize(1)
for i=1,temp do -- moving all team 1 bots to team 3
local unit = GetTeamMember(1,temp-i)
if unit and not IsCharacterHuman(unit) then
SelectCharacterTeam(unit, 3)
end
end
local temp = GetTeamSize(2)
for i=1,temp do -- moving all team 2 bots to team 4
local unit = GetTeamMember(2,temp-i)
if unit and not IsCharacterHuman(unit) then
SelectCharacterTeam(unit, 4)
end
end
(Assuming teams 3 and 4 have no CPs and cannot spawn). Now just set a timer that moves some bots back, something like this (which moves back 1 bot to each original team each second):
Code: Select all
teamsize = GetTeamSize(3) -- or 4, if they are the same
botspawn = CreateTimer("botspawn")
SetTimerValue(botspawn,1) -- 1 second timer
timercheck = OnTimerElapse(function(timer)
local unit = GetTeamMember(3,0)
if unit then
SelectCharacterTeam(unit,1)
end
unit = GetTeamMember(4,0)
if unit then
SelectCharacterTeam(unit,2)
end
teamsize = teamsize - 1
if teamsize == 0 then
ReleaseTimerElapse(timercheck)
timercheck = nil
DestroyTimer(botspawn)
botspawn = nil
else
SetTimerValue(botspawn,1)
StartTimer(botspawn)
end
end,
botspawn)
StartTimer(botspawn)