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

a problem with the system

Status
Not open for further replies.
Level 7
Joined
Apr 1, 2010
Messages
289
  • Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in MSGroup and do (Actions)
        • Loop - Actions
          • Set MSUnit = (Picked unit)
          • Custom script: set udg_Handle = GetHandleIdBJ(udg_MSUnit)
          • -------- here is wher all Hastable Values are Loaded. --------
          • -------- This Involves Speed --------
          • Set MSSpeed = (Load 0 of Handle from MS)
          • Set MSGSpeed = (Load 1 of Handle from MS)
          • Set MSAccel = (Load 2 of Handle from MS)
          • -------- This involves Facing --------
          • Set MSAngle = (Load 3 of Handle from MS)
          • Set MSGAngle = (Load 4 of Handle from MS)
          • Set MSTurn = (Load 5 of Handle from MS)
          • -------- The Location is loaded from Hastables. --------
          • Set TempPoint1 = (Load 6 of Handle in MS)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MSSpeed Not equal to MSGSpeed
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Abs((MSGSpeed - MSSpeed))) Less than or equal to MSAccel
                • Then - Actions
                  • Set MSSpeed = MSGSpeed
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • MSGSpeed Less than MSSpeed
                    • Then - Actions
                      • Set MSSpeed = (MSSpeed - MSAccel)
                    • Else - Actions
              • Set MSSpeed = (MSSpeed + MSAccel)
              • Hashtable - Save MSSpeed as 0 of Handle in MS
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MSAngle Not equal to MSGAngle
            • Then - Actions
              • Set Real1 = (Acos((Cos((MSGAngle - MSAngle)))))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Real1 Less than or equal to MSAccel
                • Then - Actions
                  • Set MSAngle = MSGAngle
                • Else - Actions
                  • Set Real1 = (MSGAngle - MSAngle)
                  • Set Real1 = (Acos((Cos(Real1))))
                  • Set Real2 = (MSAngle - MSGAngle)
                  • Set Real2 = (Acos((Cos(Real2))))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Real1 Less than Real2
                    • Then - Actions
                      • Set MSAngle = (MSAngle - MSTurn)
                    • Else - Actions
                      • Set MSAngle = (MSAngle + MSTurn)
              • Hashtable - Save MSAngle as 3 of Handle in MS
            • Else - Actions
          • Set TempPoint2 = (TempPoint1 offset by MSSpeed towards MSAngle degrees)
          • Hashtable - Save Handle OfTempPoint2 as 6 of Handle in MS
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Facing of MSUnit) Equal to MSAngle
            • Then - Actions
            • Else - Actions
              • Custom script: call SetUnitFacing(udg_MSUnit, udg_MSAngle)
          • Custom script: call SetUnitX(udg_MSUnit, GetLocationX(udg_TempPoint2))
          • Custom script: call SetUnitY(udg_MSUnit, GetLocationY(udg_TempPoint2))
          • Custom script: call RemoveLocation(udg_TempPoint1)
the system works, but the units facing wavers back and forth, and the units occasionally ignore your commands.
here is the system View attachment MoveSys.w3x
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
If you order a unit face a certain angle, then the unit's facing won't be ecatly the ordered facing. There's a bit of offset.

So you could add some tolerance here:
MSAngle Not equal to MSGAngle
Change to this:
  • (Abs((MSAngle - MSGAngle))) Greater than 3.00
3 is the tolerance, adjust it.

Sometimes the angles are a bit off, I checked with debug messages. Could you describe what this block is supposed to do:

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • MSAngle Not equal to MSGAngle
    • Then - Actions
      • Set Real1 = (Acos((Cos((MSGAngle - MSAngle)))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Real1 Less than or equal to MSAccel
        • Then - Actions
          • Set MSAngle = MSGAngle
        • Else - Actions
          • Set Real1 = (MSGAngle - MSAngle)
          • Set Real1 = (Acos((Cos(Real1))))
          • Set Real2 = (MSAngle - MSGAngle)
          • Set Real2 = (Acos((Cos(Real2))))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Real1 Less than Real2
            • Then - Actions
              • Set MSAngle = (MSAngle - MSTurn)
            • Else - Actions
              • Set MSAngle = (MSAngle + MSTurn)
      • Hashtable - Save MSAngle as 3 of Handle in MS
    • Else - Actions


Other:
  • Custom script: set udg_Handle = GetHandleIdBJ(udg_MSUnit)
->
  • Custom script: set udg_Handle = GetHandleId(udg_MSUnit)
 
Status
Not open for further replies.
Top