Jump to content
avibird 1

Help with a event handler to allow only partial damage when hit by vehicle.

Recommended Posts

Been searching and trying to write a code that will only allow partial damage when hit by a vehicle for all AI units. 

 

AI driving is still something to be desired in Urban settings. Working on mission that has multiple Urban AO with a few Patrol Vehicles link to all the AO.  There must be a way to set damage to units while hit from a a vehicle to only partial damage that will allow the unit to go unconscious but not die. I have another script that allows AI units to heal unconscious units. Any help would be great. 

Share this post


Link to post
Share on other sites

Found this old post from 2014  @KC Grimes wrote this code that seems to work I tweeted the the damage numbers in the script to make the units go unconscious after the first hit but able to be revived. Works better good to assisting Urban combat with vehicles as long as you're running an AI revived script works great.

 

{ _x addEventHandler [ "HandleDamage", { _unit = _this select 0; _selections = _x getVariable ["selections", []]; _gethit = _x getVariable ["gethit", []]; _selection = _this select 1; _projectile = _this select 4; if !(_selection in _selections) then { _selections set [count _selections, _selection]; _gethit set [count _gethit, 0]; }; _i = _selections find _selection; _olddmg = _gethit select _i; _curdmg = _this select 2; if (_projectile == "") then { _newdmg = _olddmg + (_curdmg - _olddmg) / 70; _gethit set [_i, _newdmg]; _newdmg; } else { _curdmg; }; } ]; } forEach allUnits;

 

The original number was 20; _gethit set 

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

×