OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: shadow99 on 13 Jul 2004, 05:52:26

Title: Changing Group Leaders
Post by: shadow99 on 13 Jul 2004, 05:52:26
Okay, I'm building a mission where you ambush a convoy of BMPs, but your leader temporarily turns over the mission to you whilst this is happening because it's your specialty as an explosives expert.

So, I need the group leader to turn to you, temporarily.

Don't worry about if the group's still all alive, the leader has 'setCaptive' attached to him.
Title: Re:Changing Group Leaders
Post by: m21man on 13 Jul 2004, 06:48:25
Code: [Select]
_leader = leader (group player)
_units = units (group _leader)

_units join grpnull
_units = _units - [player]
_group = group player
_units join _group
exit

Not guaranteed :P .
Title: Re:Changing Group Leaders
Post by: shadow99 on 13 Jul 2004, 09:00:54
Being a n00b, what bits to I fill in? Just (player) and (group_leader)?
Title: Re:Changing Group Leaders
Post by: m21man on 13 Jul 2004, 15:10:23
No editing should be necessary. Just try executing the script.
Title: Re:Changing Group Leaders
Post by: shadow99 on 14 Jul 2004, 07:10:23
No dice. The leader says
"All follow 1!" (Himself)
"1, Ready!"
Title: Re:Changing Group Leaders
Post by: shadow99 on 15 Jul 2004, 04:36:27
Bump
Title: Re:Changing Group Leaders
Post by: macguba on 15 Jul 2004, 12:16:50
Have you tried playing with the brackets?
Title: Re:Changing Group Leaders
Post by: THobson on 15 Jul 2004, 16:25:14
Nowhere in the script is the original leader removed from _units

Try

_units = _units - [_leader,player]

instead of

_units = _units - [player]

Title: Re:Changing Group Leaders
Post by: macguba on 15 Jul 2004, 17:05:28
Well that will mean that the original leader does not rejoin the group as an ordinary member.    

_units join grpNull

effectively means that the original group ceases to exist, which might create a waypoint problem.    

My theory is that it doesn't work because there aren't enough square brackets [ ].
Title: Re:Changing Group Leaders
Post by: THobson on 15 Jul 2004, 19:23:10
Sorry.  I misunderstood.  I thought the intention was for the origional leader to not be in the goup until after the action.

Would the waypoint problem be solved if:

_units = _units - [player]

came before

_units join grpnull
 
and not after
Title: Re:Changing Group Leaders
Post by: shadow99 on 16 Jul 2004, 13:53:45
Uh... so what's the full script?

 :-\

Sorry, but I'm terrible with all this. Thanks for the help, though.
Title: Re:Changing Group Leaders
Post by: THobson on 16 Jul 2004, 14:23:59
I have not tested it but try M21man's script except put the line:

_units = _units - [player]


before

_units join grpnull


I might get chance to look at this tonight
Title: Re:Changing Group Leaders
Post by: THobson on 16 Jul 2004, 14:46:13
If that doesn't work try:

_leader = leader (group player)
_units = units (group _leader)

_units = _units - [player]
_units join grpnull
_units join player
exit

Again - not tested.
Title: Re:Changing Group Leaders
Post by: THobson on 16 Jul 2004, 19:22:45
OK.  I have tested the code in my post above and it seems to work.

Thanks to M21Man.  I just made a minor tweak to his code.
Title: Re:Changing Group Leaders
Post by: THobson on 16 Jul 2004, 19:32:31
An update:  To change the leader to anyone you wish in the group, save the following as ChangeLeader.sqs


Code: [Select]
_newleader = _this select 0

_leader = leader (group _newleader)
_units = units (group _leader)

_units = _units - [_newleader]
_units join grpnull
_units join _newleader
exit

And then call:

[unitname] exec"ChangeLeader.sqs"

and this will change the leader to unitname.  It doesn't have to be you and it doesn't screw up the waypoints.  Though you will have to be careful of the waypoints if you become the leader.