Kusanagi Kuro
Hosted Project: SC
- Joined
- Mar 11, 2012
- Messages
- 708
Hello guys.
I have a spell which works like this: Create a hammer and rotate it around the user for 9s, each full rotation is 1.8s, with the distance between it and the user extends as time passes. This hammer will deal damage to enemies every 0.2s if the enemies havent been damaged by the hammer within the last 0.85s.
The bug:
-When I cast the 1st hammer, it works fine.
-When I cast the 2nd hammer, it still works fine until the 1st hammer is destroyed, which then cause the 2nd hammer to deal 2 instances of damage.
-When I cast the 3rd hammer while the 1st and 2nd hammer are still alive, it works fine. When the 1st hammer is destroyed, it the 2nd hammer to deal 2 instances of damage, but the 3rd hammer is still fine. When the 2nd hammer is destroyed, then the 3rd hammer is bugged.
Currently I'm using Unit Indexer included in Damage Engine 3.7.0.1 by Bribe.
So here are my triggers:
[trigger=""]
Hammer Spawn
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Berserk
Actions
Set Generic_Point = (Position of (Triggering unit))
Unit - Create 1 Dummy (Hammer) for Player 1 (Red) at (Generic_Point offset by 100.00 towards (Facing of (Triggering unit)) degrees) facing ((Facing of (Triggering unit)) - 90.00) degrees
Set CV = (Custom value of (Last created unit))
Set BH_Angle[CV] = ((Facing of (Triggering unit)) - 90.00)
Set BH_Distance[CV] = 100.00
Set BH_HostUnit[CV] = (Triggering unit)
Unit - Add a 9.00 second Generic expiration timer to (Last created unit)
Unit Group - Add (Last created unit) to BH_UnitGroup
Custom script: call SaveGroupHandle(udg_BH_Hash, udg_CV, udg_CV, CreateGroup())
Custom script: call RemoveLocation(udg_Generic_Point)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Hammer Periodic <gen> is on) Equal to False
Then - Actions
Trigger - Turn on Hammer Periodic <gen>
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Hammer Rotation <gen> is on) Equal to False
Then - Actions
Trigger - Turn on Hammer Rotation <gen>
Else - Actions
[/trigger]
[trigger=""]
Hammer Rotation
Events
Time - Every 0.03 seconds of game time
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in BH_UnitGroup) Greater than 0
Then - Actions
Unit Group - Pick every unit in BH_UnitGroup and do (Actions)
Loop - Actions
Set CV = (Custom value of (Picked unit))
Set BH_DamageHammer = (Picked unit)
Set Generic_Point = (Position of BH_HostUnit[CV])
Set Generic_Point2 = (Generic_Point offset by BH_Distance[CV] towards BH_Angle[CV] degrees)
Unit - Move BH_DamageHammer instantly to Generic_Point2, facing BH_Angle[CV] degrees
Set BH_Distance[CV] = (BH_Distance[CV] + 0.20)
Set BH_Angle[CV] = (BH_Angle[CV] + 6.00)
Custom script: call RemoveLocation(udg_Generic_Point)
Custom script: call RemoveLocation(udg_Generic_Point2)
Else - Actions
Trigger - Turn off (This trigger)
[/trigger]
[trigger=""]
Hammer Periodic
Events
Time - Every 0.20 seconds of game time
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in BH_UnitGroup) Greater than 0
Then - Actions
Unit Group - Pick every unit in BH_UnitGroup and do (Actions)
Loop - Actions
Set CV = (Custom value of (Picked unit))
Set Generic_Point = (Position of (Picked unit))
Set Generic_Group = (Units within 100.00 of Generic_Point matching ((Owner of (Matching unit)) Not equal to Player 1 (Red)))
Set BH_DamageHammer = (Picked unit)
Unit Group - Pick every unit in Generic_Group and do (Actions)
Loop - Actions
-------- This will fire the real damage trigger --------
Unit - Cause BH_DamageHammer to damage (Picked unit), dealing 0.01 damage of attack type Spells and damage type Normal
Custom script: call RemoveLocation(udg_Generic_Point)
Custom script: call DestroyGroup(udg_Generic_Group)
Else - Actions
Trigger - Turn off (This trigger)
[/trigger]
[trigger=""]
Hammer Damage
Events
Game - DamageEvent becomes Equal to 1.00
Conditions
(Unit-type of DamageEventSource) Equal to Dummy (Hammer)
DamageEventAmount Less than 1.00
(DamageEventTarget is in (Load (Custom value of DamageEventSource) of (Custom value of DamageEventSource) in BH_Hash)) Equal to False
Actions
Custom script: local unit udg_BH_DamageHammer
Custom script: local unit udg_BH_DamagedTarget
Custom script: local integer udg_CV
Set BH_DamageHammer = DamageEventSource
Set BH_DamagedTarget = DamageEventTarget
Set CV = (Custom value of BH_DamageHammer)
Unit - Cause BH_HostUnit[CV] to damage BH_DamagedTarget, dealing 5.00 damage of attack type Spells and damage type Normal
Unit Group - Add BH_DamagedTarget to (Load CV of CV in BH_Hash)
Wait 0.85 seconds
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(BH_DamageHammer is alive) Equal to True
Then - Actions
Unit Group - Remove BH_DamagedTarget from (Load CV of CV in BH_Hash)
Else - Actions
Custom script: set udg_BH_DamagedTarget = null
Custom script: set udg_BH_DamageHammer = null
[/trigger]
[trigger=""]
Hammer Remove
Events
Unit - A unit Dies
Conditions
(Unit-type of (Triggering unit)) Equal to Dummy (Hammer)
Actions
Set CV = (Custom value of (Triggering unit))
Unit Group - Remove (Triggering unit) from BH_UnitGroup
Set Generic_Group = (Load CV of CV in BH_Hash)
Hashtable - Clear all child hashtables of child CV in BH_Hash
Custom script: call DestroyGroup(udg_Generic_Group)
[/trigger]
-------------------------------------------------------------------------------------------------------------------
If I change 2 of the triggers above to this:
[trigger=""]
Hammer Damage
Events
Game - DamageEvent becomes Equal to 1.00
Conditions
(Unit-type of DamageEventSource) Equal to Dummy (Hammer)
DamageEventAmount Less than 1.00
(DamageEventTarget is in (Load (Custom value of DamageEventSource) of (Custom value of DamageEventSource) in BH_Hash)) Equal to False
Actions
Custom script: local unit udg_BH_DamageHammer
Custom script: local unit udg_BH_DamagedTarget
Custom script: local integer udg_CV
Set BH_DamageHammer = DamageEventSource
Set BH_DamagedTarget = DamageEventTarget
Set CV = (Custom value of BH_DamageHammer)
Unit - Cause BH_HostUnit[CV] to damage BH_DamagedTarget, dealing 5.00 damage of attack type Spells and damage type Normal
Unit Group - Add BH_DamagedTarget to (Load CV of CV in BH_Hash)
Wait 0.85 seconds
Unit Group - Remove BH_DamagedTarget from (Load CV of CV in BH_Hash)
Custom script: set udg_BH_DamagedTarget = null
Custom script: set udg_BH_DamageHammer = null
[/trigger]
[trigger=""]
Hammer Remove
Events
Unit - A unit Dies
Conditions
(Unit-type of (Triggering unit)) Equal to Dummy (Hammer)
Actions
Unit Group - Remove (Triggering unit) from BH_UnitGroup
[/trigger]
Then the bug is fixed. However, I'm not sure if this will leave memory leaks or not.
I have a spell which works like this: Create a hammer and rotate it around the user for 9s, each full rotation is 1.8s, with the distance between it and the user extends as time passes. This hammer will deal damage to enemies every 0.2s if the enemies havent been damaged by the hammer within the last 0.85s.
The bug:
-When I cast the 1st hammer, it works fine.
-When I cast the 2nd hammer, it still works fine until the 1st hammer is destroyed, which then cause the 2nd hammer to deal 2 instances of damage.
-When I cast the 3rd hammer while the 1st and 2nd hammer are still alive, it works fine. When the 1st hammer is destroyed, it the 2nd hammer to deal 2 instances of damage, but the 3rd hammer is still fine. When the 2nd hammer is destroyed, then the 3rd hammer is bugged.
Currently I'm using Unit Indexer included in Damage Engine 3.7.0.1 by Bribe.
So here are my triggers:
[trigger=""]
Hammer Spawn
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Berserk
Actions
Set Generic_Point = (Position of (Triggering unit))
Unit - Create 1 Dummy (Hammer) for Player 1 (Red) at (Generic_Point offset by 100.00 towards (Facing of (Triggering unit)) degrees) facing ((Facing of (Triggering unit)) - 90.00) degrees
Set CV = (Custom value of (Last created unit))
Set BH_Angle[CV] = ((Facing of (Triggering unit)) - 90.00)
Set BH_Distance[CV] = 100.00
Set BH_HostUnit[CV] = (Triggering unit)
Unit - Add a 9.00 second Generic expiration timer to (Last created unit)
Unit Group - Add (Last created unit) to BH_UnitGroup
Custom script: call SaveGroupHandle(udg_BH_Hash, udg_CV, udg_CV, CreateGroup())
Custom script: call RemoveLocation(udg_Generic_Point)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Hammer Periodic <gen> is on) Equal to False
Then - Actions
Trigger - Turn on Hammer Periodic <gen>
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Hammer Rotation <gen> is on) Equal to False
Then - Actions
Trigger - Turn on Hammer Rotation <gen>
Else - Actions
[/trigger]
[trigger=""]
Hammer Rotation
Events
Time - Every 0.03 seconds of game time
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in BH_UnitGroup) Greater than 0
Then - Actions
Unit Group - Pick every unit in BH_UnitGroup and do (Actions)
Loop - Actions
Set CV = (Custom value of (Picked unit))
Set BH_DamageHammer = (Picked unit)
Set Generic_Point = (Position of BH_HostUnit[CV])
Set Generic_Point2 = (Generic_Point offset by BH_Distance[CV] towards BH_Angle[CV] degrees)
Unit - Move BH_DamageHammer instantly to Generic_Point2, facing BH_Angle[CV] degrees
Set BH_Distance[CV] = (BH_Distance[CV] + 0.20)
Set BH_Angle[CV] = (BH_Angle[CV] + 6.00)
Custom script: call RemoveLocation(udg_Generic_Point)
Custom script: call RemoveLocation(udg_Generic_Point2)
Else - Actions
Trigger - Turn off (This trigger)
[/trigger]
[trigger=""]
Hammer Periodic
Events
Time - Every 0.20 seconds of game time
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in BH_UnitGroup) Greater than 0
Then - Actions
Unit Group - Pick every unit in BH_UnitGroup and do (Actions)
Loop - Actions
Set CV = (Custom value of (Picked unit))
Set Generic_Point = (Position of (Picked unit))
Set Generic_Group = (Units within 100.00 of Generic_Point matching ((Owner of (Matching unit)) Not equal to Player 1 (Red)))
Set BH_DamageHammer = (Picked unit)
Unit Group - Pick every unit in Generic_Group and do (Actions)
Loop - Actions
-------- This will fire the real damage trigger --------
Unit - Cause BH_DamageHammer to damage (Picked unit), dealing 0.01 damage of attack type Spells and damage type Normal
Custom script: call RemoveLocation(udg_Generic_Point)
Custom script: call DestroyGroup(udg_Generic_Group)
Else - Actions
Trigger - Turn off (This trigger)
[/trigger]
[trigger=""]
Hammer Damage
Events
Game - DamageEvent becomes Equal to 1.00
Conditions
(Unit-type of DamageEventSource) Equal to Dummy (Hammer)
DamageEventAmount Less than 1.00
(DamageEventTarget is in (Load (Custom value of DamageEventSource) of (Custom value of DamageEventSource) in BH_Hash)) Equal to False
Actions
Custom script: local unit udg_BH_DamageHammer
Custom script: local unit udg_BH_DamagedTarget
Custom script: local integer udg_CV
Set BH_DamageHammer = DamageEventSource
Set BH_DamagedTarget = DamageEventTarget
Set CV = (Custom value of BH_DamageHammer)
Unit - Cause BH_HostUnit[CV] to damage BH_DamagedTarget, dealing 5.00 damage of attack type Spells and damage type Normal
Unit Group - Add BH_DamagedTarget to (Load CV of CV in BH_Hash)
Wait 0.85 seconds
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(BH_DamageHammer is alive) Equal to True
Then - Actions
Unit Group - Remove BH_DamagedTarget from (Load CV of CV in BH_Hash)
Else - Actions
Custom script: set udg_BH_DamagedTarget = null
Custom script: set udg_BH_DamageHammer = null
[/trigger]
[trigger=""]
Hammer Remove
Events
Unit - A unit Dies
Conditions
(Unit-type of (Triggering unit)) Equal to Dummy (Hammer)
Actions
Set CV = (Custom value of (Triggering unit))
Unit Group - Remove (Triggering unit) from BH_UnitGroup
Set Generic_Group = (Load CV of CV in BH_Hash)
Hashtable - Clear all child hashtables of child CV in BH_Hash
Custom script: call DestroyGroup(udg_Generic_Group)
[/trigger]
-------------------------------------------------------------------------------------------------------------------
If I change 2 of the triggers above to this:
[trigger=""]
Hammer Damage
Events
Game - DamageEvent becomes Equal to 1.00
Conditions
(Unit-type of DamageEventSource) Equal to Dummy (Hammer)
DamageEventAmount Less than 1.00
(DamageEventTarget is in (Load (Custom value of DamageEventSource) of (Custom value of DamageEventSource) in BH_Hash)) Equal to False
Actions
Custom script: local unit udg_BH_DamageHammer
Custom script: local unit udg_BH_DamagedTarget
Custom script: local integer udg_CV
Set BH_DamageHammer = DamageEventSource
Set BH_DamagedTarget = DamageEventTarget
Set CV = (Custom value of BH_DamageHammer)
Unit - Cause BH_HostUnit[CV] to damage BH_DamagedTarget, dealing 5.00 damage of attack type Spells and damage type Normal
Unit Group - Add BH_DamagedTarget to (Load CV of CV in BH_Hash)
Wait 0.85 seconds
Unit Group - Remove BH_DamagedTarget from (Load CV of CV in BH_Hash)
Custom script: set udg_BH_DamagedTarget = null
Custom script: set udg_BH_DamageHammer = null
[/trigger]
[trigger=""]
Hammer Remove
Events
Unit - A unit Dies
Conditions
(Unit-type of (Triggering unit)) Equal to Dummy (Hammer)
Actions
Unit Group - Remove (Triggering unit) from BH_UnitGroup
[/trigger]
Then the bug is fixed. However, I'm not sure if this will leave memory leaks or not.
Last edited: