Jump to content

Papyrus scripting OnHit Help


Sturmgewehrrrrrrrrrrr

Recommended Posts

Help! I attach this script to my test sword, and it doesn't work

I want that when I hit someone with a sword, it gives me my bread, which I made


Scriptname takeBreadFREE extends ObjectReference


potion property Bread auto


Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, \

bool abBashAttack, bool abHitBlocked)


If akAggressor == Game.Getplayer()

Game.GetPlayer().AddItem(Bread, 1, true)

EndIf


EndEvent

Link to comment
Share on other sites

OnHit runs when an object gets hit by something. If you want it to run whenever your sword hits an opponent then the opponent needs to be running the script. Which in turn means that you will need a "cloaking ability" which in essence reaches out and locates nearby objects that meet your requirements and then attaches the script to them by placing said objects into quest aliases. Why the convoluted hard to explain round about method? Applying a script to each potential opponent directly will be tedious, time consuming and highly prone to conflict with any mod that affects the same objects in a direct manner.

 

See Dynamically Attaching Scripts for more info.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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