Daud199 Posted January 16, 2021 Share Posted January 16, 2021 (edited) Hello guys, i recently started with papyrus scripting and i really need help with a script that won't work. What i'm trying to do right now is casting a heal on my character every time he swings with a weapon. I'mputting the script here so if anyone can tell me what i'm doing wrong it will be very helpful ScriptName MyScript Extends ActiveMagicEffect Spell property HealingRightHand Auto Actor SelfRef Event OnEffectStart(Actor akTarget, Actor akCaster) SelfRef = akCaster RegisterForAnimationEvent(SelfRef, "weaponSwing") EndEvent Event OnEffectFinish(Actor akTarget, Actor akCaster) EndEvent Event OnAnimationEvent(ObjectReference akSource, string EventName) If (eventName == "weaponSwing") HealingRightHand.cast(SelfRef, SelfRef) EndIf EndEvent Edited January 16, 2021 by eb113 Link to comment Share on other sites More sharing options...
maxarturo Posted January 16, 2021 Share Posted January 16, 2021 (edited) - Where is the script added?, this should be added to an "Ability Spell". - Is the actor carrying the 'Ability Spell'?. - Have you fill in all its properties?. Edited January 16, 2021 by maxarturo Link to comment Share on other sites More sharing options...
Daud199 Posted January 16, 2021 Author Share Posted January 16, 2021 (edited) The script is for a magic effect that is then linked to an enchant for the weapon that should fire the spell once swinged, could it be a problem with the flags? EDIT: i checked the properties and everything is fine, the one thing that i don't understand is how attach this effect even to my character, since is something that should be tied only to the weapon Edited January 16, 2021 by eb113 Link to comment Share on other sites More sharing options...
dylbill Posted January 16, 2021 Share Posted January 16, 2021 What you need to do is put a script on the weapon, that adds the ability to your character when you equip the weapon, and removes the ability when you unequip the weapon. Alternatively, you can cast the healing spell with OnEffectStart in the enchant's magic effect script, and this will heal your character whenever you hit another actor with the weapon. Put a script like this on the weapon: Scriptname TM_WeapSwingHealScript extends ObjectReference Spell Property WeaponSwingHealAbility Auto Event OnEquipped(Actor akActor) akActor.AddSpell(WeaponSwingHealAbility) EndEvent Event OnUnEquipped(Actor akActor) akActor.RemoveSpell(WeaponSwingHealAbility) EndEventIf you're going to do it that way, change the SelfRef to the Target rather than the Caster. Link to comment Share on other sites More sharing options...
Daud199 Posted January 16, 2021 Author Share Posted January 16, 2021 Thanks a lot to both of you for the answers, it now works!!! Link to comment Share on other sites More sharing options...
dylbill Posted January 16, 2021 Share Posted January 16, 2021 Cool good to hear :) Happy Modding. Link to comment Share on other sites More sharing options...
Recommended Posts