Jump to content

MIST respawn groups with tags in their group name


Recommended Posts

Hi. I just started mission building and learning MIST. I recently learned how to use respawnGroup for AI upon group death. But i was wondering, instead of creating a trigger for every unit I'd like to respawn, can I make it so that only 1 trigger handles respawning groups with a tag in their group name (for example RESPAWN_Transport1)?

Link to comment
Share on other sites

The best way is to create a script that handles it.

 

At its simplest you can use something like the following on a trigger that will continuously execute:

 


local prefix = 'RESPAWN'
for groupName, data in pairs(mist.DBs.groupsByName) do
	if string.find(groupName, prefix) then
		if (Group.getByName(groupName) and Group.getByName(groupName):isExist() == false) or (Group.getByName(groupName) and #Group.getByName(groupName):getUnits() < 1) or not Group.getByName(groupName) then
			mist.respawnGroup(groupName)
		end
	end	
end

 

What this does is it iterates through the table mist.DBs.groupsByName and then uses string.find to see if the group's name contains the word 'RESPAWN'. If it does then it will do another check to see if every unit in the group is dead. There are 3 conditions that it checks with any of them being true results in running the script to respawn the group.

 

There are other ways to do it, I just whipped that up in about a minute, mostly copied from other code. :)

The right man in the wrong place makes all the difference in the world.

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...