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

[Solved] Item set system - can't get the set bonus to remove

Status
Not open for further replies.
Level 3
Joined
Mar 2, 2017
Messages
13
Greetings. I've made a GUI item set system. It works in a following way:
Every set item has a unique number;
That unique number links an item set it contributes towards, and an item slot it fits (so you can have several interchangeable items);
If you have some items out of set (the pre-defined in constants amount), you gain the reward ability (like in Diablo, WoW and such);
If you have less than required items out of set, you lose the reward ability.

The problem is, you don't. It works as intended except for one part: ability is not removed. Ability can be anything, it does not matter, visible or not, active or passive. You gain it once you collect the set, but then it stays forever.

I get to see "should remove it" message, all other debug message show correct info, but the ability itself stays.

Trigger is nearly the same for pickup phase, the only difference being "picks up an item" and 1 less condition at the "read" phase ((Item carried by (Hero manipulating item) in slot AItemSetCycle) Not equal to (Item being manipulated) is not present there, obviously).
  • SetCheck On Drop
    • Events
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • -------- ------------------------------------------------------------------------------------------------------------------------------------------------------------ --------
      • -------- Read items from the inventory --------
      • -------- ------------------------------------------------------------------------------------------------------------------------------------------------------------ --------
      • For each (Integer AItemSetCycle) from 1 to 6, do (Actions)
        • Loop - Actions
          • For each (Integer ASetCycletemp) from 1 to ItemSetsItemsForSetsCount, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item-type of (Item carried by (Hero manipulating item) in slot AItemSetCycle)) Equal to ItemSetsItemCustomValue[ASetCycletemp]
                  • (Item carried by (Hero manipulating item) in slot AItemSetCycle) Not equal to (Item being manipulated)
                • Then - Actions
                  • Set SetItemIsOwnedInt[ASetCycletemp] = 1
                  • Set ItemSetsItemTableXSlots[ItemSetsSlotNumber[ASetCycletemp]] = 1
                  • Set ItemSetsItemTableYSets[ItemSetsSetNumber[ASetCycletemp]] = 1
                  • Set SetItemSlotToCheck[AItemSetCycle] = 1
                • Else - Actions
      • -------- ------------------------------------------------------------------------------------------------------------------------------------------------------------ --------
      • -------- Check set requirements, mark players if they own any --------
      • -------- ------------------------------------------------------------------------------------------------------------------------------------------------------------ --------
      • Set ItemSetThatWorksForHero[(Player number of (Owner of (Hero manipulating item)))] = 0
      • For each (Integer ItemSetsCycleTemp1) from 1 to ItemSetsSetCountTotal, do (Actions)
        • Loop - Actions
          • For each (Integer ItemSetsCycleTemp2) from 1 to ItemSetsMaxSlots, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ItemSetsItemTableXSlots[ItemSetsCycleTemp2] Equal to 1
                  • ItemSetsItemTableYSets[ItemSetsCycleTemp1] Equal to 1
                • Then - Actions
                  • Set SetItemsHowManyOwnedIn[ItemSetsCycleTemp1] = (SetItemsHowManyOwnedIn[ItemSetsCycleTemp1] + 1)
                  • Game - Display to (All players) the text: (You have set item + (String(ItemSetsCycleTemp2)))
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SetItemsHowManyOwnedIn[ItemSetsCycleTemp1] Greater than or equal to ItemSetRewardReqCount[ItemSetsCycleTemp1]
            • Then - Actions
              • Set ItemSetThatWorksForHero[(Player number of (Owner of (Hero manipulating item)))] = ItemSetsCycleTemp1
              • Game - Display to (All players) the text: Hero has a working ...
            • Else - Actions
          • Game - Display to (All players) the text: ((You own + (String(SetItemsHowManyOwnedIn[ItemSetsCycleTemp1]))) + ( in set + (String(ItemSetsCycleTemp1))))
      • Game - Display to (All players) the text: (String(ItemSetThatWorksForHero[1]))
      • For each (Integer ItemSetsCycleTemp1) from 1 to ItemSetsSetCountTotal, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ItemSetThatWorksForHero[(Player number of (Owner of (Hero manipulating item)))] Equal to ItemSetsCycleTemp1
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ItemSetThatWorksForHeroDupe[(Player number of (Owner of (Hero manipulating item)))] Not equal to ItemSetsCycleTemp1
                • Then - Actions
                  • Unit - Add ItemSetReward[ItemSetThatWorksForHero[ItemSetsCycleTemp1]] to (Hero manipulating item)
                  • Set ItemSetThatWorksForHeroDupe[(Player number of (Owner of (Hero manipulating item)))] = ItemSetThatWorksForHero[ItemSetsCycleTemp1]
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ItemSetThatWorksForHeroDupe[(Player number of (Owner of (Hero manipulating item)))] Equal to ItemSetsCycleTemp1
                • Then - Actions
                  • Unit - Remove ItemSetReward[ItemSetThatWorksForHero[ItemSetsCycleTemp1]] from (Hero manipulating item)
                  • Set ItemSetThatWorksForHeroDupe[(Player number of (Owner of (Hero manipulating item)))] = ItemSetThatWorksForHero[ItemSetsCycleTemp1]
                  • Game - Display to (All players) the text: should remove it
                • Else - Actions
      • -------- ------------------------------------------------------------------------------------------------------------------------------------------------------------ --------
      • -------- Clear item lists --------
      • -------- ------------------------------------------------------------------------------------------------------------------------------------------------------------ --------
      • For each (Integer AClearTemp1) from 1 to ItemSetsItemsForSetsCount, do (Actions)
        • Loop - Actions
          • Set SetItemIsOwnedInt[AClearTemp1] = 0
      • For each (Integer AClearTemp2) from 1 to ItemSetsMaxSlots, do (Actions)
        • Loop - Actions
          • Set ItemSetsItemTableXSlots[AClearTemp2] = 0
      • For each (Integer AClearTemp3) from 1 to ItemSetsSetCountTotal, do (Actions)
        • Loop - Actions
          • Set ItemSetsItemTableYSets[AClearTemp3] = 0
          • Set SetItemsHowManyOwnedIn[AClearTemp3] = 0
Any ideas?
 
Last edited:
Level 3
Joined
Mar 2, 2017
Messages
13
Aight, with a bit of extra debugging solved it. The problem was that the ability I was referencing was incorrect. I've referenced an ability that hero should get. That gave him an ability according to set he possessed when he had one, but when had none, he would have an empty abiity removed. Not a very obscure mistake, but was really tired yesterday, eh.

^ and I like using else as I can hide code parts which are irrelevant at the point. Code is kinda obvious for me as a creator, although probably far from optimized.
 
Status
Not open for further replies.
Top