Skip to content

[General Purpose] New Disperse trajectory#1295

Closed
CrimRecya wants to merge 116 commits intoPhobos-developers:developfrom
CrimRecya:develop-trajectory-disperse
Closed

[General Purpose] New Disperse trajectory#1295
CrimRecya wants to merge 116 commits intoPhobos-developers:developfrom
CrimRecya:develop-trajectory-disperse

Conversation

@CrimRecya
Copy link
Copy Markdown
Contributor

@CrimRecya CrimRecya commented Jun 25, 2024

This is a feature split from #1261 .
It may have similarities with other parts.

  • Its trajectory looks a bit like a ROT, but its settings are more flexible. It also has a unique trajectory. And as its name suggests, it can even spread out more weapons.
    • Trajectory.Disperse.UniqueCurve controls whether to enable simulated Qian Xuesen trajectory. After enabling this, it will NOT respect the following 21 items and Trajectory.Speed.
    • Trajectory.Disperse.PreAimCoord controls the initial flight direction of the projectile, and after reaching this coordinate, it will begin to turn towards the target direction. When it is set to 0,0,0 , it will directly face the target.
      • Trajectory.Disperse.RotateCoord controls whether to rotate the projectile's firing direction within the angle bisector of Trajectory.Disperse.PreAimCoord according to the weapon's Burst. Set to 0 to disable this function.
      • Trajectory.Disperse.MirrorCoord controls whether Trajectory.Disperse.PreAimCoord need to mirror the lateral value to adapt to the current burst index. At the same time, the rotation direction calculated by Trajectory.Disperse.RotateCoord will also be reversed, and the rotation angle between each adjacent projectile on each side will not change as a result.
      • Trajectory.Disperse.FacingCoord controls whether the forward direction in Trajectory.Disperse.PreAimCoord is depending on the orientation of the firer. By default, it will depend on the vector between the firer and the target.
      • Trajectory.Disperse.ReduceCoord controls whether Trajectory.Disperse.PreAimCoord defines the initial movement coordinates when the attack distance is 10 cells, and the actual initial movement coordinates will change with the length of the attack distance. It can be simply understood as an optimization term aimed at ensuring hits at close range.
      • Trajectory.Disperse.UseDisperseBurst controls whether the calculation of Trajectory.Disperse.RotateCoord is based on its superior's Trajectory.Disperse.WeaponBurst of the dispersed trajectory, rather than Burst of the weapon. If this value is not appropriate, it will result in unsatisfactory visual displays.
      • Trajectory.Disperse.AxisOfRotation controls the rotation axis when calculating Trajectory.Disperse.RotateCoord. The axis will rotates with the unit orientation or the vector that from target position to the source position.
    • Trajectory.Disperse.LaunchSpeed controls the initial flight speed of the projectile.
    • Trajectory.Disperse.Acceleration controls the acceleration of the projectile's flight speed, increasing or decreasing the speed per frame according to this value, the final speed will be Trajectory.Speed.
    • Trajectory.Disperse.ROT controls the turning speed of the projectile which refers to the maximum angle that the projectile can rotate per frame in terms of direction.
    • Trajectory.Disperse.LockDirection controls whether after reaching Trajectory.Disperse.PreAimCoord and completing the first turn, the projectile will lock the direction of motion without further adjustment.
    • Trajectory.Disperse.CruiseEnable controls whether after reaching Trajectory.Disperse.PreAimCoord and completing the first turn, the projectile will maintain altitude while moving towards the target.
      • Trajectory.Disperse.CruiseUnableRange controls how far away it is from the target to end the cruise phase, no longer maintaining the cruise altitude, and begins to move directly towards the target. If the distance is already below this value by the time Trajectory.Disperse.PreAimCoord is reached, the cruise phase will be skipped.
      • Trajectory.Disperse.CruiseAltitude controls the minimum altitude of the projectile in the cruise phase.
      • Trajectory.Disperse.CruiseAlongLevel controls whether to calculate Trajectory.Disperse.CruiseAltitude by the height of the projectile and the ground height of the current position, otherwise it will be calculated by the height of the projectile and the height of the launch position.
    • Trajectory.Disperse.LeadTimeCalculate controls whether the projectile need to calculate the lead time of the target during motion.
    • Trajectory.Disperse.RecordSourceCoord controls whether the projectile needs to record the launch position, which will be used for the weapons in Trajectory.Disperse.Weapons. It can be nested and inherited when both sides set this to true.
    • Trajectory.Disperse.RetargetAllies controls whether the projectile chooses allies as its target when searching for new targets after losing its original target.
    • Trajectory.Disperse.RetargetRadius controls the radius of the projectile to search for a new target after losing its original target. If it hasn't arrived Trajectory.Disperse.PreAimCoord yet, the last coordinate of the original target is taken as the center of the searching circle. Otherwise, the coordinate of the distance in front of the projectile is taken as the center of the circle. Set to 0 indicates that this function is not enabled, and it will still attempt to attack the original target's location. If it is set to a negative value, it will directly self explode in place.
    • Trajectory.Disperse.TargetSnapDistance controls the maximum distance in cells from intended target the projectile can be at moment of detonation to make the projectile 'snap' on the intended target. Set to 0 to disable snapping.
    • Trajectory.Disperse.SuicideAboveRange controls the projectile to self destruct directly after reaching the flight distance. Set to 0 to disable suicide. When set to a negative number, its absolute value represents a multiple of the initial distance.
    • Trajectory.Disperse.SuicideShortOfROT controls whether the projectile will explode when it detected its insufficient turning ability.
    • Trajectory.Disperse.SuicideIfNoWeapon controls whether the projectile will self destruct after the number of times it spreads the weapon has been exhausted. If Trajectory.Disperse.WeaponCount set to 0, this will not be enabled.
    • Trajectory.Disperse.Weapons defines the dispersal weapons of the projectile.
      • Trajectory.Disperse.WeaponBurst defines how many corresponding weapons each time the projectile will fire. When the quantity is lower than Trajectory.Disperse.Weapons, it will use the last value.
      • Trajectory.Disperse.WeaponCount controls how many times the projectile can spread the weapon. Set to a negative value means unlimited times.
      • Trajectory.Disperse.WeaponDelay controls the delay for dispersing the weapons defined by Trajectory.Disperse.Weapons.
      • Trajectory.Disperse.WeaponInitialDelay controls the initial delay for dispersing the weapons defined by Trajectory.Disperse.Weapons.
      • Trajectory.Disperse.WeaponEffectiveRange controls the weapon dispersing timer to start counting only within this distance of reaching the target. Set to 0 to disable this function. Set to a negative value means it will only disperse the weapon at most once before detonation.
      • Trajectory.Disperse.WeaponSeparate controls whether the projectile no longer fire all the weapons in Trajectory.Disperse.Weapons at once and instead fire a group of weapons in the list order, following Trajectory.Disperse.WeaponBurst.
      • Trajectory.Disperse.WeaponRetarget controls whether the dispersed weapons will find new targets on their own. Using the Range, CanTarget, required AttachedEffects of weapons to search new targets.
      • Trajectory.Disperse.WeaponLocation controls whether the dispersed weapons will search for new targets at the center of the spreading position, otherwise they will focus on the original target.
      • Trajectory.Disperse.WeaponTendency controls whether the dispersed weapons will choose the original target as the first new target in each group of weapons.
      • Trajectory.Disperse.WeaponHolistic controls whether the dispersed weapons will choose targets that are in different states from the original target (in air and on ground).
      • Trajectory.Disperse.WeaponMarginal controls whether the dispersed weapons will choose unimportant items such as trees and streetlights as secondary targets.
      • Trajectory.Disperse.WeaponToAllies controls whether the dispersed weapons will choose allies as targets when searching for new targets.
      • Trajectory.Disperse.WeaponDoRepeat controls whether the dispersed weapons will select duplicate targets when the number of targets is insufficient. If it is set to true and the weapon can select both the technos and the ground as targets, the technos will be prioritized, then if all non-repeating technos have been selected and the weapon can still be launched at this time (in each round of salvo), it will start selecting duplicate technos. If it is set to false and the weapon can select both the technos and the ground as targets, the technos will be prioritized, followed by the ground cells, then if all non-repeating technos have been selected and the weapon can still be launched at this time (in each round of salvo), it will stop firing remaining bursts.

