Skip to content

Commit

Permalink
[Vanilla Improvement] No turret unit turn to the target when rearming (
Browse files Browse the repository at this point in the history
…#1465)

- Now vehicles (exclude jumpjets) without turret will attempt to turn to
the target while the weapon is cooling down, rather than after the
weapon has cooled down, by setting to `NoTurret.TrackTarget` true.

In `rulesmd.ini`:
```ini
[General]
NoTurret.TrackTarget=false   ; boolean

[SOMEUNIT]                   ; UnitType
NoTurret.TrackTarget=        ; boolean, defaults to [General]->NoTurret.TrackTarget
```

---------

Co-authored-by: 航味麻酱 <[email protected]>
  • Loading branch information
CrimRecya and TaranDahl authored Feb 24, 2025
1 parent 72dfb77 commit c93235b
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ This page lists all the individual contributions to the project by their author.
- Fix for sidebar not updating queued unit numbers when on hold
- New Parabola trajectory
- Enhanced Bombard trajectory
- No turret unit turn to the target
- **Ollerus**
- Build limit group enhancement
- Customizable rocker amplitude
Expand All @@ -407,6 +408,7 @@ This page lists all the individual contributions to the project by their author.
- Parasite returning bug fix
- Bunkerable checks dehardcode
- Prevent the units with locomotors that cause problems from entering the tank bunker
- No turret unit turn to the target
- **tyuah8** - Drive/Jumpjet/Ship/Teleport locomotor did not power on when it is un-piggybacked bugfix
- **Aephiex** - initial fix for Ares academy not working on the initial payloads of vehicles built from a war factory
- **Multfinite** - Allow to toggle main exception handler via command line argument `-ExceptionHandler=boolean`
Expand Down
15 changes: 15 additions & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,21 @@ Ammo.AddOnDeploy=0 ; integer
Due to technical constraints, units that use `Convert.Deploy` from [Ares’ Type Conversion](https://ares-developers.github.io/Ares-docs/new/typeconversion.html) to change type with `Ammo.AddOnDeploy` will add or substract ammo despite of convertion success. This will also happen when unit exits tank bunker.
```

### Unit Without Turret Always Turn To Target

- Now vehicles (exclude jumpjets) without turret will attempt to turn to the target while the weapon is cooling down, rather than after the weapon has cooled down, by setting to `NoTurret.TrackTarget` true.

In `rulesmd.ini`:
```ini
[General]
NoTurret.TrackTarget=false ; boolean

[SOMEUNIT] ; UnitType
NoTurret.TrackTarget= ; boolean, defaults to [General]->NoTurret.TrackTarget
```{warning}
Due to technical constraints, units that use `Convert.Deploy` from [Ares’ Type Conversion](https://ares-developers.github.io/Ares-docs/new/typeconversion.html) to change type with `Ammo.AddOnDeploy` will add or substract ammo despite of convertion success. This will also happen when unit exits tank bunker.
```

## Veinholes & Weeds

### Veinholes
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ New:
- Allow infantry to use land sequences in water (by Starkku)
- `<Player @ X>` can now be used as owner for pre-placed objects on skirmish and multiplayer maps (by Starkku)
- Allow customizing charge turret delays per burst on a weapon (by Starkku)
- No turret unit turn to the target (by CrimRecya & TaranDahl)
- Unit `Speed` setting now accepts floating point values (by Starkku)
- Extending `Power` to all TechnoTypes (by Morton)

Expand Down
3 changes: 3 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)

this->UseFixedVoxelLighting.Read(exINI, GameStrings::AudioVisual, "UseFixedVoxelLighting");

this->NoTurret_TrackTarget.Read(exINI, GameStrings::General, "NoTurret.TrackTarget");

this->GatherWhenMCVDeploy.Read(exINI, GameStrings::General, "GatherWhenMCVDeploy");
this->AIFireSale.Read(exINI, GameStrings::General, "AIFireSale");
this->AIFireSaleDelay.Read(exINI, GameStrings::General, "AIFireSaleDelay");
Expand Down Expand Up @@ -415,6 +417,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->CombatAlert_UseAttackVoice)
.Process(this->CombatAlert_UseEVA)
.Process(this->UseFixedVoxelLighting)
.Process(this->NoTurret_TrackTarget)
.Process(this->GatherWhenMCVDeploy)
.Process(this->AIFireSale)
.Process(this->AIFireSaleDelay)
Expand Down
3 changes: 3 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ class RulesExt
// Nullable<Vector3D<float>> VoxelShadowLightSource;
Valueable<bool> UseFixedVoxelLighting;

