Refactor Merchandise and shelves
Update scripts to support new shelf and merch loading process. See Plugin code for details.
This commit is contained in:
parent
8eeae0cf64
commit
13d4ad31c8
@ -53,28 +53,3 @@ event OnActivate(ObjectReference akActionRef)
|
||||
selectedMerchandiseRepl.SetName("Selected Merchandise")
|
||||
endif
|
||||
endEvent
|
||||
|
||||
function RefreshMerchandise()
|
||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||
ObjectReference merchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
|
||||
debug.MessageBox("RefreshMerchandise not implemented yet!")
|
||||
; if !BRMerchandiseList.Refresh(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, merchantShelf)
|
||||
; Debug.MessageBox("Failed refresh merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
; endif
|
||||
endFunction
|
||||
|
||||
event OnCreateTransactionSuccess(int id, int quantity, int amount)
|
||||
debug.Trace("BRMerchActivatorScript OnCreateTransactionSuccess id: " + id + " quantity: " + quantity + " amount: " + amount)
|
||||
ObjectReference merchRef = self.GetLinkedRef(BRLinkItemRef)
|
||||
PlayerRef.RemoveItem(Gold001, amount)
|
||||
PlayerRef.AddItem(merchRef.GetBaseObject(), quantity)
|
||||
RefreshMerchandise()
|
||||
endEvent
|
||||
|
||||
; TODO: gracefully handle expected error cases (e.g. someone else buys all of item before this player can buy them)
|
||||
Event OnCreateTransactionFail(string error)
|
||||
Debug.Trace("BRMerchActivatorScript OnCreateTransactionFail error: " + error)
|
||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||
Debug.MessageBox("Failed to buy merchandise.\n\n" + error + "\n\n" + BRScript.BugReportCopy)
|
||||
RefreshMerchandise()
|
||||
endEvent
|
@ -102,11 +102,12 @@ endFunction
|
||||
|
||||
function RefreshMerchandise()
|
||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||
ObjectReference merchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
|
||||
debug.MessageBox("RefreshMerchandise not implemented yet!")
|
||||
; if !BRMerchandiseList.Refresh(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, merchantShelf)
|
||||
; Debug.MessageBox("Failed refresh merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
; endif
|
||||
|
||||
; TODO: the assumption that player is in shop cell may be incorrect
|
||||
Cell shopCell = PlayerRef.GetParentCell()
|
||||
if !BRMerchandiseList.Load(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, shopCell, BRScript.ActiveShopShelves, self)
|
||||
Debug.MessageBox("Failed to load shop merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
endif
|
||||
endFunction
|
||||
|
||||
event OnCreateTransactionSuccess(int id, int quantity, int amount)
|
||||
@ -125,7 +126,6 @@ endEvent
|
||||
|
||||
event OnLoadMerchandiseSuccess(bool result)
|
||||
Debug.Trace("BRMerchChestScript OnLoadMerchandiseSuccess result: " + result)
|
||||
ObjectReference MerchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
|
||||
debug.MessageBox("Successfully loaded shop merchandise")
|
||||
|
||||
; TODO: the assumption that player is in shop cell may be incorrect
|
||||
@ -141,3 +141,20 @@ event OnLoadMerchandiseFail(string error)
|
||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||
Debug.MessageBox("Failed to load or clear shop merchandise.\n\n" + error + "\n\n" + BRScript.BugReportCopy)
|
||||
endEvent
|
||||
|
||||
event OnLoadShelfPageSuccess(bool result)
|
||||
Debug.Trace("BRMerchChestScript OnLoadShelfPageSuccess result: " + result)
|
||||
|
||||
; TODO: the assumption that player is in shop cell may be incorrect
|
||||
Cell shopCell = PlayerRef.GetParentCell()
|
||||
while !BRMerchandiseList.ReplaceAll3D(shopCell) ; replace all 3D or only refs linked to this chest's shelf?
|
||||
Debug.Trace("BRMerchandiseList.Replace3D returned false, waiting and trying again")
|
||||
Utility.Wait(0.05)
|
||||
endWhile
|
||||
endEvent
|
||||
|
||||
event OnLoadShelfPageFail(string error)
|
||||
Debug.Trace("BRMerchChestScript OnLoadShelfPageFail error: " + error)
|
||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||
Debug.MessageBox("Failed to load or clear page of shelf merchandise.\n\n" + error + "\n\n" + BRScript.BugReportCopy)
|
||||
endEvent
|
@ -8,11 +8,10 @@ event OnActivate(ObjectReference akActionRef)
|
||||
if akActionRef == PlayerRef
|
||||
ObjectReference MerchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
|
||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||
debug.MessageBox("BRMerchandiseList.NextPage not implemented yet!")
|
||||
; bool result = BRMerchandiseList.NextPage(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, MerchantShelf)
|
||||
; Debug.Trace("BRMerchandiseList.NextPage result: " + result)
|
||||
; if !result
|
||||
; Debug.MessageBox("Failed to load or clear shop merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
; endif
|
||||
bool result = BRMerchandiseList.NextPage(MerchantShelf)
|
||||
Debug.Trace("BRMerchandiseList.NextPage result: " + result)
|
||||
if !result
|
||||
Debug.MessageBox("Failed to load or clear shop merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
endif
|
||||
endif
|
||||
endEvent
|
@ -8,11 +8,10 @@ event OnActivate(ObjectReference akActionRef)
|
||||
if akActionRef == PlayerRef
|
||||
ObjectReference MerchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
|
||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||
debug.MessageBox("BRMerchandiseList.PrevPage not implemented yet!")
|
||||
; bool result = BRMerchandiseList.PrevPage(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, MerchantShelf)
|
||||
; Debug.Trace("BRMerchandiseList.PrevPage result: " + result)
|
||||
; if !result
|
||||
; Debug.MessageBox("Failed to load or clear shop merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
; endif
|
||||
bool result = BRMerchandiseList.PrevPage(MerchantShelf)
|
||||
Debug.Trace("BRMerchandiseList.PrevPage result: " + result)
|
||||
if !result
|
||||
Debug.MessageBox("Failed to load or clear shop merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
endif
|
||||
endif
|
||||
endEvent
|
@ -2,15 +2,15 @@ scriptname BRMerchandiseList
|
||||
|
||||
; TODO: a save function that saves the merch to the server, load should load from server
|
||||
; bool function Toggle(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf) global native
|
||||
; bool function NextPage(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf) global native
|
||||
; bool function PrevPage(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf) global native
|
||||
bool function NextPage(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 Refresh(string apiUrl, string apiKey, int shop_id, ObjectReference merchantShelf) global native
|
||||
|
||||
bool function Replace3D(ObjectReference merchantShelf) global native
|
||||
bool function ReplaceAll3D(Cell shopCell) global native
|
||||
|
||||
bool function Create(string apiUrl, string apiKey, int shopId, ObjectReference merchantChest) global native
|
||||
bool function Create(string apiUrl, string apiKey, int shopId, Cell shopCell, ObjectReference[] merchantShelves, ObjectReference merchantChest) global native
|
||||
|
||||
int function GetQuantity(ObjectReference activator) global native
|
||||
int function GetPrice(ObjectReference activator) global native
|
@ -15,7 +15,10 @@ event OnMenuClose(string menuName)
|
||||
Debug.Trace("BRPublicMerchChestScript container menu closed")
|
||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||
if BRScript.ActiveShopId == BRScript.ShopId
|
||||
bool result = BRMerchandiseList.Create(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ShopId, self)
|
||||
; 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
|
||||
@ -52,18 +55,12 @@ Event OnItemAdded(Form baseItem, int itemCount, ObjectReference itemRef, ObjectR
|
||||
endif
|
||||
endEvent
|
||||
|
||||
event OnCreateMerchandiseSuccess(bool created, int id)
|
||||
Debug.Trace("BRPublicMerchChestScript OnCreateMerchandiseSuccess created: " + created + " id: " + id)
|
||||
event OnCreateMerchandiseSuccess(bool created)
|
||||
Debug.Trace("BRPublicMerchChestScript OnCreateMerchandiseSuccess created: " + created)
|
||||
if created
|
||||
BRQuestScript BRScript = BRQuest as BRQuestScript
|
||||
BRScript.MerchandiseListId = id;
|
||||
Debug.Notification("Saved merchandise successfully")
|
||||
|
||||
ObjectReference merchantShelf = self.GetLinkedRef(BRLinkMerchShelf)
|
||||
debug.MessageBox("BRMerchandiseList.Refresh not implemented yet!")
|
||||
; if !BRMerchandiseList.Refresh(BRScript.ApiUrl, BRScript.ApiKey, BRScript.ActiveShopId, merchantShelf)
|
||||
; Debug.MessageBox("Failed refresh merchandise.\n\n" + BRScript.BugReportCopy)
|
||||
; endif
|
||||
else
|
||||
Debug.Trace("BRPublicMerchChestScript no container changes to save to the server")
|
||||
endif
|
||||
|
@ -13,7 +13,6 @@ string property ShopName auto
|
||||
string property ShopDescription auto
|
||||
; TODO: look up interior refs and merch by shop id instead of saving this?
|
||||
int property InteriorRefListId auto
|
||||
int property MerchandiseListId auto
|
||||
; Active shop data (for the currently loaded shop)
|
||||
int property ActiveOwnerId auto
|
||||
int property ActiveShopId auto
|
||||
@ -155,6 +154,9 @@ bool function LoadInteriorRefs()
|
||||
Debug.Trace("ClearCell result: " + result)
|
||||
|
||||
if BRInteriorRefList.Load(ApiUrl, ApiKey, InteriorRefListId, ShopXMarker, PrivateChest, PublicChest, self)
|
||||
ActiveShopId = ShopId
|
||||
ActiveShopName = ShopName
|
||||
ActiveShopDescription = ShopDescription
|
||||
return true
|
||||
else
|
||||
Debug.MessageBox("Failed to load shop.\n\n" + BugReportCopy)
|
||||
@ -164,9 +166,6 @@ endFunction
|
||||
|
||||
event OnLoadInteriorRefListSuccess(bool result, ObjectReference[] shelves)
|
||||
Debug.Trace("BRQuestScript OnLoadInteriorRefListSuccess result: " + result)
|
||||
ActiveShopId = ShopId
|
||||
ActiveShopName = ShopName
|
||||
ActiveShopDescription = ShopDescription
|
||||
ActiveShopShelves = shelves
|
||||
Debug.Trace("BRQuestScript OnLoadInteriorRefListSuccess ActiveShopShelves: " + ActiveShopShelves)
|
||||
Debug.MessageBox("Successfully loaded shop")
|
||||
|
Loading…
Reference in New Issue
Block a user