FPS drops to 0

Level 5
Joined
Feb 22, 2025
Messages
78
The game freezes right after the units get pulled to the center( it does not crash the game but it reamins at 0 for couple of secs). Should I limit the number of units getting pulled, also did I mess something with triggers?
Tnx in forward :)
*Edit: Before creating the spell I was using the Spinning Black Hole [3D] and had similar issues where units eather wouldn't move towards the center or the game would freeze.
Update: The spell runs smoothly when it's affecting enemy units but sometimes it affects friendly units even the caster ???? idk why that happens that's when it freezes( it tries to move allied units and apply damage- i noticed that cuz I'm using Dmg engine and floating text around allied units says blocked.)
I\m still trying to see the issue that adds wrong units to UnitGroup that is affected by the spell.
-------------------------------------------------------------------------------------
  • BLH Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Black Hole [D3]
    • Actions
      • Set BHL_Caster = (Triggering unit)
      • Set BHL_Point = (Target point of ability being cast)
      • Unit - Create 1 Black Hole Model for Neutral Passive at BHL_Point facing Default building facing degrees
      • Set BHL_Model = (Last created unit)
      • Unit - Add a 3.00 second Water Elemental expiration timer to BHL_Model
      • Countdown Timer - Start BHL_Timer as a One-shot timer that will expire in 3.00 seconds
      • Trigger - Turn on BHL Pull <gen>
--------------------------------------------------------------------------------------
  • BHL Pull
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
      • (BHL_Model is alive) Equal to True
    • Actions
      • Set BHL_TempGroup = (Units within 500.00 of BHL_Point matching (((((Matching unit) is A structure) Equal to False) and (((Matching unit) belongs to an enemy of (Owner of BHL_Caster).) Equal to True)) and (((Matching unit) is hidden) Equal to False)).)
      • Unit Group - Pick every unit in BHL_TempGroup and do (Actions)
        • Loop - Actions
          • Set BHL_TempUnit = (Picked unit)
          • Set BHL_TempPoint = (Position of BHL_TempUnit)
          • Set BHL_Angle = (Angle from BHL_TempPoint to BHL_Point)
          • Set BHL_Distance = (Distance between BHL_TempPoint and BHL_Point)
          • Set BHL_OffsetMove = ((Position of BHL_TempUnit) offset by 20.00 towards BHL_Angle degrees.)
          • Custom script: call SetUnitPathing( udg_BHL_TempUnit, false)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BHL_Distance Greater than 50.00
            • Then - Actions
              • Unit - Move BHL_TempUnit instantly to BHL_OffsetMove
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (BHL_TempUnit is in BHL_DamagedGroup.) Equal to False
                • Then - Actions
                  • Unit - Cause BHL_Caster to damage BHL_TempUnit, dealing 300.00 damage of attack type Spells and damage type Normal
                  • Unit Group - Add BHL_TempUnit to BHL_DamagedGroup
                • Else - Actions
            • Else - Actions
          • Custom script: call RemoveLocation( udg_BHL_TempPoint)
          • Custom script: call RemoveLocation( udg_BHL_OffsetMove)
      • Custom script: call DestroyGroup( udg_BHL_TempGroup)
------------------------------------------------------------------------------------------
  • BHL Explode
    • Events
      • Time - BHL_Timer expires
    • Conditions
    • Actions
      • Unit - Remove BHL_Model from the game
      • Special Effect - Create a special effect at BHL_Point using Gravity Storm.mdx
      • Special Effect - Destroy (Last created special effect)
      • Set BHL_ExpGroup = (Units within 400.00 of BHL_Point matching (((((Matching unit) is A structure) Equal to False) and (((Matching unit) belongs to an enemy of (Owner of BHL_Caster).) Equal to True)) and (((Matching unit) is hidden) Equal to False)).)
      • Set BHL_ExpP = BHL_Point
      • Set BHL_Index = 0
      • Set BHL_ExpDistance = 300.00
      • Set BHL_ExpStep = 30.00
      • Set BHL_MaxSteps = ((Integer(BHL_ExpDistance)) / (Integer(BHL_ExpStep)))
      • Trigger - Turn on BHL kLoop <gen>
-----------------------------------------------------------------------------------------
  • BHL kLoop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BHL_Index Less than BHL_MaxSteps
        • Then - Actions
          • Unit Group - Pick every unit in BHL_ExpGroup and do (Actions)
            • Loop - Actions
              • Set BHL_TempUnit = (Picked unit)
              • Set BHL_TempPoint = (Position of BHL_TempUnit)
              • Set BHL_OffsetMove = (BHL_TempPoint offset by BHL_ExpStep towards (Angle from BHL_ExpP to BHL_TempPoint) degrees.)
              • Unit - Move BHL_TempUnit instantly to BHL_OffsetMove
              • Custom script: call RemoveLocation( udg_BHL_TempPoint)
              • Custom script: call RemoveLocation( udg_BHL_OffsetMove)
              • Set BHL_Index = (BHL_Index + 1)
        • Else - Actions
          • Unit Group - Pick every unit in BHL_ExpGroup and do (Actions)
            • Loop - Actions
              • Custom script: call SetUnitPathing( GetEnumUnit(), true)
              • Unit - Create 1 DummyCaster for (Owner of BHL_Caster) at (Position of (Picked unit)) facing Default building facing degrees
              • Set BHL_StunnDummy = (Last created unit)
              • Unit - Add a 1.00 second Water Elemental expiration timer to BHL_StunnDummy
              • Unit - Order BHL_StunnDummy to Neutral - Firebolt (Picked unit)
              • Unit - Cause BHL_Caster to damage (Picked unit), dealing 300.00 damage of attack type Spells and damage type Normal
      • Trigger - Turn off (This trigger)
      • Custom script: call RemoveLocation( udg_BHL_ExpP)
      • Custom script: call DestroyGroup( udg_BHL_ExpGroup)
--------------------------------------------------------------------------------------
 
Last edited:
Level 29
Joined
Sep 26, 2009
Messages
2,594
That spell is not MUI nor MPI, so multiple active instances of the spell will break it. That may explain why it sometimes picks other units if BHL_caster is overwritten by another cast.

You do not turn off BHL Pull trigger after spell ends, on the other hand your turn off BHL kLoop trigger after single execution.
BHL Explode does not need timer event, since you attach timer to BHL_Model unit via timed life. So just detect when BHL_Model dies.

Although this doesn't happen right now since it turns off prematurely, in BHL kLoop you should create only a single dummy unit order it to cast firebolt on each picked unit, rather than create 1 dummy per target. With your current solution you will notice FPS drop due to increased amount of units placed on the screen.

You don't need to turn collision off via
  • Custom script: call SetUnitPathing( udg_BHL_TempUnit, false)
as that turns collision off only of the unit towards other objects, but it does not turn collision off of other objects towards this unit.
Simply put, turning collision off for unit A will allow it to run through unit B (ignoring collision), but unit B will still run around unit A, not through it (checking collision).
You also do not turn it back on properly. Your first trigger turns collision off for any unit within 500.00 range, but you turn it back on only for units within 400.00 range.

As to the lag, I think the primary culprit is
  • Unit - Move BHL_TempUnit instantly to BHL_OffsetMove
as that computes collision any time the unit is moved. If you have too many units stuck clustered together it may have hard time determining where to move the unit.

My advice is to get rid of the "SetUnitPathing" calls and replace the move unit action with SetUnitX/Y calls which do not compute collision. So:
  • // from this
  • Unit - Move BHL_TempUnit instantly to BHL_OffsetMove
  • // to this
  • Custom script: call SetUnitX(udg_BHL_TempUnit, GetLocationX(udg_BHL_OffsetMove))
  • Custom script: call SetUnitY(udg_BHL_TempUnit, GetLocationY(udg_BHL_OffsetMove))
 
Level 5
Joined
Feb 22, 2025
Messages
78
That spell is not MUI nor MPI, so multiple active instances of the spell will break it. That may explain why it sometimes picks other units if BHL_caster is overwritten by another cast.

You do not turn off BHL Pull trigger after spell ends, on the other hand your turn off BHL kLoop trigger after single execution.
BHL Explode does not need timer event, since you attach timer to BHL_Model unit via timed life. So just detect when BHL_Model dies.

Although this doesn't happen right now since it turns off prematurely, in BHL kLoop you should create only a single dummy unit order it to cast firebolt on each picked unit, rather than create 1 dummy per target. With your current solution you will notice FPS drop due to increased amount of units placed on the screen.

You don't need to turn collision off via
  • Custom script: call SetUnitPathing( udg_BHL_TempUnit, false)
as that turns collision off only of the unit towards other objects, but it does not turn collision off of other objects towards this unit.
Simply put, turning collision off for unit A will allow it to run through unit B (ignoring collision), but unit B will still run around unit A, not through it (checking collision).
You also do not turn it back on properly. Your first trigger turns collision off for any unit within 500.00 range, but you turn it back on only for units within 400.00 range.

As to the lag, I think the primary culprit is
  • Unit - Move BHL_TempUnit instantly to BHL_OffsetMove
as that computes collision any time the unit is moved. If you have too many units stuck clustered together it may have hard time determining where to move the unit.

My advice is to get rid of the "SetUnitPathing" calls and replace the move unit action with SetUnitX/Y calls which do not compute collision. So:
  • // from this
  • Unit - Move BHL_TempUnit instantly to BHL_OffsetMove
  • // to this
  • Custom script: call SetUnitX(udg_BHL_TempUnit, GetLocationX(udg_BHL_OffsetMove))
  • Custom script: call SetUnitY(udg_BHL_TempUnit, GetLocationY(udg_BHL_OffsetMove))
Tnx, I'll see what I can do to make it run perfectly :goblin_boom:
 
Top