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

Crafting System 2

Status
Not open for further replies.
Level 13
Joined
Oct 25, 2009
Messages
995
I have a problem with crafting system again.
  • Camp Fire
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Craft a Camp Fire
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • ((Triggering unit) has an item of type Stone) Equal to True
              • ((Triggering unit) has an item of type Wood) Equal to True
              • ((Triggering unit) has an item of type Long Grass) 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 Stone)) Greater than or equal to 1
              • (Charges remaining in (Item carried by (Triggering unit) of type Wood)) Greater than or equal to 1
              • (Charges remaining in (Item carried by (Triggering unit) of type Long Grass)) Greater than or equal to 1
            • Then - Actions
              • Wait 2.00 game-time seconds
              • Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: You have crafted a ...
              • Item - Set charges remaining in (Item carried by (Triggering unit) of type Wood) to ((Charges remaining in (Item carried by (Triggering unit) of type Wood)) - 1)
              • Item - Set charges remaining in (Item carried by (Triggering unit) of type Stone) to ((Charges remaining in (Item carried by (Triggering unit) of type Stone)) - 1)
              • Item - Set charges remaining in (Item carried by (Triggering unit) of type Long Grass) to ((Charges remaining in (Item carried by (Triggering unit) of type Long Grass)) - 1)
              • Hero - Create Camp Fire [F] and give it to (Triggering unit)
              • 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 Stone)) Less than 1
                  • (Charges remaining in (Item carried by (Triggering unit) of type Wood)) Less than 1
                  • (Charges remaining in (Item carried by (Triggering unit) of type Long Grass)) Less than 1
                • Then - Actions
                  • Item - Remove (Item carried by (Triggering unit) of type Stone)
                  • Item - Remove (Item carried by (Triggering unit) of type Wood)
                  • Item - Remove (Item carried by (Triggering unit) of type Long Grass)
                • Else - Actions
            • Else - Actions
              • Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: You didn't have the...
        • Else - Actions
After i crafted the camp fire,sometime the item will turn into this.
Craft.jpg

How can i remove these stone and long grass(The icon like grass)?
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
First of all, instead of OR, you should have AND. You need all the three ingredients right?

I suggest you remove the wait since people could potentially abuse it.

After using the item, you need to check the charges individually, have their own if/then/else for each item.

You could first check the charges, then either remove the item or reduce charges.
 
Level 13
Joined
Oct 25, 2009
Messages
995
Still confusing at checking the charges,could you give me a trigger?
EDIT: It work,i know it completely,here the trigger.
  • Camp Fire
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Craft a Camp Fire
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • ((Triggering unit) has an item of type Stone) Equal to True
              • ((Triggering unit) has an item of type Wood) Equal to True
              • ((Triggering unit) has an item of type Long Grass) 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 Stone)) Greater than or equal to 1
              • (Charges remaining in (Item carried by (Triggering unit) of type Wood)) Greater than or equal to 1
              • (Charges remaining in (Item carried by (Triggering unit) of type Long Grass)) Greater than or equal to 1
            • Then - Actions
              • Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: You have crafted a ...
              • Item - Set charges remaining in (Item carried by (Triggering unit) of type Stone) to ((Charges remaining in (Item carried by (Triggering unit) of type Stone)) - 1)
              • Item - Set charges remaining in (Item carried by (Triggering unit) of type Wood) to ((Charges remaining in (Item carried by (Triggering unit) of type Wood)) - 1)
              • Item - Set charges remaining in (Item carried by (Triggering unit) of type Long Grass) to ((Charges remaining in (Item carried by (Triggering unit) of type Long Grass)) - 1)
              • Hero - Create Camp Fire [F] and give it to (Triggering unit)
              • 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 Stone)) Less than 1
                • Then - Actions
                  • Item - Remove (Item carried by (Triggering unit) of type Stone)
                • 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 Wood)) Less than 1
                • Then - Actions
                  • Item - Remove (Item carried by (Triggering unit) of type 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 Long Grass)) Less than 1
                • Then - Actions
                  • Item - Remove (Item carried by (Triggering unit) of type Long Grass)
                • Else - Actions
            • Else - Actions
              • Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: You didn't have the...
        • Else - Actions
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Remove the extra AND, conditions are combined with an AND by default:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Triggering unit) has an item of type Stone) Equal to True
          • ((Triggering unit) has an item of type Wood) Equal to True
          • ((Triggering unit) has an item of type Long Grass) Equal to True