In rulesmd.ini:

[SOMEPROJECTILE]                                ; Projectile
Trajectory=Disperse                             ; Trajectory type
Trajectory.Disperse.UniqueCurve=false           ; boolean
Trajectory.Disperse.PreAimCoord=0,0,0           ; integer - Forward,Lateral,Height
Trajectory.Disperse.RotateCoord=0               ; floating point value
Trajectory.Disperse.MirrorCoord=true            ; boolean
Trajectory.Disperse.FacingCoord=false           ; boolean
Trajectory.Disperse.ReduceCoord=true            ; boolean
Trajectory.Disperse.UseDisperseBurst=false      ; boolean
Trajectory.Disperse.AxisOfRotation=0,0,1        ; integer - Forward,Lateral,Height
Trajectory.Disperse.LaunchSpeed=0               ; floating point value
Trajectory.Disperse.Acceleration=10.0           ; floating point value
Trajectory.Disperse.ROT=10.0                    ; floating point value
Trajectory.Disperse.LockDirection=false         ; boolean
Trajectory.Disperse.CruiseEnable=false          ; boolean
Trajectory.Disperse.CruiseUnableRange=5         ; floating point value
Trajectory.Disperse.CruiseAltitude=800          ; integer
Trajectory.Disperse.CruiseAlongLevel=false      ; boolean
Trajectory.Disperse.LeadTimeCalculate=true      ; boolean
Trajectory.Disperse.RecordSourceCoord=false     ; boolean
Trajectory.Disperse.RetargetAllies=false        ; boolean
Trajectory.Disperse.RetargetRadius=0            ; floating point value
Trajectory.Disperse.TargetSnapDistance=0.5      ; floating point value
Trajectory.Disperse.SuicideAboveRange=-3.0      ; floating point value
Trajectory.Disperse.SuicideShortOfROT=false     ; boolean
Trajectory.Disperse.SuicideIfNoWeapon=true      ; boolean
Trajectory.Disperse.Weapons=                    ; list of WeaponTypes
Trajectory.Disperse.WeaponBurst=                ; list of integers
Trajectory.Disperse.WeaponCount=0               ; integer
Trajectory.Disperse.WeaponDelay=1               ; integer
Trajectory.Disperse.WeaponInitialDelay=0        ; integer
Trajectory.Disperse.WeaponEffectiveRange=0      ; floating point value
Trajectory.Disperse.WeaponSeparate=false        ; boolean
Trajectory.Disperse.WeaponRetarget=false        ; boolean
Trajectory.Disperse.WeaponLocation=false        ; boolean
Trajectory.Disperse.WeaponTendency=false        ; boolean
Trajectory.Disperse.WeaponHolistic=false        ; boolean
Trajectory.Disperse.WeaponMarginal=false        ; boolean
Trajectory.Disperse.WeaponToAllies=false        ; boolean
Trajectory.Disperse.WeaponDoRepeat=false        ; boolean
- Make sure you set a low `Trajectory.Disperse.RetargetRadius` value unless necessary. If you set `Trajectory.Disperse.WeaponRetarget=true`, also make sure you set `Trajectory.Disperse.Weapons` a low `Range` value unless necessary.
- This does not properly support `Arcing=true` projectiles.
- Note that the listed Weapons in `Trajectory.Disperse.Weapons` must be listed in `[WeaponTypes]` for them to work.
- `Trajectory.Disperse.Weapons` now not support customized `Bolt.ColorN`.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 7, 2024

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.

