Jump to content

Photo

Need help with a magic effect script

papyrus script magic modding weapon

  • Please log in to reply
5 replies to this topic

#1
eb113

eb113

    Stranger

  • Members
  • Pip
  • 6 posts

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 by eb113, 16 January 2021 - 04:54 PM.


#2
maxarturo

maxarturo

    What does this even mean?

  • Supporter
  • PipPipPipPip
  • 2,257 posts
- 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 by maxarturo, 16 January 2021 - 04:59 PM.


#3
eb113

eb113

    Stranger

  • Members
  • Pip
  • 6 posts

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 by eb113, 16 January 2021 - 05:42 PM.


#4
dylbill

dylbill

    Faithful poster

  • Premium Member
  • 2,091 posts

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)
EndEvent

If you're going to do it that way, change the SelfRef to the Target rather than the Caster.



#5
eb113

eb113

    Stranger

  • Members
  • Pip
  • 6 posts

Thanks a lot to both of you for the answers, it now works!!!



#6
dylbill

dylbill

    Faithful poster

  • Premium Member
  • 2,091 posts

Cool good to hear :) Happy Modding.







Also tagged with one or more of these keywords: papyrus, script, magic, modding, weapon

IPB skins by Skinbox
Page loaded in: 2.301 seconds