Upgrading item ability upon repeated purchase

Moradiae

TH.net Regular
Reaction score
14
hello :),

what I am trying to do is having items that are upgradable when you keep buying them,

Initially,
I tried creating 10 items for 1 item with 10 upgrades and 10 abilities for each of them.
Then remove the [item]lv1 you just brought if your inventory have [that same item]lvX where x is greater than 1 and less than 9.
That is done by dropping that [item]lvX and create a new item of [that same item]lv X+1 and removing last dropped item

However, even with that, I was struggling with the triggers, plus it means I would have to do the same thing to all other items in the future, so I need an easier way of doing this...

From what I've found, this can be done by
Making them charged items and
Then setting the level of corresponding ability in that item equal to the number of charges.

So now the trigger is
Combining the same type of item into 1 with the sum of the charges of the 2 combining items.
Then make the level of ability of that combined item equal to the number of charges

The problem is I don't know how to do that as I have very little experience in playing with items and associating trigger functions,
however, I found this thread about the same thing, but it was outdated and one of the answerer removed the link to the map containing his trigger so all the variables he used are unknown to me:
Item Ability-Level Up

Here's the trigger by Dameon in the above link:
Code:
[B]UI MI[/B]
    Events
        Map initialization
    Conditions
    Actions
        -------- Items Varible --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
            Then - Actions
                Set ItemT_UI[1] = Item 1
                Set ItemT_UI[2] = Item 2
            Else - Actions
        -------- Abilitys Varible --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
            Then - Actions
                Set Ability_UI[1] = Item 1 
                Set Ability_UI[2] = Item 2 
            Else - Actions

Code:
[B]Item Upgradeing[/B]
    Events
        Unit - A unit Acquires an item
    Conditions
    Actions
        For each (Integer Slot) from 1 to 6, do (Actions)
            Loop - Actions
                For each (Integer Interger_UI_IC) from 1 to 2, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Item-type of (Item being manipulated)) Equal to ItemT_UI[Interger_UI_IC]
                                (Charges remaining in (Item carried by (Hero manipulating item) in slot Slot)) Less than 5
                                (Item-type of (Item carried by (Hero manipulating item) in slot Slot)) Equal to (Item-type of (Item being manipulated))
                                (Item carried by (Hero manipulating item) in slot Slot) Not equal to (Item being manipulated)
                            Then - Actions
                                Item - Set charges remaining in (Item carried by (Hero manipulating item) in slot Slot) to ((Charges remaining in (Item carried by (Hero manipulating item) in slot Slot)) + (Charges remaining in (Item being manipulated)))
                                Item - Remove (Item being manipulated)
                            Else - 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 Slot)) Equal to ItemT_UI[Interger_UI_IC]
                                (Charges remaining in (Item carried by (Hero manipulating item) in slot Slot)) Greater than 5
                            Then - Actions
                                Set Point_Temp = (Position of (Hero manipulating item))
                                Item - Create ItemT_UI[Interger_UI_IC] at Point_Temp
                                Custom script:   call RemoveLocation (udg_Point_Temp)
                                Item - Set charges remaining in (Last created item) to ((Charges remaining in (Item carried by (Hero manipulating item) in slot Slot)) - 5)
                                Item - Set charges remaining in (Item carried by (Hero manipulating item) in slot Slot) to 5
                                Hero - Give (Last created item) to (Hero manipulating item)
                            Else - 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 Slot)) Equal to ItemT_UI[Interger_UI_IC]
                            Then - Actions
                                Unit - Set level of Ability_UI[Interger_UI_IC] for (Hero manipulating item) to (Charges remaining in (Item carried by (Hero manipulating item) in slot Slot))
                            Else - Actions

Code:
[B]Item Charge Set[/B]
    Events
        Unit - A unit Uses an item
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Item-type of (Item being manipulated)) Equal to Item 1
            Then - Actions
                Item - Set charges remaining in (Item being manipulated) to ((Charges remaining in (Item being manipulated)) + 1)
            Else - Actions


Now even without the variables in it, the trigger itself is pretty confusing to me =.=
Any help would be appreciated :thup:
 
