CD Code Digest Hub /GTA V · v2

Ped 其余子系统:Horse、Action、CriminalCareer、PedWeapons、几何分析器与辅助组件

58 分钟阅读 15 个章节

本页收尾 game/Peds 目录:先给出整个目录的文件盘点(哪些文件在哪一页讲、哪些已经不参与构建),再逐个说明前三页没有展开的子系统——在 GTAV 中被编译关闭的 Horse、近战动作选择 Action(CActionManager)、Gen9 新增的 CriminalCareer、ped 侧的瞄准/目标选择/命中率 PedWeapons、视线与可瞄准性缓存 CPedGeometryAnalyser,以及挂在 CPed 上的一组小组件(IK 设置、胶囊、布料碰撞、脚步、头盔、电话、特殊能力、Cops & Crooks 街机信息、辅助移动路线、移动地面等)。

背景与相关页面#

相关源码文件#

文件作用
src/dev_ng/game/Peds/Horse/*马匹控制(RDR 遗留,ENABLE_HORSE=0)
src/dev_ng/game/Peds/Action/ActionManager.*、ActionFlags.psc、BrawlingStyle.*近战动作表与选择、格斗风格
src/dev_ng/game/Peds/CriminalCareer/*Gen9 职业生涯目录/购物车/校验/服务
src/dev_ng/game/Peds/PedWeapons/*CPedTargetting、CPlayerPedTargeting、CPedTargetEvaluator、CPedAccuracy、PedWeapons.psc
src/dev_ng/game/Peds/PedGeometryAnalyser.*视线、可瞄准性与碰撞几何辅助
src/dev_ng/game/Peds/PedIKSettings.*、PedCapsule.*、PedCloth.*、PedFootstepHelper.*、PedHelmetComponent.*、PedPhoneComponent.*ped 辅助组件与数据
src/dev_ng/game/Peds/PlayerSpecialAbility.*、ArcadeAbilityEffects.*、PlayerArcadeInformation.*特殊能力与 Cops & Crooks 街机模式
src/dev_ng/game/Peds/AssistedMovement*.*、Area.*、VehicleCombatAvoidanceArea.*、MovingGround.h辅助移动路线、区域、移动地面
src/dev_ng/game/Peds/QueriableInterface.*、PedScriptResource.*、PedTaskRecord.*、pedshockingevents.*任务查询接口、脚本资源、脚本任务记录、惊吓事件记忆
src/dev_ng/game/Peds/makefile.txt、src/dev_ng/game/vs_project2_lib/game2_lib_2015.vcxproj目录清单与实际构建清单

1. game/Peds 目录盘点#

1.1 构建事实#

  • Peds/makefile.txt 以 Directory 块列出子目录与需要 parser 代码生成的 Parse 项(例如 CriminalCareer 生成 CriminalCareerCatalog/Defs/ShoppingCartValidator,PedIntelligence 生成 PedMotivation)src/dev_ng/game/Peds/makefile.txt:1-33。
  • 实际 VS 工程 game2_lib_2015.vcxproj 中 Peds/PedGroup 下有 97 个 ClCompile 条目(包含由 .psc 生成、磁盘上并不存在的 parser cpp)。Horse、PedMoveBlend 这类空壳/被宏关闭的文件仍在工程中,例如 src/dev_ng/game/vs_project2_lib/game2_lib_2015.vcxproj:6576、game2_lib_2015.vcxproj:6597,CriminalCareer 也在其中 game2_lib_2015.vcxproj:6557。
  • Peds/PlayerPed.cpp(约 43 KB)与 Peds/Population.cpp(约 78 KB)存在于磁盘但不在工程中(工程文件中检索不到这两个条目),属于遗留源码;阅读时不要把它们当作运行路径。玩家 ped 由 CPedFactory::CreatePlayerPed 创建(见 ped-architecture.md),人口逻辑在 pedpopulation.cpp(见 ped-intelligence-and-population.md)。

1.2 文件 → 页面映射#

文件/目录主题覆盖页面
ped.h、Ped.cpp、pedDefines.h、PedFlags.*、PedFlagsMeta.psc、PedFactory.*、PedType.*CPed 骨架ped-architecture.md
PlayerInfo.*、PlayerInfo.psc玩家附加数据ped-architecture.md
PedComponentSetInfo.*、TaskData.*、taskdata.psc、taskflags.psc、HealthConfig.*、NavCapabilities.*、PedCapsule.*、PedIKSettings.*模型信息引用的数据驱动配置ped-architecture.md(本页第 7 节补充 IK/胶囊)
PedIntelligence.*、PedIntelligenceFactory.*、PedEventScanner.*、Relationships.*、RelationshipEnums.h、PedIntelligence/*、CombatBehaviour.*、CombatData.psc、CombatInfo.psc、DefensiveArea.*、FleeBehaviour.h、Gangs.*、PedStealth.*、PedTaskRecord.*AI 侧ped-intelligence-and-population.md(本页第 10 节补充小文件)
pedpopulation.*、PopCycle.*、PopZones.*、pedplacement.*、WildlifeManager.*、population_channel.h人口ped-intelligence-and-population.md
PedMotionData.*、PedMotionState.psc、PedTuning.*、PedMoveBlend/*、rendering/*运动与渲染ped-motion-and-rendering.md
Horse/*、Action/*、CriminalCareer/*、PedWeapons/*、PedGeometryAnalyser.*、PedCloth.*、PedFootstepHelper.*、PedHelmetComponent.*、PedPhoneComponent.*、PlayerSpecialAbility.*、ArcadeAbilityEffects.*、PlayerArcadeInformation.*、AssistedMovement*、Area.*、VehicleCombatAvoidanceArea.*、MovingGround.h、QueriableInterface.*、PedScriptResource.*、pedshockingevents.*、PedDebugVisualiser.*、ped_channel.h其余子系统本页
PlayerPed.*、Population.*遗留,未构建本页 1.1

2. Horse:在 GTAV 中被编译关闭的马匹系统#

Horse/ 来自 RDR 代码线。开关定义在 horseDefines.h:只有定义了 RDR_VERSION 且 >= 300 时 ENABLE_HORSE 才为 1,否则为 0,并提供 ENABLE_HORSE_ONLY(x) 辅助宏 src/dev_ng/game/Peds/Horse/horseDefines.h:4-12。代码库中 65 处 #define RDR_VERSION 全部为 0,例如 forceinclude 头 src/dev_ng/rage/base/src/forceinclude/durango_master.h:505、src/dev_ng/rage/base/src/forceinclude/orbis_final.h:489,因此 GTAV 中马匹代码全部不参与编译(文件仍在工程里,但内容被 #if ENABLE_HORSE 包裹)。

结构(仅供理解遗留引用):

类作用证据
CHorseComponent挂在可骑乘 ped 上的聚合组件,内含 freshness/speed/agitation/obstacle avoidance/brake 五个控制器src/dev_ng/game/Peds/Horse/horseComponent.h:182、horseComponent.h:306-311
CReins缰绳附着与碰撞数据horseComponent.h:55
hrsControl 及派生 hrsSpeedControl、hrsBrakeControl、hrsAgitationControl、hrsFreshnessControl、hrsObstacleAvoidanceControl各控制器(避障用 navmesh 视线辅助检测悬崖)horseControl.h:22、horseSpeed.h:36、horseBrake.h:26、horseAgitation.h:26、horseFreshness.h:25、horseObstacleavoidance.h:30
hrsSimTune / hrsSimTuneMgr调优数据(MOUNT_TUNE_FILE,mounttune.xml)horseTune.h:29、horseTune.h:73、horseTune.cpp:77、src/dev_ng/game/scene/FileLoader.cpp:1519-1536

CPed 中的钩子同样被宏关闭:可骑乘 ped 在初始化时创建座位管理器/组件预约管理器/马匹组件 src/dev_ng/game/Peds/Ped.cpp:1421-1429;ProcessControl_ComponentReservations 在关闭时为空函数 Ped.cpp:30549-30555;马匹组件更新 Ped.cpp:31072-31075;主运动任务选择中的骑乘分支 Ped.cpp:883-888。需要注意 GTAV 的“动物运动”并不依赖这些代码:四足动物用 CTaskQuadLocomotion(见 ped-motion-and-rendering.md 第 4.1 节)。

3. Action:近战动作表与 CActionManager#

3.1 解决的问题#

近战(徒手、近战武器、潜行击杀、反击)需要在“当前情境 + 输入 + 目标相对位置”下从大量候选动画中选出一个。GTAV 用数据驱动的“动作表”描述这些候选:每个 CActionDefinition 引用一组测试条件和一个 CActionResult(播放什么、伤害如何、能否接续),CActionManager 负责加载、查询与随机化选择。头注释称数据“从 CSV 加载并可运行时重载”src/dev_ng/game/Peds/Action/ActionManager.h:1343-1350,但实际加载路径是 parser .meta 文件(见 3.3),注释已过时。

3.2 数据模型#

类型作用证据
CActionDefinition一条动作定义:条件(目标类型、移动速度、期望方向、所需武器类型等)→ 结果ActionManager.h:1193
CActionResult / CWeaponActionResult / CWeaponActionResultList动作结果(clip、伤害与反应、分支、震动、VFX、面部动画集)ActionManager.h:593、ActionManager.h:806、ActionManager.h:844
CActionBranch / CActionBranchSet结果之后可接续的动作(连招)ActionManager.h:524、ActionManager.h:554
CImpulse / CImpulseCombo / CImpulseTest / CSimpleImpulseTest输入(按键脉冲)及其组合测试ActionManager.h:947、ActionManager.h:1019、ActionManager.h:1053、ActionManager.h:1137
CInterrelationTest、CRelativeRange、CActionCondPedOther、CActionCondSpecial、CStealthKillTest施动者与目标之间的相对距离/角度/状态测试、潜行击杀条件ActionManager.h:262、ActionManager.h:84、ActionManager.h:882、ActionManager.h:765、ActionManager.h:1099
CHoming、CStrikeBone/CStrikeBoneSet、CDamageAndReaction、CActionRumble、CActionVfx、CActionFacialAnimSet追踪对齐、击打骨骼、伤害与反应、手柄震动、特效、面部动画ActionManager.h:134、ActionManager.h:374、ActionManager.h:400、ActionManager.h:304、ActionManager.h:226、ActionManager.h:437、ActionManager.h:489
CActionTestCache测试结果缓存ActionManager.h:46
CActionFlags(ActionFlags.psc)目标类型、移动速度、期望方向、武器类型、玩家/AI 过滤等位集枚举src/dev_ng/game/Peds/Action/ActionFlags.psc:5-232

CActionManager 类主体 ActionManager.h:1351-1532 以 atSingleton 形式提供,宏 ACTIONMGR、INIT_ACTIONMGR、SHUTDOWN_ACTIONMGR ActionManager.h:1534-1543;它还提供大量静态几何/过滤辅助(目标位置预测、骨骼矩阵、地面高度、友好关系判断等)ActionManager.h:1356-1400。

3.3 加载与 DLC 覆盖#

  • CActionManager::Init 注册为 gameSkeleton 初始化调用 src/dev_ng/game/core/game.cpp:2354(对应的关机调用被注释掉 game.cpp:2057)。仅在初次加载或明确要求时加载数据,并为 ACTION_TABLE_DEFINITIONS 注册 DLC 挂载接口(eDFMI_UnloadFirst)src/dev_ng/game/Peds/Action/ActionManager.cpp:4722-4730。
  • 容量来自 gameconfig.xml 的池大小 "ActionTable_Branches"、"ActionTable_StealthKills" 等;随后依次遍历 ACTION_TABLE_DEFINITIONS、ACTION_TABLE_RESULTS、ACTION_TABLE_IMPULSES、ACTION_TABLE_INTERRELATIONS 四类数据文件,PARSER.LoadTree(..., "meta") 后逐项 LoadFromStructure 追加;数组满时断言提示去 gameconfig.xml 增大池 ActionManager.cpp:4961-5060。
  • DLC 挂载器 CActionInfoDataFileMounter 调 OverrideActionDefinitions(file) ActionManager.cpp:4606-4616;卸载时 RevertActionDefinitions 用 common:/data/action/definitions.meta 恢复 ActionManager.cpp:4711-4713。

3.4 选择算法#

  1. SelectSuitableAction 遍历定义,IsActionSuitable 逐项检查条件,最多收集 MAX_SUITABLE_DEFINITIONS = 10 个候选 ActionManager.cpp:6424-6473、ActionManager.cpp:6481-6532、ActionManager.h:1319。
  2. SelectActionFromSet:0 个返回空、1 个直接返回;否则按优先级排序并删除低于最高优先级的候选 ActionManager.cpp:6554-6607。
  3. 剩余同优先级候选以各自的 bias 为权重,并参考最近 ACTION_HISTORY_LENGTH = 12 个近战结果的历史(最后出现位置与连续次数,sSuitableActionInfo)调整,以避免重复同一招式 ActionManager.cpp:6609-6642、ActionManager.h:1320-1341。

调用方主要是近战任务、伤害事件与脚本命令(TaskCombatMelee.cpp、EventDamage.cpp、WeaponDamage.cpp、commands_task.cpp 等使用 ACTIONMGR);近战任务流程见 ../07-ai-tasks/task-catalogue.md。

3.5 格斗风格#

CBrawlingStyleManager 从 PED_BRAWLING_STYLE_FILE(pedbrawlingstyle.meta)加载格斗风格数据,BANK 构建支持重载/保存 src/dev_ng/game/Peds/Action/BrawlingStyle.cpp:47-80,结构见 BrawlingStyle.psc src/dev_ng/game/Peds/Action/BrawlingStyle.psc:4-38。每个 ped 保存一个风格哈希 m_BrawlingStyle src/dev_ng/game/Peds/ped.h:3030,初始化时取模型信息的默认值 Ped.cpp:1348。

4. CriminalCareer:Gen9 职业生涯构建器后端#

这是 PS5/XSX 版本“职业生涯构建器”(新建 GTA Online 角色时选择职业、用 windfall 资金购买起始物品)的数据与业务层,UI 在 frontend/landing_page 等处。

  • 编译条件:整个服务包在 #if GEN9_STANDALONE_ENABLED 中 src/dev_ng/game/Peds/CriminalCareer/CriminalCareerService.h:26。GEN9_STANDALONE_ENABLED = (1 && GEN9_UI_SIMULATION_ENABLED) || (1 && IS_GEN9_PLATFORM),而 GEN9_UI_SIMULATION_ENABLED 以 0 && ... 开头恒为 0,因此只在 RSG_GEN9 平台编译 src/dev_ng/rage/framework/src/fwutil/Gen9Settings.h:17-34。
  • 组成:CCriminalCareerService 聚合 CCriminalCareerCatalog(职业与物品目录)、CCriminalCareerShoppingCart、CCriminalCareerShoppingCartValidator(分类数量/金额限制)CriminalCareerService.h:28-110;数据类型在 CriminalCareerDefs 命名空间与 CCriminalCareerItem/CCriminalCareer 中 src/dev_ng/game/Peds/CriminalCareer/CriminalCareerDefs.h:32、CriminalCareerDefs.h:497、CriminalCareerDefs.h:567。服务是 atSingleton(SCriminalCareerService),并有供 gameSkeleton 使用的 CCriminalCareerServiceWrapper::Init/Shutdown CriminalCareerService.h:112-120。
  • 数据:构造时用 parser 加载 platform://data/criminalcareer/catalog 与 shopping_cart_validation(扩展名 META_FILE_EXT)src/dev_ng/game/Peds/CriminalCareer/CriminalCareerService.cpp:14-27。
  • 业务规则示例:切换职业时若购物车非空先清空,并自动加入带 AlwaysInShoppingCart 标志的职业物品 CriminalCareerService.cpp:29-53;加入物品时按分类数量上限(上限为 1 时替换同类物品)CriminalCareerService.cpp:55-62。
  • 注册与调用者:CLandingPage::Init、CCriminalCareerServiceWrapper::Init 在 GEN9_STANDALONE_ENABLED 下注册 game.cpp:1820-1825,关机注册 game.cpp:2037-2041。落地页控制器调用 SetChosenCareerIdentifier 等 src/dev_ng/game/frontend/landing_page/LandingPageController.cpp:229-231、LandingPageController.cpp:241-242;脚本命令 STATS_COMPLETED_CHARCTER_CREATION 在有 windfall 时扣除购物车总价、写职业 windfall 统计并发放物品 src/dev_ng/game/script/commands_stats.cpp:11174-11200。
  • 源码不一致(证据缺口):commands_stats.cpp 调用 SCriminalCareerService::GetInstance().SetOutfitSelected(iOutfit) commands_stats.cpp:11166,commands_misc.cpp 调用 ResetChosenMpCharacterSlot() src/dev_ng/game/script/commands_misc.cpp:5589-5596,但 CriminalCareerService.h 中没有声明这两个方法(全库唯一的 ResetChosenMpCharacterSlot 声明在 SaveMigration_multiplayer.h:200 的另一个类上)。这表明本快照中 Gen9 部分的头文件与调用方版本不一致,Gen9 构建能否直接编译无法从现有源码确认。

5. PedWeapons:ped 侧的目标选择、玩家锁定与命中率#

武器对象、武器信息、库存和 CPedWeaponManager 都位于 game/Weapons(ped.h 包含 Weapons/Inventory/PedInventory.h、PedWeaponManager.h ped.h:49-50),归 ../21-weapons-camera/weapons.md。Peds/PedWeapons 只负责“打谁、打得多准”:

类作用关键数值/证据
CPedTargetting : CExpensiveProcessAI 的威胁列表与目标评分(已有目标权重、LOS 受阻权重、玩家高威胁加权、飞行器内目标惩罚、未见目标忽略时间等 Tunables)每 ped 最多 MAX_NUM_TARGETS = 8 个目标 src/dev_ng/game/Peds/PedWeapons/PedTargeting.h:162;Tunables PedTargeting.h:166-195;全局最多 MAX_NO_TARGETTING_SYSTEMS = 128 个实例 PedTargeting.h:149、池 src/dev_ng/game/Peds/PedWeapons/PedTargeting.cpp:35;目标淡出 10000 ms PedTargeting.cpp:37
CPlayerPedTargeting玩家锁定:硬锁/软锁/无(eLockType)、按难度的曲线集(CCurve/CCurveSet/CTargettingDifficultyInfo)src/dev_ng/game/Peds/PedWeapons/PlayerPedTargeting.h:26、PlayerPedTargeting.h:78、PlayerPedTargeting.h:121-128、PlayerPedTargeting.h:237-300;作为 CPlayerInfo::m_targeting 成员 src/dev_ng/game/Peds/PlayerInfo.h:1483
CPedTargetEvaluator候选目标评分:近战/载具武器角度与距离权重、按关系分类的优先级(无害、中立、潜在威胁、任务威胁、P2P 各种情形、被铐、近战倒地等)结构 sTargetEntity src/dev_ng/game/Peds/PedWeapons/PedTargetEvaluator.h:21、类与 Tunables PedTargetEvaluator.h:56-110、最多评估 MAX_ENTITIES = 96 PedTargetEvaluator.h:470
CPedAccuracy / CPedAccuracyResetVariables / sPedAccuracyModifiers命中率与修正(commoncrc:/data/ai/pedaccuracy.meta)src/dev_ng/game/Peds/PedWeapons/PedAccuracy.h:23、PedAccuracy.h:84、PedAccuracy.h:174、加载 src/dev_ng/game/Peds/PedWeapons/PedAccuracy.cpp:571-573

PedWeapons.psc 定义上述 Tunables 的反射结构 src/dev_ng/game/Peds/PedWeapons/PedWeapons.psc:10-203。

CPedTargetting 生命周期:按需创建、闲置销毁。CPedIntelligence::GetTargetting(bWakeUpIfInactive) 在没有实例时从池中 rage_checked_pool_new;池满时 BANK 构建统计“超过 2 秒的旧实例”并断言 src/dev_ng/game/Peds/PedIntelligence.h:1746-1773。CPedIntelligence::UpdateTargetting 每次 AI 处理调用 CPedTargetting::UpdateTargetting,返回 false(闲置超时)即删除实例 src/dev_ng/game/Peds/PedIntelligence.cpp:415-433、PedIntelligence.cpp:1305;网络克隆也会主动刷新 src/dev_ng/game/network/Objects/Entities/NetObjPed.cpp:894。评分实现见 UpdateTargetting PedTargeting.cpp:1254 与 GetBestTarget PedTargeting.cpp:2150。128 个实例远少于 ped 池上限,这依赖“只有处于战斗/威胁状态的 ped 才持有实例”的假设(推断)。

每帧武器处理:ProcessControl_WeaponsAndAccessoriesPreIntelligence 调 CPedWeaponManager::ProcessPreAI;...PostIntelligence 在完整更新时处理库存、玩家命中率(ProcessPlayerAccuracy)、ProcessPostAI,并让 AI ped 在合适时摘下头盔 Ped.cpp:31175-31223。

6. CPedGeometryAnalyser:视线与可瞄准性#

一个全静态的工具类,集中了 AI 常用的几何查询 src/dev_ng/game/Peds/PedGeometryAnalyser.h:390-470:

  • 可瞄准性:CanPedTargetPed / CanPedTargetPoint 带一组选项位(方向测试、忽略掩体/车辆/低矮车辆/烟雾/低矮物体、屏幕内用相机位置、FOV 感知、跳过 LOS、扩展战斗距离、潜艇、近战目标点等 18 个)PedGeometryAnalyser.h:368-388、PedGeometryAnalyser.h:449-451。
  • 异步 LOS 缓存:CCanTargetCache 缓存“从 ped A 到 ped B”的结果,容量 CAN_TARGET_CACHE_SIZE = 40,超时 CAN_TARGET_CACHE_TIMEOUT = 2000 ms,按位置变化阈值失效 PedGeometryAnalyser.h:322-362。CPedGeometryAnalyser::Process 每帧清理过期条目并收集异步探测结果,非 FINAL 构建上报 LOS 统计 src/dev_ng/game/Peds/PedGeometryAnalyser.cpp:3869-3883;它在 CGameWorld::Process 中、实体处理开始前调用 src/dev_ng/game/scene/world/GameWorld.cpp:1802、GameWorld.cpp:1873-1874,关机注册见 game.cpp:2507。
  • 其他几何:绕实体移动方向、擦碰判断、复合包围体胶囊测试、点路线 LOS、能否跳过障碍等 PedGeometryAnalyser.h:420-446;CEntityBoundAI(实体的 AI 用包围多边形)PedGeometryAnalyser.h:65、CPedGrouteCalculator PedGeometryAnalyser.h:204、CRouteToDoorCalculator PedGeometryAnalyser.h:286。

7. ped 辅助组件与物理交接#

组件/数据作用证据
CPedIKSettingsInfo(CIKDeltaLimits、CPedIKSettingsInfoManager)每类 ped 的 IK 允许范围(例如注视/转体的角度增量限制),由模型信息哈希引用;ped 持有 m_pIKSettingssrc/dev_ng/game/Peds/PedIKSettings.h:20-70、加载 src/dev_ng/game/Peds/PedIKSettings.cpp:82、ped.h:2950
CBaseCapsuleInfo → CBipedCapsuleInfo(→ CBirdCapsuleInfo)、CFishCapsuleInfo、CQuadrupedCapsuleInfo;eRagdollType(男/女/大体型男/自定义)ped 物理胶囊形状与布娃娃类型,CPedCapsuleInfoManager 从 xml 加载并支持追加src/dev_ng/game/Peds/PedCapsule.h:27-41、PedCapsule.h:131、PedCapsule.h:196-226、src/dev_ng/game/Peds/PedCapsule.cpp:44-72
CPedClothCollision角色布料的碰撞体(最多 32 套,common:/data/cloth/ 下的 xml)src/dev_ng/game/Peds/PedCloth.h:13-86、src/dev_ng/game/Peds/PedCloth.cpp:13-16、PedCloth.cpp:87-135;每帧 ProcessControl_Cloth Ped.cpp:30806
CPedFootStepHelper脚步地面检测、脚高状态、音频象限与 LOD(双足 2 只脚,最多 4 只)src/dev_ng/game/Peds/PedFootstepHelper.h:20-42、PedFootstepHelper.h:126;类初始化/更新 Ped.cpp:2246、Ped.cpp:6296
CPedHelmetComponent头盔戴/摘、主角的替代飞行/军用/越野头盔道具编号src/dev_ng/game/Peds/PedHelmetComponent.h:22-28
CPedPhoneComponent手机道具与使用状态src/dev_ng/game/Peds/PedPhoneComponent.h:16

布娃娃激活、NM 行为、胶囊与 phInst 的物理实现均归 ../09-physics/game-physics-and-ragdoll.md;ped 侧只负责选择胶囊/布娃娃数据与在 ProcessPhysics 中驱动(见 ped-motion-and-rendering.md 第 4 节)。

8. 特殊能力与 Cops & Crooks 街机模式#

8.1 CPlayerSpecialAbility#

  • 类型 SpecialAbilityType 共 17 种:前 5 个 SAT_CAR_SLOWDOWN、SAT_RAGE、SAT_BULLET_TIME、SAT_SNAPSHOT、SAT_INSULT,空行之后是后加的 ENRAGED、GHOST、SPRINT_SPEED_BOOST、NITRO_COP/CROOK、EMP、SPIKE_MINE、FULL_THROTTLE、PUMPED_UP、BACKUP、OIL_SLICK、KINETIC_RAM(从命名看多为 Cops & Crooks 用,属推断);注释提示新增类型需同步 abilityNames(署名 Ruffian)src/dev_ng/game/Peds/PlayerSpecialAbility.h:66-92。前三者对应单机三主角的驾驶减速/狂暴/子弹时间能力,这是游戏设计常识而非源码注释所述。充能事件枚举 AbilityChargeEventType 见 PlayerSpecialAbility.h:27-63。
  • 类:CSpecialAbilityData(数据)PlayerSpecialAbility.h:103、CPlayerSpecialAbilityManager(静态管理与充能事件分发)PlayerSpecialAbility.h:149、CPlayerSpecialAbility(实例)PlayerSpecialAbility.h:274。数据文件 PED_SPECIAL_ABILITIES_FILE(pedspecialabilities.meta),BANK 可重载/保存 src/dev_ng/game/Peds/PlayerSpecialAbility.cpp:2300-2310、PlayerSpecialAbility.cpp:2473。
  • 帧内:CGameWorld::Process 在实体处理前调用 UpdateSpecialAbilityTrigger(本地玩家) GameWorld.cpp:1876-1877。ped 的 ProcessControl_SpecialAbilityChargeEvents:驾驶非船只车辆、速度超过估算最高平地速度的 90% 且大于 20 m/s 时触发 ACET_TOP_SPEED 持续充能;车辆离地触发 ACET_VEHICLE_JUMP Ped.cpp:31079-31118。ProcessControl_SpecialAbilities:在 Cops & Crooks 中处理“循环切换所选能力”的输入,然后对所选能力做控制处理、对所有能力调用 Process Ped.cpp:31120-31173。

8.2 街机被动能力与队伍/角色#

  • ArcadeAbilityEffects.h(Ruffian Games,2020-02-07 开始):被动效果 PARKOUR、SNITCH、MARATHON_MAN、SECOND_WIND、HACK_THE_SYSTEM、FREIGHT_TRAIN,以位标志保存,配置类存放每种效果的修正值 src/dev_ng/game/Peds/ArcadeAbilityEffects.h:2-3、ArcadeAbilityEffects.h:10-60。
  • CPlayerArcadeInformation:队伍 eArcadeTeam(CNC 警察/罪犯)、角色 eArcadeRole(警官/战术/技术、士兵/执法者/黑客)src/dev_ng/game/Peds/PlayerArcadeInformation.h:24-51。

这表明 Cops & Crooks 模式在 ped 层的扩展集中在这三个文件与 CPed 的能力处理中(推断:该模式的完整玩法与脚本侧逻辑不在本页范围,见 ../15-script-content/multiplayer-freemode.md)。

9. 辅助移动、区域与移动地面#

  • 辅助移动(assisted movement):地图中预设的“粘性路线”(窄桥、楼梯、扶手边等)让玩家摇杆输入被柔和地拉向路线。CAssistedMovementRouteStore 静态存储地图路线 72 条 + 脚本路线 8 条 + 航点路线 8 条 src/dev_ng/game/Peds/AssistedMovementStore.h:206-240,每条 CAssistedMovementRoute 最多 64 个点 AssistedMovementStore.h:22、AssistedMovementStore.h:62,CAssistedMovementToggles 控制开关 AssistedMovementStore.h:160。运行时由 CPlayerAssistedMovementControl 扫描与跟随路线(传送后 4 秒重扫)src/dev_ng/game/Peds/AssistedMovement.h:26-61,其实例由玩家徒步任务持有 src/dev_ng/game/task/Default/TaskPlayer.h:767-768、TaskPlayer.h:813。存储的初始化/关机注册 game.cpp:2312、game.cpp:2537。
  • 区域:CArea 是通用的区域基类(注释提到在基类声明虚函数会在 x64 产生奇怪代码,因此避免虚函数)src/dev_ng/game/Peds/Area.h:18;CVehicleCombatAvoidanceArea : CArea 是让车辆战斗回避的区域 src/dev_ng/game/Peds/VehicleCombatAvoidanceArea.h:14,初始化/关机注册 game.cpp:2376、game.cpp:2575。防御区域 CDefensiveArea 见 ped-intelligence-and-population.md。
  • 移动地面:NMovingGround 命名空间(2012-05-12 开始)用于让导航与掩体在移动的船和火车上工作 src/dev_ng/game/Peds/MovingGround.h:1-12。

10. 任务查询接口与其他小文件#

10.1 CQueriableInterface#

每个 CPedIntelligence 持有一个 CQueriableInterface:任务树每帧把“当前有哪些任务在运行、目标是谁、状态如何”压缩成 CTaskInfo 列表,供其他系统(尤其网络同步、脚本、LOD 判断)在不遍历任务树的情况下查询。

  • CTaskInfo 是带信息类型(目标、状态、克隆 FSM 等)的轻量记录,使用池分配器 src/dev_ng/game/Peds/QueriableInterface.h:78-100;派生有 CClonedFSMTaskInfo、CSerialisedFSMTaskInfo、CAnimTaskInfoBase QueriableInterface.h:407、QueriableInterface.h:436、QueriableInterface.h:464,以及武器目标辅助 CClonedTaskInfoWeaponTargetHelper QueriableInterface.h:357。
  • 容量:每 ped MAX_TASK_INFOS_PER_PED = 8,总数 MAX_NUM_TASK_INFOS 在 PC/Durango/Orbis 上为 268×8 = 2144,其他平台 115×8 = 920(注释要求改 ped 数时同步 PedFactory.cpp 的 TASKINFO_HEAP_SIZE)QueriableInterface.h:30-34;任务序列信息池 1200 src/dev_ng/game/Peds/QueriableInterface.cpp:128-131。
  • 接口:AddTaskInformation、ResetTaskInfo、ResetScriptTaskInfo,以及网络侧 AddTaskInfoFromNetwork 与日志 QueriableInterface.h:491-520。脚本任务信息在每次 AI 处理后重置,等待 CPedScriptedTaskRecord::Process 重新计算 Ped.cpp:31239-31240。UpdateLodState 也通过它判断“是否在驾车射击/下车”(见 ped-motion-and-rendering.md 第 6 节)。网络序列化部分见 ../17-network-sync/sync-trees-and-serialisation.md。

10.2 其他#

文件内容证据
PedScriptResource.*脚本请求的“移动模式”资源(CMovementModeScriptResource,每个最多 24 个流送请求)与管理器src/dev_ng/game/Peds/PedScriptResource.h:15-43
pedshockingevents.*CPedShockingEvent:ped 记住最近响应过的 5 个惊吓事件 ID,避免重复反应src/dev_ng/game/Peds/pedshockingevents.h:17-39
PedTaskRecord.*CPedScriptedTaskRecordData/CPedScriptedTaskRecord:记录脚本下达给 ped 的任务及状态(供脚本查询)src/dev_ng/game/Peds/PedTaskRecord.h:14、PedTaskRecord.h:62
PedStealth.*CPedStealth:每 ped 的潜行等级与“本帧被发现”标记src/dev_ng/game/Peds/PedStealth.h:18-40
FleeBehaviour.h、HealthConfig.*、NavCapabilities.*、Gangs.*、PedType.*逃跑行为参数、健康配置、导航能力、帮派信息、ped 类型与 CPedTypesrc/dev_ng/game/Peds/FleeBehaviour.h:10、src/dev_ng/game/Peds/HealthConfig.h:18-63、src/dev_ng/game/Peds/NavCapabilities.h:14、NavCapabilities.h:126、src/dev_ng/game/Peds/Gangs.h:14-51、src/dev_ng/game/Peds/PedType.h:11、PedType.h:94;AI 用法见 ped-intelligence-and-population.md

11. 调试与日志通道#

  • PedDebugVisualiser.*(约 440 KB):AI/ped 调试绘制与菜单,整体受 PEDDEBUGVISUALISER(= DEBUG_DRAW)控制 src/dev_ng/game/Peds/PedDebugVisualiser.h:6-10;工具层面的介绍见 ../23-debug-security/debug-tools.md。
  • CPedVariationDebug 仅 __BANK(见 ped-motion-and-rendering.md)。
  • 日志通道:ped_channel.h 声明 ped、respawn、wanted 通道 src/dev_ng/game/Peds/ped_channel.h:12、ped_channel.h:27、ped_channel.h:42;population_channel.h 声明 population 与 pedReuse src/dev_ng/game/Peds/population_channel.h:12、population_channel.h:26。通道机制见 ../02-rage-core/system-and-diagnostics.md。

12. 约束与边界行为#

  • 编译期关闭的代码:Horse/* 全部(ENABLE_HORSE=0);CriminalCareer/* 仅 Gen9;PedMoveBlend/* 基本为空。按文件存在判断功能会严重误判。
  • 池上限:CPedTargetting 128(带溢出)、CTaskInfo 2144/920、任务序列信息 1200、动作表各数组来自 gameconfig.xml;超限时以断言为主,FINAL 构建中的行为(例如 GetTargetting 返回空)需要调用者处理。
  • DLC:动作定义可被 DLC 覆盖并在卸载时回退到 definitions.meta;特殊能力、格斗风格等数据只有 BANK 下的重载入口。
  • 网络:CPedTargetting 在克隆上也会被刷新,CQueriableInterface 是克隆任务状态的载体;两者的一致性依赖网络同步页的规则。

13. 未决问题 / 证据不足#

  • CriminalCareerService.h 缺少 SetOutfitSelected/ResetChosenMpCharacterSlot 声明的原因(头文件版本落后?另有未提交的头文件?)无法从本快照确认。
  • gameconfig.xml 中 ActionTable_* 等池的实际数值、definitions.meta/pedaccuracy.meta/pedspecialabilities.meta 的内容未查看。
  • CPedTargetting::UpdateTargetting 与 CPedTargetEvaluator 的完整评分公式仅列出入口与 Tunables,没有逐项展开。
  • Peds/PlayerPed.cpp 与 Peds/Population.cpp 是否在其他工程(例如旧平台工程)中仍被编译,未逐一检查所有 vcxproj。