Suspect Traffic Role
Reference for the `suspect` traffic role, which marks a vehicle as a wanted suspect that police will chase. Manages the transition from watched → wanted → fleeing → arrested states.
Reference for the suspect traffic role, which marks a vehicle as a wanted suspect that police will chase. Manages the transition from watched → wanted → fleeing → arrested states.
Role Properties
| Property | Value | Description |
|---|---|---|
personalityModifiers.aggression | offset +0.2 | More aggressive driving |
pursuitMode | 2 | Default pursuit mode (aggressive) |
Actions
| Action | Description |
|---|---|
watchPolice | Initial wanted state - waiting for police to notice |
fleePolice | Active flee mode: max aggression (0.8), no lane/speed limits, strong respawn resistance |
arrest | Freezes vehicle (controller freeze) |
clear | Clears all pursuit flags, unfreezes vehicle |
Key Methods
onRoleEnded()
If the player was the target, triggers police evasion event.
onTrafficTick(tickTime)
Main logic per 0.25s tick:
- When in
"wanted"state, checkspursuit.sightValueagainst threshold (0.25 for AI, 1.0 for player) - If sight threshold met and speed threshold met:
- Finds available (non-busy, non-reset) police vehicles
- Calls
gameplay_police.setPursuitMode()to start the chase - Targets the nearest police vehicle
onUpdate(dt, dtSim)
Currently a no-op - all logic runs in the tick handler.
Internals
State Flow
watchPolice → (police notices) → fleePolice → (caught) → arrest → (cleared) → clearSight & Speed Thresholds
| Condition | AI Vehicle | Player Vehicle |
|---|---|---|
| Sight value threshold | 0.25 | 1.0 |
| Speed threshold (normal) | 0 m/s | 0 m/s |
| Speed threshold (drive check) | 1 m/s | 1 m/s |
The driveCheck flag increases the speed threshold, requiring the suspect to actually be moving before police engage.
Flee Mode Details
When fleeing:
- AI mode set to
"flee" - Aggression set to 0.8
- Aggression mode OFF (no automatic slowing)
- Drive in lane OFF, speed mode OFF
- Respawn values heavily modified (800 active radius, 40 inner radius)
Usage Example
-- Assign suspect role to a traffic vehicle
local veh = gameplay_traffic.getTrafficData()[vehId]
veh:setRole('suspect')
veh.role:setAction('watchPolice')
-- Manually trigger flee
veh.role:setAction('fleePolice')
-- Arrest the suspect
veh.role:setAction('arrest')
-- Clear suspect status
veh.role:setAction('clear')See Also
- gameplay/traffic/roles/empty - Empty Traffic Role - Related reference
- gameplay/traffic/roles/police - Police Traffic Role - Related reference
- gameplay/traffic/roles/standard - Standard Civilian Traffic Role - Related reference
- Gameplay Systems Guide - Guide
Standard Traffic Role
Reference for the `standard` traffic role, the default role for civilian traffic vehicles. Implements reactive behavior to collisions and crashes - pulling over, fleeing, following, exchanging insuran
Crash Detection
Reference for `gameplay_util_crashDetection`, which tracks vehicle damage in real-time to detect crashes and individual impacts. Provides event hooks for crash start/end and impact start/end, with acc