Discuss: non-vanilla NPC AI rules removed from the NPC AI port (split/16)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
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
- 主要語言
- C#
- 星號
- 33
- 分支
- 1
- 平均合併
- 2 天 4 小時
- 30 天內合併 PR
- 76
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
Gothic-Unity-Project/Gothic-Unity 的其他 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 82/100
Gothic-Unity-Project/Gothic-Unity#533 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 53/100
Gothic-Unity-Project/Gothic-Unity#523 ·
維護者通常 1 天內回覆
-
improvement
難度 4/5 3-5 天 新手友好度 52/100
Gothic-Unity-Project/Gothic-Unity#521 ·
維護者通常 1 天內回覆
-
bug
難度 5/5 一週以上 新手友好度 35/100
Gothic-Unity-Project/Gothic-Unity#505 ·
維護者通常 1 天內回覆
-
bug
難度 4/5 3-5 天 新手友好度 45/100
Gothic-Unity-Project/Gothic-Unity#504 ·
維護者通常 1 天內回覆
查看 Gothic-Unity-Project/Gothic-Unity 的全部 Issue
相似的 Issue
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
難度 2/5 1-3 小時 新手友好度 76/100
openclaw/openclaw-windows-node#2287 · 2 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
area:host area:operations type:bug
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
kind:ux needs-triage
難度 2/5 1-3 小時 新手友好度 66/100
elsa-workflows/elsa-foundation#4742 ·
維護者通常 1 天內回覆
-
priority:P2
難度 2/5 1-3 小時 新手友好度 88/100
-
enhancement good first issue help wanted new-language
難度 2/5 1-3 小時 新手友好度 82/100