-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89028d9
commit 4d13fd8
Showing
6 changed files
with
235 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_plugin(Store | ||
"Store.cpp") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#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); | ||
pStore->m_nMarkUp = nValue; | ||
} | ||
return {}; | ||
} | ||
|
||
NWNX_EXPORT ArgumentStack GetCustomerCount(ArgumentStack&& args) | ||
{ | ||
|
||
if (auto *pStore = Utils::PopStore(args)) | ||
{ | ||
return pStore->m_aCurrentCustomers.num; | ||
} | ||
return -1; | ||
} | ||
|