Skip to content

Commit f64c5f5

Browse files
NetsuNegiCoronia
andauthored
[Vanilla Enhancement] Customize limit when engineer repair a building (#1718)
- You can now set a maximum amount when engineer repair a building for either of them. 0 means the building will be repaired to full health. - 现在你可以设置工程师修复建筑时的修复量限制了。0意味着建筑会被直接修满(不限制)。 - Negative value means percentage. For example, `EngineerRepairAmount=-50` means you can only repair 50% of the building's health per Engineer. - 负数意味着百分比。例如, `EngineerRepairAmount=-50` 意味着每次工程师最多只可以修复50%的血量。 - If both the building and the engineer has `EngineerRepairAmount` set, the actual repair amount will be the minimum of them. - 如果工程师与建筑都设置了 `EngineerRepairAmount` ,则实际的维修量将取更小者(按计算后的实际维修量对比)。 - `BuildingRepairedSound` can now be set individually for each building type. - `BuildingRepairedSound` 现在可以被用来设置每个建筑物单独的修复音效。 - Fixed the bug that damaged particle dont disappear after building has repaired by engineer. - 修复了工程师修复建筑后,建筑物的受损粒子不会立即消失的bug。 In `rulesmd.ini` ```ini [SOMEBUILDING] ; BuildingType EngineerRepairAmount=0 ; integer BuildingRepairedSound= ; Sound entry, default to [AudioVisual] -> BuildingRepairedSound [SOMEINFANTRY] ; InfantryType EngineerRepairAmount=0 ; integer ``` --------- Co-authored-by: Coronia <[email protected]>
1 parent 6f61cbf commit f64c5f5

File tree

9 files changed

+86
-5
lines changed

9 files changed

+86
-5
lines changed

CREDITS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ This page lists all the individual contributions to the project by their author.
411411
- Fix the bug that AlphaImage remained after unit entered tunnel
412412
- Weapon target filtering by health percentage
413413
- Fix the bug that `DamageSelf` and `AllowDamageOnSelf` are ineffective on airforce
414+
- Customize limit when engineer repair a building
415+
- Fix the bug that damaged particle dont disappear after building has repaired by engineer
414416
- **Apollo** - Translucent SHP drawing patches
415417
- **ststl**:
416418
- Customizable `ShowTimer` priority of superweapons

docs/Fixed-or-Improved-Logics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
232232
- Infantry support `IsGattling=yes`.
233233
- Fixed the issue that the widespread damage caused by detonation on the bridge/ground cannot affect objects on the ground/bridge who are in the opposite case.
234234
- Fixed the bug that `DamageSelf` and `AllowDamageOnSelf` are ineffective on airforce.
235+
- Fixed the bug that damaged particle dont disappear after building has repaired by engineer.
235236

236237
## Fixes / interactions with other extensions
237238

docs/New-or-Enhanced-Logics.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ PowerPlantEnhancer.Amount=0 ; integer
591591
PowerPlantEnhancer.Factor=1.0 ; floating point value
592592
```
593593

594-
### Spy Effects
594+
### Spy effects
595595

596596
- Additional espionage bonuses can be toggled with `SpyEffect.Custom`.
597597
- `SpyEffect.VictimSuperWeapon` instantly launches a Super Weapon for the owner of the infiltrated building at building's coordinates.
@@ -605,9 +605,26 @@ SpyEffect.VictimSuperWeapon= ; SuperWeaponType
605605
SpyEffect.InfiltratorSuperWeapon= ; SuperWeaponType
606606
```
607607

608+
### Engineer repair customization
609+
610+
- You can now set a maximum amount when engineer repair a building for either of them. 0 means the building will be repaired to full health.
611+
- Negative value means percentage. For example, `EngineerRepairAmount=-50` means you can only repair 50% of the building's health per Engineer.
612+
- If both the building and the engineer has `EngineerRepairAmount` set, the actual repair amount will be the minimum of them.
613+
- `BuildingRepairedSound` can now be set individually for each building type.
614+
615+
In `rulesmd.ini`
616+
```ini
617+
[SOMEBUILDING] ; BuildingType
618+
EngineerRepairAmount=0 ; integer
619+
BuildingRepairedSound= ; Sound entry, default to [AudioVisual] -> BuildingRepairedSound
620+
621+
[SOMEINFANTRY] ; InfantryType
622+
EngineerRepairAmount=0 ; integer
623+
```
624+
608625
## Infantry
609626

610-
### Customizable FLH When Infantry Is Prone Or Deployed
627+
### Customizable FLH when infantry is prone or deployed
611628

612629
- Now infantry can override `PrimaryFireFLH` and `SecondaryFireFLH` if is prone (crawling) or deployed. Also works in conjunction with [burst-index specific firing offsets](#firing-offsets-for-specific-burst-shots).
613630

@@ -622,14 +639,14 @@ DeployedSecondaryFireFLH= ; integer - Forward,Lateral,Height
622639

623640
### Customizable `SlavesFreeSound`
624641

625-
- `SlavesFreeSound` is now dehardcoded from `[AudioVisual]` and can be set individually for each enslavable infantry type.
642+
- `SlavesFreeSound` can now be set individually for each enslavable infantry type.
626643

627644
In `rulesmd.ini`:
628645

629646
```ini
630647
[SOMEINFANTRY] ; InfantryType
631648
Slaved=yes
632-
SlavesFreeSound= ; Sound entry
649+
SlavesFreeSound= ; Sound entry, default to [AudioVisual] -> SlavesFreeSound
633650
```
634651

635652
### Default disguise for individual InfantryTypes
@@ -643,7 +660,7 @@ In `rulesmd.ini`:
643660
DefaultDisguise= ; InfantryType
644661
```
645662

646-
### Random death animaton for NotHuman Infantry
663+
### Random death animaton for NotHuman infantry
647664

648665
- Infantry with `NotHuman=yes` can now play random death anim sequence between `Die1` to `Die5` instead of the hardcoded `Die1`.
649666
- Do not forget to tweak infantry anim sequences before enabling this feature, otherwise it will play invisible anim sequence.

docs/Whats-New.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ New:
393393
- [Several new Infotypes, no display in specific status and a new single frame display method](User-Interface.md#digital-display) (by CrimRecya)
394394
- Targeting limitation for berzerk technos (by TaranDahl)
395395
- Allowed faking digital display for `InfoType=Health` at disguise (by Ollerus)
396+
- [Customize limit and sound when engineer repair a building](New-or-Enhanced-Logics.md#engineer-repair-customization) (by NetsuNegi)
396397
397398
Vanilla fixes:
398399
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
@@ -418,6 +419,7 @@ Vanilla fixes:
418419
- Second weapon with `ElectricAssault=yes` will not unconditionally attack your building with `Overpowerable=yes` (by FlyStar)
419420
- Fixed the issue that the widespread damage caused by detonation on the bridge/ground cannot affect objects on the ground/bridge who are in the opposite case (by CrimRecya)
420421
- Fixed the bug that `DamageSelf` and `AllowDamageOnSelf` are ineffective on airforce (by NetsuNegi)
422+
- Fixed the bug that damaged particle dont disappear after building has repaired by engineer (by NetsuNegi)
421423
422424
Phobos fixes:
423425
- Fixed the bug that `AllowAirstrike=no` cannot completely prevent air strikes from being launched against it (by NetsuNegi)

src/Ext/BuildingType/Body.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ void BuildingTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
200200
this->BuildingBunkerROFMult.Read(exINI, pSection, "BunkerROFMultMultiplier");
201201
this->BunkerWallsUpSound.Read(exINI, pSection, "BunkerWallsUpSound");
202202
this->BunkerWallsDownSound.Read(exINI, pSection, "BunkerWallsDownSound");
203+
this->BuildingRepairedSound.Read(exINI, pSection, "BuildingRepairedSound");
203204

204205
if (pThis->NumberOfDocks > 0)
205206
{
@@ -335,6 +336,7 @@ void BuildingTypeExt::ExtData::Serialize(T& Stm)
335336
.Process(this->BuildingBunkerROFMult)
336337
.Process(this->BunkerWallsUpSound)
337338
.Process(this->BunkerWallsDownSound)
339+
.Process(this->BuildingRepairedSound)
338340
;
339341
}
340342

src/Ext/BuildingType/Body.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class BuildingTypeExt
9292
Nullable<float> BuildingBunkerROFMult;
9393
NullableIdx<VocClass> BunkerWallsUpSound;
9494
NullableIdx<VocClass> BunkerWallsDownSound;
95+
NullableIdx<VocClass> BuildingRepairedSound;
9596

9697
ExtData(BuildingTypeClass* OwnerObject) : Extension<BuildingTypeClass>(OwnerObject)
9798
, PowersUp_Owner { AffectedHouse::Owner }
@@ -152,6 +153,7 @@ class BuildingTypeExt
152153
, BuildingBunkerROFMult {}
153154
, BunkerWallsUpSound {}
154155
, BunkerWallsDownSound {}
156+
, BuildingRepairedSound {}
155157
{ }
156158

157159
// Ares 0.A functions

src/Ext/Techno/Hooks.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,3 +989,50 @@ DEFINE_HOOK(0x6FCF3E, TechnoClass_SetTarget_After, 0x6)
989989
}
990990

991991
#pragma endregion
992+
993+
DEFINE_HOOK(0x519FEC, InfantryClass_UpdatePosition_EngineerRepair, 0xA)
994+
{
995+
enum { SkipGameCode = 0x51A010 };
996+
997+
GET(InfantryClass*, pThis, ESI);
998+
GET(BuildingClass*, pTarget, EDI);
999+
const bool wasDamaged = pTarget->GetHealthPercentage() <= RulesClass::Instance->ConditionYellow;
1000+
1001+
pTarget->Mark(MarkType::Change);
1002+
1003+
const int repairBuilding = TechnoTypeExt::ExtMap.Find(pTarget->Type)->EngineerRepairAmount;
1004+
const int repairEngineer = TechnoTypeExt::ExtMap.Find(pThis->Type)->EngineerRepairAmount;
1005+
const int strength = pTarget->Type->Strength;
1006+
1007+
auto repair = [strength, pTarget](int repair)
1008+
{
1009+
int repairAmount = strength;
1010+
1011+
if (repair > 0)
1012+
{
1013+
repairAmount = std::clamp(pTarget->Health + repair, 0, strength);
1014+
}
1015+
else if (repair < 0)
1016+
{
1017+
const double percentage = std::clamp(pTarget->GetHealthPercentage() - (static_cast<double>(repair) / 100), 0.0, 1.0);
1018+
repairAmount = static_cast<int>(std::round(strength * percentage));
1019+
}
1020+
1021+
return repairAmount;
1022+
};
1023+
1024+
pTarget->Health = Math::min(repair(repairBuilding), repair(repairEngineer));
1025+
pTarget->EstimatedHealth = pTarget->Health;
1026+
pTarget->SetRepairState(0);
1027+
1028+
if ((pTarget->GetHealthPercentage() <= RulesClass::Instance->ConditionYellow) != wasDamaged)
1029+
{
1030+
pTarget->ToggleDamagedAnims(!wasDamaged);
1031+
1032+
if (wasDamaged && pTarget->DamageParticleSystem)
1033+
pTarget->DamageParticleSystem->UnInit();
1034+
}
1035+
1036+
VocClass::PlayAt(BuildingTypeExt::ExtMap.Find(pTarget->Type)->BuildingRepairedSound.Get(RulesClass::Instance->BuildingRepairedSound), pTarget->GetCoords());
1037+
return SkipGameCode;
1038+
}

src/Ext/TechnoType/Body.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,8 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
693693

694694
this->FiringForceScatter.Read(exINI, pSection, "FiringForceScatter");
695695

696+
this->EngineerRepairAmount.Read(exINI, pSection, "EngineerRepairAmount");
697+
696698
// Ares 0.2
697699
this->RadarJamRadius.Read(exINI, pSection, "RadarJamRadius");
698700

@@ -1282,6 +1284,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
12821284
.Process(this->FireUp)
12831285
.Process(this->FireUp_ResetInRetarget)
12841286
//.Process(this->SecondaryFire)
1287+
1288+
.Process(this->EngineerRepairAmount)
12851289
;
12861290
}
12871291
void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)

src/Ext/TechnoType/Body.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ class TechnoTypeExt
376376
Valueable<bool> FireUp_ResetInRetarget;
377377
//Nullable<int> SecondaryFire;
378378

379+
Valueable<int> EngineerRepairAmount;
380+
379381
ExtData(TechnoTypeClass* OwnerObject) : Extension<TechnoTypeClass>(OwnerObject)
380382
, HealthBar_Hide { false }
381383
, UIDescription {}
@@ -702,6 +704,8 @@ class TechnoTypeExt
702704
, FireUp { -1 }
703705
, FireUp_ResetInRetarget { true }
704706
//, SecondaryFire {}
707+
708+
, EngineerRepairAmount { 0 }
705709
{ }
706710

707711
virtual ~ExtData() = default;

0 commit comments

Comments
 (0)