Skip to content

Commit c32138f

Browse files
committed
Improvements to stationary unit logic
1 parent 7333a45 commit c32138f

12 files changed

Lines changed: 417 additions & 249 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
@@ -165,7 +165,7 @@
165165
<ClCompile Include="src\Ext\TerrainType\Hooks.cpp" />
166166
<ClCompile Include="src\Ext\TerrainType\Hooks.Passable.cpp" />
167167
<ClCompile Include="src\Ext\Unit\Hooks.DeployFire.cpp" />
168-
<ClCompile Include="src\Ext\Unit\Hooks.DisallowMoving.cpp" />
168+
<ClCompile Include="src\Ext\Techno\Hooks.DisallowMoving.cpp" />
169169
<ClCompile Include="src\Ext\Unit\Hooks.DeploysInto.cpp" />
170170
<ClCompile Include="src\Ext\Unit\Hooks.Jumpjet.cpp" />
171171
<ClCompile Include="src\Ext\WarheadType\Detonate.cpp" />

YRpp

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.
@@ -1799,6 +1798,14 @@ In `rulesmd.ini`:
17991798
RadarInvisibleToHouse= ; Affected House Enumeration (none|owner/self|allies/ally|team|enemies/enemy|all), default to enemy if RadarInvisible=true, none otherwise
18001799
```
18011800

1801+
### Stationary units
1802+
1803+
- 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:
1804+
- Cannot retaliate if target is beyond their weapon range.
1805+
- Cannot acquire units outside their weapon range on `Area Guard` mission.
1806+
- `Hunt` mission is reassigned to `Guard`.
1807+
- 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.
1808+
18021809
### Subterranean unit travel height and speed
18031810

18041811
- It is now possible to control the height at which units with subterranean (Tunnel) `Locomotor` travel, globally or per TechnoType.
@@ -2224,10 +2231,6 @@ SinkSpeed=5 ; integer, leptons per frame
22242231
Sinkable.SquidGrab=true ; boolean
22252232
```
22262233

2227-
### Stationary vehicles
2228-
2229-
- 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.
2230-
22312234
### Turret recoil
22322235

22332236
- 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
@@ -2269,7 +2269,7 @@ JumpjetTilt.SidewaysSpeedFactor=1.0 ; floating point value
22692269
### Turret Response
22702270

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

22742274
In `rulesmd.ini`:
22752275
```ini

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ New:
539539
- [Penetrates damage on transporter](New-or-Enhanced-Logics.md#penetrates-damage-on-transporter) (by NetsuNegi)
540540
- Added amount limit of `LimboKill` (by NetsuNegi)
541541
- [Customizations for techno type target scan/guard range](Fixed-or-Improved-Logics.md#target-scan-guard-range-customizations) (by Starkku)
542+
- [Improvements to stationary unit logic](Fixed-or-Improved-Logics.md#stationary-units) (by Starkku)
542543
543544
Vanilla fixes:
544545
- 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
@@ -746,28 +746,34 @@ bool TechnoExt::IsHealthInThreshold(TechnoClass* pObject, double min, double max
746746
return (hp > 0 ? hp > min : hp >= min) && hp <= max;
747747
}
748748

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

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

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

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

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

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

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

772778
return false;
773779
}

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)