• 🏆 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!

Leak from call SetUnitFlyHeight()?

Status
Not open for further replies.
Level 14
Joined
Aug 30, 2004
Messages
909
Apologies for cluttering the forums, but these are separate questions, and I'd like to be sure to get answers to each of them.

I am hunting for a leak in my map. I decided to reread the tutorial here at Hive and saw this which I had previously not paid attention to:

"When using local handle variables in JASS, they cause a small leak. A handle is everything except real, string, integer, and boolean. If I'm not mistaken, this only occurs if the handle is ever destroyed or removed from the game. This means that if you are certain a handle will never cease to exist, it's safe not to null the variable. Althought players are handles, they should never need to be nulled."

  • local unit u = GetTriggerUnit()
  • call SetUnitFacing(u, 270)
  • call SetUnitFlyHeight(u, 300, 50)
  • set u = null
I began using the SetUnitFlyHeight in one of my triggers to essentially attach one unit to another (i.e. move it to that unit's location and set it to it's height). The section of my trigger is here:

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Unit-type of u) Equal to Blastboat
    • Then - Actions
      • Custom script: call SetUnitX (udg_blastBoatTurret[udg_cv], udg_x)
      • Custom script: call SetUnitY (udg_blastBoatTurret[udg_cv], udg_y)
      • Custom script: call SetUnitFlyHeight(udg_blastBoatTurret[udg_cv], GetUnitFlyHeight(udg_u) + 30, 0)
      • Unit - Make blastBoatTurret[cv] face (FlierFacing[cv] + ((Real(blastBoatTurretFacing[cv])) x 90.00)) over 0.00 seconds
    • Else - Actions
Since I'm using nothing but real variables here, I never include anything like "set u = null." Do I need to do that here when I am done with u and with blastBoatTurret?

EDIT: Also, the tutorial seems to think this only applies to custom script (JASS). If I use the native command:

  • Animation - Change blastBoatTurret[cv] flying height to ((Current flying height of u) + 30.00) at 0.00
will that solve it?

Again, apologies for all the posts.
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Since I'm using nothing but real variables here, I never include anything like "set u = null." Do I need to do that here when I am done with u and with blastBoatTurret?
Your "u" is a global variable, so there is no need to null it. You only need to null them if they are local variables since they can fall out of scope. My only concern now is how are you getting the X and Y values of the point you are moving the unit to? Do you use GetLocationX() and GetLocationY()? Do post the whole code if you can.

In your first example where u is a local, you properly null the variable, so it will not cause any leaks.
 
Level 14
Joined
Aug 30, 2004
Messages
909
Nothing would make me happier than posting the triggers here and having you guys find a leak, but we're talking about hundreds of triggers in total. The one I linked got the x,y coordinates from:

  • Custom script: set udg_x = GetUnitX(udg_u)
  • Custom script: set udg_y = GetUnitY(udg_u)
  • Custom script: call MoveLocation(udg_LocationMove1, udg_x, udg_y)
