Navigation
Browse the developer docs

FH2 Modding Guide · Chapter 7

Hook reference: races, AI and cars

Drivatars, events, the player's car, physics and pedestrians.

By Trinculo54 · from the FH2 Modding Guide · CC BY 4.0 · copied 4 Dec 2026 · read the original, which may be newer

On this page

This chapter lists the game code behind cars, car physics, AI drivers, traffic, race events and the people in the world, organised by what you want to do: move or fly the player's car, make a car a ghost, change how AI drives, add an event, or put a walking person in the world. Each entry says what the game function does, what hooking or calling it gets you, and how sure we are. Read chapter 5 first: everything here assumes its rules (byte checks, chaining, threads, guarded reads).

All addresses are for forza_durango_release_final.exe of 24 Nov 2015 (TimeDateStamp 0x565501ED, SizeOfImage 0x3A18000), image base 0x140000000. game+0xRVA is an offset from the base; the full address is 0x140000000 + RVA. Nothing here works on any other build.

Contents

7.1 How to read the entries

Each hook entry has a heading Name — game+0xRVA and a short table:

  • Kind: function (inline detour, hook_function), call site (hook_call), pointer (vtable slot, hook_pointer), instruction (hook_instruction), direct call (you call it, no hook), or data (a field or file).
  • Byte check: the bytes to compare before you hook or call. Where none is given, read them from the exe on disk yourself. Many sites have a platform name in include/fh2game.h with its bytes (FH2_GAME_..._BYTES); see chapter 2.
  • Status:
    • proven in game: a mod used it in a real game session and it did what is described;
    • offline only: read from the exe (disassembly, an offline harness that maps the real exe) or from game files, never run;
    • design only: a plan built on offline facts;
    • unconfirmed: a reading that two sources give differently, or a guess.

Most addresses in this chapter are offline only. Treat them as a map, not a promise, and byte-check them.

Data first. Much of this system is driven by data: the database (AnthemEvents, AnthemEventRaces, Tracks, Data_Car, temperaments), media\EntityModel\AI\*.xml, the stateflow XML and GameTunableSettings. A row or a file served with set_file / add_sql (platform) or a media folder (Extra Options) is safer than a hook and survives other mods. See chapter 4.

Platform users make every hook below after wait_for_code, with the calls shown in chapter 2. Extra Options plugins have no hook service: bring MinHook, check bytes yourself, and use FH2PluginVehicleUpdate where it is enough (chapter 3, 5.6).

7.2 Find the player's car and follow every car

Every car in the world, the player's, Drivatars, traffic and other players' online, is a ForzaCar (vtable game+0x2C5CB80, RTTI .?AVForzaCar@@). The easiest way to reach them is the per-frame update, which the game calls for each car.

ForzaCar::Update — game+0x2A9400

Addressgame+0x2A9400 / 0x1402A9400; ForzaCar vtable slot 0x80 (slot pointer game+0x2C5CC00)
Kindfunction (hook_function). Platform name FH2_GAME_FORZACAR_UPDATE
What the game doesUpdates one car each frame: physics hand-off, presentation alpha, exhaust effects, and the online anti-griefing rule (it calls ShouldStartGriefing at game+0x2A949F)
What a hook gives youA per-frame callback for every car with the car pointer, on the thread that owns it. Do your work after calling the original, so you see this frame's state
Argumentsuint64 (ForzaCar* car, float dt, float b, uint64 d) in rcx, xmm1, xmm2, r9 (b and d unknown; pass them through)
Byte check48 8B C4 48 89 58 18 57 48 81 EC A0
ConflictsHooked by Do A Barrel Roll, NitroSystem and FH2MP's client. The platform chains them. Extra Options swaps the vtable slot game+0x2C5CC00 (its patch list calls it a relocated vtable pointer whose original is game+0x2A9400), so it leaves the function's bytes alone and an inline hook on the function still runs behind it; it drives its plugins' FH2PluginVehicleUpdate from there. Don't swap the slot yourself
StatusProven in game (Do A Barrel Roll, NitroSystem, FH2MP)

What to do inside it:

  1. Read the kind (car+0x4D08, below) and act only on the cars you want. Kind 0 is the local player.
  2. Skip frames with |dt| >= 0.25 (loading, pauses, the simulation restarting).
  3. Read car+0x4C08 (the dynamics) fresh each frame and check its vtable: the game swaps it when the simulation restarts (game+0xFAABE0).
  4. Wrap everything in a guarded call; on a fault, turn the feature off for the session.
using UpdateFn = uint64_t (*)(void* car, float dt, float b, uint64_t d);
static UpdateFn o_update;

static uint64_t d_update(void* car, float dt, float b, uint64_t d) {
    uint64_t r = o_update(car, dt, b, d);            // the game (and other mods) first
    if (g_on && dt > 0.f && dt < 0.25f) guarded_step(car, dt);   // SEH inside, see 5.8
    return r;
}
// after wait_for_code, with the bytes checked:
api->hook_function(mod, "car update", game + FH2_GAME_FORZACAR_UPDATE,
                   (void*)&d_update, (void**)&o_update);

Extra Options plugins: export FH2PluginVehicleUpdate(const FH2PluginVehicleFrame*). It runs on the local player's car update, before the game's update, never for AI cars, with the car pointer, the pad buttons, dt and an input_enabled flag (0 in menus and loading). It cannot see other cars; for those you need your own hook.

ForzaCar kind — game+0xF62280

Addressgame+0xF62280 / 0x140F62280
Kinddirect call, or function. Platform name FH2_GAME_FORZACAR_KIND
What the game doesint (ForzaCar*): returns car+0x4D08. 0 = local player, 1 = Drivatar (AI), 2 = traffic, 3-5 = the same three in another player's game (online)
What it gives youThe test every car mod needs. Reading car+0x4D08 directly is the same thing
Byte check8B 81 08 4D 00 00 C3 (mov eax,[rcx+4D08h]; ret)
ConflictsCCBR detours it; Director Mode checks it. A memory-only check fails once another mod has hooked it: use the disk fallback (5.4)
StatusProven in game

ForzaCar dynamics — game+0xF605D0

Addressgame+0xF605D0 / 0x140F605D0
Kinddirect call (or read car+0x4C08)
What it doesReturns car+0x4C08, the car's CCarDynamics interface (section 7.3)
Byte check48 8B 81 08 4C 00 00 C3
StatusProven in game

~ForzaCar — game+0x289320

Addressgame+0x289320 / 0x140289320, called from the deleting destructor (vtable slot 0, game+0x28B380)
Kindfunction. Platform name FH2_GAME_FORZACAR_DTOR
What it gives youThe moment to forget anything you keep per car. Drivatars and traffic come and go all the time, and a new car can be built at a freed car's address (5.8)
Byte check48 89 4C 24 08 56 57 41 54 41 56 41 57
ConflictsCCBR checks these bytes in memory (1.0.0)
StatusProven in game (CCBR)

Other useful car reads

WhatWhereStatus
Which car it is (Data_Car.Id, u32)car+0x118. Read sites to byte-check: game+0xF607A2, 0xF7430B, 0xF77CD6, 0xF6760Eproven in game
Car indexcar+0x344offline only
Route position for cameras and race ordercar+0x20 is an ICameraTarget (vtable game+0x2C5CE28): slot 6 (game+0xF646E0) gives the route segment (-1 if none), slot 7 (game+0xF645C0) the TrackMatrixoffline only
Route bindingscar+0x4F70, a shared_ptr<AIOpenWorld::Routing::RouteBindings> (made at game+0xF4EF90)offline only
Driven by a recordingcar+0x50F5 (3 = recording playback), car+0x59BAproven in game (Director Mode)
Storm Island only: a per-wheel average written to [car+0x4F68]+0x38game+0x2AA3FB (cmp with 549 in a function reached from ForzaCar vtable slot 17). Guess: wetness or sprayoffline only

7.3 Fly or move the player's car

The car's physics object is CCarDynamics. car+0x4C08 points at an interface inside it, so its main fields sit at negative offsets from that pointer. There are two vtables, game+0x2EB4BB8 and a ref-counted form game+0x2EB5E18; check for either before you use the pointer.

Use the game's own getters and setters rather than writing memory: they keep the rest of the simulation in step. Do A Barrel Roll flies the car with nothing more than these, called from its ForzaCar::Update hook.

