Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[General Purpose] New Parabola trajectory #1374

Merged

Conversation

CrimRecya
Copy link
Contributor

@CrimRecya CrimRecya commented Sep 4, 2024

  • As the name says, this is a completely reset Arcing with different enhanced functions. Without doubt, It supported linkage with Trajectory=Disperse.
    • Trajectory.Parabola.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.
    • Trajectory.Parabola.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.Parabola.OpenFireMode controls how should the projectile be launched. This has the following 6 modes.
      • Speed - Automatic calculation mode with fixed horizontal velocity, using Trajectory.Speed and target coordinates as calculation conditions, i.e. the flight time of the projectile is permanently fixed.
      • Height - Automatic calculation mode with fixed maximum height, useing Trajectory.Parabola.ThrowHeight and target coordinates as calculation conditions, i.e. the detonation time of the projectile is relatively fixed.
      • Angle - Automatic calculation mode with fixed fire angle, useing Trajectory.Parabola.LaunchAngle and target coordinates as calculation conditions. In this mode, the performance consumption is high, and may have no solution. It is not recommended to enable SubjectToCliffs or enable AA with a smaller MinimumRange when using this mode.
      • SpeedAndHeight - Fixed horizontal velocity and maximum height mode, using Trajectory.Speed and Trajectory.Parabola.ThrowHeight as calculation conditions, i.e. the trajectory will only undergo altitude changes with the height of the target.
      • HeightAndAngle - Fixed maximum height and fire angle mode, using Trajectory.Parabola.ThrowHeight and Trajectory.Parabola.LaunchAngle as calculation conditions, i.e. the trajectory will change horizontally with the height of the target.
      • SpeedAndAngle - Fixed horizontal velocity and fire angle mode, using Trajectory.Speed and Trajectory.Parabola.LaunchAngle as calculation conditions, i.e. the trajectory will be permanently fixed.
    • Trajectory.Parabola.ThrowHeight controls the maximum height of the projectile and is only used for modes 1, 3, or 4. The specific height will be determined by taking the larger of the launch height and the target height then increasing this value. Non positive numbers are not supported.
    • Trajectory.Parabola.LaunchAngle controls the fire angle of the projectile and is only used for modes 2, 4, or 5. Only supports -90.0 ~ 90.0 (Cannot use boundary values) in Mode 2 or 5, and 0.0 ~ 90.0 (Cannot use boundary values) in Mode 4.
    • Trajectory.Parabola.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.
    • Trajectory.Parabola.DetonationAngle controls when the angle between the projectile in the current velocity direction and the horizontal plane is less than this value, it will detonate prematurely. Taking effect when the value is at -90.0 ~ 90.0 (Cannot use boundary values).
    • Trajectory.Parabola.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.
    • Trajectory.Parabola.BounceTimes controls how many times can it bounce back when the projectile hits the ground or cliff. Be aware that excessive projectile speed may cause abnormal operation. And Trajectory.Parabola.DetonationDistance do not conflict with this and will take effect simultaneously. So if you want to explode the bullet only after the times of bounces is exhausted, you should set Trajectory.Parabola.DetonationDistance to a non positive value.
      • Trajectory.Parabola.BounceOnWater controls whether it can bounce on the water surface.
      • Trajectory.Parabola.BounceDetonate controls whether it detonates the warhead once extra during each bounce.
      • Trajectory.Parabola.BounceAttenuation controls the attenuation coefficient of projectile bounce damage, that is, how many times the next damage after each bounce is the damage just caused. This will also affect the damage of the final detonation.
      • Trajectory.Parabola.BounceCoefficient controls the attenuation coefficient of projectile bounce elasticity, that is, how many times the speed after each bounce is the speed before bouncing.
    • Trajectory.Parabola.OffsetCoord controls the offsets of the target. Projectile will aim at this position to attack. It also supports Inaccurate=yes and Trajectory.Parabola.LeadTimeCalculate=true on this basis.
      • Trajectory.Parabola.RotateCoord controls whether to rotate the projectile's firing direction within the angle bisector of Trajectory.Parabola.OffsetCoord according to the weapon's Burst. Set to 0 to disable this function.
      • Trajectory.Parabola.MirrorCoord controls whether Trajectory.Parabola.OffsetCoord need to mirror the lateral value to adapt to the current burst index. At the same time, the rotation direction calculated by Trajectory.Parabola.RotateCoord will also be reversed, and the rotation angle between each adjacent projectile on each side will not change as a result.
      • Trajectory.Parabola.UseDisperseBurst controls whether the calculation of Trajectory.Parabola.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.Parabola.AxisOfRotation controls the rotation axis when calculating Trajectory.Parabola.RotateCoord. The axis will rotates with the unit orientation or the vector that from target position to the source position.

