Gameplay content

Justice

Crimes, the police, a night in the cells, bail, the trial, prison and the record, as one system. How your mod reports a crime, sends someone to prison and reads the record.

ul_Justice is the law, from the crime to the record. It used to be five mods (ul_Police, ul_Warrant, ul_Remand, ul_Trial, ul_Inside). Each kept its own bail, its own court or its own way into prison, so one arrest could leave the player on two bails, and a sentence handed down while they were held until trial was not counted as one. Now it is one mod with one case file, one bail, one court, one way into prison and one record.

What it covers

  • Wanted level (warrant): the stars a crime earns, cooling down over time.
  • Case files (police): a crime reported, the investigation and its leads, the interview under caution, the charge.
  • The night in the cells (remand): after an arrest or giving yourself up. The lawyer, the interview in the morning, then the custody decision: released under investigation, bail, or held until trial. A charge outside court hours waits in the cells for the next court morning (Saturday morning sits for those held); the most serious charges (Police.REMAND_SEV, murder) are always held until trial. A case already charged that is wanted again (a missed court date, a second breach) goes straight back before the court, without a new interview.
  • Bail: signing on at the station (a reminder on the day, the station marked on the map). A missed sign-on is a breach, and two lead to a warrant.
  • The court (trial): the dock, the lawyer, the verdict, the appeal, probation and community orders. Courts sit on weekdays (Trial.courtAt(hour)); a minor charge comes to court in one to two weeks, a serious one in one to three months (Police.trialDays(sev), data in P.TRIAL_DAYS). A judge alone tries minor cases, a jury sits from severity 3. A community order is unpaid hours and appointments; a suspended sentence is probation only, and a breach activates it.
  • Prison (inside): life inside, the work scheme and the licence after. A court sentence is served half inside, time on remand counted, and the rest on licence through the court's probation (Trial.startLicence(days): weekly appointments, two missed ones and the player is recalled for the rest). A parole board sits only for terms of 30 days or more. An acquittal, a fine after remand, a quashed conviction or an escape is never followed by a licence. Discipline while on remand costs privileges, never days.
  • The record: every conviction, whoever handed it down, with its kind and length. A conviction is spent after a period that depends on the sentence (Police.SPENT: a year after a fine, two after a community order, two to five after a prison term); a spent one no longer brings the boss, the jury bar or a police refusal.

Sending the player to prison

Do not set the sentence stat and call Game:imprison() yourself. Call:

luaUL.imprison(Game, days, "sentence", "ul_MyMod")   -- a court's sentence: half inside, the rest on licence, on the record
UL.imprison(Game, days, "my_reason", "ul_MyMod")  -- any other confinement: served as written, not a conviction

