Skip to content

Commit

Permalink
NoSecondaryWeaponFallback can now cancel the weapon selection for wal…
Browse files Browse the repository at this point in the history
…ls. (#1516)

Phobos previously added a rule to select weapons based on `[Warhead] ►
Wall= (bool)`
but `[TechnoType] ► NoSecondaryWeaponFallback= (bool)` cannot disable
this rule
this causing the Soviet Siege Chopper to use the `160mm` weapon to
attack walls even when not deployed.

---------

Co-authored-by: Starkku <[email protected]>
  • Loading branch information
DeathFishAtEase and Starkku authored Feb 6, 2025
1 parent 34fb1d6 commit 6355937
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- Fixed `DeployToFire` not recalculating firer's position on land if it cannot currently deploy.
- `Arcing=true` projectile elevation inaccuracy can now be fixed by setting `Arcing.AllowElevationInaccuracy=false`.
- Wall overlays are now drawn with the custom palette defined in `Palette` in `artmd.ini` if possible.
- `Secondary` will now be used against walls if `Primary` weapon Warhead has `Wall=false`, `Secondary` has `Wall=true` and the firer does not have `NoSecondaryWeaponFallback` set to true.
- If `[CombatDamage]`->`AllowWeaponSelectAgainstWalls` is set to true, `Secondary` will now be used against walls if `Primary` weapon Warhead has `Wall=false`, `Secondary` has `Wall=true` and the firer does not have `NoSecondaryWeaponFallback` set to true.
- Setting `ReloadInTransport` to true on units with `Ammo` will allow the ammo to be reloaded according to `Reload` or `EmptyReload` timers even while the unit is inside a transport.
- It is now possible to enable `Verses` and `PercentAtMax` to be applied on negative damage by setting `ApplyModifiersOnNegativeDamage` to true on the Warhead.
- Attached animations on flying units now have their layer updated immediately after the parent unit, if on same layer they always draw above the parent.
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ You can use the migration utility (can be found on [Phobos supplementaries repo]

#### From post-0.3 devbuilds

- Selecting weapons other than primary against walls based on `Wall=true` on Warhead etc. now requires `[CombatDamage]`->`AllowWeaponSelectAgainstWalls` to be set to true first.
- Lunar theater tileset parsing unhardcoding is now only applied if `lunarmd.ini` has `[General]` -> `ApplyLunarFixes` set to true.
- `Units.DisableRepairCost` was changed to `Units.UseRepairCost` (note inverted expected value) as it no longer has discrete default value and affects `Hospital=true` buildings, infantry do not have repair cost by default.
- Critical hit animations created by `Crit.AnimOnAffectedTargets=true` Warheads no longer default to `AnimList.PickRandom` if `Crit.AnimList.PickRandom` is not set.
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
this->ForceShield_KeptOnDeploy.Read(exINI, GameStrings::CombatDamage, "ForceShield.KeptOnDeploy");
this->ForceShield_EffectOnOrganics.Read(exINI, GameStrings::CombatDamage, "ForceShield.EffectOnOrganics");
this->ForceShield_KillOrganicsWarhead.Read<true>(exINI, GameStrings::CombatDamage, "ForceShield.KillOrganicsWarhead");
this->AllowWeaponSelectAgainstWalls.Read(exINI, GameStrings::CombatDamage, "AllowWeaponSelectAgainstWalls");

this->IronCurtain_ExtraTintIntensity.Read(exINI, GameStrings::AudioVisual, "IronCurtain.ExtraTintIntensity");
this->ForceShield_ExtraTintIntensity.Read(exINI, GameStrings::AudioVisual, "ForceShield.ExtraTintIntensity");
Expand Down Expand Up @@ -351,6 +352,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->ForceShield_KillOrganicsWarhead)
.Process(this->IronCurtain_ExtraTintIntensity)
.Process(this->ForceShield_ExtraTintIntensity)
.Process(this->AllowWeaponSelectAgainstWalls)
.Process(this->ColorAddUse8BitRGB)
.Process(this->ROF_RandomDelay)
.Process(this->ToolTip_Background_Color)
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 @@ -117,6 +117,8 @@ class RulesExt
Valueable<IronCurtainEffect> ForceShield_EffectOnOrganics;
Nullable<WarheadTypeClass*> ForceShield_KillOrganicsWarhead;

Valueable<bool> AllowWeaponSelectAgainstWalls;

Valueable<double> IronCurtain_ExtraTintIntensity;
Valueable<double> ForceShield_ExtraTintIntensity;
Valueable<bool> ColorAddUse8BitRGB;
Expand Down Expand Up @@ -248,6 +250,7 @@ class RulesExt
, ForceShield_KillOrganicsWarhead { }
, IronCurtain_ExtraTintIntensity { 0.0 }
, ForceShield_ExtraTintIntensity { 0.0 }
, AllowWeaponSelectAgainstWalls { false }
, ColorAddUse8BitRGB { false }
, ROF_RandomDelay { { 0 ,2 } }
, ToolTip_Background_Color { { 0, 0, 0 } }
Expand Down
6 changes: 3 additions & 3 deletions src/Ext/Techno/WeaponHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ int TechnoExt::GetWeaponIndexAgainstWall(TechnoClass* pThis, OverlayTypeClass* p
int weaponIndex = -1;
auto pWeapon = TechnoExt::GetCurrentWeapon(pThis, weaponIndex);

if ((pTechnoType->TurretCount > 0 && !pTechnoType->IsGattling) || !pWallOverlayType || !pWallOverlayType->Wall)
if ((pTechnoType->TurretCount > 0 && !pTechnoType->IsGattling) || !pWallOverlayType || !pWallOverlayType->Wall || !RulesExt::Global()->AllowWeaponSelectAgainstWalls)
return weaponIndex;
else if (weaponIndex == -1)
return 0;
Expand All @@ -187,8 +187,8 @@ int TechnoExt::GetWeaponIndexAgainstWall(TechnoClass* pThis, OverlayTypeClass* p
pWeaponExt = WeaponTypeExt::ExtMap.Find(pWeapon);
bool aeForbidsSecondary = pWeaponExt && pWeaponExt->AttachEffect_CheckOnFirer && !pWeaponExt->HasRequiredAttachedEffects(pThis, pThis);

if (pWeapon && (pWeapon->Warhead->Wall || (pWeapon->Warhead->Wood && pWallOverlayType->Armor == Armor::Wood)
&& (!TechnoTypeExt::ExtMap.Find(pTechnoType)->NoSecondaryWeaponFallback || aeForbidsPrimary)) && !aeForbidsSecondary)
if (pWeapon && (pWeapon->Warhead->Wall || (pWeapon->Warhead->Wood && pWallOverlayType->Armor == Armor::Wood))
&& (!TechnoTypeExt::ExtMap.Find(pTechnoType)->NoSecondaryWeaponFallback || aeForbidsPrimary) && !aeForbidsSecondary)
{
return weaponIndexSec;
}
Expand Down

0 comments on commit 6355937

Please sign in to comment.