• 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.

Fish cause lag?

Status
Not open for further replies.
Level 13
Joined
Oct 16, 2010
Messages
737
Strange title I am aware...

Anyway. I've made a spell for my joke hero where he summons fish dependant on how many kills he has. His kills get halved when he casts the spell. The fish then home in on enemies and explode dealing damage equal to his strength, if there are no targets then they follow the caster instead.

I was testing it and had cheated and probably had about 70 fish (couldn't really tell as they all have locust) and it caused MASSIVE lag when they returned to the caster. The likely-hood of having that many at once is very unlikely but I wanted to know whether it is the model causing the lag or my movement trigger.

So here it is:

  • Manhood Follow
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer MH_LoopInt) from 0 to MH_MaxIndex, do (Actions)
        • Loop - Actions
          • Set MH_CasterPoint = (Position of MH_Dummy[MH_LoopInt])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MH_Target[MH_LoopInt] Not equal to No unit
              • (MH_Target[MH_LoopInt] is alive) Equal to True
            • Then - Actions
              • Set TempPoint = (Position of MH_Target[MH_LoopInt])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between MH_CasterPoint and TempPoint) Less than 15.00
                • Then - Actions
                  • Unit - Kill MH_Dummy[MH_LoopInt]
                  • Unit - Cause MH_Caster to damage MH_Target[MH_LoopInt], dealing (Real((Strength of MH_Caster (Exclude bonuses)))) damage of attack type Spells and damage type Universal
                  • Set MH_Dummy[MH_LoopInt] = MH_Dummy[MH_MaxIndex]
                  • Set MH_Target[MH_LoopInt] = MH_Target[MH_MaxIndex]
                  • Set MH_MaxIndex = (MH_MaxIndex - 1)
                  • Set MH_LoopInt = (MH_LoopInt - 1)
                • Else - Actions
                  • Unit - Move MH_Dummy[MH_LoopInt] instantly to (MH_CasterPoint offset by 15.00 towards (Angle from MH_CasterPoint to TempPoint) degrees), facing TempPoint
              • Custom script: call RemoveLocation(udg_TempPoint)
            • Else - Actions
              • Set TempUnitGroup = (Units within 1200.00 of MH_CasterPoint matching ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an enemy of (Owner of MH_Caster)) Equal to True)))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in TempUnitGroup) Greater than or equal to 1
                • Then - Actions
                  • Set MH_Target[MH_LoopInt] = (Random unit from TempUnitGroup)
                  • Set MH_LoopInt = (MH_LoopInt - 1)
                • Else - Actions
                  • Set TempPoint = (Position of MH_Caster)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between MH_CasterPoint and TempPoint) Greater than 60.00
                    • Then - Actions
                      • Unit - Move MH_Dummy[MH_LoopInt] instantly to (MH_CasterPoint offset by 15.00 towards (Angle from MH_CasterPoint to TempPoint) degrees), facing TempPoint
                    • Else - Actions
                      • Unit - Make MH_Dummy[MH_LoopInt] face MH_Caster over 0.00 seconds
                  • Custom script: call RemoveLocation(udg_TempPoint)
              • Custom script: call DestroyGroup(udg_TempUnitGroup)
          • Custom script: call RemoveLocation(udg_MH_CasterPoint)
 
Level 8
Joined
Jan 8, 2013
Messages
348
well theres a leak.

  • Unit - Move MH_Dummy[MH_LoopInt] instantly to (MH_CasterPoint offset by 15.00 towards (Angle from MH_CasterPoint to TempPoint) degrees), facing TempPoint
make a new point variable! for the offset point

  • Set TempPoint2 = MH_CasterPoint offset by 15.00 towards (Angle from MH_CasterPoint to TempPoint) degrees), facing TempPoint
and then make

  • Unit - Move MH_Dummy[MH_LoopInt] instantly to TempPoint2
and destroy the point.

  • call RemoveLocation(udg_TempPoint2)
SAME HERE!

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Distance between MH_CasterPoint and TempPoint) Greater than 60.00
    • Then - Actions
      • Unit - Move MH_Dummy[MH_LoopInt] instantly to (MH_CasterPoint offset by 15.00 towards (Angle from MH_CasterPoint to TempPoint) degrees), facing TempPoint
    • Else - Actions
      • Unit - Make MH_Dummy[MH_LoopInt] face MH_Caster over 0.00 seconds
heres a leak too. fix it like above. you know hwo to handle this shit becasue you made it for Temppoint
 
Level 13
Joined
Oct 16, 2010
Messages
737
It seems to yer, it still lags on the odd occasion but I think that could easily be due to other triggers and such. I've limited the cap to 25 so only 25 can be summoned at once as summoning 40 or so was gunna be problematic. Thanks for the help though! :)
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
I think both the number of fish and the trigger are at fault.
Units are quite costly in terms of performance, to suddenly have 70 more units on screen is a lot.
However another problem is in the trigger. Creating unit group is a costly process as well, as it has to pick every unit in map and checks them for condition(s). Your trigger creates many unit groups every 0.03 seconds. The amount is equal to MH_MaxIndex. That will be noticeable.
 
Status
Not open for further replies.
Top