Jump to content
Sign in to follow this  
runforrest

check for civilian casualties with civilian module activated?

Recommended Posts

hey there.

to all of my missions i wanna add a loss trigger if civilian casualties are to high.

without the civilian module i would place some civilians within the area of a trigger with settings:

activation: civilians

not present (not sure if thats the exact word in the english editor)

type: loss

but with the civilian module, how would i do that? afaik the civilan life is created around the player within a certain range, and deleted when not being in that range. so cheking for alive civilans with a trigger wouldnt work. any ideas?

Share this post


Link to post
Share on other sites

I'd try to use a script for that.

With "allGroups" we have the possibility to get a reference on all existing civilian objects currently existing in a mission.

I would filter out all groups of side "civilian" and start a KILLED evenhandler for all units. All eventhandlers would increase a global counter variable if a civilian was killed by the player.

In case the trashcollector would delete the civilian the eventhandler would be stopped, too.

Dunno how many EHandlers can be used at once performance wise though - too many civilians would surely lag even more because you'd have 1 EH for everyone of them.

Just an idea. :)

Share this post


Link to post
Share on other sites

what u wrote is a total mystery to me :o i have no idea of scripting, eventhandlers and stuff like that. thx anyway :)

but i guess it wont take long until a script is available, as this is a very important thing to have in missions

Share this post


Link to post
Share on other sites

No need to add eventhandlers to all units. You can set special init for every civilian created by Ambient Civilians module:

[
bis_alice_mainscope,
"ALICE_civilianinit",
[{
	_this addeventhandler ["killed",{civ_casaulties = civ_casaulties + 1}]
}]
] call bis_fnc_variablespaceadd;

This will rise global variable civ_casaulties by 1 every time civilian is killed.

More info on Biki

Share this post


Link to post
Share on other sites
No need to add eventhandlers to all units. You can set special init for every civilian created by Ambient Civilians module:

[
bis_alice_mainscope,
"ALICE_civilianinit",
[{
	_this addeventhandler ["killed",{civ_casaulties = civ_casaulties + 1}]
}]
] call bis_fnc_variablespaceadd;

This will rise global variable civ_casaulties by 1 every time civilian is killed.

More info on Biki

DOH! I just made an Serialkiller map but have not found a way to get a civi kill counter so i wrote my own populationscript (my own alice, but not so good as the BIS one) ARGH!

@Gaia, you posted this 2 days to late....

Edited by NeoArmageddon

Share this post


Link to post
Share on other sites

Betatesting already started. Works great, just the support for two killer isnt ready yet. Release the next week :yay:

BTW Looking for testers-> ICQ 168566281

Share this post


Link to post
Share on other sites
No need to add eventhandlers to all units. You can set special init for every civilian created by Ambient Civilians module:

[
bis_alice_mainscope,
"ALICE_civilianinit",
[{
	_this addeventhandler ["killed",{civ_casaulties = civ_casaulties + 1}]
}]
] call bis_fnc_variablespaceadd;

This will rise global variable civ_casaulties by 1 every time civilian is killed.

More info on Biki

thx for the info

how do i use that in a mission? 4 dead civilans = mission failed

or hey much better the civilans run into their houses, get arms, and fight back :D that would be cool. i think thats not possible is it?

but maybe a workaround, lets say guerillias come out of houses(spawn at the doors or spawn inside buildings if possible, so players can not see them just popping up out of nowhere) and fight the enemies (players). is that possible?

Share this post


Link to post
Share on other sites

Anything is possible in ARMA sorta. You just gotta learn how to do it - or grease someone up to do it for you. :) But its sure possible to do what you want. I dont know how though.

Share this post


Link to post
Share on other sites
No need to add eventhandlers to all units. You can set special init for every civilian created by Ambient Civilians module:

[
bis_alice_mainscope,
"ALICE_civilianinit",
[{
	_this addeventhandler ["killed",{civ_casaulties = civ_casaulties + 1}]
}]
] call bis_fnc_variablespaceadd;

This will rise global variable civ_casaulties by 1 every time civilian is killed.

Gaia-

I attempted to use this structure to add an init to every ALICE civilian, but got a zero divisor error. It didn't say where, though, although it looks like it is associated with approximately line 17 of the fnc_civilianinit, where

_logic = BIS_alice_mainscope;

I tried this:

[bis_alice_mainscope, "ALICE_civilianinit",[{if ((random 1) < .4) then {[_this] execVM "JTD_ambientCivTraffic.sqf"};}]] call bis_fnc_variablespaceadd;

Now, I tried MANY different combinations of things. :D Oh - and this was in the initialization portion of the editor-placed module. Is it more properly in the init of the mission? Ideally, I would like a way for a mission designer to just place the code in an init box (or have it as an addon module/game logic... but one step at a time). ;)

Thanks,

T

Share this post


Link to post
Share on other sites
No need to add eventhandlers to all units. You can set special init for every civilian created by Ambient Civilians module:

[
   bis_alice_mainscope,
   "ALICE_civilianinit",
   [{
       _this addeventhandler ["killed",{civ_casaulties = civ_casaulties + 1}]
   }]
] call bis_fnc_variablespaceadd;

This will rise global variable civ_casaulties by 1 every time civilian is killed.

More info on Biki

Thanks for the great info Gaia, however I can't get it to work. I've tried adding your code to the ALICE module init line, as well as trying it from the init.sqf and it doesn't work.

When running it from the init.sqf, I've used the following code (where myALICE is the name of the ALICE module) that I normally use before passing parameters to modules:

waitUntil {!isNil {myALICE getVariable "initDone"}};
waitUntil {myALICE getVariable "initDone"};
hint "ALICE inialised"; 

When I use the above code, it never actually initialises and doesn't show the hint message. Does initialisation for ALICE work differently than for other modules?

When I remove the "waitUntil" lines, the code runs without errors, but the civilian death counter doesn't work. I've got another radio trigger that displays a hint with the Civilian death count but it doesn't increment when I kill civilians.

I've also tried adding the Functions module since we are using a function in the ALICE config.

Any ideas why it's not working?

Cheers!

Edited by [ZSU]Preacher

Share this post


Link to post
Share on other sites

I added killed by player only .Thats because all civils get this killedEH and some of them are killed on mission start by something, i dont know why, maybe they hit door frame with head to hard when jumping out :D

this setvariable
[
"ALICE_civilianinit",
[{
	_this addeventhandler ["killed",{if(_this select 1 == player) then {McH_Civ_Killed = McH_Civ_Killed + 1;}}]
}]
] call bis_fnc_variablespaceadd

You can download sample mission here

Edited by mchide

Share this post


Link to post
Share on other sites

That's cool and it works fine in sp.

Any ideas how to make it work for mp missions on dedi server ? I tried but you don't get any message in game, nor does it update the objective (I added an roe respect obj)

Share this post


Link to post
Share on other sites

To code add publicvariable"McH_Civ_Killed" maybe... Or run it only on server and send code from there. Killed and hit eventhandlers are not global events.

Edited by mchide

Share this post


Link to post
Share on other sites

I tried this but it didn't worked either...

this setvariable
[
"ALICE_civilianinit",
[{
	_this addeventhandler ["killed",{if(isplayer _this select 1) then {McH_Civ_Killed = McH_Civ_Killed + 1; publicvariable "McH_Civ_Killed"; }}]
}]
] call bis_fnc_variablespaceadd

Edit : tried with addPublicVariableEventHandler too but still nothing on dedicated.

Edited by Danreiv

Share this post


Link to post
Share on other sites
No need to add eventhandlers to all units. You can set special init for every civilian created by Ambient Civilians module:

[
bis_alice_mainscope,
"ALICE_civilianinit",
[{
	_this addeventhandler ["killed",{civ_casaulties = civ_casaulties + 1}]
}]
] call bis_fnc_variablespaceadd;

This will rise global variable civ_casaulties by 1 every time civilian is killed.

More info on Biki

Where need to put this lines to make it work? I put it into ALICE init, but the counter didn't work i still counts only the civilians that where on map from the beginning. The new created by ALICE still don't count. Could you please help me out with this?

(Im working on a SP mission, but working in a MP coop mission would be also great)

