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

[Trigger] Crafting Weapons Trigger

Status
Not open for further replies.
Level 4
Joined
Aug 16, 2013
Messages
75
I am not sure why this trigger isn't working. It works when it checks for only 1 item from the Selling unit, but when you check for more items, it doesn't pass the conditions "Charges remaining in" said item.

  • Craft Aqua Sword
    • Events
      • Unit - A unit owned by Neutral Passive Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Craft Aqua Sword
    • 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 (Selling unit) of type Broadsword)) Greater than or equal to 1
              • (Charges remaining in (Item carried by (Selling unit) of type Iron Ore)) Greater than or equal to 5
              • (Charges remaining in (Item carried by (Selling unit) of type Copper Ore)) Greater than or equal to 8
              • (Charges remaining in (Item carried by (Selling unit) of type Water Crystal)) Greater than or equal to 3
        • Then - Actions
          • Set Craft_Chance = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Craft_Chance Less than or equal to 50
            • Then - Actions
              • Floating Text - Create floating text that reads Crafting Successful. at (Position of (Selling unit)) with Z offset 0.00, using font size 10.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
              • Item - Set charges remaining in (Item carried by (Selling unit) of type Iron Ore) to ((Charges remaining in (Item carried by (Selling unit) of type Iron Ore)) - 5)
              • Item - Set charges remaining in (Item carried by (Selling unit) of type Copper Ore) to ((Charges remaining in (Item carried by (Selling unit) of type Copper Ore)) - 8)
              • Item - Set charges remaining in (Item carried by (Selling unit) of type Water Crystal) to ((Charges remaining in (Item carried by (Selling unit) of type Water Crystal)) - 3)
              • Hero - Create Aqua Sword and give it to (Selling unit)
            • Else - Actions
              • Floating Text - Create floating text that reads Crafting Failed! at (Position of (Selling unit)) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
              • Item - Set charges remaining in (Item carried by (Selling unit) of type Iron Ore) to ((Charges remaining in (Item carried by (Selling unit) of type Iron Ore)) - 5)
              • Item - Set charges remaining in (Item carried by (Selling unit) of type Copper Ore) to ((Charges remaining in (Item carried by (Selling unit) of type Copper Ore)) - 8)
              • Item - Set charges remaining in (Item carried by (Selling unit) of type Water Crystal) to ((Charges remaining in (Item carried by (Selling unit) of type Water Crystal)) - 3)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Charges remaining in (Item carried by (Selling unit) of type Iron Ore)) Equal to 0
            • Then - Actions
              • Item - Remove (Item carried by (Selling unit) of type Iron Ore)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Charges remaining in (Item carried by (Selling unit) of type Copper Ore)) Equal to 0
            • Then - Actions
              • Item - Remove (Item carried by (Selling unit) of type Copper Ore)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Charges remaining in (Item carried by (Selling unit) of type Water Crystal)) Equal to 0
            • Then - Actions
              • Item - Remove (Item carried by (Selling unit) of type Water Crystal)
            • Else - Actions
        • Else - Actions
I feel sort of stumped. I tried a couple methods but they didn't seem to work. Could anyone help?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
You know that the shop is actually the selling unit?
I get the feeling that you want to make the unit craft the item.
In that case, use "A unit acquires an item"
And use triggering unit instead of selling unit.
And use variables if you use a reference more than once.

I am almost sure that charges remaining in item carried ... is not responding to a shop.
 
Level 4
Joined
Aug 16, 2013
Messages
75
The selling unit is a forge which is a unit building. The unit building has an inventory and in order to craft, you have to put items into the unit building and then buy "Craft Aqua Sword" which will give you a different item "Aqua Sword".

