Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- `EVA.Tag` already supports being set for specific countries, and `EVAIndex` is no longer reset after load game.
- `DisableWeapons.Duration` now makes `Gattling=yes` rate tick down and stops the sounds from playing, no longer interferes with target acquisition and works together with Phobos' `OpenTopped.CheckTransportDisableWeapons`.
- Allowed Ares' `SW.AuxBuildings` and `SW.NegBuildings` to count building upgrades.
- Allowed infantry to use `Convert.Deploy` without requiring `IsSimpleDeployer=true`.

## Newly added global settings

Expand Down
15 changes: 15 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,21 @@ SpyEffect.InfiltratorSuperWeapon= ; SuperWeaponType

## Infantry

### Allow infantry to perform type conversion when deploying and undeploying

- Now infantry can perform type conversion when executing the `Deploy` and `Undeploy` sequences.

In `rulesmd.ini`:
```ini
[SOMEINFANTRY] ; InfantryType
Convert.Deploy= ; InfantryType
Convert.Undeploy= ; InfantryType
```

```{note}
For the sake of logical clarity, this feature does not allow the converted unit to trigger another conversion before the current sequence ends. If continuous conversion is needed, please use `Convert.Land/Water`.
```

### Customizable FLH when infantry is prone or deployed

- Now infantry can override `PrimaryFireFLH` and `SecondaryFireFLH` if is prone (crawling) or deployed. Also works in conjunction with [burst-index specific firing offsets](#firing-offsets-for-specific-burst-shots).
Expand Down
2 changes: 2 additions & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ HideShakeEffects=false ; boolean
- Restored the original Tiberian Sun behavior of playing the `[AudioVisual] -> DeploySound=` sound effect when clicking the sidebar to execute `Deploy` (by Noble_Fish)
- Allow `RemoveMindControl` warhead to mute `MindClearedSound` (by Noble_Fish)
- Introduce weight selection rules for ExtraWarheads (by Noble_Fish)
- [Allow infantry to perform type conversion when deploying and undeploying](New-or-Enhanced-Logics.md#allow-infantry-to-perform-type-conversion-when-deploying-and-undeploying) (by Noble_Fish)

#### Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
Expand Down Expand Up @@ -742,6 +743,7 @@ HideShakeEffects=false ; boolean
- [Aux technos and TechLevel requirement of superweapon](New-or-Enhanced-Logics.md#aux-technos-and-techlevel-requirement-of-superweapon) (by NetsuNegi & Ollerus)
- [Export interface for external call](index.md#interoperability) (by TaranDahl)
- Allowed `MindControl.Permanent` warhead to mute `MindClearedSound` (by NetsuNegi & Noble_Fish)
- Allowed infantry to use `Convert.Deploy` without requiring `IsSimpleDeployer=true` (by Noble_Fish)

```

Expand Down
10 changes: 10 additions & 0 deletions src/Ext/Infantry/Hooks.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <Ext/BuildingType/Body.h>
#include <Ext/TechnoType/Body.h>
#include <Ext/Techno/Body.h>

#include <InputManagerClass.h>

Expand All @@ -11,6 +12,15 @@ DEFINE_HOOK(0x51B2BD, InfantryClass_UpdateTarget_IsControlledByHuman, 0x6)
return (!pTarget || pThis->Owner->IsControlledByHuman()) ? 0x51B33F : 0;
}


DEFINE_HOOK(0x520AE9, InfantryClass_DoingAI_DeployConvert, 0x6)
{
GET(InfantryClass*, pThis, ESI);
auto const pExt = TechnoExt::ExtMap.Find(pThis);
pExt->DeployConvertAction();
return 0;
}

#pragma region WhatActionObjectFix

namespace WhatActionObjectTemp
Expand Down
35 changes: 35 additions & 0 deletions src/Ext/Techno/Body.Update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,41 @@ void TechnoExt::ExtData::AmmoAutoConvertActions()
}
}

void TechnoExt::ExtData::DeployConvertAction()
{
const auto pTypeExt = this->TypeExtData;

if (!pTypeExt->Convert_Deploy && !pTypeExt->Convert_Undeploy)
return;

const auto pThis = abstract_cast<InfantryClass*, true>(this->OwnerObject());

if (!pThis)
return;

const auto curSeq = pThis->SequenceAnim;

if (curSeq != Sequence::Deploy && curSeq != Sequence::Undeploy)
{
this->HasDeployConvertedInCurrentSequence = false;
return;
}

if (this->HasDeployConvertedInCurrentSequence)
return;

if (curSeq == Sequence::Deploy && pTypeExt->Convert_Deploy)
{
this->HasDeployConvertedInCurrentSequence = true;
TechnoExt::ConvertToType(pThis, pTypeExt->Convert_Deploy);
}
else if (curSeq == Sequence::Undeploy && pTypeExt->Convert_Undeploy)
{
this->HasDeployConvertedInCurrentSequence = true;
TechnoExt::ConvertToType(pThis, pTypeExt->Convert_Undeploy);
}
}

// Subterranean harvester factory exit state machine.
void TechnoExt::ExtData::UpdateSubterraneanHarvester()
{
Expand Down
1 change: 1 addition & 0 deletions src/Ext/Techno/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,7 @@ void TechnoExt::ExtData::Serialize(T& Stm)
.Process(this->HoverShutdown)
.Process(this->LastTargetCrd)
.Process(this->LastTargetCrdClearTimer)
.Process(this->HasDeployConvertedInCurrentSequence)
;
}

Expand Down
6 changes: 6 additions & 0 deletions src/Ext/Techno/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class TechnoExt
CoordStruct LastTargetCrd;
CDTimerClass LastTargetCrdClearTimer;

bool HasDeployConvertedInCurrentSequence;

ExtData(TechnoClass* OwnerObject) : Extension<TechnoClass>(OwnerObject)
, TypeExtData { nullptr }
, Shield {}
Expand Down Expand Up @@ -177,6 +179,8 @@ class TechnoExt
, HoverShutdown { false }
, LastTargetCrd { CoordStruct::Empty }
, LastTargetCrdClearTimer {}

, HasDeployConvertedInCurrentSequence { false }
{ }

void OnEarlyUpdate();
Expand Down Expand Up @@ -217,6 +221,8 @@ class TechnoExt
void UpdateTintValues();

void AmmoAutoConvertActions();
void DeployConvertAction();

void UpdateLastTargetCrd();
int GetSight();

Expand Down
2 changes: 2 additions & 0 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->CurleyShuffle.Read(exINI, pSection, "CurleyShuffle");

this->Convert_Deploy.Read(exINI, pSection, "Convert.Deploy");
this->Convert_Undeploy.Read(exINI, pSection, "Convert.Undeploy");
this->Convert_HumanToComputer.Read(exINI, pSection, "Convert.HumanToComputer");
this->Convert_ComputerToHuman.Read(exINI, pSection, "Convert.ComputerToHuman");
this->Convert_ResetMindControl.Read(exINI, pSection, "Convert.ResetMindControl");
Expand Down Expand Up @@ -1736,6 +1737,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->TiberiumEaterType)

.Process(this->Convert_Deploy)
.Process(this->Convert_Undeploy)
.Process(this->Convert_HumanToComputer)
.Process(this->Convert_ComputerToHuman)
.Process(this->Convert_ResetMindControl)
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ class TechnoTypeExt
Nullable<bool> CurleyShuffle;

Valueable<TechnoTypeClass*> Convert_Deploy; // Ares
Valueable<TechnoTypeClass*> Convert_Undeploy;
Valueable<TechnoTypeClass*> Convert_HumanToComputer;
Valueable<TechnoTypeClass*> Convert_ComputerToHuman;
Valueable<bool> Convert_ResetMindControl;
Expand Down Expand Up @@ -771,6 +772,7 @@ class TechnoTypeExt
, CurleyShuffle {}

, Convert_Deploy { }
, Convert_Undeploy { }
, Convert_HumanToComputer { }
, Convert_ComputerToHuman { }
, Convert_ResetMindControl { false }
Expand Down
Loading