How would a script detect staff casting?

Post » Sat Mar 09, 2013 5:03 am

There seems to be a staff casting anima event for the LEFT hand but not the right !!! ??? wtf??

Anyone know how a script may detect staff casting enchantments (spells) with either or both hands??
User avatar
Mike Plumley
 
Posts: 3392
Joined: Wed Sep 05, 2007 10:45 pm

Post » Sat Mar 09, 2013 9:01 am

http://www.creationkit.com/GetEquippedItemType_-_Actor

You can specify which hand to check and if it returns "8" then it's a staff

- Hypno
User avatar
Ebony Lawson
 
Posts: 3504
Joined: Fri Feb 16, 2007 11:00 am

Post » Sat Mar 09, 2013 10:32 am

Sorry I guess I was not clear, I need the script to detect when the staff that is held in the right hand is attacking (firing spells).

Not IF the staff is equipped.


http://www.creationkit.com/GetEquippedItemType_-_Actor

You can specify which hand to check and if it returns "8" then it's a staff

- Hypno
User avatar
gemma
 
Posts: 3441
Joined: Tue Jul 25, 2006 7:10 am

Post » Sat Mar 09, 2013 10:04 am

I guess you could put the player in an alias and do an OnSpellCast and then do the if GetEquippedItemType()==8
User avatar
Syaza Ramali
 
Posts: 3466
Joined: Wed Jan 24, 2007 10:46 am

Post » Sat Mar 09, 2013 1:50 am

Needs to be for all actors.
I never make combat features that only work for the player (try to anyway).
So this is in an ability magic effect.

Anyway that is not important, the important part is that Onspellcast was not triggered by the staff attack.

mmmm....it was late when I made that conclusion...and I was very tired...so I will test this again right now to be sure.


Edit: ok, Onspellcast works!

The problem was that I could not get the spell from the enchantment, that is why I thought it did not work at first.
In the following I see the first message but not the second message:

Event OnSpellCast(Form akSpell)debug.messagebox("Attack with staff works.") ;-- I see thisspell MyAttackspell = akspell as spellif MyAttackspell.IsHostile() == truedebug.messagebox("Attack spell detection works.") ;-- I do not ever see thisendif


The problem is that the staff projectile is an ENCHANTMENT not a spell.
Any idea how I can GET the spell that is IN the enchantment that is on the staff so that I can test it for Hostile and then also do other things with the spell?





I guess you could put the player in an alias and do an OnSpellCast and then do the if GetEquippedItemType()==8
User avatar
yessenia hermosillo
 
Posts: 3545
Joined: Sat Aug 18, 2007 1:31 pm

Post » Sat Mar 09, 2013 2:50 am

Edit: aaaaand this whole replied got ninja'd by Spooky finding that Onspellcast worked after all. :wallbash: Leaving it for reference anyway.

My guess is you'll have to track it yourself with an ability. There is an event, "SoundPlay.WPNStaffHandDraw" that fires when a staff gets equipped in either hand. Unfortunately, the actual casting events listed below are identical whether you have a staff in your hand or just a spell. You could use a script with states to track whether the actor has a staff equipped.

The events fired when drawing a staff and casting a FF spell with the right hand:
Spoiler

tailEquipweaponDrawInterruptCastarrowDetachMagic_Equip_OutSoundPlay.WPNStaffHandDrawEnableBumpertailCombatIdleBeginCastRightSprintStoptailCombatIdleMRh_PreChargeOut (Spell is charged and ready to release)MRh_SpellFire_EventMRh_WinStartMRh_Equipped_EventMRh_WinEndCastStoptailCombatIdle

The events fired when drawing a staff and casting a Conc spell with the left hand:
Spoiler

tailEquipweaponDrawInterruptCastarrowDetachSoundPlay.WPNStaffHandDrawweaponDrawSyncPointMagic_Equip_OutEnableBumpertailCombatIdleBeginCastLeftSprintStoptailCombatIdleMLh_PreChargeOutMLh_SpellFire_EventCastStoptailCombatIdle

The only difference between those sequences and the sequence of equipping a non staff-based spell is the lack of SoundPlay.WPNStaffHandDraw.

So... if you have your actor-attached script watch for SoundPlay.WPNStaffHandDraw events, use http://www.creationkit.com/GetEquippedItemType_-_Actor to see which hand has the staff, then switch to a state where it watches for MLh_ or MRh_SpellFire_Event (obviously depending on which hand has the staff), that should work. To detect when the actor has put the staff away, either watch for Magic_Equip_Out without a preceding SoundPlay.WPNStaffHandDraw, or just re-check the target's equipped weapons any time Magic_Equip_Out fires.

This should work pretty well overall; I'm tracking more complex states than this using similar methods. Of course, if there's an easier method or Papyrus event you can use, you should do so :wink:
User avatar
CArla HOlbert
 
Posts: 3342
Joined: Wed Feb 21, 2007 11:35 pm

Post » Sat Mar 09, 2013 12:00 am

* I forget that sound events can be used even in Skyrim...I LOVE SOUND TRIGGERS as I used them all the time in Oblivion. I did the same thing in designing my animatronic control systems by using a VOX to listen to when the sound effects start and then trigger my animatronic monsters for Haunted Houses. This way all the timing and sound synchronization could be done with a simple and cheap 7$ vox instead of what my competitors were using ($100 micro controllers).

But will that event work for ALL actors? I find many DO NOT work for all actors.

ActorREF.getAnimationVariableBool("Isattacking") == true
will NOT detect a skeleton drawing a bow but it will for NPC.

That makes things god awfully complicated for moding combat unless you only want to make a mod that is player centric.

It is too bad this is so much more complicated in Skyrim, in Oblivion you could do this : If the sound played by the actor has the word "cast" in the name of the sound file then "do stuff".

God I miss oblivion...


* Edit: oh...wait... there is no sound detection in skyrim... this is an EVENT like animation events.... bummer...


Anyway, OnSpellCast works..but I need a way to get the spell fired from the staff (enchantments will not give their spell to AKSPELL) ... do you know how to do that by any chance?



Edit:

BREAK THRU !!!

I think I can do this using the AKSource from an on hit event:

Enchantment MyEnchantmentSpell = AkSource as Enchantment

and there is a IsHostile for enchantments !

But there is no CAST for enchantments. :confused: I need to fire the enchantment back at the attacker. I guess I will put in a request in the SKSE thread. Wow, another "hole" in the basic scripting.
User avatar
Mariaa EM.
 
Posts: 3347
Joined: Fri Aug 10, 2007 3:28 am


Return to V - Skyrim