Just because you asked, here is the full trigger (it's called from another trigger that picks every unit in my flying units and sets u=picked unit, and cv=custom value of u).

I'm concerned because I'm very good (I think) at removing location leaks and unit group leaks. I learned player group leaks as well. But my map crashed in a multi-player session recently, and I noticed that there's often a few seconds of black screen when I exit the map after playing. I assume these are caused by leaks, but I've combed the triggers and can't find anything.


  • subGT Flight Ships Players
    • Events
    • Conditions
    • Actions
      • Unit - Order u to Stop
      • -------- ------ --------
      • -------- set piloting skill --------
      • -------- ------ --------
      • Set tempPilotSkill = (Agility of Hero[cv] (Include bonuses))
      • -------- ------ --------
      • -------- MOVE --------
      • -------- ------ --------
      • Set tempSpeed = (FlierSpeed[cv] - (HazardSpeed[cv] / 20.00))
      • Set tempTurn = (FlierTurn[cv] / 0.70)
      • -------- ------ --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (u has buff Ion Booster) Equal to True
        • Then - Actions
          • Set tempSpeed = (tempSpeed + 10.00)
          • Set tempTurn = (tempTurn - 2.00)
        • Else - Actions
      • -------- ------------ --------
      • If (tempSpeed Less than 0.00) then do (Set tempSpeed = 0.00) else do (Do nothing)
      • Custom script: set udg_x = GetUnitX(udg_u)
      • Custom script: set udg_y = GetUnitY(udg_u)
      • Custom script: call MoveLocation(udg_LocationMove1, udg_x, udg_y)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FlierOverrideDuration[cv] Greater than 0.00
        • Then - Actions
          • Set FlierOverrideDuration[cv] = (FlierOverrideDuration[cv] - 0.03)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • FlierYoYo[cv] Equal to True
            • Then - Actions
              • -------- YOYOing --------
              • Set FlierOverrideDirection[cv] = ((Facing of u) + 0.00)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • FlierForceTurnSize[cv] Greater than or equal to 345.00
                • Then - Actions
                  • -------- early --------
                  • Set tempSpeed = (tempSpeed / 1.60)
                  • Set tempTurn = (tempTurn + 0.20)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • FlierForceTurnSize[cv] Less than or equal to 90.00
                    • Then - Actions
                      • -------- tail end --------
                      • Set tempTurn = (tempTurn + 1.00)
                      • Set tempSpeed = (tempSpeed x 1.20)
                    • Else - Actions
                      • -------- mid --------
                      • Set tempSpeed = (tempSpeed / 1.20)
            • Else - Actions
          • Set movementDirection = FlierOverrideDirection[cv]
        • Else - Actions
          • Set movementDirection = FlierFacing[cv]
      • Set x = (x + ((Cos(movementDirection)) x tempSpeed))
      • Set y = (y + ((Sin(movementDirection)) x tempSpeed))
      • Custom script: call MoveLocation(udg_LocationMove2, udg_x, udg_y)
      • -------- --------------- --------
      • -------- check for damage --------
      • -------- --------------- --------
      • Custom script: set udg_height = GetLocationZ(udg_LocationMove1)
      • Custom script: set udg_height2 = GetLocationZ(udg_LocationMove2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Terrain pathing at LocationMove2 of type Amphibious Pathing is off) Equal to True
          • (height + 10.00) Less than height2
        • Then - Actions
          • Unit - Set life of u to ((Percentage life of u) - 10.00)%
          • Special Effect - Create a special effect attached to the origin of u using Abilities\Weapons\AncientProtectorMissile\AncientProtectorMissile.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
      • -------- --------------- --------
      • Custom script: call SetUnitX (udg_u, udg_x)
      • Custom script: call SetUnitY (udg_u, udg_y)
      • -------- ----- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of u) Equal to Blastboat
        • Then - Actions
          • Custom script: call SetUnitX (udg_blastBoatTurret[udg_cv], udg_x)
          • Custom script: call SetUnitY (udg_blastBoatTurret[udg_cv], udg_y)
          • Animation - Change blastBoatTurret[cv] flying height to ((Current flying height of u) + 30.00) at 0.00
          • Unit - Make blastBoatTurret[cv] face (FlierFacing[cv] + ((Real(blastBoatTurretFacing[cv])) x 90.00)) over 0.00 seconds
        • Else - Actions
      • -------- ----- --------
      • -------- TURNS --------
      • -------- ----- --------
      • -------- increase turnspeed if barrel rolling --------
      • -------- ----- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (u has buff Barrel Roll) Equal to True
        • Then - Actions
          • Set tempTurn = (tempTurn + ((Real(tempPilotSkill)) / 5.00))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (u has buff Drain Mana (Target)) Equal to True
        • Then - Actions
          • Set tempTurn = (tempTurn - 1.50)
        • Else - Actions
      • -------- reduce turn number if HAZARD --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FlierForceTurnDirection[cv] Not equal to 0
        • Then - Actions
          • -------- force turn --------
          • -------- Set turn to .5 as minimum --------
          • If (tempTurn Less than 0.00) then do (Set tempTurn = 0.50) else do (Do nothing)
          • Trigger - Run subGT Force Turn <gen> (checking conditions)
        • Else - Actions
          • -------- reduce turn number if HAZARD --------
          • If (HazardTurn[cv] Greater than 0.00) then do (Set tempTurn = (tempTurn - (HazardTurn[cv] / 40.00))) else do (Do nothing)
          • -------- Set turn to 0 as minimum --------
          • If (tempTurn Less than 0.00) then do (Set tempTurn = 0.00) else do (Do nothing)
          • -------- ----- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • turn[cv] Equal to False
                  • FlierSpeed[cv] Less than or equal to 0.00
            • Then - Actions
              • -------- flying forward --------
            • Else - Actions
              • Trigger - Run subGT TURN <gen> (ignoring conditions)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • dtFiring Equal to False
        • Then - Actions
          • Skip remaining actions
        • Else - Actions
      • -------- ----- --------
      • -------- TURRET AUTOFIRE --------
      • -------- ----- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Remaining time for turretTimer[cv]) Greater than or equal to 0.85
          • (AiTargets[cv] is alive) Equal to True
          • HazardLasers[cv] Less than or equal to 1.00
        • Then - Actions
          • -------- location2 already unit --------
          • Set tempUnit = u
          • Set tempInteger = cv
          • Set tempPoint = (Position of AiTargets[cv])
          • Set autofire = True
          • Set laserFromTurret = True
          • Trigger - Run subTurn Turret Fired <gen> (checking conditions)
          • Set autofire = False
          • Set laserFromTurret = False
        • Else - Actions
      • -------- ----- --------
      • -------- STRAFING --------
      • -------- ----- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HazardLasers[cv] Less than or equal to 1.00
          • FlierStrafing[cv] Greater than 0
        • Then - Actions
          • Set FlierStrafing[cv] = (FlierStrafing[cv] - 1)
          • Set autofire = True
          • -------- location2 already unit --------
          • Set CreationPlayerOwner = (Owner of u)
          • Set CreationUnitOwner = u
          • Set CreationEnemy = AiTargets[cv]
          • Custom script: set udg_x = GetUnitX(udg_u)
          • Custom script: set udg_y = GetUnitY(udg_u)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of u) Equal to Blastboat
            • Then - Actions
              • Set CreationAngle = ((Facing of u) + (90.00 x (Real(blastBoatTurretFacing[cv]))))
              • Set slipMath = 0.00
              • Set CreateX = x
              • Set CreateY = y
              • Set CreationShipType = Laser Green
            • Else - Actions
              • Set CreationAngle = (Facing of u)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Unit-type of u) Equal to Bwing Bomber
                      • (Unit-type of u) Equal to Stock YT-1300
                • Then - Actions
                  • Set slipMath = 0.00
                  • Set CreateX = x
                  • Set CreateY = y
                  • Set CreationShipType = Laser Red
                • Else - Actions
                  • Set slipMath = (CreationAngle + (FlierGunAngle[cv] x (Sign(FlierGunDistance[cv]))))
                  • Set CreationAngle = (CreationAngle + (((Real(FlierStrafing[cv])) x 2.00) - 8.00))
                  • Set CreateX = (x + ((Cos(slipMath)) x (Abs(FlierGunDistance[cv]))))
                  • Set CreateY = (y + ((Sin(slipMath)) x (Abs(FlierGunDistance[cv]))))
                  • Set CreationShipType = Laser Green
          • Set tempInteger = cv
          • Trigger - Run Create Laser <gen> (ignoring conditions)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of u) Equal to Bwing Bomber
            • Then - Actions
              • Set laserHeight[CreationOpenSpot] = (480.00 + height2)
              • Animation - Change Fliers[CreationOpenSpot] flying height to laserHeight[CreationOpenSpot] at 999.00
              • Set LaserStrengthMax[CreationOpenSpot] = 5
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of u) Equal to Blastboat
                • Then - Actions
                  • Set laserHeight[CreationOpenSpot] = (400.00 + height2)
                  • Animation - Change Fliers[CreationOpenSpot] flying height to laserHeight[CreationOpenSpot] at 999.00
                  • Set LaserStrengthMax[CreationOpenSpot] = 5
                • Else - Actions
          • Set FlierGunDistance[cv] = (FlierGunDistance[cv] x -1.00)
          • Set autofire = False
        • Else - Actions
 
