• 🏆 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!

[Trigger] How can I Improve these Triggers?

Status
Not open for further replies.
Level 7
Joined
Sep 8, 2011
Messages
211
Basically what these triggers are for is remembering ammo and clips left (gold is bullets, lumber is clips). Each specific gun has it's own set of bullets and clips, I wanted to know if it is a good Idea using variables with arrays to store them, or should I use hastables? I have no idea how to work with them though.

This trigger below is the ammo memorizer or what ever you want to call it. Right now I only have 2 guns on the map and 2 gun types.
  • Ammo Storing
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Hero has an item of type AK-47) Equal to False
          • (Hero has an item of type Pistol) Equal to False
        • Then - Actions
          • Player - Set Player 1 (Red) Current gold to 0
          • Player - Set Player 1 (Red) Current lumber to 0
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hero has Pistol_One) Equal to True
            • Then - Actions
              • Set Pistol_One_Ammo[1] = (Player 1 (Red) Current gold)
              • Set Pistol_One_Ammo[2] = (Player 1 (Red) Current lumber)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hero has AK47_One) Equal to True
            • Then - Actions
              • Set AK47_One_Ammo[1] = (Player 1 (Red) Current gold)
              • Set AK47_One_Ammo[2] = (Player 1 (Red) Current lumber)
            • Else - Actions
The triggers below is when the hero first picks up the AK-47 and when he picks it up again.
  • AK47 First Pick up
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item being manipulated) Equal to AK47_One
    • Actions
      • Player - Set Player 1 (Red) Current gold to 30
      • Player - Set Player 1 (Red) Current lumber to 1
      • Trigger - Turn off (This trigger)
      • Trigger - Turn on AK47 Repick Up <gen>
  • AK47 Repick Up
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item being manipulated) Equal to AK47_One
    • Actions
      • Player - Set Player 1 (Red) Current gold to AK47_One_Ammo[1]
      • Player - Set Player 1 (Red) Current lumber to AK47_One_Ammo[2]
Thanks for reading.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
The loop doesn't need to run 33 times a second. Maybe betwen 20 and 15 would be ok.

What happens if he has both pistol and ak ? You should make them equipable or something. (maybe you have already done that :D but it's not shown in those triggers)
Maybe:
unit uses item
item used == ak/pistol
set equipedweapon == some variable which represents each weapon can be integer or string
 
Level 7
Joined
Sep 8, 2011
Messages
211
I was just going with something boring like 'You cannot equip another weapon while you have another in your hand'

But that sounds a lot better. The only downside to that is each type of gun has its own buff as well. The starting pistol is -20% attack speed, I'm not sure how I can still only have the buff apply with the specific gun equipped unless I go with a dummy unit casting a spell on the hero.
 
Status
Not open for further replies.
Top