![Blax Laws](About/Preview.png) # Blax Laws [![RimWorld 1.7](https://img.shields.io/badge/RimWorld-1.7-19C63C)](https://rimworldgame.com) [![Needs Harmony](https://img.shields.io/badge/needs-Harmony-050805)](https://steamcommunity.com/sharedfiles/filedetails/?id=2009463077) [![Any DLC combination](https://img.shields.io/badge/DLCs-any_combination-5a6b5d)](#dlc-support) [![Status: 1.0](https://img.shields.io/badge/status-1.0-CDCDCD)](CHANGELOG.md) RimWorld mod (1.7) by Blax Gaming. Lawbook, crimes and punishments. Write your colony's laws from every act the game knows, picked the way you pick what to tailor, and your wardens enforce them. Add "Drug binge, planning: subdue" and when a colonist starts a wake-up binge, a warden goes for it at once and beats it down; if it reaches a drug first, that dose counts as "did it". Add "Drug binge, did it: jail 5 days" and the one who already took some sits out five days in your prison and walks back to work. Needs Harmony. Works with any DLC combination, core only included. ## Features ### The lawbook - ๐Ÿ“– **An empty lawbook.** A "Laws" button in the bottom bar with two tabs, Lawbook and Cases. A law is a row of Action, Stage, Severity, Punishment and Days, plus an On switch; each dropdown offers only what fits the action and stage. Nothing is watched or punished until the first row exists. `Source/BlaxLaws/UI/MainTabWindow_Laws.cs` - ๐Ÿ”Ž **Pick any act.** "Add law" opens a searchable tree like a tailoring bill's filter: every mental break, everything that can be eaten or used, every social interaction, every act the game records, every record and every bill, plus the special acts. It's built from the loaded defs when the game starts, so DLC and modded breaks, drugs and recipes show up with no patch, each labelled with its mod. Typing filters every category at once; an entry already in the book shows a tick and jumps to its row. `Source/BlaxLaws/UI/Dialog_PickAct.cs`, `Source/BlaxLaws/Catalogue/ActCatalogue.cs` - ๐Ÿ“ **Starter lawbook.** One click adds seven laws: 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: warn (Minor); insult: warn (Minor). Pressing it again adds only the missing ones. Every starter law uses core content. `Source/BlaxLaws/Lawbook.cs` - ๐ŸŽฏ **One law per act, the most specific wins.** Action, Option and Stage are a row's key; a second row with the same three is refused and the list jumps to the existing one. A drug binge row names which drug counts: any drug, hard drugs, social drugs or one drug. When two rows of a category match an act, a single def beats a group, a smaller group beats a larger one, and one drug beats hard or social drugs beats any drug: "wake-up" over "hard drugs" over "any drug", "human meat" over "any meat". - ๐ŸŽš๏ธ **Stages that mean something.** "Planning" is the moment a mental break starts and nothing is done yet; the game picks the break type only then, so only breaks have it. "Did it" is the act the break is about, such as the first dose of a binge. An entry offers only the stages the game can tell apart. - โš–๏ธ **Severity and days.** Minor, Moderate, Serious or Grave set the default days (1, 3, 5, 10) and order the case log. Days go from 1 to 50. Changing the severity moves the days along only while you haven't typed your own. - ๐Ÿ“‹ **Case log.** Who, what, stage, when, punishment and status, newest first, with a jump to the pawn and "Arrest now" for cases that wait. Deleting a law with open cases asks first, names the count and closes them as "law repealed". - ๐Ÿงฉ **Missing entries wait.** A row whose DLC or mod is gone stays in the book with its saved name, shows "Needs " or "Missing: ", isn't enforced and works again when the content comes back. ### Crimes Laws adds no crime events and no mental breaks. It only watches what the game does anyway. `Source/BlaxLaws/Detection/`, `Source/BlaxLaws/CaseFiler.cs` - ๐Ÿง  **Mental breaks.** Every break a colonist can have, berserk included; animal and baby states are left out. Groups: any drug binge, any tantrum, any insulting spree, any aggressive break, any break. - ๐Ÿ– **Ate.** Every food, meal, raw food, corpse and drug, modded and DLC ones included. Groups: any drug, hard, social or medical drugs, any meat (meals with meat included), raw meat or corpses, human meat, insect meat, raw food, any meal. It counts only when the pawn eats on its own: a doctor's dose, a warden feeding a patient or a baby being fed doesn't. A drink at a gathering spot counts. - ๐Ÿ’‰ **Used.** Psytrainers, neurotrainers, mech serums and modded usables, when the pawn uses one on its own. - ๐Ÿ—ฏ๏ธ **Social interactions.** Every interaction: insults, slights, chitchat, romance attempts, breakups, jailbreak talk, modded ones. The pawn who starts it is the offender. Group: insult or slight. - ๐Ÿงพ **Recorded acts.** Every act the game records with the pawn as its doer, such as cut a tree, butchered a human, harvested an organ or executed a prisoner. Most of them are recorded only with Ideology, and the category's tooltip says so. - ๐Ÿ“Š **Records.** Every counted record, such as kills, animals slaughtered, bodies stripped or things hauled. A case opens when the record goes up. - ๐Ÿงช **Bills.** Every recipe, such as made a human leather duster, cooked a fine meal or installed a bionic arm, when the pawn finishes one iteration. Group: any surgery. - ๐Ÿ”ฅ **Special acts.** Set a fire (the pawn who ignites it, never a raider); displayed a corpse, where the case notes "on a table" and "dug up from a grave", which it nearly always is; started a social fight, filed on the pawn who swings first, usually the insulted one. - ๐Ÿ”— **Breaks lead to their act.** A drug binge's "did it" is a dose of the drug the row names, a food binge's a meal, a fire-starting spree's a fire, a corpse obsession's the displayed corpse, an insulting spree's an insult or slight, a jailbreaker's jailbreak talk. Links go by mental state class, so a modded break built on one of these gets its link too, and another mod can add its own with a `BreakLinkDef` and no code. Every other break is Planning only for now. `Defs/BlaxLaws_BreakLinks.xml` - ๐Ÿ“ **One case per incident.** A binge is one case from start to end; it moves from planning to did it, each row fires once per case, and the case counts the doses. An act that is the did-it of an open break case belongs to that case; when it also matches a row of its own, the row with the higher severity decides. - ๐Ÿงฎ **No flood.** Acts outside a break open at most one case per offender and law a day (0 to 7 days in the settings). A further act in that window raises the count on that case and posts no message, so a meat-eating colony of 60 doesn't flood the log or the save. - ๐Ÿ‘ฅ **Who is covered.** Free colonists, children included, and colony slaves. Never guests, Hospitality visitors, quest lodgers, prisoners or babies. Acts while drafted or on a job you ordered open no case (setting). ### Punishments Which punishments a row offers depends on its entry and stage: a planning row offers warn, subdue and jail; a break's did-it row also guilty and subdue then jail; every other act warn, guilty and jail. `Defs/BlaxLaws_Punishments.xml` - โœ‹ **Warn.** The case is filed and a message posted, nothing more. - โš–๏ธ **Guilty for N days.** Vanilla guilt: 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. A longer guilt already on the pawn is never shortened. `Source/BlaxLaws/Enforcement/PunishmentWorker_Guilty.cs` - ๐Ÿ›‘ **Subdue.** A warden beats the offender down with fists to end its break: capped blunt hits on torso, shoulders, arms and legs, never the head, never a bionic part, no lost parts, no scars, no bleeding. Every part keeps at least half its health, and the bruises never add up to a deadly amount. The offender doesn't fight back, and the enforcer isn't marked guilty. The beating 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. Tantrums, murderous and sadistic rage can be subdued too; the warden is never the rage's named victim. After the break a subdue row warns instead. `Source/BlaxLaws/Enforcement/JobDriver_Subdue.cs` - ๐Ÿ”’ **Jail for N days.** A warden arrests the offender into a prisoner bed; guilt for the sentence is renewed right before the arrest, so it is always accepted. Two ticks after the capture the prisoner is set to "Maintain only", after any default a prison mod or Blax Castes writes, so nothing recruits, enslaves or executes your colonist. `Source/BlaxLaws/Sentences/PunishmentWorker_Jail.cs` - โ›“๏ธ **Subdue, then jail.** Beaten down, and in the same tick the warden's next job is the vanilla capture to a prisoner bed, ahead of a doctor's rescue. After the break it jails without the beating. - ๐Ÿ‘ถ **Children are never beaten** (Biotech): a subdue on a child becomes jail when the row has days, a warning otherwise. - ๐Ÿ˜ก **Berserk breaks fight back.** Their rows offer warn, guilty and jail, never subdue. The jail waits until the break ends or you down the pawn, then arrests or captures it. ### Enforcement - ๐Ÿš‘ **One enforcer per case, safely.** The nearest awake colonist with Warden work goes, then anyone able (setting: wardens only). Never a slave, a child, the offender, a pawn in a break, on a player order or in a party or ritual, and never one rescuing, carrying or tending someone, fighting a fire, manning a turret, doing surgery or fleeing. `Source/BlaxLaws/Enforcement/Enforcers.cs` - โš ๏ธ **Nobody is sent into danger.** While hostiles threaten the map, a berserk colonist included, cases wait and are enforced after the fight. A warden already on a case when a raid arrives is called back. - ๐Ÿ” **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, a doctor's reservation or the end of a fight happens as soon as it can. A did-it jail that arrives while the planning subdue still runs takes over from it. `Source/BlaxLaws/Enforcement/Enforcement.cs` - ๐Ÿ“จ **Messages and letters.** A message for every case. A letter only when a colonist is jailed or you have to act: no prisoner bed, no enforcer, a role holder on hold. No second letter for a break, since the vanilla one already arrives. ### Sentences - โณ **Served and released.** The colonist sits out its days on "Maintain only", keeping its work priorities, since prisoners have no disabled work types. When the time is served Laws sets "Release" and a colonist walks it out; if nobody has after a day, Laws releases it in place. The release counts from the capture, not from the filing. `Source/BlaxLaws/Sentences/Sentences.cs` - ๐Ÿ›๏ธ **The old bed.** The arrest job claims the prisoner bed before the arrest happens; if the arrest then fails, Laws gives the colonist its old bed back when it is still free. - ๐Ÿšช **Another mod's early release wins.** A jailed colonist that is recruited, released by you or another mod, escapes or dies closes its sentence with that outcome and a message. - โธ๏ธ **Role holders and mechanitors wait.** An arrest would take an ideoligion role (Ideology) and shut a mechanitor's mechs down (Biotech), so their case waits with "Arrest now" and a letter says why. Guilt is set anyway and renewed when you press it. - ๐Ÿ”— **Slaves aren't jailed yet.** Releasing an imprisoned slave would send it back to its old faction, so a slave's jail row subdues it while it is in its break and warns otherwise, until "Jail for slaves" ships. ### Save and settings - ๐Ÿ’พ **Save-safe.** One game component holds the lawbook and the cases, as names and numbers; nothing of Laws enters a vanilla save list, and the subdue job is hidden from the save. Blax Laws can be added to a running save. Unsubscribing leaves a save that loads with two errors in the log: jailed colonists stay vanilla prisoners you release by hand in the prisoner tab, and their guilt runs out on its own. `Source/BlaxLaws/GameComponent_BlaxLaws.cs` - โš™๏ธ **Mod settings.** "Enforce laws" (off keeps the case log and carries out nothing), "Show Laws tab", "Messages for cases", "Letters for jailings", "Enforcers" (wardens first or wardens only), "Subdued pawns lose their catharsis", "Player orders are exempt", "Days between cases for acts outside a break", "Keep closed cases" (60 days), "Reset to defaults". `Source/BlaxLaws/BlaxLawsMod.cs` ## Planned In build order. What each area covers and its steps are in `docs/features.md`, the specs in `docs/design.md`. - ๐Ÿ”ช **Violence, drugs and the rest of the punishments.** Assault, harming prisoners or slaves, manslaughter and murder, with "did it" for tantrums, berserk and the rages; the slaughterer break; drugs the pawn's drug policy doesn't allow. Reprimand, and banish or execute after you confirm. Release gives back the bed, grave, throne, deathrest casket, ideoligion role, mech work modes and the dropped weapon, so role holders and mechanitors no longer wait. Pardon, early release and more days. - ๐Ÿ“ˆ **Repeat offenders.** A criminal record per colonist, then harsher punishments for a repeat offence and early release on probation. - ๐Ÿ›๏ธ **Court.** "Trial" as a punishment through Ideology's trial, then court sessions on the core game: a judge, a prosecutor and spectators at a place you pick, a verdict that weighs evidence against Social skill, the sentence from your lawbook, "jail, then trial", and a court that sits on its own if you want. Then attorneys, witnesses and a guilty plea, trials over several days, courtrooms and appeals. - ๐Ÿ—ณ๏ธ **Colony votes.** Colonists propose and repeal laws and vote by traits, beliefs, opinion and mood, and you back or veto the result; the colony elects its judge; later a jury and pardon petitions. - ๐Ÿค **With the other Blax mods.** Blax Castes keeps a convict's caste through any sentence, Blax Slaves' wardens calm slaves before Laws steps in, a jailed slave becomes a slave again, and confinement as a sentence through a Blax Castes caste. - ๐Ÿ’ฌ **Your call.** Decide a case yourself, talk a colonist down instead of beating it, laws for one group only (slaves, children, a caste, or a colonist above the law), lawbook templates for the next colony, your own convicts breaking out and slave rebellions as crimes, crimes against the faith (Ideology), and a fighter you pick to subdue a berserk colonist. ## DLC support Blax Laws works with any combination of DLCs, core only included, and lists none as a dependency. Every category and punishment of this release runs on the core game. The act list shows what your game has: a DLC's breaks, drugs, interactions, usables and recipes appear when it is active and are absent without it. - **Ideology** adds slaves, who get warn, guilty and subdue, and records most of the game's acts (cut a tree, butchered a human); without it the recorded acts category rarely fires. An arrest would take a role holder's role, so its case waits for "Arrest now". - **Biotech** adds children, who are never beaten, and mechanitors, whose mechs would shut down in jail, so their case waits for "Arrest now". - **Royalty**, **Anomaly** and **Odyssey**: their acts appear in the list when active; Laws needs none of them. - **A save made with a DLC** loads without it. A law naming a DLC entry stays and shows "Needs "; a case whose offender was a slave keeps its name. ## Compatibility - โœ”๏ธ Prison Labor, Prisoner Realism and Custom Prisoner Interactions: a jailed colonist is a vanilla prisoner, so their features apply. Laws only keeps its own convicts on "Maintain only" and lets them go when the time is served; Prison Labor's work toggle stays as that mod sets it. While that toggle is on, Prison Labor turns off the work types it bars prisoners from, and they stay off after the release; turn the toggle off on a jailed colonist to keep its work priorities. - โœ”๏ธ Prisoner Sentencing and Prison Expanded: if one of them releases a colonist Laws jailed, Laws closes its sentence instead of fighting it. - โœ”๏ธ Hospitality: guests are never offenders. - โœ”๏ธ Blax Zones: arrests use any prisoner bed, zone beds included. Blax Castes: a jailed colonist moves to its new-prisoner row and back to its old caste after the release; Laws writes only "Maintain only" and "Release" on colonists it jailed. - โœ”๏ธ `Tests/run-tests.ps1 -Compat` runs the suite next to Prison Labor, Prisoner Realism, Custom Prisoner Interactions, Hospitality, Vanilla Social Interactions Expanded, Blax Castes, Blax Zones, Blax Slaves and Blax Defaults, and Humanoid Alien Races once it is installed. - โŒ Multiplayer: not supported. Load order: Harmony, Blax Castes, Blax Zones, Blax Slaves, Blax Laws. No Blax mod needs another. ## Development The repo is the mod folder. Link it into the game with a directory junction, run from the repo root (adjust the RimWorld path): ```powershell New-Item -ItemType Junction -Path "E:\SteamLibrary\steamapps\common\RimWorld\Mods\BlaxLaws" -Target (Get-Location).Path ``` Build (needs the .NET 10 SDK; output goes to `1.7/Assemblies/BlaxLaws.dll`). `RimWorldDir` and `HarmonyDir` in the csproj point at the Steam install and the Harmony mod; override them with `-p:RimWorldDir=...` elsewhere. ```powershell dotnet build Source\BlaxLaws\BlaxLaws.csproj -c Release ``` `Tests/run-tests.ps1` builds the mod and the test mod in `Tests/BlaxLawsTests`, starts RimWorld headless with its own save data folder in `%TEMP%\BlaxLawsTest`, runs the suite, saves and reloads, then loads the save with the mod's game component removed. Your mod list, saves and settings stay untouched. It needs Steam running. The script's header lists every switch. ```powershell .\Tests\run-tests.ps1 # every installed DLC .\Tests\run-tests.ps1 -NoDlc # core only .\Tests\run-tests.ps1 -Dlc Ideology # only the DLCs named .\Tests\run-tests.ps1 -Compat # next to the mods listed under Compatibility ``` Design and roadmap: `docs/design.md` and `docs/features.md`. ### Workshop upload `Tools/workshop-upload.ps1` creates and updates the Workshop item from the command line. A small tool (`Tools/WorkshopUpload`) uses the Steamworks.NET build and `steam_api64.dll` that ship with RimWorld and attaches to the running, logged-in Steam client as RimWorld, so it needs no password, no game window and no dev mode. ```powershell .\Tools\workshop-upload.ps1 # dry run: build, stage, check the Steam login and the item .\Tools\workshop-upload.ps1 -Check # release check: every -Publish gate, then the list of problems .\Tools\workshop-upload.ps1 -Publish -DescriptionFile docs\workshop-description.txt # upload and replace the description ``` The dry run and `-Check` upload nothing. The script stages only what players need (About, 1.7, Defs, Patches, Languages) in `%TEMP%`, sets the tags the game would (Mod plus the supported versions), the title from About.xml and the preview from `About/Preview.png`. The change note is every CHANGELOG.md entry newer than the version in `Tools/workshop-published.txt`. Blax Laws has no Workshop item yet. Without `About/PublishedFileId.txt` the first `-Publish` creates it, Public unless you pass `-Visibility private` (Steam's own default for a new item is Private), and writes its id to `About/PublishedFileId.txt` before the content upload, so a failed upload is retried as an update and never makes a second item. After a successful upload it writes `Tools/workshop-published.txt`. Commit both files. `-Publish` refuses unless: - the shipped files are committed and pushed, and the top CHANGELOG.md entry matches `modVersion` in About.xml; - two `Tests/run-tests.ps1` runs passed after the last build, one with every installed DLC and one with `-NoDlc` (`BlaxLawsTestResults.all.txt` and `BlaxLawsTestResults.nodlc.txt` in `%TEMP%\BlaxLawsTest`); - `About/Preview.png` is under 1 MB; - the description fits Steam's 8000-byte limit, every forgejo.blax.at link in it opens without a login, and every `[img]` host sends an `Access-Control-Allow-Origin` header. Steam loads description images cross-origin and shows a broken image otherwise. Forgejo's raw URLs send no such header, so the images are served from `cdn.blax.at/blax-gaming/laws/`, which does. The Workshop page is `docs/workshop-description.txt` (Steam BBCode). Its art is rendered from `Source/Art` (see `Source/Art/README.md`), and `docs/workshop-media.md` lists the in-game clips worth recording. `-DescriptionOnly -DescriptionFile docs\workshop-description.txt` replaces just the text, with no build, no content upload and no change note. The in-game route still works: `Tools/workshop-stage.ps1` swaps the junction for a clean copy, upload from Mods > Blax Laws > Advanced... > Upload to Steam Workshop (dev mode), then `Tools/workshop-stage.ps1 -Done` copies `About/PublishedFileId.txt` back into the repo and restores the junction. --- ## Made by Blax [![Blax Software Open Source Initiative](docs/art/blax-oss-banner.svg)](https://www.blax.at) ๐Ÿ› ๏ธ **Blax Gaming** is a project of **[Blax Software](https://www.blax.at)**, an Austrian software practice. We write Austrian-quality code in many fields: web platforms, mobile apps, backends, infrastructure, and the mods we play in our own colonies. Need something built? ๐Ÿ‘‰ [www.blax.at](https://www.blax.at)