Elias555 Posted August 12, 2017 Share Posted August 12, 2017 (edited) Trying to figure this one out , here's what I have so far. It's attached to a lesser power. Scriptname AceCastOnPowerAttackScript extends Activemagiceffect Spell Property MySpell Auto Weapon Property MyWeapon Auto Event OnEffectStart(Actor akTarget, Actor akCaster) RegisterForAnimationEvent(akCaster, "AttackPowerForward_FXStart") Debug.Notification("Ready") Game.GetPlayer().EquipItem(MyWeapon, False, True) EndEvent Event OnAnimationEvent(ObjectReference akSource, string AsEventName) ;Actor Source = akSource as Actor If AsEventName == "AttackPowerStanding_FXStart" && Game.GetPlayer().IsEquipped(MyWeapon) && akSource == Game.GetPlayer() MySpell.cast(Game.GetPlayer()) Debug.Notification("Event Fired") EndIf EndEvent Event OnEffectFinish(Actor akTarget, Actor akCaster) UnRegisterForAnimationEvent(akCaster, "AttackPowerForward_FXStart") ;Automatically occurs when effect ends I think. Debug.Notification("Done") Game.GetPlayer().UnEquipItem(MyWeapon) EndEvent The animation event never fires. I've tried other animations too but I think I've got the syntax wrong or something similar. Possibly the akSource being an actor. Edit: I tried a different approach. This is attached to a weapon. Scriptname AceCastOnPowerAttackScript extends ObjectReference Spell Property MySpell Auto Event OnEquipped(Actor akActor) RegisterForSingleUpdate(1) EndEvent Event OnUpdate() bool PowerAttack = Game.GetPlayer().GetAnimationVariableBool("bAllowRotation") If PowerAttack == True Utility.Wait(0.6) MySpell.cast(Game.GetPlayer()) UnRegisterForUpdate() EndIf RegisterForSingleUpdate(1) EndEvent Event OnUnequipped(Actor akActor) UnRegisterForUpdate() EndEvent Edit2: Tried adding a perk to the player and utilizing apply weapon swing spell. I selected random spells but it never fired. Edit3:This was the best I could come up with. Improvements or better alternatives are most welcome! Scriptname AceCastOnPowerAttackScript extends Activemagiceffect Spell Property MySpell Auto Weapon Property MyWeapon Auto Event OnEffectStart(Actor akTarget, Actor akCaster) RegisterForSingleUpdate(0.5) akCaster.DrawWeapon() akCaster.EquipItem(MyWeapon, True, True) EndEvent Event OnUpdate() bool PowerAttack = Game.GetPlayer().GetAnimationVariableBool("bAllowRotation") RegisterForSingleUpdate(0.5) If PowerAttack == True UnRegisterForUpdate() Utility.Wait(0.4) MySpell.cast(Game.GetPlayer()) EndIf EndEvent Event OnEffectFinish(Actor akTarget, Actor akCaster) UnRegisterForUpdate() akCaster.UnEquipItem(MyWeapon, False, True) akCaster.RemoveItem(MyWeapon, 1, True) EndEvent Edited August 12, 2017 by Elias555 Link to comment Share on other sites More sharing options...
Lisselli Posted August 13, 2017 Share Posted August 13, 2017 (edited) Perk is the way to go and you probably did not set it up correctly. I've worked on this, tested, and it works. Create the spell/effect you want to cast. Make sure the CastingType is Fire and Forget and the Delivery is Contact. Effect ArcheType should be Script(you can't control the magnitude of the spell being cast from a script anyway). Add a small script that will cast the spell. Do not add OnUpdates or any of those other things, they aren't needed for this to work. This is at its very basic, no kidding. Just OnEffectStart(usual params) and a ThisSpell.Cast(akTarget). For the PerkOwner tab(make sure you add the spell to cast from the perk entry point), add the following conditions: IsPowerAttacking == 1.00 There all done. This will only fire if the player is power attacking(actually if the power attacking connects). You can get creative and instead use isAttackType if you only want specific types of Power Attacking to activate the perk, like PowerAttackSide(will only fire if the power attack was from a side position, and not fire if the player is doing a running power attack, or from a standing position). It's not completely perfect but you don't need polling and OnEffectFinish is not needed. Also as a tip: UnregisterForUpdate() is not needed for RegisterForSingleUpdate(). It's only used for RegisterForUpdate(), which no one should be using anymore due to its known nature to break save games if the mod is removed(OnUpdate will keep calling itself). Edited August 13, 2017 by Lisselli Link to comment Share on other sites More sharing options...
Elias555 Posted August 13, 2017 Author Share Posted August 13, 2017 Perk is the way to go and you probably did not set it up correctly. I've worked on this, tested, and it works. Create the spell/effect you want to cast. Make sure the CastingType is Fire and Forget and the Delivery is Contact. Effect ArcheType should be Script(you can't control the magnitude of the spell being cast from a script anyway). Add a small script that will cast the spell. Do not add OnUpdates or any of those other things, they aren't needed for this to work. This is at its very basic, no kidding. Just OnEffectStart(usual params) and a ThisSpell.Cast(akTarget). For the PerkOwner tab(make sure you add the spell to cast from the perk entry point), add the following conditions: IsPowerAttacking == 1.00 There all done. This will only fire if the player is power attacking(actually if the power attacking connects). You can get creative and instead use isAttackType if you only want specific types of Power Attacking to activate the perk, like PowerAttackSide(will only fire if the power attack was from a side position, and not fire if the player is doing a running power attack, or from a standing position). It's not completely perfect but you don't need polling and OnEffectFinish is not needed. Also as a tip: UnregisterForUpdate() is not needed for RegisterForSingleUpdate(). It's only used for RegisterForUpdate(), which no one should be using anymore due to its known nature to break save games if the mod is removed(OnUpdate will keep calling itself).Thanks for the alternative but it won't allow me to hit something at a distance and if I want to off set the timing(so the spell fires after the animation) I'll still need a script.It's much cleaner than my method but it's limiting as you've described. Link to comment Share on other sites More sharing options...
Recommended Posts