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

Zero Item Charges

Level 25
Joined
Sep 26, 2009
Messages
2,378
try something like this:
  • Trigger
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Sentry Wards
      • (Charges remaining in (Item being manipulated)) Equal to 0
    • Actions
      • Game - Display to (All players) the text: No charge left
Note that items with unlimited charges will also return zero
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
There's also a few problems with this trigger specifically:
  • Item Goners
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Charges remaining in (Item carried by Blacksmith of type (Random level 1.Charged item-type))) Equal to 0
        • Then - Actions
          • Item - Remove (Item carried by Blacksmith of type (Random level 1.Charged item-type))
        • Else - Actions
  1. Your charged items are all level 0, while this trigger checks level 1 charged items.
  2. Even if the blacksmith has 'Handle' item with 0 charges, there are currently 3 types of items that have level 0 and classification 'charged'. Since you pick randomly one of those item-types, then that means there is only a 33% chance that remaining charges in 'Handle' item will be checked. If you had 10 such types of items, the chance would get down to 10%
  3. The randomly chosen item-type for the check in the condition will often be different item than the randomly chosen item for removal
  4. If the blacksmith does not have the randomly chosen item-type in inventory, then the call '(Charges remaining in (Item carried by Blacksmith of type (Random level 1.Charged item-type)))' will be evaluated as '(Charges remaining in (No item))' which will evaluate as 0. That means the condition will pass and an unrelated (randomly chosen) item will be removed.
 
Level 6
Joined
Mar 15, 2020
Messages
38
Note that I got rid of the Blueprints because I didn't understand why they were necessary.
So that it would detect a manipulating item and for the item to craft.

For the map I will check on it tomorrow I'll get some rest for now and thanks all for the help guys, I do not know how to give a rep+ but seems like you guys earned it, anyway I am still a learner for these things.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,554
So that it would detect a manipulating item and for the item to craft.

For the map I will check on it tomorrow I'll get some rest for now and thanks all for the help guys, I do not know how to give a rep+ but seems like you guys earned it, anyway I am still a learner for these things.
Right, but it's setup so it only needs to check for items when you click the "Craft Sword" ability. Anyway, when you test it you can confirm whether you like how I did it or not, or any issues you see. I'm happy to help further improve the system.

Also, Liking a post is the equivalent to +Rep.
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
These are the triggers modified by Uncle
Variables:
1705755810314.png


Triggers:
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Visibility - Disable fog of war
      • Visibility - Disable black mask
      • Game - Display to (All players) the text: |cffff0000Create 3 ...
  • Craft Sword
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Craft Sword
    • Actions
      • Set VariableSet Blacksmith_Unit = (Triggering unit)
      • Trigger - Run Create Sword <gen> (checking conditions)
  • Create Sword
    • Events
    • Conditions
      • (Blacksmith_Unit has an item of type Blade of the Sword) Equal to True
      • (Blacksmith_Unit has an item of type Handle) Equal to True
    • Actions
      • Set VariableSet Charged_Item = (Item carried by Blacksmith_Unit of type Handle)
      • Trigger - Run Item Remove One Charge <gen> (ignoring conditions)
      • -------- --------
      • Set VariableSet Charged_Item = (Item carried by Blacksmith_Unit of type Blade of the Sword)
      • Trigger - Run Item Remove One Charge <gen> (ignoring conditions)
      • -------- --------
      • Hero - Create Sword and give it to Blacksmith_Unit
      • -------- --------
      • -------- Some optional animation related stuff: --------
      • Animation - Queue Blacksmith_Unit's stand animation
      • Special Effect - Create a special effect attached to the overhead of Blacksmith_Unit using Abilities\Spells\Human\Defend\DefendCaster.mdl
      • Special Effect - Destroy (Last created special effect)
  • Item Remove One Charge
    • Events
    • Conditions
    • Actions
      • -------- How to use: --------
      • -------- Step 1: Set Charged_Item to the item that is going to lose a charge --------
      • -------- Step 2: Run this trigger (ignoring conditions) --------
      • -------- --------
      • Item - Set charges remaining in Charged_Item to ((Charges remaining in Charged_Item) - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Charges remaining in Charged_Item) Equal to 0
        • Then - Actions
          • Item - Remove Charged_Item
        • Else - Actions
  • Item With Charges Is Used
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Item-class of (Item being manipulated)) Equal to Charged
      • (Charges remaining in (Item being manipulated)) Equal to 0
    • Actions
      • -------- This removes any 0 charge item after it has been used. It must be in the Charged class! --------
      • Item - Remove (Item being manipulated)
 
Top