Difference between revisions of "AddSpell - Actor"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Chesko
m (→‎Notes: Added link to the mod which addresses the issue concerning Dual Casting.)
 
(4 intermediate revisions by 3 users not shown)
Line 34: Line 34:


== Notes ==
== Notes ==
* Adding a spell marked as an Ability to the Player without at least one [[Effect Item]] set in the Effects List will result in a crash to desktop when the Player attempts to view their Active Effects.
* Adding a Spell marked as an Ability to the Player without at least one [[Effect Item]] set in the Spell's Effects List will result in a crash to desktop when the Player attempts to view their Active Effects in the menu.
** You can get away with an Effect-less Ability by applying the AbBlank Effect to an Ability. This will prevent crashing, but keep the Ability from appearing in Active Effects.
* This function was confirmed to be one of the culprits associated with the dual casting bug where the bool returned by isDualCasting is not correct. This has been addressed by the following mod here: [https://www.nexusmods.com/skyrimspecialedition/mods/92454 Po3's Dual Casting Fix]


== See Also ==
== See Also ==
*[[Actor Script]]
*[[Actor Script]]
*[[RemoveSpell - Actor]]
*[[RemoveSpell - Actor]]

Latest revision as of 09:19, 2 June 2023

Member of: Actor Script

Adds the specified spell to this actor.

Syntax[edit | edit source]

bool Function AddSpell(Spell akSpell, bool abVerbose = true) native

Parameters[edit | edit source]

  • akSpell: The spell to add to this actor.
  • abVerbose: Pass false to suppress UI messages for spells added to the player. Spells added to NPCs never result in a UI message.
    • Default: True

Return Value[edit | edit source]

True on success.

Examples[edit | edit source]

; Adds the sheep spell to the player
if (Game.GetPlayer().AddSpell(SheepSpellProperty))
  Debug.Trace("Sheep spell added to the player")
endIf


; Adds the sheep spell to the player, silently
if (Game.GetPlayer().AddSpell(SheepSpellProperty, false))
  Debug.Trace("Sheep spell added to the player (like a ninja!)")
endIf

Notes[edit | edit source]

  • Adding a Spell marked as an Ability to the Player without at least one Effect Item set in the Spell's Effects List will result in a crash to desktop when the Player attempts to view their Active Effects in the menu.
    • You can get away with an Effect-less Ability by applying the AbBlank Effect to an Ability. This will prevent crashing, but keep the Ability from appearing in Active Effects.
  • This function was confirmed to be one of the culprits associated with the dual casting bug where the bool returned by isDualCasting is not correct. This has been addressed by the following mod here: Po3's Dual Casting Fix

See Also[edit | edit source]