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:
 

Sajin

User title under construction.
Reaction score
56
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 ^.^)
 

Moradiae

TH.net Regular
Reaction score
14
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
 

Sajin

User title under construction.
Reaction score
56
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: 92

Moradiae

TH.net Regular
Reaction score
14
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
 

Sajin

User title under construction.
Reaction score
56
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
 

Moradiae

TH.net Regular
Reaction score
14
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: 74

Moradiae

TH.net Regular
Reaction score
14
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: 92

HydraRancher

Truth begins in lies
Reaction score
197
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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top