Jump to content
Play3r

See if any Civillian is killed

Recommended Posts

i have found this script somewhere can't remember where.

I want to know if it can be changed to count all Civillian on the map, i understand that this script only counts if any CIV out of the 16 that have to be on the map dies it will end the game.

I have to check if the CIV is killed by Player and not any AI killing AI

 

I am using Bangabob's COS and i do not know how many Civillian that there is on the map, so all i want is that if you kill ONLY ONE you have failed the mission.

Can that be done with some kind of script like this one :

 

 

[] 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_endMission}; // works also in SP but you can use: "loser" call BIS_fnc_endMission for SP mission "16is the number of civ"
  }
};

Share this post


Link to post
Share on other sites

i mean if Bangabob's COS is an addon you cant change anything in that files.

You need to use extended eventhandlers to have a way for interact with units spawned with  Bangabob's COS

If Bangabob's COS are script you can just edit it and add killed EH.

Share this post


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

I am using Bangabob's COS and i do not know how many Civillian that there is on the map, so all i want is that if you kill ONLY ONE you have failed the mission.

 

Something like this:

 

//initServer.sqf in mission root
addMissionEventHandler ["EntityKilled",{

		params ["_killed", "_killer", "_instigator"];

		if (typeOf _killed isKindOf "CAManBase" AND side group _killed isequalTo civilian) exitWith {"EveryoneLost" call BIS_fnc_endMissionServer};


}];

BIS_fnc_endMissionServer

addMissionEventHandler#EntityKilled

 

You need to check for side group, since killed units are automatically side civilian, yet still remain in their group for a short time.

 

 

Cheers

  • Like 5

Share this post


Link to post
Share on other sites
58 minutes ago, Grumpy Old Man said:

 

Something like this:

 


//initServer.sqf in mission root
addMissionEventHandler ["EntityKilled",{

		params ["_killed", "_killer", "_instigator"];

		if (side group _killed isequalTo civilian) exitWith {"EveryoneLost" call BIS_fnc_endMissionServer};


}];

BIS_fnc_endMissionServer

addMissionEventHandler#EntityKilled

 

You need to check for side group, since killed units are automatically side civilian, yet still remain in their group for a short time.

 

 

Cheers

Thanks GOM 

Works like a charme.

 

thanks for the script.(gonna keep it to be used in the furture)

 // Play3r

Share this post


Link to post
Share on other sites

THX @ Play3r for the thread and THX @ GOM for the code - works also fine if you (for whatever reason) want to check if players kill animals. 

 

One thing jumped to my mind though: is it possible to check just for a certain class of civilians or animals? Like, you can kill rabbits but will get punished for killing goats?  Or you can kill civs (and then hush it up "He had an IED, we solemnly swear!"), but NOT the IDAP personnel and get punished for that if you do it?

Share this post


Link to post
Share on other sites
3 hours ago, tourist said:

THX @ Play3r for the thread and THX @ GOM for the code - works also fine if you (for whatever reason) want to check if players kill animals. 

 

One thing jumped to my mind though: is it possible to check just for a certain class of civilians or animals? Like, you can kill rabbits but will get punished for killing goats?  Or you can kill civs (and then hush it up "He had an IED, we solemnly swear!"), but NOT the IDAP personnel and get punished for that if you do it?

Sure is, just change the isKindOf check to the classname you want.

Other than that you can use setVariable to set a flag on an object, and use getVariable inside the EntityKilled EH to check if a killed unit was flagged and act accordingly:

 

//object init field
this setVariable ["TAG_fnc_HVT",true];



//initServer.sqf
addMissionEventHandler ["EntityKilled",{

		params ["_killed", "_killer", "_instigator"];

		if (_killed getVariable ["TAG_fnc_HVT",false]) exitWith {"EveryoneLost" call BIS_fnc_endMissionServer};


}];

Depending on how you plan to implement it it's probably better to add individual EHs for checking certain objects only:

//HVT object init field
this addEventhandler ["Killed",{"EveryoneLost" call BIS_fnc_endMissionServer}];

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

@GOM:

 

WOW,  fast reply, thx for that! :thumbsup:

 

Looks like you showed me how I can do exactly what I want:  individual units OR certain classes from within the CIV or animal side can be checked - will try that with the classnames first, but also for my mission a protection of individual animal and CIV side humans would do.

 

Like, if you come across a goat or cow that no one takes care of, you may or may not butcher it; it's up to you.  But if a fellow human shares his scarce ressources to provide for one or several specific animals so they will provide for him and his family and friends,  you become his enemy just the same as if you had killed one of his human loved ones.

 

It's about the concept that in a post-apoc society....

 

1) Certain domestic/farm animals are a valuable asset for all of mankind and you shoiuldn't kill them just to live on another day if you could instead round them goats or cows up, pen them in and start breeding program (MOAR food in a couple months better than LITTLE food today)+ "dairy pre-production"  aka milking them.

 

2) Some people have a LOT more useful knowledge than others and are consequently worth A LOT MORE if left alive - even from the perspective of a ruthless raider.  Think skilled surgeons or highly skilled mechanics and technicians -  you know, the kind of skillset you don't find in everybody and his uncle and need to have received university/vocational training for.

 

So folks generally shouldn't hate you for going into shootouts about loot  with someone as long as the opposing party isn't they themselves.  But if you kill the ONLY surgeon known around or butcher a cow and a bull  who could help feed a whole group of survivors with dairy products and the meat of future calves, you cross a red line and become an enemy of all the people scraping by in a rough world.

 

BIG THX for helping me to achieve that in a mission!!!:icon_dj:

  • Like 1

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

×