Jump to content
Sign in to follow this  
Undeceived

How to make the player turn to number 1 in group

Recommended Posts

(Solved - check this post)

Hi guys, can you help me with that?

In the beginning of the mission, the player is number 5 in the group (lead by AI). The group leader is number 1. The unit was created "manually" in the editor via F2-connecting of the units to the leader.

Later I want the player to become the leader and also the number 1 in the group. But no matter what I do, I couldn't get this working... The player's unit will stay as number 5. All other units (1-7) join him, but he stays 5.

So what do I need to do to turn the player to the new number 1 and the former leader to number 2, followed by the former number 2 who becomes 3, etc...?

I tried this:

[player] join grpNull;

sleep 0.5;

[player] joinsilent player;
player = leader group player;

player setrank "COLONEL";
dudeone setrank "MAJOR";
dudetwo setrank "CAPTAIN";
dudethree setrank "LIEUTENANT";
dudefour setrank "SERGEANT";
dudesix setrank "CORPORAL";
dudeseven setrank "PRIVATE";

[all dudes] join grpNull;

sleep 0.5;

[all dudes] join player;

The problem is that the player's unit, when I throw him into grpNull, stays as number 5, even being the leader of the newly created group (group leader). How can he be set to be number 1? :) That's the question I have. :D

Thanks for your help!

Edited by Undeceived

Share this post


Link to post
Share on other sites

With this command I don't need most of the code stuff from my first post to set the player as leader.

But unfortunately he still remains number 5 in the group whereas he (as new leader) should become number 1. :(

EDIT:

I added a small mission to the first post which shows the problem. I also used the command you suggested (selectleader). But still no success.

Edited by Undeceived

Share this post


Link to post
Share on other sites

Okay, now i get the problem... i think the only way to solve this seems to play around with the rank of the joining unit. Can`t find a scripting command to make the player the new formation leader.

=/

Share this post


Link to post
Share on other sites

I've tested this with a group created in editor and put this in one of the lower soldiers' init field:

grp = group this;
[this] join grpNull;
ld = leader grp;
[ld] join grpNull;
this joinAs [grp, 1];
grp selectLeader this;
[ld] join grp;

Your soldier and the group leader are removed from the group, your soldier then joins as 1 and is selected as leader.

After this just let the leader join again, he'll be at your old place.

Share this post


Link to post
Share on other sites

Ah right - joinAs did the trick. :) Thanks, DaysShadow. I wasn't aware of this command!

I changed your code a bit so that it runs from a trigger too:

Group created in editor

"officer" is the AI leader (number 1) at the beginning

Player is number 2, 3 or whatever.

When the player has to take command, run from the trigger:

[player] join grpNull; 
grp = group player; 
[officer] join grpNull; 
player joinAs [grp, 1]; 
grp selectleader player; 
[officer and other possible soldiers] join grp;

Thanks again! :)

Edited by Undeceived

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×