Skip to content

Commit 4ec5377

Browse files
Vehicle Deployment Enhancement (#2041)
- Fixed an issue where miners affected by `Passengers/DeployFire` were unable to unload minerals. - Fixed an issue where mining vehicles could not move after leaving a tank bunker. --------- - When a vehicle has `Passengers` and possesses `DeployFire/IsSimpleDeployer/DeploysInto`, it can perform custom deployment actions beyond merely releasing passengers. - `Deploy.SkipPassengerUnload` allows vehicles to bypass the passenger release process and perform other deployment actions. - `Deploy.NoPassenger` allows vehicles to perform other deployment actions after losing all passengers. - Harvester can now perform other deployment operations. Can't deploy when it's unloading minerals. - `Deploy.NoTiberium` controls whether the deployment actions can only be performed when the harvester carries no mineral. If set to false, the harvester can deploy regardless of carrying minerals or not. In `rulesmd.ini`: ```ini [SOMEVEHICLE] ; VehicleType Deploy.SkipPassengerUnload=false ; boolean Deploy.NoPassenger=false ; boolean Deploy.NoTiberium=false ; boolean ``` --------- Co-authored-by: Fly-Star <100747645+a851903106@users.noreply.github.com> Co-authored-by: Coronia <2217891145@qq.com>
1 parent 6bf0d09 commit 4ec5377

9 files changed

Lines changed: 129 additions & 17 deletions

File tree

CREDITS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,9 @@ This page lists all the individual contributions to the project by their author.
406406
- Map Action 511, 609, 610
407407
- Weapons now support `AttackFriendlies` and `AttackCursorOnFriendlies`
408408
- Attack non-threatening structures extensions
409+
- Vehicle Deployment Enhancement
410+
- Fixed an issue where miners affected by `Passengers/DeployFire` were unable to unload minerals
411+
- Fixed an issue where mining vehicles could not move after leaving a tank bunker
409412
- **NetsuNegi**:
410413
- Forbidding parallel AI queues by type
411414
- Jumpjet crash speed fix when crashing onto building

Phobos.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<ClCompile Include="src\Ext\EBolt\Body.cpp" />
2929
<ClCompile Include="src\Ext\EBolt\Hooks.cpp" />
3030
<ClCompile Include="src\Ext\Unit\Hooks.SimpleDeployer.cpp" />
31+
<ClCompile Include="src\Ext\Unit\Hooks.Unload.cpp" />
3132
<ClCompile Include="src\New\Entity\Ares\RadarJammerClass.cpp" />
3233
<ClCompile Include="src\New\Type\Affiliated\CreateUnitTypeClass.cpp" />
3334
<ClCompile Include="src\Blowfish\blowfish.cpp" />

docs/Fixed-or-Improved-Logics.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
289289
- Fixed an issue that the AI would look for the first house in the array as an enemy instead of the nearest one when there were no enemies.
290290
- Fixed the issue that weapon selection don't check if secondary's warhead has `IsLocomotor=yes`.
291291
- Fixed the issue that warhead with `IsLocomotor=yes` can be used to vehicles who is in tank bunker.
292+
- Fixed an issue where miners affected by `Passengers/DeployFire` were unable to unload minerals.
293+
- Fixed an issue where mining vehicles could not move after leaving a tank bunker.
292294

293295
## Fixes / interactions with other extensions
294296

docs/New-or-Enhanced-Logics.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,6 +2211,22 @@ WaterImage.ConditionRed= ; VehicleType entry
22112211
Note that the VehicleTypes had to be defined under [VehicleTypes] and use same image type (SHP/VXL) for vanilla/damaged states.
22122212
```
22132213

2214+
### Deployment Enhancement
2215+
2216+
- When a vehicle has `Passengers` and possesses `DeployFire/IsSimpleDeployer/DeploysInto`, it can perform custom deployment actions beyond merely releasing passengers.
2217+
- `Deploy.SkipPassengerUnload` allows vehicles to bypass the passenger release process and perform other deployment actions.
2218+
- `Deploy.NoPassenger` allows vehicles to perform other deployment actions after losing all passengers.
2219+
- Harvester can now perform other deployment operations. Can't deploy when it's unloading minerals.
2220+
- `Deploy.NoTiberium` controls whether the deployment actions can only be performed when the harvester carries no mineral. If set to false, the harvester can deploy regardless of carrying minerals or not.
2221+
2222+
In `rulesmd.ini`:
2223+
```ini
2224+
[SOMEVEHICLE] ; VehicleType
2225+
Deploy.SkipPassengerUnload=false ; boolean
2226+
Deploy.NoPassenger=false ; boolean
2227+
Deploy.NoTiberium=false ; boolean
2228+
```
2229+
22142230
### Jumpjet Tilts While Moving
22152231

22162232
![image](_static/images/jumpjet-tilt.gif)

docs/Whats-New.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ New:
520520
- [Deploy priority filtering](New-or-Enhanced-Logics.md#low-priority-for-deploy) (by Starkku)
521521
- [Weapon target filtering by target veterancy](New-or-Enhanced-Logics.md#weapon-targeting-filter) (by Flactine)
522522
- [Warhead effect filtering by target veterancy](Fixed-or-Improved-Logics.md#customizable-warhead-trigger-conditions) (by Flactine)
523+
- Vehicle Deployment Enhancement (by FlyStar)
523524
524525
Vanilla fixes:
525526
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
@@ -570,6 +571,8 @@ Vanilla fixes:
570571
- Fixed an issue that the AI would look for the first house in the array as an enemy instead of the nearest one when there were no enemies (by TaranDahl)
571572
- Fixed the issue that weapon selection don't check if secondary's warhead has `IsLocomotor=yes` (by NetsuNegi)
572573
- Fixed the issue that warhead with `IsLocomotor=yes` can be used to vehicles who is in tank bunker (by NetsuNegi)
574+
- Fixed an issue where miners affected by `Passengers/DeployFire` were unable to unload minerals (by FlyStar)
575+
- Fixed an issue where mining vehicles could not move after leaving a tank bunker (by FlyStar)
573576
574577
Phobos fixes:
575578
- Fixed the bug that `AllowAirstrike=no` cannot completely prevent air strikes from being launched against it (by NetsuNegi)

src/Ext/Techno/Hooks.Misc.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -866,23 +866,6 @@ DEFINE_HOOK(0x730D1F, ProcessDeployCommand_VoiceDeploy, 0x5)
866866

867867
#pragma endregion
868868

869-
870-
// Prevent subterranean units from deploying while underground.
871-
DEFINE_HOOK(0x73D6E6, UnitClass_Unload_Subterranean, 0x6)
872-
{
873-
enum { ReturnFromFunction = 0x73DFB0 };
874-
875-
GET(UnitClass*, pThis, ESI);
876-
877-
if (auto const pLoco = locomotion_cast<TunnelLocomotionClass*>(pThis->Locomotor))
878-
{
879-
if (pLoco->State != TunnelLocomotionClass::State::Idle)
880-
return ReturnFromFunction;
881-
}
882-
883-
return 0;
884-
}
885-
886869
#pragma region Events
887870

888871
DEFINE_HOOK(0x4C7512, EventClass_Execute_StopCommand, 0x6)

src/Ext/TechnoType/Body.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,9 @@ void TechnoTypeExt::ExtData::LoadFromINIByWhatAmI(INI_EX& exINI, const char* pSe
13901390
this->FireUp.Read(exArtINI, pArtSection, "FireUp");
13911391
this->FireUp_ResetInRetarget.Read(exArtINI, pArtSection, "FireUp.ResetInRetarget");
13921392
this->TurretResponse.Read(exINI, pSection, "TurretResponse");
1393+
this->Deploy_SkipPassengerUnload.Read(exINI, pSection, "Deploy.SkipPassengerUnload");
1394+
this->Deploy_NoPassenger.Read(exINI, pSection, "Deploy.NoPassenger");
1395+
this->Deploy_NoTiberium.Read(exINI, pSection, "Deploy.NoTiberium");
13931396
//this->SecondaryFire.Read(exArtINI, pArtSection, "SecondaryFire");
13941397
break;
13951398
}
@@ -1818,6 +1821,10 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
18181821
.Process(this->TurretResponse)
18191822

18201823
.Process(this->AttackFriendlies)
1824+
1825+
.Process(this->Deploy_SkipPassengerUnload)
1826+
.Process(this->Deploy_NoPassenger)
1827+
.Process(this->Deploy_NoTiberium)
18211828
;
18221829
}
18231830
void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)

src/Ext/TechnoType/Body.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,10 @@ class TechnoTypeExt
458458

459459
Vector2D<bool> AttackFriendlies;
460460

461+
Valueable<bool> Deploy_SkipPassengerUnload;
462+
Valueable<bool> Deploy_NoPassenger;
463+
Valueable<bool> Deploy_NoTiberium;
464+
461465
ExtData(TechnoTypeClass* OwnerObject) : Extension<TechnoTypeClass>(OwnerObject)
462466
, HealthBar_Hide { false }
463467
, HealthBar_HidePips { false }
@@ -869,6 +873,10 @@ class TechnoTypeExt
869873
, TurretResponse {}
870874

871875
, AttackFriendlies { false,false }
876+
877+
, Deploy_SkipPassengerUnload { false }
878+
, Deploy_NoPassenger { false }
879+
, Deploy_NoTiberium { false }
872880
{ }
873881

874882
virtual ~ExtData() = default;

src/Ext/Unit/Hooks.Unload.cpp

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#include <Helpers/Macro.h>
2+
#include <TunnelLocomotionClass.h>
3+
4+
#include <Ext/TechnoType/Body.h>
5+
6+
namespace UnitUnloadTemp
7+
{
8+
TechnoTypeExt::ExtData* TypeExtData = nullptr;
9+
}
10+
11+
// Prevent subterranean units from deploying while underground.
12+
DEFINE_HOOK(0x73D63B, UnitClass_Mi_Unload_Subterranean, 0x6)
13+
{
14+
enum { ReturnFromFunction = 0x73DFB0, SkipHarvester = 0x73D694, SkipPassengers = 0x73DCD3, Harvester = 0x73DEE7, Continue = 0x73D6EC };
15+
16+
GET(UnitClass* const, pThis, ESI);
17+
18+
if (auto const pLoco = locomotion_cast<TunnelLocomotionClass*>(pThis->Locomotor))
19+
{
20+
if (pLoco->State != TunnelLocomotionClass::State::Idle)
21+
return ReturnFromFunction;
22+
}
23+
24+
auto const pType = pThis->Type;
25+
auto const pTypeExt = TechnoTypeExt::ExtMap.Find(pType);
26+
UnitUnloadTemp::TypeExtData = pTypeExt;
27+
28+
// It should be the highest priority.
29+
if (pThis->BunkerLinkedItem)
30+
{
31+
if (auto const pBuilding = pThis->GetCell()->GetBuilding())
32+
pBuilding->EmptyBunker();
33+
34+
// It can fix the issue where mining carts cannot move.
35+
R->EAX(pType);
36+
return SkipHarvester;
37+
}
38+
39+
// Miners should not be hindered by other deployment actions while unloading minerals.
40+
if (pType->Harvester || pType->Weeder)
41+
{
42+
const bool hasAnyLink = pThis->HasAnyLink();
43+
44+
if (hasAnyLink || pThis->Unloading)
45+
{
46+
R->AL(hasAnyLink);
47+
return Harvester;
48+
}
49+
}
50+
51+
R->EAX(pType);
52+
53+
if (pTypeExt->Deploy_SkipPassengerUnload)
54+
return SkipPassengers;
55+
else if (pTypeExt->Deploy_NoPassenger && pThis->Passengers.NumPassengers <= 0 && pThis->MissionStatus == 0)
56+
return SkipPassengers;
57+
58+
return Continue;
59+
}
60+
61+
DEFINE_HOOK(0x73DEEB, UnitClass_Mi_Unload_SkipHarvester, 0x5)
62+
{
63+
GET(UnitClass* const, pThis, ESI);
64+
enum { SkipHarvester = 0x73D694 };
65+
66+
auto const pTypeExt = UnitUnloadTemp::TypeExtData;
67+
68+
if (!pThis->Unloading && (!pTypeExt->Deploy_NoTiberium || pThis->Tiberium.GetTotalValue() == 0))
69+
{
70+
R->EAX(pThis->Type);
71+
return SkipHarvester;
72+
}
73+
74+
return 0;
75+
}
76+
77+
DEFINE_HOOK(0x740015, UnitClass_MouseOverObject_SkipPassengers, 0x6)
78+
{
79+
enum { SkipPassengers = 0x7400F0 };
80+
81+
GET(UnitClass* const, pThis, ESI);
82+
GET(UnitTypeClass* const, pType, EAX);
83+
84+
auto const pTypeExt = TechnoTypeExt::ExtMap.Find(pType);
85+
86+
return pTypeExt->Deploy_SkipPassengerUnload
87+
|| (pTypeExt->Deploy_NoPassenger && pThis->Passengers.NumPassengers <= 0)
88+
? SkipPassengers : 0;
89+
}

0 commit comments

Comments
 (0)