I am trying to create an item, called Phthalo's Bracer, which restores 2% of the units missing health, over 8 seconds, when they receive damage from an enemy unit. I know this can easily be done using just trigger, but I wanted a little buff icon to appear on the unit without using a dummy unit. I have made an ability, based on Unholy Aura, which is added to the item when the carrying unit takes damage, then subsequently remove after 8 seconds.
Here is what I have so far!
It seems to be playing up slightly and was wondering what I may be doing wrong/inefficiently.
Here is what I have so far!
-
PhthalosBracerEndure
-
Events
- Game - DamageEvent becomes Equal to 1.00
-
Conditions
- (DamageEventSource is A structure) Not equal to True
- (DamageEventTarget has an item of type Phthalo's Bracer) Equal to True
- (DamageEventSource belongs to an enemy of (Owner of DamageEventTarget).) Equal to True
-
Actions
- -------- - --------
- -------- Save key for PB_DurationHandle --------
- Hashtable - Save 8.00 as (Key PB_DurationHandle.) of (Key PB_Handle.) in PB_HastTable.
- -------- - --------
- -------- Add to PB_UnitGroup --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (DamageEventTarget is in PB_UnitGroup.) Equal to False
-
Then - Actions
- Unit Group - Add DamageEventTarget to PB_UnitGroup
- Else - Actions
-
If - Conditions
- -------- - --------
- -------- Add ability ItemEndure --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Level of Item Endure for DamageEventTarget) Less than or equal to 0
-
Then - Actions
- Item - For Item: (Item carried by DamageEventTarget of type Phthalo's Bracer), Add Ability: Item Endure
- Else - Actions
-
If - Conditions
- -------- - --------
- -------- Turn on PhthalosBracerTimer --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (PhthalosBracerTimer <gen> is on) Equal to False
-
Then - Actions
- Trigger - Turn on PhthalosBracerTimer <gen>
- Else - Actions
-
If - Conditions
-
Events
-
PhthalosBracerTimer
-
Events
- Time - Every 0.10 seconds of game time
- Conditions
-
Actions
-
Unit Group - Pick every unit in PB_UnitGroup and do (Actions)
-
Loop - Actions
- -------- - --------
- -------- Set Variables --------
- Set VariableSet PB_Unit = (Picked unit)
- Set VariableSet PB_Handle = (Picked unit)
- Set VariableSet PB_Duration = (Load (Key PB_DurationHandle.) of (Key PB_Handle.) from PB_HastTable.)
- -------- - --------
- -------- Remove dead PB_UnitGroup --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (PB_Unit is alive) Not equal to True
-
Then - Actions
- Unit Group - Remove PB_Unit from PB_UnitGroup.
-
Else - Actions
- -------- - --------
- -------- Loop until cooldown finishes --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- PB_Duration Greater than 0.00
-
Then - Actions
- Hashtable - Save (PB_Duration - 0.10) as (Key PB_DurationHandle.) of (Key PB_Handle.) in PB_HastTable.
- Ability - Set Ability: (Unit: PB_Unit's Ability with Ability Code: Item Endure )'s Real Level Field: Life Regeneration Increase (%) ('Uau2') of Level: 0 to (((Max life of PB_Unit) - (Life of PB_Unit)) x 0.02)
- Unit - Increase level of Item Endure for PB_Unit
- Unit - Decrease level of Item Endure for PB_Unit
-
Else - Actions
- -------- - --------
- -------- Remove ability ItemEndure --------
- Item - For Item: (Item carried by PB_Unit of type Phthalo's Bracer), Remove Ability: Item Endure
- -------- - --------
- -------- Remove buff ItemEndure --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (PB_Unit has buff Endure (Item)) Equal to True
-
Then - Actions
- Unit - Remove Endure (Item) buff from PB_Unit
- Else - Actions
-
If - Conditions
- -------- - --------
- -------- Reset PB_HashTable --------
- Hashtable - Clear all child hashtables of child (Key PB_Handle.) in PB_HastTable.
- Unit Group - Remove PB_Unit from PB_UnitGroup.
-
If - Conditions
-
If - Conditions
-
Loop - Actions
- -------- - --------
- -------- Turn off PhthalosBracerTimer --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Number of units in PB_UnitGroup) Equal to 0
-
Then - Actions
- Trigger - Turn off (This trigger)
- Else - Actions
-
If - Conditions
-
Unit Group - Pick every unit in PB_UnitGroup and do (Actions)
-
Events
It seems to be playing up slightly and was wondering what I may be doing wrong/inefficiently.