Skip to content

feat(damage): Health hit tolls - #1616

Open
ze-dom wants to merge 10 commits into
MUnique:masterfrom
ze-dom:health_hit_tolls
Open

ze-dom wants to merge 10 commits into
MUnique:masterfrom
ze-dom:health_hit_tolls

Conversation

@ze-dom

@ze-dom ze-dom commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Adds the missing health tolls from both dealt and received hits:

  • Dealing damaga with wings equipped
  • Dealing damage with imp equipped
  • Dealing damage with dinorant equipped
  • Dealing damage to a player which has dinorant equipped
  • Receiving damage with an equipped dark horse
  • Rage Fighter's attacking skills

Players can now die while attacking when health pool is exhausted.

@codacy-production

codacy-production Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 2 minor

Alerts:
⚠ 2 issues (≤ 0 issues of at least minor severity)

Results:
2 new issues

Category Results
CodeStyle 2 minor

View in Codacy

🟢 Metrics 35 complexity

Metric Results
Complexity 35

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Comment thread src/GameLogic/Player.cs
await this.MagicEffectList.ClearAllEffectsProducingSpecificStatAsync(Stats.IsAsleep).ConfigureAwait(false);
}

this.Attributes[Stats.CurrentHealth] -= this.Attributes[Stats.HealthLossAfterHit];

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For equipped dark horse: zTeamS6.3, emu

Comment thread src/GameLogic/Player.cs
Comment on lines +916 to +919
if (target?.Attributes?[Stats.IsDinorantEquipped] > 0)
{
healthLossAfterDealtHit += this.Attributes[Stats.TargetHasDinorantHealthToll];
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.GameConfiguration.GlobalBaseAttributeValues.Add(hitShockDamageThreshold);

var targetHasDinorantHealthToll = this.Context.CreateNew<ConstValueAttribute>(1f, Stats.TargetHasDinorantHealthToll.GetPersistent(this.GameConfiguration), AggregateType.AddRaw);
this.GameConfiguration.GlobalBaseAttributeValues.Add(targetHasDinorantHealthToll);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.FenrirBaseDmg, 1.0f / 7, Stats.TotalEnergy));

result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.HealthLossAfterDealtHit, 3, Stats.IsWingEquipped));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Stats.AttackDamageIncrease, 1.3f, AggregateType.Multiplicate));
(Stats.IsImpEquipped, 1.0f, AggregateType.AddRaw),
(Stats.AttackDamageIncrease, 1.3f, AggregateType.Multiplicate),
(Stats.HealthLossAfterDealtHit, 3.0f, AggregateType.AddRaw));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Stats.DamageReceiveDecrement, 0.9f, AggregateType.Multiplicate),
(Stats.AttackDamageIncrease, 1.15f, AggregateType.Multiplicate));
(Stats.AttackDamageIncrease, 1.15f, AggregateType.Multiplicate),
(Stats.HealthLossAfterDealtHit, 1.0f, AggregateType.AddRaw));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Stats.MovementSpeed, MovementSpeedConstants.HorseOrFenrirMovementSpeed, AggregateType.Maximum),
(Stats.MovementSpeedUnderwater, MovementSpeedConstants.HorseOrFenrirMovementSpeed, AggregateType.Maximum));
(Stats.MovementSpeedUnderwater, MovementSpeedConstants.HorseOrFenrirMovementSpeed, AggregateType.Maximum),
(Stats.HealthLossAfterHit, 1.0f, AggregateType.AddRaw));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.AddAttributeRelationship(SkillNumber.DarkSide, Stats.SkillHealthLossAfterDealtHit, 4.0f, Stats.IsImpEquipped);
this.AddAttributeRelationship(SkillNumber.Charge, Stats.SkillHealthLossAfterDealtHit, 4.0f, Stats.IsImpEquipped);
this.AddAttributeRelationship(SkillNumber.ChainDrive, Stats.SkillHealthLossAfterDealtHit, 4.0f, Stats.IsImpEquipped);
this.AddAttributeRelationship(SkillNumber.DragonSlasher, Stats.SkillHealthLossAfterDealtHit, 100.0f, Stats.IsImpEquipped);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.AddAttributeRelationship(SkillNumber.DarkSide, Stats.SkillHealthLossAfterDealtHit, 4.0f, Stats.IsWingEquipped);
this.AddAttributeRelationship(SkillNumber.Charge, Stats.SkillHealthLossAfterDealtHit, 4.0f, Stats.IsWingEquipped);
this.AddAttributeRelationship(SkillNumber.ChainDrive, Stats.SkillHealthLossAfterDealtHit, 4.0f, Stats.IsWingEquipped);
this.AddAttributeRelationship(SkillNumber.DragonSlasher, Stats.SkillHealthLossAfterDealtHit, 100.0f, Stats.IsWingEquipped);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ze-dom
ze-dom marked this pull request as ready for review November 24, 2026 11:05

