Skip to content

Commit

Permalink
Add GetDawnHour/GetDuskHour (#1800)
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-lecomte authored Dec 20, 2024
1 parent 451aa94 commit a98c1ab
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ https://github.com/nwnxee/unified/compare/build8193.36.12...HEAD
- Race: ReactivateCreatureRaceEffects()
- Creature: {Get|Set}MulticlassLimit()
- Util: UpdateResourceDirectory()
- Util: GetDawnHour()
- Util: GetDuskHour()

### Changed
- Player: added bChatWindow parameter to FloatingTextStringOnCreature()
Expand Down
24 changes: 24 additions & 0 deletions Plugins/Util/NWScript/nwnx_util.nss
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,18 @@ int NWNX_Util_GetScriptParamIsSet(string sParamName);
/// @param nDawnHour The new dawn hour
void NWNX_Util_SetDawnHour(int nDawnHour);

/// @brief Get the module dawn hour.
/// @return The dawn hour
int NWNX_Util_GetDawnHour();

/// @brief Set the module dusk hour.
/// @param nDuskHour The new dusk hour
void NWNX_Util_SetDuskHour(int nDuskHour);

/// @brief Get the module dusk hour.
/// @return The dusk hour
int NWNX_Util_GetDuskHour();

/// @return Returns the number of microseconds since midnight on January 1, 1970.
struct NWNX_Util_HighResTimestamp NWNX_Util_GetHighResTimeStamp();

Expand Down Expand Up @@ -593,6 +601,14 @@ void NWNX_Util_SetDawnHour(int nDawnHour)
NWNX_CallFunction(NWNX_Util, sFunc);
}

int NWNX_Util_GetDawnHour()
{
string sFunc = "GetDawnHour";

NWNX_CallFunction(NWNX_Util, sFunc);
return NWNX_GetReturnValueInt();
}

void NWNX_Util_SetDuskHour(int nDuskHour)
{
string sFunc = "SetDuskHour";
Expand All @@ -601,6 +617,14 @@ void NWNX_Util_SetDuskHour(int nDuskHour)
NWNX_CallFunction(NWNX_Util, sFunc);
}

int NWNX_Util_GetDuskHour()
{
string sFunc = "GetDuskHour";

NWNX_CallFunction(NWNX_Util, sFunc);
return NWNX_GetReturnValueInt();
}

struct NWNX_Util_HighResTimestamp NWNX_Util_GetHighResTimeStamp()
{
struct NWNX_Util_HighResTimestamp t;
Expand Down
10 changes: 10 additions & 0 deletions Plugins/Util/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,11 @@ NWNX_EXPORT ArgumentStack SetDawnHour(ArgumentStack &&args)
return {};
}

NWNX_EXPORT ArgumentStack GetDawnHour(ArgumentStack &&args)
{
return Utils::GetModule()->m_nDawnHour;
}

NWNX_EXPORT ArgumentStack SetDuskHour(ArgumentStack &&args)
{
const auto duskHour = args.extract<int32_t>();
Expand All @@ -701,6 +706,11 @@ NWNX_EXPORT ArgumentStack SetDuskHour(ArgumentStack &&args)
return {};
}

NWNX_EXPORT ArgumentStack GetDuskHour(ArgumentStack &&args)
{
return Utils::GetModule()->m_nDuskHour;
}

NWNX_EXPORT ArgumentStack GetHighResTimeStamp(ArgumentStack&&)
{
auto now = std::chrono::system_clock::now();
Expand Down

0 comments on commit a98c1ab

Please sign in to comment.