Phobos icon indicating copy to clipboard operation
Phobos copied to clipboard

[Customized] Customized Vehicle Turret Rotation

Open CrimRecya opened this issue 11 months ago • 4 comments

  • When ExpandTurretRotation is set to true, the following functions will be enabled.
  • Units with turret without TurretSpins=true can looks more vivid when it is in idle.
    • Turret.IdleRotate controls whether units can rotate their turrets when in idle. Defaults to [AudioVisual] -> Turret.IdleRotate.
    • Turret.PointToMouse controls whether units will turn their turrets to your mouse when in idle. Defaults to [AudioVisual] -> Turret.PointToMouse.
      • At the present moment, this only functions in singleplayer.
    • Turret.IdleRestartMin and Turret.IdleRestartMax control the delay from idle to action occurrence together.
    • Turret.IdleIntervalMin and Turret.IdleIntervalMax control the delay between every idle actions together.
  • The turret and body of the units can now be rotated under control.
    • Turret.Restriction defines the angle at which the turret can be turned to both sides.
    • Turret.ExtraAngle defines the additional rotation angle of the turret, and Turret.Restriction will also rotate with this value. The positive number is clockwise and the negative number is counterclockwise, that is, what angle the turret should use by default or face the target.
    • Turret.BodyFoundation controls whether the unit's turret will rotate in the direction of body rotation.
    • Turret.BodyOrientation controls whether the body needs to aim at the target when firing.
    • Turret.BodyOrientationAngle defines the additional rotation angle of the body when aiming at the target. The positive number is clockwise and the negative number is counterclockwise, that is, what angle the body should use to face the target.
    • Turret.BodyOrientationSymmetric controls whether both sides of the additional body rotation angle can be used.

In rulesmd.ini:

[General]
ExpandTurretRotation=false            ; boolean

[AudioVisual]
Turret.IdleRotate=false               ; boolean
Turret.PointToMouse=false             ; boolean
Turret.BodyFoundation=false           ; boolean
Turret.IdleRestartMin=150             ; integer, number of frames
Turret.IdleRestartMax=300             ; integer, number of frames
Turret.IdleIntervalMin=150            ; integer, number of frames
Turret.IdleIntervalMax=450            ; integer, number of frames

[SOMEUNIT]                            ; VehicleType, `Turret=yes`
Turret.IdleRotate=                    ; boolean
Turret.PointToMouse=                  ; boolean
Turret.Restriction=180.0              ; floating point value
Turret.ExtraAngle=0                   ; floating point value
Turret.BodyFoundation=                ; boolean
Turret.BodyOrientation=false          ; boolean
Turret.BodyOrientationAngle=0         ; floating point value
Turret.BodyOrientationSymmetric=true  ; boolean

Update for #1308 .

CrimRecya avatar Dec 28 '24 09:12 CrimRecya

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

github-actions[bot] avatar Dec 28 '24 09:12 github-actions[bot]

Would it be easy to also make it so that rotating the turret is done relative to the body rotation? Right now it is possible to order the unit to move right behind it, and the turret turns in one direction, while the body turns in another direction, which is completely unrealistic.

Also, it doesn't make a lot of sense for the turret to not be affected by body rotation. In #352 I found that if I make the attached unit ignore the movement order -- its turret just faces in fthe orward direction, which is alright, but when the attached unit is turned - the turret lags behind a frame or a few because there's no dependency between body orientation and turret orientation, and it didn't turn with the body automatically.

This will also allow for some interesting gameplay things like not allowing to fire when rotating the body if you set TurretROT to a value that can't compensate for ROT quickly enough, like older WW2 tanks which didn't have good stabilization

Metadorius avatar Feb 21 '25 02:02 Metadorius

Would it be easy to also make it so that rotating the turret is done relative to the body rotation? Right now it is possible to order the unit to move right behind it, and the turret turns in one direction, while the body turns in another direction, which is completely unrealistic.

Are you referring to allowing the rotation of the turret to overlap with the rotation of the vehicle body (when the vehicle body rotates by one angle, the turret can rotate its own angle plus the angle of the vehicle body)? I have indeed considered this before, but currently my thinking is limited. Apart from constantly forcibly resetting the orientation and allowing it to continue rotating, I haven't come up with any particularly good methods yet.

Also, it doesn't make a lot of sense for the turret to not be affected by body rotation. In #352 I found that if I make the attached unit ignore the movement order -- its turret just faces in fthe orward direction, which is alright, but when the attached unit is turned - the turret lags behind a frame or a few because there's no dependency between body orientation and turret orientation, and it didn't turn with the body automatically.

At present, a delay of 1 frame can also be observed on ordinary units, and I am not sure if it is due to the update order at the moment. I'll mark it first so that I can make modifications when I have time later.

This will also allow for some interesting gameplay things like not allowing to fire when rotating the body if you set TurretROT to a value that can't compensate for ROT quickly enough, like older WW2 tanks which didn't have good stabilization

lol

CrimRecya avatar Feb 21 '25 06:02 CrimRecya

Are you referring to allowing the rotation of the turret to overlap with the rotation of the vehicle body (when the vehicle body rotates by one angle, the turret can rotate its own angle plus the angle of the vehicle body)? I have indeed considered this before, but currently my thinking is limited. Apart from constantly forcibly resetting the orientation and allowing it to continue rotating, I haven't come up with any particularly good methods yet.

It's not necessary to include this in the PR, I think it's fine as is and can be left for a further PR.

Metadorius avatar Feb 24 '25 15:02 Metadorius