Jump to content

Power attack triggered spell


Christianity

Recommended Posts

Anyone know if its possible to trigger a spell cast off of a melee weapon power attack? or any weapon attack if necessary.

 

I've been poking around in the creation kit, first time ever, trying to add a magic effect to the Dawnbreaker. I found that you can't apply a magic effect like FireDamageFFAimed to an Enchantment effect on a contact weapon. And I didn't see a way to apply a second enchantment to a weapon (Was thinking I might be able to just throw StaffEnchFireball on it :P).

 

Then I checked out scripting. But I don't see any events in the creation kit wiki that say they occur on a weapon swing or power attack. However in the gameplay menu under Animations, if you check "Actors\Character\Behaviors\0_Master.hkx" there is an ActionRightPowerAttack tree. The PowerAttack > PowerAttackStanding has an "Anim Event" called AttackPowerStartInPlace. Is it possible to check for that event?

 

There is an OnAnimationEvent, and RegisterForAnimationEvent but the wording in the wiki makes it seem like I'm misunderstanding its purpose.

 

So yea, I'll keep experimenting, but I'm hoping someone can save me a lot of time.

Link to comment
Share on other sites

Anyone know if its possible to trigger a spell cast off of a melee weapon power attack? or any weapon attack if necessary.

 

i looking for this too, but i just find this "WeaponLeftSwing" "WeaponSwing", and "AttackWinStart"

Link to comment
Share on other sites

Well you could try calling it by actions, im not sure if it will work, but basically what you have to do is define a variable:

Action property LeftAttack auto

Then go to the script's properties and search there for ActionLeftAttack.

Then do a RegisterForAnimationEvent(Player,LeftAttack) --Player being a variable using the PlayerRef, and leftAttack the variable we set up.

I think that last bit needs to be looping, or maybe not, maybe if you do it one time you can get a sort of loop like first time you call that function it registers and waits for the event to happen, when such event happen you can either register again or not register at all, depending on what you want to do.

OnAnimationEvent(ObjectReference Player, string LeftAttack)

code here...

endEvent

Tell me how it goes.

Link to comment
Share on other sites

I tried this and did not work:

 

Action Property ActionDualPowerAttack Auto

 

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)

 

RegisterForAnimationEvent(self, ActionDualPowerAttack)

 

endEvent

 

Event OnAnimationEvent(ObjectReference akSource, string asEventName)

 

if(akSource == self as ObjectReference)

if (asEventName == ActionDualPowerAttack)

Debug.MessageBox("PowerAttack!")

endif

 

endif

 

endEvent

 

there is no info about the Actions on the CK page :S

Link to comment
Share on other sites

@raden

 

Isn't this basically the same thing as what you do with your throwing knives mod? Making a spell trigger on power attack should be easy:

 

 

Scriptname fg109Custom1HWeaponScript extends ObjectReference

GlobalVariable property RegisterRH auto
Spell property AttackSpell auto

Bool IsRHWeapon

Event OnEquipped(Actor akActor)

if (RegisterRH.GetValue() == 1)
	RegisterForAnimationEvent(akActor, "attackPowerStart_SprintLeftHand")
	RegisterForAnimationEvent(akActor, "attackPowerStartForwardLeftHand")
	RegisterForAnimationEvent(akActor, "attackPowerStartRightLeftHand")
	RegisterForAnimationEvent(akActor, "attackPowerStartLeftLeftHand")
	RegisterForAnimationEvent(akActor, "attackPowerStartBackLeftHand")
	RegisterForAnimationEvent(akActor, "attackPowerStartInPlaceLeftHand")
else
	RegisterForAnimationEvent(akActor, "attackPowerStart_Sprint")
	RegisterForAnimationEvent(akActor, "attackPowerStartForward")
	RegisterForAnimationEvent(akActor, "attackPowerStartRight")
	RegisterForAnimationEvent(akActor, "attackPowerStartLeft")
	RegisterForAnimationEvent(akActor, "attackPowerStartBack")
	RegisterForAnimationEvent(akActor, "attackPowerStartInPlace")
	RegisterRH.SetValue(1)
	IsRHWeapon = true
endif

EndEvent

Event OnUnequipped(Actor akActor)

if (IsRHWeapon)
	UnregisterForAnimationEvent(akActor, "attackPowerStart_Sprint")
	UnregisterForAnimationEvent(akActor, "attackPowerStartForward")
	UnregisterForAnimationEvent(akActor, "attackPowerStartRight")
	UnregisterForAnimationEvent(akActor, "attackPowerStartLeft")
	UnregisterForAnimationEvent(akActor, "attackPowerStartBack")
	UnregisterForAnimationEvent(akActor, "attackPowerStartInPlace")
	RegisterRH.SetValue(0)
else
	UnregisterForAnimationEvent(akActor, "attackPowerStart_SprintLeftHand")
	UnregisterForAnimationEvent(akActor, "attackPowerStartForwardLeftHand")
	UnregisterForAnimationEvent(akActor, "attackPowerStartRightLeftHand")
	UnregisterForAnimationEvent(akActor, "attackPowerStartLeftLeftHand")
	UnregisterForAnimationEvent(akActor, "attackPowerStartBackLeftHand")
	UnregisterForAnimationEvent(akActor, "attackPowerStartInPlaceLeftHand")
endif

IsRHWeapon = false

EndEvent

Event OnAnimationEvent(ObjectReference akSource, string asEventName)

AttackSpell.Cast(akSource)

EndEvent

 

 

EDIT: Never mind, doesn't work. See post below.

Edited by fg109
Link to comment
Share on other sites

RegisterRH should be a global variable, initially set to 0. It's to keep track of whether or not the player is dual-wielding with the same weapon in the right hand already. But I just tried it out and it didn't work. I might be looking at the wrong animation events wrong, or else the game just doesn't send the events to the script...

 

I tried something else instead. Power attacking with an iron dagger will shoot out a fireball. Unfortunately, I'm unable to distinguish between different power attacks. For example, if you have an iron dagger in your left hand but power attack with your right hand weapon, a fireball will still come out.

 

EDIT: removed link

Edited by fg109
Link to comment
Share on other sites

RegisterRH should be a global variable, initially set to 0. It's to keep track of whether or not the player is dual-wielding with the same weapon in the right hand already. But I just tried it out and it didn't work. I might be looking at the wrong animation events wrong, or else the game just doesn't send the events to the script...

 

I tried something else instead. Power attacking with an iron dagger will shoot out a fireball. Unfortunately, I'm unable to distinguish between different power attacks. For example, if you have an iron dagger in your left hand but power attack with your right hand weapon, a fireball will still come out.

 

 

Hmmm.... well, in my case, that might be super-close! My use would be on a two-handed sword, so a power attack is a power attack. The catch would still be distinguishing which one. Also, would a spell cast with this method still draw from the player's magic so long as the spell selected is set up to cost magic? And why I'm asking questions, would it also be possible to check the player's race before allowing the spell to be cast?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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