Help with a script.

Post » Thu Jun 21, 2012 7:23 am

I'm trying to cast a spell on the player when he begins to draw a bow. Sadly, GetAttackState works in the console, but does not work as a condition in the CK. So I'm trying to find another way to make it work, but as I'm completely new to TES modding, I could use a little help.
User avatar
Etta Hargrave
 
Posts: 3452
Joined: Fri Sep 01, 2006 1:27 am

Post » Thu Jun 21, 2012 3:45 pm

Use this where you want to initiallise the spell being ready to be launched.
RegisterForAnimationEvent(game.getplayer(),"BeginWeaponDraw")

This is the event that will take the bow drawing
Event OnAnimationEvent(ObjectReference akSource, string asEventName)if aksource == game.getplayer() && aseventname =="beginWeaponDraw" && (game.getplayer().GetEquippedItemType(0) == 7);cast your spell hereendifEndEvent

Use this where you want your spell to not being ready for the player drawing the bow
UnregisterForAnimationEvent(game.getplayer(), "BeginWeaponDraw")


You may want to define a property as "actor property player auto" and later assign to it the value of game.getplayer(), to use it instead of calling that function, which will make it faster (not really needed in this case, but will help your othe scripts as well as other author's and vanilla ones.
User avatar
^_^
 
Posts: 3394
Joined: Thu May 31, 2007 12:01 am

Post » Thu Jun 21, 2012 9:28 am

Use this where you want to initiallise the spell being ready to be launched.
RegisterForAnimationEvent(game.getplayer(),"BeginWeaponDraw")

This is the event that will take the bow drawing
Event OnAnimationEvent(ObjectReference akSource, string asEventName)if aksource == game.getplayer() && aseventname =="beginWeaponDraw" && (game.getplayer().GetEquippedItemType(0) == 7);cast your spell hereendifEndEvent

Use this where you want your spell to not being ready for the player drawing the bow
UnregisterForAnimationEvent(game.getplayer(), "BeginWeaponDraw")


You may want to define a property as "actor property player auto" and later assign to it the value of game.getplayer(), to use it instead of calling that function, which will make it faster (not really needed in this case, but will help your othe scripts as well as other author's and vanilla ones.

Wow, thank you so much amgepo! Was not expecting such a detailed explanation :). Going to try it out now.
User avatar
Carlos Rojas
 
Posts: 3391
Joined: Thu Aug 16, 2007 11:19 am


Return to V - Skyrim