Valueable<bool> NoTurret_TrackTarget;

Valueable<bool> GatherWhenMCVDeploy;
Valueable<bool> AIFireSale;
Valueable<int> AIFireSaleDelay;
Expand Down Expand Up @@ -312,6 +314,7 @@ class RulesExt
, CombatAlert_UseAttackVoice { true }
, CombatAlert_UseEVA { true }
, UseFixedVoxelLighting { false }
, NoTurret_TrackTarget { false }
, GatherWhenMCVDeploy { true }
, AIFireSale { true }
, AIFireSaleDelay { 0 }
Expand Down
23 changes: 23 additions & 0 deletions src/Ext/Techno/Hooks.Misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,29 @@ DEFINE_HOOK(0x74691D, UnitClass_UpdateDisguise_EMP, 0x6)

#pragma endregion

#pragma region NoTurretUnitAlwaysTurnToTarget

DEFINE_HOOK(0x7410BB, UnitClass_GetFireError_CheckFacingError, 0x8)
{
enum { NoNeedToCheck = 0x74132B, ContinueCheck = 0x7410C3 };

GET(const FireError, fireError, EAX);

if (fireError == FireError::OK)
return ContinueCheck;

GET(UnitClass* const, pThis, ESI);

const auto pType = pThis->Type;

if (!TechnoTypeExt::ExtMap.Find(pType)->NoTurret_TrackTarget.Get(RulesExt::Global()->NoTurret_TrackTarget))
return NoNeedToCheck;

return (fireError == FireError::REARM && !pType->Turret && !pThis->IsWarpingIn()) ? ContinueCheck : NoNeedToCheck;
}

#pragma endregion

#pragma region Misc

// I must not regroup my forces.
Expand Down
5 changes: 5 additions & 0 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->BuildLimitGroup_ExtraLimit_Nums.Read(exINI, pSection, "BuildLimitGroup.ExtraLimit.Nums");
this->BuildLimitGroup_ExtraLimit_MaxCount.Read(exINI, pSection, "BuildLimitGroup.ExtraLimit.MaxCount");
this->BuildLimitGroup_ExtraLimit_MaxNum.Read(exINI, pSection, "BuildLimitGroup.ExtraLimit.MaxNum");

this->NoTurret_TrackTarget.Read(exINI, pSection, "NoTurret.TrackTarget");

this->Wake.Read(exINI, pSection, "Wake");
this->Wake_Grapple.Read(exINI, pSection, "Wake.Grapple");
this->Wake_Sinking.Read(exINI, pSection, "Wake.Sinking");
Expand Down Expand Up @@ -844,6 +847,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->BuildLimitGroup_ExtraLimit_MaxCount)
.Process(this->BuildLimitGroup_ExtraLimit_MaxNum)

.Process(this->NoTurret_TrackTarget)

.Process(this->Wake)
.Process(this->Wake_Grapple)
.Process(this->Wake_Sinking)
Expand Down
4 changes: 4 additions & 0 deletions src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ class TechnoTypeExt
ValueableVector<int> BuildLimitGroup_ExtraLimit_MaxCount;
Valueable<int> BuildLimitGroup_ExtraLimit_MaxNum;

Nullable<bool> NoTurret_TrackTarget;

Nullable<AnimTypeClass*> Wake;
Nullable<AnimTypeClass*> Wake_Grapple;
Nullable<AnimTypeClass*> Wake_Sinking;
Expand Down Expand Up @@ -469,6 +471,8 @@ class TechnoTypeExt
, BuildLimitGroup_ExtraLimit_MaxCount {}
, BuildLimitGroup_ExtraLimit_MaxNum { 0 }

, NoTurret_TrackTarget {}

, Wake { }
, Wake_Grapple { }
, Wake_Sinking { }
Expand Down

0 comments on commit c93235b

Please sign in to comment.