five-on-it / packages/sim/src/character
packages/sim/src/character
Characters: the on-foot avatars. A character is a dynamic capsule with locked rotations that is moved by setting its velocity from the input (walk, sprint, jump), so cars push it around like anything else. Its capsule is its body's (BODIES: a person's, or a dog's, as wide and less than half as high, lighter and quicker), set when it is spawned and kept on the client's twin (Character.body). Before it moves, the capsule is cast along its velocity: a wall or a car in the way removes the velocity component into it, so the character slides along obstacles instead of pushing into them and popping on top; slopes (ramps, the wedge under every staircase) are walked up and down. Pressing the action key does what interaction.ts decides: next to a car it goes to the door of a seat and gets in (boarding.ts; its body is switched off and it rides along), at the wheel or as a passenger, or pulls its driver out by force and takes the wheel after a beat (carjack.ts); the driver's seat forwards the player's input to the vehicle; pressing it again gets out at the seat's door, as the car's speed allows (boarding.ts: stepping out, bailing out, or staying in). By items, a container or a door it picks up, opens and shuts. Held at a locked car, it picks the lock, the character standing still at it (interaction.ts); at the wheel of a car standing still in a garage, the service input resprays or stores it (garages.ts).
Cover: with a wall or a car within reach of its aim, the cover key pins the character to it, hidden (it cannot shoot or be shot, crouching if the cover is low); pinned, it moves along the cover at a crouching pace, never away from it, and stops at its end. The expose input pops it up, able to shoot and be shot; at the end of tall cover it steps out past the edge instead, so it has a line of fire at what the cover hid, and steps back behind it when hidden again. The cover key again lets go, as does cover that is no longer there (a car that drove off). Health: a character at zero falls like a knocked-down pedestrian and, when the knockdown ends, respawns with full health: a pedestrian at its post, a player at the nearest spawn point; one that stays (a level's guard) lies where it fell for good. A knockdown may have a reason, its status (stunned, knocked out, asleep: status.ts), which ends when the character stands up. Cars hurt people on foot: a slow one shoves them out of its way, a fast one knocks them down and takes hit points by its speed (a survivor tumbles for its ragdoll time, the dead lie longer), and a character that finds itself inside a car's box (pushed in, or getting up under it) is set down beside the car.
Interfaces
Type Aliases
Variables
- BODIES
- BODY_DOG
- BODY_PERSON
- CAR_HIT_DAMAGE
- CHARACTER
- DOG
- FALL
- FLEE_PACE
- KNOCKDOWN_SPEED
- KNOCKDOWN_TICKS
- NO_VEHICLE
- RAGDOLL_TICKS
- TUMBLE_DAMPING
Functions
- characterSystem
- clearOfLifts
- doorFree
- doorSpot
- enterVehicle
- exitPoint
- exitVehicle
- feetOf
- getCharacterSeat
- getCharacterVehicle
- inCover
- isDog
- isDown
- isIndoors
- knockDown
- listCharacters
- personSpotTaken
- putOut
- removeCharacter
- respawnCharacter
- seatsTaken
- setBody
- setCowering
- setIndoors
- slideAlongObstacles
- spawnCharacter
- stopAtCar
- syncCharacters
- throwOffFeet
- vehicleOccupants