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

Item Upgrade System - need help

Status
Not open for further replies.
Level 1
Joined
Jan 26, 2010
Messages
2
Hi
I'm trying to create an item upgrading trigger.
So far I have made a trigger for each item and each level - it's a complete mess.
Each time You buy an item of the same type, it should upgrade it (till the max level). So i saved the items of the same kind in arrays:

JASS:
Actions
    -------- Set item types --------
    Set ArmorA[0] = Armor
    Set ArmorA[1] = Armor |CFFFF0000Level 2
    Set ArmorA[2] = Armor |CFFFF0000Level 3
    Set BrutallityGlovesA[0] = Brutallity Gloves
    Set BrutallityGlovesA[1] = Brutallity Gloves |CFFFF0000Level 2
    Set BrutallityGlovesA[2] = Brutallity Gloves |CFFFF0000Level 3
    Set ClawA[0] = Claw
    Set ClawA[1] = Claw |CFFFF0000Level 2
    Set ClawA[2] = Claw |CFFFF0000Level 3
    Set HealthStoneA[0] = Health Stone
    Set HealthStoneA[1] = Health Stone |CFFFF0000Level 2
    Set HealthStoneA[2] = Health Stone |CFFFF0000Level 3
    Set MaskofDeathA[0] = Mask of Death
    Set MaskofDeathA[1] = Mask of Death |CFFFF0000Level 2
    Set MaskofDeathA[2] = Mask of Death |CFFFF0000Level 3
    Set SpeedGlovesA[0] = Speed gloves
    Set SpeedGlovesA[1] = Speed gloves |CFFFF0000Level 2
    Set SpeedGlovesA[2] = Speed gloves |CFFFF0000Level 3


I have the the arrays in the size of 5 in case i add more item levels.

Anyway, I wanted to make a trigger that each time you buy an item, will check to which group (array) it relates and set that array into a local variable. I found it out impossible and ended with duplicating each array seperately when needed:

  • Global Upgrade
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Custom script: local Item Type array itm
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Armor
        • Then - Actions
          • For each (Integer A) from 0 to (itemlevelmax - 1), do (Actions)
            • Loop - Actions
              • Custom script: Set itm[Integer A] = ArmorA[Integer A]
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to Brutallity Gloves
            • Then - Actions
              • For each (Integer A) from 0 to (itemlevelmax - 1), do (Actions)
                • Loop - Actions
                  • Custom script: Set itm[Integer A] = BrutallityGlovesA[Integer A]
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item-type of (Item being manipulated)) Equal to Claw
                • Then - Actions
                  • For each (Integer A) from 0 to (itemlevelmax - 1), do (Actions)
                    • Loop - Actions
                      • Custom script: Set itm[Integer A] = ClawA[Integer A]
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Item-type of (Item being manipulated)) Equal to Health Stone
                    • Then - Actions
                      • For each (Integer A) from 0 to (itemlevelmax - 1), do (Actions)
                        • Loop - Actions
                          • Custom script: Set itm[Integer A] = HealthStoneA[Integer A]
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Item-type of (Item being manipulated)) Equal to Mask of Death
                        • Then - Actions
                          • For each (Integer A) from 0 to (itemlevelmax - 1), do (Actions)
                            • Loop - Actions
                              • Custom script: Set itm[Integer A] = MaskofDeathA[Integer A]
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Item-type of (Item being manipulated)) Equal to Speed gloves
                            • Then - Actions
                              • For each (Integer A) from 0 to (itemlevelmax - 1), do (Actions)
                                • Loop - Actions
                                  • Custom script: Set itm[Integer A] = SpeedGlovesA[Integer A]
                            • Else - Actions
                              • Skip remaining actions
      • Item - Remove (Item being manipulated)




Now, I want to check if the hero owns an item of the highest level of the same type of item bought (in case the array in that index isn't null). if he does, I want to check if that item has an upgrade itm[index+1] and if it does, simply remove the itm[index] item and give him an itm[index+1] item.
If the hero doesn't have that item level, go on to itm[index-1] and so on.



In order to do that, I need to relate to the itm array in JASS (since it's local), along with functions like giving and removing items from heros.
I don't know how to do these in JASS and help would be appreciated a lot.

Also, if you have a way to shorten my "array duplication" code, I would like to know how.

Thanks to any helpers :wink:
 
Status
Not open for further replies.
Top