SetNet.Combat 1.2.0

dotnet add package SetNet.Combat --version 1.2.0
                    
NuGet\Install-Package SetNet.Combat -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SetNet.Combat" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SetNet.Combat" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="SetNet.Combat" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SetNet.Combat --version 1.2.0
                    
#r "nuget: SetNet.Combat, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SetNet.Combat@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SetNet.Combat&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=SetNet.Combat&version=1.2.0
                    
Install as a Cake Tool

<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. CombatStatKeys maps combat's inputs (AttackPower, Defense, CritChance, CritMultiplier) onto your own SetNet.Stats keys — defaults are common RPG names, override them to match your schema.
  • Pluggable math. StandardCombatFormula computes raw = attackPower·coefficient + flatBonus, rolls an optional crit, then mitigates with raw · (armorConstant / (armorConstant + defense)), clamped to MinDamage. Tune ArmorConstant/MinDamage, or implement ICombatFormula to change the feel entirely.
  • AttackSpec describes 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.
  • Health pool. Current/max with Apply (returns true on the killing blow), Heal, SetMax, Revive, plus Changed/Died events. Resolve computes without applying; ResolveAndApply does both and reports death.
  • Deterministic tests. Seed the resolver's Random for reproducible crit rolls.
  • Server-side only. No runtime bootstrap, no wire types — a plain library. Building blocks for SetNet.Abilities and SetNet.Mobs.

Documentation & source

License

MIT

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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