Help. Why the Trigger doesn't work?

Level 6
Joined
Aug 31, 2018
Messages
167
Hello there. I don't understand why the trigger doesn't work. Please help ^^
 

Attachments

  • Death Grip.png
    Death Grip.png
    418.7 KB · Views: 27
Level 29
Joined
Sep 26, 2009
Messages
2,594
your indexing is off, since default value of DG_Index is zero. Yet your loop is iterating from value 1 till DG_Index.
Your deindexing doesn't work because you do not properly deindex instances.
You should also either choose arrays or hashtable and use that for everything in your spell. Mixing it doesn't make much sense.
Read Visualize: Dynamic Indexing to see how to properly index and deindex instances.

You do not clean leaks after yourself. This is especially bad with the "Move unit" action inside that 0.03 loop. Check Things That Leak to see how to fix it.
Same for your hashtable values - you do not clean up after yourself.

Your DG_Index check at the end of the loop trigger doesn't make sense, it basically says:
JASS:
if dg_index == 0 then
    // do something
else if dg_index == 0 then
    // do something else
end
 
Level 6
Joined
Aug 31, 2018
Messages
167
your indexing is off, since default value of DG_Index is zero. Yet your loop is iterating from value 1 till DG_Index.
Your deindexing doesn't work because you do not properly deindex instances.
You should also either choose arrays or hashtable and use that for everything in your spell. Mixing it doesn't make much sense.
Read Visualize: Dynamic Indexing to see how to properly index and deindex instances.

You do not clean leaks after yourself. This is especially bad with the "Move unit" action inside that 0.03 loop. Check Things That Leak to see how to fix it.
Same for your hashtable values - you do not clean up after yourself.

Your DG_Index check at the end of the loop trigger doesn't make sense, it basically says:
JASS:
if dg_index == 0 then
    // do something
else if dg_index == 0 then
    // do something else
end
Thank you, but oh, i am so doomed, lol. I used ChatGPT to help me do that. I dont have experience with world editor, but from what i see, i may consider and just give the map to someone else ^^
 
Level 6
Joined
Aug 31, 2018
Messages
167
Have you tried moving DG_INDEX = DG_INDEX + 1 to the top of the first trigger?
Sadly it still doesnt work :/ The guy above gave me useful info to read and understand, but the thing is, i dont want to become a developer, i just need to fix this spell so the map becomes editable, because right now no matter whan change we do on the map, we are left without this important spell and i need to fix it in order to keep map working/clean. So i just need easy solution to make this work
 
Level 6
Joined
Aug 31, 2018
Messages
167
Can you provide description of the spell and your Warcraft III patch?
Spell is literally Death Knight (from WoW) death grip (the pull/grab ability) and the map is WoW Arena Allstars itself. Catze (the creator) used same variables/hashtables on that skill and when you open the map, no matter what change u do, the trigger for that spell just breaks. So i am trying to remade it, but i am lacking skills and used ChatGPT to help me. The picture above you see is what he told me to do, but for some reason its not working.
 
Level 12
Joined
Nov 13, 2010
Messages
277
here you go
  • step 1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Life Drain
    • Actions
      • Set VariableSet DG_Caster = (Triggering unit)
      • Set VariableSet DG_Target = (Target unit of ability being cast)
      • Set VariableSet DG_Timer = 0.00
      • Trigger - Turn on step 2 <gen>

  • step 2
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
      • DG_Target Not equal to No unit
      • DG_Caster Not equal to No unit
    • Actions
      • Set VariableSet DG_Timer = (DG_Timer + 0.03)
      • Set VariableSet DG_Distance = (Distance between (Position of DG_Caster) and (Position of DG_Target))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (DG_Distance Less than or equal to 100.00) or (DG_Timer Greater than or equal to 1.50)
        • Then - Actions
          • Set VariableSet DG_Caster = No unit
          • Set VariableSet DG_Target = No unit
          • Set VariableSet DG_Timer = 0.00
          • Trigger - Turn off step 2 <gen>
        • Else - Actions
          • Set VariableSet DG_Angle = (Angle from (Position of DG_Target) to (Position of DG_Caster))
          • Unit - Move DG_Target instantly to ((Position of DG_Target) offset by 35.00 towards DG_Angle degrees.)
