Home   Help Search Login Register  

Author Topic: How to track unit's primary weapon ammo ?  (Read 689 times)

0 Members and 1 Guest are viewing this topic.

bdfy1

  • Guest
How to track unit's primary weapon ammo ?
« on: 28 Jul 2005, 01:25:06 »
"some ammo" seems to be not very helpfull command , cause it will return true when primary weapons mags expired , but HandGrenades remains.
I can get primary weapon name, all magazines, number of cartridges in the current mag - but all this won't help me in common case:( Name of mag and weapon can be the same but usually they don't
Sugestions how to track unit's ammo?

Lean Bear

  • Guest
Re:How to track unit's primary weapon ammo ?
« Reply #1 on: 28 Jul 2005, 13:38:17 »
Not sure I really get what you mean, but if you use the EH "fired" then that will return the weapon, the muzzle its using (if any), the firing mode (single, burst or auto) and the ammo.

If you had that in a simple loop, you could easily keep track of all of it.

eg. (syntax prob not 100% correct)

Code: [Select]
#Ammo

_unit addEventHandler ["fired", {goto "DisplayAmmo"}]
~0.01

goto "Ammo"

#DisplayAmmo

; Get the values
_ammo = _this select 0
_muzzle = _this select 1
_mode = _this select 2
_weapon = _this select 3

; Return the values in a hint
_displayAmmo = hint Format["Unit is using a %1\nWith a %2 muzzle\nOn %3\n\nRounds left: %4", _weapon, _muzzle, _mode, _ammo]
~1

goto "DisplayAmmo"

bdfy1

  • Guest
Re:How to track unit's primary weapon ammo ?
« Reply #2 on: 28 Jul 2005, 15:27:36 »
not bad idea...
ammo returns number of cartriges in the magazine. If it equals zero for 10 sec or so that means that unit can't reload and he is out of ammo.

bdfy1

  • Guest
Re:How to track unit's primary weapon ammo ?
« Reply #3 on: 28 Jul 2005, 16:44:00 »
solution (addon included )

Offline Blanco

  • Former Staff
  • ****
Re:How to track unit's primary weapon ammo ?
« Reply #4 on: 29 Jul 2005, 05:16:38 »
Smart  :)
I hope units will reload within those 10 seconds, I'll try it out.
I was working on another way, but it's not finished yet.
« Last Edit: 29 Jul 2005, 05:19:52 by Blanco »
Search or search or search before you ask.

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:How to track unit's primary weapon ammo ?
« Reply #5 on: 05 Aug 2005, 11:17:22 »
Ah... I never thought of finding the classname of a unit's muzzle via the 'fired' eventhandler. I was always thinking that the closest you could get was with the 'primaryweapon' command. I guess this makes the 'ammo' command a little more useful than I had last written it off as.

Only problem with this method is that you can only check it when the unit fires, not at your whim. So I guess storing the data in a global variable after each check would be the best way to go if you need this info when they aren't firing...
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:How to track unit's primary weapon ammo ?
« Reply #6 on: 06 Aug 2005, 02:52:29 »
well someone could grab a different weapon and you wouldn't know til they fired, if they fired at all...