In rulesmd.ini:

Trajectory=Parabola                             ; Trajectory type
Trajectory.Parabola.DetonationDistance=0.4      ; floating point value
Trajectory.Parabola.TargetSnapDistance=0.5      ; floating point value
Trajectory.Parabola.OpenFireMode=speed          ; ParabolaFireMode value enumeration (speed|height|angle|speedandheight|heightandangle|speedandangle)
Trajectory.Parabola.ThrowHeight=600             ; integer
Trajectory.Parabola.LaunchAngle=30              ; floating point value
Trajectory.Parabola.LeadTimeCalculate=no        ; boolean
Trajectory.Parabola.DetonationAngle=-90.0       ; floating point value
Trajectory.Parabola.DetonationHeight=-1         ; integer
Trajectory.Parabola.BounceTimes=0               ; integer
Trajectory.Parabola.BounceOnWater=no            ; boolean
Trajectory.Parabola.BounceDetonate=no           ; boolean
Trajectory.Parabola.BounceAttenuation=0.8       ; floating point value
Trajectory.Parabola.BounceCoefficient=0.8       ; floating point value
Trajectory.Parabola.OffsetCoord=0,0,0           ; integer - Forward,Lateral,Height
Trajectory.Parabola.RotateCoord=0               ; floating point value
Trajectory.Parabola.MirrorCoord=yes             ; boolean
Trajectory.Parabola.UseDisperseBurst=no         ; boolean
Trajectory.Parabola.AxisOfRotation=0,0,1        ; integer - Forward,Lateral,Height
- Compared to vanilla `Arcing`, this can also be used for aircrafts and airburst weapon.
- Certainly, `Gravity` can also affect the trajectory.

What is Trajectory=Disperse -> #1295

Trajectory=Disperse + Trajectory=Parabola
parabola
bounce

Copy link

github-actions bot commented Sep 4, 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
Contributor

@secsome secsome left a comment

Choose a reason for hiding this comment

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

Looks good in general, but additional code comments are needed. The mode related code can be considered for switching to enums

docs/New-or-Enhanced-Logics.md Show resolved Hide resolved
docs/New-or-Enhanced-Logics.md Show resolved Hide resolved
src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@secsome secsome left a comment

Choose a reason for hiding this comment

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

Just fix the document.

docs/New-or-Enhanced-Logics.md Outdated Show resolved Hide resolved
Copy link
Contributor

@secsome secsome left a comment

Choose a reason for hiding this comment

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

LGTM

@secsome
Copy link
Contributor

secsome commented Sep 18, 2024

Resolve the conflict and we can merge it

Copy link
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.

not quite related with the pr itself, 2 general questions for the maintainers

src/Ext/Bullet/Trajectories/ParabolaTrajectory.cpp Outdated Show resolved Hide resolved
src/Utilities/TemplateDef.h Outdated Show resolved Hide resolved
@CrimRecya CrimRecya changed the title New Parabola trajectory [General Purpose] New Parabola trajectory Dec 26, 2024
@CrimRecya CrimRecya merged commit 5d80ad7 into Phobos-developers:develop Feb 9, 2025
6 checks passed
CrimRecya added a commit that referenced this pull request Feb 9, 2025
This is a sequel of
#1246, which makes use
of logic and tag standard from the other trajectory pull requests
(#1293,
#1294,
#1295 and
#1374), and also
utilizes the generic random anim function from
(#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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants