I have no idea what's wrong with these triggers...

Moridin

Snow Leopard
Reaction score
144
Okay. A small problem I'm having. Some of you might be intimidated by the wall of GUI code, but I promise you my problem will probably NOT include you reading through all my code. Firstly: Here are the two triggers:

Trigger:
  • Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Static Lightning
    • Actions
      • Set Count = 1
      • Unit Group - Pick every unit in (Units within ((300.00 + (100.00 x (Real((Level of Static Lightning for (Triggering unit)))))) / 2.00) of (Target point of ability being cast) matching ((((Triggering player) is an enemy of (Owner of (Matching unit))) Equal to True) and (((Matching unit) is and do (Actions)
        • Loop - Actions
          • Set Count = (Count + 1)
          • Unit Group - Add (Picked unit) to Units_chosen
          • Unit - Pause (Picked unit)
          • Unit - Set the custom value of (Picked unit) to 0
          • Hashtable - Save Handle Of(Picked unit) as (Key (Triggering unit)) of Count in Spell
          • Hashtable - Save 500 as ((Key (Triggering unit)) + 1) of Count in Spell
          • Special Effect - Create a special effect attached to the overhead of (Picked unit) using Abilities\Spells\Other\Drain\DrainTarget.mdl
          • Hashtable - Save Handle Of(Last created special effect) as ((Key (Triggering unit)) + 2) of Count in Spell
          • Lightning - Create a Chain Lightning - Primary lightning effect from source (Position of (Triggering unit)) to target (Position of (Picked unit))
          • Hashtable - Save Handle Of(Last created lightning effect) as ((Key (Triggering unit)) + 3) of Count in Spell
      • Hashtable - Save Count as ((Key (Triggering unit)) + 1) of 1 in Spell
      • Game - Display to (All players) the text: ((String(Count)) + = Count)
      • Unit Group - Add (Triggering unit) to Units_casting
      • Unit - Pause (Triggering unit)
      • Animation - Play (Triggering unit)'s channel animation


Trigger:
  • Drag
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Units_casting and do (Actions)
        • Loop - Actions
          • Set Stopper = 1
          • For each (Integer Drag_V_1) from 2 to (Load ((Key (Picked unit)) + 1) of 1 from Spell), do (Actions)
            • Loop - Actions
              • Set current_unit = (Load (Key (Picked unit)) of Drag_V_1 in Spell)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (current_unit is in Units_chosen) Equal to False
                • Then - Actions
                  • Set Stopper = (Stopper + 1)
                  • Game - Display to (All players) the text: ((String(Stopper)) + = Stopper)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Stopper Equal to (Load ((Key (Picked unit)) + 1) of 1 from Spell)
                    • Then - Actions
                      • Game - Display to (All players) the text: ((String(Stopper)) + = Stopper)
                      • Game - Display to (All players) the text: Stopping from main ...
                      • Unit Group - Remove (Picked unit) from Units_casting
                      • Unit - Unpause (Picked unit)
                      • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Spell
                    • Else - Actions
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (current_unit is dead) Equal to True
                • Then - Actions
                  • Unit Group - Remove current_unit from Units_chosen
                  • Unit - Set the custom value of current_unit to 2
                  • Unit - Unpause current_unit
                  • Unit - Turn collision for current_unit On
                  • Special Effect - Destroy (Load ((Key (Picked unit)) + 2) of Drag_V_1 in Spell)
                • Else - Actions
                  • Unit - Turn collision for current_unit Off
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between (Position of current_unit) and (Position of (Picked unit))) Less than or equal to 150.00
                    • Then - Actions
                      • Unit - Set the custom value of current_unit to 1
                    • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Load ((Key (Picked unit)) + 1) of Drag_V_1 from Spell) Less than or equal to 0
                    • Then - Actions
                      • Unit Group - Remove current_unit from Units_chosen
                      • Unit - Set the custom value of current_unit to 2
                      • Unit - Unpause current_unit
                      • Unit - Turn collision for current_unit On
                    • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Custom value of current_unit) Equal to 0
                    • Then - Actions
                      • Lightning - Move (Load ((Key (Picked unit)) + 3) of Drag_V_1 in Spell) to source (Position of (Picked unit)) and target (Position of current_unit)
                      • Unit - Move current_unit instantly to ((Position of current_unit) offset by 1.00 towards (Angle from (Position of current_unit) to (Position of (Picked unit))) degrees)
                      • Unit - Cause (Picked unit) to damage current_unit, dealing ((40.00 x 0.03) x (Real((Level of Static Lightning for (Picked unit))))) damage of attack type Spells and damage type Normal
                    • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Custom value of current_unit) Equal to 1
                    • Then - Actions
                      • Lightning - Destroy (Load ((Key (Picked unit)) + 3) of Drag_V_1 in Spell)
                      • Special Effect - Destroy (Load ((Key (Picked unit)) + 2) of Drag_V_1 in Spell)
                      • Special Effect - Create a special effect at (Position of current_unit) using Objects\Spawnmodels\Undead\ImpaleTargetDust\ImpaleTargetDust.mdl
                      • Unit - Move current_unit instantly to ((Position of current_unit) offset by 20.00 towards (Angle from (Position of (Picked unit)) to (Position of current_unit)) degrees)
                      • Unit - Cause (Picked unit) to damage current_unit, dealing ((40.00 x (20.00 / 500.00)) x (Real((Level of Static Lightning for (Picked unit))))) damage of attack type Spells and damage type Normal
                      • Hashtable - Save ((Load ((Key (Picked unit)) + 1) of Drag_V_1 from Spell) - 20) as ((Key (Picked unit)) + 1) of Drag_V_1 in Spell
                      • Special Effect - Destroy (Last created special effect)
                    • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load ((Key (Picked unit)) + 1) of 1 from Spell) Less than 2
              • ((Picked unit) is paused) Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: Stopping from side ...
              • Unit Group - Remove (Picked unit) from Units_casting
              • Unit - Unpause (Picked unit)
            • Else - Actions

