Jump to content

Killing off a character off-screen after a quest.


Roarian

Recommended Posts

Hey, I've been tinkering with this for a bit : I have a character whose quest ends in success or failure; if failed, said character should die after the character leaves the general area, so that his corpse will be there the next time you're near. How do I go about doing this? (Killing him off on the spot is easy enough...)

 

I've already made it so that failure sets his dialogue quest to stage 10 which is used for a dialogue option, this could be a prerequisite for the suicide thing.

 

Thanks,

 

A total amateur

Link to comment
Share on other sites

DISCLAIMER: The only testing I did was making sure the script compiled. I think this will work, but no guarantees. If it doesn't, let me know and I'll give it a more thorough look-through.

 

 

Step 1: Open up the 'scripts' tab of your dialogue quest. Click the 'add' button, and [New Script]. Name it whatever you'd like (for the purposes of this guide, we'll call it MyQuestScript). The 'Extends' textbox should say Quest, and you can leave the Documentation String empty for now. It just contains a description of the script. Note that you only need to do this if the Quest doesn't already have a script. Paste the following into it.

 

Scriptname MyQuestScript extends Quest  
{Used to ensure the questgiver dies when his quest fails and the player isn't in the area}

Actor Property Victim  Auto
{Declaring a variable, in this case the questgiver to kill.  'Actor' is the type of variable, 'Property' lets it refer to something not in the script and 'Auto' saves us the complexity of setting the Property up.}
;If you give this Property the same name as the questgiver's Reference ID instead of Victim, it will make a future step easier.

Event OnUpdate() ;This will make sense later.

    if (GetStage() == 10) ;The stage in which we're supposed to kill our questgiver.

         if (Victim.GetParentCell() != Game.GetPlayer().GetParentCell() ) ;If they're in different cells...

              Victim.kill()
              UnregisterForUpdate() ;Again, this will make sense later.
         endif

    else ;If, for some reason, we exited the victim-killing stage and no longer want to off him...
          UnregisterForUpdate()
    endif
EndEvent

 

If I knew more about Quest scripting, I could probably get it to work with the alias rather than a new property, but alas (no pun intended) I don't. Save the script up and close it.

 

Step 2: Still in the scripts tab, click your script once and press the 'Properties' button. This should bring up a list of the script's Properties, in this case only the one. If you named it the same as your questgiver's Reference ID, you can just click the 'Auto-Fill All' button. If not, click the Property, press the Edit Value button and select your questgiver's Reference ID from the drop-down list. If you haven't given them a Reference ID yet, you'll probably want to do that. Now the script knows who we're talking about when we use that Property.

 

Step 3: Open up Stage 10 of your Quest, and paste the following into the Papyrus Fragment textbox.

kMyQuest.RegisterForUpdate(30)

Also, set the kMyQuest drop-down box above your Papyrus Fragment to MyQuestScript. RegisterForUpdate sends an 'Update' Event to the Form in question every () seconds (and the UnregisterForUpdate functions from earlier stop doing so). That is, when you set the Stage to 10, our OnUpdate block will run once every 30 seconds to check if the player has left yet. Feel free to decrease that number for testing purposes, or if you want to kill the questgiver really fast, but there's no need to gobble up unnecessary processing power. Click the 'Compile' button and you should be set.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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