OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Vortrog on 18 Oct 2002, 02:25:41
-
I have 9 Resistance units who once they reach a trigger, should join to form a group. (ResLeader, Res1-8). they are currently not grouped and are all individuals.
I was going to just have the activation for the trigger be
[Res1,res2, etc..res8] Join Resleader
Problem is, if the leader dies, how do do select the next living unit to become leader?
There are only 9 resistance unit in the entire map, and these are all playable.
Anyone got a to select the highest ranking unit and make them leader of a group?
-
Well, i can't access ofp at work, so i can't really test out
the stuff now. But i can give ya a hint, how to do that.
You can put all your 9 units into an array
myunits = [unit1,unit2,unit3,etc.]
Then you need to create a loop, instantly checking the first
alive member of the group.
Or you remove a unit from the array, once it got killed.
With removing the units, you can always be sure that the
first unit (myunits select 0) is alive and a potential groupleader.
hope this makes sense to you
~S~ CD
-
What do you guys think of this? Killing an ant with an atom bomb? Any better suggestions?
; use this in the activation feild of the trigger
;[RomeoLeader,Romeo1,Romeo2,Romeo3,Romeo4,Romeo5,Romeo6,Romeo7,Romeo8] exec "leader.sqs"
Script called leader.sqs
; A counter for the units in the array (number of units to check)
_unitr = 0
;Loop to check alive unit to command the new group. myunitr
#alivecheck
_myunitr = _this select _unitr
?(alive _myunitr):goto "leadership"
_unitr = _unitr + 1
?(_unitr == 9):goto "leadership"
goto "alivecheck"
;Makes the relevant _myunit the commander and adds all others to the group
#leadership
_unitr = 0
_joiner = _this select _unitr
[_joiner] join _myunitr
_unitr= _unitr + 1
?(_unitr == 9):goto "Exit"
goto "leadership"
#Exit
exit
I havent Checked it yet, but I reckon it should work.
Ill come back
Vortrog
-
One thing;
in the section: #leadership, you don't need to reset your
counter (_unitr = 0). You will even need to increase the
counter for 1, so that you don't get this as result:
[RomeoLeader] join RomeoLeader
This happens in your actual script.
Just do it this way:
;Makes the relevant _myunit the commander and adds all others to the group
#leadership
_unitr= _unitr + 1
?(_unitr == 9):goto "Exit"
_joiner = _this select _unitr
[_joiner] join _myunitr
goto "leadership"
~S~ CD