Coding Tip #4
Here’s another oldy but goody from Jands/Lude that used to be situated on their Herocity site.
Creating a Timed Spawn
I will be brief about the work in the editor but on a map create a new positional (i.e. positional_001).
In the script you will need to call the routine for the first time and define the spawn number:
def OnPostInit():
Mission_SetAttr('thug_number', 0)
regTimer('begin_spawn', 30)
Then you will need to create the spawning routine:
def begin_spawn(event):
thug_count = Mission_GetAttr('thug_number') + 1
type = 'thug'
name = '%s_%d'%(type,thug_count)
Object_Spawn(name, 'thug_with_bat', 'positional_001')
moveTo(name, getNearestHero(name))
Mission_SetAttr('thug_number', thug_count)
regTimer('begin_spawn', 30)
This routine generates an originally named thug with bat (thug_1, thug_2, etc.) at positional_001. It will generate one every 30 seconds and the thug will move towards the nearest hero.
And that’s the tip of today courtesy of the Herocity crew. Enjoy.