GOT IT WORKING WITH THIS SCRIPT of Shuko:

http://forums.bistudio.com/showthread.php?109166-Civilian-kill-Counter&p=1806523&viewfull=1#post1806523

SHK_DeadCivilianCount = 0;
SHK_DeadCivilianLimit = 3;
SHK_EndMission = false;
[] spawn {
 waituntil {SHK_EndMission};
 cuttext ["Game over. Unfortunately, you killed too many civilians.","PLAIN",2];
 sleep 10;
 endmission "END2";
};

SHK_fnc_deadCivilians = {
 hintsilent format ["Civilians dead: %1",_this];
 if (_this >= SHK_DeadCivilianLimit) then {
   SHK_EndMission = true;
   publicvariable "SHK_EndMission";
 };
};
SHK_eh_killed = {
 SHK_DeadCivilianCount = SHK_DeadCivilianCount + 1;
 publicvariable "SHK_DeadCivilianCount";
 if isdedicated then {
   if (_this >= SHK_DeadCivilianLimit) then {
     SHK_EndMission = true;
     publicvariable "SHK_EndMission";
   };
 } else {
   SHK_DeadCivilianCount call SHK_fnc_deadCivilians;
 };
};
if isserver then {
 {
   if (side _x == Civilian && _x iskindof "Man") then {
     _x addEventHandler ["killed", SHK_eh_killed];
   };
 } foreach allunits;
} else {
 "SHK_DeadCivilianCount" addpublicvariableeventhandler { (_this select 1) call SHK_fnc_deadCivilians };
};
[] spawn {
 waituntil {!isnil "BIS_alice_mainscope"};
 waituntil {!isnil "bis_fnc_variablespaceadd"};
 [bIS_alice_mainscope,"ALICE_civilianinit",[{_this addEventHandler ["killed", SHK_eh_killed]}]] call bis_fnc_variablespaceadd;

Edited by Lato1982

Share this post


Link to post
Share on other sites

dont know if you all got what you needed but this works great i believe shk is the original owner of this code

init.sqf

execVM "check_for_civ_death.sqf";// run on server side

check_for_civ_death.sqf



MC_DeadCivilianCount = 0;
MC_DeadCivilianLimit = 10;// limit amount of civ casualties allowed
MC_EndMission = false;
[] spawn {
 waituntil {MC_EndMission};
 playSound "start";
 cuttext ["Game over. Civilian casualties are at an unacceptable level. Hearts and minds, boys...","PLAIN",2];
 sleep 10;
 endmission "END2";
};

MC_fnc_deadCivilians = {
 hint parseText format["<t color=""#80FF00"">Civilians dead: %1, Watch Your Fire 10 is the limit.</t>"];
 if (_this >= MC_DeadCivilianLimit) then {
   MC_EndMission = true;
   publicvariable "MC_EndMission";
 };
};
MC_eh_killed = { 
private "_side"; 
_side = side (_this select 1); 
if (_side == WEST) then { 
MC_DeadCivilianCount = MC_DeadCivilianCount + 1; 
publicvariable "MC_DeadCivilianCount"; 
if isdedicated then { 
if (_this >= MC_DeadCivilianLimit) then { 
MC_EndMission = true; 
publicvariable "MC_EndMission"; 
}; 
} else { 
MC_DeadCivilianCount call MC_fnc_deadCivilians; 
}; 
}; 
};
if isserver then {
 {
   if (side _x == Civilian && _x iskindof "Man") then {
     _x addEventHandler ["killed", MC_eh_killed];
   };
 } foreach allunits;
} else {
 "MC_DeadCivilianCount" addpublicvariableeventhandler { (_this select 1) call MC_fnc_deadCivilians };
};
[] spawn {
 waitUntil{!isNil "BIS_fnc_init"};	
 waituntil {!isnil "BIS_alice_mainscope"};
 waituntil {!isnil "bis_fnc_variablespaceadd"};
 [bIS_alice_mainscope,"ALICE_civilianinit",[{_this addEventHandler ["killed", MC_eh_killed]}]] call bis_fnc_variablespaceadd;
};


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
Sign in to follow this  

×