Skip to content

Commit

Permalink
Merge pull request #1690 from Cjreek/get_turd
Browse files Browse the repository at this point in the history
Added NWNX_Player_GetTurd()
  • Loading branch information
mtijanic authored Aug 8, 2023
2 parents 65dfd92 + 6cc5c45 commit a2de6b6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ https://github.com/nwnxee/unified/compare/build8193.35.40...HEAD
- Creature: {Get|Set}AbilityIncreaseByLevel()
- Util: GetModuleFile()
- Creature: NWNX_Creature_GetMaxAttackRange()
- Player: GetTURD()

### Changed
- Creature: Added an argument for passing a class package to `NWNX_Creature_LevelUp()`
Expand Down
15 changes: 15 additions & 0 deletions Plugins/Player/NWScript/nwnx_player.nss
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,11 @@ void NWNX_Player_SetObjectUiDiscoveryMaskOverride(object oPlayer, object oObject
/// @param bHideDialog TRUE: Does not show the party invitation dialog
void NWNX_Player_SendPartyInvite(object oPlayer, object oInviter, int bForceInvite = FALSE, int bHideDialog = FALSE);

/// @brief Get the TURD for oPlayer
/// @param oPlayer The offline player to get the TURD from
/// @return the TURD object of oPlayer, or OBJECT_INVALID if no TURD exists
object NWNX_Player_GetTURD(object oPlayer);

/// @}

void NWNX_Player_ForcePlaceableExamineWindow(object player, object placeable)
Expand Down Expand Up @@ -1119,3 +1124,13 @@ void NWNX_Player_SendPartyInvite(object oPlayer, object oInviter, int bForceInvi

NWNX_CallFunction(NWNX_Player, sFunc);
}

object NWNX_Player_GetTURD(object oPlayer)
{
string sFunc = "GetTURD";

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

return NWNX_GetReturnValueObject();
}
17 changes: 17 additions & 0 deletions Plugins/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1952,3 +1952,20 @@ NWNX_EXPORT ArgumentStack SendPartyInvite(ArgumentStack&& args)

return {};
}

NWNX_EXPORT ArgumentStack GetTURD(ArgumentStack&& args)
{
const auto oidPlayer = args.extract<OBJECT_ID>();

if (CExoLinkedListInternal* pTURDS = Utils::GetModule()->m_lstTURDList.m_pcExoLinkedListInternal)
{
for (CExoLinkedListPosition pNode = pTURDS->pHead; pNode; pNode = pNode->pNext)
{
auto* pTURD = static_cast<CNWSPlayerTURD*>(pNode->pObject);
if ((pTURD) && (pTURD->m_oidPlayer == oidPlayer))
return pTURD->m_idSelf;
}
}

return Constants::OBJECT_INVALID;
}

0 comments on commit a2de6b6

Please sign in to comment.