->
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • ((Triggering unit) has an item of type Stone) Equal to True
      • ((Triggering unit) has an item of type Wood) Equal to True
      • ((Triggering unit) has an item of type Long Grass) Equal to True
I don't think you need to check these since you already did check that the unit has these items and items with zero charges are removed:
  • 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 Stone)) Greater than or equal to 1
      • (Charges remaining in (Item carried by (Triggering unit) of type Wood)) Greater than or equal to 1
      • (Charges remaining in (Item carried by (Triggering unit) of type Long Grass)) Greater than or equal to 1
You're leaking a player group:
  • Game - Display to (Player group((Owner of (Triggering unit)))) for 10.00 seconds the text: You have crafted a ...
First check the charges. If it is one, remove the item. Otherwise remove the item.
  • Item - Set charges remaining in (Item carried by (Triggering unit) of type Stone) to ((Charges remaining in (Item carried by (Triggering unit) of type Stone)) - 1)
->
  • 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 Stone)) equal to 1
    • Then - Actions
      • Item - Remove (Item carried by (Triggering unit) of type Stone)
    • Else - Actions
      • Set charges to charges - 1
However you could skip the "remove item" action by setting the item to Perishable in object editor. Then it will disappear immediately when the charges run out.
 
Level 9
Joined
Apr 23, 2010
Messages
312
You could just run this trigger, it will always be running.

  • Remove 0 Charge Items
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If ((Charges remaining in (Item carried by Players_Hero[(Player number of (Picked player))] in slot 1)) Equal to 0) then do (Item - Remove (Item carried by Players_Hero[(Player number of (Picked player))] in slot 1)) else do (Do nothing)
          • If ((Charges remaining in (Item carried by Players_Hero[(Player number of (Picked player))] in slot 2)) Equal to 0) then do (Item - Remove (Item carried by Players_Hero[(Player number of (Picked player))] in slot 2)) else do (Do nothing)
          • If ((Charges remaining in (Item carried by Players_Hero[(Player number of (Picked player))] in slot 3)) Equal to 0) then do (Item - Remove (Item carried by Players_Hero[(Player number of (Picked player))] in slot 3)) else do (Do nothing)
          • If ((Charges remaining in (Item carried by Players_Hero[(Player number of (Picked player))] in slot 4)) Equal to 0) then do (Item - Remove (Item carried by Players_Hero[(Player number of (Picked player))] in slot 4)) else do (Do nothing)
          • If ((Charges remaining in (Item carried by Players_Hero[(Player number of (Picked player))] in slot 5)) Equal to 0) then do (Item - Remove (Item carried by Players_Hero[(Player number of (Picked player))] in slot 5)) else do (Do nothing)
          • If ((Charges remaining in (Item carried by Players_Hero[(Player number of (Picked player))] in slot 6)) Equal to 0) then do (Item - Remove (Item carried by Players_Hero[(Player number of (Picked player))] in slot 6)) else do (Do nothing)
By the way, Players_Hero is an array variable that is set to all players heroes at the start of the game.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
13oot-Me, thats stupidly inefficient and prevents the player from ever owning a permant uncharged item.

Not only does it run 20 times a second, it runs for 16 players and checks 6 items thus it does 20*16*6 checks a second which is 1920 checks a second for something that only need be checked when an item is manipulated or changed by a trigger.
 
Status
Not open for further replies.
Top