Jump to content
Rawshark

Giving the AI more health

Recommended Posts

First off, I know the HandleDamage event handler exists but I can't seem to get it to work in my mission where I need to create a small unit of bullet sponges. I tried adding:

"[this addEventHandler ["HandleDamage",{if (_this select 1!="") then {_unit=_this select 0; damage _unit+((_this select 2)-damage _unit)*0.5}}]"

into the init box of the AI but it seems to not have any effect (at least in MP) as they just died to a single 6.5 round. I am not running ACE or anything so I cant really mess with damage coefficents that way so am looking for a script based solution for this problem.

I also tried:

_unit setVariable ["selections", []];
_unit setVariable ["gethit", []];
_unit addEventHandler
[
"HandleDamage",
{
	_unit = _this select 0;
	_selections = _unit getVariable ["selections", []];
	_gethit = _unit getVariable ["gethit", []];
	_selection = _this select 1;
	if !(_selection in _selections) then
	{
		_selections set [count _selections, _selection];
		_gethit set [count _gethit, 0];
	};
	_i = _selections find _selection;
	_olddamage = _gethit select _i;
	_damage = _olddamage + ((_this select 2) - _olddamage) * 0.5;
	_gethit set [_i, _damage];
	_damage;
}
];

into the init box of the AI but did not get the results I am looking for. i.e- the AI taking a fair number of bullets before going down.

So, if anyone has any experience in either reducing the incoming damage to AI or increasing the AI HP please let me know as I am pretty stuck.

 

Share this post


Link to post
Share on other sites

As long as you return a number inside the eventhandler, it will work.

You need to consider though that a bullet can pass through quite a few body parts, inflicting the same damage multiple times.

Test stuff with basic functions and go from there:

 

this addEventHandler ["HandleDamage",{0.001}];

 

You could use setVariable/getVariable to keep track if the same bullet has hit the object before and ignore all further damage from that bullet, or even delete the bullet after the first hit.

Also _unit won't work in the init field, unless you define it as _unit = this; first, or did you not copy that part to the example?

 

Cheers

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites
34 minutes ago, Grumpy Old Man said:

As long as you return a number inside the eventhandler, it will work.

You need to consider though that a bullet can pass through quite a few body parts, inflicting the same damage multiple times.

Test stuff with basic functions and go from there:

 


this addEventHandler ["HandleDamage",{0.001}];

 

You could use setVariable/getVariable to keep track if the same bullet has hit the object before and ignore all further damage from that bullet, or even delete the bullet after the first hit.

Also _unit won't work in the init field, unless you define it as _unit = this; first, or did you not copy that part to the example?

 

Cheers

 

 

 

Okay, so not being very experienced with scripts I am not entirely sure where to go from here. I passed different arrays but the results were either - target dies in one hit to the target takes 4 mags (_this select 0). I am quite clueless as to how to make sense of this EH so I don't really know what my next step would be to make a target take around 6-7 bullets to expire. Like you said it seems to work if there is a number in the EH but having experimented between 0 - 1 I can't seem to find that sweet zone of damage for the AI.
 

Share this post


Link to post
Share on other sites
7 hours ago, Rawshark said:

Okay, so not being very experienced with scripts I am not entirely sure where to go from here. I passed different arrays but the results were either - target dies in one hit to the target takes 4 mags (_this select 0). I am quite clueless as to how to make sense of this EH so I don't really know what my next step would be to make a target take around 6-7 bullets to expire. Like you said it seems to work if there is a number in the EH but having experimented between 0 - 1 I can't seem to find that sweet zone of damage for the AI.
 

 

"in one hit"

 

damage is more complex than this ... was it to the head, torso, arms, legs, etc?

 

 

Share this post


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

 

"in one hit"

 

damage is more complex than this ... was it to the head, torso, arms, legs, etc?

 

 

Torso. 

I have placed "this addEventHandler ["HandleDamage", { private _out_damage = 0; if (_this select 1!="") then { _unit=_this select 0; _out_damage = 0.5; }; _out_damage }];" in the init box of my target in the hopes that I am applying half damage but it just makes the target invulnerable. I suspect what is happening is that I am resetting the damage with every hit, so while the target is getting damaged (I do see the clothing getting bloodied) I ddon'tseem to be able to drop his health to 0.

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

×