Jump to content
Alicia Clark

How to make a different kind of !alive for my player and AI?

Recommended Posts

Ok, here's an example: if an AI enemy kills my AI squad unit (friend), it will not end the mission. But if I purposely kill my friend AI unit (Friendly Fire), that will end the mission. I wanted to know if you could do things like that in scripting. I'm so sorry if I'm too bad to point things out. My mother tongue is not English. Please bear with me. 

Share this post


Link to post
Share on other sites

There is a BI module for that in editor  -> modules -> others -> friendly fire

Not so handy because you have to sync the AIs you want to protect (by group). Not sure this module works with spawned AIs. Not tested deeply.

 

Or you can add a code:

 

addMissionEventHandler ["entityKilled", { 
  params ["_killed", "_killer", "_instigator"]; 
  if (isNull _instigator) then { _instigator = UAVControl vehicle _killer select 0}; 
  if (isNull _instigator) then { _instigator = _killer }; 
  if ((_killed call BIS_fnc_objectSide) getFriend playerSide >= 0.6 && _instigator == player) then {
     ["end1",FALSE] call BIS_fnc_endMission; 
  }; 
}];

 

in init.sqf,  or even any init field of any object in your editor (all fields are running at start), or, for clarity, in activation field of a trigger with condition set to TRUE (instead of this).

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Sorry to ask you this I'm new of making Arma 3 mission What is "_instigator"?and What should I put in "_instigator"?

Share this post


Link to post
Share on other sites
1 hour ago, Alicia Clark said:

What is "_instigator"?

That's just variable passed to event handler (source).

 

1 hour ago, Alicia Clark said:

What should I put in "_instigator"?

Use it or ignore if you don't need.

Share this post


Link to post
Share on other sites
9 hours ago, Alicia Clark said:

Sorry to ask you this I'm new of making Arma 3 mission What is "_instigator"?and What should I put in "_instigator"?

 

It's a BI workaround for finding the killer (player) controlling a UAV (pilot is an AI). You don't have anything to do, just run the code as is. That works in any case.


If you don't use UAV, you can remove _instigator, with little changes in my script:
 

addMissionEventHandler ["entityKilled", {
  params ["_killed", "_killer"];
  if ((_killed call BIS_fnc_objectSide) getFriend playerSide >= 0.6 && _killer == player) then {
    ["end1",FALSE] call BIS_fnc_endMission;
  };
}];

 

  • Thanks 1

Share this post


Link to post
Share on other sites

You're script is working but it's giving an error Variable space how to fix it?

Share this post


Link to post
Share on other sites
3 hours ago, Alicia Clark said:

You're script is working but it's giving an error Variable space how to fix it?

Can you give more precision about that? Not sure it's coming from these scripts. Do you have some lines from rpt file?

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

×