Posted: . At: 7:29 PM. This was 5 years ago. Post ID: 12934
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.



Sponsored



Ending a mission properly using scripting in Arma 3.


This very useful code will end a mission when three triggers have been activated and there are no enemies in the trigger area.

adt = createTrigger ["EmptyDetector", Loc];
adt setTriggerArea [1800, 1800, 0, false];
adt setTriggerActivation ["EAST", "NOT PRESENT", false];
adt setTriggerStatements ["this","",""];
 
waitUntil {
	sleep 1;
	((triggeractivated adt) && (triggeractivated tower2) && (triggeractivated man2))
};
 
["ScoreAdded",["Defeated the enemy. Good work boys.",10]] call BIS_fnc_showNotification;
['task3','SUCCEEDED'] call BIS_fnc_taskSetState;

This is another very useful code sample, this detects if a radio tower has been destroyed.

	waitUntil {	
		sleep 3; !(alive targetTower) || damage targetTower > 0.8 || ((getPosATL targetTower) select 2) < 0
	};

or use a trigger to detect the destruction of the tower. This works very well.

tower2 = createTrigger ["EmptyDetector", getPos tower1];
tower2 setTriggerArea [14, 14, 0, true];
tower2 settriggerText "";
tower2 setTriggerActivation ["NONE", "PRESENT", false];
tower2 setTriggerStatements ["!alive tower1","['task1','SUCCEEDED'] call BIS_fnc_taskSetState",""];

Set a random starting time for your mission, put this code into the initServer.sqf file to get a random time.

// Set date and time (between 7am and 4pm)
setdate [2017,ceil random 12,ceil random 28,7 + round(random 9),0];

Another example of useful Arma 3 coding. This expands upon code I posted above, this waits until 3 triggers have been activated and then runs code to clean up an AO and also removes the AO from the targets array.

adt = createTrigger ["EmptyDetector", Loc];
adt setTriggerArea [2800, 2800, 0, false];
adt setTriggerActivation ["EAST", "NOT PRESENT", false];
adt setTriggerStatements ["this","",""];
 
sleep 3;
 
{
	_x addCuratorEditableObjects [allUnits,true];
	_x addCuratorEditableObjects [vehicles,true];
} count allCurators;
 
waitUntil {
	sleep 1;
	((triggeractivated adt) && (triggeractivated tower2) && (triggeractivated man2))
};
 
//["ScoreAdded",["Defeated the enemy. Good work boys.",10]] call BIS_fnc_showNotification;
['task3','SUCCEEDED'] call BIS_fnc_taskSetState;
 
_targetArray = _targetArray - [currentAO];
 
_NewAO = [] call QS_fnc_ending;

Add this code to your mission scripting to run after all the AI have spawned, and everything will be added to Zeus.

{
	_x addCuratorEditableObjects [allUnits,true];
	_x addCuratorEditableObjects [vehicles,true];
} count allCurators;

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.