Skip to content

Commit 521605c

Browse files
CoroniaCrimRecya
andauthored
Enhanced Bombard trajectory (#1404)
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 <335958461@qq.com>
1 parent fa7fc05 commit 521605c

File tree

9 files changed

+703
-40
lines changed

9 files changed

+703
-40
lines changed

CREDITS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,15 @@ This page lists all the individual contributions to the project by their author.
385385
- Enable Building Production Queue
386386
- Fix for sidebar not updating queued unit numbers when on hold
387387
- New Parabola trajectory
388+
- Enhanced Bombard trajectory
388389
- **Ollerus**
389390
- Build limit group enhancement
390391
- Customizable rocker amplitude
391392
- Allowed `AuxBuilding` and Ares' `SW.Aux/NegBuildings` to count building upgrades
392393
- Type select for buildings (doc)
394+
- Enhanced Bombard trajectory
395+
- **NaotoYuuki**
396+
- Vertical & meteor trajectory projectile prototypes
393397
- **handama** - AI script action to jump back to previous script
394398
- **TaranDahl (航味麻酱)**
395399
- Skirmish AI "sell all buildings and set all technos to hunt" behavior dehardcode

YRpp

docs/New-or-Enhanced-Logics.md

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -825,13 +825,52 @@ Trajectory.Straight.CountAttenuation=1.0 ; floating point value
825825

826826
#### Bombard trajectory
827827

828-
- Similar trajectory to `Straight`, but targets a coordinate above the intended target (height determined by `Trajectory.Bombard.Height`). When the projectile approaches that coordinate, it will free fall and explodes when it hits the target or ground.
829-
830-
In `rulesmd.ini`:
831-
```ini
832-
[SOMEPROJECTILE] ; Projectile
833-
Trajectory=Bombard ; Trajectory type
834-
Trajectory.Bombard.Height=0.0 ; double
828+
- Similar trajectory to `Straight`, but targets a coordinate between the attacker and intended target first. When the projectile approaches that turning point, it'll turn to the intended target and explodes when it hits the target or ground.
829+
- `Trajectory.Bombard.Height` controls the height of the turning point.
830+
- `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.
831+
- 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.
832+
- 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.
833+
- `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.
834+
- `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.
835+
- `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.
836+
- `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).
837+
- `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.
838+
- `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.
839+
- `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.
840+
- `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.
841+
- The following tags further customize the projectile's descending behaviors when `Trajectory.Bombard.FreeFallOnTarget` set to false.
842+
- `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.
843+
- `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.
844+
- `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.
845+
- `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.
846+
- `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.
847+
- `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.
848+
849+
In `rulesmd.ini`:
850+
```ini
851+
[SOMEPROJECTILE] ; Projectile
852+
Trajectory=Bombard ; Trajectory type
853+
Trajectory.Bombard.Height=0.0 ; double
854+
Trajectory.Bombard.FallPercent=1.0 ; double
855+
Trajectory.Bombard.FallPercentShift=0.0 ; double
856+
Trajectory.Bombard.FallScatter.Max=0.0 ; floating point value
857+
Trajectory.Bombard.FallScatter.Min=0.0 ; floating point value
858+
Trajectory.Bombard.FallScatter.Linear=false ; boolean
859+
Trajectory.Bombard.FreeFallOnTarget=true ; boolean
860+
Trajectory.Bombard.NoLaunch=false ; boolean
861+
Trajectory.Bombard.FallSpeed=0.0 ; double
862+
Trajectory.Bombard.DetonationDistance=0.4 ; floating point value
863+
Trajectory.Bombard.DetonationHeight=-1 ; integer
864+
Trajectory.Bombard.EarlyDetonation=false ; boolean
865+
Trajectory.Bombard.TargetSnapDistance=0.5 ; floating point value
866+
Trajectory.Bombard.TurningPointAnims= ; list of Animation
867+
Trajectory.Bombard.LeadTimeCalculate=false ; boolean
868+
Trajectory.Bombard.OffsetCoord=0,0,0 ; integer - Forward,Lateral,Height
869+
Trajectory.Bombard.RotateCoord=0 ; floating point value
870+
Trajectory.Bombard.MirrorCoord=true ; boolean
871+
Trajectory.Bombard.UseDisperseBurst=false ; boolean
872+
Trajectory.Bombard.AxisOfRotation=0,0,1 ; integer - Forward,Lateral,Height
873+
Trajectory.Bombard.SubjectToGround=false ; boolean
835874
```
836875

837876
#### Parabola trajectory

docs/Whats-New.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,16 @@ New:
322322
- New Parabola trajectory (by CrimRecya)
323323
- Type select for buildings (code by TaranDahl(航味麻酱), doc by Ollerus)
324324
- Raise alert when technos are taking damage (by TaranDahl)
325+
- Enhanced Bombard trajectory (by CrimRecya & Ollerus, based on knowledge of NaotoYuuki)
325326
326327
Vanilla fixes:
327328
- 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)
328329

329330
Phobos fixes:
330331
- Type conversion on Warheads and Superweapons will no longer recursively convert units if applicable conversion pairs are listed, and only first applicable pair takes effect (by Starkku)
332+
333+
Fixes / interactions with other extensions:
334+
- Allowed `AuxBuilding` and Ares' `SW.Aux/NegBuildings` to count building upgrades (by Ollerus)
331335
</details>
332336
333337
### 0.4
@@ -643,7 +647,6 @@ Fixes / interactions with other extensions:
643647
- Suppressed Ares' swizzle warning when parsing `Tags` and `TaskForces` (by Trsdy)
644648
- Fixed Academy *(Ares feature)* not working on the initial payloads *(Ares feature)* of vehicles built from a war factory (by Trsdy, supersedes Aephiex impl.)
645649
- Fixed Ares' InitialPayload not being created for vehicles spawned by trigger actions (by Trsdy)
646-
- Allowed `AuxBuilding` and Ares' `SW.Aux/NegBuildings` to count building upgrades (by Ollerus)
647650
</details>
648651
649652
### 0.3.0.1

src/Ext/Anim/Body.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,40 @@ void AnimExt::SpawnFireAnims(AnimClass* pThis)
336336
}
337337
}
338338

339+
void AnimExt::CreateRandomAnim(const std::vector<AnimTypeClass*>& AnimList, CoordStruct coords, TechnoClass* pTechno, HouseClass* pHouse, bool invoker, bool ownedObject)
340+
{
341+
if (AnimList.empty())
342+
return;
343+
344+
auto const pAnimType = AnimList[ScenarioClass::Instance->Random.RandomRanged(0, AnimList.size() - 1)];
345+
346+
if (!pAnimType)
347+
return;
348+
349+
auto const pAnim = GameCreate<AnimClass>(pAnimType, coords);
350+
351+
if (!pAnim || !pTechno)
352+
return;
353+
354+
AnimExt::SetAnimOwnerHouseKind(pAnim, pHouse ? pHouse : pTechno->Owner, nullptr, false, true);
355+
356+
if (ownedObject)
357+
pAnim->SetOwnerObject(pTechno);
358+
359+
if (invoker)
360+
{
361+
auto const pAnimExt = AnimExt::ExtMap.Find(pAnim);
362+
363+
if (!pAnimExt)
364+
return;
365+
366+
if (pHouse)
367+
pAnimExt->SetInvoker(pTechno, pHouse);
368+
else
369+
pAnimExt->SetInvoker(pTechno);
370+
}
371+
}
372+
339373
// =============================
340374
// load / save
341375

src/Ext/Anim/Body.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,5 @@ class AnimExt
8383

8484
static void InvalidateTechnoPointers(TechnoClass* pTechno);
8585
static void InvalidateParticleSystemPointers(ParticleSystemClass* pParticleSystem);
86+
static void CreateRandomAnim(const std::vector<AnimTypeClass*>& AnimList, CoordStruct coords, TechnoClass* pTechno = nullptr, HouseClass* pHouse = nullptr, bool invoker = false, bool ownedObject = false);
8687
};

src/Ext/Bullet/Hooks.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ DEFINE_HOOK(0x46902C, BulletClass_Explode_Cluster, 0x6)
293293
constexpr bool CheckTrajectoryCanNotAlwaysSnap(const TrajectoryFlag flag)
294294
{
295295
return flag == TrajectoryFlag::Straight
296+
|| flag == TrajectoryFlag::Bombard
296297
|| flag == TrajectoryFlag::Parabola;
297298
}
298299

0 commit comments

Comments
 (0)