Missions, scenes and scripts¶
This page describes how Glacier builds and runs a Blood Money mission: the levels on the disc and the table that chains their scenes, the level controller every mission scene creates, the order in which a scene is loaded and released, how a level's script module is attached and how its scripts call the engine, and the mission state that ends in the rating, the newspaper and the profile. It comes from the decompiled C++ in src/, which compiles back into the PAL executable (SLES-53028) byte for byte, and from the archives on the PAL disc.
- For the members of a scene archive and their load order, see scene archives; for the
.PRPstream that creates the objects, properties. - For the script module file, see script modules; for the decompiled scripts, scene scripts, the script SDK, script thunks and payload layouts.
- For startup, the frame loop and the restart between scenes, see engine core; for geoms, controllers and class info, objects; for messages, events; for actors and 47, characters.
- For missions written in Lua, see mission scripts, front-end scenes of a custom level, the knowledge base and
obm.missionandobm.ratingin the API.
The levels¶
ZLevelLinking::s_asLevelname[13][8] (src/hitman3/levelcontrol/levellinking.cpp) is the campaign. The row is the level number that the profile, the statistics and the menus use; the columns are indexed by ELevelNameType (NAME 0, UNLOCKS 1, INTERVIEW 2, BRIEFING 3, WEAPONS 4, LOAD 5, NEWSPAPERSTATS 6, MISSION_DEBRIEFING 7):
const char *ZLevelLinking::s_asLevelname[13][8] = {
{ "M00", "", "M00/M00_Intro", "", "", "", "1", "" },
{ "M01", "M03", "M01/M01_Premission", "1", "1", "", "1", "1" },
{ "M03", "M04", "M03/M03_Premission", "1", "1", "", "1", "1" },
...
{ "M13", "", "M13/M13_Intro", "", "", "", "", "" }
};
| Level | Name | Title | Scenes on the disc | Controller (size) | Scripts | Script heap |
|---|---|---|---|---|---|---|
| 0 | M00 | Death of a Showman | M00_intro, M00_main, M00_news, M00_albino |
ZHM3LevelControlM00 (0x6b8) |
47 | 0x1b800 |
| 1 | M01 | A Vintage Year | M01_premission, M01_main, M01_postmission, M01_news |
ZHM3LevelControlM01 (0x5ec) |
52 | 0x1b800 |
| 2 | M03 | Curtains Down | the same four for M03 | ZHM3LevelControlM03 (0x6e0) |
56 | 0x1f400 |
| 3 | M04 | Flatline | the same four | ZHM3LevelControlM04 (0x77c) |
46 | 0x19000 |
| 4 | M05 | A New Life | the same four | ZHM3LevelControlM05 (0x73c) |
42 | 0x14000 |
| 5 | M06 | The Murder of Crows | the same four | ZHM3LevelControlM06 (0x88c) |
55 | 0x2d000 |
| 6 | M02 | You Better Watch Out... | the same four | ZHM3LevelControlM02 (0x664) |
57 | 0x25800 |
| 7 | M08 | Death on the Mississippi | the same four | ZHM3LevelControlM08 (0x664) |
55 | 0x32000 |
| 8 | M09 | Till Death Do Us Part | the same four | ZHM3LevelControlM09 (0x65c) |
50 | 0x23000 |
| 9 | M10 | A House of Cards | the same four | ZHM3LevelControlM10 (0x604) |
75 | 0x2f800 |
| 10 | M11 | A Dance with the Devil | the same four | ZHM3LevelControlM11 (0x6c0) |
58 | 0x26800 |
| 11 | M12 | Amendment XXV | the same four | ZHM3LevelControlM12 (0x62c) |
60 | 0x1d800 |
| 12 | M13 | Requiem | M13_intro, M13_main, M13_news |
ZHM3LevelControlM13 (0x668) |
26 | 0x32000 |
| none | hideout | Hideout | hideout_main |
ZHM3LevelControlHideout (0x618) |
14 | 0x19000 |
| none | M07 | none | none | ZHM3LevelControlM07 (0x5e0) |
no module | none |
Titles are AllLevels/Interface/LevelNames/<name> in the main menu scene's .LOC, shown here in title case. Every level folder also holds Loader_Sequence, the loading-screen scene. Sizes are from analysis/recovered-types.h. Scripts counts the named scripts in src/scripts/<LEVEL>/ (every .c file except module-support.c). The script heap is what GetLevelScriptExtraSize (src/hitman3/hitman3/_ps2/startup.cpp) returns for the module name; the port allocates twice that.
Column 1 chains the campaign. CompleteCurrentLevel sets the completed bit of the current row, sets the unlocked bit of every row named in its column 1 (M03 for M01, M02 for M06, M08 for M02), stores lLastCompletedLevel, and advances lCurrentLevel, from 12 back to 1. GetNextSceneName turns the row and the step nextSceneNameType into the next scene's name; front-end-scenes.md walks through the steps. M00 and M13 start with their _Intro scene from column 2 and have no briefing or debriefing scene.
The hideout has no row. It is loaded by name, HideOut/HideOut_Main: by ZLevelList::Click for the list's first entry, and by LoadNextScene for NextScene while sProfileHeader::bNextSceneHideout is set, which CompleteCurrentLevel does after level 0 outside the demo build. ZHM3LevelControlM07 is registered as LevelControlM07 and completes its mission once five actors whose groups are named Gambler, Negotiator, CrabGangBoss, Messenger and Pilot are dead, but the PAL disc has no M07 scene or script module, and its SetCurrentLevel("M07") finds no row.
The other scenes:
| Scene | What loads it |
|---|---|
bootmenu |
the engine at boot: DefaultScene=bootmenu.gms in the disc's MAIN.INI (engine core) |
attractmode |
DemoCallback (src/engine/system/_ps2/sysinterfaceps2.cpp) after DemoTimeOut (120,000 ms in MAIN.INI) without input, on scenes whose name contains hitmanbl |
HitmanBloodMoney |
the main menu. ZHM3GameData::IsFrontEnd is true only here, and LoadGameFailureScene returns it. GetNextSceneName gives it once level 12 is completed, and ZHM3LevelControlHideout::MissionCompleted when no game is in progress |
saveandcontinue |
ZStatisticsTest::FrameUpdate when the player leaves a newspaper, and the M00_SAVE_AND_CONTINUE step |
M00/M00_albino |
ZStatisticsTest::FrameUpdate after M00's newspaper, in place of saveandcontinue |
alllevels/errormessages |
LoadAlwaysGFX (src/engine/startup/_ps2/zerrormessages.cpp) mounts the archive and keeps a texture from it |
<level>/Loader_Sequence |
the loading-screen player while a scene loads (scene.md) |
The code also names scenes the PAL disc does not have: IntroMovie (ZLevelLinking::szIntroMovie), premission (szWeaponFileName, the WEAPONS step) and m00/postdemomovie (demo build only).
Level controllers¶
Each _main scene and the hideout has a level-control object, a controller of class LevelControlM00 to LevelControlM13 or LevelControlHideout. The base ZHM3LevelControl (src/hitman3/levelcontrol/levelcontrolbase.cpp, a CBaseEvent<ZBoxPrimitive> of 0x5d8 bytes) has no factory producer. The 15 subclasses register ZBoxPrimitive_LevelControl<X> class infos with the ROUTCASE_FrameUpdate, ROUTCASE_Command and ROUTCASE_FrameUpdateWhenPaused route cases. The constructor creates the ZMusicController and calls GetHM3GameData()->SetLevelControl(this); the rest of the game reaches the controller through GetHM3GameData()->GetLevelControl().
| Phase | What ZHM3LevelControl does |
|---|---|
Init |
MusicInit, clears the static m_stats, gives each syringe type two uses |
Init2 |
registers its audio events, SetMaxFrameInterval(2), subscribes itself to 47's change of clothes |
PostInit2 |
records m_bCurrentLevelCompletedBefore. Outside a loaded game, every level except M00 starts behind filter 3 of InventoryPFCollection and fades it out with the OSD hidden, m_BeginningItems go into 47's inventory (a large weapon to the weapon storage if there is one, otherwise the first to his right hand), and custom weapons and actors are counted (CalcActorCount). Then the play-through notoriety is rebuilt |
FrameUpdate |
runs the post-filter fade. Fails the mission 7 s (times the time multiplier) after m_fHitmanDiedAt. The CompleteLevel debug bind (shift and C, with cheats enabled) completes objectives 1 to 6 and calls MissionCompleted2. Enters the music controller's action mode at tension 91 or more. Five seconds in, shows notoriety on the OSD |
Command |
StealTape clears lCaughtOnTape; every message goes on to the music controller |
End |
deletes the music controller |
After the destructor, the header declares 65 virtual functions, from MusicInit to OnHitmanHideInCloset. Game code calls them when something happens (ZHM3Actor::Die calls CharacterKilled, ZHitman3::Die calls HitmanDied), the base versions are empty or return a default, and each mission overrides the ones it needs:
virtual void CharacterKilled(REF rCharacter);
virtual void HitmanPickupItem(ZItem *pItem);
virtual void MissionFailed(const char *pszReason);
virtual void MissionCompleted();
virtual void MissionCompleted2();
virtual void CompleteObjective(int32 iObjective, bool bTickoffMark);
virtual bool IsHitmanAllowedHere(ESecurityZone eZone, ZHM3HmAs *pCurrentSuit, ZGEOM *pHeadWear, ZItem *pItemLeft, ZItem *pItemRight);
| Offset | Field | Use |
|---|---|---|
0x030 |
float m_fHitmanDiedAt |
set by ZHitman3::Die; starts the fail timer |
0x034 |
ZMusicController *m_pMusicController |
the mission's music |
0x068 |
ZIntHash<uint32> m_WeaponsUsedToKill |
kills per weapon template (WeaponUsed) |
0x088 |
ZIntHash<uint32> m_WeaponsFired |
shots per weapon template (IncShotCount) |
0x0ac |
REF m_pDisguisesUsed[64] |
disguises worn |
0x1bc |
REF m_arTargets[6] |
targets by number (SetTargetNum, GetTargetNum) |
0x1d4 |
REF m_arTargetsKilledWith[6] |
the weapon each target died by |
0x1ec |
REFTAB m_HarmedCharacters |
actors 47 wounded |
0x2c4 |
ZHitmanWeaponStorage *m_pNormalWeaponStorage |
the weapon storage, emptied into the profile at the end |
0x31c |
REFTAB32 m_BeginningItems |
the items 47 starts with |
0x474 |
REFTAB32 m_rtWitnesses |
witnesses (AddWitness) |
0x524 |
REFTAB32 m_rtSuitcaseBoxes |
where a suitcase may be put down |
Every mission controller's Init sets up a profile named SingleSceneRun at difficulty 0 when no game is in progress, then calls SetCurrentLevel with its own name, which also resets nextSceneNameType to LLNONE and lLastCompletedLevel to -1. What each adds:
| Class | Adds |
|---|---|
ZHM3LevelControlM00 |
tutorial hints shown by name (DisplayTutorial("H13_PickUpPistol", ...)) on ShowTutorial and ShowHint, kills recognised by the victim's group name (Tester01, PsychoBob, MrSwingKing_01), the burning lawyer (BurnLawyer) and the gasoline emitter |
ZHM3LevelControlM01 |
cello music (InitCelloMusic, PreventCelloFromPlaying); ZMSG_CutSequenceEnd (0x89c) calls MissionCompleted |
ZHM3LevelControlM02 |
the jacuzzi's pathfinder cut-out, the aphrodisiac and champagne messages, the helipad and pier exit boxes, CheckForObjectives |
ZHM3LevelControlM03 |
the rats (m_rtFightRats, m_rtPokerRats), the chandelier, Easter, ignored weapons, bombs given to 47 |
ZHM3LevelControlM04 |
the globe and the bed, target map icons and briefing updates, disguise queries (IsHMAsHitman, IsHMasBodyguard), syringe rules, CalculateExtraStats |
ZHM3LevelControlM05 |
guard alert counters against allowed limits (m_iAllowedSuspiciousGuards), extra guards, the garage, the burning wife and the necklace |
ZHM3LevelControlM06 |
club music, the Mardi Gras floats (ZMardiGrassFloat), sniper and meeting state |
ZHM3LevelControlM07 |
the five kill flags; FrameUpdate calls MissionCompleted once all are set |
ZHM3LevelControlM08 |
the river-bank pistons, propellers and death boxes (MoveRiverbanks) |
ZHM3LevelControlM09 |
the groom on the bandstand, alligators, the water box, wedding bells, dancing |
ZHM3LevelControlM10 |
elevator buttons, bombs, the suitcase put-down message, music flags per area (s_Music_InElevator) |
ZHM3LevelControlM11 |
knife throwing and item collision checks, the projector, karaoke, crowd updates |
ZHM3LevelControlM12 |
"high noon" (OnHighNoon, AfterHighNoon), timed object moves, the camera flash |
ZHM3LevelControlM13 |
the podium and trap door (ZPodiumController), 47's revival and heartbeat, the human-shield trigger; MissionCompleted2 clears the suitcase first |
ZHM3LevelControlHideout |
available ammo types, item and custom-weapon checks (CheckItem, CheckCustomWeaponState), the map disabled; MissionCompleted loads the next scene, or HitmanBloodmoney |
Loading a scene¶
ZEngineDataBase::LoadScene (src/engine/enginedata/enginedatabase.cpp) only records the name: ZScene::Load copies it with / turned into \ and sets m_Changing. The change happens at the end of a frame, when MainLoop calls ControlSceneChange, which asks the scene what to do:
EToDo ZScene::GetToDo() const {
if (!m_Changing) {
return TODO_Nothing;
}
return m_Loaded ? (m_SceneName[0] ? TODO_UnloadAndLoad : TODO_Unload) : TODO_Load;
}
For an unload, DoUnloadScene flips and invalidates the screen, mutes the waves, pops the render and sound scenes, clears EngineGeomControl, calls UnloadDoneNotify, resets the pool allocators and puts geoms and events back to STATUS_New. ControlSceneChange then calls NukeAndRestart with the name the ZScene holds (src/engine/startup/_ps2/nukeandrestart.cpp). On the PS2 that call does not return: it destroys the script interfaces, runs EngineStaticNukes and GameStaticNukes (which reset ScriptEngine and ZScriptC), deletes the system interface and restarts the engine with that scene name (engine core).
DoLoadScene first has g_pGameDataFactory->CreateGameData() make a new ZHM3GameData, so nothing in the game data outlives a scene. Progress survives in the global com: ZLevelLinking::WriteGlobals, which SetCurrentLevel, SetStatistics, CompleteCurrentLevel and the other level-linking setters call, stores the whole sProfileHeader (0x5e10 bytes) as the global value dataProfile, and a new ZLevelLinking reads it back in Initialize. DoLoadScene then saves the old scene's values (PushValues), turns the name into m_FileName, mounts the archive, loads the .SUP and runs AllocSequence:
| Step | Call | What happens |
|---|---|---|
| 1 | g_pGameData->OnLevelChangeBegin() |
ZHM3GameData reads the menu XML for the scene, resets input tables, and loads DifficultySettings.xml, Money.xml and Notoriety.xml from the mounted archive |
| 2 | save streams | if a ZLoadGameInfoBase exists, reads the control (0x6400) and data (0xa8400) buffers and sets m_LoadingGame; a read error sets the global bLoadGameFailed |
| 3 | members | .BUF, .PRM, .LOC and the rest in the order scene.md gives |
| 4 | CreateGeoms |
the .PRP: ZDefines into the scene com (ScriptCModule among them), then every geom's properties and controllers; a ScriptC controller attaches the script module here |
| 5 | OnLevelChangeLoadDone |
empty in ZHM3GameData |
| 6 | Init |
Init on geoms and events, then ZHM3GameData::Init; then Init2 the same way |
| 7 | saved game | when loading a game, ZPackedInput exchanges "EngineDataBase" over the new scene |
| 8 | PostInit, PostInit2 |
on geoms and events |
| 9 | OnLevelChangeFinish |
just before it, M00_main, M01_main, M06_main and M11_main disallow dialogs (IsDialogAllowed(false)) unless a game was loaded |
Scene scripts¶
A geom runs a script through a ScriptC controller (ZScriptC, src/engine/eventsbase/scriptc.cpp, 0x38 bytes, route cases FrameUpdate, Command and ScheduleUpdate). Its one property is the script's name (prp.md). ZScriptC::SetName reads ScriptCModule from the scene com and calls ScriptEngine::AttachSceneScripts with ProjectPath() + "scriptcs/_gamerelease/" + module + ".ps2" (the OverrideScriptPath option replaces the directory, DisableScripts skips the step), then FindScript(name).
AttachSceneScripts (src/engine/zstdlib/zscriptc.cpp) loads the module for the first caller only; lScriptLoadedCount counts the others, and every ZScriptC destructor calls DetachSceneScripts, which frees the module with the last one. On the PS2 it reads the image into a 64 KB-aligned block, binds the imports ScriptImports, SF, ISF, fptoui and memset, applies the relocations, gives the script allocator the level's heap and calls every creator's Initialize. script-modules.md has the file layout. In the port, the same function attaches the level's scripts built as native code (native scripts).
ZScriptC::PostLoad then creates the thread. CreateScript allocates a ScriptStateInfo, the root ScriptState, the creator's script and state variable blocks and a LocalVarEntry. PostLoad reads one value per SCRIPTIMPORT entry of the creator's property list (REFs by geom name, strings into a shared string map) and calls the creator's Imports and UnpackResources. In Init2 the controller hands the state to its scheduled event, or removes itself when it has no script.
| Offset | ScriptState field |
Use |
|---|---|---|
0x00 |
void *m_pScriptVariables |
the script's variable block |
0x04 |
const SCRIPTCREATOR *m_pCreator |
the script |
0x08 |
REF m_rThis |
the geom the script runs on |
0x0c |
LocalVarEntry *m_pVariables |
the current function frame |
0x10 |
void *m_pStateVariables |
the state variable block |
0x14 |
const STATECONTROLLER *m_pStateController |
the current state |
0x1c |
const STATECONTROLLER *m_pNextStateController |
a requested state change |
0x22 |
uint16 m_Flags |
SSF_INMESSAGE, SSF_MESSAGECUE, SSF_NOMESSAGES, a 4-bit queued message count |
0x2c |
const SCRIPTCREATOR *m_pMessageHandler |
the creator whose handler runs next |
0x38 |
ZScheduledScript *m_pThreadInfo |
the scheduler thread |
0x3c |
MessageCue *m_pMessageCue |
queued messages |
ZScriptC::SchedUpdate runs the current function controller's entry point. The float it returns is the time to sleep, and negative values are requests to the scheduler (script-modules.md lists them). Messages reach a script through ScriptSendCommand(pGeom, msg, pData) or the service SF.SendScriptCommand, which give them to every event named ScriptC on the geom; SF.SendCommand goes through ZGEOM::SendCommand to every controller (events). ZScriptC::Command hands the message to each thread: to the current state's ProcessMessage, or up the creator chain (m_pParentCreator) to the first creator that has one. A thread flagged SSF_MESSAGECUE queues it instead, up to 15, and skips a duplicate with the same payload. Payload layouts are on payload-layouts.md.
Scripts call the engine through ScriptImports, the 716-entry table void *ScriptInterfaces[716] in src/engine/ScriptInterfaces/scriptinterfaces.h, and through SF, the 27 services of _SCRIPTFUNCTIONS (Sleep, SendCommand, Input, Alloc and the rest). Each interface is a plain C++ function named Group__Function. Object interfaces take the object's REF first (Zcar__Moveto(REF Ref, v3 pos, unsigned char bStopAtDist)); the level-control ones go through GetHM3GameData()->GetLevelControl(). The debug information names an original .si header for each group (z:/code/hitman3/interfaces/hm3levelcontrol.si) but keeps none of its text, so the 35 .si files in src/ are empty scaffolds. The declarations live in <name>.si.h and the functions in <name>.si.cpp beside them:
| Directory | Unit (<name>.si.cpp), prefix and functions |
Total |
|---|---|---|
src/engine/ScriptInterfaces/ |
actor Zactor 51, item Item 44, zgeom Zgeom 27, scene Scene 24, tracklink Zlink 17, math Math 15, sound Audio 11, list Zlist 9, pathfinder Pathfinder 8, engine Engine 7 plus Print, Error, Warning, Zscassert, debugfunctions Debugfunctions 6 plus Addlinedecay, Addvectordecay, istring Istring 3, physics Physics 2 |
230 |
src/hitman3/interfaces/ |
hm3actor Zhm3Actor 198, hm3levelcontrol Silevelcontrol 91, hm3boid Zhm3Boid 31, car Zcar 14, guardquartercontroller Guardquartercontroller 14, m11levelcontrol M11Levelcontrol 13, coverlist Coverlist 13, pathfollower Pathfollower 12, FriskBox Friskbox 12, dialog Dialog 12, hm3Weapon Hm3Weapon 11, fightcontroller Fightcontroller 11, m12levelcontrol M12Levelcontrol 9, m04levelcontrol M04Levelcontrol 8, actorcommunication Actorcommunication 8, hm3gui Hm3Gui 7, usepoint Zusepoint 5, bloodtrail Bloodtrail 4, securitycamera Zhm3Securitycamera 3, m13poscontroller Poscontroller 3, hideoutlevelcontrol Holevelcontrol 3, osd Osd 2, Cigs Cigs 2 |
486 |
The per-mission groups (M04Levelcontrol, M11Levelcontrol, M12Levelcontrol, Holevelcontrol) cast GetLevelControl() to their mission's class. Calling conventions and the port's adapters are on script-thunks.md.
The level-control object carries the C++ controller and a ScriptC. Every module has two level-control scripts, Alllevels_Levelcontrol and the level's own <LEVEL>_<LEVEL>_Levelcontrol derived from it. In M01, ZHM3Actor::Die calls ZHM3LevelControlM01::CharacterKilled, which passes the kill to ZHM3LevelControl::CharacterKilled. That counts it in m_stats by character type and sends CharacterKilled with an SCharacterKilled { REF rActor; } payload to the controller's own geom, where the script takes it (src/scripts/M01/M01_M01_Levelcontrol.c):
REF eliminatedActor = *(const REF *)pData;
if (eliminatedActor == vars->don) {
vars->donKilled = 1;
ScriptImports.Silevelcontrol__Completeobjective(1);
void Silevelcontrol__Completeobjective(int id) {
ZHM3LevelControl *levelControl = GetHM3GameData()->GetLevelControl();
if (levelControl) {
levelControl->CompleteObjective(id, true);
}
}
Mission state¶
Objectives and targets¶
Objectives belong to ZHM3BriefingControl (src/hitman3/levelcontrol/briefingcontrol.cpp, 0x74 bytes), embedded in ZHM3GameData at 0x6878; the level control's objective functions forward to it. Objective n exists when the scene's .LOC has /<level>/MissionObjectives/<n>/Type, and a type starting with T counts as a target (GetNumberOfTargetObjectives). State is one bit per objective in int8 m_lObjectiveCompletedFlags and m_lObjectiveHiddenFlags. Six slots of 128 characters hold replaced objective texts and paths. CompleteObjective with bTickoffMark adds the OSD tick-off mark. HideObjectivesIfAny hides objectives 5 and 6 in M04, 6 in M06 and 4 and 5 in M11 (s_asHiddenObjectives). PlaySpeech plays up to 11 briefing lines, <level>/MissionBriefing/<level>_MB_<nn>D.
Targets are separate: a script registers each with Silevelcontrol__Settargetnum, which fills m_arTargets[n - 1] without a range check. Kills and wounds are counted by the actor's m_eCharacterType, whatever the slots hold.
The end of a mission¶
ZHM3LevelControl::MissionFailed(pszReason) clears the death timer, removes the event camera, stops 47's audio, pauses sound, writes the localised reason into the MissionFailedReason GUI element and opens MissionFailedMenu. 47's death fails the mission with AllLevels/Interface/MissionFailed/HitmanDied once the timer runs out; HitmanDied sends ZMSG_HitmanDied (0x81d) to the scripts of every object in ZLIST::m_TrackLinkObjectsInstance.
MissionCompleted (scripts call it through Silevelcontrol__Missioncompleted) pauses sound, hides the OSD and starts the post-filter fade; at full blend PostFilterFade calls MissionCompleted2. MissionCompleted also calls it at once when a video ended less than 0.5 s before. MissionCompleted2 stops the pad's haptics, empties the weapon storages into the profile, empties 47's inventory (except in M00), fills m_stats (living witnesses, what each target died by, the preferred weapon and its kills, noisy shots, CalculateExtraStats, custom weapons left behind, disguises, time, whether 47 left his suit), computes the rating, money and notoriety, stores the statistics, calls CompleteCurrentLevel, and loads GetNextSceneName() while a game is in progress. On a level completed before, the profile gains the rating money, the objective money minus expenses only where it beats the old result, and the lower of the old and new notoriety; the stored statistics keep the better money and notoriety.
Rating, money and notoriety¶
ZRatingSystem::CalculateRating (src/hitman3/levelcontrol/rating.cpp) weighs each counter through m_afRatingCalcIndex[min(n, 33)] * weight, an index table that rises from 0 to 6.0:
| Score | Counter (weight) |
|---|---|
| noise | lFriskFailed (6), lCoverBlown (6), lBodiesFound (6; on Expert and Professional plus lTargetBodiesFound), lSedatedBodiesFound (6), lWitnesses (8), lCaughtOnTape (10); on Professional 5 each for custom weapons and the suit left on the level |
| violence | lInnocentsKilled (12), lInnocentsWounded (6), lEnemiesKilled (6), lEnemiesWounded (3), lPoliceMenKilled (9), lPoliceMenWounded (5) |
Both are capped at 100. eNoise and eViolence are noise * 0.06 and violence * 0.06 rounded up (0 to 6), and lRatingScore = (100 - noise) * (100 - violence). The rating's name is NewsPaper/Statistics/Rating/<violence>x<noise>, or SpecialRating<n> for one of the 19 special ratings. CalculateSpecialRating gives one when kills with one kind of weapon (or by accident) exceed a share of the level's actors (GetActorCount() times 0.5 to 0.8) and the noise score lies in a set band. Rating money is s_aRatingMoney[eNoise][eViolence], 150,000 at 0 and 0, or the special rating's entry in s_aSpecialRatingMoney. ZMoneySystem adds each completed objective's price from Money.xml and subtracts the expenses (damage control, retrieved weapons, a replacement suit). A profile starts with 75,000 (lMoney = 0x124f8 in ZLevelLinking::Initialize).
ZNotorietySystem::CalculateNotoriety gives 0 on Rookie and in M00. Otherwise it adds CaughtOnTapeDisguised or CaughtOnTapeNotDisguised, Witness1 to Witness4 for the first four witnesses and Witnessx per further witness up to MaxWitnesses<difficulty>, capped at 100, all from Notoriety.xml. ZHM3LevelControl::PostInit2 rebuilds the play-through total from the earlier levels' lNotoriety plus the bribe modifiers.
Difficulty¶
EDifficulty is eROOKIE 0, eNORMAL 1, eEXPERT 2, ePROFESSIONAL 3, held in sProfileHeader::lDifficulty. Each difficulty has its own sHeader, so progress, money and statistics are kept per difficulty. ZHM3DifficultySettings (src/hitman3/hitman3/hm3difficultysettings.cpp) keeps one sDifficultySettings (0xa4 bytes: AI timings, vision and hearing ranges, hit points, prices) per difficulty, starts from SetDefaultValues and reads DifficultySettings.xml, one element per field with Rookie, Normal, Expert and Professional attributes. Scripts read it through Silevelcontrol__Getdifficultysettings. GetNumOfSaveGamesAllowed returns -1 (no limit), 7, 3 and 0 from Rookie to Professional.
Debriefing and newspaper¶
Each _postmission scene's .PRP names PostMissionPF. ZPostMissionPF colours the debriefing camera by the last lRatingScore (9000 when no level is completed): below 4000 it blends in filter 1 of PostMissionPFCollection by 1 - score / 4000, above 6000 filter 0 by (score - 6000) / 4000, and between the two it starts with filter 2. ZNotorietyPapers, named by every _main scene from M01 to M12 and every _postmission scene except M09's, shows the child of its group at index notoriety / 10 − 1 (at most 8) and hides the rest. The menu elements ZLevelPerformanceNoise and ZLevelPerformanceViolence fill lNoise / 10 and lViolence / 10 indicator segments from the last completed level's statistics. Each _news scene runs ZStatisticsTest (src/hitman3/gui/statisticsscreen.cpp), which reads GetLastCompletedLevelStats and fills its pages from NewsPaper/Texts; front-end-scenes.md has the keys.
Progress, saves and checkpoints¶
| Offset | sHeader field (0x16f0 bytes, one per difficulty) |
|---|---|
0x0008 |
int32 lCompletedLevelsFlags, one bit per level |
0x000c |
int32 lUnlockedLevelsFlags |
0x0020 |
int32 lLastCompletedLevel |
0x0024 |
int32 lCurrentLevel |
0x0034 |
uint32 lMoney |
0x0038 |
uint32 lNotoriety |
0x003c |
ELevelNameType nextSceneNameType |
0x0040 |
sStatStruct aStats[13], 0x10c bytes each |
0x0de0 |
sSuitcaseItem aAvailableItems[64] |
0x15e4 |
sStatStruct m_lastCompletedLevelStats |
sProfileHeader adds the profile name, the four headers at 0x40, lSaveID, lDifficulty (0x5c04), bTrainingCompleted, bNextSceneHideout, the button configuration and the options. ZHM3SavePS2 (src/hitman3/gui/saveps2.cpp) writes the profile to the memory card padded to 0x8800 bytes.
A save game is a snapshot of the running scene. ZEngineDataBase::SaveGame serialises "EngineDataBase": the system interface, the sound DLL, the geom buffer, the render DLL, the Root geom tree with every property flagged FILTER_SavedGame, and the game data. The level control adds its weapon hashes and music state when the stream is a saved game, and ZScriptC saves the script memory blocks. ZHM3SavePS2::SaveGame writes SaveGame<slot>.control (padded to 0x6400) and the compressed SaveGame<slot>.data (0xa3000) for one of three slots, updates the slot's game info and saves the profile. Loading sets the two file names on a ZLoadGameInfoPS2 and reloads the current scene (ZEngineDataBase::LoadGame calls LoadScene(GetSceneName())). AllocSequence builds the scene from the disc as usual and exchanges the snapshot over it after Init and Init2, and m_LoadingGame makes objects skip their fresh-start work (ZScriptC::PostLoad creates no thread, ZHM3LevelControl::PostInit2 hands out no starting items).
Checkpoints exist in this build only as stubs. ZGameData::AddGeomToCheckPoint, AddEventToCheckPoint, CheckPointSave and CheckPointLoad are empty and ZHM3GameData does not override them. ZCheckPointBuffer (src/engine/enginedata/checkpointbuffer.cpp) keeps only its reading side. checkpoint.cpp, savegame.cpp and enginedatacommands.cpp exist in the debug record with no functions in the executable.
The front end¶
HitmanBloodMoney is the main menu. Its CMainMenu group controller (src/hitman3/gui/mainmenu.cpp) creates three views (the 3D background, a scope overlay and the logo), picks the background camera from g_iCameraActivationList by the first level not completed, hides each target group whose level (the part of its name after !) is at or before that one, and turns the cameras on once the global bHM3OpenMenuOpenMessageReceived is set. ProfileLoaded repeats this and clears the suitcase. ZHM3MenuElements::ReadXML picks the menu files by scene name, after default.xml:
| Scene name | Menu files |
|---|---|
*postmission* |
postmiss.xml |
*bootmenu* |
boot.xml |
*hitmanbloodmoney.* |
frontend.xml |
*premission* |
premiss.xml, briefing.xml |
*saveandcontinue* |
saveandc.xml |
| any other | briefing.xml, inventor.xml, ingame.xml |
Menus change scene through ZLoadScene elements, whose Scene attribute goes to LoadNextScene (src/hitman3/gui/menu/elements/hm3navigators.cpp): CurrentScene, PreviousScene (the last completed level's _main, or _Intro for levels 0 and 12), NextScene (the hideout when bNextSceneHideout is set, otherwise GetNextSceneName), a level name (made the current level, then handled as NextScene) or any other scene name. ZLevelList lists the hideout first and then the levels. A campaign mission then runs M01/M01_Premission (briefing, targets and loadout), the loading screen, M01/M01_MAIN, M01/M01_postmission, M01/M01_News and saveandcontinue.