Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ This page lists all the individual contributions to the project by their author.
- `ElectricAssault` weapons can now auto acquire allies' overpowerable defenses
- Allow `AuxBuilding` and Ares' `SW.Aux/NegBuildings` to count building upgrades
- Dynamic team delays
- Customize whether or not passenger can fire out when the transport is moving
- **NaotoYuuki** - Vertical & meteor trajectory projectile prototypes
- **handama**:
- AI script action to `16005 Jump Back To Previous Script`
Expand Down
1 change: 1 addition & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- Fixed voxel projectile and animation lighting issues.
- Fixed the bug that techno will get stuck if change owner in tunnel.
- Restored the original Tiberian Sun behavior of playing the `[AudioVisual] -> DeploySound=` sound effect when clicking the sidebar to execute `Deploy`.
- Whether or not a passenger's weapon can fire out from an `OpenTopped=yes` transport will now respect the weapon's `FireWhileMoving` setting.

## Fixes / interactions with other extensions

Expand Down
5 changes: 5 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1648,12 +1648,15 @@ DrainMoneyDisplay.OnTarget.UseDisplayIncome= ; boolean
- `OpenTopped.ShareTransportTarget` controls whether or not the current target of the transport itself is passed to the passengers as well.
- You can also customize range bonus and damage multiplier for passenger inside the transport with `OpenTransport.RangeBonus/DamageMultiplier`, which works independently from transport's `OpenTopped.RangeBonus/DamageMultiplier`.
- `OpenTopped.DecloakToFire` can customize if a transport has to uncloak to have passengers fireout if transport is also OpenTopped.
- `OpenTopped/OpenTransport.FireWhileMoving` can be used to customize whether or not passengers can fire out when the transport is moving, for transport and passenger respectively. Both of them and the weapon's `FireWhileMoving` toggle need to be set to true to allow firing out when moving.

In `rulesmd.ini`:
```ini
[General]
OpenTopped.AllowFiringIfAttackedByLocomotor=true ; boolean
OpenTopped.DecloakToFire=true ; boolean
OpenTopped.FireWhileMoving=true ; boolean
OpenTransport.FireWhileMoving=true ; boolean

[SOMETECHNO] ; TechnoType, transport with OpenTopped=yes
OpenTopped.RangeBonus= ; integer, default to [CombatDamage] -> OpenToppedRangeBonus
Expand All @@ -1664,10 +1667,12 @@ OpenTopped.AllowFiringIfDeactivated=true ; boolean
OpenTopped.AllowFiringIfAttackedByLocomotor= ; boolean, defaults to [General] -> OpenTopped.AllowFiringIfAttackedByLocomotor
OpenTopped.ShareTransportTarget=true ; boolean
OpenTopped.DecloakToFire= ; boolean, defaults to [General] -> OpenTopped.DecloakToFire
OpenTopped.FireWhileMoving= ; boolean, defaults to [General] -> OpenTopped.FireWhileMoving

[SOMETECHNO] ; TechnoType, passenger
OpenTransport.RangeBonus=0 ; integer
OpenTransport.DamageMultiplier=1.0 ; floating point value
OpenTransport.FireWhileMoving= ; boolean, defaults to [General] -> OpenTransport.FireWhileMoving
```

```{note}
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ HideShakeEffects=false ; boolean
- Add `selling`, `undeploying` and `harvesting` conditions to `DiscardOn` (by Noble_Fish)
- [Additional reinforcement aircraft (airstrike, paradrop and spy plane) spawn customizations](Fixed-or-Improved-Logics.md#reinforcement-aircraft-spawn-settings) (by Starkku)
- [`ZAdjust` for Projectiles](Fixed-or-Improved-Logics.md#zadjust-for-projectiles) (by Noble_Fish)
- Customize whether or not passenger can fire out when the transport is moving (by Ollerus)
#### Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
Expand Down
4 changes: 4 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
this->FallingDownTargetingFix.Read(exINI, GameStrings::General, "FallingDownTargetingFix");
this->AIAirTargetingFix.Read(exINI, GameStrings::General, "AIAirTargetingFix");
this->OpenTopped_DecloakToFire.Read(exINI, GameStrings::General, "OpenTopped.DecloakToFire");
this->OpenTopped_FireWhileMoving.Read(exINI, GameStrings::General, "OpenTopped.FireWhileMoving");
this->OpenTopped_AllowFiringIfAttackedByLocomotor.Read(exINI, GameStrings::General, "OpenTopped.AllowFiringIfAttackedByLocomotor");
this->OpenTransport_FireWhileMoving.Read(exINI, GameStrings::General, "OpenTransport.FireWhileMoving");

this->SortCameoByName.Read(exINI, GameStrings::General, "SortCameoByName");

Expand Down Expand Up @@ -750,7 +752,9 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->FallingDownTargetingFix)
.Process(this->AIAirTargetingFix)
.Process(this->OpenTopped_DecloakToFire)
.Process(this->OpenTopped_FireWhileMoving)
.Process(this->OpenTopped_AllowFiringIfAttackedByLocomotor)
.Process(this->OpenTransport_FireWhileMoving)
.Process(this->SortCameoByName)
.Process(this->MergeBuildingDamage)
.Process(this->BuildingRadioLink_SyncOwner)
Expand Down
4 changes: 4 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ class RulesExt
Valueable<bool> FallingDownTargetingFix;
Valueable<bool> AIAirTargetingFix;
Valueable<bool> OpenTopped_DecloakToFire;
Valueable<bool> OpenTopped_FireWhileMoving;
Valueable<bool> OpenTopped_AllowFiringIfAttackedByLocomotor;
Valueable<bool> OpenTransport_FireWhileMoving;

Valueable<bool> SortCameoByName;

Expand Down Expand Up @@ -631,7 +633,9 @@ class RulesExt
, FallingDownTargetingFix { false }
, AIAirTargetingFix { false }
, OpenTopped_DecloakToFire { false }
, OpenTopped_FireWhileMoving { true }
, OpenTopped_AllowFiringIfAttackedByLocomotor { true }
, OpenTransport_FireWhileMoving { true }

, SortCameoByName { false }

Expand Down
31 changes: 24 additions & 7 deletions src/Ext/Techno/Hooks.Firing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,18 +436,35 @@ DEFINE_HOOK(0x6FC5C7, TechnoClass_CanFire_OpenTopped, 0x6)
if (pTransport->Deactivated && !pTypeExt->OpenTopped_AllowFiringIfDeactivated)
return Illegal;

if (const auto pTransportFoot = abstract_cast<FootClass*>(pTransport))
{
if (pTransportFoot->IsAttackedByLocomotor && !pTypeExt->OpenTopped_AllowFiringIfAttackedByLocomotor.Get(RulesExt::Global()->OpenTopped_AllowFiringIfAttackedByLocomotor))
return Illegal;
}

if (pTransport->Transporter)
return Illegal;

if (pTypeExt->OpenTopped_CheckTransportDisableWeapons && TechnoExt::HasWeaponsDisabled(pTransport) && pThis->GetWeapon(weaponIndex)->WeaponType)
auto const pWeapon = pThis->GetWeapon(weaponIndex)->WeaponType;

if (pTypeExt->OpenTopped_CheckTransportDisableWeapons && TechnoExt::HasWeaponsDisabled(pTransport) && pWeapon)
return OutOfRange;

if (auto const pTransportFoot = abstract_cast<FootClass*>(pTransport))
{
if (pTransportFoot->IsAttackedByLocomotor && !pTypeExt->OpenTopped_AllowFiringIfAttackedByLocomotor.Get(RulesExt::Global()->OpenTopped_AllowFiringIfAttackedByLocomotor))
return Illegal;

if (!pTypeExt->OpenTopped_FireWhileMoving.Get(RulesExt::Global()->OpenTopped_FireWhileMoving)
|| !TechnoExt::ExtMap.Find(pThis)->TypeExtData->OpenTransport_FireWhileMoving.Get(RulesExt::Global()->OpenTransport_FireWhileMoving)
|| (pWeapon && !pWeapon->FireWhileMoving))
{
if (pTypeExt->OwnerObject()->BalloonHover)
{
if (pTransportFoot->Locomotor->Is_Moving_Now())
return Illegal;
}
else if (pTransportFoot->Destination)
{
return Illegal;
}
}
}
Comment thread
TaranDahl marked this conversation as resolved.

return Continue;
}

Expand Down
76 changes: 75 additions & 1 deletion src/Ext/Techno/Hooks.Transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ DEFINE_HOOK(0x519776, InfantryClass_UpdatePosition_NoQueueUpToEnter, 0x5)
return 0;
}

DEFINE_HOOK(0x739FA2, UnitClassClass_UpdatePosition_NoQueueUpToEnter, 0x5)
DEFINE_HOOK(0x739FA2, UnitClass_UpdatePosition_NoQueueUpToEnter, 0x5)
{
GET(UnitClass*, pThis, EBP);
GET(BuildingClass*, pBuilding, EBX);
Expand Down Expand Up @@ -885,3 +885,77 @@ DEFINE_HOOK(0x739FA2, UnitClassClass_UpdatePosition_NoQueueUpToEnter, 0x5)
}

#pragma endregion

DEFINE_HOOK(0x4D9510, FootClass_SetDestination_OpenToppedFireWhileMoving, 0x6)
{
GET(FootClass*, pThis, EBP);
GET(void*, moving, ESI);

if (!moving)
return 0;

auto const pUnit = abstract_cast<UnitClass*, true>(pThis);

if (!pUnit)
return 0;

auto const pType = pUnit->Type;

if (pType->OpenTopped && pUnit->Passengers.NumPassengers > 0)
{
const bool fireWhileMoving = TechnoTypeExt::ExtMap.Find(pType)->OpenTopped_FireWhileMoving.Get(RulesExt::Global()->OpenTopped_FireWhileMoving);
auto pPassenger = pUnit->Passengers.GetFirstPassenger();

while (pPassenger)
{
const bool canFire = fireWhileMoving && TechnoExt::ExtMap.Find(pPassenger)->TypeExtData->OpenTransport_FireWhileMoving.Get(RulesExt::Global()->OpenTransport_FireWhileMoving);

// Technically these 3 can't exist in the same time, but just in case
if (auto const pLocoTarget = pPassenger->LocomotorTarget)
{
auto const pWeapon = pPassenger->GetWeapon(pPassenger->SelectWeapon(pLocoTarget))->WeaponType;
bool canFireLocomotor = canFire;

if (pWeapon && pWeapon->Warhead->IsLocomotor)
canFireLocomotor &= pWeapon->FireWhileMoving;

if (!canFireLocomotor)
pPassenger->ReleaseLocomotor(true);
}

if (auto const pTemporal = pPassenger->TemporalImUsing)
{
if (auto const pTarget = pTemporal->Target)
{
auto const pWeapon = pPassenger->GetWeapon(pPassenger->SelectWeapon(pTarget))->WeaponType;
bool canFireTemporal = canFire;

if (pWeapon && pWeapon->Warhead->Temporal)
canFireTemporal &= pWeapon->FireWhileMoving;

if (!canFireTemporal)
pTemporal->LetGo();
}
}

if (auto const pAirstrike = TechnoExt::ExtMap.Find(pPassenger)->AirstrikeTargetingMe)
Comment thread
NetsuNegi marked this conversation as resolved.
Outdated
{
if (auto const pTarget = pAirstrike->Target)
{
auto const pWeapon = pPassenger->GetWeapon(pPassenger->SelectWeapon(pTarget))->WeaponType;
bool canFireAirstrike = canFire;

if (pWeapon && pWeapon->Warhead->Temporal)
canFireAirstrike &= pWeapon->FireWhileMoving;

if (!canFireAirstrike)
pAirstrike->ResetTarget(nullptr);
}
}

pPassenger = abstract_cast<FootClass*>(pPassenger->NextObject);
}
}

return 0;
}
2 changes: 1 addition & 1 deletion src/Ext/Techno/Hooks.WeaponRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ DEFINE_HOOK(0x7012C2, TechnoClass_WeaponRange, 0x8)
if (!pTypeExt->OpenTopped_IgnoreRangefinding && pTypeExt->OwnerObject()->OpenTopped)
{
int smallestRange = INT32_MAX;
auto pPassenger = abstract_cast<FootClass*>(pThis->Passengers.GetFirstPassenger());
auto pPassenger = pThis->Passengers.GetFirstPassenger();

while (pPassenger)
{
Expand Down
4 changes: 4 additions & 0 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,10 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->OpenTopped_UseTransportRangeModifiers.Read(exINI, pSection, "OpenTopped.UseTransportRangeModifiers");
this->OpenTopped_CheckTransportDisableWeapons.Read(exINI, pSection, "OpenTopped.CheckTransportDisableWeapons");
this->OpenTopped_DecloakToFire.Read(exINI, pSection, "OpenTopped.DecloakToFire");
this->OpenTopped_FireWhileMoving.Read(exINI, pSection, "OpenTopped.FireWhileMoving");
this->OpenTransport_RangeBonus.Read(exINI, pSection, "OpenTransport.RangeBonus");
this->OpenTransport_DamageMultiplier.Read(exINI, pSection, "OpenTransport.DamageMultiplier");
this->OpenTransport_FireWhileMoving.Read(exINI, pSection, "OpenTransport.FireWhileMoving");

if (exINI.ReadString(pSection, "AutoFire") > 0)
{
Expand Down Expand Up @@ -1631,8 +1633,10 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->OpenTopped_UseTransportRangeModifiers)
.Process(this->OpenTopped_CheckTransportDisableWeapons)
.Process(this->OpenTopped_DecloakToFire)
.Process(this->OpenTopped_FireWhileMoving)
.Process(this->OpenTransport_RangeBonus)
.Process(this->OpenTransport_DamageMultiplier)
.Process(this->OpenTransport_FireWhileMoving)

.Process(this->AutoTargetOwnPosition)
.Process(this->AutoTargetOwnPosition_Self)
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 @@ -169,8 +169,10 @@ class TechnoTypeExt
Valueable<bool> OpenTopped_UseTransportRangeModifiers;
Valueable<bool> OpenTopped_CheckTransportDisableWeapons;
Nullable<bool> OpenTopped_DecloakToFire;
Nullable<bool> OpenTopped_FireWhileMoving;
Valueable<int> OpenTransport_RangeBonus;
Valueable<float> OpenTransport_DamageMultiplier;
Nullable<bool> OpenTransport_FireWhileMoving;

Valueable<bool> AutoTargetOwnPosition;
Valueable<bool> AutoTargetOwnPosition_Self;
Expand Down Expand Up @@ -621,8 +623,10 @@ class TechnoTypeExt
, OpenTopped_UseTransportRangeModifiers { false }
, OpenTopped_CheckTransportDisableWeapons { false }
, OpenTopped_DecloakToFire {}
, OpenTopped_FireWhileMoving {}
, OpenTransport_RangeBonus { 0 }
, OpenTransport_DamageMultiplier { 1.0f }
, OpenTransport_FireWhileMoving {}

, AutoTargetOwnPosition { false }
, AutoTargetOwnPosition_Self { false }
Expand Down
Loading