FieldOffset from dynGetter / setterVtable offsetByte check
Position (vec4; centre of mass)dyn-0x390GetPosition game+0x12CD1500x270C5 F8 28 81 70 FC FF FF
Set position(unnamed)0x280read it yourself
Rotation rows right, up, forward (3 x vec4)dyn-0x380game+0x12CBEB00x2E048 8B C2 48 8D 91 80 FC FF FF
Velocity (vec4, m/s)dyn-0x350GetVelocity game+0x12CDCF00x288C5 F8 28 81 B0 FC FF FF
Set velocity (dyn, const float4*)SetVelocity game+0x12E3CF00x290C5 F8 28 02 C5 F8 29 81 B0 FC FF FF
Spin, world (vec4)dyn-0x340GetSpin game+0x12C5C900x2B8C5 F8 28 81 C0 FC FF FF
Set spinSetAngularVelocity game+0x12DD9100x2C048 83 EC 38 C5 F8 28 02 48 8D 91 E0 FC FF FF
Engine speed, redlinedyn+0x148, dyn+0x1CCgame+0x12C8050
Gear (u8)dyn+0xAA1game+0x12C7CF0
Driver inputsdyn+0xDF8game+0x12CBEF0

Notes:

  • Check the slot in both vtables before calling through it. Do A Barrel Roll checks six slots in each.
  • The setters read 16 aligned bytes: pass alignas(16) float4s and keep w from the game's own value.
  • The car's heading is atan2(forward.x, forward.z); its left side is pos - right * d. World axes: x right, y up, z forward.
  • The position is the centre of mass, which sits List_UpgradeCarBodyWeight.CMHeight above the ground (about 0.28 m on a typical car). To anchor something to the wheels, use the hubs: hub i is at dyn+0x1290 + i*0x4B0 plus the car offset at dyn+0xEF0; wheel radius at dyn+0x1570 + i*0x4B0; wheels 0 and 1 are the fronts. Proven in game.
  • Status of the table: proven in game (Do A Barrel Roll, Director Mode, an on-foot mod), except the set-position slot and the engine/gear/input getters, which are offline only.

Car placement (teleport) — game+0xF713D0

Addressgame+0xF713D0 / 0x140F713D0
Kinddirect call
What it doesPlaces a car at a transform
StatusOffline only (arguments not recorded). For a free-roam car, setting velocity and spin is the proven route

Rolled-over camera rule — game+0x3986A0

Addressgame+0x3986A0 / 0x1403986A0; ForzaMultiCam vtable game+0x2C6C840 slot 80
Kindfunction, or pointer (the slot)
What the game doesuint64 (multicam, float dt). In the hood and bumper cameras (3 and 4), once the roof points less than 0.1 towards the sky, it switches to the chase camera and remembers the one it took in mc+0x2C8 (-1 when none). A second after the roof is above 0.5 it switches back (mc+0x2CC is the timer). The cockpit camera never had the rule
What a hook gives youA rolling or flying car keeps the player's camera. Do A Barrel Roll returns 0 without running the check while flight is on, unless mc+0x2C8 != -1 (then the game's half that gives the view back runs)
Byte check48 8B C4 41 56 48 83 EC 70 48 C7 40 A8 FE FF FF FF, and slot 80 must point here
StatusProven in game. Camera code in general: chapter 8

Game speed — game+0x2F6800

Addressgame+0x2F6800 / 0x1402F6800, CGameManager::SetGameSpeed, vtable slot 17 (slot pointer game+0x2C5F950)
Kinddirect call through the slot
What it doesJumps to game+0xFC7D90, which stores the speed at gm+0x48 and turns the replay to reverse on a sign change. The update game+0xFC8FD0 scales dt by it, clamped to +-0.2 per step. Applies only while gm+0x2C is set and gm+0x37 clear; the unpause ramp at gm+0x70 forces 1.0
What it gives youSlow motion (0.25 works) and a full stop (0). Engine sound is not slowed
StatusProven in game (Director Mode)

Driving a car from a recording

Director Mode drives the player's car from its own recordings through the game's replay playback: StartPlayback game+0x1748390 sets car+0x50F5 = 3; the follow code game+0x277660 keeps the car on the path within the Replay* tolerances in GameTunableSettings.ini. A recording without the game's ghost packet (type 14) rams traffic. Proven in game; the details belong with the camera tools in chapter 8.

7.4 Make a car a ghost, fade it or hide it

A car's collision and see-through alpha come from a request set at car+0x4C58. Each request names a preset from GameTunableSettings\collidablepresets.xml (inside media\GameTunableSettings.zip); the newest request in the list wins. The game uses this for its own ghosts: intersection (collision off, no alpha change), griefing (collision off, alpha 0.5) and the AI's ai_ow. CCBR uses it to make the player a ghost in speed zones.

How CCBR does it (proven in game):

  1. Add a preset with set_file: <preset name="ccbr" collision="off" /> before </carcollidablepresets>. If your copy wasn't read, fall back to the game's intersection preset.
  2. Start: make a handle for your preset name on car+0x4C58 (game+0xF5B420) and register it (game+0xF73080).
  3. End: remove it by name (game+0xF5B890), only if the car is still the player's (vtable and kind 0 both match).
  4. Handles are MSVC std::shared_ptrs: release them as the game does (decrement uses at ctrl+8, then _Destroy, vtable slot 0; decrement weak references at ctrl+0xC, then _Delete_this, slot 1).

Collidable requests: make, add, remove — game+0xF5B420, game+0xF73080, game+0xF5B890

Addressesmake game+0xF5B420 / 0x140F5B420; add game+0xF73080 / 0x140F73080; remove game+0xF5B890 / 0x140F5B890; the set itself from game+0xF60510 / 0x140F60510 (lea rax,[rcx+4C58h]; ret)
Kinddirect calls
Signaturesmake: shared_ptr* (set, shared_ptr* out, const std::string* preset); add: uint8 (set, shared_ptr handle) (takes the handle over; passed by value); remove: uint8 (set, const std::string* preset)
Byte checksmake 48 89 54 24 10 57 48 83 EC 50; add 48 89 54 24 10 56 57 41 56; remove 40 53 48 83 EC 30 4C 8B CA; set 48 8D 81 58 4C 00 00 C3
Platform namesFH2_GAME_COLLIDABLE_REQUESTS_MAKE, _ADD, _REMOVE, FH2_GAME_FORZACAR_REQUESTS
NotesThe strings are MSVC 2012 std::strings built with the game's allocator (chapter 11). Call on a game thread, for example from the car update
StatusProven in game (CCBR)

Apply collidable state — game+0x28D930

Addressgame+0x28D930 / 0x14028D930, ForzaCar vtable slot 0x130
Kindcalled through the vtable; hookable as a pointer
What the game doesWorks out the car's alpha from its requests and hands it to the presentation (car+0x4D38, its slot 0x130 SetAlphaScalar)
Byte check40 53 48 83 EC 20 8B 05 8C 1E 22 03
ConflictsCCBR calls it through the slot, so another mod's slot hook still runs; CCBR logs if the slot no longer holds this address
StatusProven in game

Car alpha — game+0x28C590

Addressgame+0x28C590 / 0x14028C590
Kindfunction. Platform name FH2_GAME_FORZACAR_ALPHA
What the game doesfloat (self, ForzaCar**): the alpha from the newest request (or the distance fade). It feeds SetAlphaScalar from the car update (game+0x2A9400), slot 0x130, and the ghost display game+0x2A5E30
What a hook gives youSee-through other cars. CCBR caps the alpha of kinds 1 and 2 at its OthersAlpha setting during a ghost
Byte check48 8B C4 57 48 81 EC C0 00 00 00 48
StatusProven in game (CCBR)

HideCar — game+0xF649F0

Addressgame+0xF649F0 / 0x140F649F0; ShowCar game+0xF79330
Kindfunction, or direct call. Platform name FH2_GAME_CAR_HIDE
What the game doesClears car+0x50F1 and calls the presentation's slot 0x230. Only the request set's update (game+0xF7B770, call at game+0xF7BBB2) calls it, when the alpha reaches 0
GotchaThe 29 AI cars are a pool the game puts back on the road further ahead. Re-adding the AI's own ai_ow request zeroes its alpha until the next fade update, so the car blinks out for a frame. CCBR holds a visible car's hide for up to 0.15 s; ShowCar undoes a blink itself
Byte check40 53 48 83 EC 20 48 8B D9 C6 81 F1 50 00 00 00
StatusProven in game (CCBR)

Entity events (speed zones and friends) — game+0x190BF90, game+0x190BFD0

Addressessend game+0x190BF90 / 0x14190BF90 (entity, symbol); with data game+0x190BFD0 / 0x14190BFD0 (entity, symbol, data)
Kindfunction hooks (to hear events)
What a hook gives youEvery gameplay event as it is queued. CCBR starts and ends its ghost on these
Byte checks48 83 EC 48 48 8D 05; 40 53 48 83 EC 40 48 8B D9
RecursionA game call made while you handle an event can send another. Guard with a thread-local flag
StatusProven in game (CCBR)

