Skip to content

Commit

Permalink
Merge branch 'develop' into Aephiex-patch-WhenCrushed
Browse files Browse the repository at this point in the history
  • Loading branch information
Aephiex authored Nov 29, 2024
2 parents afd0e8d + 6d9775d commit e1d89eb
Show file tree
Hide file tree
Showing 16 changed files with 133 additions and 93 deletions.
3 changes: 2 additions & 1 deletion CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ This page lists all the individual contributions to the project by their author.
- Air unit tracking fix for large range / `CellSpread`
- Extra tint intensity for Iron Curtain & Force Shield
- Option to enable parsing 8-bit RGB values from `[ColorAdd]` instead of RGB565
- Customizing height at which subterranean units travel
- Customizing height and speed at which subterranean units travel
- AI superweapon delay timer customization
- Disabling `MultipleFactory` bonus from specific BuildingType
- Customizable ChronoSphere teleport delays for units
Expand Down Expand Up @@ -377,6 +377,7 @@ This page lists all the individual contributions to the project by their author.
- Skirmish AI "sell all buildings and set all technos to hunt" behavior dehardcode
- Skirmish AI "gather when MCV deploy" behavior dehardcode
- Global value of `RepairBaseNodes`
- **tyuah8** - Drive/Jumpjet/Ship/Teleport locomotor did not power on when it is un-piggybacked bugfix
- **Ares developers**
- YRpp and Syringe which are used, save/load, project foundation and generally useful code from Ares
- unfinished RadTypes code
Expand Down
12 changes: 9 additions & 3 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- Fixed objects with ally target and `AttackFriendlies=true` having their target reset every frame, particularly AI-owned buildings.
- `<Player @ X>` can now be used as owner for pre-placed objects on skirmish and multiplayer maps.
- Follower vehicle index for preplaced vehicles in maps is now explicitly constrained to `[Units]` list in map files and is no longer thrown off by vehicles that could not be created or created vehicles having other vehicles as initial passengers.
- Drive/Jumpjet/Ship/Teleport locomotor did not power on when it is un-piggybacked bugfix
- Unit `Speed` setting now accepts floating-point values. Internally parsed values are clamped down to maximum of 100, multiplied by 256 and divided by 100, the result (which at this point is converted to an integer) then clamped down to maximum of 255 giving effective internal speed value range of 0 to 255, e.g leptons traveled per game frame.
- Subterranean movement now benefits from speed multipliers from all sources such as veterancy, AttachEffect etc.

## Fixes / interactions with other extensions

Expand Down Expand Up @@ -920,21 +923,24 @@ AIAllToHunt=true ; boolean
GatherWhenMCVDeploy=true ; boolean
```

### Subterranean unit travel height
### Subterranean unit travel height and speed

- It is now possible to control the height at which units with subterranean (Tunnel) `Locomotor` travel, globally or per TechnoType.
- Subterranean movement speed is now also customizable, both globally and per TechnoType. If per-TechnoType value is negative, global value is used. This does not affect the speed at which the unit moves vertically when burrowing which is determined by `Speed` multiplied by `[General]`->`TunnelSpeed`.

In `rulesmd.ini`:
```ini
[General]
SubterraneanHeight=-256 ; integer, height in leptons (1/256th of a cell)

SubterraneanSpeed=7.5 ; floating point value

[SOMETECHNO] ; TechnoType
SubterraneanHeight= ; integer, height in leptons (1/256th of a cell)
SubterraneanSpeed=-1 ; floating point value
```

```{warning}
This expects negative values to be used and may behave erratically if set to above -50.
SubterraneanHeight expects negative values to be used and may behave erratically if set to above -50.
```

### Voxel body multi-section shadows
Expand Down
5 changes: 4 additions & 1 deletion docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ New:
- `ZAdjust` for OverlayTypes (by Starkku)
- Allow customizing extra tint intensity for Iron Curtain & Force Shield (by Starkku)
- Option to enable parsing 8-bit RGB values from `[ColorAdd]` instead of RGB565 (by Starkku)
- Customizing height at which subterranean units travel (by Starkku)
- Customizing height and speed at which subterranean units travel (by Starkku)
- Option for Warhead damage to penetrate Iron Curtain or Force Shield (by Starkku)
- Option for Warhead to remove all shield types at once (by Starkku)
- Allow customizing voxel light source position (by Kerbiter, Morton, based on knowledge of thomassnedon)
Expand Down Expand Up @@ -468,6 +468,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)
- Unit `Speed` setting now accepts floating point values (by Starkku)
- Allow weapon or warhead detonation when techno type is crushed (by Aephiex)
Vanilla fixes:
Expand Down Expand Up @@ -550,6 +551,8 @@ Vanilla fixes:
- Fixed infantry `SecondaryFire` / `SecondaryProne` sequences being displayed in water instead of `WetAttack` (by Starkku)
- Fixed objects with ally target and `AttackFriendlies=true` having their target reset every frame, particularly AI-owned buildings (by Starkku)
- Follower vehicle index for preplaced vehicles in maps is now explicitly constrained to `[Units]` list in map files and is no longer thrown off by vehicles that could not be created or created vehicles having other vehicles as initial passengers (by Starkku)
- Drive/Jumpjet/Ship/Teleport locomotor did not power on when it is un-piggybacked bugfix (by tyuah8)
- Subterranean movement now benefits from speed multipliers from all sources such as veterancy, AttachEffect etc. (by Starkku)
Phobos fixes:
- Fixed a few errors of calling for superweapon launch by `LaunchSW` or building infiltration (by Trsdy)
Expand Down
5 changes: 4 additions & 1 deletion src/Ext/Building/Hooks.Grinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ DEFINE_HOOK(0x4D4B43, FootClass_Mission_Capture_ForbidUnintended, 0x6)
GET(InfantryClass*, pThis, EDI);
enum { LosesDestination = 0x4D4BD1 };

if (!pThis || pThis->Target)
return 0;

auto pBld = specific_cast<BuildingClass*>(pThis->Destination);
if (!pThis || !pBld || pThis->Target)
if (!pBld)
return 0;

if (pThis->Type->Engineer)
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 @@ -78,6 +78,8 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
this->ChronoSphereDelay.Read(exINI, GameStrings::General, "ChronoSphereDelay");
this->AIChronoSphereSW.Read(exINI, GameStrings::General, "AIChronoSphereSW");
this->AIChronoWarpSW.Read(exINI, GameStrings::General, "AIChronoWarpSW");

exINI.ReadSpeed(GameStrings::General, "SubterraneanSpeed", &this->SubterraneanSpeed);
this->SubterraneanHeight.Read(exINI, GameStrings::General, "SubterraneanHeight");
this->AISuperWeaponDelay.Read(exINI, GameStrings::General, "AISuperWeaponDelay");
this->UseGlobalRadApplicationDelay.Read(exINI, GameStrings::Radiation, "UseGlobalRadApplicationDelay");
Expand Down Expand Up @@ -285,6 +287,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->ChronoSphereDelay)
.Process(this->AIChronoSphereSW)
.Process(this->AIChronoWarpSW)
.Process(this->SubterraneanSpeed)
.Process(this->SubterraneanHeight)
.Process(this->AISuperWeaponDelay)
.Process(this->UseGlobalRadApplicationDelay)
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class RulesExt
Valueable<int> ChronoSphereDelay;
ValueableIdx<SuperWeaponTypeClass> AIChronoSphereSW;
ValueableIdx<SuperWeaponTypeClass> AIChronoWarpSW;
int SubterraneanSpeed;
Valueable<int> SubterraneanHeight;
Nullable<int> AISuperWeaponDelay;
Valueable<bool> UseGlobalRadApplicationDelay;
Expand Down Expand Up @@ -177,6 +178,7 @@ class RulesExt
, ChronoSphereDelay { 0 }
, AIChronoSphereSW {}
, AIChronoWarpSW {}
, SubterraneanSpeed { 19 }
, SubterraneanHeight { -256 }
, AISuperWeaponDelay {}
, UseGlobalRadApplicationDelay { true }
Expand Down
47 changes: 8 additions & 39 deletions src/Ext/TAction/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,48 +291,17 @@ bool TActionExt::RunSuperWeaponAt(TActionClass* pThis, int X, int Y)
}
while (!MapClass::Instance->IsWithinUsableArea(targetLocation, false));

// Skip this check to use FindByCountryIndex
// Only valid House indexes
if ((pThis->Param4 >= HouseClass::Array->Count
&& pThis->Param4 < HouseClass::PlayerAtA)
|| pThis->Param4 > (HouseClass::PlayerAtA + HouseClass::Array->Count - 3))
{
return true;
}
//if ((pThis->Param4 >= HouseClass::Array->Count
// && pThis->Param4 < HouseClass::PlayerAtA)
// || pThis->Param4 > (HouseClass::PlayerAtA + HouseClass::Array->Count - 3))
//{
// return true;
//}

switch (pThis->Param4)
{
case HouseClass::PlayerAtA:
houseIdx = 0;
break;

case HouseClass::PlayerAtB:
houseIdx = 1;
break;

case HouseClass::PlayerAtC:
houseIdx = 2;
break;

case HouseClass::PlayerAtD:
houseIdx = 3;
break;

case HouseClass::PlayerAtE:
houseIdx = 4;
break;

case HouseClass::PlayerAtF:
houseIdx = 5;
break;

case HouseClass::PlayerAtG:
houseIdx = 6;
break;

case HouseClass::PlayerAtH:
houseIdx = 7;
break;

case -1:
// Random non-neutral
for (auto pHouse : *HouseClass::Array)
Expand Down Expand Up @@ -396,7 +365,7 @@ bool TActionExt::RunSuperWeaponAt(TActionClass* pThis, int X, int Y)
break;
}

if (HouseClass* pHouse = HouseClass::Array->GetItem(houseIdx))
if (HouseClass* pHouse = HouseClass::Index_IsMP(houseIdx) ? HouseClass::FindByIndex(houseIdx) : HouseClass::FindByCountryIndex(houseIdx))
{
if (auto const pSuper = pHouse->Supers.GetItem(swIdx))
{
Expand Down
6 changes: 3 additions & 3 deletions src/Ext/TEvent/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ bool TEventExt::HouseOwnsTechnoTypeTEvent(TEventClass* pThis)
if (!pType)
return false;

auto pHouse = HouseClass::FindByIndex(pThis->Value);
auto pHouse = HouseClass::Index_IsMP(pThis->Value) ? HouseClass::FindByIndex(pThis->Value) : HouseClass::FindByCountryIndex(pThis->Value);
if (!pHouse)
return false;

Expand Down Expand Up @@ -219,7 +219,7 @@ bool TEventExt::CellHasAnyTechnoTypeFromListTEvent(TEventClass* pThis, ObjectCla
if (pThis->Value <= -2)
pHouse = pEventHouse;
else if (pThis->Value >= 0)
pHouse = HouseClass::Array->GetItem(pThis->Value);
pHouse = HouseClass::Index_IsMP(pThis->Value) ? HouseClass::FindByIndex(pThis->Value) : HouseClass::FindByCountryIndex(pThis->Value);

if (pHouse && pTechno->Owner != pHouse)
break;
Expand Down Expand Up @@ -257,7 +257,7 @@ bool TEventExt::CellHasTechnoTypeTEvent(TEventClass* pThis, ObjectClass* pObject
if (pThis->Value <= -2)
pHouse = pEventHouse;
else if (pThis->Value >= 0)
pHouse = HouseClass::Array->GetItem(pThis->Value);
pHouse = HouseClass::Index_IsMP(pThis->Value) ? HouseClass::FindByIndex(pThis->Value) : HouseClass::FindByCountryIndex(pThis->Value);

if (pHouse)
{
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 @@ -367,6 +367,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->WarpOutWeapon.Read<true>(exINI, pSection, "WarpOutWeapon");
this->WarpInWeapon_UseDistanceAsDamage.Read(exINI, pSection, "WarpInWeapon.UseDistanceAsDamage");

exINI.ReadSpeed(pSection, "SubterraneanSpeed", &this->SubterraneanSpeed);
this->SubterraneanHeight.Read(exINI, pSection, "SubterraneanHeight");

this->OreGathering_Anims.Read(exINI, pSection, "OreGathering.Anims");
Expand Down Expand Up @@ -723,6 +724,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->WarpOutWeapon)
.Process(this->WarpInWeapon_UseDistanceAsDamage)

.Process(this->SubterraneanSpeed)
.Process(this->SubterraneanHeight)

.Process(this->OreGathering_Anims)
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 @@ -103,6 +103,7 @@ class TechnoTypeExt
Valueable<WeaponTypeClass*> WarpOutWeapon;
Valueable<bool> WarpInWeapon_UseDistanceAsDamage;

int SubterraneanSpeed;
Nullable<int> SubterraneanHeight;

ValueableVector<AnimTypeClass*> OreGathering_Anims;
Expand Down Expand Up @@ -302,6 +303,7 @@ class TechnoTypeExt
, WarpOutWeapon {}
, WarpInWeapon_UseDistanceAsDamage { false }

, SubterraneanSpeed { -1 }
, SubterraneanHeight {}

, OreGathering_Anims {}
Expand Down
28 changes: 26 additions & 2 deletions src/Ext/TechnoType/Hooks.Teleport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ DEFINE_HOOK(0x7193F6, TeleportLocomotionClass_ILocomotion_Process_WarpoutAnim, 0
WeaponTypeExt::DetonateAt(pExt->WarpOutWeapon, pLinked, pLinked);

const int distance = (int)Math::sqrt(pLinked->Location.DistanceFromSquared(pLocomotor->LastCoords));
TechnoExt::ExtMap.Find(pLinked)->LastWarpDistance = distance;
auto linkedExt = TechnoExt::ExtMap.Find(pLinked);
linkedExt->LastWarpDistance = distance;

if (auto pImage = pType->AlphaImage)
{
Expand Down Expand Up @@ -60,7 +61,7 @@ DEFINE_HOOK(0x7193F6, TeleportLocomotionClass_ILocomotion_Process_WarpoutAnim, 0
pLinked->WarpingOut = false;
}
}

linkedExt->LastWarpInDelay = std::max(pLocomotor->Timer.GetTimeLeft(), linkedExt->LastWarpInDelay);
return 0x7195BC;
}

Expand Down Expand Up @@ -141,3 +142,26 @@ DEFINE_HOOK(0x719BD9, TeleportLocomotionClass_Process_ChronosphereDelay2, 0x6)

return 0;
}

DEFINE_HOOK(0x4DA53E, FootClass_Update_WarpInDelay, 0x6)
{
GET(FootClass*, pThis, ESI);

auto const pExt = TechnoExt::ExtMap.Find(pThis);

if (pExt->HasRemainingWarpInDelay)
{
if (pExt->LastWarpInDelay)
{
pExt->LastWarpInDelay--;
}
else
{
pExt->HasRemainingWarpInDelay = false;
pExt->IsBeingChronoSphered = false;
pThis->WarpingOut = false;
}
}

return 0;
}
17 changes: 17 additions & 0 deletions src/Ext/TechnoType/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,20 @@ DEFINE_HOOK(0x711FDF, TechnoTypeClass_RefundAmount_FactoryPlant, 0x8)

return 0;
}


DEFINE_HOOK(0x71464A, TechnoTypeClass_ReadINI_Speed, 0x7)
{
enum { SkipGameCode = 0x71469F };

GET(TechnoTypeClass*, pThis, EBP);
GET(CCINIClass*, pINI, ESI);
GET(char*, pSection, EBX);
GET(int, eliteAirstrikeRechargeTime, EAX);

pThis->EliteAirstrikeRechargeTime = eliteAirstrikeRechargeTime; // Restore overridden instructions.
INI_EX exINI(pINI);
exINI.ReadSpeed(pSection, "Speed", &pThis->Speed);

return SkipGameCode;
}
2 changes: 1 addition & 1 deletion src/Ext/WarheadType/Detonate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void WarheadTypeExt::ExtData::Detonate(TechnoClass* pOwner, HouseClass* pHouse,

void WarheadTypeExt::ExtData::DetonateOnOneUnit(HouseClass* pHouse, TechnoClass* pTarget, TechnoClass* pOwner, bool bulletWasIntercepted)
{
if (!pTarget || pTarget->InLimbo || !pTarget->IsAlive || !pTarget->Health || pTarget->IsSinking)
if (!pTarget || pTarget->InLimbo || !pTarget->IsAlive || !pTarget->Health || pTarget->IsSinking || pTarget->BeingWarpedOut)
return;

TechnoExt::ExtData* pTargetExt = nullptr;
Expand Down
1 change: 1 addition & 0 deletions src/Misc/Hooks.Ares.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <BuildingClass.h>
#include <FootClass.h>

#include <Utilities/Macro.h>

// In vanilla YR, game destroys building animations directly by calling constructor.
Expand Down
Loading

0 comments on commit e1d89eb

Please sign in to comment.