• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Why is this spell getting bugged sometimes?

Status
Not open for further replies.
Level 14
Joined
Jul 19, 2007
Messages
772
I can't find the problem why this triggered ability gets bugged sometimes.

Projects a powerful magical blast in a targeted area, dealing 1x/2x/3x/4x intelligence damage and knocks back enemy land units with the distance of 250.

The bug doesn't happening everytime I'm casting the spell it just happening sometimes but it really needs to be solved.. The bug causes the spell to randomly pick an unit within the AOE of the spell and stunning until something kills it and it can even be happening on the casting unit too! The spell is mean't to only damage and knockback enemy units and it does work like it should when it doesn't make the mysterious stunning-bug..

Here is the triggers.
  • Invisible Force
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Invisible Force
    • Actions
      • Set TempLoc1 = (Target point of ability being cast)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 400,00 of TempLoc1) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an enemy of (Triggering player)) Equal to True
              • ((Picked unit) is Magic Immune) Equal to False
              • ((Picked unit) is dead) Equal to False
            • Then - Actions
              • Set TempUnit1 = (Picked unit)
              • Set TempLoc2 = (Position of TempUnit1)
              • Custom script: set udg_TempInt1 = GetHandleId(udg_TempUnit1)
              • -------- Deal Damage --------
              • Unit - Cause (Triggering unit) to damage TempUnit1, dealing (Real(((Level of Invisible Force for (Triggering unit)) x (Intelligence of (Triggering unit) (Include bonuses))))) damage of attack type Spells and damage type Normal
              • -------- Stun Unit --------
              • Set SS_Unit_Target = TempUnit1
              • Set SS_Real_Duration = 1,00
              • Set SS_Boolean_Stack = False
              • Set SS_Real_Distance = (Random real number between 1,00 and 300,00)
              • Custom script: call ExecuteFunc("StunSystem_Run")
              • -------- Add Knockback --------
              • Special Effect - Create a special effect attached to the origin of TempUnit1 using Abilities\Spells\Other\Tornado\Tornado_Target.mdl
              • Hashtable - Save Handle Of(Last created special effect) as (Key effect_1) of TempInt1 in Knockback_Hash
              • Hashtable - Save 0,00 as (Key loop) of TempInt1 in Knockback_Hash
              • Hashtable - Save 0,00 as (Key offset) of TempInt1 in Knockback_Hash
              • Hashtable - Save (Angle from TempLoc1 to TempLoc2) as (Key angle) of TempInt1 in Knockback_Hash
              • Unit Group - Add TempUnit1 to Knockback_Group
              • Custom script: call RemoveLocation(udg_TempLoc2)
              • Trigger - Turn on Knockback <gen>
            • Else - Actions
      • Custom script: call RemoveLocation(udg_TempLoc1)
  • Knockback
    • Events
      • Time - Every 0,03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Knockback_Group and do (Actions)
        • Loop - Actions
          • Set Temp_Unit_1 = (Picked unit)
          • Set Temp_Real_1 = (Load (Key loop) of (Key (Picked unit)) from Knockback_Hash)
          • -------- -------------------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Temp_Real_1 Less than or equal to (Knockback_Time x (1,00 / 0,03))
            • Then - Actions
              • Set Temp_Loc_1 = (Position of Temp_Unit_1)
              • -------- -------------------- --------
              • Set Temp_Real_2 = (Load (Key angle) of (Key (Picked unit)) from Knockback_Hash)
              • -------- -------------------- --------
              • Set Temp_Real_3 = (Knockback_Speed x (Power(0,90, Temp_Real_1)))
              • -------- -------------------- --------
              • Set Temp_Real_4 = (X of Temp_Loc_1)
              • Set Temp_Real_5 = (Y of Temp_Loc_1)
              • -------- -------------------- --------
              • Set Temp_Real_4 = ((X of Temp_Loc_1) + (Temp_Real_3 x (Cos(Temp_Real_2))))
              • Set Temp_Real_5 = ((Y of Temp_Loc_1) + (Temp_Real_3 x (Sin(Temp_Real_2))))
              • -------- -------------------- --------
              • Set Temp_Loc_2 = (Point(Temp_Real_4, Temp_Real_5))
              • -------- -------------------- --------
              • Custom script: set udg_Boolean = IsTerrainWalkable(udg_Temp_Loc_2)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Boolean Equal to True
                • Then - Actions
                  • Custom script: call SetUnitX(udg_Temp_Unit_1, udg_Temp_Real_4)
                  • Custom script: call SetUnitY(udg_Temp_Unit_1, udg_Temp_Real_5)
                • Else - Actions
              • -------- -------------------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Knockback_Rotate Equal to True
                  • (Random integer number between 1 and 4) Equal to 1
                • Then - Actions
                  • Unit - Make Temp_Unit_1 face ((Facing of Temp_Unit_1) - 180,00) over 0,00 seconds
                • Else - Actions
              • -------- -------------------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Knockback_DoT Equal to True
                • Then - Actions
                  • Set Temp_Unit_2 = (Load (Key caster) of (Key (Picked unit)) in Knockback_Hash)
                  • Set Temp_Real_2 = (Load (Key dmg) of (Key (Picked unit)) from Knockback_Hash)
                  • Unit - Cause Temp_Unit_2 to damage Temp_Unit_1, dealing Temp_Real_2 damage of attack type Spells and damage type Normal
                • Else - Actions
              • -------- -------------------- --------
              • Hashtable - Save (Temp_Real_1 + 1,00) as (Key loop) of (Key (Picked unit)) in Knockback_Hash
              • -------- -------------------- --------
              • Custom script: call RemoveLocation(udg_Temp_Loc_1)
              • Custom script: call RemoveLocation(udg_Temp_Loc_2)
            • Else - Actions
              • -------- -------------------- --------
              • Special Effect - Destroy (Load (Key effect_1) of (Key (Picked unit)) in Knockback_Hash)
              • -------- -------------------- --------
              • Unit Group - Remove Temp_Unit_1 from Knockback_Group
              • -------- -------------------- --------
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Knockback_Hash
              • -------- -------------------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in Knockback_Group) Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
 
