From d471714fbd65e6d5d2a49b4567860b8723e55108 Mon Sep 17 00:00:00 2001 From: "j.foucher" Date: Wed, 1 Apr 2026 18:14:36 +0200 Subject: [PATCH] Fix rival faction detection: include Faction in fallback TeamId resolution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - GetTeamAttitudeTowards fallback (interface path) was calling MakeTeamId without Faction, so enemies of different factions had identical TeamIds → always Friendly instead of Hostile - Now reads Faction from PersonalityProfile when resolving via interface Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Private/PS_AI_Behavior_AIController.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Unreal/PS_AI_Agent/Plugins/PS_AI_Behavior/Source/PS_AI_Behavior/Private/PS_AI_Behavior_AIController.cpp b/Unreal/PS_AI_Agent/Plugins/PS_AI_Behavior/Source/PS_AI_Behavior/Private/PS_AI_Behavior_AIController.cpp index 68a2f27..c6bf8eb 100644 --- a/Unreal/PS_AI_Agent/Plugins/PS_AI_Behavior/Source/PS_AI_Behavior/Private/PS_AI_Behavior_AIController.cpp +++ b/Unreal/PS_AI_Agent/Plugins/PS_AI_Behavior/Source/PS_AI_Behavior/Private/PS_AI_Behavior_AIController.cpp @@ -368,14 +368,22 @@ ETeamAttitude::Type APS_AI_Behavior_AIController::GetTeamAttitudeTowards(const A } } - // 3) Fallback: check if Pawn implements IPS_AI_Behavior_Interface → derive TeamId from NPCType + // 3) Fallback: check if Pawn implements IPS_AI_Behavior_Interface → derive TeamId from NPCType + Faction if (OtherTeam == FGenericTeamId::NoTeam && OtherPawn->Implements()) { const EPS_AI_Behavior_NPCType OtherNPCType = IPS_AI_Behavior_Interface::Execute_GetBehaviorNPCType(const_cast(OtherPawn)); if (OtherNPCType != EPS_AI_Behavior_NPCType::Any) { - OtherTeam = PS_AI_Behavior_Team::MakeTeamId(OtherNPCType); + uint8 OtherFaction = 0; + if (const auto* OtherPersonality = OtherPawn->FindComponentByClass()) + { + if (OtherPersonality->Profile) + { + OtherFaction = OtherPersonality->Profile->Faction; + } + } + OtherTeam = PS_AI_Behavior_Team::MakeTeamId(OtherNPCType, OtherFaction); } } }