Skip to content

Commit 7edb6a9

Browse files
committed
Improvements to stationary unit logic
1 parent b56f33b commit 7edb6a9

11 files changed

Lines changed: 416 additions & 248 deletions

CREDITS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ This page lists all the individual contributions to the project by their author.
161161
- Warhead shield penetration & breaking
162162
- Strafing aircraft weapon customization
163163
- Vehicle `DeployFire` fixes/improvements
164-
- Stationary VehicleTypes
164+
- Stationary units
165165
- Burst logic improvements
166166
- TechnoType auto-firing weapons
167167
- Secondary weapon fallback customization

Phobos.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
<ClCompile Include="src\Ext\TerrainType\Hooks.cpp" />
167167
<ClCompile Include="src\Ext\TerrainType\Hooks.Passable.cpp" />
168168
<ClCompile Include="src\Ext\Unit\Hooks.DeployFire.cpp" />
169-
<ClCompile Include="src\Ext\Unit\Hooks.DisallowMoving.cpp" />
169+
<ClCompile Include="src\Ext\Techno\Hooks.DisallowMoving.cpp" />
170170
<ClCompile Include="src\Ext\Unit\Hooks.DeploysInto.cpp" />
171171
<ClCompile Include="src\Ext\Unit\Hooks.Jumpjet.cpp" />
172172
<ClCompile Include="src\Ext\WarheadType\Detonate.cpp" />

docs/Fixed-or-Improved-Logics.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
250250
- Fixed the bug that Locomotor warhead won't stop working when firer (except for vehicle) stop firing.
251251
- Fixed the bug that hover vehicle will sink if destroyed on bridge.
252252
- Fixed the fact that when the selected unit is in a rearmed state, it can unconditionally use attack mouse on the target.
253-
- 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.
254253
- 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.
255254
- Fixed pathfinding crashes (EIP 0x42A525, 0x42C507, 0x42C554) that happened on bigger maps due to too small pathfinding node buffer.
256255
- `IsSimpleDeployer` `BalloonHover=true` units with `DeployToLand=false` are no longer forced to land when hovering.
@@ -1811,6 +1810,14 @@ In `rulesmd.ini`:
18111810
RadarInvisibleToHouse= ; Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all), default to enemy if RadarInvisible=true, none otherwise
18121811
```
18131812

1813+
### Stationary units
1814+
1815+
- 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:
1816+
- Cannot retaliate if target is beyond their weapon range.
1817+
- Cannot acquire units outside their weapon range on `Area Guard` mission.
1818+
- `Hunt` mission is reassigned to `Guard`.
1819+
- 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.
1820+
18141821
### Subterranean unit travel height and speed
18151822

18161823
- It is now possible to control the height at which units with subterranean (Tunnel) `Locomotor` travel, globally or per TechnoType.
@@ -2238,10 +2245,6 @@ SinkSpeed=5 ; integer, leptons per frame
22382245
Sinkable.SquidGrab=true ; boolean
22392246
```
22402247

2241-
### Stationary vehicles
2242-
2243-
- 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.
2244-
22452248
### Turret recoil
22462249

22472250
- Now you can use `TurretRecoil` to control units' turret/barrel recoil effect when firing.

docs/New-or-Enhanced-Logics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2270,7 +2270,7 @@ JumpjetTilt.SidewaysSpeedFactor=1.0 ; floating point value
22702270
### Turret Response
22712271

22722272
- When the vehicle loses its target, you can customize whether to align the turret direction with the vehicle body.
2273-
- When `Speed=0` or TechnoTypes cells cannot move due to `MovementRestrictedTo`, the default value is no; in other cases, it is yes.
2273+
- 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.
22742274

22752275
In `rulesmd.ini`:
22762276
```ini

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ New:
542542
- Allow jumpjet climbing ignore building height (by TaranDahl)
543543
- [Allow draw SuperWeapon timer as percentage](User-Interface.md#allow-draw-superweapon-timer-as-percentage) (by NetsuNegi)
544544
- Customize particle system of parasite logic (by NetsuNegi)
545+
- [Improvements to stationary unit logic](Fixed-or-Improved-Logics.md#stationary-units) (by Starkku)
545546
546547
Vanilla fixes:
547548
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)

src/Ext/Script/Mission.Attack.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,11 @@ void ScriptExt::Mission_Attack(TeamClass* pTeam, int calcThreatMode, bool repeat
235235
continue;
236236
}
237237

238-
const auto whatAmI = pFoot->WhatAmI();
239-
240-
// If the vehicle cannot be moved, perhaps it is better this way.
241-
if (whatAmI == AbstractType::Unit
242-
&& TechnoExt::CannotMove(static_cast<UnitClass*>(pFoot))
243-
&& !pFoot->IsCloseEnough(pSelectedTarget, pFoot->SelectWeapon(pSelectedTarget)))
244-
{
238+
// If the unit cannot be moved, perhaps it is better this way.
239+
if (TechnoExt::CannotMove(pFoot, true) && !pFoot->IsCloseEnough(pSelectedTarget, pFoot->SelectWeapon(pSelectedTarget)))
245240
continue;
246-
}
241+
242+
const auto whatAmI = pFoot->WhatAmI();
247243

248244
// Aircraft hack. I hate how this game auto-manages the aircraft missions.
249245
if (whatAmI == AbstractType::Aircraft

src/Ext/Techno/Body.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -747,28 +747,34 @@ bool TechnoExt::IsHealthInThreshold(TechnoClass* pObject, double min, double max
747747
return (hp > 0 ? hp > min : hp >= min) && hp <= max;
748748
}
749749

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

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

757-
const auto movementRestrictedTo = pType->MovementRestrictedTo;
758-
759-
if (movementRestrictedTo == LandType::None)
760-
return false;
757+
if (checkSpeedMultiplier && TechnoExt::GetCurrentSpeedMultiplier(pThis) <= 0.0)
758+
return true;
761759

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

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

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

770-
if (movementRestrictedTo != landType)
771-
return true;
769+
if (movementRestrictedTo == LandType::None)
770+
return false;
771+
772+
if (!pThis->OnBridge && (landType == LandType::Water || landType == LandType::Beach))
773+
landType = LandType::Road;
774+
775+
if (movementRestrictedTo != landType)
776+
return true;
777+
}
772778

773779
return false;
774780
}

src/Ext/Techno/Body.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ class TechnoExt
289289
static bool IsVeterancyInThreshold(TechnoClass* pObject, double min, double max);
290290
static UnitTypeClass* GetUnitTypeExtra(UnitClass* pUnit, TechnoTypeExt::ExtData* pData);
291291
static AircraftTypeClass* GetAircraftTypeExtra(AircraftClass* pAircraft);
292-
static bool CannotMove(UnitClass* pThis);
292+
static bool CannotMove(FootClass* pThis, bool checkSpeedMultiplier);
293293
static bool HasAmmoToDeploy(TechnoClass* pThis);
294294
static void HandleOnDeployAmmoChange(TechnoClass* pThis, int maxAmmoOverride = -1);
295295
static bool SimpleDeployerAllowedToDeploy(UnitClass* pThis, bool defaultValue, bool alwaysCheckLandTypes);

0 commit comments

Comments
 (0)