Skip to content
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

Player: add bChatWindow parameter to FloatingTextStringOnCreature() #1753

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ https://github.com/nwnxee/unified/compare/build8193.36.12...HEAD
- Player: ReloadColorPalettes()

### Changed
- N/A
- Player: added bChatWindow parameter to FloatingTextStringOnCreature()

### Deprecated
- N/A
Expand Down
8 changes: 5 additions & 3 deletions Plugins/Player/NWScript/nwnx_player.nss
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ void NWNX_Player_SetCreatureNameOverride(object oPlayer, object oCreature, strin
/// @param oPlayer The player to display the text to.
/// @param oCreature The creature to display the text above.
/// @param sText The text to display.
void NWNX_Player_FloatingTextStringOnCreature(object oPlayer, object oCreature, string sText);
/// @param bChatWindow If TRUE, sText will be displayed in oPlayer's chat window.
void NWNX_Player_FloatingTextStringOnCreature(object oPlayer, object oCreature, string sText, int bChatWindow = TRUE);

/// @brief Toggle oPlayer's PlayerDM status.
/// @note This function does nothing for actual DMClient DMs or players with a client version < 8193.14
Expand Down Expand Up @@ -918,10 +919,11 @@ void NWNX_Player_SetCreatureNameOverride(object oPlayer, object oCreature, strin
NWNX_CallFunction(NWNX_Player, sFunc);
}

void NWNX_Player_FloatingTextStringOnCreature(object oPlayer, object oCreature, string sText)
void NWNX_Player_FloatingTextStringOnCreature(object oPlayer, object oCreature, string sText, int bChatWindow = TRUE)
{
string sFunc = "FloatingTextStringOnCreature";

NWNX_PushArgumentInt(bChatWindow);
NWNX_PushArgumentString(sText);
NWNX_PushArgumentObject(oCreature);
NWNX_PushArgumentObject(oPlayer);
Expand Down Expand Up @@ -1147,7 +1149,7 @@ object NWNX_Player_GetTURD(object oPlayer)

NWNX_PushArgumentObject(oPlayer);
NWNX_CallFunction(NWNX_Player, sFunc);

return NWNX_GetReturnValueObject();
}

Expand Down
13 changes: 12 additions & 1 deletion Plugins/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,14 +1264,25 @@ NWNX_EXPORT ArgumentStack FloatingTextStringOnCreature(ArgumentStack&& args)
auto text = args.extract<std::string>();
ASSERT_OR_THROW(!text.empty());

int32_t bChatWindow = true;
try
{
bChatWindow = !!args.extract<int32_t>();
}
catch(const std::runtime_error&)
{
LOG_WARNING("NWNX_Player_FloatingTextStringOnCreature() called from NWScript without 'bChatWindow' parameter. Please update nwnx_player.nss");
}

if (auto *pCreature = Utils::AsNWSCreature(Utils::GetGameObject(oidCreature)))
{
if (auto *pMessage = static_cast<CNWSMessage*>(Globals::AppManager()->m_pServerExoApp->GetNWSMessage()))
if (auto *pMessage = Globals::AppManager()->m_pServerExoApp->GetNWSMessage())
{
CNWCCMessageData messageData;
messageData.SetObjectID(0, pCreature->m_idSelf);
messageData.SetInteger(9, 94);
messageData.SetString(0, text);
messageData.SetInteger(0, bChatWindow);

pMessage->SendServerToPlayerCCMessage(pPlayer->m_nPlayerID, Constants::MessageClientSideMsgMinor::Feedback, &messageData, nullptr);
}
Expand Down
Loading