rimworld-blax-laws/docs/design.md

159 KiB

Blax Laws

Write a lawbook and the colony enforces it. Add "Drug binge, wake-up, 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. A law's Action is picked from a searchable list the mod builds from the game's own defs, the way you pick what to tailor: every mental break, everything that can be eaten or used, every social interaction, every act the game records and every bill, with DLC and modded content included. Laws only watches what the game already does. Beyond that it covers sentences that give back what jail took, repeat offenders, a court with a judge the colony elects, attorneys who argue with their Social skill, witnesses and trials over several days, and colony votes on the laws themselves. What the mod covers and in which order: docs/features.md.

Status: design, no code yet. Checked against the RimWorld 1.7.5021 game code on 2026-11-30; the act catalogue (2026-12-01) was checked against the 1.7.5021 reference assemblies, which have every signature and no method bodies, so its behaviour claims are listed under "To verify" until the decompiled code confirms them. 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.

Changes on 2026-12-01, the five Blax plans checked against each other:

  • The ownership list is the same in all five design docs; parts that wait on an open question name it. The sibling doc changes are done on the siblings' plan branches.
  • Castes' planned CapturedBy scope keeps arrests in the new-prisoner row, so an unhinted arrest never lands in the captured row. A jailed slave made a slave again gets the blax.laws.released hint too.
  • "Slaves' wardens first" and talk down stand down only for the breaks Slaves' wardens take (not IsAggro, not the rebellion); tantrums and rages stay Laws'. The indentured term hint is Slaves' open question 3, and confinement's sentence caste is Castes' area 5, step 5.

Changes on 2026-12-01, plan review (the feature plan checked against the decompiled 1.7 code):

  • First release cut back to the quick MVP Fabian asked for: the lawbook, the catalogue with its breaks and special acts, warn, guilty, subdue, jail and serving the sentence with the hold for role holders and mechanitors. Violence, slaughterers, drugs against the policy, reprimand, banish and execute, the give-back and pardon follow as the next release. The areas stay as they were; docs/features.md "Order" says which part ships when.
  • Breaks: the line is now a state hostile to the colony (MentalState.ForceHostileTo(Faction.OfPlayer), only berserk-type states in vanilla), not IsAggro. Tantrums, murderous and sadistic rage and slaughterers can be arrested (Verse.AI/GenAI.cs:83) and get every break punishment, Subdue included. A berserk case takes Warn, Guilty or Jail, and the jail waits until the break ends or the pawn is down. "Subdue for aggressive breaks" became "Subdue a pawn that fights back": never automatic, the player picks the fighter.
  • One act, one case keeps the break case, but when the act also matches a row of its own (a murder during a murderous rage), the row with the higher severity decides.
  • Violence: melee hits carry no intended target, so friendly fire is only a hit whose intended target is set and isn't the victim; a death without an attacker (bleeding out, infection) turns the victim's recent assault case into manslaughter.
  • Hooks: bills are caught by a postfix on RecordsUtility.Notify_BillDone, not the empty, inlinable Bill.Notify_IterationCompleted; CompUsable.UsedBy files only for a pawn using the item on its own job; Ate counts a drink at a gathering spot.
  • Court: our own convene window, since Dialog_BeginLordJob needs an installed DLC; judge and speakers stand on ArriveToCell, since Core's GiveSpeech duty needs a throne; courtrooms read impressiveness instead of adding a room role; custody sets guilt for the arrest and clears it at the capture; new punishment "Jail, then trial"; an acting judge from court sessions on; the repeat term reads the criminal record.
  • Plan: colony votes start with the voting core and law votes, which need no court; the criminal record comes before court sessions; prison breaks cover only Laws' own convicts; jail for slaves skips indentured slaves; crimes against the faith read the colony's ideoligion and every precept comp with a bad thought, and apostasy is the ChangedIdeo event. New: "Applies to", talk down, decide myself, Slaves' wardens first, confinement through Castes. Indenture as a sentence moved to the ideas.

Changes on 2026-12-01, the feature plan (Fabian, 2026-12-01: plan the whole mod, chunked by what belongs together, never by time or size):

  • docs/features.md is the new plan of record for scope and order: seven areas (lawbook, crimes, enforcement and punishments, sentences, repeat offenders, court, colony votes), each with steps only where a part needs another part, a sibling feature or a decision first. This file keeps the specs. "At a glance" is a table by area, "Releases" became "Areas and steps", and day counts and totals are gone; per-feature S, M and L marks stay as information. Version numbers in the dated notes below refer to the old cut.
  • Regrouped: violence, slaughterers and drugs against the policy join the first release's crimes; reprimand, banish and execute its punishments; the give-back and pardon its sentences, so a jail never takes a bedroom or a role for good. The Ideology trial is the court's first step. Subdue for aggressive breaks is its own enforcement step. Elected judge and law votes form one area around the shared voting core. Prison breaks and slave rebellions are the crimes' "uprisings" step.
  • Two sections were split along the new areas: "Violence" (its aggressive-break subdue is now "Subdue for aggressive breaks") and "Slaughterers, prison breaks and slave rebellions". Spec content is otherwise unchanged; version references became feature names.
  • New in the plan, not specced yet: lawbook templates, crimes against the faith, repeat offenders (criminal record, escalation, probation), witnesses, guilty plea, appeals, jury and pardon petitions, most of them promoted from the Backlog. Indenture as a sentence is an open question for Fabian.

Changes on 2026-12-01, the act catalogue (Fabian, 2026-11-30: the crimes he named were examples from a full list, "like when deciding what to tailor"):

  • A law's Action is now an entry of the act catalogue: seven categories built from the loaded defs when the game starts (mental breaks, ate, used, social interactions, recorded acts, records, bills) plus a short list of special acts that need their own hook (set a fire, displayed a corpse, started a social fight). Each category also offers group entries (any drug, hard drugs, human meat, any surgery and so on). DLC and modded defs show up with no patch, labelled with the mod they come from.
  • The six crimes are gone as a type. Their detection stays and now serves the categories; the old crimes are starter lawbook rows and links between a break and its act.
  • "Did it" for a break comes from a link table by mental state class: a dose during a drug binge, a meal during a food binge, a fire during a fire-starting spree, a displayed corpse during a corpse obsession, an insult during an insulting spree, a jailbreak talk during a jailbreaker break. A modded break that reuses a vanilla class gets its link too. Every other break offers Planning only until a later release links it.
  • Aggressive breaks (berserk, murderous rage and the rest with IsAggro) are in the catalogue from 1.0 but offer Warn and Guilty only: subdue would walk an unarmed warden into a pawn that fights back, and vanilla refuses to arrest them. (Corrected by the plan review above: vanilla refuses the arrest only for states hostile to the arrester, berserk in vanilla.)
  • One act, one case: an act that is the did-it of an open break case belongs to that case; otherwise each category's most specific enabled row decides. Rows of different categories that can catch the same act get an overlap hint in the editor.
  • New hooks: Pawn_RecordsTracker.Increment and AddTo, HistoryEventsManager.RecordEvent, Notify_IterationCompleted on the bill classes, CompUsable.UsedBy. Hook D (CompDrug.PostIngested) is dropped, since hook C sees every dose.
  • Plan: 1.0 takes 12 days instead of 10 (the picker and the category workers). 1.8 shrinks from 3 days to 2: food binges, jailbreakers, desertion and slaughterers are breaks in the 1.0 catalogue. The plan is 50 days.
  • Defaults to confirm: one entry per row rather than a set of ticked entries (the most-specific rule needs one entry per row), and no subdue for aggressive breaks before 1.2.

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

What the mod covers, by area. Which area and step comes first, and why: docs/features.md.