I tried setting the variable Crafting_Forge to triggering unit, buying unit, and selling unit. It still won't work. It doesn't even get passed the 4 conditions which checks for the charges remaining of each item.

  • Craft Aqua Sword
    • Events
      • Unit - A unit owned by Neutral Passive Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Craft Aqua Sword
    • Actions
      • Set Crafting_Forge = (Buying unit)
      • 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 Crafting_Forge of type Broadsword)) Greater than or equal to 1
              • (Charges remaining in (Item carried by Crafting_Forge of type Iron Ore)) Greater than or equal to 5
              • (Charges remaining in (Item carried by Crafting_Forge of type Copper Ore)) Greater than or equal to 8
              • (Charges remaining in (Item carried by Crafting_Forge of type Water Crystal)) Greater than or equal to 3
        • Then - Actions
          • Set Craft_Chance = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Craft_Chance Less than or equal to 50
            • Then - Actions
              • Floating Text - Create floating text that reads Crafting Successful... at (Position of Crafting_Forge) with Z offset 0.00, using font size 10.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
              • Item - Set charges remaining in (Item carried by Crafting_Forge of type Iron Ore) to ((Charges remaining in (Item carried by Crafting_Forge of type Iron Ore)) - 5)
              • Item - Set charges remaining in (Item carried by Crafting_Forge of type Copper Ore) to ((Charges remaining in (Item carried by Crafting_Forge of type Copper Ore)) - 8)
              • Item - Set charges remaining in (Item carried by Crafting_Forge of type Water Crystal) to ((Charges remaining in (Item carried by Crafting_Forge of type Water Crystal)) - 3)
              • Hero - Create Aqua Sword and give it to Crafting_Forge
            • Else - Actions
              • Floating Text - Create floating text that reads Crafting Failed! at (Position of Crafting_Forge) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
              • Item - Set charges remaining in (Item carried by Crafting_Forge of type Iron Ore) to ((Charges remaining in (Item carried by Crafting_Forge of type Iron Ore)) - 5)
              • Item - Set charges remaining in (Item carried by Crafting_Forge of type Copper Ore) to ((Charges remaining in (Item carried by Crafting_Forge of type Copper Ore)) - 8)
              • Item - Set charges remaining in (Item carried by Crafting_Forge of type Water Crystal) to ((Charges remaining in (Item carried by Crafting_Forge of type Water Crystal)) - 3)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Charges remaining in (Item carried by Crafting_Forge of type Iron Ore)) Equal to 0
            • Then - Actions
              • Item - Remove (Item carried by Crafting_Forge of type Iron Ore)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Charges remaining in (Item carried by Crafting_Forge of type Copper Ore)) Equal to 0
            • Then - Actions
              • Item - Remove (Item carried by Crafting_Forge of type Copper Ore)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Charges remaining in (Item carried by Crafting_Forge of type Water Crystal)) Equal to 0
            • Then - Actions
              • Item - Remove (Item carried by Crafting_Forge of type Water Crystal)
            • Else - Actions
        • Else - Actions
 
Level 4
Joined
Aug 16, 2013
Messages
75
This test map is pretty much a copy and paste of the trigger.

I am using an item stacking system, but I doubt that's the cause of it not working.
 

Attachments

  • Crafting Items.w3x
    43.2 KB · Views: 56
Level 24
Joined
Aug 1, 2013
Messages
4,657
The problem was that you are checking the inventory of the unit that buys the item... the unit that is selected by the shop, the Paladin in the example.
You should set Crafting_Forge to Selling unit and it should work.

One thing that you could look at is the if chance is greater than or equal to 50 thing.
I changed some positions of actions and it can save you some work.

  • Craft Aqua Sword
    • Events
      • Unit - A unit owned by Neutral Passive Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Craft Aqua Sword
    • Actions
      • Set Crafting_Forge = (Selling unit)
      • 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 Crafting_Forge of type Iron Ore)) Greater than or equal to 2
              • (Charges remaining in (Item carried by Crafting_Forge of type Bronze Ore)) Greater than or equal to 3
              • (Charges remaining in (Item carried by Crafting_Forge of type Water Crystal)) Greater than or equal to 1
        • Then - Actions
          • Set Craft_Chance = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Craft_Chance Less than or equal to 50
            • Then - Actions
              • Floating Text - Create floating text that reads Crafting Successful... at (Position of Crafting_Forge) with Z offset 0.00, using font size 10.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
              • Hero - Create Searing Blade and give it to Crafting_Forge
            • Else - Actions
              • Floating Text - Create floating text that reads Crafting Failed! at (Position of Crafting_Forge) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
          • Item - Set charges remaining in (Item carried by Crafting_Forge of type ) to ((Charges remaining in (Item carried by Crafting_Forge of type Iron Ore)) - 2)
          • Item - Set charges remaining in (Item carried by Crafting_Forge of type ) to ((Charges remaining in (Item carried by Crafting_Forge of type Bronze Ore)) - 3)
          • Item - Set charges remaining in (Item carried by Crafting_Forge of type ) to ((Charges remaining in (Item carried by Crafting_Forge of type Water Crystal)) - 2)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Charges remaining in (Item carried by Crafting_Forge of type Iron Ore)) Equal to 0
            • Then - Actions
              • Item - Remove (Item carried by Crafting_Forge of type Iron Ore)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Charges remaining in (Item carried by Crafting_Forge of type Bronze Ore)) Equal to 0
            • Then - Actions
              • Item - Remove (Item carried by Crafting_Forge of type Bronze Ore)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Charges remaining in (Item carried by Crafting_Forge of type Water Crystal)) Equal to 0
            • Then - Actions
              • Item - Remove (Item carried by Crafting_Forge of type Water Crystal)
            • Else - Actions
        • Else - Actions
 
Level 4
Joined
Aug 16, 2013
Messages
75
Ohhh. I think I get why it wasn't working now.

In my first trigger, "broadsword" doesn't have any charges to it. The reason why it wasn't working was because I was checking if broadsword had a charge of 1. It 100% works now if I change that charge 1 to charge 0 since it isn't a charged item.

Thank you for putting your time into helping me Wietlol. I totally overlooked this into thinking charge 1 = no charges for some reason.
 
Status
Not open for further replies.
Top