Event symbols are globals; each send site is a lea rdx,[rip+symbol] (48 8D 15). Check that the site still decodes to the symbol you expect.

EventSymbolSent at
ARUI_Trigger_Enteredgame+0x34BFCA0game+0x6B84F2
ARUI_Trigger_Exitedgame+0x34BFB50game+0x6B992A
SpeedTrapActivatedgame+0x34BFDD8game+0x6B8A87 (with data)
SpeedZoneActivatedgame+0x34BFF20game+0x6B965E (with data)
SpeedZoneCompletedgame+0x34BFB10game+0x6B8EA8
SpeedZoneAbortedgame+0x34BFDB8game+0x6A2AF7

Offline, the game sends nothing before a speed trap (its markers need Rivals data), so only speed zones are useful triggers. End a ghost on a timer as well, in case no end event comes.

Online ghosts: the anti-griefing bit — game+0x28D350

Collision requests are not replicated online: a local ghost still hits other players' copies of your car. The one ghost the game already sends to other players is its anti-griefing rule.

AddressesShouldStartGriefing game+0x28D350 / 0x14028D350 bool (car, float abs_dt), called once at game+0x2A949F; StartGriefing game+0x2A5F00; ShouldStopGriefing game+0x28CCB0; StopGriefing game+0x28D6D0
Kindfunction. Platform name FH2_GAME_FORZACAR_SHOULD_START_GRIEFING
What the game doesJudges only the local car (kind 0): too slow (under 5 mph after 20 s) or wrong way. Then the griefing preset turns collision off and alpha to 0.5 for a 5.5-7.5 s cooldown. The flag is at ICarDynamics+0x4EE5 (set through slot 0x950, read through 0x958); remote copies (kind 3) mirror it
GateUseOnlineAntiGriefing, GameOptions+0x4830 (slot 0x310), off by default
Byte check48 8B C4 57 48 81 EC 90 00 00 00 48
StatusOffline only here. Online ghosting is covered in chapter 12

Hide the seated driver — game+0xF75500

Addressgame+0xF75500 / 0x140F75500, Car::SetDriverVisible(car, bool shown)
Kinddirect call (cutscenes use it)
What it doesHides or shows the driver: car+0x4D38 is the ICarPresentation, its slot 0x358 is SetDrawDriver; car+0x4F10 keeps the last value
GotchaNothing in plain free roam shows him again: restore it yourself
Byte check48 89 5C 24 08 57 48 83 EC 20 48 8B D9 48 8B 89 38 4D 00 00 0F B6 FA 48 85 C9 74 10
StatusProven in game (an on-foot mod)

7.5 Resets: the Hand of God

FH2 has no manual reset (Back is rewind). The "Hand of God" (HOG) fires by itself when a car falls, rolls over or leaves a race route, and puts it back by one of five modes.

HOG trigger checks — game+0x2A8B50

Addressgame+0x2A8B50 / 0x1402A8B50
Kindfunction (per car)
What the game doesSurface: each wheel's contact surface goes to IsHandOfGodTriggerSurface game+0x1059350; only surface 55 InvisibleTeleportingBorder triggers. Falling: y below HandOfGod/FallingThreshold/YPosition (-50) and falling faster than .../YSpeed (-10). Rolled over: 2 or fewer wheels down, up.y < 0.3, speed <= 0.2 for longer than HandOfGod/MaxRolledOverTimeBeforeReset (2 s). Races: off track, wrong way, missed checkpoint (HandOfGodReset\* tunables)
SwitchesThe thresholds are GameTunableSettings.ini values (data, not code). NoHandOfGodReset (options+0x3207) turns HOG off
StatusOffline only for the thresholds; a rolled-over reset 2.2 s after stopping was seen in game

Reset target — game+0xF5DB40

Addressgame+0xF5DB40 / 0x140F5DB40; its wrapper game+0xF62010
Kindfunction
What the game doesbool (car, float* pos, float* orient, bool pop): picks where the car goes, by the mode at car+0x4F94: 0 NearestRoad, 1 NearestEventRoad (race cars), 2 NearestSatNavRoad, 3 LastStablePosition (free roam), 4 a tagged road's stored place (car+0x4FA0)
Mode 0Takes the road tracker's node [[[car+0x4F70]+0xA8]]+0x10 (x, y, z at node+0x14) and faces the neighbour closest to where the car pointed (game+0x19179E0; reads no road direction, so a spun car restarts facing backwards)
Mode 1Gets a place and direction along the race route (game+0x19186B0, branch at game+0xF5DDE9)
Mode 3 and no nodeThe newest valid position from the vector at car+0x11D8 (64 bytes each), popped on use, so repeated resets walk further back; an empty list gives the current transform
What a hook gives you"Reset to the nearest road" in free roam: write 0 to car+0x4F94 around the original call and put the car's own mode back after
GotchaTest for mode == 3 only. The hook serves every car; forcing mode 0 on mode 1 replaces race resets, Drivatars' included
Byte checkEntry, 18 bytes: 48 8B C4 56 57 41 54 41 56 41 57 48 81 EC B0 00 00 00. Also check the mode and node reads at game+0xF5DB87 (50 bytes), the node position read at game+0xF5DC34 (25 bytes) and the valid-positions read at game+0xF5DF4D (18 bytes)
Who sets the modeRespawnModeModule gives each car mode 3 when it is added (game+0x669520); only a CarRespawnModeComponent changes it (game+0x4BD420 -> game+0x66DBC0); no stock entity asks for mode 0
StatusProven in game for the free-roam reset; race resets offline only

Valid-position recorder — game+0xF80160

Addressgame+0xF80160 / 0x140F80160
Kindfunction
What the game doesWhile all four wheels are down, stores a position every ValidPositions/TimeInterval (1 s), at least ValidPositions/Distance (5 m) from the last, with up.y >= AngleCos (0.94), at most 20 kept, and none for 5 s after a reset
GotchaNo road or surface test: a car resting on an invisible floor records positions there
StatusOffline only

The reset flow is data: stateflow\hand_of_god.xml. reset_full fades out, stops the car, teleports, resets the camera, then waits in wait_for_streaming_around_local_human_car before fading in. On a custom world that wait can stall for 20 s or more if the car lands where the world's streaming never reports ready (seen in game); an override of the flow without that wait is the proposed fix (design only).

7.6 Change how AI drives

The race AI (RacingAI::Driver, MetaAIDriver) and the free-roam AI (AIOpenWorld) are mostly tuned by data. Start there; there are no proven hooks on the AI's decisions yet.

What the data controls

File or tableWhat it sets
media\EntityModel\AI\RacingAI.xmlPassing and avoidance costs (CarCost, OffTrackCost, TimeToCollisionCost...), look-ahead, RaceTableReader (CurbMarginInner_m 2.0, CurbMarginOuter_m -1.0, WallMargin_m 1.0, ShouldLimitChi), reset rules (ResetIfStuck..., ResetIfFellThisLow)
Difficulty.xml, AITimes.xml, CarLoadingSettings.xml, Densities*.xmlDifficulty, per-route reference times (optional), car loading caps (11 festival cars), spawn densities
media\DrivatarGlobalCache\DefaultCache.bin125 cached Drivatar records (25 gamertags)
Database temperament rowsDefault sideswipe and blocking behaviour (an AI database mod changes only these rows)
Data_Car_BucketsWhich cars opponents can be given

Cached Drivatars carry their own values. Each record in DefaultCache.bin has SideswipeMean, TemperamentMean, CornerCuttingMean, GoingWideMean, RacingLineOffsetMean and more, so database edits do not reach them. To change those Drivatars you would have to clamp the values as they are loaded (no site found yet).

Racing AI classes and states (names only)

The RTTI names show where an AI hook would go. None of these has been hooked.

ClassStates
MetaAIDriverRollingStartState, StationaryStartState, SoloLappingState, PassingState, BlockingState, CrashRecoveryState, FrozenState, HandsOffState, NoTrackState, PostRaceKeepDrivingState, PostRaceStopState, pit states (unused in FH2)
PassingDriverHighRelVelDynamicPass, LowRelVelDynamicPass, Trailing, AlongSide, Sideswipe, Avoiding, ScriptedPassSetup/Execute, Blocked, ReverseToUnBlock, StartingLine*
BlockingDriverBlocking, DoneBlocking, SwitchBlockTarget, Watching
CrashRecoveryDriverTurningAroundForwards/Backwards, BackAwayFromCrash, BackAwayOnTrack, DoneRecovering, Stopping

A suggested first experiment for a cleaner-driving mod is to refuse the Sideswipe transition. Design only.

Debug option names in the exe (DisableDrivatarTendencies, UseFixedDrivatars, EnableBlockingBehavior, MaxDrivatars...) exist, but how to set them is not known.

