OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: nominesine on 03 Nov 2010, 23:18:28
-
How do I detect if a player refuses to accept a secOp mission, or ignores the request until the mission is cancelled? Í'd like to trigger a script if the player turns down or fails three secOps missions from the SOMmodule.
BI Developer DNA gave the following clue on a similar matter over at the official forums, but I fail to understand what he means. Any help?
You can do this by checking the SOM's history, stored in its main variable scope:
private ["_mainScope", "_history"];
_mainScope = player getVariable "mainScope";
_history = _mainScope getVariable "history"; //[# completed, # failed]
EDIT: Made some clarifications in my own post.
-
What is a sample output of the history?
-
I don't know, since I am unable to understand what the quoted code is supposed to do :scratch:
-
Just turn it into a mini-script and run the return of _history as a str-hint:
private ["_mainScope", "_history"];
_mainScope = player getVariable "mainScope";
_history = _mainScope getVariable "history";
hint str (_history);
mainScope is clearly...something or other. Maybe the SOM module synched to the player? Which in turn has a variable called 'history' attached to it, which apparently contains the information you need :) Clearly BIS uses this themselves as they 'reward' the player in the Combat "My Mission"-missions for successfully completing SOM missions.
Wolfrug out.
-
Yup. BI saves a lot to the player entity.
I think normally they use BIS_mainScope though.
You can easily check their sqf and FSM after all. :)
-
According to missions\som\data\fsms\secopmanager.fsm (see "Init") the history is an array consisting of two numbers: the number of completed missions and the number of failed missions. Ergo...
private ["_mainScope", "_numberOfFailedMissions"];
_mainScope = player getVariable "mainScope";
_numberOfFailedMissions = (_mainScope getVariable "history") select 1;
hint _numberOfFailedMissions;
-
Thanks. Mainscope select 0 counts completed missions, and that works like a charm. Counting failed ones is a bit more difficult, since I don't know what qualifies as a fail according to the SOM. Simply ignoring the mission or aborting it does not increase this part of the history array.
But since I am now able to give the player a customized bonus upon completing a predefined number of missions, I'm quite happy anyway :D
-
Since this may interest others, I'll share my findings here. This is is the script I'm using (NOLAG_SOMcounter.sqf). The script refers to NOLAG_play1_1 wich is the min playable unit. You may replace it with player in a strict single player scenario.
while {NOLAG_andCounting} do
{
private ["_mainScope", "_numberOfCompletedMissions", "_numberOfFailedMissions"];
_mainScope = NOLAG_play1_1 getVariable "mainScope";
_numberOfCompletedMissions = (_mainScope getVariable "history") select 0;
_numberOfFailedMissions = (_mainScope getVariable "history") select 1;
sleep 1;
if (_numberOfFailedMissions > 0) then {NOLAG_somBad = true};
sleep 1;
if (_numberOfCompletedMissions > _numberOfFailedMissions) then {NOLAG_somGood = true};
sleep 1;
};
Counting the number of completed missions is easy. Notice however that a failed mission also qualifies as a COMPLETED mission, as well as a FAILED one. Hence the soultion where you will trigger a reward (NOLAG_somGood = true) if, and only if, the total number of completed missions exceeds the number of failed ones. If I just count completed missions a failure may result in a reward.
To trigger a negative effect I just need to count the number of failed missions. It seems that this variable will always remain equal to or lower than the number of completed missions.
Thank's Worldeater for all the help. Hope this is useful to some people.