Jump to content
Sign in to follow this  
vincentz

Script for giving score when AI in group kills enemy

Recommended Posts

Usually I have some idea, but here I'm clueless :(

I want to give 1 score for each kill the AI in my group makes.

eventhandler?

Share this post


Link to post
Share on other sites
eventhandler?

I think this is the only solution.

You need attach for each AI event handler

_unit addEventHandler ["Killed", {_this call onKilledAi}];

Example of event handler:

server\eventHandlers\onKilledAi.sqf

_unit = _this select 0;
_killer = _this select 1;

_killer addScore 1;

_unit spawn {
sleep (5 * 60);

hideBody _this;
};

true

Command addScore works only on server. So you need attach event handler on server.

Edited by Schatten

Share this post


Link to post
Share on other sites

thanks. I was hoping for a "trick" to do it. I have well over 150 (more if selected in MP Parameters) enemy units, and putting eventhandler on all of them, i guess, will slow down the system considerably.

Share this post


Link to post
Share on other sites
I was hoping for a "trick" to do it. I have well over 150 (more if selected in MP Parameters) enemy units, and putting eventhandler on all of them, i guess, will slow down the system considerably.

Try.

If enemy units are placed in editor use this code after mission starts:

{if (!(isPlayer _x)) then {_x addEventHandler ["Killed", {_this call onKilledAi}]}} count (allMissionObjects "CAManBase");

Or simply attach event handler to enemy units during creation using script:

_unit addEventHandler ["Killed", {_this call onKilledAi}];

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  

×