Try this

Trigger 1
Trigger:
  • events
    • Map initialization
    • conditions
    • none
    • actions
    • Set items[1] = [your item here]
    • Set items[2] = [your item here]
    • Set items[3] = [your item here]
    • Set Ability[1] = [your ability corresponding to Item 1]
    • Set Ability[2] = [your ability corresponding to Item 2]
    • Set Ability[3] = [your ability corresponding to Item 3]


Trigger 2

Trigger:
  • events
    • Unit Acquires an Item
    • conditions
      • none
    • Actions
      • For integer A from 1 to 3 (3 being the amount of items in your integers)
        • loop actions:
        • if -
          • Item is equal to Items[integer a]
      • then -
        • Item - remove (item being manipulated) from (Hero manipulating item)
        • if - level of ability Ability[integer a] is greater then 0 = true
        • then -
          • Unit -Increase Level of Ability[integer a]
        • else -
          • unit - add Ability[integer a] to (hero manipulating item)
      • else -
      • do nothing


Ive never tried this kind of system before but i hope this helps (idk if it will work or not btw ^.^)
 
Don't really understand your code in trigger 2 there..., is it just me or is the sub "Then-Actions" things are kinda weirdly placed?

Anyhow, here's what I made out of it, since I'll be testing it with one item for now, a red shoe that adds bonus to a hero's movement speed:

Code:
[B]set var[/B]
    Events
        Map initialization
    Conditions
    Actions
        Set Item_upable[1] = Red Shoe
        Set abt_foritem[1] = Item Abt - Red Shoe (max lv 10)

Code:
[B]up item[/B]
    Events
        Unit - A unit Acquires an item
    Conditions
    Actions
        For each (Integer A) from 1 to 1, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Item-type of (Item being manipulated)) Equal to Item_upable[(Integer A)]
                    Then - Actions
                        Item - Remove (Item being manipulated)
                        Unit - Increase level of abt_foritem[(Integer A)] for (Hero manipulating item)
                    Else - Actions
                        Do nothing


Please let me know if I've interpretted any part wrongly,
anyhow, here's the result i've tried using the code above.

Results:
the item get removed from my inventory instantly when i purchase it
i get the level 1 of that ability_foritem[A] but upon repeated purchase, it doesn't increase and the item is removed everytime

I faced the problem of item being removed a couple of times now but this one is something as it adds the ability up (once),
so I was thinking if instead, if there's a way to check
Event - unit acquires an item
Condition - hero manipulating item have 2 of the same item-type of item being manipulated?

because if so, then removing it would mean there's still one left (preferably the old one with ability of some level X and
Then remove the one you just brought (with ability of level 1)
and increase the level of ability for hero manipulating item (to X+1)??

wait, this is getting confusing with me trying to put everything into one post, let me get this on first, and try what i've wrote myself :q

========================================================EDITED 1

the closest I got to coding the condition: hero manipulating item have 2 of the same item-type of item being manipulated is
Trigger:
  • Ifs - conditions
    • (Number of items carried by (Hero manipulating item)) Greater than or equal to 2


but that would only works if there's 1 item type in the whole system,
I couldn't do like --> (Number of item-type of (item being manipulated) carried by (hero manipulating item)) >= 2

========================================================EDITED 2

tried another way from this link:
Trigger:
  • <b>up item 2</b>
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 1, do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 6, 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 (Integer B))) Equal to Item_upable[(Integer A)]
                  • (Item carried by (Hero manipulating item) in slot (Integer B)) Not equal to (Item being manipulated)
                • Then - Actions
                  • Item - Remove (Item being manipulated)
                  • Item - Set charges remaining in (Item carried by (Hero manipulating item) in slot (Integer B)) to ((Charges remaining in (Item carried by (Hero manipulating item) in slot (Integer B))) + 1)
                • Else - Actions
                  • Do nothing


the item stacks up!!! :D
All I need to do now is include Actions to set the level of ability to the number of charges right?
let me see how it will turn out first =q
 
fixed it in WE after testing it

