Jump to content
Sign in to follow this  
FunnyCookieEver

Make vehicle vulnerable only by player(vehicle)

Recommended Posts

Is there any way to make enemy plane vulnerable only by player? Player is on the plane to specify. I want to make this because there are a lot of AAA on the ground, that are made to shoot very badly but they are still hitting enemy planes.

Or the other way to make so, that turrets don't cause damage.

Share this post


Link to post
Share on other sites
this addEventHandler ["HandleDamage", {
	params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"];
	if (!(isPlayer _source || isPlayer _instigator)) then {
		_damage = 0;
	};
	_damage
}];

Untested

  • Like 1

Share this post


Link to post
Share on other sites
17 minutes ago, FunnyCookieEver said:

That didn't work

What exactly didn't work?

The plane stops taking damage, as intended.

If you also want to make the vehicles crew immune to any damage (explosions, piercing ammo, etc) where a player is not the damage source you'll have to handle that separately.

 

Cheers

Share this post


Link to post
Share on other sites
28 minutes ago, FunnyCookieEver said:

That didn't work

What exactly did it not do?  I wrote that while writing on a java program at the same time so it's entirely possible that it there is something wrong wit it.

 

If you want both the plane and the pilot not to take damage you can run something along these lines:

private _EHCode = ["HandleDamage", {
	params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"];
	if (!(isPlayer _source || isPlayer _instigator)) then {
		_damage = 0;
	};
	_damage
}];

_plane addEventHandler _EHCode;
(driver _plane) addEventHandler _EHCode;

Or is there a problem with the code itself?  As mentioned I didn't test it so it's certainly 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  

×