Forum Jump :

Author Message


Posts: 2
Rank:


Level: Member

Country: nl
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2016-09-17 18:29        
     
Hello,

I am trying to make a failure ending if there are <= 16 civilians left on the map. But for some reason the trigger also counts empty vehicles as civilians. Is there a way to avoid the trigger from also counting empty vehicles?

All best,

Robinblitz


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#2 Posted at 2016-09-17 18:50        
     
You can check it using the isKindOf command, using the "CaManBase" class.

_civilian isKindOf "CaManBase";

This will make sure they have two legs.

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Advertisement


Author Message


Posts: 2
Rank:


Level: Member

Country: nl
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2016-09-17 19:33        
     
# 654wak654 : You can check it using the isKindOf command, using the "CaManBase" class.

_civilian isKindOf "CaManBase";

This will make sure they have two legs.

Turned out that this was the correct condition: Turned out that this was the condition: {_x isKindOf "CaManBase"} count thisList <= 16


Thanks for the help! :)


Author Message


Posts: 22
Rank:


Level: Member

Country: us
Location: http://sectionfivegaming.weebly.com/
Occupation:
Age: 21
In-game name: Swift

 
#4 Posted at 2016-09-21 02:08        
     
In init.sqf

null=[] execVM "Scripts\civCount.sqf";

civCount.sqf

SHK_DeadCivilianCount = 0;
SHK_DeadCivilianLimit = 10;
SHK_fnc_deadCivilians = {
  hintsilent format ["Civilians dead: %1",_this];
  if (_this >= SHK_DeadCivilianLimit) then {
		civDead = true;
  };
};
if isserver then {
  {
	if (side _x == Civilian && _x iskindof "Man") then {
      _x addEventHandler ["killed", {
        SHK_DeadCivilianCount = SHK_DeadCivilianCount + 1;
        publicvariable "SHK_DeadCivilianCount";
        if !isdedicated then {
          SHK_DeadCivilianCount call SHK_fnc_deadCivilians;
        };
      }];
    };
  } foreach allunits;
};
if !isdedicated then {
  "SHK_DeadCivilianCount" addpublicvariableeventhandler { (_this select 1) call SHK_fnc_deadCivilians };
};



In trigger conditions: civDead
Type: Mission failed


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#5 Posted at 2016-09-21 03:25        
     
@pompous, some problems with your script:
- init.sqf runs on server and each client. Prefer initServer.sqf even if you precise this code is for server only.
- use MPKilled rather than Killed. You'll save the need to public variable the count.
- this only works with edited units. When spawned, the units must have also this EH. So you need a loose loop and a variable on units to avoid EH multiplication. But I guess, all civilians are on the map at start here.

The trigger with: {_x isKindOf "CaManBase"} count thisList <= 16 should work fine but you need to cover all the map for thislist and the list of civilians (thisList) can be huge!
Forget the trigger (checked every 0.5 sec). replace by this small script:
A simple loop can damper the check occurrence:
In initServer.sqf:

[] spawn {
  while {true} do {
  sleep 3;
  _cnt = { side _x == civilian } count allUnits; // allUnits implies men & alive and not waiting for respawn
  if (_cnt < 16) exitWith {"Loser" call BIS_fnc_endMissionServer}; // works also in SP but you can use: "loser" call BIS_fnc_endMission for SP mission
  }
}

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 40
Rank:


Level: Member

Country: dk
Location:
Occupation: Trucker
Age:
In-game name:

 
#6 Posted at 2016-12-29 13:02        
     
.

This post was edited by L.Lysgaard (2017-07-20 17:15, 94 days ago)

It is better to burn out than fade away.