Skip to content

Characters, AI and the player

This page covers everything that walks: the engine's ZActor, the game's ZHM3Actor and the parts it is built from, 47 as ZHitman3, how guards and civilians see and hear him, and the locomotion, animation, navigation and crowd code under them. It was read from the decompiled source in src/engine/ and src/hitman3/, and every offset in the tables was checked against analysis/recovered-types.h. NPC decisions are made in the scene scripts, so the AI sections follow a perception up to the point where a script receives it.

Class hierarchy

Class Base Size Source What it adds
ZLNKOBJ ZSTDOBJ 0xf4 src/engine/geomsextend/zlnkobj.cpp the animated, boned object: m_Model (Animation::Model), the ground bone m_Ground, animation variations, m_pBoneModify (ragdoll), the vision id m_iVisionID
ZIKLNKOBJ ZLNKOBJ 0x17c src/engine/geomsextend/ziklnkobj.cpp body facing and head targets, the link-action dispatcher m_pActionDispatcher
ZCTRLIKLNKOBJ ZIKLNKOBJ 0x18c src/engine/geomsextend/zctrliklnkobj.cpp m_eController, m_rContactGeom, m_fLightReceived
ZLNKWHANDS ZCTRLIKLNKOBJ 0x384 src/engine/geomsextend/zlnkwhands.cpp the hands m_LHand and m_RHand (ZIKHAND), m_AimTarget, speech and material sound definitions, item animations, CreateLnkAction
ZActor ZLNKWHANDS 0x8b0 src/engine/geomsextend/zactor.cpp locomotion, paths, the boid, ACTORSTATE
ZHM3Actor ZActor 0xb00 src/hitman3/characters/hm3actor.cpp the game's NPCs, humans as well as dogs and rats (EActorSpecies)
ZPlayer ZLNKWHANDS 0x718 src/engine/geomsextend/zplayer.cpp movement objects, the status word, collision boxes
ZHitman3 ZPlayer and five parts 0x1400 src/hitman3/characters/zhitman3.cpp 47
ZHM3Boid ZIKLNKOBJ 0x320 src/hitman3/characters/hm3boid.cpp the flocking creatures the Bird scripts drive (Zhm3Boid__Setminmaxspeed)

ZPlayer and ZActor both derive from ZLNKWHANDS, so 47 has none of ZActor's locomotion, path or boid fields. src/hitman3/characters/ declares 157 classes, and its .cpp files hold 2,639 functions.

ZActor

ZActor (src/engine/geomsextend/zactor.h) is the engine's walking character. Its main fields:

Offset Field Type Meaning
0x3a4 m_rHero REF the hero, set by SetHero
0x3a8 m_pkBoid ZHumanBoid * the crowd boid that carries the position
0x3ac m_Entity ZEntity the actor's node in the pathfinder
0x3d4 m_Reservation ZEntity a node of the tracker's reserved type (ReservedType)
0x3fc m_Locomotion ZLocomotionState current animation, transition and look-at state (0x44 bytes)
0x440 m_iQuePos, m_iProgramQueSize int16 cursor and length of the program queue
0x444 m_ProgramQue[40] ProgramQueEntry one locomotion state per stretch of the path
0x4e4 m_Path PF4::ZPath the current path
0x52c m_Action[2] int8 the running and the next Locomotion::EStates
0x534 m_pAudibleRoomList REFTAB * a level-file room list the sound tracing uses for this actor
0x540 m_vInitialPos, m_vInitialDir V3 position and facing at ClassInit
0x560 m_fMoveSpeedMultiplier float scales move speed
0x564 m_FrameTimeAccumulator, m_FrameTimeAccumulatorBound float off-screen time slicing
0x56c m_vEndDir, m_vEndPos V3 where and how the path ends
0x590 m_lPathDoneFlag, m_ePathCancelReason uint8 PATHDONEFLAG and PATH_CANCEL_REASONS
0x592 m_ActorState int8 ACTORSTATE
0x594 m_MoveSetBindings ZSetBindings speeds and distances of the active moveset (0x2e8 bytes)
0x888 flags 29 one-bit fields m_bPathFinderEnabled, m_bIsSeeing, m_bIsScared, m_bForceOnScreen and others
0x88c flags2 bits m_bScriptPaused, m_bStopMovement
0x8a0 m_pScriptUBAnimToPlay Animation::Header * an upper-body animation a script asked for
enum ACTORSTATE {
    ACTORSTATE_DEAD = 0,
    ACTORSTATE_AWAKE = 1,
    ACTORSTATE_UNCONSCIOUS = 2,
    ACTORSTATE_SLEEPING = 3
};

