snkman 351 Posted June 4, 2007 Hey Guy's, just wondering is it possible to detect, if a grenade explodes beside a player? I wanna to make some effect's like in Call of Duty if a grenade explodes right beside you you get a strange beeeeeep and a blackout for some secounds. So i thought would be cool to have this in ArmA too. Share this post Link to post Share on other sites
ManDay 0 Posted June 4, 2007 What about eventhandlers? http://community.bistudio.com/wiki/ArmA:_Event_Handlers#Hit Try it. Me, I never used event handlers but it should work fine. Share this post Link to post Share on other sites
snkman 351 Posted June 4, 2007 Yeah that's what i was thinking about too. I still did some stuff with eventHandlers but i don't know how to find out if a player was damaged by a grenade or impact... So may with the eventHandler "Hit" or "Dammaged" but what should i put in the condition of the eventHandler? Share this post Link to post Share on other sites
ManDay 0 Posted June 4, 2007 Actually I dont even know how to assign an EH to something But hey: Quote[/b] ]Triggered when the unit is hit/damaged.Is not always triggered when unit is killed by a hit. Most of the time only the killed event handler is triggered when a unit dies from a hit. The hit EH will not necessarily fire if only minor damage occurred (e.g. firing a bullet at a tank), even though the damage increased. Isnt that enough? Share this post Link to post Share on other sites
snkman 351 Posted June 4, 2007 Yes but the "Hit" eventHandler also trigges if a unit is hit by a bullet but i need something it only triggers if a unit was wounded by a grenade and or impact. Share this post Link to post Share on other sites
ManDay 0 Posted June 4, 2007 Wouldnt it be possible to check this by the # causedBy: Object - Object that caused the damage. Contains the unit itself in case of collisions. parm? Just a guess you may check which class the object belongs to. Share this post Link to post Share on other sites
snkman 351 Posted June 4, 2007 Hmm... Yes sounds good well now the only think i have to do is to find out how to script that. If there are any suggestions plz let me know! Share this post Link to post Share on other sites
Taurus 20 Posted June 4, 2007 To "trace debug" the whole thing, have the player chat the object Passed array: [unit, causedBy, damage] * unit: Object - Object the event handler is assigned to * causedBy: Object - Object that caused the damage. Contains the unit itself in case of collisions. * damage: Number - Level of damage caused by the hit e.g. player groupChat format["causedBy: %1",_causedBy]; I'll make an example later if needed. Share this post Link to post Share on other sites
snkman 351 Posted June 4, 2007 Yes plz this would be very cool becouse i really don't understand how to use the causedBy thing. I think there also should some ammo types definied in the eventhandler like: GrenadeHand, G_40mm_HE, Sh_125_HE so the eventhandler knows when he should be exec. Share this post Link to post Share on other sites
Taurus 20 Posted June 4, 2007 It seems this is not what you are looking for in the initline of the unit: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler["hit",{nil = _this spawn compile preprocessFile "roflcopter.sqf"}]; (maybe the wrong way to access the script-file?) roflcopter.sqf <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0; _causedBy = _this select 1; _damage = _this select 2; player sideChat format["_unit:%1, causedBy:%2, damage:%3",_unit,_causedBy,_damage]; unit: returns the fellow who took damage. causedBy: returns the one throwing a grenade, firing a bullet and etc.. damage: The amount of damage taken by unit. Share this post Link to post Share on other sites
snkman 351 Posted June 4, 2007 Well nope that's not what im looking for. But anyway thanks for the example i think i now do understand it a bit more. Share this post Link to post Share on other sites
UNN 0 Posted June 5, 2007 You need to use the fired event handle. Here is an example mission and scripts that allow you to execute a script or code, when a Grenade is thrown. You can test for a Grenade landing within a specified range of a player. UNN_GrenadeImpact.zip Adjust the value for the blast proximity in UNNGrenadeImpact.sqs. You need to add the EventHandler for all Players and AI that can thow Grenades, in a single or multiplayer mission. ATM it's only setup for the default BIS grenade. If you want to add more, just update this line in the init.sqf: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">UNN_GRENADECLASSES=["GrenadeHandTimed"]; Share this post Link to post Share on other sites
snkman 351 Posted June 7, 2007 Hey UNN and thank you very much for the script. It work's very well and it's coded very clean with examples to all lines. Really great. Well so this is the only way to get this working? Just if i add a eventHandler to each unit, which can throw grenades? I think on big map's with many unit's this can cause lag if i add a eventhandler to each unit. Don't get me wrong the script is really greate but if there's an easyer way i would be very happy. Share this post Link to post Share on other sites