Jump to content
Sign in to follow this  
SSgt Schirf

Script to Select Sleeper Unit

Recommended Posts

Hello!

I am designing a mission based off an airsoft game mode we used to play.

The mission has 2-5 BluFor survivors (survivor_1 through _5) being hunted by one OpFor Hunter (hunter).

However, to add some complexity, I wanted one of the survivors to be a sleeper unit. At five minutes into gameplay, the sleeper would receive orders to kill the remaining survivors. I believe I have done this in the script below.

What I really need is a double check of my script before I implement it. I am 80% sure that this has some error in it (be it syntax or logic).

Can somebody please double check my code?

// Created for ArmA 3 - Operation Deathlord
// Script by: FoxRazgriz

// Runs five minutes after the game starts,
// selects a player at random to be the sleeper,
// gives them an objective to betray the others,
// and displays that on their screen for the entire match.

// Runs five minutes after the game starts (called in init.sqf)
sleep 300;

// Selects a player at random ***from the remaining BluFor players*** to be the sleeper

// Option 1:
// sleeper = playableUnits select floor(random count playableUnits);
// Option 2:
sleeper = {alive _x && side _x == WEST} select floor(random count thisList);

// Gives them an objective to betray the others.
[sleeper, "tsk_sleeper", ["You are the traitor in your group!\n\nBetray the others in any manner you see fit.","Betray the Others",""], objNull, true] call BIS_fnc_taskCreate;

// And displays that on their screen (???for the entire match???)
// grp_Ind is the name of the Ind group, initialized in the init field of an AAF unit
// that is not present in mission
sleeper join grp_Ind;
sleeper groupChat "I am the traitor now. All BluFor survivors must die!";

// Lets the game know the sleeper is active so the trigger can be tripped
// "activeSleeper" is a variable in init.sqf that is False until
// the end of this script. It is used in an in-game trigger
// to tell if the sleeper has killed everyone.
activeSleeper = true;

// The trigger may not be necessary if this code works:

while {true} do {

_remainingBluFor = {alive _x && side _x == WEST} count allUnits;

if (_remainingBluFor == 0) then {
	["tsk_sleeper","SUCCEEDED"] call BIS_fnc_taskSetState;
}; // end if statement

}; // end while statement

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  

×