Difference between revisions of "MIST respawnInZone"

From DCS World Wiki - Hoggitworld.com
 
Line 101: Line 101:
 
   end
 
   end
 
</code>
 
</code>
 +
The following would offset the first waypoint and would keep any of the tasks assigned to that group.
 +
 +
  mist.respawnInZone('groupName', 'zone', nil, 4000, {offsetWP1 = true, initTasks = true})
 
|notes= As of mist 3.3 this function supports the use of static objects.
 
|notes= As of mist 3.3 this function supports the use of static objects.
  

Latest revision as of 04:43, 10 February 2022


mist.respawnInZone

Added with: Mist 3.0
Description
Respawns a group of the name groupName to a randomized point within a trigger zone.
Syntax
string mist.respawnInZone(string groupName ,string/table zoneName/tableOfZoneNames , boolean disperse ,number radius ,table vars )
Valid Input Values:
groupName= name of the group that is to respawn inside a zone

zoneName= Name of the zone as placed in the editor to that the group will randomly spawn inside of.

or

tableOfZoneNames= If numerous zone names are given, a single zone will be chosen at random for the group to spawn inside of.

disperse= if this variable is present each unit of the group will be randomly dispersed in the zone. If not present, the group will remain in its default formation

radius= if this variable is present in addition to disperse, this radius will specify the maximum distance each unit will be from the first unit of the group.


vars tables have the following recognized fields( required entries in blue, optional in green):

 vars = 
 {
 
 anyTerrain = boolean anyTerrain, 
 validTerrain = table validTerrain, 
 offsetRoute = boolean offsetRoute, 
 offsetWP1 = boolean offsetWP1, 
 initTasks = boolean initTasks,
 }


anyTerrain is an optional variable that if present will define any terrain type as valid.

validTerrain is an optional variable used to define specific terrain types you may wish to spawn objects over. Useful for spawning ground units on a runway or in water because by default these options are disabled.

offsetRoute is an optional variable that if present will offset the entire route of the group from the groups original position. Note all task information is kept. For example if used on a ship the assigned shape of the route will be kept, it will simply be offset to the new spawn point.

offsetWP1 is an optional variable that if present will offset the first waypoint of the route of the group from the groups original position. Note all task information is kept. For example if used on a ship, the original route will be kept, but the first waypoint will be in the new location. .

initTasks is an optional variable that will keep the tasks assigned at WP1, but will erase every other waypoint.

Return value:
string
Return example:
string of group's name
Usage Examples:
The following code will respawn a group randomly in a zone once it is has died.

 if (Group.getByName('groupName') and Group.getByName('groupName'):getSize() < 1) or not Group.getByName('groupName') then
   mist.respawnInZone('groupName', 'myZone', true, 500)
 end

The following would offset the first waypoint and would keep any of the tasks assigned to that group.

  mist.respawnInZone('groupName', 'zone', nil, 4000, {offsetWP1 = true, initTasks = true})
Notes:
As of mist 3.3 this function supports the use of static objects.

This function limits where groups of certain types can spawn. Ground groups can only spawn on the ground and roads. Ships can only spawn on water. And aircraft can be spawned anywhere. Note that for ground groups any part of the airbase like the runway, ramp, or taxiway is not a valid spawning location. This is done so ground units won't accidentally block AI aircraft paths when at an airbase.

Related Functions
dynAdd, dynAddStatic, groupTableCheck, getNextUnitId, getNextGroupId, respawnGroup, respawnInZone, cloneGroup, cloneInZone, teleportGroup, teleportInZone, teleportToPoint, spawnRandomizedGroup

Scripting Engine

MIST Root Page