Jump to content
bigshot

How to Only Take Damage from Bullets...is this possible?

Recommended Posts

Im working on updating my Duws mission, and have a scenario where you need to find the enemy HQ building and kill the officer inside of it...but I dont want players just blowing up the building from afar with rockets or bomb drops from Jtac for that matter. it would be played best if they could only kill him with any sort of bullets. While I already made the building itself indestructible he still dies from impact blasts from bombs and rockets.

Is there any way to script it so that he will only take damage from bullets, or a small hand grenade? (taking him from a distance via sniper rifle is also ok).

Share this post


Link to post
Share on other sites

@bigshot,

Disable damage on the NPC,

this allowDamage false;

The NPC will need a "hitPart" Event handler,

this addEventHandler ["HitPart", {
	(_this select 0) params ["_target", "_shooter", "_projectile", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"];
if (_isDirect) then {_target setDamage 1};
}];

Other parameters ("_projectile", "_ammo") may be better than simply "_isDirect" but it's a start.

Have fun!

  • Like 2

Share this post


Link to post
Share on other sites

Thanks very much for this idea!... will have a go at it, although it says this EH wont run unless the shooter is local to the EH.

How might I get this to work if the server is a hosted one (non dedi) and a connected client makes the shot?

Share this post


Link to post
Share on other sites

In init field of the unit to be shot by rifle/gun only

 

this addEventHandler ["handleDamage",{
params ["", "", "_damage", "", "_projectile"];
private _dam = 0;
if (_projectile isKindOf "BulletBase") then {_dam = _damage};
_dam
}];

 

  • Like 2

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

×