Jump to content
viel.kuul.10

How to count dead soldiers in the groups?

Recommended Posts

For a couple of days I try to make a script that will show me the message usually after the battle, not only how many were killed and which soldier (rifleman, grenadier, heavy gunner etc.), but in which group (1-2 Bravo, 2-4 Charlie or _group1, _group2 etc. )? I have already solved the number of dead and the type of fighters, but I am not succeeding as far as the groups is concerned.

private _sectionleaders = [];
private _grenadiers = [];
private _riflemen = [];

private _aliveWest = allUnits select "_group1","_group2" {side _x isEqualTo WEST && {alive _x}};

{
switch (typeOf _x) do {
case "B_Soldier_SL_F": {_sectionleaders pushBackUnique _x};
case "B_Soldier_GL_F": {_grenadiers pushBackUnique _x};
case "B_Soldier_F": {_riflemen pushBackUnique _x};

};
} forEach allDeadMen;

hint format [ ">>> DEAD UNITS <<<

Section Leaders: %1
Grenadiers: %2
Riflemen: %3",
count _sectionleaders,count _grenadiers,count _riflemen];

Share this post


Link to post
Share on other sites

Dead men are civilian. (so counting WEST && alive (or EAST && alive) units  is not necessary).

They stay a little bit in their group before being deleted from them (several seconds).

 

private _aliveWest = allUnits select "_group1","_group2" {side _x isEqualTo WEST && {alive _x}}; is wrong.

_group1 _group2 ("_group1", "_group2" has no sense, except for markers in this context) are local variables. So they must be defined before in your code.

Check if these variables are OK. Example:  hint str [_group1,_group2]; must returns the groups in this code.

Then ,you can write:

private _aliveWest = allUnits select {group _x in [_group1,_group2]  && side _x isEqualTo WEST};  

 

But I'm not sure to understand what you want to do with that.

Share this post


Link to post
Share on other sites

I want the hint to be displayed when I enter the trigger and to write similarly in the hint:

 

DEAD NATO UNITS
Group 1: Squad Leaders: 1, Riflemen: 1
Group 2: Grenadier: 2, Riflemen: 4

 

In group 1 there are two dead (1x Squad Leaders 1, 1x Riflemen), and in group 2 there are six dead (...).
The reason why I want this is that after the battle I know how many soldiers were killed, what type of fighters but I don't know in which group, in which unit.

Share this post


Link to post
Share on other sites
10 hours ago, pierremgi said:

Dead men are civilian. (so counting WEST && alive (or EAST && alive) units  is not necessary).

They stay a little bit in their group before being deleted from them (several seconds).

 

private _aliveWest = allUnits select "_group1","_group2" {side _x isEqualTo WEST && {alive _x}}; is wrong.

_group1 _group2 ("_group1", "_group2" has no sense, except for markers in this context) are local variables. So they must be defined before in your code.

Check if these variables are OK. Example:  hint str [_group1,_group2]; must returns the groups in this code.

Then ,you can write:

private _aliveWest = allUnits select {group _x in [_group1,_group2]  && side _x isEqualTo WEST};  

 

But I'm not sure to understand what you want to do with that.

 

Does not work. Can you make a complete script out of this? I named the groups with _group1 and _group2.

Share this post


Link to post
Share on other sites
5 hours ago, viel.kuul.10 said:

 

Does not work. Can you make a complete script out of this? I named the groups with _group1 and _group2.

No.

I don't know where your _group1, _group2 come from, if you are in a single or multiplayer session, if you intend to extend your code to other groups, perhaps spawned groups...

So, if you want some help, start showing your whole code and your final intention. If there are just two poor groups, you first have to choose global variables as name.

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

No.

I don't know where your _group1, _group2 come from, if you are in a single or multiplayer session, if you intend to extend your code to other groups, perhaps spawned groups...

So, if you want some help, start showing your whole code and your final intention. If there are just two poor groups, you first have to choose global variables as name.

 

Iam in a singleplayer. In one mission I use the Greek army. In fact, I haven't named Greek units yet, but I plan to name them with, for example, group1, group2 ... etc. Also I intend to extend the script to other units like spawned and enemy.

What I want is to know in which group the soldier was killed, it would make it much easier for me to search for bodies on the terrain after the battle. Otherwise I wander on the terrain and I guess the soldier was killed maybe in this or that group, if you understand me.

 

