Jump to content
Sign in to follow this  
Astrosammy

AI Vehicle run over healing

Recommended Posts

AIs running over each other and the player can be very annoying. Maybe this quick and dirty script is useful for some:

It detects these incidents using the Hit event handler, and repairs the damage.

As I said, its quick and dirty, so I leave this here as a start for more experienced scripters.

And sorry, I know it's a bit hard to read :p.

_handled = [];
//add eventhandler to units spawned at mission start
{_x addEventHandler ["Hit",{

if((vehicle (_this select 1) != _this select 1) && (((_this select 1) distance (_this select 0)) < 10) && (side (_this select 0) == side (_this select 1) || ((side (_this select 0) == west) && (side (_this select 1) == civilian)) || ((side (_this select 1) == west) && (side (_this select 0) == civilian)))) then
{


hint format ["%4 %1 was hit by %5 %2's vehicle and damaged %3 percent.",name (_this select 0),name (_this select 1),((_this select 2)*100),side (_this select 0), side (_this select 1)];

(_this select 0) setDamage ((damage (_this select 0)) - (_this select 2));

};

}];

_handled = _handled + [_x];
} foreach allunits;

while {true} do //add eventhandler to units spawned after mission start
{

{

if (!(_x in _handled)) then
{

_x addEventHandler ["Hit",{

if((vehicle (_this select 1) != _this select 1) && (((_this select 1) distance (_this select 0)) < 10) && (side (_this select 0) == side (_this select 1) || ((side (_this select 0) == west) && (side (_this select 1) == civilian)) || ((side (_this select 1) == west) && (side (_this select 0) == civilian)))) then
{


hint format ["%4 %1 was hit by %5 %2's vehicle and damaged %3 percent.",name (_this select 0),name (_this select 1),((_this select 2)*100),side (_this select 0), side (_this select 1)];

(_this select 0) setDamage ((damage (_this select 0)) - (_this select 2));

};

sleep 0.1;

}];

};

_handled = _handled + [_x];
} foreach allunits;


sleep 0.1;
};

(Script has no arguments)

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  

×