Cristobot Posted December 19, 2020 Share Posted December 19, 2020 Newbie here! I want a spell to show some information about any NPC that it hits. 1) I've created a Magic Effect that is Fire and Forget 2) I've created a spell with that Magic Effect 3) When I fire the spell, I see that it hits the NPC due to the hit effect art Where I NEED HELP: For the Magic Effect, I've tried scripting an onHIt() Event to show a MessageBox("Hello World") when the spell hits something... but nothing ever happens! (My script compiles, btw) Here is my simple script: Scriptname crbtGetNPCData extends ObjectReference Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) debug.messagebox("Hello World") EndEvent Link to comment Share on other sites More sharing options...
IsharaMeradin Posted December 19, 2020 Share Posted December 19, 2020 Unfortunately, OnHit has to run on the object being hit and not the object causing the hit. Unsure of the best approach to what you want to achieve. Perhaps apply a magic effect to the target which contains a script that shows your information in the OnEffectStart event. Link to comment Share on other sites More sharing options...
maxarturo Posted December 19, 2020 Share Posted December 19, 2020 (edited) The "OnHit()" event fires when the object gets hit and not for the object that hits it, as you have it now. If you want the message to appear ONLY when the spell hits something, then you need to go a little further. 1) Create a unique 'Explosion' that your spell will use. 2) Create an "Enchantment", it can be an 'Empty' magic effect > archetype Script. 3) In your Enchantment's Magic Effect add a script: Event OnEffectStart(Actor akTarget, Actor akCaster) MyMSG.Show() EndEvent * I use 'Message' instead of a 'Notification' because is easier to translate your mod later on. 4) Add your Enchantment to your 'Unique Explosion'. 5) Add the explosion to your Scripted Magic Effect. 6) Add the Scripted Magic Effect to your spell. You are done !... Have a happy modding. EDIT: I didn't intend to post the same info as IsharaMeradin did, but she posted it while i was writing. She was faster.... Edited December 19, 2020 by maxarturo Link to comment Share on other sites More sharing options...
dylbill Posted December 19, 2020 Share Posted December 19, 2020 You can use OnEffectStart. Fire and forget spells with a projectile only take effect when they hit an actor. I do something similar in my mod Mark and Summon NPC Friends: https://www.nexusmods.com/skyrim/mods/96380 Link to comment Share on other sites More sharing options...
maxarturo Posted December 19, 2020 Share Posted December 19, 2020 dylbill suggestion is more suitable for this occasion. I got carried away cause i was trying to fix an issue with one of my assets that use the technic i posted, when i posted it... * Not that this won't work. Link to comment Share on other sites More sharing options...
Cristobot Posted December 21, 2020 Author Share Posted December 21, 2020 Thanks so much to everyone for the feedback! I will give it a try! I'm a veteran programmer but totally new to the Creation Kit and Papyrus, which is both cool and confusing. I eventually want to show some information about the NPC that was hit by the spell, and starting with a debug.MessageBox() seemed like the way to begin. Eventually I'll have to show some other kind of information box? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted December 21, 2020 Share Posted December 21, 2020 You can still use a message box to show information. You can do things like: Debug.MessageBox("Target: "+akTarget.GetName()+"; Health: "+akTarget.GetActorValue("Health")) akTarget is just a placeholder for whatever variable you might be using to reference the target actorFYI - GetName requires SKSE Link to comment Share on other sites More sharing options...
Cristobot Posted December 23, 2020 Author Share Posted December 23, 2020 Thanks!I was able to use: Debug.MessageBox("Health: "+ akTarget.GetActorValue("Health")) Debug.MessageBox("Magicka: "+ akTarget.GetActorValue("Magicka")) Debug.MessageBox("Stamina: " + akTarget.GetActorValue("Stamina")) How can I get NPC values like their skills?Ultimately, I want to list an NPC's Perks, if they have any. Is there some comprehensive reference for Papyrus? I seem to be searching all over the place for simple answers, although you guys have been the most help so far! :smile: Link to comment Share on other sites More sharing options...
dylbill Posted December 23, 2020 Share Posted December 23, 2020 Skills are also actor values. You can find a list here: https://www.creationkit.com/index.php?title=Actor_Values Instead of using 3 message boxes, you can use a single message box with \n to denote new lines. You can also use \ to continue your papyrus line on the next line so it's easy to see. Example: Debug.MessageBox("Health: " + akTarget.GetActorValue("Health") + \ "\n Magicka: " + akTarget.GetActorValue("Magicka") + \ "\n Stamina: " + akTarget.GetActorValue("Stamina") + \ "\n One Handed:" + akTarget.GetActorValue("OneHanded")) Link to comment Share on other sites More sharing options...
IsharaMeradin Posted December 23, 2020 Share Posted December 23, 2020 https://www.creationkit.com/index.php?title=Category:Papyrus I do not know how to use it. But SKSE has a GetPerks function on the ActorValueInfo script. Link to comment Share on other sites More sharing options...
Recommended Posts