Jump to content
Sign in to follow this  
Gameadd1cted

Dead civilian (run over), "killed" EventHandler

Recommended Posts

Hi,

Ia BLUEFOR / OPFOR fires at and kills a civilian with a "killed" event handler, it will return the killing unit / object.

Nevertheless, if you run over a civilian (let's say a traffic accident), it will not return the killer.

Moreover, I noticed at the end of the missions that Arma does not take into account death provoked by such accidents.

Is there any way we can know the killer who ran over a civilian?

Edited by Gameadd1cted
More detailed title

Share this post


Link to post
Share on other sites

If there's no killer, then find the nearest player/driver?

Share this post


Link to post
Share on other sites

Shuko, thanks again for the quick answer.

I thought someting similar, but I wanted to make sure there is not a straight forward option (my coding skills are quite limited).

I'll give it a try.

Share this post


Link to post
Share on other sites
If there's no killer, then find the nearest player/driver?

I think this will be triggered if the killed is a player and selects respawn.

Similarly, killer is empty if they fall to their death, or are crushed by something.

But checking for a nearby vehicle is the way forward no doubt. Make sure it has velocity too, I'd suggest.

Share this post


Link to post
Share on other sites

Thanks guys for your help.

I attach the code.

It works only on dedicated server as playableUnits returns an empty array in SP.

private ["_unit","_killer","_vehicles","_y"];
_unit = _this select 0;
_killer = _this select 1;
_vehicles = [];


[color="Gray"]//Detect possible run over[/color]
if (_killer == _unit) then
{
   _vehicles = nearestObjects [_unit, ["car"], 20];

   {
       _y = _x;
       {if (driver _y == _x) then {_killer = driver _y;};
       } forEach playableUnits;
   } forEach _vehicles;

};[color="Gray"]//if over run[/color]

if (side group _killer == west) then
{
	a3d_int_civilian_killed_by_west = a3d_int_civilian_killed_by_west + 1;
	publicVariable "a3d_int_civilian_killed_by_west";
};
[color="gray"]//Must use side group. Otherwise side would return "ENEMY" for renegade units[/color]

if (side group _killer == east) then
{
	a3d_int_civilian_killed_by_east = a3d_int_civilian_killed_by_east + 1;
	publicVariable "a3d_int_civilian_killed_by_east";
};

[color="gray"]//Total civilian death toll[/color]
a3d_int_civilian_killed = a3d_int_civilian_killed + 1;
publicVariable "a3d_int_civilian_killed";
[color="gray"]//a great example for publicVariableEventHandler can be found at:
//http://derfel.org/arma2/publicvariable_and_pveventhandler.html

[/color]

The radius for detecting the nearest vehicles might be decreased.

Nevertheless, nearestObjects returns an array ordered according to the distance, so it shouldn't be a problem.

Share this post


Link to post
Share on other sites

As I said in another thread, you should use nearestObject if you only want 1 returned object. It's much easier on the server CPU.

Share this post


Link to post
Share on other sites
As I said in another thread, you should use nearestObject if you only want 1 returned object. It's much easier on the server CPU.

Thanks, I'll modify it accordingly.

Share this post


Link to post
Share on other sites

hello, what would be the code to get this script working for humans vs humans (PVP) missions ?

I'm using missions with two sides (blufor, opfor) and i'm trying to find a way to get the vehicles run over kills visible in the kill confirmation.

Edited by cychou

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  

×