gc8 970 Posted December 1, 2018 Hey does anyone happen to have script or something to detect if CAS plane fires bomb or missile? Sometimes it fires machine gun which I need to rule out in my script. I'm using the Fired event handler to detect firing. thx! Share this post Link to post Share on other sites
pierremgi 4740 Posted December 1, 2018 Use firedMan EH (on driver) Share this post Link to post Share on other sites
gc8 970 Posted December 1, 2018 2 minutes ago, pierremgi said: Use firedMan EH (on driver) I don't understand how that helps when I'm currently using Fired EH? Share this post Link to post Share on other sites
Harzach 2507 Posted December 1, 2018 46 minutes ago, gc8 said: I don't understand how that helps when I'm currently using Fired EH? Because of how the Fired EH works (or doesn't, in this case). Read the entry: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Fired *edit* - derp, unless you are attaching the Fired EH to the vehicle, in which case you can simply grab the second or third param: this addEventHandler ["Fired", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; systemchat format ["%1 was fired", _weapon]; }]; Share this post Link to post Share on other sites
gc8 970 Posted December 1, 2018 6 minutes ago, Harzach said: Because of how the Fired EH works (or doesn't, in this case). Read the entry: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Fired Yeah I have the vehicle created on server and Fired EH set on the server so according to my understanding it should work Share this post Link to post Share on other sites
Harzach 2507 Posted December 1, 2018 Just now, gc8 said: Fired EH set on the server Meaning...? Share this post Link to post Share on other sites
gc8 970 Posted December 1, 2018 2 minutes ago, Harzach said: Meaning...? I'm adding the EH to the plane it self: _plane addEventHandler ["Fired", { }]; And it works. Just need a way to detect the machine guns firing Share this post Link to post Share on other sites
Harzach 2507 Posted December 1, 2018 So I'm not sure if there is a way to reliably return the cannon on any aircraft, but if you don't need for it to be dynamic: //A-164 Wipeout this addEventHandler ["Fired", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; if (_weapon == "Gatling_30mm_Plane_CAS_01_F") then {hint "CANNON FIRED"}; }]; Share this post Link to post Share on other sites
gc8 970 Posted December 1, 2018 1 minute ago, Harzach said: So I'm not sure if there is a way to reliably return the cannon on any aircraft, but if you don't need for it to be dynamic: //A-164 Wipeout this addEventHandler ["Fired", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; if (_muzzle == "Gatling_30mm_Plane_CAS_01_F") then {hint "CANNON FIRED"}; }]; I was thinking that but solution that works with mods would be great, that's why I posted here Share this post Link to post Share on other sites
Harzach 2507 Posted December 1, 2018 The first index of weaponsTurret might always be the gun? The config guys would probably know. Share this post Link to post Share on other sites
gc8 970 Posted December 1, 2018 3 minutes ago, Harzach said: The first index of weaponsTurret might always be the gun? The config guys would probably know. I was just browsing the B_Plane_CAS_01_dynamicLoadout_F config but the only weapon listed there is the gatling. So I really don't understand this stuff too well Share this post Link to post Share on other sites
Harzach 2507 Posted December 1, 2018 More to do with standard practice, I mean. In the Wipeout, the gun is the first index returned by weaponsTurret, and it would make sense for that to be a standard across all armed aircraft, since there is always a gun (?) but pylons can be different. Share this post Link to post Share on other sites
Harzach 2507 Posted December 1, 2018 Anyway, this works with the Wipeout: this addEventHandler ["Fired", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; private _cannon = (_unit weaponsTurret [-1]) select 0; if (_weapon == _cannon) then {systemChat format ["%1 FIRED", _weapon]}; }]; Are you adding the EH dynamically (script) or explicitly (in object init)? Share this post Link to post Share on other sites
gc8 970 Posted December 1, 2018 11 minutes ago, Harzach said: More to do with standard practice, I mean. In the Wipeout, the gun is the first index returned by weaponsTurret, and it would make sense for that to be a standard across all armed aircraft, since there is always a gun (?) but pylons can be different. I just tested this with almost all the planes (total 6) and the machine gun was at first index of weaponsTurret [-1] with all planes except the "I_Plane_Fighter_03_dynamicLoadout_F" (buzzard) So that almost worked =/ Share this post Link to post Share on other sites
gc8 970 Posted December 1, 2018 4 minutes ago, Harzach said: Are you adding the EH dynamically (script) or explicitly (in object init)? dynamically from script after plane is created in the script Share this post Link to post Share on other sites
Harzach 2507 Posted December 1, 2018 30 minutes ago, gc8 said: I_Plane_Fighter_03_dynamicLoadout_F Ahh, yeah. The Buzzard uses a gunpod, which is on a pylon. I'm trying to put together something that will detect a gun/cannon via find, but there is NO standard naming convention for vehicle weapon/muzzle classnames! This works for the Buzzard: this addEventHandler ["Fired", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; toLower _weapon; private _str = _weapon splitString "_"; if (_str find "cannon" >= 0) then { hint "IT'S A GUN" }; }]; ...but not every airplane has a gun/cannon with either of those terms in its name, the Wipeout being an example. This way, you'll still need to check the weapon or muzzle name of every aircraft's gun for a relevant string to "grab." Share this post Link to post Share on other sites
gc8 970 Posted December 1, 2018 13 minutes ago, Harzach said: I'm trying to put together something that will detect a gun/cannon via find, but there is NO standard naming convention for vehicle weapon/muzzle classnames! Yes I noticed the same thing. While some air planes have easily identified names for the weapons such as "Missile" or "Rocket" in the name, some don't. Like the buzzard again has only names such as "M_scalpel_AT" and "M_Air_AA" Share this post Link to post Share on other sites
Harzach 2507 Posted December 1, 2018 Maybe if we grab muzzle velocity? Back in a bit! Share this post Link to post Share on other sites
gc8 970 Posted December 1, 2018 Hey I figured it out :D The _projectile can be used to detect which kind of projectile it is. All machine guns are some color tracer. Then there's Bomb, Missile and rocket Share this post Link to post Share on other sites
Harzach 2507 Posted December 1, 2018 this addEventHandler ["Fired", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; if (speed _projectile > 1000) then { hint "IT'S A GUN" }; }]; Share this post Link to post Share on other sites
gc8 970 Posted December 1, 2018 Demo: (vehicle player) addEventHandler ["Fired", { params ["_plane", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; hint format["weapon %1\nmuzzle %2\nmode %3\nammo %4\nmagazine %5\nprojectile %6",_weapon,_muzzle,_mode,_ammo,_magazine,_projectile]; _casAmmo = ["rocket","missile","bomb","tracer"]; _found = false; { if( (tolower (str _projectile)) find _x >= 0 ) then { systemchat format["TYPE IS %1", _x]; _found = true; }; } foreach _casAmmo; if(!_found) then { systemchat format["Unknown projectile: %1", _projectile]; }; }]; Share this post Link to post Share on other sites
Harzach 2507 Posted December 1, 2018 12 minutes ago, gc8 said: Hey I figured it out :D The _projectile can be used to detect which kind of projectile it is. All machine guns are some color tracer. Then there's Bomb, Missile and rocket Nope. With the RHS A10A for example, _projectile returns "empty.p3d." Share this post Link to post Share on other sites
gc8 970 Posted December 1, 2018 2 minutes ago, Harzach said: Nope. With the RHS A10A for example, _projectile returns "empty.p3d." oh rhs, havent tried that! Edit: Works with vanilla though Share this post Link to post Share on other sites
Harzach 2507 Posted December 1, 2018 Checking muzzle velocity is pretty solid, I think. A gun or cannon will always have a very high velocity, while even the hottest rockets or missiles will be relatively slow off the rails. 1 Share this post Link to post Share on other sites
gc8 970 Posted December 1, 2018 Just now, Harzach said: Checking muzzle velocity is pretty solid, I think. A gun or cannon will always have a very high velocity, while even the hottest rockets or missiles will be relatively slow off the rails. could be, thx Will get back to this tomorrow Share this post Link to post Share on other sites