Skip to content

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

packages/sim/src/carjack ​

What the interaction key does to a car, and carjacking (GAME_DESIGN §6.3 and §7.2). What the key does is decided in one place, interactionOf (interaction.ts), which weighs every car within reach against the other things the key acts on; this module says what it would do to one car (vehicleInteraction) and carries out a carjack.

Next to a car within reach (as getting in always was: its half length plus CHARACTER.enterRange), a wrecked one never:

  • an empty driver's seat is taken (Get in);
  • a driver is pulled out (Carjack) by a character standing beside the driver's door (on that door's flank, the left but for the bus, between the bumpers, not nearer another doorway of that flank well apart from it: the bus's middle one) while the car is stopped or crawling (8 km/h at most), unless the driver is a player and the game's rules do not let players hurt each other (SimRules.playerDamage off; on in free roam), or is in the carjacker's party (Character.party), or the car stands in one of the game's safe zones (griefing.ts);
  • otherwise a free seat is taken (Get in as passenger): from behind, in front, on the far side, or when its driver may not be carjacked, riding along as it always was; of the free seats, the one whose door is nearest;
  • a car faster than a crawl (seats.ts' exitMode), nothing: nobody gets in a moving car.

Getting in goes by the seat's door (boarding.ts); a seat someone is getting in is kept for them, as the wheel is for a carjacker in its beat.

A locked car (locks.ts) changes that, but for the carjack, which is by force: one the character carries the key of (and does not own) says Unlock, which unlocks it and takes the seat it would have taken; an empty one without the key says Locked, and the key held picks its lock (pick, interaction.ts); one with a driver it may not carjack stays shut (locked). Its owner finds it open.

A carjack pulls the driver out at the driver's door (a step clear of the carjacker when it stands right at it) and knocks them down for their tumble time (the knockdown a car deals a person, without the damage); every other occupant gets out at their own door, standing (a member of the carjacker's party would stay aboard); the dead slumped in their seats (boarding.ts) are pulled out and lie dead at their doors; a carjack event is recorded, which the server's missions and the AI read and the client logs. The carjacker then stands at the door for a beat of half a second, facing it, the wheel kept for it and its hands busy (no shots), and, if the car is still there, whole, driverless and within reach, gets in where it stands as anybody does at a door (boarding.ts' getInAt: half a second more, then it has the wheel). Knocked down meanwhile, it lets go (knockDown). A car carjacked is the carjacker's from then on.

Variables ​

Functions ​