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.
Spawn delay
Moderator: Moderators
-
ZoomV
- Rebel Warrant Officer

- Posts: 308
- Joined: Thu Aug 15, 2013 11:27 am
- Projects :: Old Republic Map pack
- xbox live or psn: No gamertag set
- Location: Belsavis, Maximum Security Ward
-
jedimoose32
- Field Commander

- Posts: 938
- Joined: Thu Jan 24, 2008 12:41 am
- Projects :: Engineering Degree
- Location: The Flatlands of Canada
Re: Spawn delay
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.
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.
-
razac920
- 2nd Lieutenant

- Posts: 365
- Joined: Sun Jan 16, 2011 12:42 am
Re: Spawn delay
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).
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).
-
ZoomV
- Rebel Warrant Officer

- Posts: 308
- Joined: Thu Aug 15, 2013 11:27 am
- Projects :: Old Republic Map pack
- xbox live or psn: No gamertag set
- Location: Belsavis, Maximum Security Ward
Re: Spawn delay
Can you elaborate?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).
-
razac920
- 2nd Lieutenant

- Posts: 365
- Joined: Sun Jan 16, 2011 12:42 am
Re: Spawn delay
Sure, start with some code like this:
(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
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
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)