Area What players get Needs Replaces
Lawbook An empty Laws tab. Add a law as Action, Stage, Severity, Punishment and Days, or press "Starter lawbook". The Action comes from a searchable catalogue built from the game's defs. A case log. Later: lawbook templates across saves, laws for one group of pawns None (castes: Blax Castes) Rimworld Law and Order (419, 1.6 only, needs Ideology)
Crimes Every mental break, everything eaten or used, every social interaction, every recorded act and record, every bill, plus fire setting, corpse display, social fights, assault, harming prisoners or slaves, manslaughter, murder, slaughterers and drugs against the policy, DLC and modded content included. Later: prison breaks by Laws' own convicts and slave rebellions, crimes against the faith None (slaves, most recorded acts, slave rebellion, faith: Ideology) Law and Order's crimes, its sabotage crime partly. 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)
Enforcement and punishments Warn, guilty for N days, subdue (a capped beating that stops a break and never kills), jail, subdue then jail, reprimand, banish and execute after confirmation. Later: talk down, decide myself, Slaves' wardens first for slaves, subdue a pawn that fights back None (children never beaten: Biotech) Arresting your own colonist mid-break by hand, which Arrest and Release (4.6k, no 1.7) exists for
Sentences Sentences served on Maintain only and released by a warden. Release gives back the bed, grave, throne, deathrest casket, ideoligion role, mech work modes and the dropped weapon. Pardon, early release, add days. Later, with the sibling mods: Blax Castes keeps the caste, jail for slaves, confinement through Blax Castes None (role: Ideology; throne: Royalty; casket, mechs: Biotech; slaves: Ideology) Custom Guilt Duration for colonists (3.4k, no 1.7), Guilty! (302, 1.6)
Repeat offenders A criminal record per pawn, escalating punishments for repeat offences, probation. New, not specced None None; parole like Prison Expanded's (3.3k) for colonists
Court "Trial" as a punishment through Ideology's trial. Court sessions on the core game: an appointed judge, a prosecutor and spectators at a place you pick, a verdict that weighs evidence against Social skill, the sentence from the lawbook, "Jail, then trial", an acting judge, a court hour, a removal button. Attorneys, witnesses and a guilty plea. Trials over 1 to 3 days, courtrooms, appeals None (Ideology's trial: Ideology) The vanilla trial as the only court (Ideology), Law and Order's trials
Colony votes A voting core, law votes with back and veto, pardon petitions, an elected judge with terms, by-elections and recalls (or the leader or moral guide with Ideology), a jury None (leader as judge, precept stances: Ideology) None; overlaps Rimocracy (6.3k), which elects leaders and votes on its decisions

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 area runs on the core game, and a DLC in brackets marks the parts that switch off without it (see "DLC support"). Effort marks on features (S = 0.5 days, M = 2, L = 5) are information only; they decide nothing about grouping.

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 (while law votes are on, it counts acts without opening cases).
  • "Starter lawbook" adds seven suggested rows in one click, only when pressed: any drug binge planning: subdue, Moderate; any drug binge did it: jail 5 days, Serious; fire-starting spree planning: subdue, Serious; fire-starting spree did it: jail 10 days, Grave; corpse obsession planning: subdue, Moderate; started a social fight did it: warn, Minor; Insult did it: warn, Minor. "Ate: any meat" is left out, since most colonies eat meat. Pressing it again adds only rows that are missing.
  • One catalogue entry per row. An entry is a single def (Insult, Wake-up, the fire-starting spree) or a group (any drug binge, hard drugs, human meat, any surgery). A row that ticks several entries, like a bill's ingredient filter, would make "the most specific row wins" ambiguous, so a player who wants three drugs adds three rows or picks a group.
  • 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. Option exists only for drug binges (which drug counts as "did it": any, hard, social or one chemical). When several enabled rows of one category match an act, the most specific wins: a single def over a group over the category's "any"; for binges one chemical over hard or social drugs over any drug. The starter rows plus "drug binge, 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". Only break entries have Planning, since the game decides the break type at the moment the break starts and never earlier. A break has "Did it" only when the link table names its act (see "Act catalogue and detection"); every other entry is "Did it" only. 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 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: the first release has Warn, Guilty for N days, Subdue, Jail for N days and Subdue then jail; Reprimand, Banish and Execute come in the next release, Trial and "Jail, then trial" with the court. Which entry and stage offers which: the table in "Lawbook tab". 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.
  • Breaks hostile to the colony (the live state's ForceHostileTo(Faction.OfPlayer) is true: berserk and berserk warcall in vanilla, Verse.AI/MentalState_Berserk.cs:12-15) offer Warn, Guilty and Jail, never Subdue: the pawn fights back, and vanilla refuses to arrest it (Verse.AI/GenAI.cs:83). Its Jail waits until the break ends or you down it, then arrests or captures it; guilt makes both certain (Verse.AI/GenAI.cs:59-66). Every other break, the aggressive ones included (tantrums, murderous and sadistic rage, slaughterer: IsAggro but arrestable and never aimed at the enforcer), offers the full break list. "Subdue a pawn that fights back" (Enforcement, step 3) adds a subdue for hostile breaks that the player starts.
  • 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 act, one case. An act that is the did-it of an open break case (a dose during the binge) belongs to that case, and no other row opens a second case for it. When the act also matches a row of its own (a murder during a murderous rage, a dose under "Ate: wake-up"), the case carries out the row with the higher severity, the break's row on a tie, so a "Murder: jail 10 days, Grave" row still applies to the most common colony murder. Outside a break each category files its own case, so "Ate: wake-up" and "Recorded acts: ingested a drug" (Ideology) both catch a dose; the editor shows an overlap hint on rows of different categories that can catch the same act.
  • 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.
  • Every act outside a break opens 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, a meat-eating colony of 60 or a "Records: things hauled" row 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 (Laws' own convicts only for a prison break, Crimes step 2) or babies. Slaves get Warn, Guilty and Subdue; jail comes with "Jail for slaves" (Sentences, step 2).
  • 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. A colonist in a berserk break counts as such a threat, so cases on its map wait until it ends or is downed.
  • 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 while "Release gives back what jail took" is switched off, because arrest takes the role and shuts the mechs down. The case waits with an "Arrest now" button and a letter says why. The first release ships with this hold; with the give-back on (the next release) both come back after the release and the hold drops.
  • 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 catalogue shows every entry the loaded game has, Royalty's psytrainers and a modded drug included, each labelled with its mod. Entries that make little sense as crimes (eating a simple meal, chitchat) stay in: the list is the game's, the lawbook is yours.
  • The court convenes when you press "Convene court", 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. Votes are off per save until you switch them on.
  • 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<Law> laws (deep) and nextLawId. A Law holds only names and numbers: id, act key (category plus defName or group id, such as Ate/WakeUp, Ate/@humanMeat, Break/FireStartingSpree, Special/SetFire), the entry's label and source mod as they read when the row was written, option (a chemical defName or a drug group, binges only), stage and severity as enum names, punishment defName, days, enabled.
    • List<Case> cases (deep) and nextCaseId. A Case holds the offender (pawn reference plus name and ThingID), the victim (same), the law's act key and the defName that matched it (which drug, which recipe), 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-act flags and sets, the act catalogue and the enforcement queue (all 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.

The act catalogue is built from the game's defs, saved as names

  • Laws defines no crime list of its own. ActCategoryDef (our own Def type, seven of them: Break, Ate, Used, Interaction, RecordedAct, Record, Bill) names an ActCategoryWorker that reads the loaded defs once, after def loading, and returns the category's entries: one per def plus its group entries. ActDef (our own Def type) is a special act with its own hook and ActWorker: SetFire, DisplayedCorpse and StartedSocialFight in the first release, the violent acts and the slaughterer's kill with "Violence" and "Slaughterers", prison break and slave rebellion with the uprisings. BreakLinkDef (our own Def type) names a mental state class and the act that counts as its "did it" (see "Act catalogue and detection"). PunishmentDef with label, the stages and entry kinds it fits, and a PunishmentWorker. The first release ships them in Defs/BlaxLaws_Categories.xml, BlaxLaws_Acts.xml, BlaxLaws_BreakLinks.xml and BlaxLaws_Punishments.xml. Another mod can add a BreakLinkDef for its own break class with no code.
  • ActCatalogue holds the entries: key, label, icon, source mod (def.modContentPack, shown as "Core", the DLC's name or the mod's name), category, the stages and punishments the entry offers. It is built once per game start (a few thousand entries with a large mod list; the picker searches it, nothing else walks it) and never saved.
  • The save names entries only as strings: the act key, resolved through the catalogue. A row whose entry is missing (a DLC drug without its DLC, a removed mod's interaction) stays in the book with its saved label and mod, shows "Needs " or "Missing: " and isn't enforced. It works again when the mod comes back.
  • The lawbook UI reads the stage list from the entry, so an entry 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

  • One static flag per category and per special act, plus per category a HashSet of the watched defs (groups expanded when the set is built: "hard drugs" becomes every ThingDef whose drug category is Hard), are a cache of the current game's lawbook. Groups that depend on the thing rather than its def (a meal with human meat in it) keep a predicate that runs only when the category's flag is on. Flags and sets 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 a hook costs one static field read per call; with the flag on, one set lookup.
  • 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 (Backlog).
  • Player orders: the offender Drafted or its current job playerForced (Verse.AI/Job.cs:37) exempts the act while the setting is on.
  • First-release 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. Break category: 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. Ate category, and every binge dose (it reaches CompDrug.PostIngested through ThingWithComps.PostIngested, Verse/ThingWithComps.cs:767-774, so the old hook D is gone).
    • E. Pawn_InteractionsTracker.TryInteractWith (RimWorld/Pawn_InteractionsTracker.cs:176), about 90 lines, returns true at :268. Interaction category.
    • F. Pawn_InteractionsTracker.StartSocialFight (RimWorld/Pawn_InteractionsTracker.cs:373): a message, two 9-argument TryStartMentalState calls and a tale. Special act StartedSocialFight.
    • I. Verb_Ignite.TryCastShot (RimWorld/Verb_Ignite.cs:12), a protected override reached only through the virtual verb call. Special act SetFire.
    • J. MentalState_CorpseObsession.MentalStateTick (Verse.AI/MentalState_CorpseObsession.cs:18), a virtual override that runs only for obsessed pawns. Special act DisplayedCorpse.
    • U. CompUsable.UsedBy(Pawn p), public virtual, prefix and postfix (RimWorld/CompUsable.cs:161). Used category. It runs from JobDriver_UseItem (RimWorld/JobDriver_UseItem.cs:95-96), from IngestionOutcomeDoer_UseThing (RimWorld/IngestionOutcomeDoer_UseThing.cs:10) and on the patient of a doctor's Recipe_AdministerUsableItem (RimWorld/Recipe_AdministerUsableItem.cs:15, Core's AdministerMechSerumHealer, Defs/ThingDefs_Items/Items_Exotic.xml:102). It returns without any effect when CanBeUsedBy fails (RimWorld/CompUsable.cs:163-166), so the prefix stores CanBeUsedBy(p, false, true).Accepted in __state and the postfix files only when it was true and one of p's own current job targets is the used thing; a patient lying in bed is never the user. Patched on CompUsable and on every subclass that overrides it, found by reflection at startup (in the game code only CompUseableDatacore, which calls base, RimWorld/CompUseableDatacore.cs:30), with a per-call depth guard so an override that calls base files once.
    • H. HistoryEventsManager.RecordEvent(HistoryEvent, bool). Recorded-act category; the offender is the event's HistoryEventArgsNames.Doer (args.TryGetArg<Pawn>), an event without a doer opens nothing. Most of these events are recorded only with Ideology active (see "To verify").
    • R. Pawn_RecordsTracker.Increment(RecordDef) and AddTo(RecordDef, float). Record category; the offender is the tracker's pawn. Time records are not in the catalogue: they count up on their own every 80 ticks (RecordsTickInterval), and if that runs through AddTo, the set lookup drops them. Both methods are short; if the decompiled code shows a body small enough for the JIT to inline (see "To verify"), the record category polls instead: every 250 ticks it compares the watched records of free colonists with the last values, unsaved, and loses only the player-order exemption.
    • B. RecordsUtility.Notify_BillDone(Pawn billDoer, List<Thing> products) (RimWorld/RecordsUtility.cs:52), static, two nested loops, not inlinable. Bill category; the offender is billDoer, the recipe billDoer.CurJob?.RecipeDef (a null files nothing). Toils_Recipe.FinishRecipeAndStartStoringProduct calls it right after bill.Notify_IterationCompleted for every bill type, surgery and Biotech's mech gestators included, always with the pawn that finished the bill (Verse.AI/Toils_Recipe.cs:197-200), and nothing else calls Notify_IterationCompleted. That method itself isn't patched: Bill's version is empty (RimWorld/Bill.cs:278-280) and Bill_Medical calls it as a non-virtual base call the JIT may inline (RimWorld/Bill_Medical.cs:129).
  • Two more hooks serve the jail, not detection (see "Enforcement runs a tick later"): K on Pawn_GuestTracker.CapturedBy and 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. A berserk colonist is hostile to the player faction (MentalState_Berserk.ForceHostileTo(Faction) returns true, Verse.AI/MentalState_Berserk.cs:12-15; RimWorld/GenHostility.cs:128-133), enters the attack target cache when the break starts (Verse.AI/MentalStateHandler.cs:175) and passes IsPotentialThreat (RimWorld/GenHostility.cs:266-308), so it counts as danger for as long as it rages. That is wanted: a Jail row on a berserk offender waits until the break ends or the pawn is downed, and other cases on that map wait as for a raid. Only "Subdue a pawn that fights back" (Enforcement, step 3) leaves its own offender out of the check.
  • 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. For "Release gives back what jail took" the prefix notes the weapon the pawn still holds, before SetGuestStatus drops it (:564; :461), and for "Castes keeps the caste" it sends Castes the blax.laws.jailed hint.
  • Hook L, for the give-back and for Castes, a prefix and postfix on GenGuest.PrisonerRelease (RimWorld/GenGuest.cs:8-21). It returns at once unless the pawn serves a Laws sentence. For "Castes keeps the caste" 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 <suspendable>false</suspendable> (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 (court sessions).
  • 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 category is core: the catalogue lists whatever the loaded game holds, so a DLC's breaks, drugs, interactions, usables and recipes appear when the DLC is active and are absent without it. The starter lawbook uses only Core entries (Defs/MentalStateDefs/MentalStates_Mood.xml: FireStartingSpree :58, Binging_DrugExtreme :91, CorpseObsession :399, Binging_DrugMajor :276; Insult in Defs/InteractionDefs/Interactions_Social.xml:80), and so does the wake-up example (Defs/Drugs/WakeUp.xml:5, chemical :115). The meat groups of the Ate category read the food itself, because vanilla's AteMeat event is Ideology-only and skips processed food (Verse/Thing.cs:2055-2064).
  • Recorded acts are the exception in practice: the category is core, but most history events are recorded only with Ideology active, so without Ideology the category may be nearly empty or never fire. The picker lists the event defs that exist and the category's tooltip says "Most recorded acts need Ideology".
  • A missing entry from a DLC shows "Needs ", read from the source mod saved with the row; from any other mod "Missing: ".
  • 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<DLC>] DefOf fields. DLC code only behind ModsConfig.<DLC>Active; ModLister.Check<DLC> is an install check, not an active check.
  • A choice that needs a DLC shows disabled with "Needs " instead of hiding: the Trial punishment until court sessions exist ("Needs Ideology"), the 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 entry 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; 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 Area, step Needs Without it
Lawbook tab, starter lawbook, case log Lawbook 1 None Works
Act catalogue: breaks, ate, used, interactions, records, bills, special acts Crimes 1 None Works; DLC entries are simply absent
Act catalogue: recorded acts Crimes 1 None (most events: Ideology) Lists the event defs; most never fire
Violent crimes, slaughterer link, drug policy crimes Crimes 1 None Works
Warn, guilty, subdue, jail, subdue then jail Enforcement 1 None Works. Slaves don't exist
Laws for slaves (warn, guilty, subdue) Enforcement 1 Ideology No slaves to cover
Children never beaten Enforcement 1 Biotech No children
Reprimand, banish, execute Enforcement 1 None Works
Slaves' wardens first Enforcement 2 Ideology, Blax Slaves No slaves; without Slaves' feature Laws subdues slaves itself
Subdue a pawn that fights back Enforcement 3 None Works
Release gives back bed, grave; pardon Sentences 1 None Works
Release gives back throne Sentences 1 Royalty Skipped
Release gives back deathrest casket, mech modes Sentences 1 Biotech Skipped
Release gives back the ideoligion role Sentences 1 Ideology Skipped
Hold for role holders, while the give-back is off Sentences 1 Ideology No roles
Hold for mechanitors, while the give-back is off Sentences 1 Biotech No mechanitors
Jail for slaves Sentences 2 Ideology No slaves
Trial through the vanilla trial Court 1 Ideology "Trial" shows disabled with "Needs Ideology" until court sessions make it core
Court sessions, "Jail, then trial", court hour, removal button Court 2 None Works. A throne as court place needs Royalty, a lectern or ritual spot Ideology
Attorneys, multi-day trials, courtrooms Court 3, Court 4 None Works
Elected judge Colony votes 2 None Works
Leader or moral guide as judge Colony votes 2 Ideology Option disabled with "Needs Ideology"; a saved choice falls back to elected
Law votes Colony votes 1 None Works without the precept term
Prison break crime Crimes 2 None Works
Slave rebellion crime Crimes 2 Ideology Row shows "Needs Ideology"

Areas and steps

The specs, grouped by area as in docs/features.md, which gives the order and the reasons for it. An area is one player problem; its steps follow what each part needs built first, never a time box. Features marked New in features.md get their spec here before their step is built.

Lawbook, step 1: the book

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 act picker first (spec below), then adds the row; each other column is a dropdown that offers only what fits the chosen action and stage. Clicking a row's Action opens the picker again. "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 (icon, category and label, with the source mod in the tooltip); Option, only for drug binges (Any, Hard, Social, then every drug's ChemicalDef by label, built from the ThingDefs whose CompProperties_Drug names a chemical); Stage; Severity; Punishment; Days, a 1 to 50 field for Guilty, Jail, Subdue then jail, Trial and Jail then trial and "-" otherwise; On; delete. An overlap icon marks a row that can catch the same act as a row of another category; its tooltip names that row.

    • A new row gets the entry's first stage, Moderate, Warn and On.

    • Punishments per entry and stage:

      Entry Stage Punishments
      A break that isn't hostile to the colony, aggressive ones (tantrums, murderous and sadistic rage, slaughterer) included Planning Warn, Subdue, Jail
      The same, with a linked act Did it Warn, Reprimand, Guilty, Subdue, Jail, Subdue then jail, Banish, Execute, Trial, Jail then trial. Subdue acts only while the offender is still in its break; after it a Subdue row warns and Subdue then jail jails
      A break hostile to the colony (berserk) Planning Warn, Guilty, Jail. Jail waits until the break ends or the pawn is down
      The same, with its Violence link Did it Warn, Reprimand, Guilty, Jail, Banish, Execute, Trial, Jail then trial. Jail waits as above
      Every entry outside the breaks: ate, used, interactions, recorded acts, records, bills, special acts Did it Warn, Reprimand, Guilty, Jail, Banish, Execute, Trial, Jail then trial

      Each punishment shows up once its feature is built: Reprimand, Banish and Execute in the release after the first, Trial with Court step 1, "Jail, then trial" with Court step 2. A berserk state is told apart by its class in the catalogue (MentalState_Berserk, MentalState_BerserkWarcall and their subclasses, plus an XML list for modded classes), and enforcement re-checks ForceHostileTo(Faction.OfPlayer) on the live state, which wins over the catalogue.

    • 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.

  • Act picker: a window like the ingredient filter of a tailoring bill. A search field on top (vanilla QuickSearchWidget, the one the trade and policy dialogs use), below it the categories as a collapsible tree: Mental breaks, Ate, Used, Social interactions, Recorded acts, Records, Bills, Special acts. Each category opens with its groups first ("Any drug binge", "Hard drugs", "Human meat", "Any surgery"), then every entry A to Z with its icon (the thing's icon for ate, used and bills, the interaction symbol, the def's label otherwise) and its source mod in grey. Typing filters every category at once and opens those with hits. An entry already in the book shows a tick; clicking it jumps to that row. One click picks an entry and closes the window. With a large mod list a category holds hundreds of bills; the tree draws only the visible rows.
  • How:
    • MainButtonDef BlaxLaws_Laws with tabWindowClass BlaxLaws.MainTabWindow_Laws. The window is a MainTabWindow with two TabRecords, a scroll view and Widgets.Dropdown per column.
    • Dialog_PickAct : Window draws the picker: a QuickSearchWidget in DoWindowContents, its filter.Matches(label) against each entry's label and defName, the tree in a scroll view that skips rows outside the view rect. It reads ActCatalogue and returns an act key.
    • 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<Name> 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 catalogue 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 plus S for the picker.
  • Tests: A new game has an empty book, no cases and every watch flag false. Adding an "any drug binge" row sets the Break flag and the watched set holds both binge defs; deleting it clears them. Starter lawbook adds 7 rows; pressing it again adds none. Rows keep id, act key, saved label and mod, option, stage, severity, punishment, days and the On flag through phase 2. A row whose act key doesn't resolve (written into the component by the test, once with "Core" and once with "Ideology" as its saved mod) stays, reports "Missing: Core" or "Needs Ideology" 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: any meat" resets it to Warn. A Planning row never offers Reprimand, Banish or Execute; a Berserk row never offers Subdue; a Tantrum row does. The drug option list holds WakeUp and no non-drug chemical. The picker's search for "wake" lists Wake-up under Ate and "make wake-up" under Bills; for "insult" it lists Insult under interactions and the insulting sprees under breaks. "Ate: wake-up" next to "Recorded acts: ingested a drug" shows the overlap icon on both.
  • 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.

Lawbook, step 2: the book across saves and groups

Not specced yet: lawbook templates and "Applies to" (see docs/features.md). "Applies to" needs no field reserved now: a Law saved without it loads as "everyone", and keys that are unique on Action, Option and Stage stay unique with a fourth part.

Crimes, step 1: every act the game records

Act catalogue and detection

  • Players get: Any act in the catalogue can be a law. The categories, what fills them and what opens a case:

    Category Entries Groups A case opens when
    Mental breaks Every MentalStateDef a MentalBreakDef starts, plus the states colonists reach another way (berserk); animal and baby states are left out Any drug binge, any tantrum, any insulting spree, any aggressive break, any break Planning: the break starts. Did it: its linked act happens during the break (link table below)
    Ate Every ThingDef with ingestible: food, meals, raw food, corpses, drugs, modded and DLC ones Any drug, hard drugs, social drugs, medical drugs; any meat (meals with meat included), raw meat or corpses, human meat, insect meat; raw food; any meal The pawn eats it on its own job; a doctor's dose or a warden feeding a patient doesn't count
    Used Every ThingDef with a CompUsable: psytrainers, neurotrainers, mech serums, modded usables None UsedBy runs for the pawn
    Social interactions Every InteractionDef: insult, slight, chitchat, romance attempts, breakups, jailbreak talk, modded ones Insult or slight The pawn starts it and it happens (TryInteractWith returns true); the offender is the initiator
    Recorded acts Every HistoryEventDef except the faction-level ones (goodwill, trade, quests, raids; an exclusion list in XML): cut a tree, butchered a human, harvested an organ, executed a prisoner, ate human meat, got lovin' outside marriage None The game records the event with the pawn as its doer. Most need Ideology
    Records Every RecordDef that counts (Int or Float; time records left out): kills, humanlike kills, animals slaughtered, bodies stripped, things deconstructed, things hauled None The pawn's record goes up
    Bills Every RecipeDef: made a human leather duster, cooked a fine meal, installed a bionic arm, butchered a corpse Any surgery The pawn finishes one iteration of the bill
    Special acts Set a fire, displayed a corpse, started a social fight; assault, harmed a prisoner or slave, manslaughter, murder (Violence); the slaughterer's kill; prison break and slave rebellion (uprisings) None Their own hooks, below
  • Link table: a break's "Did it" stage exists only when a BreakLinkDef names its act. Links go by mental state class, subclasses included, so a modded break that reuses a vanilla class has its "Did it" too:

    Mental state class Breaks in Core Did it
    MentalState_BingingDrug Binging_DrugExtreme, Binging_DrugMajor Ate a drug that matches the row's option (default: any drug)
    MentalState_Binging, not the drug binge Binging_Food Ate anything
    MentalState_FireStartingSpree FireStartingSpree Set a fire
    MentalState_CorpseObsession CorpseObsession Displayed a corpse
    MentalState_InsultingSpree InsultingSpree, TargetedInsultingSpree Insult or slight
    MentalState_Jailbreaker Jailbreaker The jailbreak talk (SparkJailbreak interaction)

    Tantrums, berserk, murderous and sadistic rage get their links with "Violence", slaughterers with "Slaughterers", both in the release after the first. Every other break, desertion (GiveUpExit) included, is Planning only.

  • How:

    • Catalogue build. Each ActCategoryWorker walks its DefDatabase once after def loading: breaks from DefDatabase<MentalBreakDef> (mentalState), plus an include list in XML (Berserk) and an exclude list (animal and baby states: Manhunter, ManhunterPermanent, Roaming, BabyCry, BabyGiggle and their kin, to be read from the defs); ate from ThingDefs with IsIngestible; used from ThingDefs whose comps include a CompProperties_Usable; interactions from DefDatabase<InteractionDef>; recorded acts from DefDatabase<HistoryEventDef> minus the exclusion list; records from DefDatabase<RecordDef> with type Int or Float; bills from DefDatabase<RecipeDef>. Groups are predicates over defs, written once in code: drug groups by ingestible.drugCategory (None, Medical, Social, Hard), meat groups as below, "raw food" by ingestible.preferability, "any meal" by IsProcessedFood, "any surgery" by RecipeDef.IsSurgery, "any aggressive break" by MentalStateDef.IsAggro.
    • Most specific row: per category, a row on the exact def beats a group row beats the category's "any". Two groups that both match ("hard drugs" and "any drug") rank by size: the smaller group wins.
    • 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 C when ingester.MentalState is MentalState_BingingDrug and the drug's CompProperties_Drug 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 break's crime; an "Ate" row may still catch it.
      • 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.
    • Interactions. Hook E: __result true and intDef in the watched set (Insult, Slight, any other). Offender ___pawn (the initiator), victim the recipient. Insults in a spree also come through here (RimWorld/JobDriver_Insult.cs:34) and are the insulting spree's did-it. Planning for sprees: hook A on InsultingSpree or TargetedInsultingSpree. The jailbreaker's talk is the SparkJailbreak interaction (InteractionDefOf.SparkJailbreak), the did-it of MentalState_Jailbreaker.
    • Ate. Hook C. The prefix reads the eaten def, 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. Meat groups: "any meat" from the food kind (meals with meat included), "raw meat or corpses" from IsMeat or IsCorpse on unprocessed food, "human meat" from that last call, "insect meat" from the meat's source race. It counts only when the ingester eats on its own: one of the targets (A, B or C) of its own current job is the eaten thing. That covers the Ingest job (RimWorld/JobDriver_Ingest.cs:115) and a drink at a gathering spot, which JobDriver_SocialRelax ingests at target C under its own job def (RimWorld/JobDriver_SocialRelax.cs:75), the most common way colonists take beer and smokeleaf. A doctor's dose (RimWorld/Recipe_AdministerIngestible.cs:11, inside the doctor's bill), a warden or parent feeding someone (RimWorld/JobDriver_FoodFeedPatient.cs:78, RimWorld/JobDriver_Feed.cs:47) and a baby fed by others (RimWorld/JobDriver_BottleFeedBaby.cs:86, 103) run on the feeder's job, so the eater's own job never targets the food and they are skipped. Caravans feed off the map (RimWorld.Planet/Caravan_NeedsTracker.cs:182, 209, 245), which the offender filter drops.
    • Used. Hook U, the used thing's def against the watched set. A psytrainer, neurotrainer or serum (Royalty, Biotech or Core) files on the pawn that used it on its own job; a patient a doctor gives a healer mech serum files nothing.
    • Recorded acts. Hook H: the event def against the watched set, then args.TryGetArg<Pawn>(HistoryEventArgsNames.Doer, ...); an event without a doer pawn files nothing. RecordEvent also runs for events the player orders (an execution), so the player-order exemption reads the doer's job like every other hook.
    • Records. Hook R: the record def against the watched set; the offender is the tracker's pawn. A record goes up for many reasons ("things hauled" every haul), and the cooldown keeps one case a day per pawn and row.
    • Bills. Hook B: the recipe of the doer's current job against the watched set, the doer as offender. Bills are standing player orders but not forced jobs, so the exemption doesn't cover them: a row on "make yayo" files on the cook who made it, which is the row's point.
    • Each category worker opens a case or moves an open break case to did it, increments the count, and queues the punishment of the most specific enabled matching row (see "Defaults I picked") once per stage. An act that is the linked did-it of an open break case goes to that case and opens no other case; when it also matches a row of its own, the row with the higher severity decides, the break's row on a tie (see "Defaults I picked").
    • The cooldown setting applies to every act outside a break. 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 and the catalogue 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; Laws' "Talk down" (Enforcement, step 1, New) covers that for colonists on 1.7.

  • Replaces: Law and Order's crimes are new events and breaks; Laws replaces the idea with vanilla's own acts.

  • Effort: M for the categories, groups and links, S for hooks U, H, R and B, S for the catalogue tests.

  • 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.
    • Ate: raw meat, a simple meal with meat and human meat against the meat groups; a row on the Simple meal def catches the simple meal and not the raw meat; a drafted pawn eating opens nothing; a doctor administering a drug to a patient opens nothing for either pawn; a beer drunk on social relax files under "Ate: beer"; 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.
    • Catalogue: every MentalBreakDef's state, every ingestible ThingDef, every InteractionDef, every Int or Float RecordDef and every RecipeDef of the loaded game has an entry; no Time record and no excluded state has one. The test mod's own defs (a test drug ThingDef, a test InteractionDef, a test RecipeDef, a test mental state reusing MentalState_FireStartingSpree) appear with the test mod as source, and the test break offers Did it through the link. In a -NoDlc run no DLC entry appears and the starter lawbook still adds 7 rows.
    • Used: a colonist using a healer mech serum on its own job files on it; a doctor-administered healer serum files nothing for either pawn; a UsedBy call that CanBeUsedBy refuses files nothing. Interactions: a forced Chitchat with a Chitchat row files on the initiator. Records: pawn.records.Increment(RecordDefOf.BodiesStripped) with a row files one case, a second increment the same day raises the count. Recorded acts: an ExecutedPrisoner event with a doer files on the doer, the same event without a doer files nothing (skipped without Ideology if vanilla records it only there). Bills: a finished "make simple meal" iteration files on the cook; a surgery files on the doctor; a mech gestator bill files on the mechanitor who finishes it (skipped: needs Biotech).
    • Jailbreaker: a forced Jailbreaker break opens planning, the SparkJailbreak interaction moves it to did it. A Berserk row offers Warn, Guilty and Jail; a Tantrum or MurderousRage row also offers Subdue.
    • Cost: 100000 calls each of TryInteractWith, Increment and RecordEvent with an empty book run within 2% of the same calls with the patches unapplied (test switch).
  • Risks: Double counting across categories (a dose is an Ate act, a recorded act and maybe a record) is accepted and shown by the overlap icon; inside a break the break case owns the act. Slights are frequent between rivals (weight 0.02, RimWorld/InteractionWorker_Slight.cs:15); the cooldown keeps the log readable. A modded break with its own state class is in the catalogue with Planning only until someone adds a BreakLinkDef. A mod that records acts without Increment, RecordEvent or TryInteractWith is invisible to Laws. The catalogue labels come from the defs; a modded def without a label shows its defName.

Violence

  • Players get: Four special acts: assault (hurt a free colonist, a guest or another pawn that isn't hostile, outside a social fight), harming a prisoner or slave of the colony, manslaughter and murder. A hit that kills is murder. When the victim of an assault or harm case dies of its wounds within 2 days, by bleeding out, an infection or any other death without an attacker, that case becomes manslaughter. The violent breaks are in the catalogue with Planning, and Violence gives them Did it: a tantrum damaged or destroyed something, a berserk pawn or a murderous or sadistic rage hurt someone (murderous rage names its target from the start). A berserk case takes Warn, Guilty or Jail; tantrums and the rages take every break punishment, Subdue included (see "Defaults I picked").
  • How:
    • Links: the breaks are catalogue entries already (Tantrum, TargetedTantrum, BedroomTantrum, SadisticRage, MurderousRage; MentalStates_Mood.xml:318, 352, 368, 381, 191); Violence adds BreakLinkDefs for MentalState_Tantrum, MentalState_Berserk and MentalState_MurderousRage (MentalState_SadisticRageTantrum is a tantrum subclass and links to harming a prisoner or slave).
    • Hits: 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. The offender is dinfo.Instigator. During an open break case any damage the offender deals, to a pawn or a wall, is that break's did-it. Outside a break the victim's status picks the act: a prisoner of the colony or a colony slave is "harmed a prisoner or slave", any other humanlike pawn that isn't hostile is assault.
    • Excluded: drafted instigators; damage with instigatorGuilty false (executions; Laws' own subdue, which also sets a scope flag); victims in a state hostile to the colony (a colonist hitting back at a berserker); hits while both pawns are in a social fight (that is "started a social fight"); surgery (no instigator); friendly fire. A hit counts as friendly fire only when dinfo.IntendedTarget is set and isn't the victim (Verse/DamageInfo.cs:94): vanilla melee builds its DamageInfo with no intended target (RimWorld/Verb_MeleeAttackDamage.cs:50-51), only bullets (RimWorld/Bullet.cs:23) and explosions (Verse/DamageWorker.cs:316) set one, so "intended target not the victim" alone would drop every punch, every blade, every berserk and every tantrum hit. Vanilla already marks undrafted attackers of player pawns guilty for a day (Verse/Pawn_HealthTracker.cs:321-329).
    • Deaths: a prefix and postfix on Pawn.Kill (Verse/Pawn.cs:2096). With an instigator in dinfo that passes the filter above, the death is murder, and the killing hit files no assault besides. Most deaths after an attack carry no instigator: bleeding out or an infection reaches Kill through Notify_HediffChanged, which runs CheckForStateChange(null, hediff) (Verse/Pawn_HealthTracker.cs:290-294, the Kill at :515), and a disease's death roll calls Kill(null, this) (Verse/Hediff.cs:512). For such a death Laws looks for an assault or harm case of the last 2 days, open or closed, with this pawn as victim, and moves it to manslaughter like a later stage (see "One enforcement per case"). The link lives in the saved case, so it survives a load.
  • 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, plus S for the links.
  • Tests: An undrafted colonist's punch on another colonist files assault, on a prisoner of the colony harming a prisoner. A forced berserk's melee hit on a colonist moves the berserk case to did it; a forced tantrum hitting a wall moves the tantrum case to did it. A shot that kills files murder and no assault. A stabbed colonist that bleeds out turns its assault case into manslaughter, also after a save and load in between. A murder during a murderous rage with "Murderous rage, did it: warn, Moderate" and "Murder: jail 10 days, Grave" gives one case and 10 days. An undrafted colonist's shot at a raider that hits a colonist opens nothing. A drafted shot, subdue damage and a social fight open nothing.

Slaughterers

  • Players get: Did it for the slaughterer break: it slaughtered an animal.
  • How: A BreakLinkDef for MentalState_Slaughterer on a new special act, fed by a postfix on the private ExecutionUtility.ExecutionInt (RimWorld/ExecutionUtility.cs:20).
  • Save and removal: Cases only.
  • Overlaps: None.
  • Replaces: Nothing.
  • Effort: S.
  • Tests: A forced slaughterer break moves to did it when the pawn slaughters an animal.

Drugs against the policy

  • Players get: a group entry "Drug the policy doesn't allow" in the Ate category, outside binges and player orders.
  • How: Hook C 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.

Crimes, step 2: uprisings

Needs "Pardon, early release and longer sentences" for "Add days" on a convict, and Fabian's answer on "Jail for slaves" for rebel slaves.

Prison breaks and slave rebellions

  • Players get: Two acts: prison break by Laws' own convicts and slave rebellion (Ideology). A convict who breaks out gets Warn, "Add days" on its sentence or a confirmed execution (see "Banish and execute"). Other escapees, captured raiders and enemy prisoners included, stay with the prison mods: punishing them is sentencing enemy prisoners, which Prisoner Sentencing and Prison Expanded cover.
  • How: Postfixes on PrisonBreakUtility.StartPrisonBreak (RimWorld/PrisonBreakUtility.cs:214, whose out list names the escapees) and SlaveRebellionUtility.StartSlaveRebellion (RimWorld/SlaveRebellionUtility.cs:403). For the prison break act only, the offender filter gains prisoners of the colony that serve a Laws sentence or sit in Laws' custody ("Jail, then trial"); colony slaves are offenders already.
  • Save and removal: Cases only.
  • Overlaps: Blax Slaves owns rebellion; the rebellion act only records who rebelled.
  • Replaces: Law and Order's sabotage crime, partly.
  • Effort: S plus S.
  • Tests: One case per act; a captured raider in the same break opens nothing; a convict's prison break row offers Warn, Add days and Execute only; the slave rebellion test skips without Ideology.

Crimes, step 3: crimes against the faith

Not specced yet: "anything the colony's ideoligion forbids" and "left the colony's ideoligion" (see docs/features.md). Both run on hook H, so no new hook is needed. The group reads every precept comp whose eventDef is the recorded event and that gives the doer or those who learn of it a bad thought (PreceptComp_SelfTookMemoryThought, RimWorld/PreceptComp_SelfTookMemoryThought.cs:8, 16; PreceptComp_KnowsMemoryThought) or is a PreceptComp_UnwillingToDo. UnwillingToDo alone would miss meat, cannibalism and organ use, which have none (Ideology/Defs/PreceptDefs/Precepts_MeatEating.xml:25-45), and where it exists vanilla already stops the pawn's own job (RimWorld/IdeoUtility.cs:109-116). Leaving the ideoligion is the ChangedIdeo event, recorded while the old ideoligion is still set (RimWorld/Pawn_IdeoTracker.cs:189-192). Needs Ideology.

Enforcement and punishments, step 1

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 ActCategoryWorker, ActWorker 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.
  • 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.
    • A forced berserk with a Jail row: nobody is sent while it rages; once the break ends, or the test downs the pawn, it is arrested or captured. A raid still blocks every case as before.

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; ending guilt by hand is "Pardon, early release and longer sentences".
  • 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); the 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 any break that isn't hostile to the arrester (Verse.AI/GenAI.cs:73-103, the check at :83).
    • Aggressive breaks that aren't hostile (tantrums, murderous and sadistic rage, slaughterer) can be subdued: their state targets things, a named victim, prisoners or animals, never the enforcer, and the direct TakeDamage gives them no melee threat to answer. The enforcer pick skips the victim a murderous rage names (MentalState_MurderousRage.target).
    • "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' "Wardens calm breakdowns" calms 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.
  • 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.
    • A forced tantrum and a forced murderous rage with subdue rows: both go down, the enforcer is never attacked and never the rage's named victim.
  • 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 plain subdue. A berserk pawn does strike back, with its weapon; that is why only the player can start a subdue on it ("Subdue a pawn that fights back").

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.

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.

Not specced yet: talk down and decide myself (see docs/features.md). Talk down ends a break through MentalState.RecoverFromState, which gives the break's catharsis (Verse.AI/MentalState.cs:92-95), so the spec decides whether "Subdued pawns lose their catharsis" covers it. Decide myself reuses the waiting case and "Arrest now".

Enforcement and punishments, step 2: with the sibling mods

Slaves' wardens first

  • Players get: With Blax Slaves' "Wardens calm breakdowns" on, a slave in a break those wardens take is left to them: Laws files the case but sends no subdue and no talk down. Its did-it rows still apply.
  • How: SlavesApi.CalmsBreaks, bound by reflection at startup like the Castes calls (see "Works with the other Blax mods"), read before a subdue or a talk down of a slave. Laws stands down only for the breaks Slaves' wardens take: a state that isn't IsAggro (MentalStateDef.IsAggro, Verse/MentalStateDef.cs:108) and isn't the slave rebellion. A tantrum, a murderous or sadistic rage or a slaughterer is IsAggro (Core MentalStateDefs/MentalStates_Mood.xml:157, 195, 322), so the wardens skip it and Laws' subdue still applies. Without Slaves or with the flag false, Laws subdues slaves as before.
  • Save and removal: Nothing saved.
  • Overlaps: Blax Slaves owns calming slaves.
  • Effort: S.
  • Tests: With Slaves in -Compat and the flag on, a slave's binge planning case with a subdue row sends nobody; with the flag off, a subdue. Skipped without Ideology or Slaves.

Enforcement and punishments, step 3: subdue a pawn that fights back

Subdue a pawn that fights back

New: the outline below; the full spec comes before the step is built.

  • Players get: For a break hostile to the colony (berserk), a "Subdue with " button on the case and an alert while it waits. The case names the best candidate by Melee, the weapon it holds against the offender's, and health; pressing the button sends that pawn on the subdue job. Laws never sends anyone at a berserk pawn on its own: it hits back with its weapon at full damage while the subdue job deals capped bruises, so a Melee comparison alone would get enforcers killed in a permadeath colony.
  • How: The button starts the subdue job like a player order. For this one case the danger rule leaves the offender out: Laws walks map.attackTargetsCache.TargetsHostileToFaction(Faction.OfPlayer) through GenHostility.IsActiveThreatTo (RimWorld/GenHostility.cs:238-258 does the same loop) and skips the offender, and skips EnemiesAreNearby(offender). Any other threat still blocks. No letter: Laws adds no Letter class.
  • Save and removal: Nothing new; the case records the subdue as before.
  • Overlaps: None.
  • Replaces: Drafting a fighter by hand against your own berserk colonist.
  • Effort: S.
  • Tests: A forced berserk with a subdue choice: nobody is sent until the button is pressed; after it, the named pawn subdues it; a raid on the map still blocks the button's job.

Sentences, step 1: serve and come back

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' default prisoner interaction 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. In the first release, and later while "Release gives back what jail took" is switched off, Laws doesn't arrest those on its own: the case waits with "Arrest now" and a letter. Guilt is set at filing anyway and renewed when "Arrest now" starts the job.
    • Slaves: without "Jail for slaves" Laws 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 that feature'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, 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' 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; once Castes ships its read-only API, 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); without "Release gives back what jail took" the pawn picks a free bed again; with it the old one comes 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.

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 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 "Jail for N days"), 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.<DLC>Active.
  • Save and removal: Snapshot fields in the case: references and def names. Removal drops them; the pawn stays a prisoner, as "Jail for N days" says.
  • Overlaps: Arrest and Release (2593514063, 4.6k, no 1.7) warns that arrest strips Ideology roles; Laws gives them back.
  • Replaces: Nothing.
  • Effort: M.
  • 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.

Sentences, step 2: with the sibling mods

Each part waits for its sibling or for Fabian's answer. Confinement for N days is New in docs/features.md, not specced; it needs a timed caste assignment from Castes. Indenture as a sentence is an idea there.

Castes keeps the caste

  • Players get: With Blax Castes' join API (API version 2), 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, or right before a jailed slave is made a slave again ("Jail for slaves") (API version 2, Castes' join API). Castes reads a hint in its SetGuestStatus hook, inside those calls, and drops it at the end of the tick. With the hint, Castes' 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' prisoner caste set to Enslave, a hinted pawn's mode is MaintainOnly two ticks after the capture.

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, with Castes' blax.laws.released hint right before it, since hook L's release prefix doesn't run on this path ("Castes keeps the caste"). 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.
    • Indentured slaves: before the arrest Laws reads SlavesApi.TermDaysLeft. In Blax Slaves' plan an arrest ends an indentured term like any imprisonment (its open question 1), so the re-enslave at the end would leave an indentured servant a slave for life. While a term runs, Laws doesn't jail: the row falls back to subdue while the slave is in its break, else to warn, as for slaves without this feature, until Slaves offers a hint that keeps the term through a Laws sentence (Slaves' open question 3, planned with its indentured servitude). With that member bound, Laws calls it from hook K's prefix, right before the capture, and jails as for any slave.
  • 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. With Slaves in -Compat once it ships indentured servitude, an indentured slave with a jail row is subdued or warned, never jailed. 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, together with the term hint.

Repeat offenders

Not specced yet: the criminal record and probation (step 1), escalation (step 2) (see docs/features.md). Step 1 needs the first release's cases, probation also "Pardon, early release and longer sentences". The record keeps convictions after "Keep closed cases" prunes them (7 to 360 days), so the court's repeat term reads the record, never closed cases.

Court, step 1: Ideology's trial as a punishment

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 court sessions make 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.
  • 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.

Court, step 2: court sessions on the core game

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 (see "Trial through Ideology's ritual").
  • 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.
  • Acting judge: when the judge is the accused, the victim, or family of either (pawn.relations.FamilyByBlood plus spouse and lover), or is dead, jailed, away from the map or gone, the session uses the best uninvolved candidate: a free adult colonist who isn't involved, by Social. The convene dialog names the acting judge and why. "Court on its own" skips a case that has no uninvolved candidate, and the Cases tab says why. The same rule serves elected judges (Colony votes, step 2) and appeals (Court, step 4).
  • 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. A case whose appointed judge is the accused's spouse convenes with an acting judge, and the dialog names the reason.

Jail, then trial

  • Players get: A punishment for did-it rows: the offender is arrested at once, as for Jail, waits in custody on Maintain only and goes to court. A conviction gives the row's days minus the days already served in custody; an acquittal releases it and closes the case. A plain Trial row arrests nobody, so a binger who already took some would keep bingeing until the court sits; this is the row for Fabian's "jail and maybe court". With Ideology, the leader's Accuse ability can also try a case in custody.
  • How: The arrest is Jail's (see "Jail for N days"): guilt right before the Arrest or Capture job makes it certain (Verse/Pawn.cs:4085-4089; a downed free colonist can only be captured while guilty, Verse.AI/GenAI.cs:59-66), and without it the arrester's ArrestSuccessChance decides and a refusal is berserk (Verse/Pawn.cs:4099, 4132-4135). Hook K's postfix clears that guilt at the capture with Notify_Guilty(0) (RimWorld/Pawn_GuiltTracker.cs:46-49): custody is no conviction, and a guilty pawn can't be accused in the vanilla trial (RimWorld/CompAbilityEffect_StartTrial.cs:44-47). Maintain only two ticks after the capture, as for Jail. A conviction turns the custody into a sentence: release tick = capture tick plus the row's days, with the verdict's guilt. An acquittal sets Release at once. An escape closes the case as escaped, by Jail's early-end rule. Court days (Court, step 4) keep the accused in this custody between the days.
  • Save and removal: The custody lives in the case like a sentence. After removal the pawn stays a vanilla prisoner of the colony.
  • Overlaps: None.
  • Replaces: Nothing.
  • Effort: S.
  • Tests: A did-it binge case with "Jail, then trial, 5 days": the binger is a prisoner within 2500 ticks against a Social 0 arrester, is not guilty after the capture, and its case waits for court. Convicted after 2 days in custody, it is released 3 days later; acquitted, it is released at once. With Ideology the leader can accuse it (skipped without Ideology).

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_ConveneCourt : Window of our own, with its header, the place picker, the factor list with the chance and the button row, laid out like vanilla's ritual window. It reuses only PawnRoleSelectionWidgetBase<CourtRole> (RimWorld/PawnRoleSelectionWidgetBase.cs:13) for the role slots; its constructor has no DLC check (:101). Dialog_BeginLordJob isn't used: its constructor sets the participants drawer, closeOnClickedOutside, absorbInputAroundWindow and forcePause only inside if (ModLister.CheckAnyExpansion("Ritual")) (RimWorld/Dialog_BeginLordJob.cs:134-143). That check asks which DLCs are installed, not which are active (Verse/ModLister.cs:283-286, 426-428), and logs an error when none is (:347-353), so a player who owns no DLC would get a logged error and a court dialog without its role column. 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 and no ModLister.Check* error is logged when it opens; the factor list sums to the chance shown. A -NoDlc run only deactivates DLCs that stay installed, so it can't trigger the install check itself; the test also asserts that Dialog_ConveneCourt doesn't derive from Dialog_BeginLordJob.

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 judge (or the acting judge, see "Cases go to trial") 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. A case with no uninvolved judge waits, and the Cases tab says why. 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. 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 for the judge and the speakers, which walks to the cell and stands there with JobGiver_Idle (Core Defs/DutyDefs/Duties_Rituals.xml:5-22), DeliverPawnToCell for a jailed accused (:55) and Spectate for the crowd (Core Defs/DutyDefs/Duties_Gatherings.xml:55). Core's GiveSpeech duty (:139) isn't used: its only job giver, JobGiver_GiveSpeech, returns no job unless the duty's focus is a Building_Throne assigned to the speaker (RimWorld/JobGiver_GiveSpeech.cs:19-22), so at a party spot or a table the judge and the attorneys would reach their cell, get no job and walk off to work. The lord toil's tick plays the speech bubbles through MoteMaker.MakeInteractionBubble (RimWorld/MoteMaker.cs:181), not TryInteractWith, which writes a play log entry holding the InteractionDef (RimWorld/Pawn_InteractionsTracker.cs:249), and the speech sound. Laws adds no DutyDef: a duty is saved in mindState.duty while a session runs, so an own one would be one more def for the removal button to clear. One gathering at a time, as vanilla allows.
  • Save and removal: A running session is a vanilla lord with our LordJob class and vanilla duties; 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 at a party spot, with the judge and both speakers at their cells for the whole session; 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, read from the criminal record (Repeat offenders, step 1), never from closed cases, which "Keep closed cases" may prune after 7 days. 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 (see "Defence and prosecution") the accused speaks for itself. Opinion comes from OpinionOf (RimWorld/Pawn_RelationsTracker.cs:592). Thoughts are situational, as for Reprimand.
  • 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.

Court, step 3: the people of a trial

Not specced yet: witnesses and the guilty plea (see docs/features.md).

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.
  • Tests: A Social 12 attorney lowers P by the formula; a refusing pawn below opinion 10 isn't proposed; XP lands on both speakers.

Court, step 4: long trials

Not specced yet: appeals (see docs/features.md).

Court days

  • Players get: Serious and grave cases take 2 or 3 court days, one session a day at the court hour (see "Court on its own"), 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. An accused in custody ("Jail, then trial") stays there until the verdict; a free accused comes to each court day.
  • 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 is the one from "Jail, then trial": guilt only for the arrest, cleared at the capture. Custody without guilt would turn accused colonists berserk at the arrest (Verse/Pawn.cs:4085-4089, 4132-4135).
  • Save and removal: Day results in the case.
  • Overlaps: None.
  • Replaces: Nothing.
  • Effort: M for days and the tally, S for absences.
  • 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 verdict given in an impressive room costs the convict less mood: when the room around the court place reaches the courtroom impressiveness (setting), the convict gets the milder thought. The room keeps its own role, dining room, rec room or throne room.
  • How: At the verdict, room.GetStat(RoomStatDefOf.Impressiveness) (Verse/Room.cs:823) of the room that holds the court place. No RoomRoleDef: a room has exactly one role, the highest score of all role workers (Verse/Room.cs:872). A courtroom role that scores higher would take over the dining room, the rec room or the throne room, which scores 10000 (RimWorld/RoomRoleWorker_ThroneRoom.cs:17-30) and which a noble's throne room requirement needs (Royalty); one that scores lower would never show.
  • Settings: "Courtroom impressiveness".
  • Save and removal: Nothing saved and no def to remove.
  • Overlaps: RimCourt's seat spot is a different building.
  • Replaces: Nothing.
  • Effort: S, plus S tests.
  • Tests: A verdict at a place in a room above the setting gives the milder thought, below it the normal one; a throne room used as court place keeps its throne room role.

Colony votes, step 1: the voting core and law votes

Needs the first release only: law votes count acts through the first release's hooks in tally-only mode and use nothing from the court.

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.

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 voting core plus the score terms. An act without a law is invisible to the hooks (its flag is false and the hook returns at once), so while votes are on every category's flag is set in tally-only mode: the hooks count acts per catalogue entry in an unsaved tally and open no case, and a proposal rolls from that tally. Records stay out of the tally ("things hauled" would only produce noise); they come up through petitions and "Call a vote". The violent crimes 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 ActStanceDef XML keyed by act key (traits, bystander thought, history events with MayRequire="Ludeon.RimWorld.Ideology"), written for the common entries; an entry without one gets stances only from opinion and mood. 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.
  • 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.

Not specced yet: pardon petitions (see docs/features.md). They need the voting core and "Pardon, early release and longer sentences", nothing from the court.

Colony votes, step 2: the judge's office

Needs court sessions (Court, step 2), whose acting-judge rule the elected judge uses.

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 involved in a case hands it to an acting judge by the rule in "Cases go to trial"; a by-election fills a vacancy, and the acting judge sits until it is decided.
  • 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.

Colony votes, step 3: the jury

Not specced yet: the jury (see docs/features.md). Needs court sessions and the voting core.

Headless tests

First release

  • 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(actKey, option, stage, severity, punishment, days). The test mod ships its own defs for the catalogue tests: a drug ThingDef, an InteractionDef, a RecipeDef and a MentalStateDef plus MentalBreakDef that reuse MentalState_FireStartingSpree.
  • 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. The catalogue tests run there too: the compat mods' defs must appear under their mod names.
  • Performance: 60 colonists and the starter lawbook, 2500 ticks with and without Laws, median of three runs: Laws adds under 2%. The same with a "Records: things hauled" row and an "Ate: any meal" row, the two busiest hooks.
  • Phase 2: phase 3 still expects exactly 2 errors. All 8 DLC combinations.
  • 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).