Copy link
Copy Markdown
Contributor

@chaserli chaserli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is fully decoupled and can/should go first among all these 3 new trajectories. I might have a few concerns about potential overhead in BulletRetargetTechno but it should be fine in game.

Comment thread src/Ext/Bullet/Trajectories/DisperseTrajectory.cpp Outdated
Comment thread src/Ext/Bullet/Trajectories/DisperseTrajectory.cpp Outdated
Comment thread src/Ext/Bullet/Trajectories/DisperseTrajectory.cpp Outdated
FS-21 pushed a commit to FS-21/Phobos that referenced this pull request Feb 18, 2025
This is a sequel of
Phobos-developers#1246, which makes use
of logic and tag standard from the other trajectory pull requests
(Phobos-developers#1293,
Phobos-developers#1294,
Phobos-developers#1295 and
Phobos-developers#1374), and also
utilizes the generic random anim function from
(Phobos-developers#1380). Many thanks to
@CrimRecya for making these projectiles as well as helping with
improvement of enhanced Bombard trajectory. Also thanks **NaotoYuuki**
for providing the prototypes of vertical and meteor projectiles, which
are used as the base of these additions.

1 - Bombard Trajectory now support `Inaccurate=true,
BallisticScatter.Max and BallisticScatter.Min` keys, which allows them
to scatter when picking targets.

2 - Bombard Trajectory, instead of simply flying to the top of the
target and free fall, is now extended into a series of trajectories
which flying to a 'turning point' first, and then turning to the targets
or respawning on their top. The behaviors of the projectile and the
position of the turning point could be customized by the following tags:

- `Trajectory.Bombard.Height` controls the height of the turning point.
- `Trajectory.Bombard.FallPercent` controls the distance of the turning
point by its percentage of the total distance between attacker and
intended target. If set to 0%, then it'll fly up vertically. If set to
100%, then it'll travel to the top of the intended target.
- For each launch the turning point percentage could add or minus a
random value, which is not greater than
`Trajectory.Bombard.FallPercentShift`. If set to 0%, random shift will
be disabled.
- You can also makes the turning point scatter randomly in a circle with
`Trajectory.Bombard.FallScatter.Max` as its radius. If set to 0, random
scatter will be disabled. `Trajectory.Bombard.FallScatter.Min` can be
used to determine the minimum radius of the circle. If
`Trajectory.Bombard.FallScatter.Linear` set to true, the random scatter
will be limited to the line that is vertical to the original direction
of the projectile.
- `Trajectory.Bombard.FreeFallOnTarget` controls how it'll hit the
intended target. If set to true, the projectile will be respawned above
the intended target and free fall. If set to false, the projectile will
travel to the intended target from the turning point.
- `Trajectory.Bombard.NoLaunch` controls whether the attacker will fire
the projectile by itself. If set to true, projectile will directly fall
from the turning point.
- `Trajectory.Bombard.FallSpeed` controls the initial speed of the
projectile after it turns. If set to 0.0, then it'll use
`Trajectory.Speed`. Can't work when
`Trajectory.Bombard.FreeFallOnTarget` set to true.
- `Trajectory.Bombard.DetonationDistance` controls the maximum distance
in cells from intended target (checked at start of each game frame,
before the projectile moves) at which the projectile will be forced to
detonate. Set to 0 to disable forced detonation (note that this can
cause the projectile to overshoot the target).
- `Trajectory.Bombard.DetonationHeight` controls when the projectile is
in a descending state and below the height of the launch position plus
this value, it will detonate prematurely. Taking effect when it is set
to non negative value. If `Trajectory.Bombard.EarlyDetonation` is set to
true, it'll take effect during the ascending stage instead, which makes
it detonate when its height is above the launch position plus this
value.
- `Trajectory.Bombard.TargetSnapDistance` controls the maximum distance
in cells from intended target the projectile can be at moment of
detonation to make the projectile 'snap' on the intended target. Set to
0 to disable snapping.
- `Trajectory.Bombard.TurningPointAnims`, if set, will play an anim when
the projectile reaches the turning point. If
`Trajectory.Bombard.FreeFallOnTarget` is set to true, it'll be spawned
above the target with the projectile together. If
`Trajectory.Bombard.NoLaunch` is set to true, it'll be played at where
the projectile falls, no matter if it's free fall or not. If more than
one animation is listed, a random one is selected.
- `Trajectory.Bombard.LeadTimeCalculate` controls whether the projectile
need to calculate the lead time of the target when firing. Note that
this will not affect the facing of the turret.
- The following tags further customize the projectile's descending
behaviors when `Trajectory.Bombard.FreeFallOnTarget` set to false.
- `Trajectory.Bombard.OffsetCoord` controls the offsets of the target.
Projectile will aim at this position to attack. It also supports
`Inaccurate=yes` and `Trajectory.Bombard.LeadTimeCalculate=true` on this
basis.
- `Trajectory.Bombard.RotateCoord` controls whether to rotate the
projectile's firing direction within the angle bisector of
`Trajectory.Bombard.OffsetCoord` according to the weapon's `Burst`. Set
to 0 to disable this function.
- `Trajectory.Bombard.MirrorCoord` controls whether
`Trajectory.Bombard.OffsetCoord` need to mirror the lateral value to
adapt to the current burst index. At the same time, the rotation
direction calculated by `Trajectory.Bombard.RotateCoord` will also be
reversed, and the rotation angle between each adjacent projectile on
each side will not change as a result.
- `Trajectory.Bombard.UseDisperseBurst` controls whether the calculation
of `Trajectory.Bombard.RotateCoord` is based on its superior's
`Trajectory.Disperse.WeaponBurst` of the dispersed trajectory, rather
than `Burst` of the weapon. If this value is not appropriate, it will
result in unsatisfactory visual displays.
- `Trajectory.Bombard.AxisOfRotation` controls the rotation axis when
calculating `Trajectory.Bombard.RotateCoord`. The axis will rotates with
the unit orientation or the vector that from target position to the
source position.
- `Trajectory.Bombard.SubjectToGround` controls whether the projectile
should explode when it hits the ground. Note that this will not make AI
search for suitable attack locations.

In `rulesmd.ini`:
```ini
[SOMEPROJECTILE]                              ; Projectile
Trajectory=Bombard                            ; Trajectory type
Trajectory.Bombard.Height=0.0                 ; double
Trajectory.Bombard.FallPercent=1.0            ; double
Trajectory.Bombard.FallPercentShift=0.0       ; double
Trajectory.Bombard.FallScatter.Max=0.0        ; floating point value
Trajectory.Bombard.FallScatter.Min=0.0        ; floating point value
Trajectory.Bombard.FallScatter.Linear=false   ; boolean
Trajectory.Bombard.FreeFallOnTarget=true      ; boolean
Trajectory.Bombard.NoLaunch=false             ; boolean
Trajectory.Bombard.FallSpeed=0.0              ; double
Trajectory.Bombard.DetonationDistance=0.4     ; floating point value
Trajectory.Bombard.DetonationHeight=-1        ; integer
Trajectory.Bombard.EarlyDetonation=false      ; boolean
Trajectory.Bombard.TargetSnapDistance=0.5     ; floating point value
Trajectory.Bombard.TurningPointAnims=         ; list of Animation
Trajectory.Bombard.LeadTimeCalculate=false    ; boolean
Trajectory.Bombard.OffsetCoord=0,0,0          ; integer - Forward,Lateral,Height
Trajectory.Bombard.RotateCoord=0              ; floating point value
Trajectory.Bombard.MirrorCoord=true           ; boolean
Trajectory.Bombard.UseDisperseBurst=false     ; boolean
Trajectory.Bombard.AxisOfRotation=0,0,1       ; integer - Forward,Lateral,Height
Trajectory.Bombard.SubjectToGround=false      ; boolean
```

If all values are set to default, it'll perform as the old Bombard
Trajectory.

**NOTE:** Both the old and new Bombard trajectories might trigger a
fatal error when firing a Voxel=true projectile (EIP: 007564B4), which
is unresolved yet. Avoid using it for now, and if someone could make it
work I'll be really grateful.

---------

Co-authored-by: CrimRecya <335958461@qq.com>
@CrimRecya CrimRecya added On Hold Due to some reasons, it cannot be completed temporarily Needs splitting The PR should be splitted into several separate standalone commits labels Mar 7, 2025
@CrimRecya
Copy link
Copy Markdown
Contributor Author

Has been completely rewrited.

@CrimRecya CrimRecya closed this Mar 18, 2025
@CrimRecya CrimRecya deleted the develop-trajectory-disperse branch April 1, 2025 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs splitting The PR should be splitted into several separate standalone commits On Hold Due to some reasons, it cannot be completed temporarily Tested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants