• Home
  • API reference
  • Source code
Show / Hide Table of Contents
  • osrlib.Controllers
    • GameManager
  • osrlib.Core
    • Ability
    • AbilityType
    • Adventure
    • Alignment
    • Being
    • BeingTargetingEventArgs
    • BeingTargetingEventHandler
    • CharacterClass
    • Dungeon
    • Encounter
    • GameAction
    • GameActionEventArgs
    • GameActionEventHandler
    • GamePosition
    • Modifier
    • Party
    • Quest
    • User
    • Weapon
    • WeaponType
  • osrlib.Dice
    • DiceHand
    • DiceRoll
    • DiceRolledEventArgs
    • DiceRolledEventHandler
    • Die
  • osrlib.SaveLoad
    • SaveLoadLocal
    • SaveType
  • osrlib.Tests
    • CoreRulesTests
    • DiceTests
    • PartyGenerator
    • ReadMeTests
    • SaveLoadTests
    • SteppedBattleTests
  • osrlib.Utility
    • Randomizer

Class Weapon

A Weapon is a melee or ranged martial weapon, or an offensive spell.

Inheritance
System.Object
Weapon
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
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 Source

AttackModifiers

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).

| Improve this Doc View Source

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
| Improve this Doc View Source

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).

| Improve this Doc View Source

Description

Gets or sets the weapon or spell's description.

Declaration
public string Description { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

Name

Gets or sets the name of the weapon or spell.

Declaration
public string Name { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

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 Source

GetAttackRoll(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: 0.

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.

| Improve this Doc View Source

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: 0.

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.

| Improve this Doc View Source

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.

Overrides
System.Object.ToString()
  • Improve this Doc
  • View Source
Back to top Generated by DocFX