The release after the first

  • Combat: with Violence, a combat run with 20 colonists against raiders: TakeDamage adds under 1% with the violence laws off. Effort S.
  • Phase 2: also covers the give-back snapshots of "Release gives back what jail took"; phase 3 still expects exactly 2 errors. All 8 DLC combinations.

Court, step 1

  • Phase 2 covers waiting trials; phase 3 still expects exactly 2 errors. All 8 DLC combinations. Effort S.

Court, step 2

  • The suite runs in all 8 DLC combinations; the place picker's throne and ritual spot entries skip without their DLC. Effort S.

Crimes, step 2

  • All 8 DLC combinations; the slave rebellion test skips without Ideology. The new acts join the tally-only mode of law votes, checked with one forced act 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 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, the same list in all five Blax design docs; a part that waits on Fabian's answer names the open question:
    • Castes: every per-pawn policy default of colonists, slaves and prisoners (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), and the planned ones: the cold-weather apparel policy, the Combat Extended loadout, the Royalty and Biotech switches (room and apparel requirements, psyfocus target, entropy limit, hemogen pack use, deathrest auto-wake), the slave interaction mode a new slave starts on (Castes' open question 2) and per-caste values other Blax mods register, which those mods apply (Castes' open question 1).
    • Zones: sleeping spots, beds by zone, every friendly drop location and per-cell work rules (work rule areas), with path rules on those areas (Zones' open question 3); 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, Laws' open question 1), the slave interaction modes (vanilla's plus Recruit and Convert), trade, prices, suppression, rebellion, slave medicine and the slave economy. Slaves routes its silver payouts through ZonesApi.TryFindDropSpot, with DropCellFinder.TradeDropSpot as fallback. Pawns are never routed into zones.
    • Defaults: starting settings of vanilla stockpiles and growing zones, storage buildings, production bills, workbenches, buildings, animals and mechs, the named areas a new map starts with, 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, trials, judges, attorneys and law votes. It acts through vanilla arrest, capture, release and guilt plus its own non-lethal subdue job, and talks colonists and slaves out of a break, except slaves while Slaves' wardens calm breaks. 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 gives back what the sentence took: bed, grave, throne, deathrest casket, ideoligion role, mech work modes and the weapon the arrest dropped. It puts a slave it jailed back into slavery (Laws' open question 1). 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 sentence, the fallback day included, inside that window; "Add days" stops at 50 days in total until the API version 2 hint keeps the record. Castes' planned CapturedBy scope never moves an arrest to the captured row: a pawn of the player's faction gets its "arrested" reason, which keeps the new-prisoner row (Castes docs/features.md, area 2, step 1). Laws' hint ("Castes keeps the caste") adds only the former-caste record that outlives formerCasteDays.
  • The one write into Castes' area: the Maintain only and Release modes for pawns Laws jailed, in every version of both mods. With Castes' join API (API version 2), Laws' "Castes keeps the caste" sends blax.laws.jailed from hook K and blax.laws.released from hook L through HintJoinReason; Castes' 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.
  • "Confinement for N days" (Sentences, step 2, New) would ask Castes to put a convict into a caste the player picks for sentences and back through blax.laws.released. That needs a timed caste assignment in Castes' join API (docs/features.md, open question 2). Castes plans it as "Sentence caste for Blax Laws" (its area 5, step 5), only on Fabian's yes, and its spec decides whether a third Laws reason sent through NotifyJoined is enough.
  • Castes' read-only API (version 1) lists Laws' caste checks as waiting on it: that is "Applies to" (Lawbook, step 2), which reads CastesApi.CasteIdOf.

Blax Slaves

  • Slaves are offenders like colonists, with warn, guilty and subdue from the first release. Rebellion stays Slaves'; the slave rebellion act (Crimes, step 2) only records it.
  • Slaves' "Wardens calm breakdowns" calms slaves out of breaks that aren't IsAggro and aren't the rebellion. While SlavesApi.CalmsBreaks says that feature is on, Laws neither subdues nor talks down a slave in such a break and lets Slaves' wardens talk it down ("Slaves' wardens first").
  • "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. It never jails a slave while SlavesApi.TermDaysLeft says an indentured term runs, since Slaves ends the term at an arrest, until Slaves offers a hint that keeps the term through a Laws sentence (Slaves' open question 3).
  • 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' people sleeping zones for prisoners are made of real beds, so arrests find them with no Laws code.
  • A court place and a courtroom 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; "Release gives back what jail took" 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 "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

Status on 2026-12-01, when the five plans were checked against each other: every entry below is done on the siblings' plan/features branches, except the READMEs and the Workshop "More Blax Gaming mods" lines, which wait until Laws is on the Workshop.

  • 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). Castes' default prisoner interaction skips pawns with the blax.laws.jailed hint. Done in Castes' "Blax Laws" section instead of the table, and Castes' prisoner mode now skips every arrested colonist and imprisoned slave, hinted or not.
  • Slaves docs/roadmap.md: SlavesApi gains a bool CalmsBreaks with "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 the Laws release that brings the give-back the weapon an arrest drops is allowed again at the release.
  • Slaves docs/roadmap.md and docs/features.md (its open question 3): an indentured term keeps running through a Laws sentence when Laws hints the arrest (a SlavesApi call naming the pawn from hook K's prefix, right before the capture, shipping with Slaves' indentured servitude); until that exists, Laws doesn't jail indentured slaves. Asked together with Laws' open question 1.
  • Castes docs/features.md, only if Fabian says yes to confinement (Laws' open question 2): area 5, step 5, "Sentence caste for Blax Laws", ended by blax.laws.released.

To verify against the decompiled code

The act catalogue was checked on 2026-12-01 against the 1.7.5021 reference assemblies (RimRef, Krafs.Rimworld.Ref 1.7.5021-unstable): every type, field and signature it names exists there (a probe that calls each of them compiles against RimRef with no error), method bodies don't. Before the first release is built, check these in the decompiled 1.7 code and fix the design where it differs:

  • Pawn_RecordsTracker.Increment and AddTo: body size (inlining risk, else the record category polls), whether time records go through AddTo.
  • HistoryEventsManager.RecordEvent: which events Core records without Ideology, which carry HistoryEventArgsNames.Doer, and the list of faction-level events to exclude.
  • The self-eating check in hook C: that the eaten thing is still one of the ingester's own job targets when Toils_Ingest finalizes, also after a carried stack was split off. Checked by the plan review: the bill hook, CompUsable.UsedBy and the feeding and social relax paths (see hooks B, U and C).
  • The break include and exclude lists: which states MentalBreakDefs name, and which animal and baby states to leave out.
  • The jailbreaker's talk goes through TryInteractWith (an earlier draft patched InteractionWorker_SparkJailbreak.Interacted directly).
  • The insect meat group: how insect meat is told apart (the meat's source race flesh type is the likely field).
  • The picker with a large mod list: catalogue size and draw cost.

Backlog

Promoted to docs/features.md on 2026-12-01 as New features: lawbook templates; the group "anything the offender's ideoligion forbids" and apostasy (single events such as adultery as GotLovin_NonSpouse are catalogue entries already); witnesses as a role and as evidence (free colonists with line of sight to the act, recorded in a new Case field at filing); the guilty plea; appeals and retrial under a new judge; a jury from the spectators; pardon petitions from a convict's friends. The rest waits for demand:

  • Rows that tick several entries, like a bill's ingredient filter, if one entry per row proves too narrow; needs a precedence rule for overlapping sets.
  • Used buildings and any job as a catalogue category (played horseshoes, used the comms console), through the same StartJob hook as the next item.
  • "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-forced jobs as crimes: executions, organ harvesting and butchering a human are in the catalogue (recorded acts, bills) and count unless the job was forced or the pawn drafted. A per-row "player orders count too" switch would drop the exemption. Vanilla already has "about to" checks in work givers through HistoryEvent.Notify_PawnAboutToDo_Job.
  • Freeing a held entity (Anomaly) as an act.
  • Theft: vanilla colonists never steal; a "took forbidden goods during a break" flag in the Thing.Ingested prefix.
  • 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.
  • A Castes right "may serve in court".
  • 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).
  • Indenture as a sentence through Blax Slaves' indentured servitude (an idea in docs/features.md since the plan review): a slave loses Warden, Hunting, Art and Research for good and any ideoligion role, so it needs a give-back plan and a SlavesApi call first.

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 (see "Trial through Ideology's ritual").
  • 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.
  • Dialog_BeginLordJob as the convene dialog: it builds its role column only when a DLC is installed (RimWorld/Dialog_BeginLordJob.cs:134-143) and logs an error otherwise.
  • Core's GiveSpeech duty for court speakers: it gives a job only to a speaker on its own throne (RimWorld/JobGiver_GiveSpeech.cs:19-22).
  • A courtroom RoomRoleDef: a room has one role (Verse/Room.cs:872), so it would replace the dining room, rec room or throne room.
  • Patching Bill.Notify_IterationCompleted: empty and called as a base call the JIT may inline (RimWorld/Bill.cs:278-280, RimWorld/Bill_Medical.cs:129); hook B uses RecordsUtility.Notify_BillDone.
  • 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; "Slaughterers" patches the private ExecutionInt), the empty MentalState.Notify_AttackedTarget.