commit 8d0f5692e802e27536be7e199bb43e15f2a09aa1 Author: Fabian @ Blax Software Date: Mon Nov 30 22:42:53 2026 +0100 docs: Blax Laws design and README draft Lawbook, crimes and punishments for RimWorld 1.7: design for nine releases, 1.0 still to be reworked around a full crime catalogue. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..02c2c8c --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +Source/**/bin/ +Source/**/obj/ +.vs/ +*.user +Tests/**/1.7/ +Tests/**/bin/ +Tests/**/obj/ +Tools/**/bin/ +Tools/**/obj/ +docs/media/raw/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..a427a25 --- /dev/null +++ b/README.md @@ -0,0 +1,83 @@ +# Blax Laws + +[![RimWorld 1.7](https://img.shields.io/badge/RimWorld-1.7-19C63C)](https://rimworldgame.com) +[![Needs Harmony](https://img.shields.io/badge/needs-Harmony-050805)](https://steamcommunity.com/sharedfiles/filedetails/?id=2009463077) +[![Any DLC combination](https://img.shields.io/badge/DLCs-any_combination-5a6b5d)](#dlc-support) +[![Status: design](https://img.shields.io/badge/status-design-CDCDCD)](docs/design.md) + +RimWorld mod (1.7) by Blax Gaming. Lawbook, crimes and punishments. Write your colony's laws, and colonists who break them get stopped, jailed and, later, tried in court. Add "Drug binge, planning, subdue" and when a colonist starts a wake-up binge, a warden goes for it at once and beats it down; if it reaches a drug first, that dose counts as "did it" and the did-it law applies. Add "Drug binge, did it, jail 5 days" and the one who already took some sits out five days in your prison and walks back to work. Needs Harmony. Works with any DLC combination, core only included. + +Status: design. Nothing is built yet; below is what 1.0 will do. The full design is in `docs/design.md`. + +## Features + +### The lawbook + +- 📖 **An empty lawbook.** A "Laws" tab in the bottom bar. Add a law as Action (with an option such as "wake-up"), Stage, Severity, Punishment and Days, each a dropdown that only offers what fits. Nothing is watched or punished until the first row exists. `Source/BlaxLaws/MainTabWindow_Laws.cs` +- 📝 **Starter lawbook.** One click adds seven suggested laws: subdue drug binges, fire-starting sprees and corpse obsession before they start, jail for binges and fires already done, a warning for fights and insults. `Source/BlaxLaws/Lawbook.cs` +- 🎯 **One law per act.** Each action, option and stage appears once in the book, and when two laws fit an act the more specific one wins: "wake-up" over "any drug", "human meat" over "any meat". +- 🎚️ **Stages that mean something.** "Planning" is the moment a mental break starts and nothing is done yet; "Did it" is the act. A crime only offers the stages the game can really tell apart. +- 📋 **Case log.** Who, what, when, which punishment and how it ended, newest first, with a jump to the pawn and "Arrest now" for cases that wait. + +### Crimes + +- 💊 **Drug binge.** Any drug, hard or social drugs, or one chemical such as wake-up. Planning when the binge starts, did it with every dose. `Source/BlaxLaws/Detection/BingeHooks.cs` +- 🔥 **Fire starting.** Planning when a pyromaniac's spree starts, did it with every fire set. +- ⚰️ **Corpse obsession.** Planning when the obsession starts, did it when the corpse is on display; the case notes "on a table" and whether the corpse was dug up from a grave, which it usually is. +- 👊 **Started a fight.** The pawn who reacts and swings first, usually the insulted one. +- 🗯️ **Insults.** Every insult by the one who insults, slights too if you want. Planning for insulting sprees. +- 🍖 **Ate meat.** Any meat (meals included), raw meat and corpses, or human meat. +- 🧮 **No flood.** Meat, fights and insults outside a break open at most one case per colonist and law a day; more acts only raise its count. + +### Punishments + +- ✋ **Warn.** A record and a message. +- ⚖️ **Guilty for N days.** Vanilla guilt: the arrest of a free colonist is always accepted, executing it costs the colony only the small "justified execution" mood hit plus its family's grief, and banishing it costs no colony-wide mood. +- 🛑 **Subdue.** A warden beats the offender down with fists to stop the break: bruises on torso and limbs, never the head or a bionic part, no lost parts, no scars, and the beating doesn't hand out the break's catharsis. No warden is pulled off a rescue, a patient or a fire, and nobody is sent while raiders are on the map. `Source/BlaxLaws/JobDriver_Subdue.cs` +- 🔒 **Jail for N days.** Arrested into a prisoner bed, kept on "Maintain only" so no prison mod recruits or enslaves your colonist, released by a warden when the time is served, back to work with its priorities intact. `Source/BlaxLaws/Enforcement.cs` +- 🔗 **Subdue, then jail.** Beaten down and carried straight to a cell before a doctor takes it to bed. + +### Save and settings + +- 💾 **Save-safe.** One piece of game data holds the lawbook and the cases. Unsubscribing leaves a save that loads with two errors in the log; jailed colonists stay prisoners you can release by hand. `Source/BlaxLaws/GameComponent_BlaxLaws.cs` +- ⚙️ **Mod settings.** "Enforce laws", "Show Laws tab", messages and letters, who enforces, catharsis after subdue, player orders exempt, days between cases for acts outside a break, how long closed cases stay, "Reset to defaults". + +## Planned + +Later releases, in order (details in `docs/design.md`): + +- 🛏️ **1.1 Sentences done right.** Release gives back the bed, grave, throne, deathrest casket, ideoligion role and mech work modes. Pardon and early release, reprimands, jail for slaves, banishment and execution after your confirmation, and "Trial" through Ideology's vanilla trial. +- 🔪 **1.2 Violent crimes.** Tantrums and vandalism, assault, harming prisoners or slaves, murderous rage, manslaughter and murder. +- 🏛️ **1.3 Court sessions.** Trials without any DLC: a judge, a prosecutor and spectators at a place you pick, a verdict that weighs evidence against Social skill, the sentence from your lawbook. If you want, the court sits on its own at a set hour. A button removes the mod from a save. +- 🗳️ **1.4 Elected judge.** The colony votes for a judge for 60 days at a time, with by-elections and recalls. +- 🗣️ **1.5 Attorneys.** The accused asks a colonist to defend it or speaks for itself; both sides argue with Social. +- 📅 **1.6 Multi-day trials and courtrooms.** Up to three court days for grave crimes, custody between them, and courtrooms that make a verdict easier to accept. +- 🙋 **1.7 Law votes.** Colonists propose and repeal laws and vote by traits, beliefs, opinion and mood, and you can back or veto the result. +- 🚪 **1.8 More crimes.** Jailbreaks, desertion, slaughtering colony animals, food binges, drugs against the drug policy, prison breaks, slave rebellions. + +## DLC support + +Blax Laws works with any combination of DLCs, core only included, and lists none as a dependency. Every 1.0 crime and punishment runs on the core game. + +- **Ideology** adds slaves, who can be warned, marked guilty and subdued. Role holders aren't jailed automatically in 1.0, because an arrest takes their role. +- **Biotech** adds children, who are never beaten, and mechanitors, who aren't jailed automatically in 1.0, because an arrest shuts their mechs down. +- **Royalty**, **Anomaly** and **Odyssey**: 1.0 uses none of their content. +- **A save made with a DLC** loads without it. + +## Compatibility + +- ✔️ Prison Labor, Prisoner Realism, Custom Prisoner Interactions and Hospitality: a jailed colonist is a vanilla prisoner, so their features apply; Laws only keeps its own prisoners on "Maintain only" and lets them go when the time is served. +- ✔️ Prisoner Sentencing and Prison Expanded: if one of them releases a colonist Laws jailed, Laws closes its sentence instead of fighting it. +- ✔️ RimCourt: it judges civil disputes as the lord, Laws tries those who break your laws; both run side by side. +- ♻️ Replaces Rimworld Law and Order, which has no 1.7 build, needs Ideology and adds its own crime events. +- ❌ Multiplayer: not supported. + +Load order: Harmony, Blax Castes, Blax Zones, Blax Slaves, Blax Laws. No Blax mod needs another. + +--- + +## Made by Blax + +[![Blax Software Open Source Initiative](docs/art/blax-oss-banner.svg)](https://www.blax.at) + +🛠️ **Blax Gaming** is a project of **[Blax Software](https://www.blax.at)**, an Austrian software practice. We write Austrian-quality code in many fields: web platforms, mobile apps, backends, infrastructure, and the mods we play in our own colonies. Need something built? 👉 [www.blax.at](https://www.blax.at) diff --git a/docs/design.md b/docs/design.md new file mode 100644 index 0000000..ad6a80c --- /dev/null +++ b/docs/design.md @@ -0,0 +1,710 @@ +# Blax Laws + +Write a lawbook and the colony enforces it. Add "Drug binge, planning, subdue" and when a colonist starts a wake-up binge, a warden goes for it at once and beats it down; if it reaches a drug first, that dose counts as "did it" and the did-it law applies. Add "Drug binge, did it, jail 5 days" and the one who already took some is arrested, sits out five days in your prison and walks back to work. The book starts empty and only watches what the game already does: drug binges, fire-starting sprees, corpse obsession (the corpse on the dining table), social fights, insults and eating meat. Later releases add violent crimes, a court with a judge the colony elects, attorneys who argue with their Social skill, trials over several days, colony votes on the laws themselves and more crimes. + +Status: design, no code yet. Checked against the RimWorld 1.7.5021 game code on 2026-11-30. RimWorld 1.7, package id `blax.laws`. From the first release a plain unsubscribe leaves a save that loads: jailed colonists stay vanilla prisoners and the log shows 2 errors. + +Next (Fabian, 2026-11-30): the crimes are not a fixed set of six. His examples were entries of a full list: a law's Action is picked from a searchable catalogue built from the game's defs at runtime (every mental break, anything eaten or used, every social interaction, recorded acts, finished bills), like choosing what to tailor, so modded and DLC content shows up. The six crimes below become starter lawbook rows; the 1.0 section, data model, detection, tests and the later crime releases still need that rewrite before the build starts. + +Changes on 2026-11-30, after three reviews: + +- Plan re-cut: 1.0 takes 10 days instead of 7, because the enforcement core, the case lifecycle, the capture hook and the scaffold now have a budget. 1.0 still ships whole: cutting it to the wake-up example would save one day. The violent crimes stay in 1.2, right before the court; the other new crimes move behind the votes as 1.8, so Fabian's court, judge, attorneys and votes come first. 1.3 gains "Convene court on its own" at a court hour. The plan is 49 days instead of 44. +- Fixed what would have broken the save promise: the subdue job is no longer suspendable, so a vomit or a forced wait can't push it into the saved job queue, and the save prefix pulls it from the queue as a backstop. +- Enforcement made safe for permadeath: the enforcer is never pulled off a rescue, a tending, a fire, a turret, a surgery or a flight, and nothing is enforced while hostiles threaten the map. Arrests check their reservations first. Subdue hands over to the vanilla capture through the job queue the moment the target goes down. +- Jail fixed against the game: the arrest job itself takes the colonist's bed, so Laws snapshots it before the job and gives it back when the arrest fails; guilt is renewed right before every arrest and the sentence counts from the capture; a hook on `CapturedBy` (and in 1.1 on `GenGuest.PrisonerRelease`) replaces "one tick after the capture", which nothing could detect; "Maintain only" lands two ticks after the capture, after any next-tick default from Castes or a prison mod. +- Subdue made reliable: hits are timed by game ticks (the toil runs on a tick interval), bionic parts are skipped, damage is scaled for Tough pawns, and the job stops once three hits in a row add no pain instead of after a fixed 20. +- Rules the lawbook lacked: one enforcement per case, a later stage's punishment replaces an unfinished earlier one; Action, Option and Stage are a row's key and the most specific row wins; the cooldown covers every act outside a break, meat included; a row spec says which punishments and days each crime and stage offers. +- Vanilla behaviour corrected: executing a guilty colonist still costs the -2 "justified execution" thought and its family's grief; corpse obsession nearly always digs the corpse up, read from the corpse, not from the job. +- Court and votes: the verdict weighs only what the case records (no witnesses, no "found later"); law votes watch acts in a tally-only mode so proposals after an unlawed act can fire. +- Matched with Blax Castes: Laws always writes Maintain only and Release for its convicts, Castes 1.4 skips hinted pawns, a jailed colonist goes to the new-prisoner row, never the captured row, and the shared ownership lines gain the same exceptions in all five docs. + +Changes on 2026-11-30, first design: + +- Built from Fabian's request of 2026-11-30 and six research passes: crimes, punishments, court, votes, the Workshop landscape and the Blax conventions. Every game behaviour the design relies on was checked again in the decompiled 1.7 code and cites file:line. Code paths are relative to the decompiled Assembly-CSharp, XML paths to the game's Data folder. Anomaly and Odyssey aren't installed here, so their parts are read from code only. +- 1.0 is the quick MVP: lawbook, six crimes, subdue and jail, in 7 days. No court in 1.0. Each later release ships on its own. +- Stages are what the code can tell. "Planning" means the mental break has started and nothing is done yet, so it exists only for crimes that start as a break. The game rolls the break type at the moment the break starts (Verse.AI/MentalBreaker.cs:311-328); before that it only knows that some break is close, never which one. +- Nothing of Laws enters a vanilla save list, the subdue job included: it is hidden from the save while it runs (see "Data model"). +- The court doesn't reuse the vanilla Ideology trial as its engine: there the leader is always judge and prosecutor, nobody defends, crowd size decides and core-only games have none. Laws runs its own court on core classes and listens to the vanilla trial when Ideology is active. + +## At a glance + +| Version | What players get | Needs | Replaces | Days | +|---|---|---|---|---| +| 1.0 | An empty Laws tab. Add a law as Action, Stage, Severity, Punishment and Days, or press "Starter lawbook". Six crimes from vanilla behaviour: drug binge (any drug or one, wake-up included), fire starting, corpse obsession, starting a social fight, insults, eating meat. Punishments: warn, guilty for N days, subdue (a capped beating that stops a break and never kills), jail for N days then back to work, subdue then jail. A case log, messages and letters | None (slaves: Ideology) | Rimworld Law and Order (419, 1.6 only, needs Ideology). Covers "arrest my own pawn for assault" and "reprimand my own pawn" asked on Prisoner Sentencing (1.3k) and "colonists commit small crimes and get caught" asked on RimCourt (8.8k) | 10 | +| 1.1 | Sentences done right: release gives back the bed, grave, throne, deathrest casket, ideoligion role and mech work modes. Pardon and early release. Reprimand (mood). Jail for slaves. Banish and execute as confirmed punishments. "Trial" as a punishment, through Ideology's vanilla trial. Blax Castes keeps the caste through any sentence | None (slaves, trial: Ideology; throne: Royalty; casket, mechs: Biotech) | Custom Guilt Duration for colonists (3.4k, no 1.7), Guilty! (302, 1.6) | 6 | +| 1.2 | Violent crimes: tantrum and vandalism, assault, harming prisoners or slaves, murderous rage, manslaughter, murder | None | Law and Order's assault and murder crimes | 3 | +| 1.3 | Court sessions on the core game: a case goes to trial before an appointed judge, a prosecutor and spectators at a place you pick, when you convene it or, if you switch that on, at the next court hour. The verdict weighs the evidence against the speakers' Social skill, and the sentence comes from the lawbook. A button removes Laws from a save | None | The vanilla trial as the only court (Ideology), Law and Order's trials | 9 | +| 1.4 | Elected judge: the colony votes by opinion and Social skill, for a 60-day term, with by-elections and recalls. With Ideology the leader or the moral guide can be judge instead | None (leader as judge: Ideology) | None; overlaps Rimocracy (6.3k), which elects leaders | 4 | +| 1.5 | Attorneys: the accused asks a colonist to defend him or speaks for himself; prosecutor and defender argue with Social, gain Social XP and are remembered for it | None | None; answers the prosecution and defence request on RimCourt | 3 | +| 1.6 | Trials over 1 to 3 court days by severity, custody between the days, and courtrooms that make a verdict easier to accept | None | None | 6 | +| 1.7 | Law votes: colonists propose and repeal laws, each pawn votes by traits, ideoligion, opinion and mood, the result says why, and you can back or veto it | None (precept stances: Ideology) | None; overlaps Rimocracy's decisions (6.3k) | 5 | +| 1.8 | More crimes: jailbreak, desertion, slaughtering colony animals, food binge, drugs against the drug policy, prison break, slave rebellion | None (slave rebellion: Ideology) | Law and Order's sabotage crime, partly | 3 | +| Total | | | | 49 | + +Effort: S = 0.5 days, M = 2, L = 5, summed per release and rounded up. Subscriber counts are current subscribers from the Steam Web API (GetPublishedFileDetails), read on 2026-11-30; "no 1.7" means the item has no 1.7 tag. Needs: "None" means the release runs on the core game, and a DLC in brackets marks the parts that switch off without it (see "DLC support"). + +Total: 49 working days. 1.0 takes 10 and is useful alone. It ships whole: a 1.0 cut to the wake-up example (lawbook, binge, fire and corpse; warn, subdue, jail) would still need the enforcement core, the subdue job, jail and the scaffold, and would save one day. 1.1 comes next because 1.0's jail leaves gaps a long colony feels (unclaimed beds, lost roles). 1.2 adds only the violent crimes, the cases a court is most often wanted for (assault, murder), so the court line (1.3 to 1.6) starts on day 20 and builds step by step. Law votes (1.7) reuse the voting core of the judge election (1.4). The other new crimes (1.8) wait until the court, the judge, attorneys and votes are out, since those are the additions asked for. + +## Defaults I picked + +Change if you disagree. + +- Name: Blax Laws, subtitle "Lawbook, crimes and punishments". It keeps the one-word plural of Slaves, Castes, Zones and Defaults, and says what the player edits: a book of laws. "Court" names one later feature, "Justice" and "Legislation" are abstract nouns that break the plural pattern, and "Law" alone sits next to "Law and Order" on the Workshop. Mods folder `BlaxLaws`, Forgejo repo `rimworld-blax-laws` when you create it. +- The lawbook starts empty, in new games and in saves the mod is added to. Until a row exists Laws detects nothing and punishes nothing (from 1.7, while law votes are on, it counts acts without opening cases). +- "Starter lawbook" adds seven suggested rows in one click, only when pressed: drug binge (any drug) planning: subdue, Moderate; drug binge did it: jail 5 days, Serious; fire starting planning: subdue, Serious; fire starting did it: jail 10 days, Grave; corpse obsession planning: subdue, Moderate; started a fight did it: warn, Minor; insult did it: warn, Minor. "Ate meat" is left out, since most colonies eat meat. Pressing it again adds only rows that are missing. +- Action, Option and Stage together are a row's key: the editor refuses a second row with the same three and jumps to the existing one. When several enabled rows match one act, the most specific wins: one chemical over hard or social drugs over any drug, human meat over raw meat over any meat. The starter rows plus "wake-up, did it, jail 10 days" give a wake-up binger one case and 10 days. +- Stages: "Planning" (the break has started, nothing done yet) and "Did it". The stage dropdown offers only the stages a crime really has: planning exists for drug binges, fire-starting sprees, corpse obsession and insulting sprees, never for meat, fights or a random insult. No guessing from mood or traits. +- Severity is Minor, Moderate, Serious or Grave. It sets the default days (1, 3, 5, 10), orders the case log and, from 1.3, weighs in court. Days go from 1 to 50, so a sentence plus the release walk stays inside Blax Castes' default memory of the old caste (60 days). +- Punishments in 1.0: Warn, Guilty for N days, Subdue, Jail for N days, Subdue then jail. Planning (binge, fire, corpse, insulting spree) offers Warn, Subdue and Jail. Did it offers all five for those crimes, and Warn, Guilty and Jail for meat, fights and insults. Subdue acts only while the offender is still in its break; after the break a Subdue row warns and a Subdue then jail row jails. +- One case per incident. A binge is one case from its start to its end; it moves from planning to did it, and each row fires once per case. A dose count and notes ("on a table", "dug up from a grave") go into the case. +- One enforcement per case. A later stage's punishment replaces an unfinished earlier one: a did-it Jail that arrives while the planning subdue still runs ends the subdue, and the same enforcer starts the arrest, or the capture if the offender is already down (Verse.AI/GenAI.cs:39-67). Warn and Guilty run alongside. +- Acts outside a break (meat, fights, insults outside a spree) open at most one case per offender and law per day (setting, 0 to 7 days). A further act inside that window raises the count on that case and posts no message, so a feud or a meat-eating colony of 60 doesn't flood the log or the save. +- Who the laws cover: free colonists, children included, and colony slaves. Never guests, Hospitality visitors, quest lodgers, prisoners or babies. Slaves get Warn, Guilty and Subdue in 1.0; jail for slaves comes in 1.1. +- Children (Biotech) are never beaten: Subdue on a child becomes Jail when the row has days, otherwise Warn. +- Player orders are exempt: an act done while drafted or on a player-forced job opens no case (setting). +- Who enforces: the nearest awake free colonist with Warden work active who can do the job (violence for subdue, manipulation for an arrest), then anyone able. Never a slave, a child, the offender, a pawn in a break, a pawn on a player order, a pawn in a party or ritual, or a pawn on a job that must not be dropped: rescuing, carrying or tending someone, fighting a fire, manning a turret, surgery, fleeing. +- Laws starts the enforcer's job at once, interrupting what it does. Law enforcement is urgent; a binge's first dose comes as soon as the pawn reaches a drug, and the binge goes for the closest drug on the map (RimWorld/JobGiver_Binge.cs:17; RimWorld/JobGiver_BingeDrug.cs:83). The one exception is danger: while hostiles threaten the map, nobody is sent, the case waits and the sweep retries after the fight. +- Subdue hits torso and limbs only, never the head or a bionic part, with capped blunt damage that leaves bruises, and stops at downed or once three hits in a row add no pain (go-juice, painkillers). The subdued pawn loses the Catharsis that ending its break would give (setting), so the beating doesn't reward the crime. +- Jail convicts through vanilla guilt for the sentence length, renewed right before the arrest. While it lasts the arrest of a free colonist is always accepted. Executing a guilty colonist costs the colony only the -2 "justified execution" thought (ideoligion precepts may change it) plus its family's grief; banishing it costs no colony-wide thought, though banishing it to its death still grieves its family. +- A jailed colonist is set to "Maintain only" two ticks after the capture, after any default a prison mod or Blax Castes writes, so no default recruits, enslaves or executes it. When the sentence is served Laws sets "Release" and a warden walks it out; if nobody has after a day, Laws releases it in place. +- Role holders (Ideology) and mechanitors with mechs (Biotech) aren't jailed automatically in 1.0, because arrest takes the role and shuts the mechs down. The case waits with an "Arrest now" button and a letter says why. 1.1 gives both back after release and drops the hold. +- Messages for every case. Letters only when a colonist is jailed or you have to act: no prisoner bed, no enforcer, a role holder on hold. The vanilla break letter already arrives, so Laws never sends a second letter for a break. +- "Enforce laws" switched off keeps the case log running and carries out nothing. +- Laws adds no crime events and no mental breaks. It only watches what the game does anyway; Law and Order was called useless after its crime events flooded a commitment save. +- The court convenes when you press "Convene court" (1.3), or on its own at the court hour once you switch on "Convene court on its own" (off). "Trial" is a punishment you pick per row. The judge is appointed until you switch to elections (1.4). Votes are off per save until you switch them on (1.7). +- Multiplayer: not supported. + +Everything below is for the modder building it. + +## Data model + +Three parts carry everything: the component, the defs and the hooks. Enforcement and the subdue job sit on top of them. + +### Lawbook and cases in one GameComponent + +All state lives in one `GameComponent_BlaxLaws`. Laws are colony policy across every map, caravan and world pawn, so a MapComponent would be the wrong place. + +- Saved: + - `List laws` (deep) and `nextLawId`. A `Law` holds only names and numbers: id, crime defName, option (a chemical defName, a meat kind or "slights too"), stage and severity as enum names, punishment defName, days, enabled. + - `List cases` (deep) and `nextCaseId`. A `Case` holds the offender (pawn reference plus name and ThingID), the victim (same), crime defName, mental state defName for planning cases, stage reached, count, note flags, open tick, status (Open, Enforcing, Jailed, Closed), outcome key, enforcer reference (one enforcement at a time), which stages' punishments ran, the last act tick for the cooldown, and for jail the capture tick, whether the Maintain only write is done, the release tick and the bed the pawn owned before the arrest job. + - A random int token for ids handed to other mods later, as Castes does. +- Pawn references: Castes' pattern. `Scribe_References` with `logNullErrors` off; on save and after load, references to Discarded or destroyed pawns become null and the case keeps the name. Closed cases older than the retention setting (60 days) are pruned on save. +- Not saved: the watched-crime flags and the enforcement queue (both rebuilt), the instance cache (a weak reference, as in Castes). +- `Game.FillComponents` adds the component to a new game and after loading (Verse/Game.cs:345, 443-446, 472-489), so a save made without Laws loads with an empty book. +- Plain unsubscribe: the component node loads as null with exactly 2 errors, "Could not find class BlaxLaws.GameComponent_BlaxLaws" and "SaveableFromNode exception: Can't load abstract class Verse.GameComponent", and `FillComponents` removes the null (Verse/Game.cs:474). Laws, cases and sentences go with it. Guilt is vanilla (RimWorld/Pawn_GuiltTracker.cs:40-44) and runs out on its own. A jailed colonist stays a vanilla prisoner of the colony; release it by hand in the prisoner tab. + +### Crimes and punishments are defs, saved as names + +- `CrimeDef` (our own Def type) with label, the stages it offers, its option kind and a `CrimeWorker` class. `PunishmentDef` with label, the stages and crime kinds it fits, and a `PunishmentWorker`. 1.0 ships six crimes and five punishments in `Defs/BlaxLaws_Crimes.xml` and `Defs/BlaxLaws_Punishments.xml`. +- The save names them only as strings, resolved with `GetNamedSilentFail`. A row whose def is missing (a later DLC crime without its DLC, a removed compat crime) stays in the book, shows "Needs " or "Unknown" and isn't enforced. +- The lawbook UI reads the stage list from the def, so a crime without a planning stage never offers one. +- Our defs never enter a vanilla save list. Laws adds no HediffDef, no memory ThoughtDef, no PrisonerInteractionModeDef, no HistoryEventDef, WorkTypeDef or RecordDef (vanilla keeps those in a `DefMap` saved by index, Verse/DefMap.cs:52-66), no IncidentDef, no Letter subclass and no LetterDef. The one JobDef (subdue) is hidden from the save. The Laws tab's MainButtonDef is never saved. + +### Detection: one postfix per act, quiet while the book is empty + +- Static flags per crime (binge, fire, corpse, fight, insult, meat) plus a `HashSet` of watched break states are a cache of the current game's lawbook. They are rebuilt on every lawbook write and in the component's `FinalizeInit`, and cleared when a game starts or loads. Every hook reads its flag first, so while the book is empty and law votes are off (1.7) a hook costs one static field read per call. +- Every hook body sits in try/catch with a one-time log, reset in `FinalizeInit` (Zones' `Once` pattern). A hook only records; it never punishes. Punishments run from the enforcement queue on the next tick. +- Offender filter, shared by every hook: spawned on a map, humanlike, `Faction.IsPlayer`, free colonist or colony slave, not a quest lodger (RimWorld/QuestUtility.cs:524), not a baby, not subhuman. Caravan acts are skipped in 1.0 (Backlog). +- Player orders: the offender `Drafted` or its current job `playerForced` (Verse.AI/Job.cs:37) exempts the act while the setting is on. +- 1.0 hooks, all postfixes unless noted, none on a method the JIT may inline: + - A. `MentalStateHandler.TryStartMentalState` (Verse.AI/MentalStateHandler.cs:91), about 110 lines. `PostStart` runs at :162 before `return true` at :202, so the binge chemical and the obsession corpse are already chosen. Opens planning cases. + - C. `Thing.Ingested` (Verse/Thing.cs:2005), prefix and postfix. Called once per meal from `Toils_Ingest` (RimWorld/Toils_Ingest.cs:428), and from doctors and caravans. Meat. + - D. `CompDrug.PostIngested` (RimWorld/CompDrug.cs:47), a virtual override reached from `ThingWithComps.PostIngested` (Verse/ThingWithComps.cs:767-774). Binge doses. + - E. `Pawn_InteractionsTracker.TryInteractWith` (RimWorld/Pawn_InteractionsTracker.cs:176), about 90 lines, returns true at :268. Insults. + - F. `Pawn_InteractionsTracker.StartSocialFight` (RimWorld/Pawn_InteractionsTracker.cs:373): a message, two 9-argument `TryStartMentalState` calls and a tale. Fights. + - I. `Verb_Ignite.TryCastShot` (RimWorld/Verb_Ignite.cs:12), a protected override reached only through the virtual verb call. Fires. + - J. `MentalState_CorpseObsession.MentalStateTick` (Verse.AI/MentalState_CorpseObsession.cs:18), a virtual override that runs only for obsessed pawns. Corpse displayed. +- Two more hooks serve the jail, not detection (see "Enforcement runs a tick later"): K on `Pawn_GuestTracker.CapturedBy` and, from 1.1, L on `GenGuest.PrisonerRelease`. +- Not patched: `MentalState_CorpseObsession.Notify_CorpseHauled` (one store, :47-50), `Pawn_GuiltTracker.Notify_Guilty` (one store, RimWorld/Pawn_GuiltTracker.cs:46-49), `MentalStateHandler.ClearMentalStateDirect` and `MentalState.RecoverFromState`. A break that ends with nothing done is found by the 250-tick sweep over open planning cases instead, which needs no hook. + +### Enforcement runs a tick later + +- `Enforcement` holds a queue of (case, stage) entries. The component's `GameComponentTick` drains it on the tick after a hook filled it, so nothing acts inside a status change, an ingestion or an interaction, as Castes defers its work. The "Maintain only" write waits one tick more (see "Jail for N days"). +- Every 250 ticks a sweep walks the open cases only (a handful at a time): closes planning cases whose break ended, re-issues lost subdue jobs, retries arrests that waited for a bed, an enforcer or the end of a fight, and gives the old bed back when an arrest or capture job ended without a prisoner. Every 2500 ticks it checks sentences. Nothing scans all pawns. +- Enforcer pick: free colonists on the offender's map, awake, not downed, not in a mental state, not drafted, no player-forced job, no lord (parties, rituals, caravans forming), not the offender, not a child, not a slave. Also skipped: a pawn whose `CurJob.def.casualInterruptible` is false (in Core's JobDefs that covers Rescue, Capture, Arrest, TendPatient, BeatFire, ExtinguishSelf, ManTurret, DeliverToBed and LayDown), a pawn carrying a pawn (`IsCarryingPawn`, RimWorld/PawnUtility.cs:115), a pawn on Flee or FleeAndCower (Core Defs/JobDefs/Jobs_Misc.xml:510, 518) and a pawn on a `DoBill` whose recipe `IsSurgery` (Verse/RecipeDef.cs:362). Wardens (Warden work active) first, then anyone able, nearest by straight distance among those that can reach the offender. Subdue needs a pawn able to do violence, an arrest one with Manipulation. +- Danger: no enforcement starts while `GenHostility.AnyHostileActiveThreatToPlayer(map)` (RimWorld/GenHostility.cs:227) is true on the offender's map or `PawnUtility.EnemiesAreNearby(offender)` (RimWorld/PawnUtility.cs:161). The case waits and the sweep retries. +- Jobs start with `Pawn_JobTracker.StartJob(job, JobCondition.InterruptForced, ..., preToilReservationsCanFail: true)` with `playerForced` set. Before an Arrest or Capture, Laws checks `enforcer.CanReserve(offender)` and `CanReserve(bed)` (Verse.AI/ReservationUtility.cs:63); without that, `StartJob` would log a reservation error and end the job as Errored (Verse.AI/Pawn_JobTracker.cs:336, 373-380), for example when a doctor already reserved the downed offender. On a failed check the case waits for the sweep. Laws never queues its own job; the one job it queues is the vanilla Capture after a subdue (see "Subdue"). +- Hook K, a prefix and postfix on `Pawn_GuestTracker.CapturedBy` (RimWorld/Pawn_GuestTracker.cs:561-576, 16 lines with calls, not inlinable). It returns at once unless the pawn has a case in Enforcing with an Arrest or Capture job out. The postfix records the capture tick and queues the "Maintain only" write; the case saves whether that write is done, so a save made in between still gets it after the load. From 1.1 the prefix sends Castes the `blax.laws.jailed` hint and notes the weapon the pawn still holds, before `SetGuestStatus` drops it (:564; :461). +- Hook L (1.1), a prefix and postfix on `GenGuest.PrisonerRelease` (RimWorld/GenGuest.cs:8-21). It returns at once unless the pawn serves a Laws sentence. The prefix sends `blax.laws.released`; the postfix queues the give-back for the next tick. Castes reads a hint in its `SetGuestStatus` hook, inside these calls, and drops it at the end of the tick, so the sweep would be too late. + +### The subdue job never enters a save + +- Subdue needs its own JobDef and driver (`BlaxLaws_Subdue`, `JobDriver_Subdue`). A saved job with a missing JobDef would break the enforcer after removal: `Job.ExposeData` saves the def (Verse.AI/Job.cs:505), the driver class goes missing, `Pawn_JobTracker.ExposeData` then calls `EndCurrentJob` (Verse.AI/Pawn_JobTracker.cs:105-109), which reads `curJob.def.collideWithPawns` (:433) on a job whose def is null. The pawn would keep a job with no driver and never start another (:131-133, 197-203). +- So the job never reaches the file. A prefix on the virtual `Pawn_JobTracker.ExposeData` (Verse.AI/Pawn_JobTracker.cs:90), only while `Scribe.mode == Saving` and only when `curJob.def` is ours, hides `curJob` and `curDriver` from the scribe, and a finalizer puts them back even if saving throws. Zones uses the same prefix-and-finalizer pattern for its zone list. +- The job never waits in the job queue, which is deep-saved (Verse.AI/Pawn_JobTracker.cs:94; Verse.AI/QueuedJob.cs:37). Vanilla interrupts that resume the current job afterwards would put it there through `SuspendCurrentJob` (:293-296, 408-411): vomiting (Verse/Hediff.cs:480), `PawnUtility.ForceWait` (RimWorld/PawnUtility.cs:314), disorientation (Verse/HediffComp_Disorientation.cs:25) and `HediffComp_ReactOnDamage` (:31). So `BlaxLaws_Subdue` sets `false` (default true, Verse/JobDef.cs:24) and keeps `allowOpportunisticPrefix` false (:28; Verse.AI/Pawn_JobTracker.cs:655). An interrupt then ends the job instead of queueing it (:297-299, 415), disorientation skips it outright (it checks `CurJobDef.suspendable`, Verse/HediffComp_Disorientation.cs:15), and the sweep re-issues the subdue. As a backstop the save prefix also pulls `jobQueue` entries whose def is ours, and the finalizer puts them back. +- The job reserves nothing: `TryMakePreToilReservations` returns true without a reservation, so no reservation list refers to it (vanilla saves job references in `ReservationManager.cs:57`, `AttackTargetReservationManager.cs:20`, `PawnDestinationReservationManager.cs:25` and `PhysicalInteractionReservationManager.cs:20`). +- After loading, the enforcer just picks a new job. The case still says "subdue in progress", and the sweep starts a new subdue within 250 ticks if the offender is still in its break. +- Result: Laws' only save footprint is the component node. Phase 3 asserts exactly 2 errors. + +### Rules every feature follows + +- Undo only what Laws did. Sentences end, interaction modes and restorations apply only to pawns Laws jailed; another mod's prisoner, or a colonist you arrested by hand, is never touched. +- No game state in statics: the hot-path flags are a cache of the current game's book, rebuilt on load. Scopes set in a prefix are cleared in a finalizer. +- Store what the player chose: names and numbers, never live defs. +- Bulk changes ask first and name the count: deleting a law with open cases, the removal button (1.3). +- Every hook body in try/catch with a one-time log; a Laws error never breaks an ingestion, an interaction or a save. +- Never prefix a method of a few lines that the JIT may inline. +- A setting written into defs at startup says "restart required"; the Laws tab toggle writes `MainButtonDef.buttonVisible` live, because the bar counts that field for its width (RimWorld/MainButtonsRoot.cs:15-27) but draws by `Worker.Visible` (:65-81). + +### DLC support + +Every Blax mod works with any DLC combination, core only included (rule of 2026-11-29). For Laws: + +- About.xml names no DLC, neither as a dependency nor in loadAfter. +- Every 1.0 crime is core: the break defs are in Core (Defs/MentalStateDefs/MentalStates_Mood.xml: FireStartingSpree :58, Binging_DrugExtreme :91, CorpseObsession :399, Binging_DrugMajor :276, InsultingSpree :519, TargetedInsultingSpree :556), Insult and Slight in Core (Defs/InteractionDefs/Interactions_Social.xml:80, 116), wake-up in Core (Defs/Drugs/WakeUp.xml:5, chemical :115). No 1.0 crime uses a HistoryEvent: `AteMeat` is Ideology-only and skips processed food (Verse/Thing.cs:2055-2064), so the meat law reads the food itself. +- DLC content meets checks that are false without the DLC: slaves exist only with Ideology (`IsSlave`), children with Biotech (`DevelopmentalStage`), roles with Ideology (`ModsConfig.IdeologyActive` before any role read), mechanitors with Biotech (`ModsConfig.BiotechActive`, as vanilla checks at RimWorld/Pawn_GuestTracker.cs:536), subhumans with Anomaly (`IsSubhuman`, which `CanBeArrestedBy` also checks, Verse.AI/GenAI.cs:79-82). +- DLC defs only through `MayRequire` in XML and `[MayRequire]` DefOf fields. DLC code only behind `ModsConfig.Active`; `ModLister.Check` is an install check, not an active check. +- A choice that needs a DLC shows disabled with "Needs " instead of hiding: 1.1's Trial until 1.3 ("Needs Ideology"), 1.4's leader and moral guide as judge. +- A save made with a DLC loads without it: the component holds pawn references, names and numbers. A row naming a DLC crime stays and shows "Needs ". A case whose offender was a slave keeps its name. +- Anomaly and Odyssey: guarded in code only. Laws calls no Anomaly or Odyssey code in 1.0; an Odyssey colony with pawns on two maps enforces per map. +- Tests: `run-tests.ps1 -NoDlc` and `-Dlc`, from Zones' script. A release runs the whole suite, phases 2 and 3 included, in all 8 combinations of Royalty, Ideology and Biotech. A test that needs a DLC logs "skipped: needs Ideology" (or its DLC) without failing. + +| Feature | Release | Needs | Without it | +|---|---|---|---| +| Lawbook tab, starter lawbook, case log | 1.0 | None | Works | +| Six crimes | 1.0 | None | Works | +| Warn, guilty, subdue, jail, subdue then jail | 1.0 | None | Works. Slaves don't exist | +| Laws for slaves (warn, guilty, subdue) | 1.0 | Ideology | No slaves to cover | +| Hold for role holders | 1.0 | Ideology | No roles | +| Hold for mechanitors | 1.0 | Biotech | No mechanitors | +| Children never beaten | 1.0 | Biotech | No children | +| Release gives back bed, grave | 1.1 | None | Works | +| Release gives back throne | 1.1 | Royalty | Skipped | +| Release gives back deathrest casket, mech modes | 1.1 | Biotech | Skipped | +| Release gives back the ideoligion role | 1.1 | Ideology | Skipped | +| Reprimand, pardon, banish, execute | 1.1 | None | Works | +| Jail for slaves | 1.1 | Ideology | No slaves | +| Trial through the vanilla trial | 1.1 | Ideology | "Trial" shows disabled with "Needs Ideology" until 1.3 makes it core | +| Violent crimes | 1.2 | None | Works | +| Court sessions, court hour, removal button | 1.3 | None | Works. A throne as court place needs Royalty, a lectern or ritual spot Ideology | +| Elected judge | 1.4 | None | Works | +| Leader or moral guide as judge | 1.4 | Ideology | Option disabled with "Needs Ideology"; a saved choice falls back to elected | +| Attorneys, multi-day trials, courtrooms | 1.5, 1.6 | None | Works | +| Law votes | 1.7 | None | Works without the precept term | +| Breaks, escapes, drug policy crimes | 1.8 | None | Works | +| Slave rebellion crime | 1.8 | Ideology | Row shows "Needs Ideology" | + +## Releases + +### 1.0 Lawbook, six crimes, subdue and jail (10 days) + +#### Lawbook tab + +- **Players get:** A "Laws" button in the bottom bar, after Ideoligions (order 105; Ideos is 100 and Menu 500, Ideology/Defs/MainButtonDefs/MainButtons.xml:9, Core/Defs/Misc/MainButtonDefs/MainButtons.xml:131). Two tabs. "Lawbook" lists your laws as rows (spec below). "Add law" opens the Action menu first, then adds the row; each column is a dropdown that offers only what fits the chosen action and stage. "Starter lawbook" adds the suggested rows. "Cases" lists cases newest first: who, what, stage, when, punishment, status, with a button to jump to the pawn and, for cases that wait, "Arrest now". An empty book shows one line: "No laws yet. Add one or press Starter lawbook." +- **Row spec:** + - Columns: Action; Option, only for crimes that have options (drugs: Any, Hard, Social, then every drug's `ChemicalDef` by label, built from the ThingDefs whose `CompProperties_Drug` names a chemical; meat: Any, Raw meat or corpses, Human meat; insults: Slights count too); Stage; Severity; Punishment; Days, a 1 to 50 field for Guilty, Jail and Subdue then jail and "-" otherwise; On; delete. + - A new row gets the crime's first stage, Moderate, Warn and On. + - Punishments per crime and stage: + + | Crime | Stage | Punishments | + |---|---|---| + | Drug binge, fire starting, corpse obsession, insulting spree | Planning | Warn, Subdue, Jail | + | The same | Did it | Warn, Guilty, Subdue, Jail, Subdue then jail. Subdue acts only while the offender is still in its break; after it a Subdue row warns and Subdue then jail jails | + | Ate meat, started a fight, insult outside a spree | Did it | Warn, Guilty, Jail | + + - Changing Severity resets Days to the new default only while Days still equals the old default. Changing Action or Stage resets a punishment that no longer fits to Warn. + - Action, Option and Stage are the row's key. A duplicate is refused and the list jumps to the existing row. +- **How:** + - `MainButtonDef BlaxLaws_Laws` with `tabWindowClass BlaxLaws.MainTabWindow_Laws`. The window is a `MainTabWindow` with two `TabRecord`s, a scroll view and `Widgets.Dropdown` per column. + - Every write goes through one `Lawbook` class (as every Castes write goes through `CasteManager`): add, edit, delete, starter. It rebuilds the watched flags after each write. + - Deleting a law that has open cases asks first and names the count; those cases close as "law repealed". + - The case list reads the component; the jump button uses `CameraJumper.TryJumpAndSelect`. + - Settings page: "Enforce laws" (on), "Show Laws tab" (on, writes `buttonVisible` live), "Messages for cases" (on), "Letters for jailings" (on), "Enforcers" (wardens first / wardens only), "Subdued pawns lose their catharsis" (on), "Player orders are exempt" (on), "Days between cases for acts outside a break" (1, 0 to 7), "Keep closed cases" (60 days, 7 to 360), "Reset to defaults". Keys `BlaxLaws_Setting` plus `...Tip`. +- **Settings:** As listed; the book itself is per save. +- **Save and removal:** The book and cases save in the component. Removal drops them with it. +- **Overlaps:** Federation: Laws and Warrants (3823463956, 10 subs, 1.6) has the only other laws tab on the Workshop, inside its own scenario. +- **Replaces:** Nothing alone; with the crimes and punishments below it replaces Rimworld Law and Order (3661387691, 419 subs, last update 2026-02-15, 1.6 only, needs Ideology, five hardcoded crimes). +- **Effort:** M, 2 days. +- **Tests:** A new game has an empty book, no cases and every watch flag false. Adding a binge row sets the binge flag and the watched state set holds both binge defs; deleting it clears them. Starter lawbook adds 7 rows; pressing it again adds none. Rows keep id, option, stage, severity, punishment, days and the On flag through phase 2. A row whose crime defName doesn't resolve (written into the component by the test) stays, reports "Unknown" and opens no case. A save made without Laws loads with an empty component. With "Show Laws tab" off, `buttonVisible` is false at once. A second row with the same Action, Option and Stage is refused. A new row reads first stage, Moderate, Warn, On. Moderate to Serious moves untouched Days from 3 to 5 and leaves typed Days alone. Switching a Subdue row's action to Ate meat resets it to Warn. The drug option list holds WakeUp and no non-drug chemical. +- **Risks:** Humanoid Alien Races pawns never got Law and Order's tab; Laws has no per-pawn tab, and its offender filter is `RaceProps.Humanlike`, so alien colonists are covered. Test with HAR in `-Compat`. + +#### Six crimes + +- **Players get:** Laws notice these acts and open a case: + + | Action | Option | Planning | Did it | + |---|---|---|---| + | Drug binge | Any drug (default), hard drugs, social drugs, or one chemical such as wake-up | The binge break starts, drug chosen, nothing taken yet | Each dose taken during the binge, counted | + | Fire starting | None | A fire-starting spree starts | Each fire set, counted | + | Corpse obsession | None | The obsession starts, corpse chosen | The corpse is displayed; the case notes "on a table" and "dug up from a grave", which is nearly always true | + | Started a fight | None | None | A social fight starts. The offender is the pawn who reacts and swings, usually the insulted one | + | Insult | Slights count too (off) | An insulting spree starts | Each insult, by the one who insults | + | Ate meat | Any meat, meals with meat included (default); raw meat or corpses; human meat | None | The pawn eats it | + +- **How:** + - Drug binge. + - Planning: hook A when the new state is `MentalState_BingingDrug`. Its `PostStart` picks the chemical (Verse.AI/MentalState_BingingDrug.cs:24-27, `ChooseRandomChemical` at :49), preferring a chemical the pawn is addicted to (:51-62). Wake-up is a hard drug (Core Defs/Drugs/WakeUp.xml:27), so a wake-up binge comes from an extreme break (Binging_DrugExtreme, `drugCategory` Hard, MentalStates_Mood.xml:91-106) or from any binge of a wake-up addict. + - Did it: hook D when `ingester.MentalState is MentalState_BingingDrug` and `parent`'s chemical matches the row's option. Doctor-given doses (RimWorld/Recipe_AdministerIngestible.cs:11) don't count. A dose outside a binge is normal drug use, not this crime. + - The binge ignores forbidden items and the drug policy and lasts 40000 to 60000 ticks (MentalStates_Mood.xml:98-99), so stopping it after dose 1 still prevents the rest. + - Fire starting. Planning: hook A on `FireStartingSpree` (MentalStates_Mood.xml:58-71; the break needs the Pyromaniac trait, Core Defs/TraitDefs/Traits_Singular.xml:340-343). Did it: hook I, offender `CasterPawn`, which `FireUtility.TryStartFireIn` gets as instigator (RimWorld/Verb_Ignite.cs:12-21). Raiders also ignite (RimWorld/TrashUtility.cs:97, 117); the offender filter drops them. + - Corpse obsession. Planning: hook A on `CorpseObsession` (MentalStates_Mood.xml:399-413); `PostStart` picks the corpse (Verse.AI/MentalState_CorpseObsession.cs:41-45). Did it: hook J sees `alreadyHauledCorpse` turn true, which the job's last toil sets (RimWorld/JobDriver_HaulCorpseToPublicPlace.cs:82-95, the call at :90). 80% of drops go on a table (:64, `TryFindTableCell` :97-123); the case checks the corpse's cell for a `def.IsTable` building. "Dug up" is read from the corpse, never from the job: hook J sees the flag only after that last, instant toil, when the haul job and its grave target are gone. Hook A notes it from `corpse.ParentHolder is Building_Grave`, and hook J re-reads it for the current `__instance.corpse` on each call while `alreadyHauledCorpse` is false, since vanilla may pick another corpse (Verse.AI/MentalState_CorpseObsession.cs:26-28). Vanilla only obsesses over buried corpses (`GetClosestCorpseToDigUp` searches `ThingRequestGroup.Grave`, Verse.AI/CorpseObsessionMentalStateUtility.cs:17-21), Anomaly's unnatural corpse aside (:13), so the note is nearly always set. The flag is saved by vanilla (MentalState_CorpseObsession.cs:15), so after a load it is already true: hook J only moves a case that is open at planning, and the case's stage is saved, so the corpse is never filed twice. + - Started a fight. Hook F, offender `___pawn`, the pawn whose tracker starts the fight; `otherPawn` is the provoker. It is called from `CheckSocialFightStart` (RimWorld/Pawn_InteractionsTracker.cs:355-371) on the recipient of an interaction (:217). Slaves only fight slaves and prisoners only prisoners (:402-409). The row's tooltip says who counts as the offender. + - Insult. Hook E: `__result` true and `intDef` Insult, or Slight with the option. Offender `___pawn` (the initiator), victim the recipient. Insults in a spree also come through here (RimWorld/JobDriver_Insult.cs:34). Planning: hook A on `InsultingSpree` or `TargetedInsultingSpree`. + - Ate meat. Hook C. The prefix reads `FoodUtility.GetFoodKind(__instance)` (RimWorld/FoodUtility.cs:1454), `def.IsProcessedFood` and `FoodUtility.IsHumanlikeCorpseOrHumanlikeMeatOrIngredient(__instance)` (used at Verse/Thing.cs:2033) into `__state`, before the stack can be destroyed; the postfix files the case. Babies fed by others are filtered out. + - Each crime's worker opens a case or moves an open one to did it, increments the count, and queues the punishment of the most specific enabled matching row (see "Defaults I picked") once per stage. + - The cooldown setting applies to every act outside a break: meat, fights and insults outside a spree. Inside the window a further act by the same offender under the same law raises the count on that case, open or closed, and files nothing new. An insult that sparks a fight files two cases: the insult for the insulter, the fight for the one who swings. +- **Settings:** The cooldown and "Player orders are exempt" from the settings page; per row the option. +- **Save and removal:** Cases save in the component. Hooks save nothing. +- **Overlaps:** Insult System (3783191560, 86 subs) and Grudges! (3491693870, 27.5k, 1.6, unmaintained) add social conflict; Laws only reads vanilla interactions. Pawn Rules (Continued) (3024243615, 6.7k) prevents meat eating per pawn; Laws punishes it afterwards. Snap Out! (1319782555, 636k, no 1.7) talks a pawn out of a break; it is the gentle partner of subdue. +- **Replaces:** Law and Order's crimes are new events and breaks; Laws replaces the idea with vanilla's own acts. +- **Effort:** M, 2 days. +- **Tests:** + - Binge: with a "wake-up" row, `TryStartMentalState(Binging_DrugExtreme)` on a colonist whose binge chemical a test hook sets to WakeUp opens one planning case; with yayo chosen, no case. `wakeUp.Ingested(pawn, 0)` during the binge moves it to did it with count 1, a second dose makes count 2, still one case. A wake-up dose outside a binge opens nothing. An "any drug" row catches a beer binge (Binging_DrugMajor). The starter rows plus "wake-up, did it, jail 10 days": a wake-up dose during a binge gives one case and a 10-day sentence. + - Fire: a forced spree opens planning; a forced Ignite job on a wooden wall moves it to did it with count 1. A raider's ignite opens nothing. + - Corpse: a forced obsession on a corpse in a grave opens planning with "dug up from a grave"; driving the haul job to the end with a table in reach moves it to did it with "on a table" and keeps the note. Phase 2 after a save with the flag already true: still one did-it entry. + - Fight: `recipient.interactions.StartSocialFight(initiator)` files the case on the recipient, not the initiator. + - Insult: `TryInteractWith(target, Insult)` files on the initiator. A Slight only with the option. A second insult within a day files nothing; with the cooldown at 0 it files a second case. + - Meat: raw meat, a simple meal with meat and human meat against the three options; a drafted pawn eating opens nothing; a player-forced eat job opens nothing while the setting is on and a case when it is off. 60 colonists eating meat for a day under an "any meat, warn" law produce at most 60 cases and 60 messages. + - Cost: 100000 `TryInteractWith` calls with an empty book run within 2% of the same calls with the patches unapplied (test switch). +- **Risks:** Double counting across laws (a meat bite during a food binge, 1.8) needs the precedence rule "one case per incident per crime". Slights are frequent between rivals (weight 0.02, RimWorld/InteractionWorker_Slight.cs:15); the cooldown keeps the log readable. Modded mental states with their own classes are invisible unless they reuse these defs. + +#### Enforcement and cases + +- **Players get:** Cases move on by themselves. A planning case closes when the break ends with nothing done, a lost subdue starts again, and an arrest that waited for a bed, an enforcer or the end of a fight happens as soon as it can. One enforcer per case, never one pulled off a rescue, a tending or a fire, and nobody sent through a raid. +- **How:** The `Enforcement` queue, the 250- and 2500-tick sweeps, the enforcer pick with its job and danger filters, the reservation checks and hook K (all in "Enforcement runs a tick later"); the case lifecycle (Open, Enforcing, Jailed, Closed, each closed case with an outcome key); one enforcement per case and the hand-over between stages; the cooldown; the `CrimeWorker` and `PunishmentWorker` base classes. +- **Settings:** "Enforce laws", "Enforcers", "Messages for cases", "Letters for jailings". +- **Save and removal:** Cases in the component. The queue isn't saved; cases in Enforcing refill it after a load. +- **Overlaps:** None. +- **Replaces:** Nothing. +- **Effort:** M, 2 days. +- **Tests:** + - A warden tending a patient, beating a fire, carrying a downed colonist or doing surgery is never picked; the next candidate is. + - During a raid a binge case waits and nobody is sent; after the raid the sweep enforces it. + - A downed offender a doctor has already reserved for a rescue: no arrest starts, no reservation error or warning is logged, and the sweep arrests it once the reservation is gone. + - Hand-over: the drug lies next to the binger, starter rows active. One enforcer acts, the pawn ends as a prisoner, never in a medical bed, and the case log shows one did-it outcome. + - "Enforce laws" off: cases open and close, nothing is enforced. + +#### Warn and guilty + +- **Players get:** "Warn" files the case and posts a message, nothing more: a record you can act on yourself. "Guilty for N days" marks the pawn guilty the vanilla way until the days run out: the guilty icon shows, the arrest of a free colonist is always accepted, executing it costs the colony only the -2 "justified execution of colonist" thought plus its family's grief, and banishing it costs no colony-wide thought (banishing it to its death still grieves its family). +- **How:** + - `pawn.guilt.Notify_Guilty(days * 60000)` (RimWorld/Pawn_GuiltTracker.cs:46-49), which vanilla saves (:40-44) and counts down (:51-61). + - Guilt gives arrest acceptance 1.0 for an `IsColonist` pawn that isn't a quest lodger (Verse/Pawn.cs:4087). A slave in a break isn't `IsColonist` (Verse/Pawn.cs:518-527; `SlaveIsSecure` is false in a mental state, RimWorld/Pawn_GuestTracker.cs:164-175), so the arrester's `ArrestSuccessChance` decides for it (Verse/Pawn.cs:4099). + - Guilt also gives capture when downed (Verse.AI/GenAI.cs:39-67) and the character card's execute toggle for a free colonist (RimWorld/CharacterCardUtility.cs:278-285). + - Execution: for a guilty victim `GiveThoughtsForPawnExecuted` picks stage 0 (RimWorld/ThoughtUtility.cs:27-31) and records `ExecutedColonist` with it (:72). In a core-only game `Execution_Classic` turns that into `KnowColonistExecuted` stage 0, "justified execution of colonist", -2 mood for 6 days for every colonist (Core Defs/PreceptDefs/Precepts_PrisonerExecution.xml:50-53; Core Defs/ThoughtDefs/Thoughts_Memory_Death.xml:56-67); an ideoligion's execution precept may change that. Family and friends still grieve: `AppendThoughts_Relations` ignores guilt for deaths and for banishment to die (RimWorld/PawnDiedOrDownedThoughtsUtility.cs:81-84, 253). + - Banishment: guilt only removes the colony-wide `ColonistBanished` and `ColonistBanishedToDie` thoughts (RimWorld/PawnDiedOrDownedThoughtsUtility.cs:214-232; RimWorld/PawnBanishUtility.cs:150). + - A longer guilt already on the pawn is never shortened. +- **Settings:** None beyond the row. +- **Save and removal:** Guilt is vanilla. Nothing of ours is saved on the pawn. +- **Overlaps:** Custom Guilt Duration (2865127870, 3.4k, no 1.7) and Guilty! (3654983512, 302, 1.6) set guilt length globally; Laws sets it per law. They compose: the last writer wins for that pawn. +- **Replaces:** Nothing yet; 1.1 adds pardon. +- **Effort:** Inside the crimes and jail budgets. +- **Tests:** A guilty row with 3 days leaves `TicksUntilInnocent` at 180000; a longer existing guilt stays. Guilty colonist with Social 0 arrester: `GetAcceptArrestChance` is 1. `PawnDiedOrDownedThoughtsUtility.GetThoughts` for a guilty colonist with a spouse: Banished lists no colony-wide thought; BanishedToDie lists the spouse's grief and no colony-wide thought. +- **Risks:** Guilt also comes from vanilla (undrafted friendly fire, Verse/Pawn_HealthTracker.cs:321-329), so Laws never treats a guilty pawn as its own convict without a case. With guilt on, the vanilla Ideology trial refuses the pawn (`ValidateNotGuilty`, RimWorld/CompAbilityEffect_StartTrial.cs:44-47); 1.1's Trial punishment therefore sets no guilt before the trial. + +#### Subdue + +- **Players get:** For a pawn caught planning (or still in its break after the act), a warden walks over and beats it down with fists: bruises on torso and limbs, never the head, never a bionic part, never a lost part, never a scar. The break ends when the pawn goes down. Doctors carry it to bed, and the bruises heal in a few days. The pawn remembers who hit it (-15 opinion for 10 days, vanilla's "harmed me"). The enforcer is not marked guilty, and the beaten pawn doesn't fight back. +- **How:** + - `JobDriver_Subdue`: fail on the target despawned, dead, or no longer in the break its case recorded. One toil, `Toils_Combat.FollowAndMeleeAttack(TargetIndex.A, hit)` (Verse.AI/Toils_Combat.cs:115-178), which follows the target, calls `hit` while adjacent and ends when the target is downed (:165-167) or unreachable (:132-134). The toil runs as a `tickIntervalAction` (:123), which `Thing.DoTick` calls every 1 to 15 ticks depending on how often the camera updates the pawn (Verse/Thing.cs:726-735, bounds :604-606), so counting calls would make the beating up to 15 times slower off screen. The driver keeps a `lastHitTick` field instead (the job is never saved, so the field needs no save) and hits when `Find.TickManager.TicksGame - lastHitTick >= 90`. + - The hit: a random body part of the target that isn't missing, has depth Outside, isn't solid, isn't in the head group (torso, shoulders, arms, legs) and doesn't carry or sit below an added part (`hediffSet.PartOrAnyAncestorHasDirectlyAddedParts`, Verse/HediffSet.cs:1225): an injury there gives no pain (Verse/Hediff_Injury.cs:132-135) and only damages the implant. Damage 4 to 8, divided by the target's `IncomingDamageFactor`, which vanilla multiplies in even with armour ignored (Verse/DamageWorker_AddInjury.cs:164-167; Tough is 0.5, Core Defs/TraitDefs/Traits_Singular.xml:532), so the injury itself is 4 to 8. A factor of 0 ends the job as below. The injury is capped so the part keeps at least half its HP. `new DamageInfo(DamageDefOf.Blunt, amount, 0, -1, enforcer, part, null, SourceCategory.ThingOrUnknown, target, instigatorGuilty: false)` (Verse/DamageInfo.cs:144), with `SetAllowDamagePropagation(false)` (:260) and `SetIgnoreArmor(true)` (:214) so power armour doesn't make it endless, then `TakeDamage`. Then `enforcer.Drawer.Notify_MeleeAttackOn(target)` (Verse/Pawn_DrawTracker.cs:128), a punch sound and Melee XP. + - Blunt on a non-solid part makes a Bruise: no bleeding, pain 0.0125 per point (Core Defs/HediffDefs/Hediffs_Local_Injuries.xml:383-400). A pawn goes down when pain reaches its pain shock threshold (Verse/Pawn_HealthTracker.cs:101), 0.8 for a normal adult, so about 64 points or 11 hits. + - `instigatorGuilty: false` skips vanilla's guilt for harming a player pawn (Verse/Pawn_HealthTracker.cs:321-329). Calling `TakeDamage` directly sets no `meleeThreat`, which a vanilla melee verb would (RimWorld/Verb_MeleeAttack.cs:33-37), so the target doesn't turn on the enforcer. The target does get `HarmedMe` toward the enforcer (Verse/Pawn_HealthTracker.cs:379-382). + - Going down runs `RecoverFromState` (Verse/Pawn_HealthTracker.cs:850-853), which gives the break's `moodRecoveryThought`, Catharsis for the six watched breaks (MentalStates_Mood.xml:76, 103, 413, 539), when the break was mood-caused (Verse.AI/MentalState.cs:92-95). The driver reads that thought def before the hit and, if the hit downed the pawn, removes the memory gained this tick. + - The job ends with a message once three hits in a row haven't raised `hediffSet.PainTotal` (Verse/HediffSet.cs:57, which multiplies in pain factors at :1351-1353): go-juice, painkillers, or every reachable part at its cap. A hard ceiling of 40 hits backs that up. A "subdue then jail" row arrests instead, which works on a pawn in a non-aggro break (Verse.AI/GenAI.cs:73-103). + - "Subdue then jail": in the tick the hit downs the target, the driver puts vanilla `JobDefOf.Capture` to a prisoner bed at the front of the enforcer's job queue (`jobQueue.EnqueueFirst`, Verse.AI/JobQueue.cs:40) and ends its toil, so the capture is the enforcer's next job, ahead of a doctor's rescue (RimWorld/WorkGiver_RescueDowned.cs:38-60). A queued job fails its reservations silently (`fromQueue`, Verse.AI/Pawn_JobTracker.cs:336, 373-375), and a queued vanilla Capture is safe in a save. Guilt is renewed before the job is queued, as for any capture (see "Jail for N days"), since a downed colonist can be captured only while guilty (Verse.AI/GenAI.cs:39-67). + - Downing drops the pawn's weapon and inventory forbidden (Verse/Pawn_HealthTracker.cs:856-859), as any downing does. + - Children (Biotech) never get this job; their row falls back as "Defaults I picked" says. + - Save: see "The subdue job never enters a save". +- **Settings:** "Subdued pawns lose their catharsis" (on), "Enforcers". +- **Save and removal:** Nothing saved for the job; the case records "subdue in progress" and the enforcer. +- **Overlaps:** Beat Your Prisoners (Continued) (2902220334, 18.2k) beats prisoners to lower resistance, a different target. Its players reported fists destroying heads; that is why Laws caps damage per part and skips the head. Blax Slaves 2.0's wardens calm slaves out of non-violent breaks; Laws stands down for slaves when that is active (see "Works with the other Blax mods"). +- **Replaces:** Arresting your own colonist mid-break by hand, the workaround Arrest and Release (2593514063, 4.6k, no 1.7) exists for. +- **Effort:** S plus S, 1 day. +- **Tests:** + - A binge planning case with a subdue row: within 2500 ticks the offender is downed, has only Bruise injuries, every part at 50% HP or more, no head injury, no Catharsis memory (and has it with the setting off), the enforcer isn't guilty and the offender's `meleeThreat` is null. The same run with the camera on another map: still downed within 2500 ticks. + - A Tough colonist and a colonist with two bionic arms both go down; the bionic arms take no injury. + - A go-juice offender: the job ends after three hits without new pain, with one message. + - A child offender with a subdue row is warned, and with a subdue then jail row is jailed without a beating (skipped: needs Biotech). + - Save while the job runs: the .rws contains no "BlaxLaws_Subdue"; after the reload the enforcer runs another job and the sweep starts a new subdue within 250 ticks. Start `Vomit` with `resumeCurJobAfterwards` on the enforcer mid-subdue, then save: the .rws contains no "BlaxLaws_Subdue" and the enforcer's queue holds no subdue job. + - A "subdue then jail" row ends with the pawn a prisoner, never in a medical bed, with a doctor free to rescue. +- **Risks:** Tone: Blax Slaves cut torture and flogging as beyond vanilla's tone. Subdue is a short fistfight to stop a break, closer to vanilla's social fight than to flogging, and the description says so. An enforcer weaker than the offender still wins, since the target never strikes back; accepted for an MVP, and weighing Melee skill is in the Backlog. + +#### Jail for N days + +- **Players get:** The offender is arrested, sits out the sentence in a prisoner bed and goes back to work. A letter names the sentence and the release day. The case log counts down. While jailed, the pawn keeps its work priorities and, with Blax Castes, returns to its old caste. +- **How:** + - Conviction: guilt for the sentence length when the case is filed (see "Warn and guilty"). The arrest can come days later (no prisoner bed, a hold until "Arrest now", no enforcer, a raid), and guilt counts down meanwhile (RimWorld/Pawn_GuiltTracker.cs:51-61). Once it has run out, the arrest falls back to the arrester's `ArrestSuccessChance` (Verse/Pawn.cs:4087, 4099), a refusal is berserk (:4132-4135), and a downed colonist can't be captured (Verse.AI/GenAI.cs:39-67). So right before every Arrest or Capture job Laws calls `Notify_Guilty(Math.Max(TicksUntilInnocent, sentence ticks + 60000))`, the extra day covering the release fallback, and the release tick counts from the capture, not from filing. + - Bed: `RestUtility.FindBedFor(offender, enforcer, checkSocialProperness: false, ignoreOtherReservations: false, GuestStatus.Prisoner)`, then with `ignoreOtherReservations: true`, as the arrest float menu does (RimWorld/FloatMenuOptionProvider_Arrest.cs:41-49). A bed from the second search must still pass `CanReserve` (see "Enforcement runs a tick later"). No bed: a letter, the case waits, and the 2500-tick sweep retries. + - The old bed: the arrest job's first toil, `Toils_Bed.ClaimBedIfNonMedical(TargetIndex.B, TargetIndex.A)` (RimWorld/JobDriver_TakeToBed.cs:73; RimWorld/Toils_Bed.cs:40-51), makes the offender claim the prisoner bed, which unclaims its own (RimWorld/Pawn_Ownership.cs:125-138). That happens before the arrest check and the capture. If the job then fails, its finish action only gives up the prisoner bed (JobDriver_TakeToBed.cs:74-80). So Laws stores `ownership.OwnedBed` in the case right before it starts the Arrest or Capture job, and when the job ends without the pawn becoming `IsPrisonerOfColony`, the sweep reclaims that bed with `ClaimBedIfNonMedical` if it is still free. + - Job: `JobMaker.MakeJob(JobDefOf.Arrest, offender, bed)` with `count = 1` (:52-54), or `JobDefOf.Capture` when the offender is down. The float menu offers Arrest only to drafted pawns (:27-30), so Laws builds the job itself. The job fails on `CanBeArrestedBy` (RimWorld/JobDriver_TakeToBed.cs:85-89; Verse.AI/GenAI.cs:73-103): pawns in a binge, a fire-starting spree or a corpse obsession can be arrested, berserk ones can't. + - At contact the target rolls `CheckAcceptArrest` (Verse/Pawn.cs:4102-4137; RimWorld/JobDriver_TakeToBed.cs:91-116). A refusal turns the pawn berserk (Verse/Pawn.cs:4132-4135); with guilt a colonist never refuses. + - Picking it up calls `CapturedBy` (RimWorld/JobDriver_TakeToBed.cs:164-178), which runs `SetGuestStatus(player, Prisoner)` (RimWorld/Pawn_GuestTracker.cs:443-540). That ends the break without Catharsis, because `ClearMind_NewTemp` resets the mental state directly (Verse/Pawn.cs:2807-2813; Verse.AI/Pawn_MindState.cs:343-350; Verse.AI/MentalStateHandler.cs:58-61), drops weapon and inventory forbidden (Pawn_GuestTracker.cs:461), undrafts, clears surgery bills (:533), drops a deathrest casket that isn't for prisoners (:534; RimWorld/Pawn_Ownership.cs:294-304; the colonist bed is already gone, see above) and sends a mechanitor's control groups to self-shutdown (:536-539; RimWorld/Pawn_MechanitorTracker.cs:312-322). Work priorities survive: prisoners have no disabled work types, only slaves do (RimWorld/GuestUtility.cs:39-52). + - Two ticks after the capture Laws sets `SetExclusiveInteraction(PrisonerInteractionModeDefOf.MaintainOnly)` (RimWorld/Pawn_GuestTracker.cs:304); hook K's postfix records the capture tick and queues the write. Prison Labor sets its default mode on every new player prisoner in a `SetGuestStatus` postfix, inside the capture. Castes 1.4 can set one from its join queue on the first tick after the capture, the tick Laws would use with a one-tick delay. Both components tick in one loop over `Game.components` (Verse/GameComponentUtility.cs:24-31), in type order in a new game and in append order when a mod is added to a running save (Verse/Game.cs:472-489), so with Castes added after Laws, Castes would write last. Two ticks wins over both in any order. Will is 0 for the player kinds (Core Defs/PawnKindDefs_Humanlikes/PawnKinds_Player.xml:11, set at RimWorld/Pawn_GuestTracker.cs:474), so an Enslave default would succeed at the first warden visit (RimWorld/InteractionWorker_EnslaveAttempt.cs:19-20, 44-51). That is why Laws' write must land last. Prison Labor's non-exclusive labor toggle stays as Prison Labor set it: hard labor in jail is that mod's call. + - The sentence record stores the capture tick, the release tick (capture plus the sentence) and the bed the pawn owned before the arrest job. Every 2500 ticks, a served sentence gets `SetExclusiveInteraction(Release)`. Wardens take it through `WorkGiver_Warden_ReleasePrisoner` (RimWorld/WorkGiver_Warden_ReleasePrisoner.cs:8-36), which skips downed prisoners and prisoners in a break (:15-19). `JobDriver_ReleasePrisoner` carries the pawn out and calls `GenGuest.PrisonerRelease` (Verse.AI/JobDriver_ReleasePrisoner.cs:31-37): `WasImprisoned` (-6 mood for 12 days; RimWorld/GenGuest.cs:10-13), `UnclaimAll` (:47; Pawn_Ownership.cs:286-292), and `SetGuestStatus(null)` because the home faction is the player (:55-62). Laws never patches the release job driver; Rimocracy's patch there broke every release (NullReferenceException, reported 2025-07 and 2025-08). + - Fallback: one day after the due tick without a release, Laws calls `GenGuest.PrisonerRelease` itself. + - Early end: once a jailed pawn is no longer `IsPrisonerOfColony` before its release tick (recruited, released by you or another mod, escaped, dead), the sentence closes with that outcome and a message. + - Hold: an Ideology role holder would lose its role on arrest, because `Precept_Role.ValidatePawn` refuses a player pawn that isn't a free non-slave colonist (RimWorld/Precept_Role.cs:582-585), and a mechanitor's mechs would shut down. Laws doesn't arrest those on its own in 1.0: the case waits with "Arrest now" and a letter. Guilt is set at filing anyway and renewed when "Arrest now" starts the job. + - Slaves: 1.0 never jails a slave. Releasing an imprisoned slave sends it back to its old faction and off the map (RimWorld/GenGuest.cs:14-19; Pawn_GuestTracker.cs:479-482), so slave jail waits for 1.1's re-enslave. A slave's jail row falls back to subdue while it is in its break, else to warn. +- **Settings:** "Letters for jailings" (on). Days per row. +- **Save and removal:** The sentence lives in the case. After removal a jailed colonist stays a vanilla prisoner of the colony; its guilt runs out on its own. +- **Overlaps:** Prisoner Sentencing (3736998871, 1.3k, 1.7) has a Temporary sentence that lets a former colonist rejoin; Prison Expanded (3827258534, 3.3k, 1.7) has its own sentences and parole. Both may release the same pawn: Laws notices the early release and closes its sentence instead of fighting them. Prisoner Realism (3760196312, 23.9k) institutionalises prisoners after about 10 days in jail and has its own "Arrest here", which Laws' jobs don't need. Custom Prisoner Interactions (2841231775, 51.2k) skips colonists on capture. +- **Replaces:** The manual arrest-and-release cycle. +- **Effort:** S plus S plus S, 1.5 days, hook K included. +- **Tests:** + - A did-it binge case with "jail 3 days": within 2500 ticks the offender is `IsPrisonerOfColony`, its mental state is null, it has no Catharsis, `TicksUntilInnocent` is at least 240000 minus the ticks since the arrest started, and two ticks after the capture its mode is MaintainOnly (also with Prison Labor in `-Compat`). Skip to the release tick: the mode is Release; a warden releases it; the pawn is a free colonist with `WasImprisoned` and the same work priorities as before the arrest. + - Mode order: Laws' component moved before Castes' in `Game.components`, and an Enslave mode written at capture plus 1 (by the test now, by Castes 1.4's prisoner caste once it exists): the mode is MaintainOnly at capture plus 2 (Enslave skipped: needs Ideology; the core run uses ReduceResistance). + - Prison Labor in `-Compat`, once with its non-exclusive "Force to work" (`PrisonLabor_workOption`) off and once on: the same work priorities as before the arrest after the release. Its 1.7 PrisonLabor.dll has `Patches_WorkSettings`, `LaborWorkSettings` and `InitWorkSettings`; if priorities change, Overlaps and the README say so. + - With Castes in `-Compat`: the caste after the release matches the old one, read through reflection on `GameComponent_BlaxCastes.CasteOf(Pawn)`, so the test mod needs no reference to Castes; from Castes 1.1 through `CastesApi.CasteIdOf` (API version 1). Skipped without Castes. + - The old bed: an arrest interrupted after its first toil leaves the colonist owning its old bed by the next sweep. A bed someone else claimed meanwhile stays theirs. + - Late arrest: a 5-day row with no prisoner bed for 6 days, then one is built: the arrest is accepted against a Social 0 arrester, and the release comes 5 days after the capture. + - No prisoner bed: one letter, no arrest; building one leads to the arrest at the next sweep. + - Holds and fallbacks, each skipped with "skipped: needs ": a role holder (Ideology) and a mechanitor with a mech (Biotech) get no arrest and one letter, and "Arrest now" arrests; a slave in a binge with a jail row is subdued, and the same row outside a break warns (Ideology). In the DLC-off runs no hold or fallback logs anything. + - Recruiting the jailed pawn closes the sentence as "released early". The fallback releases a pawn no warden can reach. +- **Risks:** Arrest needs a prisoner bed (FloatMenuOptionProvider_Arrest.cs:41-49). Release unclaims bed, grave, throne and casket (RimWorld/GenGuest.cs:47); 1.0 accepts that the pawn picks a free bed again, 1.1 gives the old one back. Jailed colonists can break out (base MTB 60 days, Verse/PawnKindDef.cs:129; RimWorld/PrisonBreakUtility.cs:42-110); the early-end rule closes the sentence. Prisoner Realism's institutionalisation starts around 10 days, so the starter rows stay at 5 and 10. + +#### Headless tests in 1.0 + +- **Harness:** copy Zones' `Tests/` (the most complete: three phases, `-Worktree`, `-WaitSeconds`) as `Tests/BlaxLawsTests`. Switch `-blaxlawstests`, data folder `%TEMP%\BlaxLawsTest`, results `BlaxLawsTestResults.txt`, settings files `Mod_BlaxLaws_*` deleted every run. +- **Phase 3:** after phase 2 the runner saves as `BlaxLawsTest3`, replaces `Class="BlaxLaws.GameComponent_BlaxLaws"` with a type that doesn't exist, loads, and runs the phase 3 tests: exactly the 2 expected errors, a jailed colonist still a prisoner of the colony, no "BlaxLaws" in any pawn's job or queue. Phase 2 saves while an enforcer vomits mid-subdue (`Vomit` started with `resumeCurJobAfterwards`), so phase 3 also proves a queued subdue never reaches the file. +- **Fixtures:** Colonist, ColonySlave (Ideology), Child (Biotech), Prisoner, `Tick`, `QuietStoryteller`, `SnapshotSettings` from Castes; new: `PrisonerBed(cell)`, `Drug(def, cell)`, `Table(cell)`, `Corpse(cell)`, `ForceBreak(pawn, def, chemical)`, `LawRow(crime, option, stage, severity, punishment, days)`. +- **Compat runs:** `-Compat` adds Prison Labor, Prisoner Realism, Custom Prisoner Interactions, Hospitality, Vanilla Social Interactions Expanded, Humanoid Alien Races if installed (Law and Order's tab never showed for its pawns), Blax Castes, Blax Slaves, Blax Zones and Blax Defaults. Package ids are read from each installed About.xml and recorded in Compat.cs with their source, as Castes does. Prisoner Sentencing and Prison Expanded aren't installed; their early release is simulated with a direct `GenGuest.PrisonerRelease`. +- **Performance:** 60 colonists and the starter lawbook, 2500 ticks with and without Laws, median of three runs: Laws adds under 2%. +- **Effort:** S plus S for the harness copy, the compat and performance runs, plus S for the scaffold (csproj, startup, LawsLog, Compat, DlcSupport, the Tools copy, the art with a "scale" badge): 1.5 days. + +### 1.1 Sentences done right and more punishments (6 days) + +1.0's jail works but costs a long colony things vanilla never gives back. This release closes those gaps first, then adds the punishments that need no new crime. + +#### Release gives back what jail took + +- **Players get:** After a sentence the pawn walks back into its own bedroom, its grave plot, its throne and its deathrest casket, takes up its ideoligion role again, its mechs return to their work modes and the weapon the arrest made it drop is allowed again. The 1.0 hold for role holders and mechanitors goes away: they are jailed like anyone, and the letter says what comes back at release. +- **How:** Right before Laws starts the Arrest or Capture job, before its first toil takes the bed (see 1.0's jail), it snapshots into the case: owned bed and grave, throne (Royalty), deathrest casket (Biotech), the Ideology role (the `Precept_RoleSingle` the pawn holds) and each mech control group's work mode (`MechanitorControlGroup.WorkMode`, RimWorld/MechanitorControlGroup.cs:55). Hook K's prefix adds the primary weapon the pawn still holds when `CapturedBy` runs, which `SetGuestStatus` then drops (RimWorld/Pawn_GuestTracker.cs:461). A weapon dropped earlier, at a subdue downing (Verse/Pawn_HealthTracker.cs:856-859), is never taken: Blax Defaults' colony forbid rule or vanilla decides about it. After `GenGuest.PrisonerRelease`, from hook L's postfix, Laws reclaims what is still free: `ClaimBedIfNonMedical` (RimWorld/Pawn_Ownership.cs:125), `ClaimGrave` (:168), `ClaimThrone` (:197), `ClaimDeathrestCasket` (:251), `Precept_RoleSingle.Assign(pawn, addThoughts: false)` (RimWorld/Precept_RoleSingle.cs:73) if nobody holds the role, `SetWorkMode` per group (RimWorld/MechanitorControlGroup.cs:84), and unforbids the weapon if it still lies where it dropped. A thing another pawn claimed meanwhile stays theirs, and the release letter names it. Each DLC part runs behind its `ModsConfig.Active`. +- **Save and removal:** Snapshot fields in the case: references and def names. Removal drops them; the pawn stays a prisoner as in 1.0. +- **Overlaps:** Arrest and Release (2593514063, 4.6k, no 1.7) warns that arrest strips Ideology roles; Laws gives them back. +- **Replaces:** Nothing. +- **Effort:** M, 2 days. +- **Tests:** Per item, one arrest and release on the core game and its DLC; each comes back. A bed claimed by another pawn during the sentence stays with that pawn and the letter names it. A role given to someone else stays with them. Royalty, Biotech and Ideology parts log "skipped: needs " without it. `-Compat` with Blax Defaults' colony rule on and a Poor rifle: after subdue then jail, the rifle follows the colony rule once the pawn is carried off, and the release leaves it forbidden; after a plain arrest, the release allows the rifle the arrest dropped. + +#### Pardon, early release and longer sentences + +- **Players get:** On a jailed case: "Release now", "Add days" and "Pardon" (ends guilt, releases, closes the case as pardoned). On an open case: "Pardon". A pardon never needs a warden's walk when the pawn isn't jailed. +- **How:** Release uses the same Release mode as a served sentence. Pardon is `Notify_Guilty(0)` and `awaitingExecution = false` (RimWorld/Pawn_GuiltTracker.cs:9, 46-49). "Add days" stops at 50 days in total while Castes' API version 2 isn't bound, so the pawn stays inside Castes' 60-day memory of its old caste; with version 2 the `blax.laws.jailed` hint keeps that memory however long the sentence runs. +- **Save and removal:** Only the case's fields change. +- **Overlaps:** None. +- **Replaces:** Nothing. +- **Effort:** S. +- **Tests:** "Release now" releases within a warden's trip; "Add days" moves the release tick and, without Castes' API version 2, stops at 50 days in total; "Pardon" leaves `IsGuilty` false and the case closed. + +#### Reprimand + +- **Players get:** A mood punishment for minor crimes: "Reprimanded" -4, -8, -12 or -16 by severity, for 3 days. +- **How:** A situational ThoughtDef whose worker reads the expiry tick from the component. Situational thoughts aren't saved and refresh every 100 ticks (RimWorld/SituationalThoughtHandler.cs:23, 34). A memory thought would be saved per pawn (RimWorld/MemoryThoughtHandler.cs:36) and log an error per memory after removal. +- **Save and removal:** The expiry tick lives in the case. After removal the thought is simply gone. +- **Overlaps:** RimCourt's rulings carry their own mood effects; they never touch the same pawn through Laws. +- **Replaces:** Nothing. +- **Effort:** S. +- **Tests:** The thought shows with the right stage, ends after 3 days, survives phase 2 with the same remaining time, and the .rws holds no "BlaxLaws" thought. + +#### Jail for slaves + +- **Players get:** Jail rows apply to slaves. A jailed slave is a slave again when the sentence ends, and stays on the map. +- **How:** Arresting a slave sets its old faction (RimWorld/Pawn_GuestTracker.cs:479-482); a release would send it off the map (RimWorld/GenGuest.cs:14-19). At the end Laws calls `guest.SetGuestStatus(Faction.OfPlayer, GuestStatus.Slave)` (RimWorld/Pawn_GuestTracker.cs:485-507) instead of releasing. That skips `GenGuest.TryEnslavePrisoner` (RimWorld/GenGuest.cs:127-155), so no `EnslavedPrisoner` precept event fires. A slave in a break isn't `IsColonist` (Verse/Pawn.cs:518-527), so guilt doesn't make its arrest certain; the arrester's Social decides, and a refusal is vanilla's berserk. +- **Needs:** Ideology; without it the option doesn't exist, since there are no slaves. +- **Save and removal:** The case remembers that the prisoner was a slave. After removal a jailed slave stays a prisoner of its old faction in your prison, as vanilla's Imprison mode leaves it. +- **Overlaps:** Vanilla's Imprison slave mode does the arrest by hand; Laws adds the way back. +- **Replaces:** Nothing. +- **Effort:** S. +- **Tests:** A slave jailed for 1 day is a slave of the colony again afterwards, never leaves the map, and no `EnslavedPrisoner` event was recorded. Skipped without Ideology. +- **Risks:** This writes slave status, which Blax Slaves owns. It only puts back the status the sentence took. Open decision for Fabian. + +#### Banish and execute + +- **Players get:** Two more punishments, always confirmed in a dialog, never automatic: banish and execute. With guilt, an execution costs the colony only the -2 "justified execution of colonist" thought (ideoligion precepts may change it) plus the family's grief; a banishment costs no colony-wide thought, and banishing to its death still grieves the family. +- **How:** Banish opens `PawnBanishUtility.ShowBanishPawnConfirmationDialog` (RimWorld/PawnBanishUtility.cs:157). Execute sets `awaitingExecution` for a free guilty colonist, which wardens carry out (RimWorld/CharacterCardUtility.cs:278-285), or the vanilla Execution mode for a jailed one. Guilt picks the mildest execution stage (RimWorld/ThoughtUtility.cs:27-31, 72) and drops the colony-wide banishment thoughts (RimWorld/PawnDiedOrDownedThoughtsUtility.cs:214-232); relations still grieve (:81-84, 253). See "Warn and guilty". +- **Save and removal:** Vanilla fields only. +- **Overlaps:** More Executions (3819037971, 1.2k) adds execution methods; they apply to Laws' executions like any other. +- **Replaces:** Nothing. +- **Effort:** S. +- **Tests:** The dialog appears and nothing happens without a click. A confirmed execution in a core-only run gives every colonist `KnowColonistExecuted` at stage 0 (-2) and nothing harsher, and the victim's spouse its grief thought. A confirmed plain banishment gives no colony-wide thought. + +#### Trial through Ideology's ritual + +- **Players get:** A "Trial" punishment. The case waits for a trial and sets no guilt. With Ideology your leader's Accuse ability works on the accused, and the vanilla verdict closes the case: convicted means the row's sentence (jail N days), exonerated closes it. Without Ideology "Trial" shows disabled with "Needs Ideology" until 1.3's own court makes it core. +- **How:** Prefix and postfix on `RitualOutcomeEffectWorker_Trial.Apply` (RimWorld/RitualOutcomeEffectWorker_Trial.cs:21-58), a 37-line override, patched only with Ideology active. The prefix stores the convict's `TicksUntilInnocent`; a conviction calls `Notify_Guilty(900000)` (:49). A guilty pawn can't be accused (RimWorld/CompAbilityEffect_StartTrial.cs:44-47), so a jump means convicted. All three trial variants (colonist, prisoner, mental state) use this worker, so Fabian's "accuse him while he binges" works through vanilla: conviction makes the arrest certain (Verse/Pawn.cs:4087). +- **Save and removal:** The case waits in the component; the trial itself is vanilla. +- **Overlaps:** Accusations+ (2557321190, 62, 1.3 only) extended the vanilla trial. +- **Replaces:** Nothing. +- **Effort:** S plus S, 1 day. +- **Tests:** A trial row and an open case; drive the worker's `Apply` with a forced positive outcome: the case closes convicted and the jail starts. Negative outcome: closed exonerated. Skipped without Ideology; in a `-NoDlc` run the row shows "Needs Ideology" and the case waits. + +#### Castes keeps the caste + +- **Players get:** With Blax Castes 1.3, a jailed colonist goes to the new-prisoner row, never the captured row, and comes back to its own caste whatever the sentence length. +- **How:** `CastesApi.HintJoinReason(pawn, "blax.laws.jailed")` from hook K's prefix, right before the capture, and `"blax.laws.released"` from hook L's prefix, right before the release (API version 2, Castes 1.3). Castes reads a hint in its `SetGuestStatus` hook, inside those calls, and drops it at the end of the tick. With the hint, Castes 1.4's prisoner caste sets no mode on the pawn. Laws keeps writing Maintain only after the capture and Release at the end for its convicts, whatever the Castes version. +- **Save and removal:** Nothing in Laws; Castes keeps its own record. +- **Overlaps:** None. +- **Replaces:** Nothing. +- **Effort:** S. +- **Tests:** With Castes in `-Compat` and API version 2, an arrest lands in the new-prisoner row, not the captured row, and a 70-day sentence (test override past the 50-day limit) still returns the pawn to its old caste. Without version 2 the call is a no-op. With Castes 1.4 and an Enslave prisoner caste, a hinted pawn's mode is MaintainOnly two ticks after the capture. + +#### Headless tests in 1.1 + +- Phase 2 covers snapshots and waiting trials; phase 3 still expects exactly 2 errors. All 8 DLC combinations. Effort S. + +### 1.2 Violent crimes (3 days) + +Only the violent crimes come before the court: they are the cases a trial is most often wanted for. The other new crimes wait for 1.8. + +#### Violence + +- **Players get:** Tantrum and vandalism (planning: the tantrum starts; did it: damaged or destroyed something), assault (hurt a colonist, slave or guest outside a fight), harming prisoners or slaves (sadistic rage included), murderous rage (planning, with the target named), manslaughter and murder. +- **How:** Hook A for the breaks (Tantrum, TargetedTantrum, BedroomTantrum, SadisticRage, MurderousRage; MentalStates_Mood.xml:318, 352, 368, 381, 191). A postfix on `Thing.TakeDamage` (Verse/Thing.cs:1477), the funnel for all damage and hot in combat, so it reads its static flag before anything else. A prefix and postfix on `Pawn.Kill` (Verse/Pawn.cs:2096) catch deaths. Excluded: drafted instigators, damage with `instigatorGuilty` false (executions; Laws' own subdue, which also sets a scope flag), victims in an aggro state, surgery (no instigator), friendly fire (`dinfo.IntendedTarget` not the victim, Verse/DamageInfo.cs:94). Vanilla already marks such attackers guilty for a day (Verse/Pawn_HealthTracker.cs:321-329). +- **Save and removal:** Cases only. +- **Overlaps:** Prison mods that beat prisoners with the beater as instigator (Prisoner Realism's demoralize, Beat Your Prisoners) are caught by "harming prisoners". That is the law's point; its tooltip says so. +- **Replaces:** Law and Order's assault and murder crimes. +- **Effort:** M. +- **Tests:** One case per crime and stage; a drafted shot opens nothing; subdue damage opens nothing. + +#### Headless tests in 1.2 + +- A combat run with 20 colonists against raiders: `TakeDamage` adds under 1% with the violence laws off. Effort S. + +### 1.3 Court sessions (9 days) + +#### Cases go to trial + +- **Players get:** "Trial" works on the core game. A case with a trial row waits in the Cases tab with "Convene court" and a gizmo on the accused, or convenes itself at the court hour when you switch that on (see "Court on its own"). With Ideology, the vanilla trial still closes the case (1.1). +- **How:** The case file gains judge, prosecutor, evidence term, session results and a short transcript of plain strings. The judge office (pawn, appointed by you) lives in the component. +- **Save and removal:** All in the component. +- **Overlaps:** RimCourt (3790057068, 8.8k, 1.7) is "you rule civil disputes as the lord"; Laws is "the colony tries those who break its laws". Its author called a colony vote "kind of a different mod". +- **Replaces:** The vanilla trial as the only court; Law and Order's trials. +- **Effort:** M. +- **Tests:** A trial row files a waiting case with no guilt; "Convene court" opens the dialog. + +#### Convene dialog + +- **Players get:** The familiar ritual-style window: role slots for judge, prosecutor, accused and spectators, a place picker (party spot, any table; from Royalty a throne; from Ideology a ritual spot or lectern), and every verdict factor with the expected conviction chance. +- **How:** `Dialog_BeginLordJob` (RimWorld/Dialog_BeginLordJob.cs:10, factors at :343, label at :81) and `PawnRoleSelectionWidgetBase` (RimWorld/PawnRoleSelectionWidgetBase.cs:13), which carry no precept and no DLC check; Anomaly's psychic rituals use them the same way (RimWorld/Dialog_BeginPsychicRitual.cs). A half-day spike confirms the dialog in a core-only game before the rest is built. +- **Save and removal:** The last place is stored by ThingID. +- **Overlaps:** None. +- **Replaces:** Nothing. +- **Effort:** M. +- **Tests:** The dialog builds in a `-NoDlc` run; the factor list sums to the chance shown. + +#### Court on its own + +- **Players get:** "Convene court on its own" (off) and "Court hour" (10). When on, a waiting case convenes at the next court hour at the last place you used, with the appointed judge and the default prosecutor, when the judge and the accused are free (not drafted, downed, in a break or in another gathering) and no hostiles threaten the map. Otherwise it tries again the next day. A message names the case; no click needed. With it off, the court sits only when you press "Convene court". +- **How:** Every 2500 ticks the component compares `GenLocalDate.HourOfDay(map)` (RimWorld/GenLocalDate.cs:16) with the court hour and starts the same lord job as the dialog, one case at a time, oldest and gravest first. 1.6's court days reuse this scheduler. +- **Settings:** "Convene court on its own" (off), "Court hour" (10, 0 to 23). +- **Save and removal:** Settings only; the last place is already in the component. +- **Overlaps:** None. +- **Replaces:** One "Convene court" click per case in a large colony. +- **Effort:** S. +- **Tests:** With the setting on, a waiting case convenes at the court hour without a click; during a raid it waits for the next day; with no place used yet it waits and the Cases tab says why; with the setting off nothing convenes. + +#### Court session + +- **Players get:** The roles walk to the place, spectators gather, the judge and the speakers trade arguments in speech bubbles for about two in-game hours, and a letter gives the verdict and the sentence. A warden brings a jailed accused and takes it back afterwards. Danger, a drafted or downed role pawn, or a missing judge calls the session off; the case stays open. +- **How:** `LordJob_BlaxCourtSession : LordJob_Joinable_Gathering` (RimWorld/LordJob_Joinable_Gathering.cs:7, call-off at :40), toils after the marriage ceremony pattern (RimWorld/LordJob_Joinable_MarriageCeremony.cs:7). Core duties only: ArriveToCell and DeliverPawnToCell (Core Defs/DutyDefs/Duties_Rituals.xml:5, 55), Spectate and GiveSpeech (Core Defs/DutyDefs/Duties_Gatherings.xml:55, 139). Bubbles through `MoteMaker.MakeInteractionBubble` (RimWorld/MoteMaker.cs:181), not `TryInteractWith`, which writes a play log entry holding the InteractionDef (RimWorld/Pawn_InteractionsTracker.cs:249). One gathering at a time, as vanilla allows. +- **Save and removal:** A running session is a vanilla lord with our LordJob class; see the removal button. +- **Overlaps:** Party and ritual mods block a session while their gathering runs, and the other way round. +- **Replaces:** Nothing. +- **Effort:** M. +- **Tests:** A session from convene to verdict in a `-NoDlc` run; a drafted judge calls it off and the case stays open; a jailed accused is back in its bed afterwards. + +#### Verdict and sentence + +- **Players get:** Conviction chance P = 0.5 + evidence + 0.25 x (prosecutor's negotiation ability minus the accused's) + judge bias, clamped to 0.1 to 0.9. Evidence, from what the case already records: did it +0.25, each count past the first +0.05 up to +0.15, planning only (stopped before acting) 0, a repeat conviction for the same law within 60 days +0.10. Laws sees every act as it happens, so there is no "found later" term; witnesses are in the Backlog. Judge bias: -0.2 x the judge's opinion of the accused / 100. No crowd term. Convicted: the row's sentence, with guilt for at least 15 days as vanilla's trial gives (RimWorld/RitualOutcomeEffectWorker_Trial.cs:8), and "Convicted" -15 for 20 days. Acquitted: +8 for 10 days. +- **How:** Negotiation ability is 0.4 plus a Social bonus, times Talking and Hearing (Core Defs/Stats/Stats_Pawns_Social.xml:5-32), the scale vanilla's trial uses. Without an attorney (1.5) the accused speaks for itself. Opinion comes from `OpinionOf` (RimWorld/Pawn_RelationsTracker.cs:592). Thoughts are situational, as in 1.1. +- **Save and removal:** Session results in the case. +- **Overlaps:** None. +- **Replaces:** Nothing. +- **Effort:** S plus S. +- **Tests:** With a test seed, P matches the formula for three set-ups: a planning-only case, a did-it case with count 4 (evidence +0.40) and a repeat offender. A conviction starts the sentence; an acquittal closes the case. + +#### Remove Blax Laws from a game + +- **Players get:** "Remove Blax Laws from this game" in the mod settings. It names the counts, ends running court sessions and subdue jobs, asks whether to release the colonists Laws jailed, removes the component and ends with "Save now, then disable the mod". +- **How:** A running session leaves a lord whose LordJob class is missing after a plain unsubscribe: it loads with a null job, `PostLoadInit` throws on it (Verse.AI.Group/Lord.cs:246), and `LordTick` throws on every tick after (:610), each one logged (Verse.AI.Group/LordManager.cs:48-60). The button ends sessions first. It runs from the UI, never inside `GameComponentTick`, which loops by index (Verse/GameComponentUtility.cs:24-37). `Game.FillComponents` only runs on new games and loads (Verse/Game.cs:345, 446), so a removed component stays gone until the next load. +- **Save and removal:** This is the removal. +- **Overlaps:** None. +- **Replaces:** Nothing. +- **Effort:** S. +- **Tests:** Phase 3 with a session running and the button pressed: no Laws error, no lord left with our job. + +#### Headless tests in 1.3 + +- The suite runs in all 8 DLC combinations; the place picker's throne and ritual spot entries skip without their DLC. Effort S. + +### 1.4 Elected judge (4 days) + +#### Voting core + +- **Players get:** The machinery every later vote shares. Who votes: free adult colonists on the home map (`IsFreeNonSlaveColonist`, Verse/Pawn.cs:542-552), never quest lodgers, slaves, children or prisoners; pawns in a break or away abstain. A "Votes" tab in the Laws window shows the ballot and each voter's choice. A vanilla letter gives the tally. An alert stays up while a vote is open and opens the tab when clicked. "Aye" and "Nay" float over the voters when it closes. +- **How:** `Alert.OnClick` (RimWorld/Alert.cs:170); alerts are found by reflection and never saved. `MoteMaker.ThrowText` (RimWorld/MoteMaker.cs:43). No custom letter class (the archive deep-saves letters) and no IncidentDef (the storyteller saves fired incident defs): the component schedules votes with `Rand.MTBEventOccurs` (Verse/Rand.cs:523) every 2500 ticks. Rolls that must read the same twice run inside `Rand.PushState` with a seed from the vote id and the pawn. "My side won", "my side lost" and "overruled" are situational thoughts. +- **Save and removal:** Open votes and their rows live in the component. +- **Overlaps:** None. +- **Replaces:** Nothing. +- **Effort:** M. +- **Tests:** The same tally twice gives the same result; an alert click opens the tab; the .rws holds no Laws letter class. + +#### Judge election + +- **Players get:** The judge holds office for 60 days. An election runs when the term ends, when the judge dies, leaves, is jailed or convicted, or when you press "Hold election". Each voter picks the candidate with the highest opinion plus 3 x Social level, +15 for itself; ties go to higher Social. You can confirm the winner or appoint someone else, which gives the overruled voters a small mood penalty. A recall vote comes up when the colony's mean opinion of the judge drops below -10. A judge who is the accused, the victim or family of the accused hands the case to an acting judge. +- **How:** Opinion from `OpinionOf` (RimWorld/Pawn_RelationsTracker.cs:592), once per voter and candidate per election: 3600 lookups at 60 pawns, once per term. +- **Settings:** "Judge: appointed (default), elected, ideoligion leader, moral guide". +- **Save and removal:** Office and term in the component. +- **Overlaps:** Leader Election (3822858677, 253), Colony Leadership (Continued) (2859856468, 3.5k), Ideology Leadership Expanded (3743069183, 3.2k, 1.6) and Rimocracy elect leaders; Laws elects only the judge and never writes `Faction.leader` or a role. +- **Replaces:** Nothing. +- **Effort:** S plus S. +- **Tests:** A friend-heavy colony elects the popular Social 10 pawn; a vacancy on the judge's death triggers a by-election; a recall passes below -10. + +#### Ideoligion leader as judge + +- **How:** Reads the role holder with `ChosenPawnSingle` (RimWorld/Precept_RoleSingle.cs:130) behind `ModsConfig.IdeologyActive`. Without Ideology the two options show disabled with "Needs Ideology", and a saved choice falls back to elected. +- **Save and removal:** The choice is a setting name. +- **Effort:** S. +- **Tests:** With Ideology the leader presides; in a `-NoDlc` run the saved choice reads as elected. + +### 1.5 Attorneys (3 days) + +#### Defence and prosecution + +- **Players get:** When a trial is set, the accused asks the colonist with the best mix of its liking for the accused and negotiation ability, and that colonist accepts when its opinion of the accused is 10 or more. You can assign anyone in the dialog (a reluctant attorney argues a little worse) or let the accused speak for itself. The prosecutor defaults to the victim, then the best speaker. Both speakers get 200 Social XP per session. A defended convict takes the verdict better (-8 instead of -15); an acquitted one likes its attorney more (+15). A Kind judge cuts sentences by a quarter, a Psychopath or Bloodlust judge adds a quarter. +- **How:** The defender's negotiation ability replaces the accused's in P. XP through `SkillRecord.Learn`. Opinion effects are situational social thoughts read from the case file, with an early-out set of pawns that have court history, so 60 x 60 opinion recalculations stay cheap. +- **Save and removal:** Roles per case in the component. +- **Overlaps:** RimCourt players asked for prosecution and defence colonists using Social (2026-08-27); its author has no plans for it. +- **Replaces:** Nothing. +- **Effort:** S per part (asking, prosecutor, XP and opinions, judge traits) plus S tests, 3 days. +- **Tests:** A Social 12 attorney lowers P by the formula; a refusing pawn below opinion 10 isn't proposed; XP lands on both speakers. + +### 1.6 Multi-day trials and courtrooms (6 days) + +#### Court days + +- **Players get:** Serious and grave cases take 2 or 3 court days, one session a day at the court hour from 1.3, with an alert when court sits. The case window shows how each day went. The verdict on the last day comes from the mean of the days. An absent attorney means the accused speaks for itself that day; a failed day is rescheduled. The accused can be held in custody until the verdict. +- **How:** Each session computes its own P with that day's attendees, plus a small swing shown as "the day went to the prosecution" or "to the defence". Custody reuses jail without guilt. +- **Save and removal:** Day results in the case. +- **Overlaps:** None. +- **Replaces:** Nothing. +- **Effort:** M for days and the tally, S for absences, S for custody. +- **Tests:** A grave case runs 3 days; the verdict uses the mean; an escape during custody closes the case as escaped. + +#### Courtrooms + +- **Players get:** A room built around the court place counts as a courtroom when it is impressive enough. A verdict given there costs the convict less mood. +- **How:** A `RoomRoleDef` whose worker scores a room holding the chosen court place, after `RoomRoleWorker_ThroneRoom` (RimWorld/RoomRoleWorker_ThroneRoom.cs:17-30). Room roles are computed, never saved. +- **Save and removal:** Nothing saved; a room loses the role with the mod. +- **Overlaps:** RimCourt's seat spot is a different building. +- **Replaces:** Nothing. +- **Effort:** M, plus S tests. +- **Tests:** A room with the place and high impressiveness gets the role; the convict's thought is milder there. + +### 1.7 Law votes (5 days) + +#### Colony votes on the lawbook + +- **Players get:** A per-save switch, off by default. Colonists propose a law after an act that has none (25% chance, at most once per action per 10 days), petition to repeal an unpopular one (every 10 days on average) or you press "Call a vote" on any row. One vote at a time, open for 24 hours. Each voter's score adds trait stances (a pyromaniac votes against a fire law, a teetotaler for a drug law), self-interest (a trait whose only break is the targeted one), what a bystander would feel unless the voter doesn't care, Ideology precepts on the act, opinion of the offender and the proposer, and low mood. A proposal passes with more yes than no votes and at least half the voters taking a side; a tie keeps the current law. The result letter gives each voter's main reason ("Bob: no (pyromaniac)"). You can back or veto the result; the overruled side gets a small mood penalty. You can always edit the lawbook directly. +- **How:** The 1.4 voting core plus the score terms. An act without a law is invisible in 1.0 (its flag is false and the hook returns at once), so while votes are on every crime's flag is set in tally-only mode: the hooks count acts per crime in an unsaved tally and open no case, and a proposal rolls from that tally. The violent crimes (1.2) are the exception, since their `Thing.TakeDamage` hook is hot in combat; they come up only through petitions and "Call a vote". Self-interest reads `TraitDegreeData.randomMentalState` and `theOnlyAllowedMentalBreaks` (RimWorld/TraitDegreeData.cs:35, 63), so modded traits count with no patch. Bystander immunity through `ThoughtUtility.ThoughtNullified` (RimWorld/ThoughtUtility.cs:305). The stance data lives in the `CrimeDef` XML from 1.0 (traits, bystander thought, history events with `MayRequire="Ludeon.RimWorld.Ideology"`), unused until now, so the save format doesn't change. Precept comps are read directly, not through `Ideo.MemberWillingToDo`, which rolls a random chance inside (RimWorld/Ideo.cs:881). +- **Save and removal:** Proposals and open votes in the component. +- **Overlaps:** Rimocracy (2159080853, 6.3k) votes on leadership decisions; Laws votes only on lawbook rows and the judge. +- **Replaces:** Nothing. +- **Effort:** S plus S proposals, M scores and reasons, S plus S vote flow, S tests: 5 days. +- **Tests:** A pyromaniac votes no on a fire law; a teetotaler yes on a drug law; a cannibal no on a cannibalism law; a friend of the offender no, a rival yes; 2 of 6 voters taking a side fails on quorum; overrule thoughts reach only the overruled side; with 60 voters opening and closing a vote stays under a millisecond budget. With votes on and an empty book, a forced fire-starting spree counts in the tally, opens no case and can raise a fire-law proposal; with votes off the fire flag stays false. + +### 1.8 More crimes (3 days) + +#### Breaks, escapes and desertion + +- **Players get:** Jailbreak (a colonist frees prisoners), desertion (planning only: the give-up-and-leave break, since a deserter who left is out of reach), slaughtering colony animals, food binge, prison break (prisoners as offenders), slave rebellion (Ideology). +- **How:** Hook A for Jailbreaker, GiveUpExit, Slaughterer and Binging_Food (MentalStates_Mood.xml:125, 249, 153, 432). Postfixes on `InteractionWorker_SparkJailbreak.Interacted` (RimWorld/InteractionWorker_SparkJailbreak.cs:9), `PrisonBreakUtility.StartPrisonBreak` (RimWorld/PrisonBreakUtility.cs:214, whose out list names the escapees), `SlaveRebellionUtility.StartSlaveRebellion` (RimWorld/SlaveRebellionUtility.cs:403) and the private `ExecutionUtility.ExecutionInt` (RimWorld/ExecutionUtility.cs:20) for the slaughterer. Food binge reuses hook C. +- **Save and removal:** Cases only. +- **Overlaps:** Blax Slaves owns rebellion; the rebellion crime only records who rebelled. +- **Replaces:** Law and Order's sabotage crime, partly. +- **Effort:** M. +- **Tests:** One case per crime; the slave rebellion test skips without Ideology. + +#### Drugs against the policy + +- **Players get:** "Took a drug the drug policy doesn't allow", outside binges and player orders. +- **How:** Hook D compares `ingester.drugs.CurrentPolicy[def]` (`allowedForJoy`, `allowedForAddiction`, `allowScheduled`; RimWorld/DrugPolicyEntry.cs:9-13). Medical drugs and doctor-given doses don't count. +- **Save and removal:** Cases only. +- **Overlaps:** Castes sets drug policies; Laws only reads them. +- **Replaces:** Nothing. +- **Effort:** S. +- **Tests:** A forced ingest of a drug the policy forbids opens a case; an allowed one doesn't. + +#### Headless tests in 1.8 + +- All 8 DLC combinations; the slave rebellion test skips without Ideology. The new crimes join 1.7's tally-only mode, checked with one forced break each. Effort S. + +## Works with the other Blax mods + +- Package ids: `blax.slaves`, `blax.castes`, `blax.zones`, `blax.defaults`, `blax.laws`. No hard dependencies. Laws' About.xml lists `brrainz.harmony`, `blax.castes` and `blax.slaves` in loadAfter, because it binds `CastesApi` (1.1) and `SlavesApi`. Load order becomes Castes, Zones, Slaves, Laws. No sibling lists `blax.laws`, so there is no loadAfter cycle. Defaults lists no sibling and no sibling lists Defaults. +- Detection: one Compat helper, `ModLister.GetActiveModWithIdentifier(id, ignorePostfix: true)`. Sibling APIs bound by reflection into cached delegates at startup; a missing sibling or method is a silent no-op. Laws offers no API in 1.x; a `LawsApi` with an int `Version` comes when a sibling needs one. +- Ownership: + - Castes: every per-pawn policy default (apparel, food, drug, reading, medical care, schedule, work priorities, weapon loadout, allowed area, hostility, self-tend, carried medicine, fire at will, prisoner interaction except the Maintain only and Release modes Laws sets on colonists it jailed). + - Zones: sleeping spots, beds by zone, every friendly drop location and per-cell work rules (work rule areas); it never changes a pawn's work priorities or allowed area. + - Slaves: slave status (except the status Laws gives back to a slave it jailed), trade, prices, suppression, rebellion, slave medicine and the slave economy. + - Defaults: starting settings of vanilla stockpiles and growing zones, storage buildings, production bills, workbenches, buildings, animals and mechs, and what the game forbids when pawns go down, die or are stripped. It writes when something is made or joins, and through its opt-in forbid rules when a pawn goes down, dies or is stripped. It keeps nothing in the save. + - Laws: the colony's lawbook (which acts are crimes, at which stage, how severe and how they are punished), cases, sentences and, from 1.3, trials, judges, attorneys and law votes. It acts through vanilla arrest, capture, release and guilt plus its own non-lethal subdue job. For the colonists it jailed, and only for them, it writes the prisoner interaction mode (Maintain only after the arrest, Release when the sentence ends) and, from 1.1, gives back what the sentence took: bed, grave, throne, deathrest casket, ideoligion role, mech work modes and the weapon the arrest dropped. From 1.1, and only if Fabian agrees, it puts a slave it jailed back into slavery. It never sets policies, work priorities, allowed areas, zones or suppression. It keeps its state in one GameComponent. + +### Blax Castes + +- An arrest is vanilla `CapturedBy`, so Castes 1.0 already moves the jailed colonist to the new-prisoner row and a release within `formerCasteDays` (60) back to its old caste. Laws' 50-day limit on days keeps every 1.0 sentence, the fallback day included, inside that window; 1.1's "Add days" stops at 50 days in total until the API version 2 hint keeps the record. From Castes 1.3 an arrest without the hint lands in the captured row (Castes' new `CapturedBy` scope); Laws 1.1 hints it. +- The one write into Castes' area: the Maintain only and Release modes for pawns Laws jailed, in every version of both mods. From Castes 1.3 (API version 2) Laws 1.1 sends `blax.laws.jailed` from hook K and `blax.laws.released` from hook L through `HintJoinReason`; Castes 1.4's prisoner caste then sets no mode on the hinted pawn, and Laws still writes Maintain only two ticks after the capture. +- Laws never writes a policy, a schedule, medical care or a work priority. Jail keeps priorities because prisoners have no disabled work types; the `-Compat` run checks that Prison Labor doesn't change them. + +### Blax Slaves + +- Slaves are offenders like colonists, with warn, guilty and subdue in 1.0. Rebellion stays Slaves'; 1.8's rebellion crime only records it. +- Slaves 2.0's wardens calm slaves out of non-violent breaks. When a SlavesApi member says that feature is on, Laws doesn't subdue slaves and lets Slaves' wardens talk them down. +- 1.1's jail for slaves puts a jailed slave back into slavery at the end, without vanilla's enslave event. It restores the status the sentence took; it's still a write to slave status, so it ships only if Fabian agrees. +- Suppression is never touched. A re-enslaved slave starts with the suppression vanilla gives a new slave. + +### Blax Zones + +- Jail uses any vanilla prisoner bed. Zones 1.5's prisoner sleeping zones are made of real beds, so arrests find them with no Laws code. +- A court place (1.3) and a courtroom (1.6) are stored by ThingID in Laws' component, never as a zone. + +### Blax Defaults + +- Arrest drops the weapon and inventory forbidden inside `SetGuestStatus`, which Defaults' forbid rules don't see; 1.1 unforbids the weapon the arrest dropped, noted in hook K's prefix. A subdue downing goes through `MakeDowned` first, so a subdued pawn holds no weapon at the capture: Defaults' colony forbid rule decides about that weapon once the pawn is carried off, and Laws never touches it. Neither mod hooks the other. A `-Compat` test with the colony rule on covers both paths (see 1.1 "Release gives back what jail took"). + +### Shared conventions + +- Patches applied one class at a time from a `[StaticConstructorOnStartup]` class, logging "[Blax Laws] N patches applied". Every feature has a toggle. Every hook body in try/catch with a one-time log. Headless test mod copied from Zones (`Tests/BlaxLawsTests`, `run-tests.ps1`) with phase 3; a release runs all 8 DLC combinations. + +### Sibling doc changes, when this design is accepted + +- All four docs and READMEs: package ids gain `blax.laws`; the ownership lists gain the Laws sentence above; load order reads "Castes, Zones, Slaves, Laws"; the "More Blax Gaming mods" lines on the Workshop pages name Blax Laws. +- The shared ownership lines, the same in all five docs: Castes' line ends "prisoner interaction except the Maintain only and Release modes Laws sets on colonists it jailed"; Slaves' line reads "slave status (except the status Laws gives back to a slave it jailed)"; the Laws line is the one above. In Castes `docs/design.md` (its "Works with the other Blax mods" list), Zones `docs/design.md` (the ownership bullet in its Blax mods section), Slaves `docs/roadmap.md` (the "Ownership" bullet) and Defaults `docs/design.md` (its ownership line and the Castes paragraph that lists prisoner interaction). +- Castes `docs/design.md`: the join reason table gains `blax.laws.jailed` (new-prisoner row, never the captured row, no prisoner mode, former-caste record kept beyond `formerCasteDays`) and `blax.laws.released` (previous caste whatever its age). 1.4's default prisoner interaction skips pawns with the `blax.laws.jailed` hint. +- Slaves `docs/roadmap.md`: `SlavesApi` gains a bool `CalmsBreaks` with 2.0's "Wardens calm breakdowns", which Laws reads to stand its subdue down for slaves. The Cut line on flogging gets a note that Laws' subdue is a capped fistfight to end a break, not a punishment system for slaves. +- Zones `docs/design.md`: "Works with the other Blax mods" notes that Laws' arrests use prisoner zone beds like any prisoner bed. +- Defaults `docs/design.md`: the Blax mods section notes that Laws' subdue downs a pawn through `MakeDowned`, so the colony forbid rule decides about that weapon, and that from Laws 1.1 the weapon an arrest drops is allowed again at the release. + +## Backlog + +- "Attempted" stage between planning and did it (M): needs a postfix on the huge, hot `Pawn_JobTracker.StartJob` (Verse.AI/Pawn_JobTracker.cs:252) with a set of watched JobDefs, for example an ingest job toward wake-up during a binge. +- Crimes on caravans (S): today only pawns on a map are watched; caravan cases would wait until the pawn is home. +- Player-ordered acts as crimes, each an explicit option: execution, organ harvesting, butchering a human, hemogen extraction (Biotech). Vanilla already has "about to" checks in work givers through `HistoryEvent.Notify_PawnAboutToDo_Job`. +- Ideoligion precept violations and apostasy through `HistoryEventsManager.RecordEvent` (RimWorld/HistoryEventsManager.cs:55), adultery through `GotLovin_NonSpouse` (Core), freeing a held entity (Anomaly). +- Theft: vanilla colonists never steal; a "took forbidden goods during a break" flag in the `Thing.Ingested` prefix. +- Guilty plea for a shorter sentence; appeals and retrial under a new judge; witnesses as a role and as evidence (free colonists with line of sight to the act, recorded in a new Case field at filing); a jury from the spectators. +- A judge's bench with art (needs a removal story for a missing ThingDef). A titled noble presides (Royalty). Trial by duel (Ideology's duel lord job). +- Trials for guests and enemy prisoners, next to Prisoner Sentencing and Prison Expanded. +- RimCourt bridge: its pillory and lash as punishments while RimCourt is active. +- Lawbook templates shared across saves, in a Config file with Defaults' write, read-back and backup rules. +- A Castes right "may serve in court". +- Pardon petitions from a convict's friends; votes on punishments ("beating is cruel"); campaigning through vanilla deep talks; Royalty vote weight. +- Confessions and interrogation, next to Prisoner Interrogation Ritual (3696342867, 1.3k). +- Subdue weighs the enforcer's Melee against the offender's. + +## Cut + +- New crime events or extra mental breaks: Law and Order did that and a commitment save drowned in murderous rages. Laws only watches. +- A "planning" stage guessed from mood or traits before a break: the break type doesn't exist until the break starts (Verse.AI/MentalBreaker.cs:311-328). +- Vanilla's `AteMeat` event for the meat law: Ideology only and blind to meals (Verse/Thing.cs:2055-2064). +- The vanilla Ideology trial as the court: leader-only judge who also prosecutes, no defender, the leader's 10-day ability cooldown, a verdict driven by crowd size, Ideology only. Laws listens to it instead (1.1). +- A hidden ritual precept to get the ritual dialog for free: it would sit in every ideoligion in the save (RimWorld/Ideo.cs:617-624) and log errors per ideo after removal. +- Votes or court days as IncidentDefs, GameConditions or quests, a custom Letter class or LetterDef, memory ThoughtDefs, HediffDefs for punishments, our own InteractionDefs: each leaves our defs in vanilla save lists. +- A "Law enforcement" work type: WorkTypeDefs sit in a `DefMap` saved by index, so adding or removing the mod shifts other mods' values. +- Subdue with vanilla melee (`AttackMelee` or the social fight job): the weapon or fists hit the head, the undrafted enforcer turns guilty and the target fights back. +- Fines: colonists own no silver, so a fine only burns colony silver. +- Work bans: disabling work types zeroes priorities for good (RimWorld/Pawn_WorkSettings.cs:195-205), and Castes owns priorities. +- Torture and flogging: beyond vanilla's tone; War Crimes Expanded 2 has torture for those who want it. +- Patching `JobDriver_ReleasePrisoner`: releases go through the vanilla interaction mode. +- Using the guilt timer as the sentence: other mods change guilt length; the case keeps its own release tick. +- Patching tiny methods: `Notify_CorpseHauled`, `Pawn_GuiltTracker.Notify_Guilty`, `ExecutionUtility.DoExecutionByCut` (a one-line wrapper; 1.8 patches the private `ExecutionInt`), the empty `MentalState.Notify_AttackedTarget`.