Jump to content
Sign in to follow this  
mad_cheese

Teamswitch -> AI command disable?

Recommended Posts

Hi there, i've been searching for days ...

It should be an easy question though.

In a mission containing multiple playable characters, if I switch away from the teamleader and he turns AI, he starts giving commands to his unit. while this is nice, sometimes i'd like the choice to turn that off. If you have played the early versions of ghost recon you will have an idea what i want to archive. if you switched to another unit, the last one played will just hold it's position/stance and also keep it's field of view.

The mission I am working on requires some good squad movement and as soon as I'm not playing the teamleader, I have to revive the others every 5 m because the ai ordered them to embrace that open ground and die.

i guess i'm stuck in one direction missing something obvious. i'm out of things to type into search windows...

if i still messed up searching, i am fine with a link and will be eternally ashamed of myself.

thanks a lot!!

Share this post


Link to post
Share on other sites

try this for Single Player missions:

save this in a text file as leader.sqf or better use arma edit.

Place it in your mission folder.

leader.sqf

while {true} do {
if ( player == (leader (group player)) ) then {
	waitUntil {(leader (group player)) != player};
	sleep 1;
	waitUntil {alive player};
	(group player) selectLeader player;
};
};

Now type this in any units initline in editor:

_null = [] execVM "leader.sqf"

This will check if you are leader of your group, then wait until you are not leader of the group, then check and wait until player is alive, then make you leader of your group and repeat as long as the mission is running.

selectLeader is used and you can search up more of the commands on same page if you are interested in more details.

Edited by Demonized
fixed missing ) and = in script

Share this post


Link to post
Share on other sites

thanks for your answer demonized! unfortunately i could not get it to work.

first off: it's a universal script right? no need for unitnames etc. (i tried and it didnt work either but noob-me figures that it's not needed for this one)

to eliminate a misunderstanding: using your script, say unit1 would be the leader and if the player switches to unit2, after one second unit2 is the leader and the same thing will happen with every unit i switch to, correct? so everytime i switch i should hear something like "2, i'm the new actual"?

i checked the script with squint and it told me i can't start lines like this and that, but i couldn't figure it out. :(

anyways, i feel like it's close! i hope it can be fixed as i would use this is most missions i make. :yay:

Share this post


Link to post
Share on other sites

I used something like this.

Allways leading.

While {true} do {
WaitUntil {leader (group player) != player};
WaitUntil {alive player};
(group player) selectLeader player;
};

Only need to start this once.

Share this post


Link to post
Share on other sites

i fixed some errors in my first post, but Coyotas way seems much better, as it is a few lines less :)

Both work same way, and in Single Player missions, player is always the player unit, no matter if you teamswitch or whatnot.

Youre asumption of how it would work is correct.

Share this post


Link to post
Share on other sites

woop! guys, big thanks both of you.

there's a small beauty mistake in the shorter script:

if you are unit1 out of your team and you get heavily injured you get a repeated radio com that (x) is the new actual until. further it happens if 1 is dead and unit2 gets injured.

in the new demonized version it happens too but goes away after the first or second time.

however, i love it!

Share this post


Link to post
Share on other sites

hehe..

carlgustaffa is right, onteamswitch works. i found this forum link

http://forums.bistudio.com/showthread.php?t=86660

and it contains this code that one can use in the init- or leader.sqf:

onTeamSwitch ( {_group = group _from; _group selectLeader _to;} );

-> my favorite one.

the downside to this one is that -if i'm not wrong- a former leader will claim back his lead until you switch again (it happens once you get injured and then heal that soldier with another unit. i think it's the former leader, but at least someone snatches the command until you switch again. )

all these work great and i think this also upgraded my scripting skills from very basic to basic. not to mention the searching... i can't believe in all that time i didn't search the biki for "leader".

really appreciate the help!

Share this post


Link to post
Share on other sites

Someone here (whose name escapes me, alas) came up with this:

Place this...

onTeamSwitch {group player selectLeader player};

...in a trigger, set to repeatedly, Anybody present, and covering an area more than large enough to cover the whole playing area. Works a treat.

Share this post


Link to post
Share on other sites

In the multiplayer setup you can chose the role you want to play and additionally you can deactivate the AI of your own person. Doesn't this have the desired effect?

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  

×