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

[Spell] Crafting System

Status
Not open for further replies.

Remixer

Map Reviewer
Level 31
Joined
Feb 19, 2011
Messages
1,955
Hello dear community.

I am currently working on a map (as my signature points out) that includes item crafting.

I'm creating new items from materials with abilities but now I have a problem. I am not enough skilled / creative to make the system detect when unit has 1 or more of the same item type.

So far all the recipes required only 1 of each item type at max. However, now I am making a recipe that requires 2 of the same item type.

I'd be happy if some one (more advanced in triggering (GUI)) could show me the way to check if the unit has 2 of the same item types, if not the crafting will fail. This would help me a lot. Thanks.
 
Level 11
Joined
Jan 23, 2015
Messages
788
Make an If/Then/Else action and try looking for the following comparison,

Integer Comparison - Number of items in (Items Owned by <Hero>) matching ((Item-type of (Matching Item) Equal to <Item>

though I am not sure that Items Owned by Hero is the correct name or if it even exists..
 

Ardenian

A

Ardenian

You could check each inventory slot. I don't know the exact trigger, but I recall there is a condition to check what item is held in a particular slot. Using multiple If/Then/Else and a variable you set to the amount of items of a specific type allows you to get the amount of a specific item type in the inventory.
 
Level 11
Joined
Jun 2, 2013
Messages
613
Just off the top of my head what about something like this...

Create two Items that are basically the same EXCEPT
1) item your unit will acquire (powerup).
2) An item that the unit keeps in your inventory (charged).

When a unit acquires the first item (powerup), if it doesn't have one of the charged items, give him the item using a trigger. (or create the powerup on the ground if inventory is full).
If he already has the charged item then add +1 to the charges of that item.

Now, create a trigger when you use your combine ability, it checks for item charges and then subtract those charges, if there is enough to make your new item. When the item's charges hit's 0, remove/destroy the item.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
To count how many items of a certain type a unit holds, you can simply do something like this.
Pick every slot and check if the item type of the item in that slot is the one you are counting. If so, you increase an integer variable.
At the end of the loop, that integer variable shows how many items that unit has.

Triggerwise:
  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • Set TempUnit[0] = <YourUnit>
      • Set TempInteger[1] = 0
      • For each (Integer TempInteger[0]) 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[0] in slot TempInteger[0])) Equal to <YourItemType>
            • Then - Actions
              • Set TempInteger[1] = (TempInteger[1] + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempInteger[1] Greater than or equal to 2
        • Then - Actions
          • -------- TempUnit[0] has enough items of type <YourItemType> to complete the recipe. --------
        • Else - Actions
          • -------- TempUnit[0] has not enough items of type <YourItemType> to complete the recipe. --------
 
Status
Not open for further replies.
Top