With ul_Justice installed, the stay goes through it (any reason but a court's "sentence" is served in full, with no licence after): it knows why the player is inside, life inside counts the days, and a later conviction or release knows what it replaces. Without it, UL.imprison does what mods always did (the sentence stat, then Game:imprison()). Pass nil as days when an earlier scene already set the sentence.

ModLint warns about a direct Game:imprison() outside ul_Justice (rule L111), and python -I Tools/Justice/route_prison.py --apply rewrites the calls it finds.

A "sentence" through UL.imprison is recorded as a custody conviction for you. For a conviction without prison (a fine, a community order) that your own mod's court hands down, add it to the record:

luaif Services.has("justice") then
	Services.justice.convict({ crime = "fraud", kind = "fine" })   -- kind and days decide when it is spent
end

A prisoner's day in court

An imprisoned player can only enter the prison: every other door stays shut, and Game:setBackground cannot take them anywhere else. When your story needs the prisoner somewhere for a scene (the court for a trial on remand, a hospital, a funeral under guard), take them there under escort:

luaif Game:escortTo("courthouse") then   -- the same words as setBackground; false for a free player or a town without one
	-- the scene goes on in the courtroom, the player still a prisoner (isImprisoned() stays true)
end
Game:escorted()     -- the place the escort went to ("courthouse"), or "" when there is none
Game:escortBack()   -- back to the prison now: the rest of the scene plays in the cell

The escort lasts while the scene that asked for it plays: when it ends, the game takes the player back to the prison. Call Game:escortBack() only for lines that must be read back inside. A court that lets the prisoner go (an acquittal, a sentence served on remand) calls Game:endPrison() during the escort: the player walks out of the court, free, with no prison gate. With ul_Justice, Justice.goTo(Game, tag) escorts a prisoner for you, and Justice.release lets them go from the court.

Reading it

lualocal J = Services.has("justice") and Services.justice or nil
if J then
	J.imprisoned()   -- in prison now
	J.stay()         -- why: "remand:<case>", "sentence:<case>", "<mod>:<reason>", or "" when free
	J.onRemand()     -- held without a conviction yet
	J.record()       -- convictions so far, spent ones included
	J.liveRecord()   -- convictions not yet spent: what a boss or a background check should read
	J.lastEnd()      -- how the last stay ended: "served", "escaped", "released", "quashed" or ""
	J.licenceDays()  -- the licence waiting at the end of this stay
end

Townspeople in prison

A townsperson your mod sends to prison leaves the town for the term: People:get(id):jail(days, "my_reason") holds them in custody at the prison, takes their office and, past 30 days, their job, and lets them out on the day the term ends (npc_released in their history). People:get(id):unjail() lets them out early (a conviction quashed). ul_Justice's own court does this for the townspeople it convicts, through Trial.jail(person, days): like the player, they come back at half the term. A townsperson is only jailed on a real case, never for a trial invented as colour, and the jury the player sits on tries a stranger.

Crimes against the player

Services.police.report{ ..., by = npc } opens a case where the player is the victim (or a witness): the police ask for a statement, and the case goes on, or closes unreported when nobody saw it and the player never came in. Naming someone at the front desk counts as grounded only by a crime of that kind the game recorded them doing to the player, and each record grounds one report; otherwise, or for a crime nobody can name, the report risks being found out as a false one (the case withdrawn, the compensation taken back, an innocent's conviction quashed). The lawyer is hired per case (Police.hireLawyer(tier, case)).

An offence of your own

Police.report refuses a crime id that is not in Police.CRIMES, and ul_Justice lists the common ones only (theft, fraud, assault, burglary...). A mod whose story has another offence registers it with Services.police.addCrime(id, def), with the same fields as ul_Justice's own (ul_Justice/Lua/ul_police_data.lua: label in plain words, never one country's statute; sev 1-5; stars; report; leads, keys of Police.EVIDENCE; days, fine, hours for the sentence; caution). The list is not saved: register it again at every load, and before each report.

lua-- ul_Honeytrap: a target who caught the player photographing their screen may complain
Honeytrap.CRIMES = { data_theft = { label = "theft of confidential data", sev = 2, stars = 1, report = 0.5,
	leads = { "witness", "phone", "cctv" }, days = { 60, 365 }, fine = { 1000, 8000 }, hours = 120, caution = true } }

local function crimes()
	if not (Services.has("police") and Services.police.addCrime) then return end
	for id, def in pairs(Honeytrap.CRIMES) do pcall(Services.police.addCrime, id, def) end
end
Events:on("ul_Honeytrap", "loaded", crimes)

-- then, when it happens
crimes()
local c = Services.police.report({ crime = "data_theft", victim = target, witnesses = {}, seen = true })

The case then goes the usual way: the leads come in, the player is invited to an interview when the evidence is enough (Police.INVITE), then charged or released. Evidence your mod knows of (the victim's complaint and statement) goes on the file in ul_Justice's encoding, c.ev = "complaint:1,detailed_statement:1", saved with Services.police.save(c): the service has no addEvidence yet. Mods that register offences this way: ul_Undertow and ul_ForbiddenBlood (sexual_assault), ul_Honeytrap (data_theft), ul_Base's sex work (soliciting, procuring), ul_Mob (harassment). List police in MODULE_USES.

A Witness act someone takes to the police opens a case as the crime Police.ACT_CRIMES names for its type, or as a star crime by its severity when it names none (an assault for a severity of 3). A mod whose act type is its own offence adds the entry with its crime, again at every load: ul_Mob maps false_accusation to harassment, so the false post it records reaches the police as harassment and not as an assault.

luaif Services.has("police") and type(Services.police.ACT_CRIMES) == "table" then
	Services.police.ACT_CRIMES.false_accusation = "harassment"
end

The other services keep their names, so code written for the five mods keeps working: Services.police.report{...} to report a crime, Services.warrant.chargeAct(...) to charge an act someone witnessed (see Witnesses), and inside, trial, remand. List the ones you call in MODULE_USES (see Services).

Old names

ul_Base/retired_mods.txt says ul_Police -> ul_Justice, and the same for the four others. A folder left over from an old install is skipped. A mod that lists ul_Warrant in MODULE_REQUIREMENTS, or asks Game:isModEnabled("ul_Police"), gets ul_Justice. A player who had turned all five off starts with ul_Justice off. New code should ask Services.has("police") (or "warrant", "justice") rather than a mod's name.

A save from before the merge is carried over the first time it loads: the five mods' own state moves to ul_Justice.