Actor

Part of openmw.types

Usage:

local Actor = require('openmw.types').Actor

Type types

types.Actor

Common #Actor functions for Creature, NPC, and Player.

Type Actor

Actor.EQUIPMENT_SLOT

Available #EQUIPMENT_SLOT values.

Actor.STANCE

#STANCE

Actor.activeEffects(actor)

Return the active magic effects (#ActorActiveEffects) currently affecting the given actor.

Actor.activeSpells(actor)

Return the active spells (#ActorActiveSpells) currently affecting the given actor.

Actor.canMove(object)

Returns true if the object is an actor and is able to move.

Actor.getCurrentSpeed(actor)

Current speed.

Actor.getEquipment(actor, slot)

Get equipment.

Actor.getPathfindingAgentBounds(actor)

Agent bounds to be used for pathfinding functions.

Actor.getRunSpeed(actor)

Speed of running.

Actor.getSelectedEnchantedItem(actor)

Get currently selected enchanted item

Actor.getSelectedSpell(actor)

Get currently selected spell

Actor.getStance(actor)

Returns the current stance (whether a weapon/spell is readied), see the list of #STANCE values.

Actor.getWalkSpeed(actor)

Speed of walking.

Actor.hasEquipped(actor, item)

Returns true if the item is equipped on the actor.

Actor.inventory(actor)

Actor inventory.

Actor.isOnGround(actor)

Is the actor standing on ground.

Actor.isSwimming(actor)

Is the actor in water.

Actor.objectIsInstance(object)

Whether the object is an actor.

Actor.setEquipment(actor, equipment)

Set equipment.

Actor.setSelectedEnchantedItem(actor, item)

Set currently selected enchanted item, equipping it if applicable

Actor.setSelectedSpell(actor, spell)

Set selected spell

Actor.setStance(actor, stance)

Sets the current stance (whether a weapon/spell is readied), see the list of #STANCE values.

Actor.spells(actor)

Return the spells (#ActorSpells) of the given actor.

Actor.stats

The actor's stats.

Type ActorActiveEffects

ActorActiveEffects:getEffect(effectId, extraParam)

Get a specific active effect on the actor.

ActorActiveEffects:modify(value, effectId, extraParam)

Permanently modifies the magnitude of an active effect by increasing it by the provided value.

ActorActiveEffects:remove(effectId, extraParam)

Completely removes the active effect from the actor.

ActorActiveEffects:set(value, effectId, extraParam)

Permanently modifies the magnitude of an active effect to be exactly equal to the provided value.

Type ActorActiveSpells

ActorActiveSpells:isSpellActive(spellOrId)

Get whether a specific spell is active on the actor.

ActorActiveSpells:remove(spellOrId)

Remove the given spell and all its effects from the given actor's active spells.

Type ActorSpells

ActorSpells:add(spellOrId)

Add spell (only in global scripts or on self).

ActorSpells:clear()

Remove all spells (only in global scripts or on self).

ActorSpells:remove(spellOrId)

Remove spell (only in global scripts or on self).

Type ActorStats

ActorStats.attributes
ActorStats.dynamic
ActorStats.level(actor)

Level (returns #LevelStat)

Type AttributeStat

AttributeStat.base

The actor's base attribute value.

AttributeStat.damage

The amount the attribute has been damaged.

AttributeStat.modified

The actor's current attribute value (read-only.)

AttributeStat.modifier

The attribute's modifier.

Type AttributeStats

AttributeStats.agility(actor)

Agility (returns #AttributeStat)

AttributeStats.endurance(actor)

Endurance (returns #AttributeStat)

AttributeStats.intelligence(actor)

Intelligence (returns #AttributeStat)

AttributeStats.luck(actor)

Luck (returns #AttributeStat)

AttributeStats.personality(actor)

Personality (returns #AttributeStat)

AttributeStats.speed(actor)

Speed (returns #AttributeStat)

AttributeStats.strength(actor)

Strength (returns #AttributeStat)

AttributeStats.willpower(actor)

Willpower (returns #AttributeStat)

Type DynamicStat

DynamicStat.base
DynamicStat.current
DynamicStat.modifier

Type DynamicStats

DynamicStats.fatigue(actor)

Fatigue (returns #DynamicStat)

DynamicStats.health(actor)

Health (returns #DynamicStat)

DynamicStats.magicka(actor)

Magicka (returns #DynamicStat)

Type EQUIPMENT_SLOT

EQUIPMENT_SLOT.Ammunition
EQUIPMENT_SLOT.Amulet
EQUIPMENT_SLOT.Belt
EQUIPMENT_SLOT.Boots
EQUIPMENT_SLOT.CarriedLeft
EQUIPMENT_SLOT.CarriedRight
EQUIPMENT_SLOT.Cuirass
EQUIPMENT_SLOT.Greaves
EQUIPMENT_SLOT.Helmet
EQUIPMENT_SLOT.LeftGauntlet
EQUIPMENT_SLOT.LeftPauldron
EQUIPMENT_SLOT.LeftRing
EQUIPMENT_SLOT.Pants
EQUIPMENT_SLOT.RightGauntlet
EQUIPMENT_SLOT.RightPauldron
EQUIPMENT_SLOT.RightRing
EQUIPMENT_SLOT.Robe
EQUIPMENT_SLOT.Shirt
EQUIPMENT_SLOT.Skirt

Type LevelStat

LevelStat.current

The actor's current level.

LevelStat.progress

The NPC's level progress (read-only.)

Type STANCE

STANCE.Nothing

Default stance

STANCE.Spell

Magic stance

STANCE.Weapon

Weapon stance

Type SkillStat

SkillStat.base

The NPC's base skill value.

SkillStat.damage

The amount the skill has been damaged.

SkillStat.modified

The NPC's current skill value (read-only.)

SkillStat.modifier

The skill's modifier.

SkillStat.progress

[0-1] The NPC's skill progress.

Type SkillStats

SkillStats.acrobatics(actor)

Acrobatics (returns #SkillStat)

SkillStats.alchemy(actor)

Alchemy (returns #SkillStat)

SkillStats.alteration(actor)

Alteration (returns #SkillStat)

SkillStats.armorer(actor)

Armorer (returns #SkillStat)

SkillStats.athletics(actor)

Athletics (returns #SkillStat)

SkillStats.axe(actor)

Axe (returns #SkillStat)

SkillStats.block(actor)

Block (returns #SkillStat)

SkillStats.bluntweapon(actor)

Blunt Weapon (returns #SkillStat)

SkillStats.conjuration(actor)

Conjuration (returns #SkillStat)

SkillStats.destruction(actor)

Destruction (returns #SkillStat)

SkillStats.enchant(actor)

Enchant (returns #SkillStat)

SkillStats.handtohand(actor)

Hand To Hand (returns #SkillStat)

SkillStats.heavyarmor(actor)

Heavy Armor (returns #SkillStat)

SkillStats.illusion(actor)

Illusion (returns #SkillStat)

SkillStats.lightarmor(actor)

Light Armor (returns #SkillStat)

SkillStats.longblade(actor)

Long Blade (returns #SkillStat)

SkillStats.marksman(actor)

Marksman (returns #SkillStat)

SkillStats.mediumarmor(actor)

Medium Armor (returns #SkillStat)

SkillStats.mercantile(actor)

Mercantile (returns #SkillStat)

SkillStats.mysticism(actor)

Mysticism (returns #SkillStat)

SkillStats.restoration(actor)

Restoration (returns #SkillStat)

SkillStats.security(actor)

Security (returns #SkillStat)

SkillStats.shortblade(actor)

Short Blade (returns #SkillStat)

SkillStats.sneak(actor)

Sneak (returns #SkillStat)

SkillStats.spear(actor)

Spear (returns #SkillStat)

SkillStats.speechcraft(actor)

Speechcraft (returns #SkillStat)

SkillStats.unarmored(actor)

Unarmored (returns #SkillStat)

Type types

Field(s)

#Actor types.Actor

Common #Actor functions for Creature, NPC, and Player.

Type Actor

Common functions for Creature, NPC, and Player.

Field(s)

#EQUIPMENT_SLOT Actor.EQUIPMENT_SLOT

Available #EQUIPMENT_SLOT values.

Used in Actor.equipment(obj) and Actor.setEquipment(obj, eqp).

#STANCE Actor.STANCE

#STANCE

Actor.activeEffects(actor)

Return the active magic effects (#ActorActiveEffects) currently affecting the given actor.

Parameter

Return value

#ActorActiveEffects:

Actor.activeSpells(actor)

Return the active spells (#ActorActiveSpells) currently affecting the given actor.

Parameter

Return value

#ActorActiveSpells:

Actor.canMove(object)

Returns true if the object is an actor and is able to move.

For dead, paralyzed, or knocked down actors it returns false.

Parameter

Return value

#boolean:

Actor.getCurrentSpeed(actor)

Current speed.

Parameter

Return value

#number:

Actor.getEquipment(actor, slot)

Get equipment.

Has two overloads: 1) With a single argument: returns a table slot -> openmw.core#GameObject of currently equipped items. See #EQUIPMENT_SLOT. Returns empty table if the actor doesn't have equipment slots. 2) With two arguments: returns an item equipped to the given slot.

Parameters

Return value

#EquipmentTable, openmw.core#GameObject:

Actor.getPathfindingAgentBounds(actor)

Agent bounds to be used for pathfinding functions.

Parameter

Return value

#table: with shapeType and halfExtents

Actor.getRunSpeed(actor)

Speed of running.

For dead actors it still returns a positive value.

Parameter

Return value

#number:

Actor.getSelectedEnchantedItem(actor)

Get currently selected enchanted item

Parameter

Return value

openmw.core#GameObject, nil enchanted item or nil

Actor.getSelectedSpell(actor)

Get currently selected spell

Parameter

Return value

openmw.core#Spell, nil

Actor.getStance(actor)

Returns the current stance (whether a weapon/spell is readied), see the list of #STANCE values.

Parameter

Return value

#number:

Actor.getWalkSpeed(actor)

Speed of walking.

For dead actors it still returns a positive value.

Parameter

Return value

#number:

Actor.hasEquipped(actor, item)

Returns true if the item is equipped on the actor.

Parameters

Return value

#boolean:

Actor.inventory(actor)

Actor inventory.

Parameter

Return value

openmw.core#Inventory:

Actor.isOnGround(actor)

Is the actor standing on ground.

Can be called only from a local script.

Parameter

Return value

#boolean:

Actor.isSwimming(actor)

Is the actor in water.

Can be called only from a local script.

Parameter

Return value

#boolean:

Actor.objectIsInstance(object)

Whether the object is an actor.

Parameter

Return value

#boolean:

Actor.setEquipment(actor, equipment)

Set equipment.

Keys in the table are equipment slots (see #EQUIPMENT_SLOT). Each value can be either a GameObject or recordId. Raises an error if the actor doesn't have equipment slots and table is not empty. Can be used only in local scripts and only on self.

Parameters

Usage:

local self = require('openmw.self')
local Actor = require('openmw.types').Actor
Actor.setEquipment(self, {}) -- unequip all
Actor.setSelectedEnchantedItem(actor, item)

Set currently selected enchanted item, equipping it if applicable

Parameters

Actor.setSelectedSpell(actor, spell)

Set selected spell

Parameters

Actor.setStance(actor, stance)

Sets the current stance (whether a weapon/spell is readied), see the list of #STANCE values.

Can be used only in local scripts on self.

Parameters

Actor.spells(actor)

Return the spells (#ActorSpells) of the given actor.

Parameter

Return value

#ActorSpells:

#ActorStats Actor.stats

The actor's stats.

Type ActorActiveEffects

Read-only list of effects currently affecting the actor.

Usages:

  • -- print active effects
    for _, effect in pairs(Actor.activeEffects(self)) do
        print('Active Effect: '..effect.id..', attribute='..tostring(effect.affectedAttribute)..', skill='..tostring(effect.affectedSkill)..', magnitude='..tostring(effect.magnitude))
    end
  • -- Check for a specific effect
    local effect = Actor.activeEffects(self):getEffect(core.magic.EFFECT_TYPE.Telekinesis)
    if effect then
        print(effect.id..', attribute='..tostring(effect.affectedAttribute)..', skill='..tostring(effect.affectedSkill)..', magnitude='..tostring(effect.magnitude))
    else
        print('No Telekinesis effect')
    end
  • -- Check for a specific effect targeting a specific attribute.
    local effect = Actor.activeEffects(self):getEffect(core.magic.EFFECT_TYPE.FortifyAttribute, core.ATTRIBUTE.Luck)
    if effect then
        print(effect.id..', attribute='..tostring(effect.affectedAttribute)..', skill='..tostring(effect.affectedSkill)..', magnitude='..tostring(effect.magnitude))
    else
        print('No Fortify Luck effect')
    end

Field(s)

ActorActiveEffects:getEffect(effectId, extraParam)

Get a specific active effect on the actor.

Parameters

  • #string effectId : effect ID

  • #string extraParam : Optional skill or attribute ID

Return value

openmw.core#ActiveEffect: if such an effect is active, nil otherwise

ActorActiveEffects:modify(value, effectId, extraParam)

Permanently modifies the magnitude of an active effect by increasing it by the provided value.

This adds the effect to the list of active effects if not already active.

Parameters

  • #number value :

  • #string effectId : effect ID

  • #string extraParam : Optional skill or attribute ID

ActorActiveEffects:remove(effectId, extraParam)

Completely removes the active effect from the actor.

This removes both the effects incurred by active spells and effect added by console, mwscript, or luascript.

Parameters

  • #string effectId : effect ID

  • #string extraParam : Optional skill or attribute ID

ActorActiveEffects:set(value, effectId, extraParam)

Permanently modifies the magnitude of an active effect to be exactly equal to the provided value.

This adds the effect to the list of active effects if not already active. Note that although the modification is permanent, the magnitude will not stay equal to the value if any active spells with this effects are added/removed.

Parameters

  • #number value :

  • #string effectId : effect ID

  • #string extraParam : Optional skill or attribute ID

Type ActorActiveSpells

Read-only list of spells currently affecting the actor.

Usages:

  • -- print active spells
    for _, spell in pairs(Actor.activeSpells(self)) do
        print('Active Spell: '..tostring(spell))
    end
  • -- Check for a specific spell
    if Actor.activeSpells(self):isSpellActive('bound longbow') then
        print('Player has bound longbow')
    else
        print('Player does not have bound longbow')
    end

Field(s)

ActorActiveSpells:isSpellActive(spellOrId)

Get whether a specific spell is active on the actor.

Parameter

Return value

true if spell is active, false otherwise

ActorActiveSpells:remove(spellOrId)

Remove the given spell and all its effects from the given actor's active spells.

Parameter

Type ActorSpells

List of spells with additional functions add/remove/clear (modification are allowed only in global scripts or on self).

Usages:

  • -- print available spells
    local mySpells = types.Actor.spells(self)
    for _, spell in pairs(mySpells) do print(spell.id) end
  • -- print available spells (equivalent)
    local mySpells = types.Actor.spells(self)
    for i = 1, #mySpells do print(mySpells[i].id) end
  • -- add ALL spells that exist in the world
    local mySpells = types.Actor.spells(self)
    for _, spell in pairs(core.magic.spells) do
        if spell.type == core.magic.SPELL_TYPE.Spell then
            mySpells:add(spell)
        end
    end
  • -- add specific spell
    types.Actor.spells(self):add('thunder fist')
  • -- check specific spell
    local mySpells = types.Actor.spells(self)
    if mySpells['thunder fist'] then print('I have thunder fist') end

Field(s)

ActorSpells:add(spellOrId)

Add spell (only in global scripts or on self).

Parameter

ActorSpells:clear()

Remove all spells (only in global scripts or on self).

ActorSpells:remove(spellOrId)

Remove spell (only in global scripts or on self).

Parameter

Type ActorStats

Field(s)

#AttributeStats ActorStats.attributes
#DynamicStats ActorStats.dynamic
ActorStats.level(actor)

Level (returns #LevelStat)

Parameter

Return value

#LevelStat:

Type AttributeStat

Field(s)

#number AttributeStat.base

The actor's base attribute value.

#number AttributeStat.damage

The amount the attribute has been damaged.

#number AttributeStat.modified

The actor's current attribute value (read-only.)

#number AttributeStat.modifier

The attribute's modifier.

Type AttributeStats

Field(s)

AttributeStats.agility(actor)

Agility (returns #AttributeStat)

Parameter

Return value

#AttributeStat:

AttributeStats.endurance(actor)

Endurance (returns #AttributeStat)

Parameter

Return value

#AttributeStat:

AttributeStats.intelligence(actor)

Intelligence (returns #AttributeStat)

Parameter

Return value

#AttributeStat:

AttributeStats.luck(actor)

Luck (returns #AttributeStat)

Parameter

Return value

#AttributeStat:

AttributeStats.personality(actor)

Personality (returns #AttributeStat)

Parameter

Return value

#AttributeStat:

AttributeStats.speed(actor)

Speed (returns #AttributeStat)

Parameter

Return value

#AttributeStat:

AttributeStats.strength(actor)

Strength (returns #AttributeStat)

Parameter

Return value

#AttributeStat:

AttributeStats.willpower(actor)

Willpower (returns #AttributeStat)

Parameter

Return value

#AttributeStat:

Type DynamicStat

Field(s)

#number DynamicStat.base
#number DynamicStat.current
#number DynamicStat.modifier

Type DynamicStats

Field(s)

DynamicStats.fatigue(actor)

Fatigue (returns #DynamicStat)

Parameter

Return value

#DynamicStat:

DynamicStats.health(actor)

Health (returns #DynamicStat)

Parameter

Return value

#DynamicStat:

DynamicStats.magicka(actor)

Magicka (returns #DynamicStat)

Parameter

Return value

#DynamicStat:

Type EQUIPMENT_SLOT

Field(s)

#number EQUIPMENT_SLOT.Ammunition
#number EQUIPMENT_SLOT.Amulet
#number EQUIPMENT_SLOT.Belt
#number EQUIPMENT_SLOT.Boots
#number EQUIPMENT_SLOT.CarriedLeft
#number EQUIPMENT_SLOT.CarriedRight
#number EQUIPMENT_SLOT.Cuirass
#number EQUIPMENT_SLOT.Greaves
#number EQUIPMENT_SLOT.Helmet
#number EQUIPMENT_SLOT.LeftGauntlet
#number EQUIPMENT_SLOT.LeftPauldron
#number EQUIPMENT_SLOT.LeftRing
#number EQUIPMENT_SLOT.Pants
#number EQUIPMENT_SLOT.RightGauntlet
#number EQUIPMENT_SLOT.RightPauldron
#number EQUIPMENT_SLOT.RightRing
#number EQUIPMENT_SLOT.Robe
#number EQUIPMENT_SLOT.Shirt
#number EQUIPMENT_SLOT.Skirt

Type EquipmentTable

Map from values of #EQUIPMENT_SLOT to items openmw.core#GameObjects

EquipmentTable is a map of #number to openmw.core#GameObject.

Type LevelStat

Field(s)

#number LevelStat.current

The actor's current level.

#number LevelStat.progress

The NPC's level progress (read-only.)

Type STANCE

Field(s)

#number STANCE.Nothing

Default stance

#number STANCE.Spell

Magic stance

#number STANCE.Weapon

Weapon stance

Type SkillStat

Field(s)

#number SkillStat.base

The NPC's base skill value.

#number SkillStat.damage

The amount the skill has been damaged.

#number SkillStat.modified

The NPC's current skill value (read-only.)

#number SkillStat.modifier

The skill's modifier.

#number SkillStat.progress

[0-1] The NPC's skill progress.

Type SkillStats

Field(s)

SkillStats.acrobatics(actor)

Acrobatics (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.alchemy(actor)

Alchemy (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.alteration(actor)

Alteration (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.armorer(actor)

Armorer (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.athletics(actor)

Athletics (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.axe(actor)

Axe (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.block(actor)

Block (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.bluntweapon(actor)

Blunt Weapon (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.conjuration(actor)

Conjuration (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.destruction(actor)

Destruction (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.enchant(actor)

Enchant (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.handtohand(actor)

Hand To Hand (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.heavyarmor(actor)

Heavy Armor (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.illusion(actor)

Illusion (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.lightarmor(actor)

Light Armor (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.longblade(actor)

Long Blade (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.marksman(actor)

Marksman (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.mediumarmor(actor)

Medium Armor (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.mercantile(actor)

Mercantile (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.mysticism(actor)

Mysticism (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.restoration(actor)

Restoration (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.security(actor)

Security (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.shortblade(actor)

Short Blade (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.sneak(actor)

Sneak (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.spear(actor)

Spear (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.speechcraft(actor)

Speechcraft (returns #SkillStat)

Parameter

Return value

#SkillStat:

SkillStats.unarmored(actor)

Unarmored (returns #SkillStat)

Parameter

Return value

#SkillStat: