-
Notifications
You must be signed in to change notification settings - Fork 96
Create a new store plugin #1743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| add_plugin(Store | ||
| "Store.cpp") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| /// @addtogroup store | ||
| /// @brief Functions exposing additional store properties. | ||
| /// @{ | ||
| /// @file nwnx_store.nss | ||
| #include "nwnx" | ||
|
|
||
| const string NWNX_Store = "NWNX_Store"; ///< @private | ||
|
|
||
| /// @brief Return status of a base item purchase status. | ||
| /// @param oStore The store object. | ||
| /// @param nBaseItem A BASE_ITEM_* value | ||
| /// @return TRUE if the quest has been completed. -1 if the player does not have the journal entry. | ||
| int NWNX_Store_GetIsRestrictedBuyItem(object oStore, int nBaseItem); | ||
|
|
||
| /// @brief Return the blackmarket mark down of a store | ||
| /// @param oStore The store object. | ||
| /// @return mark down of a store, -1 on error | ||
| int NWNX_Store_GetBlackMarketMarkDown(object oStore); | ||
|
|
||
| /// @brief Set the blackmarket mark down of a store | ||
| /// @param oStore The store object. | ||
| /// @param nValue The amount. | ||
| void NWNX_Store_SetBlackMarketMarkDown(object oStore, int nValue); | ||
|
|
||
| /// @brief Return the mark down of a store | ||
| /// @param oStore The store object. | ||
| /// @return mark down of a store, -1 on error | ||
| int NWNX_Store_GetMarkDown(object oStore); | ||
|
|
||
| /// @brief Set the mark down of a store | ||
| /// @param oStore The store object. | ||
| /// @param nValue The amount. | ||
| void NWNX_Store_SetMarkDown(object oStore, int nValue); | ||
|
|
||
| /// @brief Return the mark up of a store | ||
| /// @param oStore The store object. | ||
| /// @return mark up of a store, -1 on error | ||
| int NWNX_Store_GetMarkUp(object oStore); | ||
|
|
||
| /// @brief Set the mark up of a store | ||
| /// @param oStore The store object. | ||
| /// @param nValue The amount. | ||
| void NWNX_Store_SetMarkUp(object oStore, int nValue); | ||
|
|
||
| /// @brief Return current customer count | ||
| /// @param oStore The store object. | ||
| /// @return count, or -1 on error | ||
| int NWNX_Store_GetCurrentCustomersCount(object oStore); | ||
|
|
||
| /// @} | ||
|
|
||
| int NWNX_Store_GetIsRestrictedBuyItem(object oStore, int nBaseItem) | ||
| { | ||
| string sFunc = "GetIsRestrictedBuyItem"; | ||
|
|
||
| NWNX_PushArgumentInt(nBaseItem); | ||
| NWNX_PushArgumentObject(oStore); | ||
|
|
||
| NWNX_CallFunction(NWNX_Store, sFunc); | ||
| return NWNX_GetReturnValueInt(); | ||
| } | ||
|
|
||
| int NWNX_Store_GetBlackMarketMarkDown(object oStore) | ||
| { | ||
| string sFunc = "GetBlackMarketMarkDown"; | ||
|
|
||
| NWNX_PushArgumentObject(oStore); | ||
|
|
||
| NWNX_CallFunction(NWNX_Store, sFunc); | ||
| return NWNX_GetReturnValueInt(); | ||
| } | ||
|
|
||
| void NWNX_Store_SetBlackMarketMarkDown(object oStore, int nValue) | ||
| { | ||
| string sFunc = "SetBlackMarketMarkDown"; | ||
|
|
||
| NWNX_PushArgumentInt(nValue); | ||
| NWNX_PushArgumentObject(oStore); | ||
|
|
||
| NWNX_CallFunction(NWNX_Store, sFunc); | ||
| } | ||
|
|
||
| int NWNX_Store_GetMarkDown(object oStore) | ||
| { | ||
| string sFunc = "GetMarkDown"; | ||
|
|
||
| NWNX_PushArgumentObject(oStore); | ||
|
|
||
| NWNX_CallFunction(NWNX_Store, sFunc); | ||
| return NWNX_GetReturnValueInt(); | ||
| } | ||
|
|
||
| void NWNX_Store_SetMarkDown(object oStore, int nValue) | ||
| { | ||
| string sFunc = "SetMarkDown"; | ||
|
|
||
| NWNX_PushArgumentInt(nValue); | ||
| NWNX_PushArgumentObject(oStore); | ||
|
|
||
| NWNX_CallFunction(NWNX_Store, sFunc); | ||
| } | ||
|
|
||
| int NWNX_Store_GetMarkUp(object oStore) | ||
| { | ||
| string sFunc = "GetMarkUp"; | ||
|
|
||
| NWNX_PushArgumentObject(oStore); | ||
|
|
||
| NWNX_CallFunction(NWNX_Store, sFunc); | ||
| return NWNX_GetReturnValueInt(); | ||
| } | ||
|
|
||
| void NWNX_Store_SetMarkUp(object oStore, int nValue) | ||
| { | ||
| string sFunc = "SetMarkUp"; | ||
|
|
||
| NWNX_PushArgumentInt(nValue); | ||
| NWNX_PushArgumentObject(oStore); | ||
|
|
||
| NWNX_CallFunction(NWNX_Store, sFunc); | ||
| } | ||
|
|
||
| int NWNX_Store_GetCurrentCustomerCount(object oStore) | ||
| { | ||
| string sFunc = "GetCurrentCustomerCount"; | ||
|
|
||
| NWNX_PushArgumentObject(oStore); | ||
|
|
||
| NWNX_CallFunction(NWNX_Store, sFunc); | ||
| return NWNX_GetReturnValueInt(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| #include "nwnx.hpp" | ||
|
|
||
| #include "API/CNWSStore.hpp" | ||
|
|
||
| using namespace NWNXLib; | ||
| using namespace NWNXLib::API; | ||
|
|
||
| NWNX_EXPORT ArgumentStack GetIsRestrictedBuyItem(ArgumentStack&& args) | ||
| { | ||
| if (auto *pStore = Utils::PopStore(args)) | ||
| { | ||
| const auto nBaseItemID = args.extract<int32_t>(); | ||
| return pStore->GetIsRestrictedBuyItem(nBaseItemID); | ||
| } | ||
| return -1; | ||
| } | ||
|
|
||
| NWNX_EXPORT ArgumentStack GetBlackMarketMarkDown(ArgumentStack&& args) | ||
| { | ||
| if (auto *pStore = Utils::PopStore(args)) | ||
| { | ||
| return pStore->m_nBlackMarketMarkDown; | ||
| } | ||
| return -1; | ||
| } | ||
|
|
||
| NWNX_EXPORT ArgumentStack SetBlackMarketMarkDown(ArgumentStack&& args) | ||
| { | ||
| if (auto *pStore = Utils::PopStore(args)) | ||
| { | ||
| const auto nValue = args.extract<int32_t>(); | ||
| ASSERT_OR_THROW(nValue >= 0); | ||
| ASSERT_OR_THROW(nValue <= 100); | ||
| pStore->m_nBlackMarketMarkDown = nValue; | ||
| } | ||
| return {}; | ||
| } | ||
|
|
||
| NWNX_EXPORT ArgumentStack GetMarkDown(ArgumentStack&& args) | ||
| { | ||
|
|
||
| if (auto *pStore = Utils::PopStore(args)) | ||
| { | ||
| return pStore->m_nMarkDown; | ||
| } | ||
| return -1; | ||
| } | ||
|
|
||
| NWNX_EXPORT ArgumentStack SetMarkDown(ArgumentStack&& args) | ||
| { | ||
| if (auto *pStore = Utils::PopStore(args)) | ||
| { | ||
| const auto nValue = args.extract<int32_t>(); | ||
| ASSERT_OR_THROW(nValue >= 0); | ||
| ASSERT_OR_THROW(nValue <= 100); | ||
| pStore->m_nMarkDown = nValue; | ||
| } | ||
| return {}; | ||
| } | ||
|
|
||
| NWNX_EXPORT ArgumentStack GetMarkUp(ArgumentStack&& args) | ||
| { | ||
|
|
||
| if (auto *pStore = Utils::PopStore(args)) | ||
| { | ||
| return pStore->m_nMarkUp; | ||
| } | ||
| return -1; | ||
| } | ||
|
|
||
| NWNX_EXPORT ArgumentStack SetMarkUp(ArgumentStack&& args) | ||
| { | ||
| if (auto *pStore = Utils::PopStore(args)) | ||
| { | ||
| const auto nValue = args.extract<int32_t>(); | ||
| ASSERT_OR_THROW(nValue >= 1); | ||
| ASSERT_OR_THROW(nValue <= 1000); | ||
|
Comment on lines
+76
to
+77
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are the asserts
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The values are the min and max that the toolset editor allows us to use in the UI. They're percentage points: 110 is 10% increase in price. |
||
| pStore->m_nMarkUp = nValue; | ||
| } | ||
| return {}; | ||
| } | ||
|
|
||
| NWNX_EXPORT ArgumentStack GetCustomerCount(ArgumentStack&& args) | ||
| { | ||
| if (auto *pStore = Utils::PopStore(args)) | ||
| { | ||
| return pStore->m_aCurrentCustomers.num; | ||
| } | ||
| return -1; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.