Important lines are color coded and the meanings at the bottom

Code:
Item Int
    Events
        Map initialization
    Conditions
    Actions
[COLOR="Magenta"]        Set Items[1] = Thunder Clap
        Set Items[2] = Trueshot[/COLOR]
[COLOR="Cyan"]        Set Ability_Item[1] = Thunder Clap 
        Set Ability_Item[2] = Trueshot Aura[/COLOR]



Code:
Ability Advance
    Events
        Unit - A unit Acquires an item
    Conditions
    Actions
        For each (Integer A) from 1 to 2, do (Actions)
            Loop - Actions

                -------- this IF statement controls Thunderclap in the first condition --------

                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Item-type of (Item being manipulated)) Equal to Thunder Clap
                    Then - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                [COLOR="Yellow"](Level of Ability_Item[1] for (Hero manipulating item)) Greater than 0[/COLOR]
                            Then - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        [COLOR="Red"](Level of Ability_Item[1] for (Hero manipulating item)) Equal to 3[/COLOR]
                                    Then - Actions
                                        Hero - Drop (Item being manipulated) from (Hero manipulating item)
                                        Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: Ability Already Max...
                                    [COLOR="Lime"]Else - Actions
                                        Item - Remove (Item being manipulated)
                                        Unit - Increase level of Ability_Item[1] for (Hero manipulating item)[/COLOR]
[COLOR="DarkOrange"]                            Else - Actions
                                Item - Remove (Item being manipulated)
                                Unit - Add Ability_Item[1] to (Hero manipulating item)[/COLOR]
                    Else - Actions
                        Do nothing
                -------- this IF statment controls Trueshot in the first condition --------
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Item-type of (Item being manipulated)) Equal to Trueshot
                    Then - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                [COLOR="Yellow"](Level of Ability_Item[2] for (Hero manipulating item)) Greater than 0[/COLOR]
                            Then - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        [COLOR="Red"](Level of Ability_Item[2] for (Hero manipulating item)) Equal to 3[/COLOR]
                                    Then - Actions
                                        Hero - Drop (Item being manipulated) from (Hero manipulating item)
                                        Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: Ability Already Max...
                                    [COLOR="Lime"]Else - Actions
                                        Item - Remove (Item being manipulated)
                                        Unit - Increase level of Ability_Item[2] for (Hero manipulating item)[/COLOR]
[COLOR="DarkOrange"]                            Else - Actions
                                Item - Remove (Item being manipulated)
                                Unit - Add Ability_Item[2] to (Hero manipulating item)[/COLOR]
                    Else - Actions
                        Do nothing
Green - Increases level after the unit already has the inital ability
Orange - Adds the ability to the unit the first time he acquires the item
Magenta - Variable Type Item (array)
red - Controls the max level of the ability
cyan - Variable type is ability (array)
Yellow - Checks if the unit that acquires the item already has the ability or not


Map attached
 

Attachments

  • Item Test.w3x
    17.8 KB · Views: 96
neat!! :thup:

can't figure out with the font style in this forums, but i got it now after openning the map XD

so I can actually combine A number of IF statement controls for different items by looping integer A right?

Let see how I can combine all this into what I want :D
 
Actually the for integer a does nothing in this trigger (i forgot to delete it xD) but yes you can have an unlimited amount of ifs inside of each other
 
This is what I have at the moment:

Trigger:
  • set var
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Item_upable[1] = Red Shoe
      • Set Item_upable[2] = Protective Ring
      • Set item_cost[1] = 1
      • Set item_cost[2] = 3
      • Set abt_foritem[1] = Item Abt - Red Shoe (max lv 10)
      • Set abt_foritem[2] = Item Abt - Protective Ring (max lv 10)


Trigger:
  • up item 3
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 2, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to Item_upable[(Integer A)]
            • Then - Actions
              • For each (Integer B) from 1 to 6, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ***(Charges remaining in (Item carried by (Hero manipulating item) in slot (Integer B))) Equal to 10***
                      • (Item-type of (Item carried by (Hero manipulating item) in slot (Integer B))) Equal to Item_upable[(Integer A)]
                      • (Item carried by (Hero manipulating item) in slot (Integer B)) Not equal to (Item being manipulated)
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Level of abt_foritem[(Integer A)] for (Hero manipulating item)) Equal to 10
                        • Then - Actions
                          • Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: Ability Already Max...
                          • Player - Add item_cost[(Integer A)] to (Owner of (Hero manipulating item)) Current gold
                          • Item - Remove (Item being manipulated)
                        • Else - Actions
                          • Item - Set charges remaining in (Item carried by (Hero manipulating item) in slot (Integer B)) to ((Charges remaining in (Item carried by (Hero manipulating item) in slot (Integer B))) + 1)
                          • Unit - Increase level of abt_foritem[(Integer A)] for (Hero manipulating item)
                          • Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: |cffffcc00Item Upgr...
                          • Item - Remove (Item being manipulated)
                    • Else - Actions
                      • Do nothing
            • Else - Actions
              • Do nothing


What I am trying to do is, from your trigger in the above post, keep the items and then, upon repeated purchase, the charges remaining in that item add up (the item is not consumable so charges remaining only act as an indicator of how many times it is purchased)
Also to set the maximum charges to 10 and when the player purchase anymore item of the same type, remove and give gold back

The problem is that I don't know why the ability doesn't increase even though the game showed me "Item Upgraded"

I tried using both [increase level of ability[A]] and [set level of ability[A] to remaining charges of (item-type of (item being manipulated))] but they didn't work :(

I am trying to figure out what's wrong and fixing it atm



======Edited 1

map uploaded


======Edited 2
see ***______*** in the second trigger

The above trigger doesn't stop charges from going above 10 because the checking is done on the ability level that doesn't increase as I wanted, so I tried changing the checking to be done on the remaining charges instead and now it's capped at 10

now what I am thinking is that because in my case, the ability is with the item, that's why this line:
Trigger:
  • Unit - Increase level of abt_foritem[(Integer A)] for (Hero manipulating item)

didn't work..
 

Attachments

  • item testtt.w3x
    91.6 KB · Views: 77
I won't be here for a few hours now, so I'll post what I have atm here:
it's an update from the previous one, but still not working

Trigger:
  • up item 3
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 2, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to Item_upable[(Integer A)]
            • Then - Actions
              • For each (Integer B) from 1 to 6, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of abt_foritem[(Integer A)] for (Hero manipulating item)) Greater than 0
                      • (Item-type of (Item carried by (Hero manipulating item) in slot (Integer B))) Equal to Item_upable[(Integer A)]
                      • (Item carried by (Hero manipulating item) in slot (Integer B)) Not equal to (Item being manipulated)
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Charges remaining in (Item carried by (Hero manipulating item) in slot (Integer B))) Equal to 10
                        • Then - Actions
                          • Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: Ability Already Max...
                          • Player - Add item_cost[(Integer A)] to (Owner of (Hero manipulating item)) Current gold
                          • Item - Remove (Item being manipulated)
                        • Else - Actions
                          • Item - Set charges remaining in (Item carried by (Hero manipulating item) in slot (Integer B)) to ((Charges remaining in (Item carried by (Hero manipulating item) in slot (Integer B))) + 1)
                          • Unit - Set level of abt_foritem[(Integer A)] for (Hero manipulating item) to (Charges remaining in (Item being manipulated))
                          • Game - Display to (Player group((Owner of (Hero manipulating item)))) the text: |cffffcc00Item Upgr...
                          • Item - Remove (Item being manipulated)
                    • Else - Actions
                      • Unit - Add abt_foritem[(Integer A)] to (Hero manipulating item)
                      • Game - Display to (All players) the text: af
            • Else - Actions
              • Do nothing


map attached
 

Attachments

  • item testtt.w3x
    91.7 KB · Views: 94
That's quite a bundle of conditions you have there, I think some of them are clashing.

Also, "Do Nothing" literately does nothing. You don't need it at all.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good
  • The Helper The Helper:
    I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
  • The Helper The Helper:
    This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top