• 🏆 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] MUI and simultaneous cycles

Status
Not open for further replies.
Level 5
Joined
Feb 8, 2015
Messages
93
So I've created a spell that sends a line of 8 explosions down a path, dealing damage.
The explosions proc every 0.85 seconds, so a full line takes about 7 seconds to complete.

The spell works just fine, but the Hero has a "cooldown reset" ability, so it has to be MUI - and indeed, with hashtables, I can run several cycles at a time.

But there's this odd effect where after trying to run two casts at a time, the next cast will only make 1-2 explosions, and then stop completely. The next few are similarly dysfunctional, before eventually returning to normal.
It seems as if the SmoldTrail_i (which counts numbers of explosions) gets overridden by other casts somehow, but I can't seem to find out why - I feel like my hashtables are in order.

Also, there are several Point variables that aren't cleared - because when I did, the trigger refused to function. Is overwriting with a hashtable Location-handle-load okay? Or is this leaking like crazy?

(P.S. there's also a "dummy catapult does a burning oil effect" on target, but that's left disabled in my copy-paste, along with the visual effect)

  • Smoldering Trail Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Good: Smoldering Trail (Channel)
    • Actions
      • Set SmoldTrail_cast = (Triggering unit)
      • Set SmoldTrail_dist = 800.00
      • Set SmoldTrail_i = 8
      • Set SmoldTrail_jumpdist = (SmoldTrail_dist / (Real(SmoldTrail_i)))
      • -------- Calculates the angle of explosion-path --------
      • Set SmoldTrail_CastP = (Position of SmoldTrail_cast)
      • Set SmoldTrail_TargP = (Target point of ability being cast)
      • Set SmoldTrail_ang = (Angle from SmoldTrail_CastP to SmoldTrail_TargP)
      • -------- Sets the damage formula (50*x+25) where x is level of ability --------
      • Set SmoldTrail_dmg = (25.00 + (50.00 x (Real((Level of (Ability being cast) for SmoldTrail_cast)))))
      • -------- Creates a dummy (handle) --------
      • Unit - Create 1 Dummy for (Owner of SmoldTrail_cast) at SmoldTrail_CastP facing Default building facing degrees
      • Unit Group - Add (Last created unit) to SmoldTrail_ug
      • -------- Saves the angle, damage, and number of explosions to this unique dummy --------
      • Hashtable - Save SmoldTrail_i as 0 of (Key (Last created unit)) in SmoldTrail_hash
      • Hashtable - Save SmoldTrail_dmg as 1 of (Key (Last created unit)) in SmoldTrail_hash
      • Hashtable - Save SmoldTrail_ang as 2 of (Key (Last created unit)) in SmoldTrail_hash
      • Hashtable - Save Handle OfSmoldTrail_CastP as 3 of (Key (Last created unit)) in SmoldTrail_hash
      • -------- Cleans up the Locations --------
      • Custom script: call RemoveLocation(udg_SmoldTrail_TargP)

  • Smoldering Trail Loop
    • Events
      • Time - Every 0.85 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SmoldTrail_ug and do (Actions)
        • Loop - Actions
          • Set SmoldTrail_Loopu = (Picked unit)
          • -------- Loads parameters for this unit (saved in Smoldering Trail Cast) --------
          • Set SmoldTrail_i = (Load 0 of (Key (Picked unit)) from SmoldTrail_hash)
          • Set SmoldTrail_dmg = (Load 1 of (Key (Picked unit)) from SmoldTrail_hash)
          • Set SmoldTrail_ang = (Load 2 of (Key (Picked unit)) from SmoldTrail_hash)
          • Set SmoldTrail_Tempp1 = (Load 3 of (Key (Picked unit)) in SmoldTrail_hash)
          • -------- Checks remaining explosion count --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SmoldTrail_i Greater than 0
            • Then - Actions
              • -------- Duration remains... Periodic Damage (and Explosion accumulation) --------
              • Set SmoldTrail_Tempp2 = (SmoldTrail_Tempp1 offset by SmoldTrail_jumpdist towards SmoldTrail_ang degrees)
              • -------- Damages enemies around the point --------
              • Set SmoldTrail_Tempug = (Units within 150.00 of SmoldTrail_Tempp2 matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is dead) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of SmoldTrail_Loopu)) Equal to True) and ((((Matching un
              • Set SmoldTrail_AlreadyDamaged = (Load 4 of (Key (Picked unit)) in SmoldTrail_hash)
              • Unit Group - Pick every unit in SmoldTrail_Tempug and do (Actions)
                • Loop - Actions
                  • Set SmoldTrail_Picked = (Picked unit)
                  • Unit - Cause SmoldTrail_Loopu to damage SmoldTrail_Picked, dealing SmoldTrail_dmg damage of attack type Spells and damage type Normal
                  • Unit Group - Add SmoldTrail_Picked to SmoldTrail_AlreadyDamaged
                  • Hashtable - Save Handle OfSmoldTrail_AlreadyDamaged as 4 of (Key (Picked unit)) in SmoldTrail_hash
              • -------- Cleans up the tempgroup --------
              • Custom script: call DestroyGroup(udg_SmoldTrail_Tempug)
              • -------- Creates a dummy explosion effect --------
              • Unit - Create 1 Dummy Effect: Neutral Building Explosion for Neutral Passive at SmoldTrail_Tempp2 facing Default building facing degrees
              • Unit - Add a 0.98 second Generic expiration timer to (Last created unit)
              • -------- Creates a dummy to apply the Burning Oil effect --------
              • Unit - Create 1 Smoldering Trail Burning Oil Dummy for (Owner of SmoldTrail_Loopu) at SmoldTrail_Tempp2 facing Default building facing degrees
              • Set SmoldTrail_Tempu = (Last created unit)
              • Unit - Order SmoldTrail_Tempu to Attack Ground SmoldTrail_Tempp2
              • Unit - Add a 1.00 second Generic expiration timer to SmoldTrail_Tempu
              • -------- Resaves Variables (number of explosions left, and point of last explosion have changed) --------
              • Hashtable - Save (SmoldTrail_i - 1) as 0 of (Key (Picked unit)) in SmoldTrail_hash
              • Hashtable - Save Handle OfSmoldTrail_Tempp2 as 3 of (Key (Picked unit)) in SmoldTrail_hash
            • Else - Actions
              • -------- Cleans hashtable, removes unit from group --------
              • Unit Group - Remove SmoldTrail_Loopu from SmoldTrail_ug
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in SmoldTrail_hash
              • Custom script: call RemoveLocation(udg_SmoldTrail_Tempp1)
              • Custom script: call RemoveLocation(udg_SmoldTrail_Tempp2)
              • Set SmoldTrail_AlreadyDamaged = (Load 4 of (Key (Picked unit)) in SmoldTrail_hash)
              • Custom script: call DestroyGroup(udg_SmoldTrail_AlreadyDamaged)
              • -------- Removes the dummy unit completely --------
              • Unit - Remove SmoldTrail_Loopu from the game
          • -------- Removes the previous point variable --------
          • Custom script: call RemoveLocation(udg_SmoldTrail_Tempp1)
 
Level 5
Joined
Feb 8, 2015
Messages
93
Indexing might be easier!
Highly recommend this tutorial.

Also reading through your loop trigger I couldn't help but notice the filtering!
Read into this - Very helpful for unit grouping
I'm going to sound quite offensive when I say this, but I truly don't mean any offense.

I still don't see what's the issue with my trigger? I'm not saying there is a smarter, prettier way to do it. But in any case I would like to understand just why it doesn't work - and why it malfunctions in such a peculiar fashion. Namely that it works perfectly... most of the time.

Any way, I'll try redesigning it with the indexing. Thanks.
 
Last edited:
Level 5
Joined
Feb 8, 2015
Messages
93
Double post for bumb.


I redesigned the trigger(s) to use indexing... And while it (/the code) looks prettier, it still has similar malfunctions.
I think the issue might stem from the *same* caster, "running multiple cycles" simultaneously.

What happens now is; if I try to run multiple ability cycles at the same time, one of them will sort of "wiff" and stop working, and somehow it's stacks are added to the first cycle.
So it goes like this. Cast ability 2 times in quick succesion.
Second cast does 4/8 explosions
First cast goes to 8+4=12 explosions


Here are the revised triggers...
  • Smoldering Trail Cast01
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Good: Smoldering Trail (Channel)
    • Actions
      • Set SmoldTrail_index = (SmoldTrail_index + 1)
      • Set SmoldTrail_cast[SmoldTrail_index] = (Triggering unit)
      • -------- Calculates damage (per explosion) --------
      • Set SmoldTrail_dmg[SmoldTrail_index] = (25.00 + (50.00 x (Real((Level of (Ability being cast) for SmoldTrail_cast[SmoldTrail_index])))))
      • -------- Target point, caster location, and angle --------
      • Set SmoldTrail_CastP = (Position of SmoldTrail_cast[SmoldTrail_index])
      • Set SmoldTrail_TargP = (Target point of ability being cast)
      • Set SmoldTrail_ang[SmoldTrail_index] = (Angle from SmoldTrail_CastP to SmoldTrail_TargP)
      • -------- Number of explosions (starts at 0, goes to 8) --------
      • Set SmoldTrail_ExploCount[SmoldTrail_index] = 0
      • -------- Jump Distance (Always the same) --------
      • Set SmoldTrail_dist = 800.00
      • Set SmoldTrail_jumpdist = (SmoldTrail_dist / 8.00)
      • -------- Point for first explosion --------
      • Set SmoldTrail_CurrentLoc[SmoldTrail_index] = (SmoldTrail_CastP offset by SmoldTrail_jumpdist towards SmoldTrail_ang[SmoldTrail_index] degrees)
      • -------- Cleans up the casterloc/targetloc variables --------
      • Custom script: call RemoveLocation(udg_SmoldTrail_CastP)
      • Custom script: call RemoveLocation(udg_SmoldTrail_TargP)
      • -------- Loop trigger on/off --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SmoldTrail_index Greater than 0
        • Then - Actions
          • Trigger - Turn on Smoldering Trail Loop01 <gen>
        • Else - Actions

  • Smoldering Trail Loop01
    • Events
      • Time - Every 0.85 seconds of game time
    • Conditions
    • Actions
      • For each (Integer SmoldTrail_loopinteger) from 1 to SmoldTrail_index, do (Actions)
        • Loop - Actions
          • Set SmoldTrail_Tempug = (Units within 150.00 of SmoldTrail_CurrentLoc[SmoldTrail_loopinteger])
          • Unit Group - Pick every unit in SmoldTrail_Tempug and do (Actions)
            • Loop - Actions
              • Set SmoldTrail_Picked = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (SmoldTrail_Picked is A structure) Equal to False
                  • (SmoldTrail_Picked is Magic Immune) Equal to False
                  • (SmoldTrail_Picked is being transported) Equal to False
                  • (SmoldTrail_Picked is dead) Equal to False
                  • (SmoldTrail_Picked is paused) Equal to False
                  • (SmoldTrail_Picked is in SmoldTrail_AlreadyDamaged[SmoldTrail_loopinteger]) Equal to False
                  • (SmoldTrail_Picked belongs to an ally of (Owner of SmoldTrail_cast[SmoldTrail_loopinteger])) Equal to False
                • Then - Actions
                  • Unit - Cause SmoldTrail_cast[SmoldTrail_loopinteger] to damage SmoldTrail_Picked, dealing SmoldTrail_dmg[SmoldTrail_loopinteger] damage of attack type Spells and damage type Normal
                  • Unit Group - Add SmoldTrail_Picked to SmoldTrail_AlreadyDamaged[SmoldTrail_loopinteger]
                • Else - Actions
          • Custom script: call DestroyGroup(udg_SmoldTrail_Tempug)
          • Set SmoldTrail_CurrentLoc[SmoldTrail_loopinteger] = (SmoldTrail_CurrentLoc[SmoldTrail_loopinteger] offset by SmoldTrail_jumpdist towards SmoldTrail_ang[SmoldTrail_loopinteger] degrees)
          • -------- Creates a dummy explosion effect --------
          • Unit - Create 1 Dummy Effect: Neutral Building Explosion for Neutral Passive at SmoldTrail_CurrentLoc[SmoldTrail_loopinteger] facing Default building facing degrees
          • Unit - Add a 0.98 second Generic expiration timer to (Last created unit)
          • -------- Creates a dummy to apply the Burning Oil effect --------
          • Unit - Create 1 Smoldering Trail Burning Oil Dummy for (Owner of SmoldTrail_cast[SmoldTrail_loopinteger]) at SmoldTrail_CurrentLoc[SmoldTrail_loopinteger] facing Default building facing degrees
          • Set SmoldTrail_Tempu = (Last created unit)
          • Unit - Order SmoldTrail_Tempu to Attack Ground SmoldTrail_CurrentLoc[SmoldTrail_loopinteger]
          • Unit - Add a 1.00 second Generic expiration timer to SmoldTrail_Tempu
          • -------- Saves number of explosions (so far) --------
          • Set SmoldTrail_ExploCount[SmoldTrail_loopinteger] = (SmoldTrail_ExploCount[SmoldTrail_loopinteger] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SmoldTrail_ExploCount[SmoldTrail_loopinteger] Greater than or equal to 8
            • Then - Actions
              • Custom script: call DestroyGroup(udg_SmoldTrail_AlreadyDamaged[udg_SmoldTrail_loopinteger])
              • Set SmoldTrail_cast[SmoldTrail_loopinteger] = SmoldTrail_cast[SmoldTrail_index]
              • Set SmoldTrail_ExploCount[SmoldTrail_loopinteger] = SmoldTrail_ExploCount[SmoldTrail_index]
              • Set SmoldTrail_index = (SmoldTrail_index - 1)
              • Set SmoldTrail_loopinteger = (SmoldTrail_loopinteger - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SmoldTrail_index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
 
Level 24
Joined
Feb 9, 2009
Messages
1,787
Not offensive at all, your fine!
I'd have an easier time if there was a test map, as I'm massively out of practice with hashtables.
I've been trying recreate this trigger with Bribe's unit indexer, but running into issues replicating your unit group filtering since I can't see the rest.

Please Read into this - This not only speeds up the unit group it makes it easier to tweak, easier on the eyes of those looking at your trigger.

Edit: lol I was testing the map, I didn't see your other reply
 

Attachments

  • Smouldering Trail.w3x
    48.3 KB · Views: 25
Level 5
Joined
Feb 8, 2015
Messages
93
Here's a test map I made with the trigger/ability copied from my other map.

Can't for the life of me figure out what's wrong...

Edit: I also know of Bribe's unit indexer, and it's great.
But to be honest, I wanted to try making everything from scratch, so to say.
 

Attachments

  • SmoldTraiLTest.w3x
    16.9 KB · Views: 26
Level 24
Joined
Feb 9, 2009
Messages
1,787
Aha!
You need to bring the other variables into the fold of the index!
You only have the caster and the explosion count in the end of the loop, you still need "Dmg" / "Ang" & "Current Loc"!

Also why not use special effects instead of dummy unit effects?

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • SmoldTrail_ExploCount[SmoldTrail_loopinteger] Equal to 8
    • Then - Actions
      • Custom script: call DestroyGroup(udg_SmoldTrail_AlreadyDamaged[udg_SmoldTrail_loopinteger])
      • Set SmoldTrail_CurrentLoc[SmoldTrail_loopinteger] = SmoldTrail_CurrentLoc[SmoldTrail_index]
      • Set SmoldTrail_ang[SmoldTrail_loopinteger] = SmoldTrail_ang[SmoldTrail_index]
      • Set SmoldTrail_dmg[SmoldTrail_loopinteger] = SmoldTrail_dmg[SmoldTrail_index]
      • Set SmoldTrail_cast[SmoldTrail_loopinteger] = SmoldTrail_cast[SmoldTrail_index]
      • Set SmoldTrail_ExploCount[SmoldTrail_loopinteger] = SmoldTrail_ExploCount[SmoldTrail_index]
      • Set SmoldTrail_loopinteger = (SmoldTrail_loopinteger - 1)
      • Set SmoldTrail_index = (SmoldTrail_index - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SmoldTrail_index Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
    • Else - Actions
 
Level 5
Joined
Feb 8, 2015
Messages
93
Aha!
You need to bring the other variables into the fold of the index!
You only have the caster and the explosion count in the end of the loop, you still need "Dmg" / "Ang" & "Current Loc"!
Ahhh thank you! Thank you, thank you!

Also why not use special effects instead of dummy unit effects?
I heard some time it was actually more efficient to use dummy units (?).

Also, I've had experiences where running loop triggers (i.e. for every A from x to y, do... Special Effect...Remove last created special effect) simply didn't show any special effects at all. With dummy units and expiration timers, they always show up.
 
Level 24
Joined
Feb 9, 2009
Messages
1,787
#1
Glad to hear, sorry I was useless for the original inquiry.


#2 - Special effects
I've never had that issue with loops personally, but both work equally well, the decision is what you want to achieve:
- special effects = efficiency
- dummy effects = modification (although this is debatable as new update allows for all kinds of special effect modification.)
 
Status
Not open for further replies.
Top