tes3magicSourceInstance⚓︎
A game structure that keeps track of a magic source and all the actors it affects. Each spell cast, alchemy or enchanted item use is a magic source. Area effect magic can hit multiple actors and have up to 8 effects. Individual magic effects are tes3magicEffectInstance
s.
This type inherits the following: tes3baseObject
Properties⚓︎
blocked
⚓︎
The blocked state of the object.
Returns:
result
(boolean)
castChanceOverride
⚓︎
No description yet available.
Returns:
result
(number)
caster
⚓︎
Read-only. No description yet available.
Returns:
result
(tes3reference)
corprusHoursSinceLastWorsen
⚓︎
The number of hours passed since the player's corprus state last worsened.
Returns:
result
(number)
deleted
⚓︎
Read-only. The deleted state of the object.
Returns:
result
(boolean)
disabled
⚓︎
Read-only. The disabled state of the object.
Returns:
result
(boolean)
id
⚓︎
Read-only. The unique identifier for the object.
Returns:
result
(string)
item
⚓︎
Read-only. No description yet available.
Returns:
result
(tes3item)
itemData
⚓︎
Read-only. No description yet available.
Returns:
result
(tes3itemData)
itemID
⚓︎
Read-only. No description yet available.
Returns:
result
(string)
magicID
⚓︎
Read-only. For spells created in the Contruction Set, this is the id of the spell defined there. For spells created during play, with spellmaking, this is a number.
Returns:
result
(string)
modified
⚓︎
The modification state of the object since the last save.
Returns:
result
(boolean)
objectFlags
⚓︎
Read-only. The raw flags of the object.
Returns:
result
(number)
objectType
⚓︎
Read-only. The type of object. Maps to values in tes3.objectType
.
Returns:
result
(tes3.objectType)
persistent
⚓︎
The persistent flag of the object.
Returns:
result
(boolean)
projectile
⚓︎
Read-only. No description yet available.
Returns:
result
(tes3mobileProjectile)
serialNumber
⚓︎
Read-only. Unique indentifier for just this magic source.
Returns:
result
(number)
source
⚓︎
Read-only. No description yet available.
Returns:
result
(tes3alchemy, tes3enchantment, tes3spell)
sourceEffects
⚓︎
Read-only. An array-style table holding spell effects this magic source has.
Returns:
result
(tes3effect[])
sourceless
⚓︎
The soruceless flag of the object.
Returns:
result
(boolean)
sourceMod
⚓︎
Read-only. The filename (including the extension) of the mod that owns this object. It has nil
value if the object was anything other than loaded from an ESP or ESM file.
Returns:
result
(string)
sourceType
⚓︎
Read-only. The type of this magic source. Maps to tes3.magicSourceType
constants.
Returns:
result
(tes3.magicSourceType)
state
⚓︎
Shows if the state is pre-cast, cast, beginning, working, ending, retired, etc. Maps to tes3.spellState
constants.
Returns:
result
(tes3.spellState)
supportsLuaData
⚓︎
If true, references of this object can store temporary or persistent lua data.
Returns:
result
(boolean)
target
⚓︎
Read-only. No description yet available.
Returns:
result
(tes3reference)
timestampCastBegin
⚓︎
The timestamp at which this magic source was cast.
Returns:
result
(number)
Methods⚓︎
__tojson
⚓︎
Serializes the object to json.
local string = myObject:__tojson()
Returns:
string
(string)
getEffectInstance
⚓︎
Gets the magic effect instance for a given effect index and target reference. Effect instances may not all be active on a target, due to reflect, absorption, dispels, different durations and other factors.
local result = myObject:getEffectInstance(index, target)
Parameters:
index
(number): The index in the effect list to fetch, between0
and7
.target
(tes3reference): The target actor for the effect.
Returns:
result
(tes3magicEffectInstance)
getMagnitudeForIndex
⚓︎
Gets the magnitude from the casting source for a given effect index.
local result = myObject:getMagnitudeForIndex(index)
Parameters:
index
(number): The index in the effect list to fetch, between0
and7
.
Returns:
result
(number)
playVisualEffect
⚓︎
This function plays an animation for an effect from the tes3magicSourceInstance
object.
myObject:playVisualEffect({ effectIndex = ..., position = ..., visual = ..., scale = ..., reference = ... })
Parameters:
params
(table)effectIndex
(number): The index in the effect whose visual will be played, a number in range [0, 7].position
(tes3vector3, number[]): A table or ates3vector3
holdingx
,y
andz
coordinates at which the visual effect will be played.visual
(tes3physicalObject, string): The visual effect to be played.scale
(number): Default:1
. The scale of the effect. Only applies to effects that are designed to be scaled.reference
(tes3reference, string): A reference on which the visual effect will be played.
Example: Plays the soul trap effect if the player kills a target that is affected by vampirism.
local function onDamaged(e)
-- Check if we killed our target with this damage.
if e.killingBlow then
-- Iterate through the killed target's active magic effects.
for _, activeMagicEffect in pairs(e.mobile.activeMagicEffectList) do
-- Check if the target is a vampire.
if activeMagicEffect.effectId == tes3.effect.vampirism then
-- Play the soul trap visual effect at the position of the target.
activeMagicEffect.instance:playVisualEffect{
effectIndex = 0,
position = e.mobile.position,
visual = "VFX_Soul_Trap"
}
break
end
end
end
end
event.register(tes3.event.damaged, onDamaged)