Skip to content

Commit db34a8a

Browse files
committed
Allowed player's self-healing effects to be benefited by houses with PlayerControl=true in campaign
1 parent 6b245df commit db34a8a

File tree

6 files changed

+57
-14
lines changed

6 files changed

+57
-14
lines changed

CREDITS.md

+1
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ This page lists all the individual contributions to the project by their author.
419419
- Enhanced Bombard trajectory
420420
- Shield armor inheritance customization
421421
- Fix `DefaultDisguise` showing wrong house colors for different players
422+
- Allowed player's self-healing effects to be benefited by houses with `PlayerControl=true` in campaign
422423
- **NaotoYuuki** - Vertical & meteor trajectory projectile prototypes
423424
- **handama** - AI script action to `16005 Jump Back To Previous Script`
424425
- **TaranDahl (航味麻酱)**:

docs/Fixed-or-Improved-Logics.md

+2
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ BallisticScatter.Max= ; floating point value, distance in cells
619619

620620
- It is now possible to set a global cap for the effects of `InfantryGainSelfHeal` and `UnitsGainSelfHeal` by setting `InfantryGainSelfHealCap` & `UnitsGainSelfHealCap` under `[General]`, respectively.
621621
- Whether or not `MultiplayPassive=true` houses benefit from these effects can be controlled via `GainSelfHealAllowMultiplayPassive`.
622+
- In campaign, whether or not these effects for player can be benefited by houses with `PlayerControl=true` can be controlled via `GainSelfHealAllowPlayerControl`.
622623
- It is also possible to change the pip frames displayed from `pips.shp` individually for infantry, units and buildings by setting the frames for infantry & unit self-healing on `Pips.SelfHeal.Infantry/Units/Buildings` under `[AudioVisual]`, respectively.
623624
- `Pips.SelfHeal.Infantry/Units/Buildings.Offset` can be used to customize the pixel offsets for the displayed pips, individually for infantry, units and buildings.
624625
- Whether or not a TechnoType benefits from effects of `InfantryGainSelfHeal` or `UnitsGainSelfHeal` buildings or neither can now be controlled by setting `SelfHealGainType`.
@@ -630,6 +631,7 @@ In `rulesmd.ini`:
630631
InfantryGainSelfHealCap= ; integer, maximum amount of InfantryGainSelfHeal that can be in effect at once, must be 1 or higher
631632
UnitsGainSelfHealCap= ; integer, maximum amount of UnitsGainSelfHeal that can be in effect at once, must be 1 or higher
632633
GainSelfHealAllowMultiplayPassive=true ; boolean
634+
GainSelfHealAllowPlayerControl=false ; boolean
633635

634636
[AudioVisual]
635637
Pips.SelfHeal.Infantry=13,20 ; integer, frames of pips.shp for infantry & unit-self healing pips, respectively

docs/Whats-New.md

+1
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ New:
341341
- Play an anim when recycling a spawner (by TaranDahl)
342342
- Recycle the spawner on other FLH (by TaranDahl)
343343
- Technos can maintain a suitable distance after firing (by CrimRecya)
344+
- Allowed player's self-healing effects to be benefited by houses with `PlayerControl=true` in campaign (by Ollerus)
344345

345346
Vanilla fixes:
346347
- Prevent the units with locomotors that cause problems from entering the tank bunker (by TaranDahl)

src/Ext/Rules/Body.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
7171
this->InfantryGainSelfHealCap.Read(exINI, GameStrings::General, "InfantryGainSelfHealCap");
7272
this->UnitsGainSelfHealCap.Read(exINI, GameStrings::General, "UnitsGainSelfHealCap");
7373
this->GainSelfHealAllowMultiplayPassive.Read(exINI, GameStrings::General, "GainSelfHealAllowMultiplayPassive");
74+
this->GainSelfHealAllowPlayerControl.Read(exINI, GameStrings::General, "GainSelfHealAllowPlayerControl");
7475
this->EnemyInsignia.Read(exINI, GameStrings::General, "EnemyInsignia");
7576
this->DisguiseBlinkingVisibility.Read(exINI, GameStrings::General, "DisguiseBlinkingVisibility");
7677
this->ChronoSparkleDisplayDelay.Read(exINI, GameStrings::General, "ChronoSparkleDisplayDelay");
@@ -310,6 +311,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
310311
.Process(this->InfantryGainSelfHealCap)
311312
.Process(this->UnitsGainSelfHealCap)
312313
.Process(this->GainSelfHealAllowMultiplayPassive)
314+
.Process(this->GainSelfHealAllowPlayerControl)
313315
.Process(this->EnemyInsignia)
314316
.Process(this->DisguiseBlinkingVisibility)
315317
.Process(this->ChronoSparkleDisplayDelay)