Level 14
Joined
Aug 30, 2004
Messages
909
MoveLocation 1/2 are given? Are they properly removed later before you re-assign them?
TempPoint also has no RemoveLocation action within this code scope.

What makes me a bit sceptical is the 'Skip remaining actions'.
Do you ensure all locations are removed, even you skip all actions in this trigger call?

You do have an eye for this stuff!

Sadly, I do remove tempPoint in the subTurnTurretFire trigger.

I don't ever assign MoveLocation 1 or 2 or remove them. I use them like a tempPoint that is always moved with this custom script command:

  • Custom script: call MoveLocation(udg_LocationMove2, udg_x, udg_y)
I was told as long as I move the location rather than assign it, that it won't leak. Is this correct?

Also, I tried to find Leak Check online and the version I downloaded doesn't seem to work on my computer. I'd love to get a program that scans triggers and points out these possibilities (rather like you did). Does such a program exist?

Finally, I read on one of the tutorials that all units that are created leak a tiny bit. I'm generating easily about 20 units a second when several players are firing lasers. The FPS goes to about 20-30 at times, but it always seems to work. On a longer game I could well have created over 10,000 units and had them die. Could this leak grow large enough to crash the game?


EDIT: if you wouldn't mind, I was told this doesn't leak as well. Is that true:

  • Custom script: call GroupEnumUnitsInRange(udg_tempDamageUnits3, udg_x, udg_y, 300, null)
 
