Skip to content

Commit afedd4a

Browse files
committed
Fix SelfHealGainType=none not working (replace with value called noheal)
1 parent 0873ad8 commit afedd4a

File tree

6 files changed

+70
-74
lines changed

6 files changed

+70
-74
lines changed

docs/Fixed-or-Improved-Logics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ Pips.SelfHeal.Units.Offset=33,-32 ; X,Y, pixels relative to default
475475
Pips.SelfHeal.Buildings.Offset=15,10 ; X,Y, pixels relative to default
476476

477477
[SOMETECHNO] ; TechnoType
478-
SelfHealGainType= ; Self-Heal Gain Type Enumeration (none|infantry|units)
478+
SelfHealGainType= ; Self-Heal Gain Type Enumeration (noheal|infantry|units)
479479
```
480480

481481
### Chrono sparkle animation customization & improvements

docs/Whats-New.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ You can use the migration utility (can be found on [Phobos supplementaries repo]
2121

2222
#### From post-0.3 devbuilds
2323

24+
- `SelfHealGainType` value `none` has been changed to `noheal` due to `none` being treated as a blank string and not parsed by the game.
2425
- Affected target enum (`CanTarget`, `Crit.Affects` et al) now considers buildings considered vehicles (`ConsideredVehicle=true` or not set in conjunction with `UndeploysInto` & 1x1 foundation) as units instead of buildings.
2526
- If `CreateUnit.AlwaysSpawnOnGround` is set to false, jumpjet vehicles created will now automatically take off instead of staying on ground. Set to true to force spawn on ground.
2627
- Digital display `Offset` and `Offset.ShieldDelta` Y-axis coordinates now work in inverted fashion (negative goes up, positive goes down) to be consistent with how pixel offsets work elsewhere in the game.
@@ -567,6 +568,7 @@ Phobos fixes:
567568
- Buildings considered vehicles (`ConsideredVehicle=true` or not set in conjunction with `UndeploysInto` & 1x1 foundation) are now considered units by affected target enum checks (by Starkku)
568569
- Fixed Phobos Warhead effects not reliably being applied on damage area as opposed to full weapon-based Warhead detonation (by Starkku)
569570
- Fix `LimboKill` not working reliably (by CrimRecya)
571+
- Fixed `SelfHealGainType=none` not working (changed to `noheal`) (by Starkku)
570572
571573
Fixes / interactions with other extensions:
572574
- `IsSimpleDeployer` units with Hover locomotor and `DeployToLand` no longer get stuck after deploying or play their move sound indefinitely (by Starkku)

src/Ext/Techno/Body.Update.cpp

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -602,67 +602,65 @@ void TechnoExt::ApplyGainedSelfHeal(TechnoClass* pThis)
602602

603603
if (pThis->Health && healthDeficit > 0)
604604
{
605-
if (auto const pExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType()))
606-
{
607-
bool isBuilding = pThis->WhatAmI() == AbstractType::Building;
608-
bool isOrganic = pThis->WhatAmI() == AbstractType::Infantry || pThis->WhatAmI() == AbstractType::Unit && pThis->GetTechnoType()->Organic;
609-
auto defaultSelfHealType = isBuilding ? SelfHealGainType::None : isOrganic ? SelfHealGainType::Infantry : SelfHealGainType::Units;
610-
auto selfHealType = pExt->SelfHealGainType.Get(defaultSelfHealType);
605+
auto const pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType());
606+
bool isBuilding = pThis->WhatAmI() == AbstractType::Building;
607+
bool isOrganic = pThis->WhatAmI() == AbstractType::Infantry || pThis->WhatAmI() == AbstractType::Unit && pThis->GetTechnoType()->Organic;
608+
auto defaultSelfHealType = isBuilding ? SelfHealGainType::NoHeal : isOrganic ? SelfHealGainType::Infantry : SelfHealGainType::Units;
609+
auto selfHealType = pTypeExt->SelfHealGainType.Get(defaultSelfHealType);
611610

612-
if (selfHealType == SelfHealGainType::None)
613-
return;
611+
if (selfHealType == SelfHealGainType::NoHeal)
612+
return;
614613

615-
bool applyHeal = false;
616-
int amount = 0;
614+
bool applyHeal = false;
615+
int amount = 0;
617616

618-
if (selfHealType == SelfHealGainType::Infantry)
619-
{
620-
int count = RulesExt::Global()->InfantryGainSelfHealCap.isset() ?
621-
std::min(std::max(RulesExt::Global()->InfantryGainSelfHealCap.Get(), 1), pThis->Owner->InfantrySelfHeal) :
622-
pThis->Owner->InfantrySelfHeal;
617+
if (selfHealType == SelfHealGainType::Infantry)
618+
{
619+
int count = RulesExt::Global()->InfantryGainSelfHealCap.isset() ?
620+
std::min(std::max(RulesExt::Global()->InfantryGainSelfHealCap.Get(), 1), pThis->Owner->InfantrySelfHeal) :
621+
pThis->Owner->InfantrySelfHeal;
623622

624-
amount = RulesClass::Instance->SelfHealInfantryAmount * count;
623+
amount = RulesClass::Instance->SelfHealInfantryAmount * count;
625624

626-
if (!(Unsorted::CurrentFrame % RulesClass::Instance->SelfHealInfantryFrames) && amount)
627-
applyHeal = true;
628-
}
629-
else
630-
{
631-
int count = RulesExt::Global()->UnitsGainSelfHealCap.isset() ?
632-
std::min(std::max(RulesExt::Global()->UnitsGainSelfHealCap.Get(), 1), pThis->Owner->UnitsSelfHeal) :
633-
pThis->Owner->UnitsSelfHeal;
625+
if (!(Unsorted::CurrentFrame % RulesClass::Instance->SelfHealInfantryFrames) && amount)
626+
applyHeal = true;
627+
}
628+
else
629+
{
630+
int count = RulesExt::Global()->UnitsGainSelfHealCap.isset() ?
631+
std::min(std::max(RulesExt::Global()->UnitsGainSelfHealCap.Get(), 1), pThis->Owner->UnitsSelfHeal) :
632+
pThis->Owner->UnitsSelfHeal;
634633

635-
amount = RulesClass::Instance->SelfHealUnitAmount * count;
634+
amount = RulesClass::Instance->SelfHealUnitAmount * count;
636635

637-
if (!(Unsorted::CurrentFrame % RulesClass::Instance->SelfHealUnitFrames) && amount)
638-
applyHeal = true;
639-
}
636+
if (!(Unsorted::CurrentFrame % RulesClass::Instance->SelfHealUnitFrames) && amount)
637+
applyHeal = true;
638+
}
640639

641-
if (applyHeal && amount)
642-
{
643-
if (amount >= healthDeficit)
644-
amount = healthDeficit;
640+
if (applyHeal && amount)
641+
{
642+
if (amount >= healthDeficit)
643+
amount = healthDeficit;
645644

646-
bool wasDamaged = pThis->GetHealthPercentage() <= RulesClass::Instance->ConditionYellow;
645+
bool wasDamaged = pThis->GetHealthPercentage() <= RulesClass::Instance->ConditionYellow;
647646

648-
pThis->Health += amount;
647+
pThis->Health += amount;
649648

650-
if (wasDamaged && (pThis->GetHealthPercentage() > RulesClass::Instance->ConditionYellow
651-
|| pThis->GetHeight() < -10))
649+
if (wasDamaged && (pThis->GetHealthPercentage() > RulesClass::Instance->ConditionYellow
650+
|| pThis->GetHeight() < -10))
651+
{
652+
if (auto const pBuilding = abstract_cast<BuildingClass*>(pThis))
652653
{
653-
if (auto const pBuilding = abstract_cast<BuildingClass*>(pThis))
654-
{
655-
pBuilding->Mark(MarkType::Change);
656-
pBuilding->ToggleDamagedAnims(false);
657-
}
654+
pBuilding->Mark(MarkType::Change);
655+
pBuilding->ToggleDamagedAnims(false);
656+
}
658657

659-
if (pThis->WhatAmI() == AbstractType::Unit || pThis->WhatAmI() == AbstractType::Building)
660-
{
661-
auto dmgParticle = pThis->DamageParticleSystem;
658+
if (pThis->WhatAmI() == AbstractType::Unit || pThis->WhatAmI() == AbstractType::Building)
659+
{
660+
auto dmgParticle = pThis->DamageParticleSystem;
662661

663-
if (dmgParticle)
664-
dmgParticle->UnInit();
665-
}
662+
if (dmgParticle)
663+
dmgParticle->UnInit();
666664
}
667665
}
668666
}

src/Ext/Techno/Body.Visuals.cpp

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,28 @@ void TechnoExt::DrawSelfHealPips(TechnoClass* pThis, Point2D* pLocation, Rectang
1414
bool isInfantryHeal = false;
1515
int selfHealFrames = 0;
1616

17-
if (auto const pExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType()))
18-
{
19-
if (pExt->SelfHealGainType.isset() && pExt->SelfHealGainType.Get() == SelfHealGainType::None)
20-
return;
17+
auto const pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType());
2118

22-
bool hasInfantrySelfHeal = pExt->SelfHealGainType.isset() && pExt->SelfHealGainType.Get() == SelfHealGainType::Infantry;
23-
bool hasUnitSelfHeal = pExt->SelfHealGainType.isset() && pExt->SelfHealGainType.Get() == SelfHealGainType::Units;
24-
bool isOrganic = false;
19+
if (pTypeExt->SelfHealGainType.isset() && pTypeExt->SelfHealGainType.Get() == SelfHealGainType::NoHeal)
20+
return;
2521

26-
if (pThis->WhatAmI() == AbstractType::Infantry ||
27-
pThis->GetTechnoType()->Organic && pThis->WhatAmI() == AbstractType::Unit)
28-
{
29-
isOrganic = true;
30-
}
22+
bool hasInfantrySelfHeal = pTypeExt->SelfHealGainType.isset() && pTypeExt->SelfHealGainType.Get() == SelfHealGainType::Infantry;
23+
bool hasUnitSelfHeal = pTypeExt->SelfHealGainType.isset() && pTypeExt->SelfHealGainType.Get() == SelfHealGainType::Units;
24+
bool isOrganic = false;
3125

32-
if (pThis->Owner->InfantrySelfHeal > 0 && (hasInfantrySelfHeal || (isOrganic && !hasUnitSelfHeal)))
33-
{
34-
drawPip = true;
35-
selfHealFrames = RulesClass::Instance->SelfHealInfantryFrames;
36-
isInfantryHeal = true;
37-
}
38-
else if (pThis->Owner->UnitsSelfHeal > 0 && (hasUnitSelfHeal || (pThis->WhatAmI() == AbstractType::Unit && !isOrganic)))
39-
{
40-
drawPip = true;
41-
selfHealFrames = RulesClass::Instance->SelfHealUnitFrames;
42-
}
26+
if (pThis->WhatAmI() == AbstractType::Infantry || (pThis->GetTechnoType()->Organic && pThis->WhatAmI() == AbstractType::Unit))
27+
isOrganic = true;
28+
29+
if (pThis->Owner->InfantrySelfHeal > 0 && (hasInfantrySelfHeal || (isOrganic && !hasUnitSelfHeal)))
30+
{
31+
drawPip = true;
32+
selfHealFrames = RulesClass::Instance->SelfHealInfantryFrames;
33+
isInfantryHeal = true;
34+
}
35+
else if (pThis->Owner->UnitsSelfHeal > 0 && (hasUnitSelfHeal || (pThis->WhatAmI() == AbstractType::Unit && !isOrganic)))
36+
{
37+
drawPip = true;
38+
selfHealFrames = RulesClass::Instance->SelfHealUnitFrames;
4339
}
4440

4541
if (drawPip)

src/Utilities/Enum.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ enum class AutoDeathBehavior
152152

153153
enum class SelfHealGainType
154154
{
155-
None = 0,
155+
NoHeal = 0,
156156
Infantry = 1,
157157
Units = 2
158158
};

src/Utilities/TemplateDef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,9 @@ namespace detail
838838
{
839839
if (parser.ReadString(pSection, pKey))
840840
{
841-
if (_strcmpi(parser.value(), "none") == 0)
841+
if (_strcmpi(parser.value(), "noheal") == 0)
842842
{
843-
value = SelfHealGainType::None;
843+
value = SelfHealGainType::NoHeal;
844844
}
845845
else if (_strcmpi(parser.value(), "infantry") == 0)
846846
{

0 commit comments

Comments
 (0)