Discuss: non-vanilla NPC AI rules removed from the NPC AI port (split/16)
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
Rechercherichtung
Read the issue’s descriptions of the six removed rules and inspect commit 3e652e84 on branch split/16-npc-ai alongside the removal commit. The discussion needs a decision about which rules, if any, should return and whether they should be optional or address a specific VR behavior; done means that scope is agreed.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Why they were removed
During the review of PR #479 (branch split/16-npc-ai, the NPC AI port) the maintainer decided that the port should match vanilla Gothic (G1/G2) exactly. Six AI rules were our own additions, not what the Daedalus scripts or the original engine do - more like a mod than a remake. Each sat behind its own DeveloperConfig flag (all on in Production). The flags and the code behind them were removed, so the game now does what the scripts and the engine do.
This issue keeps what they did and how, so we can discuss whether any of them should come back (for example as an optional, mod-like setting).
Restoring: the last commit that still has the code is 3e652e84 on branch split/16-npc-ai. The removal is the commit "refactor: AI rules beyond the vanilla scripts are removed" right after it on the same branch. git show 3e652e84:<path> gives the old files; reverting the removal commit brings everything back at once.
1. EnableNpcArmedThreatDetection - NPCs react to an armed, fighting NPC nearby
What it did: an NPC in its routine (no target) that saw a non-hero NPC with a drawn weapon (not fists) who was actively fighting someone within 4 m went into ZS_AssessFighter, as if the hero had drawn a weapon next to it.
Vanilla: B_AssessFighter (PERC_ASSESSFIGHTER / PERC_DRAWWEAPON) returns at once for anyone but the player (!Npc_IsPlayer(other)), so NPC-vs-NPC fights with weapons go unnoticed by bystanders unless another perception (fight sound, others' damage) fires.
Implementation:
AiHandler.ExecuteActivePerceptions(perception tick):if (Properties.TargetNpc == null && Dev.EnableNpcArmedThreatDetection) _npcAiService.CheckForArmedNpcThreat(NpcInstance);NpcAiService.CheckForArmedNpcThreat->NpcTargetSelectionDomain.CheckForArmedNpcThreat(self): loop over awake NPCs (hero skipped - that is the scripts' job), candidate must be alive,FightModenot NoWeapon/Fist,TargetNpc != null, within 4 m, not Friendly, not same guild, not a party member, not self's summoner, and visible (ExtNpcCanSeeNpc). If self is not already inZS_ASSESSFIGHTER: setEnemyNpc/TargetNpcto the candidate, setotherandExtAiStartState(self, ZS_AssessFighter).
2. EnableActiveAttackerRetarget - a fighting NPC turns to a second attacker
What it did: an NPC that already had a target (from a previous tick) and could not see that target any more switched to the closest NPC/monster within its senses range that was fighting it (had it as its own TargetNpc/EnemyNpc), sensed through walls too (hearing/smell). Example: Cavalorn or a wolf attacks a guard who is locked on the hero behind a wall.
Vanilla: combat states like ZS_Attack register no PERC_ASSESSENEMY, so an NPC in a fight stays on its target until the scripts change it (Npc_GetNextTarget in ZS_Attack_Loop, damage perceptions).
Implementation:
AiHandler.ExecuteActivePerceptions: a snapshothadTargetBeforeThisTick = Properties.TargetNpc != nullbeforeUpdateEnemyNpc, thenif (hadTargetBeforeThisTick && Dev.EnableActiveAttackerRetarget) _npcAiService.UpdateActiveAttackerTarget(NpcInstance);NpcAiService.UpdateActiveAttackerTarget->NpcTargetSelectionDomain.UpdateActiveAttackerTarget(self): keep the current target while it is alive and visible; otherwise scan the hero and awake NPCs for the closest one that targets self (not dead, not Friendly, not same guild, not a party member, not self's summoner, within senses range,CanSenseNpc(..., freeLOS: true)) and set it asEnemyNpc/TargetNpc.
3. EnableNpcHitRetaliation - an NPC hit by another NPC targets the attacker
What it did: when a non-hero NPC hit a living target, the target's TargetNpc/EnemyNpc were force-set to the attacker (wolves, monsters, companions became the active fight target), except Friendly attackers, same guild and party members (summons).
Vanilla: B_CombatReactToDamage switches the target only when the player is the attacker; other hits only go through the AssessDamage perception (B_AssessDamage / B_MM_ReactToDamage).
Implementation: DamagePerceptionDomain.BroadcastDamagePerceptions called TrySwitchTargetToAttacker(attacker, target, heroIndex) after the victim's ReactToDamage:
if (!Dev.EnableNpcHitRetaliation || attacker is hero || target dead || same guild ||
IsPartyMember(attacker) || ExtGetAttitude(target, attacker) == Friendly) return;
target.Props.TargetNpc = attacker.Instance;
target.Props.EnemyNpc = attacker.Instance;
5. EnableGuardsAgainstBerzerk - guards knock out a berzerk NPC (G1)
What it did: whenever an NPC in ZS_Berzerk dealt a hit, every awake NPC within 15 m that C_NpcIsGuard accepted (and that was up, not the hero, not berzerk or in ZS_Attack itself) got the berzerker as EnemyNpc/TargetNpc, drew its weapon (AI_DrawWeapon) and started ZS_Attack. As the berzerker is not hostile to them, ZS_Attack_End only knocks it out.
Vanilla: G1 lets a berzerk NPC rage; guards only protect their charges from non-friends (B_AssessFightSound, "friendly fire" rule).
Implementation: DamagePerceptionDomain.CallGuardsAgainstBerzerk(attacker) at the start of BroadcastDamagePerceptions, with IsGuardCandidate and the range constant _guardsHelpRange = 15f. Needed DaedalusConst.ZsAttack and DaedalusConst.CNpcIsGuard (also removed). DamagePerceptionDomain.IsBerzerk stays - FightService still uses it.
6. EnableHeroSummonAttitude - NPCs see the hero's summons like the hero
What it did: between the hero's summon and a non-summon NPC, the attitude was the NPC's attitude towards the hero (temp, then permanent, then guild table): bandits and wolves fought the summon, Cavalorn or Xardas left it alone.
Vanilla: the guild table decides. In G2 B_InitMonsterAttitudes makes humans hostile to the GIL_SUMMONED_* guilds, so guards attack the hero's summons too.
Implementation: NpcHelperService.GetPersonAttitude, after the summoner/summon friendly rule:
if (Dev.EnableHeroSummonAttitude)
{
if (IsHeroSummon(other) && self.SummonedBy == null && !IsHero(self)) return GetAttitudeTowardsHero(self);
if (IsHeroSummon(self) && other.SummonedBy == null && !IsHero(other)) return GetAttitudeTowardsHero(other);
}
plus the private helpers IsHeroSummon and GetAttitudeTowardsHero. The rule that a summon and its own summoner are always friendly stays (it is unconditional and not part of this flag).
7. EnableProclaimFromAfar - the proclaiming NPC stops chasing within 12 m
What it did: an NPC in ZS_ProclaimAndPunish (G2, "Now wait...") chasing the hero cleared its AI queue and went to the state's End (the proclaim and the attack) once the hero was within 12 m; after HAI_TIME_PURSUIT seconds it cleared the queue so the loop could decide (back to routine). Added because a hero running away right after his attack was chased until caught (Lukis).
Vanilla: ZS_ProclaimAndPunish_Loop only runs again once its AI_GotoNpc is done, i.e. when the NPC reached the hero; then it checks PERC_DIST_DIALOG (5 m) and HAI_TIME_PURSUIT. (The engine-side stop of AI_GotoNpc after HAI_TIME_PURSUIT in GoToNpc is ungated and stays.)
Implementation: AiHandler.CheckProclaimChase(), called every tick in Update after ExecuteActivePerceptions; constants _proclaimState = "ZS_PROCLAIMANDPUNISH", _proclaimDistance = 12f, _defaultPursuitSeconds = 20f, and DaedalusConst.HaiTimePursuit (also removed):
if (!Dev.EnableProclaimFromAfar || loop state != Loop || queue empty and action finished || state != ZS_PROCLAIMANDPUNISH) return;
var isClose = distance(npc, hero) <= 12;
if (!isClose && StateTime <= HAI_TIME_PURSUIT) return;
_npcAiService.ExtNpcClearAiQueue(NpcInstance);
if (isClose) CurrentLoopState = LoopState.End;
(#4 EnableHeroChaseCooldown is not part of this removal - it is still being looked at.)
To discuss
Should any of these come back? If yes, as what: an optional, mod-like setting (off by default, the game stays vanilla), or a fix in a specific situation where vanilla behaviour looks broken in VR? Please say which rule and why.
🤖 Generated with Claude Code
- Vorherrschende Sprache
- C#
- Sterne
- 33
- Forks
- 1
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 76
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus Gothic-Unity-Project/Gothic-Unity
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Gothic-Unity-Project/Gothic-Unity#533 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 53/100
Gothic-Unity-Project/Gothic-Unity#523 ·
Maintainer antworten meist innerhalb von 1 Tag
-
improvement
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 52/100
Gothic-Unity-Project/Gothic-Unity#521 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
Gothic-Unity-Project/Gothic-Unity#505 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
Gothic-Unity-Project/Gothic-Unity#504 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in Gothic-Unity-Project/Gothic-Unity
Ähnliche Issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
openclaw/openclaw-windows-node#2287 · 2 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
area:host area:operations type:bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
kind:ux needs-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
elsa-workflows/elsa-foundation#4742 ·
Maintainer antworten meist innerhalb von 1 Tag
-
priority:P2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
-
enhancement good first issue help wanted new-language
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100