OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: GavinP on 17 Aug 2006, 20:14:59

Title: What happens when...
Post by: GavinP on 17 Aug 2006, 20:14:59
I've got a playable unit of twelve soldiers all grouped in the editor. The leader has gr1=group this in his init field. What happens when the role isn't taken and AI is switched off? Does the group continue to be known as gr1?

This is rather critical as I want to use Grouplink2 on the mission, but its doubtful my team will have a full 12 on so the officer role will probably not be taken.
Title: Re: What happens when...
Post by: nominesine on 18 Aug 2006, 12:52:20
Yes, all members of the group are still labeled gr1. It doesn't matter wether they are under AI or human control.
Title: Re: What happens when...
Post by: myke13021 on 18 Aug 2006, 19:07:24
maybe the use of

Code: [Select]
gr1 = group player

in the init.sqs would be a sure way to name the group. imo the server client/client issue wouldn't affect the problem as "player" is always local since all playable units are in the same group.

@nominesine
i think he liked to know if the gr1 = group this in the group leaders init line also takes effect if AI is off and none taken the part of the group leader, therefore the group leader unit isn't present ingame
Title: Re: What happens when...
Post by: GavinP on 18 Aug 2006, 19:09:22
Thanks guys. Yes, Myke, I did want to know if the group would be called gr1 even if the officer wasn't used in the game, regardless of AI or not.

I'll test out your idea of player.
Title: Re: What happens when...
Post by: Garcia on 18 Aug 2006, 23:07:49
maybe the use of

Code: [Select]
gr1 = group player

in the init.sqs would be a sure way to name the group. imo the server client/client issue wouldn't affect the problem as "player" is always local since all playable units are in the same group.

@nominesine
i think he liked to know if the gr1 = group this in the group leaders init line also takes effect if AI is off and none taken the part of the group leader, therefore the group leader unit isn't present ingame

Wouldn't recommend that. If this was used in a mission with several playable groups (which this apparently isn't though) the different clients would maybe end up having different groups labeled with 'grp1'. Though, what goes for this mission, it's still not a good solution. If the mission is played on a dedicated server, the server won't have any group labeled as 'grp1', which probably will cause problems.

I'd suggest you place a group, write 'grp1 = group this' in the leaders init field, start the mission as a multiplayer mission, disable all AI, choose someone else than the leader. Then, in a trigger or a script (i.e, in the init.sqs, after a small delay) write this:

Code: [Select]
hint format ["%1",leader grp1
if the hint comes back with you, the group is still labeled as 'grp1'. If it comes back with some scalar bool array fla fla fla error, it's not. If the latter, I suggest adding 'grp1 = group this' to all units in the group.
Title: Re: What happens when...
Post by: GavinP on 19 Aug 2006, 01:11:30
Thanks. I understand what you are getting at there. I was trying to figure out a way of debugging.
Title: Re: What happens when...
Post by: nominesine on 21 Aug 2006, 12:55:35
Put gr1=group this in all init fields. Then it doesn't matter wich unit's are selected and wich unit's aren't selected. The actual leader of the group will then be recognized as leader gr1

The command Leader has it's downsides though. Read this (http://www.ofpec.com/forum/index.php?topic=22956.msg154030#msg154030).
Title: Re: What happens when...
Post by: Garcia on 21 Aug 2006, 22:47:52
uh...I've used the leader command in multiplayer without problems. It always changes to the new leader. I once had a script running for several groups, placing a marker at the leaders position, to see how they behaved, and when the leader(s) were killed, the marker always changed to the new leader.
Title: Re: What happens when...
Post by: Mr.Peanut on 22 Aug 2006, 19:46:15
I have found the leader command to not be robust in MP.  It may work most of the time, but it does not work all of the time.  Especially if there is a mix of AI and players in a group.
Title: Re: What happens when...
Post by: GavinP on 23 Aug 2006, 20:42:17
Cheers guys, you always learn more than the original "want" here, and that makes things so much better.
Title: Re: What happens when...
Post by: Garcia on 24 Aug 2006, 20:15:31
Cheers guys, you always learn more than the original "want" here, and that makes things so much better.

Good to hear ;) Usually nowdays people just get a "why the **** did you not answer earlier?" or something like that when trying to help :confused:
Title: Re: What happens when...
Post by: Chris Death on 29 Aug 2006, 00:56:50
OK, just to complete the answer on the primary question in this thread:

NO, if a unit isn't choosen and AI is switched off, also the code in it's init field disappears.

Possible solutions are:

What nomesine already suggested: put it into each unit's init field

or: create a trigger covering the whole group - activation: side of the group/present/once

condition: this
onActivation: gr1 = group thislist select 0

Another way is also:

name each individual of the group like: g1,g2,g2...g12
and in init.sqs you could do following:

grp_array = []
"if (alive _x) then {grp_array = grp_array + [_x]}" foreach [g1,g2,g3,g4,g5,g6,g7,g8,g9,g10,g11,g12]
gr1 = group grp_array select 0

Off course there are way more methods to do that and i don't want sit on your head to take this or that, but
the 3 i mentioned work for sure and you should take the one which you most prefer.  :)

~S~ CD