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

Recipe Trigger

Status
Not open for further replies.
Level 10
Joined
Mar 25, 2010
Messages
187
Hi, have an issue with my Blacksmithing Recipe trigger.
Here's the trigger :


  • Copper Axe
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Smith
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has an item of type Plans : Copper Axe) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Charges remaining in (Item carried by (Triggering unit) of type |c00804000Copper Bar|r)) Equal to 5
                  • (Charges remaining in (Item carried by (Triggering unit) of type Simple Wood)) Equal to 2
                  • (Charges remaining in (Item carried by (Triggering unit) of type Linen Cloth)) Equal to 2
            • Then - Actions
              • Item - Create Copper Axe at (Position of (Triggering unit))
              • Item - Remove (Item carried by (Triggering unit) of type |c00804000Copper Bar|r)
              • Item - Remove (Item carried by (Triggering unit) of type Simple Wood)
              • Item - Remove (Item carried by (Triggering unit) of type Linen Cloth)
              • Set Smithing_Level = (Smithing_Level + 1)
              • Game - Display to (All players) the text: (Your Smithing is now + (String(Smithing_Level)))
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • And - All (Conditions) are true
                    • Conditions
                      • (Charges remaining in (Item carried by (Triggering unit) of type |c00804000Copper Bar|r)) Greater than 5
                      • (Charges remaining in (Item carried by (Triggering unit) of type Simple Wood)) Greater than 2
                      • (Charges remaining in (Item carried by (Triggering unit) of type Linen Cloth)) Greater than 2
                • Then - Actions
                  • Item - Create Copper Axe at (Position of (Triggering unit))
                  • Item - Set charges remaining in (Item carried by (Triggering unit) of type |c00804000Copper Bar|r) to ((Charges remaining in (Item carried by (Triggering unit) of type |c00804000Copper Bar|r)) - 5)
                  • Item - Set charges remaining in (Item carried by (Triggering unit) of type Simple Wood) to ((Charges remaining in (Item carried by (Triggering unit) of type Simple Wood)) - 2)
                  • Item - Set charges remaining in (Item carried by (Triggering unit) of type Linen Cloth) to ((Charges remaining in (Item carried by (Triggering unit) of type Linen Cloth)) - 2)
                  • Set Smithing_Level = (Smithing_Level + 1)
                  • Game - Display to (All players) the text: (Your Smithing is now + (String(Smithing_Level)))
                • Else - Actions
                  • Game - Display to (All players) the text: You don't have the ...
        • Else - Actions
Now what this trigger is supposed to do is simple enough, the player uses his Blacksmith ability, trigger then checks if the player has all the correct materials; in this case 5 Copper Bars, 2 Simple Wood and 2 Linen Cloth.

It'll then make the item if you have the required materials, the problem is however that whenever you have more than the required amount of materials ( wether it be copper, wood or linen ) it'll say you don't have the required materials.
Whereas it's supposed to subtract the amount needed.

I believe another recipe might be interfering, since it worked fine before that.
 
You should check if it has 5 or more charges, 2 or more charges, etc...
Then, you wouldn't remove the items, you'd set their charges to:
Their Charges - 5 for example.
If the charges after that are 0, then you would remove the item.
Isn't that simple? :)


Your problem is that you're not using "Equal to or Greater than".
The reason it's saying that you don't have the needed items is because it will only trigger if you have the exact requirements, or if you have more than the required amount for every single recipe item :)
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
First, remove the extra and:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Condition 1
      • Condition 2
      • Condition 2
    • Then - Actions
    • Else - Actions
Then you should display the message to triggering player. If it is single player then it doesn't really matter.

And the problem is that if you have 5,3,2 resources for example, both checks will fail.

The first requires 5,2,2 and if will fail. The second requires (at least) 6,3,3 and it will fail also, even though you should be able to craft the item.

I'd make the conditons greater than or equal to 5,2,2. Then set the item type to perishable in object editor, they should disappear when the charges reach zero.

EDIT: The item apparently doesn't disappear immeadiately. You have to remove the item with a trigger.
 
Level 10
Joined
Mar 25, 2010
Messages
187
Right, i think it works properly now ( except when i'm carrying two recipes )
Is this the proper trigger?

  • Copper Axe
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Smith
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has an item of type Plans : Copper Axe) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Charges remaining in (Item carried by (Triggering unit) of type |c00804000Copper Bar|r)) Greater than or equal to 5
              • (Charges remaining in (Item carried by (Triggering unit) of type Simple Wood)) Greater than or equal to 2
              • (Charges remaining in (Item carried by (Triggering unit) of type Linen Cloth)) Greater than or equal to 2
            • Then - Actions
              • Item - Create Copper Axe at (Position of (Triggering unit))
              • Item - Set charges remaining in (Item carried by (Triggering unit) of type |c00804000Copper Bar|r) to ((Charges remaining in (Item carried by (Triggering unit) of type |c00804000Copper Bar|r)) - 5)
              • Item - Set charges remaining in (Item carried by (Triggering unit) of type Simple Wood) to ((Charges remaining in (Item carried by (Triggering unit) of type Simple Wood)) - 2)
              • Item - Set charges remaining in (Item carried by (Triggering unit) of type Linen Cloth) to ((Charges remaining in (Item carried by (Triggering unit) of type Linen Cloth)) - 2)
              • Set Smithing_Level = (Smithing_Level + 1)
              • Game - Display to (All players) the text: (Your Smithing is now + (String(Smithing_Level)))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Charges remaining in (Item carried by (Triggering unit) of type |c00804000Copper Bar|r)) Equal to 0
                • Then - Actions
                  • Item - Remove (Item carried by (Triggering unit) of type |c00804000Copper Bar|r)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Charges remaining in (Item carried by (Triggering unit) of type Simple Wood)) Equal to 0
                • Then - Actions
                  • Item - Remove (Item carried by (Triggering unit) of type Simple Wood)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Charges remaining in (Item carried by (Triggering unit) of type Linen Cloth)) Equal to 0
                • Then - Actions
                  • Item - Remove (Item carried by (Triggering unit) of type Linen Cloth)
                • Else - Actions
            • Else - Actions
              • Game - Display to (All players) the text: You don't have the ...
        • Else - Actions
 
Last edited:
Status
Not open for further replies.
Top