• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

help with destroying location leak

Status
Not open for further replies.
Level 4
Joined
Feb 22, 2012
Messages
74
I have tried to make a pretty simple spell here. It is supposed to work a little like holy light. If you cast on an ally, it heals them and damages nearby enemies. If you cast on enemy, it damages them and heals nearby allies.

Well, I need a point variable to do the aoe effect. So I made a trigger to check if the point is actually being cleared.

It turns out the point does NOT clear if I have the caster use the spell on himself AND there are no nearby enemies. Why is that happening?

If I use the spell when there are nearby enemies, the point properly returns to 0,0.
 

Attachments

  • spell.png
    spell.png
    59.9 KB · Views: 96
  • pointcheck.png
    pointcheck.png
    29.6 KB · Views: 81
Please right click on the top of your trigger where it says your map name and hit copy as text than paste it here in code tags
 
  • Judgement
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Judgement [Paladin Q]
    • Actions
      • Set tempPoint[0] = (Position of (Target unit of ability being cast))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of ability being cast) belongs to an enemy of (Owner of (Triggering unit))) Equal to False
        • Then - Actions
          • Unit - Set life of (Target unit of ability being cast) to ((Life of (Target unit of ability being cast)) + paladinJudgementHeal)
          • Set tempGroup = (Units within paladinJudgementRadius of tempPoint[0] matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)))
          • Set tempReal[0] = (paladinJudgementDamage / (Real((Number of units in tempGroup))))
          • Unit Group - Pick every unit in tempGroup and do (Actions)
            • Loop - Actions
              • Unit - Cause (Triggering unit) to damage (Picked unit), dealing tempReal[0] damage of attack type Spells and damage type Divine
              • Unit Group - Remove (Picked unit) from tempGroup
        • Else - Actions
          • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing paladinJudgementDamage damage of attack type Spells and damage type Divine
          • Set tempGroup = (Units within paladinJudgementRadius of tempPoint[0] matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to False)))
          • Set tempReal[0] = (paladinJudgementHeal / (Real((Number of units in tempGroup))))
          • Unit Group - Pick every unit in tempGroup and do (Actions)
            • Loop - Actions
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + tempReal[0])
              • Unit Group - Remove (Picked unit) from tempGroup
      • Custom script: call RemoveLocation(udg_tempPoint[0])
      • Custom script: set udg_tempPoint[0] = null
 
wrong code tag

its
  • (or the button that looks like a gear next to the green 001100101010)
  • e/ O.o
  • 2e/ found your problem. If the number of units in the unit group is 0, it will try to divide by zero and cause a thread crash which stops remaining functions (and is why your variable isnt getting wiped)
  • [TRIGGER] Set tempReal[0] = (paladinJudgementHeal / (Real((Number of units in tempGroup))))
this to be exact.

also, why use an array if your ALWAYS using [0] except for -point ?
 
I have an array for more complex spells which may use more tempPoints.

Can you still only have 1 local variable if you use custom script actions in GUI?

Thank you I forgot about if there are 0 units.

So I can just add another if statement which can stop the branch from proceeding if the unit group is 0 units
 
I have an array for more complex spells which may use more tempPoints.

Can you still only have 1 local variable if you use custom script actions in GUI?

Thank you I forgot about if there are 0 units.

So I can just add another if statement which can stop the branch from proceeding if the unit group is 0 units

@top Your debug wouldn't return [0] than i believe.. i dont know.

@bottom Yeah.

@middle Um... what? you cant have any local variables besides things like triggering player, triggering unit, etc. What you can do is

  • Custom Script : local unit a = GetTriggerUnit()
  • Custom Script : set udg_TempUnit = a
You wouldnt need to do this if u dont use waits (btw a Point is called a Location in jass) but if u use waits you, after the wait, would do

  • Custom Script : set udg_TempUnit = a
because TempUnit might get wiped while the wait happens but the local will not so you can still use TempUnit in GUI
 
Status
Not open for further replies.
Back
Top