Skip to content

Commit 5d80ad7

Browse files
authored
[General Purpose] New Parabola trajectory (#1374)
- 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`: ```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 ``` ```{note} - Compared to vanilla `Arcing`, this can also be used for aircrafts and airburst weapon. - Certainly, `Gravity` can also affect the trajectory. ```
1 parent 5b2b5e0 commit 5d80ad7

File tree

9 files changed

+1356
-3
lines changed

9 files changed

+1356
-3
lines changed

CREDITS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ This page lists all the individual contributions to the project by their author.
364364
- `TurretOffset` support for SHP vehicles
365365
- Customizable rocker amplitude
366366
- Customizable wake anim
367-
- Initial effort on optimization for crates' random distribution
367+
- Initial effort on optimization for crates' random distribution
368368
- **Fryone**
369369
- Customizable ElectricBolt Arcs
370370
- Sound entry on unit's creation
@@ -384,6 +384,7 @@ This page lists all the individual contributions to the project by their author.
384384
- Enhanced Straight trajectory
385385
- Enable Building Production Queue
386386
- Fix for sidebar not updating queued unit numbers when on hold
387+
- New Parabola trajectory
387388
- **Ollerus**
388389
- Build limit group enhancement
389390
- Customizable rocker amplitude

Phobos.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<ClCompile Include="src\Ext\Bullet\Trajectories\BombardTrajectory.cpp" />
3939
<ClCompile Include="src\Ext\Bullet\Trajectories\PhobosTrajectory.cpp" />
4040
<ClCompile Include="src\Ext\Bullet\Trajectories\StraightTrajectory.cpp" />
41+
<ClCompile Include="src\Ext\Bullet\Trajectories\ParabolaTrajectory.cpp" />
4142
<ClCompile Include="src\Ext\CaptureManager\Hooks.cpp" />
4243
<ClCompile Include="src\Ext\CaptureManager\Body.cpp" />
4344
<ClCompile Include="src\Ext\OverlayType\Body.cpp" />
@@ -199,6 +200,7 @@
199200
<ClInclude Include="src\Ext\Bullet\Trajectories\BombardTrajectory.h" />
200201
<ClInclude Include="src\Ext\Bullet\Trajectories\PhobosTrajectory.h" />
201202
<ClInclude Include="src\Ext\Bullet\Trajectories\StraightTrajectory.h" />
203+
<ClInclude Include="src\Ext\Bullet\Trajectories\ParabolaTrajectory.h" />
202204
<ClInclude Include="src\Ext\OverlayType\Body.h" />
203205
<ClInclude Include="src\Ext\ParticleType\Body.h" />
204206
<ClInclude Include="src\Ext\Sidebar\Body.h" />

docs/New-or-Enhanced-Logics.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,10 @@ Currently interceptor weapons with projectiles that do not have `Inviso=true` wi
737737

738738
- Projectiles can now have customizable trajectories.
739739
- `Trajectory` should not be combined with original game's projectile trajectory logics (`Arcing`, `ROT`, `Vertical` or `Inviso`). Attempt to do so will result in the other logics being disabled and a warning being written to log file.
740-
- Initial speed of the projectile is defined by `Trajectory.Speed`, which unlike `Speed` used by `ROT` > 0 projectiles is defined on projectile not weapon.
740+
- The speed of the projectile is defined by `Trajectory.Speed`, which unlike `Speed` used by `ROT` > 0 projectiles is defined on projectile not weapon.
741+
- In `Trajectory=Straight`, it refers to the whole distance speed of the projectile and it has no restrictions.
742+
- In `Trajectory=Bombard`, it refers to the initial speed of the projectile and it has no restrictions.
743+
- In `Trajectory=Parabola`, it refers to the horizontal velocity of the projectile and is only used for modes 0, 3, or 5 and it has no restrictions.
741744

742745
In `rulesmd.ini`:
743746
```ini
@@ -831,6 +834,63 @@ Trajectory=Bombard ; Trajectory type
831834
Trajectory.Bombard.Height=0.0 ; double
832835
```
833836

837+
#### Parabola trajectory
838+
839+
- As the name says, this is a completely reset `Arcing` with different enhanced functions. Without doubt, It supported linkage with `Trajectory=Disperse`.
840+
- `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. More specifically, when it is set to a negative value, if the target is movable, it will change its target to the cell where the target is located (This is a function expanded for `Disperse` and `Airburst` purposes).
841+
- `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.
842+
- `Trajectory.Parabola.OpenFireMode` controls how should the projectile be launched. This has the following 6 modes.
843+
- 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.
844+
- 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.
845+
- 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.
846+
- 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.
847+
- 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.
848+
- 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.
849+
- `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.
850+
- `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.
851+
- `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.
852+
- `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).
853+
- `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.
854+
- `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.
855+
- `Trajectory.Parabola.BounceOnWater` controls whether it can bounce on the water surface.
856+
- `Trajectory.Parabola.BounceDetonate` controls whether it detonates the warhead once extra during each bounce.
857+
- `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.
858+
- `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.
859+
- `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.
860+
- `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.
861+
- `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.
862+
- `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.
863+
- `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.
864+
865+
In `rulesmd.ini`:
866+
```ini
867+
[SOMEPROJECTILE] ; Projectile
868+
Trajectory=Parabola ; Trajectory type
869+
Trajectory.Parabola.DetonationDistance=0.4 ; floating point value
870+
Trajectory.Parabola.TargetSnapDistance=0.5 ; floating point value
871+
Trajectory.Parabola.OpenFireMode=Speed ; ParabolaFireMode value enumeration (Speed|Height|Angle|SpeedAndHeight|HeightAndAngle|SpeedAndAngle)
872+
Trajectory.Parabola.ThrowHeight=600 ; integer
873+
Trajectory.Parabola.LaunchAngle=30 ; floating point value
874+
Trajectory.Parabola.LeadTimeCalculate=no ; boolean
875+
Trajectory.Parabola.DetonationAngle=-90.0 ; floating point value
876+
Trajectory.Parabola.DetonationHeight=-1 ; integer
877+
Trajectory.Parabola.BounceTimes=0 ; integer
878+
Trajectory.Parabola.BounceOnWater=no ; boolean
879+
Trajectory.Parabola.BounceDetonate=no ; boolean
880+
Trajectory.Parabola.BounceAttenuation=0.8 ; floating point value
881+
Trajectory.Parabola.BounceCoefficient=0.8 ; floating point value
882+
Trajectory.Parabola.OffsetCoord=0,0,0 ; integer - Forward,Lateral,Height
883+
Trajectory.Parabola.RotateCoord=0 ; floating point value
884+
Trajectory.Parabola.MirrorCoord=yes ; boolean
885+
Trajectory.Parabola.UseDisperseBurst=no ; boolean
886+
Trajectory.Parabola.AxisOfRotation=0,0,1 ; integer - Forward,Lateral,Height
887+
```
888+
889+
```{note}
890+
- Compared to vanilla `Arcing`, this can also be used for aircrafts and airburst weapon.
891+
- Certainly, `Gravity` can also affect the trajectory.
892+
```
893+
834894
### Shrapnel enhancements
835895

836896
![image](_static/images/shrapnel.gif)

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ New:
319319
- Custom exit cell for infantry factory (by Starkku)
320320
- Option for vehicles to keep target when issued move command (by Starkku)
321321
- Skip anim delay for burst fire (by TaranDahl)
322+
- New Parabola trajectory (by CrimRecya)
322323
323324
Vanilla fixes:
324325
- Aircraft will now behave as expected according to it's `MovementZone` and `SpeedType` when moving onto different surfaces. In particular, this fixes erratic behavior when vanilla aircraft is ordered to move onto water surface and instead the movement order changes to a shore nearby (by CrimRecya)

src/Ext/Bullet/Hooks.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ DEFINE_HOOK(0x46902C, BulletClass_Explode_Cluster, 0x6)
292292

293293
constexpr bool CheckTrajectoryCanNotAlwaysSnap(const TrajectoryFlag flag)
294294
{
295-
return flag == TrajectoryFlag::Straight;
295+
return flag == TrajectoryFlag::Straight
296+
|| flag == TrajectoryFlag::Parabola;
296297
}
297298

298299
DEFINE_HOOK(0x467CCA, BulletClass_AI_TargetSnapChecks, 0x6)

0 commit comments

Comments
 (0)