Skip to content

Commit 77d7b79

Browse files
authored
[Vanillia Enhancement] Customize harvester dump amount (#1636)
- Now you can limit how much ore the harvester can dump out per time, like it in Tiberium Sun. - 现在你可以限制矿车每次能倾倒出多少矿石,就像《泰伯利亚之日》中的那样。 - Less than or equal to 0 means no limit, it will always dump out all at one time. - 小于等于0意味着没有限制,它总是一次性倒光全部矿石。 In `rulesmd.ini`: ```ini [General] HarvesterDumpAmount=0.0 ; float point value [SOMEVEHICLE] HarvesterDumpAmount= ; float point value ```
1 parent 913523a commit 77d7b79

File tree

9 files changed

+50
-0
lines changed

9 files changed

+50
-0
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ This page lists all the individual contributions to the project by their author.
377377
- Fix wrong shadow when a vehicle has hover locomotor and is being lifted by `IsLocomotor=yes` warhead
378378
- Fix the bug that a unit can overlap with `Teleport` units after it's been damaged by a fallen unit lifted by `IsLocomotor=yes` warheads
379379
- Customize parasite culling targets
380+
- Customize harvester dump amount
380381
- **Apollo** - Translucent SHP drawing patches
381382
- **ststl**:
382383
- Customizable `ShowTimer` priority of superweapons

Phobos.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<ClCompile Include="src\Blowfish\blowfish.cpp" />
2222
<ClCompile Include="src\Blowfish\Hooks.Blowfish.cpp" />
2323
<ClCompile Include="src\Ext\TechnoType\Hooks.MatrixOp.cpp" />
24+
<ClCompile Include="src\Ext\Unit\Hooks.Harvester.cpp" />
2425
<ClCompile Include="src\Ext\Unit\Hooks.Sinking.cpp" />
2526
<ClCompile Include="src\Misc\Hooks.AlphaImage.cpp" />
2627
<ClCompile Include="src\New\Entity\AttachEffectClass.cpp" />

docs/Fixed-or-Improved-Logics.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,20 @@ In `artmd.ini`:
14851485
TurretShadow= ; boolean
14861486
```
14871487

1488+
### Customize harvester dump amount
1489+
1490+
- Now you can limit how much ore the harvester can dump out per time, like it in Tiberium Sun.
1491+
- Less than or equal to 0 means no limit, it will always dump out all at one time.
1492+
1493+
In `rulesmd.ini`:
1494+
```ini
1495+
[General]
1496+
HarvesterDumpAmount=0.0 ; float point value
1497+
1498+
[SOMEVEHICLE]
1499+
HarvesterDumpAmount= ; float point value
1500+
```
1501+
14881502
## Veinholes & Weeds
14891503

14901504
### Veinholes

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ New:
363363
- [Overload characteristic dehardcoded](New-or-Enhanced-Logics.md#overload-characteristic-dehardcoded) (by Otamaa)
364364
- [RadarInvisible for non-enemy house](Fixed-or-Improved-Logics.md#radarinvisible-for-non-enemy-house) (By TaranDahl)
365365
- New `Pips.HideIfNoStrength` and `SelfHealing.EnabledBy` additions for shields (by FS-21)
366+
- [Customize harvester dump amount](New-or-Enhanced-Logics.md#customize-harvester-dump-amount) (by NetsuNegi)
366367
367368
Vanilla fixes:
368369
- Prevent the units with locomotors that cause problems from entering the tank bunker (by TaranDahl)

src/Ext/Rules/Body.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
6868
INI_EX exINI(pINI);
6969

7070
this->Storage_TiberiumIndex.Read(exINI, GameStrings::General, "Storage.TiberiumIndex");
71+
this->HarvesterDumpAmount.Read(exINI, GameStrings::General, "HarvesterDumpAmount");
7172
this->InfantryGainSelfHealCap.Read(exINI, GameStrings::General, "InfantryGainSelfHealCap");
7273
this->UnitsGainSelfHealCap.Read(exINI, GameStrings::General, "UnitsGainSelfHealCap");
7374
this->GainSelfHealAllowMultiplayPassive.Read(exINI, GameStrings::General, "GainSelfHealAllowMultiplayPassive");
@@ -319,6 +320,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
319320
.Process(this->AITargetTypesLists)
320321
.Process(this->AIScriptsLists)
321322
.Process(this->Storage_TiberiumIndex)
323+
.Process(this->HarvesterDumpAmount)
322324
.Process(this->InfantryGainSelfHealCap)
323325
.Process(this->UnitsGainSelfHealCap)
324326
.Process(this->GainSelfHealAllowMultiplayPassive)

src/Ext/Rules/Body.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class RulesExt
3232
std::vector<std::vector<ScriptTypeClass*>> AIScriptsLists;
3333

3434
Valueable<int> Storage_TiberiumIndex;
35+
Valueable<float> HarvesterDumpAmount;
3536
Nullable<int> InfantryGainSelfHealCap;
3637
Nullable<int> UnitsGainSelfHealCap;
3738
Valueable<bool> GainSelfHealAllowMultiplayPassive;
@@ -209,6 +210,7 @@ class RulesExt
209210

210211
ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
211212
, Storage_TiberiumIndex { -1 }
213+
, HarvesterDumpAmount { 0.0f }
212214
, InfantryGainSelfHealCap {}
213215
, UnitsGainSelfHealCap {}
214216
, GainSelfHealAllowMultiplayPassive { true }

src/Ext/TechnoType/Body.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
300300
this->ForbidParallelAIQueues.Read(exINI, pSection, "ForbidParallelAIQueues");
301301
this->ShieldType.Read<true>(exINI, pSection, "ShieldType");
302302

303+
this->HarvesterDumpAmount.Read(exINI, pSection, "HarvesterDumpAmount");
304+
303305
this->Ammo_AddOnDeploy.Read(exINI, pSection, "Ammo.AddOnDeploy");
304306
this->Ammo_AutoDeployMinimumAmount.Read(exINI, pSection, "Ammo.AutoDeployMinimumAmount");
305307
this->Ammo_AutoDeployMaximumAmount.Read(exINI, pSection, "Ammo.AutoDeployMaximumAmount");
@@ -739,6 +741,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
739741
.Process(this->ShieldType)
740742
.Process(this->PassengerDeletionType)
741743

744+
.Process(this->HarvesterDumpAmount)
745+
742746
.Process(this->Ammo_AddOnDeploy)
743747
.Process(this->Ammo_AutoDeployMinimumAmount)
744748
.Process(this->Ammo_AutoDeployMaximumAmount)

src/Ext/TechnoType/Body.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ class TechnoTypeExt
6262
std::unique_ptr<PassengerDeletionTypeClass> PassengerDeletionType;
6363
std::unique_ptr<DroppodTypeClass> DroppodType;
6464

65+
Nullable<float> HarvesterDumpAmount;
66+
6567
Valueable<int> Ammo_AddOnDeploy;
6668
Valueable<int> Ammo_AutoDeployMinimumAmount;
6769
Valueable<int> Ammo_AutoDeployMaximumAmount;
@@ -417,6 +419,8 @@ class TechnoTypeExt
417419
, DeployingAnim_ReverseForUndeploy { true }
418420
, DeployingAnim_UseUnitDrawer { true }
419421

422+
, HarvesterDumpAmount {}
423+
420424
, Ammo_AddOnDeploy { 0 }
421425
, Ammo_AutoDeployMinimumAmount { -1 }
422426
, Ammo_AutoDeployMaximumAmount { -1 }

src/Ext/Unit/Hooks.Harvester.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <UnitClass.h>
2+
3+
#include <Ext/TechnoType/Body.h>
4+
5+
DEFINE_HOOK(0x73E411, UnitClass_Mission_Unload_DumpAmount, 0x7)
6+
{
7+
enum { SkipGameCode = 0x73E41D };
8+
9+
GET(UnitClass*, pThis, ESI);
10+
GET(int, tiberiumIdx, EBP);
11+
const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->Type);
12+
const float totalAmount = pThis->Tiberium.GetAmount(tiberiumIdx);
13+
float dumpAmount = pTypeExt->HarvesterDumpAmount.Get(RulesExt::Global()->HarvesterDumpAmount);
14+
15+
if (dumpAmount <= 0.0f || totalAmount < dumpAmount)
16+
dumpAmount = totalAmount;
17+
18+
__asm fld dumpAmount;
19+
20+
return SkipGameCode;
21+
}

0 commit comments

Comments
 (0)