Last edited:
Level 14
Joined
Jul 19, 2007
Messages
772
What stun system are you using?
This one. I haven't created this spell by myself, a friend did and he can't find the problem why the spell is doing this bug sometimes..
  • Stun System by KhaosMachine
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- The unit-type that cast the stun ability --------
      • Set SS_UnitType_Dummy = Spell Cast Dummy (Clouds of the Sea)
      • Set SS_Ability_Stun = Stun
      • Set SS_String_Order = stomp
      • Set SS_Buff_Stun = Stunned (Pause)
      • Set SS_Real_Interval = 0.05
      • -------- |||||||||||||||||||||||||||||||||||||||||||||||||END OF CONFIGURATION||||||||||||||||||||||||||||||||||||||||||||||||| --------
      • Set SS_Region_Map = (Playable map area)
      • Set SS_Player_NeutralPassive = Neutral Passive
      • Set SS_Player_Temp = Player 1 (Red)
      • Set SS_Point_Temp = (Center of (Playable map area))
      • Unit - Create 1 SS_UnitType_Dummy for SS_Player_Temp at SS_Point_Temp facing 0.00 degrees
      • Set SS_Unit_Temp = (Last created unit)
      • Unit - Add SS_Ability_Stun to SS_Unit_Temp
      • Unit - Remove SS_Unit_Temp from the game
      • Custom script: call RemoveLocation(udg_SS_Point_Temp)
      • Custom script: endfunction
      • Custom script: function StunSystem_Running takes nothing returns nothing
      • Unit Group - Pick every unit in SS_UnitGroup_Group and do (Actions)
        • Loop - Actions
          • Set SS_Unit_Temp = (Picked unit)
          • Set ID = (Custom value of SS_Unit_Temp)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SS_Real_Time[ID] Greater than or equal to 0.00
            • Then - Actions
              • Set SS_Real_Time[ID] = (SS_Real_Time[ID] - 0.05)
            • Else - Actions
              • Unit - Remove SS_Buff_Stun buff from SS_Unit_Temp
              • Unit Group - Remove SS_Unit_Temp from SS_UnitGroup_Group
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (SS_UnitGroup_Group is empty) Equal to True
                • Then - Actions
                  • Countdown Timer - Pause SS_Timer_Running
                • Else - Actions
      • Custom script: endfunction
      • Custom script: function StunSystem_Run takes nothing returns nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SS_Unit_Target Not equal to No unit
          • (SS_Unit_Target is alive) Equal to True
        • Then - Actions
          • Set SS_Point_Temp2 = (Position of SS_Unit_Target)
          • Set ID = (Custom value of SS_Unit_Target)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SS_Boolean_Stack Equal to True
            • Then - Actions
              • Set SS_Real_Time[ID] = (SS_Real_Time[ID] + SS_Real_Duration)
            • Else - Actions
              • Set SS_Real_Time[ID] = SS_Real_Duration
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (SS_Unit_Target has buff SS_Buff_Stun) Equal to False
            • Then - Actions
              • Set SS_Point_Temp = (SS_Point_Temp2 offset by SS_Real_Distance towards (Random angle) degrees)
              • Unit - Move SS_Unit_Target instantly to SS_Point_Temp
              • Unit - Create 1 SS_UnitType_Dummy for Neutral Passive at SS_Point_Temp facing 0.00 degrees
              • Set SS_Unit_Temp = (Last created unit)
              • Unit - Add SS_Ability_Stun to SS_Unit_Temp
              • Unit - Order SS_Unit_Temp to Orc Tauren Chieftain - War Stomp
              • Custom script: call IssueImmediateOrder(udg_SS_Unit_Temp, udg_SS_String_Order)
              • Unit - Add a 0.40 second Generic expiration timer to SS_Unit_Temp
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (SS_UnitGroup_Group is empty) Equal to True
                • Then - Actions
                  • Custom script: call TimerStart(udg_SS_Timer_Running, udg_SS_Real_Interval, true, function StunSystem_Running)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (SS_Unit_Target is in SS_UnitGroup_Group) Equal to True
                • Then - Actions
                • Else - Actions
                  • Unit Group - Add SS_Unit_Target to SS_UnitGroup_Group
              • Unit - Move SS_Unit_Target instantly to SS_Point_Temp2
              • Custom script: call RemoveLocation(udg_SS_Point_Temp)
            • Else - Actions
          • Custom script: call RemoveLocation(udg_SS_Point_Temp2)
        • Else - Actions
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
((Picked unit) belongs to an enemy of (Triggering player)) Equal to True
It would only ever pick the casting unit if this was to pass. Check if Triggering player is the appropriate value and that a player does not return as an enemy of itself (I know in SC2 allies do not count the player who you are testing, not sure how WC3 defines enemies).

