Script Help: Script for when NPC hit by spell

Post » Wed Aug 27, 2014 3:16 pm

Hello community.

I am working on a mod that one small aspect will have a quest update when the player casts a specific spell at a specific npc.

I considered using the OnSpellCast, but do not know if it is when the target casts it or the player. I assume the script would need to be attached to the target and that it would be some manner of "activemagiceffect" type script. My Scripting knowledge is very basic but I would assume it would be something like this.

Spoiler

ScriptName ExampleQuestTrigger Extends ObjectReference

Actor Property Creature Auto
Quest Property QuestName01 Auto

MagicEffect Property ModdedSpell Auto

If PlayerRef Casts ModdedSpell at me

QuestName01.SetStage(100)

EndIf

Sorry for the sadness that is my scripting ability but help with this would really speed things along for me.

I intend to enable the creature when the quest starts to avoid quest breaking and OnDeath for player failure.

Thank you

User avatar
Ana Torrecilla Cabeza
 
Posts: 3427
Joined: Wed Jun 28, 2006 6:15 pm

Post » Wed Aug 27, 2014 4:23 pm

ScriptName ExampleQuestTrigger Extends ObjectReference{attach this script to the npc that the player is supposed to hit};make sure to fill all three of these properties by pressing the "Properties";button in the Creation Kit after attaching this script to the actor!Actor Property PlayerRef AutoQuest Property QuestName01  AutoMagicEffect Property ModdedSpell AutoEvent OnMagicEffectApply(ObjectReference akCaster, MagicEffect akEffect)    if (akCaster == PlayerRef && akEffect == ModdedSpell)        QuestName01.SetStage(100)        GoToState("Disabled")    endifEndEventState Disabled    Event OnMagicEffectApply(ObjectReference akCaster, MagicEffect akEffect)        ;when we are in the disabled state, this won't do anything anymore    EndEventEndState
User avatar
stevie trent
 
Posts: 3460
Joined: Thu Oct 11, 2007 3:33 pm

Post » Wed Aug 27, 2014 10:14 am

I will be building the quest now. Thank you. I will test it but at a glance it seems solid.

I will also report success but it will take me a while.

Thank you.

User avatar
Tracey Duncan
 
Posts: 3299
Joined: Wed Apr 18, 2007 9:32 am


Return to V - Skyrim