• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Can some1 check if my Item Upgrading trigger may cause issue?

Level 3
Joined
Mar 18, 2023
Messages
28
Hello. First off, I'm a scrub on WE and don't have much time to learn as much as I want to. But I had free time this weekend and wanted to try Indexing stuff for the first time. I made this basic trigger for leveling up certain items and was wondering if someone can check it and see if there's any possible way to exploit it, or if there's an oversight, or if it could cause some kind of major performance issue. I tested it for a bit and had some issues that I think I fixed. Also, if you have a much easier/faster way to do all this without having it be a super complex system or is something that needs installation with a bunch of new triggers or variables, I'd appreciate it too. The map at its core is pretty basic so there's no need to go overboard. Oh and it's a hero def map and all these items are bought from shop with no restriction.

  • Weapon Upg 1
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Triggering unit) has an item of type AllItemTypes[43]) Equal to True
          • Or - Any (Conditions) are true
            • Conditions
              • ((Triggering unit) has an item of type AllItemTypes[1]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[2]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[3]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[4]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[5]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[7]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[8]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[9]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[10]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[11]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[13]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[14]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[15]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[16]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[17]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[19]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[20]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[21]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[22]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[23]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[25]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[26]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[27]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[28]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[29]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[31]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[32]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[33]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[34]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[35]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[37]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[38]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[39]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[40]) Equal to True
              • ((Triggering unit) has an item of type AllItemTypes[41]) Equal to True
    • Actions
      • -------- This is the Item to Upgrade stuff --------
      • Item - Remove (Item carried by (Triggering unit) of type AllItemTypes[43])
      • Set VariableSet CraftIndex = (CraftIndex + 1)
      • Set VariableSet CraftU[CraftIndex] = (Triggering unit)
      • Set VariableSet CraftP[CraftIndex] = (Position of CraftU[CraftIndex])
      • Special Effect - Create a special effect at CraftP[CraftIndex] using Abilities\Spells\Items\AIem\AIemTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation(udg_CraftP[udg_CraftIndex])
      • For each (Integer CraftLoop[CraftIndex]) from 1 to 41, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (CraftU[CraftIndex] has an item of type AllItemTypes[CraftLoop[CraftIndex]]) Equal to True
            • Then - Actions
              • -------- These Items here are the Max Level Items so that's why I don't want it to be affected --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CraftLoop[CraftIndex] Not equal to 6
                  • CraftLoop[CraftIndex] Not equal to 12
                  • CraftLoop[CraftIndex] Not equal to 18
                  • CraftLoop[CraftIndex] Not equal to 24
                  • CraftLoop[CraftIndex] Not equal to 30
                  • CraftLoop[CraftIndex] Not equal to 36
                  • CraftLoop[CraftIndex] Not equal to 42
                • Then - Actions
                  • Item - Remove (Item carried by CraftU[CraftIndex] of type AllItemTypes[CraftLoop[CraftIndex]])
                  • Hero - Create AllItemTypes[(CraftLoop[CraftIndex] + 1)] and give it to CraftU[CraftIndex]
                  • Skip remaining actions
                • Else - Actions
            • Else - Actions
      • Set VariableSet CraftIndex = (CraftIndex - 1)
 
Last edited:

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,619
The only thing that needs to be an Array in that trigger is AllItemTypes. The rest of the variables are either unnecessary or can be normal non-Arrays.

Here's how you can simplify it:
  • Weapon Upg 1
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item class of (Item being manipulated)) Equal to Artifact
      • ((Triggering unit) has an item of type AllItemTypes[43]) Equal to True
    • Actions
      • Set VariableSet CraftU = (Triggering unit)
      • For each (Integer CraftLoop) from 1 to 41, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (CraftU has an item of type AllItemTypes[CraftLoop]) Equal to True
            • Then - Actions
              • -------- Only upgrade non-max level items (multiples of 6 are max) --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (CraftLoop mod 6) Not equal to 0
                • Then - Actions
                  • Special Effect - Create a special effect attached to the origin of CraftU using Abilities\Spells\Items\AIem\AIemTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Item - Remove (Item carried by CraftU of type AllItemTypes[43])
                  • Item - Remove (Item carried by CraftU of type AllItemTypes[CraftLoop])
                  • Hero - Create AllItemTypes[(CraftLoop + 1)] and give it to CraftU
                  • Custom script: exitwhen true
                • Else - Actions
            • Else - Actions
I added an Artifact classification check in the Conditions to help optimize the trigger. You can put all of your Items in a specific classification to prevent this trigger from running when other non-upgradeable items are acquired.

Mod is a math function that you can use to check for multiples of a number. In this case I use it to check if CraftLoop is NOT a multiple of 6 since AllItemTypes[6], [12], [18], etc. are unable to be upgraded.

Custom script: exitwhen true works like Skip remaining actions. Last I remember you need to use this instead but I could be mistaken.

I got rid of the Index variable and unchecked the Array option for the other variables. I also made sure to only remove the upgrade item [43] if we found something to upgrade. I changed the Special Effect to use the origin of the unit which should work fine, this removes the need for the Point variable. Also, you didn't need And - All (Conditions) are true, that's already the default behavior of Conditions. The only time you need AND is when you're using it inside of an OR to create a situation like A + B = true OR C + D = true.

Anyway, if you're ever manually adding 41 conditions to a trigger than it's safe to assume that you're doing something the wrong way. But you had the right idea here, you were just a little too Array heavy and didn't realize you no longer needed the OR conditions.
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,049
Skip remaining actions. Last I remember you need to use this instead but I could be mistaken.
Skip Remaining Actions is return not exitwhen true.

@asdfdude I see that you have an And - All Conditions Are True in your example. What you did would work fine, but you should know that by default all conditions are ANDed together anyway. You would have needed to specify the OR like you did, but not the AND as that doesn't actually change how the conditions are combined.
 
Top