mrSkortch/MissionScriptingTools

getLeadPos returns a nil value in some rare cases

Closed this issue · 1 comments

The getLeadPos does some error-checking to make sure that the group lead exists. If a group lead doesn't exist, the function returns a nil value and functions like groupToRandomPoint will fail.

For some reason, getUnits of a DCSGroup instance might in some rare cases return a list of units that are actually "non-existing"/destroyed, which will make groupToRandomPoint throw an error. This happened very frequently when group units were killed off (so the list of group units should be empty) in my mission until I figured out I have to double-check that the group actually has existing units before calling groupToRandomZone.

I suggest to add a condition to functions invoking getLeadPos to check the returned value.

Should be fixed in build 76.