Jump to content

Detecting Magic Cast


Recommended Posts

Decided to start a bew thread on this because things have changed.

Objective - Stop player from casting ANY spell.

Current State - Have a script running at stage 0, start game enabled, that should check for a magic cast.

Issues - Not recieving confirmation that script has registered a magic cast.

 

Function MagicCast()
RegisterForAnimationEvent(Game.GetPlayer(), "BeginCastRight")
RegisterForAnimationEvent(Game.GetPlayer(), "BeginCastLeft")
EndFunction

Event OnAnimationEvent(ObjectReference akSource, string asEventName)
if (akSource == Game.GetPlayer()) && (asEventName == "BeginCastRight")
Debug.MessageBox("BeginCastRight Registered!")
endIf
if (akSource == Game.GetPlayer()) && (asEventName == "BeginCastLeft")
Debug.MessageBox("BeginCastLeft Registered!")
endIf
endEvent

 

At stage 0 scripted -

kmyquest.MagicCast()

Help Please!

Link to comment
Share on other sites

I've actually made some progress on this, thanks mainly to your reply to my post months ago. I have the script running on Player Alias in a quest that starts game enabled, it's a 'None' quest so can't be seen/ At stage 0 quest runs and Player alias runs this script...

 

Quest Property My_KillMagic Auto

Event OnSpellCast(Form akSpell)
If My_KillMagic.GetStage() < 100
if (akSpell as Spell)
(GetReference() as Actor).InterruptCast()
Endif
endif
EndEvent

 

Eventually player will regain the ability, somehow - haven't really worked that part of the story out yet -, to cast spells again. But because all spells were removed when the mod started, player will only have their Base Race Spells available. Setting stage to 100 in the quest ends it.

It works well. I will add either some damage to the player when they try to cast or a stagger fx - something. I tested it by dropping spell tomes around where the player spawns and player can learn (again) the spells and can cast them as normal. Seems the script only prevents casting of Base Spells.

 

EDIT: Afterthought. Maybe after player learns a new spell then the script won't work and all spells are cast-able. Need to check later.

Link to comment
Share on other sites

Just tried consoling...

player.setav magicka 99999

 

Still can cast spells other than base spells.

 

Anyway, I am considering another approach using setactorvalue in a script so that magicka is set to 00000 until... whenever. But would be nice to know why this issue/bug/glitch occurs.

Link to comment
Share on other sites

Give him an "Active Effect" that will work as a "Curse", it will detect the spell cast animation and damage X% of the player's magicka every time.

This a more realistic approach and you can easily add and remove the "Curse" where ever / when ever you want.

Link to comment
Share on other sites

 

Give him an "Active Effect" that will work as a "Curse", it will detect the spell cast animation and damage X% of the player's magicka every time.
This a more realistic approach and you can easily add and remove the "Curse" where ever / when ever you want.

 

 

"Active Effect"? You mean like a disease?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...