- Joined
- Apr 1, 2010
- Messages
- 289
Math problem
the problem is with the turning. i tried to make take the shortest direction but it isn't working.
Another question is there a way to force a unit to face a direction. without using the gui move instantly?
edit: solved thanks to Mage goo
[hidden = "Solution"]
-
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
- Game - Display to (All players) the text: Increasing Speed
- Set MSSpeed = (MSSpeed - MSAccel)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Set MSSpeed = (MSSpeed + MSAccel)
- Hashtable - Save MSSpeed as 0 of Handle in MS
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Else - Actions
-
If - Conditions
-
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 = (Acos((Cos((MSAngle - MSGAngle)))))
- Set Real2 = (Asin((Cos((MSAngle + MSGAngle)))))
-
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)
-
If - Conditions
-
If - Conditions
- Hashtable - Save MSAngle as 3 of Handle in MS
- Else - Actions
-
If - Conditions
- Set TempPoint2 = (TempPoint1 offset by MSSpeed towards MSAngle degrees)
- Hashtable - Save Handle OfTempPoint2 as 6 of Handle in MS
- 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)
-
Loop - Actions
-
Unit Group - Pick every unit in MSGroup and do (Actions)
-
Events
Another question is there a way to force a unit to face a direction. without using the gui move instantly?
edit: solved thanks to Mage goo
[hidden = "Solution"]
-
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)
-
If - Conditions
-
If - Conditions
- Hashtable - Save MSAngle as 3 of Handle in MS
- Else - Actions
-
If - Conditions
Last edited: