• 🏆 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] Cycle "Target point of Ability being cast" MUI [REFORGED] need help

Status
Not open for further replies.
Level 12
Joined
Feb 5, 2018
Messages
521
Ini
  • Set VariableSet HC_TargetPoint[HC_Count] = (Target point of ability being cast)
Loop
  • For each (Integer HC_LoopInteger) from 1 to HC_Count, do (Actions)
    • Loop - Actions
      • Set VariableSet HC_Caster[HC_LoopInteger] = HC_Caster[HC_LoopInteger]
      • Set VariableSet HC_CasterPoint[HC_LoopInteger] = (Position of HC_Caster[HC_LoopInteger])
      • -------- I want to cycle this correctly --------
      • -------- This trigger probably does not work --------
      • -------- Because this location does not exist --------
      • Set VariableSet HC_TargetPoint[HC_LoopInteger] = HC_TargetPoint[HC_LoopInteger]
      • -------- --- --------
      • Set VariableSet HC_Angle[HC_LoopInteger] = (Angle from HC_CasterPoint[HC_LoopInteger] to HC_TargetPoint[HC_LoopInteger])
      • Set VariableSet HC_Distance[HC_LoopInteger] = (Distance between HC_CasterPoint[HC_LoopInteger] and HC_TargetPoint[HC_LoopInteger])
      • Unit - Move HC_Caster[HC_LoopInteger] instantly to (HC_CasterPoint[HC_LoopInteger] offset by 75.00 towards HC_Angle[HC_LoopInteger] degrees.)
      • Destructible - Pick every destructible within HC_AOE of HC_CasterPoint[HC_LoopInteger] and do (Actions)
        • Loop - Actions
          • Set VariableSet HC_Destructible = (Picked destructible)
          • Unit - Order TreeHarvester[HC_Count] to HarvestHC_Destructible
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current order of TreeHarvester[HC_Count]) Equal to (Order(harvest))
            • Then - Actions
              • Destructible - Kill HC_Destructible
            • Else - Actions
              • Unit - Order TreeHarvester[HC_Count] to Stop.
      • Custom script: call RemoveLocation (udg_HC_CasterPoint[udg_HC_LoopInteger])
      • Custom script: call RemoveLocation (udg_HC_TargetPoint[udg_HC_LoopInteger])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HC_Distance[HC_LoopInteger] Less than or equal to 25.00
        • Then - Actions
          • -------- The Distance condition is not met, because there is no location --------
          • Special Effect - Create a special effect attached to the origin of HC_Caster[HC_LoopInteger] using Abilities\Spells\Human\Thunderclap\ThunderClapCaster.mdl
          • Set VariableSet HC_Spef = (Last created special effect)
          • Special Effect - Destroy HC_Spef
          • Set VariableSet HC_UG[HC_LoopInteger] = (Units within 225.00 of HC_TargetPoint[HC_LoopInteger] matching (((Matching unit) belongs to an enemy of (Owner of HC_Caster[HC_LoopInteger]).) Equal to True).)
          • Unit Group - Pick every unit in HC_UG[HC_LoopInteger] and do (Actions)
            • Loop - Actions
              • Set VariableSet HC_Target[HC_LoopInteger] = (Picked unit)
              • Unit - Cause HC_Caster[HC_LoopInteger] to damage (Picked unit), dealing 100.00 damage of attack type Spells and damage type Normal
          • Unit - Unpause HC_Caster[HC_LoopInteger]
          • Animation - Reset HC_Caster[HC_LoopInteger]'s animation
          • Animation - Change HC_Caster[HC_LoopInteger]'s animation speed to 100.00% of its original speed
          • Animation - Change HC_Caster[HC_LoopInteger] flying height to 0.00 at 0.00
          • Unit - Turn collision for HC_Caster[HC_LoopInteger] On.
          • -------- Here is where I cycle loopinteger back to normal count --------
          • Set VariableSet HC_Caster[HC_LoopInteger] = HC_Caster[HC_Count]
          • Set VariableSet HC_CasterPoint[HC_LoopInteger] = HC_CasterPoint[HC_Count]
          • Set VariableSet HC_TargetPoint[HC_LoopInteger] = HC_TargetPoint[HC_Count]
          • Set VariableSet HC_Angle[HC_LoopInteger] = HC_Angle[HC_Count]
          • Set VariableSet HC_Distance[HC_LoopInteger] = HC_Distance[HC_Count]
          • Set VariableSet HC_LoopInteger = (HC_LoopInteger - 1)
          • Set VariableSet HC_Count = (HC_Count - 1)
          • -------- Remove Leaks --------
          • Custom script: call RemoveLocation (udg_HC_TargetPoint[udg_HC_LoopInteger])
          • Custom script: call RemoveLocation (udg_HC_CasterPoint[udg_HC_LoopInteger])
          • Custom script: call DestroyGroup (udg_HC_UG[udg_HC_LoopInteger])
          • Unit - Make TreeHarvester[HC_Count] Vulnerable
          • Unit - Kill TreeHarvester[HC_Count]
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HC_Count Equal to 0
            • Then - Actions
              • Trigger - Turn off (This trigger)
            • Else - Actions

Hello again. Always the same issue with triggers like this. I've made many similar triggers like this, but usually I have used only unit position locations.

I have no idea how to cycle the target point of ability being cast from the initial trigger. Thanks for your help in advance. :)

So the location in the loop trigger leaks, and the units charging get stuck, moving back and forth in a small distance. And when you cast it again the first unit that were using the ability jumps to center of the map. And there are infinite special effects of thunderclap, because the HC_Count on the trigger never returns to 0 so the loop keeps running indefinite.
 
Level 12
Joined
Feb 5, 2018
Messages
521
It’s unclear to me what you mean by “cycle.” Save that point in a variable in the cast trigger and just keep referencing it...?
Full Ini Trigger
  • Heroic Charge
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Heroic Charge
    • Actions
      • Set VariableSet HC_Count = (HC_Count + 1)
      • Set VariableSet HC_Caster[HC_Count] = (Triggering unit)
      • -------- I want to cycle this --------
      • Set VariableSet HC_TargetPoint[HC_Count] = (Target point of ability being cast)
      • -------- -- --------
      • Set VariableSet HC_CasterPoint[HC_Count] = (Position of HC_Caster[HC_Count])
      • Set VariableSet HC_Angle[HC_Count] = (Angle from HC_CasterPoint[HC_Count] to HC_TargetPoint[HC_Count])
      • Set VariableSet HC_Distance[HC_Count] = (Distance between HC_CasterPoint[HC_Count] and HC_TargetPoint[HC_Count])
      • Set VariableSet HC_AOE = 125.00
      • Animation - Play HC_Caster[HC_Count]'s stand, ready animation
      • Animation - Change HC_Caster[HC_Count]'s animation speed to 0.00% of its original speed
      • Unit - Add Crow Form to HC_Caster[HC_Count]
      • Animation - Change HC_Caster[HC_Count] flying height to 25.00 at 0.00
      • Unit - Remove Crow Form from HC_Caster[HC_Count]
      • Unit - Pause HC_Caster[HC_Count]
      • Unit - Turn collision for HC_Caster[HC_Count] Off.
      • Unit - Create 1Peasant for Neutral Passive at HC_CasterPoint[HC_Count] facing Default building facing degrees
      • Set VariableSet TreeHarvester[HC_Count] = (Last created unit)
      • Unit - Hide TreeHarvester[HC_Count]
      • Unit - Make TreeHarvester[HC_Count] Invulnerable
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HC_Count Equal to 1
        • Then - Actions
          • Trigger - Turn on Heroic Charge Loop <gen>
        • Else - Actions
So what I mean is I want to use the location trough the loop, but for some reason it does not work like this. It cannot find the location in the Loop.
 
Level 38
Joined
Feb 27, 2007
Messages
4,951
If you keep referencing "target point of ability being cast" yes it will not work (thread explanation here). Save it in to HC_TargetPoint[...] and you can keep referencing that variable. I fail to see why this doesn't work in your trigger since it loops over HC_LoopInteger from 1 to HC_Count, which should be all instances of the spell.,
 
Level 12
Joined
Feb 5, 2018
Messages
521
Here, you can test it so maybe you will get a better view of what's wrong. :)
 

Attachments

  • TestMapCharge.w3m
    21.1 KB · Views: 19
Level 25
Joined
Sep 26, 2009
Messages
2,373
The issue is in your loop trigger's below part of code:
  • Set VariableSet HC_TargetPoint[HC_LoopInteger] = HC_TargetPoint[HC_LoopInteger]
  • ...
  • Destructible - Pick every destructible within HC_AOE of HC_CasterPoint[HC_LoopInteger] and do (Actions)
    • Loop - Actions
      • ...
  • Custom script: call RemoveLocation (udg_HC_TargetPoint[udg_HC_LoopInteger])
The following action:
  • Set VariableSet HC_TargetPoint[HC_LoopInteger] = HC_TargetPoint[HC_LoopInteger]
does not create a new location, so there is no need to remove the location after the "pick every destructible" action block.

You should, however, remove the location once the instance of the spell ends (which you do already)

What basically happens in your trigger is that you delete the target location the first time your loop executes for the given instance.
 
Level 12
Joined
Feb 5, 2018
Messages
521
The issue is in your loop trigger's below part of code:
  • Set VariableSet HC_TargetPoint[HC_LoopInteger] = HC_TargetPoint[HC_LoopInteger]
  • ...
  • Destructible - Pick every destructible within HC_AOE of HC_CasterPoint[HC_LoopInteger] and do (Actions)
    • Loop - Actions
      • ...
  • Custom script: call RemoveLocation (udg_HC_TargetPoint[udg_HC_LoopInteger])
The following action:
  • Set VariableSet HC_TargetPoint[HC_LoopInteger] = HC_TargetPoint[HC_LoopInteger]
does not create a new location, so there is no need to remove the location after the "pick every destructible" action block.

You should, however, remove the location once the instance of the spell ends (which you do already)

What basically happens in your trigger is that you delete the target location the first time your loop executes for the given instance.

Ok I removed the custom script from the code above. And increased the distance check from 25 to 50 and now it works.

Only that for some reason it wants to create the special effect three times instead of once. Other than that it runs fine now :)

Thanks for help :)
 
Status
Not open for further replies.
Top