• 🏆 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 giving me headaches for the last few months, if not year

Status
Not open for further replies.
Level 18
Joined
May 11, 2012
Messages
2,103
Incredibly simple, and good looking spell that just refuses to obey.

The looping part just stops when it reaches an enemy unit, meaning that if there is an enemy unit 600 units away from my hero, and I cast this spell, the loop will only run first 2 times (2*300=600, duhh). And there it stops, all the loops won't execute.

Problem? My eyes don't see any.

This sometimes works properly, and sometimes not.

Dummy unit has cast point and backswing 0.010, and the dummy is properly configured, too.

  • Mega Blast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mega Blast
    • Actions
      • -------- ================================================ --------
      • Set TempTrigUnit = (Triggering unit)
      • Set TempPoint = (Position of TempTrigUnit)
      • Set TempPoint2 = (Target point of ability being cast)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Mega Blast for TempTrigUnit) Equal to 1
        • Then - Actions
          • Set TempReal = 2.00
        • Else - Actions
          • Set TempReal = 1.00
      • -------- ================================================ --------
      • For each (Integer TempInt) from 1 to 8, do (Actions)
        • Loop - Actions
          • -------- ================================================ --------
          • Set TempPoint3 = (TempPoint offset by (300.00 x (Real(TempInt))) towards (Angle from TempPoint to TempPoint2) degrees)
          • Set TempUnitGroup = (Units within 300.00 of TempPoint3 matching ((((Matching unit) is A structure) Not equal to True) and ((((Matching unit) is Magic Immune) Not equal to True) and ((((Matching unit) is dead) Not equal to True) and (((Matching unit) belongs to an enemy of (Trigg
          • -------- ================================================ --------
          • Unit - Create 1 Dummy Mega Blast for (Triggering player) at TempPoint3 facing Default building facing degrees
          • Set TempDummyUnit = (Last created unit)
          • -------- ================================================ --------
          • Unit - Add a 0.25 second Generic expiration timer to TempDummyUnit
          • Unit - Add Dummy Mega Blast to TempDummyUnit
          • Unit - Set level of Dummy Mega Blast for TempDummyUnit to (Level of Mega Blast for TempTrigUnit)
          • Unit - Order TempDummyUnit to Orc Tauren Chieftain - War Stomp
          • -------- ================================================ --------
          • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
            • Loop - Actions
              • -------- ================================================ --------
              • Unit - Cause TempTrigUnit to damage (Picked unit), dealing ((Real((Agility of TempTrigUnit (Include bonuses)))) / TempReal) damage of attack type Spells and damage type Normal
              • -------- ================================================ --------
          • -------- ================================================ --------
          • Special Effect - Create a special effect at TempPoint3 using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
          • Special Effect - Destroy (Last created special effect)
          • -------- ================================================ --------
          • Custom script: call RemoveLocation(udg_TempPoint3)
          • Custom script: call DestroyGroup(udg_TempUnitGroup)
          • -------- ================================================ --------
      • -------- ================================================ --------
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Custom script: call RemoveLocation(udg_TempPoint2)
      • Custom script: set udg_TempTrigUnit = null
      • Custom script: set udg_TempPoint = null
      • Custom script: set udg_TempPoint2 = null
      • Custom script: set udg_TempPoint3 = null
      • Custom script: set udg_TempUnitGroup = null
      • -------- ================================================ --------
 
Level 18
Joined
May 11, 2012
Messages
2,103
Already done that. What am I supposed to notice? That those remaining loops are created in the center of the map?

Why don't you just reset the variable of the loop? TempInt to 0 every time this spell is cast. Just place it before the loop starts.

Does the variable not gets put to 1 automaticly when used in a loop?
 
I have no clue what's causing this bug, but for efficiency, you could store all the constant information before the loop. You could also forego the third global location variable and instead use the first one offset towards the constant angle.

For troubleshooting, you can choose to temporarily add a model to the dummies, along with backswing and cast point.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Dummy unit has cast point and backswing 0.010, and the dummy is properly configured, too.

Dummy units are supposed to have a cast point and backswing of 0 (does not answer why your loop stops all together).

You are 100% sure that the loop immediately stops when it reaches a unit? As in, you no longer see "debug messages" displaying the current loop int?
 
Level 18
Joined
May 11, 2012
Messages
2,103
Dummy units are supposed to have a cast point and backswing of 0 (does not answer why your loop stops all together).

You are 100% sure that the loop immediately stops when it reaches a unit? As in, you no longer see "debug messages" displaying the current loop int?

The dummy had value of 0 already, and for the sake of testing, I put it to 0.010, but it was of no difference.

100%? I am 1500% sure!
It goes: 1,2,3,4 and stops on 4th loop (for example).
As I said, this sometimes works ok, but sometimes as I described above.

Okey. I think you can try this. Place remove location and destroy group in the loop outside. Before the loop ends, clean the group by removing all units (Pick every unit and remove from group).
That will leave me will leaks, m8.
 
Level 18
Joined
May 11, 2012
Messages
2,103
That is so weird, I don't see anything that would stop the loop from the trigger you posted us. My only guess is that there are some conflicting variables that are being used in other triggers that could possibly be going off somewhere in the middle of the loop.

I suspect that collision, too. But I have way too many triggers to delete 1by1 and see wheres is the collision.

I even copied this trigger from another similar one that works fine regardless, and only modified it to do what this one do and it still malunctions in this form.
Maybe somebody can rewrite this crap in vJass as I don't know much about it and don't have time to bother to learn.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Try copying the spell to another clean map, test the spell, and tell us if it works or still bugs out.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
There you go, nothing wrong with your spell. Try what grandmaster Wietlol suggested bro. Good Luck.

EDIT: You could also try using dedicated temporary variables, that might narrow the search for the actual problem, next step would then be (probably) Weitlol's suggestion.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
The problem is most likely to be a data collision.
One of the triggers that runs on a damage event is messing with you variables.

Shadowing variables is ussually quite nice, but as you are using a ForGroupBJ(), you are using a separate function for their actions and filters.
So, you should actually be using different variables to avoid the bugs.
 
Level 18
Joined
May 11, 2012
Messages
2,103
The problem is most likely to be a data collision.
One of the triggers that runs on a damage event is messing with you variables.

Shadowing variables is ussually quite nice, but as you are using a ForGroupBJ(), you are using a separate function for their actions and filters.
So, you should actually be using different variables to avoid the bugs.

So be it. Will report back tommorow how it worked.
 
Level 18
Joined
May 11, 2012
Messages
2,103
Sorry for interrupting the discussion but where exactly did you set "TempInt"? (the value you use for the loop)

TempInt is auto set to starting number in a loop, so no need for setting is before it.

I thought about this too. Based on that trigger itself is fine. But when Weitlol pointed out that other triggers affecting the trigger. He should just set TempInt to 0 like I suggested.

It was indeed variable collision. I am using so many triggers with Temporary variables, guess warcraft isn't that efficient. So I decided to create dedicated vars for each trigger. And from now on, it all works fine.
 
Status
Not open for further replies.
Top