Class Being
The Being represents a living entity in within an Adventure, and is used for both player characters and monsters.
Inheritance
Inherited Members
Namespace: osrlib.Core
Assembly: osrlib.Core.dll
Syntax
public class Being
Examples
Create a player character
Being fighter = new Being
{
Name = "Blarg the Destructor",
Defense = 10,
MaxHitPoints = DiceRoll.RollDice(new DiceHand(2, DieType.d6)),
ActiveWeapon = new Weapon { Name = "Battle Axe", Type = WeaponType.Melee, DamageDie = new DiceHand(1, DieType.d12) }
};
fighter.HitPoints = fighter.MaxHitPoints;
fighter.RollAbilities();
Create a monster
Being goblin = new Being
{
Name = "Goblin Chieftain",
Defense = 12,
MaxHitPoints = DiceRoll.RollDice(new DiceHand(4, DieType.d6)),
ActiveWeapon = new Weapon { Name = "Javelin", Type = WeaponType.Ranged, DamageDie = new DiceHand(2, DieType.d4) }
};
goblin.HitPoints = goblin1.MaxHitPoints;
goblin.RollAbilities();
Properties
| Improve this Doc View SourceAbilities
Gets or sets the Being's Ability collection.
Declaration
public List<Ability> Abilities { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<Ability> |
ActiveWeapon
Gets or sets the Being's active weapon or spell. The active weapon is a weapon or offensive spell, and is used when when the Being attacks another being.
Declaration
public Weapon ActiveWeapon { get; set; }
Property Value
Type | Description |
---|---|
Weapon |
Alignment
Gets or sets the Alignment of the Being.
Declaration
public Alignment Alignment { get; set; }
Property Value
Type | Description |
---|---|
Alignment |
Class
Gets or sets the Being's CharacterClass.
Declaration
public CharacterClass Class { get; set; }
Property Value
Type | Description |
---|---|
CharacterClass |
Remarks
This can be a player character class or a monster type.
Defense
Gets or sets the minimum attack roll needed to hit the GamePiece.
Declaration
public int Defense { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
ExperiencePoints
Gets or sets the number of experience points for the Being.
Declaration
public int ExperiencePoints { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
This is the amount of experience possessed by a player character or the XP value of a monster.
HitPoints
Gets or sets the number of hit points for the Being.
Declaration
public int HitPoints { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
IsAlive
Gets whether the Being is alive (has greater than zero hit points).
Declaration
public bool IsAlive { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsTargetable
Gets or sets whether the Being can be attacked. Default: true
.
Declaration
public bool IsTargetable { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
MaxHitPoints
Gets or sets the maximum hit points for the Being.
Declaration
public int MaxHitPoints { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Name
Gets or sets the name of the Being.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String |
PotentialTargets
Gets the list of targets from which this Being can select one or more targets before calling PerformActionOnSelectedTargets().
Declaration
public ReadOnlyCollection<Being> PotentialTargets { get; }
Property Value
Type | Description |
---|---|
System.Collections.ObjectModel.ReadOnlyCollection<Being> |
Remarks
You can't populate this list directly. Use osrlib.Core.Being.AddPotentialTargets(System.Collections.Generic.List{osrlib.Core.Being}) instead.
SelectedTargets
Gets the list of targets that the Being has selected for its next GameAction.
Declaration
public ReadOnlyCollection<Being> SelectedTargets { get; }
Property Value
Type | Description |
---|---|
System.Collections.ObjectModel.ReadOnlyCollection<Being> |
Remarks
You can't populate this list directly. Use SelectTarget(Being), then call PerformActionOnSelectedTargets() to perform GameActions on the targets in the collection with this Being's ActiveWeapon.
Methods
| Improve this Doc View SourceAddAbilityModifier(Modifier, AbilityType)
Adds a modifier to the specified ability's ScoreModifiers collection. This acts as a bonus or penalty, for example due to an enchantment or curse affecting the Being.
Declaration
public void AddAbilityModifier(Modifier modifier, AbilityType abilityType)
Parameters
Type | Name | Description |
---|---|---|
Modifier | modifier | The modifier to adjust the specified ability score. |
AbilityType | abilityType | The ability to which to apply the modifier. |
ApplyDamage(Int32)
Deducts the specified amount of HitPoints from the Being.
Declaration
public bool ApplyDamage(int damage)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | damage | The amount of HitPoints to deduct. |
Returns
Type | Description |
---|---|
System.Boolean | Whether the applied damage killed the being. |
Remarks
If the Being is killed by this damage, the osrlib.Core.Being.OnKilled event is raised.
The event is raised only if the Being was previously alive, and returns true
only if the Being was alive prior to taking this damage.
GetAttackRoll()
Returns the attack roll rolled by the Being. The Being's active weapon (or spell) is used in calculating the roll, as are any ability modifiers appropriate for the weapon type.
Declaration
public DiceRoll GetAttackRoll()
Returns
Type | Description |
---|---|
DiceRoll | The DiceRoll to be compared to a Being's defense value. |
GetDamageRoll()
Returns the damage roll rolled by the Being. The Being's active weapon (or spell) is used in calculating the roll, as are any ability modifiers appropriate for the weapon type.
Declaration
public DiceRoll GetDamageRoll()
Returns
Type | Description |
---|---|
DiceRoll | The DiceRoll to be deducted from an opponent Being's hit points. |
PerformActionOnSelectedTargets()
For each Being in its SelectedTargets collection, creates and performs a GameAction.
Declaration
public void PerformActionOnSelectedTargets()
Remarks
Call this after the SelectedTargets collection has been populated with SelectTarget(Being) or SelectTargets(List<Being>).
RollAbilities()
Rolls the full set of ability scores for the Being. Calling this method removes any abilities currently in the Being's Abilities collection.
Declaration
public List<Ability> RollAbilities()
Returns
Type | Description |
---|---|
System.Collections.Generic.List<Ability> | The Being's newly populated Abilities collection. |
RollAbilityScore(AbilityType)
Rolls the specified ability score and adds the ability to the Being's ability collection. If an ability of the same type is already in the Abilities collection, the existing ability is removed before adding the new one generated by this method.
Declaration
public Ability RollAbilityScore(AbilityType abilityType)
Parameters
Type | Name | Description |
---|---|---|
AbilityType | abilityType | The type of ability to roll and add to the Abilities collection. |
Returns
Type | Description |
---|---|
Ability | The newly rolled Ability. |
SelectTarget(Being)
Adds the specified Being to the list of targets that will be the destination of the GameAction executed when PerformActionOnSelectedTargets() is called.
Declaration
public void SelectTarget(Being target)
Parameters
Type | Name | Description |
---|---|---|
Being | target | The Being that will be a destination of the GameAction performed when PerformActionOnSelectedTargets() is called. |
SelectTargets(List<Being>)
Adds the specified Beings to the list of targets that will be the destination of the GameAction executed when PerformActionOnSelectedTargets() is called.
Declaration
public void SelectTargets(List<Being> targets)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<Being> | targets | The collection of Beings that will be a destination of the GameAction performed when PerformActionOnSelectedTargets() is called. |
ToString()
Gets the string representation of the Being.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | Single-line text representation of the Being. |
Overrides
Events
| Improve this Doc View SourceActionPerformed
Event raised when this Being has performed a GameAction, such as when the Being attacks an enemy.
Declaration
public event GameActionEventHandler ActionPerformed
Event Type
Type | Description |
---|---|
GameActionEventHandler |
Remarks
Subscribe to this event to obtain information about the Being on which this Being is performing an action and determine the victor of the action. For example, you might use this to display the name of this Being, the stats about the the weapon or spell they wielded (via the ActiveWeapon property), and whether the action was successful (whether they hit and the damage dealt).
Killed
Event raised when the Being's HitPoints reach zero or below.
Declaration
public event EventHandler Killed
Event Type
Type | Description |
---|---|
System.EventHandler |
PerformingAction
Event raised when this Being is about to perform a GameAction, such as when the Being is about to attack an enemy.
Declaration
public event GameActionEventHandler PerformingAction
Event Type
Type | Description |
---|---|
GameActionEventHandler |
Remarks
Subscribe to this event to obtain information about the Being on which this Being is performing an action. For example, you might use this to display the name of this Being and stats about the the weapon or spell they're wielding (via the ActiveWeapon property).
PotentialTargetsAdded
Event raised when the Being's PotentialTargets collection is populated.
Declaration
public event EventHandler PotentialTargetsAdded
Event Type
Type | Description |
---|---|
System.EventHandler |
SelectedAsTarget
Event raised when this Being has been selected as a target; that is, the targeting Being's SelectTarget(Being) was called with this Being as the target.
Declaration
public event BeingTargetingEventHandler SelectedAsTarget
Event Type
Type | Description |
---|---|
BeingTargetingEventHandler |
TargetSelected
Event raised when this Being selects a target with SelectTarget(Being).
Declaration
public event BeingTargetingEventHandler TargetSelected
Event Type
Type | Description |
---|---|
BeingTargetingEventHandler |