jubbie 0 Posted December 31, 2005 I was wondering if anyone knew of a script that would help reduce the number of civillian deaths. All too often in my missions people blow the hell out of towns or cars, killing many civillians in the process. Does anyone know of or could make a script that detects if a civillian is killed by a player and then kill or blind that player? I just want people to stop shooting everything they see and using firepower like there are no consequences. Any ideas? Share this post Link to post Share on other sites
Lean Bear 0 Posted January 4, 2006 I pressume that this would be in SP right? Cause I don't think this would work in MP. In your mission, put a biiiggg trigger that covers all the civilians on the island and set it so that it is activated by presence of civilians. Then, in the OnActivation field, type: all_civs = this list (Or is it list this ....) This code should select all the civilians under the trigger and group them into an array called all_civs. (btw You might have to name all the civilians first, if so, just do: c1, c2, c3... c89 etc. but I think it will work without) Then, make a script with code something like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; Delay to make sure OFP has the array safely stored ~5 ; Begin loop #Loop ~0.001 ? {!alive _x} forEach list all_civs : goto "Hurt" goto "Loop" ; Hurt the player a bit to repent for the murder #Hurt ; This will always deduct 25% of his life ; ie. not just take 1 quater away each time, but first 25%, ; then 25% of what is left etc. _life = getDammage player _hurt = _life * (1/4) _hurt / 100 player setDammage (getDammage player - _hurt) goto "Loop" Then run it either from the init.sqs or as the init.sqs and see if it works. There are many flaws to this version tho and it depends on what the mission is like and how many civs there are. If its a lone wolf mission then it should be fine - but if you have trigger happy comrades, then if they shoot a civ, you will get hurt. There are ways around this but it requires even more scripting - so try this out first Share this post Link to post Share on other sites
baddo 0 Posted January 4, 2006 An event handler would be much better for the job because it would not consume nowhere near as much processing power than a looping script checking a trigger's list. Here is an example how to use killed event handlers to punish players if they go and kill civilians. Put this to initialization field of all civilians which you want to have the penalty attached: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["killed",{_this select 1 setpos getpos jail}] Then put an invisible helipad/whatever to a far away island in the map, name it jail and then go and kill the civilian having the event handler. Of course you can start whatever punishment from the event handler, it's your choice. Maybe a small delay before the punishment happens would be nice, with a text saying that the player went too far and must be punished and sent to jail/whatever. Share this post Link to post Share on other sites
thobson 38 Posted January 4, 2006 I have used this to make people un killable <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x addEventHandler [{Hit}, {_this select 0 setDammage 0}]} forEach [array of units] {_x addEventHandler [{Dammaged}, {_this select 0 setDammage 0}]} forEach [array of units] Share this post Link to post Share on other sites
causticwindow911 0 Posted January 5, 2006 Is there any way to make it so that a trigger detects when a player kills a civilian, instead of just having it where a civilian may die randomly? I also would like to know if its possible to do that in MP, without assigning civilians names. Share this post Link to post Share on other sites
Lean Bear 0 Posted January 5, 2006 Yeap, just make a trigger like I described in my first post, then make an init.sqs which looks like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; Init.sqs ~2 ; Add EH to all civs in radius of trigger which checks if the unit who killed them was a player ; If it is, then kill the player (or whatever you'd like to do), otherwise the script will exit. {_x addEventHandler [{killed}, {if (_this select 1 == player) then {player setDammage 1} else {exit}}]} forEach list all_civs Dunno about MP tho I'm afraid. Share this post Link to post Share on other sites
General Barron 0 Posted January 5, 2006 Is there any way to make it so that a trigger detects when a player kills a civilian, instead of just having it where a civilian may die randomly? I also would like to know if its possible to do that in MP, without assigning civilians names. Use a "killed" event handler like Baddo suggested. Put this in the init field of every civillian unit: this addEventHandler ["killed",{_this exec "civ_killer.sqs"}] Then make a script called "civ_killer.sqs". This script could do anything you want it to. I'll post a script that simply kills the unit who killed a civillian (this could kill AI as well as players): civ_killer.sqs: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_killer = _this select 1 _killer setdammage 1 exit Share this post Link to post Share on other sites
Lean Bear 0 Posted January 6, 2006 @ GB That's the same as mine but with an extra script Share this post Link to post Share on other sites
General Barron 0 Posted January 6, 2006 @ GBThat's the same as mine but with an extra script Heh, you're right. I only read your first post, and figured your second one was basically the same thing . You do have a typeo though... Share this post Link to post Share on other sites
Lean Bear 0 Posted January 8, 2006 Oh yeah... thanks for spotting that I was too busy trying to figure out if all the braces were right Corrected now. Share this post Link to post Share on other sites