Set ID = (Custom value of SS_Unit_Temp)
The stun system is not safe if anything else in the map uses custom values of units. This is why you should never, ever use custom value functionality of a unit outside of a map specific system. What is likely happening is something other than the stun system modifies the custom value on the unit causing the instance mapping to become corrupt so the stun system can never remove the stun buff as it cannot perform a unit->instance translation correctly.

Set Temp_Real_1 = (Load (Key loop) of (Key (Picked unit)) from Knockback_Hash)
Custom script: set udg_TempInt1 = GetHandleId(udg_TempUnit1)
Are you sure the underlined produce the exact same results?
 
Level 14
Joined
Jul 19, 2007
Messages
772
It would only ever pick the casting unit if this was to pass. Check if Triggering player is the appropriate value and that a player does not return as an enemy of itself (I know in SC2 allies do not count the player who you are testing, not sure how WC3 defines enemies).


The stun system is not safe if anything else in the map uses custom values of units. This is why you should never, ever use custom value functionality of a unit outside of a map specific system. What is likely happening is something other than the stun system modifies the custom value on the unit causing the instance mapping to become corrupt so the stun system can never remove the stun buff as it cannot perform a unit->instance translation correctly.


Are you sure the underlined produce the exact same results?
Well the stun-bug doesn't only happening on the casting Hero, it just picks one randomly unit in the casting area of the spell and stunning it for all the time or until it dies. It can happening on both enemies and allies. The bug doesn't happening very often but sometimes it does and it ruins alot of the gameplay..
 

hdm

hdm

Level 9
Joined
Nov 19, 2011
Messages
384
Nice statement. On behalf of all of us, thank you.
Next time please just bump the thread ;)
A more reasonable explanation would be, "we" don't know how to fix the trigger or have not seen your post.

