Jump to content
viel.kuul.10

How to count dead soldiers in the groups?

Recommended Posts

I managed to split this script into three parts or three hints individually.

 

Spoiler

addMissionEventHandler ["entityKilled",{
  params ["_unit"];
  private _grp = group _unit;
  private _side = side _grp;
  private _type = getText (configOf _unit / "displayName");
  if (isNil {_grp getVariable "dataKilled"}) then {
    _grp setVariable ["dataKilled",[[_side,_type,0]]];
  } else {
    if !([_side,_type] in ((_grp getVariable "dataKilled") apply {[_x#0,_x#1]})) then {
      (_grp getVariable "dataKilled") pushBack [_side,_type,0];
    };
  };
  private _idx = (((_grp getVariable "dataKilled") apply {[_x#0,_x#1]}) find [_side,_type]);
  private _cnt = (_grp getVariable "dataKilled") #_idx#2;
  (_grp getVariable "dataKilled") set [_idx, [_side,_type,_cnt +1]];
}];


[] spawn {
  while {true} do {
    waitUntil {sleep 1; triggerActivated trig1};
    private _txtWEST = "DEAD HELLENIC UNITS ";

    {
      _grp = _x;
      {
        _x params ["_side","_type","_cnt"];
        call { 
          if (_side isEqualTo WEST) exitWith {
            if !(str _grp in str _txtWEST) then {
              _txtWEST = composeText [_txtWEST,lineBreak,str _grp] 
            };
            _txtWEST = composeText [_txtWEST,' ' +_type + ' ' + str _cnt];
          };

        };
      } forEach (_grp getVariable "dataKilled");
    } forEach (allGroups select {!isNil {_x getVariable "dataKilled"}});
    if (_txtWEST isEqualTo "DEAD HELLENIC UNITS ") then {_txtWEST = "DEAD HELLENIC UNITS: 0 casualty"};

    hint composeText [_txtWEST];
    waitUntil {sleep 1; !triggerActivated trig1};
  };
};


[] spawn {
  while {true} do {
    waitUntil {sleep 1; triggerActivated trig2};

    private _txtEAST = "DEAD TURKISH UNITS ";

    {
      _grp = _x;
      {
        _x params ["_side","_type","_cnt"];
        call { 

          if (_side isEqualTo EAST) exitWith {
            if !(str _grp in str _txtEAST) then {
              _txtEAST = composeText [_txtEAST,lineBreak,str _grp] 
            };
            _txtEAST = composeText [_txtEAST,' ' +_type + ' ' + str _cnt];
          };

        };
      } forEach (_grp getVariable "dataKilled");
    } forEach (allGroups select {!isNil {_x getVariable "dataKilled"}});

    if (_txtEAST isEqualTo "DEAD TURKISH UNITS ") then {_txtEAST = "DEAD TURKISH UNITS: 0 casualty"};

    hint composeText [_txtEAST];
    waitUntil {sleep 1; !triggerActivated trig2};
  };
};


[] spawn {
  while {true} do {
    waitUntil {sleep 1; triggerActivated trig3};

    private _txtINDEP = "DEAD MAIDEN UNITS ";
    {
      _grp = _x;
      {
        _x params ["_side","_type","_cnt"];
        call { 

          if (_side isEqualTo INDEPENDENT) exitWith {
            if !(str _grp in str _txtINDEP) then {
              _txtINDEP = composeText [_txtINDEP,lineBreak,str _grp] 
            };
            _txtINDEP = composeText [_txtINDEP,' ' +_type + ' ' + str _cnt];
          };
        };
      } forEach (_grp getVariable "dataKilled");
    } forEach (allGroups select {!isNil {_x getVariable "dataKilled"}});

    if (_txtINDEP isEqualTo "DEAD MAIDEN UNITS ") then {_txtINDEP = "DEAD MAIDEN UNITS: 0 casualty"};
    hint composeText [_txtINDEP];
    waitUntil {sleep 1; !triggerActivated trig3};
  };
};

 

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

×