Jump to content

Help Power Attack Detection through script


Recommended Posts

Hi, I'm trying to creat a patch for Smooth Combo Animation and Attack Behavior Revamp.

 

Thing is SCA use a script to make sure that the combo only advances when normal swing animation, as opposed to power attacka animation, are played, to do this, the script uses the following line:

 

if !selfref.GetAnimationVariableBool("bAllowRotation")

 

This works because normal attacks are set with bAllowRotation = true.

However ABR changes this behavior, so that NO attack are allowed to Rotate.

 

I need another way to make sure that the power attacks are verified through scripts.

 

Thank you!

Link to comment
Share on other sites

There's an AnimationVariableInt iState_NPCPowerAttacking

https://www.creationkit.com/index.php?title=List_of_Animation_Variables

 

It might only work for NPC's though, you'd have to test. There's also a Creation Kit condtion IsPowerAttacking. There doesn't seem to be a papyrus condition, but a workaround to use that is to use a spell and put the condition on its magic effect in the CK. Then use a script with OnEffectStart on the magic effect. That event will only fire if the condition is met.

Link to comment
Share on other sites

Thanks I will look into it.

I'm not sure the option in CreationKit will work, since the script is being delivered through a perk that always stay active, so even if the option for it to fire only when is not powerattack does not work.

 

The script works by firing every time you swing your weapon, however it must not fire when you are power attacking, since this cause a bug with Dynamic Animation Replacer, that the ending of your power attack animation is replaced with the next power attack animation.

 

I was trying to make a check for onanimationevent for every power attack, but I was not able to. I'm very new to coding in general.

Just to be sure, how should I make a negative statement?

 

Should it be like this:

!onanimationevent(powerattacking)

?

 

Thanks.

 

Edit: my next move is trying to see how other mods that use a powerattack verification, and then make a reverse statement. Also sorry for any english errors, it is not my main language, but please, do point it out, it helps my learning greatly.

Edited by sonic123br
Link to comment
Share on other sites

Diggin through Colorful magic mod, I was able to locate a script that mught help.

self.UnregisterForAnimationEvent(akCaster as objectreference, "AttackPowerStanding_FXstart")
self.UnregisterForAnimationEvent(akCaster as objectreference, "AttackPowerRight_FXstart")
self.UnregisterForAnimationEvent(akCaster as objectreference, "AttackPowerLeft_FXstart")
self.UnregisterForAnimationEvent(akCaster as objectreference, "AttackPowerBackward_FXstart")
self.UnregisterForAnimationEvent(akCaster as objectreference, "AttackPowerForward_FXstart")
Does this work only for the Blood Skaal blade, or it will work for every weapon?
How would I be able to make a negative check on these conditions?
Link to comment
Share on other sites

Hey, so I had to detect power attack with my mod Triple Triad Card Game in Skyrim. I use it for the unique gunblade weapon in the mod. Whenever you power attack with it, it fires a bullet (done by casting a spell with a bullet projectile.) When I was testing I found that the power attack animations weren't reliable, so I used a spell to check, which does happen when you swing your weapon.

 

So first I have a spell ability that registers for weapon swings:

 

Scriptname TT_GunbladeAbilityScript extends ActiveMagicEffect 

Spell Property TT_GunbladePowerAttackCheck Auto 

Event OnEffectStart(Actor akTarget, Actor akCaster)
    RegisterForAnimationEvent(akTarget, "weaponSwing")
    RegisterForAnimationEvent(akTarget, "weaponLeftSwing")
    ;RegisterForAnimationEvent(akTarget, "PowerAttackStop") ;this didn't work.
     
EndEvent

Event OnAnimationEvent(ObjectReference akSource, String asEventName)
    TT_GunbladePowerAttackCheck.Cast(akSource, akSource) ;cast the gunblade spell check on self
    ;spell has the TT_GunbladShotScript attached with the IsPowerAttacking == 1 condition.
EndEvent 

Then to do the code stuff I have a script on the TT_GunbladePowerAttackCheck spell's magic effect.

Scriptname TT_GunbladShotScript extends ActiveMagicEffect 
;The spell this magic effect is on has the condition isPowerAttacking == 1
;This script is on the TT_GunbladePowerAttackCheck spell's magic effect


Spell Property TT_GunbladeSpell Auto 
Spell Property TT_GunbladeAbility Auto
Sound Property TT_GunbladeShot Auto
Sound Property TT_GunbladeClick Auto 
Sound Property TT_GunbladeCock Auto 
Weapon Property TT_Gunblade Auto 
MiscObject Property TT_GunbladeBullets Auto


Event OnEffectStart(Actor akTarget, Actor akCaster) 
    ;effect only starts if the akTarget is power attacking
    If akTarget.GetItemCount(TT_GunbladeBullets) > 0
        If akTarget.GetAnimationVariableBool("bLeftHandAttack") == False && akTarget.GetEquippedWeapon() == TT_Gunblade ;if gunblade is equipped in right hand and attacking with right hand. 
            TT_GunbladeSpell.Cast(akTarget)
            TT_GunbladeShot.Play(akTarget)
            akTarget.RemoveItem(TT_GunbladeBullets, 1, true)
        Elseif akTarget.GetAnimationVariableBool("bLeftHandAttack") == True && akTarget.GetEquippedWeapon(True) == TT_Gunblade    
            TT_GunbladeSpell.Cast(akTarget)
            TT_GunbladeShot.Play(akTarget)
            akTarget.RemoveItem(TT_GunbladeBullets, 1, true)
        Endif 
            
    Elseif akTarget.GetEquippedWeapon() == TT_Gunblade || akTarget.GetEquippedWeapon(True) == TT_Gunblade 
        TT_GunbladeClick.Play(akTarget) 
    Else 
        akTarget.RemoveSpell(TT_GunbladeAbility) ;remove this ability.
    Endif
EndEvent

You would change IsPowerAttacking == 0 for yours.

 

The magic effect for the TT_GunbladePowerAttackCheck spell has

Effect Archetype: Script

Casting Type: Fire and Forget

Delivery: Target Actor

 

Hope that helps.

Link to comment
Share on other sites

Just some addition to dylbill post.


The 2 'AnimationEvents' will only detect power attacks from 1H weapons, if you also need to detect 2H power attacks, then you also need:

AttackPowerStanding_FXstart

AttackPowerRight_FXstart

AttackPowerLeft_FXstart

AttackPowerBackward_FXstart

AttackPowerForward_FXstart

Link to comment
Share on other sites

  • Recently Browsing   0 members

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