src/Ext/Rules/Body.h

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class RulesExt
3535
Nullable<int> InfantryGainSelfHealCap;
3636
Nullable<int> UnitsGainSelfHealCap;
3737
Valueable<bool> GainSelfHealAllowMultiplayPassive;
38+
Valueable<bool> GainSelfHealAllowPlayerControl;
3839
Valueable<bool> EnemyInsignia;
3940
Valueable<AffectedHouse> DisguiseBlinkingVisibility;
4041
Valueable<int> ChronoSparkleDisplayDelay;
@@ -200,6 +201,7 @@ class RulesExt
200201
, InfantryGainSelfHealCap {}
201202
, UnitsGainSelfHealCap {}
202203
, GainSelfHealAllowMultiplayPassive { true }
204+
, GainSelfHealAllowPlayerControl { false }
203205
, EnemyInsignia { true }
204206
, DisguiseBlinkingVisibility { AffectedHouse::Owner }
205207
, ChronoSparkleDisplayDelay { 24 }

src/Ext/Techno/Body.Update.cpp

+49-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// methods used in TechnoClass_AI hooks or anything similar
22
#include "Body.h"
33

4+
#include <SessionClass.h>
45
#include <SpawnManagerClass.h>
56
#include <ParticleSystemClass.h>
67

@@ -678,33 +679,67 @@ void TechnoExt::ApplyGainedSelfHeal(TechnoClass* pThis)
678679
if (selfHealType == SelfHealGainType::NoHeal)
679680
return;
680681

681-
bool applyHeal = false;
682682
int amount = 0;
683+
auto const pOwner = pThis->Owner;
683684

684685
if (selfHealType == SelfHealGainType::Infantry)
685686
{
686-
int count = RulesExt::Global()->InfantryGainSelfHealCap.isset() ?
687-
std::min(std::max(RulesExt::Global()->InfantryGainSelfHealCap.Get(), 1), pThis->Owner->InfantrySelfHeal) :
688-
pThis->Owner->InfantrySelfHeal;
687+
if (Unsorted::CurrentFrame % RulesClass::Instance->SelfHealInfantryFrames)
688+
return;
689689

690-
amount = RulesClass::Instance->SelfHealInfantryAmount * count;
690+
const bool hasCap = RulesExt::Global()->InfantryGainSelfHealCap.isset();
691+
const int cap = RulesExt::Global()->InfantryGainSelfHealCap.Get();
692+
int count = hasCap ? std::clamp(pOwner->InfantrySelfHeal, 1, cap) : pOwner->InfantrySelfHeal;
691693

692-
if (!(Unsorted::CurrentFrame % RulesClass::Instance->SelfHealInfantryFrames) && amount)
693-
applyHeal = true;
694+
if (RulesExt::Global()->GainSelfHealAllowPlayerControl && SessionClass::IsCampaign() && (!hasCap || count < cap))
695+
{
696+
for (auto pHouse : HouseClass::Array)
697+
{
698+
if (pHouse != pOwner && pHouse->IsControlledByCurrentPlayer())
699+
{
700+
count += pHouse->InfantrySelfHeal;
701+
702+
if (hasCap && count >= cap)
703+
{
704+
count = cap;
705+
break;
706+
}
707+
}
708+
}
709+
}
710+
711+
amount = RulesClass::Instance->SelfHealInfantryAmount * count;
694712
}
695713
else
696714
{
697-
int count = RulesExt::Global()->UnitsGainSelfHealCap.isset() ?
698-
std::min(std::max(RulesExt::Global()->UnitsGainSelfHealCap.Get(), 1), pThis->Owner->UnitsSelfHeal) :
699-
pThis->Owner->UnitsSelfHeal;
715+
if (Unsorted::CurrentFrame % RulesClass::Instance->SelfHealUnitFrames)
716+
return;
700717

701-
amount = RulesClass::Instance->SelfHealUnitAmount * count;
718+
const bool hasCap = RulesExt::Global()->UnitsGainSelfHealCap.isset();
719+
const int cap = RulesExt::Global()->UnitsGainSelfHealCap.Get();
720+
int count = hasCap ? std::clamp(pOwner->UnitsSelfHeal, 1, cap) : pOwner->UnitsSelfHeal;
702721

703-
if (!(Unsorted::CurrentFrame % RulesClass::Instance->SelfHealUnitFrames) && amount)
704-
applyHeal = true;
722+
if (RulesExt::Global()->GainSelfHealAllowPlayerControl && SessionClass::IsCampaign() && (!hasCap || count < cap))
723+
{
724+
for (auto pHouse : HouseClass::Array)
725+
{
726+
if (pHouse != pOwner && pHouse->IsControlledByCurrentPlayer())
727+
{
728+
count += pHouse->UnitsSelfHeal;
729+
730+
if (hasCap && count >= cap)
731+
{
732+
count = cap;
733+
break;
734+
}
735+
}
736+
}
737+
}
738+
739+
amount = RulesClass::Instance->SelfHealUnitAmount * count;
705740
}
706741

707-
if (applyHeal && amount)
742+
if (amount)
708743
{
709744
if (amount >= healthDeficit)
710745
amount = healthDeficit;

0 commit comments

Comments
 (0)