Jump to content

aoh125

Recommended Posts

Hello, I am wondering if there is a way to refresh a merchants selling items while the purchasing window is still open and active?

 

I am currently using this and very similar scripts (open spoiler) to sell items that increase the mod merchants stock items, gold, and a few misc other things via perks and global variables. The script does what i want it to but the only way to access the next stage of purchaseable upgrade book is to back out of the selling window and reopen it, which im sure most will find annoying/unimmersive. The merchant who sells the upgrade books chest is set to not respawn to avoid any potentional repurchasing of the same upgrade items so reset objectreference would remove the current stage book (this is the only thing i noticed on the wiki that seemed like it might do what im trying to accomplish). Think thats the most relevant information. Thanks in advance for any help/replys.

 

Scriptname BMI_TradeCertificate extends ObjectReference

ObjectReference Property BMI_OrkMCRef Auto ;MerchantChestRef
Book Property BMI_BulkTraderPerkBook Auto ;next perk book to be added
Perk Property BMI_TradecertificatePerk Auto
Actor Property PlayerRef Auto

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
If akNewContainer == PlayerREF
PlayerRef.AddPerk(BMI_TradecertificatePerk)
BMI_OrkMCRef.AddItem(BMI_BulkTraderPerkBook)
EndIf
EndEvent

 

 

**unimportant my reasoning for not just using dialogue or activators**

I like that with the merchant set up the upgrades cost more early game and so while this mod's merchants are admitedly over powered once fully upgraded , at least there is some semblance of balance with the fact it costs considerably more if you dont have haggle items or leveled speachcraft and try to upgrade them. Plus im a noob at modding so this was easier to understand and implement what i wanted to accomplish. :laugh:

Link to comment
Share on other sites

  • Replies 51
  • Created
  • Last Reply

Top Posters In This Topic

Looks like you are giving them the upgrade as soon as they buy it. With OnContainerChange as apposed to when they read the book ...
In that case possibly you could go with a effect on the player. They glow for a second with some spell or food effect with sound and they are upgraded.

While in the process of that you are also able to sneak in a close the menu call. All looks legit and the merchant part would work as you intended.

Link to comment
Share on other sites

Hey NexusComa, thanks for the reply and idea on my problem.

 

*most relevant question* There is a papyrus function that calls for a menu close then (and im assuming a reopen would be available as well)?

 

Yea initially i had them set to do it on read but thought that this was more ideal. Im not familiar with a close the menu call. i was looking into utility.wait utilitymenumode.wait and disable player control then enable this morning after posting but none of that worked out to any promising result (since the menu was open the game was still paused for all of it so kinda moot). That really is all i need is to be able to close(and ideally reopen the menu if even for just .1 second it would likly be enough). could do with a fade to maybe hide it but again i couldnt find any function to force close or open menu. Might be worth noting im not using skse scripting. Could you possibly give a little more direction on the close menu call or any advice as to where i might find information on it. Now that im thinking on it perhaps you mean the player closing the menu to be able to read the book and activate the perk themself is what sneaks the close menu call in? Sorry im by no means good at this and even with hours upon hours of research watching tutorials for various random scripting and modding and just generally thinking on stuff i dont always get things working as id like.

 

*kind of unrelated* in the process of messing with utility.wait etc i did change things around again so the items are in the void and the chest can respawn its merchant gold allowing the npc to be a misc merchant fence again.

 

ObjectReference Property BMI_BB1Ref Auto ;Bulk Book ref
Perk Property BMI_TradecertificatePerk Auto
Actor Property PlayerRef Auto

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
If akNewContainer == PlayerREF
PlayerRef.AddPerk(BMI_TradecertificatePerk)
BMI_BB1Ref.Enable()
EndIf
EndEvent

 

Edited by aoh125
Link to comment
Share on other sites

Actually I ran into that same problem with the close thing. Ended up doing a "mix complete" box. I was thinking maybe since this is merchant menu there would be a way to do it. There is an open close menu command.

Not sure if it would help unless you could lock in the the menu to close ... try looking here: https://www.creationkit.com/index.php?title=Category:Papyrus for calls. Some calls can do things you don't think of at 1st or can be
used in different ways then originally intended. I wonder what would happen if you open a menu of your own for just a moment than close it before it even showed up. That may just close the menu you're in.

There are some examples at that site too. A few are detailed menu scripts.

Edited by NexusComa
Link to comment
Share on other sites

Going to have a look now, appreciate the help and direction, This stuffs rather confusing for me but im slowly starting to get less compiling errors and making progress with scripting in a general sense lol.

 

Thats the page i've spent hours combing threw this am. I will be giving a custom menu a try so ill make sure to update if that works out.

 

*update* just used a message box that i had setup for something else to see if that would work (as i understand it its more or less a menu but just with the 1 option). Seems to have the same issue as anything else i've tried, since the trade menu is still open the game is still paused so the merchants available items aren't updated. Was certainly worth a shot and something i hadnt even considered lol.

 

Might just leave this problem alone.The books all say that the next stage of book is available from the merchant when read so there is something to redirect a player back to check the merchant.

Edited by aoh125
Link to comment
Share on other sites

Please note that I have not tested this. Theoretically, it should work.

 

Requires SKSE

 

 

Scriptname BMI_TradeCertificate extends ObjectReference

ObjectReference Property BMI_OrkMCRef Auto ;MerchantChestRef
Book Property BMI_BulkTraderPerkBook Auto ;next perk book to be added
Perk Property BMI_TradecertificatePerk Auto
Actor Property PlayerRef Auto

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
	If akNewContainer == PlayerREF

		Game.DisablePlayerControls(False, False, False, False, False, True)	; Exit menu
		Utility.Wait(0.01)

		PlayerRef.AddPerk(BMI_TradecertificatePerk)
		BMI_OrkMCRef.AddItem(BMI_BulkTraderPerkBook)

		Utility.Wait(0.01) 
		Game.EnablePlayerControls(False, False, False, False, False, True)	; Reenable menu	accessibilty

		; unless there is god awful delay in the game, the player should still have their crosshair pointing at the merchant
		; get merchant via crosshair and re-activate the barter menu
		ObjectReference Ref = Game.GetCurrentCrosshairRef()	
		If Ref && Ref as Actor ; is Ref a valid target and is it an actor
			(Ref as Actor).ShowBarterMenu()
		EndIf

	EndIf
EndEvent

 

 

What it does is once the book is obtained the barter menu is closed via disabling player controls (works with container and inventory menus so I do not see why it would not work with a barter menu), perk is added and new book added to merchant chest. Player controls are re-enabled and then an SKSE function is used to get the crosshair target. Since the player won't have much time to move the crosshair, it should still be pointing at the merchant (of course some NPCs do like to wander and push the player around while in conversation so there is a slim chance that the crosshair won't be pointing at the merchant by the time the shop option is selected). Get the merchant and re-open the barter menu. If it fails due to an invalid crosshair target, the shop can still be accessed via normal dialog.

 

If your books will be at a dedicated merchant, you can probably have a property point to their pre-placed object reference instead of grabbing them via crosshair.

 

All that said, I do like the idea of the perk being added when the book is read and then the chest updated after that.

Link to comment
Share on other sites

HI IsharaMeradin. Thanks for taking the time to make an adjusted script to try. Im going try saving it with complie errors and loading in game (since i dont have skse scripts extracted i dont think it will compile right for me in CK). I did try something very similar and it didnt seem to have any effect on the barter menu.

 

ObjectReference Property BMI_BB1Ref Auto ;Bulk Book ref
Perk Property BMI_TradecertificatePerk Auto
Actor Property PlayerRef Auto

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
If akNewContainer == PlayerREF
PlayerRef.AddPerk(BMI_TradecertificatePerk)
BMI_BB1Ref.Enable()
Game.DisablePlayerControls(False, False, False, False, False, True)
utility.wait(0.1)
Game.EnablePlayerControls(False, False, False, False, False, True)
EndIf
EndEvent

 

 

Far as i can tell the main difference between what i attempted and your script is that yours would reopen the barter menu using the cross-hairs to target the merchant. In my verison and attempt the menu never closed so im guessing that will be the case here as well but im still going to give it a try just to be certain and since you took the time to make it for me.

 

backed up my scripts folder and overwrote it with skse verison to attempt to compile things correctly. Still ended up with this afterwards.

 

Starting 1 compile threads for 1 files...
Compiling "BMI_TradeCertificate"...
D:\Games\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\BMI_TradeCertificate.psc(22,29): GetCurrentCrosshairRef is not a function or does not exist
D:\Games\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\BMI_TradeCertificate.psc(22,29): cannot call the member function GetCurrentCrosshairRef alone or on a type, must call it on a variable
No output generated for BMI_TradeCertificate, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on BMI_TradeCertificate

 

Thanks again for your attempts, begining to think maybe im going about this all wrong and i should add a wait utility or uumm registerForSingleUpdateGameTime(1.0) or (24/48) something to make it so instead of instantly adding the next available book you need to wait anyway which makes the fact the menu doesnt update kinda trivial.

maybe something like this

 

ObjectReference Property BMI_BB1Ref Auto ;Bulk Book ref
Perk Property BMI_TradecertificatePerk Auto
Actor Property PlayerRef Auto

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
If akNewContainer == PlayerREF
PlayerRef.AddPerk(BMI_TradecertificatePerk)
RegisterForSingleUpdateGameTime(1.0)
EndIf
EndEvent

Event OnUpdateGameTime()
BMI_BB1Ref.Enable()
EndEvent

 

The books themselves are nothing fancey, slight texture edits and customized text inside. When i first tried getting all the globals and perks working correctly more or less mimicing the vanilla TG merchant perks and Master Trader ones i was using onread instead of on container change. Just seemed more idk stream lined and less room for potential confusion doing it with on container change. Might move back to an onread event since it seems popular while talking about it here.

 

The onupdategametime() idea doesnt appear to work as i had hoped (was using it for a sort of profits after fully upgrading the merchants and becoming more or less a partner in there business but that was on a container so guessing the fact the script here is different enough to make it fail (even though it compiles fine). Leaning towards again leaving this whole thing be and just using what i have working in place with the exception of maybe making it on read instead of on container change. seems like a lot of headache to get such a small detail to work as more specifically desired.

Edited by aoh125
Link to comment
Share on other sites

I haven't looked at it recently. But I think the SKSE team decided to change their Creation Kit to use the same directory structure as original Skyrim. Thus their source scripts might be going to "Data > Scripts > Source" rather than "Data > Source > Scripts" as is the default directory for SSE. Worth checking into any way.

 

FYI - A lot of mod authors opted to change the CK's directory calling it a "bug" rather than adapting to the changes brought by a new release. Thus you will find some mods for SSE using the old structure and other mods using the new. It is something to remember when working with other mods. Always check where they put their source scripts and move as needed when working with their mods in the Creation Kit.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...