Skip to content

[Dehardcode] Allow miners do area guard #1641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 26, 2025
Merged
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
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ This page lists all the individual contributions to the project by their author.
- Fix an issue where AI would select unreachable buildings and get stuck when looking for buildings like tank bunkers, bio reactors, etc
- Prone speed customization
- RadarInvisible for non-enemy house
- Allow miners do area guard
- **tyuah8**:
- Drive/Jumpjet/Ship/Teleport locomotor did not power on when it is un-piggybacked bugfix
- Destroyed unit leaves sensors bugfix
Expand Down
12 changes: 11 additions & 1 deletion docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,17 @@ MinimapColor= ; integer - Red,Green,Blue

## Vehicles

### Allow miners do area guard

- In vanilla, when miners enter area guard mission, they immediately switch to harvest mission. Now you can make them perform area guard mission normally like other technos.
- We made it work only for miners controlled by the player, because this will prevent AI's miners from going work.

In `rulesmd.ini`:
```ini
[SOMEVEHICLE] ; VehicleType
Harvester.CanGuardArea=no ; boolean
```

### Bunker entering check dehardcode

- In vanilla, vehicles entering tank bunkers are subject to a series of hardcoding restrictions, including having to have turrets, having to have weapons, and not having Hover speed types. Now you can skip these restrictions.
Expand All @@ -1350,7 +1361,6 @@ BunkerableAnyway=false ; boolean
Skipping checks with this feature doesn't mean that vehicles and tank bunkers will interact correctly. Following the simple checks performed by the provider of this feature, bunkerability is mainly determined by Locomotor. The details about locomotors' bunkerability can be found on [ModEnc](https://modenc.renegadeprojects.com/Bunkerable).
```


### Customizing crushing tilt and slowdown

- Vehicles with `Crusher=true` and `OmniCrusher=true` / `MovementZone=CrusherAll` were hardcoded to tilt when crushing vehicles / walls respectively. This now obeys `TiltsWhenCrushes` but can be customized individually for these two scenarios using `TiltsWhenCrusher.Vehicles` and `TiltsWhenCrusher.Overlays`, which both default to `TiltsWhenCrushes`.
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ New:
- Customize airstrike targets (by NetsuNegi)
- Aggressive attack move mission (by CrimRecya)
- Amphibious access vehicle (by CrimRecya)
- Allow miners do area guard (by TaranDahl)

Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
Expand Down
4 changes: 4 additions & 0 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->Overload_ParticleSys.Read(exINI, pSection, "Overload.ParticleSys");
this->Overload_ParticleSysCount.Read(exINI, pSection, "Overload.ParticleSysCount");

this->Harvester_CanGuardArea.Read(exINI, pSection, "Harvester.CanGuardArea");

// Ares 0.2
this->RadarJamRadius.Read(exINI, pSection, "RadarJamRadius");

Expand Down Expand Up @@ -1016,6 +1018,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->Overload_DeathSound)
.Process(this->Overload_ParticleSys)
.Process(this->Overload_ParticleSysCount)

.Process(this->Harvester_CanGuardArea)
;
}
void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)
Expand Down
4 changes: 4 additions & 0 deletions src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ class TechnoTypeExt
NullableIdx<VocClass> Overload_DeathSound;
Nullable<ParticleSystemTypeClass*> Overload_ParticleSys;
Valueable<int> Overload_ParticleSysCount;

Valueable<bool> Harvester_CanGuardArea;

ExtData(TechnoTypeClass* OwnerObject) : Extension<TechnoTypeClass>(OwnerObject)
, HealthBar_Hide { false }
Expand Down Expand Up @@ -641,6 +643,8 @@ class TechnoTypeExt
, Overload_DeathSound {}
, Overload_ParticleSys {}
, Overload_ParticleSysCount { 5 }

, Harvester_CanGuardArea { false }
{ }

virtual ~ExtData() = default;
Expand Down
12 changes: 12 additions & 0 deletions src/Ext/Unit/Hooks.Harvester.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <UnitClass.h>
#include <HouseClass.h>

#include <Ext/TechnoType/Body.h>

Expand All @@ -19,3 +20,14 @@ DEFINE_HOOK(0x73E411, UnitClass_Mission_Unload_DumpAmount, 0x7)

return SkipGameCode;
}

DEFINE_HOOK(0x4D6D34, FootClass_MissionAreaGuard_Miner, 0x5)
{
enum { GoGuardArea = 0x4D6D69 };

GET(FootClass*, pThis, ESI);

auto const pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType());

return pTypeExt->Harvester_CanGuardArea && pThis->Owner->IsControlledByHuman() ? GoGuardArea : 0;
}