@sven-n sven-n left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hit tolls, and for linking the sources per value. The update plugins for 0.75, 0.95d and Season 6 are there, too. A few things before it can go in:

  1. Two initialization tests fail (built on current master):

    SmallWingsDataTest.NewDatabaseContainsSmallWingsAsync
    SmallWingsDataTest.UpdateAddsSmallWingsToExistingDatabaseAsync
      System.InvalidOperationException : Sequence contains no matching element
        at SmallWingsDataTest.AssertSmallWing ... line 96: GetPowerUp(item, Stats.CanFly)
    

    The wings now get IsWingEquipped instead of a direct CanFly power-up, and the small wings copy that. If CanFly now comes from an attribute combination of IsWingEquipped, please update SmallWingsDataTest accordingly, check that the small wings still let a character enter Icarus, and decide whether they should cost health per hit like the other wings (that's a behaviour change for them, too).

  2. Dying from your own hit: AfterHitTargetAsync used to keep at least 1 HP (Math.Max(..., 1)). Now the health loss for dealing a hit can kill the attacker (OnDeathAsync(null) with an empty DeathInformation). Is that what the original does? If so, please say so in the description, with the source; if not, please keep the clamp. Either way, a test for it would be good.

  3. Renamed stat meaning: the GUID D84A719B… keeps its meaning ("health loss after hitting a target"), so the persisted data is fine. But the C# property Stats.HealthLossAfterHit now means a different stat (after getting hit), while the old meaning moved to HealthLossAfterDealtHit. Plugins or code which use Stats.HealthLossAfterHit would silently change their behaviour. Please give the new stat a new name (e.g. HealthLossAfterReceivedHit), and keep HealthLossAfterHit for the old one (or rename it with an [Obsolete] forwarder).

  4. The description is one line. For a change to the damage handling, please describe what changes for players (which items and skills cost health, and when) and how you tested it.

The Web test failure PacketsAreShownInChronologicalOrder in the same run is a flaky test, unrelated to this PR.


Generated by Claude Code

@ze-dom

ze-dom commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author
  1. Tests addressed and now both pass with appropriate checks.
  2. Yes, it's the original behavior; it can be checked from the current PR's code comments (e.g.) referencing the sources for each hit toll - right after it there is a clamp to 0. Test added.
  3. This attribute was not being assigned values anywhere in the codebase (placeholder), so I think it's safe.
  4. Enriched description.

@ze-dom
ze-dom requested a review from sven-n November 25, 2026 09:34

@sven-n sven-n left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing the missing hit tolls! I have a question about how much item-specific state we need in the attribute model. In general, I would prefer items to declare the effects they cause, and combat code to consume the resulting attributes without knowing which exact item produced them.

  • IsWingEquipped seems justified: the wing toll differs by character class (1 vs. 3 HP), and this attribute is also used for CanFly. A class-dependent relationship makes sense here.
  • IsImpEquipped is less clear-cut: I see why it is used for the Rage Fighter's skill-specific tolls, which cannot be represented by a single constant item toll. However, could we express this more generically as a skill-dependent equipment effect instead of introducing an Imp-specific flag?
  • TargetHasDinorantHealthToll seems unnecessary: the toll is currently a global attribute of the attacker, activated when target.Attributes[Stats.IsDinorantEquipped] > 0. Could the Dinorant itself provide a numeric attribute on the defender, such as HealthTollInflictedOnAttacker? Then the hit logic could simply use healthLossAfterDealtHit += target?.Attributes?[Stats.HealthTollInflictedOnAttacker] ?? 0;. This would keep the value on the item, remove the Dinorant-specific condition from Player, and support other equipment with similar effects. IsDinorantEquipped can of course stay for its existing uses elsewhere.

One related question: should a skill-specific toll replace the entire accumulated HealthLossAfterDealtHit value? If two items contribute tolls (for example, wings and a Dinorant), replacing the whole sum with SkillHealthLossAfterDealtHit could drop one of those contributions. I suggest tests covering equipment combinations and skill-specific tolls to confirm the intended behavior.

Overall, I think IsWingEquipped has a good reason to exist, but would especially like to see the target Dinorant toll expressed directly as an item attribute.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants