Jump to content

[SE] Make Weapon Damage Player When Swinging


Recommended Posts

[Almost posted this in the wrong place, moved it here!]

Hello all! I am working on a big mod and unique weapons and collectables. I have a sword that when attacking, takes health from the player. (High Reward, High Risk) However, I have been trying EVERYTHING in Creation Kit to make this work. I've tried enchantments, Perks, Scripts... nothing for goodness sake will work at all! I managed to make it give health, but don't know how to make it take away health... I am feeling a little defeated! If it's not possible, than I understand and I will just move on. I just wanted to at least put it to rest before I can call it a fail completely.

Any pointers or help would be greatly appreciated! Oh and I will also be sure to credit whomever can solve this mystery for me! 

(I am also willing to show scripts I have attempted to use if anyone needs them)

Link to comment
Share on other sites

I get that, but I don't really know how to go about it... I have tried doing that (both with a script and value modifier) and nothing seems to work. 😞

Link to comment
Share on other sites

Hitting, the health only takes when you make contact with an enemy. Still haven't had any solution... So I am probably just gonna nerf the idea and make absorb health from the enemy instead. It appears to be impossible at this point. 😛

Link to comment
Share on other sites

To detect hits, just put an enchantment on your weapon or add a new magic effect to the enchantment if it already has one. Then add a script to the magic effect that extends ActiveMagicEffect and use the OnEffectStart Event. The event will trigger whenever you hit something with the weapon.

Link to comment
Share on other sites

Another option is if you're using SKSE, my mod Dylbills Papyrus Functions: https://www.nexusmods.com/skyrimspecialedition/mods/65410 includes DbSkseEvents. 

Example script: 

;script attached to a form such as a quest
 
Weapon Property MyWeapon Auto
Weapon Property MyOtherWeapon Auto
 
Event OnInit()
    ;compare MyWeapon with 'Source'. Register this form for when anything is hit with MyWeapon.
    DbSkseEvents.RegisterFormForGlobalEvent("OnHitGlobal", self, MyWeapon, 2)
 
    ;compare MyOtherWeapon with 'Source'. Register this form for when anything is hit with MyOtherWeapon.
    DbSkseEvents.RegisterFormForGlobalEvent("OnHitGlobal", self, MyOtherWeapon, 2)
EndEvent
 
Event OnHitGlobal(ObjectReference Attacker, ObjectReference Target, Form Source, Ammo akAmmo, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
    Actor attackerActor = Attacker as Actor
    if attackerActor && (Target as actor) ;an actor hit another actor with MyWeapon or MyOtherWeapon
        if Source == MyWeapon
            attackerActor.DamageAv("Health", 10.0)
        Elseif Source == MyOtherWeapon
            attackerActor.DamageAv("Health", 20.0)
        Endif
    Endif
EndEvent
Link to comment
Share on other sites

  • Recently Browsing   0 members

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