Class Weapon
A Weapon is a melee or ranged martial weapon, or an offensive spell.
Inheritance
Inherited Members
Namespace: osrlib.Core
Assembly: osrlib.Core.dll
Syntax
public class Weapon
Examples
Create a basic melee weapon
Weapon dagger = new Weapon
{
Name = "Dagger",
Description = "A standard dagger.",
Type = WeaponType.Melee,
DamageDie = new DiceHand(1, DieType.d4)
};
Create a magical weapon
Weapon magicSword = new Weapon
{
Name = "Long Sword + 1",
Description = "A finely crafted sword, its blade dimly glows.",
Type = WeaponType.Melee,
DamageDie = new DiceHand(1, DieType.d8)
};
magicSword.AttackModifiers.Add(new Modifier { ModifierSource = magicSword, ModifierValue = 1 });
magicSword.DamageModifiers.Add(new Modifier { ModifierSource = magicSword, ModifierValue = 1 });
Create an offensive spell
Weapon flameJet = new Weapon
{
Name = "Flame Jet",
Description = "A jet of flame issues forth from the caster's hands.",
Type = WeaponType.Spell,
DamageDie = new DiceHand(1, DieType.d12)
};
Properties
| Improve this Doc View SourceAttackModifiers
Gets or sets the to-hit enchantments (bonuses) or curses (penalties) for the weapon or spell.
Declaration
public List<Modifier> AttackModifiers { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<Modifier> |
Remarks
AttackModifiers and DamageModifiers are typically static for the life of the weapon. For example,
to make a Long Sword +1, add both an AttackModifier and DamageModifier with ModifierValue of 1
.
Don't add a Being's Ability modifiers to this collection - instead, pass those when you call GetAttackRoll(Int32).
DamageDie
Gets or sets the die rolled when calculating the weapon or spell's damage. Default: 1d4
.
Declaration
public DiceHand DamageDie { get; set; }
Property Value
Type | Description |
---|---|
DiceHand |
DamageModifiers
Gets or sets the damage enchantments (bonuses) or curses (penalties) for the weapon or spell.
Declaration
public List<Modifier> DamageModifiers { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<Modifier> |
Remarks
AttackModifiers and DamageModifiers are typically static for the life of the weapon. For example,
to make a Long Sword +1, add both an AttackModifier and DamageModifier with ModifierValue of 1
.
Don't add a Being's Ability modifiers to this collection - instead, pass those when you
call GetDamageRoll(Int32).
Description
Gets or sets the weapon or spell's description.
Declaration
public string Description { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Name
Gets or sets the name of the weapon or spell.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Type
Gets or sets the weapon type. An offensive spell is considered a weapon.
Declaration
public WeaponType Type { get; set; }
Property Value
Type | Description |
---|---|
WeaponType |
Methods
| Improve this Doc View SourceGetAttackRoll(Int32)
Rolls a DieType.d20, sums any modifiers, and returns the result.
Declaration
public DiceRoll GetAttackRoll(int modifier = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | modifier | The bonus or penalty to apply to the roll. Default: |
Returns
Type | Description |
---|---|
DiceRoll | The to-hit roll after its RollDice() has been called. |
Remarks
The modifier is typically supplied by Ability bonuses/penalties or enchantments/curses applied to the Being wielding the weapon or spell.
GetDamageRoll(Int32)
Rolls the weapon's DamageDie, sums any modifiers, and returns the result.
Declaration
public DiceRoll GetDamageRoll(int modifier = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | modifier | The bonus or penalty to apply to the roll. Default: |
Returns
Type | Description |
---|---|
DiceRoll | The damage roll after its RollDice() has been called. |
Remarks
The modifier is typically supplied by Ability bonuses/penalties or enchantments/curses applied to the Being wielding the weapon or spell.
ToString()
Gets the string representation of the Weapon.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | Single-line text representation of the Weapon. |