WitchsWorkshop Posted April 8, 2023 Share Posted April 8, 2023 Hi everyone, So I'm super new to writing Bethesda scripts and was wondering what the script would be for advancing to the next quest stage upon the player killing an NPC? For context, it's just a simple bounty quest. Player goes into dungeon, gets quest to kill Bandit chief, kills bandit chief and onto the next objective. Thanks! ^-^ -Witchy Link to comment Share on other sites More sharing options...
dylbill Posted April 8, 2023 Share Posted April 8, 2023 You can put a script directly on the bandit chief and use the OnDeath event: Scriptname BanditChiefScript extends Actor Quest Property MyQuest Auto Event OnDeath(Actor akKiller) If akKiller == Game.GetPlayer() MyQuest.SetStage(20) Else ;player didn't kill the bandit chief, do something different here Endif EndEvent Change the script name to something more unique for you mod. 1 Link to comment Share on other sites More sharing options...
ThalmorJusticiar7th Posted February 6 Share Posted February 6 On 4/9/2023 at 12:42 AM, dylbill said: You can put a script directly on the bandit chief and use the OnDeath event: Scriptname BanditChiefScript extends Actor Quest Property MyQuest Auto Event OnDeath(Actor akKiller) If akKiller == Game.GetPlayer() MyQuest.SetStage(20) Else ;player didn't kill the bandit chief, do something different here Endif EndEvent Change the script name to something more unique for you mod. hey man, i know this might be late to ask for this, but. what if i want to add this to an Alias inside my quest that spans over, lets say all of the Giants in the game ? i want the quest to advance upon killing any giant in the game, so i created a reference for "lvlgiant" and then added this script to the alias. will this work ? will the quest advance upon player killing any giant ? thanks in advance Link to comment Share on other sites More sharing options...
scorrp10 Posted February 6 Share Posted February 6 That will not work. An Alias can only be filled with a specific reference. That is, with a specific particular giant. Link to comment Share on other sites More sharing options...
dylbill Posted February 7 Share Posted February 7 For this I think what would work is OnStoryKillActor https://ck.uesp.net/wiki/OnStoryKillActor_-_Quest set up with the Kill Actor Event https://ck.uesp.net/wiki/Kill_Actor_Event in the story manager. Another method is if you're using SKSE you can use my mod Dylbill's Papyrus Functions that has DbSkseEvents.psc. Here's an example script: race Property giantRace Auto Event OnInit() ;register this script for when the player kills any npc DbSkseEvents.RegisterFormForGlobalEvent("OnDeathGlobal", self, Game.GetPlayer(), 1) EndEvent Event OnDeathGlobal(Actor Victim, Actor Killer) if Victim.GetRace() == giantRace ;do something ;unregister for the event if it's no longer needed DbSkseEvents.UnRegisterFormForGlobalEvent("OnDeathGlobal", self, Game.GetPlayer(), 1) endif EndEvent Link to comment Share on other sites More sharing options...
ThalmorJusticiar7th Posted February 7 Share Posted February 7 (edited) 3 hours ago, dylbill said: For this I think what would work is OnStoryKillActor https://ck.uesp.net/wiki/OnStoryKillActor_-_Quest set up with the Kill Actor Event https://ck.uesp.net/wiki/Kill_Actor_Event in the story manager. Another method is if you're using SKSE you can use my mod Dylbill's Papyrus Functions that has DbSkseEvents.psc. Here's an example script: race Property giantRace Auto Event OnInit() ;register this script for when the player kills any npc DbSkseEvents.RegisterFormForGlobalEvent("OnDeathGlobal", self, Game.GetPlayer(), 1) EndEvent Event OnDeathGlobal(Actor Victim, Actor Killer) if Victim.GetRace() == giantRace ;do something ;unregister for the event if it's no longer needed DbSkseEvents.UnRegisterFormForGlobalEvent("OnDeathGlobal", self, Game.GetPlayer(), 1) endif EndEvent i thought that solution 1 can only work for 1 specific actor ? i use SKSE myself but won't be using it for my mod because it's gonna have no requirements. Edited February 7 by ThalmorJusticiar7th Link to comment Share on other sites More sharing options...
ThalmorJusticiar7th Posted February 7 Share Posted February 7 8 hours ago, scorrp10 said: That will not work. An Alias can only be filled with a specific reference. That is, with a specific particular giant. well i found out that i can add them through the "create reference to object" option, and add lvlgiant and lvldragon which are the general encounter actors that include all of the giants/dragons. can't that work if we choose "none" for the container option and just add them as a reference to object without container ? Link to comment Share on other sites More sharing options...
xkkmEl Posted February 7 Share Posted February 7 A form, such as LvlGiant or LvlDragon, represents a "class" of objects. An ObjectReference is an instance of such a class, a specific one. Aliases can only hold one ObjectReference, and so that approach will only work for detecting the death of that one instance you put in the alias. "Create reference to object" creates a new ObjectReference. It will not help you detect events on pre-existing references. 1 Link to comment Share on other sites More sharing options...
ThalmorJusticiar7th Posted February 8 Share Posted February 8 On 2/7/2025 at 2:52 PM, xkkmEl said: A form, such as LvlGiant or LvlDragon, represents a "class" of objects. An ObjectReference is an instance of such a class, a specific one. Aliases can only hold one ObjectReference, and so that approach will only work for detecting the death of that one instance you put in the alias. "Create reference to object" creates a new ObjectReference. It will not help you detect events on pre-existing references. gotcha. i've been focusing on trying out the otherway that @scorrp10 mentioned. and i think i'm pretty close to getting it to work in game. if i have further problems, i would come back and ask for your help to iron it all out. thank you for the assist. Link to comment Share on other sites More sharing options...
Recommended Posts