Minigames
Free shared minigames used by GR1M resources (and yours). The first game is a first-person layered lockpick (analog cylinder give, bind tracking, pick strain).
This resource does not unlock doors or consume items. Callers await a boolean and apply their own rewards.
#Timing bar and rummage
exports.GR1M_Minigames:TimingBar(difficulty, inputs)takes the same arguments aslib.skillCheck, so you can swap it in wherever you uselib.skillCheck. Tune it withConfig.TimingBar. Settingenabled = falsebrings back the radial.exports.GR1M_Minigames:Start('rummage', { pieces = 9, seconds = 14, kicker = 'Dumpster', title = 'Rummage', hint = '...' })blocks and returns a boolean. Any option left out comes fromConfig.Rummage.
#Tattoo needle
exports.GR1M_Minigames:Start('tattoo', { mode = 'ink'|'laser', radius = 22, seconds = 9, need = 0.72 })blocks and returnssuccess, accuracy. A guide point runs along a random stencil; hold left mouse and keep the needle on it.needis the share of the run that must be on the line. Defaults inConfig.Tattoo. Used by GR1M_Tattoo, which re-checks timing on the server.- Fires the local client event
GR1M_Minigames:tattooBuzz(true/false) when the needle starts and stops, for the machine sound.
#Install
Start after ox_lib:
ensure ox_lib
ensure GR1M_Minigames
#Dependencies
ox_lib(notify + promises)- Soft:
GR1M_Skills—lockpick_speedandlockpick_bonus_triesif that resource is started
#Exports
-- Preferred
local ok = exports['GR1M_Minigames']:Start('lockpick', {
difficulty = 'medium', -- easy | medium | hard | master, or 1-5
attempts = 3, -- optional override
})
-- Alias matching the old lockpick resource (not wired to doors yet)
local ok = exports['GR1M_Minigames']:startLockpick(3)
exports['GR1M_Minigames']:IsEnabled()
Start returns true only when the cylinder turns. Fail, snap, cancel, and death all return false.
#Difficulty
| Key | Bind | Tracking | Picks | Notes |
|---|---|---|---|---|
| easy | wide | static | 5 | Full give is generous |
| medium | medium | slight follow | 3 | Default |
| hard | tight | follows plug | 2 | Worn wobble |
| master | tiny | follows + jitter | 1 | Fast strain |
Tune in config/shared.lua.
#Lockpick art
Layered PNGs live in web/img/lockpick/ and share pivots in layout.json. The pick is one true-alpha image whose tip sits in the keyhole; the handle orbits that pivot. Rebuild with:
python tools/build_lockpick_layers.py
#Adding later minigames
Keep lockpick in web/js/lockpick.js. New games get their own JS module; Lua Start(name, opts) already keys off name.
Design source: the approved mockup gr1m-procedures.html (v3). Games are drawn on canvas in the same dark clinical look. The games only report what happened; GR1M_Medical applies every medical effect server side.
#Client exports
-- Blocks until the game ends. name: 'surgery' | 'cpr' | 'iv' | 'defib' | 'splint' | 'anaesthesia'
local result = exports.GR1M_Minigames:Start(name, opts)
Common opts:
session(string) id GR1M_Medical uses to route events and spectators.difficultynumber 0.5 (easiest, high medical skill) .. 1.5 (civilian). Scales timing windows, tremor, speeds.patient{ name = 'HALE, Marcus', age = 34, sex = 'M', weightKg = 82, allergies = 'Penicillin' }broadcastboolean: emit state snapshots for spectators (about 8 per second).
Per game opts:
surgery:stepslist (subset/order of 'timeout','anaesthesia','incision','extraction','haemostasis','irrigation','closure'),anaesthesia'ga'|'cse'|nil (nil = choose in game),assistedboolean (a second player runs the anaesthetic: no solo drift, steadier hand, nurse suction),wound{ region = 'rleg', retained = true },volstarting blood volume ml.cpr:cycles(default 5),rhythmCheckboolean.iv:site'antecubital' | 'forearm' | 'hand',gauge14|16|18|20|22.defib:rhythm'VF' | 'pVT' | 'asystole' | 'PEA',joulesdefault 200.splint:fracture'distal_radius' | 'tibia' | 'forearm'.anaesthesia(assistant side of team surgery):mode'ga'|'cse'.
result table (always has success boolean, cancelled boolean):
- surgery:
{ success, steps = { [id] = { ok, text } }, bloodLostMl, anaesthesia = 'ga'|'cse', intubationTries, hits = { nerve, artery, vein }, complications = { 'nerve_injury', 'awareness', ... } } - cpr:
{ success, quality (0-100), cycles, compressions, avgRate, avgDepthCm, maxPauseS } - iv:
{ success, attempts, blown, spill, gauge } - defib:
{ success, decision = 'shock'|'cpr', correct, padQuality (0-100) } - splint:
{ success, alignment (0-100), cmsAfter = 'normal'|'impaired' } - anaesthesia:
{ success, timeInBandPct }
exports.GR1M_Minigames:Spectate(name, state, info) -- show/update the spectator view (patient's screen)
exports.GR1M_Minigames:StopSpectate()
exports.GR1M_Minigames:Feed(session, data) -- live input from a teammate, e.g. { depth = 62 } or { suction = true }
exports.GR1M_Minigames:Cancel()
#Client events fired by GR1M_Minigames (local TriggerEvent)
GR1M_Minigames:client:state(name, session, state) whenbroadcast, about 8 Hz.stateis a small table the spectator renderer understands.GR1M_Minigames:client:event(name, session, key, data) on milestones. Keys GR1M_Medical narrates / applies:surgery:
timeout_done,preox,induced,intubated,oesophageal,cse_done,too_light,block_regressing,incision_done,vessel_hit{vessel},round_gripped,round_removed,bleeder_open,arterial_tied,irrigated,counted,suture{ok},done; cpr:compression{depth, rate},breath,cycle{quality},rhythm_check; iv:tourniquet,cleaned,scratch,flashback,blown,spill,flushed,secured; defib:pad_on{pad},analyzing,shock,no_shock; splint:cms_before,block,reduced,splinted,cms_after.
#Spectator view
Spectate shows a passive version of the same game (no input) in a picture-in-picture panel bottom right, fed by the state snapshots relayed through the server. GR1M_Medical wraps it with the patient's state line and narration feed, and applies the blur / darkness (asleep, unconscious) itself through info: { state = 'GENERAL ANAESTHETIC', blur = 7, dark = 0.6, feel = '...' }.
#Implementation notes and additions (v1.1.0)
Files: client/medical.lua, web/js/medical-*.js (core + one file per game), web/css/medical.css. Start('lockpick', …) still returns a boolean; every medical name returns the result table. Escape cancels (cancelled = true); after the end banner shows, Escape just closes early with the real result.
Additions to the contract above:
info.title(header text, default the game name) andinfo.feed(list of strings or{ t, text }, newest first, max 12 shown).- Surgery:
stepsorder is respected; with nostepsandwound.retained == falsethe extraction step is dropped.If
anaesthesiais set and'anaesthesia'is not insteps, the patient starts already under that anaesthetic. - Surgery ends early (
success = false, complicationexsanguination) when blood volume falls to 1,600 ml.success= every step completed without exsanguination; per-stepokandcomplicationscarry the quality. Complication ids:nerve_injury,artery_injury,vein_injury,awareness,pain,difficult_airway,haemorrhage,exsanguination,infection_risk(any step failed). - Surgery event
step{ id, index }when each step opens. Event payloads:induced {depth},cse_done {depth},intubated {tries},oesophageal {tries},too_light {bis},block_regressing {depth},incision_done {accuracy},vessel_hit {vessel},round_removed {hits},bleeder_open {arterial},suture {ok, index},done {bloodLostMl, failedSteps | exsanguinated}. - CPR:
compression {depth, rate, n, cycle},breath {n, cycle},cycle {quality, cycle}.success= quality >= 60. - IV:
blownis a boolean (any vein blown) plusblownCount; the game fails after 3 blown veins.Events
scratch {attempt},blown {count},secured {spill}. - Defib: result also has
rhythm;success=correct. Eventspad_on {pad, quality},shock {joules, rhythm, correct},no_shock {rhythm, correct}. - Splint: events
cms_before {status},reduced {alignment},cms_after {status}.cmsAfterisimpairedbelow 78 % alignment.tibia/forearmreuse the same fluoro drawing with their own labels and steps. - Anaesthesia (assistant): fires
assist{ depth, suction = true, blood = true }(depth every 0.7 s once the mode is known,suction / blood once per press).
success=timeInBandPct >= 60. Feedforsurgery:{ assisted = true|false },{ depth }(ignored until the anaesthetic is in),{ suction = true },{ blood = true | n }. Any of depth / suction / blood marks the teammate as live: solo drift and the nurse's auto top-up stop.Feedforanaesthesia:{ mode = 'ga'|'cse' }(starts the anaesthetic at depth 70 / 85),{ depth, sync = true },{ vol, lost }(shown on the monitor),{ ended = true }or{ done = true }ends with the real result.- Debug (when
Config.DebugCommand):/testmed <name> [0.5-1.5] [assisted] [spec] [ga|cse] [VF|pVT|asystole|PEA] [tibia|forearm].specbroadcasts and mirrors the state into your own spectator panel; events print to F8.
GR1M