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 Engrave trajectory #1293

Open
wants to merge 85 commits into
base: develop
Choose a base branch
from

Conversation

CrimRecya
Copy link
Contributor

@CrimRecya CrimRecya commented Jun 25, 2024

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

  • Visually, like the thermal lance. Calling it 'trajectory' may not be appropriate. It does not read the settings on the weapon.
    • Trajectory.Straight.ApplyRangeModifiers controls whether any applicable weapon range modifiers from the firer are applied to the engrave process.
    • Trajectory.Engrave.SourceCoord controls the starting point of engraving line segment. Taking the target as the coordinate center. Specifically, it will start from the firing position when set to 0,0 . The height of the point will always at ground level.
    • Trajectory.Engrave.TargetCoord controls the end point of engraving line segment. Taking the target as the coordinate center. The height of the point will always at ground level.
      • Trajectory.Engrave.MirrorCoord controls whether Trajectory.Engrave.SourceCoord and Trajectory.Engrave.TargetCoord need to mirror the lateral value to adapt to the current FLH.
    • Trajectory.Engrave.UseDisperseCoord controls whether the emission position of the engrave laser need to replaced with the FLH of its superior's dispersed trajectory, which set Trajectory.Disperse.RecordSourceCoord to true.
    • Trajectory.Engrave.TheDuration controls the duration of the entire engrave process. Set to 0 will automatically use Trajectory.Engrave.SourceCoord and Trajectory.Engrave.TargetCoord to calculate the process duration.
    • Trajectory.Engrave.IsLaser controls whether laser drawing is required.
      • Trajectory.Engrave.IsSupported controls whether the engrave laser will be brighter and thicker. Need to set Trajectory.Engrave.IsHouseColor or Trajectory.Engrave.IsSingleColor to true.
      • Trajectory.Engrave.IsHouseColor controls whether set the engrave laser to draw using player's team color. These lasers respect Trajectory.Engrave.LaserThickness and Trajectory.Engrave.IsSupported.
      • Trajectory.Engrave.IsSingleColor controls whether set the engrave laser to draw using only Trajectory.Engrave.LaserInnerColor. These lasers respect Trajectory.Engrave.LaserThickness and Trajectory.Engrave.IsSupported.
      • Trajectory.Engrave.LaserInnerColor controls the inner color of the engrave laser.
      • Trajectory.Engrave.LaserOuterColor controls the outer color of the engrave laser.
      • Trajectory.Engrave.LaserOuterSpread controls the spread color of the engrave laser.
      • Trajectory.Engrave.LaserThickness controls the thickness of the engrave laser. Need to set Trajectory.Engrave.IsHouseColor or Trajectory.Engrave.IsSingleColor to true.
      • Trajectory.Engrave.LaserDuration controls the duration of the engrave laser.
      • Trajectory.Engrave.LaserDelay controls how often to draw the engrave laser.
    • Trajectory.Engrave.DamageDelay controls how often to detonate warheads.
    • Trajectory.Engrave.ProximityImpact controls the initial proximity fuse times. When there are enough remaining times and the projectile approaches another valid target, it will detonate a warhead defined by Trajectory.Engrave.ProximityWarhead on it. If the number of times is exhausted, the engraving process can still continue, but it will not detonate additional warhead as a result. This function can be cancelled by setting to 0. A negative integer means unlimited times. (You can use this to cause non repeated damage to all units encountered during the flight of the projectile.)
      • Trajectory.Engrave.ProximityWarhead defines the warhead detonated by Trajectory.Engrave.ProximityImpact, and Trajectory.Engrave.ProximityDamage defines the damage caused by Trajectory.Engrave.ProximityWarhead.
      • Trajectory.Engrave.ProximityRadius controls the range of proximity fuse. It can NOT be set as a negative integer.
      • Trajectory.Engrave.ProximityDirect controls whether let the target receive damage instead of detonating the warhead.
      • Trajectory.Engrave.ProximityMedial controls whether to detonate Trajectory.Engrave.ProximityWarhead at the bullet's location rather than the proximity target's location.
      • Trajectory.Engrave.ProximityAllies controls whether allies will also trigger the proximity fuse.
      • Trajectory.Engrave.ProximitySuicide controls whether the projectile will self destruct after the number of proximity fuse times has been exhausted. If Trajectory.Engrave.ProximityImpact set to 0, this will not be enabled.

