Jump to content

[LE] Help to get a power attack to cast a spell


Recommended Posts

Im trying to learn how to make a custom weapon in Skyrim that will fire off a spell when you power attack depending on the direction. Power attack forward casts fireball side casts chain lightning ect.

 

From what ive looked up I just can't get my head around doing this but from what ive seen its almost always done using a custom script.

 

Does anyone know how to do this in a script?

Link to comment
Share on other sites

I don't get what im doing wrong. Ive set up the weapon and replaced all the place holder stuff but its not firing

 

Scriptname AceCastOnPowerAttackScript extends activemagiceffect

Spell Property AAAFire Auto

Weapon Property AAA1 Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)

RegisterForSingleUpdate(0.5)

akCaster.DrawWeapon()

akCaster.EquipItem(AAA1, True, True)

EndEvent

Event OnUpdate()

bool PowerAttack = Game.GetPlayer().GetAnimationVariableBool("bAllowRotation")

RegisterForSingleUpdate(0.5)

If PowerAttack == True

UnRegisterForUpdate()

Utility.Wait(0.4)

AAAFire.cast(Game.GetPlayer())

EndIf

EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)

UnRegisterForUpdate()

akCaster.UnEquipItem(AAA1, False, True)

akCaster.RemoveItem(AAA1, 1, True)

EndEvent

Edited by dennisj
Link to comment
Share on other sites

To do this, I would make a new spell ability and put the condition IsPowerAttacking == 1 on it's magic effect so that the effect starts whenever you power attack. On the magic effect put this script:

 

 

 

Scriptname PowerAttackSpellScript extends ActiveMagicEffect 

;Put the condition IsPowerAttacking == 1 on this spell abilities magic effect

Spell Property MyPowerAttackSpell Auto

Event OnEffectStart(Actor akTarget, Actor akCaster) ;effect start when power attacking
    MyPowerAttackSpell.Cast(akTarget) ;casts the spell from the actor who is power attacking
EndEvent 

 

Put this script on your weapon:

 

 

Scriptname PowerAttackAddAbilityScript extends ObjectReference 

Spell Property PowerAttackTrigger Auto ;this is the spell ability you made above that detects power attacking

Event OnEquipped(Actor akActor)
    akActor.AddSpell(PowerAttackTrigger)
EndEvent 

Event OnUnequipped(Actor akActor)
    akActor.RemoveSpell(PowerAttackTrigger) 
EndEvent 

 

Name the scripts something more unique and don't forget to fill properties in the creation kit after compiling.

Link to comment
Share on other sites

Im trying to learn how to make a custom weapon in Skyrim that will fire off a spell when you power attack depending on the direction. Power attack forward casts fireball side casts chain lightning ect.

 

From what ive looked up I just can't get my head around doing this but from what ive seen its almost always done using a custom script.

 

Does anyone know how to do this in a script?

 

This mod applies dragonrend upon a power attack, maybe this would help you?

I don't know the answer to your question just that I use a mod that does this.

 

It's called DragonBlade.

Good luck!

https://www.nexusmods.com/skyrimspecialedition/mods/29341

Link to comment
Share on other sites

  • Recently Browsing   0 members

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