• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Trigger problem

Status
Not open for further replies.
Level 7
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:
  • 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
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 :p but anyways, here's the script that BBW started:
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
 
  • SolarSatelliteMovement
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set X_Unit_Planet[1] = Ancient Protector 0003 <gen>
      • Set X_Unit_Satelite[1] = Wisp 0002 <gen>
      • Set X_Unit_Satelite[2] = Wisp 0004 <gen>
      • Set X_Unit_Satelite[3] = Wisp 0005 <gen>
      • Set X_Unit_Satelite[4] = Wisp 0006 <gen>
      • Set X_Unit_Satelite[5] = Wisp 0007 <gen>
      • Set X_Unit_Satelite[6] = Wisp 0008 <gen>
      • Set X_Point[1] = (Position of X_Unit_Planet[1])
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Unit - Turn collision for X_Unit_Satelite[(Integer A)] Off
          • Set X_Angle[(Integer A)] = ((Facing of X_Unit_Satelite[(Integer A)]) + 3.00)
          • Set X_Point[2] = (X_Point[1] offset by 300.00 towards X_Angle[(Integer A)] degrees)
          • Unit - Move X_Unit_Satelite[(Integer A)] instantly to X_Point[2], facing X_Angle[(Integer A)] degrees
          • Custom script: call RemoveLocation(udg_X_Point[2])
      • Custom script: call RemoveLocation(udg_X_Point[1])
Can help, btw you need 2 triggers one to use as setup trigger and another one for loop!

I am 2 lazy to create everything, but you can set starting angle for each satellite in setup trigger also, that way satellites can have different distance from each other!

Setup trigger should look like:
  • Set X_Unit_Planet[1] = Ancient Protector 0003 <gen>
  • Set X_Unit_Satelite[1] = Wisp 0002 <gen>
  • Set X_Unit_Satelite[2] = Wisp 0004 <gen>
  • Set X_Unit_Satelite[3] = Wisp 0005 <gen>
  • Unit - Turn collision for X_Unit_Satelite[1] Off
  • Unit - Turn collision for X_Unit_Satelite[2] Off
  • Set X_Angle[1] = 60
  • Set X_Angle[1] = 120
and so on
 

Attachments

  • test map.w3x
    17.1 KB · Views: 92
Level 7
Joined
Feb 18, 2007
Messages
216
thanks, those unit arrays are just for testing purposes I guess? because my map has no satellites already, they're buildable units :) so I've to use that unit group. But I'll check if that system reduces the lag.

EDIT: I modified the trigger so that it's possible to construct satellites on several planets (like in the original trigger). Now the map starts to megalag and freezes the game before even 10 satellites are trained. Any other ideas ? :)
 
Last edited:
Status
Not open for further replies.
Top