[SOLVED] Checking if unit already have ability X
Ok so I have this item that will sometimes give the hero carrying it an ability when hit. Everything is working as intended, that is, the ability should not be added to the hero if the hero in question already has the ability, and after 10 seconds the ability should be removed.
Now, my problem is that to achieve this, I'm using the custom value of the unit to detect whether the unit already has the ability or not and each unit only has one custom value (I want each unit to be able to benefit from more than one item that gives abilities/buffs upon being hit or upon striking other units etc. at once). I do not want to use buffs to detect this, because those are limited to the number of different spells that exist in the game and they do not stack.
For example, if I were to use Inner Fire as a dummy ability to apply a buff for this item, then this is going to create problems with my other item that is also based of off Inner Fire and the actual Inner Fire spell.
So my question is, how do I best create multi-instanceability here without using buffs? Is there some way to use arrays to store multiple custom values for units? Or is there some other better way of doing this?
NOTE: I'm not proficient in JASS, so I will need the solution to be either 100% GUI or partially GUI and partially JASS.
My current GUI code for the trigger in question looks like this:
Ok so I have this item that will sometimes give the hero carrying it an ability when hit. Everything is working as intended, that is, the ability should not be added to the hero if the hero in question already has the ability, and after 10 seconds the ability should be removed.
Now, my problem is that to achieve this, I'm using the custom value of the unit to detect whether the unit already has the ability or not and each unit only has one custom value (I want each unit to be able to benefit from more than one item that gives abilities/buffs upon being hit or upon striking other units etc. at once). I do not want to use buffs to detect this, because those are limited to the number of different spells that exist in the game and they do not stack.
For example, if I were to use Inner Fire as a dummy ability to apply a buff for this item, then this is going to create problems with my other item that is also based of off Inner Fire and the actual Inner Fire spell.
So my question is, how do I best create multi-instanceability here without using buffs? Is there some way to use arrays to store multiple custom values for units? Or is there some other better way of doing this?
NOTE: I'm not proficient in JASS, so I will need the solution to be either 100% GUI or partially GUI and partially JASS.
My current GUI code for the trigger in question looks like this:
-
Force of Will
-
Events
- Unit - A unit Is attacked
-
Conditions
- ((Attacked unit) is A Hero) Equal to True
- ((Attacked unit) has an item of type |cff0066ccForce of Will|r) Equal to True
- (Custom value of (Attacked unit)) Equal to 0
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Random integer number between 1 and 100) Less than or equal to 100
-
Then - Actions
- Set TempUnit = (Attacked unit)
- Special Effect - Create a special effect attached to the origin of TempUnit using Abilities\Spells\Items\AIim\AIimTarget.mdl
- Special Effect - Destroy (Last created special effect)
- Unit - Add Force of Will to (Attacked unit)
- Unit - Set the custom value of (Attacked unit) to 1
- Wait 10.00 seconds
- Unit - Remove Force of Will from (Attacked unit)
- Unit - Set the custom value of (Attacked unit) to 0
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Events
Last edited: