• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!

[Trigger] How to remove this location variable

Status
Not open for further replies.
Level 8
Joined
Mar 15, 2007
Messages
230
I have a quick question. I have three triggers for this ability I'm making called Condemn. What it does is the caster channels for a few seconds before creating a unit that thunderclaps. I have one trigger with "starts the effect of an ability" where I get the location, and a second "finishes casting an ability" where the dummy unit is summoned. It works fine, but I don't know how to remove the location.
So, here are my triggers:
  • Get Condemn Point
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Condemn (Inquisitor)
    • Actions
      • Set VariableSet UDex = (Custom value of (Casting unit))
      • Set VariableSet Condemn_Point[UDex] = (Target point of ability being cast)
  • Condemn Damage
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Condemn (Inquisitor)
    • Actions
      • Set VariableSet UDex = (Custom value of (Casting unit))
      • Unit - Create 1 Condemn Dummy for (Owner of (Casting unit)) at Condemn_Point[UDex] facing Default building facing degrees
      • Unit - Set level of Condemn dummy (Inquisitor) for (Last created unit) to (Level of Condemn (Inquisitor) for (Casting unit))
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap.
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • -------- Add Units to Fire Nova Group --------
      • Unit Group - Pick every unit in (Units within 150.00 of Condemn_Point[UDex].) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an enemy of (Owner of (Casting unit)).) Equal to True
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) is hidden) Equal to False
            • Then - Actions
              • Set VariableSet UDex = (Custom value of (Picked unit))
              • Set VariableSet Condemn_Caster[UDex] = (Casting unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is in Condemn_Group.) Equal to False
                • Then - Actions
                  • Unit Group - Add (Picked unit) to Condemn_Group
                • Else - Actions
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Condemn DoT <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Condemn DoT <gen>
        • Else - Actions
 

Uncle

Warcraft Moderator
Level 66
Joined
Aug 10, 2018
Messages
6,863
Put this at the very bottom of the Condemn Damage trigger:
  • Custom script: call RemoveLocation (udg_Condemn_Point[udg_UDex])
Edit:
Actually, that might not work if your Dummy unit gets Indexed into the system since UDex would then be changed to that Dummy's custom value. Edit #2: I see now, you change UDex in your Pick every unit function as well, that's why you were wondering where you should Remove the Location.

Solution:
So instead of using UDex as your variable try using a different unique Integer.
  • Example
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set VariableSet UDexNew = (Custom value of (Triggering unit))
      • Unit Group - Pick every unit in (Units within 512.00 of Spell_Point[UDexNew].) and do (Actions)
        • Loop - Actions
          • Set VariableSet UDex = (Custom value of (Picked unit))
          • -------- Do stuff referencing UDex --------
      • Custom script: call RemoveLocation (udg_Spell_Point[udg_UDexNew])
Note that using UDex is not required and is used solely as an optimization since it's easier/more efficient than doing "Custom value of unit" over and over again. So you can use "Custom value of casting/picked/etc unit" as a safe alternative.

And apologies if I used UDex in my example triggers and made it a habit of yours. It's safe to use UDex under most circumstances. You just need to remember that the Unit Indexer system changes UDex whenever a new unit is created and Indexed into the system. In other words, after creating a unit (Like your Dummy), the UDex variable changes. So any Actions after creating the Dummy that reference UDex will be referencing the wrong value. In this case it'd be referencing the Dummy's custom value instead of your Casting Unit's custom value.
 
Last edited:
Status
Not open for further replies.
Top