- Joined
- Mar 15, 2020
- Messages
- 107
How to detect item charges are zero so it will be remove?
Last edited:
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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
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
So that it would detect a manipulating item and for the item to craft.Note that I got rid of the Blueprints because I didn't understand why they were necessary.
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.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.
I have problem opening the map since I am using an old version.Like Nichilus said, there's only two ways to lose charges. So setup your triggers to detect those two ways. Here's an example.
Note that I got rid of the Blueprints because I didn't understand why they were necessary.
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)
