Jump to content
Sign in to follow this  
AlphaKappa

How to increase a unit/vehicle's health to 200% or more?

Recommended Posts

Does anyone know how to do this? After searching around, I haven't been able to find anything about this. Can you boost the "health" of a helicopter, for example?

Thanks

Share this post


Link to post
Share on other sites

Perhaps you could use "HandleDamage" EventHandler to filter out half or more of damage from every hit. The only idea at the moment.

Edited by Rydygier

Share this post


Link to post
Share on other sites

I use this:

Unit addEventHandler ["HandleDamage", {false}];

Unit addEventHandler ["Hit", {Unit setDamage (0.02 + getDammage Unit)}];

Unit = unit with increase health

0.02 = damage after every hit

It can be used in script or editing

In your case:

In editing named an helicopter like: heli

in its init line copy this:

heli addEventHandler ["HandleDamage", {false}];

heli addEventHandler ["Hit", {heli setDamage (0.01 + getDammage heli)}];

Edited by maxjoiner

Share this post


Link to post
Share on other sites

This seems to make the helicopter near-indestructible to SAM's. Is there some way to modify that or maybe use something else so that the helicopter can be tougher, but not invincible?

Share this post


Link to post
Share on other sites

What's do you think that 0.02 is in the script for?

Share this post


Link to post
Share on other sites

Can't you just return the damage divided in two?

this addEventHandler ["HandleDamage", {((_this select 2)/2)}];

Share this post


Link to post
Share on other sites

This is the correct way:

_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) * [color="#FF0000"]0.5[/color];
	_gethit set [_i, _damage];
	_damage;
}
];

_this select 2 returns the overall damage of the unit after the hit, meaning its old damage plus the new damage. Dividing the damage by two every time the unit gets hit would mostly just heal it unless the hit's power is greater than the unit's current damage.

Edited by Celery

Share this post


Link to post
Share on other sites

When I paste your code into the init field and hit "ok" I get the message "Local variable in global space". I'm assuming it's because of all the underscores, heh. Anyway I'm not sure if my searching lead me to the right place.

I'm trying to tweak a script I just created where a car alarm goes off when a specific car is damaged. There are a few triggers involved too, but it's a bit involved to post it here, anyway... the alarm goes off for 1 minute and then stops. I start and stop the sounds by attaching invisible helipads that play the sound and deleting the helipads when i want the sound to stop. After the alarm stops, I would like for the alarm to go off again if the car takes any further damage. Just like a real car. The script I wrote is not working well. After the minute has passed and the alarm has stopped, a newly created trigger is then ready to check if the vehicle gets hit again and takes further damage - and will set the alarm off again. All I really need to do is check to see if the vehicle has been hit again, it doesn't matter what it was hit by or what part of the vehicle was hit, I just need it to detect if it's been hit again and if I can't do that, then I want to try to get the current getDammage of the vehicle and then have the alarm script go off if the vehicle has been damaged more than the current getDammage amount. I hope that made sense. I'm sure this is possible, but I'm not exactly sure how to script it. I wish it were as simple as putting (wasHitAgain car1) in the condition field, lol.

===========================

(edit)

I'm trying to do something like...

trigger condition:

getDammage car1 >= getDammage car1 + 0.01

trigger activation: will re-run the car alarm script and deletes this trigger

but obviously the condition isn't working for me. Any ideas as to how to make the condition work correctly?

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites
When I paste your code into the init field and hit "ok" I get the message "Local variable in global space".

The FIRST THREE

_unit

have to be replaced by

this

Share this post


Link to post
Share on other sites

I tried putting this in the init field of the car:

this addEventHandler ["hit","hint 'car was hit'"];

This works, but only when I hit the car with a rocket. If I hit the car with a bullet, or lots of bullets, it does not show the hint message at all. I need it to show the hint message if just 1 bullet hits the car.

---------- Post added at 04:53 AM ---------- Previous post was at 03:53 AM ----------

I tried celery's script and everything works correctly now, except my car takes no damage.

If I use this my car alarm script works great and the car detects being hit, but the car never takes damage:

this addEventHandler
[
"HandleDamage",
{
       // this part activates my alarm trigger, the alarm sound plays from an attached invisible helipad, 
       // both the helipad and trigger are deleted and recreated after 60 seconds 
       // to prevent overlapping alarm sounds when the vehicle is hit.
       // So when the alarm stops, it can be set off again if the car is hit again.
carHit=true;    
publicVariable "carHit";
}
];

What would I need to add to this script to make the car take normal damage?

---------- Post added at 05:38 AM ---------- Previous post was at 04:53 AM ----------

Nevermind.

This worked:

this addEventHandler ["HandleDamage", {carHit=true;publicVariable "carHit";((_this select 2)+0)}]; 

Nearly gave up, tried all of the above. Nothing worked on a car. The car was always indestructible. Then I tried what cuel mentioned above and one of the tires on the car went a little flat, but then I couldn't damage the car any further unless I used a maaw, which blew the car up. Then I tried changing the damage to 0, and everything worked perfect.

Thanks cuel, sorta :)

Now my car alarms are working perfectly.

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites

Sort of related to this, how do you check for the damage of a unit, say I wanted to trigger a message when a helicopter had received a certain amount of damage or a certain amount of "health" left (I have one to say when its been destroyed but helicopters in arma often drift down to the ground and don't explode). Is this possible?

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  

×