Home   Help Search Login Register  

Author Topic: Units join group  (Read 1148 times)

0 Members and 1 Guest are viewing this topic.

Offline Vortrog

  • Members
  • *
  • Ski'in, Fish'in, Shoot'in, OFP'in
    • Vortrog's Lair
Units join group
« 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?

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Units join group
« Reply #1 on: 18 Oct 2002, 02:36:48 »
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
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline Vortrog

  • Members
  • *
  • Ski'in, Fish'in, Shoot'in, OFP'in
    • Vortrog's Lair
Re:Units join group
« Reply #2 on: 18 Oct 2002, 07:27:00 »
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

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Units join group
« Reply #3 on: 18 Oct 2002, 07:46:21 »
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:

Code: [Select]
[RomeoLeader] join RomeoLeader
This happens in your actual script.

Just do it this way:

Code: [Select]
;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
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted