Skip to content
Open
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
2 changes: 1 addition & 1 deletion CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ This page lists all the individual contributions to the project by their author.
- Warhead shield penetration & breaking
- Strafing aircraft weapon customization
- Vehicle `DeployFire` fixes/improvements
- Stationary VehicleTypes
- Stationary units
- Burst logic improvements
- TechnoType auto-firing weapons
- Secondary weapon fallback customization
Expand Down
2 changes: 1 addition & 1 deletion Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
<ClCompile Include="src\Ext\TerrainType\Hooks.cpp" />
<ClCompile Include="src\Ext\TerrainType\Hooks.Passable.cpp" />
<ClCompile Include="src\Ext\Unit\Hooks.DeployFire.cpp" />
<ClCompile Include="src\Ext\Unit\Hooks.DisallowMoving.cpp" />
<ClCompile Include="src\Ext\Techno\Hooks.DisallowMoving.cpp" />
<ClCompile Include="src\Ext\Unit\Hooks.DeploysInto.cpp" />
<ClCompile Include="src\Ext\Unit\Hooks.Jumpjet.cpp" />
<ClCompile Include="src\Ext\WarheadType\Detonate.cpp" />
Expand Down
13 changes: 8 additions & 5 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
- Fixed the bug that Locomotor warhead won't stop working when firer (except for vehicle) stop firing.
- Fixed the bug that hover vehicle will sink if destroyed on bridge.
- Fixed the fact that when the selected unit is in a rearmed state, it can unconditionally use attack mouse on the target.
- When `Speed=0` or the TechnoTypes cell cannot move due to `MovementRestrictedTo`, vehicles cannot attack targets beyond the weapon's range. `Area Guard` and `Hunt` missions will also become ineffective.
- Fixed an issue that barrel anim data will be incorrectly overwritten by turret anim data if the techno's section exists in the map file.
- Fixed pathfinding crashes (EIP 0x42A525, 0x42C507, 0x42C554) that happened on bigger maps due to too small pathfinding node buffer.
- `IsSimpleDeployer` `BalloonHover=true` units with `DeployToLand=false` are no longer forced to land when hovering.
Expand Down Expand Up @@ -1811,6 +1810,14 @@ In `rulesmd.ini`:
RadarInvisibleToHouse= ; Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all), default to enemy if RadarInvisible=true, none otherwise
```

### Stationary units

- Infantry & vehicles with `Speed=0` or those that are prevented from moving on their cell by `MovementRestrictedTo` are now truly stationary will not attempt to move if issued movement commands. Should not be used on trainable/buildable units as they become stuck in factory. Following behaviours apply:
- Cannot retaliate if target is beyond their weapon range.
- Cannot acquire units outside their weapon range on `Area Guard` mission.
- `Hunt` mission is reassigned to `Guard`.
- Units rendered stationary by speed multipliers instead of intrinsic properties of TechnoType will respond to cursor actions e.g assigning destination but will not move while the multiplier is in effect.

### 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.
Expand Down Expand Up @@ -2238,10 +2245,6 @@ SinkSpeed=5 ; integer, leptons per frame
Sinkable.SquidGrab=true ; boolean
```

### Stationary vehicles

- Setting VehicleType `Speed` to 0 now makes game treat them as stationary, behaving in very similar manner to deployed vehicles with `IsSimpleDeployer` set to true. Should not be used on buildable vehicles, as they won't be able to exit factories.

### Turret recoil

- Now you can use `TurretRecoil` to control units' turret/barrel recoil effect when firing.
Expand Down
2 changes: 1 addition & 1 deletion docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -2270,7 +2270,7 @@ JumpjetTilt.SidewaysSpeedFactor=1.0 ; floating point value
### Turret Response

- When the vehicle loses its target, you can customize whether to align the turret direction with the vehicle body.
- When `Speed=0` or TechnoTypes cells cannot move due to `MovementRestrictedTo`, the default value is no; in other cases, it is yes.
- If VehicleType has `Speed=0` or `MovementRestrictedTo` prevents it from moving on the cell, the default value is no; in other cases, it is yes.

In `rulesmd.ini`:
```ini
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ New:
- Allow jumpjet climbing ignore building height (by TaranDahl)
- [Allow draw SuperWeapon timer as percentage](User-Interface.md#allow-draw-superweapon-timer-as-percentage) (by NetsuNegi)
- Customize particle system of parasite logic (by NetsuNegi)
- [Improvements to stationary unit logic](Fixed-or-Improved-Logics.md#stationary-units) (by Starkku)
Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
Expand Down
12 changes: 4 additions & 8 deletions src/Ext/Script/Mission.Attack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,11 @@ void ScriptExt::Mission_Attack(TeamClass* pTeam, int calcThreatMode, bool repeat
continue;
}

const auto whatAmI = pFoot->WhatAmI();

// If the vehicle cannot be moved, perhaps it is better this way.
if (whatAmI == AbstractType::Unit
&& TechnoExt::CannotMove(static_cast<UnitClass*>(pFoot))
&& !pFoot->IsCloseEnough(pSelectedTarget, pFoot->SelectWeapon(pSelectedTarget)))
{
// If the unit cannot be moved, perhaps it is better this way.
if (TechnoExt::CannotMove(pFoot, true) && !pFoot->IsCloseEnough(pSelectedTarget, pFoot->SelectWeapon(pSelectedTarget)))
continue;
}

const auto whatAmI = pFoot->WhatAmI();

// Aircraft hack. I hate how this game auto-manages the aircraft missions.
if (whatAmI == AbstractType::Aircraft
Expand Down
34 changes: 20 additions & 14 deletions src/Ext/Techno/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,9 @@ void TechnoExt::SyncInvulnerability(TechnoClass* pFrom, TechnoClass* pTo)

double TechnoExt::GetCurrentSpeedMultiplier(FootClass* pThis)
{
double houseMultiplier = 1.0;
auto const pExt = TechnoExt::ExtMap.Find(pThis);
auto const whatAmI = pThis->WhatAmI();
double houseMultiplier = 1.0;

if (whatAmI == AbstractType::Aircraft)
houseMultiplier = pThis->Owner->Type->SpeedAircraftMult;
Expand All @@ -194,8 +195,6 @@ double TechnoExt::GetCurrentSpeedMultiplier(FootClass* pThis)
else
houseMultiplier = pThis->Owner->Type->SpeedUnitsMult;

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

return pThis->SpeedMultiplier * houseMultiplier * pExt->AE.SpeedMultiplier *
(pThis->HasAbility(Ability::Faster) ? RulesClass::Instance->VeteranSpeed : 1.0);
}
Expand Down Expand Up @@ -747,28 +746,34 @@ bool TechnoExt::IsHealthInThreshold(TechnoClass* pObject, double min, double max
return (hp > 0 ? hp > min : hp >= min) && hp <= max;
}

bool TechnoExt::CannotMove(UnitClass* pThis)
bool TechnoExt::CannotMove(FootClass* pThis, bool checkSpeedMultiplier)
{
const auto pType = pThis->Type;
const auto pType = pThis->GetTechnoType();

if (pType->Speed == 0)
return true;

const auto movementRestrictedTo = pType->MovementRestrictedTo;

if (movementRestrictedTo == LandType::None)
return false;
if (checkSpeedMultiplier && TechnoExt::ExtMap.Find(pThis)->IsZeroSpeed)
return true;

auto landType = pThis->GetCell()->LandType;

if (landType == LandType::Tunnel)
if (landType == LandType::Tunnel && pType->Locomotor != LocomotionClass::CLSIDs::Jumpjet)
return false;

if (pThis->OnBridge && (landType == LandType::Water || landType == LandType::Beach))
landType = LandType::Road;
if (pThis->WhatAmI() == AbstractType::Unit)
{
const auto movementRestrictedTo = static_cast<UnitTypeClass*>(pType)->MovementRestrictedTo;

if (movementRestrictedTo != landType)
return true;
if (movementRestrictedTo == LandType::None)
return false;

if (!pThis->OnBridge && (landType == LandType::Water || landType == LandType::Beach))
landType = LandType::Road;

if (movementRestrictedTo != landType)
return true;
}

return false;
}
Expand Down Expand Up @@ -1063,6 +1068,7 @@ void TechnoExt::ExtData::Serialize(T& Stm)
.Process(this->SpecialTracked)
.Process(this->FallingDownTracked)
.Process(this->JumpjetStraightAscend)
.Process(this->IsZeroSpeed)
;
}

Expand Down
5 changes: 4 additions & 1 deletion src/Ext/Techno/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class TechnoExt

bool JumpjetStraightAscend; // Is set to true jumpjet units will ascend straight and do not adjust rotation or position during it.

bool IsZeroSpeed; // Temporary speed multipliers have made this techno stationary.

ExtData(TechnoClass* OwnerObject) : Extension<TechnoClass>(OwnerObject)
, TypeExtData { nullptr }
, Shield {}
Expand Down Expand Up @@ -166,6 +168,7 @@ class TechnoExt
, SpecialTracked { false }
, FallingDownTracked { false }
, JumpjetStraightAscend { false }
, IsZeroSpeed { false }
{ }

void OnEarlyUpdate();
Expand Down Expand Up @@ -289,7 +292,7 @@ class TechnoExt
static bool IsVeterancyInThreshold(TechnoClass* pObject, double min, double max);
static UnitTypeClass* GetUnitTypeExtra(UnitClass* pUnit, TechnoTypeExt::ExtData* pData);
static AircraftTypeClass* GetAircraftTypeExtra(AircraftClass* pAircraft);
static bool CannotMove(UnitClass* pThis);
static bool CannotMove(FootClass* pThis, bool checkSpeedMultiplier);
static bool HasAmmoToDeploy(TechnoClass* pThis);
static void HandleOnDeployAmmoChange(TechnoClass* pThis, int maxAmmoOverride = -1);
static bool SimpleDeployerAllowedToDeploy(UnitClass* pThis, bool defaultValue, bool alwaysCheckLandTypes);
Expand Down
Loading