ZActor::ClassFrameUpdate decides each frame how much work an actor gets. An actor that is on screen, ragdolled or in its first frame gets a full update. Off screen, the frame time builds up in m_FrameTimeAccumulator, and the full animation and locomotion update runs only when it reaches m_FrameTimeAccumulatorBound, which advances in steps of 0.5 seconds. Each new actor's first bound is 0.05 seconds earlier than the previous actor's (wrapping after 0.5) plus a random ±0.025 seconds, so off-screen actors update on different frames. An actor in a cut sequence or not awake skips IK and the slicing, and a dead, unconscious or sleeping one advances its animations every frame. ZActor::UpdatePosition then copies the boid's tracker position into the actor's x and z, switches the locomotion state (CheckForProgramSwitch) and runs the state's UpdatePosition.

ZHM3Actor and its parts

ZHM3Actor (src/hitman3/characters/hm3actor.h) adds the game's needs to ZActor:

Offset Field Type Meaning
0x8b0 m_eCharacterType eCharacterType civilian, enemy, VIP, target, animal, policeman, optional target
0x8b4 m_rHitmanAs REF the ZHM3HmAs outfit 47 can take from this body
0x8b8 m_rWeapon, m_rWeaponTemplate REF the actor's weapon
0x8d4 m_fStartingHitpoints, m_fHitpoints float health
0x8dc m_fTension, m_bDecayTension float, bool alertness, 0 to 100
0x8e4 m_fRelaxedVisionRange to m_fAlertFOV four float vision range and field of view, relaxed and alert
0x8f4 m_pSuspectedSuit ZHM3HmAs * set by Zhm3Actor__Setsuspectedsuit; the disguise check sees through this outfit from up to 2,000 units
0x900 m_fHunger to m_fInterestTime eight float the four needs (eNeed) and their rates
0x94c m_tBeganSeeingHitman and three more TIMETYPE when the actor started seeing 47, running, stealthy, or in a frisk box
0x97c hitmanTrackingFlags 12 one-bit fields what the actor has concluded about 47
0x980 m_rActorProperties REF a ZHM3ActorProperties object
0x9d8 m_eBodyPosition EActorBodyPosition normal, sitting, lying down
0x9e0 flags 31 bit fields m_bHitmanVisible, m_bIgnoreDisguise, m_bIsSearching, m_bUnconscious and others
0x9ec m_eActorSpecies EActorSpecies eHuman, eDog, eRat, eCorpse, eWheelChair
0x9f0 m_BodyArray[10] SBodyInfo bodies passed to RegisterDeadBody, with position and whether nude
0xa74 m_Mood uint8 EMood, eNoMood to eFrown
0xabc m_sActorElevatorInfo sUseElevatorInfo elevator use

The parts:

Part Source What it does
NPC actions hm3actoractions.h eight ZLnkAction classes created by ZHM3Actor::CreateLnkAction from ActorActionId: ZHM3ActorPunch, ZHM3ActorActionPushed, ZHM3ActorStrangleInElevator, ZHM3ActorBite, ZHM3WardenRemovesCIAAgent, ZHM3ActorRepairUtilBox, ZHM3ActorMoveChair, ZHM3ActorAttackWithStunGun. Other ids fall through to ZLNKWHANDS::CreateLnkAction (item handling)
Movesets hm3actormovesets.cpp builds the 15 shared Locomotion::ZSets and registers the door and elevator states (below)
Properties hm3actorproperties.h ZHM3ActorProperties (0x24 bytes): m_prtKnownHitmanAses, m_fRecognizeSpeedKnown, m_iForgetTime, m_fInspectionDistMin, m_fInspectionDistMax, read by the disguise check
Accessories hm3accessory.h ZHM3AccessoryGeom, a ZLNKOBJ attached to a bone, with m_bOnHitman. 47 carries up to three (m_aAccessoryGeoms[3]) and moves them in ZHitman3::ChangeIntoNewClothes
Dialog hm3dialogcontrol.cpp ZHM3DialogControl plays a two-actor conversation. GenerateLocaleName builds each line's name as "%s%.2d%s" (prefix, line number, speaker postfix), and Next gives the line to whichever speaker has a locale resource of that name, stopping when neither has
Communication actorcommunication.cpp ZActorCommunication (below)
Script interface src/hitman3/interfaces/hm3actor.si.cpp 198 Zhm3Actor__* functions the scripts call, beside 51 Zactor__* in src/engine/ScriptInterfaces/actor.si.cpp