In rulesmd.ini:

Trajectory=Engrave                             ; Trajectory type
Trajectory.Engrave.ApplyRangeModifiers=false   ; boolean
Trajectory.Engrave.SourceCoord=0,0             ; integer - Forward,Lateral
Trajectory.Engrave.TargetCoord=0,0             ; integer - Forward,Lateral
Trajectory.Engrave.MirrorCoord=true            ; boolean
Trajectory.Engrave.UseDisperseCoord=false      ; boolean
Trajectory.Engrave.TheDuration=0               ; integer
Trajectory.Engrave.IsLaser=true                ; boolean
Trajectory.Engrave.IsSupported=false           ; boolean
Trajectory.Engrave.IsHouseColor=false          ; boolean
Trajectory.Engrave.IsSingleColor=false         ; boolean
Trajectory.Engrave.LaserInnerColor=0,0,0       ; integer - Red,Green,Blue
Trajectory.Engrave.LaserOuterColor=0,0,0       ; integer - Red,Green,Blue
Trajectory.Engrave.LaserOuterSpread=0,0,0      ; integer - Red,Green,Blue
Trajectory.Engrave.LaserThickness=3            ; integer
Trajectory.Engrave.LaserDuration=1             ; integer
Trajectory.Engrave.LaserDelay=1                ; integer
Trajectory.Engrave.DamageDelay=2               ; integer
Trajectory.Engrave.ProximityImpact=0           ; integer
Trajectory.Engrave.ProximityWarhead=           ; WarheadType
Trajectory.Engrave.ProximityDamage=0           ; integer
Trajectory.Engrave.ProximityRadius=0.7         ; floating point value
Trajectory.Engrave.ProximityDirect=false       ; boolean
Trajectory.Engrave.ProximityMedial=false       ; boolean
Trajectory.Engrave.ProximityAllies=false       ; boolean
Trajectory.Engrave.ProximitySuicide=false      ; boolean
- It's best not to let it be intercepted.

Copy link

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.

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]>
Copy link
Contributor

@Coronia Coronia left a comment

Choose a reason for hiding this comment

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

I can't tell if it's 100% correct, so I could only point out some minor problems for now. Hope others could take a look at it as well

const auto checkDifference = this->GetFloorCoordHeight(pBullet, futureCoords) - futureCoords.Z;

// When crossing the cliff, directly move the position of the bullet, otherwise change the vertical velocity
if (std::abs(checkDifference) >= 384)
Copy link
Contributor

Choose a reason for hiding this comment

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

need comment on these magic number to explain what they're for

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A number slightly lower than the cliff height difference, simply because it is 256+128. I also use it in Straight.

casualtyChecked.reserve(std::max(validTechnos.size(), this->TheCasualty.size()));

if (const auto pFirer = pBullet->Owner)
this->TheCasualty[pFirer->UniqueID] = 20;
Copy link
Contributor

Choose a reason for hiding this comment

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

magic number again

Copy link
Contributor Author

@CrimRecya CrimRecya Feb 11, 2025

Choose a reason for hiding this comment

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

Record all encountered targets in 20 frames, and if they are not encountered again during this period, they will be removed from the record.

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 <[email protected]>
@mevitar
Copy link

mevitar commented Feb 18, 2025

Engrave doesn't work in the newest build anymore. Was something changed, or is this just github nonsense?

Coronia and others added 2 commits February 19, 2025 16:40
…e on uncrushable unit (Phobos-developers#1529)

- Fix an issue where a unit will leave an impassable invisible barrier
in its original position when it is teleported by ChronoSphere onto an
uncrushable unit and self destruct.

Thx to @NetsuNegi .
@CrimRecya
Copy link
Contributor Author

Engrave doesn't work in the newest build anymore. Was something changed, or is this just github nonsense?

There have only been some minor fixes recently.

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