I run my own statistics in Excel outside the game.

 

There’s my whole script about Greek army. I have also for the enemy army. I haven't installed that script for the groups yet.

 

Spoiler

private _sectionleaders = [];     
private _teamleaders = [];     
private _riflemenal1a1 = [];     
private _riflemenm72a2 = [];     
private _machinegunnersmg42 = [];     
private _machinegunnersasst = [];     
private _atspecialists = [];     
private _atassistants = [];    
private _snipers = [];     
private _engineers = [];     
private _medics = [];     
private _crewmen = [];     
private _crewnavs = [];     
private _helipilots = [];     
private _airpilots = [];     
private _commanders = [];    
private _generals = [];    
     
private _aliveWest = allUnits select {side _x isEqualTo WEST && {alive _x}};      
      
{      
 switch (typeOf _x) do {      
  case "LOP_GRE_Infantry_SL": {_sectionleaders pushBackUnique _x};       
  case "LOP_GRE_Infantry_TL": {_teamleaders pushBackUnique _x};      
  case "LOP_GRE_Infantry_Rifleman": {_riflemenal1a1 pushBackUnique _x};      
  case "LOP_GRE_Infantry_Rifleman_2": {_riflemenm72a2 pushBackUnique _x};      
  case "LOP_GRE_Infantry_MG": {_machinegunnersmg42 pushBackUnique _x};      
  case "LOP_GRE_Infantry_MG_Asst": {_machinegunnersasst pushBackUnique _x};      
  case "LOP_GRE_Infantry_AT": {_atspecialists pushBackUnique _x};      
  case "LOP_GRE_Infantry_AT_Asst": {_atassistants pushBackUnique _x};      
  case "GR_D1_Spotter": {_snipers pushBackUnique _x};     
  case "LOP_GRE_Infantry_Engineer": {_engineers pushBackUnique _x};                   
  case "LOP_GRE_Infantry_Corpsman": {_medics pushBackUnique _x};                                                                         
  case "LOP_GRE_Infantry_Crewman": {_crewmen pushBackUnique _x};      
  case "GR_E1_NAVY": {_crewnavs pushBackUnique _x};         
  case "LOP_GRE_Infantry_Pilot": {_helipilots pushBackUnique _x};       
  case "B_Pilot_F": {_airpilots pushBackUnique _x};           
  case "GR_A1_Officer_Frml": {_commanders pushBackUnique _x};         
  case "GR_A1_Officer": {_generals pushBackUnique _x};              
     
 };      
} forEach allDeadMen;      
      
hint format [                                                     ">>> DEAD HELLENIC UNITS <<<      
                                              
Section Leaders: %1                                                               
Team Leaders: %2                                                           
Riflemen (L1A1): %3                                                        
Riflemen (M72A2): %4                                                              
Machine Gunners (MG-42): %5                                                                 
Machine Gunners Assist.: %6                                                          
AT Specialists: %7                                                        
AT Assistants: %8                                                            
Spotters: %9                                                            
Combat Engineers: %10                                                                  
Combat Medics: %11                                                        
Land Crewmen: %12                                                        
Naval Crewmen: %13                                                        
Heli Pilots: %14                                                           
Air Pilots: %15                                                           
Commanders: %16                                                           
Generals: %17",                                                 
count _sectionleaders,count _teamleaders,count _riflemenal1a1,count _riflemenm72a2,count _machinegunnersmg42,count _machinegunnersasst,count _atspecialists,count _atassistants,count _snipers, 
count _engineers,count _medics,count _crewmen,count _crewnavs,count _helipilots,count _airpilots,count _commanders,count _generals];

 

Share this post


Link to post
Share on other sites

OK thanks for these points. It's time saving.

 

You can try this code in init.sqf, ... or where you want.  Here the hint is displayed when a trigger named trigEnd is activated. You can change this condition, obviously. (see inside the spawned code below)


 

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 {
  private _txtWEST = "DEAD NATO UNITS ";
  private _txtEAST = "DEAD OPFOR UNITS ";
  private _txtINDEP = "DEAD GREEK UNITS ";
  waitUntil {sleep 1; triggerActivated trigEnd};
  {
    _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];
        };
        if (_side isEqualTo EAST) exitWith {
          if !(str  _grp in str _txtEAST) then {
            _txtEAST = composeText [_txtEAST,lineBreak,str _grp]
          };
          _txtEAST = composeText [_txtEAST,' ' +_type + ' ' + str _cnt];
        };
        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 (_txtWEST isEqualTo "DEAD NATO UNITS ") then {_txtWEST = "DEAD NATO UNITS: 0 casualty"};
  if (_txtEAST isEqualTo "DEAD OPFOR UNITS ") then {_txtEAST = "DEAD OPFOR UNITS: 0 casualty"};
  if (_txtINDEP isEqualTo "DEAD GREEK UNITS ") then {_txtINDEP = "DEAD GREEK UNITS: 0 casualty"};
  hint composeText [_txtWEST,lineBreak,_txtEAST,lineBreak,_txtINDEP];
};

 

Share this post


Link to post
Share on other sites
50 minutes ago, pierremgi said:

OK thanks for these points. It's time saving.

 

You can try this code in init.sqf, ... or where you want.  Here the hint is displayed when a trigger named trigEnd is activated. You can change this condition, obviously. (see inside the spawned code below)


 


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 {
  private _txtWEST = "DEAD NATO UNITS ";
  private _txtEAST = "DEAD OPFOR UNITS ";
  private _txtINDEP = "DEAD GREEK UNITS ";
  waitUntil {sleep 1; triggerActivated trigEnd};
  {
    _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];
        };
        if (_side isEqualTo EAST) exitWith {
          if !(str  _grp in str _txtEAST) then {
            _txtEAST = composeText [_txtEAST,lineBreak,str _grp]
          };
          _txtEAST = composeText [_txtEAST,' ' +_type + ' ' + str _cnt];
        };
        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 (_txtWEST isEqualTo "DEAD NATO UNITS ") then {_txtWEST = "DEAD NATO UNITS: 0 casualty"};
  if (_txtEAST isEqualTo "DEAD OPFOR UNITS ") then {_txtEAST = "DEAD OPFOR UNITS: 0 casualty"};
  if (_txtINDEP isEqualTo "DEAD GREEK UNITS ") then {_txtINDEP = "DEAD GREEK UNITS: 0 casualty"};
  hint composeText [_txtWEST,lineBreak,_txtEAST,lineBreak,_txtINDEP];
};

 

 

It works, thank you. I have to admit I was lost in your script. But I'm learning something new. But there is a small problem, I can activate this only once. I tried in the trigger to check repeatable but it doesn't work.

Can you embed some vehicle destruction script in your existing script?

Share this post


Link to post
Share on other sites

It's up to you deciding what condition you want.

 

21 hours ago, viel.kuul.10 said:

I want the hint to be displayed when I enter the trigger and to write similarly in the hint:

The reason why I want this is that after the battle I know how many soldiers were killed, what type of fighters but I don't know in which group, in which unit.

 

The addmissionEventHandler fires each time a unit is killed (first part).

The spawned script (2nd part) elaborate the result with all impacted groups by at least one kill. You can decide to display the hint hint you want, even in a loop:

 

[] spawn { // same as above

  while {true} do {   // loop

   waitUntil {sleep 1: something repeatable};  // repeatable trigger activation or else. Vehicle destructions work also but which ones?

  <the above code to be executed here, from private to hint lines>

   waitUntil {sleep1; somethingElse}; // usually trigger deactivation

  }; // end of loop

}; // same as above to end the spawned code
 

Share this post


Link to post
Share on other sites
59 minutes ago, pierremgi said:

It's up to you deciding what condition you want.

 

 

The addmissionEventHandler fires each time a unit is killed (first part).

The spawned script (2nd part) elaborate the result with all impacted groups by at least one kill. You can decide to display the hint hint you want, even in a loop:

 

[] spawn { // same as above

  while {true} do {   // loop

   waitUntil {sleep 1: something repeatable};  // repeatable trigger activation or else. Vehicle destructions work also but which ones?

  <the above code to be executed here, from private to hint lines>

   waitUntil {sleep1; somethingElse}; // usually trigger deactivation

  }; // end of loop

}; // same as above to end the spawned code
 

 

I made init.sqf, put a trigger named trigEnd in my mission to activate this script. But I can only activate once and I would like to activate repeatedly. How?

All vehicles, from cars, tanks to helicopters, planes. Vessels, aircraft, everything.

Share this post


Link to post
Share on other sites
59 minutes ago, viel.kuul.10 said:

 

I made init.sqf, put a trigger named trigEnd in my mission to activate this script. But I can only activate once and I would like to activate repeatedly. How?

All vehicles, from cars, tanks to helicopters, planes. Vessels, aircraft, everything. 

What is your trigger condition?????????????

The script count also any vehicles (if you tested it...)

Share this post


Link to post
Share on other sites
16 hours ago, pierremgi said:

What is your trigger condition?????????????

The script count also any vehicles (if you tested it...)

 

Only  this  in the condition.

Share this post


Link to post
Share on other sites
9 minutes ago, viel.kuul.10 said:

 

Only  this  in the condition.

 

What he means is -WHAT is activating your trigger. "This" meaning WHAT exactly? If we cant tell what activates your trigger -we cant help you on how to keep calling it.

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, froggyluv said:

 

What he means is -WHAT is activating your trigger. "This" meaning WHAT exactly? If we cant tell what activates your trigger -we cant help you on how to keep calling it.

 

The trigger is named by trigEnd, activation: type none, activation any player, activation type present, repeatable checked. Expression: condition this, on activation nothing, on deactivation also nothing.

Share this post


Link to post
Share on other sites
51 minutes ago, viel.kuul.10 said:

 

The trigger is named by trigEnd, activation: type none, activation any player, activation type present, repeatable checked. Expression: condition this, on activation nothing, on deactivation also nothing.

Well, now, it's clear.

in init.sqf:
 

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 trigEnd};
    private _txtWEST = "DEAD NATO UNITS ";
    private _txtEAST = "DEAD OPFOR UNITS ";
    private _txtINDEP = "DEAD GREEK 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];
          };
          if (_side isEqualTo EAST) exitWith {
            if !(str _grp in str _txtEAST) then {
              _txtEAST = composeText [_txtEAST,lineBreak,str _grp] 
            };
            _txtEAST = composeText [_txtEAST,' ' +_type + ' ' + str _cnt];
          };
          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 (_txtWEST isEqualTo "DEAD NATO UNITS ") then {_txtWEST = "DEAD NATO UNITS: 0 casualty"};
    if (_txtEAST isEqualTo "DEAD OPFOR UNITS ") then {_txtEAST = "DEAD OPFOR UNITS: 0 casualty"};
    if (_txtINDEP isEqualTo "DEAD GREEK UNITS ") then {_txtINDEP = "DEAD GREEK UNITS: 0 casualty"};
    hint composeText [_txtWEST,lineBreak,_txtEAST,lineBreak,_txtINDEP];
    waitUntil {sleep 1; !triggerActivated trigEnd};
  };
};


 

 

  • Thanks 1

Share this post


Link to post
Share on other sites

It works, thanks! I'll get back later when I test that with the vehicles.

 

If I’m not asking too much, can you embed a script about all living units in this existing script?

Share this post


Link to post
Share on other sites

I have tested that with the vehicles. Scripts work when it comes to only vehicles that are already located in a terrain but do not recognize those that have spawned.

Share this post


Link to post
Share on other sites
3 hours ago, viel.kuul.10 said:

I have tested that with the vehicles. Scripts work when it comes to only vehicles that are already located in a terrain but do not recognize those that have spawned.

 

Probably because you are spawning these groups (spawned vehicles) after the trigger activation and before the trigger deactivation. I don't know what is your condition for spawning some vehicles. So, you can split the loop (i wrote) into two spawned loops, one for treating the groups, another one for trigger activation/hint/trigger deactivation.

Try to do that yourself. It's a good exercise.

 

Share this post


Link to post
Share on other sites
19 hours ago, pierremgi said:

 

Probably because you are spawning these groups (spawned vehicles) after the trigger activation and before the trigger deactivation. I don't know what is your condition for spawning some vehicles. So, you can split the loop (i wrote) into two spawned loops, one for treating the groups, another one for trigger activation/hint/trigger deactivation.

Try to do that yourself. It's a good exercise.

 

 

I think I have already solved this by incorporating _entity among the params. Now this looks like this: params ["_unit", "_entity"];

 

Which is the event among the addMissionEventHandler that helps count all living units? Can you help me?

Share this post


Link to post
Share on other sites

https://community.bistudio.com/wiki/Arma_3:_Mission_Event_Handlers#EntityKilled

the second param of this MEH refers to the killer. So your.... _entity. As usual, I'm not sure to understand your approach.

The MEH I gave you is just fine. What you have to do, (not me), is to treat your groups and manage your trigger hints. I gave you an example, but, as usual, there are extra inputs. It's endless... (til I decide it's over as far as I'm concerned).

Share this post


Link to post
Share on other sites
On 4/19/2021 at 8:28 PM, pierremgi said:

https://community.bistudio.com/wiki/Arma_3:_Mission_Event_Handlers#EntityKilled

the second param of this MEH refers to the killer. So your.... _entity.

 

https://community.bistudio.com/wiki/Arma_3:_Mission_Event_Handlers#EntityRespawned

 

On 4/19/2021 at 8:28 PM, pierremgi said:

https://community.bistudio.com/wiki/Arma_3:_Mission_Event_Handlers#EntityKilled

As usual, I'm not sure to understand your approach.

 

Really? I speak English, not Chinese! I feel like I'm talking to an alien.

 

On 4/19/2021 at 8:28 PM, pierremgi said:

The MEH I gave you is just fine. What you have to do, (not me), is to treat your groups and manage your trigger hints. I gave you an example, but, as usual, there are extra inputs. It's endless... (til I decide it's over as far as I'm concerned).

 

As usual you avoid answering my questions directly.

Share this post


Link to post
Share on other sites
1 hour ago, viel.kuul.10 said:

Really? I speak English, not Chinese! I feel like I'm talking to an alien.

 

@pierremgi isn't a native English speaker, so there's that. But he's not talking about language when he says he doesn't understand your approach. He means he doesn't understand why you're doing things the way you are, mainly due to you only providing snippets of info about what you're doing. Example:

 

I think I have already solved this by incorporating _entity among the params. Now this looks like this: params ["_unit", "_entity"];

Incorporated it why, and how? Though as Pierre explained afterwards, and assuming you've added into the EntityKilled EH, the _entity index refers to the killer and is listed in the documentation as "_killer". So Pierre is confused with your use of this param because he doesn't understand why you want to know who was the killer.

Share this post


Link to post
Share on other sites

Hey, I don't want to argue. I wrote everything clearly here what I want in the game. So it's not clear to me what's not clear to you, lol. I asked something so if you don’t want to help, then you don’t have to.

I put _entity in this script to recognize the vehicles when they spawn.

Share this post


Link to post
Share on other sites
9 hours ago, viel.kuul.10 said:

I put _entity in this script to recognize the vehicles when they spawn.

 

Into where, and how? This is the problem. No one knows where you've added _entity, but if you have only added it in the EntityKilled EH, then all _entity is doing is defining the killer. Which is what myself and Pierre have explained.

Share this post


Link to post
Share on other sites
On 4/30/2021 at 6:45 AM, beno_83au said:

 

Into where, and how? This is the problem. No one knows where you've added _entity, but if you have only added it in the EntityKilled EH, then all _entity is doing is defining the killer. Which is what myself and Pierre have explained.

 

Spoiler

addMissionEventHandler ["entityKilled",{
  params ["_unit", "_entity"];
  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 trigEnd};
    private _txtWEST = "DEAD NATO UNITS ";
    private _txtEAST = "DEAD OPFOR UNITS ";
    private _txtINDEP = "DEAD GREEK 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];
          };
          if (_side isEqualTo EAST) exitWith {
            if !(str _grp in str _txtEAST) then {
              _txtEAST = composeText [_txtEAST,lineBreak,str _grp] 
            };
            _txtEAST = composeText [_txtEAST,' ' +_type + ' ' + str _cnt];
          };
          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 (_txtWEST isEqualTo "DEAD NATO UNITS ") then {_txtWEST = "DEAD NATO UNITS: 0 casualty"};
    if (_txtEAST isEqualTo "DEAD OPFOR UNITS ") then {_txtEAST = "DEAD OPFOR UNITS: 0 casualty"};
    if (_txtINDEP isEqualTo "DEAD GREEK UNITS ") then {_txtINDEP = "DEAD GREEK UNITS: 0 casualty"};
    hint composeText [_txtWEST,lineBreak,_txtEAST,lineBreak,_txtINDEP];
    waitUntil {sleep 1; !triggerActivated trigEnd};
  };
};

 

How can I divide this script into three parts? Each side with its own hint? The hint doesn’t load whole because it’s too long, especially after a big battle.

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

×