The player

ZHitman3 uses multiple inheritance. The base offsets come from analysis/recovered-types.h, which records them in bits (0x38c0 is byte 0x718):

class ZHitman3 : public ZPlayer, public ZHM3InputControl, public ZHM3MovementControl, public ZHM3WeaponsControl, public ZHM3Inventory, public ZHM3ActionControl {
Offset Part Size Contents
0x000 ZPlayer 0x718 status word m_CurrentStatus at 0x388, m_Movements[32] at 0x580, m_pActiveMovement at 0x604
0x718 ZHM3InputControl 0x1c this frame's button states
0x734 ZHM3MovementControl 0x48 turn and move speed, the four control schemes
0x77c ZHM3WeaponsControl 0x50 fire and reload state, magazine counts, aim collision
0x7cc ZHM3Inventory 0xc the inventory
0x7d8 ZHM3ActionControl 0x324 the action menu (EHM3Action, 60 values from eNone to eAThrowChute)
0xafc ZHitman3 members to 0x1400 camera, auto-aim, 203 Animation::Header * members (some of them arrays), hit points (m_fHitpoints 0xf54, m_fHitpointsMax 0xf58), m_pCurrentSuit 0xf80, zones, death sequence

Status. m_CurrentStatus holds the PLAYER_STATUS_* bits of src/engine/geomsextend/zplayer.h: walking 0x1, running 0x2, backward 0x4, strafing 0x8/0x10, turning 0x20 to 0x100, controls locked 0x200, sneaking 0x400, dragging a body 0x800, leaning 0x2000 to 0x10000, kill line-up 0x20000, dead 0x40000, attached to a guide 0x400000, stairs 0x10000000 to 0x40000000. m_CurrentStatusExtended holds the STATUSEXT_* bits in zhitman3.h (crouching 0x20, falling 0x400, human shield 0x2000, in a closet 0x40000 and others). The debug types have no enum for either word, so these names are the recovery's, read off the functions that test each bit (IsWalking, IsRunning, IsSneaking, IsDead, ZPlayer::DragBody).

Movement. 47 moves through ZMovementBase objects, one active at a time. ZPlayer::CreateMovements registers the engine's (MC_ANIMATION, MC_STAND, MC_BASEMOVE, MC_GUIDE), and ZHitman3::CreateMovements adds 17 more, one for each ZHM3MOVEMENTS number from HM3MC_FALL (7) to HM3MC_M13TABLE (24) except HM3MC_CARRYBODY (16). They cover the human shield, wall climbing and hugging, ladders, drain pipes, windows, balconies, death, cut sequences and dialog (src/hitman3/characters/zhitman3movement.h).

Controls. ZHM3InputControl (zhitman3inputcontrol.cpp) reads 22 named action handles such as Action::ZHandle a_crouch("CrouchSneak"), "FireWeapon", "DropBody" and "UseAction" into its bit fields each frame. ZHM3MovementControl turns them into motion through one of four control classes in zhitman3movementcontrol.h: ZHitman3ControlConsole, ZHitman3ControlConsoleStrafe, ZHitman3ControlMouse and ZHitman3ControlMouseStrafe. The worked match of their Update functions is in ../development/fixes/sqrt-abs-register-order.md.

Weapons and items. Items are ZHM3Item, ZHM3ItemWeapon, ZHM3ItemContainer, ZHM3ItemAmmo and their templates (hm3items.h); EHM3ItemType in hm3itemtype.h names 320 item types (eHM3NumItems is 321). 47's own actions are ZHitmanAction and ZLnkAction subclasses in zhitman3actions.h: 70 classes, among them ZHitmanActionStrangulate, ZHitmanActionPickLock, ZHitmanActionHumanShield and one ZHitmanActionChargeHit* per melee weapon. HitmanActionId lists 65 ids (0x10000001 and up).

Disguises. An outfit is a ZHM3HmAs group (src/hitman3/background/hm3hmas.h) with m_eDressQuality (eQualityBad to eQualityHitman), the weapons it may carry openly (m_rtWeaponsAllowed), its allowed security zones and m_iDisguiseGroup. ZHitman3::ClassInit sets both m_pCurrentSuit and m_pHMAsHM (47's own suit) to the scene's HitmanTemplate. CanChangeClothes takes an outfit from a dead or unconscious ZHM3Actor (its m_rHitmanAs) or a ZHM3ClothBundle, and refuses one from 47's current disguise group. ChangeIntoNewClothes swaps the mesh, the accessories and the footwear sound material, and tells the level control (OnHitmanChangeClothes).

How NPCs perceive 47

Vision. ZCheckVisible (src/engine/eventsbase/checkvisible.cpp) keeps up to 200 seers and 200 seeables in a grid of 16 by 1 by 16 cells. FrameUpdate checks at most 20 seers per frame: it limits the cells by vision range and angle, tests each cell against the seer's cone, and sends ZMSG_ObjectVisible and ZMSG_ObjectNotVisible to the seer when a seeable enters or leaves its view. ZHM3Actor::SetVisionRangeAndFOV writes the seer's range and FOV.

What the actor sees. Each frame ZHitman3::UpdateObjectVisibleFlags publishes what 47 is doing in m_iObjectVisibleFlags[2]: VISIBLE_* bits (sneaking, crouching, running, dragging a body, lockpicking, climbing, in a closet, weapons not allowed by the disguise, in a forbidden zone) and ATTACK_* bits (firing, injecting, strangling, punching, pushing, throwing). Like the status words, these flag names are the recovery's. ZHM3Actor::OnObjectVisible copies the flags into the message and adds its own conclusions, which ClassFrameUpdate keeps up to date:

Conclusion Rule (hm3actor.cpp)
VISIBLE_HitmanIsNear 47 within 300 units
VISIBLE_RunningTooLong seen running longer than 1.5 s within 300 units, or 6 s farther away
VISIBLE_StealthyTooLong seen sneaking or crouching longer than 3 s
VISIBLE_VisiblyArmed checked only while VISIBLE_WeaponsNotAllowed is set. A one-handed weapon counts within 500 units times the difficulty's civilian or guard multiplier, a two-handed one within 3,000, a hideable one within 500 at most. An untightened fibre wire never counts
VISIBLE_VisiblyLockpicking lockpicking within 3,000 units of an enemy, target, optional target or policeman, 800 of anyone else

Seeing 47 at all sets ZHM3LevelControl::m_stats.bGhostFailed when the seer is an enemy, target, optional target or policeman. If the flags include dragging, attacking, lockpicking, a human shield or a visible weapon, the actor is added as a witness (AddWitness). An actor that is dead, unconscious or being killed is seen as VISIBLE_Body plus body flags, and weapons and items as VISIBLE_Weapon and VISIBLE_Item.

Hearing. CEVENTCONTROLLER::NotifyActors (src/engine/audio/soundengine/eventcontroller.cpp) traces sounds through the sound graph, using the actor's m_pAudibleRoomList, and calls ZActor::OnSound with the events the actor hears. ZHM3Actor::OnSound turns 18 audio events (eAudioEvent_SHOT, eAudioEvent_FOOTSTEP, eAudioEvent_DOOR and others) into 16 ePerceptionType_Sound_* perceptions at eInterestlevel_Neutral.

Disguise inspection. ZHM3Actor::OnObjectVisible calls ZHitman3::OnStartInspection, which hands the seer to ZClothTracker (src/hitman3/background/clothtracker.cpp). Every 0.1 seconds the tracker lowers each inspecting actor's fQuality (1.0 for a fresh outfit, 0.5 for a blown one):

  • The base speed is 0.02, times the notoriety multiplier (1.1 to 1.4 above a notoriety of 30), times the outfit's factor: 0.7 for eQualityBad, 0.3 eQualityGood, 0.1 eQualitySuper, 0 eQualityPerfect, 0.5 eQualityHitman. 47's own suit in eZone1 counts 0. An actor whose ZHM3ActorProperties lists the outfit as known uses m_fRecognizeSpeedKnown instead.
  • Distance scales it, through GetInspectionMultiplier or a falloff between 100 and 500 units times the difficulty and notoriety distance multipliers. In zone eZoneMegaForbidden the speed is 100. The result is multiplied by the difficulty's speed multiplier before it is subtracted.
  • When fQuality falls below 0.5 the actor gets an ePerceptionType_HitmanVisible perception at eInterestlevel_Strange with ePerceptionInfo_DISGUISESUSPECTED. At 0 the outfit is blown, and every actor inspecting it gets ePerceptionType_CoverBlown at eInterestlevel_Threatening. The first time an outfit is blown, the seer is added as a witness, and m_stats.lCoverBlown grows when the outfit is not eQualityHitman.
  • An actor that stops seeing 47 recovers fQuality at 0.1 / m_iForgetTime per step (a difficulty rate without actor properties) and is dropped once it is back to full.

The perception message. All of these arrive as MSG_Perception (0x91f) carrying an sPerception (src/external/j/jamout_hitman3/scriptc/headers/messages/perception.h): a type out of 45 ePerceptionType values, distance, position, source, an eInterestlevel, the dress worn, time, and one of 27 ePerceptionInfo values.

enum _eInterestlevel {
    eInterestlevel_Neutral = 0,
    eInterestlevel_Interesting = 1,
    eInterestlevel_Strange = 2,
    eInterestlevel_Suspicious = 3,
    eInterestlevel_Threatening = 4,
    eInterestlevel_Dangerous = 5
};

Tension. ZHM3Actor::SetTension maps an interest level to m_fTension: 0 for neutral and interesting, 30 strange, 60 suspicious, 100 threatening and dangerous. At 30 or more the actor is scared (m_bIsScared) and, once its weapon exists, switches to the alert vision range and FOV. A value above 10 turns decay off. Scripts raise tension with Zhm3Actor__Increasetension (capped at 100) and let it decay with Zhm3Actor__Releasetension, after which ClassFrameUpdate multiplies it by 0.9998 each frame and restores the relaxed vision below 30.

From perception to behaviour

The perception goes to the actor's script. The shared scripts in src/scripts/Alllevels/ derive from each other in this order: Perceptionconverter, Basefunc, Human, Civilian, Guard, Cameraguard. Armed derives from Civilian and Armedbartender from Armed; Dog derives from Basefunc. The base of them all receives the message in Alllevels_Perceptionconverter_on_perception, and its functions classify, filter and dispatch it (..._ClassifyVisualPerception, ..._FilterPerceptionEvent, ..._DispatchPerceptionToHandler). Their state controllers:

Script State controllers (root included) Examples
Human 64 Alllevels_Human_SearchForTargetState, _EngageTargetState, _TakeCoverState, _FleeFromThreatState, _UnconsciousState
Civilian 19 Alllevels_Civilian_PerceptionReactionState, _ThreatReactionState, _CallForHelpState, _FollowBloodTrailState
Guard 23 Alllevels_Guard_ReactToPerceptionState, _ConfrontIntruderState, _FriskHitmanState, _DragBodyToBagState, _QuartersIdleState
Armed 5 Alllevels_Armed_HolsterAfterCombatState, _PickUpDroppedWeaponState

The disc keeps no names for script states or functions. The project named them for what the actor does (scripts/scene-scripts.md). Three engine objects coordinate actors:

  • ZFightController (fightcontroller.cpp) keeps up to 50 sAttacker entries, each ENGAGED, HUNTING or STANDBY. BalanceCombatStrength divides the engaged actors' summed GetCombatStrength (weapon strength times health) by the target's and picks an eAttackStyle: NORMAL from 1.0 up, DEFENSIVE above 0.5, RETREAT below. eAttackStyle_AGGRESIVE is only the value TimeUpdate resets to when nobody is engaged. If all non-standby attackers together are below five times the target's strength, it calls RequestAssistance at most every 5 seconds, which wakes standby actors and then radios for the missing strength.
  • ZActorCommunication (actorcommunication.cpp) is the radio: up to 100 users (MAX_RADIO_USERS) on channels. SendRadioMessageToNeededForce messages the closest users one by one until their combat strength covers the request; there are also closest-N, ranged, global and in-box sends.
  • ZGuardQuarterController (guardquartercontroller.cpp) registers up to 32 guards and offers sGQCTasks (eGQCTaskType_PickUpWeapon, _PickUpDeadBody, _PickUpSuitcase) to each free guard in turn until one accepts. Its ZWeaponStorage holds 28 weapons, 14 rifles and 14 pistols.

Locomotion and movesets

An actor's movement is a small state machine. The engine fills Locomotion::ZStates::m_States[20] with six states, and ZHM3ActorMovesets::Initialize registers four game states and maps pathfinder link actions onto them:

Value State Class Path action
0 eFollowPath ZFollowPath PWA_DEFAULT
1 eFullBody ZFullBody
2 eDead ZDead
3 eWounded ZWounded
4 eSpecialLink ZSpecialLink every other action by default
5 eIdle ZIdle
6 eUseDoor ZUseDoor PWA_DOOR
7 eEnterElevator ZEnterElevator PWA_ENTERELEVATOR
8 eExitElevator ZExitElevator PWA_EXITELEVATOR
9 eTravelInElevator ZTravelInElevator PWA_RAPEL

ZActor::PreparePath cuts a path into m_ProgramQue entries through m_PathAction2Program. A state is a ZState with TakeControl, ReleaseControl, UpdatePosition, ApproachSpeed, Interruptable and Breakable; CheckForPathProgramSwitch hands control to the next entry when the current state releases it. Inside a state, ZLocomotionState::ELocomotionState (LOCOSTATE_DISABLED, _STAND, _ACTIVEANIM, _MANUALANIM, _MOVEFORWARD) says what the body is doing.

A moveset is a Locomotion::ZSet of up to 10 entries (looping animations with speed and distance thresholds) and 20 transitions (start, stop and turn animations between entries). ZHM3ActorMovesets::Initialize builds all 15 from animation template names:

standardMoveSet.m_Entries[iEntries++].Init(templateNames, 1.0f, 0.0f, 0.0f, 100000.0f, "/Movement/Walk/Forward");
standardMoveSet.m_Transitions[iTrans++].Init(templateNames, 0, 1, "/Movement/Walk/Start", 0.0f, 1.0f)->SetManualAnimStart(0.41666663f);
# Script name (eMoveSet_*) Entries Transitions Turn speed
0 NORMAL 7 18 8
1 SLOW 4 2 8
2 DRUNK 2 1 8
3 DOG 3 0 12
4 RAT 3 0 20
5 DRAG 2 0 8
6 JOGG 7 3 12
7 DRILL 7 3 12
8 TOURGUIDE 7 18 8
9 SNEAK 2 0 8
10 CRATE 2 2 12
11 BELLYDANCE 2 1 8
12 M11ASSASSINCARTWHEELLEFT 2 0 8
13 M11ASSASSINCARTWHEELRIGHT 2 0 8
14 M11ASSASSINFASTRUN 2 0 8

That is 54 entries and 48 transitions. TOURGUIDE is a copy of NORMAL with its first transition replaced by /_Special/TouristGuideWalk. Scripts pick a set with Zactor__Setmoveset, which calls ZActor::SetMoveSet; the names come from src/engine/ScriptInterfaces/moveset.h.

Animation

The animation runtime is src/engine/animation/animation.cpp; the data it reads is described in formats/anm.md. Each ZLNKOBJ has an Animation::Model with four ActiveAnimation slots (m_ActiveAnims[4]) and seven IK targets (eLookAt, eAim, eSpineLock, both hands, both ankles). An ActiveAnimation holds its Header, frame range, blend, speed (deltaframe) and a mode built from EActiveAnimModes: a play mode (eLoop, eFrame, eOnce) plus bits such as eMirror, eMoveGround, eFullBody, eAimTarget, ePaused and a priority.

ZLNKOBJ::UpdateAnimationsAndGroundLink advances every slot by deltaframe times the frame time. A looping animation wraps and restarts its sound. A one-shot calls AnimEnd, and sends ZMSG_LnkAnimEnd with its sequenceId when the object's m_Status is 5; ZHM3Actor::ClassCommand uses that message to clear its death animation. The ground animation (GetGroundAnimation, in a mode with eMoveGround or eAnimDest) gives the frame's root motion through Header::GetGround, written into the m_Ground bone; with none, m_Ground is reset. On a path, Locomotion::ZFollowPath::UpdatePosition passes the boid's tracker position to ZActor::LocoFromMotion as the new position, and the locomotion code chooses moveset entries and transitions for the move (GetBestFitAnimation, GetBestFitTransition).

The body is split into nine state groups (EStates: torso, spine, head, two legs, two arms, two hands), and ZHumanState::Blend mixes two states under a mask of these groups (EStateMask). Upper-body animations carry HEADERMASK_UpperBody. EBoneID names 56 skeleton bones, from Pelvis to RThumb2, and four more static ones: Ground, eCamera, eLHandAttacher and eRHandAttacher. 47's animation collection comes from a ZHitmanAnim object, whose PostLoad passes its m_pHMAnimFileName to SetAnimCollectionProperty (src/hitman3/characters/hitmananim.cpp).

The pathfinder is PF4RunTime::ZData (src/engine/pathfinder4/pf4runtime.cpp), behind the abstract PF4::ZInterface (pf4interface.h: FindPath, MapLocation, AddObstacle, CloseLinks, OpenLinks and others). Its data comes from the .GMS (formats/gms.md). Each graph locates a point in plan by walking a split tree, a 2D BSP of line equations (ZGraph::GetComponent):

int side = data->m_pSplitTrees[treeIndex].eqn[0] * x + data->m_pSplitTrees[treeIndex].eqn[1] * y >= data->m_pSplitTrees[treeIndex].eqn[2];

A leaf names a component. Nodes are joined by ZLinks that carry a cost, a type (eExit or eAction), an action number, a key mask and a door controller (m_rDoorController). Movable obstacles are PF4::ZDynamicObstacles, convex hulls of up to 10 points. ZEntityTracker (tracker.h) puts actors and the hero into the graph as ZMetaNodes and finds the closest ones. Within one graph each (x, z) maps to one component, so walkable floors cannot overlap in plan; ../modding/levels/knowledge-base.md and ../modding/levels/new-scene.md cover building this data for new levels.

Crowds

Every ZActor and ZPlayer has a ZHumanBoid (m_pkBoid, src/engine/boids/clients/human.cpp). ZBoidSystem::FrameUpdate (src/engine/boids/boidsystem/boidsystem.cpp) calls every boid's FrameUpdate with the whole boid list, then every boid's Move; ZBoid declares the avoidance as AvoidBoids and HardAvoidBoids. A boid is in one EBoidState (eFollowPath, eControlled, eSoftObstacle, eHardObstacle, ePassivePushable, eInActive, eHero), and its m_Mask marks it pushable, a pusher or being pushed. The actor takes its x and z from the boid's tracker position.

Background crowds use a separate system. ZHFlow (src/hitman3/background/humanflow.cpp) moves many ZFlowInstances over a flow data block of four planes (distance, collision bits, light, direction) plus an obstacle list. Each instance is in a ZHFlowState::STATE (STAND, WALK, BALCONYDANCE, PANIC, PARADE, DEAD, DRINK), and ZMardiGrassHFlow and ZHFlowM11 are the level-specific variants.

Numbers

What Count Source
Classes declared in src/hitman3/characters/ 157 headers
Functions in src/hitman3/characters/*.cpp 2,639 address comments
Functions in zactor.cpp / hm3actor.cpp / zhitman3.cpp 231 / 225 / 397 address comments
Script functions on actors 198 Zhm3Actor__, 51 Zactor__, 31 Zhm3Boid__ *.si.cpp
Movesets, entries, transitions 15, 54, 48 hm3actormovesets.cpp
Locomotion state slots, used 20, 10 zactor.cpp, hm3actormovesets.cpp
47's movements 4 engine + 17 game zplayer.cpp, zhitman3.cpp
47's action classes, NPC action classes 70, 8 zhitman3actions.h, hm3actoractions.h
Action-menu entries (EHM3Action) 60 zhitman3actioncontrol.h
Item types 320 hm3itemtype.h
Perception types, perception infos, interest levels 45, 27, 6 perception.h, interestlevel.h
Seers, seeables, seers checked per frame 200, 200, 20 checkvisible.h, checkvisible.cpp
Fight controller attackers, radio users 50, 100 fightcontroller.h, actorcommunication.h