• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Excess Charges System

Status
Not open for further replies.
Level 5
Joined
Dec 11, 2010
Messages
101
Okay, so ill try to explain what i need the best i can.

Say that in slot 1, my gun has 7/7 charges left. When i reload, it will subtract 7 charges from item in slot 3. I got this working.

My problem is that, if i go to reload even if I am only missing 1 bullet, it will still take away 7 charges.

My Question is:
Is there an Item Action that will subtract Item Charges from slot 3 equal to the number of missing charges from Slot 1?

This is what I had originally, but i'm looking to make it so you dont "lose" excess charges from slot 1.
  • Reload Normal Guns
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • ((Ability being cast) Equal to Reload [W] ) and (((Triggering unit) has buff Speed Cola ) Equal to False)
    • Actions
      • Unit - Remove Swap Weapons [Q] from (Triggering unit)
      • Unit - Remove Reload [W] from (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Charges remaining in (Item carried by (Triggering unit) in slot 1)) Less than or equal to 6) and ((Item-type of (Item carried by (Triggering unit) in slot 1)) Equal to M1911)
        • Then - Actions
          • Floating Text - Create floating text that reads Reloading (1.90 sec... above (Triggering unit) with Z offset 0.00, using font size 10.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
          • Wait 1.90 seconds
          • Item - Set charges remaining in (Item carried by (Triggering unit) in slot 1) to 7
          • Item - Set charges remaining in (Item carried by (Triggering unit) in slot 3) to ((Charges remaining in (Item carried by (Triggering unit) in slot 3)) - 7)
          • Unit - Add Swap Weapons [Q] to (Triggering unit)
          • Unit - Add Reload [W] to (Triggering unit)
          • Floating Text - Destroy (Last created floating text)
        • Else - Actions
If you need me to elaborate, ill try my best.
 
Level 5
Joined
Dec 11, 2010
Messages
101
  • Reload Normal Guns Copy
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • ((Ability being cast) Equal to Reload [W] ) and (((Triggering unit) has buff Speed Cola ) Equal to False)
    • Actions
      • Unit - Remove Swap Weapons [Q] from (Triggering unit)
      • Unit - Remove Reload [W] from (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Charges remaining in (Item carried by (Triggering unit) in slot 1)) Less than or equal to 6) and ((Item-type of (Item carried by (Triggering unit) in slot 1)) Equal to M1911)
        • Then - Actions
          • Floating Text - Create floating text that reads Reloading (1.90 sec... above (Triggering unit) with Z offset 0.00, using font size 10.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
          • Floating Text - Change the lifespan of (Last created floating text) to 0.60 seconds
          • Floating Text - Destroy (Last created floating text)
          • Wait 1.90 seconds
          • Item - Set charges remaining in (Item carried by (Triggering unit) in slot 3) to ((Charges remaining in (Item carried by (Triggering unit) in slot 3)) + (Charges remaining in (Item carried by (Triggering unit) in slot 1)))
          • Item - Set charges remaining in (Item carried by (Triggering unit) in slot 3) to ((Charges remaining in (Item carried by (Triggering unit) in slot 3)) - 7)
          • Item - Set charges remaining in (Item carried by (Triggering unit) in slot 1) to 7
          • Unit - Add Swap Weapons [Q] to (Triggering unit)
          • Unit - Add Reload [W] to (Triggering unit)
        • Else - Actions
          • Unit - Add Swap Weapons [Q] to (Triggering unit)
          • Unit - Add Reload [W] to (Triggering unit)
Nailed it. Dunno why i didn't try this first.
 
The problem doesn't seem clear; however I'm glad you fixed it. But just a word of advice, don't use "waits" if at all possible. The only reason why this trigger even works is because you are using GetTriggerUnit() time after time. This style of GUI is redundant and GetTriggerUnit() should be stored into a variable, and instead of using waits you should use timers.

Waits are not exact and the time it takes to resume the trigger variates highly based on everyone's MS.

I'm not saying what you're doing is wrong, and it will by all means work for you; just remember if you have a problem with your trigger not working properly, check to see if there is a wait in there. Waits can screw up so much.
 
Level 5
Joined
Dec 11, 2010
Messages
101
The trigger worked for the most part, but I ran into another problem when I had 1 charge in slot 3, it would set the slot 1 item to 7 charges despite only havering 1. I solved this as well.

The wait timers are my units "reloading" but still being able to move. Before I had added wait timers, I had cast times that my unit had to stay still while casting (which standing still in my map is not a good idea). I'm not the best with a good portion of the GUI, but for the most part I get things to work.
 
Status
Not open for further replies.
Top