Jump to content
Sign in to follow this  
Specter

check which side killed someone

Recommended Posts

Is it possible to check who killed how many members of a different side? as in "killedby"?

what i want to do is have a script activating whenever one of two factions shoot a civilian and after a certain number of dead civilians i want a script to run that arms the civilians and sets them hostile to the faction that hits the kill-counter first...

Share this post


Link to post
Share on other sites

Hi, that might be a big script to ask someone to do...but if I know how I would do it for you.

Also you might check into count commands in the Command Reference for OFP..

Like count units in this list or something?

-----

Also

-----

Try this buddy..

Countenemy

Click that link, that might help you for part of the script..

Share this post


Link to post
Share on other sites

At mission start init a counter variable for each side and the kills limit:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">counterWest = 0;

counterEast = 0;

civDeathLimit = 4;

Then give each each civilian a killed eventhandler:

<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 execVM "civkilled.sqf";}];

civkilled.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private["_killer","_currVal"];

_killer = _this select 1;

_currVal = 0;

if(side _killer == west || side _killer == east) then {

       _currVal = call (compile format["counter%1 = counter%1 + 1; counter%1", side _killer]);

       if(_currVal == civDeathLimit) then {

               [side _killer] execVM "armCivilians.sqf";

               // remove the following 2 lines if you want the civs to be able to go mad at more than one faction

               // an alternative to setting all counters higher than the limit, is to remove the "killed"-ehs from the remaining civ units.

               counterWest = 5;

               counterEast = 5;

       };

};

In the script 'armCivilians.sqf' you can go on now on your own, with arming them and telling them to attack the new enemys ( the value (_this select 0) holds the side that reached the limit). The command 'setFriend' doesn't seem to have any effects on the civilian side, but you can order a civ unit to attack a single target with the command 'doFire'.

Share this post


Link to post
Share on other sites
At mission start init a counter variable for each side and the kills limit:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">counterWest = 0;

counterEast = 0;

counterGuer = 0;

civDeathLimit = 4;

Then give each each civilian a killed eventhandler:

<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 execVM "civkilled.sqf";}];

civkilled.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

private["_killer","_currVal"];

_killer = _this select 1;

{

      _currVal = 0;

      if(format["%1",side _killer] == _x) then {

               _currVal = call (compile format["counter%1 = counter%1 + 1; counter%1", _x]);

       };

       if(_currVal == civDeathLimit) then {

               [_x] execVM "armCivilians.sqf";

               // remove the following 3 lines if you want the

               // civs to be able to go mad at more than one faction

               // an alternative to setting all counters higher than the limit, is to remove the "killed"-ehs from the remaining civ units.

               counterWest = 5;

               counterEast = 5;

               counterGuer = 5;

       };

} forEach ["WEST","EAST","GUER"];

In the script 'armCivilians.sqf' you can go on now on your own, with arming them and telling them to attack the new enemys ( the value (_this select 0) holds the side that reached the limit). The command 'setFriend' doesn't seem to have any effects on the civilian side, but you can order a civ unit to attack a single target with the command 'doFire'.

Nice, that's exactly what I'm looking for.

On the civ-side not attacking, yeah I know that but I was thinking about placing the civilian units under guer, set guer friendly to all at the beginning and then use your script.

And as far as I understand your script from reading it once, I just drop the "counterGuer = 0;" from the init. Is that correct?

Share this post


Link to post
Share on other sites

the entry "GUER" from array in the last the line as well.

Check my post above, I edited it for your needs and shortened it a bit

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  

×