Hello
I downloaded angusjm's excellent respawn script again today from the Editors Depot after a long time out of OFP..
When angusjm first made the script, I had him modify it for me, but these modifications haven't made it into the one he uploaded to OFPEC, so I was hoping some of you guys could help me.
The script works this way:
; Call this script using the following syntax:
;
; [1,unit to converge around,array of groups,units per group,type of unit,skill of units,radius around unit to converge around,body disapear on or off (1 on, 0 off)]
;
; The AI will be created of a random one of the type specified and will head towards the unit to converge around
;
;Example [1,player,[east1,east2],12,["SoldierEB","SoldierEMG"],0.1,50,1] exec "ajmrespawn.sqs"
In short order, the script creates a number of soldiers randomly in a 360 degree area around the "target". Radius, number of soldiers and type of soldiers can be defined in the syntax.
Now, what I want is for me to be able to define how many degrees around the target that the soldiers are spawned/respawned. When angusjm did this for me back in the days, he made it work like this:
- An extra number was added into the syntax, a number that could be between 0 and 360 (degrees) and defined by the mission maker
- The target's heading was returned to the script (azimuth)
- The spawned units would spawn in an area relative to the heading of the target
...this meaning that if the mission maker defined the new number in the array to, say, 10, and the targets azimuth was 0, the enemy units would spawn between -5 and 5 (of the target's azimuth). You could say that the number defined in the array was split in two over the target's azimuth (so if you wrote 360 in the array, enemy units would spawn 180 degrees on either side of the target's 0 azimuth, resulting in it being surrounded).
It's hard to explain, but I hope you get it. Here is the script, I really hope you can do something with it - it's really cool for defend/chase type mission:
_wtd = _this select 0
_aUnit = _this select 1
? _wtd == 0: goto "missemall"
_agroups = _this select 2
_apg = _this select 3
_askill = _this select 5
_aradius = _this select 6
_thon = _this select 7
_list=_this select 4;
_ntotal=count _list;
_c = 0
#loop
#gloop
_rg = count units (_agroups select _c)
? _rg >= _apg : goto "misscreate"
_rg = _apg - _rg
#iloop
_rnum = random ((360))
_num = _rnum - (_rnum mod 1)
_d1 = getpos _aunit select 0
_d2 = getpos _aunit select 1
_d3 = 0
_random=random(_ntotal);
_result=_random - ((_random) mod (1));
if (_result==_ntotal) then {_result=_result-1};
_utype = (_list select _result);
_d1 = _d1 + _aradius * sin(_rnum)
_d2 = _d2 + _aradius * cos(_rnum)
_utype createunit [[_d1,_d2,_d3],_agroups select _c,"",_askill,"PRIVATE"]
? _thon == 1 : {_x addeventhandler [{killed},{[0,_this] exec {AJMRespawn.sqs}}]} foreach units (_agroups select _c)
_agroups select _c move getpos _aunit
leader (_agroups select _c) move getpos _aunit
_rg = _rg - 1
? _rg == 0 : goto "misscreate"
goto "iloop"
#misscreate
_c = _c + 1
? _c == count _agroups : _c = 0; goto "eloop"
goto "gloop"
#eloop
~0.5
goto "loop"
#missemall
~5
deletevehicle (_aunit select 0)
Cheers,
Viking