I am trying to create an item, like magic stick from Dota, which restores 15 health and mana based on the number of charges the item has.
When the item is bought, it starts with 0 charges. The number of charges increases by +1 every time an enemy or neutral unit casts an ability within 800 of the item carrier, up to a maximum of 10 charges. When the item is used, the unit has [15 x (number of charges)] health and mana restored, and the charges are reset to 0.
I seem to be having an issue when there is only 1 charge in the item. If I have 2 charges, the item works correctly and give me +30 health and mana. But if I have only one charge, it doesn't do anything...
Here is what I have so far, I am just wondering if there is a better way of doing this.
When the item is bought, it starts with 0 charges. The number of charges increases by +1 every time an enemy or neutral unit casts an ability within 800 of the item carrier, up to a maximum of 10 charges. When the item is used, the unit has [15 x (number of charges)] health and mana restored, and the charges are reset to 0.
I seem to be having an issue when there is only 1 charge in the item. If I have 2 charges, the item works correctly and give me +30 health and mana. But if I have only one charge, it doesn't do anything...
Here is what I have so far, I am just wondering if there is a better way of doing this.
-
MagicStickCharge
-
Events
-
Unit - A unit Starts the effect of an ability
-
-
Conditions
-
Actions
-
-------- - --------
-
-------- Set MS_Point --------
-
Set VariableSet MS_Point = (Position of (Triggering unit))
-
-------- - --------
-
-------- Add to MS_UnitGroup --------
-
Set VariableSet MS_UnitGroup = (Units within 800.00 of MS_Point matching (((Matching unit) has an item of type Magic Stick) Equal to True).)
-
-------- - --------
-
-------- Add charge to MagicStick --------
-
Unit Group - Pick every unit in MS_UnitGroup and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
((Triggering unit) is visible to (Owner of (Picked unit)).) Equal to True
-
((Triggering unit) belongs to an ally of (Owner of (Picked unit)).) Not equal to True
-
(Charges remaining in (Item carried by (Picked unit) of type Magic Stick)) Less than 10
-
(Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Boolean Field: Item Ability ('aite')) Not equal to True
-
-
Then - Actions
-
Item - Set charges remaining in (Item carried by (Picked unit) of type Magic Stick) to ((Charges remaining in (Item carried by (Picked unit) of type Magic Stick)) + 1)
-
-
Else - Actions
-
-
-
-
-------- - --------
-
-------- Clean up --------
-
Custom script: call RemoveLocation (udg_MS_Point)
-
Custom script: call DestroyGroup (udg_MS_UnitGroup)
-
-
-
MagicStickUse
-
Events
-
Unit - A unit Uses an item
-
-
Conditions
-
(Item-type of (Item being manipulated)) Equal to Magic Stick
-
-
Actions
-
-------- - --------
-
-------- Use MagicStick --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Charges remaining in (Item being manipulated)) Greater than 0
-
-
Then - Actions
-
Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (15.00 + (Real((15 x (Charges remaining in (Item being manipulated)))))))
-
Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + (15.00 + (Real((15 x (Charges remaining in (Item being manipulated)))))))
-
Item - Set charges remaining in (Item being manipulated) to 0
-
Special Effect - Create a special effect attached to the origin of (Triggering unit) using Abilities\Spells\Items\AIre\AIreTarget.mdl
-
Special Effect - Destroy (Last created special effect)
-
-
Else - Actions
-
-
-
Last edited: