ahmedslimkw 223 Posted July 15, 2016 Hello! Is there a way to make a trigger activate if any number of civilians (E.G Four civilians) are killed? I'm trying to utilize a couple of civilian spawner scripts so a certain unit will chase the player if a certain number of civilians are killed, I searched online for a couple of help but with no avail. It might seem pretty complicated or impossible (S.P mission btw not online) Any help is appreciated! (I pretty much am focusing into editing missions now not modifications :)) Thanks! Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted July 15, 2016 Most precise way would be to add killed eventhandlers to all civilians as soon as they're spawned and modify a global variable after each eventhandler goes off. Cheers Share this post Link to post Share on other sites
ahmedslimkw 223 Posted July 15, 2016 Most precise way would be to add killed eventhandlers to all civilians as soon as they're spawned and modify a global variable after each eventhandler goes off. Cheers Thanks for the quick response! Unfortunately I'm not really a good script creator as I only used very basic scripts. Do you have more like a step-by-step guide? Much appreciated! Thanks! (Il google search the eventHandlers on the wiki, maybe I could learn a thing or two! :)) Share this post Link to post Share on other sites
KevsNoTrev 44 Posted July 15, 2016 i have done this in the past - add a killed evenhandler to the civilian, checking if a player killed them as they get run over by others drivers on occasion. This EH will need to count the number of dead Civs, once its at a desired level run your script to end mission or other punishment. if you want to try it yourself resist the urge to peek.... btw not tested fully as had to pull this out of a mission. // Global variable to hold the death counter. DeadCivilians = 0; CivMaxDeath=5; if isServer then { // Function to update death counter. fnc_countCivDeaths = { DeadCivilians = DeadCivilians + 1; if (DeadCivilians >=CivMaxDeath) then { //======endmission or punishment stuff goes here======= }; // Send the new value to clients only needed for MP publicvariable "DeadCivilians"; }; // Client side. } else { // Function to display the death count. fnc_showCivDeathCount = {hintsilent format ["Dead Civilians: %1",DeadCivilians];}; // PublicVariable eventhandler to catch the update sent by the server. "DeadCivilians" addPublicVariableEventHandler {call fnc_showCivDeathCount}; }; // Civ EH check if player is killer <<---- will need to be added to civ spawn script and change the variable for the unit _CivUnit addEventhandler ["killed",{ params ["_unit","_killer"]; if (isplayer _killer) then { call fnc_countCivDeaths }; };]; Share this post Link to post Share on other sites
ahmedslimkw 223 Posted July 15, 2016 i have done this in the past - add a killed evenhandler to the civilian, checking if a player killed them as they get run over by others drivers on occasion. This EH will need to count the number of dead Civs, once its at a desired level run your script to end mission or other punishment. if you want to try it yourself resist the urge to peek.... btw not tested fully as had to pull this out of a mission. // Global variable to hold the death counter.DeadCivilians = 0;CivMaxDeath=5;if isServer then { // Function to update death counter. fnc_countCivDeaths = { DeadCivilians = DeadCivilians + 1; if (DeadCivilians >=CivMaxDeath) then { //======endmission or punishment stuff goes here======= }; // Send the new value to clients only needed for MP publicvariable "DeadCivilians"; };// Client side.} else { // Function to display the death count. fnc_showCivDeathCount = {hintsilent format ["Dead Civilians: %1",DeadCivilians];}; // PublicVariable eventhandler to catch the update sent by the server. "DeadCivilians" addPublicVariableEventHandler {call fnc_showCivDeathCount};};// Civ EH check if player is killer <<---- will need to be added to civ spawn script and change the variable for the unit _CivUnit addEventhandler ["killed",{ params ["_unit","_killer"]; if (isplayer _killer) then { call fnc_countCivDeaths }; };]; Many thanks for the code! Il check it out and report in ASAP! (apparently I'm gonna sleep in a hour so rip) Regarding the =CivMaxDeath) then { is it possible if there is a number of civilians killed it will execute the waypoint of a unit making It chase the player? Share this post Link to post Share on other sites
KevsNoTrev 44 Posted July 15, 2016 absolutely your choice- i left that part with just a comment on where to put your stuff. e.g. fnc_countCivDeaths = { DeadCivilians = DeadCivilians + 1; if (DeadCivilians >=CivMaxDeath) then { //leader group _unitname setwaypoint ..... etc // finish as desired. }; // Send the new value to clients only needed for MP publicvariable "DeadCivilians"; }; this may have to be refined as 4 people could be killed if you take out an ifrit with an RPG/Tiatn etc. It will run the finish 4 times. I would suggest having a script called that will only run if it has not been triggered yet.Being server side (local for SP) you could change a CheckIfRunning variable to true and only if false run the script 1 Share this post Link to post Share on other sites
ahmedslimkw 223 Posted July 15, 2016 absolutely your choice- i left that part with just a comment on where to put your stuff. e.g. fnc_countCivDeaths = { DeadCivilians = DeadCivilians + 1; if (DeadCivilians >=CivMaxDeath) then { //leader group _unitname setwaypoint ..... etc // finish as desired. }; // Send the new value to clients only needed for MP publicvariable "DeadCivilians"; }; this may have to be refined as 4 people could be killed if you take out an ifrit with an RPG/Tiatn etc. It will run the finish 4 times. I would suggest having a script called that will only run if it has not been triggered yet.Being server side (local for SP) you could change a CheckIfRunning variable to true and only if false run the script Thank you very much for your time! Il utilize this info and report in if I get it working :D Thanks! Share this post Link to post Share on other sites
AZCoder 921 Posted July 15, 2016 Arma 3 introduced mission event handlers ... you could just check when anyone is killed and see if they are civilian or not. Just throwing this out there because I don't think it's commonly known yet. https://community.bistudio.com/wiki/Arma_3:_Event_Handlers/addMissionEventHandler#EntityKilled addMissionEventHandler ["EntityKilled", { if (side (_this select 0) == civilian) then { systemChat "Civ killed"; } }]; 1 Share this post Link to post Share on other sites
ahmedslimkw 223 Posted July 16, 2016 Arma 3 introduced mission event handlers ... you could just check when anyone is killed and see if they are civilian or not. Just throwing this out there because I don't think it's commonly known yet. https://community.bistudio.com/wiki/Arma_3:_Event_Handlers/addMissionEventHandler#EntityKilled addMissionEventHandler ["EntityKilled", { if (side (_this select 0) == civilian) then { systemChat "Civ killed"; } }]; Good to know man! Il delve in the mission event handlers, maybe il find something useful :) Thanks for the code! Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted July 16, 2016 Be careful when using that, since dead units are always on the civilian side. You can either set the side as a variable on the unit and retrieve it once it's been killed, or you simply get the side from the units config (which can lead to problems if the unit gets joined into a different sides group). Cheers Share this post Link to post Share on other sites
ahmedslimkw 223 Posted July 16, 2016 Be careful when using that, since dead units are always on the civilian side. You can either set the side as a variable on the unit and retrieve it once it's been killed, or you simply get the side from the units config (which can lead to problems if the unit gets joined into a different sides group). Cheers Ah! thanks a absolutely your choice- i left that part with just a comment on where to put your stuff. e.g. fnc_countCivDeaths = { DeadCivilians = DeadCivilians + 1; if (DeadCivilians >=CivMaxDeath) then { //leader group _unitname setwaypoint ..... etc // finish as desired. }; // Send the new value to clients only needed for MP publicvariable "DeadCivilians"; }; this may have to be refined as 4 people could be killed if you take out an ifrit with an RPG/Tiatn etc. It will run the finish 4 times. I would suggest having a script called that will only run if it has not been triggered yet.Being server side (local for SP) you could change a CheckIfRunning variable to true and only if false run the script I tried this script and it worked perfectly when i used a hint! However when im completely stuck on how to generate a waypoint in a script, I want a unit named "Test" To follow a players position if any number of civilians are killed. I went online and checked a couple of answers and definitely the script works! But now im stuck with the waypoints... Thanks a bunch all of you who helped me! :D Share this post Link to post Share on other sites
Mynock 243 Posted July 16, 2016 Would using a while/do loop to tell the unit to move to the player's position every few seconds that is triggered to run when the civilian death count reaches a certain threshold work? Share this post Link to post Share on other sites
ahmedslimkw 223 Posted July 16, 2016 Would using a while/do loop to tell the unit to move to the player's position every few seconds that is triggered to run when the civilian death count reaches a certain threshold work? Hmm I'm not sure on what you mean as I'm very basic in scripting ATM. If you mean that if a civillian death count reaches a threshold a unit will continuesly move to the players position in a attempt to kill them (possible with an opfor unit continuesly moving to the blufor unit *player* in an attempt to bring him down) Then yeah, except I don't know the script and tried using numerous scripts to add a waypoint with either error and or it not executing at all... Thanks for trying to help! Share this post Link to post Share on other sites
Mynock 243 Posted July 16, 2016 while { whatever-condition-you-want-to-have-happen } do { chaserUnit doMove position player; sleep 5; };So using one of the other scripts above for the civilian death count, create a variable or something when the civilian death count is reached, plug that condition into the brackets between the while and do, and then the unit named chaserUnit (or whatever variable name you used) will move to the player's position every 5 seconds, creating a chase type effect. You'll probably want to use additional commands like setBehaviour and setSpeedMode to get the unit to actually chase the player vs just walking after them. Share this post Link to post Share on other sites
killzone_kid 1326 Posted July 16, 2016 Perhaps this would be easier: 1 Share this post Link to post Share on other sites
ahmedslimkw 223 Posted July 16, 2016 while { whatever-condition-you-want-to-have-happen } do { chaserUnit doMove position player; sleep 5; };So using one of the other scripts above for the civilian death count, create a variable or something when the civilian death count is reached, plug that condition into the brackets between the while and do, and then the unit named chaserUnit (or whatever variable name you used) will move to the player's position every 5 seconds, creating a chase type effect. You'll probably want to use additional commands like setBehaviour and setSpeedMode to get the unit to actually chase the player vs just walking after them. Perhaps this would be easier: Thanks a bunch for your help you two! Il test your script Mynock and if it doesn't work il use KK solution (Put the condition on the waypoint condition box might be the solution?) Many thanks! Share this post Link to post Share on other sites
Mynock 243 Posted July 16, 2016 What I wrote and what killzone_kid showed you accomplish two different things. Used in conjunction you can likely accomplish your goal. In the On Act. field of the trigger you can execute the while/do script to start the enemy unit chasing the player. Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted July 16, 2016 Perhaps this would be easier: This will only work reliably if the required number of civs will be killed in short succession after each other, since dead units will be removed from their groups after a short time (something like 2 minutes, can't recall). Cheers Share this post Link to post Share on other sites
killzone_kid 1326 Posted July 17, 2016 This will only work reliably if the required number of civs will be killed in short succession after each other, since dead units will be removed from their groups after a short time (something like 2 minutes, can't recall). Cheers Then one can countSide instead and check if it falls below threshold.// total civilians 10 civilian countSide allUnits < 7 even easier Share this post Link to post Share on other sites
ahmedslimkw 223 Posted July 17, 2016 What I wrote and what killzone_kid showed you accomplish two different things. Used in conjunction you can likely accomplish your goal. In the On Act. field of the trigger you can execute the while/do script to start the enemy unit chasing the player.Appreciate the heads up! Sorry If i replied late, dozed off on my bed :PIl use the script one by one the in conjunction just to make sure I don't make any mistakes :) il first mix both of your solution then go one by one hopefully making it happen. Thanks! Share this post Link to post Share on other sites
AZCoder 921 Posted July 17, 2016 Be careful when using that, since dead units are always on the civilian side. You can either set the side as a variable on the unit and retrieve it once it's been killed, or you simply get the side from the units config (which can lead to problems if the unit gets joined into a different sides group). Cheers Thanks for pointing that out. I changed my code sample as follows and it seems to work fine for differentiating sides. addMissionEventHandler ["EntityKilled", { private["_entity","_type","_side"]; _entity = _this select 0; _type = typeOf _entity; _side = getNumber (configFile >> "CfgVehicles" >> _type >> "side"); if (_side == 3) then { systemChat format["Civ killed!"]; }; if (_side == 1) then { systemChat format["Blufor killed!"]; }; }]; Share this post Link to post Share on other sites
ahmedslimkw 223 Posted July 18, 2016 (Uhh what the hell my comment didn't appear? Damn this internet) I got it working with the help of Mynocks solution and KevsNoTrev script, KK solution didn't work sadly but it proves useful for hints and stuff. Your all a wonderful bunch! Thanks! 1 Share this post Link to post Share on other sites