The race line the AI follows

A race's Drivatars drive on the route's race line, media\OpenWorld\<world>\AITracks\Route<id>.owt (FTWO version 3; format in chapter 10). Speeds and braking points are not in the file: the game works them out at race load ("AI training", wait_for_ai_training in the race flow) from the line's curvature and RacingAI.xml. The AI's limits are the ends of each point's side vector, minus the margins above; walls never reach it as data.

AITrackComponent load — game+0x720C70

Addressgame+0x720C70 / 0x140720C70; AITrackComponent vtable game+0x2CD2208 slot 4
Kindfunction
What the game doesWhen a race is activated (not at boot), builds game:\Media\OpenWorld\%s\AITracks\%s.owt from the world's media name and "Route" + id, queues the read and fires AITrackDataLoaded; the callback game+0x721A90 reads the FTWO and sends LoadedAITrack
What a hook gives youThe moment a race line loads; a place to log or redirect it. Serving the file with set_file is usually enough
StatusOffline only for the code; serving a new .owt proven in game (a converted circuit raced with 7 Drivatars)

FTWO reader and waypoint converter — game+0x18E0480, game+0x18D0D30

Addressesreader game+0x18E0480 / 0x1418E0480 (payload game+0x18E0300); point to waypoint game+0x18D0D30 / 0x1418D0D30; shared container header game+0x18E3410
What they doThe reader accepts any build hash for .owt files. The converter makes 64-byte TrackMatrix waypoints: position, side vector and chi[0..2] from the file's i16 values / 32767. chi[3..7] in the file are never read. chi[2] is the racing line
What a hook gives youPer-waypoint control: a different racing line, or a line pushed to one side, without new files
StatusOffline only (the format was decoded and every stock file rebuilt byte for byte)

Suggested driving line — game+0xFB28C0

Addressgame+0xFB28C0 / 0x140FB28C0, RaceLineProvider (vtable game+0x2E6C788) update
What it doesDraws the suggested line from at least 4 waypoints: pos + side * chi[TrackMatrix+0xA8] over a 125-point window, coloured by speed. Free roam uses the same renderer for the GPS route
StatusOffline only

Who gets which car

SiteWhatStatus
game+0x46E3F0 / 0x14046E3F0Opponent car pick by Data_Car_Buckets bucket; pools are filtered by the SQL function HasCarMedia, so a car row without its files is never pickedoffline only
game+0x996240 / 0x140996240 IsCarAllowedWhether a car may be used in an event; FH2MP detours it for its online car rulesoffline only here
game+0x28D9A0 / 0x14028D9A0eventstock handling: forces stock parts for events that require themoffline only

Showcase opponents (planes, trains) are scripted paths with rubber banding (ShowcaseEvents.xml: rubber_band_spring, accel_rate, decel_rate, rubber_band_offset_ahead...), not racing AI. Offline only.

7.7 Traffic and free-roam Drivatars

Free-roam Drivatars ("festival" cars) and traffic share one spawner. Unlike race Drivatars they drive on the world's AI lanes: a tile list (tracks\<T>\Ribbon_00\<T>_00.oww) plus lane blocks (LBWO) that stream in with the world's GeoChunks, tied to the road graph (.nav) by node keys. Formats are in chapter 10.

Free-roam Drivatars and trafficRace Drivatars
Spawned byFreeroamDrivatarComponent (who) and CarSpawnModule (where)the race flow: load_ai_cars, place_cars_on_grid
Drive on.oww + LBWO lanesthe route's .owt race line
Pace"Cruise" dynamic difficultythe race difficulty

CarSpawnModule::Update — game+0x729A70

Addressgame+0x729A70 / 0x140729A70 (vtable game+0x2CD2008)
Kindfunction
What the game doesEvery frame: (a) looks up track_route/car_spawn_data until found (parked cars); (b) gate at game+0x729AB5..0x729B38: needs a nav world at +0x1C8 and an AI world at AIOpenWorldModule+0x158 (an .oww with at least one tile), else does nothing at all; (c) a 5-phase round robin at +0x1D8; (d) the festival update game+0x72A120, then traffic game+0x72A650
What a hook gives youControl over when anything spawns. In practice the data and the spawn mode are enough
StatusProven in game: no .oww, no cars; with one, Drivatars spawn

Spawn mode — game+0x92EAF0

Addressgame+0x92EAF0 / 0x14092EAF0 (stored at game+0x92ECA3)
Kindfunction, or use the stateflow behaviours
What the game doesSets the mode bits: 1 Festival (Drivatars), 2 Traffic. On Storm Island the call at game+0x92EB56 clears Traffic; an online session clears Festival (game+0x92EC81). The festival update also needs +0x1A0 (cleared by DisableSpawningWrapper)
From dataStateflow behaviours global.ai_spawning_mode_festival, global.ai_spawning_instant_spawn_festival, ai_spawning_enable_immediate (both, instant)
StatusOffline only for the code; the stateflow recipe below is proven in game

Festival spawner — game+0x854F50

Addressgame+0x854F50 / 0x140854F50 (this = module+0x2D8); traffic spawner game+0x855EB0 (module+0x2E8)
What the game doesWhen its timer runs out, compares live festival cars with the density limit, then tries a group spawn (game+0x851DA0) or a single spawn (game+0x852A80). A failed spawn is silent and retried later
Where a car goesWalks the .nav from the player's tracked node (game+0x84D690), up to 100 steps (about 2 km), ahead or behind at random, biased by the player's speed; skips spots near other cars; then asks for the lane between the two nodes reached (game+0x18D8660)
CrashA nav node that belongs to no road dereferences null at game+0x84D924. Every node must be in a road, every road two nodes or more
StatusOffline only (the lane lookup was replayed offline); spawning proven in game

Lane lookup — game+0x18D8660

Addressgame+0x18D8660 / 0x1418D8660 (-> game+0x18D7F30)
What it doesScans nearby tiles for a lane record whose two i16 node keys equal the two nav nodes' keys (node+0x10), either way round, noting "reversed". Keys above 32767 never match (signed compare)
StatusOffline only

Densities

Each lane carries density ids (1-based) into EntityModel\AI\Densities.xml, festival list and traffic list (game+0x18D3F90). Ids of 0, or an entry whose max is 0, give no cars. Spawn-in and spawn-out distances default to 300 m and 375 m. Stock entries: empty and none give nothing; festival gives Drivatars 0.2-0.5 and no traffic; open_world gives Drivatars 0.02-0.05. A festival-only density was proven in game.

FreeroamDrivatarComponent

Vtable game+0x2C98C00. Entity driving_to_event_sign_up (Storm Island: Max 16, Min 11, RefreshTime 600). Properties: Min +0xB0, RefreshTime +0xD0, Max +0xF0, ForceDrivatarsDuringIE +0x130. Slot 4 game+0x558FE0 sets the ready flag +0x185 once Min identities are acquired. Min and Max change acquisition and readiness, not how many cars drive. WaitForFreeroamDrivatars (game+0x961230) ends at once when no component exists. Offline only.

