SetNet.Combat
1.2.0
dotnet add package SetNet.Combat --version 1.2.0
NuGet\Install-Package SetNet.Combat -Version 1.2.0
<PackageReference Include="SetNet.Combat" Version="1.2.0" />
<PackageVersion Include="SetNet.Combat" Version="1.2.0" />
<PackageReference Include="SetNet.Combat" />
paket add SetNet.Combat --version 1.2.0
#r "nuget: SetNet.Combat, 1.2.0"
#:package SetNet.Combat@1.2.0
#addin nuget:?package=SetNet.Combat&version=1.2.0
#tool nuget:?package=SetNet.Combat&version=1.2.0
<p align="center"> <img src="https://raw.githubusercontent.com/Povstalez/SetNet/master/assets/icon.png" alt="SetNet" width="96"> </p>
SetNet.Combat
Server-authoritative combat resolution for SetNet.
Turn an attacker's and a defender's StatSets into a DamageResult — attack-power scaling, armor mitigation, crit rolls — through a pluggable ICombatFormula, then apply it to a Health pool. Which stats mean "attack power" / "defense" / "crit" is fully configurable via CombatStatKeys, so combat never hard-codes a stat vocabulary and fits whatever schema you defined. Server-side, no wire protocol.
Install
dotnet add package SetNet
dotnet add package SetNet.Combat
Usage
Build one resolver and reuse it across the whole server — it's stateless except its RNG:
var combat = new CombatResolver(); // StandardCombatFormula + default CombatStatKeys
var attackerHp = new Health(100);
var targetHp = new Health(100);
// a basic swing: 1.0× the attacker's attack power, physical, can crit
var spec = new AttackSpec(coefficient: 1.0, damageType: "physical");
DamageResult hit = combat.ResolveAndApply(attackerStats, targetStats, spec, targetHp, out bool died);
Console.WriteLine($"{hit.Amount} dmg{(hit.IsCrit ? " (crit!)" : "")}, {hit.Mitigated} absorbed");
if (died) OnKill();
targetHp.Changed += (cur, max) => Redraw(cur / max);
Notes
- Configurable stat keys.
CombatStatKeysmaps combat's inputs (AttackPower,Defense,CritChance,CritMultiplier) onto your ownSetNet.Statskeys — defaults are common RPG names, override them to match your schema. - Pluggable math.
StandardCombatFormulacomputesraw = attackPower·coefficient + flatBonus, rolls an optional crit, then mitigates withraw · (armorConstant / (armorConstant + defense)), clamped toMinDamage. TuneArmorConstant/MinDamage, or implementICombatFormulato change the feel entirely. AttackSpecdescribes the attack, not the attacker. A coefficient on attack power, a flat bonus, a damage type and whether it can crit — reused by abilities to scale spells off the caster's stats.Healthpool. Current/max withApply(returns true on the killing blow),Heal,SetMax,Revive, plusChanged/Diedevents.Resolvecomputes without applying;ResolveAndApplydoes both and reports death.- Deterministic tests. Seed the resolver's
Randomfor reproducible crit rolls. - Server-side only. No runtime bootstrap, no wire types — a plain library. Building blocks for
SetNet.AbilitiesandSetNet.Mobs.
Documentation & source
- 🐙 https://github.com/Povstalez/SetNet — full module catalog in docs/MODULES.md
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- SetNet (>= 1.2.0)
- SetNet.Stats (>= 1.2.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SetNet.Combat:
| Package | Downloads |
|---|---|
|
SetNet.Abilities
Server-authoritative abilities / skills for SetNet: define abilities with cooldown, resource cost, range and target kind, plus composable effects (deal damage via SetNet.Combat, heal, or apply a timed stat buff via SetNet.Stats). Clients request client.UseAbilities().UseAsync(id, target); the server validates and applies. Entity stats/health/positions come through seams, so mobs and players share the same system. Rides the unified protocol. Depends on SetNet + SetNet.Stats + SetNet.Combat. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.2.0 | 146 | 8/5/2026 |