Advertisement

Author Topic: "Fired" EH - How to find the corresponding turret? [SOLVED]  (Read 1404 times)

0 Members and 1 Guest are viewing this topic.

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
I'm currently working on a somewhat generic solution for air burst ammo. The idea is to let the weapon fire its original ammo and start a timer. Once the (user defined) time is up the original projectile gets replaced with one that explodes immediately. This way only 3 or 4 additional lines are required per ammo type:

Code: [Select]
someAmmo {
    ... bla ...
};
someAmmo_AirBurst : someAmmo {
    explosionTime =  0.00000001; // using zero does not work properly
    explosive = 1;
};

This approach works quite well with a Vulcan: I compare the bullet direction with the weapon direction and if they match (read: if the bullet has most probably been fired from that gun) I run the fuse script that replaces the old bullet after some time (if it still exists). All this is done from the "Fired" EH.

But it get's tricky if the vehicle has multiple turrets with the same armament. I can't tell which turret was used from the data that's passed to the EH (i.e. unit, weapon, muzzle, mode and ammo) because the data is the same for all turrets. But if I don't know which turret was used I can't do the comparison (note: finding the weapon direction for an arbitrary turret is a pain in itself but it's doable).

All I could do is to check every single turret for near bullets. But I'm not really happy with this solution.

So my question is: is there a reliable way to determine the turret a gun was fired from?
« Last Edit: 07 Mar 2009, 01:14:47 by Worldeater »
try { return true; } finally { return false; }

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: "Fired" EH - How to find the corresponding turret?
« Reply #1 on: 06 Mar 2009, 11:07:09 »
Just a thought:

Since you can get unit who's firing, you can use assignedVehicleRole to figure out the turret path the unit is currently sitting in. I assume a single unit can't sit in more than one turret, right?

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: "Fired" EH - How to find the corresponding turret?
« Reply #2 on: 06 Mar 2009, 12:05:30 »
The problem is that "unit" is the vehicle, not the gunner...  :(
try { return true; } finally { return false; }

Offline i0n0s

  • Former Staff
  • ****
Re: "Fired" EH - How to find the corresponding turret?
« Reply #3 on: 06 Mar 2009, 15:24:32 »
If you have the weapon dir, you get the bullet dir and compare them, if it is in a tolerance, you can say that the bullet came from this turret.

But Wolfrug is right. For AI you can simple replace all bullets, and for human, they can only fire one turret so you can run your script local on each player.

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: "Fired" EH - How to find the corresponding turret?
« Reply #4 on: 06 Mar 2009, 16:11:36 »
 at work here , but thinking out loud :).
 if we can obtain the turret (in my experience the ["Turret",[0]] is actually the last turret defined in the config.cpp according to commanding = -_x and or proxyindex number ). maybe you can get the animationstatus of the recoil on each turret and monitor it , that is assuming it has that animation.

 hope it helps
 DB
I love ofp

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: "Fired" EH - How to find the corresponding turret?
« Reply #5 on: 06 Mar 2009, 23:32:04 »
Certainly in the MH60, the same minigun weapon in different turrets has different names. One is class "M134" and the other is "M134_2" (can't remember which is right and which is left, but I'm sure you can find that out).

In third-party vehicles however, modders may not have shown the same forethought though.

EDIT: bear in mind that with you system, you do damage with a created object (which doesn't affect AI correctly and doesn't blame the original firer for the shot in event handlers). You ideally should have the gun fire the "live" ammo, move that away somewhere safe, replace with created "dummy" ammo, then replace the dummy with the live ammo after the set time. This way, any damage that the weapon does is correctly attributed.
« Last Edit: 06 Mar 2009, 23:36:40 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: "Fired" EH - How to find the corresponding turret?
« Reply #6 on: 07 Mar 2009, 01:14:09 »
Interesting. I like the idea with the different gun names since it is a) simple and b) does not require any additional code (no code, no testing, no bugs).

Problem solved. :)

Regarding the replacement: I know of the implications but replacing it is the whole trick. If I don't delete the original bullet there's no need to replace anything at all.
try { return true; } finally { return false; }