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
- 7.2 Find the player's car and follow every car
- 7.3 Fly or move the player's car
- 7.4 Make a car a ghost, fade it or hide it
- 7.5 Resets: the Hand of God
- 7.6 Change how AI drives
- 7.7 Traffic and free-roam Drivatars
- 7.8 Add or change an event
- 7.9 The post-race rewards scene
- 7.10 Extra rows on the online race setup screen
- 7.11 How a car loads, and how car data can crash it
- 7.12 Spawn or drive pedestrians
- 7.13 Animation: crowds, drivers and car parts
- 7.14 Master address table
- 7.15 Structures and offsets for this system
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.hwith 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
| Address | game+0x2A9400 / 0x1402A9400; ForzaCar vtable slot 0x80 (slot pointer game+0x2C5CC00) |
| Kind | function (hook_function). Platform name FH2_GAME_FORZACAR_UPDATE |
| What the game does | Updates 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 you | A 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 |
| Arguments | uint64 (ForzaCar* car, float dt, float b, uint64 d) in rcx, xmm1, xmm2, r9 (b and d unknown; pass them through) |
| Byte check | 48 8B C4 48 89 58 18 57 48 81 EC A0 |
| Conflicts | Hooked 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 |
| Status | Proven in game (Do A Barrel Roll, NitroSystem, FH2MP) |
What to do inside it:
- Read the kind (
car+0x4D08, below) and act only on the cars you want. Kind 0 is the local player. - Skip frames with
|dt| >= 0.25(loading, pauses, the simulation restarting). - Read
car+0x4C08(the dynamics) fresh each frame and check its vtable: the game swaps it when the simulation restarts (game+0xFAABE0). - 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
| Address | game+0xF62280 / 0x140F62280 |
| Kind | direct call, or function. Platform name FH2_GAME_FORZACAR_KIND |
| What the game does | int (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 you | The test every car mod needs. Reading car+0x4D08 directly is the same thing |
| Byte check | 8B 81 08 4D 00 00 C3 (mov eax,[rcx+4D08h]; ret) |
| Conflicts | CCBR detours it; Director Mode checks it. A memory-only check fails once another mod has hooked it: use the disk fallback (5.4) |
| Status | Proven in game |
ForzaCar dynamics — game+0xF605D0
| Address | game+0xF605D0 / 0x140F605D0 |
| Kind | direct call (or read car+0x4C08) |
| What it does | Returns car+0x4C08, the car's CCarDynamics interface (section 7.3) |
| Byte check | 48 8B 81 08 4C 00 00 C3 |
| Status | Proven in game |
~ForzaCar — game+0x289320
| Address | game+0x289320 / 0x140289320, called from the deleting destructor (vtable slot 0, game+0x28B380) |
| Kind | function. Platform name FH2_GAME_FORZACAR_DTOR |
| What it gives you | The 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 check | 48 89 4C 24 08 56 57 41 54 41 56 41 57 |
| Conflicts | CCBR checks these bytes in memory (1.0.0) |
| Status | Proven in game (CCBR) |
Other useful car reads
| What | Where | Status |
|---|---|---|
Which car it is (Data_Car.Id, u32) | car+0x118. Read sites to byte-check: game+0xF607A2, 0xF7430B, 0xF77CD6, 0xF6760E | proven in game |
| Car index | car+0x344 | offline only |
| Route position for cameras and race order | car+0x20 is an ICameraTarget (vtable game+0x2C5CE28): slot 6 (game+0xF646E0) gives the route segment (-1 if none), slot 7 (game+0xF645C0) the TrackMatrix | offline only |
| Route bindings | car+0x4F70, a shared_ptr<AIOpenWorld::Routing::RouteBindings> (made at game+0xF4EF90) | offline only |
| Driven by a recording | car+0x50F5 (3 = recording playback), car+0x59BA | proven in game (Director Mode) |
Storm Island only: a per-wheel average written to [car+0x4F68]+0x38 | game+0x2AA3FB (cmp with 549 in a function reached from ForzaCar vtable slot 17). Guess: wetness or spray | offline 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.
| Field | Offset from dyn | Getter / setter | Vtable offset | Byte check |
|---|---|---|---|---|
| Position (vec4; centre of mass) | dyn-0x390 | GetPosition game+0x12CD150 | 0x270 | C5 F8 28 81 70 FC FF FF |
| Set position | (unnamed) | 0x280 | read it yourself | |
| Rotation rows right, up, forward (3 x vec4) | dyn-0x380 | game+0x12CBEB0 | 0x2E0 | 48 8B C2 48 8D 91 80 FC FF FF |
| Velocity (vec4, m/s) | dyn-0x350 | GetVelocity game+0x12CDCF0 | 0x288 | C5 F8 28 81 B0 FC FF FF |
Set velocity (dyn, const float4*) | SetVelocity game+0x12E3CF0 | 0x290 | C5 F8 28 02 C5 F8 29 81 B0 FC FF FF | |
| Spin, world (vec4) | dyn-0x340 | GetSpin game+0x12C5C90 | 0x2B8 | C5 F8 28 81 C0 FC FF FF |
| Set spin | SetAngularVelocity game+0x12DD910 | 0x2C0 | 48 83 EC 38 C5 F8 28 02 48 8D 91 E0 FC FF FF | |
| Engine speed, redline | dyn+0x148, dyn+0x1CC | game+0x12C8050 | ||
| Gear (u8) | dyn+0xAA1 | game+0x12C7CF0 | ||
| Driver inputs | dyn+0xDF8 | game+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 keepwfrom the game's own value. - The car's heading is
atan2(forward.x, forward.z); its left side ispos - right * d. World axes: x right, y up, z forward. - The position is the centre of mass, which sits
List_UpgradeCarBodyWeight.CMHeightabove the ground (about 0.28 m on a typical car). To anchor something to the wheels, use the hubs: hub i is atdyn+0x1290 + i*0x4B0plus the car offset atdyn+0xEF0; wheel radius atdyn+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
| Address | game+0xF713D0 / 0x140F713D0 |
| Kind | direct call |
| What it does | Places a car at a transform |
| Status | Offline only (arguments not recorded). For a free-roam car, setting velocity and spin is the proven route |
Rolled-over camera rule — game+0x3986A0
| Address | game+0x3986A0 / 0x1403986A0; ForzaMultiCam vtable game+0x2C6C840 slot 80 |
| Kind | function, or pointer (the slot) |
| What the game does | uint64 (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 you | A 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 check | 48 8B C4 41 56 48 83 EC 70 48 C7 40 A8 FE FF FF FF, and slot 80 must point here |
| Status | Proven in game. Camera code in general: chapter 8 |
Game speed — game+0x2F6800
| Address | game+0x2F6800 / 0x1402F6800, CGameManager::SetGameSpeed, vtable slot 17 (slot pointer game+0x2C5F950) |
| Kind | direct call through the slot |
| What it does | Jumps 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 you | Slow motion (0.25 works) and a full stop (0). Engine sound is not slowed |
| Status | Proven 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):
- Add a preset with
set_file:<preset name="ccbr" collision="off" />before</carcollidablepresets>. If your copy wasn't read, fall back to the game'sintersectionpreset. - Start: make a handle for your preset name on
car+0x4C58(game+0xF5B420) and register it (game+0xF73080). - End: remove it by name (
game+0xF5B890), only if the car is still the player's (vtable and kind 0 both match). - Handles are MSVC
std::shared_ptrs: release them as the game does (decrement uses atctrl+8, then_Destroy, vtable slot 0; decrement weak references atctrl+0xC, then_Delete_this, slot 1).
Collidable requests: make, add, remove — game+0xF5B420, game+0xF73080, game+0xF5B890
| Addresses | make game+0xF5B420 / 0x140F5B420; add game+0xF73080 / 0x140F73080; remove game+0xF5B890 / 0x140F5B890; the set itself from game+0xF60510 / 0x140F60510 (lea rax,[rcx+4C58h]; ret) |
| Kind | direct calls |
| Signatures | make: 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 checks | make 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 names | FH2_GAME_COLLIDABLE_REQUESTS_MAKE, _ADD, _REMOVE, FH2_GAME_FORZACAR_REQUESTS |
| Notes | The 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 |
| Status | Proven in game (CCBR) |
Apply collidable state — game+0x28D930
| Address | game+0x28D930 / 0x14028D930, ForzaCar vtable slot 0x130 |
| Kind | called through the vtable; hookable as a pointer |
| What the game does | Works out the car's alpha from its requests and hands it to the presentation (car+0x4D38, its slot 0x130 SetAlphaScalar) |
| Byte check | 40 53 48 83 EC 20 8B 05 8C 1E 22 03 |
| Conflicts | CCBR calls it through the slot, so another mod's slot hook still runs; CCBR logs if the slot no longer holds this address |
| Status | Proven in game |
Car alpha — game+0x28C590
| Address | game+0x28C590 / 0x14028C590 |
| Kind | function. Platform name FH2_GAME_FORZACAR_ALPHA |
| What the game does | float (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 you | See-through other cars. CCBR caps the alpha of kinds 1 and 2 at its OthersAlpha setting during a ghost |
| Byte check | 48 8B C4 57 48 81 EC C0 00 00 00 48 |
| Status | Proven in game (CCBR) |
HideCar — game+0xF649F0
| Address | game+0xF649F0 / 0x140F649F0; ShowCar game+0xF79330 |
| Kind | function, or direct call. Platform name FH2_GAME_CAR_HIDE |
| What the game does | Clears 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 |
| Gotcha | The 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 check | 40 53 48 83 EC 20 48 8B D9 C6 81 F1 50 00 00 00 |
| Status | Proven in game (CCBR) |
Entity events (speed zones and friends) — game+0x190BF90, game+0x190BFD0
| Addresses | send game+0x190BF90 / 0x14190BF90 (entity, symbol); with data game+0x190BFD0 / 0x14190BFD0 (entity, symbol, data) |
| Kind | function hooks (to hear events) |
| What a hook gives you | Every gameplay event as it is queued. CCBR starts and ends its ghost on these |
| Byte checks | 48 83 EC 48 48 8D 05; 40 53 48 83 EC 40 48 8B D9 |
| Recursion | A game call made while you handle an event can send another. Guard with a thread-local flag |
| Status | Proven 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.
| Event | Symbol | Sent at |
|---|---|---|
ARUI_Trigger_Entered | game+0x34BFCA0 | game+0x6B84F2 |
ARUI_Trigger_Exited | game+0x34BFB50 | game+0x6B992A |
SpeedTrapActivated | game+0x34BFDD8 | game+0x6B8A87 (with data) |
SpeedZoneActivated | game+0x34BFF20 | game+0x6B965E (with data) |
SpeedZoneCompleted | game+0x34BFB10 | game+0x6B8EA8 |
SpeedZoneAborted | game+0x34BFDB8 | game+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.
| Addresses | ShouldStartGriefing game+0x28D350 / 0x14028D350 bool (car, float abs_dt), called once at game+0x2A949F; StartGriefing game+0x2A5F00; ShouldStopGriefing game+0x28CCB0; StopGriefing game+0x28D6D0 |
| Kind | function. Platform name FH2_GAME_FORZACAR_SHOULD_START_GRIEFING |
| What the game does | Judges 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 |
| Gate | UseOnlineAntiGriefing, GameOptions+0x4830 (slot 0x310), off by default |
| Byte check | 48 8B C4 57 48 81 EC 90 00 00 00 48 |
| Status | Offline only here. Online ghosting is covered in chapter 12 |
Hide the seated driver — game+0xF75500
| Address | game+0xF75500 / 0x140F75500, Car::SetDriverVisible(car, bool shown) |
| Kind | direct call (cutscenes use it) |
| What it does | Hides or shows the driver: car+0x4D38 is the ICarPresentation, its slot 0x358 is SetDrawDriver; car+0x4F10 keeps the last value |
| Gotcha | Nothing in plain free roam shows him again: restore it yourself |
| Byte check | 48 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 |
| Status | Proven 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
| Address | game+0x2A8B50 / 0x1402A8B50 |
| Kind | function (per car) |
| What the game does | Surface: 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) |
| Switches | The thresholds are GameTunableSettings.ini values (data, not code). NoHandOfGodReset (options+0x3207) turns HOG off |
| Status | Offline only for the thresholds; a rolled-over reset 2.2 s after stopping was seen in game |
Reset target — game+0xF5DB40
| Address | game+0xF5DB40 / 0x140F5DB40; its wrapper game+0xF62010 |
| Kind | function |
| What the game does | bool (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 0 | Takes 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 1 | Gets a place and direction along the race route (game+0x19186B0, branch at game+0xF5DDE9) |
| Mode 3 and no node | The 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 |
| Gotcha | Test for mode == 3 only. The hook serves every car; forcing mode 0 on mode 1 replaces race resets, Drivatars' included |
| Byte check | Entry, 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 mode | RespawnModeModule 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 |
| Status | Proven in game for the free-roam reset; race resets offline only |
Valid-position recorder — game+0xF80160
| Address | game+0xF80160 / 0x140F80160 |
| Kind | function |
| What the game does | While 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 |
| Gotcha | No road or surface test: a car resting on an invisible floor records positions there |
| Status | Offline 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 table | What it sets |
|---|---|
media\EntityModel\AI\RacingAI.xml | Passing 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*.xml | Difficulty, per-route reference times (optional), car loading caps (11 festival cars), spawn densities |
media\DrivatarGlobalCache\DefaultCache.bin | 125 cached Drivatar records (25 gamertags) |
| Database temperament rows | Default sideswipe and blocking behaviour (an AI database mod changes only these rows) |
Data_Car_Buckets | Which 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.
| Class | States |
|---|---|
MetaAIDriver | RollingStartState, StationaryStartState, SoloLappingState, PassingState, BlockingState, CrashRecoveryState, FrozenState, HandsOffState, NoTrackState, PostRaceKeepDrivingState, PostRaceStopState, pit states (unused in FH2) |
PassingDriver | HighRelVelDynamicPass, LowRelVelDynamicPass, Trailing, AlongSide, Sideswipe, Avoiding, ScriptedPassSetup/Execute, Blocked, ReverseToUnBlock, StartingLine* |
BlockingDriver | Blocking, DoneBlocking, SwitchBlockTarget, Watching |
CrashRecoveryDriver | TurningAroundForwards/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
| Address | game+0x720C70 / 0x140720C70; AITrackComponent vtable game+0x2CD2208 slot 4 |
| Kind | function |
| What the game does | When 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 you | The moment a race line loads; a place to log or redirect it. Serving the file with set_file is usually enough |
| Status | Offline 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
| Addresses | reader game+0x18E0480 / 0x1418E0480 (payload game+0x18E0300); point to waypoint game+0x18D0D30 / 0x1418D0D30; shared container header game+0x18E3410 |
| What they do | The 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 you | Per-waypoint control: a different racing line, or a line pushed to one side, without new files |
| Status | Offline only (the format was decoded and every stock file rebuilt byte for byte) |
Suggested driving line — game+0xFB28C0
| Address | game+0xFB28C0 / 0x140FB28C0, RaceLineProvider (vtable game+0x2E6C788) update |
| What it does | Draws 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 |
| Status | Offline only |
Who gets which car
| Site | What | Status |
|---|---|---|
game+0x46E3F0 / 0x14046E3F0 | Opponent car pick by Data_Car_Buckets bucket; pools are filtered by the SQL function HasCarMedia, so a car row without its files is never picked | offline only |
game+0x996240 / 0x140996240 IsCarAllowed | Whether a car may be used in an event; FH2MP detours it for its online car rules | offline only here |
game+0x28D9A0 / 0x14028D9A0 | eventstock handling: forces stock parts for events that require them | offline 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 traffic | Race Drivatars | |
|---|---|---|
| Spawned by | FreeroamDrivatarComponent (who) and CarSpawnModule (where) | the race flow: load_ai_cars, place_cars_on_grid |
| Drive on | .oww + LBWO lanes | the route's .owt race line |
| Pace | "Cruise" dynamic difficulty | the race difficulty |
CarSpawnModule::Update — game+0x729A70
| Address | game+0x729A70 / 0x140729A70 (vtable game+0x2CD2008) |
| Kind | function |
| What the game does | Every 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 you | Control over when anything spawns. In practice the data and the spawn mode are enough |
| Status | Proven in game: no .oww, no cars; with one, Drivatars spawn |
Spawn mode — game+0x92EAF0
| Address | game+0x92EAF0 / 0x14092EAF0 (stored at game+0x92ECA3) |
| Kind | function, or use the stateflow behaviours |
| What the game does | Sets 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 data | Stateflow behaviours global.ai_spawning_mode_festival, global.ai_spawning_instant_spawn_festival, ai_spawning_enable_immediate (both, instant) |
| Status | Offline only for the code; the stateflow recipe below is proven in game |
Festival spawner — game+0x854F50
| Address | game+0x854F50 / 0x140854F50 (this = module+0x2D8); traffic spawner game+0x855EB0 (module+0x2E8) |
| What the game does | When 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 goes | Walks 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) |
| Crash | A 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 |
| Status | Offline only (the lane lookup was replayed offline); spawning proven in game |
Lane lookup — game+0x18D8660
| Address | game+0x18D8660 / 0x1418D8660 (-> game+0x18D7F30) |
| What it does | Scans 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) |
| Status | Offline 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)
- Ship
.nav,.owwand LBWO tiles with matching hashes (every LBWO tile must carry the.oww's hash). - Copy the
driving_to_event_sign_upentity into the world's entity group. - In the arrival flow, before the fade-in:
<behavior id="LoadInitialFestivalCars" waitforload="true"/>and<behavior id="MultiCarLoading"/>. - After
start_driving:global.ai_spawning_mode_festival, thenglobal.ai_spawning_instant_spawn_festival. - 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.
| Piece | Where | Code needed |
|---|---|---|
| Route, event and race rows | Tracks, 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.tz | no |
| Route file (grid, checkpoints, finish, parking) | tracks\<world>\trackroutes\Route<route>.nt | preload hook on a custom world |
| Race line (only with Drivatars) | OpenWorld\<world>\AITracks\Route<route>.owt | no |
| Rewards cutscene | Cinematics\Global\RouteSpecific\<route>\PostRace_Rewards_Complete_01.xml (section 7.9) | no (custom world only) |
| Show the race on its world only | GetEventVisibility hook | yes, if the race must be hidden elsewhere |
| Gantry object (optional) | START_LINE_<route> (circuit) or FINISH_LINE_<route> in ribbon_00\GameObjs.xml | no |
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
| Addresses | loader game+0x50B180 / 0x14050B180; creator game+0x509860 / 0x140509860; zone name builder game+0x507020 / 0x140507020 |
| Kind | functions (no hook needed) |
| What the game does | At 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 |
| Consequences | An 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 |
| Status | Proven in game (a zone added to a served copy of the Storm Island file made the game create the race) |
GetEventVisibility — game+0x3A9D80
| Address | game+0x3A9D80 / 0x1403A9D80; callers game+0x477C4A, game+0x469155 |
| Kind | function |
| What the game does | int (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 you | Show 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 check | 48 8B C4 57 48 83 EC 60 |
| Status | Proven in game |
Route preload — game+0x5D8200 (hooks at game+0x5D832A, game+0x5D833D)
| Address | game+0x5D8200 / 0x1405D8200 (LocatorsModule, vtable game+0x2CAA520, slot 1); route list query game+0x5E77C0 |
| What the game does | At 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 |
| Kind | two instruction hooks, for a custom world id |
| Hook 1 | game+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 2 | game+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 |
| Disagreement | Another reading names the call itself at game+0x5D8343 (E8 78 F4 00 00 EB 0B). The two hooks above are the proven ones |
| Status | Proven in game. Guess, untested: a mod reusing a stock world id needs only the route row's MediaTrack |
Race entity setup — game+0x61DF90
| Address | game+0x61DF90 / 0x14061DF90, RaceRouteEntityCreateComponent slot 4 |
| What the game does | Sets 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 |
| Status | Offline only; a race without the object ran in game |
Other race-flow sites
| Site | What | Status |
|---|---|---|
game+0x47A6F0 (-> 0x479F90) | Checkpoint tracking: reads route_checkpoint_%03d; laps and finish come from checkpoints, not the gantry | offline only |
game+0x4C4640 | StrayWarningDistance / StrayTeleportDistance query (150 / 200 m on stock routes) | offline only |
game+0x4BD3B0 | Track-limit zones tz_tl_base.tz, tz_tl_route%d.tz (not needed for a race) | offline only |
game+0x93F2A5 | career.switch_on_career_event_type reads the current race with no null check: a race without database rows crashes here | offline only |
game+0x50A2E0 | Entity 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 57 | proven in game |
game+0x93F191 | SwitchOnActiveTrack'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 screen | proven 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 out | XP proven in game; the rest offline only |
The race flow (state names seen in a real race)
- Sign-up:
activation_flow>offline_race_entry_flow>race_sign_up_change_car. - Loading:
car_loading_flow>load_ai_cars>assign_drivatar_liveries_and_tunes, pre-race intro and menu. - 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. - Racing:
race_flow>wait_for_end_condition. - Results:
event_finished_flow>show_event_results> standings >update_roadtrip_career(the result is written to the career here: back up saves before testing). - Rewards:
rewards_flow>play_cutscene>common_flow(credits, XP, level bar) > fade out. - 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
| Address | game+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 does | Gets 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 fallback | hook_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 |
| Status | Design only (the data fix made it unnecessary) |
| Site | What | Status |
|---|---|---|
game+0x4DA3B0 | Cutscene component ready: state +0x314 == 4 (XML loaded) and the cinematic ready test | offline only |
game+0x17468F0 | Cinematic ready: every scene object's IsReady and every requested zone id loaded (global map game+0x36E1EE0) | offline only |
game+0x1752ED0 | Parses SpecificRouteID into the wait list; skips 10000 | offline only |
game+0x28FA30 | Route-specific cinematic lookup (Cinematics\Global\RouteSpecific\<route>\, then Global\); 116 stock routes have a folder | proven in game (served per-route files) |
game+0x4D62A9, 0x4D6324, 0x4D6346 | Route-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
| Address | game+0xD78E50 / 0x140D78E50; page vtable game+0x2E0CBD8; called once per opening from game+0xD8200D |
| Kind | function. 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 check | 40 55 53 56 57 41 54 41 56 41 57 48 8D AC 24 F0 |
| Layout | page+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) |
| Status | Proven 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):
| Site | What | Byte check |
|---|---|---|
game+0xD709F0 | make a row (out, &title, selected, &choices, &function) | 48 8B C4 48 89 48 08 57 41 56 41 57 48 83 EC 30 |
game+0xD6E650 | add a row (collection, row) | 40 53 48 83 EC 20 48 8B 41 50 4C 8B 09 4C 8B C2 |
game+0xD6F470 | Start: 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+0x2E105C0 | std::function wrapper vtable for a plain function pointer: {vtable, fn at +8, pad, impl at +0x18 = &self}; slot 2 = game+0x17F1410 | |
game+0x323310, game+0x140AF10 | MakeDisplayString(out, const char*, len), then (out, &display string) -> the String a row shows | |
game+0xD618E0 | the game's two-choice list factory (out) | |
game+0xC65B90, game+0xB52170 | make 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.
| Site | What it does | Failure it explains |
|---|---|---|
game+0x117DC10 CarScene constructor | Queues <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 modelbins | no carbin, skeleton or gr2 = the scene fails |
game+0x13F1D70 Model::Load | Waits for every material instance with no failure exit | a missing .materialbin (or library AO map) = the car loads for ever, no crash, no log (seen in game) |
game+0x13E7398, 0x13E7124 | Model blob reads | a model without Modl or Skel crashes |
game+0x10BE910, 0x1192590 | Textures and AO maps | count "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 rows | a car missing any of those rows has no render description |
game+0x1056210 physics builder | Builds the part records (one aspiration part) | a part row whose owner doesn't match gives NULL |
game+0x105BEEC in the clutch reader game+0x105BEA0 | Reads the clutch record | crash 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 GetStockPartId | First IsStock=1 row for the car, or -1 | |
game+0x2CD090 garage fit-part | Part id array at +8 (43 entries); engine, drivetrain and body swaps reset their sub-parts | |
game+0x1090EA9, 0x1090C0D | Record-set reads: a missing row, column or NULL reads as INT_MAX / FLT_MAX | the 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
| Address | game+0x132DA50 / 0x14132DA50; live TrackPresentation11 vtable game+0x2EC30C0, slot 14 (game+0x2EC3130) |
| Kind | direct 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 |
| count | The 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 check | 40 55 56 57 48 81 EC B0 00 00 00 |
| Status | Proven in game (built at once, 7 batches) |
Pedestrian object name — call site game+0x132DAF2
| Address | game+0x132DAF2 / 0x14132DAF2, a call to game+0x22C300 (std::string assign (str*, const char*, size_t)) inside CreatePedestrians |
| Kind | call site (hook_call) |
| What a hook gives you | Swap "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 check | 41 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) |
| Status | Proven in game |
TrackPresentation11::UpdatePedestrians — game+0x135A3C0
| Address | game+0x135A3C0 / 0x14135A3C0, slot 15 (game+0x2EC3138) |
| Kind | direct 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 |
| Gotcha | Pass a control block whose release functions do nothing and whose memory outlives the block: the game keeps the pointer |
| Byte check | 48 8B C4 48 89 50 10 56 57 41 56 48 83 EC 60 |
| Status | Proven in game (call once; from then on only rewrite the entries) |
Driving the people:
- Entries:
*(*(block+0x710)), 0x30 bytes each, 16-byte aligned:+0x00float4 position (w = 1),+0x10float4 direction (sin yaw, 0, cos yaw, 0),+0x20u8 shown. - What a person plays: write its state record (groups at
*(block+0x6A0), 0x50 each;group+0x20= 10-byte records:+0class,+1model,+5animation,+6u16 frame). Set+5to 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(vtablegame+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.
| Address | bake game+0x138BC40 / 0x14138BC40; instruction hook at game+0x138C00C / 0x14138C00C (sampling done, buffer not yet made; the buffer is created at game+0x138C05F) |
| Kind | instruction (hook_instruction) |
| Registers | r15 = 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 check | 44 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 |
| Technique | Overwrite 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 |
| Status | Proven 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.
| Site | What | Status |
|---|---|---|
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 order | offline only |
game+0x13B2B60 crowd update | When a person's animation ends, picks cheer for the first people x density x cheer, idle for the rest. No car position is read | offline only |
game+0x139CD30 draw | Draws the file crowd after the procedural crowd, only when the file has groups | offline 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 machinedriver.gsf,driver.modelbin; seated animations only; 130 bones). Hide him withSetDriverVisible(section 7.4). - Posing him yourself (design only): a call-site hook at
game+0x137D8C9gives the 4x4 that places him inrdxand the frame inr9;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 atgame+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
Hipstrack of his clips plus the steering wheel offset. Proven in game.
Car part animation
- Each car's
animations\<media>.gsfis 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 atgame+0xF7BCC0; the driver's animation folder atgame+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.
| RVA | Full address | Name | Kind | Status |
|---|---|---|---|---|
0x289320 | 0x140289320 | ~ForzaCar | function | P |
0x28C590 | 0x14028C590 | car alpha | function | P |
0x28CCB0 | 0x14028CCB0 | ShouldStopGriefing | function | O |
0x28D350 | 0x14028D350 | ShouldStartGriefing | function | O |
0x28D6D0 | 0x14028D6D0 | StopGriefing | function | O |
0x28D930 | 0x14028D930 | apply collidable state (slot 0x130) | pointer / call | P |
0x28D9A0 | 0x14028D9A0 | eventstock handling | call | O |
0x28FA30 | 0x14028FA30 | route-specific cinematic lookup | function | P (data) |
0x2A5F00 | 0x1402A5F00 | StartGriefing | function | O |
0x2A8B50 | 0x1402A8B50 | HOG trigger checks | function | O |
0x2A9400 | 0x1402A9400 | ForzaCar::Update (slot 0x80) | function | P |
0x2AA3FB | 0x1402AA3FB | island-only per-wheel value | instruction | O |
0x2CD090 | 0x1402CD090 | garage fit-part | call | O |
0x2F6800 | 0x1402F6800 | SetGameSpeed (slot 17) | call | P |
0x3986A0 | 0x1403986A0 | rolled-over camera rule | function | P |
0x3A9D80 | 0x1403A9D80 | GetEventVisibility | function | P |
0x46E3F0 | 0x14046E3F0 | opponent car pick | call | O |
0x47A6F0 | 0x14047A6F0 | checkpoint tracking | function | O |
0x4BD3B0 | 0x1404BD3B0 | track-limit zones | function | O |
0x4C4640 | 0x1404C4640 | stray distances query | function | O |
0x4DA3B0 | 0x1404DA3B0 | cutscene component ready | function | O |
0x507020 | 0x140507020 | race zone name builder | function | O |
0x509860 | 0x140509860 | race activation creator | function | P (data) |
0x50A2E0 | 0x14050A2E0 | entity group file loader | function | P |
0x50B180 | 0x14050B180 | race activation files loader | function | P (data) |
0x558FE0 | 0x140558FE0 | FreeroamDrivatarComponent slot 4 | function | O |
0x5D8200 | 0x1405D8200 | route preload | function | P |
0x5D832A | 0x1405D832A | route preload world check | instruction | P |
0x5D833D | 0x1405D833D | route preload MediaTrack | instruction | P |
0x5E77C0 | 0x1405E77C0 | route list query | function | O |
0x61DF90 | 0x14061DF90 | race entity setup | function | O |
0x720C70 | 0x140720C70 | AITrackComponent load | function | O (file P) |
0x729A70 | 0x140729A70 | CarSpawnModule::Update | function | P |
0x729AB5 | 0x140729AB5 | spawner AI-world gate | instruction | P |
0x72A120 | 0x14072A120 | festival update | function | O |
0x72A650 | 0x14072A650 | traffic update | function | O |
0x84D924 | 0x14084D924 | null road crash site | - | O |
0x854F50 | 0x140854F50 | festival spawner | function | O |
0x855EB0 | 0x140855EB0 | traffic spawner | function | O |
0x92EAF0 | 0x14092EAF0 | SetSpawnMode | function | O |
0x93F191 | 0x14093F191 | SwitchOnActiveTrack compare | instruction | P |
0x93F2A5 | 0x14093F2A5 | switch_on_career_event_type null read | - | O |
0x961230 | 0x140961230 | WaitForFreeroamDrivatars | function | O |
0x978D10 | 0x140978D10 | WaitForCutsceneCinematicReady test (slot 0x70) | pointer | D |
0x98DC90 | 0x14098DC90 | point-to-point check | function | O |
0x996240 | 0x140996240 | IsCarAllowed | function | O |
0xD6E650 | 0x140D6E650 | Event Options: add row | call | P |
0xD6F470 | 0x140D6F470 | Event Options: Start | function | P |
0xD709F0 | 0x140D709F0 | Event Options: make row | call | P |
0xD78E50 | 0x140D78E50 | Event Options row builder | function | P |
0xF5B420 | 0x140F5B420 | collidable requests: make | call | P |
0xF5B890 | 0x140F5B890 | collidable requests: remove | call | P |
0xF5DB40 | 0x140F5DB40 | HOG reset target | function | P |
0xF60510 | 0x140F60510 | collidable request set getter | call | P |
0xF605D0 | 0x140F605D0 | car dynamics getter | call | P |
0xF62010 | 0x140F62010 | reset wrapper | function | O |
0xF62280 | 0x140F62280 | ForzaCar kind | call / function | P |
0xF649F0 | 0x140F649F0 | HideCar | function | P |
0xF713D0 | 0x140F713D0 | car placement | call | O |
0xF73080 | 0x140F73080 | collidable requests: add | call | P |
0xF75500 | 0x140F75500 | SetDriverVisible | call | P |
0xF79330 | 0x140F79330 | ShowCar | call | O |
0xF80160 | 0x140F80160 | valid-position recorder | function | O |
0xFB28C0 | 0x140FB28C0 | suggested driving line update | function | O |
0x1056210 | 0x141056210 | car physics builder | call | O |
0x105BEEC | 0x14105BEEC | clutch reader crash site | - | P (crash) |
0x117DC10 | 0x14117DC10 | CarScene constructor | function | O |
0x11A1910 | 0x1411A1910 | CarScene state machine | function | O |
0x12C5C90 | 0x1412C5C90 | dyn GetSpin | call | P |
0x12CBEB0 | 0x1412CBEB0 | dyn rotation rows | call | P |
0x12CD150 | 0x1412CD150 | dyn GetPosition | call | P |
0x12CDCF0 | 0x1412CDCF0 | dyn GetVelocity | call | P |
0x12DD910 | 0x1412DD910 | dyn SetAngularVelocity | call | P |
0x12E3CF0 | 0x1412E3CF0 | dyn SetVelocity | call | P |
0x132DA50 | 0x14132DA50 | CreatePedestrians | call | P |
0x132DAF2 | 0x14132DAF2 | pedestrian object name call | call site | P |
0x135A3C0 | 0x14135A3C0 | UpdatePedestrians | call | P |
0x137D8C9 | 0x14137D8C9 | driver placement call | call site | D |
0x138BC40 | 0x14138BC40 | crowd animation bake | function | P |
0x138C00C | 0x14138C00C | bake: arrays ready | instruction | P |
0x138FA00 | 0x14138FA00 | crowd Load | function | O |
0x13B2B60 | 0x1413B2B60 | crowd cheer/idle update | function | O |
0x18D0D30 | 0x1418D0D30 | .owt point to waypoint | function | O |
0x18D8660 | 0x1418D8660 | lane lookup between nodes | function | O |
0x18DFDF0 | 0x1418DFDF0 | LBWO tile reader | function | O |
0x18E0480 | 0x1418E0480 | FTWO (.owt) reader | function | O |
0x18E0620 | 0x1418E0620 | FWWO (.oww) reader | function | O |
0x190BF90 | 0x14190BF90 | send entity event | function | P |
0x190BFD0 | 0x14190BFD0 | send entity event with data | function | P |
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)
| Offset | Type | Meaning | Status |
|---|---|---|---|
+0x20 | sub-object | ICameraTarget (vtable game+0x2C5CE28); slots 6, 7: route segment, TrackMatrix | O |
+0x118 | u32 | Data_Car.Id | P |
+0x344 | i32 | car index | O |
+0x3F5 | u8 | no-collision byte | O |
+0x11D8 | vector | valid positions for resets (64 bytes each, newest last) | P |
+0x4C08 | ptr | CCarDynamics interface (re-read every frame) | P |
+0x4C58 | object | collidable request set; std::list at +8, last node = sentinel->prev; node+0x10 request, request+0x10 preset entry, preset name std::string at +0x20 | P |
+0x4D08 | i32 | kind: 0 local player, 1 Drivatar, 2 traffic, 3-5 remote | P |
+0x4D38 | ptr | ICarPresentation (+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+0x2EBB478 | P |
+0x4F10 | u8 | last SetDriverVisible value | P |
+0x4F50 | ptr | RaceLineProvider (made on message 0x24 with state 3) | O |
+0x4F70 | shared_ptr | RouteBindings; [[+0x4F70]+0xA8]+0x10 = the road tracker's current nav node | P |
+0x4F94 | i32 | respawn mode 0-4 | P |
+0x4FA0 | transform | stored reset place (mode 4) | O |
+0x50F1 | u8 | cleared by HideCar | P |
+0x50F5 | u8 | system use; 3 = recording playback | P |
+0x50F8 | CameraOverrides rows | O | |
+0x5370 | object | replay component (its first pointer is the car, once loaded) | P |
+0x59BA, +0x59C8, +0x59C9 | u8 | driven by a recording, relative, keep height | P |
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 dyn | Type | Meaning | Status |
|---|---|---|---|
-0x390 | float4 | position (centre of mass) | P |
-0x380 | 3 x float4 | rows right, up, forward | P |
-0x350 | float4 | velocity (m/s) | P |
-0x340 | float4 | spin, world | P |
+0x148, +0x1CC | float | engine speed, redline | O |
+0xAA1 | u8 | gear | O |
+0xDF8 | driver inputs | O | |
+0xEF0 | float4 | car offset for the hubs | P |
+0x1290 + i*0x4B0 | float4 | wheel hub i (0, 1 front) | P |
+0x1570 + i*0x4B0 | float | wheel radius i | P |
+0x4EE5 | u8 | anti-griefing flag (slots 0x950 set, 0x958 read) | O |
TrackMatrix (the AI's and race position's view of a route)
| Offset | Meaning |
|---|---|
+0x58 | waypoint ring buffer (64-byte waypoints: position, side, chi slots at +0x20 + 4*i) |
+0x60, +0x64, +0x68 | start, count, capacity |
+0xA0, +0xA4 | base, version |
+0xA8 | selected chi index (which line is drawn) |
+0xAC | looped flag |
Status: offline only.
CarSpawnModule
| Offset | Meaning |
|---|---|
+0x1A0 | spawning enabled (cleared by DisableSpawningWrapper) |
+0x1C8 | nav world (must be set) |
+0x1D8 | round-robin phase (mod 5) |
+0x1DC | spawn mode bits (1 Festival, 2 Traffic) |
+0x230 | density manager |
+0x2D8, +0x2E8 | festival spawner, traffic spawner |
Status: offline only; the gate's behaviour proven in game.
Pedestrian block
| Path | Meaning |
|---|---|
track+0x15458 | pedestrian 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 / +0xA8 | batches begin / end, 0x58 each: name std::string at +0x30, template at +0x50 (null = nothing drawable) |
data+0xD0, data+0xE0 | block 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*0x18 | batch b's entry list {int* first, int* last} |
crowd+0x1D98 | class records, 0x120 each; model list begin / end at +8 / +0x10 (0x20 per model) |
crowd+0x1EE0, +0x1EE1 | crowd 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)
| Offset | Meaning |
|---|---|
+0x10 | reference count |
+0x70 | Title (String: UTF-16 at +0x28, length at +0x30) |
+0x78 | SelectedIndex (i32) |
+0x80 | choice list |
+0x88 | std::function<void(LaunchOptions&, int)>; impl pointer at +0xA0 |
Status: proven in game.
