• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Item Charges Problem.

Status
Not open for further replies.
Does someone know the cause of this problem with this code in side this map?

  • Map Variables
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Set MilestonesCount = 1
      • Hashtable - Create a hashtable
      • Set Hashtable = (Last created hashtable)
      • Hashtable - Create a hashtable
      • Set SkillHashtable = (Last created hashtable)
      • Hashtable - Create a hashtable
      • Set SkillHashtable2 = (Last created hashtable)
      • Set WeaponTypes[1] = M4A1 Carbine
      • Set WeaponTypes[2] = AK-47
      • Set WeaponTypes[3] = Ithaca 37
      • Set WeaponTypes[4] = Arctic Warfare Magnum
      • Set WeaponTypes[5] = X1015 Rifle Beam
      • Set WeaponTypes[6] = Baikal IZH-43
      • Set WeaponTypes[7] = Steyr Scout Tactical
      • Set WeaponTypes[8] = RPG-7
      • Set WeaponUnit[1] = M4A1 Carbine
      • Set WeaponUnit[2] = AK-47
      • Set WeaponUnit[3] = Ithaca 37
      • Set WeaponUnit[4] = Arctic Warfare Magnum
      • Set WeaponUnit[5] = X1015 Rifle Beam
      • Set WeaponUnit[6] = Baikal IZH-43
      • Set WeaponUnit[7] = Steyr Scout Tactical
      • Set WeaponUnit[8] = RPG-7 Rocket Launcher
      • Set BulletType[1] = 5.56mm Magazine
      • Set BulletType[2] = 7.62mm Magazine
      • Set BulletType[3] = 12 Gauge Shells
      • Set BulletType[4] = .300 Lapua Magnum
      • Set BulletType[5] = 512V Battery Cubes
      • Set BulletType[6] = 12 Gauge Shells
      • Set BulletType[7] = 7.62mm Magazine
      • Set BulletType[8] = Rockets
      • Set WeaponRounds[1] = 30
      • Set WeaponRounds[2] = 30
      • Set WeaponRounds[3] = 4
      • Set WeaponRounds[4] = 5
      • Set WeaponRounds[5] = 75
      • Set WeaponRounds[6] = 2
      • Set WeaponRounds[7] = 10
      • Set WeaponRounds[8] = 1
      • Set TotalWeapons = 8
      • Set ReloadSounds[1] = Reload1 <gen>
      • Set ReloadSounds[2] = Reload2 <gen>
      • Set ReloadSounds[3] = Reload3 <gen>
      • Set ReloadSounds[4] = Reload4 <gen>
      • Set ReloadSounds[5] = Reload5 <gen>
      • Set ReloadSounds[6] = Reload6 <gen>
      • Set ReloadSounds[7] = Reload7 <gen>
      • Set ReloadSounds[8] = Reload8 <gen>
      • Set ReloadSounds[9] = Reload9 <gen>
      • Set EquipSounds[1] = Equip1 <gen>
      • Set EquipSounds[2] = Equip2 <gen>
      • Set EquipSounds[3] = Equip3 <gen>
      • Set EquipSounds[4] = Equip4 <gen>
      • Set EquipSounds[5] = Equip5 <gen>
      • Set EquipSounds[6] = Equip6 <gen>
      • Set EquipSounds[7] = Equip7 <gen>
      • Set EquipSounds[8] = Equip8 <gen>
      • Set EquipSounds[9] = Equip9 <gen>
      • For each (Integer A) from 1 to 9, do (Actions)
        • Loop - Actions
          • Trigger - Add to Finished Reloading <gen> the event (Time - ReloadTimer[(Integer A)] expires)
      • For each (Integer B) from 1 to 150, do (Actions)
        • Loop - Actions
          • Set TempPoint = (Random point in Random Zombie Group <gen>)
          • Unit - Create 1 ??? (Basic Zombie) for Player 12 (Brown) at TempPoint facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_TempPoint)
      • For each (Integer RepeatInteger) from 1 to 900, do (Actions)
        • Loop - Actions
          • Set TempPoint = (Random point in Random Drop Items <gen>)
          • Unit - Create 1 ??? (Basic Zombie) for Player 12 (Brown) at TempPoint facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_TempPoint)
      • For each (Integer RepeatInteger) from 1 to 300, do (Actions)
        • Loop - Actions
          • Set TempPoint = (Random point in Random Drop Items <gen>)
          • Unit - Create 1 ??? (Mutated Zombie) for Player 12 (Brown) at TempPoint facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_TempPoint)
      • Set RandomZombieGroup = (Units in Random Zombie Group <gen>)
      • Set RandomZombie = (Random unit from RandomZombieGroup)
      • Custom script: call DestroyGroup(udg_RandomZombieGroup)
  • Equip
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-class of (Item being manipulated)) Equal to Permanent
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IsReloading[(Player number of (Owner of (Triggering unit)))] Equal to True
        • Then - Actions
          • Game - Display to (Player group((Owner of (Triggering unit)))) the text: |cffffcc00You can't...
          • Skip remaining actions
        • Else - Actions
      • For each (Integer A) from 1 to TotalWeapons, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Triggering unit)) Not equal to WeaponUnit[(Integer A)]
              • (Item being manipulated) Equal to (Item carried by (Triggering unit) of type WeaponTypes[(Integer A)])
            • Then - Actions
              • Item - Make CurrentlyEquippedItem[(Player number of (Owner of (Triggering unit)))] Unpawnable
              • Set RealAmmoCount = (Charges remaining in (Item being manipulated))
              • Item - Set charges remaining in (Item being manipulated) to 2
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Charges remaining in (Item being manipulated)) Equal to 1
                  • (Charges remaining in (Item being manipulated)) Not equal to 0
                • Then - Actions
                  • Item - Make (Item being manipulated) Pawnable
                  • Item - Set charges remaining in (Item being manipulated) to 1
                  • Item - Make (Item being manipulated) Unpawnable
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Charges remaining in (Item being manipulated)) Not equal to 0
                • Then - Actions
                  • Item - Set charges remaining in (Item being manipulated) to (RealAmmoCount + 1)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Charges remaining in (Item being manipulated)) Equal to 0
                • Then - Actions
                  • Item - Make (Item being manipulated) Pawnable
                  • Item - Set charges remaining in (Item being manipulated) to 0
                • Else - Actions
              • Set HPBefore = (Life of (Triggering unit))
              • Set ManaBefore = (Mana of (Triggering unit))
              • Unit - Replace (Triggering unit) with a WeaponUnit[(Integer A)] using The old unit's life and mana
              • Item - Make CurrentlyEquippedItem[(Player number of (Owner of (Triggering unit)))] Droppable
              • Set CurrentlyEquippedItem[(Player number of (Owner of (Triggering unit)))] = (Item being manipulated)
              • Item - Make (Item being manipulated) Undroppable
              • Sound - Play EquipSounds[(Player number of (Owner of (Triggering unit)))]
              • Set Survivor[(Player number of (Owner of (Last replaced unit)))] = (Last replaced unit)
              • Unit - Set life of (Last replaced unit) to HPBefore
              • Unit - Set mana of (Last replaced unit) to ManaBefore
              • Selection - Select (Last replaced unit) for (Owner of (Last replaced unit))
            • Else - Actions
  • Reload
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-class of (Item being manipulated)) Equal to Permanent
    • Actions
      • For each (Integer A) from 1 to TotalWeapons, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Triggering unit)) Equal to WeaponUnit[(Integer A)]
              • (Item being manipulated) Equal to (Item carried by (Triggering unit) of type WeaponTypes[(Integer A)])
            • Then - Actions
              • Item - Make CurrentlyEquippedItem[(Player number of (Owner of (Triggering unit)))] Unpawnable
              • Set RealAmmoCount = (Charges remaining in (Item being manipulated))
              • Item - Set charges remaining in (Item being manipulated) to 2
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Charges remaining in (Item being manipulated)) Not equal to 0
                • Then - Actions
                  • Item - Set charges remaining in (Item being manipulated) to (RealAmmoCount + 1)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Triggering unit) has an item of type BulletType[(Integer A)]) Equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Charges remaining in (Item being manipulated)) Equal to 1
                      • (Charges remaining in (Item being manipulated)) Not equal to 0
                    • Then - Actions
                      • Item - Make (Item being manipulated) Pawnable
                      • Item - Set charges remaining in (Item being manipulated) to 1
                      • Item - Make (Item being manipulated) Unpawnable
                    • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Charges remaining in (Item being manipulated)) Equal to 0
                    • Then - Actions
                      • Item - Make (Item being manipulated) Pawnable
                      • Item - Set charges remaining in (Item being manipulated) to 0
                    • Else - Actions
                  • Game - Display to (All players) the text: ((|cffffcc00 + ((Name of (Owner of (Triggering unit))) + |r)) + is reloading...)
                  • Countdown Timer - Start ReloadTimer[(Player number of (Owner of (Triggering unit)))] as a One-shot timer that will expire in 2.15 seconds
                  • Custom script: set udg_HandleID = GetHandleId(GetLastCreatedTimerBJ())
                  • Hashtable - Save (Player number of (Owner of (Triggering unit))) as 1 of HandleID in Hashtable
                  • Set ReloadingUnit[(Player number of (Owner of (Triggering unit)))] = (Triggering unit)
                  • Set IsReloading[(Player number of (Owner of (Triggering unit)))] = True
                  • Sound - Play ReloadSounds[(Player number of (Owner of (Triggering unit)))]
                • Else - Actions
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: |cffffcc00You don't...
                  • Set RealAmmoCount = (Charges remaining in (Item being manipulated))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Charges remaining in (Item being manipulated)) Equal to 0
                    • Then - Actions
                      • Item - Make (Item being manipulated) Pawnable
                      • Item - Set charges remaining in (Item being manipulated) to 0
                      • Item - Make (Item being manipulated) Unpawnable
                    • Else - Actions
            • Else - Actions
  • Finished Reloading
    • Events
    • Conditions
    • Actions
      • Custom script: set udg_HandleID = GetHandleId(GetExpiredTimer())
      • Set PlayerID = (Load 1 of HandleID from Hashtable)
      • Sound - Stop ReloadSounds[PlayerID] After fading
      • For each (Integer A) from 1 to TotalWeapons, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of ReloadingUnit[PlayerID]) Equal to WeaponUnit[(Integer A)]
            • Then - Actions
              • Set IsReloading[PlayerID] = False
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Charges remaining in (Item carried by ReloadingUnit[PlayerID] of type BulletType[(Integer A)])) Greater than 1
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Charges remaining in (Item carried by ReloadingUnit[PlayerID] of type BulletType[(Integer A)])) Greater than or equal to WeaponRounds[(Integer A)]
                    • Then - Actions
                      • Set FilledIn = (WeaponRounds[(Integer A)] - (Charges remaining in (Item carried by ReloadingUnit[PlayerID] of type WeaponTypes[(Integer A)])))
                      • Item - Set charges remaining in (Item carried by ReloadingUnit[PlayerID] of type WeaponTypes[(Integer A)]) to ((Charges remaining in (Item carried by ReloadingUnit[PlayerID] of type WeaponTypes[(Integer A)])) + FilledIn)
                      • Item - Set charges remaining in (Item carried by ReloadingUnit[PlayerID] of type BulletType[(Integer A)]) to ((Charges remaining in (Item carried by ReloadingUnit[PlayerID] of type BulletType[(Integer A)])) - FilledIn)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Charges remaining in (Item carried by ReloadingUnit[PlayerID] of type BulletType[(Integer A)])) Less than WeaponRounds[(Integer A)]
                        • Then - Actions
                          • Item - Set charges remaining in (Item carried by ReloadingUnit[PlayerID] of type WeaponTypes[(Integer A)]) to (Charges remaining in (Item carried by ReloadingUnit[PlayerID] of type BulletType[(Integer A)]))
                          • Item - Set charges remaining in (Item carried by ReloadingUnit[PlayerID] of type BulletType[(Integer A)]) to 0
                        • Else - Actions
                • Else - Actions
                  • Game - Display to (Player group((Owner of ReloadingUnit[PlayerID]))) the text: |cffffcc00You don't...
            • Else - Actions
Problem
  • Ammunition gets refilled by 1 automatically when unequipping a weapon then equipping it again at 0 ammo
  • Same problem when reloading at 0 ammo in the weapon
  • Switching to a 0 ammo weapon will increase the switching weapon's ammo inside by 1
  • For some weird reason i think warcraft treats items with 0/1 as same, causing this problem to occur
If you want to inspect the map here it is:
Click Nao
 

Attachments

  • Idiotzombies.w3x
    690.2 KB · Views: 85
Status
Not open for further replies.
Top