Skip to content

Commit a15f909

Browse files
committed
Berzerk / Psychedelic duration stacking customization
1 parent 60bd502 commit a15f909

13 files changed

Lines changed: 154 additions & 1 deletion

File tree

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ This page lists all the individual contributions to the project by their author.
291291
- Wall overlay unit sell exploit fix
292292
- Fix vehicles disguised as trees incorrectly displaying veterancy insignia when they shouldn't
293293
- GapGen + SpySat desync fix
294+
- Berzerk duration stacking behaviour customization
294295
- **Morton (MortonPL)**:
295296
- `XDrawOffset` for animations
296297
- Shield passthrough & absorption

YRpp

docs/Fixed-or-Improved-Logics.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2429,6 +2429,19 @@ AllowBerzerkOnAllies=false ; boolean
24292429
No per-warhead setting because `AffectsAllies` etc. is respected.
24302430
```
24312431

2432+
### Berzerk (Psychedelic) duration stacking customization
2433+
2434+
- By default `Psychedelic` warheads override the current duration of the berzerk effect regardless of if the new duration is higher or lower than the current one. This can now be customized with `Psychedelic.StackingMode`, with both global setting under `[CombatDamage]` and per-Warhead customization.
2435+
2436+
In `rulesmd.ini`:
2437+
```ini
2438+
[CombatDamage]
2439+
Psychedelic.StackingMode=override ; Stacking mode enum (override|setifzero|min|max|add|subtract|multiply|divide)
2440+
2441+
[SOMEWARHEAD] ; WarheadType
2442+
Psychedelic.StackingMode= ; Stacking mode enum (override|setifzero|min|max|add|subtract|multiply|divide)
2443+
```
2444+
24322445
### Combat light customizations
24332446

24342447
- You can now set minimum detail level at which combat light effects are shown by setting `[AudioVisual] -> CombatLightDetailLevel` or `CombatLightDetailLevel` on Warhead.

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ New:
573573
- [Allow replacing vanilla repairing with togglable auto repairing](User-Interface.md#allow-replacing-vanilla-repairing-with-togglable-auto-repairing) (by TaranDahl)
574574
- Use `OpenTopped.AllowFiringIfAttackedByLocomotor` to control whether the passengers of a non-building transport unit can fire when the unit is being attacked by a weapon whose warhead has `IsLocomotor=true` (by Noble_Fish)
575575
- Framework for dynamic sight (by TaranDahl)
576+
- [Berzerk / `Psychedelic` duration stacking customization](Fixed-or-Improved-Logics.md#berzerk-psychedelic-duration-stacking-customization) (by Starkku)
576577
577578
Vanilla fixes:
578579
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)

src/Ext/Rules/Body.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,8 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
397397
this->FiringAnim_Update.Read(exINI, GameStrings::AudioVisual, "FiringAnim.Update");
398398
this->ExtendedPlayerRepair.Read(exINI, GameStrings::General, "ExtendedPlayerRepair");
399399

400+
this->Psychedelic_StackingMode.Read(exINI, GameStrings::CombatDamage, "Psychedelic.StackingMode");
401+
400402
// Section AITargetTypes
401403
int itemsCount = pINI->GetKeyCount("AITargetTypes");
402404
for (int i = 0; i < itemsCount; ++i)
@@ -720,6 +722,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
720722
.Process(this->ShipLocomotorMakesWake)
721723
.Process(this->FiringAnim_Update)
722724
.Process(this->ExtendedPlayerRepair)
725+
.Process(this->Psychedelic_StackingMode)
723726
;
724727
}
725728

src/Ext/Rules/Body.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ class RulesExt
344344
Valueable<bool> DriveLocomotorMakesWake;
345345
Valueable<bool> HoverLocomotorMakesWake;
346346
Valueable<bool> ShipLocomotorMakesWake;
347+
348+
Valueable<StackingMode> Psychedelic_StackingMode;
347349

348350
ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
349351
, Storage_TiberiumIndex { -1 }
@@ -631,6 +633,8 @@ class RulesExt
631633
, ShipLocomotorMakesWake { true }
632634
, FiringAnim_Update { false }
633635
, ExtendedPlayerRepair { false }
636+
637+
, Psychedelic_StackingMode { StackingMode::Override }
634638
{ }
635639

636640
virtual ~ExtData() = default;

src/Ext/WarheadType/Body.cpp

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

406406
this->Taunt.Read(exINI, pSection, "Taunt");
407407

408+
this->Psychedelic_StackingMode.Read(exINI, pSection, "Psychedelic.StackingMode");
409+
408410
// Convert.From & Convert.To
409411
TypeConvertGroup::Parse(this->Convert_Pairs, exINI, pSection, AffectedHouse::All);
410412

@@ -737,6 +739,8 @@ void WarheadTypeExt::ExtData::Serialize(T& Stm)
737739

738740
.Process(this->Taunt)
739741

742+
.Process(this->Psychedelic_StackingMode)
743+
740744
// Ares tags
741745
.Process(this->AffectsEnemies)
742746
.Process(this->AffectsOwner)

src/Ext/WarheadType/Body.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ class WarheadTypeExt
247247

248248
Valueable<bool> Taunt;
249249

250+
Nullable<StackingMode> Psychedelic_StackingMode;
251+
250252
// Ares tags
251253
// http://ares-developers.github.io/Ares-docs/new/warheads/general.html
252254
Valueable<bool> AffectsEnemies;
@@ -522,6 +524,8 @@ class WarheadTypeExt
522524
, ApplyPerTargetEffectsOnDetonate {}
523525

524526
, Taunt { false }
527+
528+
, Psychedelic_StackingMode {}
525529
{ }
526530

527531
void ApplyConvert(HouseClass* pHouse, TechnoClass* pTarget);

src/Ext/WarheadType/Hooks.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,3 +665,17 @@ DEFINE_HOOK(0x48DC90, MapClass_UnselectAll_ClearLimboLaunchers, 0x5)
665665
}
666666

667667
#pragma endregion
668+
669+
DEFINE_HOOK(0x701D6B, TechnoClass_ReceiveDamage_Psychedelic, 0x6)
670+
{
671+
enum { SkipGameCode = 0x701D71 };
672+
673+
GET(TechnoClass*, pThis, ESI);
674+
GET(WarheadTypeClass*, pWH, EBP);
675+
GET(int, damage, EAX);
676+
677+
auto const pWHExt = WarheadTypeExt::ExtMap.Find(pWH);
678+
EnumFunctions::CalcValueWithStackingMode(pThis->BerzerkDurationLeft, damage, pWHExt->Psychedelic_StackingMode);
679+
680+
return SkipGameCode;
681+
}

src/Utilities/Enum.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,18 @@ enum class DamageDisplayType
243243
Intercept = 2
244244
};
245245

246+
enum class StackingMode
247+
{
248+
Override = 0,
249+
SetIfZero = 1,
250+
Min = 2,
251+
Max = 3,
252+
Add = 4,
253+
Subtract = 5,
254+
Multiply = 6,
255+
Divide = 7
256+
};
257+
246258
enum class ChronoSparkleDisplayPosition : unsigned char
247259
{
248260
None = 0x0,

0 commit comments

Comments
 (0)