There is this software by Ralle, and I think also some leak checker/finder our data base.
http://www.hiveworkshop.com/forums/apps.php?p=leaktester

(can't guerantee for them)

If locations are not created, it should not leak usually.
Creating 10k units and alike are pretty heavy operations, and a huge memory traffic inside the game probably also can lead to some loading time. Not just "bad coding".

I do remove tempPoint in the subTurnTurretFire trigger.
Ah, ok then.
Just tip for next time. It's usually a bit better for structure and readability if creation/destruction for these temp stuff is done within the same trigger scope.

I don't ever assign MoveLocation 1 or 2 or remove them.
Though, I'm a bit curious. Do you really never assign these locations, or only once at init?

I was told as long as I move the location rather than assign it, that it won't leak. Is this correct?
Yeah, moving locations is totaly, okay.

On a longer game I could well have created over 10,000 units and had them die. Could this leak grow large enough to crash the game?
Usually the map will first get unplayable. Totaly. But a direct crash should not happen just from leaks. The first step is for sure just the inability to play the map because of leaks.

GroupEnumUnitsInRange does not leak per se, that's true.
However, it fills up an already existing unit group, which should not be forgetten to get destroyed.
But the function itself doesn't leak, no.
 
Last edited:
Level 14
Joined
Aug 30, 2004
Messages
909
GroupEnumUnitsInRange does not leak per se, that's true.
However, it fills up an already existing unit group, which should not be forgetten to get destroyed.
But the function itself doesn't leak, no.

Thanks for the software, I'll give that a shot after my next play test! Also the tip about coding; I completely agree. I've learned so much making this map. My next one will be much more coding friendly!

To answer your question; I did initialize the Location points at Map Initialize.

Regarding your quote above; I use this line:

  • Custom script: call GroupEnumUnitsInRange(udg_tempDamageUnits3, udg_x, udg_y, 300, null)
And then I pick every unit in tempDamageUnits3 and run some calculations. I've posted the full trigger below if you would like to take a look. I never Destroy that group though! Should I?


More questions as long as you're willing:

1. I left in a space in one trigger. Will this still work or will it leak?:

  • Custom script: call DestroyGroup( udg_blastboatPotentialTargets)
note the space between "(" and "udg_blastboat...)"

2. Would this leak because I'm referring to a unit group that doesn't exist?

  • Custom script: call DestroyGroup(udg_blastboatPotentialTargets)
  • Set AiTargets[CreationOpenSpot] = (Random unit from blastboatPotentialTargets)
3. You inadvertently punched me in the soul when you said that leaks won't cause a crash until the game becomes unplayable! I played with 4 friends the other day and we were all fine until the game crashed us all instantly. When I was hunting for the bug I noticed the black screen upon quitting the game and assumed that meant I was leaking a bit (the black screen was about 2-4 seconds at worst). I just assumed that those leaks caused the crash. If not, I don't know what to look for! That's another problem though I guess. I'd at least like to get the game leakless for release, and if a crash bug pops up from time to time maybe I can get some more information from the playtesters here.

Thanks again so much! This has got me frazzled and I'm always so grateful for the good people here at the Hive.


The trigger that uses tempDamageUnit3:

  • subDT Missile Damage
    • Events
    • Conditions
    • Actions
      • Set tempInteger = (Custom value of tempLaser)
      • -------- -------- --------
      • Custom script: set udg_x = GetUnitX(udg_tempLaser)
      • Custom script: set udg_y = GetUnitY(udg_tempLaser)
      • Custom script: set udg_x2 = GetUnitX(udg_AiTargets[udg_tempInteger])
      • Custom script: set udg_y2 = GetUnitY(udg_AiTargets[udg_tempInteger])
      • -------- -------- --------
      • -------- MISSILE SPEED ADJUST --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • turn[tempInteger] Equal to True
        • Then - Actions
          • Set FlierSpeed[tempInteger] = (FlierSpeed[tempInteger] - ((5.00 - FlierTurn[tempInteger]) / 4.00))
        • Else - Actions
          • Set FlierSpeed[tempInteger] = (FlierSpeed[tempInteger] + ((5.00 - FlierTurn[tempInteger]) / 2.00))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FlierSpeed[tempInteger] Greater than MaxSpeed[tempInteger]
        • Then - Actions
          • Set FlierSpeed[tempInteger] = MaxSpeed[tempInteger]
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FlierSpeed[tempInteger] Less than MinSpeed[tempInteger]
        • Then - Actions
          • Set FlierSpeed[tempInteger] = MinSpeed[tempInteger]
        • Else - Actions
      • -------- -------- --------
      • -------- If not close to target, SKIP --------
      • -------- -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Square root((Abs(((Power((x - x2), 2.00)) + (Power((y - y2), 2.00))))))) Greater than 125.00
        • Then - Actions
          • Skip remaining actions
        • Else - Actions
      • -------- -------- --------
      • -------- MISSILE HITS --------
      • -------- -------- --------
      • Set BlastedUnit = AiTargets[tempInteger]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of tempLaser) Not equal to Ion Pulse Missile
        • Then - Actions
          • Special Effect - Create a special effect attached to the origin of BlastedUnit using Abilities\Weapons\SteamTank\SteamTankImpact.mdl
        • Else - Actions
          • Special Effect - Create a special effect attached to the origin of BlastedUnit using Abilities\Weapons\Bolt\BoltImpact.mdl
      • Special Effect - Destroy (Last created special effect)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of tempLaser) Equal to Concussion Missile
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • FlierMissileAdvanced[tempInteger] Equal to True
            • Then - Actions
              • Set tempReal = _AdvConcussionMissileStats[4]
              • Set cameraSwayCounter[(Player number of (Owner of BlastedUnit))] = 5
            • Else - Actions
              • Set tempReal = _ConcussionMissileStats[4]
              • Set cameraSwayCounter[(Player number of (Owner of BlastedUnit))] = 3
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player number of (Owner of BlastedUnit)) Less than or equal to 10
              • (Custom value of BlastedUnit) Less than or equal to 10
            • Then - Actions
              • Camera - Shake the camera for (Owner of BlastedUnit) with magnitude 6.00
            • Else - Actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of tempLaser) Equal to Ion Pulse Missile
            • Then - Actions
              • Set ionPulseCounter = 3
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • MaxShield[(Custom value of BlastedUnit)] Greater than or equal to (Level of Shielding (item ability) for BlastedUnit)
                  • MaxShield[(Custom value of BlastedUnit)] Greater than 0
                • Then - Actions
                  • Unit - Increase level of Shielding (item ability) for BlastedUnit
                  • Set ionPulseCounter = (ionPulseCounter - 1)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • MaxShield[(Custom value of BlastedUnit)] Greater than or equal to (Level of Shielding (item ability) for BlastedUnit)
                  • MaxShield[(Custom value of BlastedUnit)] Greater than 0
                • Then - Actions
                  • Unit - Increase level of Shielding (item ability) for BlastedUnit
                  • Set ionPulseCounter = (ionPulseCounter - 1)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • MaxShield[(Custom value of BlastedUnit)] Greater than or equal to (Level of Shielding (item ability) for BlastedUnit)
                  • MaxShield[(Custom value of BlastedUnit)] Greater than 0
                • Then - Actions
                  • Unit - Increase level of Shielding (item ability) for BlastedUnit
                  • Set ionPulseCounter = (ionPulseCounter - 1)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (BlastedUnit is Mechanical) Equal to True
                • Then - Actions
                  • -------- NO damage to mechanical units --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (BlastedUnit is A ground unit) Equal to True
                    • Then - Actions
                      • Set tempPlayerGroup = (Player group((Owner of tempLaser)))
                      • Game - Display to tempPlayerGroup the text: |c00FF0000That targ...
                      • Custom script: call DestroyForce(udg_tempPlayerGroup)
                    • Else - Actions
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ionPulseCounter Greater than 0
                    • Then - Actions
                      • -------- shields gone --------
                      • Set tempHazardShip = BlastedUnit
                      • For each (Integer A) from 1 to ionPulseCounter, do (Actions)
                        • Loop - Actions
                          • Set hazardAnnounced = False
                          • Set tempHazardType = (Random integer number between 0 and 4)
                          • Trigger - Run Hazard Experienced <gen> (ignoring conditions)
                    • Else - Actions
              • Unit - Remove tempLaser from the game
              • Unit - Kill tempLaser
              • Skip remaining actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of tempLaser) Equal to Proton Torpedo 2
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • FlierMissileAdvanced[(Custom value of tempLaser)] Equal to True
                    • Then - Actions
                      • Set cameraSwayCounter[(Player number of (Owner of BlastedUnit))] = 7
                      • Set tempReal = _AdvProtonStats[4]
                    • Else - Actions
                      • Set cameraSwayCounter[(Player number of (Owner of BlastedUnit))] = 5
                      • Set tempReal = _ProtonTorpStats[4]
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Player number of (Owner of BlastedUnit)) Less than or equal to 10
                      • (Custom value of BlastedUnit) Less than or equal to 10
                    • Then - Actions
                      • Camera - Shake the camera for (Owner of BlastedUnit) with magnitude 18.00
                    • Else - Actions
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of tempLaser) Equal to Concussion Bomb
                    • Then - Actions
                      • Set tempReal = _ConcussionBombStats[4]
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Player number of (Owner of BlastedUnit)) Less than or equal to 10
                          • (Custom value of BlastedUnit) Less than or equal to 10
                        • Then - Actions
                          • Set cameraSwayCounter[(Player number of (Owner of BlastedUnit))] = 9
                          • Camera - Shake the camera for (Owner of BlastedUnit) with magnitude 24.00
                        • Else - Actions
                    • Else - Actions
      • Custom script: call GroupEnumUnitsInRange(udg_tempDamageUnits3, udg_x, udg_y, 300, null)
      • -------- better tracking increases damage, up to double. --------
      • Set tempReal = (tempReal + ((Real(TargetingStrength[tempInteger])) x 0.10))
      • Unit Group - Pick every unit in tempDamageUnits3 and do (Actions)
        • Loop - Actions
          • Set BlastedUnit2 = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (BlastedUnit2 belongs to an enemy of (Owner of tempLaser)) Equal to True
            • Then - Actions
              • Set hazardInteger = (Custom value of BlastedUnit2)
              • -------- damage --------
              • Set tempShields = (MaxShield[hazardInteger] - (Level of Shielding (item ability) for BlastedUnit2))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • FlierShieldAngling[hazardInteger] Equal to 0
                • Then - Actions
                • Else - Actions
                  • -------- find new shield value --------
                  • Set tempReal2 = (Abs(((Facing of tempLaser) - (Facing of BlastedUnit2))))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • tempReal2 Greater than 180.00
                    • Then - Actions
                      • Set tempReal2 = (Abs((tempReal2 - 360.00)))
                    • Else - Actions
                  • -------- temp real is difference in facing between laser and victim --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • tempReal2 Greater than or equal to 90.00
                    • Then - Actions
                      • Set laserHitFront = True
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • FlierShieldAngling[hazardInteger] Equal to 1
                        • Then - Actions
                          • -------- double shields --------
                          • Set tempShields = (tempShields + MaxShield[hazardInteger])
                        • Else - Actions
                          • Set tempShields = 0
                    • Else - Actions
                      • Set laserHitFront = False
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • FlierShieldAngling[hazardInteger] Equal to -1
                        • Then - Actions
                          • -------- double shields --------
                          • Set tempShields = (tempShields + MaxShield[hazardInteger])
                        • Else - Actions
                          • Set tempShields = 0
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • FlierShieldDoubled[hazardInteger] Equal to True
                • Then - Actions
                  • Set tempShields = (tempShields + MaxShield[hazardInteger])
                • Else - Actions
              • Set tempReal2 = (tempReal x (Power(0.90, ((Real(MaxShield[hazardInteger])) - (Real((Level of Shielding (item ability) for BlastedUnit2)))))))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (BlastedUnit2 is Mechanical) Equal to True
                • Then - Actions
                  • Unit - Cause tempLaser to damage BlastedUnit2, dealing (tempReal2 x 2.00) damage of attack type Chaos and damage type Universal
                • Else - Actions
                  • Unit - Cause tempLaser to damage BlastedUnit2, dealing tempReal2 damage of attack type Chaos and damage type Universal
            • Else - Actions
      • Unit - Kill tempLaser
 
Hehe, you're welcome. :)

Yeah it's okay you don't destroy the group, as no new one gets created.
GroupEnumUnitsInRange only will empty the group, and then fill it again.
When no new group is created, it might be re-used over and over.

1. It's totaly alright. You can let as much spaces as you whish in this case. It will be just when it comes to compiling.

2. The code is questionable from semantic point of view, and not truely clear what will happen, but JASS/GUI should just return a "null" value for you if the group does not exist.
I doubt it would couse a crash, but just probably unwanted results.

3. Hm, back then I remember we had a black screen for several minutes after long games, but the map was still playable ingame.
So I'm afraid the source of the crash is not just a leak. :/

The posted code also seems fine.
Only what I mentioned is that a unit is "killed" after it was "removed".
Just removing the unit will be fine, as a removed unit can't be killed no more.
 
Status
Not open for further replies.
Top