Jump to content
Sign in to follow this  
super-truite

Ammo event handler

Recommended Posts

For the flashbang mod, I have been using a silly technique to execute some scripts when the ammo explode (dummy particle effects with script executed with "ontimer"...).

Now that I have learned a bit more about editing, I guess I would do it differently, with a "fired" eventhandler on the player side.

But I would like confirmation that there is no such thing as "ammo hit" or "ammo explosion" event handlers?

On the same note, did someone find how the scripted effects, like the camera shake or the Postprocess effects are triggered when a grenade explodes?

The only thing I noticed is this line

simulation = "shotGrenade";

in the Handgrenade class, but I don't see where the simulation classes are defined?

Share this post


Link to post
Share on other sites

I don't think there is any ammo EH for ammunition.

However, you can track the projectile with _this select 6 from the "fired" EH and check if it's still alive in a loop.

_proj = _this select 6;

while {alive _proj} do
{
    sleep 0.1;
};

// code for explosion

Share this post


Link to post
Share on other sites

yes, that was the plan in case there is no ammo EH.

What I don't like is that I have to check, each time someone fires, if the ammo fired is the good one, then check when the ammo explode...

I don't know if the performance hit is noticeable, but it would be more logical to do it from the ammo point of view.

Here we are speaking about a grenade and unless you launch hundreds of them at the same time, I guess the performance gain would be useless, but what if someone wanted to make each bullet of a Gatling gun to trigger some script at impact :)?

And just for the clarity of the codes, this could be an improvement.

But I am sure there is something we are missing, since the BIS grenades are clearly triggering some script-like effects when they explode...

Share this post


Link to post
Share on other sites

Yes, that's a good point. It might not seem like much, but if a lot of addons use "fired" EH then we could end up with multiple handlers triggered every time the player fires something.

I remember looking through the configs for Arma 2 and seeing some interesting stuff here:

http://community.bistudio.com/wiki/CfgAmmo_Config_Reference#explosionEffects

Although the trail goes cold there for me, and I didn't manage to find how the explosion effects are defined or if you can fire another script when calling them.

Share this post


Link to post
Share on other sites

In fact, those correspond to particle effects defined in the CfgCloudet class. It is with this that I managed to define a pseudo-EH for ammunition:

I created a new (dummy) particle effect in the CfgCloudet class, with a unique and invisible particle which triggers a script after its creation (you have the possibility to execute code in a particle effect).

Unfortunately, it is not that reliable (there is a little delay that I didn't manage to remove, between the explosion and the execution of the script) and it is a pretty weird method, which makes the code unreadable by someone else than the creator of the mod...

What is interesting in in your BIKI link though is:

SIMULATION

Description: Declares simulation type. Also affects the behavior the projectile causes to the shooter/object hit; changing "shotShell" to "shotBullet" makes a tank shell pass through more trees rather than being stopped by them, and also removes the recoil which usually affects the tank/vehicle the cannon is mounted to. Changing "shotBullet" to "shotSpread" (OA only) causes the changed ammo to behave like it is buckshot (again, OA only).

Possible values: refer to Models & Classnames: Simulation Types for a list of all supported simulation types.

As I suspected, this seems to be how the effects on player are triggered when a grenade explode. I didn't manage to find where those "simulations" are defined though...

Share this post


Link to post
Share on other sites
As I suspected, this seems to be how the effects on player are triggered when a grenade explode. I didn't manage to find where those "simulations" are defined though...

they are hardcoded unfortunately

your on the right lines though , the nearest way of a psuedo ammoeventhandler is the ontimerscript from the muzzleflash effects grenadhand or thrown muzzle doesnt have one by default but one could be added as an event trigger or direct through the firedhandler as per the other weapons , which obviously is not ammo but back to fired handler

Share this post


Link to post
Share on other sites

:(.

So it seems that I am stuck with my Ammo EH made with duck tape and with "fired" EH...

It won't be really an issue for what I want to do, but I fear that it can be a huge limitation, performance wise, for other people.

I guess it is worth a request on the feedback tracker.

Share this post


Link to post
Share on other sites

yeah , i think a few people would vote it up certainly .

otherwise FSM`s are very good but its hard to get a way to implement to suite all and every scenario . FSM`s are ok for Niche things but for a generic grenade that any unit can throw it becomes a bit more CBA like set up where things are kept from breaking when the next guy adds one and its loaded after yours etc .

of course for you there is the animchanged as grenades have a unique anim , maybe that is just as good as ammo handler for you in this niche event , i suppose but you have that loop waiting for it which i guess what you want to avoid

https://community.bistudio.com/wiki/ArmA:_Event_Handlers#AnimChanged

Edited by Sealife

Share this post


Link to post
Share on other sites

I remember seeing Event Handlers in configs somewhere... I wonder if you could write a custom config that would allow you to insert an EH... I don't remember where I saw it tho lol, but I know some have them...

its a bit unrelated, but I wonder if anyone knows how to get information on a groupmembers set explosives?

what I mean is in you action menu after you set a bomb, it will say touch off 1 or 2 or whatever bombs. how can I find out programatically how many bombs I have and also get the references to them.

I was thinking of creating a exposives panel that would allow you to touch off individual bombs or bombs of others in your group but the only reference I have found sofar is the touchoff action, which indiscriminately blows up everything at once.

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  

×