I am making a custom movement system for a boat map. I store the player's boat as a unit: u, with custom value 1. I then reference the custom value in other array variables, for example the boat can be ordered to face FlierFacing[1].
The problem is rather simple but as far as I can tell utterly unsolvable! Every .03 seconds, I give the action:
Sometimes, seemingly at random but consistently (maybe 1 out of 10 times) the boat will jitter back and forth or pause briefly and then suddenly do a dramatic turn. I assumed there was something wrong in my calculation of "FlierFacing" which is the variable that determines where the ship should be facing. So I put the following action in the repeat trigger:
What's strange is that they do NOT line up when the boat gets jittery. They can be off by as many as 10 degrees.
In short,
I fire an action that makes unit u face an angle. Unit u, for some reason, does NOT face that angle even though it's being given no other orders, I never use the "face angle" action anywhere else in the map, the action to force the unit to face that direction is given every .03 seconds, and the trigger appears to be programmed correctly because it works 9 times out of 10.
The only thing I can think is that something else in the game mechanics is making the boat turn...like pathing or something, though it seems to happen in the open ocean, I've turned collision off, and I've set the boat's in-game turn rate to 0.
I've put the map in the Pastebin. Just right-click around for a bit (recognize that the current is pulling you east). You should see what I'm talking about and the numbers on the left will not be the same.
http://www.hiveworkshop.com/forums/pastebin_data/mv35eh/_files/river raid.w3x
FULL TRIGGER, it is called by another trigger every .03 seconds
The problem is rather simple but as far as I can tell utterly unsolvable! Every .03 seconds, I give the action:
- Unit - Make u face FlierFacing[tempInteger] over 0.00 seconds
Sometimes, seemingly at random but consistently (maybe 1 out of 10 times) the boat will jitter back and forth or pause briefly and then suddenly do a dramatic turn. I assumed there was something wrong in my calculation of "FlierFacing" which is the variable that determines where the ship should be facing. So I put the following action in the repeat trigger:
- Game - Display to (All players) the text: ((flier: + (String(FlierFacing[1]))) + ( facing: + (String((Facing of Fliers[1])))))
What's strange is that they do NOT line up when the boat gets jittery. They can be off by as many as 10 degrees.
In short,
I fire an action that makes unit u face an angle. Unit u, for some reason, does NOT face that angle even though it's being given no other orders, I never use the "face angle" action anywhere else in the map, the action to force the unit to face that direction is given every .03 seconds, and the trigger appears to be programmed correctly because it works 9 times out of 10.
The only thing I can think is that something else in the game mechanics is making the boat turn...like pathing or something, though it seems to happen in the open ocean, I've turned collision off, and I've set the boat's in-game turn rate to 0.
I've put the map in the Pastebin. Just right-click around for a bit (recognize that the current is pulling you east). You should see what I'm talking about and the numbers on the left will not be the same.
http://www.hiveworkshop.com/forums/pastebin_data/mv35eh/_files/river raid.w3x
FULL TRIGGER, it is called by another trigger every .03 seconds
-
Current Move
- Events
- Conditions
-
Actions
- Unit - Make u face FlierFacing[tempInteger] over 0.00 seconds
- Custom script: set udg_x = GetUnitX(udg_u)
- Custom script: set udg_y = GetUnitY(udg_u)
- Set x = (x + ((Cos(CurrentWaterDirection[tempInteger])) x CurrentWaterSpeed[tempInteger]))
- Set y = (y + ((Sin(CurrentWaterDirection[tempInteger])) x CurrentWaterSpeed[tempInteger]))
- Set x = (x + ((Cos((Facing of Fliers[tempInteger]))) x FlierSpeed[tempInteger]))
- Set y = (y + ((Sin((Facing of Fliers[tempInteger]))) x FlierSpeed[tempInteger]))
- Set tempPoint = (Point(x, y))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Terrain pathing at tempPoint of type Floatability is off) Equal to True
-
Then - Actions
- -------- *******check point with polar offset, 90 degrees in both directions for pathability******** --------
- Unit - Set life of u to ((Percentage life of u) - 1.00)%
-
Else - Actions
- Custom script: call SetUnitX (udg_u, udg_x)
- Custom script: call SetUnitY (udg_u, udg_y)
-
If - Conditions
- Custom script: call RemoveLocation (udg_tempPoint)
- -------- ------- --------
- -------- turn --------
- -------- ------- --------
- Set math_1 = (FlierTurn[tempInteger] - FlierFacing[tempInteger])
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- math_1 Less than 0.00
-
Then - Actions
- Set math_1 = (math_1 + 360.00)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
- math_1 Less than 1.00
- math_1 Greater than 359.00
-
Conditions
-
Or - Any (Conditions) are true
-
Then - Actions
- Set FlierFacing[tempInteger] = FlierTurn[tempInteger]
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- math_1 Greater than 180.00
-
Then - Actions
- Set FlierFacing[tempInteger] = (FlierFacing[tempInteger] - 1.00)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- FlierFacing[tempInteger] Less than 0.00
-
Then - Actions
- Set FlierFacing[tempInteger] = (FlierFacing[tempInteger] + 360.00)
- Else - Actions
-
If - Conditions
-
Else - Actions
- Set FlierFacing[tempInteger] = (FlierFacing[tempInteger] + 1.00)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- FlierFacing[tempInteger] Greater than 360.00
-
Then - Actions
- Set FlierFacing[tempInteger] = (FlierFacing[tempInteger] - 360.00)
- Else - Actions
-
If - Conditions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- -------- ------- --------
- -------- adjust water current --------
- -------- ------- --------
- Set math_1 = (CurrentWaterDirection[tempInteger] - TargetWaterDirection[tempInteger])
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
- (Abs(math_1)) Less than 3.00
- (Abs(math_1)) Greater than 357.00
-
Conditions
-
Or - Any (Conditions) are true
-
Then - Actions
- -------- current water = target --------
- Set CurrentWaterDirection[tempInteger] = TargetWaterDirection[tempInteger]
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- math_1 Less than 0.00
-
Then - Actions
- Set math_1 = (math_1 + 360.00)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- math_1 Greater than 180.00
-
Then - Actions
- Set CurrentWaterDirection[tempInteger] = (CurrentWaterDirection[tempInteger] + 2.00)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- CurrentWaterDirection[tempInteger] Less than 0.00
-
Then - Actions
- Set CurrentWaterDirection[tempInteger] = (CurrentWaterDirection[tempInteger] + 360.00)
- Else - Actions
-
If - Conditions
-
Else - Actions
- Set CurrentWaterDirection[tempInteger] = (CurrentWaterDirection[tempInteger] - 2.00)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- CurrentWaterDirection[tempInteger] Greater than 360.00
-
Then - Actions
- Set CurrentWaterDirection[tempInteger] = (CurrentWaterDirection[tempInteger] - 360.00)
- Else - Actions
-
If - Conditions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- -------- speed --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- CurrentWaterSpeed[tempInteger] Greater than TargetWaterSpeed[tempInteger]
-
Then - Actions
- Set CurrentWaterSpeed[tempInteger] = (CurrentWaterSpeed[tempInteger] - 0.05)
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- CurrentWaterSpeed[tempInteger] Less than TargetWaterSpeed[tempInteger]
-
Then - Actions
- Set CurrentWaterSpeed[tempInteger] = (CurrentWaterSpeed[tempInteger] + 0.05)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions