我曾经以为用等待时延迟的主要原因,不过测试的时候感觉好像不是.....难道占用内存过多是延迟的原因么??
这是从一个论坛看到的一个帖子 Massive lag and then disconnect Hello, I recently started playing my old map again and wanted to update ( I wasn't mapping for a long time) and I thought of something and tried to make it in GUI but It proved to be difficult, so I tried JASS. In single player it works perfectly, but I tried this online and it caused a huge lag and then everyone disconnected. ( I am super noob in JASS ) So how could I fix this? and what is wrong with it??
[pre]
function Trig_Mod_Actions takesnothingreturnsnothing
call TriggerAddAction( gg_trg_Mod, function Trig_Mod_Actions )
endfunction
This trigger is called after point[1] is being set at the location I want it and GapPlayer is set too, this code is called every 0.01 s (0.03s causes bugs with black mask).
Other trigger which is in GUI that runs the JASS:
GAP test Copy 2
Events
Time - Every 0.01 seconds of game time
Conditions
Actions
For each (Integer A) from 1 to 12, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(GapUnit[(Integer A)] is alive) Equal to True
Then - Actions
Set Point[1] = (Position of GapUnit[(Integer A)])
Set Tforce = (All enemies of (Owner of GapUnit[(Integer A)]))
Player Group - Pick every player in (All enemies of (Owner of GapUnit[(Integer A)])) and do (Actions)
Loop - Actions
Set Temp_Group = (Units within 1400.00 of Point[1])
Unit Group - Pick every unit in Temp_Group and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Picked unit)) Equal to (Picked player)
Then - Actions
Set Gap[Gapindex] = False
Else - Actions
Custom script: call DestroyGroup (udg_Temp_Group)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Gap[Gapindex] Equal to True
Then - Actions
Set GapPlayer = (Picked player)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
BlackMaskOn Equal to True
Then - Actions
Trigger - Run Mod <gen> (ignoring conditions)
Else - Actions
Trigger - Run Mod2 <gen> (ignoring conditions)
Else - Actions
Set Gap[Gapindex] = True
Set Gapindex = (Gapindex + 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Gapindex Greater than 144
(Mod2 is the same as Mod1 but with FOGGED instead of MASKED)
tigger before I used JASS which didn't really lag at first but then leaked visibility modifiers:
GAP test
Events
Time - Every 0.01 seconds of game time
Conditions
Actions
For each (Integer B) from 1 to 144, do (Actions)
Loop - Actions
Visibility - Destroy VisibilityGAP[(Integer B)]
For each (Integer A) from 1 to 12, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(GapUnit[(Integer A)] is alive) Equal to True
Then - Actions
Set Point[1] = (Position of GapUnit[(Integer A)])
Player Group - Pick every player in (All enemies of (Owner of GapUnit[(Integer A)])) and do (Actions)
Loop - Actions
Set Temp_Group = (Units within 1400.00 of Point[1])
Unit Group - Pick every unit in Temp_Group and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Picked unit)) Equal to (Picked player)
Then - Actions
Set Gap[Gapindex] = False
Else - Actions
Custom script: call DestroyGroup (udg_Temp_Group)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Gap[Gapindex] Equal to True
Then - Actions
Visibility - Create an initially Enabled visibility modifier for (Picked player) emitting Black mask from Point[1] to a radius of 1200.00
Set VisibilityGAP[Gapindex] = (Last created visibility modifier)
Else - Actions
Set Gap[Gapindex] = True
Set Gapindex = (Gapindex + 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Gapindex Greater than 144