Skip to content

five-on-it / packages/sim/src/interaction

packages/sim/src/interaction ​

The interaction key on foot (GAME_DESIGN §7.2): one context key, E, whose action is decided in one place, interactionOf. The server acts on it in the character system; the client shows it as the prompt beside the character, worked out from its own view of the world (the server stays the judge of range and side). Also what the item keys do (itemSystem): use and drop the selected item, and move items in and out of the container the character has open.

The candidates, each with its reach and the side it is used from:

  • a car within reach (carjack.ts): get in at the wheel, carjack its driver at the driver's door, or ride along, by the door of the seat (boarding.ts); a locked car (locks.ts) is unlocked on the way in by its key (Unlock), or says it is locked: held for PICK's seconds, the key picks its lock (pickLock), the character standing still at it;
  • a car's trunk: from behind a car standing still that nobody drives and that opens to the character, within REACH.trunk of its rear bumper (a two-wheeler has none);
  • a stored car taken out (garages.ts): standing in the empty bay of a garage that stores, with a car stored, as if a metre away;
  • items on the ground: picked up within REACH.pickup;
  • a crate from any side, or a locker from its front, within REACH.container: opened into a panel;
  • a door, from either side within REACH.door of its doorway: opened (swung away from the character) or shut again;
  • a locked door or container says Locked, and does nothing, unless the character carries an item with its tag: then it opens, unlocked for good;
  • a door a keypad locks asks for its code (keypad), from either side;
  • a contact (a character with the contact role, on its feet) says Talk within REACH.talk; a terminal says Use or Hack from any side within REACH.terminal (interactables.ts). These three only raise an interact event: the server's missions open the conversation, the terminal's screen or the keypad;
  • a shop (a terminal whose verb is shop) says Shop like a terminal: it opens its stock as a panel, and taking a line out of it buys one, paid in the player's Cash (cash.ts), when it fits in the inventory;
  • a body (GAME_DESIGN §8) within REACH.body of its centre: an NPC asleep, knocked out or dead (never a player, never a pedestrian), whose pockets a player searches (they open as a panel, like a container's); an NPC at the key instead wakes one that sleeps or is knocked out (a shake);
  • the container the character has open: closed, before anything else (the panel's E).

The closest wins: each candidate is measured from the character to the nearest edge of what it acts on (a car's or a container's footprint, a door's doorway, the items' spot, a person's capsule, a body's centre). Two within TIE of each other go by PRIORITY: what is open first, then the items, a person to talk to, a body, a terminal (a shop), a container, a trunk, a stored car (take out), a door, and the car last (carjack, unlock, get in, ride along, pick), so the particular thing beats the car parked beside it, and the trunk beats getting in when standing right behind an empty car. A garage's respray and storage are not interactions: the panel's 1 and 2 at the wheel.

Cash (cash.ts): the cash items a player picks up or takes out of a container are counted into their Cash, never into a slot.

Interfaces ​

Type Aliases ​

Variables ​

Functions ​