Skip to content
Menu
Mob City
  • Home
  • Contact
  • Patreon
  • About
Mob City

Combat System v0.1

Posted on December 13, 2025

Mob City isn’t just a city simulation; it’s a living sandbox where crews, police, and civilians react to danger. The combat layer aims to run well with very large crowds, and feel grounded – shots are loud, people panic, and order can reassert itself when the dust settles.

High‑Level Flow

Under the hood, the game loop runs events → update → render. Combat plugs into the update phase in four passes designed for clarity and performance:
1) Perception: Units gather local signals (shots heard, hostiles seen, orders received).
2) Intent: Each unit picks a state (idle, guard, engage / chase, flee) and a target or way-point (grid cell).
3) Resolution: Line‑of‑sight checks, hit resolution, and health changes occur. Note: shooting obstacles are not yet implemented

Below is a loop over potential aggressors (gangsters, police, etc.). The function names are quite descriptive so you can see the life cycle. In the future, again, I may vectorize this for performance as well.

While the system is incomplete, it’s a good foundation to build on. So far, directional shooting changes were the most difficult implement because it required interaction between OOP and vectorized elements/objects of the code. Below you can see a working video

Core Concepts

  • Units & States: Every combatant tracks a compact state machine: idle → guard → engage / chase → (optionally) flee or downed. Health points are yet to be implemented but trivial to do
  • Line of Sight (LOS): Engagement requires visibility; LOS is checked against the world grid. This is central to target acquisition and determines whether a shot can be taken.
  • Fire Resolution: When a shot is taken, accuracy and damage resolve instantly within the current tick. The result adjusts health; death transitions the unit to a non‑interactive state and updates sorting/animation.
  • Roles in the World: Policemen engage threats but are designed to return to their patrol state if no issues remain. Gangsters engage per player intent but may flee based on stance (or to be implemented – situational pressure)

NPC Behaviors and performance

Units respond to immediate threats they can hear or see. Policemen de‑escalate by returning to patrol once a scene clears, while gangsters weigh stance and local odds and may abandon a fight if morale breaks. To prevent visual “blips,” state transitions are de-bounced across ticks so momentary perception changes don’t trigger split‑second shooting or animation flicker. Below you can see a policeman and a rival gangster chasing down our poor Zachary “Goose” Clukies

The goal is a combat layer that feels immediate and legible while scaling to city‑level chaos. With a simple, vectorized core and clear state transitions, the game can stage big firefights without losing the story beats – panic, pursuit, and the return to normalcy when sirens fade.

Below you can find how a typical battle may look like

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Combat System v0.1
  • A call to arms! (really just admin stuff)
  • Toggling view modes and unit selection
  • Building occlusion
  • Rendering 120k+ entities
©2025 Mob City