Jump to content

Papyrus Script: Change The Quest Stage by Drinking a Potion Help!


Recommended Posts

Is there anyone who knows how to do this? I am attempting to create a drinking contest where the quest stage will change once the player takes the Mead/potion from the table or drinks the potion. I've tried attaching the script to the mead in the cell window however, I am unsure of how to do this and have already tried various scripts, but none of them seem to advance the quest stage. I must admit that my understanding of scripting is limited, especially beyond the basics, but I can still manage to make a working quest. Nevertheless, here is what I am currently trying.

 

Additionally, if anyone is aware of a script that enables the player to use a potion, it would be greatly appreciated. The reason for  this  is due to my lack of knowledge in creating a script that can advance the stage after the player consumes a potion.

 

HELP IS GREATLY APPRECIATED!

 

Spoiler

Scriptname NAPlayerFoodMeadMugFull01Script extends ObjectReference  

 

Quest Property NA_MQ_WOLF_THEPARTY  Auto  

 

ObjectReference Property NAPlayerFoodMeadMugFull01  Auto  

 

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

 

 if Game.GetPlayer().AddItem(NAPlayerFoodMeadMugFull01,1)

 

  elseif akSourceContainer == Game.GetPlayer()

 

              NA_MQ_WOLF_THEPARTY.SetStage(130)

 

  endIf

 

endEvent

 

Edited by Jenova23
Link to comment
  • Jenova23 changed the title to Papyrus Script: Change The Quest Stage by Drinking a Potion Help!

OnItemAdded is an event that will fire on the container object into which the potion is placed (like the player), not on the potion object.

 

If you are trying to track when a specific potion reference moves into the player's inventory, you can use the OnItemAdded event on the player (and use a persistent potion reference), or use the OnContainerChanged event on the potion.

 

To track when the potion is consumed, you probably need to place a specific magic effect on the potion (and therefore use a specific potion base form) and catch the OnMagicEffectApply event on the player.

 

To catch events on the player, the easiest is to put the player in an alias and tack on a ReferenceAlias script.

 

Your script also looks somewhat confused in its use of the if...elseif...endif construct.  The if condition will always be true; the elseif part will never fire.

 

Add "Debug.messageBox( message)" traces abundantly to verify what code is being run while trying to figure it all out.

Link to comment
  • 2 weeks later...
On 4/11/2024 at 3:01 AM, pfB6cs said:

OnItemAdded is an event that will fire on the container object into which the potion is placed (like the player), not on the potion object.

 

If you are trying to track when a specific potion reference moves into the player's inventory, you can use the OnItemAdded event on the player (and use a persistent potion reference), or use the OnContainerChanged event on the potion.

 

To track when the potion is consumed, you probably need to place a specific magic effect on the potion (and therefore use a specific potion base form) and catch the OnMagicEffectApply event on the player.

 

To catch events on the player, the easiest is to put the player in an alias and tack on a ReferenceAlias script.

 

Your script also looks somewhat confused in its use of the if...elseif...endif construct.  The if condition will always be true; the elseif part will never fire.

 

Add "Debug.messageBox( message)" traces abundantly to verify what code is being run while trying to figure it all out.

Thanks that worked!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use