Wc3C.net

Wc3C.net (http://www.wc3c.net/forums.php)
-   Triggers & Scripts (http://www.wc3c.net/forumdisplay.php?f=8)
-   -   Trigger causes lag and needs a fix (http://www.wc3c.net/showthread.php?t=109837)

TheTerran 10-01-2010 05:48 PM

[SOLVED] Trigger causes lag and needs a fix
 
I am 'attaching' 12 units to one unit that let's call 'Main Unit' by moving every 0.01 second the units to the main unit. The units have to be forming a circle around the main unit and when the Main Unit moves, the 'attached' units to remain in the same circle, so I use these triggers:

Trigger:
Test2
Events
Time - Every 0.01 seconds of game time
Conditions
Actions
Unit - Move Marine 0003 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 30.00 degrees)
Unit - Move Terran Medic 0010 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 60.00 degrees)
Unit - Move Marine 0007 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 90.00 degrees)
Unit - Move Marine 0004 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 120.00 degrees)
Unit - Move Marine 0013 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 150.00 degrees)
Unit - Move Marine 0012 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 180.00 degrees)
Unit - Move Terran Medic 0009 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 210.00 degrees)
Unit - Move Marine 0006 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 240.00 degrees)
Unit - Move Terran Medic 0011 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 270.00 degrees)
Unit - Move Marine 0008 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 300.00 degrees)
Unit - Move Terran Medic 0015 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 330.00 degrees)
Unit - Move Marine 0014 <gen> instantly to ((Position of (Random unit from (Units of type Main Unit))) offset by 320.00 towards 360.00 degrees)

I know these are shitty triggers but I decided to try it in the most simple way and the result is:

- this trigger causes lag after the 3rd minute so I need an alternative of it that isnt laggy but you get what im trying to do
- Even if I make the circle and they stand attached to the main unit like that, whenever the Main unit rotates/turns on a direction, they do not rotate because they are placed at degrees in general but I need to make the degrees towards the facing of the Main unit.

How can I do this circle and moved every 0.01 w/o lag and make them rotate as the Main Unit rotates? That is if say Marine 007 is at 90 degrees, when the Main Unit turns on some other direction, Marine 007 should also turn his 90 degrees towards the facing of the Main Unit and the same for all units to turn based on Main unit

akolyt0r 10-01-2010 07:02 PM

you have like:
12*2*100*60 = 144000 memory leaks per minute
you have to call RemoveLocation, or else you will have massive point leaks

you need to replace each line of your trigger with something like:
Trigger:
Set TempUnitPoint = Position of Random Unit from Units of type Main Unit
Set TempUnitOffsetPoint = TempUnitPoint offset by 320 towards XXX degrees
Unit - Move XXX instantly to TempUnitOffsetPoint
CustomScript - call RemoveLocation(udg_TempUnitPoint)
CustomScript - call RemoveLocation(udg_TempUnitOffsetPoint)

also i would try to replace 0.01 seconds with 0.002 seconds, it will most likely still look smooth in game, but the trigger will cause 50% less performance issues

TheTerran 10-01-2010 09:14 PM

Ay with your help this worked thanks. But this solves the lag problem, at least now it seems to be OK. Problem 2 that has to do with the degree - now that I made the circle of units around the Main Unit, whenever I move the Main Unit on the map, it turns direction and when it turns direction, the circle of 12 units doesn't turn. So how do I make these degrees based on the Main unit's facing so that when it turns, the 12 units also turn side. They should be like part of the Main unit, so the 'circle of units' should turn side along with the Main unit turning side

Trigger:
Test
Collapse Events
Time - Every 0.03 seconds of game time
Conditions
Collapse Actions
Set MainUnitPoint = (Position of (Random unit from (Units of type Domed Space Platform)))
Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 30.00 degrees)
Unit - Move Marine 0003 <gen> instantly to MainUnitUnitPoint
Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 60.00 degrees)
Unit - Move Marine 0004 <gen> instantly to MainUnitUnitPoint
Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 90.00 degrees)
Unit - Move Marine 0006 <gen> instantly to MainUnitUnitPoint
Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 120.00 degrees)
Unit - Move Marine 0007 <gen> instantly to MainUnitUnitPoint
Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 150.00 degrees)
Unit - Move Marine 0008 <gen> instantly to MainUnitUnitPoint
Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 180.00 degrees)
Unit - Move Marine 0012 <gen> instantly to MainUnitUnitPoint
Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 210.00 degrees)
Unit - Move Marine 0013 <gen> instantly to MainUnitUnitPoint
Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 240.00 degrees)
Unit - Move Marine 0014 <gen> instantly to MainUnitUnitPoint
Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 270.00 degrees)
Unit - Move Terran Medic 0009 <gen> instantly to MainUnitUnitPoint
Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 300.00 degrees)
Unit - Move Terran Medic 0010 <gen> instantly to MainUnitUnitPoint
Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 330.00 degrees)
Unit - Move Terran Medic 0011 <gen> instantly to MainUnitUnitPoint
Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards 360.00 degrees)
Unit - Move Terran Medic 0015 <gen> instantly to MainUnitUnitPoint
Custom script: call RemoveLocation(udg_MainUnitPoint)
Custom script: call RemoveLocation(udg_MainUnitUnitPoint)

akolyt0r 10-02-2010 12:46 PM

First, you need to put
Trigger:
Custom script: call RemoveLocation(udg_MainUnitUnitPoint)
after EACH "Unit - Move ..." line, or you will still have massive leaks.

Regarding your turn problem .... try something like:
Trigger:
Set MainUnitUnitPoint = (MainUnitPoint offset by 320.00 towards ( (facing of YOURMAINUNIT) + XXX) degrees)

TheTerran 10-02-2010 05:12 PM

yes I did it thanks +rep


All times are GMT. The time now is 12:43 PM.

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services