- Joined
- Feb 18, 2007
- Messages
- 216
I'm using this kind of trigger in my map to make satellites circle around planets, and it works well:
The problem is that after a while, especially if there's several satellites, my map starts to lag like hell. So could someone help me to make lagless version of this trigger. BlueBerryWizard already started it but was too lazy to finish it
I don't know a shit about JASS so I can't finish it myself. Ofc if the lagless version could be made with GUI that would be better
but anyways, here's the script that BBW started:
-
SolarSatelliteMovement
-
Events
-
Time - Every 0.05 seconds of game time
-
-
Conditions
-
Actions
-
Unit Group - Pick every unit in solar_sats and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Distance between (Position of (Picked unit)) and (Position of Planet (grass) 0000 <gen>)) Less than or equal to 600.00
-
-
Then - Actions
-
Set temp_point = (Position of Planet (grass) 0000 <gen>)
-
Set temp_loc = (temp_point offset by 500.00 towards ((Angle from (Position of Planet (grass) 0000 <gen>) to (Position of (Picked unit))) + 0.50) degrees)
-
Unit - Move (Picked unit) instantly to temp_loc, facing ((Angle from (Position of Planet (grass) 0000 <gen>) to (Position of (Picked unit))) + 90.00) degrees
-
Custom script: call RemoveLocation(udg_temp_loc)
-
Custom script: call RemoveLocation(udg_temp_point)
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Distance between (Position of (Picked unit)) and (Position of Planet (lava) 0291 <gen>)) Less than or equal to 600.00
-
-
Then - Actions
-
Set temp_point = (Position of Planet (lava) 0291 <gen>)
-
Set temp_loc = (temp_point offset by 500.00 towards ((Angle from (Position of Planet (lava) 0291 <gen>) to (Position of (Picked unit))) + 0.50) degrees)
-
Unit - Move (Picked unit) instantly to temp_loc, facing ((Angle from (Position of Planet (lava) 0291 <gen>) to (Position of (Picked unit))) + 90.00) degrees
-
Custom script: call RemoveLocation(udg_temp_loc)
-
Custom script: call RemoveLocation(udg_temp_point)
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Distance between (Position of (Picked unit)) and (Position of Planet (snow) 0468 <gen>)) Less than or equal to 600.00
-
-
Then - Actions
-
Set temp_point = (Position of Planet (snow) 0468 <gen>)
-
Set temp_loc = (temp_point offset by 500.00 towards ((Angle from (Position of Planet (snow) 0468 <gen>) to (Position of (Picked unit))) + 0.50) degrees)
-
Unit - Move (Picked unit) instantly to temp_loc, facing ((Angle from (Position of Planet (snow) 0468 <gen>) to (Position of (Picked unit))) + 90.00) degrees
-
Custom script: call RemoveLocation(udg_temp_loc)
-
Custom script: call RemoveLocation(udg_temp_point)
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Distance between (Position of (Picked unit)) and (Position of Planet (dirt) 0466 <gen>)) Less than or equal to 600.00
-
-
Then - Actions
-
Set temp_point = (Position of Planet (dirt) 0466 <gen>)
-
Set temp_loc = (temp_point offset by 500.00 towards ((Angle from (Position of Planet (dirt) 0466 <gen>) to (Position of (Picked unit))) + 0.50) degrees)
-
Unit - Move (Picked unit) instantly to temp_loc, facing ((Angle from (Position of Planet (dirt) 0466 <gen>) to (Position of (Picked unit))) + 90.00) degrees
-
Custom script: call RemoveLocation(udg_temp_loc)
-
Custom script: call RemoveLocation(udg_temp_point)
-
-
Else - Actions
-
-
-
-
-
-
-
-
-
-
-
JASS:
scope SolarSatelliteMovement initializer init
public function Callback takes nothing returns nothing
local unit u = GetEnumUnit()
local real dx = GetLocationX(locB) - GetLocationX(locA)
local real dy = GetLocationY(locB) - GetLocationY(locA)
local real sr SquareRoot(dx * dx + dy * dy)
set dx = GetLocationX(locB) - GetLocationX(locA)
set dy = GetLocationY(locB) - GetLocationY(locA)
set sr = SquareRoot(dx * dx + dy * dy)
if sr < 600.00 then
//blah blah add moar stuff here I'ma lazyface
endif
set u = null
endfunction
public function Actions takes nothing returns nothing
call ForGroup(udg_solar_sats, function Callback)
endfunction
//===========================================================================
public function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerAddAction( t, function Actions )
set t = null
endfunction