Merch chest activator, fixup buy and sell
Moved public chest to dummy cell and created activator with chest model to interact with in the shop cell instead. Fixed issues with buying and selling to shops.
This commit is contained in:
parent
f1cdd9baf5
commit
b33fa4ec77
BIN
Bazaar Realm.esp
BIN
Bazaar Realm.esp
Binary file not shown.
22
Source/Scripts/BRMerchChestActivatorScript.psc
Normal file
22
Source/Scripts/BRMerchChestActivatorScript.psc
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
scriptname BRMerchChestActivatorScript extends ObjectReference
|
||||||
|
|
||||||
|
Keyword property BRLinkMerchChest auto
|
||||||
|
Keyword property BRLinkPublicMerchChest auto
|
||||||
|
Actor property PlayerRef auto
|
||||||
|
Quest property BRQuest auto
|
||||||
|
|
||||||
|
event OnActivate(ObjectReference akActionRef)
|
||||||
|
if akActionRef == PlayerRef
|
||||||
|
Debug.Trace("BRMerchChestActivatorScript activator was activated")
|
||||||
|
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||||
|
if BRScript.ActiveShopId == BRScript.ShopId
|
||||||
|
ObjectReference privateChest = GetLinkedRef(BRLinkMerchChest)
|
||||||
|
privateChest.RegisterForMenu("ContainerMenu")
|
||||||
|
privateChest.Activate(akActionRef)
|
||||||
|
else
|
||||||
|
ObjectReference publicChest = GetLinkedRef(BRLinkPublicMerchChest)
|
||||||
|
publicChest.RegisterForMenu("ContainerMenu")
|
||||||
|
publicChest.Activate(akActionRef)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endEvent
|
@ -1,13 +1,6 @@
|
|||||||
scriptname BRMerchChestScript extends ObjectReference
|
scriptname BRMerchChestScript extends ObjectReference
|
||||||
|
|
||||||
Keyword property BRLinkMerchShelf auto
|
|
||||||
Keyword property BRLinkMerchChest auto
|
|
||||||
Keyword property BRLinkItemRef auto
|
Keyword property BRLinkItemRef auto
|
||||||
Keyword property BRLinkActivatorRef auto
|
|
||||||
Keyword property BRLinkMerchToggle auto
|
|
||||||
Keyword property BRLinkMerchNext auto
|
|
||||||
Keyword property BRLinkMerchPrev auto
|
|
||||||
Activator property ActivatorStatic auto
|
|
||||||
Actor property PlayerRef auto
|
Actor property PlayerRef auto
|
||||||
Quest property BRQuest auto
|
Quest property BRQuest auto
|
||||||
MiscObject property Gold001 auto
|
MiscObject property Gold001 auto
|
||||||
@ -32,6 +25,19 @@ event OnMenuClose(string menuName)
|
|||||||
debug.Trace("BRMerchChestScript barter menu closed, stop listending to add/remove events")
|
debug.Trace("BRMerchChestScript barter menu closed, stop listending to add/remove events")
|
||||||
AddInventoryEventFilter(BREmptyFormList)
|
AddInventoryEventFilter(BREmptyFormList)
|
||||||
UnregisterForMenu("BarterMenu")
|
UnregisterForMenu("BarterMenu")
|
||||||
|
elseif menuName == "ContainerMenu"
|
||||||
|
debug.Trace("BRMerchChestScript container menu closed")
|
||||||
|
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||||
|
if BRScript.ActiveShopId == BRScript.ShopId
|
||||||
|
; TODO: the assumption that player is in shop cell may be incorrect
|
||||||
|
Cell shopCell = PlayerRef.GetParentCell()
|
||||||
|
|
||||||
|
bool result = BRMerchandiseList.Create(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ShopId, shopCell, BRScript.ActiveShopShelves, self)
|
||||||
|
if !result
|
||||||
|
Debug.MessageBox("Failed to save shop merchandise.\n\n" + BRScript.BugReportCopy)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
UnregisterForMenu("ContainerMenu")
|
||||||
endif
|
endif
|
||||||
endEvent
|
endEvent
|
||||||
|
|
||||||
@ -39,6 +45,8 @@ event OnMenuOpen(string menuName)
|
|||||||
if menuName == "BarterMenu"
|
if menuName == "BarterMenu"
|
||||||
debug.Trace("BRMerchChestScript barter menu opened, start listening to add/remove events")
|
debug.Trace("BRMerchChestScript barter menu opened, start listening to add/remove events")
|
||||||
RemoveAllInventoryEventFilters()
|
RemoveAllInventoryEventFilters()
|
||||||
|
elseif menuName == "ContainerMenu"
|
||||||
|
debug.Trace("BRMerchChestScript container menu opened")
|
||||||
endif
|
endif
|
||||||
endEvent
|
endEvent
|
||||||
|
|
||||||
|
@ -4,13 +4,13 @@ scriptname BRMerchandiseList
|
|||||||
; bool function Toggle(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf) global native
|
; bool function Toggle(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf) global native
|
||||||
bool function NextPage(ObjectReference merchantShelf) global native
|
bool function NextPage(ObjectReference merchantShelf) global native
|
||||||
bool function PrevPage(ObjectReference merchantShelf) global native
|
bool function PrevPage(ObjectReference merchantShelf) global native
|
||||||
bool function Load(string apiUrl, string apiKey, int shop_id, Cell shopCell, ObjectReference[] merchantShelves, ObjectReference merchantChest) global native
|
bool function Load(string apiUrl, string apiKey, int shop_id, Cell shopCell, ObjectReference[] merchantShelves, ObjectReference privateMerchantChest) global native
|
||||||
; bool function Refresh(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf) global native
|
; bool function Refresh(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf) global native
|
||||||
|
|
||||||
bool function Replace3D(ObjectReference merchantShelf) global native
|
bool function Replace3D(ObjectReference merchantShelf) global native
|
||||||
bool function ReplaceAll3D(Cell shopCell) global native
|
bool function ReplaceAll3D(Cell shopCell) global native
|
||||||
|
|
||||||
bool function Create(string apiUrl, string apiKey, int shopId, Cell shopCell, ObjectReference[] merchantShelves, ObjectReference merchantChest) global native
|
bool function Create(string apiUrl, string apiKey, int shopId, Cell shopCell, ObjectReference[] merchantShelves, ObjectReference privateMerchandiseChest) global native
|
||||||
|
|
||||||
int function GetQuantity(ObjectReference activator) global native
|
int function GetQuantity(ObjectReference activator) global native
|
||||||
int function GetPrice(ObjectReference activator) global native
|
int function GetPrice(ObjectReference activator) global native
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
scriptname BRPublicMerchChestScript extends ObjectReference
|
scriptname BRPublicMerchChestScript extends ObjectReference
|
||||||
|
|
||||||
Keyword property BRLinkMerchShelf auto
|
|
||||||
Keyword property BRLinkMerchChest auto
|
Keyword property BRLinkMerchChest auto
|
||||||
Actor property PlayerRef auto
|
Actor property PlayerRef auto
|
||||||
Quest property BRQuest auto
|
Quest property BRQuest auto
|
||||||
@ -16,16 +15,6 @@ endEvent
|
|||||||
event OnMenuClose(string menuName)
|
event OnMenuClose(string menuName)
|
||||||
if menuName == "ContainerMenu"
|
if menuName == "ContainerMenu"
|
||||||
Debug.Trace("BRPublicMerchChestScript container menu closed")
|
Debug.Trace("BRPublicMerchChestScript container menu closed")
|
||||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
|
||||||
if BRScript.ActiveShopId == BRScript.ShopId
|
|
||||||
; TODO: the assumption that player is in shop cell may be incorrect
|
|
||||||
Cell shopCell = PlayerRef.GetParentCell()
|
|
||||||
|
|
||||||
bool result = BRMerchandiseList.Create(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ShopId, shopCell, BRScript.ActiveShopShelves, self)
|
|
||||||
if !result
|
|
||||||
Debug.MessageBox("Failed to save shop merchandise.\n\n" + BRScript.BugReportCopy)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
UnregisterForMenu("ContainerMenu")
|
UnregisterForMenu("ContainerMenu")
|
||||||
AddInventoryEventFilter(BREmptyFormList)
|
AddInventoryEventFilter(BREmptyFormList)
|
||||||
endif
|
endif
|
||||||
@ -44,8 +33,7 @@ endEvent
|
|||||||
|
|
||||||
event OnActivate(ObjectReference akActionRef)
|
event OnActivate(ObjectReference akActionRef)
|
||||||
if akActionRef == PlayerRef
|
if akActionRef == PlayerRef
|
||||||
Debug.Trace("BRPublicMerchChestScript container was opened")
|
Debug.Trace("BRPublicMerchChestScript container was activated")
|
||||||
RegisterForMenu("ContainerMenu")
|
|
||||||
endif
|
endif
|
||||||
endEvent
|
endEvent
|
||||||
|
|
||||||
@ -54,8 +42,7 @@ Event OnItemAdded(Form baseItem, int itemCount, ObjectReference itemRef, ObjectR
|
|||||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||||
Form selectedMerchandiseRepl = BRScript.SelectedMerchandise.GetBaseObject()
|
Form selectedMerchandiseRepl = BRScript.SelectedMerchandise.GetBaseObject()
|
||||||
selectedMerchandiseRepl.SetName(baseItem.GetName())
|
selectedMerchandiseRepl.SetName(baseItem.GetName())
|
||||||
ObjectReference shelf = self.GetLinkedRef(BRLinkMerchShelf)
|
ObjectReference privateChest = GetLinkedRef(BRLinkMerchChest)
|
||||||
ObjectReference privateChest = shelf.GetLinkedRef(BRLinkMerchChest)
|
|
||||||
int price = BRMerchandiseList.GetSellPrice(baseItem)
|
int price = BRMerchandiseList.GetSellPrice(baseItem)
|
||||||
if BRSellMerchandise.Show(itemCount, price * itemCount, price) == 0
|
if BRSellMerchandise.Show(itemCount, price * itemCount, price) == 0
|
||||||
debug.Trace("BRPublicMerchChestScript creating sell transaction")
|
debug.Trace("BRPublicMerchChestScript creating sell transaction")
|
||||||
|
Loading…
Reference in New Issue
Block a user