Home   Help Search Login Register  

Author Topic: Diable or unload weapon with exact ammo count  (Read 1421 times)

0 Members and 1 Guest are viewing this topic.

Offline Gnat

  • Addons Depot
  • Former Staff
  • ****
  • I Bite!
    • Gnats
Diable or unload weapon with exact ammo count
« on: 14 Mar 2009, 03:23:53 »
Guys,
I'm wanting to disable a weapon (missile launcher on sub, when very deep) for a short bit, and when I re-enable (back near surface) I want the same ammo count etc
I'm finding that when I use the REMOVEWEAPON and ADDWEAPON the magazine count resets and I can't see any way to a) count extact number of rounds and put exact number of rounds back in.

In reality I'd prefer a method that simply make the weapon (or any gunner) un-firable for a while, but can't think of a trick to that.

Thanks.

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: Diable or unload weapon with exact ammo count
« Reply #1 on: 14 Mar 2009, 06:35:56 »
hm weird .. at least in ofp that remove-addWeapon thing work
from what i can remember.

what about one missile per magazine?

Offline Odin

  • Members
  • *
Re: Diable or unload weapon with exact ammo count
« Reply #2 on: 14 Mar 2009, 08:14:00 »
Would somthing like this work with a get in eventhandler maybe
Code: [Select]
_vehicle = _this select 0;
_position = _this select 1;
_unit = _this select 2;

if (not(_position == "gunner")) exitwith {};
if ((position player select 2)>2) then
  {
   _unit assignAsCargo _vehicle;
   [_unit] orderGetIn true;
  };
if ((position player select 2)<2) then
  {
   _unit assignAsGunner _vehicle;
   [_unit] orderGetIn true;
  };

Untested so not realy sure  :whistle:

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Diable or unload weapon with exact ammo count
« Reply #3 on: 14 Mar 2009, 09:40:16 »
Concerning addweapon/removeweapon: at least with soldiers, probably vehicles too, if you add/removeweapon a weapon it will load a full magazine upon its next reload. Since you're not actually removing any magazines, I don't see how it can "reset" the ammo count --> unless, as mentioned, it has more than one "magazine". So how does it work: is it a torpedo launcher with 1 shot/2 shots per magazine, with like 10 magazines all together, or is it like the FFAR launchers, one big magazine with like 50 shots? If its the latter, the ammo count should be fine - if it's the former, it will have "reloaded" itself when you readd the weapon - but that doesn't mean the magazine with 1 shot or whatever left won't still be there :) Test it to see!

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

Offline Gnat

  • Addons Depot
  • Former Staff
  • ****
  • I Bite!
    • Gnats
Re: Diable or unload weapon with exact ammo count
« Reply #4 on: 14 Mar 2009, 12:04:07 »
@Odin
Thanks, nice idea but I didn't want to shunt the player (or AI around) as they may be able to bypass.

@Wolfrug n kju
Yeh, I was hoping to avoid the 1shot magazine workaround ..... but I've been left with little choice.
Anyhow, works well enough when you control development of the Addon yourself ;)

Quote
_sub = _this Select 0;
_iAmmo = "M_GNTHarpoon_LAS";
_iMag = "1Rnd_Harpoon_LAS";
_iWeapon = "GNTHarpoonLauncher_LAS";

while {(alive _sub)} do {
   _Depthx = _sub animationPhase "FrontCont";   
   if(_Depthx > 0.25) then
   {
      _Mcount = {_x == _iMag} count magazines _sub;
      _sub removeMagazines _iMag;
      while {(alive _sub) and (_sub animationPhase "FrontCont" > 0.25)} do
      {
         sleep 0.05;
      };
      for "_x" from 1 to _Mcount do
      {
         _sub addMagazine _iMag;
      };
      (gunner _sub) selectWeapon _iWeapon;
   };

Cheers guys