i have add a map if you don't know how to make the trigger yourself
 

Attachments

  • boom.w3m
    14 KB · Views: 3
Last edited:
Level 29
Joined
Sep 26, 2009
Messages
2,594
just my two cents:
  • @HolyWillRise chat gpt is a tool that can help you generate some code/script, but you should not solely rely on it, since it does not always produce good/working script. Your Death Grip has a lot of stuff done right, but it also has some mistakes and various inefficiencies. What I want to say is: You should still learn how to trigger stuff. Use chat gpt to generate some code for you, but it is vital to understand what the code does. There are many tutorials on the site one can learn from. Otherwise you risk getting into same situation you did right now.
  • @polardude your solution will work, but it will work for only one unit at a time. If two DK's cast Death Grip at the same time, it will break. The original solution, although faulty, was MUI, yours is not.
  • Both solutions use "Unit - Move unit" action to change position of the target. That may seem fine, until you get something in the way between the target and caster... like a bunch of trees, town hall structure or just a large group of enemies :)
 
Level 12
Joined
Nov 13, 2010
Messages
277
i made it into a mui but i dont have time to make a map for you but i made the trigger

Code:
Event: Map Initialization
Action:
Hashtable - Create a hashtable and store it in DeathGripTable
Set DeathGripGroup = (Empty group)
Code:
Event: Unit starts the effect of an ability
Condition: Ability being cast = Death Grip

Actions:
Set Caster = Triggering Unit
Set Target = Target unit of ability being cast
Custom script: set bj_wantDestroyGroup = true
Unit Group - Add Target to DeathGripGroup

Hashtable - Save (Caster) as 0 of (Handle of Target) in DeathGripTable
Hashtable - Save 0.00 as 1 of (Handle of Target) in DeathGripTable
Turn on skill Loop
Code:
Event: Every 0.03 seconds

Actions:
Unit Group - Pick every unit in DeathGripGroup and do actions:
    Set Target = (Picked unit)
    Hashtable - Load 0 of (Handle of Target) in DeathGripTable → Caster
    Hashtable - Load 1 of (Handle of Target) in DeathGripTable → Timer

    If (Target or Caster is dead) then:
        Remove Target from DeathGripGroup
        Clear hashtable entries
        then we skip to next unit

    Set Angle = (Angle from Position of Target to Position of Caster)
    Set Distance = Distance between them
    If (Distance <= 100 or Timer >= 1.50) then:
        Remove Target from DeathGripGroup
        Clear hashtable entries
    Else:
        Move Target instantly to (Target position offset by 20 toward Angle) with pathing
        Save (Timer + 0.03) as 1 of Handle of Target
 
Level 29
Joined
Sep 26, 2009
Messages
2,594
Note that stuff like this:
  • Unit - Move DG_Target instantly to ((Position of DG_Target) offset by 35.00 towards DG_Angle degrees.)
leaks two locations:
  • first: (Position of DG_Target)
  • second: first position offset by X towards Y

Assuming unit would fly the entire 1.5 seconds, the loop would iterate 50 times (0.03 * 50 => 1.50 seconds), so a single instance would leak 100 locations.

To prevent memory leaks, you would need to put each location into separate "Point" variable, then clean both of them, like so:
  • Set VariableSet Point1 = (Position of DG_Target)
  • Set VariableSet Point2 = (Point1 offset by 35.00 towards DG_Angle degrees.)
  • Unit - Move DG_Target instantly to Point2
  • Custom script: call RemoveLocation(udg_Point1)
  • Custom script: call RemoveLocation(udg_Point2)
 
Top