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

Upgrade Item System

Status
Not open for further replies.
Level 3
Joined
May 5, 2013
Messages
56
Hey Guys, I have already looked for the following problem in the Forum, but could not find anything about it.

I tried to make a system, in which a unit (a hero) can sort of upgrade an item. You buy an item on level one, for example Sword (low). When you again buy the item Sword (low), both items are removed and you get the item Sword (medium). When you again buy the item Sword (low) and you already have Sword (medium), again both items are replaced for the item Sword (large).

I kind of want to create, that you can upgrade your item Sowrd (low) to Sword (medium) and then Sword (large) by just buying the same item.

I have done something like this:
  • Sword Upgrade
    • Events
      • Einheit - A unit buys an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • ((Triggering unit) has an item of type Sword) Equal to True
        • 'THEN'-Actions
          • Item - Remove (Item carried by (Triggering unit) of type Sword (low))
          • Hero - Create Sword (medium) and give it to (Triggering unit)
        • 'ELSE'-Actions
But the Problem is, the item is already replaced before i buy the item Sword (low), so I kind of instant-buy the item Sword (medium), without even having Sword (low).

Here I read something about checking the Items in each slot, but I honestly dont know how I do that :/
 
Level 13
Joined
Jul 16, 2012
Messages
679
Hmm Try This if this Work

Trigger
  • Untitled Trigger 001
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
    • Actions
      • Set TempUnit = (Triggering unit)
      • For each (Integer TempLoop) 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 TempUnit in slot TempLoop)) Equal to Put_Here_Your_Item
            • Then - Actions
              • Item - Remove (Item carried by TempUnit in slot TempLoop)
              • Hero - Create Put_Here_Your_Item and give it to TempUnit
            • Else - Actions
 
Level 3
Joined
May 5, 2013
Messages
56
Since your using triggering unit which is a local, you can put a wait of 0.00 or 0.01 on there which might fix your problem without having to do a 1-6 loop of a inventory slot check.

I have leanred (somebody once told me) that waits are inefficient, and don't always work, especially when they are under 1 second.

But I think you missunderstood me, I try to explain it better:

Step 0: The Hero's inventory is empty.
Step 1: The Hero buys a sword (low) from the shop.
Step 2: He buys another sword (low). He now has 2x sword (low), so both are removed, and the Hero gets a sword (medium).
Step 3: The Hero buys another sword (low), and now has sword (low) and sword (medium). Again both are removed, and he gets a sword (large).

I don't want it to somehow wait, he should directly get the "upgraded" sword. But my problem is, when I buy "Step 1", he instantly removes the sword (low) for a sword (medium).

This is my Trigger (which doesn't work):



  • Sword Upgrade
    • events
      • Unit - A unit Acquires an item
    • conditions
    • Actions
      • For each ( Integer Item_Upgrade [1 ] ) from 1 to 2, do ( Actions )
        • Grinding - Actions
          • If ( All Conditions are True) then do (Then Actions ) else do (Else Actions )
            • 'If' conditions
              • ( ( Triggering unit) Has an item of type Sword ) Equal To True
              • Or - Any ( Conditions) are true
                • conditions
                  • ( Item -type of ( Item Carried by ( Triggering unit) in slot 1) ) Equal Sword
                  • ( Item -type of ( Item Carried by ( Triggering unit) in slot 2) ) Equal Sword
                  • ( Item -type of ( Item Carried by ( Triggering unit) in slot 3) ) Equal Sword
                  • ( Item -type of ( Item Carried by ( Triggering unit) in slot 4) ) Equal Sword
                  • ( Item -type of ( Item Carried by ( Triggering unit) in slot 5) ) Equal Sword
                  • ( Item -type of ( Item Carried by ( Triggering unit) in slot 6) ) Equal Sword
            • ' THEN' actions
              • Set Item_Upgrade [ 1] = 0
            • ' ELSE actions
              • Item - Remove ( Item Carried by ( Triggering unit) of type Sword )
              • Hero - Create Sword (medium) and give it to ( Triggering unit)
              • Set Item_Upgrade [ 1] = 2
 
Loop from 1 to 6. Put there an If/Then/Else with 2 ItemComparissons as condition:

Check if itemType of item in slot[loopIndex] == SwordLow AND item in slot[loopIndex] != Item being manipulated.

If both is true, unit has got an other item of type SwordLow, and you can make your actions.

Edit: This is for step 2 of course. I guess you will menage step 3 on your own then?
 
Level 3
Joined
May 5, 2013
Messages
56
I got it now, it works, thanks guys.

And I have done Step 3 by myself :)

You can use my item recipe system. It allows for multiple items of same item type to make an item. It is either in my sig or in my resources on my page.

I took a look at your system, but it was written in Jass I think. I don't know how to Jass sry :/
 
Status
Not open for further replies.
Top