Home   Help Search Login Register  

Author Topic: Counting uncompleted SOM missions  (Read 1647 times)

0 Members and 1 Guest are viewing this topic.

Offline nominesine

  • Former Staff
  • ****
  • I'm NOT back!
    • The IKB Forum
Counting uncompleted SOM missions
« on: 03 Nov 2010, 23:18:28 »
Quote from: DnA;1736649
You can do this by checking the SOM's history, stored in its main variable scope:

Code: [Select]
private ["_mainScope", "_history"];
_mainScope = player getVariable "mainScope";
_history = _mainScope getVariable "history"; //[# completed, # failed]

EDIT:
Made some clarifications in my own post.
« Last Edit: 03 Nov 2010, 23:35:21 by nominesine »
OFPEC | Intel Depot
RETARDED Ooops... Retired!

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: Counting uncompleted SOM missions
« Reply #1 on: 04 Nov 2010, 07:55:26 »
What is a sample output of the history?

Offline nominesine

  • Former Staff
  • ****
  • I'm NOT back!
    • The IKB Forum
Re: Counting uncompleted SOM missions
« Reply #2 on: 04 Nov 2010, 12:55:11 »
I don't know, since I am unable to understand what the quoted code is supposed to do  :scratch:
OFPEC | Intel Depot
RETARDED Ooops... Retired!

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Counting uncompleted SOM missions
« Reply #3 on: 04 Nov 2010, 13:14:47 »
Just turn it into a mini-script and run the return of _history as a str-hint:

Code: [Select]
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.

"When 900 years YOU reach, look as good you will not!"

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: Counting uncompleted SOM missions
« Reply #4 on: 04 Nov 2010, 14:39:26 »
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.  :)

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Counting uncompleted SOM missions
« Reply #5 on: 05 Nov 2010, 11:11:58 »
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...

Code: [Select]
private ["_mainScope", "_numberOfFailedMissions"];
_mainScope = player getVariable "mainScope";
_numberOfFailedMissions = (_mainScope getVariable "history") select 1;

hint _numberOfFailedMissions;
try { return true; } finally { return false; }

Offline nominesine

  • Former Staff
  • ****
  • I'm NOT back!
    • The IKB Forum
Re: Counting uncompleted SOM missions
« Reply #6 on: 09 Nov 2010, 14:43:12 »
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
OFPEC | Intel Depot
RETARDED Ooops... Retired!

Offline nominesine

  • Former Staff
  • ****
  • I'm NOT back!
    • The IKB Forum
Re: Counting uncompleted SOM missions
« Reply #7 on: 11 Nov 2010, 10:34:02 »
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.

Code: [Select]
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.
OFPEC | Intel Depot
RETARDED Ooops... Retired!