Free-roam AI on a world that has none (recipe, proven in game)

  1. Ship .nav, .oww and LBWO tiles with matching hashes (every LBWO tile must carry the .oww's hash).
  2. Copy the driving_to_event_sign_up entity into the world's entity group.
  3. In the arrival flow, before the fade-in: <behavior id="LoadInitialFestivalCars" waitforload="true"/> and <behavior id="MultiCarLoading"/>.
  4. After start_driving: global.ai_spawning_mode_festival, then global.ai_spawning_instant_spawn_festival.
  5. Use Festival only (traffic densities 0/0).

Side effect: the free-roam driving line starts drawing, because the lanes give it a road.

Silent "no cars" checklist: no .oww or zero tiles; LBWO hash differs (game+0x18DFEAC); lane keys don't match the nav or exceed 32767; density 0 or max 0; spawn mode none; a DisableSpawningWrapper left active.

Performance: each free-roam Drivatar car load makes about 4,000 file calls on the main thread, and the cost grows with the number of overlay media folders (car packs, Extra Options mods). Races, whose cars are preloaded, stutter far less. Proven in game.

7.8 Add or change an event

A race is mostly data. On the mainland (track 542) and Storm Island (549) you need no code at all; on a custom world you need a few small hooks, because some loaders are hard-coded to those two worlds.

PieceWhereCode needed
Route, event and race rowsTracks, AnthemEvents, AnthemEventRaces via add_sql (guarded INSERT, then UPDATE for tuned values)no
Trigger zone race_trigger_zone_rt<route>a served copy of tracks\anthem\...\triggers.tz or tracks\Test03\...\triggers.tzno
Route file (grid, checkpoints, finish, parking)tracks\<world>\trackroutes\Route<route>.ntpreload hook on a custom world
Race line (only with Drivatars)OpenWorld\<world>\AITracks\Route<route>.owtno
Rewards cutsceneCinematics\Global\RouteSpecific\<route>\PostRace_Rewards_Complete_01.xml (section 7.9)no (custom world only)
Show the race on its world onlyGetEventVisibility hookyes, if the race must be hidden elsewhere
Gantry object (optional)START_LINE_<route> (circuit) or FINISH_LINE_<route> in ribbon_00\GameObjs.xmlno

Database fields that matter: RaceModeId 0 (LapsRace; copying a Storm Island row brings its Scramble mode), CustomWeather 0 and TimeOfDayStart -1 to keep the player's weather and hour, CampaignId 0 so the race is not hidden inside a championship, RibbonConfiguration 0 for a circuit (2-4 = point to point). File formats and the full list are in chapter 4 and chapter 10.

Race activations: loader and creator — game+0x50B180, game+0x509860

Addressesloader game+0x50B180 / 0x14050B180; creator game+0x509860 / 0x140509860; zone name builder game+0x507020 / 0x140507020
Kindfunctions (no hook needed)
What the game doesAt the first world load of a session the loader reads both triggers.tz files (mainland and Test03) into the trigger-zone manager (game+0x194E0B0) and never again that session (state at game+0x34BA4C8). The creator then makes a race_activation for every race row whose zone race_trigger_zone_rt<route> exists, with no world filter, and resizes the zone to 200 m
ConsequencesAn added zone exists on every world at the same coordinates. Keep it more than 200 m from any spawn or arrival point, or the prompt pops up on arrival. There is no debug launcher in the release exe: a race starts only by driving into its zone
StatusProven in game (a zone added to a served copy of the Storm Island file made the game create the race)

GetEventVisibility — game+0x3A9D80

Addressgame+0x3A9D80 / 0x1403A9D80; callers game+0x477C4A, game+0x469155
Kindfunction
What the game doesint (career in rcx, race id in edx), returns 1 or 0. Hides races of the other career location (mainland or island), Initial Experience races past their stage, and championship races (EventType 0) outside the current championship. A prompt's Enabled follows it, re-asked on every career.refresh_event_visibility broadcast (game+0x624000 via game+0x477C20)
What a hook gives youShow your race only where it belongs: return 1 for your race on your world, 0 elsewhere, and call the original for every other race. Send career.refresh_event_visibility on arrival so the change shows at once
Byte check48 8B C4 57 48 83 EC 60
StatusProven in game

Route preload — game+0x5D8200 (hooks at game+0x5D832A, game+0x5D833D)

Addressgame+0x5D8200 / 0x1405D8200 (LocatorsModule, vtable game+0x2CAA520, slot 1); route list query game+0x5E77C0
What the game doesAt world load, preloads every Route<id>.nt for routes with an event row whose Tracks.MediaTrack is the world. Hard-coded to two worlds: id 542 takes the mainland loader, 549 calls game+0x5E77C0 with MediaTrack 549. A route with no event row is never loaded
Kindtwo instruction hooks, for a custom world id
Hook 1game+0x5D832A (sub ecx,21Eh, after mov ecx,[rsi+20h] at game+0x5D8327): make your world's id read as 549 so the island branch runs. Check 8B 4E 20 81 E9 1E 02 00 00 74 18 83 F9 07 at game+0x5D8327
Hook 2game+0x5D833D (mov rdx,rsi): set r8 to your world's id, so the query lists your routes. Check 41 B8 25 02 00 00 48 8B D6 49 8B CE E8 78 F4 00 00 at game+0x5D8337
DisagreementAnother reading names the call itself at game+0x5D8343 (E8 78 F4 00 00 EB 0B). The two hooks above are the proven ones
StatusProven in game. Guess, untested: a mod reusing a stock world id needs only the route row's MediaTrack

Race entity setup — game+0x61DF90

Addressgame+0x61DF90 / 0x14061DF90, RaceRouteEntityCreateComponent slot 4
What the game doesSets route_transforms.CollectionName = "Route<id>", and looks up START_LINE_<route> (circuit; its start gantry is its finish) or FINISH_LINE_<route> (point to point, game+0x98DC90 reads RibbonConfiguration). If the object is missing, the finish cutscene falls back to PostRace_Finishline_Complete_Fallback
StatusOffline only; a race without the object ran in game

Other race-flow sites

SiteWhatStatus
game+0x47A6F0 (-> 0x479F90)Checkpoint tracking: reads route_checkpoint_%03d; laps and finish come from checkpoints, not the gantryoffline only
game+0x4C4640StrayWarningDistance / StrayTeleportDistance query (150 / 200 m on stock routes)offline only
game+0x4BD3B0Track-limit zones tz_tl_base.tz, tz_tl_route%d.tz (not needed for a race)offline only
game+0x93F2A5career.switch_on_career_event_type reads the current race with no null check: a race without database rows crashes hereoffline only
game+0x50A2E0Entity group file loader (…, file name in r8). After a race, quit_race reloads free roam by "mainland or island"; on a custom world, swap the file name to keep that world's own group. Byte check 48 8B C4 48 89 50 10 55 41 56 41 57proven in game
game+0x93F191SwitchOnActiveTrack's cmp eax,225h. Answering "island" for a custom world gives it the island-style map, but doing it during race flows makes the race take the island's race type (Scramble). Keep it to the map screenproven in game
game+0x6B7808, 0x6C2DF0, 0x62D1D3, 0x5E4F5E...Stats written only for 542 or 549 (speed zones, traps, events raced, roads discovered). XP and credits are awarded before the compare, so a custom world still pays outXP proven in game; the rest offline only

The race flow (state names seen in a real race)

  1. Sign-up: activation_flow > offline_race_entry_flow > race_sign_up_change_car.
  2. Loading: car_loading_flow > load_ai_cars > assign_drivatar_liveries_and_tunes, pre-race intro and menu.
  3. Grid: setup_grid_ordering, load_checkpoints, place_cars_on_grid (start_location_N), wait_for_streaming, wait_for_ai_training, the countdown cutscene, 321_countdown.
  4. Racing: race_flow > wait_for_end_condition.
  5. Results: event_finished_flow > show_event_results > standings > update_roadtrip_career (the result is written to the career here: back up saves before testing).
  6. Rewards: rewards_flow > play_cutscene > common_flow (credits, XP, level bar) > fade out.
  7. Back to free roam: quit_race_entry > quit_race > start_driving.

The 3-2-1 countdown needs only the grid and the car (its cutscene anchors to the player's bumpers). Proven in game.

7.9 The post-race rewards scene

On a world without the mainland's cinematic zones, a race finishes, shows results and standings, then sits for ever while the player's car drives itself: the state log stops at wait_for_cutscene_cinematic_ready. That state has one exit and no timeout.

Why: the stock Cinematics.zip Global\PostRace_Rewards_Complete_01.xml asks for cinematic streaming zone 10065 through its scene root's SpecificRouteID. A world without that zone drops the request, so the check never passes. Its 26 AnimatedModel objects (avatar, promoters, wristband props) also wait for models that only that zone holds. The pre-race intro plays because its id, 10000, is skipped. PostRace_Rewards_Championship_01.xml has the same trap.

The fix is data (proven in game): the cutscene component looks for media\Cinematics\Global\RouteSpecific\<route>\<file> first and falls back to Global\. Serve a route-specific copy with SpecificRouteID="", the 26 self-closing AnimatedModel objects removed and the 52 timeline tracks that animate them removed. Keep the cameras, the car recording that parks the player at end_position_000, car proxies, the 7 UI panels, the broadcast event, the 7 loop points that common_flow waits on and the 17 bookmarks. Rewards then show without the avatar.

WaitForCutsceneCinematicReady per-frame test — game+0x978D10

Addressgame+0x978D10 / 0x140978D10; vtable game+0x2D34C20, slot 0x70 (pointer at game+0x2D34C90). Real slots are every other qword; the odd ones are xor eax,eax; ret
What the game doesGets the CutsceneComponent (game+0x978610), asks game+0x4DA3B0 if it is ready, and only then fires the transition game+0x1925260(this, this+0x150) at game+0x978D57
Code fallbackhook_pointer on the slot (expect game+0x978D10): call the original, and on your world only fire the transition yourself after about 2 s. Check 48 8D 93 50 01 00 00 at game+0x978D4D. A stateflow edit would change every race
StatusDesign only (the data fix made it unnecessary)
SiteWhatStatus
game+0x4DA3B0Cutscene component ready: state +0x314 == 4 (XML loaded) and the cinematic ready testoffline only
game+0x17468F0Cinematic ready: every scene object's IsReady and every requested zone id loaded (global map game+0x36E1EE0)offline only
game+0x1752ED0Parses SpecificRouteID into the wait list; skips 10000offline only
game+0x28FA30Route-specific cinematic lookup (Cinematics\Global\RouteSpecific\<route>\, then Global\); 116 stock routes have a folderproven in game (served per-route files)
game+0x4D62A9, 0x4D6324, 0x4D6346Route-specific path built, existence check, fallback to Global\offline only

7.10 Extra rows on the online race setup screen

The session leader's Event Options page (Scenes/Anthem/A_OnlineEventOptions) is built in code, row by row, each time it opens. A mod can add its own rows in the game's style. Online play itself is in chapter 12.

OnlineEventOptions row builder — game+0xD78E50

Addressgame+0xD78E50 / 0x140D78E50; page vtable game+0x2E0CBD8; called once per opening from game+0xD8200D
Kindfunction. Hook the builder, not its call: Extra Options (0.6.1) replaces the call at game+0xD8200D with its own function that runs the builder and then adds its rows. Hooked at the builder, your rows come after the game's and before Extra Options'
Byte check40 55 53 56 57 41 54 41 56 41 57 48 8D AC 24 F0
Layoutpage+0x410 row collection; collection+0x50 -> inner; inner+0x30 i32 row count; rows reached via inner+0x28 -> +0x28 -> array of row pointers. Row (OnlineEventOptionsItem, vtable game+0x2E0C898, 0xA8 bytes): +0x70 Title (String: UTF-16 at +0x28, length at +0x30), +0x78 SelectedIndex, +0x80 the choice list, +0x88 a std::function<void(LaunchOptions&, int)> (impl pointer at row+0xA0)
StatusProven in game (rows added beside Extra Options 0.6.1, choices switched, events started)

Helpers you call from the hook (offline-checked bytes; used by the proven probe):

SiteWhatByte check
game+0xD709F0make a row (out, &title, selected, &choices, &function)48 8B C4 48 89 48 08 57 41 56 41 57 48 83 EC 30
game+0xD6E650add a row (collection, row)40 53 48 83 EC 20 48 8B 41 50 4C 8B 09 4C 8B C2
game+0xD6F470Start: calls every row's function with its SelectedIndex (check 8B 42 78 89 44 24 70 48 8B 8A A0 00 00 00 48 85 C9 at game+0xD6F4C7)
game+0x2E105C0std::function wrapper vtable for a plain function pointer: {vtable, fn at +8, pad, impl at +0x18 = &self}; slot 2 = game+0x17F1410
game+0x323310, game+0x140AF10MakeDisplayString(out, const char*, len), then (out, &display string) -> the String a row shows
game+0xD618E0the game's two-choice list factory (out)
game+0xC65B90, game+0xB52170make a list entry (out, &value, &display string); insert it (list, index, entry)

Every added row needs a callable function. An empty one throws bad_function_call at Start and stops the game. Game objects keep their reference count at +0x10; free with game+0x257730 when it reaches 0. Don't hook MakeDisplayString: other mods check its bytes in memory (5.9).

7.11 How a car loads, and how car data can crash it

Cars are mostly a data topic (chapter 4, formats in chapter 10), and the platform's car packs handle adding them. These sites explain the failures you will meet. All offline only unless said.

SiteWhat it doesFailure it explains
game+0x117DC10 CarScene constructorQueues <media>.carbin, Lights.bin, LightPresets.bin, animations\<media>.gsf under media\cars\<media>\
game+0x11A1910 CarScene state machine (state at scene+0x80)carbin, then skeleton .modelbin and .gr2 (required), .gsf and light files (optional), then parts and their modelbinsno carbin, skeleton or gr2 = the scene fails
game+0x13F1D70 Model::LoadWaits for every material instance with no failure exita missing .materialbin (or library AO map) = the car loads for ever, no crash, no log (seen in game)
game+0x13E7398, 0x13E7124Model blob readsa model without Modl or Skel crashes
game+0x10BE910, 0x1192590Textures and AO mapscount "failed" as done; a missing texture draws black
game+0xF67DC0 (car vtable slot 62)Render description: an INNER JOIN of Data_Car, List_Wheels, rim, tyre and brake rowsa car missing any of those rows has no render description
game+0x1056210 physics builderBuilds the part records (one aspiration part)a part row whose owner doesn't match gives NULL
game+0x105BEEC in the clutch reader game+0x105BEA0Reads the clutch recordcrash when a saved upgrade's row is gone; the transmission reader crashes the same way at game+0x1064614. Proven in game. Keep upgrade row ids stable
game+0x104D5F0 GetStockPartIdFirst IsStock=1 row for the car, or -1
game+0x2CD090 garage fit-partPart id array at +8 (43 entries); engine, drivetrain and body swaps reset their sub-parts
game+0x1090EA9, 0x1090C0DRecord-set reads: a missing row, column or NULL reads as INT_MAX / FLT_MAXthe game trusts every row and reports nothing

The car class whose slots 7 and 62 are listed here has the vtable game+0x2E6B0A0 in the car-loading study, which is not the ForzaCar vtable game+0x2C5CB80; which class it is is unconfirmed.

7.12 Spawn or drive pedestrians

FH2 has a complete, unused pedestrian system: a track presentation can build a block of people of one crowd class and draw them at positions it reads from an array every frame, with the crowd's own models and animations. It is unused because the object it asks for, PEDESTRIAN_MEDIUM, is in no shipped file. An on-foot mod revived it to give the player a walking body. Everything in this section is proven in game unless marked.

All crowd people share one skeleton (Anthem_Crowd in media\Crowds.zip): 24 rigged models and 133 animations, baked into one GPU bone buffer at world load. Classes and animations are numbered by their position in media\crowds\_library\spectators.crowdbin: classes 69 idle, 106 casual walk, 78 run, 110 fast walk; animations 61 idle, 124 casual walk, 128 fast walk, 70 run. There are no jump, crouch or turn animations.

TrackPresentation11::CreatePedestrians — game+0x132DA50

Addressgame+0x132DA50 / 0x14132DA50; live TrackPresentation11 vtable game+0x2EC30C0, slot 14 (game+0x2EC3130)
Kinddirect call, on the render side
What it does(track, int count): asks library CROWDTEMPLATE for the pedestrian object and builds the block on a resource thread. track+0x15458 is the handle (+0x00 a critical section, +0x28 the request, +0x30 = track+0x15488 the built object); request bytes +0x34 and +0x35 both 4 = built
countThe number of models the class has: (*(rec+0x10) - *(rec+8)) / 0x20, with rec = *(crowd+0x1D98) + class*0x120. 0 divides by zero at game+0x13962D0 on a resource thread: check it first
Byte check40 55 56 57 48 81 EC B0 00 00 00
StatusProven in game (built at once, 7 batches)

Pedestrian object name — call site game+0x132DAF2

Addressgame+0x132DAF2 / 0x14132DAF2, a call to game+0x22C300 (std::string assign (str*, const char*, size_t)) inside CreatePedestrians
Kindcall site (hook_call)
What a hook gives youSwap "PEDESTRIAN_MEDIUM" for a real object, for example WALKER_CASUAL_MALE_WALK (class 106; LOD set PEDESTRIAN: full 3D models out to 250 m, no sprite). The object is looked up in CROWDTEMPLATE (media\tracks\anthem\ribbon_00\instancetemplates\objects) by crowd vtable slot 13
Byte check41 B8 11 00 00 00 48 8D 15 2B EF F0 00 48 8D 4C 24 70 E8 09 E8 EF FE at game+0x132DAE0 (mov r8d,17; lea rdx,"PEDESTRIAN_MEDIUM"; call)
StatusProven in game

TrackPresentation11::UpdatePedestrians — game+0x135A3C0

Addressgame+0x135A3C0 / 0x14135A3C0, slot 15 (game+0x2EC3138)
Kinddirect call, once
What it does(track, shared_ptr* p), p = {object*, control block*}; the object's first field points at your entries. Afterwards block+0x710 is that object and the game reads your entries every frame
GotchaPass a control block whose release functions do nothing and whose memory outlives the block: the game keeps the pointer
Byte check48 8B C4 48 89 50 10 56 57 41 56 48 83 EC 60
StatusProven in game (call once; from then on only rewrite the entries)

Driving the people:

  • Entries: *(*(block+0x710)), 0x30 bytes each, 16-byte aligned: +0x00 float4 position (w = 1), +0x10 float4 direction (sin yaw, 0, cos yaw, 0), +0x20 u8 shown.
  • What a person plays: write its state record (groups at *(block+0x6A0), 0x50 each; group+0x20 = 10-byte records: +0 class, +1 model, +5 animation, +6 u16 frame). Set +5 to the animation for the gait and zero the frame on a change. Writing a frame number each update plays that frame (the game adds 0-2 frames itself).
  • Which entry belongs to which person of batch b: *(*(block+0x720)) + b*0x18 = {int* first, int* last}.

Gotchas:

  • Do everything on the render side, inside the view-update path that reads the entries. A fault there must hide all entries.
  • Place the body from the frame whose eye matches cull view 18's camera (keep the last 8 frames, match within 0.5 m), or it shakes.
  • Hold each gait change for 0.15 s: a slow walk otherwise flips between stand and walk many times a second, and every change restarts the animation.
  • Pedestrians cast no shadow (they are in render rows 2 and 6; shadows are row 7). Not investigated.
  • A main-thread alternative through the deferred proxy at ForzaSimulation+0x368 (vtable game+0x2EBF590) exists but was not used (offline only).

Ground and walls for a walker

A walker needs the collision around it. The proven way is to issue one extra query from inside a CollisionWorld::GetPolys hook (game+0x12CC730, the same function WreckingBall hooks; the platform chains them), on the game's thread, right after the game's own query, and copy the triangles out. Details of the query and the triangle format are in chapter 6. Car-scale worlds need car-scale speeds: a 4.5 m/s jog and 9 m/s sprint felt right where real walking speeds felt broken.

7.13 Animation: crowds, drivers and car parts

Crowd animation bake — game+0x138BC40 (hook at game+0x138C00C)

At world load the game samples every crowd animation at 30 fps into two arrays and makes the GPU bone buffer from one of them; no CPU copy is kept. To play your own animation, overwrite a stock one's rows in that array before the buffer is made.

Addressbake game+0x138BC40 / 0x14138BC40; instruction hook at game+0x138C00C / 0x14138C00C (sampling done, buffer not yet made; the buffer is created at game+0x138C05F)
Kindinstruction (hook_instruction)
Registersr15 = array A, Granny composite matrices (inverse bind x world): the one that is drawn. rsi = array B, world matrices (only used for the camera-flash hand). r13 = {u32 animations, u32 poses, u32 most bones}. r14 = the animation set: +0x18/+0x20 vector of 16-byte records {firstFrame, firstPose, frames, skeleton}; +0x30/+0x38 vector of 0x78-byte skeleton records (bones per pose at +2)
Byte check44 89 64 24 34 C7 44 24 38 08 00 00 00 41 8B 45 04 8D 0C C0 C1 E1 02 at game+0x138C007
TechniqueOverwrite a victim animation's rows in array A (firstPose * 36 bytes in) and set its frame count; then select that animation per person (state +5) and drive its frame. Before writing, compare a known pose (idle 61, frame 0, bones 2 and 19) with a stored copy within 0.01, or leave the table alone
StatusProven in game (a 39-frame jump played over animation 107). Writing array B instead failed: the person played the stock animation

Pose format (array A): per bone 9 floats: x axis, y axis, position; z = cross(x, y). 57 bones in the model's Skel order (0 root, 1 Reference, 2 Hips, 3-8 left leg, 9-14 right leg, 15-16 spine, 17-29 left arm and hand, 30 neck, 31 head, 32-39 face, 40-52 right arm and hand, 53-56 LOD nodes). Model space: metres, y up, facing -z, +x is his left. Unit axes only: the game cannot draw a scaled bone. The Granny skeleton has 52 bones (z up, about 5 units a metre); a bone map in each skeleton record joins the two. Measured in game: 133 animations, 1,725,789 poses, 59.3 MB.

Crowds in the stands

Stand crowds are drawn by Presentation11::CrowdPresentation11 (live vtable game+0x2EC3550). A world can serve a populated tracks\<world>\Ribbon_00\<world>_track_00.crowd (FH2's own are empty) and the game draws it, lit and varied (proven in game). The file format and the procedural crowds of the open world are in chapter 10 and chapter 6.

SiteWhatStatus
game+0x138FA00 crowd Load(name, ribbon, ?, float density, float cheer, bool): stores clamp(density) at this+0x1C2C and min(cheer, 1) at this+0x1C30; each section uses only its first people x density people, in file orderoffline only
game+0x13B2B60 crowd updateWhen a person's animation ends, picks cheer for the first people x density x cheer, idle for the rest. No car position is readoffline only
game+0x139CD30 drawDraws the file crowd after the procedural crowd, only when the file has groupsoffline only

Don't bother driving the cheer share: in all 114 stock crowd classes the Cheer list equals the Idle list, so a hook that raises this+0x1C30 changes nothing visible. Classes that differ would need a new spectators.crowdbin. The two loader entry points named in different studies (game+0x119E2A0 reader -> game+0x11AE8F0 parser, and game+0x1394790) are both recorded; which calls which is unconfirmed.

The driver

  • The seated driver is Presentation11::DriverModel (media\drivers\<kind>.zip: driver.gr2, a Granny state machine driver.gsf, driver.modelbin; seated animations only; 130 bones). Hide him with SetDriverVisible (section 7.4).
  • Posing him yourself (design only): a call-site hook at game+0x137D8C9 gives the 4x4 that places him in rdx and the frame in r9; EntityFrame+0 -> Animation::Frame, Frame+0x28 -> the Granny world pose (64 bytes a bone), Frame+0x18 -> the skeleton. The palette is copied from the composite at game+0x16FDBA0, so write both. He is drawn inside the car's draw (game+0x139C050) with the car's LOD, so he may vanish with the car.
  • Moving where the driver sits is data: the Hips track of his clips plus the steering wheel offset. Proven in game.

Car part animation

  • Each car's animations\<media>.gsf is a Granny state machine; clips it doesn't reference never play. A car runs with another car's gsf (its CRC is not enforced), and a rewritten gsf works (proven in game).
  • Part clips name bones in plain text (boneHood, boneDoorLF, boneSpeed, boneWiperL...): a replacement skeleton must keep those names. Clips are chosen at game+0xF7BCC0; the driver's animation folder at game+0x138FE63.
  • Pop-up parts rotate about their bone's pivot; a pop-up without a group bone stays shut.
  • Animated scenery (Ferris wheels, balloons, showcase aircraft) uses the same Granny files in a world's bin.zip; see chapter 6.

7.14 Master address table

All RVAs; full address = 0x140000000 + RVA. Status: P = proven in game, O = offline only, D = design only.

RVAFull addressNameKindStatus
0x2893200x140289320~ForzaCarfunctionP
0x28C5900x14028C590car alphafunctionP
0x28CCB00x14028CCB0ShouldStopGriefingfunctionO
0x28D3500x14028D350ShouldStartGriefingfunctionO
0x28D6D00x14028D6D0StopGriefingfunctionO
0x28D9300x14028D930apply collidable state (slot 0x130)pointer / callP
0x28D9A00x14028D9A0eventstock handlingcallO
0x28FA300x14028FA30route-specific cinematic lookupfunctionP (data)
0x2A5F000x1402A5F00StartGriefingfunctionO
0x2A8B500x1402A8B50HOG trigger checksfunctionO
0x2A94000x1402A9400ForzaCar::Update (slot 0x80)functionP
0x2AA3FB0x1402AA3FBisland-only per-wheel valueinstructionO
0x2CD0900x1402CD090garage fit-partcallO
0x2F68000x1402F6800SetGameSpeed (slot 17)callP
0x3986A00x1403986A0rolled-over camera rulefunctionP
0x3A9D800x1403A9D80GetEventVisibilityfunctionP
0x46E3F00x14046E3F0opponent car pickcallO
0x47A6F00x14047A6F0checkpoint trackingfunctionO
0x4BD3B00x1404BD3B0track-limit zonesfunctionO
0x4C46400x1404C4640stray distances queryfunctionO
0x4DA3B00x1404DA3B0cutscene component readyfunctionO
0x5070200x140507020race zone name builderfunctionO
0x5098600x140509860race activation creatorfunctionP (data)
0x50A2E00x14050A2E0entity group file loaderfunctionP
0x50B1800x14050B180race activation files loaderfunctionP (data)
0x558FE00x140558FE0FreeroamDrivatarComponent slot 4functionO
0x5D82000x1405D8200route preloadfunctionP
0x5D832A0x1405D832Aroute preload world checkinstructionP
0x5D833D0x1405D833Droute preload MediaTrackinstructionP
0x5E77C00x1405E77C0route list queryfunctionO
0x61DF900x14061DF90race entity setupfunctionO
0x720C700x140720C70AITrackComponent loadfunctionO (file P)
0x729A700x140729A70CarSpawnModule::UpdatefunctionP
0x729AB50x140729AB5spawner AI-world gateinstructionP
0x72A1200x14072A120festival updatefunctionO
0x72A6500x14072A650traffic updatefunctionO
0x84D9240x14084D924null road crash site-O
0x854F500x140854F50festival spawnerfunctionO
0x855EB00x140855EB0traffic spawnerfunctionO
0x92EAF00x14092EAF0SetSpawnModefunctionO
0x93F1910x14093F191SwitchOnActiveTrack compareinstructionP
0x93F2A50x14093F2A5switch_on_career_event_type null read-O
0x9612300x140961230WaitForFreeroamDrivatarsfunctionO
0x978D100x140978D10WaitForCutsceneCinematicReady test (slot 0x70)pointerD
0x98DC900x14098DC90point-to-point checkfunctionO
0x9962400x140996240IsCarAllowedfunctionO
0xD6E6500x140D6E650Event Options: add rowcallP
0xD6F4700x140D6F470Event Options: StartfunctionP
0xD709F00x140D709F0Event Options: make rowcallP
0xD78E500x140D78E50Event Options row builderfunctionP
0xF5B4200x140F5B420collidable requests: makecallP
0xF5B8900x140F5B890collidable requests: removecallP
0xF5DB400x140F5DB40HOG reset targetfunctionP
0xF605100x140F60510collidable request set gettercallP
0xF605D00x140F605D0car dynamics gettercallP
0xF620100x140F62010reset wrapperfunctionO
0xF622800x140F62280ForzaCar kindcall / functionP
0xF649F00x140F649F0HideCarfunctionP
0xF713D00x140F713D0car placementcallO
0xF730800x140F73080collidable requests: addcallP
0xF755000x140F75500SetDriverVisiblecallP
0xF793300x140F79330ShowCarcallO
0xF801600x140F80160valid-position recorderfunctionO
0xFB28C00x140FB28C0suggested driving line updatefunctionO
0x10562100x141056210car physics buildercallO
0x105BEEC0x14105BEECclutch reader crash site-P (crash)
0x117DC100x14117DC10CarScene constructorfunctionO
0x11A19100x1411A1910CarScene state machinefunctionO
0x12C5C900x1412C5C90dyn GetSpincallP
0x12CBEB00x1412CBEB0dyn rotation rowscallP
0x12CD1500x1412CD150dyn GetPositioncallP
0x12CDCF00x1412CDCF0dyn GetVelocitycallP
0x12DD9100x1412DD910dyn SetAngularVelocitycallP
0x12E3CF00x1412E3CF0dyn SetVelocitycallP
0x132DA500x14132DA50CreatePedestrianscallP
0x132DAF20x14132DAF2pedestrian object name callcall siteP
0x135A3C00x14135A3C0UpdatePedestrianscallP
0x137D8C90x14137D8C9driver placement callcall siteD
0x138BC400x14138BC40crowd animation bakefunctionP
0x138C00C0x14138C00Cbake: arrays readyinstructionP
0x138FA000x14138FA00crowd LoadfunctionO
0x13B2B600x1413B2B60crowd cheer/idle updatefunctionO
0x18D0D300x1418D0D30.owt point to waypointfunctionO
0x18D86600x1418D8660lane lookup between nodesfunctionO
0x18DFDF00x1418DFDF0LBWO tile readerfunctionO
0x18E04800x1418E0480FTWO (.owt) readerfunctionO
0x18E06200x1418E0620FWWO (.oww) readerfunctionO
0x190BF900x14190BF90send entity eventfunctionP
0x190BFD00x14190BFD0send entity event with datafunctionP

7.15 Structures and offsets for this system

Offsets are from the object's start unless said. Status as in 7.1; layouts common to many systems (MSVC 2012 std::string, std::list, shared_ptr) are in chapter 11.

ForzaCar (vtable game+0x2C5CB80)

OffsetTypeMeaningStatus
+0x20sub-objectICameraTarget (vtable game+0x2C5CE28); slots 6, 7: route segment, TrackMatrixO
+0x118u32Data_Car.IdP
+0x344i32car indexO
+0x3F5u8no-collision byteO
+0x11D8vectorvalid positions for resets (64 bytes each, newest last)P
+0x4C08ptrCCarDynamics interface (re-read every frame)P
+0x4C58objectcollidable request set; std::list at +8, last node = sentinel->prev; node+0x10 request, request+0x10 preset entry, preset name std::string at +0x20P
+0x4D08i32kind: 0 local player, 1 Drivatar, 2 traffic, 3-5 remoteP
+0x4D38ptrICarPresentation (+0x10 of a wrapper); slots 0x130 SetAlphaScalar, 0x228 ShowCar, 0x230 HideCar, 0x358 SetDrawDriver. Wrapper +8 = the real presentation, alpha at +0x314, shown at +0x318. Wrapper vtables: deferred game+0x2EBEF68, P11 game+0x2EC2B70, default game+0x2EB8C50, null game+0x2EBB478P
+0x4F10u8last SetDriverVisible valueP
+0x4F50ptrRaceLineProvider (made on message 0x24 with state 3)O
+0x4F70shared_ptrRouteBindings; [[+0x4F70]+0xA8]+0x10 = the road tracker's current nav nodeP
+0x4F94i32respawn mode 0-4P
+0x4FA0transformstored reset place (mode 4)O
+0x50F1u8cleared by HideCarP
+0x50F5u8system use; 3 = recording playbackP
+0x50F8CameraOverrides rowsO
+0x5370objectreplay component (its first pointer is the car, once loaded)P
+0x59BA, +0x59C8, +0x59C9u8driven by a recording, relative, keep heightP

Vtable slots: 0 deleting destructor game+0x28B380; 0x80 update game+0x2A9400; 0x130 apply collidable state game+0x28D930.

CCarDynamics (vtables game+0x2EB4BB8, game+0x2EB5E18)

Offset from dynTypeMeaningStatus
-0x390float4position (centre of mass)P
-0x3803 x float4rows right, up, forwardP
-0x350float4velocity (m/s)P
-0x340float4spin, worldP
+0x148, +0x1CCfloatengine speed, redlineO
+0xAA1u8gearO
+0xDF8driver inputsO
+0xEF0float4car offset for the hubsP
+0x1290 + i*0x4B0float4wheel hub i (0, 1 front)P
+0x1570 + i*0x4B0floatwheel radius iP
+0x4EE5u8anti-griefing flag (slots 0x950 set, 0x958 read)O

TrackMatrix (the AI's and race position's view of a route)

OffsetMeaning
+0x58waypoint ring buffer (64-byte waypoints: position, side, chi slots at +0x20 + 4*i)
+0x60, +0x64, +0x68start, count, capacity
+0xA0, +0xA4base, version
+0xA8selected chi index (which line is drawn)
+0xAClooped flag

Status: offline only.

CarSpawnModule

OffsetMeaning
+0x1A0spawning enabled (cleared by DisableSpawningWrapper)
+0x1C8nav world (must be set)
+0x1D8round-robin phase (mod 5)
+0x1DCspawn mode bits (1 Festival, 2 Traffic)
+0x230density manager
+0x2D8, +0x2E8festival spawner, traffic spawner

Status: offline only; the gate's behaviour proven in game.

Pedestrian block

PathMeaning
track+0x15458pedestrian handle (critical section; request at +0x28; built object at +0x30 = track+0x15488)
ped = *(track+0x15488), block = *(ped+0x30), data = *(block+8)the block (vtable game+0x2F5D450) and its data
data+0xA0 / +0xA8batches begin / end, 0x58 each: name std::string at +0x30, template at +0x50 (null = nothing drawable)
data+0xD0, data+0xE0block box low / high (float3)
*(*(block+0x710))your entries, 0x30 each: position float4, direction float4, u8 shown at +0x20
*(block+0x6A0)groups, 0x50 each; +0x20 state records (10 bytes: class, model, +5 animation, +6 u16 frame); +0x38 u32 count shown
*(*(block+0x720)) + b*0x18batch b's entry list {int* first, int* last}
crowd+0x1D98class records, 0x120 each; model list begin / end at +8 / +0x10 (0x20 per model)
crowd+0x1EE0, +0x1EE1crowd loaded, load failed

The real crowd object is [[TrackPresentation11+8]+0x58]; the game thread sees only the deferred proxy. Status: proven in game.

OnlineEventOptionsItem (0xA8 bytes, vtable game+0x2E0C898)

OffsetMeaning
+0x10reference count
+0x70Title (String: UTF-16 at +0x28, length at +0x30)
+0x78SelectedIndex (i32)
+0x80choice list
+0x88std::function<void(LaunchOptions&, int)>; impl pointer at +0xA0

Status: proven in game.

“The FH2 Modding Guide” by Trinculo54 is licensed under CC BY 4.0; its code samples are under the MIT licence. This page is an unchanged copy (links point to this site) of 07-hooks-races-cars.md at commit bb10508; corrections belong in the original repository.