How to bump the tread?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
Well the stun-bug doesn't only happening on the casting Hero, it just picks one randomly unit in the casting area of the spell and stunning it for all the time or until it dies. It can happening on both enemies and allies. The bug doesn't happening very often but sometimes it does and it ruins alot of the gameplay..
Well that is either caused by some external system interfering with the system or that one of the area search conditions is returning true when it should not.

On closer inspection of the stun system it apparently requires a unit index system. It expects each unit to have a unique custom value and will bug if two or more affected units do not.
 
Level 14
Joined
Jul 19, 2007
Messages
772
Well that is either caused by some external system interfering with the system or that one of the area search conditions is returning true when it should not.

On closer inspection of the stun system it apparently requires a unit index system. It expects each unit to have a unique custom value and will bug if two or more affected units do not.
Alright but I have no idéa how to make it. I didn't make the triggers of the spell at all and would be thankful if someone would help me.. Another small bug I found with this ability is the special-effect created to units who get knocked back. The special-effect will not be removed from the Unit/Hero if it dies of this spell. When the Hero gets revived it still has the tornado special-effect and will never be removed..
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
As mentioned, you need a unit indexer for the knockback system to operate (gives each unit a unique custom value). Tons of such systems exist, just import any that does its job properly and it will work.

After that is done we can talk about other bugs as all you are reporting currently are likely caused by the lack of a unit indexer.
 
Level 14
Joined
Jul 19, 2007
Messages
772
As mentioned, you need a unit indexer for the knockback system to operate (gives each unit a unique custom value). Tons of such systems exist, just import any that does its job properly and it will work.

After that is done we can talk about other bugs as all you are reporting currently are likely caused by the lack of a unit indexer.
Well I dunno how to do that.. I'm very lost at triggering :/
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
Either you import the one the ability recommended, find your own or I would recommend not using the custom ability.

In case if you want to write your own the mechanics are pretty simple...

When a unit enters existence you allocate it an index and set its custom value to that index. This index either comes from a collection of indices (pop one off it) or if that collection is empty it comes from a counter (value of counter then increment counter by 1). When a unit leaves existence (such as on death usually) you then add its index in the form of its custom value to the collection to be recycled. Incredibly easy for anyone doing any kind of computer science degree, however if you do not understand any of the terms above I would advise using a ready-made unit indexer as they are as simple as importing a trigger and some globals.
 
Level 14
Joined
Jul 19, 2007
Messages
772
Either you import the one the ability recommended, find your own or I would recommend not using the custom ability.

In case if you want to write your own the mechanics are pretty simple...

When a unit enters existence you allocate it an index and set its custom value to that index. This index either comes from a collection of indices (pop one off it) or if that collection is empty it comes from a counter (value of counter then increment counter by 1). When a unit leaves existence (such as on death usually) you then add its index in the form of its custom value to the collection to be recycled. Incredibly easy for anyone doing any kind of computer science degree, however if you do not understand any of the terms above I would advise using a ready-made unit indexer as they are as simple as importing a trigger and some globals.
I'm sorry but I don't really get what you are talking about.. I don't think I can fix this bug at all by myself because I'm kinda lost of triggering. I wish the one who created this ability to me could help me but he just can't find what's wrong in the triggers which sometimes causes this perma-stunning bug..
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
I will ebut he just can't find what's wrong in the triggers which sometimes causes this perma-stunning bug..
I will repeat myself. Looking at the logic that kind of bug is expected if the map has no unit indexer that assigns a unique custom value within array range to each unit. Such systems are commonly used by some abilities and often people assume your map has one already. Since there are communication problems with what I am saying I would suggest you post the map in a way this problem can be easily recreated so that we can try and fix it instead of telling you how we think it needs to be fixed which may or may not be correct. A lot of people prefer hands on over proxy as far as fixing stuff.
 
Level 14
Joined
Jul 19, 2007
Messages
772
I will repeat myself. Looking at the logic that kind of bug is expected if the map has no unit indexer that assigns a unique custom value within array range to each unit. Such systems are commonly used by some abilities and often people assume your map has one already. Since there are communication problems with what I am saying I would suggest you post the map in a way this problem can be easily recreated so that we can try and fix it instead of telling you how we think it needs to be fixed which may or may not be correct. A lot of people prefer hands on over proxy as far as fixing stuff.
Well I will not post my map in this thread because I don't want anyone to steal it but if anyone is going to help me fix the bug I can send it in a private message...
 
Status
Not open for further replies.
Top