Skip to content

Commit

Permalink
Merge pull request #1695 from summonFox/Fix-reveal-plugin-revealing-a…
Browse files Browse the repository at this point in the history
…ll-PCs

Reveal: Fix Reveal plugin always revealing PCs when the plugin is enabled, regardless of usage.
  • Loading branch information
Daztek authored Aug 26, 2023
2 parents 0c277c9 + da43754 commit bb55146
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ https://github.com/nwnxee/unified/compare/build8193.35.40...HEAD

### Fixed
- Experimental: PlayerHitpointsAsPercentage: added the new argument nMessageLimit to SendServerToPlayerGameObjUpdate hook
- Reveal: Fixed Reveal plugin always revealing all PCs regardless of plugin usage.

## 8193.35.40
https://github.com/nwnxee/unified/compare/build8193.35.37...build8193.35.40
Expand Down
32 changes: 20 additions & 12 deletions Plugins/Reveal/Reveal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,45 @@ Reveal::Reveal(Services::ProxyServiceList* services)
Reveal::~Reveal()
{
}
int32_t Reveal::HookStealthDetection(CNWSCreature* pObserverCreature, CNWSCreature* pHidingCreature, int32_t bClearLOS, int32_t* bSeen, int32_t* bHeard, int32_t bTargetInvisible)
BOOL Reveal::HookStealthDetection(CNWSCreature* pObserverCreature, CNWSCreature* pHidingCreature, BOOL bClearLOS, BOOL* bSeen, BOOL* bHeard, BOOL bTargetHiding)
{
if (pObserverCreature->m_bPlayerCharacter && pHidingCreature->m_bPlayerCharacter && pHidingCreature->m_nStealthMode)
{
if (pObserverCreature->GetArea() == pHidingCreature->GetArea())
{
if (*pHidingCreature->nwnxGet<int>(revealKey + "PARTY"))
auto partyReveal = pHidingCreature->nwnxGet<int>(revealKey + "PARTY");
if (partyReveal && *partyReveal)
{
if (pObserverCreature->GetFaction()->GetLeader() == pHidingCreature->GetFaction()->GetLeader())
{
if(*pHidingCreature->nwnxGet<int>(detectionKey + "PARTY"))
{
*bSeen = true;
}
auto detectionVector = pHidingCreature->nwnxGet<int>(detectionKey + "PARTY");
if (detectionVector && *detectionVector)
*bSeen = *detectionVector;
else
*bSeen = false;

*bHeard = true;
return true;
}
}
if (*pHidingCreature->nwnxGet<int>(revealKey + Utils::ObjectIDToString(pObserverCreature->m_idSelf)))

auto reveal = pHidingCreature->nwnxGet<int>(revealKey + Utils::ObjectIDToString(pObserverCreature->m_idSelf));
if (reveal && *reveal)
{
pHidingCreature->nwnxRemove(revealKey + Utils::ObjectIDToString(pObserverCreature->m_idSelf)); //remove mapping after first check
if (*pHidingCreature->nwnxGet<int>(detectionKey + Utils::ObjectIDToString(pObserverCreature->m_idSelf)))
{
*bSeen = true;
}

auto detectionVector = pHidingCreature->nwnxGet<int>(detectionKey + Utils::ObjectIDToString(pObserverCreature->m_idSelf));
if (detectionVector && *detectionVector)
*bSeen = *detectionVector;
else
*bSeen = false;

*bHeard = true;
return true;
}
}
}
return g_plugin->m_DoStealthDetection->CallOriginal<int32_t>(pObserverCreature, pHidingCreature, bClearLOS, bSeen, bHeard, bTargetInvisible);
return g_plugin->m_DoStealthDetection->CallOriginal<BOOL>(pObserverCreature, pHidingCreature, bClearLOS, bSeen, bHeard, bTargetHiding);
}


Expand Down
2 changes: 1 addition & 1 deletion Plugins/Reveal/Reveal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Reveal : public NWNXLib::Plugin
private:
NWNXLib::Hooks::Hook m_DoStealthDetection;

static int32_t HookStealthDetection(CNWSCreature* thisCreature, CNWSCreature* pHidingCreature, int32_t bClearLOS, int32_t* bSeen, int32_t* bHeard, int32_t bTargetInvisible);
static BOOL HookStealthDetection(CNWSCreature* thisCreature, CNWSCreature* pHidingCreature, BOOL bClearLOS, BOOL* bSeen, BOOL* bHeard, BOOL bTargetHiding);

ArgumentStack RevealTo(ArgumentStack&& args);
ArgumentStack SetRevealToParty(ArgumentStack&& args);
Expand Down

0 comments on commit bb55146

Please sign in to comment.