Jump to content

Can't get 'On Death' script to work in quest


cumbrianlad

Recommended Posts

Hi.

 

I have a quest that starts (so all aliases fill).

 

I have several actors as reference aliases. I've tried attaching two versions of the 'On Death' script to each alias. 'DefaultAliasOnDeathScript' and 'DefaultSetStageOnDeathRefAlias'. Each time, I set the stage. In the case of the latter script I also assigned my quest property.

 

There are several stages that can be set, depending on the actor that is killed. All are set up the same. In each stage that is set by the death script the papyrus fragment is along the lines of what is below, the only difference being the amount of gold removed from the container.

 

;Gerta killed
Alias_MercyChest.GetReference().RemoveItem(Gold001,1200,False)
MBRVmsgMercyGerta.Show()

 

The issue is that when Gerta, or any other alias is killed, the message doesn't display and the gold is not removed from the 'MercyChest' alias.

 

I have tried: Recompile all papyrus scripts. All successfully compile. I even tried making a new SEQ file out of desperation, even though this quest is not 'start game enabled', 2 quests in the mod are. Gerta and 3 other aliases are used in another quest but not marked as 'Reserved' so I don't have 'Allow Reserved' flagged against their use in this quest.

 

I have tried killing them in different ways but nothing works.

 

What am I missing? I wondered about writing my own script using the 'OnDying' event, in case the 'OnDeath' event was not working.

 

I'm testing using a save that has never seen my mod.

 

Any suggestions?

Link to comment
Share on other sites

Hey, I just tested the OnDeath event on an alias, and it works. I would recommend writing your own scripts for each alias, and attaching the script directly to the reference alias's in the quest. Something like:

 

 

 

 

Scriptname GertaDeathScript Extends ReferenceAlias
 
Message Property MBRVmsgMercyGerta Auto
ReferenceAlias Property Alias_MercyChest Auto
 
Event OnDeath(Actor akKiller)
    Alias_MercyChest.GetReference().RemoveItem(Gold001,1200,False)
    MBRVmsgMercyGerta.Show() 
EndEvent
 

Link to comment
Share on other sites

Or if you wanted to just write one script, and attach it to each alias, you could do:

 

 

 

 
Scriptname GoldDeathScript Extends ReferenceAlias
 
Message Property MBRVmsgMercyGerta Auto
ReferenceAlias Property Alias_MercyChest Auto
Int Property GoldAmount Auto      ;Set the Gold Amount in the Creation Kit. That way each alias can have it's own amount.
MiscObject Property Gold001 auto

Event OnDeath(Actor akKiller)
    Alias_MercyChest.GetReference().RemoveItem(Gold001,GoldAmount,False)
    MBRVmsgMercyGerta.Show() 
EndEvent
 

 

Edit: You can also fill the message property with a different message for each alias in the creation kit.

Edited by dylbill
Link to comment
Share on other sites

As far as I understand you are using a quest (with a quest fragment script) and some aliases which have the following vanilla script attached.

 

DefaultAliasOnDeathScript

 

Scriptname DefaultAliasOnDeathScript extends ReferenceAlias  
{Sets a stage on the parent quest when the alias dies}

  Int Property StageToSetOnDeath Auto
{What stage should be set when the alias dies?}

  Int property PrerequisiteStage = -1 auto
{What stage must be active to set the stage
    -1 == do not use and is the default}

EVENT OnInit()
    Debug.Trace(" OnInit() - has been reached.. " +self)    ; debbuging only
ENDEVENT

EVENT OnDeath(Actor akKiller)
    Debug.Trace(" OnDeath(" +StageToSetOnDeath+ ") - has been reached.. " +self)   ; debugging only

    if PrerequisiteStage == -1
        getOwningQuest().setStage(StageToSetOnDeath)
    elseif getOwningQuest().getStage() == PrerequisiteStage
        getOwningQuest().setStage(StageToSetOnDeath)
    else    
;         debug.Trace(self + " did not set stage " + StageToSetOnDeath + " because prerequisite stage was not set")
    endif
ENDEVENT

 

 

 

Causes not working:

- Did you make the quest running?

- Have you set the properties in the fragment script?

- Have you set the int properties right?

- Have you set the optional flag for the alias?

 

You wrote: "Each time, I set the stage."

- Have you set different stages?

 

My advise: use Debug.Trace() to control the work of your scripts!

Link to comment
Share on other sites

Thanks for the replies. The messages were showing, my mistake. They were just tiny because I'd done them in 2 lines. I've made them 1 line and they show up much better.

 

It's just the part that removes the gold that isn't working for some reason.

 

Edit: just had a brainwave. I had the gold in the base item but was trying to take it from the alias. I've removed the chest items from the base form and added them to the chest's alias inventory.

 

It now works sweet as a nut.

 

Thanks for taking the time to write that script dylbill. I'll bear it in mind, but since it's all working now, I'll just leave it as it is.

Link to comment
Share on other sites

Red Dragon, I just noticed your post because I'd started writing my response when it struck me about what the problem could be. i was testing while you were typing!

 

The message properties and misc object property were all in the main quest script, below the fragments.

 

Thanks for replying, though.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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