Skip to content

Commit

Permalink
Fixed issue with Feared characters not getting their radial menu
Browse files Browse the repository at this point in the history
  • Loading branch information
DMD authored and DMD committed Feb 10, 2018
1 parent fb86fb0 commit 258458d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
38 changes: 38 additions & 0 deletions TemplePlus/party.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "gamesystems/gamesystems.h"
#include "gamesystems/objects/objsystem.h"
#include "condition.h"
#include "combat.h"
#include "turn_based.h"

struct LegacyPartySystemAddresses : temple::AddressTable
{
Expand Down Expand Up @@ -54,6 +56,10 @@ class LegacyPartySystemHacks : TempleFix
return FALSE;
return orgFearfulResponse(handle);
});

replaceFunction<objHndl()>(0x1002BE60, [](){
return party.GetConsciousPartyLeader();
});
}
} partyHacks;

Expand Down Expand Up @@ -211,6 +217,38 @@ objHndl LegacyPartySystem::GetLeader()
return leader;
}

objHndl LegacyPartySystem::GetConsciousPartyLeader(){

auto selectedCount = CurrentlySelectedNum();
for (auto i=0; i <selectedCount; i++){
auto dude = GetCurrentlySelected(i);
if (!dude) continue;
if (!critterSys.IsDeadOrUnconscious(dude))
return dude;
}

// added fix in case the leader is not currently selected and is in combat
if (combatSys.isCombatActive()){
auto curActor = tbSys.turnBasedGetCurrentActor();
if (IsInParty(curActor))
return curActor;
}

auto partySize = GroupListGetLen();
for (auto i=0; i <partySize; i++){
auto dude = GroupListGetMemberN(i);
if (!dude)continue;
if (!critterSys.IsDeadOrUnconscious(dude))
return dude;
}

// still none found:
if (partySize)
return GroupListGetMemberN(0);

return objHndl::null;
}

objHndl LegacyPartySystem::PartyMemberWithHighestSkill(SkillEnum skillEnum)
{
auto highestSkillMemberGet = temple::GetRef<objHndl(__cdecl)(SkillEnum)>(0x1002BD50);
Expand Down
5 changes: 3 additions & 2 deletions TemplePlus/party.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ struct LegacyPartySystem : temple::AddressTable
void (__cdecl *SetStoryState)(int newState);

objHndl GetLeader();
objHndl(__cdecl*GetConsciousPartyLeader)();
objHndl GetConsciousPartyLeader();
objHndl(__cdecl*_GetConsciousPartyLeader)();
objHndl PartyMemberWithHighestSkill(SkillEnum skillEnum);
int MoneyAdj(int plat, int gold, int silver, int copper); // this is a direct manipulator which doesn't convert currencies
void DebitMoney(int plat, int gold, int silver, int copper);
Expand All @@ -62,7 +63,7 @@ struct LegacyPartySystem : temple::AddressTable
rebase(GroupPCsLen, 0x1002B370);
rebase(GroupListGetMemberN, 0x1002B150);
rebase(GroupListGetLen, 0x1002B2B0);
rebase(GetConsciousPartyLeader, 0x1002BE60);
rebase(_GetConsciousPartyLeader, 0x1002BE60);
rebase(ObjFindInGroupArray, 0x100DF780);
rebase(ObjIsInGroupArray, 0x100DF960);
rebase(ObjIsAIFollower, 0x1002B220);
Expand Down

0 comments on commit 258458d

Please sign in to comment.