Now my problem is that this piece of code:

Trigger:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Stopper Equal to (Load ((Key (Picked unit)) + 1) of 1 from Spell)
    • Then - Actions
      • Game - Display to (All players) the text: ((String(Stopper)) + = Stopper)
      • Game - Display to (All players) the text: Stopping from main ...
      • Unit Group - Remove (Picked unit) from Units_casting
      • Unit - Unpause (Picked unit)
      • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Spell
    • Else - Actions


....in the second trigger somehow loops it back to the first trigger. I have no idea why it does this...and I need it to stop. No where in the either trigger have I used the actions:

Trigger - Run trigger (Checking conditions)/(ignoring conditions)

Edit: also how do you hide stuff with spoilers ? :S
 

jomik

New Member
Reaction score
17
Edit: also how do you hide stuff with spoilers ? :S
Think you hide them with
tags :p

I'm looking over your code now >.<

What are you doing with the
Trigger:
  • Stopper Equal to (Load ((Key (Picked unit)) + 1) of 1 from Spell)

condition? 1 from Spell? :O

Ahh think I know now :p I dunno much about hashtables, so it's probably some hashtable thing? :p
And you have massive amounts of leaks :D
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Well, I don't know why it would be going back to the first trigger, but I think you have the child/parent keys swapped when saving to the hashtable.

If you want to be able to do this:
Trigger:
  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Spell


Then the way you're doing it:
Trigger:
  • Hashtable - Save Handle Of(Last created lightning effect) as ((Key (Triggering unit)) + 3) of Count in Spell

...is backwards. You'd need to do this:
Trigger:
  • ...
    • Hashtable - Save Handle Of(Picked unit) as (4*Count) of (Key (Triggering unit)) in Spell
    • Hashtable - Save 500 as ((4*Count) + 1) of (Key (Triggering unit)) in Spell
    • Hashtable - Save Handle Of(Last created special effect) as ((4*Count) + 2) of (Key (Triggering unit)) in Spell
    • Hashtable - Save Handle Of(Last created lightning effect) as ((4*Count) + 3) of (Key (Triggering unit)) in Spell


Edit: also how do you hide stuff with spoilers ? :S
Spoilers don't work in all the forums, eg. they work in Tutorials and Resources, but not in World Editor Help. :(
 

Moridin

Snow Leopard
Reaction score
144
If you want to be able to do this:
Trigger:

* Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Spell



Then the way you're doing it:
Trigger:

* Hashtable - Save Handle Of(Last created lightning effect) as ((Key (Triggering unit)) + 3) of Count in Spell


...is backwards. You'd need to do this:
Trigger:

* ...
o Hashtable - Save Handle Of(Picked unit) as (4*Count) of (Key (Triggering unit)) in Spell
o Hashtable - Save 500 as ((4*Count) + 1) of (Key (Triggering unit)) in Spell
o Hashtable - Save Handle Of(Last created special effect) as ((4*Count) + 2) of (Key (Triggering unit)) in Spell
o Hashtable - Save Handle Of(Last created lightning effect) as ((4*Count) + 3) of (Key (Triggering unit)) in Spell

Haha. Don't worry. I think I know what I'm doing. Thank you for the help anyway. The way my hashtable is organised is:

Casting unit Bash distance
Sub-unit Effect for s-u
Sub-unit Effect for s-u
Sub-unit Effect for s-u
Sub-unit Effect for s-u
------

I'm looking over your code now >.<

What are you doing with the
Trigger:

* Stopper Equal to (Load ((Key (Picked unit)) + 1) of 1 from Spell)


condition? 1 from Spell? :O

Ahh think I know now I dunno much about hashtables, so it's probably some hashtable thing?
And you have massive amounts of leaks

The way I've triggered the spell, it causes all the targeted units to do their actions simultaneously no matter who the caster is. In this way, I have no easy way of checking whether a specific caster has finished casting the spell or not. To avoid bugs with a caster being later designated as the point for a drag/bash, I use the stopper variable to determine exactly how many unit's a caster has already run the spell through. If that number(stopper) = the count of units targeted by that caster...then his spell must be over...so I remove him from the group.
 

jomik

New Member
Reaction score
17
Hmm, I can't see the error :O But it's a kinda complex code too :S
You should start on JASS :p

How do you check that it goes back to the first trigger? :)
 

Moridin

Snow Leopard
Reaction score
144
I put numerous text messages around....and found that a text message in the first trigger was getting triggered again and again.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top