From 4b114015475ac0442092ec22868b279ef606c111 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sun, 8 Nov 2026 16:22:34 -0800 Subject: [PATCH 01/78] Add stealth awareness, patrols and admin tools for scav guards --- tgstation.dme | 7 + voidcrew/_DEFINES/stealth.dm | 104 +++ voidcrew/modules/stealth/scav_guards.dm | 64 ++ voidcrew/modules/stealth/stealth_admin.dm | 248 ++++++ voidcrew/modules/stealth/stealth_ai.dm | 805 ++++++++++++++++++ voidcrew/modules/stealth/stealth_patrol.dm | 373 ++++++++ .../modules/stealth/stealth_perception.dm | 115 +++ voidcrew/modules/stealth/stealth_test_ruin.dm | 10 + 8 files changed, 1726 insertions(+) create mode 100644 voidcrew/_DEFINES/stealth.dm create mode 100644 voidcrew/modules/stealth/scav_guards.dm create mode 100644 voidcrew/modules/stealth/stealth_admin.dm create mode 100644 voidcrew/modules/stealth/stealth_ai.dm create mode 100644 voidcrew/modules/stealth/stealth_patrol.dm create mode 100644 voidcrew/modules/stealth/stealth_perception.dm create mode 100644 voidcrew/modules/stealth/stealth_test_ruin.dm diff --git a/tgstation.dme b/tgstation.dme index 79045ef1f52..5436811288d 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -6741,6 +6741,7 @@ #include "voidcrew\_DEFINES\ship_signals.dm" #include "voidcrew\_DEFINES\shuttles.dm" #include "voidcrew\_DEFINES\sound.dm" +#include "voidcrew\_DEFINES\stealth.dm" #include "voidcrew\_DEFINES\subsystems.dm" #include "voidcrew\_DEFINES\techweb_nodes.dm" #include "voidcrew\_DEFINES\trade.dm" @@ -7726,6 +7727,12 @@ #include "voidcrew\modules\shuttle\survey\survey_data_disk.dm" #include "voidcrew\modules\shuttle\survey\survey_designs.dm" #include "voidcrew\modules\slime_extract_piles\slime_extract_piles.dm" +#include "voidcrew\modules\stealth\scav_guards.dm" +#include "voidcrew\modules\stealth\stealth_admin.dm" +#include "voidcrew\modules\stealth\stealth_ai.dm" +#include "voidcrew\modules\stealth\stealth_patrol.dm" +#include "voidcrew\modules\stealth\stealth_perception.dm" +#include "voidcrew\modules\stealth\stealth_test_ruin.dm" #include "voidcrew\modules\storage\smart_locker.dm" #include "voidcrew\modules\storage\wall_locker.dm" #include "voidcrew\modules\surgery\experimental_dissection.dm" diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm new file mode 100644 index 00000000000..6fefe3e1bc7 --- /dev/null +++ b/voidcrew/_DEFINES/stealth.dm @@ -0,0 +1,104 @@ +// Stealth layer for chosen human NPCs (voidcrew/modules/stealth/). Awareness is AI state only. + +// ===== Awareness states (BB_STEALTH_STATE) ===== +#define STEALTH_UNAWARE "unaware" +#define STEALTH_SUSPICIOUS "suspicious" +#define STEALTH_ALERT "alert" +#define STEALTH_SEARCHING "searching" + +// ===== Blackboard keys ===== +/// One of the STEALTH_* states +#define BB_STEALTH_STATE "stealth_state" +/// world.time of the last state change +#define BB_STEALTH_STATE_SINCE "stealth_state_since" +/// world.time the guard last stopped being unaware (stealth_was_unaware()) +#define BB_STEALTH_UNAWARE_LOST_AT "stealth_unaware_lost_at" +/// TRUE once alerted, searching or hit. Never cleared by time or dormancy. +#define BB_STEALTH_WARY "stealth_wary" +/// REF(mob) => list(notice, turf last scan, world.time last perceived) +#define BB_STEALTH_NOTICE "stealth_notice" +/// The candidate with the highest notice +#define BB_STEALTH_FOCUS "stealth_focus" +/// Where it last saw (or was hit from) whoever it is after +#define BB_STEALTH_LAST_SEEN_TURF "stealth_last_seen_turf" +/// world.time of that sighting +#define BB_STEALTH_LAST_SEEN_AT "stealth_last_seen_at" +/// REFs of fallen group members it has already reacted to +#define BB_STEALTH_BODIES_SEEN "stealth_bodies_seen" +/// Its claimed stop, or the sentry's post +#define BB_STEALTH_HOME_TURF "stealth_home_turf" + +// Notice entry fields +#define STEALTH_ENTRY_NOTICE 1 +#define STEALTH_ENTRY_TURF 2 +#define STEALTH_ENTRY_SEEN_AT 3 + +// ===== Bark kinds ===== +#define STEALTH_BARK_SUSPICIOUS "stealth_suspicious" +#define STEALTH_BARK_GIVE_UP "stealth_give_up" +#define STEALTH_BARK_LOST "stealth_lost" +#define STEALTH_BARK_SEARCH "stealth_search" +#define STEALTH_BARK_HIT_UNSEEN "stealth_hit_unseen" +#define STEALTH_BARK_BODY "stealth_body" +#define STEALTH_BARK_CHATTER "stealth_chatter" + +// ===== What a stealth goto is for ===== +#define STEALTH_GOTO_PATROL "patrol" +#define STEALTH_GOTO_INVESTIGATE "investigate" +#define STEALTH_GOTO_BODY "body" +#define STEALTH_GOTO_SEARCH "search" +#define STEALTH_GOTO_HOME "home" + +// ===== Numbers (first playtest defaults; the owner tunes them) ===== +#define STEALTH_SCAN_INTERVAL (1 SECONDS) +#define STEALTH_SIGHT_RANGE 8 +#define STEALTH_ALERT_MAX_RANGE 7 +#define STEALTH_DARK_SIGHT_RANGE 4 +#define STEALTH_DARK_LUMCOUNT 0.2 +#define STEALTH_DARK_MULT 0.5 +#define STEALTH_CLOSE_RANGE 2 +#define STEALTH_CONE_HALF_ANGLE 60 +#define STEALTH_WARY_HALF_ANGLE 75 +#define STEALTH_SEARCH_HALF_ANGLE 90 +#define STEALTH_NOTICE_RATE 1.0 +#define STEALTH_NOTICE_MIN_FALLOFF 0.25 +#define STEALTH_SUSPICIOUS_AT 1.0 +#define STEALTH_ALERT_AT 2.5 +#define STEALTH_NOTICE_DECAY 0.34 +#define STEALTH_NOTICE_FORGET (20 SECONDS) +#define STEALTH_BEHIND_RATE 0.4 +#define STEALTH_RUN_MULT 2 +#define STEALTH_STILL_MULT 0.5 +#define STEALTH_LYING_MULT 0.5 +#define STEALTH_SUSPICIOUS_MULT 1.5 +#define STEALTH_SEARCHING_MULT 2 +#define STEALTH_WARY_MULT 1.5 +#define STEALTH_MAX_CANDIDATES 8 +#define STEALTH_INVESTIGATE_DELAY (2 SECONDS) +#define STEALTH_LOOK_AROUND_TIME (4 SECONDS) +#define STEALTH_SUSPICIOUS_TIMEOUT (12 SECONDS) +#define STEALTH_LOSE_TARGET_TIME (4 SECONDS) +#define STEALTH_SEARCH_TIME (40 SECONDS) +#define STEALTH_SEARCH_POINTS 3 +#define STEALTH_SEARCH_RADIUS 5 +#define STEALTH_BODY_SCAN_INTERVAL (2 SECONDS) +#define STEALTH_BARK_KIND_COOLDOWN (8 SECONDS) +#define STEALTH_GROUP_RADIUS 48 +#define STEALTH_ROUTE_CLAIM_RANGE 2 +#define STEALTH_PATROL_DEFAULT_WAIT (6 SECONDS) +#define STEALTH_LOOK_TURN_INTERVAL (3 SECONDS) +#define STEALTH_LOOK_TURN_CHANCE 50 +#define STEALTH_LOOK_TURN_ARC 90 +#define STEALTH_SENTRY_TURN_INTERVAL (8 SECONDS) +#define STEALTH_CHATTER_RANGE 3 +#define STEALTH_CHATTER_COOLDOWN (45 SECONDS) +#define STEALTH_PATROL_MAX_FAILS 3 +#define STEALTH_PATROL_SKIP_TIME (2 MINUTES) +#define STEALTH_PATROL_MAX_PATH 60 +#define STEALTH_LEASH_RANGE 24 +#define STEALTH_ADMIN_OVERLAY_TIME (5 MINUTES) +/// Seconds of search between "Come on out." lines +#define STEALTH_SEARCH_BARK_INTERVAL (12 SECONDS) + +/// The scav den's side +#define FACTION_SCAV "scav" diff --git a/voidcrew/modules/stealth/scav_guards.dm b/voidcrew/modules/stealth/scav_guards.dm new file mode 100644 index 00000000000..cc54f580537 --- /dev/null +++ b/voidcrew/modules/stealth/scav_guards.dm @@ -0,0 +1,64 @@ +/** + * # Scav den guards + * + * The first NPCs with the stealth controller (owner decisions 6 and 11). Placeholder dress until step 4 + * gives them their own look: the melee guard borrows the Syndicate sword table, the gunner the pistol one. + */ + +/datum/human_npc_voice/scav + lines = list( + RUIN_NPC_BARK_SPOT = list("There! Get 'em!", "Intruder!", "Got you now!", "Over here!"), + HUMAN_NPC_BARK_DOWNED = list("Ugh... I'm hit...", "Somebody..."), + HUMAN_NPC_BARK_RECOVER = list("Still here.", "That all?"), + HUMAN_NPC_BARK_CUFFED = list("You don't know who you're messing with."), + STEALTH_BARK_SUSPICIOUS = list("Hm?", "Who's there?", "Thought I saw something."), + STEALTH_BARK_GIVE_UP = list("Nothing.", "Jumpy tonight.", "Must be the rats."), + STEALTH_BARK_LOST = list("Lost them!", "Where'd they go?"), + STEALTH_BARK_SEARCH = list("Come on out.", "I know you're here."), + STEALTH_BARK_HIT_UNSEEN = list("Contact!", "Where's that coming from?"), + STEALTH_BARK_BODY = list("Man down!", "Who did this?"), + STEALTH_BARK_CHATTER = list("Shipment's late again.", "My feet are killing me.", "You hear that? No? Good."), + ) + emotes = list( + HUMAN_NPC_BARK_DOWNED = list("collapses."), + STEALTH_BARK_SUSPICIOUS = list("squints into the dark.", "turns, frowning."), + STEALTH_BARK_GIVE_UP = list("shrugs."), + STEALTH_BARK_SEARCH = list("checks behind a crate."), + STEALTH_BARK_HIT_UNSEEN = list("ducks."), + STEALTH_BARK_CHATTER = list("yawns.", "stretches."), + ) + chances = list(RUIN_NPC_BARK_SPOT = 100) + +// A line and an emote together read as a script: for the stealth kinds, now one and now the other. +/datum/human_npc_voice/scav/emotes_for(kind) + . = ..() + if(length(.) && length(lines_for(kind)) && prob(60)) + return null + +// The spot line always comes, even right after a stealth line. +/datum/human_npc_voice/scav/bark(mob/living/carbon/human/npc/speaker, kind, force = FALSE) + return ..(speaker, kind, force || kind == RUIN_NPC_BARK_SPOT) + +/datum/human_npc_voice/scav/lines_for(kind) + . = ..() + if(length(.) && length(emotes[kind]) && prob(30)) + return null + +/mob/living/carbon/human/npc/ruin/trooper/scav + name = "scav guard" + npc_name = "Scav Guard" + faction = list(FACTION_SCAV) + ai_controller = /datum/ai_controller/basic_controller/human_npc/stealth + npc_voice = /datum/human_npc_voice/scav + npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/sword + +/mob/living/carbon/human/npc/ruin/trooper/scav/gunner + npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/pistol + +/obj/effect/spawner/human_npc/ruin/scav + name = "scav guard spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/scav + +/obj/effect/spawner/human_npc/ruin/scav/gunner + name = "scav gunner spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/scav/gunner diff --git a/voidcrew/modules/stealth/stealth_admin.dm b/voidcrew/modules/stealth/stealth_admin.dm new file mode 100644 index 00000000000..fc3e9d3c847 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_admin.dm @@ -0,0 +1,248 @@ +/** + * # Stealth guard admin tools + * + * "Stealth Guards" (Debug): lists every stealth guard on your z-level, shows and forces its awareness, + * shows its sight to you alone, and acts on whole groups. Every action is logged (abuse review P16). + * + * The AI sleeps unless a living player is on the level. An admin watching as a ghost needs + * "Force Z-Level Active" (npc_ships/code/admin_verbs.dm). + */ + +/// The stealth guards on `z`, by group. +/proc/stealth_guards_on_level(z) + . = list() + for(var/datum/stealth_group/group as anything in GLOB.stealth_groups) + for(var/mob/living/guard as anything in group.living_members()) + var/turf/where = get_turf(guard) + if(where?.z == z) + . += guard + +/// One line about `guard`, for admins. +/proc/stealth_guard_summary(mob/living/carbon/human/npc/guard) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + if(!istype(stealth_ai)) + return "[guard] (no stealth AI)" + var/atom/focus = stealth_ai.blackboard[BB_STEALTH_FOCUS] + var/focus_text = "none" + if(focus) + var/list/entry = stealth_ai.blackboard[BB_STEALTH_NOTICE]?[REF(focus)] + focus_text = "[focus] [entry ? round(entry[STEALTH_ENTRY_NOTICE], 0.01) : "-"]" + var/since = round((world.time - stealth_ai.blackboard[BB_STEALTH_STATE_SINCE]) / (1 SECONDS)) + var/route_text = stealth_ai.route_id ? "route [stealth_ai.route_id] stop [stealth_ai.route_index]" : "sentry" + var/status_text = list("[AI_STATUS_ON]" = "on", "[AI_STATUS_IDLE]" = "idle", "[AI_STATUS_OFF]" = "off")["[stealth_ai.ai_status]"] || "off" + return "[guard.real_name] [REF(guard)] | [stealth_ai.group?.id || "no group"] | [stealth_ai.stealth_state()] [since]s | focus [focus_text] | [stealth_ai.blackboard[BB_STEALTH_WARY] ? "wary" : "calm"] | [route_text] | AI [status_text]" + +ADMIN_VERB(stealth_guards, R_DEBUG, "Stealth Guards", "View and force the awareness of stealth guards on your z-level.", ADMIN_CATEGORY_DEBUG) + var/turf/here = get_turf(user.mob) + if(isnull(here)) + to_chat(user, span_warning("You need to be standing somewhere."), confidential = TRUE) + return + var/list/choices = list() + var/list/groups = list() + for(var/mob/living/carbon/human/npc/guard as anything in stealth_guards_on_level(here.z)) + choices[stealth_guard_summary(guard)] = guard + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + if(stealth_ai.group) + groups["Whole group: [stealth_ai.group.id]"] = stealth_ai.group + if(!length(choices)) + to_chat(user, span_notice("No stealth guards on this z-level."), confidential = TRUE) + return + var/list/all_choices = sort_list(choices) + sort_list(groups) + var/choice = tgui_input_list(user, "Which guard or group?", "Stealth Guards", all_choices) + if(isnull(choice)) + return + if(groups[choice]) + stealth_admin_group(user, groups[choice]) + else if(choices[choice]) + stealth_admin_guard(user, choices[choice]) + BLACKBOX_LOG_ADMIN_VERB("Stealth Guards") + +/proc/stealth_admin_log(client/user, text, atom/where) + log_admin("[key_name(user)] stealth guards: [text][where ? " at [AREACOORD(where)]" : ""]") + message_admins("[key_name_admin(user)] stealth guards: [text][where ? " at [ADMIN_VERBOSEJMP(where)]" : ""]") + +/proc/stealth_admin_guard(client/user, mob/living/carbon/human/npc/guard) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + if(QDELETED(guard) || !istype(stealth_ai)) + return + var/list/actions = list("Force Unaware", "Force Suspicious at my turf", "Force Alert on me", "Force Alert on a mob I pick", "Force Searching at my turf", "Toggle Wary", "Show its sight", "Jump to it", "Next stop") + var/action = tgui_input_list(user, stealth_guard_summary(guard), "Stealth Guard", actions) + if(isnull(action) || QDELETED(guard)) + return + var/turf/here = get_turf(user.mob) + switch(action) + if("Force Unaware") + stealth_ai.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + stealth_ai.stealth_go_unaware() + if("Force Suspicious at my turf") + stealth_ai.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + stealth_ai.stealth_go_suspicious(here) + if("Force Alert on me") + if(!isliving(user.mob)) + to_chat(user, span_warning("You need a living body for that."), confidential = TRUE) + return + stealth_ai.stealth_go_alert(user.mob) + if("Force Alert on a mob I pick") + var/list/mobs = list() + for(var/mob/living/someone in range(HUMAN_NPC_SIGHT_RANGE * 2, guard)) + if(someone != guard) + mobs["[someone] ([REF(someone)])"] = someone + var/picked = tgui_input_list(user, "Alert on whom?", "Stealth Guard", sort_list(mobs)) + if(isnull(picked) || QDELETED(mobs[picked])) + return + stealth_ai.stealth_go_alert(mobs[picked]) + if("Force Searching at my turf") + stealth_ai.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + stealth_ai.stealth_go_searching(here) + if("Toggle Wary") + stealth_ai.blackboard[BB_STEALTH_WARY] = !stealth_ai.blackboard[BB_STEALTH_WARY] + if("Show its sight") + stealth_toggle_sight_overlay(user, guard) + if("Jump to it") + user.mob.forceMove(get_turf(guard)) + if("Next stop") + var/next = stealth_ai.stealth_next_index() + if(next) + stealth_ai.stealth_drop_walk() + stealth_ai.at_stop = FALSE + stealth_ai.route_index = next + stealth_admin_log(user, "[action] on [key_name(guard)]", guard) + +/proc/stealth_admin_group(client/user, datum/stealth_group/group) + var/list/actions = list("Calm all", "Clear wary", "Alert all on me", "Search all at my turf", "Show every route") + var/action = tgui_input_list(user, "[group.id]: [length(group.living_members())] guards", "Stealth Group", actions) + if(isnull(action) || QDELETED(group)) + return + var/turf/here = get_turf(user.mob) + if(action == "Show every route") + stealth_show_routes(user, group) + else + for(var/mob/living/guard as anything in group.living_members()) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + if(!istype(stealth_ai) || guard.stat == DEAD) + continue + switch(action) + if("Calm all") + stealth_ai.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + stealth_ai.stealth_go_unaware() + if("Clear wary") + stealth_ai.blackboard[BB_STEALTH_WARY] = FALSE + if("Alert all on me") + if(isliving(user.mob)) + stealth_ai.stealth_go_alert(user.mob) + if("Search all at my turf") + stealth_ai.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + stealth_ai.stealth_go_searching(here) + stealth_admin_log(user, "[action] on [group.id]", group.home) + +/// Numbered markers on every stop of every route in `group`, for `user` alone, for a minute. +/proc/stealth_show_routes(client/user, datum/stealth_group/group) + var/list/images = list() + for(var/route in group.routes) + var/list/stops = group.routes[route] + for(var/index in 1 to length(stops)) + var/datum/stealth_stop/stop = stops[index] + var/image/marker = image('icons/effects/alphacolors.dmi', stop.spot, "white") + SET_PLANE(marker, ABOVE_LIGHTING_PLANE, stop.spot) + marker.color = stop.chatter ? "#ffaa00" : "#00aaff" + marker.alpha = 110 + marker.maptext = MAPTEXT("[route][index]") + images += marker + user.images |= images + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(stealth_remove_images), WEAKREF(user), images), 60 SECONDS) + +/proc/stealth_remove_images(datum/weakref/user_ref, list/images) + var/client/user = user_ref?.resolve() + user?.images -= images + +// ===== Sight overlay ===== + +/// Admins watching one guard's sight: admin ckey => overlay +GLOBAL_LIST_EMPTY(stealth_sight_overlays) + +/proc/stealth_toggle_sight_overlay(client/user, mob/living/carbon/human/npc/guard) + var/datum/stealth_sight_overlay/old = GLOB.stealth_sight_overlays[user.ckey] + var/same = old?.guard_ref?.resolve() == guard + if(old) + qdel(old) + if(same) + return + new /datum/stealth_sight_overlay(user, guard) + +/** + * The tiles one guard sees, shown to one admin: green for its lit cone, blue for how far it sees into + * the dark, yellow for the close radius it feels all round. Rebuilt each scan while watched; ends when + * the guard dies, on a second toggle, or after STEALTH_ADMIN_OVERLAY_TIME. + */ +/datum/stealth_sight_overlay + var/datum/weakref/user_ref + var/datum/weakref/guard_ref + var/ckey + var/list/image/images = list() + +/datum/stealth_sight_overlay/New(client/user, mob/living/carbon/human/npc/guard) + user_ref = WEAKREF(user) + guard_ref = WEAKREF(guard) + ckey = user.ckey + GLOB.stealth_sight_overlays[ckey] = src + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + LAZYADD(stealth_ai.watchers, src) + RegisterSignal(guard, COMSIG_LIVING_DEATH, PROC_REF(on_guard_gone)) + RegisterSignal(guard, COMSIG_QDELETING, PROC_REF(on_guard_gone)) + QDEL_IN(src, STEALTH_ADMIN_OVERLAY_TIME) + refresh() + +/datum/stealth_sight_overlay/Destroy() + clear() + if(GLOB.stealth_sight_overlays[ckey] == src) + GLOB.stealth_sight_overlays -= ckey + var/mob/living/carbon/human/npc/guard = guard_ref?.resolve() + if(guard) + UnregisterSignal(guard, list(COMSIG_LIVING_DEATH, COMSIG_QDELETING)) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + if(istype(stealth_ai)) + LAZYREMOVE(stealth_ai.watchers, src) + return ..() + +/datum/stealth_sight_overlay/proc/on_guard_gone(datum/source) + SIGNAL_HANDLER + qdel(src) + +/datum/stealth_sight_overlay/proc/clear() + var/client/user = user_ref?.resolve() + user?.images -= images + images.Cut() + +/datum/stealth_sight_overlay/proc/refresh() + clear() + var/client/user = user_ref?.resolve() + var/mob/living/carbon/human/npc/guard = guard_ref?.resolve() + if(isnull(user) || QDELETED(guard)) + return + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + if(!istype(stealth_ai)) + return + var/turf/center = get_turf(guard) + if(isnull(center)) + return + var/eyes = stealth_ai.stealth_eyes_open() + var/half_angle = stealth_ai.stealth_half_angle() + var/night = HAS_TRAIT(guard, TRAIT_NIGHT_VISION) + for(var/turf/tile as anything in RANGE_TURFS(STEALTH_SIGHT_RANGE, center)) + var/dist = get_dist(center, tile) + var/colour + if(eyes && stealth_in_cone(guard, tile, half_angle) && can_see(center, tile, STEALTH_SIGHT_RANGE)) + if(dist <= STEALTH_DARK_SIGHT_RANGE || night) + colour = "#3399ff" + else + colour = "#33cc33" + if(dist <= STEALTH_CLOSE_RANGE) + colour = colour || "#ffcc00" + if(isnull(colour)) + continue + var/image/marker = image('icons/effects/alphacolors.dmi', tile, "white") + SET_PLANE(marker, ABOVE_LIGHTING_PLANE, tile) + marker.color = colour + marker.alpha = 70 + images += marker + user.images |= images diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm new file mode 100644 index 00000000000..b766d7e25e5 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -0,0 +1,805 @@ +/** + * # Stealth guards: awareness + * + * A human NPC type opts in with `ai_controller = /datum/ai_controller/basic_controller/human_npc/stealth`. + * Nothing changes for any other human NPC (owner decision 4). + * + * The guard is unaware, suspicious, alert or searching (BB_STEALTH_STATE). That is AI state only: the + * body takes damage, wounds, stuns and crit through tg exactly as before, and players never get a state. + * + * - Unaware: walks its patrol (stealth_patrol.dm) or stands its post. + * - Suspicious: saw something. Turns to it, says so, stares a moment, walks over and looks around, then + * gives up and goes back to its route. + * - Alert: has a target and fights as every human NPC does. It keeps the target all round with tg's + * can_attack() (no cone, no darkness); out of sight for STEALTH_LOSE_TARGET_TIME, it searches. + * - Searching: runs to where it last saw someone and sweeps the spots round it, then gives up. + * + * Wary (BB_STEALTH_WARY) is set by any alert, search, hit or surrender and is never cleared: a wider cone + * and quicker notice for the rest of its life (abuse review P4). + * + * Every attack or touch gets a reaction, even from out of sight (P3): alert on the attacker if it can see + * them, otherwise a search at their turf. Detection is a once-a-second scan owned by this controller, never + * tg's movement-triggered target field (P1). Nothing here runs while the AI is off (no player on the + * level); timers are world.time stamps, so a guard that wakes after its search ran out steps straight + * back to unaware and stays wary (T1). + */ +/datum/ai_controller/basic_controller/human_npc/stealth + blackboard = list( + BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/human_npc, + BB_TARGET_MINIMUM_STAT = HARD_CRIT, + BB_AGGRO_RANGE = HUMAN_NPC_SIGHT_RANGE, + BB_HUMAN_NPC_SHOT_DELAY = 3 SECONDS, + BB_HUMAN_NPC_FIRE_RANGE = 7, + BB_HUMAN_NPC_KEEP_AWAY = 2, + BB_STEALTH_STATE = STEALTH_UNAWARE, + ) + // The patrol subtree decides what an unaware guard does; no random walk. + idle_behavior = null + ai_movement = /datum/ai_movement/jps/stealth + planning_subtrees = list( + /datum/ai_planning_subtree/human_npc_soft_crit, + /datum/ai_planning_subtree/escape_captivity, + /datum/ai_planning_subtree/human_npc_walk_out, + /datum/ai_planning_subtree/human_npc_surrender, + /datum/ai_planning_subtree/stealth_perception, + /datum/ai_planning_subtree/stealth_react, + /datum/ai_planning_subtree/human_npc_arm, + /datum/ai_planning_subtree/human_npc_shoot, + /datum/ai_planning_subtree/human_npc_melee, + /datum/ai_planning_subtree/stealth_patrol, + ) + /// Its patrol group (stealth_patrol.dm) + var/datum/stealth_group/group + /// Whether it has joined a group and claimed a route + var/stealth_ready = FALSE + /// The route id it walks, or null for a sentry + var/route_id + /// Index of the stop it is heading for or standing at + var/route_index = 1 + /// +1 or -1 along the route + var/route_step = 1 + /// The way a sentry faces at its post + var/sentry_dir = SOUTH + /// Stop index => failed tries to reach it + var/list/stop_fails = list() + /// Stop index => world.time it may be tried again + var/list/stop_skip_until = list() + /// world.time it leaves the stop it stands at + var/wait_until = 0 + /// Whether it has done its arrival at the current stop + var/at_stop = FALSE + /// Where its current stealth walk goes + var/turf/goto_turf + /// What that walk is for (STEALTH_GOTO_*) + var/goto_purpose + /// "arrived" or "failed" once the walk is over, else null + var/goto_result + /// Set while it drops its own walk, so a dropped walk doesn't count as a failure + var/dropping_walk = FALSE + /// world.time its current walk began + var/goto_started = 0 + /// Set when a walk ran out of time + var/goto_timed_out = FALSE + /// world.time its current look round ends + var/look_until = 0 + /// The way it faces while standing (a stop's facing, a sentry's post, where it saw something) + var/stand_dir = SOUTH + /// world.time it may next turn its head while standing + var/next_turn = 0 + /// Suspicious: where it walks to look + var/turf/investigate_turf + /// Suspicious: whether it has walked over and looked + var/investigated = FALSE + /// world.time of the last notice gain on its focus (suspicion holds STEALTH_SUSPICIOUS_TIMEOUT after it) + var/last_gain = 0 + /// Searching: the spot it searches round + var/turf/search_center + /// Searching: the spots still to check + var/list/search_queue = list() + /// Searching: whether it is looking round at the spot it reached + var/search_looking = FALSE + /// world.time of its next search line + var/next_search_bark = 0 + /// Alert: world.time it first failed to see its target in this stretch, or 0 + var/lost_since = 0 + /// world.time of its next look for fallen friends + var/next_body_scan = 0 + /// Bark kind => world.time it may say that kind again + var/list/bark_ready_at = list() + /// Its stat at the last change, to tell recovery from crit + var/last_stat = CONSCIOUS + /// Admins watching its sight overlay (stealth_admin.dm) + var/list/datum/stealth_sight_overlay/watchers + +/datum/ai_controller/basic_controller/human_npc/stealth/TryPossessPawn(atom/new_pawn) + . = ..() + if(. & AI_CONTROLLER_INCOMPATIBLE) + return + blackboard[BB_STEALTH_NOTICE] = list() + blackboard[BB_STEALTH_BODIES_SEEN] = list() + blackboard[BB_STEALTH_STATE_SINCE] = world.time + RegisterSignal(new_pawn, COMSIG_LIVING_GET_PULLED, PROC_REF(on_pulled)) + RegisterSignal(new_pawn, COMSIG_ATOM_BUMPED, PROC_REF(on_bumped)) + RegisterSignal(new_pawn, COMSIG_CARBON_HELP_ACT, PROC_REF(on_helped)) + RegisterSignal(new_pawn, COMSIG_PROJECTILE_PREHIT, PROC_REF(on_projectile_prehit)) + RegisterSignal(new_pawn, COMSIG_MOVABLE_Z_CHANGED, PROC_REF(on_z_changed)) + RegisterSignal(new_pawn, COMSIG_LIVING_STATUS_REMOVED, PROC_REF(on_status_removed)) + RegisterSignal(new_pawn, COMSIG_AI_BLACKBOARD_KEY_SET(BB_BASIC_MOB_CURRENT_TARGET), PROC_REF(on_target_set)) + +/datum/ai_controller/basic_controller/human_npc/stealth/UnpossessPawn(destroy) + if(pawn) + UnregisterSignal(pawn, list( + COMSIG_LIVING_GET_PULLED, + COMSIG_ATOM_BUMPED, + COMSIG_CARBON_HELP_ACT, + COMSIG_PROJECTILE_PREHIT, + COMSIG_MOVABLE_Z_CHANGED, + COMSIG_LIVING_STATUS_REMOVED, + COMSIG_AI_BLACKBOARD_KEY_SET(BB_BASIC_MOB_CURRENT_TARGET), + )) + group?.remove_member(pawn) + group = null + for(var/datum/stealth_sight_overlay/overlay as anything in watchers?.Copy()) + qdel(overlay) + watchers = null + goto_turf = null + investigate_turf = null + search_center = null + search_queue = null + return ..() + +// ===== State ===== + +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_state() + return blackboard[BB_STEALTH_STATE] + +/// Changes state, stamping the time, and drops whatever walk it was on. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_set_state(new_state) + var/old_state = blackboard[BB_STEALTH_STATE] + if(old_state == STEALTH_UNAWARE && new_state != STEALTH_UNAWARE) + blackboard[BB_STEALTH_UNAWARE_LOST_AT] = world.time + blackboard[BB_STEALTH_STATE] = new_state + blackboard[BB_STEALTH_STATE_SINCE] = world.time + look_until = 0 + lost_since = 0 + stealth_drop_walk() + var/run = (new_state == STEALTH_ALERT || new_state == STEALTH_SEARCHING) + stealth_set_pace(run) + human_npc_set_ai_movement(src, new_state == STEALTH_ALERT ? /datum/ai_movement/basic_avoidance : /datum/ai_movement/jps/stealth) + for(var/datum/stealth_sight_overlay/overlay as anything in watchers) + overlay.refresh() + +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_set_wary() + blackboard[BB_STEALTH_WARY] = TRUE + +/// Walks (calm) or runs, through tg's own move intent, as bounty_ai_set_pace() does. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_set_pace(run) + var/mob/living/body = pawn + if(!isliving(body) || QDELETED(body)) + return + if(run != (body.move_intent == MOVE_INTENT_RUN)) + body.toggle_move_intent() + +/// Ends its own stealth walk, if it has one, without counting it as a failed path. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_drop_walk() + var/datum/ai_behavior/walk = GET_AI_BEHAVIOR(/datum/ai_behavior/stealth_goto) + if(walk && current_behaviors[walk]) + dropping_walk = TRUE + fail_behavior(walk) + dropping_walk = FALSE + goto_turf = null + goto_result = null + +/// `where` pulled back to within STEALTH_LEASH_RANGE of home (abuse R3). Null if nowhere sensible. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_leash(turf/where) + var/turf/home = blackboard[BB_STEALTH_HOME_TURF] + if(isnull(where) || isnull(home) || where.z != home.z) + return where + if(get_dist(home, where) <= STEALTH_LEASH_RANGE) + return where + var/turf/clamped = get_ranged_target_turf_direct(home, where, STEALTH_LEASH_RANGE) + if(isnull(clamped) || clamped.is_blocked_turf(exclude_mobs = TRUE)) + return null + return clamped + +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_go_unaware() + var/list/notice = blackboard[BB_STEALTH_NOTICE] + notice?.Cut() + clear_blackboard_key(BB_STEALTH_FOCUS) + search_queue?.Cut() + stealth_set_state(STEALTH_UNAWARE) + stealth_rejoin_route() + +/// Suspicious of something at `where`. `purpose` is STEALTH_GOTO_INVESTIGATE or STEALTH_GOTO_BODY. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_go_suspicious(turf/where, purpose = STEALTH_GOTO_INVESTIGATE) + var/mob/living/body = pawn + stealth_set_state(STEALTH_SUSPICIOUS) + goto_purpose = purpose + investigate_turf = stealth_leash(where) + investigated = FALSE + last_gain = world.time + set_blackboard_key(BB_STEALTH_LAST_SEEN_TURF, where) + blackboard[BB_STEALTH_LAST_SEEN_AT] = world.time + if(where && get_turf(body) != where) + stand_dir = get_dir(body, where) + body.setDir(stand_dir) + stealth_bark(purpose == STEALTH_GOTO_BODY ? STEALTH_BARK_BODY : STEALTH_BARK_SUSPICIOUS) + +/// Searching round `where`. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_go_searching(turf/where) + stealth_set_wary() + if(isnull(where)) + where = get_turf(pawn) + stealth_set_state(STEALTH_SEARCHING) + search_center = stealth_leash(where) || get_turf(pawn) + search_queue = stealth_search_spots(search_center) + search_looking = FALSE + next_search_bark = world.time + STEALTH_SEARCH_BARK_INTERVAL + set_blackboard_key(BB_STEALTH_LAST_SEEN_TURF, where) + blackboard[BB_STEALTH_LAST_SEEN_AT] = world.time + +/// Alert on `target` (a mob, or the mech or vehicle someone sits in). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_go_alert(atom/target) + if(QDELETED(target)) + return + if(stealth_state() != STEALTH_ALERT) + stealth_set_state(STEALTH_ALERT) + stealth_set_wary() + set_blackboard_key(BB_STEALTH_FOCUS, target) + set_blackboard_key(BB_STEALTH_LAST_SEEN_TURF, get_turf(target)) + blackboard[BB_STEALTH_LAST_SEEN_AT] = world.time + set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, target) + +/// The spots a search checks: the centre first, then a few open tiles round it in its line of sight. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_search_spots(turf/center) + . = list() + if(isnull(center)) + return + . += center + var/list/pool = list() + var/datum/region = map_region_for_turf(center) + for(var/turf/open/spot in RANGE_TURFS(STEALTH_SEARCH_RADIUS, center)) + if(spot == center || spot.is_blocked_turf(exclude_mobs = TRUE)) + continue + if(map_region_excludes_turf(region, spot) || !stealth_leash(spot)) + continue + pool += spot + var/picked = 0 + while(length(pool) && picked < STEALTH_SEARCH_POINTS) + var/turf/spot = pick_n_take(pool) + if(!can_see(center, spot, STEALTH_SEARCH_RADIUS)) + continue + . += spot + picked++ + +/// Says a stealth line, at most once per STEALTH_BARK_KIND_COOLDOWN for each kind (abuse P14). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_bark(kind) + var/mob/living/carbon/human/npc/body = pawn + if(!ishumannpc(body) || body.stat != CONSCIOUS) + return FALSE + if(world.time < bark_ready_at[kind]) + return FALSE + bark_ready_at[kind] = world.time + STEALTH_BARK_KIND_COOLDOWN + return body.npc_bark(kind, force = TRUE) + +/// Moves every awareness timestamp back by `time`, as if that long had passed (unit tests, admin tools). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_rewind(time) + blackboard[BB_STEALTH_STATE_SINCE] -= time + if(blackboard[BB_STEALTH_LAST_SEEN_AT]) + blackboard[BB_STEALTH_LAST_SEEN_AT] -= time + if(blackboard[BB_STEALTH_UNAWARE_LOST_AT]) + blackboard[BB_STEALTH_UNAWARE_LOST_AT] -= time + last_gain -= time + if(lost_since) + lost_since -= time + wait_until -= time + look_until -= time + next_body_scan -= time + for(var/kind in bark_ready_at) + bark_ready_at[kind] -= time + +// ===== The scan ===== + +/** + * One scan: expires a suspicion or search whose time has run out (also how a guard catches up after + * sleeping), keeps an alert guard's target, or looks for someone new and for fallen friends. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_scan_once() + var/mob/living/carbon/human/guard = pawn + if(QDELETED(guard) || guard.stat != CONSCIOUS) + return + stealth_setup() + var/state = stealth_state() + if(state == STEALTH_SEARCHING && world.time - blackboard[BB_STEALTH_STATE_SINCE] >= STEALTH_SEARCH_TIME) + stealth_bark(STEALTH_BARK_GIVE_UP) + stealth_go_unaware() + else if(state == STEALTH_SUSPICIOUS && world.time - last_gain >= STEALTH_SUSPICIOUS_TIMEOUT) + stealth_bark(STEALTH_BARK_GIVE_UP) + stealth_go_unaware() + if(stealth_state() == STEALTH_ALERT) + stealth_keep_target() + else + stealth_look() + if(stealth_state() != STEALTH_ALERT && world.time >= next_body_scan) + stealth_check_bodies() + for(var/datum/stealth_sight_overlay/overlay as anything in watchers) + overlay.refresh() + +/// The cone half-angle it sees with now. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_half_angle() + if(stealth_state() == STEALTH_SEARCHING) + return STEALTH_SEARCH_HALF_ANGLE + if(blackboard[BB_STEALTH_WARY]) + return STEALTH_WARY_HALF_ANGLE + return STEALTH_CONE_HALF_ANGLE + +/// Whether its eyes work: not blind, not lying down (the close radius still works either way). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_eyes_open() + var/mob/living/guard = pawn + return !guard.is_blind() && guard.body_position != LYING_DOWN + +/// How far it sees onto `tile` in its cone: shorter in the dark unless it sees in the dark. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_range_onto(turf/tile) + if(!HAS_TRAIT(pawn, TRAIT_NIGHT_VISION) && stealth_tile_is_dark(tile)) + return STEALTH_DARK_SIGHT_RANGE + return STEALTH_SIGHT_RANGE + +/// Looks for someone new: raises notice on whoever it perceives, decays the rest, changes state. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_look() + var/mob/living/carbon/human/guard = pawn + var/list/notice = blackboard[BB_STEALTH_NOTICE] + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) + if(isnull(strategy) || !isturf(guard.loc)) + return + var/state = stealth_state() + var/wary = blackboard[BB_STEALTH_WARY] + var/atom/focus = blackboard[BB_STEALTH_FOCUS] + var/eyes = stealth_eyes_open() + var/half_angle = stealth_half_angle() + var/scan_seconds = STEALTH_SCAN_INTERVAL / (1 SECONDS) + var/list/perceived = list() + for(var/mob/living/candidate as anything in stealth_candidates(guard, HUMAN_NPC_SIGHT_RANGE)) + // A mech or vehicle is never hidden: seen all round, no darkness, straight to alert (abuse P9). + var/atom/vehicle = stealth_vehicle_of(candidate) + if(vehicle) + if(strategy.can_attack(guard, vehicle, HUMAN_NPC_SIGHT_RANGE)) + stealth_go_alert(vehicle) + return + continue + // In a locker, a crate or anything else: unseen. + if(!isturf(candidate.loc)) + continue + var/turf/where = candidate.loc + var/dist = get_dist(guard, where) + if(dist > STEALTH_SIGHT_RANGE) + continue + if(!strategy.can_attack(guard, candidate, STEALTH_SIGHT_RANGE)) + continue + var/rate = 0 + if(eyes && !stealth_is_cloaked(candidate) && stealth_in_cone(guard, where, half_angle)) + var/cap = stealth_range_onto(where) + if(dist <= cap) + rate = STEALTH_NOTICE_RATE * clamp((cap + 1 - dist) / cap, STEALTH_NOTICE_MIN_FALLOFF, 1) + if(cap < STEALTH_SIGHT_RANGE) + rate *= STEALTH_DARK_MULT + var/felt = FALSE + if(!rate && dist <= STEALTH_CLOSE_RANGE) + // At its shoulder: light doesn't matter (abuse P7). + rate = STEALTH_BEHIND_RATE + felt = TRUE + if(!rate) + continue + var/key = REF(candidate) + var/list/entry = notice[key] + if(isnull(entry)) + entry = list(0, null, 0) + notice[key] = entry + // First seen counts as moving: it just came into view. + var/moved = entry[STEALTH_ENTRY_TURF] != where + // STEP 2 STAND-IN: move intent stands in for "running is loud" until real footstep hearing lands. + var/running = moved && candidate.move_intent == MOVE_INTENT_RUN + if(running) + rate *= STEALTH_RUN_MULT + else if(!moved) + rate *= STEALTH_STILL_MULT + if(candidate.body_position == LYING_DOWN) + rate *= STEALTH_LYING_MULT + if(state == STEALTH_SUSPICIOUS && focus == candidate) + rate *= STEALTH_SUSPICIOUS_MULT + if(state == STEALTH_SEARCHING) + rate *= STEALTH_SEARCHING_MULT + if(wary) + rate *= STEALTH_WARY_MULT + entry[STEALTH_ENTRY_NOTICE] += rate * scan_seconds + if(felt && running) + entry[STEALTH_ENTRY_NOTICE] = max(entry[STEALTH_ENTRY_NOTICE], STEALTH_SUSPICIOUS_AT) + guard.setDir(get_dir(guard, where)) + entry[STEALTH_ENTRY_TURF] = where + entry[STEALTH_ENTRY_SEEN_AT] = world.time + perceived[key] = candidate + // Decay whoever it didn't perceive; forget anyone unseen for long enough. + var/best_key + var/best_notice = 0 + for(var/key in notice) + var/list/entry = notice[key] + if(!perceived[key]) + entry[STEALTH_ENTRY_NOTICE] = max(0, entry[STEALTH_ENTRY_NOTICE] - STEALTH_NOTICE_DECAY * scan_seconds) + if(world.time - entry[STEALTH_ENTRY_SEEN_AT] > STEALTH_NOTICE_FORGET) + notice -= key + continue + if(entry[STEALTH_ENTRY_NOTICE] > best_notice) + best_notice = entry[STEALTH_ENTRY_NOTICE] + best_key = key + if(isnull(best_key)) + clear_blackboard_key(BB_STEALTH_FOCUS) + return + var/mob/living/best = perceived[best_key] || locate(best_key) + if(!isliving(best) || QDELETED(best)) + notice -= best_key + return + set_blackboard_key(BB_STEALTH_FOCUS, best) + var/list/best_entry = notice[best_key] + var/turf/best_turf = best_entry[STEALTH_ENTRY_TURF] + var/seen_now = !!perceived[best_key] + switch(state) + if(STEALTH_UNAWARE) + if(best_notice >= STEALTH_SUSPICIOUS_AT) + stealth_go_suspicious(best_turf) + if(STEALTH_SUSPICIOUS, STEALTH_SEARCHING) + if(!seen_now) + return + // No alert by sight from off-screen (abuse P8). + if(best_notice >= STEALTH_ALERT_AT && get_dist(guard, best_turf) <= STEALTH_ALERT_MAX_RANGE) + stealth_go_alert(best) + return + if(state == STEALTH_SEARCHING) + if(best_notice >= STEALTH_SUSPICIOUS_AT) + stealth_go_suspicious(best_turf) + return + last_gain = world.time + set_blackboard_key(BB_STEALTH_LAST_SEEN_TURF, best_turf) + blackboard[BB_STEALTH_LAST_SEEN_AT] = world.time + +/** + * Alert: keeps its target with tg's all-round can_attack() at the NPC's sight range (abuse P2). Out of + * sight for STEALTH_LOSE_TARGET_TIME, it searches where it last saw them, not where they are now. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_keep_target() + var/mob/living/guard = pawn + var/atom/target = blackboard[BB_BASIC_MOB_CURRENT_TARGET] + var/atom/remembered = target || blackboard[BB_STEALTH_FOCUS] + if(QDELETED(remembered)) + stealth_go_searching(blackboard[BB_STEALTH_LAST_SEEN_TURF]) + return + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) + if(strategy?.can_attack(guard, remembered, HUMAN_NPC_SIGHT_RANGE)) + lost_since = 0 + set_blackboard_key(BB_STEALTH_LAST_SEEN_TURF, get_turf(remembered)) + blackboard[BB_STEALTH_LAST_SEEN_AT] = world.time + if(!target) + set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, remembered) + return + // In plain sight but no longer worth fighting (down, dead, an ally now): look round where they fell. + if(get_dist(guard, remembered) <= HUMAN_NPC_SIGHT_RANGE && can_see(guard, remembered, HUMAN_NPC_SIGHT_RANGE)) + clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + clear_blackboard_key(BB_STEALTH_FOCUS) + stealth_go_searching(get_turf(remembered)) + return + if(!lost_since) + lost_since = world.time + if(world.time - lost_since < STEALTH_LOSE_TARGET_TIME) + return + clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + stealth_bark(STEALTH_BARK_LOST) + stealth_go_searching(blackboard[BB_STEALTH_LAST_SEEN_TURF]) + +/** + * Fallen friends (abuse P13): group members that are dead, in crit, cuffed or lying down, in its sight. + * It reacts to each body once. The first guard to find one is suspicious and walks over; a guard that + * finds a body someone already reported just searches there. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_check_bodies() + next_body_scan = world.time + STEALTH_BODY_SCAN_INTERVAL + if(isnull(group)) + return + var/mob/living/guard = pawn + var/list/seen = blackboard[BB_STEALTH_BODIES_SEEN] + var/eyes = stealth_eyes_open() + var/half_angle = stealth_half_angle() + for(var/mob/living/member as anything in group.living_members()) + if(member == guard) + continue + if(!(member.stat == DEAD || HAS_TRAIT(member, TRAIT_CRITICAL_CONDITION) || HAS_TRAIT(member, TRAIT_RESTRAINED) || member.body_position == LYING_DOWN)) + continue + var/key = REF(member) + if(key in seen) + continue + var/turf/where = get_turf(member) + if(isnull(where) || where.z != guard.z) + continue + var/dist = get_dist(guard, where) + if(dist > STEALTH_SIGHT_RANGE) + continue + var/in_sight = dist <= STEALTH_CLOSE_RANGE + if(!in_sight && eyes && stealth_in_cone(guard, where, half_angle)) + in_sight = dist <= stealth_range_onto(where) + if(!in_sight || !can_see(guard, where, STEALTH_SIGHT_RANGE)) + continue + seen += key + if((key in group.reported_bodies) || stealth_state() == STEALTH_SEARCHING) + stealth_go_searching(where) + else + group.reported_bodies += key + stealth_go_suspicious(where, STEALTH_GOTO_BODY) + return + +// ===== Touches, hits and recovery ===== + +/** + * Anyone touching or hurting it (abuse P3): alert on them if it can see them, otherwise a search at + * their turf. Always wary. Allies are ignored. Returns TRUE if it took a target. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_touched(atom/source) + var/mob/living/guard = pawn + if(QDELETED(source) || QDELETED(guard) || source == guard || guard.stat == DEAD) + return FALSE + if(ismovable(source) && guard.faction_check_atom(source)) + return FALSE + stealth_set_wary() + if(stealth_state() == STEALTH_ALERT && blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + return FALSE + var/atom/who = isliving(source) ? bounty_ai_target_for(source) : source + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) + if(strategy?.can_attack(guard, who)) + stealth_go_alert(who) + return TRUE + stealth_go_searching(get_turf(source)) + stealth_bark(STEALTH_BARK_HIT_UNSEEN) + return FALSE + +/datum/ai_controller/basic_controller/human_npc/stealth/on_pawn_attacked(mob/living/source, atom/attacker, attack_flags) + if(stealth_touched(attacker)) + return + if(!blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + return ..() + +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_pulled(mob/living/source, atom/movable/puller) + SIGNAL_HANDLER + stealth_touched(puller) + +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_bumped(atom/source, atom/movable/bumper) + SIGNAL_HANDLER + if(isliving(bumper)) + stealth_touched(bumper) + +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_helped(mob/living/source, mob/living/helper) + SIGNAL_HANDLER + stealth_touched(helper) + +/// relay_attackers only reports a mob firer; a turret or other machine shooting it counts the same. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_projectile_prehit(atom/source, obj/projectile/hit_projectile) + SIGNAL_HANDLER + if(!hit_projectile.is_hostile_projectile() || isnull(hit_projectile.firer) || ismob(hit_projectile.firer)) + return + stealth_touched(hit_projectile.firer) + +/// Anything else that sets a target (an admin, another subtree) makes it alert. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_target_set(datum/source) + SIGNAL_HANDLER + var/atom/target = blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(isnull(target) || stealth_state() == STEALTH_ALERT) + return + stealth_set_state(STEALTH_ALERT) + stealth_set_wary() + set_blackboard_key(BB_STEALTH_FOCUS, target) + +/// Carried off the level: drops its route and holds where it is (abuse R3). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_z_changed(datum/source) + SIGNAL_HANDLER + stealth_become_sentry(get_turf(pawn)) + +/datum/ai_controller/basic_controller/human_npc/stealth/on_stat_changed(mob/living/source, new_stat) + . = ..() + var/was = last_stat + last_stat = new_stat + if(new_stat == CONSCIOUS && was != CONSCIOUS && was != DEAD) + stealth_came_round() + +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_status_removed(mob/living/source, datum/status_effect/effect) + SIGNAL_HANDLER + if(istype(effect, /datum/status_effect/incapacitating/stamcrit)) + stealth_came_round() + +/// Back on its feet after crit or stamcrit: it knows something happened. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_came_round() + var/mob/living/guard = pawn + if(QDELETED(guard) || guard.stat == DEAD) + return + stealth_set_wary() + if(blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + return + stealth_go_searching(get_turf(guard)) + +// A guard that gives up is wary from then on. +/mob/living/carbon/human/npc/npc_surrender() + . = ..() + if(.) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = ai_controller + if(istype(stealth_ai)) + stealth_ai.stealth_set_wary() + +/** + * Step 3 hook. TRUE if this guard was unaware when the current blow began: unaware now, or it stopped + * being unaware during this same tick (relay_attackers flips it before damage for hands and bullets, + * abuse P12). FALSE for any NPC without the stealth controller. + */ +/mob/living/carbon/human/npc/proc/stealth_was_unaware() + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = ai_controller + if(!istype(stealth_ai)) + return FALSE + if(stealth_ai.stealth_state() == STEALTH_UNAWARE) + return TRUE + return stealth_ai.blackboard[BB_STEALTH_UNAWARE_LOST_AT] == world.time + +// ===== Planning ===== + +/// Pathfinding movement with room for a long patrol leg. +/datum/ai_movement/jps/stealth + maximum_length = STEALTH_PATROL_MAX_PATH + +/// Queues the scan every plan. Never ends planning. +/datum/ai_planning_subtree/stealth_perception + +/datum/ai_planning_subtree/stealth_perception/SelectBehaviors(datum/ai_controller/basic_controller/human_npc/stealth/controller, seconds_per_tick) + var/mob/living/guard = controller.pawn + if(guard.stat != CONSCIOUS || !istype(controller)) + return + controller.stealth_setup() + controller.queue_behavior(/datum/ai_behavior/stealth_scan) + +/datum/ai_behavior/stealth_scan + action_cooldown = STEALTH_SCAN_INTERVAL + behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/stealth_scan/perform(seconds_per_tick, datum/ai_controller/basic_controller/human_npc/stealth/controller) + if(istype(controller)) + controller.stealth_scan_once() + return AI_BEHAVIOR_DELAY + +/// Suspicious: stare, walk over, look round. Searching: sweep the spots. Ends planning while it acts. +/datum/ai_planning_subtree/stealth_react + +/datum/ai_planning_subtree/stealth_react/SelectBehaviors(datum/ai_controller/basic_controller/human_npc/stealth/controller, seconds_per_tick) + if(!istype(controller) || controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + return + var/mob/living/guard = controller.pawn + switch(controller.stealth_state()) + if(STEALTH_SUSPICIOUS) + if(world.time < controller.blackboard[BB_STEALTH_STATE_SINCE] + STEALTH_INVESTIGATE_DELAY) + controller.queue_behavior(/datum/ai_behavior/stealth_stand) + return SUBTREE_RETURN_FINISH_PLANNING + if(!controller.investigated) + var/turf/dest = controller.investigate_turf + if(dest && get_turf(guard) != dest && controller.goto_result != "failed") + controller.stealth_walk(dest, controller.goto_purpose) + return SUBTREE_RETURN_FINISH_PLANNING + controller.investigated = TRUE + controller.stealth_drop_walk() + if(controller.goto_purpose == STEALTH_GOTO_BODY) + controller.stealth_go_searching(get_turf(guard)) + return SUBTREE_RETURN_FINISH_PLANNING + controller.look_until = world.time + STEALTH_LOOK_AROUND_TIME + controller.queue_behavior(/datum/ai_behavior/stealth_stand) + return SUBTREE_RETURN_FINISH_PLANNING + if(STEALTH_SEARCHING) + if(world.time >= controller.next_search_bark) + controller.next_search_bark = world.time + STEALTH_SEARCH_BARK_INTERVAL + controller.stealth_bark(STEALTH_BARK_SEARCH) + if(controller.search_looking) + if(world.time < controller.look_until) + controller.queue_behavior(/datum/ai_behavior/stealth_stand) + return SUBTREE_RETURN_FINISH_PLANNING + controller.search_looking = FALSE + if(length(controller.search_queue)) + controller.search_queue.Cut(1, 2) + if(!length(controller.search_queue)) + controller.search_queue = controller.stealth_search_spots(controller.search_center) + if(!length(controller.search_queue)) + controller.queue_behavior(/datum/ai_behavior/stealth_stand) + return SUBTREE_RETURN_FINISH_PLANNING + var/turf/spot = controller.search_queue[1] + if(get_turf(guard) == spot || (controller.goto_turf == spot && controller.goto_result)) + controller.stealth_drop_walk() + controller.search_looking = TRUE + controller.look_until = world.time + STEALTH_LOOK_AROUND_TIME + controller.queue_behavior(/datum/ai_behavior/stealth_stand) + return SUBTREE_RETURN_FINISH_PLANNING + controller.stealth_walk(spot, STEALTH_GOTO_SEARCH) + return SUBTREE_RETURN_FINISH_PLANNING + +/// Starts (or keeps) its stealth walk to `dest`. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_walk(turf/dest, purpose) + var/datum/ai_behavior/walk = GET_AI_BEHAVIOR(/datum/ai_behavior/stealth_goto) + if(goto_turf != dest && current_behaviors[walk]) + stealth_drop_walk() + if(goto_turf != dest) + goto_result = null + goto_turf = dest + goto_purpose = purpose + queue_behavior(/datum/ai_behavior/stealth_goto) + +/** + * Walks to the controller's goto_turf with its pathfinding movement. Ends on arrival, or as a failure + * when the pathfinder gives up or the leg takes far too long (abuse R2). + */ +/datum/ai_behavior/stealth_goto + required_distance = 0 + action_cooldown = 0.5 SECONDS + behavior_flags = AI_BEHAVIOR_REQUIRE_MOVEMENT | AI_BEHAVIOR_MOVE_AND_PERFORM | AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/stealth_goto/setup(datum/ai_controller/basic_controller/human_npc/stealth/controller) + . = ..() + if(!istype(controller) || isnull(controller.goto_turf)) + return FALSE + controller.goto_started = world.time + set_movement_target(controller, controller.goto_turf) + +/datum/ai_behavior/stealth_goto/perform(seconds_per_tick, datum/ai_controller/basic_controller/human_npc/stealth/controller) + var/turf/dest = controller.goto_turf + if(isnull(dest)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + var/turf/here = get_turf(controller.pawn) + if(here == dest) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + // Someone stands on the spot: next to it will do. + if(get_dist(here, dest) <= 1 && dest.is_blocked_turf(exclude_mobs = FALSE) && !dest.is_blocked_turf(exclude_mobs = TRUE)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + if(world.time - controller.goto_started > STEALTH_PATROL_MAX_PATH * max(controller.movement_delay, 0.4 SECONDS) * 1.5) + controller.goto_timed_out = TRUE + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_INSTANT + +/datum/ai_behavior/stealth_goto/finish_action(datum/ai_controller/basic_controller/human_npc/stealth/controller, succeeded) + if(istype(controller) && !controller.dropping_walk) + if(succeeded) + controller.goto_result = "arrived" + else + // Only a real path failure counts; being re-planned away from a walk does not. + var/path_failed = controller.goto_timed_out || controller.consecutive_pathing_attempts >= controller.ai_movement.max_pathing_attempts + if(path_failed) + controller.goto_result = "failed" + controller.stealth_walk_failed() + controller.goto_timed_out = FALSE + return ..() + +/** + * Standing: at a stop, a sentry's post, staring at something, or looking round. Turns its head now and + * then. Never finishes by itself; planning replaces it. + */ +/datum/ai_behavior/stealth_stand + action_cooldown = 1 SECONDS + behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/stealth_stand/perform(seconds_per_tick, datum/ai_controller/basic_controller/human_npc/stealth/controller) + var/mob/living/guard = controller.pawn + if(!istype(controller) || guard.stat != CONSCIOUS || !isturf(guard.loc)) + return AI_BEHAVIOR_DELAY + if(world.time < controller.look_until) + // Looking round: two other ways over STEALTH_LOOK_AROUND_TIME. + if(world.time >= controller.next_turn) + controller.next_turn = world.time + STEALTH_LOOK_AROUND_TIME / 2 + guard.setDir(turn(controller.stand_dir, pick(90, -90, 180))) + return AI_BEHAVIOR_DELAY + if(world.time < controller.next_turn) + return AI_BEHAVIOR_DELAY + var/state = controller.stealth_state() + if(state == STEALTH_SUSPICIOUS && !controller.investigated) + guard.setDir(controller.stand_dir) + return AI_BEHAVIOR_DELAY + var/sentry = isnull(controller.route_id) + controller.next_turn = world.time + (sentry ? STEALTH_SENTRY_TURN_INTERVAL : STEALTH_LOOK_TURN_INTERVAL) + if(guard.dir != controller.stand_dir) + guard.setDir(controller.stand_dir) + else if(sentry || prob(STEALTH_LOOK_TURN_CHANCE)) + guard.setDir(turn(controller.stand_dir, pick(STEALTH_LOOK_TURN_ARC, -STEALTH_LOOK_TURN_ARC))) + return AI_BEHAVIOR_DELAY diff --git a/voidcrew/modules/stealth/stealth_patrol.dm b/voidcrew/modules/stealth/stealth_patrol.dm new file mode 100644 index 00000000000..ed476f71dd4 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_patrol.dm @@ -0,0 +1,373 @@ +/** + * # Stealth patrols + * + * A template maps one group marker (/obj/effect/landmark/stealth_group) and any number of patrol points + * (/obj/effect/landmark/stealth_patrol). Points and guards belong to the nearest marker in their own map + * region within STEALTH_GROUP_RADIUS, so two dens on one packed planet never share routes (abuse R1). + * Nothing is matched by z-level alone, and no group processes on a timer. + * + * A guard claims the route with a stop within STEALTH_ROUTE_CLAIM_RANGE of where it spawned, starting at + * that stop. With none in range it is a sentry at its spawn turf, facing the way the spawner faced. + */ + +/// Every live patrol group +GLOBAL_LIST_EMPTY(stealth_groups) +/// Patrol points not yet handed to a group +GLOBAL_LIST_EMPTY(stealth_unassigned_points) + +/datum/stealth_stop + var/turf/spot + var/wait = STEALTH_PATROL_DEFAULT_WAIT + var/dir = SOUTH + var/chatter = FALSE + var/order = 0 + +/datum/stealth_group + /// A unique id, for admins + var/id + /// Weakref to its map region (a footprint or reservation), or null on an unpacked level + var/datum/weakref/region_ref + /// Whether its region was null when made (so a null region is a match, not a lost one) + var/no_region = FALSE + /// Where its marker stood + var/turf/home + /// Its marker, while it exists + var/obj/effect/landmark/stealth_group/marker + /// Route id => list of /datum/stealth_stop in order + var/list/routes = list() + /// Route id => "loop" or "pingpong" + var/list/route_modes = list() + /// Weakrefs to its guards + var/list/datum/weakref/members = list() + /// REFs of fallen members someone has already reported + var/list/reported_bodies = list() + /// world.time chatter is next allowed + var/next_chatter = 0 + +GLOBAL_VAR_INIT(stealth_group_count, 0) + +/datum/stealth_group/New(turf/where) + id = "group-[++GLOB.stealth_group_count]" + home = where + var/datum/region = map_region_for_turf(where) + if(region) + region_ref = WEAKREF(region) + else + no_region = TRUE + GLOB.stealth_groups += src + +/datum/stealth_group/Destroy() + GLOB.stealth_groups -= src + if(marker) + marker.group = null + marker = null + members = null + routes = null + home = null + return ..() + +/// Whether `tile` is in this group's map region. +/datum/stealth_group/proc/region_matches(turf/tile) + var/datum/region = map_region_for_turf(tile) + if(no_region) + return isnull(region) + return !isnull(region) && region == region_ref?.resolve() + +/datum/stealth_group/proc/add_member(mob/living/guard) + members |= WEAKREF(guard) + +/datum/stealth_group/proc/remove_member(mob/living/guard) + if(isnull(members)) + return + members -= WEAKREF(guard) + prune() + +/// Its guards that still exist. +/datum/stealth_group/proc/living_members() + . = list() + for(var/datum/weakref/ref as anything in members?.Copy()) + var/mob/living/guard = ref?.resolve() + if(QDELETED(guard)) + members -= ref + continue + . += guard + +/// Removes the group once its marker and every member are gone. +/datum/stealth_group/proc/prune() + if(QDELETED(src)) + return + if(marker || length(living_members())) + return + qdel(src) + +/datum/stealth_group/proc/add_point(obj/effect/landmark/stealth_patrol/point) + var/datum/stealth_stop/stop = new + stop.spot = get_turf(point) + stop.wait = point.wait < 0 ? STEALTH_PATROL_DEFAULT_WAIT : point.wait + stop.dir = point.dir + stop.chatter = point.chatter + stop.order = point.order + var/list/route = routes[point.route] + if(isnull(route)) + routes[point.route] = route = list() + var/index = 1 + while(index <= length(route)) + var/datum/stealth_stop/other = route[index] + if(other.order > stop.order) + break + index++ + route.Insert(index, stop) + if(point.order == 1 || isnull(route_modes[point.route])) + route_modes[point.route] = point.route_mode + +/// The nearest group to `tile` in its own region within STEALTH_GROUP_RADIUS, or null. +/proc/stealth_group_for(turf/tile) + if(isnull(tile)) + return null + stealth_assign_points() + var/datum/stealth_group/best + var/best_dist = INFINITY + for(var/datum/stealth_group/group as anything in GLOB.stealth_groups) + if(group.home?.z != tile.z) + continue + var/dist = get_dist(group.home, tile) + if(dist > STEALTH_GROUP_RADIUS || dist >= best_dist || !group.region_matches(tile)) + continue + best = group + best_dist = dist + return best + +/// Hands every loaded patrol point to its group. Points with no group yet wait for one. +/proc/stealth_assign_points() + for(var/obj/effect/landmark/stealth_patrol/point as anything in GLOB.stealth_unassigned_points) + if(QDELETED(point)) + GLOB.stealth_unassigned_points -= point + continue + var/turf/spot = get_turf(point) + var/datum/stealth_group/best + var/best_dist = INFINITY + for(var/datum/stealth_group/group as anything in GLOB.stealth_groups) + if(group.home?.z != spot?.z || !group.marker) + continue + var/dist = get_dist(group.home, spot) + if(dist > STEALTH_GROUP_RADIUS || dist >= best_dist || !group.region_matches(spot)) + continue + best = group + best_dist = dist + if(best) + best.add_point(point) + GLOB.stealth_unassigned_points -= point + +// ===== Landmarks ===== + +/// One per template: the patrol group its points and guards join. +/obj/effect/landmark/stealth_group + name = "stealth patrol group" + icon_state = "x" + var/datum/stealth_group/group + +/obj/effect/landmark/stealth_group/Initialize(mapload) + . = ..() + group = new(get_turf(src)) + group.marker = src + +/obj/effect/landmark/stealth_group/Destroy() + var/datum/stealth_group/old = group + group = null + if(old) + old.marker = null + old.prune() + return ..() + +/// A stop on a guard route. Its dir is the way the guard faces there. +/obj/effect/landmark/stealth_patrol + name = "stealth patrol point" + icon_state = "x3" + /// The route it belongs to ("a", "b", ...) + var/route = "a" + /// Its place on the route, from 1 + var/order = 1 + /// Deciseconds to stand here; -1 for STEALTH_PATROL_DEFAULT_WAIT, 0 to walk straight through + var/wait = -1 + /// TRUE: guards here talk to each other + var/chatter = FALSE + /// "loop" or "pingpong", read from the order 1 point + var/route_mode = "loop" + +/obj/effect/landmark/stealth_patrol/Initialize(mapload) + . = ..() + GLOB.stealth_unassigned_points += src + +/obj/effect/landmark/stealth_patrol/Destroy() + GLOB.stealth_unassigned_points -= src + return ..() + +// ===== Guards on routes ===== + +/// Joins a group and claims a route, once, on its first plan (after its map has loaded). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_setup() + if(stealth_ready) + return + stealth_ready = TRUE + var/mob/living/guard = pawn + var/turf/spawn_turf = get_turf(guard) + set_blackboard_key(BB_STEALTH_HOME_TURF, spawn_turf) + sentry_dir = guard.dir + stand_dir = guard.dir + group = stealth_group_for(spawn_turf) + if(isnull(group)) + group = new(spawn_turf) + group.add_member(guard) + // The route with a stop nearest its spawn, within reach. + var/best_dist = INFINITY + for(var/route in group.routes) + var/list/stops = group.routes[route] + for(var/index in 1 to length(stops)) + var/datum/stealth_stop/stop = stops[index] + var/dist = get_dist(stop.spot, spawn_turf) + if(dist > STEALTH_ROUTE_CLAIM_RANGE || dist >= best_dist) + continue + best_dist = dist + route_id = route + route_index = index + if(route_id) + var/datum/stealth_stop/start = group.routes[route_id][route_index] + set_blackboard_key(BB_STEALTH_HOME_TURF, start.spot) + +/// Drops its route and holds `where` as a sentry from now on (abuse R2, R3). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_become_sentry(turf/where) + route_id = null + at_stop = FALSE + if(where) + set_blackboard_key(BB_STEALTH_HOME_TURF, where) + sentry_dir = pawn.dir + stand_dir = pawn.dir + +/// Its route's stops, or null. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_stops() + if(isnull(route_id) || isnull(group)) + return null + return group.routes[route_id] + +/// Back from a suspicion or a search: heads for the nearest stop of its route. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_rejoin_route() + at_stop = FALSE + wait_until = 0 + var/list/stops = stealth_stops() + if(!length(stops)) + return + var/turf/here = get_turf(pawn) + var/best_dist = INFINITY + for(var/index in 1 to length(stops)) + var/datum/stealth_stop/stop = stops[index] + var/dist = get_dist(stop.spot, here) + if(dist < best_dist) + best_dist = dist + route_index = index + +/// The next stop after the current one that isn't being skipped, or 0 if every stop is skipped. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_next_index() + var/list/stops = stealth_stops() + var/count = length(stops) + if(!count) + return 0 + var/pingpong = group.route_modes[route_id] == "pingpong" + var/index = route_index + for(var/tries in 1 to count * 2) + index += route_step + if(index > count || index < 1) + if(pingpong && count > 1) + route_step = -route_step + index += route_step * 2 + else + index = index > count ? 1 : count + if(world.time >= stop_skip_until["[index]"]) + return index + return 0 + +/// A walk the pathfinder gave up on (abuse R2): a stop that fails often enough is skipped for a while. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_walk_failed() + if(goto_purpose == STEALTH_GOTO_HOME) + // It can't get back to its post: this is its post now. + stealth_become_sentry(get_turf(pawn)) + return + if(goto_purpose != STEALTH_GOTO_PATROL || isnull(route_id)) + return + var/key = "[route_index]" + stop_fails[key]++ + if(stop_fails[key] < STEALTH_PATROL_MAX_FAILS) + return + stop_fails[key] = 0 + stop_skip_until[key] = world.time + STEALTH_PATROL_SKIP_TIME + var/next = stealth_next_index() + if(!next) + stealth_become_sentry(get_turf(pawn)) + return + route_index = next + +/// Unaware with no target: walks its route or holds its post. +/datum/ai_planning_subtree/stealth_patrol + +/datum/ai_planning_subtree/stealth_patrol/SelectBehaviors(datum/ai_controller/basic_controller/human_npc/stealth/controller, seconds_per_tick) + if(!istype(controller) || controller.stealth_state() != STEALTH_UNAWARE || controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + return + var/mob/living/guard = controller.pawn + if(guard.stat != CONSCIOUS) + return + var/turf/here = get_turf(guard) + var/list/stops = controller.stealth_stops() + if(!length(stops)) + controller.route_id = null + var/turf/post = controller.blackboard[BB_STEALTH_HOME_TURF] + if(post && here != post && controller.goto_result != "failed") + controller.stealth_walk(post, STEALTH_GOTO_HOME) + return SUBTREE_RETURN_FINISH_PLANNING + controller.stand_dir = controller.sentry_dir + controller.queue_behavior(/datum/ai_behavior/stealth_stand) + return SUBTREE_RETURN_FINISH_PLANNING + if(controller.at_stop) + if(world.time < controller.wait_until) + controller.queue_behavior(/datum/ai_behavior/stealth_stand) + return SUBTREE_RETURN_FINISH_PLANNING + controller.at_stop = FALSE + var/next = controller.stealth_next_index() + if(!next) + controller.stealth_become_sentry(here) + return + controller.route_index = next + var/datum/stealth_stop/stop = stops[controller.route_index] + // Leash (abuse R3): a stop outside its region or too far from it means it was carried off. + if(!controller.group.region_matches(stop.spot) || stop.spot.z != here.z || get_dist(stop.spot, here) > STEALTH_LEASH_RANGE) + controller.stealth_become_sentry(here) + return + if(here == stop.spot || (controller.goto_turf == stop.spot && controller.goto_result == "arrived")) + controller.stealth_drop_walk() + controller.stealth_arrive(stop) + controller.queue_behavior(/datum/ai_behavior/stealth_stand) + return SUBTREE_RETURN_FINISH_PLANNING + if(controller.goto_turf == stop.spot && controller.goto_result == "failed") + controller.goto_result = null + controller.stealth_walk(stop.spot, STEALTH_GOTO_PATROL) + return SUBTREE_RETURN_FINISH_PLANNING + +/// At a stop: faces its way, waits, and talks if it's a chatter stop and a friend is near. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_arrive(datum/stealth_stop/stop) + at_stop = TRUE + stop_fails["[route_index]"] = 0 + wait_until = world.time + stop.wait + stand_dir = stop.dir + pawn.setDir(stop.dir) + next_turn = world.time + STEALTH_LOOK_TURN_INTERVAL + if(!stop.chatter || world.time < group.next_chatter) + return + var/mob/living/guard = pawn + for(var/mob/living/friend as anything in group.living_members()) + if(friend == guard || friend.stat != CONSCIOUS || get_dist(friend, guard) > STEALTH_CHATTER_RANGE) + continue + var/datum/ai_controller/basic_controller/human_npc/stealth/friend_ai = friend.ai_controller + if(!istype(friend_ai) || friend_ai.stealth_state() != STEALTH_UNAWARE) + continue + group.next_chatter = world.time + STEALTH_CHATTER_COOLDOWN + var/datum/ai_controller/basic_controller/human_npc/stealth/speaker = pick(src, friend_ai) + speaker.stealth_bark(STEALTH_BARK_CHATTER) + return diff --git a/voidcrew/modules/stealth/stealth_perception.dm b/voidcrew/modules/stealth/stealth_perception.dm new file mode 100644 index 00000000000..d3bc47df7a7 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_perception.dm @@ -0,0 +1,115 @@ +/** + * # Stealth perception + * + * Sight for guards that opted into stealth (stealth_ai.dm). It is AI math only: no fov_view on the body + * (a player who later takes it over must not inherit it), and the cone and darkness are never added to + * can_attack(), so an alert guard keeps tg's all-round check and an attack from behind still lands on a + * guard that can turn round (abuse review P1, P2). + * + * A scan, once a second while the AI is awake: the nearest few living mobs on the HEARING grid (every mob + * is hearing-sensitive, so SSD bodies and other NPCs count), each passed through the guard's own + * can_attack() first (faction, stat, line of sight, invisibility, the packed-level cordon, Ghostskin + * camo), then the cone, light and movement rules below raise or decay its "notice". + */ + +#ifdef UNIT_TESTS +/// Turfs the unit tests treat as dark, since the test level is fully lit +GLOBAL_LIST_EMPTY(stealth_test_dark_turfs) +#endif + +/// Whether `target` is within `half_angle` degrees of `viewer`'s facing. Integer math, no trig per call. +/// The same tile is in the cone; a target exactly side-on is not, even at 90 degrees. +/proc/stealth_in_cone(atom/viewer, atom/target, half_angle) + var/turf/from = get_turf(viewer) + var/turf/target_turf = get_turf(target) + if(isnull(from) || isnull(target_turf)) + return FALSE + var/dx = target_turf.x - from.x + var/dy = target_turf.y - from.y + if(!dx && !dy) + return TRUE + var/facing = viewer.dir + var/sx = (facing & EAST) ? 1 : ((facing & WEST) ? -1 : 0) + var/sy = (facing & NORTH) ? 1 : ((facing & SOUTH) ? -1 : 0) + var/facing_len2 = sx * sx + sy * sy + if(!facing_len2) + return FALSE + var/forward = dx * sx + dy * sy + if(forward <= 0) + return FALSE + return forward * forward >= (dx * dx + dy * dy) * facing_len2 * stealth_cos2(half_angle) + +/// cos^2 of `angle` degrees, from a table for the angles the stealth layer uses. +/proc/stealth_cos2(angle) + switch(angle) + if(60) + return 0.25 + if(75) + return 0.0669873 + if(90) + return 0 + var/c = cos(angle) + return c * c + +/** + * Whether `tile` is dark enough to hide in. A turf with no lighting object (planet ground lit only by its + * area's ambient light) reads its area's base light, which get_lumcount() skips (it returns 1 there). + * Same rule as the bounty AI's ai_tile_is_dark() (bounty_ai_meek.dm), which is a type proc. + */ +/proc/stealth_tile_is_dark(turf/tile) + if(!isturf(tile)) + return FALSE +#ifdef UNIT_TESTS + if(tile in GLOB.stealth_test_dark_turfs) + return TRUE +#endif + if(!tile.lighting_object) + var/area/tile_area = tile.loc + return (tile_area.base_lighting_alpha / 255) + tile.dynamic_lumcount < STEALTH_DARK_LUMCOUNT + return tile.get_lumcount() < STEALTH_DARK_LUMCOUNT + +/// The vehicle `who` sits in (a mech or another vehicle), or null. +/proc/stealth_vehicle_of(mob/living/who) + var/atom/holder = who.loc + if(ismecha(holder) || isvehicle(holder)) + return holder + return null + +/** + * Whether a cloak hides `who` from a guard's sight beyond the close radius (owner decision 20: cyberware + * cloaks and boon abilities). Ghostskin camo is already refused by can_attack() past its spot range + * (cyberware_stealth.dm); this adds the heretic shadow cloak a Vestige boon grants. + */ +/proc/stealth_is_cloaked(mob/living/who) + if(HAS_TRAIT(who, TRAIT_CYBER_CAMO)) + return TRUE + return !!who.has_status_effect(/datum/status_effect/shadow_cloak) + +/** + * The living mobs a guard might see, nearest first, at most STEALTH_MAX_CANDIDATES. Uses the spatial + * grid, never view() or hearers(). + */ +/proc/stealth_candidates(mob/living/guard, range) + var/turf/center = get_turf(guard) + if(isnull(center)) + return list() + var/list/buckets = new /list(range + 1) + for(var/mob/living/found in SSspatial_grid.orthogonal_range_search(center, SPATIAL_GRID_CONTENTS_TYPE_HEARING, range)) + if(found == guard) + continue + var/turf/found_turf = get_turf(found) + if(isnull(found_turf) || found_turf.z != center.z) + continue + var/dist = get_dist(center, found_turf) + if(dist > range) + continue + var/list/bucket = buckets[dist + 1] + if(isnull(bucket)) + buckets[dist + 1] = bucket = list() + bucket += found + . = list() + for(var/list/bucket in buckets) + for(var/mob/living/found as anything in bucket) + . += found + if(length(.) >= STEALTH_MAX_CANDIDATES) + return . diff --git a/voidcrew/modules/stealth/stealth_test_ruin.dm b/voidcrew/modules/stealth/stealth_test_ruin.dm new file mode 100644 index 00000000000..69c376eca47 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_test_ruin.dm @@ -0,0 +1,10 @@ +/** + * The stealth playtest room (temporary: deleted when step 4's scav den lands). Never seeds on a planet; + * an admin places it with "Map Template - Place". + */ +/datum/map_template/ruin/jungle/stealth_test + name = "Stealth Test Room" + id = "jungle-stealth-test" + description = "A guarded compound for testing guard sight and patrols." + suffix = "jungle_stealth_test.dmm" + unpickable = TRUE From d8652f37ac921f6943b8c6bcef43fc3efcca412c Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sun, 8 Nov 2026 16:25:30 -0800 Subject: [PATCH 02/78] Add the stealth test room map --- .../JungleRuins/jungle_stealth_test.dmm | 846 ++++++++++++++++++ 1 file changed, 846 insertions(+) create mode 100644 _maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm diff --git a/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm new file mode 100644 index 00000000000..d882f79dcc5 --- /dev/null +++ b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm @@ -0,0 +1,846 @@ +//MAP CONVERTED BY dmm2tgm.py THIS HEADER COMMENT PREVENTS RECONVERSION, DO NOT REMOVE +"a" = ( +/obj/effect/spawner/human_npc/ruin/scav{ + dir = 2 + }, +/turf/open/floor/iron, +/area/ruin/powered) +"f" = ( +/obj/effect/landmark/stealth_patrol{ + route = "b"; + order = 3; + dir = 1 + }, +/turf/open/floor/plating, +/area/ruin/powered) +"h" = ( +/obj/effect/landmark/stealth_patrol{ + route = "b"; + order = 1; + dir = 4; + route_mode = "pingpong" + }, +/obj/effect/spawner/human_npc/ruin/scav{ + dir = 4 + }, +/turf/open/floor/plating, +/area/ruin/powered) +"i" = ( +/turf/open/misc/grass/jungle, +/area/overmap_encounter/planet_ruin) +"l" = ( +/obj/machinery/light/directional/north, +/turf/open/floor/iron, +/area/ruin/powered) +"o" = ( +/obj/effect/landmark/stealth_patrol{ + route = "b"; + order = 2; + dir = 8 + }, +/turf/open/floor/plating, +/area/ruin/powered) +"p" = ( +/obj/effect/spawner/structure/window, +/turf/open/floor/iron, +/area/ruin/powered) +"q" = ( +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 3; + dir = 2 + }, +/obj/effect/spawner/human_npc/ruin/scav{ + dir = 2 + }, +/turf/open/floor/iron, +/area/ruin/powered) +"s" = ( +/obj/structure/closet/crate, +/turf/open/floor/plating, +/area/ruin/powered) +"t" = ( +/obj/machinery/door/airlock/public, +/turf/open/floor/iron, +/area/ruin/powered) +"v" = ( +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 4; + dir = 4; + chatter = 1 + }, +/turf/open/floor/iron, +/area/ruin/powered) +"x" = ( +/turf/open/floor/iron, +/area/ruin/powered) +"z" = ( +/obj/structure/table, +/turf/open/floor/iron, +/area/ruin/powered) +"B" = ( +/obj/structure/closet/crate/large, +/turf/open/floor/plating, +/area/ruin/powered) +"F" = ( +/obj/machinery/light_switch/directional/west, +/turf/open/floor/iron, +/area/ruin/powered) +"I" = ( +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 2; + dir = 4 + }, +/obj/effect/spawner/human_npc/ruin/scav/gunner{ + dir = 8 + }, +/turf/open/floor/iron, +/area/ruin/powered) +"J" = ( +/turf/closed/wall, +/area/ruin/powered) +"P" = ( +/turf/open/floor/plating, +/area/ruin/powered) +"Q" = ( +/obj/effect/landmark/stealth_group, +/turf/open/floor/iron, +/area/ruin/powered) +"V" = ( +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 1; + dir = 8 + }, +/obj/effect/spawner/human_npc/ruin/scav{ + dir = 4 + }, +/turf/open/floor/iron, +/area/ruin/powered) +"W" = ( +/obj/machinery/light/directional/south, +/turf/open/floor/iron, +/area/ruin/powered) + +(1,1,1) = {" +i +i +i +i +i +i +i +i +i +i +i +i +i +i +i +i +i +i +i +i +i +i +"} +(2,1,1) = {" +i +J +J +J +J +J +J +J +J +J +J +J +J +J +J +J +J +J +J +J +i +i +"} +(3,1,1) = {" +i +J +x +x +J +P +P +P +P +P +P +P +P +P +P +P +P +P +s +J +i +i +"} +(4,1,1) = {" +i +J +l +x +J +P +P +P +P +P +P +s +P +P +P +P +P +P +P +J +i +i +"} +(5,1,1) = {" +i +J +x +V +J +P +P +h +P +P +P +P +P +P +P +P +P +P +P +J +i +i +"} +(6,1,1) = {" +i +J +x +x +J +P +P +P +P +P +P +P +P +P +P +P +f +P +P +J +i +i +"} +(7,1,1) = {" +i +J +x +x +J +P +P +P +P +P +P +P +P +P +P +P +P +P +P +J +i +i +"} +(8,1,1) = {" +i +J +x +x +t +P +P +P +P +P +P +P +B +P +P +P +P +P +P +J +i +i +"} +(9,1,1) = {" +i +J +x +x +J +P +P +P +P +P +P +P +B +P +P +P +P +P +P +J +i +i +"} +(10,1,1) = {" +i +J +l +x +J +P +B +B +P +P +P +P +P +P +P +P +P +P +P +J +i +i +"} +(11,1,1) = {" +i +J +x +x +J +P +P +P +P +P +P +P +P +P +P +P +P +P +P +J +i +i +"} +(12,1,1) = {" +i +J +x +x +J +P +P +P +P +P +P +P +P +P +P +P +P +P +P +J +i +i +"} +(13,1,1) = {" +i +J +x +x +J +P +P +P +P +P +o +P +P +P +P +B +P +P +P +J +i +i +"} +(14,1,1) = {" +i +J +x +x +J +P +P +P +P +P +P +P +P +P +P +s +P +P +P +J +i +i +"} +(15,1,1) = {" +i +J +x +x +J +P +P +P +P +P +P +P +P +P +P +P +P +P +B +J +i +i +"} +(16,1,1) = {" +i +J +l +x +J +J +J +J +J +J +J +J +J +J +J +J +J +J +J +J +i +i +"} +(17,1,1) = {" +i +J +x +x +J +x +x +x +x +x +Q +x +F +x +x +x +x +x +x +J +i +i +"} +(18,1,1) = {" +i +J +x +x +J +l +x +x +x +x +x +x +x +x +x +x +x +x +W +J +i +i +"} +(19,1,1) = {" +i +J +x +x +p +x +x +x +x +x +x +x +x +x +v +x +x +x +x +J +i +i +"} +(20,1,1) = {" +i +J +x +x +p +x +x +x +x +x +x +x +x +x +x +x +x +x +x +J +i +i +"} +(21,1,1) = {" +i +J +x +x +p +x +x +x +x +x +x +x +x +x +x +x +x +x +x +J +i +i +"} +(22,1,1) = {" +i +J +l +x +J +x +x +x +x +x +x +x +x +x +x +x +x +a +x +t +i +i +"} +(23,1,1) = {" +i +J +x +x +J +x +x +x +x +x +x +x +x +x +x +x +x +x +x +J +i +i +"} +(24,1,1) = {" +i +J +x +x +p +x +x +x +x +x +z +z +x +x +x +x +x +x +x +J +i +i +"} +(25,1,1) = {" +i +J +x +x +p +x +x +x +x +x +z +z +x +x +x +x +x +x +x +J +i +i +"} +(26,1,1) = {" +i +J +I +x +p +x +x +x +x +x +x +x +x +x +x +x +x +x +x +J +i +i +"} +(27,1,1) = {" +i +J +x +x +t +x +x +q +x +x +x +x +x +x +x +x +x +x +x +J +i +i +"} +(28,1,1) = {" +i +J +x +x +J +l +x +x +x +x +x +x +x +x +x +x +x +x +W +J +i +i +"} +(29,1,1) = {" +i +J +J +J +J +J +J +J +J +J +J +J +J +J +J +J +J +J +J +J +i +i +"} +(30,1,1) = {" +i +i +i +i +i +i +i +i +i +i +i +i +i +i +i +i +i +i +i +i +i +i +"} From a1358a6bb0c91b0eda13d1731776cbff71468d0c Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sun, 8 Nov 2026 16:30:04 -0800 Subject: [PATCH 03/78] Add stealth guard unit tests --- voidcrew/modules/unit_tests/_unit_tests.dm | 1 + .../modules/unit_tests/voidcrew_stealth.dm | 321 ++++++++++++++++++ 2 files changed, 322 insertions(+) create mode 100644 voidcrew/modules/unit_tests/voidcrew_stealth.dm diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index eb7c190c9f0..19067100870 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -234,6 +234,7 @@ #include "voidcrew_simple_mob_ai.dm" #include "voidcrew_slime_extract_piles.dm" #include "voidcrew_smart_locker.dm" +#include "voidcrew_stealth.dm" #include "voidcrew_survey_archive.dm" #include "voidcrew_survey_capabilities.dm" #include "voidcrew_survey_identity.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth.dm b/voidcrew/modules/unit_tests/voidcrew_stealth.dm new file mode 100644 index 00000000000..942314a1ee1 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_stealth.dm @@ -0,0 +1,321 @@ +// Stealth guards (voidcrew/modules/stealth/). Unit tests compile before voidcrew/_DEFINES, so values from +// there are written out: states "unaware", "suspicious", "alert", "searching"; blackboard keys +// "stealth_state", "stealth_wary", "stealth_last_seen_turf"; STEALTH_PATROL_MAX_FAILS 3, +// STEALTH_LOSE_TARGET_TIME 4 s, STEALTH_SEARCH_TIME 40 s. + +#define STEALTH_TEST_GUARD /mob/living/carbon/human/npc/ruin/trooper/scav + +/// A floored block of `width` x `height` tiles for one test. Released by the caller. +/datum/unit_test/proc/stealth_block(width, height) + var/datum/turf_reservation/block = SSmapping.request_turf_block_reservation(width, height, 1) + if(isnull(block)) + return null + var/turf/corner = block.bottom_left_turfs[1] + for(var/turf/spot as anything in block(corner.x, corner.y, corner.z, corner.x + width - 1, corner.y + height - 1, corner.z)) + spot.ChangeTurf(/turf/open/floor/iron) + return block + +/datum/unit_test/proc/stealth_at(datum/turf_reservation/block, dx, dy) + var/turf/corner = block.bottom_left_turfs[1] + return locate(corner.x + dx, corner.y + dy, corner.z) + +/// A guard at (dx, dy) of `block`, facing `facing`. +/datum/unit_test/proc/stealth_guard(datum/turf_reservation/block, dx, dy, facing = EAST) + var/mob/living/carbon/human/npc/guard = allocate(STEALTH_TEST_GUARD, stealth_at(block, dx, dy)) + guard.setDir(facing) + return guard + +/// A walking, ordinary person at (dx, dy) of `block`. +/datum/unit_test/proc/stealth_person(datum/turf_reservation/block, dx, dy) + var/mob/living/carbon/human/consistent/person = allocate(/mob/living/carbon/human/consistent, stealth_at(block, dx, dy)) + if(person.move_intent == MOVE_INTENT_RUN) + person.toggle_move_intent() + return person + +/datum/unit_test/proc/stealth_ai(mob/living/guard) + return guard.ai_controller + +/datum/unit_test/proc/stealth_scans(mob/living/guard, count) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + for(var/i in 1 to count) + stealth_ai.stealth_scan_once() + +/// Cone math against a guard facing east. +/datum/unit_test/voidcrew_stealth_cone + +/datum/unit_test/voidcrew_stealth_cone/Run() + var/datum/turf_reservation/block = stealth_block(9, 9) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/obj/item/viewer = allocate(/obj/item/pen, stealth_at(block, 4, 4)) + viewer.setDir(EAST) + // offset => expected at 60, 75, 90 + var/list/cases = list( + list(3, 0, TRUE, TRUE, TRUE), + list(3, 2, TRUE, TRUE, TRUE), + list(2, 3, FALSE, TRUE, TRUE), + list(0, 3, FALSE, FALSE, FALSE), + list(-2, 0, FALSE, FALSE, FALSE), + list(0, 0, TRUE, TRUE, TRUE), + ) + var/list/angles = list(60, 75, 90) + for(var/list/test_case as anything in cases) + var/turf/spot = stealth_at(block, 4 + test_case[1], 4 + test_case[2]) + for(var/i in 1 to 3) + TEST_ASSERT_EQUAL(!!stealth_in_cone(viewer, spot, angles[i]), test_case[2 + i], "Offset ([test_case[1]], [test_case[2]]) at half-angle [angles[i]]") + qdel(block) + +/// The dark helper reads the test list; ordinary test floor is lit. +/datum/unit_test/voidcrew_stealth_dark + +/datum/unit_test/voidcrew_stealth_dark/Run() + var/datum/turf_reservation/block = stealth_block(3, 3) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/turf/lit = stealth_at(block, 0, 0) + var/turf/dark = stealth_at(block, 1, 0) + GLOB.stealth_test_dark_turfs += dark + TEST_ASSERT(!stealth_tile_is_dark(lit), "Ordinary test floor reads as dark") + TEST_ASSERT(stealth_tile_is_dark(dark), "A turf in the test dark list reads as lit") + GLOB.stealth_test_dark_turfs -= dark + qdel(block) + +/// Sight: behind stays unaware, in front goes suspicious then alert, dark at range and off-screen never alert. +/datum/unit_test/voidcrew_stealth_sight + +/datum/unit_test/voidcrew_stealth_sight/Run() + var/datum/turf_reservation/block = stealth_block(20, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + // Behind, 3 tiles, lit, still. + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 3, 2) + stealth_scans(guard, 10) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard noticed someone standing 3 tiles behind it") + qdel(guard) + // In front, 2 tiles. + guard = stealth_guard(block, 6, 2) + stealth_ai = stealth_ai(guard) + person.forceMove(stealth_at(block, 8, 2)) + stealth_scans(guard, 2) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "suspicious", "A guard wasn't suspicious of someone 2 tiles in front after two scans") + stealth_scans(guard, 2) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard wasn't alert on someone 2 tiles in front after four scans") + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], person, "The alert guard has no target") + qdel(guard) + // In front, 6 tiles, dark. + guard = stealth_guard(block, 6, 2) + stealth_ai = stealth_ai(guard) + var/turf/dark = stealth_at(block, 12, 2) + GLOB.stealth_test_dark_turfs += dark + person.forceMove(dark) + stealth_scans(guard, 10) + GLOB.stealth_test_dark_turfs -= dark + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard saw someone 6 tiles off in the dark") + qdel(guard) + // In front, 8 tiles, lit: never alert from off-screen. + guard = stealth_guard(block, 6, 2) + stealth_ai = stealth_ai(guard) + person.forceMove(stealth_at(block, 14, 2)) + for(var/i in 1 to 30) + stealth_ai.stealth_scan_once() + TEST_ASSERT(stealth_ai.stealth_state() != "alert", "A guard went alert on someone 8 tiles off") + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "suspicious", "A guard never grew suspicious of someone 8 tiles in front in the light") + qdel(guard) + qdel(block) + +/// Alert: keeps its target all round; loses it behind a wall and searches where it last saw it. +/datum/unit_test/voidcrew_stealth_alert + +/datum/unit_test/voidcrew_stealth_alert/Run() + var/datum/turf_reservation/block = stealth_block(16, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 9, 2) + stealth_ai.stealth_go_alert(person) + person.forceMove(stealth_at(block, 3, 2)) + stealth_scans(guard, 5) + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], person, "An alert guard dropped a target that stepped behind it") + // Behind a wall now. + var/turf/last_seen = stealth_at(block, 9, 2) + person.forceMove(last_seen) + stealth_scans(guard, 1) + for(var/dy in 0 to 4) + var/turf/wall_spot = stealth_at(block, 11, dy) + wall_spot.ChangeTurf(/turf/closed/wall) + person.forceMove(stealth_at(block, 13, 2)) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard gave up on a target the moment it went out of sight") + stealth_ai.stealth_rewind(5 SECONDS) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "searching", "A guard that lost its target isn't searching") + TEST_ASSERT_EQUAL(stealth_ai.blackboard["stealth_last_seen_turf"], last_seen, "The search isn't at the last place it saw them") + TEST_ASSERT_NULL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], "A searching guard still has a target") + qdel(block) + +/// Hit from out of sight: searches the attacker's turf, wary. Pulled: alert on the puller. The step 3 hook. +/datum/unit_test/voidcrew_stealth_touched + +/datum/unit_test/voidcrew_stealth_touched/Run() + var/datum/turf_reservation/block = stealth_block(20, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 15, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 1, 2) + SEND_SIGNAL(guard, COMSIG_ATOM_WAS_ATTACKED, person, ATTACKER_DAMAGING_ATTACK) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "searching", "A guard hit from out of sight isn't searching") + TEST_ASSERT_EQUAL(stealth_ai.blackboard["stealth_last_seen_turf"], get_turf(person), "The search isn't at the attacker's turf") + TEST_ASSERT(stealth_ai.blackboard["stealth_wary"], "A guard that was hit isn't wary") + qdel(guard) + // Pulled. + guard = stealth_guard(block, 15, 2) + stealth_ai = stealth_ai(guard) + person.forceMove(stealth_at(block, 14, 2)) + person.start_pulling(guard) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A pulled guard isn't alert") + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], person, "A pulled guard isn't after the puller") + person.stop_pulling() + qdel(guard) + // The hook: unaware when the blow began, even though the blow made it alert. + guard = stealth_guard(block, 15, 2) + stealth_ai = stealth_ai(guard) + TEST_ASSERT(guard.stealth_was_unaware(), "An unaware guard doesn't read as unaware") + SEND_SIGNAL(guard, COMSIG_ATOM_WAS_ATTACKED, person, ATTACKER_DAMAGING_ATTACK) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard hit by someone beside it isn't alert") + TEST_ASSERT(guard.stealth_was_unaware(), "The hook forgot the guard was unaware in the same tick") + stealth_ai.stealth_rewind(1) + TEST_ASSERT(!guard.stealth_was_unaware(), "The hook still reads unaware after time passed") + var/mob/living/carbon/human/npc/plain = allocate(/mob/living/carbon/human/npc/ruin/trooper/syndicate, stealth_at(block, 3, 2)) + TEST_ASSERT(!plain.stealth_was_unaware(), "An NPC without stealth reads as unaware") + qdel(block) + +/// A fallen friend in view: suspicious once; the same body never sets it off again. +/datum/unit_test/voidcrew_stealth_bodies + +/datum/unit_test/voidcrew_stealth_bodies/Run() + var/datum/turf_reservation/block = stealth_block(12, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + allocate(/obj/effect/landmark/stealth_group, stealth_at(block, 6, 4)) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 2) + var/mob/living/carbon/human/npc/friend = stealth_guard(block, 5, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/datum/ai_controller/basic_controller/human_npc/stealth/friend_ai = stealth_ai(friend) + stealth_ai.stealth_setup() + friend_ai.stealth_setup() + TEST_ASSERT_EQUAL(stealth_ai.group, friend_ai.group, "Two guards by one marker aren't in one group") + friend.death() + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "suspicious", "A guard didn't react to a dead friend in view") + stealth_ai.stealth_go_unaware() + stealth_ai.next_body_scan = 0 + stealth_scans(guard, 3) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "The same body set a guard off twice") + qdel(block) + +/// Routes: each guard claims only its own group's stops, in order; a guard far from any stop is a sentry. +/// A stop it can't reach is skipped after STEALTH_PATROL_MAX_FAILS failures. +/datum/unit_test/voidcrew_stealth_routes + +/datum/unit_test/voidcrew_stealth_routes/Run() + var/datum/turf_reservation/first = stealth_block(10, 5) + var/datum/turf_reservation/second = stealth_block(10, 5) + TEST_ASSERT(first && second, "No room for the test") + var/list/guards = list() + for(var/datum/turf_reservation/block in list(first, second)) + allocate(/obj/effect/landmark/stealth_group, stealth_at(block, 9, 4)) + // Made out of order, so the group has to sort them. + var/obj/effect/landmark/stealth_patrol/third = allocate(/obj/effect/landmark/stealth_patrol, stealth_at(block, 7, 0)) + third.order = 3 + var/obj/effect/landmark/stealth_patrol/second_stop = allocate(/obj/effect/landmark/stealth_patrol, stealth_at(block, 4, 0)) + second_stop.order = 2 + var/obj/effect/landmark/stealth_patrol/first_stop = allocate(/obj/effect/landmark/stealth_patrol, stealth_at(block, 1, 0)) + first_stop.order = 1 + guards += stealth_guard(block, 1, 0) + var/list/stop_columns = list(1, 4, 7) + for(var/i in 1 to 2) + var/datum/turf_reservation/block = i == 1 ? first : second + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guards[i]) + stealth_ai.stealth_setup() + TEST_ASSERT_EQUAL(stealth_ai.route_id, "a", "Guard [i] didn't claim the route it spawned on") + var/list/stops = stealth_ai.stealth_stops() + TEST_ASSERT_EQUAL(length(stops), 3, "Guard [i]'s route has [length(stops)] stops, not its own group's 3") + for(var/index in 1 to length(stops)) + var/datum/stealth_stop/stop = stops[index] + TEST_ASSERT_EQUAL(stop.order, index, "Guard [i]'s stop [index] is out of order") + TEST_ASSERT_EQUAL(stop.spot, stealth_at(block, stop_columns[index], 0), "Guard [i]'s stop [index] isn't in its own block") + var/mob/living/carbon/human/npc/sentry = stealth_guard(first, 1, 4, SOUTH) + var/datum/ai_controller/basic_controller/human_npc/stealth/sentry_ai = stealth_ai(sentry) + // Four tiles from the nearest stop, beyond STEALTH_ROUTE_CLAIM_RANGE (2). + sentry_ai.stealth_setup() + TEST_ASSERT_NULL(sentry_ai.route_id, "A guard away from every stop claimed a route") + TEST_ASSERT_EQUAL(sentry_ai.sentry_dir, SOUTH, "The sentry doesn't face the way it spawned") + // Unreachable stop. + var/datum/ai_controller/basic_controller/human_npc/stealth/walker = stealth_ai(guards[1]) + walker.route_index = 2 + walker.goto_purpose = "patrol" + for(var/i in 1 to 3) + walker.stealth_walk_failed() + TEST_ASSERT(walker.stop_skip_until["2"] > world.time, "A stop that failed 3 times isn't skipped") + TEST_ASSERT(walker.route_index != 2, "The guard still heads for a skipped stop") + qdel(first) + qdel(second) + +/// A search that ran out while the guard slept ends on waking: unaware, still wary. +/datum/unit_test/voidcrew_stealth_wake + +/datum/unit_test/voidcrew_stealth_wake/Run() + var/datum/turf_reservation/block = stealth_block(5, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + stealth_ai.stealth_go_searching(stealth_at(block, 3, 3)) + stealth_ai.stealth_rewind(41 SECONDS) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A search past its time didn't end on waking") + TEST_ASSERT(stealth_ai.blackboard["stealth_wary"], "A guard that searched isn't wary") + qdel(block) + +/// Someone in a locker in front of a guard is unseen; a mech in range is alert at once. +/datum/unit_test/voidcrew_stealth_containers + +/datum/unit_test/voidcrew_stealth_containers/Run() + var/datum/turf_reservation/block = stealth_block(10, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 4, 2) + var/obj/structure/closet/locker = allocate(/obj/structure/closet, stealth_at(block, 4, 2)) + locker.close() + person.forceMove(locker) + stealth_scans(guard, 10) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard saw someone shut in a locker") + person.forceMove(stealth_at(block, 6, 2)) + var/obj/vehicle/sealed/mecha/ripley/mech = allocate(/obj/vehicle/sealed/mecha/ripley, stealth_at(block, 6, 2)) + person.forceMove(mech) + mech.add_occupant(person) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard wasn't alert on a mech in front of it") + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], mech, "The guard isn't after the mech") + mech.remove_occupant(person) + person.forceMove(stealth_at(block, 8, 2)) + qdel(block) + +/// Deleting a guard takes it out of its group; with the marker and every guard gone the group goes too. +/datum/unit_test/voidcrew_stealth_cleanup + +/datum/unit_test/voidcrew_stealth_cleanup/Run() + var/datum/turf_reservation/block = stealth_block(6, 4) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/obj/effect/landmark/stealth_group/marker = new(stealth_at(block, 5, 3)) + var/datum/stealth_group/group = marker.group + var/mob/living/carbon/human/npc/guard = new STEALTH_TEST_GUARD(stealth_at(block, 1, 1)) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + stealth_ai.stealth_setup() + TEST_ASSERT_EQUAL(stealth_ai.group, group, "The guard didn't join the marker's group") + qdel(guard) + TEST_ASSERT_EQUAL(length(group.living_members()), 0, "A deleted guard is still in its group") + TEST_ASSERT(group in GLOB.stealth_groups, "A group with its marker standing was removed") + qdel(marker) + TEST_ASSERT(!(group in GLOB.stealth_groups), "A group with no marker and no guards is still registered") + qdel(block) + +#undef STEALTH_TEST_GUARD From 3b8f10ee080a784825c47c6ec98b22c428eb0432 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sun, 8 Nov 2026 16:30:35 -0800 Subject: [PATCH 04/78] Hide bodies in containers from stealth guards --- voidcrew/modules/stealth/stealth_ai.dm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index b766d7e25e5..82ac03fad38 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -514,7 +514,10 @@ var/key = REF(member) if(key in seen) continue - var/turf/where = get_turf(member) + // A body stuffed in a locker, a crate or a bag is hidden, as a living person there is. + if(!isturf(member.loc)) + continue + var/turf/where = member.loc if(isnull(where) || where.z != guard.z) continue var/dist = get_dist(guard, where) From eba30b4b0510a4e3599bac48d725f023fc654816 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sun, 8 Nov 2026 17:09:57 -0800 Subject: [PATCH 05/78] Fix stealth z-change hook and test lighting --- voidcrew/modules/stealth/stealth_ai.dm | 12 ++++++------ voidcrew/modules/stealth/stealth_perception.dm | 4 ++-- voidcrew/modules/unit_tests/voidcrew_stealth.dm | 16 +++++++++------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index 82ac03fad38..9580dff84bd 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -122,7 +122,6 @@ RegisterSignal(new_pawn, COMSIG_ATOM_BUMPED, PROC_REF(on_bumped)) RegisterSignal(new_pawn, COMSIG_CARBON_HELP_ACT, PROC_REF(on_helped)) RegisterSignal(new_pawn, COMSIG_PROJECTILE_PREHIT, PROC_REF(on_projectile_prehit)) - RegisterSignal(new_pawn, COMSIG_MOVABLE_Z_CHANGED, PROC_REF(on_z_changed)) RegisterSignal(new_pawn, COMSIG_LIVING_STATUS_REMOVED, PROC_REF(on_status_removed)) RegisterSignal(new_pawn, COMSIG_AI_BLACKBOARD_KEY_SET(BB_BASIC_MOB_CURRENT_TARGET), PROC_REF(on_target_set)) @@ -133,7 +132,6 @@ COMSIG_ATOM_BUMPED, COMSIG_CARBON_HELP_ACT, COMSIG_PROJECTILE_PREHIT, - COMSIG_MOVABLE_Z_CHANGED, COMSIG_LIVING_STATUS_REMOVED, COMSIG_AI_BLACKBOARD_KEY_SET(BB_BASIC_MOB_CURRENT_TARGET), )) @@ -596,10 +594,12 @@ stealth_set_wary() set_blackboard_key(BB_STEALTH_FOCUS, target) -/// Carried off the level: drops its route and holds where it is (abuse R3). -/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_z_changed(datum/source) - SIGNAL_HANDLER - stealth_become_sentry(get_turf(pawn)) +/// Carried off the level: drops its route and holds where it is (abuse R3). The base controller already +/// listens for the level change. +/datum/ai_controller/basic_controller/human_npc/stealth/on_changed_z_level(atom/source, turf/old_turf, turf/new_turf, same_z_layer, notify_contents) + . = ..() + if(stealth_ready && new_turf) + stealth_become_sentry(new_turf) /datum/ai_controller/basic_controller/human_npc/stealth/on_stat_changed(mob/living/source, new_stat) . = ..() diff --git a/voidcrew/modules/stealth/stealth_perception.dm b/voidcrew/modules/stealth/stealth_perception.dm index d3bc47df7a7..8b1054fffbf 100644 --- a/voidcrew/modules/stealth/stealth_perception.dm +++ b/voidcrew/modules/stealth/stealth_perception.dm @@ -13,7 +13,7 @@ */ #ifdef UNIT_TESTS -/// Turfs the unit tests treat as dark, since the test level is fully lit +/// Unit tests: turf => TRUE to treat it as dark, FALSE as lit (reserved test space has no light of its own) GLOBAL_LIST_EMPTY(stealth_test_dark_turfs) #endif @@ -61,7 +61,7 @@ GLOBAL_LIST_EMPTY(stealth_test_dark_turfs) return FALSE #ifdef UNIT_TESTS if(tile in GLOB.stealth_test_dark_turfs) - return TRUE + return GLOB.stealth_test_dark_turfs[tile] #endif if(!tile.lighting_object) var/area/tile_area = tile.loc diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth.dm b/voidcrew/modules/unit_tests/voidcrew_stealth.dm index 942314a1ee1..72adddda140 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth.dm @@ -13,6 +13,7 @@ var/turf/corner = block.bottom_left_turfs[1] for(var/turf/spot as anything in block(corner.x, corner.y, corner.z, corner.x + width - 1, corner.y + height - 1, corner.z)) spot.ChangeTurf(/turf/open/floor/iron) + GLOB.stealth_test_dark_turfs[spot] = FALSE return block /datum/unit_test/proc/stealth_at(datum/turf_reservation/block, dx, dy) @@ -52,7 +53,8 @@ var/list/cases = list( list(3, 0, TRUE, TRUE, TRUE), list(3, 2, TRUE, TRUE, TRUE), - list(2, 3, FALSE, TRUE, TRUE), + list(2, 3, TRUE, TRUE, TRUE), + list(1, 3, FALSE, TRUE, TRUE), list(0, 3, FALSE, FALSE, FALSE), list(-2, 0, FALSE, FALSE, FALSE), list(0, 0, TRUE, TRUE, TRUE), @@ -64,7 +66,7 @@ TEST_ASSERT_EQUAL(!!stealth_in_cone(viewer, spot, angles[i]), test_case[2 + i], "Offset ([test_case[1]], [test_case[2]]) at half-angle [angles[i]]") qdel(block) -/// The dark helper reads the test list; ordinary test floor is lit. +/// The dark helper reads the test lists: a dark-listed turf is dark, a lit-listed one is not. /datum/unit_test/voidcrew_stealth_dark /datum/unit_test/voidcrew_stealth_dark/Run() @@ -72,10 +74,10 @@ TEST_ASSERT_NOTNULL(block, "No room for the test") var/turf/lit = stealth_at(block, 0, 0) var/turf/dark = stealth_at(block, 1, 0) - GLOB.stealth_test_dark_turfs += dark - TEST_ASSERT(!stealth_tile_is_dark(lit), "Ordinary test floor reads as dark") + GLOB.stealth_test_dark_turfs[dark] = TRUE + TEST_ASSERT(!stealth_tile_is_dark(lit), "A lit test turf reads as dark") TEST_ASSERT(stealth_tile_is_dark(dark), "A turf in the test dark list reads as lit") - GLOB.stealth_test_dark_turfs -= dark + GLOB.stealth_test_dark_turfs[dark] = FALSE qdel(block) /// Sight: behind stays unaware, in front goes suspicious then alert, dark at range and off-screen never alert. @@ -105,10 +107,10 @@ guard = stealth_guard(block, 6, 2) stealth_ai = stealth_ai(guard) var/turf/dark = stealth_at(block, 12, 2) - GLOB.stealth_test_dark_turfs += dark + GLOB.stealth_test_dark_turfs[dark] = TRUE person.forceMove(dark) stealth_scans(guard, 10) - GLOB.stealth_test_dark_turfs -= dark + GLOB.stealth_test_dark_turfs[dark] = FALSE TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard saw someone 6 tiles off in the dark") qdel(guard) // In front, 8 tiles, lit: never alert from off-screen. From b165c92872d7e11a443b07ca9f8f71ad2b32ba53 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Mon, 9 Nov 2026 12:50:14 -0800 Subject: [PATCH 06/78] Keep AI awake on a forced-active z-level while ghosted --- voidcrew/modules/npc_ships/code/admin_verbs.dm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/voidcrew/modules/npc_ships/code/admin_verbs.dm b/voidcrew/modules/npc_ships/code/admin_verbs.dm index c62568887a6..04e08c76142 100644 --- a/voidcrew/modules/npc_ships/code/admin_verbs.dm +++ b/voidcrew/modules/npc_ships/code/admin_verbs.dm @@ -281,6 +281,14 @@ ADMIN_VERB(force_z_level_active, R_DEBUG, "Force Z-Level Active", "Keep a z-leve message_admins("[key_name_admin(user)] forced z-level [z_level] active for AI debugging.") BLACKBOX_LOG_ADMIN_VERB("Force Z-Level Active") +// tg idles an AI unless a living mob with a client is in its nearby grid cells. A ghost isn't living and the +// activator dummy has no client, so on a forced-active level the AI would sit idle and never plan. +/datum/ai_controller/should_idle() + var/turf/pawn_turf = get_turf(pawn) + if(pawn_turf && GLOB.z_level_activator_dummies["[pawn_turf.z]"]) + return FALSE + return ..() + /// Global list of room visualization overlays (ship_ref -> list of overlay images) GLOBAL_LIST_EMPTY(room_visualization_overlays) From 7c3ac8f6435b4ce6bdc84a2e30595e860c5ec54e Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Mon, 9 Nov 2026 15:23:38 -0800 Subject: [PATCH 07/78] Stealth guards calm down after downing their target, wary fades, admin view of every guard's sight Guards with nobody else noticed say a line, look round for a few seconds and go back to their route after killing or downing their target. Hits from a second attacker during a fight are remembered. Wary now fades after three minutes with nothing new. Admins can show the sight of every guard on their level at once. The notice map moves off the blackboard, whose qdel sweep runtimed on it. --- voidcrew/_DEFINES/stealth.dm | 12 +- voidcrew/modules/stealth/scav_guards.dm | 2 + voidcrew/modules/stealth/stealth_admin.dm | 80 ++++++++++-- voidcrew/modules/stealth/stealth_ai.dm | 123 ++++++++++++++++-- .../modules/unit_tests/voidcrew_stealth.dm | 86 +++++++++++- 5 files changed, 278 insertions(+), 25 deletions(-) diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index 6fefe3e1bc7..f479200fef1 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -13,10 +13,8 @@ #define BB_STEALTH_STATE_SINCE "stealth_state_since" /// world.time the guard last stopped being unaware (stealth_was_unaware()) #define BB_STEALTH_UNAWARE_LOST_AT "stealth_unaware_lost_at" -/// TRUE once alerted, searching or hit. Never cleared by time or dormancy. +/// TRUE once alerted, searching or hit. Fades after STEALTH_WARY_TIME with nothing new (checked each scan). #define BB_STEALTH_WARY "stealth_wary" -/// REF(mob) => list(notice, turf last scan, world.time last perceived) -#define BB_STEALTH_NOTICE "stealth_notice" /// The candidate with the highest notice #define BB_STEALTH_FOCUS "stealth_focus" /// Where it last saw (or was hit from) whoever it is after @@ -28,7 +26,7 @@ /// Its claimed stop, or the sentry's post #define BB_STEALTH_HOME_TURF "stealth_home_turf" -// Notice entry fields +// Notice entry fields (the controller's notice_map) #define STEALTH_ENTRY_NOTICE 1 #define STEALTH_ENTRY_TURF 2 #define STEALTH_ENTRY_SEEN_AT 3 @@ -41,6 +39,8 @@ #define STEALTH_BARK_HIT_UNSEEN "stealth_hit_unseen" #define STEALTH_BARK_BODY "stealth_body" #define STEALTH_BARK_CHATTER "stealth_chatter" +/// It just put its target down +#define STEALTH_BARK_DOWNED "stealth_target_downed" // ===== What a stealth goto is for ===== #define STEALTH_GOTO_PATROL "patrol" @@ -79,6 +79,10 @@ #define STEALTH_SUSPICIOUS_TIMEOUT (12 SECONDS) #define STEALTH_LOSE_TARGET_TIME (4 SECONDS) #define STEALTH_SEARCH_TIME (40 SECONDS) +/// After putting its target down with nobody else about: how long it looks round before calming down +#define STEALTH_CALM_LOOK_TIME (6 SECONDS) +/// How long wary lasts after the last notice gain, hit, touch, alert or search +#define STEALTH_WARY_TIME (3 MINUTES) #define STEALTH_SEARCH_POINTS 3 #define STEALTH_SEARCH_RADIUS 5 #define STEALTH_BODY_SCAN_INTERVAL (2 SECONDS) diff --git a/voidcrew/modules/stealth/scav_guards.dm b/voidcrew/modules/stealth/scav_guards.dm index cc54f580537..82bf667f0de 100644 --- a/voidcrew/modules/stealth/scav_guards.dm +++ b/voidcrew/modules/stealth/scav_guards.dm @@ -18,6 +18,7 @@ STEALTH_BARK_HIT_UNSEEN = list("Contact!", "Where's that coming from?"), STEALTH_BARK_BODY = list("Man down!", "Who did this?"), STEALTH_BARK_CHATTER = list("Shipment's late again.", "My feet are killing me.", "You hear that? No? Good."), + STEALTH_BARK_DOWNED = list("Got 'em.", "Stay down.", "That's handled."), ) emotes = list( HUMAN_NPC_BARK_DOWNED = list("collapses."), @@ -26,6 +27,7 @@ STEALTH_BARK_SEARCH = list("checks behind a crate."), STEALTH_BARK_HIT_UNSEEN = list("ducks."), STEALTH_BARK_CHATTER = list("yawns.", "stretches."), + STEALTH_BARK_DOWNED = list("spits."), ) chances = list(RUIN_NPC_BARK_SPOT = 100) diff --git a/voidcrew/modules/stealth/stealth_admin.dm b/voidcrew/modules/stealth/stealth_admin.dm index fc3e9d3c847..d0616631683 100644 --- a/voidcrew/modules/stealth/stealth_admin.dm +++ b/voidcrew/modules/stealth/stealth_admin.dm @@ -2,7 +2,8 @@ * # Stealth guard admin tools * * "Stealth Guards" (Debug): lists every stealth guard on your z-level, shows and forces its awareness, - * shows its sight to you alone, and acts on whole groups. Every action is logged (abuse review P16). + * shows its sight to you alone (one guard, or every guard on the level at once), and acts on whole groups. + * Every action is logged (abuse review P16). * * The AI sleeps unless a living player is on the level. An admin watching as a ghost needs * "Force Z-Level Active" (npc_ships/code/admin_verbs.dm). @@ -25,12 +26,16 @@ var/atom/focus = stealth_ai.blackboard[BB_STEALTH_FOCUS] var/focus_text = "none" if(focus) - var/list/entry = stealth_ai.blackboard[BB_STEALTH_NOTICE]?[REF(focus)] + var/list/entry = stealth_ai.notice_map?[REF(focus)] focus_text = "[focus] [entry ? round(entry[STEALTH_ENTRY_NOTICE], 0.01) : "-"]" var/since = round((world.time - stealth_ai.blackboard[BB_STEALTH_STATE_SINCE]) / (1 SECONDS)) var/route_text = stealth_ai.route_id ? "route [stealth_ai.route_id] stop [stealth_ai.route_index]" : "sentry" var/status_text = list("[AI_STATUS_ON]" = "on", "[AI_STATUS_IDLE]" = "idle", "[AI_STATUS_OFF]" = "off")["[stealth_ai.ai_status]"] || "off" - return "[guard.real_name] [REF(guard)] | [stealth_ai.group?.id || "no group"] | [stealth_ai.stealth_state()] [since]s | focus [focus_text] | [stealth_ai.blackboard[BB_STEALTH_WARY] ? "wary" : "calm"] | [route_text] | AI [status_text]" + var/state_text = stealth_ai.calm_until ? "[stealth_ai.stealth_state()] (calming)" : stealth_ai.stealth_state() + var/wary_text = "calm" + if(stealth_ai.blackboard[BB_STEALTH_WARY]) + wary_text = "wary [max(0, round((STEALTH_WARY_TIME - (world.time - stealth_ai.wary_at)) / (1 SECONDS)))]s" + return "[guard.real_name] [REF(guard)] | [stealth_ai.group?.id || "no group"] | [state_text] [since]s | focus [focus_text] | [wary_text] | [route_text] | AI [status_text]" ADMIN_VERB(stealth_guards, R_DEBUG, "Stealth Guards", "View and force the awareness of stealth guards on your z-level.", ADMIN_CATEGORY_DEBUG) var/turf/here = get_turf(user.mob) @@ -47,11 +52,15 @@ ADMIN_VERB(stealth_guards, R_DEBUG, "Stealth Guards", "View and force the awaren if(!length(choices)) to_chat(user, span_notice("No stealth guards on this z-level."), confidential = TRUE) return - var/list/all_choices = sort_list(choices) + sort_list(groups) + var/level_choice = "Every guard on this level: toggle sight" + var/list/all_choices = list(level_choice) + sort_list(choices) + sort_list(groups) var/choice = tgui_input_list(user, "Which guard or group?", "Stealth Guards", all_choices) if(isnull(choice)) return - if(groups[choice]) + if(choice == level_choice) + var/shown = stealth_toggle_level_sight(user, here.z) + stealth_admin_log(user, "[shown ? "showed" : "hid"] the sight of every guard on z[here.z]", here) + else if(groups[choice]) stealth_admin_group(user, groups[choice]) else if(choices[choice]) stealth_admin_guard(user, choices[choice]) @@ -95,7 +104,10 @@ ADMIN_VERB(stealth_guards, R_DEBUG, "Stealth Guards", "View and force the awaren stealth_ai.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) stealth_ai.stealth_go_searching(here) if("Toggle Wary") - stealth_ai.blackboard[BB_STEALTH_WARY] = !stealth_ai.blackboard[BB_STEALTH_WARY] + if(stealth_ai.blackboard[BB_STEALTH_WARY]) + stealth_ai.stealth_clear_wary() + else + stealth_ai.stealth_set_wary() if("Show its sight") stealth_toggle_sight_overlay(user, guard) if("Jump to it") @@ -126,7 +138,7 @@ ADMIN_VERB(stealth_guards, R_DEBUG, "Stealth Guards", "View and force the awaren stealth_ai.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) stealth_ai.stealth_go_unaware() if("Clear wary") - stealth_ai.blackboard[BB_STEALTH_WARY] = FALSE + stealth_ai.stealth_clear_wary() if("Alert all on me") if(isliving(user.mob)) stealth_ai.stealth_go_alert(user.mob) @@ -160,6 +172,45 @@ ADMIN_VERB(stealth_guards, R_DEBUG, "Stealth Guards", "View and force the awaren /// Admins watching one guard's sight: admin ckey => overlay GLOBAL_LIST_EMPTY(stealth_sight_overlays) +/// The GLOB.stealth_sight_overlays key for `user`'s whole-level view. +#define STEALTH_LEVEL_OVERLAY_KEY(user) "level:[user.ckey]" + +/// Shows or hides the sight of every stealth guard on `z` to `user`. TRUE if now shown. +/proc/stealth_toggle_level_sight(client/user, z) + var/datum/stealth_level_overlay/old = GLOB.stealth_sight_overlays[STEALTH_LEVEL_OVERLAY_KEY(user)] + if(old) + qdel(old) + return FALSE + new /datum/stealth_level_overlay(user, z) + return TRUE + +/** + * Every guard's sight on one level, for one admin: one child overlay per guard. Ends on a second toggle + * or after STEALTH_ADMIN_OVERLAY_TIME; a guard that dies or is deleted drops its own child. + */ +/datum/stealth_level_overlay + var/key + var/list/datum/stealth_sight_overlay/children = list() + +/datum/stealth_level_overlay/New(client/user, z) + key = STEALTH_LEVEL_OVERLAY_KEY(user) + GLOB.stealth_sight_overlays[key] = src + for(var/mob/living/carbon/human/npc/guard as anything in stealth_guards_on_level(z)) + if(guard.stat == DEAD || !istype(guard.ai_controller, /datum/ai_controller/basic_controller/human_npc/stealth)) + continue + children += new /datum/stealth_sight_overlay(user, guard, src) + QDEL_IN(src, STEALTH_ADMIN_OVERLAY_TIME) + +/datum/stealth_level_overlay/Destroy() + if(GLOB.stealth_sight_overlays[key] == src) + GLOB.stealth_sight_overlays -= key + for(var/datum/stealth_sight_overlay/child as anything in children.Copy()) + qdel(child) + children.Cut() + return ..() + +#undef STEALTH_LEVEL_OVERLAY_KEY + /proc/stealth_toggle_sight_overlay(client/user, mob/living/carbon/human/npc/guard) var/datum/stealth_sight_overlay/old = GLOB.stealth_sight_overlays[user.ckey] var/same = old?.guard_ref?.resolve() == guard @@ -179,22 +230,29 @@ GLOBAL_LIST_EMPTY(stealth_sight_overlays) var/datum/weakref/guard_ref var/ckey var/list/image/images = list() + /// The whole-level view this belongs to, or null for a single guard's + var/datum/stealth_level_overlay/parent -/datum/stealth_sight_overlay/New(client/user, mob/living/carbon/human/npc/guard) +/datum/stealth_sight_overlay/New(client/user, mob/living/carbon/human/npc/guard, datum/stealth_level_overlay/parent) user_ref = WEAKREF(user) guard_ref = WEAKREF(guard) ckey = user.ckey - GLOB.stealth_sight_overlays[ckey] = src + src.parent = parent + if(isnull(parent)) + GLOB.stealth_sight_overlays[ckey] = src + QDEL_IN(src, STEALTH_ADMIN_OVERLAY_TIME) var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller LAZYADD(stealth_ai.watchers, src) RegisterSignal(guard, COMSIG_LIVING_DEATH, PROC_REF(on_guard_gone)) RegisterSignal(guard, COMSIG_QDELETING, PROC_REF(on_guard_gone)) - QDEL_IN(src, STEALTH_ADMIN_OVERLAY_TIME) refresh() /datum/stealth_sight_overlay/Destroy() clear() - if(GLOB.stealth_sight_overlays[ckey] == src) + if(parent) + parent.children -= src + parent = null + else if(GLOB.stealth_sight_overlays[ckey] == src) GLOB.stealth_sight_overlays -= ckey var/mob/living/carbon/human/npc/guard = guard_ref?.resolve() if(guard) diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index 9580dff84bd..8d235f45e69 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -14,8 +14,12 @@ * can_attack() (no cone, no darkness); out of sight for STEALTH_LOSE_TARGET_TIME, it searches. * - Searching: runs to where it last saw someone and sweeps the spots round it, then gives up. * - * Wary (BB_STEALTH_WARY) is set by any alert, search, hit or surrender and is never cleared: a wider cone - * and quicker notice for the rest of its life (abuse review P4). + * Wary (BB_STEALTH_WARY) is set by any alert, search, hit or surrender: a wider cone and quicker notice + * (abuse review P4). It fades after STEALTH_WARY_TIME with nothing new: every notice gain, hit, touch and + * scan spent alert or searching starts that clock again (owner decision 23). + * + * Putting its target down (dead or in crit) with nobody else noticed ends the alarm: a short line, a look + * round where it stands for STEALTH_CALM_LOOK_TIME, then back to its route (decision 23). * * Every attack or touch gets a reaction, even from out of sight (P3): alert on the attacker if it can see * them, otherwise a search at their turf. Detection is a once-a-second scan owned by this controller, never @@ -110,12 +114,19 @@ var/last_stat = CONSCIOUS /// Admins watching its sight overlay (stealth_admin.dm) var/list/datum/stealth_sight_overlay/watchers + /// REF(mob) => list(notice, turf last scan, world.time last perceived). Not a blackboard key: the + /// blackboard's qdel sweep indexes every nested list by its values, and these hold plain numbers. + var/list/notice_map + /// world.time wary was last set or refreshed + var/wary_at = 0 + /// Searching after putting its target down: world.time it calms down, or 0 + var/calm_until = 0 /datum/ai_controller/basic_controller/human_npc/stealth/TryPossessPawn(atom/new_pawn) . = ..() if(. & AI_CONTROLLER_INCOMPATIBLE) return - blackboard[BB_STEALTH_NOTICE] = list() + notice_map = list() blackboard[BB_STEALTH_BODIES_SEEN] = list() blackboard[BB_STEALTH_STATE_SINCE] = world.time RegisterSignal(new_pawn, COMSIG_LIVING_GET_PULLED, PROC_REF(on_pulled)) @@ -160,6 +171,9 @@ blackboard[BB_STEALTH_STATE_SINCE] = world.time look_until = 0 lost_since = 0 + calm_until = 0 + if(new_state == STEALTH_ALERT || new_state == STEALTH_SEARCHING) + stealth_set_wary() stealth_drop_walk() var/run = (new_state == STEALTH_ALERT || new_state == STEALTH_SEARCHING) stealth_set_pace(run) @@ -167,8 +181,24 @@ for(var/datum/stealth_sight_overlay/overlay as anything in watchers) overlay.refresh() +/// Makes it wary, or starts the wary clock again. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_set_wary() blackboard[BB_STEALTH_WARY] = TRUE + wary_at = world.time + +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_clear_wary() + blackboard[BB_STEALTH_WARY] = FALSE + wary_at = 0 + +/// Each scan: alert or searching keeps it wary; otherwise wary fades once STEALTH_WARY_TIME passes with nothing new. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_update_wary() + if(!blackboard[BB_STEALTH_WARY]) + return + var/state = stealth_state() + if(state == STEALTH_ALERT || state == STEALTH_SEARCHING) + wary_at = world.time + else if(world.time - wary_at >= STEALTH_WARY_TIME) + stealth_clear_wary() /// Walks (calm) or runs, through tg's own move intent, as bounty_ai_set_pace() does. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_set_pace(run) @@ -201,7 +231,7 @@ return clamped /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_go_unaware() - var/list/notice = blackboard[BB_STEALTH_NOTICE] + var/list/notice = notice_map notice?.Cut() clear_blackboard_key(BB_STEALTH_FOCUS) search_queue?.Cut() @@ -288,6 +318,9 @@ if(blackboard[BB_STEALTH_UNAWARE_LOST_AT]) blackboard[BB_STEALTH_UNAWARE_LOST_AT] -= time last_gain -= time + wary_at -= time + if(calm_until) + calm_until -= time if(lost_since) lost_since -= time wait_until -= time @@ -307,8 +340,12 @@ if(QDELETED(guard) || guard.stat != CONSCIOUS) return stealth_setup() + stealth_update_wary() var/state = stealth_state() - if(state == STEALTH_SEARCHING && world.time - blackboard[BB_STEALTH_STATE_SINCE] >= STEALTH_SEARCH_TIME) + if(state == STEALTH_SEARCHING && calm_until) + if(world.time >= calm_until) + stealth_go_unaware() + else if(state == STEALTH_SEARCHING && world.time - blackboard[BB_STEALTH_STATE_SINCE] >= STEALTH_SEARCH_TIME) stealth_bark(STEALTH_BARK_GIVE_UP) stealth_go_unaware() else if(state == STEALTH_SUSPICIOUS && world.time - last_gain >= STEALTH_SUSPICIOUS_TIMEOUT) @@ -345,7 +382,7 @@ /// Looks for someone new: raises notice on whoever it perceives, decays the rest, changes state. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_look() var/mob/living/carbon/human/guard = pawn - var/list/notice = blackboard[BB_STEALTH_NOTICE] + var/list/notice = notice_map var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) if(isnull(strategy) || !isturf(guard.loc)) return @@ -408,6 +445,7 @@ rate *= STEALTH_SEARCHING_MULT if(wary) rate *= STEALTH_WARY_MULT + wary_at = world.time entry[STEALTH_ENTRY_NOTICE] += rate * scan_seconds if(felt && running) entry[STEALTH_ENTRY_NOTICE] = max(entry[STEALTH_ENTRY_NOTICE], STEALTH_SUSPICIOUS_AT) @@ -477,11 +515,16 @@ if(!target) set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, remembered) return - // In plain sight but no longer worth fighting (down, dead, an ally now): look round where they fell. + // In plain sight but no longer worth fighting. if(get_dist(guard, remembered) <= HUMAN_NPC_SIGHT_RANGE && can_see(guard, remembered, HUMAN_NPC_SIGHT_RANGE)) clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) clear_blackboard_key(BB_STEALTH_FOCUS) - stealth_go_searching(get_turf(remembered)) + var/mob/living/fallen = remembered + if(isliving(fallen) && (fallen.stat != CONSCIOUS || HAS_TRAIT(fallen, TRAIT_INCAPACITATED))) + stealth_target_downed(fallen) + else + // An ally now, or out of reach: look round where it last was. + stealth_go_searching(get_turf(remembered)) return if(!lost_since) lost_since = world.time @@ -491,6 +534,54 @@ stealth_bark(STEALTH_BARK_LOST) stealth_go_searching(blackboard[BB_STEALTH_LAST_SEEN_TURF]) +/** + * Its target is down (decision 23). Anyone else it has noticed keeps the alarm going as usual: alert on + * someone it can see who hit it or was nearly spotted, otherwise suspicious or searching where they were. + * With nobody else it says so, looks round where it stands, and calms down once STEALTH_CALM_LOOK_TIME is + * up. The fallen one is forgotten: if they get up, they are noticed afresh (against a wary guard). + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_target_downed(mob/living/fallen) + var/mob/living/guard = pawn + var/list/notice = notice_map + notice -= REF(fallen) + stealth_set_state(STEALTH_SEARCHING) + search_center = get_turf(guard) + search_queue?.Cut() + search_looking = FALSE + calm_until = world.time + STEALTH_CALM_LOOK_TIME + look_until = calm_until + stand_dir = guard.dir + // Anyone it noticed lately or who hit it during the fight, read before this look decays them. + var/best_notice = 0 + var/turf/best_turf + var/mob/living/best + for(var/key in notice) + var/list/entry = notice[key] + if(entry[STEALTH_ENTRY_NOTICE] < STEALTH_SUSPICIOUS_AT || entry[STEALTH_ENTRY_NOTICE] <= best_notice) + continue + if(world.time - entry[STEALTH_ENTRY_SEEN_AT] > STEALTH_NOTICE_FORGET) + continue + var/mob/living/someone = locate(key) + if(!isliving(someone) || QDELETED(someone) || someone.stat == DEAD) + continue + best_notice = entry[STEALTH_ENTRY_NOTICE] + best_turf = entry[STEALTH_ENTRY_TURF] + best = someone + // One look now: anyone else in view goes the normal way (suspicious or alert). + stealth_look() + if(stealth_state() != STEALTH_SEARCHING || !calm_until) + return + if(best) + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) + if(best_notice >= STEALTH_ALERT_AT && strategy?.can_attack(guard, best, HUMAN_NPC_SIGHT_RANGE)) + stealth_go_alert(best) + else if(best_notice >= STEALTH_ALERT_AT) + stealth_go_searching(best_turf) + else + stealth_go_suspicious(best_turf) + return + stealth_bark(STEALTH_BARK_DOWNED) + /** * Fallen friends (abuse P13): group members that are dead, in crit, cuffed or lying down, in its sight. * It reacts to each body once. The first guard to find one is suspicious and walks over; a guard that @@ -548,6 +639,16 @@ return FALSE stealth_set_wary() if(stealth_state() == STEALTH_ALERT && blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + // Busy with someone else: it remembers who else is hurting it for when that fight ends. + if(isliving(source) && source != blackboard[BB_BASIC_MOB_CURRENT_TARGET]) + var/list/notice = notice_map + var/list/entry = notice[REF(source)] + if(isnull(entry)) + entry = list(0, null, 0) + notice[REF(source)] = entry + entry[STEALTH_ENTRY_NOTICE] = max(entry[STEALTH_ENTRY_NOTICE], STEALTH_ALERT_AT) + entry[STEALTH_ENTRY_TURF] = get_turf(source) + entry[STEALTH_ENTRY_SEEN_AT] = world.time return FALSE var/atom/who = isliving(source) ? bounty_ai_target_for(source) : source var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) @@ -623,7 +724,7 @@ return stealth_go_searching(get_turf(guard)) -// A guard that gives up is wary from then on. +// A guard that gives up is wary. /mob/living/carbon/human/npc/npc_surrender() . = ..() if(.) @@ -695,6 +796,10 @@ controller.queue_behavior(/datum/ai_behavior/stealth_stand) return SUBTREE_RETURN_FINISH_PLANNING if(STEALTH_SEARCHING) + // Its target is down: it looks round where it stands until it calms down. + if(controller.calm_until) + controller.queue_behavior(/datum/ai_behavior/stealth_stand) + return SUBTREE_RETURN_FINISH_PLANNING if(world.time >= controller.next_search_bark) controller.next_search_bark = world.time + STEALTH_SEARCH_BARK_INTERVAL controller.stealth_bark(STEALTH_BARK_SEARCH) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth.dm b/voidcrew/modules/unit_tests/voidcrew_stealth.dm index 72adddda140..99debed4084 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth.dm @@ -1,7 +1,7 @@ // Stealth guards (voidcrew/modules/stealth/). Unit tests compile before voidcrew/_DEFINES, so values from // there are written out: states "unaware", "suspicious", "alert", "searching"; blackboard keys // "stealth_state", "stealth_wary", "stealth_last_seen_turf"; STEALTH_PATROL_MAX_FAILS 3, -// STEALTH_LOSE_TARGET_TIME 4 s, STEALTH_SEARCH_TIME 40 s. +// STEALTH_LOSE_TARGET_TIME 4 s, STEALTH_SEARCH_TIME 40 s, STEALTH_CALM_LOOK_TIME 6 s, STEALTH_WARY_TIME 3 min. #define STEALTH_TEST_GUARD /mob/living/carbon/human/npc/ruin/trooper/scav @@ -320,4 +320,88 @@ TEST_ASSERT(!(group in GLOB.stealth_groups), "A group with no marker and no guards is still registered") qdel(block) +/// Its target dead with nobody else about: a short look round, then unaware. Anyone else in view or hurting it +/// keeps the alarm going. +/datum/unit_test/voidcrew_stealth_calm + +/datum/unit_test/voidcrew_stealth_calm/Run() + var/datum/turf_reservation/block = stealth_block(12, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/target = stealth_person(block, 4, 2) + stealth_ai.stealth_go_alert(target) + stealth_scans(guard, 1) + target.death() + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "searching", "A guard that killed its target isn't looking round") + TEST_ASSERT(stealth_ai.calm_until, "A guard that killed its target with nobody about isn't calming down") + TEST_ASSERT_NULL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], "A guard still has a dead target") + stealth_ai.stealth_rewind(7 SECONDS) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard didn't calm down after its target died") + TEST_ASSERT(stealth_ai.blackboard["stealth_wary"], "A guard that just fought isn't wary") + qdel(guard) + qdel(target) + // Someone else in plain view: no calming down. + guard = stealth_guard(block, 2, 2) + stealth_ai = stealth_ai(guard) + target = stealth_person(block, 4, 2) + var/mob/living/carbon/human/bystander = stealth_person(block, 5, 3) + stealth_ai.stealth_go_alert(target) + target.death() + stealth_scans(guard, 1) + TEST_ASSERT(stealth_ai.stealth_state() == "suspicious" || stealth_ai.stealth_state() == "alert", "A guard calmed down with someone else in front of it") + TEST_ASSERT(!stealth_ai.calm_until, "A guard is calming down with someone else in front of it") + qdel(guard) + qdel(target) + qdel(bystander) + // Someone behind it hit it during the fight: it turns on them. + guard = stealth_guard(block, 6, 2) + stealth_ai = stealth_ai(guard) + target = stealth_person(block, 8, 2) + var/mob/living/carbon/human/flanker = stealth_person(block, 3, 2) + stealth_ai.stealth_go_alert(target) + SEND_SIGNAL(guard, COMSIG_ATOM_WAS_ATTACKED, flanker, ATTACKER_DAMAGING_ATTACK) + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], target, "A hit from someone else pulled the guard off its target") + target.death() + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard calmed down while someone else was hurting it") + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], flanker, "The guard didn't turn on whoever else hit it") + qdel(block) + +/// Wary fades after STEALTH_WARY_TIME with nothing new; a notice gain starts the clock again. +/datum/unit_test/voidcrew_stealth_wary_fade + +/datum/unit_test/voidcrew_stealth_wary_fade/Run() + var/datum/turf_reservation/block = stealth_block(12, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + stealth_ai.stealth_go_searching(stealth_at(block, 3, 3)) + stealth_ai.stealth_rewind(41 SECONDS) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "The search didn't end") + TEST_ASSERT(stealth_ai.blackboard["stealth_wary"], "A guard that searched isn't wary") + stealth_ai.stealth_rewind(2 MINUTES) + stealth_scans(guard, 1) + TEST_ASSERT(stealth_ai.blackboard["stealth_wary"], "Wary faded too soon") + // A glimpse of someone far off starts the clock again. + var/mob/living/carbon/human/person = stealth_person(block, 9, 2) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A glimpse at the edge of sight made the guard suspicious") + qdel(person) + stealth_ai.stealth_rewind(2 MINUTES) + stealth_scans(guard, 1) + TEST_ASSERT(stealth_ai.blackboard["stealth_wary"], "A notice gain didn't refresh wary") + stealth_ai.stealth_rewind(70 SECONDS) + stealth_scans(guard, 1) + TEST_ASSERT(!stealth_ai.blackboard["stealth_wary"], "Wary didn't fade with nothing new") + TEST_ASSERT(stealth_ai.stealth_half_angle() == 60, "A guard no longer wary still has the wary cone") + // A hit makes it wary again. + var/mob/living/carbon/human/attacker = stealth_person(block, 11, 4) + SEND_SIGNAL(guard, COMSIG_ATOM_WAS_ATTACKED, attacker, ATTACKER_DAMAGING_ATTACK) + TEST_ASSERT(stealth_ai.blackboard["stealth_wary"], "A hit didn't make the guard wary again") + qdel(block) + #undef STEALTH_TEST_GUARD From b52043a50c6e46a7c7d2a37b3bbb343a4b397b91 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Mon, 9 Nov 2026 15:34:32 -0800 Subject: [PATCH 08/78] Human NPC gunners check the bullet's real path for allies The ally check walked get_line(), which takes one turf per step. A shot at an angle clips turfs beside that line, so a gunner fired past a guard standing next to its target and hit him. The check now walks every turf the straight line passes through. --- voidcrew/modules/human_npcs/human_npc_ai.dm | 38 ++++++++++++++++++- .../modules/unit_tests/voidcrew_human_npcs.dm | 38 +++++++++++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/voidcrew/modules/human_npcs/human_npc_ai.dm b/voidcrew/modules/human_npcs/human_npc_ai.dm index b2aea64e703..fb42989a309 100644 --- a/voidcrew/modules/human_npcs/human_npc_ai.dm +++ b/voidcrew/modules/human_npcs/human_npc_ai.dm @@ -513,7 +513,7 @@ /proc/human_npc_ally_in_line(mob/living/shooter, atom/target) var/turf/shooter_turf = get_turf(shooter) var/turf/target_turf = get_turf(target) - for(var/turf/line_turf as anything in get_line(shooter_turf, target_turf)) + for(var/turf/line_turf as anything in human_npc_shot_path(shooter_turf, target_turf)) if(line_turf == shooter_turf || line_turf == target_turf) continue for(var/mob/living/other in line_turf) @@ -523,6 +523,42 @@ return TRUE return FALSE +/** + * Every turf a shot from the centre of `start_turf` to the centre of `end_turf` passes through, in order. A bullet + * flies the straight line, so at an angle it clips turfs that get_line()'s one-turf-per-step line skips + * (someone beside the target, a tile off that line). Where the line runs exactly through a corner both + * turfs beside it count. + */ +/proc/human_npc_shot_path(turf/start_turf, turf/end_turf) + . = list(start_turf) + if(isnull(start_turf) || isnull(end_turf) || start_turf.z != end_turf.z) + return + var/x_sign = SIGN(end_turf.x - start_turf.x) + var/y_sign = SIGN(end_turf.y - start_turf.y) + var/x_count = abs(end_turf.x - start_turf.x) + var/y_count = abs(end_turf.y - start_turf.y) + var/x = start_turf.x + var/y = start_turf.y + var/x_done = 0 + var/y_done = 0 + while(x_done < x_count || y_done < y_count) + // Which grid line the shot crosses next: a vertical one (< 0), a horizontal one (> 0) or both at a corner. + var/decision = (1 + 2 * x_done) * y_count - (1 + 2 * y_done) * x_count + if(decision == 0) + . += locate(x + x_sign, y, start_turf.z) + . += locate(x, y + y_sign, start_turf.z) + x += x_sign + y += y_sign + x_done++ + y_done++ + else if(decision < 0) + x += x_sign + x_done++ + else + y += y_sign + y_done++ + . += locate(x, y, start_turf.z) + /// One step sideways, keeping no further from the target, for a clear shot. /proc/human_npc_sidestep(mob/living/shooter, atom/target) var/turf/our_turf = get_turf(shooter) diff --git a/voidcrew/modules/unit_tests/voidcrew_human_npcs.dm b/voidcrew/modules/unit_tests/voidcrew_human_npcs.dm index 7916bed68e1..d7fa9db4e58 100644 --- a/voidcrew/modules/unit_tests/voidcrew_human_npcs.dm +++ b/voidcrew/modules/unit_tests/voidcrew_human_npcs.dm @@ -431,3 +431,41 @@ ware.forceMove(elsewhere) TEST_ASSERT(human_npc_wait_deleted(ware), "Chrome taken out of a living NPC stayed working") TEST_ASSERT_NOTNULL(locate(/obj/item/burnt_chrome) in elsewhere, "Chrome taken out of a living NPC left no scrap") + +/// A gunner holds fire with an ally anywhere on the bullet's path, including beside the target where a +/// diagonal shot clips the corner of their turf (owner playtest: a gunner shot the knife guard beside its target). +/datum/unit_test/voidcrew_human_npc_ally_in_line + +/datum/unit_test/voidcrew_human_npc_ally_in_line/Run() + var/turf/corner = run_loc_floor_bottom_left + TEST_ASSERT(run_loc_floor_top_right.x - corner.x >= 3 && run_loc_floor_top_right.y - corner.y >= 4, "Test fixture: the test room is too small") + var/mob/living/carbon/human/npc/sample/gunner/shooter = allocate(/mob/living/carbon/human/npc/sample/gunner, locate(corner.x, corner.y + 4, corner.z)) + var/mob/living/carbon/human/consistent/target = allocate(/mob/living/carbon/human/consistent, locate(corner.x + 3, corner.y, corner.z)) + var/mob/living/carbon/human/consistent/ally = allocate(/mob/living/carbon/human/consistent, locate(corner.x + 3, corner.y + 1, corner.z)) + ally.faction = shooter.faction.Copy() + TEST_ASSERT(!(ally.loc in get_line(shooter, target)), "Test fixture: the ally is on get_line(), so this doesn't test the clipped corner") + TEST_ASSERT(human_npc_ally_in_line(shooter, target), "A gunner fired past an ally standing beside its target") + // Straight down a corridor. + ally.forceMove(locate(corner.x + 2, corner.y + 2, corner.z)) + TEST_ASSERT(human_npc_ally_in_line(shooter, target), "A gunner fired through an ally between it and its target") + // Lying down: shots pass over. + ally.set_body_position(LYING_DOWN) + TEST_ASSERT(!human_npc_ally_in_line(shooter, target), "A gunner held fire for an ally lying down") + ally.set_body_position(STANDING_UP) + // Well off the path. + ally.forceMove(locate(corner.x + 3, corner.y + 4, corner.z)) + TEST_ASSERT(!human_npc_ally_in_line(shooter, target), "A gunner held fire for an ally nowhere near the path") + // A stranger on the path is not an ally. + ally.faction = list("ally_in_line_stranger") + ally.forceMove(locate(corner.x + 2, corner.y + 2, corner.z)) + TEST_ASSERT(!human_npc_ally_in_line(shooter, target), "A gunner held fire for someone not on its side") + +/// An ally's stray shot doesn't turn a human NPC on them. +/datum/unit_test/voidcrew_human_npc_ally_stray_hit + +/datum/unit_test/voidcrew_human_npc_ally_stray_hit/Run() + var/mob/living/carbon/human/npc/sample/gunner/npc = allocate(/mob/living/carbon/human/npc/sample/gunner, run_loc_floor_bottom_left) + var/mob/living/carbon/human/consistent/ally = allocate(/mob/living/carbon/human/consistent, locate(run_loc_floor_bottom_left.x + 1, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)) + ally.faction = npc.faction.Copy() + SEND_SIGNAL(npc, COMSIG_ATOM_WAS_ATTACKED, ally, ATTACKER_DAMAGING_ATTACK) + TEST_ASSERT_NULL(npc.ai_controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET], "An ally's stray shot made the NPC target them") From f05057abf1bdeea21e3bae7018347850471be244 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Mon, 9 Nov 2026 15:58:34 -0800 Subject: [PATCH 09/78] Stealth guards show a ? or ! over their heads, and wary wears off after 60 s The ? fills as a guard notices you and only you see it. Alert is a red ! for everyone; it drains while the guard has lost you, then turns into a yellow ? that drains over the search. Drawn on the guard, so never through walls, and above the lighting so it reads in the dark. Built only with a player nearby. Wary now fades after 60 seconds with nothing new. --- tgstation.dme | 1 + voidcrew/_DEFINES/stealth.dm | 12 +- voidcrew/icons/effects/stealth_meter.dmi | Bin 0 -> 869 bytes voidcrew/modules/stealth/stealth_ai.dm | 7 + voidcrew/modules/stealth/stealth_meter.dm | 247 ++++++++++++++++++ .../modules/unit_tests/voidcrew_stealth.dm | 93 ++++++- 6 files changed, 355 insertions(+), 5 deletions(-) create mode 100644 voidcrew/icons/effects/stealth_meter.dmi create mode 100644 voidcrew/modules/stealth/stealth_meter.dm diff --git a/tgstation.dme b/tgstation.dme index 5436811288d..40fb9422b1e 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7730,6 +7730,7 @@ #include "voidcrew\modules\stealth\scav_guards.dm" #include "voidcrew\modules\stealth\stealth_admin.dm" #include "voidcrew\modules\stealth\stealth_ai.dm" +#include "voidcrew\modules\stealth\stealth_meter.dm" #include "voidcrew\modules\stealth\stealth_patrol.dm" #include "voidcrew\modules\stealth\stealth_perception.dm" #include "voidcrew\modules\stealth\stealth_test_ruin.dm" diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index f479200fef1..b2a833d134e 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -82,7 +82,7 @@ /// After putting its target down with nobody else about: how long it looks round before calming down #define STEALTH_CALM_LOOK_TIME (6 SECONDS) /// How long wary lasts after the last notice gain, hit, touch, alert or search -#define STEALTH_WARY_TIME (3 MINUTES) +#define STEALTH_WARY_TIME (60 SECONDS) #define STEALTH_SEARCH_POINTS 3 #define STEALTH_SEARCH_RADIUS 5 #define STEALTH_BODY_SCAN_INTERVAL (2 SECONDS) @@ -104,5 +104,15 @@ /// Seconds of search between "Come on out." lines #define STEALTH_SEARCH_BARK_INTERVAL (12 SECONDS) +// The mark over a guard's head (stealth_meter.dm, owner decision 27) +/// Pixel rows in the "?" and "!" glyphs: fill and drain steps +#define STEALTH_METER_ROWS 7 +/// Tiles from the guard within which a living player makes the mark worth drawing +#define STEALTH_METER_RANGE 10 +/// pixel_z of the glyph's bottom over a standing, medium-height guard: 1 px clear of the head +#define STEALTH_METER_HEAD_Z 30 +/// pixel_z of the glyph's bottom over a guard lying down +#define STEALTH_METER_LYING_Z 17 + /// The scav den's side #define FACTION_SCAV "scav" diff --git a/voidcrew/icons/effects/stealth_meter.dmi b/voidcrew/icons/effects/stealth_meter.dmi new file mode 100644 index 0000000000000000000000000000000000000000..d22aa60e03b7204cc951054b9d79489358601a88 GIT binary patch literal 869 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K55;)j^Mqo;508us>{dHL)>e67LG zo8|3w25&cB=l4E%KW($|*;N-_y4S-)7QQ%hyl#1)QbnFi8;v^ zb5bDY@6;2%=3DOT|7JMD_rZ5%U;26m2BvIJ7srr_IY1}n-8K+m2w3@HhN5$u((x0T zMo&0woz7oO{=y?`lkw(;=5Y?2louBa9k_2TRkqL#2-e!Kxp%vSpg{fe=k=2owBIiU z1r8=SP=9UupG#-Y{+_@5{Ji<)uJ2X%{aL+#$G_L!&G+xy%gpCJTz08lApYOg`;~vc zZ>hDk+g*D@m2g_-TCqO=mNHnPwhATo3~B>?(_cmZyzte-XWQNRNnmGlppQo z7QucsB0za>-WhlJT$jeEn8!`AeEdDQPieVz;oEA4kIA3wcL{gy&({0DSy$Ec|IbJJ z@BV!f|F?9jKf~ks+2RX+d|Ll++4uO1stMEj9&FW5ICe>J#W&WTAD{Lw`E`3sjpX(v zrzJi<-M{r0Gp5f#BL6()ZRf|-{0y%zoV@YZi=R&(ov!cx`n{sIw5II)U-zv)>ZSXl zOHFRf`F!%|^#8?6pWUwAaqoJ3m8^L(Z~y+sPmisat@oQP<}TD(Z~4=ox1u1UO{(az z>rU=I`{kRpHRVnJnatnA_A&l*{SD67VoxmoFSlO!lk@)g|i`AWV9p4n#&ieN9_VvH71^zl}q%mg9U`x^BKENV1 z;hO1Qh71Re7=~vv{Owv_9$3aK{6p8_i|(2qpWa6|91w1hy}>7=x$EC9)*q~;CFP>) SiUl5l+~Dcz=d#Wzp$P!?RFvBQ literal 0 HcmV?d00001 diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index 8d235f45e69..cfbc9fa46ee 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -151,6 +151,7 @@ for(var/datum/stealth_sight_overlay/overlay as anything in watchers?.Copy()) qdel(overlay) watchers = null + QDEL_NULL(meter) goto_turf = null investigate_turf = null search_center = null @@ -180,6 +181,7 @@ human_npc_set_ai_movement(src, new_state == STEALTH_ALERT ? /datum/ai_movement/basic_avoidance : /datum/ai_movement/jps/stealth) for(var/datum/stealth_sight_overlay/overlay as anything in watchers) overlay.refresh() + stealth_meter_update() /// Makes it wary, or starts the wary clock again. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_set_wary() @@ -359,6 +361,7 @@ stealth_check_bodies() for(var/datum/stealth_sight_overlay/overlay as anything in watchers) overlay.refresh() + stealth_meter_update() /// The cone half-angle it sees with now. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_half_angle() @@ -699,6 +702,8 @@ /// listens for the level change. /datum/ai_controller/basic_controller/human_npc/stealth/on_changed_z_level(atom/source, turf/old_turf, turf/new_turf, same_z_layer, notify_contents) . = ..() + // Its mark's plane belongs to the old level; the next scan builds a new one. + QDEL_NULL(meter) if(stealth_ready && new_turf) stealth_become_sentry(new_turf) @@ -706,6 +711,8 @@ . = ..() var/was = last_stat last_stat = new_stat + if(new_stat != CONSCIOUS) + QDEL_NULL(meter) if(new_stat == CONSCIOUS && was != CONSCIOUS && was != DEAD) stealth_came_round() diff --git a/voidcrew/modules/stealth/stealth_meter.dm b/voidcrew/modules/stealth/stealth_meter.dm new file mode 100644 index 00000000000..1de75bf3a18 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_meter.dm @@ -0,0 +1,247 @@ +/** + * # Stealth guards: the mark over the head (owner decisions 24 and 27, draft D) + * + * - Its notice of you above 0: a "?" only you see (a client image). It fills yellow from the bottom to + * STEALTH_SUSPICIOUS_AT, then red rises through the yellow toward STEALTH_ALERT_AT. + * - Alert: a solid red "!" everyone sees. Target out of sight: the red drains from the top over + * STEALTH_LOSE_TARGET_TIME and refills when it sees them again. + * - Searching: a yellow "?" everyone sees, draining from the top over the search (or until calm_until + * after it put its target down). Empty: gone. + * - While a public mark shows, nobody sees their own "?" on that guard. + * + * Both are drawn on the guard (vis_contents for the public mark, an image located on the guard for the + * private one), so they show only when the guard itself is in view, never through walls; above the + * lighting so they read in the dark. Fills round to the nearest row; drains round up, so the last row + * stays lit until the time really runs out. + * + * Cost: the meter is built only while a living player is within STEALTH_METER_RANGE of a conscious guard, + * updated by the guard's 1 s scan and its state changes, and changes an icon_state only when the step + * changes. A drain steps on a timer at each row change (at most STEALTH_METER_ROWS per drain); animate() + * is not used, because a chained icon_state animation can't snap back when the target is seen again. + * Dormant guards don't scan, so they build nothing. + */ +/datum/stealth_meter + /// The guard's controller, which owns this meter + var/datum/ai_controller/basic_controller/human_npc/stealth/controller + var/mob/living/guard + /// The public mark, in the guard's vis_contents while it shows + var/obj/effect/abstract/stealth_mark/mark + /// icon_state of the public mark, or null + var/public_state + /// REF(player) => list(image, client it was given to) + var/list/private_marks = list() + /// Timer for the next drain step + var/drain_timer + +/datum/stealth_meter/New(datum/ai_controller/basic_controller/human_npc/stealth/controller, mob/living/guard) + src.controller = controller + src.guard = guard + RegisterSignal(guard, COMSIG_LIVING_SET_BODY_POSITION, PROC_REF(on_body_position)) + +/datum/stealth_meter/Destroy() + if(drain_timer) + deltimer(drain_timer) + drain_timer = null + set_public(null) + for(var/key in private_marks.Copy()) + remove_private(key) + if(guard) + UnregisterSignal(guard, COMSIG_LIVING_SET_BODY_POSITION) + controller = null + guard = null + return ..() + +/// Reads the controller and shows what it says. Changes nothing that hasn't changed. +/datum/stealth_meter/proc/update() + if(QDELETED(guard) || isnull(controller)) + return + var/new_public = stealth_meter_public_state(controller.stealth_state(), world.time, controller.lost_since, controller.blackboard[BB_STEALTH_STATE_SINCE], controller.calm_until) + set_public(new_public) + update_private(new_public ? null : controller.notice_map) + schedule_drain() + +/datum/stealth_meter/proc/set_public(new_state) + if(new_state == public_state) + return + public_state = new_state + if(isnull(new_state)) + if(mark) + guard?.vis_contents -= mark + QDEL_NULL(mark) + return + if(isnull(mark)) + mark = new + SET_PLANE_EXPLICIT(mark, ABOVE_LIGHTING_PLANE, guard) + mark.pixel_z = stealth_meter_offset(guard) + guard.vis_contents += mark + mark.icon_state = new_state + +/// Gives each nearby player their own "?" for their notice entry, and takes away the rest. +/datum/stealth_meter/proc/update_private(list/notice) + var/list/wanted = list() + var/turf/here = get_turf(guard) + if(length(notice) && here) + for(var/key in notice) + var/list/entry = notice[key] + var/state = stealth_meter_notice_state(entry[STEALTH_ENTRY_NOTICE]) + if(isnull(state)) + continue + var/mob/viewer = locate(key) + if(!ismob(viewer) || isnull(viewer.client) || viewer.z != here.z || get_dist(viewer, here) > STEALTH_METER_RANGE) + continue + wanted[key] = state + for(var/key in private_marks.Copy()) + var/list/held = private_marks[key] + var/mob/viewer = locate(key) + if(!wanted[key] || !ismob(viewer) || viewer.client != held[2]) + remove_private(key) + for(var/key in wanted) + var/list/held = private_marks[key] + if(held) + var/image/shown = held[1] + if(shown.icon_state != wanted[key]) + shown.icon_state = wanted[key] + continue + var/mob/viewer = locate(key) + var/image/shown = image('voidcrew/icons/effects/stealth_meter.dmi', guard, wanted[key]) + shown.appearance_flags = RESET_COLOR | RESET_ALPHA | RESET_TRANSFORM | KEEP_APART + shown.mouse_opacity = MOUSE_OPACITY_TRANSPARENT + SET_PLANE_EXPLICIT(shown, ABOVE_LIGHTING_PLANE, guard) + shown.pixel_z = stealth_meter_offset(guard) + viewer.client.images += shown + private_marks[key] = list(shown, viewer.client) + +/datum/stealth_meter/proc/remove_private(key) + var/list/held = private_marks[key] + private_marks -= key + if(!held) + return + var/image/shown = held[1] + var/client/given_to = held[2] + given_to?.images -= shown + shown.loc = null + +/// A draining mark steps at each row change rather than waiting for the next scan. +/datum/stealth_meter/proc/schedule_drain() + if(drain_timer) + deltimer(drain_timer) + drain_timer = null + var/delay = stealth_meter_next_step(controller.stealth_state(), world.time, controller.lost_since, controller.blackboard[BB_STEALTH_STATE_SINCE], controller.calm_until) + if(delay > 0) + drain_timer = addtimer(CALLBACK(src, PROC_REF(on_drain_step)), delay, TIMER_STOPPABLE) + +/datum/stealth_meter/proc/on_drain_step() + drain_timer = null + controller?.stealth_meter_update() + +/datum/stealth_meter/proc/on_body_position(datum/source) + SIGNAL_HANDLER + var/offset = stealth_meter_offset(guard) + if(mark) + mark.pixel_z = offset + for(var/key in private_marks) + var/list/held = private_marks[key] + var/image/shown = held[1] + shown.pixel_z = offset + +/// The public mark. Lives only in its guard's vis_contents. +/obj/effect/abstract/stealth_mark + name = "" + icon = 'voidcrew/icons/effects/stealth_meter.dmi' + icon_state = null + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + appearance_flags = RESET_COLOR | RESET_ALPHA | RESET_TRANSFORM | KEEP_APART + anchored = TRUE + +// ===== The controller's side ===== + +/datum/ai_controller/basic_controller/human_npc/stealth + /// The mark over its head while anyone is near to see it (stealth_meter.dm) + var/datum/stealth_meter/meter + +/// Builds, updates or drops the mark. Nothing while it isn't conscious or nobody living is near. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_meter_update() + var/mob/living/guard = pawn + if(QDELETED(guard) || guard.stat != CONSCIOUS || !stealth_meter_viewers_near(guard)) + QDEL_NULL(meter) + return + if(isnull(meter)) + meter = new(src, guard) + meter.update() + +/// Whether a living player is close enough to the guard to see its mark. +/proc/stealth_meter_viewers_near(mob/living/guard) + var/turf/here = get_turf(guard) + if(isnull(here) || here.z > length(SSmobs.clients_by_zlevel)) + return FALSE + for(var/mob/viewer as anything in SSmobs.clients_by_zlevel[here.z]) + if(get_dist(viewer, here) <= STEALTH_METER_RANGE) + return TRUE + return FALSE + +/// pixel_z for the glyph's bottom over `guard`: clear of its head, lower when it lies down. +/proc/stealth_meter_offset(mob/living/guard) + if(guard.body_position == LYING_DOWN) + return STEALTH_METER_LYING_Z + . = STEALTH_METER_HEAD_Z + if(ishuman(guard)) + var/mob/living/carbon/human/person = guard + var/list/offsets = GLOB.human_heights_to_offsets["[person.mob_height]"] + if(length(offsets)) + . += offsets[1] + offsets[2] + +// ===== Pure: state to icon_state ===== + +/// The private "?" for a notice level, or null for none. Fills round to the nearest row. +/proc/stealth_meter_notice_state(notice) + if(!(notice > 0)) + return null + if(notice < STEALTH_SUSPICIOUS_AT) + return "q_y[clamp(round(notice / STEALTH_SUSPICIOUS_AT * STEALTH_METER_ROWS, 1), 0, STEALTH_METER_ROWS)]" + var/red = clamp(round((notice - STEALTH_SUSPICIOUS_AT) / (STEALTH_ALERT_AT - STEALTH_SUSPICIOUS_AT) * STEALTH_METER_ROWS, 1), 0, STEALTH_METER_ROWS) + return red ? "q_r[red]" : "q_y[STEALTH_METER_ROWS]" + +/// Rows still lit with `time_left` of `total`: rounded up, 0 once the time is up. +/proc/stealth_meter_drain_rows(time_left, total) + if(total <= 0 || time_left <= 0) + return 0 + return clamp(CEILING(time_left / total * STEALTH_METER_ROWS - 0.001, 1), 0, STEALTH_METER_ROWS) + +/// When a public drain ends and how long it lasts, as list(end, total), or null when nothing drains. +/proc/stealth_meter_drain_span(state, lost_since, state_since, calm_until) + switch(state) + if(STEALTH_ALERT) + if(lost_since) + return list(lost_since + STEALTH_LOSE_TARGET_TIME, STEALTH_LOSE_TARGET_TIME) + if(STEALTH_SEARCHING) + var/end = calm_until || (state_since + STEALTH_SEARCH_TIME) + return list(end, end - state_since) + return null + +/// The public mark for a guard's state, or null for none. +/proc/stealth_meter_public_state(state, now, lost_since, state_since, calm_until) + switch(state) + if(STEALTH_ALERT) + if(!lost_since) + return "ex_r[STEALTH_METER_ROWS]" + var/list/span = stealth_meter_drain_span(state, lost_since, state_since, calm_until) + var/rows = stealth_meter_drain_rows(span[1] - now, span[2]) + // Drained: the full searching "?" it is about to become. + return rows ? "ex_r[rows]" : "q_y[STEALTH_METER_ROWS]" + if(STEALTH_SEARCHING) + var/list/span = stealth_meter_drain_span(state, lost_since, state_since, calm_until) + var/rows = stealth_meter_drain_rows(span[1] - now, span[2]) + return rows ? "q_y[rows]" : null + return null + +/// Deciseconds until a draining public mark loses its next row, or 0 when nothing drains. +/proc/stealth_meter_next_step(state, now, lost_since, state_since, calm_until) + var/list/span = stealth_meter_drain_span(state, lost_since, state_since, calm_until) + if(isnull(span) || span[2] <= 0) + return 0 + var/time_left = span[1] - now + var/rows = stealth_meter_drain_rows(time_left, span[2]) + if(rows <= 0) + return 0 + // The row goes when the time left reaches (rows - 1) sevenths; a tick later to land past it. + return max(world.tick_lag, time_left - (rows - 1) * span[2] / STEALTH_METER_ROWS + world.tick_lag) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth.dm b/voidcrew/modules/unit_tests/voidcrew_stealth.dm index 99debed4084..335867c5e48 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth.dm @@ -1,7 +1,7 @@ // Stealth guards (voidcrew/modules/stealth/). Unit tests compile before voidcrew/_DEFINES, so values from // there are written out: states "unaware", "suspicious", "alert", "searching"; blackboard keys // "stealth_state", "stealth_wary", "stealth_last_seen_turf"; STEALTH_PATROL_MAX_FAILS 3, -// STEALTH_LOSE_TARGET_TIME 4 s, STEALTH_SEARCH_TIME 40 s, STEALTH_CALM_LOOK_TIME 6 s, STEALTH_WARY_TIME 3 min. +// STEALTH_LOSE_TARGET_TIME 4 s, STEALTH_SEARCH_TIME 40 s, STEALTH_CALM_LOOK_TIME 6 s, STEALTH_WARY_TIME 60 s. #define STEALTH_TEST_GUARD /mob/living/carbon/human/npc/ruin/trooper/scav @@ -383,7 +383,7 @@ stealth_scans(guard, 1) TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "The search didn't end") TEST_ASSERT(stealth_ai.blackboard["stealth_wary"], "A guard that searched isn't wary") - stealth_ai.stealth_rewind(2 MINUTES) + stealth_ai.stealth_rewind(40 SECONDS) stealth_scans(guard, 1) TEST_ASSERT(stealth_ai.blackboard["stealth_wary"], "Wary faded too soon") // A glimpse of someone far off starts the clock again. @@ -391,10 +391,10 @@ stealth_scans(guard, 1) TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A glimpse at the edge of sight made the guard suspicious") qdel(person) - stealth_ai.stealth_rewind(2 MINUTES) + stealth_ai.stealth_rewind(40 SECONDS) stealth_scans(guard, 1) TEST_ASSERT(stealth_ai.blackboard["stealth_wary"], "A notice gain didn't refresh wary") - stealth_ai.stealth_rewind(70 SECONDS) + stealth_ai.stealth_rewind(30 SECONDS) stealth_scans(guard, 1) TEST_ASSERT(!stealth_ai.blackboard["stealth_wary"], "Wary didn't fade with nothing new") TEST_ASSERT(stealth_ai.stealth_half_angle() == 60, "A guard no longer wary still has the wary cone") @@ -404,4 +404,89 @@ TEST_ASSERT(stealth_ai.blackboard["stealth_wary"], "A hit didn't make the guard wary again") qdel(block) +/// The mark over a guard's head: notice and state to icon_state (draft D: fills round to nearest, drains round up). +/datum/unit_test/voidcrew_stealth_meter_states + +/datum/unit_test/voidcrew_stealth_meter_states/Run() + // Private "?": yellow to 1.0, then red to 2.5. + TEST_ASSERT_NULL(stealth_meter_notice_state(0), "No notice still shows a mark") + TEST_ASSERT_EQUAL(stealth_meter_notice_state(0.05), "q_y0", "A little notice isn't an empty grey ?") + TEST_ASSERT_EQUAL(stealth_meter_notice_state(0.3), "q_y2", "0.3 notice") + TEST_ASSERT_EQUAL(stealth_meter_notice_state(0.5), "q_y4", "Half notice doesn't round to the nearest row") + TEST_ASSERT_EQUAL(stealth_meter_notice_state(1), "q_y7", "Suspicious isn't a full yellow ?") + TEST_ASSERT_EQUAL(stealth_meter_notice_state(1.75), "q_r4", "Halfway to alert isn't half red") + TEST_ASSERT_EQUAL(stealth_meter_notice_state(2.5), "q_r7", "Alert notice isn't a full red ?") + TEST_ASSERT_EQUAL(stealth_meter_notice_state(4), "q_r7", "Notice past alert overflows the glyph") + // Public marks. Times in deciseconds; now = 10000. + TEST_ASSERT_NULL(stealth_meter_public_state("unaware", 10000, 0, 9000, 0), "An unaware guard has a public mark") + TEST_ASSERT_NULL(stealth_meter_public_state("suspicious", 10000, 0, 9000, 0), "A suspicious guard has a public mark") + TEST_ASSERT_EQUAL(stealth_meter_public_state("alert", 10000, 0, 9000, 0), "ex_r7", "Alert with the target in sight isn't a full red !") + TEST_ASSERT_EQUAL(stealth_meter_public_state("alert", 10000, 9980, 9000, 0), "ex_r4", "Target lost 2 of 4 s: the ! doesn't drain rounding up") + TEST_ASSERT_EQUAL(stealth_meter_public_state("alert", 10000, 9961, 9000, 0), "ex_r1", "The last row of the ! went out early") + TEST_ASSERT_EQUAL(stealth_meter_public_state("alert", 10000, 9960, 9000, 0), "q_y7", "A drained ! doesn't become the yellow ?") + TEST_ASSERT_EQUAL(stealth_meter_public_state("searching", 10000, 0, 10000, 0), "q_y7", "A fresh search isn't a full yellow ?") + TEST_ASSERT_EQUAL(stealth_meter_public_state("searching", 10000, 0, 9800, 0), "q_y4", "Halfway through the 40 s search") + TEST_ASSERT_NULL(stealth_meter_public_state("searching", 10000, 0, 9600, 0), "A finished search still shows") + TEST_ASSERT_EQUAL(stealth_meter_public_state("searching", 10000, 0, 9970, 10030), "q_y4", "Calming down doesn't drain to calm_until") + // The drain steps at each row: the full ! loses its top row after 1/7 of 4 s. + var/step = stealth_meter_next_step("alert", 10000, 10000, 9000, 0) + TEST_ASSERT(step > 40 / 7 && step < 40 / 7 + 1, "The first drain step isn't at 1/7 of the lose time (got [step])") + TEST_ASSERT_EQUAL(stealth_meter_next_step("alert", 10000, 0, 9000, 0), 0, "A steady ! schedules a drain") + +/// The mark goes with its guard: death, deletion, and the public mark hides the private one. +/datum/unit_test/voidcrew_stealth_meter_cleanup + +/datum/unit_test/voidcrew_stealth_meter_cleanup/Run() + var/datum/turf_reservation/block = stealth_block(8, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 4, 2) + stealth_ai.stealth_go_alert(person) + // No client is near in a test, so build it by hand. + stealth_ai.meter = new /datum/stealth_meter(stealth_ai, guard) + var/datum/stealth_meter/meter = stealth_ai.meter + meter.update() + var/obj/effect/abstract/stealth_mark/mark = meter.mark + TEST_ASSERT_NOTNULL(mark, "An alert guard has no mark") + TEST_ASSERT_EQUAL(mark.icon_state, "ex_r7", "An alert guard's mark isn't a full red !") + TEST_ASSERT(mark in guard.vis_contents, "The mark isn't drawn on the guard") + TEST_ASSERT_EQUAL(mark.pixel_z, stealth_meter_offset(guard), "The mark isn't just over a standing guard's head") + TEST_ASSERT(mark.pixel_z >= 25, "The mark sits in a standing guard's face") + guard.set_body_position(LYING_DOWN) + TEST_ASSERT_EQUAL(mark.pixel_z, 17, "The mark didn't drop when the guard lay down") + guard.set_body_position(STANDING_UP) + guard.death() + TEST_ASSERT(QDELETED(meter), "A dead guard kept its mark") + TEST_ASSERT(!(mark in guard.vis_contents), "A dead guard still draws its mark") + TEST_ASSERT(QDELETED(mark), "A dead guard's mark wasn't deleted") + // Deletion. + var/mob/living/carbon/human/npc/second = stealth_guard(block, 6, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/second_ai = stealth_ai(second) + second_ai.stealth_go_searching(stealth_at(block, 6, 3)) + second_ai.meter = new /datum/stealth_meter(second_ai, second) + meter = second_ai.meter + meter.update() + mark = meter.mark + TEST_ASSERT_EQUAL(mark?.icon_state, "q_y7", "A searching guard's mark isn't a full yellow ?") + qdel(second) + TEST_ASSERT(QDELETED(meter), "A deleted guard's meter lived on") + TEST_ASSERT(QDELETED(mark), "A deleted guard's mark lived on") + qdel(block) + +/// A stealth guard hit by an ally's stray shot doesn't turn on them or raise the alarm. +/datum/unit_test/voidcrew_stealth_ally_hit + +/datum/unit_test/voidcrew_stealth_ally_hit/Run() + var/datum/turf_reservation/block = stealth_block(6, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 2) + var/mob/living/carbon/human/npc/ally = stealth_guard(block, 4, 2, WEST) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + SEND_SIGNAL(guard, COMSIG_ATOM_WAS_ATTACKED, ally, ATTACKER_DAMAGING_ATTACK) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "An ally's stray shot raised the alarm") + TEST_ASSERT_NULL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], "An ally's stray shot made the guard target them") + TEST_ASSERT(!stealth_ai.blackboard["stealth_wary"], "An ally's stray shot made the guard wary") + qdel(block) + #undef STEALTH_TEST_GUARD From baeb3bd89f1cffac928b99b93e5c5f599978824f Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Mon, 9 Nov 2026 16:47:50 -0800 Subject: [PATCH 10/78] Raise the guard's head mark clear of its head Standing marks sit 6 px higher and follow the head's height offset; a lying guard's mark clears its body. No own ? shows in the moment after a search ends. --- voidcrew/_DEFINES/stealth.dm | 8 ++++---- voidcrew/modules/stealth/stealth_meter.dm | 13 +++++++++---- voidcrew/modules/unit_tests/voidcrew_stealth.dm | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index b2a833d134e..76b3bb2e977 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -109,10 +109,10 @@ #define STEALTH_METER_ROWS 7 /// Tiles from the guard within which a living player makes the mark worth drawing #define STEALTH_METER_RANGE 10 -/// pixel_z of the glyph's bottom over a standing, medium-height guard: 1 px clear of the head -#define STEALTH_METER_HEAD_Z 30 -/// pixel_z of the glyph's bottom over a guard lying down -#define STEALTH_METER_LYING_Z 17 +/// pixel_z of the glyph's bottom over a standing, medium-height guard: a clear gap over the hair +#define STEALTH_METER_HEAD_Z 36 +/// pixel_z of the glyph's bottom over a guard lying down (its sprite also drops PIXEL_Y_OFFSET_LYING) +#define STEALTH_METER_LYING_Z 29 /// The scav den's side #define FACTION_SCAV "scav" diff --git a/voidcrew/modules/stealth/stealth_meter.dm b/voidcrew/modules/stealth/stealth_meter.dm index 1de75bf3a18..2ef21c83009 100644 --- a/voidcrew/modules/stealth/stealth_meter.dm +++ b/voidcrew/modules/stealth/stealth_meter.dm @@ -7,7 +7,7 @@ * STEALTH_LOSE_TARGET_TIME and refills when it sees them again. * - Searching: a yellow "?" everyone sees, draining from the top over the search (or until calm_until * after it put its target down). Empty: gone. - * - While a public mark shows, nobody sees their own "?" on that guard. + * - While alert or searching, nobody sees their own "?" on that guard. * * Both are drawn on the guard (vis_contents for the public mark, an image located on the guard for the * private one), so they show only when the guard itself is in view, never through walls; above the @@ -55,9 +55,13 @@ /datum/stealth_meter/proc/update() if(QDELETED(guard) || isnull(controller)) return - var/new_public = stealth_meter_public_state(controller.stealth_state(), world.time, controller.lost_since, controller.blackboard[BB_STEALTH_STATE_SINCE], controller.calm_until) + var/state = controller.stealth_state() + var/new_public = stealth_meter_public_state(state, world.time, controller.lost_since, controller.blackboard[BB_STEALTH_STATE_SINCE], controller.calm_until) set_public(new_public) - update_private(new_public ? null : controller.notice_map) + // Alert and searching own the mark even once it has drained: no private "?" in the moment before the scan + // sends it back to unaware (and clears its notice). + var/public_owned = new_public || state == STEALTH_ALERT || state == STEALTH_SEARCHING + update_private(public_owned ? null : controller.notice_map) schedule_drain() /datum/stealth_meter/proc/set_public(new_state) @@ -186,9 +190,10 @@ . = STEALTH_METER_HEAD_Z if(ishuman(guard)) var/mob/living/carbon/human/person = guard + // The head rides the upper body offset (measured in a live client: a dwarf's head sits 5 px lower, not 9). var/list/offsets = GLOB.human_heights_to_offsets["[person.mob_height]"] if(length(offsets)) - . += offsets[1] + offsets[2] + . += offsets[1] // ===== Pure: state to icon_state ===== diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth.dm b/voidcrew/modules/unit_tests/voidcrew_stealth.dm index 335867c5e48..5fd22bed15f 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth.dm @@ -452,9 +452,9 @@ TEST_ASSERT_EQUAL(mark.icon_state, "ex_r7", "An alert guard's mark isn't a full red !") TEST_ASSERT(mark in guard.vis_contents, "The mark isn't drawn on the guard") TEST_ASSERT_EQUAL(mark.pixel_z, stealth_meter_offset(guard), "The mark isn't just over a standing guard's head") - TEST_ASSERT(mark.pixel_z >= 25, "The mark sits in a standing guard's face") + TEST_ASSERT(mark.pixel_z > 29, "The mark sits in a standing guard's face") guard.set_body_position(LYING_DOWN) - TEST_ASSERT_EQUAL(mark.pixel_z, 17, "The mark didn't drop when the guard lay down") + TEST_ASSERT_EQUAL(mark.pixel_z, 29, "The mark didn't drop when the guard lay down") guard.set_body_position(STANDING_UP) guard.death() TEST_ASSERT(QDELETED(meter), "A dead guard kept its mark") From 4a601457cabc01cc510985ce80162403bf850611 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Mon, 9 Nov 2026 20:03:11 -0800 Subject: [PATCH 11/78] Scav guard barks roll once for a line or an emote --- voidcrew/modules/stealth/scav_guards.dm | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/voidcrew/modules/stealth/scav_guards.dm b/voidcrew/modules/stealth/scav_guards.dm index 82bf667f0de..5566367635e 100644 --- a/voidcrew/modules/stealth/scav_guards.dm +++ b/voidcrew/modules/stealth/scav_guards.dm @@ -31,20 +31,24 @@ ) chances = list(RUIN_NPC_BARK_SPOT = 100) -// A line and an emote together read as a script: for the stealth kinds, now one and now the other. -/datum/human_npc_voice/scav/emotes_for(kind) - . = ..() - if(length(.) && length(lines_for(kind)) && prob(60)) - return null +/datum/human_npc_voice/scav + /// For the bark being said now: "line" or "emote" when its kind has both, else null + var/say_as +// A line and an emote together read as a script: a kind with both gets one or the other, picked once a bark. // The spot line always comes, even right after a stealth line. /datum/human_npc_voice/scav/bark(mob/living/carbon/human/npc/speaker, kind, force = FALSE) - return ..(speaker, kind, force || kind == RUIN_NPC_BARK_SPOT) + say_as = null + if(length(lines[kind]) && length(emotes[kind])) + say_as = (human_npc_can_talk(speaker) && prob(70)) ? "line" : "emote" + . = ..(speaker, kind, force || kind == RUIN_NPC_BARK_SPOT) + say_as = null + +/datum/human_npc_voice/scav/emotes_for(kind) + return say_as == "line" ? null : ..() /datum/human_npc_voice/scav/lines_for(kind) - . = ..() - if(length(.) && length(emotes[kind]) && prob(30)) - return null + return say_as == "emote" ? null : ..() /mob/living/carbon/human/npc/ruin/trooper/scav name = "scav guard" From 5f714190c16f9995a2e7e199054b3610acaa9633 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Mon, 9 Nov 2026 20:03:11 -0800 Subject: [PATCH 12/78] Stealth guards: fix the review findings Guards walk back to their route or post after a chase instead of turning sentry, in legs when it is far. Only being carried to another level or map region makes a sentry; a guard that can't get back waits and retries. The AI stays fully awake while any living player is on the level, the scan runs from planning instead of the behaviour queue, and long walks are no longer cancelled every step. An alert guard still notices others and turns on someone clearly nearer or on whoever hits it, at most once every few seconds. A glimpse while searching is an alert. Notice is capped, and only what it sees now decides its state. The candidate cap counts only those it can perceive. A box that moves at its shoulder or bumps it is noticed. Blasts, fire, gas and stuns with nobody to blame send it and nearby friends searching. Cuffs, syringes, the strip menu and thrown items count as touches. The head mark exists only while the scan runs, so it clears on cuffs, stuns and player control. A player in the body gets no reactions. --- voidcrew/_DEFINES/stealth.dm | 23 +- voidcrew/modules/stealth/stealth_ai.dm | 710 ++++++++++++++---- voidcrew/modules/stealth/stealth_meter.dm | 60 +- voidcrew/modules/stealth/stealth_patrol.dm | 144 ++-- .../modules/stealth/stealth_perception.dm | 44 +- 5 files changed, 763 insertions(+), 218 deletions(-) diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index 76b3bb2e977..28a9ff9ab02 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -17,14 +17,10 @@ #define BB_STEALTH_WARY "stealth_wary" /// The candidate with the highest notice #define BB_STEALTH_FOCUS "stealth_focus" -/// Where it last saw (or was hit from) whoever it is after -#define BB_STEALTH_LAST_SEEN_TURF "stealth_last_seen_turf" -/// world.time of that sighting +/// world.time it last saw (or was hit from) whoever it is after; the turf is the controller's last_seen_turf #define BB_STEALTH_LAST_SEEN_AT "stealth_last_seen_at" /// REFs of fallen group members it has already reacted to #define BB_STEALTH_BODIES_SEEN "stealth_bodies_seen" -/// Its claimed stop, or the sentry's post -#define BB_STEALTH_HOME_TURF "stealth_home_turf" // Notice entry fields (the controller's notice_map) #define STEALTH_ENTRY_NOTICE 1 @@ -64,6 +60,8 @@ #define STEALTH_NOTICE_MIN_FALLOFF 0.25 #define STEALTH_SUSPICIOUS_AT 1.0 #define STEALTH_ALERT_AT 2.5 +/// Notice never climbs past this, so nobody banks a lead that hides someone else +#define STEALTH_NOTICE_MAX STEALTH_ALERT_AT #define STEALTH_NOTICE_DECAY 0.34 #define STEALTH_NOTICE_FORGET (20 SECONDS) #define STEALTH_BEHIND_RATE 0.4 @@ -100,6 +98,21 @@ #define STEALTH_PATROL_SKIP_TIME (2 MINUTES) #define STEALTH_PATROL_MAX_PATH 60 #define STEALTH_LEASH_RANGE 24 +/// Tiles a single walk covers; a destination further off is walked in legs +#define STEALTH_WALK_LEG 40 +/// A sentry that can't get back to its post tries again this often +#define STEALTH_HOME_RETRY_TIME (30 SECONDS) +/// Alert: someone else must be this many tiles nearer than its target before it turns on them +#define STEALTH_SWITCH_MARGIN 2 +/// Alert: the shortest time between two changes of target +#define STEALTH_SWITCH_COOLDOWN (4 SECONDS) +/// Health lost within STEALTH_HARM_WINDOW, with nobody to blame, that sends it looking +#define STEALTH_HARM_HEALTH 10 +#define STEALTH_HARM_WINDOW (10 SECONDS) +/// The shortest time between two reactions to harm nobody can be blamed for +#define STEALTH_HARM_COOLDOWN (10 SECONDS) +/// How far its group hears it being blown up, burned, gassed or stunned +#define STEALTH_HARM_ALERT_RANGE 9 #define STEALTH_ADMIN_OVERLAY_TIME (5 MINUTES) /// Seconds of search between "Come on out." lines #define STEALTH_SEARCH_BARK_INTERVAL (12 SECONDS) diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index cfbc9fa46ee..fd3dcbc1e69 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -1,3 +1,23 @@ +/// Signals that mean someone has their hands on it: each names them first. +#define STEALTH_HANDLED_SIGNALS list(\ + COMSIG_CARBON_HELP_ACT,\ + COMSIG_CARBON_CUFF_ATTEMPTED,\ + COMSIG_LIVING_TRY_SYRINGE_INJECT,\ + COMSIG_LIVING_TRY_SYRINGE_WITHDRAW,\ + COMSIG_BEING_STRIPPED,\ + COMSIG_ATOM_ITEM_INTERACTION,\ + COMSIG_ATOM_ITEM_INTERACTION_SECONDARY,\ +) +/// tg's signals for a stun, knockdown or sleep about to land: each carries its length first. +#define STEALTH_STUN_SIGNALS list(\ + COMSIG_LIVING_STATUS_STUN,\ + COMSIG_LIVING_STATUS_KNOCKDOWN,\ + COMSIG_LIVING_STATUS_IMMOBILIZE,\ + COMSIG_LIVING_STATUS_PARALYZE,\ + COMSIG_LIVING_STATUS_UNCONSCIOUS,\ + COMSIG_LIVING_STATUS_SLEEP,\ +) + /** * # Stealth guards: awareness * @@ -11,8 +31,11 @@ * - Suspicious: saw something. Turns to it, says so, stares a moment, walks over and looks around, then * gives up and goes back to its route. * - Alert: has a target and fights as every human NPC does. It keeps the target all round with tg's - * can_attack() (no cone, no darkness); out of sight for STEALTH_LOSE_TARGET_TIME, it searches. - * - Searching: runs to where it last saw someone and sweeps the spots round it, then gives up. + * can_attack() (no cone, no darkness); out of sight for STEALTH_LOSE_TARGET_TIME, it searches. It still + * notices others, and turns on someone clearly nearer or on anyone who hits it, at most once per + * STEALTH_SWITCH_COOLDOWN (decision 29). + * - Searching: runs to where it last saw someone and sweeps the spots round it, then gives up. A glimpse + * of anyone within STEALTH_ALERT_MAX_RANGE while it searches is an alert at once. * * Wary (BB_STEALTH_WARY) is set by any alert, search, hit or surrender: a wider cone and quicker notice * (abuse review P4). It fades after STEALTH_WARY_TIME with nothing new: every notice gain, hit, touch and @@ -22,10 +45,16 @@ * round where it stands for STEALTH_CALM_LOOK_TIME, then back to its route (decision 23). * * Every attack or touch gets a reaction, even from out of sight (P3): alert on the attacker if it can see - * them, otherwise a search at their turf. Detection is a once-a-second scan owned by this controller, never - * tg's movement-triggered target field (P1). Nothing here runs while the AI is off (no player on the - * level); timers are world.time stamps, so a guard that wakes after its search ran out steps straight - * back to unaware and stays wary (T1). + * them, otherwise a search at their turf. Harm that names nobody (a blast, fire, gas, a flashbang) sends + * it and the friends near it searching where it happened. Detection is a once-a-second scan owned by this + * controller, never tg's movement-triggered target field (P1). + * + * The AI runs while any living player is on its level (can_idle is off: tg's idle mode starved its walks). + * With no player on the level tg switches it off and nothing here runs; timers are world.time stamps, so a + * guard that wakes after its search ran out steps straight back to unaware and stays wary (T1). + * + * A player in the body (an admin driving it) gets none of this: no reactions, no forced run, no marks. The + * guard picks up again, unaware, when they leave. */ /datum/ai_controller/basic_controller/human_npc/stealth blackboard = list( @@ -40,12 +69,16 @@ // The patrol subtree decides what an unaware guard does; no random walk. idle_behavior = null ai_movement = /datum/ai_movement/jps/stealth + // tg drops every action, on each step, while the walk's end is further off than this. Its 14 is shorter + // than a patrol leg or a walk home. The alert chase never leaned on it: stealth_keep_target() ends a chase. + max_target_distance = STEALTH_PATROL_MAX_PATH + can_idle = FALSE planning_subtrees = list( + /datum/ai_planning_subtree/stealth_perception, /datum/ai_planning_subtree/human_npc_soft_crit, /datum/ai_planning_subtree/escape_captivity, /datum/ai_planning_subtree/human_npc_walk_out, /datum/ai_planning_subtree/human_npc_surrender, - /datum/ai_planning_subtree/stealth_perception, /datum/ai_planning_subtree/stealth_react, /datum/ai_planning_subtree/human_npc_arm, /datum/ai_planning_subtree/human_npc_shoot, @@ -64,6 +97,11 @@ var/route_step = 1 /// The way a sentry faces at its post var/sentry_dir = SOUTH + /// The stop it last reached, or the sentry's post. Investigations and searches stay within + /// STEALTH_LEASH_RANGE of it. A var, not a blackboard key: the blackboard drops a turf when it changes. + var/turf/home_turf + /// world.time a sentry next tries to walk back to a post it couldn't reach + var/home_retry_at = 0 /// Stop index => failed tries to reach it var/list/stop_fails = list() /// Stop index => world.time it may be tried again @@ -72,11 +110,13 @@ var/wait_until = 0 /// Whether it has done its arrival at the current stop var/at_stop = FALSE - /// Where its current stealth walk goes + /// Where its current stealth walk ends + var/turf/goto_dest + /// The turf it is walking to now: goto_dest, an open tile beside it, or the end of one leg of a long walk var/turf/goto_turf /// What that walk is for (STEALTH_GOTO_*) var/goto_purpose - /// "arrived" or "failed" once the walk is over, else null + /// "arrived" or "failed" once the walk to goto_dest is over, else null var/goto_result /// Set while it drops its own walk, so a dropped walk doesn't count as a failure var/dropping_walk = FALSE @@ -94,8 +134,10 @@ var/turf/investigate_turf /// Suspicious: whether it has walked over and looked var/investigated = FALSE - /// world.time of the last notice gain on its focus (suspicion holds STEALTH_SUSPICIOUS_TIMEOUT after it) + /// world.time of the last notice gain it saw (suspicion holds STEALTH_SUSPICIOUS_TIMEOUT after it) var/last_gain = 0 + /// Where it last saw (or was hit from) whoever it is after + var/turf/last_seen_turf /// Searching: the spot it searches round var/turf/search_center /// Searching: the spots still to check @@ -106,6 +148,10 @@ var/next_search_bark = 0 /// Alert: world.time it first failed to see its target in this stretch, or 0 var/lost_since = 0 + /// Alert: world.time it may next change target + var/next_switch_at = 0 + /// world.time of its next scan + var/next_scan = 0 /// world.time of its next look for fallen friends var/next_body_scan = 0 /// Bark kind => world.time it may say that kind again @@ -117,10 +163,25 @@ /// REF(mob) => list(notice, turf last scan, world.time last perceived). Not a blackboard key: the /// blackboard's qdel sweep indexes every nested list by its values, and these hold plain numbers. var/list/notice_map + /// REF(mob) => the turf the box, locker or bag it hides in stood on at the last scan (only those close by) + var/list/hidden_spots /// world.time wary was last set or refreshed var/wary_at = 0 /// Searching after putting its target down: world.time it calms down, or 0 var/calm_until = 0 + /// world.time someone last touched or hit it: harm at about that time is theirs, not a mystery + var/explained_at = 0 + /// Whether harm with nobody named is waiting to be judged + var/harm_pending = FALSE + /// How long before that harm a touch still explains it + var/harm_window = 0 + /// Where it stood when that harm landed + var/turf/harm_turf + /// world.time it may next react to harm with nobody named + var/next_harm_at = 0 + /// Its health when it last had nothing to explain, and when that was + var/health_mark + var/health_mark_at = 0 /datum/ai_controller/basic_controller/human_npc/stealth/TryPossessPawn(atom/new_pawn) . = ..() @@ -131,8 +192,11 @@ blackboard[BB_STEALTH_STATE_SINCE] = world.time RegisterSignal(new_pawn, COMSIG_LIVING_GET_PULLED, PROC_REF(on_pulled)) RegisterSignal(new_pawn, COMSIG_ATOM_BUMPED, PROC_REF(on_bumped)) - RegisterSignal(new_pawn, COMSIG_CARBON_HELP_ACT, PROC_REF(on_helped)) + RegisterSignals(new_pawn, STEALTH_HANDLED_SIGNALS, PROC_REF(on_handled)) + RegisterSignal(new_pawn, COMSIG_ATOM_PREHITBY, PROC_REF(on_prehitby)) RegisterSignal(new_pawn, COMSIG_PROJECTILE_PREHIT, PROC_REF(on_projectile_prehit)) + RegisterSignals(new_pawn, list(COMSIG_ATOM_EX_ACT, COMSIG_LIVING_IGNITED, COMSIG_MOB_FLASHED), PROC_REF(on_harmed)) + RegisterSignals(new_pawn, STEALTH_STUN_SIGNALS, PROC_REF(on_stunned)) RegisterSignal(new_pawn, COMSIG_LIVING_STATUS_REMOVED, PROC_REF(on_status_removed)) RegisterSignal(new_pawn, COMSIG_AI_BLACKBOARD_KEY_SET(BB_BASIC_MOB_CURRENT_TARGET), PROC_REF(on_target_set)) @@ -141,28 +205,82 @@ UnregisterSignal(pawn, list( COMSIG_LIVING_GET_PULLED, COMSIG_ATOM_BUMPED, - COMSIG_CARBON_HELP_ACT, + COMSIG_ATOM_PREHITBY, COMSIG_PROJECTILE_PREHIT, + COMSIG_ATOM_EX_ACT, + COMSIG_LIVING_IGNITED, + COMSIG_MOB_FLASHED, COMSIG_LIVING_STATUS_REMOVED, COMSIG_AI_BLACKBOARD_KEY_SET(BB_BASIC_MOB_CURRENT_TARGET), - )) + ) + STEALTH_HANDLED_SIGNALS + STEALTH_STUN_SIGNALS) group?.remove_member(pawn) group = null for(var/datum/stealth_sight_overlay/overlay as anything in watchers?.Copy()) qdel(overlay) watchers = null QDEL_NULL(meter) + home_turf = null + last_seen_turf = null + harm_turf = null goto_turf = null + goto_dest = null investigate_turf = null search_center = null search_queue = null + hidden_spots = null return ..() +// With the AI off (nobody on the level, stunned, in crit, a player in the body) nothing scans, so no mark. +/datum/ai_controller/basic_controller/human_npc/stealth/set_ai_status(new_ai_status, additional_flags = NONE) + . = ..() + if(ai_status == AI_STATUS_OFF) + QDEL_NULL(meter) + +/datum/ai_controller/basic_controller/human_npc/stealth/on_sentience_gained() + . = ..() + QDEL_NULL(meter) + +// The player has left the body: it is a guard again, with nothing on its mind. +/datum/ai_controller/basic_controller/human_npc/stealth/on_sentience_lost() + . = ..() + addtimer(CALLBACK(src, PROC_REF(stealth_take_back)), 1) + +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_take_back() + var/mob/living/guard = pawn + if(QDELETED(guard) || guard.client) + return + clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + if(stealth_ready && guard.stat != DEAD) + stealth_go_unaware() + reset_ai_status() + // ===== State ===== /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_state() return blackboard[BB_STEALTH_STATE] +/// Whether a player is in the body. Nothing here reacts, moves or marks it then. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_driven() + var/mob/living/guard = pawn + return !isnull(guard?.client) + +/// Cuffed, held hard, strapped to something or shut in something: tg's escape_captivity has it and it doesn't scan. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_captive() + var/mob/living/guard = pawn + if(!isturf(guard.loc) || HAS_TRAIT(guard, TRAIT_RESTRAINED)) + return TRUE + if(guard.buckled && !ismob(guard.buckled)) + return TRUE + var/mob/living/holder = guard.pulledby + return istype(holder) && holder.grab_state > GRAB_PASSIVE + +/// Whether its scan is running. Its head mark shows only then, so a mark never outlives the scan that feeds it. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_scanning() + var/mob/living/guard = pawn + if(QDELETED(guard) || guard.stat != CONSCIOUS || guard.client || ai_status == AI_STATUS_OFF) + return FALSE + return !stealth_captive() + /// Changes state, stamping the time, and drops whatever walk it was on. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_set_state(new_state) var/old_state = blackboard[BB_STEALTH_STATE] @@ -176,8 +294,8 @@ if(new_state == STEALTH_ALERT || new_state == STEALTH_SEARCHING) stealth_set_wary() stealth_drop_walk() - var/run = (new_state == STEALTH_ALERT || new_state == STEALTH_SEARCHING) - stealth_set_pace(run) + if(!stealth_driven()) + stealth_set_pace(new_state == STEALTH_ALERT || new_state == STEALTH_SEARCHING) human_npc_set_ai_movement(src, new_state == STEALTH_ALERT ? /datum/ai_movement/basic_avoidance : /datum/ai_movement/jps/stealth) for(var/datum/stealth_sight_overlay/overlay as anything in watchers) overlay.refresh() @@ -210,27 +328,43 @@ if(run != (body.move_intent == MOVE_INTENT_RUN)) body.toggle_move_intent() -/// Ends its own stealth walk, if it has one, without counting it as a failed path. -/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_drop_walk() - var/datum/ai_behavior/walk = GET_AI_BEHAVIOR(/datum/ai_behavior/stealth_goto) - if(walk && current_behaviors[walk]) - dropping_walk = TRUE - fail_behavior(walk) - dropping_walk = FALSE - goto_turf = null - goto_result = null +/// The way `guard` faces, as one of the four ways its sprite can show (a walk can leave it on a diagonal). +/proc/stealth_facing(atom/guard) + var/facing = guard.dir + if(facing & (facing - 1)) + return facing & (EAST | WEST) + return facing + +/// The way from `origin` to `goal`, as one of the four ways a sprite can face: along the longer side. +/proc/stealth_dir_to(atom/origin, atom/goal) + var/turf/start = get_turf(origin) + var/turf/end = get_turf(goal) + var/dx = end.x - start.x + var/dy = end.y - start.y + if(abs(dx) >= abs(dy)) + return dx >= 0 ? EAST : WEST + return dy > 0 ? NORTH : SOUTH + +/// The nearest open tile to `spot` within `reach` tiles (`spot` itself if it is open), or null. +/proc/stealth_open_near(turf/spot, reach = 2) + if(isnull(spot)) + return null + if(isopenturf(spot) && !spot.is_blocked_turf(exclude_mobs = TRUE)) + return spot + for(var/ring in 1 to reach) + for(var/turf/open/near in RANGE_TURFS(ring, spot)) + if(get_dist(near, spot) == ring && !near.is_blocked_turf(exclude_mobs = TRUE)) + return near + return null /// `where` pulled back to within STEALTH_LEASH_RANGE of home (abuse R3). Null if nowhere sensible. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_leash(turf/where) - var/turf/home = blackboard[BB_STEALTH_HOME_TURF] + var/turf/home = home_turf if(isnull(where) || isnull(home) || where.z != home.z) return where if(get_dist(home, where) <= STEALTH_LEASH_RANGE) return where - var/turf/clamped = get_ranged_target_turf_direct(home, where, STEALTH_LEASH_RANGE) - if(isnull(clamped) || clamped.is_blocked_turf(exclude_mobs = TRUE)) - return null - return clamped + return stealth_open_near(get_ranged_target_turf_direct(home, where, STEALTH_LEASH_RANGE)) /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_go_unaware() var/list/notice = notice_map @@ -242,18 +376,23 @@ /// Suspicious of something at `where`. `purpose` is STEALTH_GOTO_INVESTIGATE or STEALTH_GOTO_BODY. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_go_suspicious(turf/where, purpose = STEALTH_GOTO_INVESTIGATE) - var/mob/living/body = pawn stealth_set_state(STEALTH_SUSPICIOUS) goto_purpose = purpose - investigate_turf = stealth_leash(where) investigated = FALSE last_gain = world.time - set_blackboard_key(BB_STEALTH_LAST_SEEN_TURF, where) + stealth_aim_at(where) + stealth_bark(purpose == STEALTH_GOTO_BODY ? STEALTH_BARK_BODY : STEALTH_BARK_SUSPICIOUS) + +/// Suspicious: turns to `where` and makes it the place to walk over to. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_aim_at(turf/where) + var/mob/living/body = pawn + investigate_turf = stealth_leash(where) + last_seen_turf = where blackboard[BB_STEALTH_LAST_SEEN_AT] = world.time if(where && get_turf(body) != where) - stand_dir = get_dir(body, where) + // Never a diagonal: the sprite can't show one, and the cone would point where the guard doesn't look. + stand_dir = stealth_dir_to(body, where) body.setDir(stand_dir) - stealth_bark(purpose == STEALTH_GOTO_BODY ? STEALTH_BARK_BODY : STEALTH_BARK_SUSPICIOUS) /// Searching round `where`. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_go_searching(turf/where) @@ -265,21 +404,45 @@ search_queue = stealth_search_spots(search_center) search_looking = FALSE next_search_bark = world.time + STEALTH_SEARCH_BARK_INTERVAL - set_blackboard_key(BB_STEALTH_LAST_SEEN_TURF, where) + last_seen_turf = where blackboard[BB_STEALTH_LAST_SEEN_AT] = world.time -/// Alert on `target` (a mob, or the mech or vehicle someone sits in). +/// Alert on `target` (a mob, or the mech someone sits in). /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_go_alert(atom/target) if(QDELETED(target)) return if(stealth_state() != STEALTH_ALERT) stealth_set_state(STEALTH_ALERT) stealth_set_wary() + lost_since = 0 set_blackboard_key(BB_STEALTH_FOCUS, target) - set_blackboard_key(BB_STEALTH_LAST_SEEN_TURF, get_turf(target)) + last_seen_turf = get_turf(target) blackboard[BB_STEALTH_LAST_SEEN_AT] = world.time set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, target) +/// Alert: turns from its target to `new_target`, and remembers the old one for when this fight ends. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_switch_target(atom/new_target) + var/atom/old_target = blackboard[BB_BASIC_MOB_CURRENT_TARGET] + var/mob/living/old_mob = ismecha(old_target) ? bounty_ai_pilot_of(old_target) : old_target + if(isliving(old_mob) && !QDELETED(old_mob)) + stealth_remember(old_mob) + next_switch_at = world.time + STEALTH_SWITCH_COOLDOWN + // What it was doing was aimed at the old one. + CancelActions() + stealth_go_alert(new_target) + +/// Notes `who` as someone it knows is there and hostile, at alert-level notice. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_remember(mob/living/who) + var/list/notice = notice_map + var/key = REF(who) + var/list/entry = notice[key] + if(isnull(entry)) + entry = list(0, null, 0) + notice[key] = entry + entry[STEALTH_ENTRY_NOTICE] = max(entry[STEALTH_ENTRY_NOTICE], STEALTH_ALERT_AT) + entry[STEALTH_ENTRY_TURF] = get_turf(who) + entry[STEALTH_ENTRY_SEEN_AT] = world.time + /// The spots a search checks: the centre first, then a few open tiles round it in its line of sight. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_search_spots(turf/center) . = list() @@ -288,10 +451,13 @@ . += center var/list/pool = list() var/datum/region = map_region_for_turf(center) + var/turf/home = home_turf + // No spot further from home than the leash, or than the centre if that is already past it. + var/reach = (home && home.z == center.z) ? max(STEALTH_LEASH_RANGE, get_dist(home, center)) : INFINITY for(var/turf/open/spot in RANGE_TURFS(STEALTH_SEARCH_RADIUS, center)) if(spot == center || spot.is_blocked_turf(exclude_mobs = TRUE)) continue - if(map_region_excludes_turf(region, spot) || !stealth_leash(spot)) + if(map_region_excludes_turf(region, spot) || (home && get_dist(home, spot) > reach)) continue pool += spot var/picked = 0 @@ -305,12 +471,14 @@ /// Says a stealth line, at most once per STEALTH_BARK_KIND_COOLDOWN for each kind (abuse P14). /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_bark(kind) var/mob/living/carbon/human/npc/body = pawn - if(!ishumannpc(body) || body.stat != CONSCIOUS) + if(!ishumannpc(body) || body.stat != CONSCIOUS || body.client) return FALSE if(world.time < bark_ready_at[kind]) return FALSE + if(!body.npc_bark(kind, force = TRUE)) + return FALSE bark_ready_at[kind] = world.time + STEALTH_BARK_KIND_COOLDOWN - return body.npc_bark(kind, force = TRUE) + return TRUE /// Moves every awareness timestamp back by `time`, as if that long had passed (unit tests, admin tools). /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_rewind(time) @@ -327,22 +495,34 @@ lost_since -= time wait_until -= time look_until -= time + next_scan -= time next_body_scan -= time + next_switch_at -= time + next_harm_at -= time + home_retry_at -= time + health_mark_at -= time + if(explained_at) + explained_at -= time for(var/kind in bark_ready_at) bark_ready_at[kind] -= time + for(var/key in stop_skip_until) + stop_skip_until[key] -= time // ===== The scan ===== /** * One scan: expires a suspicion or search whose time has run out (also how a guard catches up after - * sleeping), keeps an alert guard's target, or looks for someone new and for fallen friends. + * sleeping), keeps an alert guard's target, and looks for someone new and for fallen friends. */ /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_scan_once() var/mob/living/carbon/human/guard = pawn - if(QDELETED(guard) || guard.stat != CONSCIOUS) + if(QDELETED(guard) || guard.stat != CONSCIOUS || guard.client) return + next_scan = world.time + STEALTH_SCAN_INTERVAL stealth_setup() stealth_update_wary() + stealth_uncover_eyes() + stealth_check_health() var/state = stealth_state() if(state == STEALTH_SEARCHING && calm_until) if(world.time >= calm_until) @@ -355,6 +535,9 @@ stealth_go_unaware() if(stealth_state() == STEALTH_ALERT) stealth_keep_target() + // Still fighting: it weighs everyone else. (Losing or downing its target has already looked round.) + if(stealth_state() == STEALTH_ALERT) + stealth_look() else stealth_look() if(stealth_state() != STEALTH_ALERT && world.time >= next_body_scan) @@ -376,13 +559,25 @@ var/mob/living/guard = pawn return !guard.is_blind() && guard.body_position != LYING_DOWN +/// Something over its eyes that blinds it (a blindfold someone put on it): with a hand free it pulls it off, as anyone would. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_uncover_eyes() + var/mob/living/carbon/human/guard = pawn + if(!ishuman(guard) || !guard.is_blind_from(EYES_COVERED) || HAS_TRAIT(guard, TRAIT_HANDS_BLOCKED)) + return + for(var/obj/item/clothing/worn in list(guard.glasses, guard.wear_mask, guard.head)) + if(worn.tint >= TINT_BLIND && guard.dropItemToGround(worn)) + return + /// How far it sees onto `tile` in its cone: shorter in the dark unless it sees in the dark. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_range_onto(turf/tile) if(!HAS_TRAIT(pawn, TRAIT_NIGHT_VISION) && stealth_tile_is_dark(tile)) return STEALTH_DARK_SIGHT_RANGE return STEALTH_SIGHT_RANGE -/// Looks for someone new: raises notice on whoever it perceives, decays the rest, changes state. +/** + * Looks for people: raises notice on whoever it perceives, decays the rest, changes state. Alert, it leaves + * its own target alone (stealth_keep_target() has it) and weighs everyone else as someone to turn on. + */ /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_look() var/mob/living/carbon/human/guard = pawn var/list/notice = notice_map @@ -390,44 +585,76 @@ if(isnull(strategy) || !isturf(guard.loc)) return var/state = stealth_state() + var/alert = state == STEALTH_ALERT + var/atom/target = alert ? blackboard[BB_BASIC_MOB_CURRENT_TARGET] : null var/wary = blackboard[BB_STEALTH_WARY] var/atom/focus = blackboard[BB_STEALTH_FOCUS] var/eyes = stealth_eyes_open() var/half_angle = stealth_half_angle() var/scan_seconds = STEALTH_SCAN_INTERVAL / (1 SECONDS) var/list/perceived = list() + var/list/was_hidden = hidden_spots + var/list/now_hidden + var/judged = 0 for(var/mob/living/candidate as anything in stealth_candidates(guard, HUMAN_NPC_SIGHT_RANGE)) - // A mech or vehicle is never hidden: seen all round, no darkness, straight to alert (abuse P9). - var/atom/vehicle = stealth_vehicle_of(candidate) - if(vehicle) - if(strategy.can_attack(guard, vehicle, HUMAN_NPC_SIGHT_RANGE)) - stealth_go_alert(vehicle) - return - continue - // In a locker, a crate or anything else: unseen. - if(!isturf(candidate.loc)) - continue + // Only those it could perceive count toward the cap, so bystanders it can't see never crowd a player out. + if(judged >= STEALTH_MAX_CANDIDATES) + break + var/key = REF(candidate) var/turf/where = candidate.loc + var/boxed = FALSE + if(!isturf(where)) + var/atom/movable/shell = candidate.loc + // A mech is never hidden: seen all round, no darkness, straight to alert (abuse P9). + if(ismecha(shell)) + if(shell == target || !strategy.can_attack(guard, shell, HUMAN_NPC_SIGHT_RANGE)) + continue + judged++ + if(!alert) + stealth_go_alert(shell) + return + stealth_remember(candidate) + perceived[key] = candidate + continue + shell = stealth_shell_of(candidate) + if(isnull(shell)) + continue + where = shell.loc + // Any other vehicle is as plain as its driver would be on that tile. A box, a locker or a bag hides them. + boxed = !isvehicle(shell) + if(candidate == target) + continue var/dist = get_dist(guard, where) if(dist > STEALTH_SIGHT_RANGE) continue + if(boxed) + // Hidden, unless the thing they hide in moves at its shoulder (decision 29). + if(dist > STEALTH_CLOSE_RANGE + 1) + continue + LAZYSET(now_hidden, key, where) + var/turf/stood = was_hidden?[key] + if(dist > STEALTH_CLOSE_RANGE || isnull(stood) || stood == where) + continue if(!strategy.can_attack(guard, candidate, STEALTH_SIGHT_RANGE)) continue + judged++ var/rate = 0 - if(eyes && !stealth_is_cloaked(candidate) && stealth_in_cone(guard, where, half_angle)) + var/felt = FALSE + if(boxed) + rate = STEALTH_NOTICE_RATE + felt = TRUE + else if(eyes && !stealth_is_cloaked(candidate) && stealth_in_cone(guard, where, half_angle)) var/cap = stealth_range_onto(where) if(dist <= cap) rate = STEALTH_NOTICE_RATE * clamp((cap + 1 - dist) / cap, STEALTH_NOTICE_MIN_FALLOFF, 1) if(cap < STEALTH_SIGHT_RANGE) rate *= STEALTH_DARK_MULT - var/felt = FALSE if(!rate && dist <= STEALTH_CLOSE_RANGE) // At its shoulder: light doesn't matter (abuse P7). rate = STEALTH_BEHIND_RATE felt = TRUE if(!rate) continue - var/key = REF(candidate) var/list/entry = notice[key] if(isnull(entry)) entry = list(0, null, 0) @@ -449,19 +676,32 @@ if(wary) rate *= STEALTH_WARY_MULT wary_at = world.time - entry[STEALTH_ENTRY_NOTICE] += rate * scan_seconds + entry[STEALTH_ENTRY_NOTICE] = min(entry[STEALTH_ENTRY_NOTICE] + rate * scan_seconds, STEALTH_NOTICE_MAX) if(felt && running) entry[STEALTH_ENTRY_NOTICE] = max(entry[STEALTH_ENTRY_NOTICE], STEALTH_SUSPICIOUS_AT) - guard.setDir(get_dir(guard, where)) + if(!alert && where != guard.loc) + guard.setDir(stealth_dir_to(guard, where)) entry[STEALTH_ENTRY_TURF] = where entry[STEALTH_ENTRY_SEEN_AT] = world.time perceived[key] = candidate + hidden_spots = now_hidden // Decay whoever it didn't perceive; forget anyone unseen for long enough. var/best_key var/best_notice = 0 + var/seen_key + var/seen_notice = 0 + // What it knows of its own target keeps while it fights them. + var/mob/living/target_mob = ismecha(target) ? bounty_ai_pilot_of(target) : target + var/target_key = isliving(target_mob) ? REF(target_mob) : null for(var/key in notice) var/list/entry = notice[key] - if(!perceived[key]) + if(key == target_key) + continue + if(perceived[key]) + if(entry[STEALTH_ENTRY_NOTICE] > seen_notice) + seen_notice = entry[STEALTH_ENTRY_NOTICE] + seen_key = key + else entry[STEALTH_ENTRY_NOTICE] = max(0, entry[STEALTH_ENTRY_NOTICE] - STEALTH_NOTICE_DECAY * scan_seconds) if(world.time - entry[STEALTH_ENTRY_SEEN_AT] > STEALTH_NOTICE_FORGET) notice -= key @@ -469,35 +709,89 @@ if(entry[STEALTH_ENTRY_NOTICE] > best_notice) best_notice = entry[STEALTH_ENTRY_NOTICE] best_key = key - if(isnull(best_key)) + if(alert) + stealth_weigh_switch(perceived, strategy) + return + // Whoever it sees now decides what it does; a higher entry it can't see no longer speaks for them. + var/judged_key = seen_key || best_key + if(isnull(judged_key)) clear_blackboard_key(BB_STEALTH_FOCUS) return - var/mob/living/best = perceived[best_key] || locate(best_key) + var/mob/living/best = perceived[judged_key] || locate(judged_key) if(!isliving(best) || QDELETED(best)) - notice -= best_key + notice -= judged_key return set_blackboard_key(BB_STEALTH_FOCUS, best) - var/list/best_entry = notice[best_key] + var/list/best_entry = notice[judged_key] + var/level = best_entry[STEALTH_ENTRY_NOTICE] var/turf/best_turf = best_entry[STEALTH_ENTRY_TURF] - var/seen_now = !!perceived[best_key] + var/seen_now = !isnull(seen_key) + // No alert by sight from off-screen (abuse P8). + var/in_reach = get_dist(guard, best_turf) <= STEALTH_ALERT_MAX_RANGE switch(state) if(STEALTH_UNAWARE) - if(best_notice >= STEALTH_SUSPICIOUS_AT) + if(level >= STEALTH_SUSPICIOUS_AT) stealth_go_suspicious(best_turf) - if(STEALTH_SUSPICIOUS, STEALTH_SEARCHING) + if(STEALTH_SUSPICIOUS) if(!seen_now) return - // No alert by sight from off-screen (abuse P8). - if(best_notice >= STEALTH_ALERT_AT && get_dist(guard, best_turf) <= STEALTH_ALERT_MAX_RANGE) + if(level >= STEALTH_ALERT_AT && in_reach) stealth_go_alert(best) return - if(state == STEALTH_SEARCHING) - if(best_notice >= STEALTH_SUSPICIOUS_AT) - stealth_go_suspicious(best_turf) - return last_gain = world.time - set_blackboard_key(BB_STEALTH_LAST_SEEN_TURF, best_turf) - blackboard[BB_STEALTH_LAST_SEEN_AT] = world.time + // It looks at, and walks to, where they are now, not where it first saw them. + if(!investigated && level >= STEALTH_SUSPICIOUS_AT && last_seen_turf != best_turf) + stealth_aim_at(best_turf) + else + last_seen_turf = best_turf + blackboard[BB_STEALTH_LAST_SEEN_AT] = world.time + if(STEALTH_SEARCHING) + if(!seen_now || level < STEALTH_SUSPICIOUS_AT) + return + // It is primed: a glimpse is enough. + if(in_reach) + stealth_go_alert(best) + return + // Too far to be sure: the search moves to where it saw them. + var/turf/new_center = stealth_leash(best_turf) + if(calm_until || (new_center && get_dist(new_center, search_center) > 1)) + stealth_go_searching(best_turf) + +/** + * Alert: whether to turn on someone else it has noticed. They must be at alert-level notice, in reach, and + * either clearly nearer than its target or in view while the target is not. Never more than once per + * STEALTH_SWITCH_COOLDOWN, so two people can't make it flap between them. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_weigh_switch(list/perceived, datum/targeting_strategy/strategy) + if(world.time < next_switch_at || !length(perceived)) + return + var/mob/living/guard = pawn + var/list/notice = notice_map + var/atom/target = blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(QDELETED(target)) + return + var/target_dist = get_dist(guard, target) + var/target_unseen = !!lost_since + var/atom/pick + var/pick_dist = INFINITY + for(var/key in perceived) + var/list/entry = notice[key] + if(isnull(entry) || entry[STEALTH_ENTRY_NOTICE] < STEALTH_ALERT_AT) + continue + var/atom/thing = bounty_ai_target_for(perceived[key]) + if(thing == target) + continue + var/dist = get_dist(guard, thing) + if(dist > STEALTH_ALERT_MAX_RANGE || dist >= pick_dist) + continue + if(!target_unseen && dist + STEALTH_SWITCH_MARGIN > target_dist) + continue + if(!strategy.can_attack(guard, thing, HUMAN_NPC_SIGHT_RANGE)) + continue + pick = thing + pick_dist = dist + if(pick) + stealth_switch_target(pick) /** * Alert: keeps its target with tg's all-round can_attack() at the NPC's sight range (abuse P2). Out of @@ -508,12 +802,12 @@ var/atom/target = blackboard[BB_BASIC_MOB_CURRENT_TARGET] var/atom/remembered = target || blackboard[BB_STEALTH_FOCUS] if(QDELETED(remembered)) - stealth_go_searching(blackboard[BB_STEALTH_LAST_SEEN_TURF]) + stealth_go_searching(last_seen_turf) return var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) if(strategy?.can_attack(guard, remembered, HUMAN_NPC_SIGHT_RANGE)) lost_since = 0 - set_blackboard_key(BB_STEALTH_LAST_SEEN_TURF, get_turf(remembered)) + last_seen_turf = get_turf(remembered) blackboard[BB_STEALTH_LAST_SEEN_AT] = world.time if(!target) set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, remembered) @@ -535,7 +829,7 @@ return clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) stealth_bark(STEALTH_BARK_LOST) - stealth_go_searching(blackboard[BB_STEALTH_LAST_SEEN_TURF]) + stealth_go_searching(last_seen_turf) /** * Its target is down (decision 23). Anyone else it has noticed keeps the alarm going as usual: alert on @@ -553,7 +847,7 @@ search_looking = FALSE calm_until = world.time + STEALTH_CALM_LOOK_TIME look_until = calm_until - stand_dir = guard.dir + stand_dir = stealth_facing(guard) // Anyone it noticed lately or who hit it during the fight, read before this look decays them. var/best_notice = 0 var/turf/best_turf @@ -570,7 +864,7 @@ best_notice = entry[STEALTH_ENTRY_NOTICE] best_turf = entry[STEALTH_ENTRY_TURF] best = someone - // One look now: anyone else in view goes the normal way (suspicious or alert). + // One look now: anyone else in view goes the normal way (alert, or the search moves to them). stealth_look() if(stealth_state() != STEALTH_SEARCHING || !calm_until) return @@ -587,8 +881,9 @@ /** * Fallen friends (abuse P13): group members that are dead, in crit, cuffed or lying down, in its sight. - * It reacts to each body once. The first guard to find one is suspicious and walks over; a guard that - * finds a body someone already reported just searches there. + * It reacts to each fall once: a friend who gets back up and goes down again is news again. The first + * guard to find one is suspicious and walks over; a guard that finds a body someone already reported just + * searches there. */ /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_check_bodies() next_body_scan = world.time + STEALTH_BODY_SCAN_INTERVAL @@ -601,9 +896,12 @@ for(var/mob/living/member as anything in group.living_members()) if(member == guard) continue + var/key = REF(member) if(!(member.stat == DEAD || HAS_TRAIT(member, TRAIT_CRITICAL_CONDITION) || HAS_TRAIT(member, TRAIT_RESTRAINED) || member.body_position == LYING_DOWN)) + // On its feet again. + seen -= key + group.reported_bodies -= key continue - var/key = REF(member) if(key in seen) continue // A body stuffed in a locker, a crate or a bag is hidden, as a living person there is. @@ -632,29 +930,32 @@ /** * Anyone touching or hurting it (abuse P3): alert on them if it can see them, otherwise a search at - * their turf. Always wary. Allies are ignored. Returns TRUE if it took a target. + * their turf. Always wary. Allies are ignored. Alert on someone else already, it turns on whoever hit it + * (at most once per STEALTH_SWITCH_COOLDOWN, unless they are clearly nearer) and otherwise remembers them + * for when that fight ends. Returns TRUE if it took a target. */ /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_touched(atom/source) var/mob/living/guard = pawn - if(QDELETED(source) || QDELETED(guard) || source == guard || guard.stat == DEAD) + if(QDELETED(source) || QDELETED(guard) || source == guard || guard.stat == DEAD || guard.client) return FALSE + // Whatever hurts it at this moment has a name, an ally's stray shot included. + explained_at = world.time if(ismovable(source) && guard.faction_check_atom(source)) return FALSE stealth_set_wary() - if(stealth_state() == STEALTH_ALERT && blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) - // Busy with someone else: it remembers who else is hurting it for when that fight ends. - if(isliving(source) && source != blackboard[BB_BASIC_MOB_CURRENT_TARGET]) - var/list/notice = notice_map - var/list/entry = notice[REF(source)] - if(isnull(entry)) - entry = list(0, null, 0) - notice[REF(source)] = entry - entry[STEALTH_ENTRY_NOTICE] = max(entry[STEALTH_ENTRY_NOTICE], STEALTH_ALERT_AT) - entry[STEALTH_ENTRY_TURF] = get_turf(source) - entry[STEALTH_ENTRY_SEEN_AT] = world.time - return FALSE var/atom/who = isliving(source) ? bounty_ai_target_for(source) : source var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) + var/atom/target = blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(stealth_state() == STEALTH_ALERT && !QDELETED(target)) + if(who == target) + return FALSE + if(isliving(source)) + stealth_remember(source) + var/nearer = get_dist(guard, who) + STEALTH_SWITCH_MARGIN <= get_dist(guard, target) + if((nearer || world.time >= next_switch_at) && strategy?.can_attack(guard, who)) + stealth_switch_target(who) + return TRUE + return FALSE if(strategy?.can_attack(guard, who)) stealth_go_alert(who) return TRUE @@ -663,6 +964,8 @@ return FALSE /datum/ai_controller/basic_controller/human_npc/stealth/on_pawn_attacked(mob/living/source, atom/attacker, attack_flags) + if(source.client) + return if(stealth_touched(attacker)) return if(!blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) @@ -672,14 +975,30 @@ SIGNAL_HANDLER stealth_touched(puller) +/// Someone walked into it, or something with someone inside did (a box on the move). /datum/ai_controller/basic_controller/human_npc/stealth/proc/on_bumped(atom/source, atom/movable/bumper) SIGNAL_HANDLER if(isliving(bumper)) stealth_touched(bumper) + return + if(!ismovable(bumper)) + return + for(var/mob/living/inside in bumper.get_all_contents()) + stealth_touched(inside) + return -/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_helped(mob/living/source, mob/living/helper) +/// A help-click, cuffs, a syringe, a hand in its pockets or anything else used on it. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_handled(mob/living/source, mob/living/toucher) SIGNAL_HANDLER - stealth_touched(helper) + if(ismob(toucher)) + stealth_touched(toucher) + +/// Anything thrown that lands on it, harmless or not (relay_attackers only reports what hurts). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_prehitby(atom/source, atom/movable/hit_atom, datum/thrownthing/throwingdatum) + SIGNAL_HANDLER + var/mob/thrower = throwingdatum?.get_thrower() + if(ismob(thrower)) + stealth_touched(thrower) /// relay_attackers only reports a mob firer; a turret or other machine shooting it counts the same. /datum/ai_controller/basic_controller/human_npc/stealth/proc/on_projectile_prehit(atom/source, obj/projectile/hit_projectile) @@ -692,12 +1011,92 @@ /datum/ai_controller/basic_controller/human_npc/stealth/proc/on_target_set(datum/source) SIGNAL_HANDLER var/atom/target = blackboard[BB_BASIC_MOB_CURRENT_TARGET] - if(isnull(target) || stealth_state() == STEALTH_ALERT) + if(isnull(target) || stealth_state() == STEALTH_ALERT || stealth_driven()) return stealth_set_state(STEALTH_ALERT) stealth_set_wary() set_blackboard_key(BB_STEALTH_FOCUS, target) +/// A blast, flames or a flash on it. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_harmed(datum/source) + SIGNAL_HANDLER + stealth_note_harm() + +/// A stun, a knockdown or sleep about to land on it. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_stunned(datum/source, amount) + SIGNAL_HANDLER + if(amount > 0) + stealth_note_harm() + +/** + * Something hurt or stunned it. Judged a moment later, once the blow behind it has had the chance to name + * who dealt it (tg reports an item hit's attacker after its damage). Harm someone is named for within + * `window` is theirs and stealth_touched() has dealt with it. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_note_harm(window = 0.2 SECONDS) + var/mob/living/carbon/human/npc/guard = pawn + if(harm_pending || QDELETED(guard) || guard.stat == DEAD || guard.client) + return + // Its own surrender puts it on the floor. + if(ishumannpc(guard) && guard.npc_surrendering) + return + harm_pending = TRUE + harm_window = window + harm_turf = get_turf(guard) + addtimer(CALLBACK(src, PROC_REF(stealth_judge_harm)), 0.2 SECONDS) + +/// Harm nobody was named for (a blast, fire, gas, a flashbang): it and the friends near it go looking there. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_judge_harm() + harm_pending = FALSE + var/turf/where = harm_turf + harm_turf = null + var/mob/living/guard = pawn + if(QDELETED(guard) || guard.stat == DEAD || guard.client || isnull(where)) + return + if(explained_at && world.time - explained_at <= harm_window + 0.2 SECONDS) + return + if(world.time < next_harm_at) + return + next_harm_at = world.time + STEALTH_HARM_COOLDOWN + stealth_setup() + stealth_trouble_at(where) + for(var/mob/living/friend as anything in group?.living_members()) + if(friend == guard) + continue + var/turf/friend_turf = get_turf(friend) + if(friend_turf?.z != where.z || get_dist(friend_turf, where) > STEALTH_HARM_ALERT_RANGE) + continue + var/datum/ai_controller/basic_controller/human_npc/stealth/friend_ai = friend.ai_controller + if(istype(friend_ai)) + friend_ai.stealth_trouble_at(where) + +/// Trouble at `where` it can't put a face to: wary, and searching there unless it already has someone to fight. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_trouble_at(turf/where) + var/mob/living/guard = pawn + if(QDELETED(guard) || guard.stat != CONSCIOUS || guard.client) + return + stealth_set_wary() + if(blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + return + if(stealth_state() == STEALTH_SEARCHING && !calm_until) + return + stealth_go_searching(where) + stealth_bark(STEALTH_BARK_HIT_UNSEEN) + +/// Each scan: health lost with nobody to blame (gas, acid, bleeding, anything without a signal of its own). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_check_health() + var/mob/living/guard = pawn + var/health = guard.health + if(isnull(health_mark) || health > health_mark || world.time - health_mark_at > STEALTH_HARM_WINDOW) + health_mark = health + health_mark_at = world.time + return + if(health_mark - health < STEALTH_HARM_HEALTH) + return + health_mark = health + health_mark_at = world.time + stealth_note_harm(STEALTH_HARM_WINDOW) + /// Carried off the level: drops its route and holds where it is (abuse R3). The base controller already /// listens for the level change. /datum/ai_controller/basic_controller/human_npc/stealth/on_changed_z_level(atom/source, turf/old_turf, turf/new_turf, same_z_layer, notify_contents) @@ -718,17 +1117,20 @@ /datum/ai_controller/basic_controller/human_npc/stealth/proc/on_status_removed(mob/living/source, datum/status_effect/effect) SIGNAL_HANDLER - if(istype(effect, /datum/status_effect/incapacitating/stamcrit)) + if(istype(effect, /datum/status_effect/incapacitating)) stealth_came_round() -/// Back on its feet after crit or stamcrit: it knows something happened. +/// Back on its feet after crit, a stun, a knockdown or sleep: it knows something happened. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_came_round() var/mob/living/guard = pawn - if(QDELETED(guard) || guard.stat == DEAD) + if(QDELETED(guard) || guard.stat != CONSCIOUS || guard.client) return stealth_set_wary() if(blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) return + // Already looking, and only just: one stun often ends as several effects. + if(stealth_state() == STEALTH_SEARCHING && !calm_until && world.time - blackboard[BB_STEALTH_STATE_SINCE] < STEALTH_LOSE_TARGET_TIME) + return stealth_go_searching(get_turf(guard)) // A guard that gives up is wary. @@ -758,24 +1160,22 @@ /datum/ai_movement/jps/stealth maximum_length = STEALTH_PATROL_MAX_PATH -/// Queues the scan every plan. Never ends planning. +/** + * Runs the scan once a second, straight from planning: it never waits in the behaviour queue, where a walk + * or tg's idle mode could starve it or be starved by it. First in the list, and never ends planning. With + * the scan stopped (cuffed, held, a player in the body) it takes the head mark down. + */ /datum/ai_planning_subtree/stealth_perception /datum/ai_planning_subtree/stealth_perception/SelectBehaviors(datum/ai_controller/basic_controller/human_npc/stealth/controller, seconds_per_tick) - var/mob/living/guard = controller.pawn - if(guard.stat != CONSCIOUS || !istype(controller)) + if(!istype(controller)) + return + if(!controller.stealth_scanning()) + QDEL_NULL(controller.meter) return controller.stealth_setup() - controller.queue_behavior(/datum/ai_behavior/stealth_scan) - -/datum/ai_behavior/stealth_scan - action_cooldown = STEALTH_SCAN_INTERVAL - behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION - -/datum/ai_behavior/stealth_scan/perform(seconds_per_tick, datum/ai_controller/basic_controller/human_npc/stealth/controller) - if(istype(controller)) + if(world.time >= controller.next_scan && !controller.blackboard_key_exists(BB_HUMAN_NPC_EXIT)) controller.stealth_scan_once() - return AI_BEHAVIOR_DELAY /// Suspicious: stare, walk over, look round. Searching: sweep the spots. Ends planning while it acts. /datum/ai_planning_subtree/stealth_react @@ -784,6 +1184,8 @@ if(!istype(controller) || controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) return var/mob/living/guard = controller.pawn + if(guard.stat != CONSCIOUS) + return switch(controller.stealth_state()) if(STEALTH_SUSPICIOUS) if(world.time < controller.blackboard[BB_STEALTH_STATE_SINCE] + STEALTH_INVESTIGATE_DELAY) @@ -791,7 +1193,7 @@ return SUBTREE_RETURN_FINISH_PLANNING if(!controller.investigated) var/turf/dest = controller.investigate_turf - if(dest && get_turf(guard) != dest && controller.goto_result != "failed") + if(dest && !controller.stealth_walk_over(dest)) controller.stealth_walk(dest, controller.goto_purpose) return SUBTREE_RETURN_FINISH_PLANNING controller.investigated = TRUE @@ -799,6 +1201,7 @@ if(controller.goto_purpose == STEALTH_GOTO_BODY) controller.stealth_go_searching(get_turf(guard)) return SUBTREE_RETURN_FINISH_PLANNING + controller.stand_dir = stealth_facing(guard) controller.look_until = world.time + STEALTH_LOOK_AROUND_TIME controller.queue_behavior(/datum/ai_behavior/stealth_stand) return SUBTREE_RETURN_FINISH_PLANNING @@ -823,26 +1226,68 @@ controller.queue_behavior(/datum/ai_behavior/stealth_stand) return SUBTREE_RETURN_FINISH_PLANNING var/turf/spot = controller.search_queue[1] - if(get_turf(guard) == spot || (controller.goto_turf == spot && controller.goto_result)) + if(controller.stealth_walk_over(spot)) controller.stealth_drop_walk() controller.search_looking = TRUE + controller.stand_dir = stealth_facing(guard) controller.look_until = world.time + STEALTH_LOOK_AROUND_TIME controller.queue_behavior(/datum/ai_behavior/stealth_stand) return SUBTREE_RETURN_FINISH_PLANNING controller.stealth_walk(spot, STEALTH_GOTO_SEARCH) return SUBTREE_RETURN_FINISH_PLANNING -/// Starts (or keeps) its stealth walk to `dest`. -/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_walk(turf/dest, purpose) +// ===== Walking ===== + +/// Whether its walk to `dest` got there: on the tile, or as near as it could stand. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_walk_arrived(turf/dest) + return get_turf(pawn) == dest || (goto_dest == dest && goto_result == "arrived") + +/// Whether its walk to `dest` is over, there or not. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_walk_over(turf/dest) + return get_turf(pawn) == dest || (goto_dest == dest && !isnull(goto_result)) + +/// Whether the pathfinder gave up on its walk to `dest`. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_walk_gave_up(turf/dest) + return goto_dest == dest && goto_result == "failed" + +/// Ends its own stealth walk, if it has one, without counting it as a failed path. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_drop_walk() var/datum/ai_behavior/walk = GET_AI_BEHAVIOR(/datum/ai_behavior/stealth_goto) - if(goto_turf != dest && current_behaviors[walk]) + if(walk && current_behaviors[walk]) + dropping_walk = TRUE + fail_behavior(walk) + dropping_walk = FALSE + goto_turf = null + goto_dest = null + goto_result = null + +/// Starts (or keeps) its stealth walk to `dest`. A walk already over stays over until it is dropped. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_walk(turf/dest, purpose) + if(goto_dest != dest) stealth_drop_walk() - if(goto_turf != dest) - goto_result = null - goto_turf = dest + goto_dest = dest goto_purpose = purpose + if(goto_result) + return + if(isnull(goto_turf)) + goto_turf = stealth_next_leg(dest) queue_behavior(/datum/ai_behavior/stealth_goto) +/** + * The turf to walk to now on the way to `dest`: `dest`, an open tile beside it when something stands on it + * (a crate dropped on a patrol stop), or, when it is more than STEALTH_WALK_LEG off, a point part of the + * way there. A guard drawn a long way out comes home in legs instead of asking for a path too long to find. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_next_leg(turf/dest) + var/turf/here = get_turf(pawn) + if(isnull(here) || here.z != dest.z) + return dest + if(get_dist(here, dest) > STEALTH_WALK_LEG) + return stealth_open_near(get_ranged_target_turf_direct(here, dest, STEALTH_WALK_LEG - 10), 3) || dest + if(dest.is_blocked_turf(exclude_mobs = TRUE)) + return stealth_open_near(dest, 1) || dest + return dest + /** * Walks to the controller's goto_turf with its pathfinding movement. Ends on arrival, or as a failure * when the pathfinder gives up or the leg takes far too long (abuse R2). @@ -856,28 +1301,34 @@ . = ..() if(!istype(controller) || isnull(controller.goto_turf)) return FALSE + // Stamped each time the walk starts or starts again (after a stun, or the level waking), so time spent + // not walking never counts against it. controller.goto_started = world.time set_movement_target(controller, controller.goto_turf) /datum/ai_behavior/stealth_goto/perform(seconds_per_tick, datum/ai_controller/basic_controller/human_npc/stealth/controller) var/turf/dest = controller.goto_turf if(isnull(dest)) - return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED var/turf/here = get_turf(controller.pawn) if(here == dest) - return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED // Someone stands on the spot: next to it will do. if(get_dist(here, dest) <= 1 && dest.is_blocked_turf(exclude_mobs = FALSE) && !dest.is_blocked_turf(exclude_mobs = TRUE)) - return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED if(world.time - controller.goto_started > STEALTH_PATROL_MAX_PATH * max(controller.movement_delay, 0.4 SECONDS) * 1.5) controller.goto_timed_out = TRUE - return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED - return AI_BEHAVIOR_INSTANT + return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_DELAY /datum/ai_behavior/stealth_goto/finish_action(datum/ai_controller/basic_controller/human_npc/stealth/controller, succeeded) if(istype(controller) && !controller.dropping_walk) if(succeeded) - controller.goto_result = "arrived" + if(controller.goto_turf == controller.goto_dest || get_dist(controller.goto_turf, controller.goto_dest) <= 1) + controller.goto_result = "arrived" + else + // One leg of a long walk: the next plan sets out on the next. + controller.goto_turf = null else // Only a real path failure counts; being re-planned away from a walk does not. var/path_failed = controller.goto_timed_out || controller.consecutive_pathing_attempts >= controller.ai_movement.max_pathing_attempts @@ -918,3 +1369,6 @@ else if(sentry || prob(STEALTH_LOOK_TURN_CHANCE)) guard.setDir(turn(controller.stand_dir, pick(STEALTH_LOOK_TURN_ARC, -STEALTH_LOOK_TURN_ARC))) return AI_BEHAVIOR_DELAY + +#undef STEALTH_HANDLED_SIGNALS +#undef STEALTH_STUN_SIGNALS diff --git a/voidcrew/modules/stealth/stealth_meter.dm b/voidcrew/modules/stealth/stealth_meter.dm index 2ef21c83009..d2f070ab5fa 100644 --- a/voidcrew/modules/stealth/stealth_meter.dm +++ b/voidcrew/modules/stealth/stealth_meter.dm @@ -14,11 +14,14 @@ * lighting so they read in the dark. Fills round to the nearest row; drains round up, so the last row * stays lit until the time really runs out. * - * Cost: the meter is built only while a living player is within STEALTH_METER_RANGE of a conscious guard, - * updated by the guard's 1 s scan and its state changes, and changes an icon_state only when the step - * changes. A drain steps on a timer at each row change (at most STEALTH_METER_ROWS per drain); animate() - * is not used, because a chained icon_state animation can't snap back when the target is seen again. - * Dormant guards don't scan, so they build nothing. + * Cost: the meter is built only while a living player is within STEALTH_METER_RANGE of a guard whose scan + * is running (or an admin is watching its sight), updated by the guard's 1 s scan and its state changes, + * and changes an icon_state only when the step changes. A drain steps on a timer at each row change (at + * most STEALTH_METER_ROWS per drain); animate() is not used, because a chained icon_state animation can't + * snap back when the target is seen again. + * + * The mark lives only while the scan that feeds it runs. A guard that is cuffed, held, stunned, down, asleep + * with its level, or driven by a player has no mark, so none is ever left stale over its head. */ /datum/stealth_meter /// The guard's controller, which owns this meter @@ -28,7 +31,7 @@ var/obj/effect/abstract/stealth_mark/mark /// icon_state of the public mark, or null var/public_state - /// REF(player) => list(image, client it was given to) + /// REF(player), or "watch:ckey" for an admin watching its sight => list(image, client it was given to) var/list/private_marks = list() /// Timer for the next drain step var/drain_timer @@ -80,40 +83,58 @@ guard.vis_contents += mark mark.icon_state = new_state -/// Gives each nearby player their own "?" for their notice entry, and takes away the rest. +/// Gives each nearby player their own "?" for their notice entry, and takes away the rest. An admin watching +/// the guard's sight gets the fullest one, whoever it is for. /datum/stealth_meter/proc/update_private(list/notice) + // key => list(icon_state, client to show it to) var/list/wanted = list() var/turf/here = get_turf(guard) if(length(notice) && here) + var/top_state + var/top_notice = 0 for(var/key in notice) var/list/entry = notice[key] var/state = stealth_meter_notice_state(entry[STEALTH_ENTRY_NOTICE]) if(isnull(state)) continue + if(entry[STEALTH_ENTRY_NOTICE] > top_notice) + top_notice = entry[STEALTH_ENTRY_NOTICE] + top_state = state var/mob/viewer = locate(key) - if(!ismob(viewer) || isnull(viewer.client) || viewer.z != here.z || get_dist(viewer, here) > STEALTH_METER_RANGE) + if(!ismob(viewer) || isnull(viewer.client)) + continue + // By its turf: someone hiding in a box has no z of their own. + var/turf/viewer_turf = get_turf(viewer) + if(viewer_turf?.z != here.z || get_dist(viewer_turf, here) > STEALTH_METER_RANGE) continue - wanted[key] = state + wanted[key] = list(state, viewer.client) + if(top_state) + for(var/datum/stealth_sight_overlay/overlay as anything in controller.watchers) + var/client/admin = overlay.user_ref?.resolve() + if(isnull(admin) || wanted[REF(admin.mob)]) + continue + wanted["watch:[admin.ckey]"] = list(top_state, admin) for(var/key in private_marks.Copy()) var/list/held = private_marks[key] - var/mob/viewer = locate(key) - if(!wanted[key] || !ismob(viewer) || viewer.client != held[2]) + var/list/want = wanted[key] + if(isnull(want) || want[2] != held[2]) remove_private(key) for(var/key in wanted) + var/list/want = wanted[key] var/list/held = private_marks[key] if(held) var/image/shown = held[1] - if(shown.icon_state != wanted[key]) - shown.icon_state = wanted[key] + if(shown.icon_state != want[1]) + shown.icon_state = want[1] continue - var/mob/viewer = locate(key) - var/image/shown = image('voidcrew/icons/effects/stealth_meter.dmi', guard, wanted[key]) + var/client/viewer = want[2] + var/image/shown = image('voidcrew/icons/effects/stealth_meter.dmi', guard, want[1]) shown.appearance_flags = RESET_COLOR | RESET_ALPHA | RESET_TRANSFORM | KEEP_APART shown.mouse_opacity = MOUSE_OPACITY_TRANSPARENT SET_PLANE_EXPLICIT(shown, ABOVE_LIGHTING_PLANE, guard) shown.pixel_z = stealth_meter_offset(guard) - viewer.client.images += shown - private_marks[key] = list(shown, viewer.client) + viewer.images += shown + private_marks[key] = list(shown, viewer) /datum/stealth_meter/proc/remove_private(key) var/list/held = private_marks[key] @@ -163,10 +184,11 @@ /// The mark over its head while anyone is near to see it (stealth_meter.dm) var/datum/stealth_meter/meter -/// Builds, updates or drops the mark. Nothing while it isn't conscious or nobody living is near. +/// Builds, updates or drops the mark. Nothing while its scan isn't running (stealth_scanning()), or with no +/// living player near and no admin watching its sight. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_meter_update() var/mob/living/guard = pawn - if(QDELETED(guard) || guard.stat != CONSCIOUS || !stealth_meter_viewers_near(guard)) + if(!stealth_scanning() || (!length(watchers) && !stealth_meter_viewers_near(guard))) QDEL_NULL(meter) return if(isnull(meter)) diff --git a/voidcrew/modules/stealth/stealth_patrol.dm b/voidcrew/modules/stealth/stealth_patrol.dm index ed476f71dd4..6fe4a9d518b 100644 --- a/voidcrew/modules/stealth/stealth_patrol.dm +++ b/voidcrew/modules/stealth/stealth_patrol.dm @@ -8,6 +8,9 @@ * * A guard claims the route with a stop within STEALTH_ROUTE_CLAIM_RANGE of where it spawned, starting at * that stop. With none in range it is a sentry at its spawn turf, facing the way the spawner faced. + * + * A guard drawn off its route or post (a chase, a search) walks back, however far. One that can't get back + * waits and tries again. Only being carried to another level or map region makes it a sentry where it is. */ /// Every live patrol group @@ -211,9 +214,9 @@ GLOBAL_VAR_INIT(stealth_group_count, 0) stealth_ready = TRUE var/mob/living/guard = pawn var/turf/spawn_turf = get_turf(guard) - set_blackboard_key(BB_STEALTH_HOME_TURF, spawn_turf) - sentry_dir = guard.dir - stand_dir = guard.dir + home_turf = spawn_turf + sentry_dir = stealth_facing(guard) + stand_dir = sentry_dir group = stealth_group_for(spawn_turf) if(isnull(group)) group = new(spawn_turf) @@ -232,16 +235,19 @@ GLOBAL_VAR_INIT(stealth_group_count, 0) route_index = index if(route_id) var/datum/stealth_stop/start = group.routes[route_id][route_index] - set_blackboard_key(BB_STEALTH_HOME_TURF, start.spot) + home_turf = start.spot -/// Drops its route and holds `where` as a sentry from now on (abuse R2, R3). +/// Drops its route and holds `where` as a sentry from now on: it was carried off its level or out of its +/// region (abuse R3). A guard that only walked or was chased away keeps its route and walks back. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_become_sentry(turf/where) route_id = null at_stop = FALSE + home_retry_at = 0 + stealth_drop_walk() if(where) - set_blackboard_key(BB_STEALTH_HOME_TURF, where) - sentry_dir = pawn.dir - stand_dir = pawn.dir + home_turf = where + sentry_dir = stealth_facing(pawn) + stand_dir = sentry_dir /// Its route's stops, or null. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_stops() @@ -249,16 +255,19 @@ GLOBAL_VAR_INIT(stealth_group_count, 0) return null return group.routes[route_id] -/// Back from a suspicion or a search: heads for the nearest stop of its route. +/// Back from a suspicion, a search or a chase: heads for the nearest stop of its route it can still try. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_rejoin_route() at_stop = FALSE wait_until = 0 + home_retry_at = 0 var/list/stops = stealth_stops() if(!length(stops)) return var/turf/here = get_turf(pawn) var/best_dist = INFINITY for(var/index in 1 to length(stops)) + if(world.time < stop_skip_until["[index]"]) + continue var/datum/stealth_stop/stop = stops[index] var/dist = get_dist(stop.spot, here) if(dist < best_dist) @@ -285,11 +294,15 @@ GLOBAL_VAR_INIT(stealth_group_count, 0) return index return 0 -/// A walk the pathfinder gave up on (abuse R2): a stop that fails often enough is skipped for a while. +/** + * A walk the pathfinder gave up on (abuse R2). A stop that fails often enough is skipped for a while; with + * every stop skipped it waits where it is and tries again when the first skip runs out. A sentry that can't + * reach its post waits and tries again too. Neither gives up its route or post for good: only being carried + * off does that. + */ /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_walk_failed() if(goto_purpose == STEALTH_GOTO_HOME) - // It can't get back to its post: this is its post now. - stealth_become_sentry(get_turf(pawn)) + home_retry_at = world.time + STEALTH_HOME_RETRY_TIME return if(goto_purpose != STEALTH_GOTO_PATROL || isnull(route_id)) return @@ -300,59 +313,92 @@ GLOBAL_VAR_INIT(stealth_group_count, 0) stop_fails[key] = 0 stop_skip_until[key] = world.time + STEALTH_PATROL_SKIP_TIME var/next = stealth_next_index() - if(!next) - stealth_become_sentry(get_turf(pawn)) - return - route_index = next + if(next) + route_index = next -/// Unaware with no target: walks its route or holds its post. +/// Unaware with no target: walks its route or holds its post. Last in the list: it always leaves the guard +/// something to do, so planning never comes up empty. /datum/ai_planning_subtree/stealth_patrol /datum/ai_planning_subtree/stealth_patrol/SelectBehaviors(datum/ai_controller/basic_controller/human_npc/stealth/controller, seconds_per_tick) - if(!istype(controller) || controller.stealth_state() != STEALTH_UNAWARE || controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + if(!istype(controller)) return var/mob/living/guard = controller.pawn if(guard.stat != CONSCIOUS) return - var/turf/here = get_turf(guard) - var/list/stops = controller.stealth_stops() - if(!length(stops)) - controller.route_id = null - var/turf/post = controller.blackboard[BB_STEALTH_HOME_TURF] - if(post && here != post && controller.goto_result != "failed") - controller.stealth_walk(post, STEALTH_GOTO_HOME) - return SUBTREE_RETURN_FINISH_PLANNING - controller.stand_dir = controller.sentry_dir + if(controller.stealth_state() == STEALTH_UNAWARE && !controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + if(length(controller.stealth_stops())) + controller.stealth_plan_route() + else + controller.stealth_plan_post() + // Alert with nobody in reach of the fighting subtrees, or holding: it stands and looks about. + if(!length(controller.planned_behaviors)) controller.queue_behavior(/datum/ai_behavior/stealth_stand) - return SUBTREE_RETURN_FINISH_PLANNING - if(controller.at_stop) - if(world.time < controller.wait_until) - controller.queue_behavior(/datum/ai_behavior/stealth_stand) - return SUBTREE_RETURN_FINISH_PLANNING - controller.at_stop = FALSE - var/next = controller.stealth_next_index() + return SUBTREE_RETURN_FINISH_PLANNING + +/// A sentry: stands its post, or walks back to it. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_plan_post() + var/mob/living/guard = pawn + var/turf/here = get_turf(guard) + route_id = null + var/turf/post = home_turf + if(post && here != post) + if(post.z != here.z || map_region_for_turf(post) != map_region_for_turf(here)) + // Carried off: this is its post now. + stealth_become_sentry(here) + else if(world.time >= home_retry_at) + if(stealth_walk_gave_up(post)) + stealth_drop_walk() + if(!stealth_walk_arrived(post)) + stealth_walk(post, STEALTH_GOTO_HOME) + return + stand_dir = sentry_dir + queue_behavior(/datum/ai_behavior/stealth_stand) + +/// A route guard: waits at its stop, then walks to the next one it can reach. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_plan_route() + var/mob/living/guard = pawn + var/turf/here = get_turf(guard) + var/list/stops = stealth_stops() + if(at_stop) + if(world.time < wait_until) + queue_behavior(/datum/ai_behavior/stealth_stand) + return + var/next = stealth_next_index() if(!next) - controller.stealth_become_sentry(here) + // Every other stop is shut off: it stays here until one opens. + queue_behavior(/datum/ai_behavior/stealth_stand) return - controller.route_index = next - var/datum/stealth_stop/stop = stops[controller.route_index] - // Leash (abuse R3): a stop outside its region or too far from it means it was carried off. - if(!controller.group.region_matches(stop.spot) || stop.spot.z != here.z || get_dist(stop.spot, here) > STEALTH_LEASH_RANGE) - controller.stealth_become_sentry(here) + at_stop = FALSE + route_index = next + if(world.time < stop_skip_until["[route_index]"]) + var/next = stealth_next_index() + if(!next) + // Shut in: it waits, and tries again when the first skip runs out. + stand_dir = stealth_facing(guard) + queue_behavior(/datum/ai_behavior/stealth_stand) + return + route_index = next + var/datum/stealth_stop/stop = stops[route_index] + // Leash (abuse R3): a stop on another level or in another region means it was carried off. + if(stop.spot.z != here.z || !group.region_matches(here)) + stealth_become_sentry(here) + queue_behavior(/datum/ai_behavior/stealth_stand) return - if(here == stop.spot || (controller.goto_turf == stop.spot && controller.goto_result == "arrived")) - controller.stealth_drop_walk() - controller.stealth_arrive(stop) - controller.queue_behavior(/datum/ai_behavior/stealth_stand) - return SUBTREE_RETURN_FINISH_PLANNING - if(controller.goto_turf == stop.spot && controller.goto_result == "failed") - controller.goto_result = null - controller.stealth_walk(stop.spot, STEALTH_GOTO_PATROL) - return SUBTREE_RETURN_FINISH_PLANNING + if(stealth_walk_arrived(stop.spot)) + stealth_drop_walk() + stealth_arrive(stop) + queue_behavior(/datum/ai_behavior/stealth_stand) + return + // A failed try that hasn't yet shut the stop off: it tries again. + if(stealth_walk_gave_up(stop.spot)) + stealth_drop_walk() + stealth_walk(stop.spot, STEALTH_GOTO_PATROL) /// At a stop: faces its way, waits, and talks if it's a chatter stop and a friend is near. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_arrive(datum/stealth_stop/stop) at_stop = TRUE + home_turf = stop.spot stop_fails["[route_index]"] = 0 wait_until = world.time + stop.wait stand_dir = stop.dir diff --git a/voidcrew/modules/stealth/stealth_perception.dm b/voidcrew/modules/stealth/stealth_perception.dm index 8b1054fffbf..acc23fd0ab9 100644 --- a/voidcrew/modules/stealth/stealth_perception.dm +++ b/voidcrew/modules/stealth/stealth_perception.dm @@ -6,10 +6,12 @@ * can_attack(), so an alert guard keeps tg's all-round check and an attack from behind still lands on a * guard that can turn round (abuse review P1, P2). * - * A scan, once a second while the AI is awake: the nearest few living mobs on the HEARING grid (every mob - * is hearing-sensitive, so SSD bodies and other NPCs count), each passed through the guard's own - * can_attack() first (faction, stat, line of sight, invisibility, the packed-level cordon, Ghostskin - * camo), then the cone, light and movement rules below raise or decay its "notice". + * A scan, once a second while the AI is awake: the living mobs near it on the HEARING grid (every mob is + * hearing-sensitive, so SSD bodies and other NPCs count), nearest first, without its own side or the dead. + * Each goes through the guard's own can_attack() (faction, stat, line of sight, invisibility, the + * packed-level cordon, Ghostskin camo), and the first STEALTH_MAX_CANDIDATES that pass get the cone, light + * and movement rules that raise or decay its "notice". Only mobs it could perceive count toward that cap, + * so a pile of corpses, mice or its own friends can't crowd a player out. */ #ifdef UNIT_TESTS @@ -68,12 +70,21 @@ GLOBAL_LIST_EMPTY(stealth_test_dark_turfs) return (tile_area.base_lighting_alpha / 255) + tile.dynamic_lumcount < STEALTH_DARK_LUMCOUNT return tile.get_lumcount() < STEALTH_DARK_LUMCOUNT -/// The vehicle `who` sits in (a mech or another vehicle), or null. -/proc/stealth_vehicle_of(mob/living/who) - var/atom/holder = who.loc - if(ismecha(holder) || isvehicle(holder)) - return holder - return null +/** + * What `who` is shut inside, as it stands on a turf: the box, locker, bag or car, or the outermost of them. + * Null on a turf of their own, or when someone is carrying them (the carrier is the one to see). + */ +/proc/stealth_shell_of(mob/living/who) + if(isturf(who.loc)) + return null + var/atom/movable/shell = who.loc + while(shell && !isturf(shell.loc)) + shell = shell.loc + if(!ismovable(shell)) + return null + if(isnull(shell) || ismob(shell)) + return null + return shell /** * Whether a cloak hides `who` from a guard's sight beyond the close radius (owner decision 20: cyberware @@ -86,8 +97,8 @@ GLOBAL_LIST_EMPTY(stealth_test_dark_turfs) return !!who.has_status_effect(/datum/status_effect/shadow_cloak) /** - * The living mobs a guard might see, nearest first, at most STEALTH_MAX_CANDIDATES. Uses the spatial - * grid, never view() or hearers(). + * The living mobs a guard might notice within `range`, nearest first: not itself, not its own side, not the + * dead. Uses the spatial grid, never view() or hearers(). The caller caps how many it judges. */ /proc/stealth_candidates(mob/living/guard, range) var/turf/center = get_turf(guard) @@ -95,7 +106,7 @@ GLOBAL_LIST_EMPTY(stealth_test_dark_turfs) return list() var/list/buckets = new /list(range + 1) for(var/mob/living/found in SSspatial_grid.orthogonal_range_search(center, SPATIAL_GRID_CONTENTS_TYPE_HEARING, range)) - if(found == guard) + if(found == guard || found.stat == DEAD) continue var/turf/found_turf = get_turf(found) if(isnull(found_turf) || found_turf.z != center.z) @@ -103,13 +114,12 @@ GLOBAL_LIST_EMPTY(stealth_test_dark_turfs) var/dist = get_dist(center, found_turf) if(dist > range) continue + if(guard.faction_check_atom(found)) + continue var/list/bucket = buckets[dist + 1] if(isnull(bucket)) buckets[dist + 1] = bucket = list() bucket += found . = list() for(var/list/bucket in buckets) - for(var/mob/living/found as anything in bucket) - . += found - if(length(.) >= STEALTH_MAX_CANDIDATES) - return . + . += bucket From 1bd1a7a5d136e4ed0bb3224cfdcd62c89262966d Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Mon, 9 Nov 2026 20:03:12 -0800 Subject: [PATCH 13/78] Stealth tests that run the real guard AI: patrol, walk home, target switch, box, blast, cuffs --- .../modules/unit_tests/voidcrew_stealth.dm | 402 +++++++++++++++++- 1 file changed, 394 insertions(+), 8 deletions(-) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth.dm b/voidcrew/modules/unit_tests/voidcrew_stealth.dm index 5fd22bed15f..4b5dd0f34c6 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth.dm @@ -1,7 +1,10 @@ // Stealth guards (voidcrew/modules/stealth/). Unit tests compile before voidcrew/_DEFINES, so values from // there are written out: states "unaware", "suspicious", "alert", "searching"; blackboard keys -// "stealth_state", "stealth_wary", "stealth_last_seen_turf"; STEALTH_PATROL_MAX_FAILS 3, -// STEALTH_LOSE_TARGET_TIME 4 s, STEALTH_SEARCH_TIME 40 s, STEALTH_CALM_LOOK_TIME 6 s, STEALTH_WARY_TIME 60 s. +// "stealth_state", "stealth_wary"; STEALTH_PATROL_MAX_FAILS 3, STEALTH_LOSE_TARGET_TIME 4 s, +// STEALTH_SEARCH_TIME 40 s, STEALTH_CALM_LOOK_TIME 6 s, STEALTH_WARY_TIME 60 s, STEALTH_SWITCH_COOLDOWN 4 s. +// +// The tests down to voidcrew_stealth_body_again call the scan and the state procs directly, with the AI off. The +// voidcrew_stealth_live tests at the bottom run the real AI: planning, the scan and real walking. #define STEALTH_TEST_GUARD /mob/living/carbon/human/npc/ruin/trooper/scav @@ -150,7 +153,7 @@ stealth_ai.stealth_rewind(5 SECONDS) stealth_scans(guard, 1) TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "searching", "A guard that lost its target isn't searching") - TEST_ASSERT_EQUAL(stealth_ai.blackboard["stealth_last_seen_turf"], last_seen, "The search isn't at the last place it saw them") + TEST_ASSERT_EQUAL(stealth_ai.last_seen_turf, last_seen, "The search isn't at the last place it saw them") TEST_ASSERT_NULL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], "A searching guard still has a target") qdel(block) @@ -165,7 +168,7 @@ var/mob/living/carbon/human/person = stealth_person(block, 1, 2) SEND_SIGNAL(guard, COMSIG_ATOM_WAS_ATTACKED, person, ATTACKER_DAMAGING_ATTACK) TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "searching", "A guard hit from out of sight isn't searching") - TEST_ASSERT_EQUAL(stealth_ai.blackboard["stealth_last_seen_turf"], get_turf(person), "The search isn't at the attacker's turf") + TEST_ASSERT_EQUAL(stealth_ai.last_seen_turf, get_turf(person), "The search isn't at the attacker's turf") TEST_ASSERT(stealth_ai.blackboard["stealth_wary"], "A guard that was hit isn't wary") qdel(guard) // Pulled. @@ -356,18 +359,21 @@ qdel(guard) qdel(target) qdel(bystander) - // Someone behind it hit it during the fight: it turns on them. + // Someone behind it hits it during the fight: it turns on them, and not straight back when the first one hits it. guard = stealth_guard(block, 6, 2) stealth_ai = stealth_ai(guard) target = stealth_person(block, 8, 2) var/mob/living/carbon/human/flanker = stealth_person(block, 3, 2) stealth_ai.stealth_go_alert(target) SEND_SIGNAL(guard, COMSIG_ATOM_WAS_ATTACKED, flanker, ATTACKER_DAMAGING_ATTACK) - TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], target, "A hit from someone else pulled the guard off its target") - target.death() + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], flanker, "A guard didn't turn on someone else who hit it") + SEND_SIGNAL(guard, COMSIG_ATOM_WAS_ATTACKED, target, ATTACKER_DAMAGING_ATTACK) + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], flanker, "A guard hit by two people flapped straight back to the first") + // The one it turned on dies: the other is still there, and remembered. + flanker.death() stealth_scans(guard, 1) TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard calmed down while someone else was hurting it") - TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], flanker, "The guard didn't turn on whoever else hit it") + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], target, "The guard didn't go back to whoever else hit it") qdel(block) /// Wary fades after STEALTH_WARY_TIME with nothing new; a notice gain starts the clock again. @@ -489,4 +495,384 @@ TEST_ASSERT(!stealth_ai.blackboard["stealth_wary"], "An ally's stray shot made the guard wary") qdel(block) +/// The candidate cap counts only those it could perceive: a crowd of its own side at its feet doesn't hide someone further off. +/datum/unit_test/voidcrew_stealth_cap + +/datum/unit_test/voidcrew_stealth_cap/Run() + var/datum/turf_reservation/block = stealth_block(10, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + // More than STEALTH_MAX_CANDIDATES (8) of its own side, all nearer than the person. + for(var/i in 1 to 10) + var/mob/living/basic/mouse/mouse = allocate(/mob/living/basic/mouse, stealth_at(block, 3, 2)) + mouse.faction = list("scav") // FACTION_SCAV + stealth_person(block, 5, 2) + stealth_scans(guard, 3) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "suspicious", "A crowd of its own side hid someone 3 tiles in front of a guard") + qdel(block) + +/// Notice stops at STEALTH_ALERT_AT (2.5), so someone out of reach can't bank a lead that hides a second person. +/datum/unit_test/voidcrew_stealth_notice_cap + +/datum/unit_test/voidcrew_stealth_notice_cap/Run() + var/datum/turf_reservation/block = stealth_block(20, 7) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 3) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + // Eight tiles off: noticed, never alert (STEALTH_ALERT_MAX_RANGE 7). + var/mob/living/carbon/human/far = stealth_person(block, 14, 3) + stealth_scans(guard, 30) + var/list/entry = stealth_ai.notice_map[REF(far)] + TEST_ASSERT_NOTNULL(entry, "A guard never noticed someone 8 tiles in front of it") + TEST_ASSERT(entry[1] <= 2.5, "Notice climbed past the alert level ([entry[1]])") + // They step out of sight behind it; someone else walks up in front. + far.forceMove(stealth_at(block, 0, 3)) + var/mob/living/carbon/human/near = stealth_person(block, 8, 3) + stealth_scans(guard, 5) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "Someone it could no longer see kept a guard from alerting on the person in front of it") + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], near, "The guard isn't after the person in front of it") + qdel(block) + +/// A friend who went down, got up and went down again is news again. +/datum/unit_test/voidcrew_stealth_body_again + +/datum/unit_test/voidcrew_stealth_body_again/Run() + var/datum/turf_reservation/block = stealth_block(12, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + allocate(/obj/effect/landmark/stealth_group, stealth_at(block, 6, 4)) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 2) + var/mob/living/carbon/human/npc/friend = stealth_guard(block, 5, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/datum/ai_controller/basic_controller/human_npc/stealth/friend_ai = stealth_ai(friend) + stealth_ai.stealth_setup() + friend_ai.stealth_setup() + friend.set_body_position(LYING_DOWN) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "suspicious", "A guard didn't react to a friend on the floor") + stealth_ai.stealth_go_unaware() + friend.set_body_position(STANDING_UP) + stealth_ai.next_body_scan = 0 + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A friend back on its feet set a guard off") + friend.death() + stealth_ai.next_body_scan = 0 + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "suspicious", "A guard ignored a friend killed after getting back up") + qdel(block) + +// ===== The real AI ===== + +/** + * Tests that run the guard's real AI: planning, the scan and real walking, over a few seconds of game time. A + * person on SSmobs' list of players keeps the level awake, as a player there does. Every wait is on game time + * with a long deadline and ends as soon as the thing happens, so a slow machine only makes them slower. + */ +/datum/unit_test/voidcrew_stealth_live + abstract_type = /datum/unit_test/voidcrew_stealth_live + /// The walled room this test runs in + var/datum/turf_reservation/room + /// person => the z-level they were listed on + var/list/players = list() + +/datum/unit_test/voidcrew_stealth_live/Destroy() + for(var/mob/living/person as anything in players) + SSmobs.clients_by_zlevel[players[person]] -= person + players = null + . = ..() + QDEL_NULL(room) + +/// Builds a lit, walled, floored room `width` x `height` inside (walls keep its air in). FALSE if there is no room. +/datum/unit_test/voidcrew_stealth_live/proc/make_room(width, height) + room = SSmapping.request_turf_block_reservation(width + 2, height + 2, 1) + if(isnull(room)) + return FALSE + var/turf/corner = room.bottom_left_turfs[1] + for(var/turf/spot as anything in block(corner.x, corner.y, corner.z, corner.x + width + 1, corner.y + height + 1, corner.z)) + var/edge = spot.x == corner.x || spot.y == corner.y || spot.x == corner.x + width + 1 || spot.y == corner.y + height + 1 + spot.ChangeTurf(edge ? /turf/closed/wall : /turf/open/floor/iron) + GLOB.stealth_test_dark_turfs[spot] = FALSE + return TRUE + +/// The floor (dx, dy) from the room's inside corner. +/datum/unit_test/voidcrew_stealth_live/proc/at(dx, dy) + var/turf/corner = room.bottom_left_turfs[1] + return locate(corner.x + 1 + dx, corner.y + 1 + dy, corner.z) + +/datum/unit_test/voidcrew_stealth_live/proc/guard_at(dx, dy, facing = EAST) + var/mob/living/carbon/human/npc/guard = allocate(STEALTH_TEST_GUARD, at(dx, dy)) + guard.setDir(facing) + guard.AddElement(/datum/element/forced_gravity, 1) + return guard + +/// A walking person the guards can't hurt (the tests are about what the guards do, not how the fight goes). +/// `listed` puts them on SSmobs' list of players. +/datum/unit_test/voidcrew_stealth_live/proc/person_at(dx, dy, listed = TRUE) + var/mob/living/carbon/human/consistent/person = allocate(/mob/living/carbon/human/consistent, at(dx, dy)) + if(person.move_intent == MOVE_INTENT_RUN) + person.toggle_move_intent() + person.AddElement(/datum/element/forced_gravity, 1) + person.physiology.brute_mod = 0 + person.physiology.burn_mod = 0 + person.physiology.stamina_mod = 0 + if(listed) + var/turf/where = get_turf(person) + SSmobs.clients_by_zlevel[where.z] += person + players[person] = where.z + return person + +/// Switches a guard's AI on, as someone arriving on its level does. +/datum/unit_test/voidcrew_stealth_live/proc/wake(mob/living/guard) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + stealth_ai.reset_ai_status() + return stealth_ai + +/// A stop on route "a". +/datum/unit_test/voidcrew_stealth_live/proc/stop_at(dx, dy, order, wait = 5) + var/obj/effect/landmark/stealth_patrol/stop = allocate(/obj/effect/landmark/stealth_patrol, at(dx, dy)) + stop.order = order + stop.wait = wait + return stop + +/// A route leg longer than tg's 14-tile walk limit, with the only player far off behind a wall: it gets there. +/datum/unit_test/voidcrew_stealth_live/patrol + +/datum/unit_test/voidcrew_stealth_live/patrol/Run() + TEST_ASSERT(make_room(40, 5), "No room for the test") + allocate(/obj/effect/landmark/stealth_group, at(0, 4)) + stop_at(1, 2, 1) + stop_at(26, 2, 2) + // A wall between the far stop and the player, who is 37 tiles from the guard: past tg's idle radius. + for(var/dy in 0 to 4) + var/turf/wall_spot = at(32, dy) + wall_spot.ChangeTurf(/turf/closed/wall) + person_at(38, 2) + var/mob/living/carbon/human/npc/guard = guard_at(1, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = wake(guard) + TEST_ASSERT_EQUAL(stealth_ai.ai_status, AI_STATUS_ON, "A guard with a player far off on its level isn't fully awake") + var/turf/far_stop = at(26, 2) + var/deadline = world.time + 90 SECONDS + while(get_turf(guard) != far_stop && world.time < deadline) + sleep(2) + TEST_ASSERT_EQUAL(stealth_ai.route_id, "a", "The guard never claimed its route") + TEST_ASSERT_EQUAL(get_turf(guard), far_stop, "A guard didn't finish a 25-tile route leg (it is [get_dist(guard, far_stop)] tiles short)") + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A patrolling guard with nobody in sight isn't unaware") + // And back: the route goes on. + var/turf/near_stop = at(1, 2) + deadline = world.time + 90 SECONDS + while(get_turf(guard) != near_stop && world.time < deadline) + sleep(2) + TEST_ASSERT_EQUAL(get_turf(guard), near_stop, "A guard didn't walk back along its route") + TEST_ASSERT_NOTNULL(stealth_ai.route_id, "A guard gave up its route") + +/// Left far from its route by a chase, a guard walks back to it; a sentry walks back to its post. +/datum/unit_test/voidcrew_stealth_live/walk_home + +/datum/unit_test/voidcrew_stealth_live/walk_home/Run() + TEST_ASSERT(make_room(52, 5), "No room for the test") + allocate(/obj/effect/landmark/stealth_group, at(0, 2)) + stop_at(1, 0, 1, 50) + stop_at(4, 0, 2, 50) + for(var/dy in 0 to 4) + var/turf/wall_spot = at(49, dy) + wall_spot.ChangeTurf(/turf/closed/wall) + person_at(50, 2) + var/mob/living/carbon/human/npc/walker = guard_at(1, 0) + // Four tiles from the nearest stop: past STEALTH_ROUTE_CLAIM_RANGE (2), so a sentry. + var/mob/living/carbon/human/npc/sentry = guard_at(1, 4, SOUTH) + var/datum/ai_controller/basic_controller/human_npc/stealth/walker_ai = wake(walker) + var/datum/ai_controller/basic_controller/human_npc/stealth/sentry_ai = wake(sentry) + walker_ai.stealth_setup() + sentry_ai.stealth_setup() + TEST_ASSERT_EQUAL(walker_ai.route_id, "a", "The guard on the route didn't claim it") + TEST_ASSERT_NULL(sentry_ai.route_id, "The guard off the route claimed it") + var/turf/post = at(1, 4) + // Where a long chase ends: 43 tiles from the route. Further than STEALTH_LEASH_RANGE (24), and than one walk + // (STEALTH_WALK_LEG 40), so the way back is in two legs. + walker.forceMove(at(47, 0)) + sentry.forceMove(at(47, 4)) + walker_ai.stealth_go_searching(at(47, 0)) + sentry_ai.stealth_go_searching(at(47, 4)) + walker_ai.stealth_rewind(41 SECONDS) + sentry_ai.stealth_rewind(41 SECONDS) + var/deadline = world.time + 120 SECONDS + while(world.time < deadline && !(get_turf(sentry) == post && walker_ai.at_stop)) + sleep(2) + TEST_ASSERT_EQUAL(walker_ai.route_id, "a", "A guard left far from its route became a sentry") + TEST_ASSERT(walker_ai.at_stop, "A guard left far from its route never got back to a stop (it is at [walker.x - at(0, 0).x], [walker.y - at(0, 0).y])") + TEST_ASSERT(get_dist(walker, at(4, 0)) <= 3, "The guard is at a stop that isn't on its route") + TEST_ASSERT_EQUAL(get_turf(sentry), post, "A sentry left far from its post didn't walk back (it is [get_dist(sentry, post)] tiles off)") + TEST_ASSERT_EQUAL(sentry_ai.home_turf, post, "A sentry's post moved") + +/// Searching, it goes straight to alert on someone it glimpses, never down to suspicious. +/datum/unit_test/voidcrew_stealth_live/search_to_alert + +/datum/unit_test/voidcrew_stealth_live/search_to_alert/Run() + TEST_ASSERT(make_room(14, 5), "No room for the test") + var/mob/living/carbon/human/npc/guard = guard_at(3, 2) + var/mob/living/carbon/human/person = person_at(12, 0) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = wake(guard) + stealth_ai.stealth_go_searching(at(3, 2)) + // Three tiles in front of it: one scan's worth of notice is past suspicious but short of alert. + person.forceMove(at(6, 2)) + var/went_suspicious = FALSE + var/deadline = world.time + 20 SECONDS + while(stealth_ai.stealth_state() != "alert" && world.time < deadline) + if(stealth_ai.stealth_state() == "suspicious") + went_suspicious = TRUE + sleep(1) + TEST_ASSERT(!went_suspicious, "A searching guard that glimpsed someone dropped to suspicious") + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A searching guard didn't go alert on someone three tiles in front of it") + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], person, "The guard isn't after the person it glimpsed") + +/// Alert on a decoy it can't reach, it still notices someone nearer and turns on them; it doesn't flap back. +/datum/unit_test/voidcrew_stealth_live/switch_target + +/datum/unit_test/voidcrew_stealth_live/switch_target/Run() + TEST_ASSERT(make_room(14, 5), "No room for the test") + // A glass wall: the decoy beyond it is in plain sight and out of reach. + for(var/dy in 0 to 4) + allocate(/obj/structure/window/reinforced/fulltile, at(8, dy)) + var/mob/living/carbon/human/npc/guard = guard_at(3, 2) + var/mob/living/carbon/human/decoy = person_at(11, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = wake(guard) + stealth_ai.stealth_go_alert(decoy) + sleep(3 SECONDS) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard gave up on someone standing in plain sight behind glass") + // tg drops the target key each time the walk at the glass fails; the next scan takes it back. Its focus stays. + TEST_ASSERT_EQUAL(stealth_ai.blackboard["stealth_focus"], decoy, "A guard forgot the person behind the glass") + // Someone else beside it, on its side of the glass. + var/mob/living/carbon/human/intruder = person_at(1, 2, FALSE) + intruder.forceMove(get_step(guard, WEST) || at(1, 2)) + var/deadline = world.time + 30 SECONDS + while(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET] != intruder && world.time < deadline) + // Kept at its shoulder, wherever it has got to. + if(get_dist(intruder, guard) > 1) + var/turf/beside = get_step(guard, WEST) + if(beside && !beside.is_blocked_turf()) + intruder.forceMove(beside) + sleep(2) + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], intruder, "A guard busy with a decoy never turned on someone at its shoulder") + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard that changed target isn't alert") + // The decoy hits it at once: too soon to turn back (STEALTH_SWITCH_COOLDOWN 4 s), and the decoy is no nearer. + SEND_SIGNAL(guard, COMSIG_ATOM_WAS_ATTACKED, decoy, ATTACKER_DAMAGING_ATTACK) + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], intruder, "A guard flapped back to its old target the moment it was hit") + var/flapped = FALSE + deadline = world.time + 3 SECONDS + while(world.time < deadline) + if(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET] == decoy) + flapped = TRUE + sleep(2) + TEST_ASSERT(!flapped, "A guard flapped back to the decoy while someone stood nearer") + // Later, a hit from the decoy does turn it. + stealth_ai.stealth_rewind(5 SECONDS) + SEND_SIGNAL(guard, COMSIG_ATOM_WAS_ATTACKED, decoy, ATTACKER_DAMAGING_ATTACK) + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], decoy, "A guard didn't turn on someone who hit it once the cooldown had passed") + +/// Someone in a cardboard box: unseen while it sits still, noticed when it moves at the guard's shoulder, found when it bumps it. +/datum/unit_test/voidcrew_stealth_live/box + +/datum/unit_test/voidcrew_stealth_live/box/Run() + TEST_ASSERT(make_room(16, 7), "No room for the test") + person_at(15, 6) + var/mob/living/carbon/human/npc/guard = guard_at(3, 3, WEST) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = wake(guard) + var/mob/living/carbon/human/stowaway = person_at(6, 3, FALSE) + var/obj/structure/closet/cardboard/box = allocate(/obj/structure/closet/cardboard, at(6, 3)) + stowaway.forceMove(box) + // Still, three tiles behind it, then still at two. + sleep(3 SECONDS) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard noticed a box that never moved") + TEST_ASSERT(LAZYACCESS(stealth_ai.hidden_spots, REF(stowaway)), "The guard's scan never found the person in the box (the test can't tell hidden from missing)") + // It shuffles about within two tiles. + var/list/spots = list(at(5, 3), at(5, 4), at(5, 3), at(5, 2)) + var/spot_index = 0 + var/deadline = world.time + 30 SECONDS + while(stealth_ai.stealth_state() == "unaware" && world.time < deadline) + spot_index = (spot_index % length(spots)) + 1 + box.forceMove(spots[spot_index]) + sleep(1.2 SECONDS) + TEST_ASSERT(stealth_ai.stealth_state() != "unaware", "A guard ignored a box shuffling about at its shoulder") + // A second guard, and a box that walks into it. + var/mob/living/carbon/human/npc/second = guard_at(12, 1, WEST) + var/datum/ai_controller/basic_controller/human_npc/stealth/second_ai = wake(second) + second_ai.stealth_setup() + var/mob/living/carbon/human/second_person = person_at(14, 1, FALSE) + var/obj/structure/closet/cardboard/second_box = allocate(/obj/structure/closet/cardboard, at(13, 1)) + second_person.forceMove(second_box) + step(second_box, WEST) + TEST_ASSERT_EQUAL(second_ai.stealth_state(), "alert", "A box that walked into a guard wasn't found out") + TEST_ASSERT_EQUAL(second_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], second_person, "The guard isn't after whoever is in the box") + +/// A blast with nobody to blame: the guard it hits and the friend near it both go looking there. A hit with a name doesn't rouse the friend. +/datum/unit_test/voidcrew_stealth_live/blast + +/datum/unit_test/voidcrew_stealth_live/blast/Run() + TEST_ASSERT(make_room(30, 5), "No room for the test") + allocate(/obj/effect/landmark/stealth_group, at(0, 4)) + for(var/dy in 0 to 4) + var/turf/wall_spot = at(20, dy) + wall_spot.ChangeTurf(/turf/closed/wall) + var/mob/living/carbon/human/person = person_at(25, 2) + var/mob/living/carbon/human/npc/struck = guard_at(3, 2, WEST) + var/mob/living/carbon/human/npc/friend = guard_at(8, 2, EAST) + var/datum/ai_controller/basic_controller/human_npc/stealth/struck_ai = wake(struck) + var/datum/ai_controller/basic_controller/human_npc/stealth/friend_ai = wake(friend) + sleep(2 SECONDS) + TEST_ASSERT_EQUAL(struck_ai.group, friend_ai.group, "Two guards by one marker aren't in one group") + TEST_ASSERT_EQUAL(friend_ai.stealth_state(), "unaware", "A guard with nothing going on isn't unaware") + // A named hit first: the friend, facing away, hears nothing of it. + SEND_SIGNAL(struck, COMSIG_ATOM_WAS_ATTACKED, person, ATTACKER_DAMAGING_ATTACK) + struck.Stun(0.5 SECONDS) + sleep(1 SECONDS) + TEST_ASSERT_EQUAL(struck_ai.stealth_state(), "searching", "A guard hit from out of sight isn't searching") + TEST_ASSERT_EQUAL(friend_ai.stealth_state(), "unaware", "A hit with a name on it roused the guard's friend") + // Now a blast. + struck_ai.stealth_go_unaware() + struck_ai.stealth_clear_wary() + struck_ai.stealth_rewind(30 SECONDS) + var/turf/where_hit = get_turf(struck) + EX_ACT(struck, EXPLODE_LIGHT) + var/deadline = world.time + 5 SECONDS + while(friend_ai.stealth_state() != "searching" && world.time < deadline) + sleep(1) + TEST_ASSERT_EQUAL(friend_ai.stealth_state(), "searching", "A blast on a guard didn't send its friend looking") + TEST_ASSERT_EQUAL(friend_ai.last_seen_turf, where_hit, "The friend isn't looking where the blast was") + TEST_ASSERT(friend_ai.blackboard["stealth_wary"], "The friend isn't wary after the blast") + TEST_ASSERT(struck_ai.blackboard["stealth_wary"], "A guard caught in a blast isn't wary") + TEST_ASSERT(struck.stat != CONSCIOUS || struck_ai.stealth_state() == "searching", "A guard caught in a blast went back to its post") + +/// The mark over an alert guard's head goes when it is cuffed, and stays gone while it is. +/datum/unit_test/voidcrew_stealth_live/cuffed_mark + +/datum/unit_test/voidcrew_stealth_live/cuffed_mark/Run() + TEST_ASSERT(make_room(10, 5), "No room for the test") + var/mob/living/carbon/human/npc/guard = guard_at(3, 2) + var/mob/living/carbon/human/person = person_at(5, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = wake(guard) + stealth_ai.stealth_go_alert(person) + var/deadline = world.time + 10 SECONDS + while(isnull(stealth_ai.meter?.mark) && world.time < deadline) + sleep(1) + TEST_ASSERT_NOTNULL(stealth_ai.meter?.mark, "An alert guard with someone beside it has no mark") + var/obj/effect/abstract/stealth_mark/mark = stealth_ai.meter.mark + TEST_ASSERT(mark in guard.vis_contents, "The mark isn't drawn on the guard") + guard.set_handcuffed(new /obj/item/restraints/handcuffs(guard)) + guard.update_handcuffed() + TEST_ASSERT(HAS_TRAIT(guard, TRAIT_RESTRAINED), "The cuffs didn't go on") + deadline = world.time + 5 SECONDS + while(!isnull(stealth_ai.meter) && world.time < deadline) + sleep(1) + TEST_ASSERT_NULL(stealth_ai.meter, "A cuffed guard kept its mark") + TEST_ASSERT(!(mark in guard.vis_contents), "A cuffed guard still draws its mark") + // Hitting it while it is cuffed doesn't bring the mark back. + SEND_SIGNAL(guard, COMSIG_ATOM_WAS_ATTACKED, person, ATTACKER_DAMAGING_ATTACK) + var/came_back = FALSE + deadline = world.time + 3 SECONDS + while(world.time < deadline) + if(stealth_ai.meter) + came_back = TRUE + sleep(1) + TEST_ASSERT(!came_back, "A mark came back over a cuffed guard") + #undef STEALTH_TEST_GUARD From 38eec77e2e2eb53ece4ca04332f1ea1e706792c3 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Mon, 9 Nov 2026 20:54:17 -0800 Subject: [PATCH 14/78] Stealth guards hear: gunfire by loudness, footsteps, thrown things, knocks, glass, doors, bodies, shouts and radios Guards react to noise as a group. A small noise sends one guard to look, a second at the same spot two, a third everyone; a guard that never comes back is missed. Gunfire, blasts and screams send the nearest few running while sentries hold. Suppressed guns are heard only close by and in the open. Running is heard and walking is not, by tg's own footstep rules, and running no longer makes you easier to see. Guards who see or feel someone shout for help; lookouts carry an earpiece and call it in after three seconds unless they are dropped, jammed or EMPed first. A guard that heard something shows a grey ?. No sound ever gives a guard a target. Adds the Stealth Noise admin verb and a noise view. --- tgstation.dme | 6 + voidcrew/_DEFINES/stealth.dm | 1 - voidcrew/_DEFINES/stealth_hearing.dm | 165 ++++++ voidcrew/modules/stealth/scav_guards.dm | 55 +- voidcrew/modules/stealth/stealth_admin.dm | 25 +- .../modules/stealth/stealth_admin_noise.dm | 141 +++++ voidcrew/modules/stealth/stealth_ai.dm | 86 ++- voidcrew/modules/stealth/stealth_hearing.dm | 239 +++++++++ voidcrew/modules/stealth/stealth_meter.dm | 39 +- voidcrew/modules/stealth/stealth_noise.dm | 498 ++++++++++++++++++ .../modules/stealth/stealth_noise_sources.dm | 264 ++++++++++ voidcrew/modules/stealth/stealth_patrol.dm | 15 + voidcrew/modules/stealth/stealth_radio.dm | 149 ++++++ 13 files changed, 1647 insertions(+), 36 deletions(-) create mode 100644 voidcrew/_DEFINES/stealth_hearing.dm create mode 100644 voidcrew/modules/stealth/stealth_admin_noise.dm create mode 100644 voidcrew/modules/stealth/stealth_hearing.dm create mode 100644 voidcrew/modules/stealth/stealth_noise.dm create mode 100644 voidcrew/modules/stealth/stealth_noise_sources.dm create mode 100644 voidcrew/modules/stealth/stealth_radio.dm diff --git a/tgstation.dme b/tgstation.dme index 40fb9422b1e..25ed4aac37d 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -6742,6 +6742,7 @@ #include "voidcrew\_DEFINES\shuttles.dm" #include "voidcrew\_DEFINES\sound.dm" #include "voidcrew\_DEFINES\stealth.dm" +#include "voidcrew\_DEFINES\stealth_hearing.dm" #include "voidcrew\_DEFINES\subsystems.dm" #include "voidcrew\_DEFINES\techweb_nodes.dm" #include "voidcrew\_DEFINES\trade.dm" @@ -7729,10 +7730,15 @@ #include "voidcrew\modules\slime_extract_piles\slime_extract_piles.dm" #include "voidcrew\modules\stealth\scav_guards.dm" #include "voidcrew\modules\stealth\stealth_admin.dm" +#include "voidcrew\modules\stealth\stealth_admin_noise.dm" #include "voidcrew\modules\stealth\stealth_ai.dm" +#include "voidcrew\modules\stealth\stealth_hearing.dm" #include "voidcrew\modules\stealth\stealth_meter.dm" +#include "voidcrew\modules\stealth\stealth_noise.dm" +#include "voidcrew\modules\stealth\stealth_noise_sources.dm" #include "voidcrew\modules\stealth\stealth_patrol.dm" #include "voidcrew\modules\stealth\stealth_perception.dm" +#include "voidcrew\modules\stealth\stealth_radio.dm" #include "voidcrew\modules\stealth\stealth_test_ruin.dm" #include "voidcrew\modules\storage\smart_locker.dm" #include "voidcrew\modules\storage\wall_locker.dm" diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index 28a9ff9ab02..53bc8633070 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -65,7 +65,6 @@ #define STEALTH_NOTICE_DECAY 0.34 #define STEALTH_NOTICE_FORGET (20 SECONDS) #define STEALTH_BEHIND_RATE 0.4 -#define STEALTH_RUN_MULT 2 #define STEALTH_STILL_MULT 0.5 #define STEALTH_LYING_MULT 0.5 #define STEALTH_SUSPICIOUS_MULT 1.5 diff --git a/voidcrew/_DEFINES/stealth_hearing.dm b/voidcrew/_DEFINES/stealth_hearing.dm new file mode 100644 index 00000000000..305e42b692a --- /dev/null +++ b/voidcrew/_DEFINES/stealth_hearing.dm @@ -0,0 +1,165 @@ +// Stealth guards: hearing (voidcrew/modules/stealth/stealth_noise.dm and friends). Step 2 of the stealth layer. + +// ===== Noise kinds (stealth_noise()) ===== +#define STEALTH_NOISE_GUN_QUIET "gun_quiet" +#define STEALTH_NOISE_GUN_PISTOL "gun_pistol" +#define STEALTH_NOISE_GUN_SMG "gun_smg" +#define STEALTH_NOISE_GUN_LONG "gun_long" +#define STEALTH_NOISE_IMPACT "impact" +#define STEALTH_NOISE_BLAST "blast" +#define STEALTH_NOISE_GLASS "glass" +#define STEALTH_NOISE_THROWN "thrown" +#define STEALTH_NOISE_KNOCK "knock" +#define STEALTH_NOISE_BASH "bash" +#define STEALTH_NOISE_DOOR "door" +#define STEALTH_NOISE_THUD "thud" +#define STEALTH_NOISE_VOICE "voice" +#define STEALTH_NOISE_SCREAM "scream" +#define STEALTH_NOISE_SHOUT "shout" + +/// Every kind, for the admin verb and the tests +#define STEALTH_NOISE_KINDS list(\ + STEALTH_NOISE_GUN_QUIET,\ + STEALTH_NOISE_GUN_PISTOL,\ + STEALTH_NOISE_GUN_SMG,\ + STEALTH_NOISE_GUN_LONG,\ + STEALTH_NOISE_IMPACT,\ + STEALTH_NOISE_BLAST,\ + STEALTH_NOISE_GLASS,\ + STEALTH_NOISE_THROWN,\ + STEALTH_NOISE_KNOCK,\ + STEALTH_NOISE_BASH,\ + STEALTH_NOISE_DOOR,\ + STEALTH_NOISE_THUD,\ + STEALTH_NOISE_VOICE,\ + STEALTH_NOISE_SCREAM,\ + STEALTH_NOISE_SHOUT,\ +) + +// ===== What a guard does about a noise ===== +/// Turns to face it and carries on +#define STEALTH_HEAR_GLANCE 1 +/// One guard goes to look, then two, then everyone +#define STEALTH_HEAR_INVESTIGATE 2 +/// The nearest few run to it and search; the rest hold, wary +#define STEALTH_HEAR_ALARM 3 +/// A friend calling: whoever hears it runs to the one shouting +#define STEALTH_HEAR_SHOUT 4 + +// Fields of a stealth_noise_profile() list +#define STEALTH_PROFILE_REACH 1 +#define STEALTH_PROFILE_LEVEL 2 +#define STEALTH_PROFILE_FLAGS 3 + +// ===== Noise flags ===== +/// Unheard through any wall or closed door +#define STEALTH_NOISE_LOS_ONLY (1<<0) +/// Walls and doors take half as much off it +#define STEALTH_NOISE_LOUD (1<<1) +/// Heard even when one of their own made it +#define STEALTH_NOISE_ALLIES_COUNT (1<<2) +/// Heard only by the group of the guard that made it +#define STEALTH_NOISE_GROUP_ONLY (1<<3) + +// ===== Radio call kinds, lowest first: a pending call is only replaced by a more urgent one ===== +#define STEALTH_CALL_REPORT 1 +#define STEALTH_CALL_MISSING 2 +#define STEALTH_CALL_ALARM 3 + +// Fields of a controller's pending_call +#define STEALTH_CALL_KIND 1 +#define STEALTH_CALL_WHERE 2 +#define STEALTH_CALL_DUE 3 +#define STEALTH_CALL_NAME 4 + +// ===== Bark kinds ===== +#define STEALTH_BARK_HEARD "stealth_heard" +#define STEALTH_BARK_HEARD_AGAIN "stealth_heard_again" +#define STEALTH_BARK_GUNFIRE "stealth_gunfire" +#define STEALTH_BARK_HOLD "stealth_hold" +#define STEALTH_BARK_HELP "stealth_help" +#define STEALTH_BARK_MISSING "stealth_missing" +#define STEALTH_BARK_RADIO_REPORT "stealth_radio_report" +#define STEALTH_BARK_RADIO_ALARM "stealth_radio_alarm" +#define STEALTH_BARK_RADIO_MISSING "stealth_radio_missing" +#define STEALTH_BARK_COPY "stealth_copy" +#define STEALTH_BARK_RADIO_DEAD "stealth_radio_dead" + +// ===== Numbers (first playtest defaults; the owner tunes them) ===== +// Reach in open air, in tiles. Each is at or under how far a player hears the same tg sound. +#define STEALTH_NOISE_RANGE_GUN_QUIET 4 +#define STEALTH_NOISE_RANGE_GUN_PISTOL 9 +#define STEALTH_NOISE_RANGE_GUN_SMG 11 +#define STEALTH_NOISE_RANGE_GUN_LONG 14 +#define STEALTH_NOISE_RANGE_IMPACT 5 +#define STEALTH_NOISE_RANGE_IMPACT_QUIET 1 +#define STEALTH_NOISE_RANGE_BLAST 16 +#define STEALTH_NOISE_RANGE_GLASS 8 +#define STEALTH_NOISE_RANGE_THROWN_SMALL 4 +#define STEALTH_NOISE_RANGE_THROWN_MEDIUM 6 +#define STEALTH_NOISE_RANGE_THROWN_HEAVY 8 +#define STEALTH_NOISE_RANGE_KNOCK 5 +#define STEALTH_NOISE_RANGE_BASH 7 +#define STEALTH_NOISE_RANGE_DOOR 4 +#define STEALTH_NOISE_RANGE_THUD 4 +#define STEALTH_NOISE_RANGE_VOICE 5 +#define STEALTH_NOISE_RANGE_SCREAM 9 +#define STEALTH_NOISE_RANGE_SHOUT 9 +/// Tiles of reach a wall eats +#define STEALTH_MUFFLE_WALL 3 +/// Tiles of reach a closed solid door eats +#define STEALTH_MUFFLE_DOOR 2 +/// Gunfire and blasts go through walls better +#define STEALTH_MUFFLE_LOUD_MULT 0.5 +/// Past this many walls and doors nothing is heard +#define STEALTH_MUFFLE_MAX_BLOCKERS 3 +/// Inside this many muffled tiles a guard knows the spot +#define STEALTH_NOISE_EXACT_RANGE 6 +/// One tile of error per this many tiles past exact +#define STEALTH_NOISE_FUZZ_STEP 3 +#define STEALTH_NOISE_FUZZ_MAX 3 +/// The same kind of noise this soon and this near an earlier one is the same noise +#define STEALTH_NOISE_COALESCE (0.5 SECONDS) +#define STEALTH_NOISE_COALESCE_RANGE 3 +#define STEALTH_GLANCE_TIME (3 SECONDS) +/// How long a guard told to hold faces the noise before it goes back to its round +#define STEALTH_HOLD_TIME (10 SECONDS) +/// A search moves to a newer noise at most this often +#define STEALTH_RECENTRE_COOLDOWN (4 SECONDS) +/// "The same spot" for counting lures +#define STEALTH_LURE_RADIUS 6 +#define STEALTH_LURE_MEMORY (3 MINUTES) +/// A sentry leaves its post only for a noise this close +#define STEALTH_SENTRY_INVESTIGATE_RANGE 4 +/// How long a guard that went to look has before its friends miss it +#define STEALTH_CHECKIN_TIME (30 SECONDS) +#define STEALTH_ALARM_RESPONDERS 4 +/// After two alarms in memory +#define STEALTH_ALARM_RESPONDERS_LATER 2 +#define STEALTH_ALARM_MEMORY (3 MINUTES) +/// While alert with its target in view +#define STEALTH_SHOUT_INTERVAL (10 SECONDS) +/// Hand to the earpiece, then this long before the call goes out +#define STEALTH_RADIO_CALL_TIME (3 SECONDS) +/// A call this far past due (its level slept) is never made +#define STEALTH_RADIO_CALL_STALE (5 SECONDS) +/// One alarm delivery per group per this long +#define STEALTH_RADIO_GROUP_COOLDOWN (10 SECONDS) +/// Carriers that move on a call +#define STEALTH_RADIO_RESPONDERS 4 +/// Who a carrier's answer carries to, in muffled tiles +#define STEALTH_RELAY_VOICE_RANGE 5 +#define STEALTH_RELAY_VOICE_RESPONDERS 2 +/// How far a running step on plain floor in shoes carries to a guard +#define STEALTH_FOOTSTEP_RANGE 5 +/// How far a player hears that same step (tg: volume 75, range 17 - 1 - 6) +#define STEALTH_FOOTSTEP_PLAYER_RANGE 8 +/// The furthest any step is listened for +#define STEALTH_FOOTSTEP_MAX_RANGE 7 +#define STEALTH_FOOTSTEP_CRAWL_RANGE 2 +/// Notice a heard step adds +#define STEALTH_FOOTSTEP_NOTICE 0.5 +/// How long the admin noise view keeps one event on screen +#define STEALTH_NOISE_VIEW_TIME (4 SECONDS) +/// icon_state of the empty grey "?" over a guard that heard something (stealth_meter.dmi) +#define STEALTH_METER_HEARD_STATE "q_y0" diff --git a/voidcrew/modules/stealth/scav_guards.dm b/voidcrew/modules/stealth/scav_guards.dm index 5566367635e..69f98b05c67 100644 --- a/voidcrew/modules/stealth/scav_guards.dm +++ b/voidcrew/modules/stealth/scav_guards.dm @@ -17,8 +17,19 @@ STEALTH_BARK_SEARCH = list("Come on out.", "I know you're here."), STEALTH_BARK_HIT_UNSEEN = list("Contact!", "Where's that coming from?"), STEALTH_BARK_BODY = list("Man down!", "Who did this?"), - STEALTH_BARK_CHATTER = list("Shipment's late again.", "My feet are killing me.", "You hear that? No? Good."), + STEALTH_BARK_CHATTER = list("Shipment's late again.", "My feet are killing me.", "You hear that? No? Good.", "Radio check.", "Quiet tonight. I hate quiet."), STEALTH_BARK_DOWNED = list("Got 'em.", "Stay down.", "That's handled."), + STEALTH_BARK_HEARD = list("What was that?", "You hear that?", "Hm."), + STEALTH_BARK_HEARD_AGAIN = list("Again?", "That's twice now."), + STEALTH_BARK_GUNFIRE = list("Shots!", "That's gunfire!", "Shots, %SIDE% side!"), + STEALTH_BARK_HOLD = list("Stay put.", "Eyes open."), + STEALTH_BARK_HELP = list("Over here!", "Need a hand!"), + STEALTH_BARK_MISSING = list("%NAME%? ...%NAME%!", "Where's %NAME% got to?", "Should've been back by now."), + STEALTH_BARK_RADIO_REPORT = list("Checking something, %SIDE% side.", "Checking something."), + STEALTH_BARK_RADIO_ALARM = list("Contact, %SIDE% side! Get over here!", "Trouble, %SIDE% side!", "Trouble! Get over here!"), + STEALTH_BARK_RADIO_MISSING = list("%NAME%, come in.", "%NAME%'s not answering.", "Got one not answering."), + STEALTH_BARK_COPY = list("Copy.", "Moving.", "On my way."), + STEALTH_BARK_RADIO_DEAD = list("Radio's dead.", "Nothing but static."), ) emotes = list( HUMAN_NPC_BARK_DOWNED = list("collapses."), @@ -28,12 +39,20 @@ STEALTH_BARK_HIT_UNSEEN = list("ducks."), STEALTH_BARK_CHATTER = list("yawns.", "stretches."), STEALTH_BARK_DOWNED = list("spits."), + STEALTH_BARK_HEARD = list("cocks their head.", "looks round."), + STEALTH_BARK_GUNFIRE = list("flinches."), + STEALTH_BARK_HOLD = list("shifts their grip."), + STEALTH_BARK_RADIO_DEAD = list("taps their earpiece."), ) chances = list(RUIN_NPC_BARK_SPOT = 100) /datum/human_npc_voice/scav /// For the bark being said now: "line" or "emote" when its kind has both, else null var/say_as + /// For the bark being said now: the side of the den a line names ("east"), or null + var/fill_side + /// For the bark being said now: the friend a line asks after, or null. A guard's own name, never player text. + var/fill_name // A line and an emote together read as a script: a kind with both gets one or the other, picked once a bark. // The spot line always comes, even right after a stealth line. @@ -47,8 +66,24 @@ /datum/human_npc_voice/scav/emotes_for(kind) return say_as == "line" ? null : ..() +// A line that names a side of the den ("%SIDE%") or a friend ("%NAME%") is only said when there is one to name. /datum/human_npc_voice/scav/lines_for(kind) - return say_as == "emote" ? null : ..() + if(say_as == "emote") + return null + var/list/written = ..() + if(!length(written)) + return written + . = list() + for(var/line in written) + if(findtext(line, "%SIDE%")) + if(!fill_side) + continue + line = replacetext(line, "%SIDE%", fill_side) + if(findtext(line, "%NAME%")) + if(!fill_name) + continue + line = replacetext(line, "%NAME%", fill_name) // xss-safe: an NPC guard's own name, set by code, never player text + . += line /mob/living/carbon/human/npc/ruin/trooper/scav name = "scav guard" @@ -61,6 +96,18 @@ /mob/living/carbon/human/npc/ruin/trooper/scav/gunner npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/pistol +/// A gunner with an earpiece: on its group's radio net (stealth_radio.dm). +/mob/living/carbon/human/npc/ruin/trooper/scav/lookout + name = "scav lookout" + npc_name = "Scav Lookout" + npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/pistol + stealth_radio = TRUE + +/mob/living/carbon/human/npc/ruin/trooper/scav/lookout/npc_dress(datum/human_npc_order/order) + . = ..() + if(isnull(ears)) + equip_to_slot_or_del(new /obj/item/radio/headset(src), ITEM_SLOT_EARS) + /obj/effect/spawner/human_npc/ruin/scav name = "scav guard spawner" npc_type = /mob/living/carbon/human/npc/ruin/trooper/scav @@ -68,3 +115,7 @@ /obj/effect/spawner/human_npc/ruin/scav/gunner name = "scav gunner spawner" npc_type = /mob/living/carbon/human/npc/ruin/trooper/scav/gunner + +/obj/effect/spawner/human_npc/ruin/scav/lookout + name = "scav lookout spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/scav/lookout diff --git a/voidcrew/modules/stealth/stealth_admin.dm b/voidcrew/modules/stealth/stealth_admin.dm index d0616631683..3e695d07f17 100644 --- a/voidcrew/modules/stealth/stealth_admin.dm +++ b/voidcrew/modules/stealth/stealth_admin.dm @@ -35,7 +35,7 @@ var/wary_text = "calm" if(stealth_ai.blackboard[BB_STEALTH_WARY]) wary_text = "wary [max(0, round((STEALTH_WARY_TIME - (world.time - stealth_ai.wary_at)) / (1 SECONDS)))]s" - return "[guard.real_name] [REF(guard)] | [stealth_ai.group?.id || "no group"] | [state_text] [since]s | focus [focus_text] | [wary_text] | [route_text] | AI [status_text]" + return "[guard.real_name] [REF(guard)] | [stealth_ai.group?.id || "no group"] | [state_text] [since]s | focus [focus_text] | [wary_text] | [route_text] | AI [status_text] | [stealth_guard_hearing_summary(guard, stealth_ai)]" ADMIN_VERB(stealth_guards, R_DEBUG, "Stealth Guards", "View and force the awareness of stealth guards on your z-level.", ADMIN_CATEGORY_DEBUG) var/turf/here = get_turf(user.mob) @@ -74,7 +74,7 @@ ADMIN_VERB(stealth_guards, R_DEBUG, "Stealth Guards", "View and force the awaren var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller if(QDELETED(guard) || !istype(stealth_ai)) return - var/list/actions = list("Force Unaware", "Force Suspicious at my turf", "Force Alert on me", "Force Alert on a mob I pick", "Force Searching at my turf", "Toggle Wary", "Show its sight", "Jump to it", "Next stop") + var/list/actions = list("Force Unaware", "Force Suspicious at my turf", "Force Alert on me", "Force Alert on a mob I pick", "Force Searching at my turf", "Toggle Wary", "Show its sight", "Jump to it", "Next stop", "Hear a noise here", "Start radio call (alarm at my turf)") var/action = tgui_input_list(user, stealth_guard_summary(guard), "Stealth Guard", actions) if(isnull(action) || QDELETED(guard)) return @@ -112,6 +112,17 @@ ADMIN_VERB(stealth_guards, R_DEBUG, "Stealth Guards", "View and force the awaren stealth_toggle_sight_overlay(user, guard) if("Jump to it") user.mob.forceMove(get_turf(guard)) + if("Hear a noise here") + // The hearing for this one guard, whatever the distance: it goes to look. + stealth_ai.last_heard = list("admin", world.time) + if(stealth_ai.stealth_can_investigate()) + stealth_ai.stealth_go_heard(here) + else + stealth_ai.stealth_respond(here) + if("Start radio call (alarm at my turf)") + if(!stealth_ai.stealth_start_call(STEALTH_CALL_ALARM, here)) + to_chat(user, span_warning("It carries no radio."), confidential = TRUE) + return if("Next stop") var/next = stealth_ai.stealth_next_index() if(next) @@ -121,13 +132,21 @@ ADMIN_VERB(stealth_guards, R_DEBUG, "Stealth Guards", "View and force the awaren stealth_admin_log(user, "[action] on [key_name(guard)]", guard) /proc/stealth_admin_group(client/user, datum/stealth_group/group) - var/list/actions = list("Calm all", "Clear wary", "Alert all on me", "Search all at my turf", "Show every route") + var/list/actions = list("Calm all", "Clear wary", "Alert all on me", "Search all at my turf", "Show every route", "Radio alarm at my turf", "Show noise memory", "Forget noises") var/action = tgui_input_list(user, "[group.id]: [length(group.living_members())] guards", "Stealth Group", actions) if(isnull(action) || QDELETED(group)) return var/turf/here = get_turf(user.mob) if(action == "Show every route") stealth_show_routes(user, group) + else if(action == "Radio alarm at my turf") + group.next_radio_alarm = 0 + var/told = group.radio_call(null, STEALTH_CALL_ALARM, here) + to_chat(user, span_notice("[told] guard\s with a working radio got it."), confidential = TRUE) + else if(action == "Show noise memory") + stealth_show_noise_memory(user, group) + else if(action == "Forget noises") + group.forget_noises() else for(var/mob/living/guard as anything in group.living_members()) var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller diff --git a/voidcrew/modules/stealth/stealth_admin_noise.dm b/voidcrew/modules/stealth/stealth_admin_noise.dm new file mode 100644 index 00000000000..18da8449950 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_admin_noise.dm @@ -0,0 +1,141 @@ +/** + * # Stealth guard admin tools: noise + * + * "Stealth Noise" (Debug): makes a real stealth_noise() where you stand, of any kind and reach, with or + * without you as its maker, and says how many guards heard it. It can also switch on the noise view: for + * STEALTH_ADMIN_OVERLAY_TIME every noise on your level is drawn for you alone, with its kind and reach at the + * source, a ring at the edge of its reach, and over each guard what it made of it ("heard 6.5/9 -> goes", + * "muffled 11.5/9", "deaf", "busy"). Images are built only while someone watches. Every use is logged. + */ + +/// One admin's noise view. Kept in GLOB.stealth_sight_overlays under "noise:". +/datum/stealth_noise_view + var/datum/weakref/user_ref + var/key + +/datum/stealth_noise_view/New(client/user) + user_ref = WEAKREF(user) + key = "noise:[user.ckey]" + GLOB.stealth_sight_overlays[key] = src + QDEL_IN(src, STEALTH_ADMIN_OVERLAY_TIME) + +/datum/stealth_noise_view/Destroy() + if(GLOB.stealth_sight_overlays[key] == src) + GLOB.stealth_sight_overlays -= key + return ..() + +/// Draws one noise for its admin: the source, its reach, and what each guard made of it (`notes`, guard => text). +/datum/stealth_noise_view/proc/show(turf/where, kind, reach, list/notes, coalesced) + var/client/user = user_ref?.resolve() + if(isnull(user)) + qdel(src) + return + var/list/images = list() + var/image/marker = image('icons/effects/alphacolors.dmi', where, "white") + SET_PLANE(marker, ABOVE_LIGHTING_PLANE, where) + marker.color = coalesced ? "#888888" : "#ff66cc" + marker.alpha = coalesced ? 60 : 140 + if(!coalesced) + marker.maptext = MAPTEXT("[kind] [reach]") + marker.maptext_width = 96 + images += marker + if(!coalesced) + for(var/turf/edge as anything in RANGE_TURFS(reach, where)) + if(get_dist(edge, where) != reach) + continue + var/image/tint = image('icons/effects/alphacolors.dmi', edge, "white") + SET_PLANE(tint, ABOVE_LIGHTING_PLANE, edge) + tint.color = "#ff66cc" + tint.alpha = 40 + images += tint + for(var/mob/living/guard as anything in notes) + var/turf/guard_turf = get_turf(guard) + if(isnull(guard_turf)) + continue + var/image/label = new + label.loc = guard_turf + SET_PLANE(label, ABOVE_LIGHTING_PLANE, guard_turf) + label.maptext = MAPTEXT("[notes[guard]]") + label.maptext_width = 128 + label.maptext_y = 34 + images += label + user.images |= images + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(stealth_remove_images), user_ref, images), STEALTH_NOISE_VIEW_TIME) + +/// The noise views of admins standing on `z`. +/proc/stealth_noise_views(z) + . = list() + for(var/key in GLOB.stealth_sight_overlays) + var/datum/stealth_noise_view/view = GLOB.stealth_sight_overlays[key] + if(!istype(view)) + continue + var/client/user = view.user_ref?.resolve() + var/turf/user_turf = get_turf(user?.mob) + if(user_turf?.z == z) + . += view + +/// Switches `user`'s noise view on or off. TRUE if now on. +/proc/stealth_toggle_noise_view(client/user) + var/datum/stealth_noise_view/old = GLOB.stealth_sight_overlays["noise:[user.ckey]"] + if(old) + qdel(old) + return FALSE + new /datum/stealth_noise_view(user) + return TRUE + +ADMIN_VERB(stealth_make_noise, R_DEBUG, "Stealth Noise", "Make a noise stealth guards can hear at your turf, or watch the noises on your z-level.", ADMIN_CATEGORY_DEBUG) + var/turf/here = get_turf(user.mob) + if(isnull(here)) + to_chat(user, span_warning("You need to be standing somewhere."), confidential = TRUE) + return + var/view_choice = "Toggle the noise view" + var/choice = tgui_input_list(user, "Which noise?", "Stealth Noise", list(view_choice) + STEALTH_NOISE_KINDS) + if(isnull(choice)) + return + if(choice == view_choice) + var/shown = stealth_toggle_noise_view(user) + to_chat(user, span_notice("Noise view [shown ? "on" : "off"]."), confidential = TRUE) + stealth_admin_log(user, "[shown ? "showed" : "hid"] the noise view", here) + return + var/list/profile = stealth_noise_profile(choice) + var/reach = tgui_input_number(user, "Reach in tiles (0 for its usual [profile[STEALTH_PROFILE_REACH]])", "Stealth Noise", 0, 40, 0) + if(isnull(reach)) + return + var/as_me = isliving(user.mob) && tgui_alert(user, "Who made it?", "Stealth Noise", list("Nobody", "Me")) == "Me" + here = get_turf(user.mob) + var/heard = stealth_noise(here, choice, reach || null, as_me ? user.mob : null) + to_chat(user, span_notice("[heard] guard\s heard it."), confidential = TRUE) + stealth_admin_log(user, "made a [choice] noise[reach ? " (reach [reach])" : ""][as_me ? " as themselves" : ""], heard by [heard]", here) + BLACKBOX_LOG_ADMIN_VERB("Stealth Noise") + +/// The radio, the call on its way out and the last thing heard, for the guard summary. +/proc/stealth_guard_hearing_summary(mob/living/carbon/human/npc/guard, datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai) + var/radio_text = "none" + if(guard.stealth_radio) + var/obj/item/radio/earpiece = guard.ears + if(!istype(earpiece)) + radio_text = "none" + else if(!earpiece.is_on()) + radio_text = "off" + else if(is_within_radio_jammer_range(guard)) + radio_text = "jammed" + else + radio_text = "ok" + . = "radio [radio_text]" + if(stealth_ai.pending_call) + . += " (calling in [max(0, round((stealth_ai.pending_call[STEALTH_CALL_DUE] - world.time) / (1 SECONDS)))]s)" + if(stealth_ai.last_heard) + . += " | heard [stealth_ai.last_heard[1]] [round((world.time - stealth_ai.last_heard[2]) / (1 SECONDS))]s ago" + +/// What `group` remembers of noises, as chat text for `user`. +/proc/stealth_show_noise_memory(client/user, datum/stealth_group/group) + var/list/lines = list("[group.id]: [group.alarm_count()] alarms in memory") + // Prunes as it counts. + group.lure_count(group.home) + for(var/list/lure as anything in group.lures) + var/turf/spot = lure[1] + lines += "lure at ([spot.x], [spot.y]), [round((world.time - lure[2]) / (1 SECONDS))]s ago, [group.lure_count(spot)] near it" + for(var/datum/stealth_check/check as anything in group.checks) + var/mob/living/gone = check.who?.resolve() + lines += "out looking: [gone ? gone.real_name : "(gone)"] at ([check.where.x], [check.where.y]), missed in [round((check.due - world.time) / (1 SECONDS))]s, [length(check.waiters)] waiting" + to_chat(user, span_notice(lines.Join("
")), confidential = TRUE) diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index fd3dcbc1e69..82377896aa5 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -228,6 +228,9 @@ search_center = null search_queue = null hidden_spots = null + pending_call = null + heard_map = null + heard_now = null return ..() // With the AI off (nobody on the level, stunned, in crit, a player in the body) nothing scans, so no mark. @@ -239,6 +242,7 @@ /datum/ai_controller/basic_controller/human_npc/stealth/on_sentience_gained() . = ..() QDEL_NULL(meter) + stealth_drop_call() // The player has left the body: it is a guard again, with nothing on its mind. /datum/ai_controller/basic_controller/human_npc/stealth/on_sentience_lost() @@ -291,6 +295,9 @@ look_until = 0 lost_since = 0 calm_until = 0 + suspicion_heard = FALSE + if(new_state != STEALTH_UNAWARE) + glance_until = 0 if(new_state == STEALTH_ALERT || new_state == STEALTH_SEARCHING) stealth_set_wary() stealth_drop_walk() @@ -374,14 +381,15 @@ stealth_set_state(STEALTH_UNAWARE) stealth_rejoin_route() -/// Suspicious of something at `where`. `purpose` is STEALTH_GOTO_INVESTIGATE or STEALTH_GOTO_BODY. -/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_go_suspicious(turf/where, purpose = STEALTH_GOTO_INVESTIGATE) +/// Suspicious of something at `where`. `purpose` is STEALTH_GOTO_INVESTIGATE or STEALTH_GOTO_BODY. `line` is +/// the bark kind it says, or null for the usual one. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_go_suspicious(turf/where, purpose = STEALTH_GOTO_INVESTIGATE, line = null) stealth_set_state(STEALTH_SUSPICIOUS) goto_purpose = purpose investigated = FALSE last_gain = world.time stealth_aim_at(where) - stealth_bark(purpose == STEALTH_GOTO_BODY ? STEALTH_BARK_BODY : STEALTH_BARK_SUSPICIOUS) + stealth_bark(line || (purpose == STEALTH_GOTO_BODY ? STEALTH_BARK_BODY : STEALTH_BARK_SUSPICIOUS)) /// Suspicious: turns to `where` and makes it the place to walk over to. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_aim_at(turf/where) @@ -411,7 +419,8 @@ /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_go_alert(atom/target) if(QDELETED(target)) return - if(stealth_state() != STEALTH_ALERT) + var/news = stealth_state() != STEALTH_ALERT + if(news) stealth_set_state(STEALTH_ALERT) stealth_set_wary() lost_since = 0 @@ -419,6 +428,9 @@ last_seen_turf = get_turf(target) blackboard[BB_STEALTH_LAST_SEEN_AT] = world.time set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, target) + // It has seen or felt them itself: it calls for help (decision 8). + if(news) + stealth_first_hand(last_seen_turf) /// Alert: turns from its target to `new_target`, and remembers the old one for when this fight ends. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_switch_target(atom/new_target) @@ -468,17 +480,28 @@ . += spot picked++ -/// Says a stealth line, at most once per STEALTH_BARK_KIND_COOLDOWN for each kind (abuse P14). -/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_bark(kind) +/** + * Says a stealth line, at most once per STEALTH_BARK_KIND_COOLDOWN for each kind (abuse P14). `about` is the + * place the line is about: a line can name its side of the den. `name` is the friend a line asks after. + * `always` skips the cooldown (a radio call is said every time it is made). + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_bark(kind, turf/about, name, always = FALSE) var/mob/living/carbon/human/npc/body = pawn if(!ishumannpc(body) || body.stat != CONSCIOUS || body.client) return FALSE - if(world.time < bark_ready_at[kind]) - return FALSE - if(!body.npc_bark(kind, force = TRUE)) + if(!always && world.time < bark_ready_at[kind]) return FALSE - bark_ready_at[kind] = world.time + STEALTH_BARK_KIND_COOLDOWN - return TRUE + var/datum/human_npc_voice/scav/voice = ispath(body.npc_voice, /datum/human_npc_voice/scav) ? human_npc_singleton(body.npc_voice) : null + if(voice) + var/turf/centre = group?.home + voice.fill_side = (about && centre && about.z == centre.z && about != centre) ? dir2text(get_dir(centre, about)) : null + voice.fill_name = name + . = body.npc_bark(kind, force = TRUE) + if(voice) + voice.fill_side = null + voice.fill_name = null + if(.) + bark_ready_at[kind] = world.time + STEALTH_BARK_KIND_COOLDOWN /// Moves every awareness timestamp back by `time`, as if that long had passed (unit tests, admin tools). /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_rewind(time) @@ -501,6 +524,11 @@ next_harm_at -= time home_retry_at -= time health_mark_at -= time + glance_until -= time + next_shout -= time + next_recentre -= time + if(pending_call) + pending_call[STEALTH_CALL_DUE] -= time if(explained_at) explained_at -= time for(var/kind in bark_ready_at) @@ -533,6 +561,10 @@ else if(state == STEALTH_SUSPICIOUS && world.time - last_gain >= STEALTH_SUSPICIOUS_TIMEOUT) stealth_bark(STEALTH_BARK_GIVE_UP) stealth_go_unaware() + // Its ears, its radio and its missing friends (stealth_hearing.dm, stealth_radio.dm, stealth_noise.dm). + stealth_hear_footsteps() + stealth_deliver_call() + group?.check_overdue() if(stealth_state() == STEALTH_ALERT) stealth_keep_target() // Still fighting: it weighs everyone else. (Losing or downing its target has already looked round.) @@ -542,6 +574,7 @@ stealth_look() if(stealth_state() != STEALTH_ALERT && world.time >= next_body_scan) stealth_check_bodies() + heard_now = null for(var/datum/stealth_sight_overlay/overlay as anything in watchers) overlay.refresh() stealth_meter_update() @@ -639,10 +672,8 @@ continue judged++ var/rate = 0 - var/felt = FALSE if(boxed) rate = STEALTH_NOTICE_RATE - felt = TRUE else if(eyes && !stealth_is_cloaked(candidate) && stealth_in_cone(guard, where, half_angle)) var/cap = stealth_range_onto(where) if(dist <= cap) @@ -652,20 +683,15 @@ if(!rate && dist <= STEALTH_CLOSE_RANGE) // At its shoulder: light doesn't matter (abuse P7). rate = STEALTH_BEHIND_RATE - felt = TRUE if(!rate) continue var/list/entry = notice[key] if(isnull(entry)) entry = list(0, null, 0) notice[key] = entry - // First seen counts as moving: it just came into view. - var/moved = entry[STEALTH_ENTRY_TURF] != where - // STEP 2 STAND-IN: move intent stands in for "running is loud" until real footstep hearing lands. - var/running = moved && candidate.move_intent == MOVE_INTENT_RUN - if(running) - rate *= STEALTH_RUN_MULT - else if(!moved) + // First seen counts as moving: it just came into view. Sight knows moved or still, nothing more: + // running is heard, not seen (stealth_hear_footsteps()). + if(entry[STEALTH_ENTRY_TURF] == where) rate *= STEALTH_STILL_MULT if(candidate.body_position == LYING_DOWN) rate *= STEALTH_LYING_MULT @@ -677,10 +703,6 @@ rate *= STEALTH_WARY_MULT wary_at = world.time entry[STEALTH_ENTRY_NOTICE] = min(entry[STEALTH_ENTRY_NOTICE] + rate * scan_seconds, STEALTH_NOTICE_MAX) - if(felt && running) - entry[STEALTH_ENTRY_NOTICE] = max(entry[STEALTH_ENTRY_NOTICE], STEALTH_SUSPICIOUS_AT) - if(!alert && where != guard.loc) - guard.setDir(stealth_dir_to(guard, where)) entry[STEALTH_ENTRY_TURF] = where entry[STEALTH_ENTRY_SEEN_AT] = world.time perceived[key] = candidate @@ -701,7 +723,8 @@ if(entry[STEALTH_ENTRY_NOTICE] > seen_notice) seen_notice = entry[STEALTH_ENTRY_NOTICE] seen_key = key - else + else if(!heard_now?[key]) + // Unseen and unheard this scan. entry[STEALTH_ENTRY_NOTICE] = max(0, entry[STEALTH_ENTRY_NOTICE] - STEALTH_NOTICE_DECAY * scan_seconds) if(world.time - entry[STEALTH_ENTRY_SEEN_AT] > STEALTH_NOTICE_FORGET) notice -= key @@ -735,6 +758,8 @@ if(STEALTH_SUSPICIOUS) if(!seen_now) return + // It has someone in sight now: their own "?" takes over from the heard one. + suspicion_heard = FALSE if(level >= STEALTH_ALERT_AT && in_reach) stealth_go_alert(best) return @@ -809,6 +834,8 @@ lost_since = 0 last_seen_turf = get_turf(remembered) blackboard[BB_STEALTH_LAST_SEEN_AT] = world.time + // Still has them in view: it keeps calling. + stealth_shout() if(!target) set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, remembered) return @@ -924,6 +951,7 @@ else group.reported_bodies += key stealth_go_suspicious(where, STEALTH_GOTO_BODY) + stealth_first_hand(where) return // ===== Touches, hits and recovery ===== @@ -961,6 +989,7 @@ return TRUE stealth_go_searching(get_turf(source)) stealth_bark(STEALTH_BARK_HIT_UNSEEN) + stealth_first_hand(get_turf(source)) return FALSE /datum/ai_controller/basic_controller/human_npc/stealth/on_pawn_attacked(mob/living/source, atom/attacker, attack_flags) @@ -1026,6 +1055,8 @@ /datum/ai_controller/basic_controller/human_npc/stealth/proc/on_stunned(datum/source, amount) SIGNAL_HANDLER if(amount > 0) + // Whatever it was about to say on the radio is lost. + stealth_drop_call() stealth_note_harm() /** @@ -1060,6 +1091,8 @@ next_harm_at = world.time + STEALTH_HARM_COOLDOWN stealth_setup() stealth_trouble_at(where) + if(guard.stat == CONSCIOUS) + stealth_first_hand(where) for(var/mob/living/friend as anything in group?.living_members()) if(friend == guard) continue @@ -1112,6 +1145,7 @@ last_stat = new_stat if(new_stat != CONSCIOUS) QDEL_NULL(meter) + stealth_drop_call() if(new_stat == CONSCIOUS && was != CONSCIOUS && was != DEAD) stealth_came_round() diff --git a/voidcrew/modules/stealth/stealth_hearing.dm b/voidcrew/modules/stealth/stealth_hearing.dm new file mode 100644 index 00000000000..7d515e7381a --- /dev/null +++ b/voidcrew/modules/stealth/stealth_hearing.dm @@ -0,0 +1,239 @@ +/** + * # Stealth guards: what a guard does about what it hears + * + * The group decides who goes (stealth_noise.dm); these are the things one guard can be told to do, the + * shout that passes first-hand knowledge on by earshot, and the footsteps its own scan listens for. + * + * - stealth_go_heard(): suspicious of a noise. The same stare, walk over and look round as a sighting, with + * a heard line and the grey "?" (stealth_meter.dm). It never makes a guard wary by itself. + * - stealth_glance(): turns to face a noise for a moment without leaving its state, route or post. + * - stealth_hold(): stays where it is, wary, facing the noise. + * - stealth_respond(): runs to a spot and searches there (an alarm, a shout, a radio call, a missing friend). + * - stealth_shout(): calls for help. Only for what it learned first hand: a guard that came because of a + * shout or a call never shouts onward, so one sighting can't chain the whole den awake. + * + * Footsteps (owner decision 13) follow tg's own rules: walking is silent, running is heard, and anything + * that silences a player's steps for players silences them for guards (stealth_footstep_reach()). They are + * pulled by the guard's scan, so a walker pays nothing per step. Steps alone can make a guard turn and + * look, never alert. + */ +/datum/ai_controller/basic_controller/human_npc/stealth + /// Suspicious because of a noise, not a sighting: it shows the grey "?" + var/suspicion_heard = FALSE + /// world.time its glance at a noise ends + var/glance_until = 0 + /// The way it glances + var/glance_dir = SOUTH + /// REF(mob) => the turf it stood on at the last scan, for everyone in earshot of a footstep + var/list/heard_map + /// REF(mob) => TRUE for everyone whose steps it heard this scan (their notice doesn't decay) + var/list/heard_now + /// Its radio call on the way out: list(kind, turf, world.time due, name), or null + var/list/pending_call + /// world.time it may next shout for help + var/next_shout = 0 + /// world.time its search may next move to a newer noise + var/next_recentre = 0 + /// list(noise kind, world.time) of the last thing it heard, for admins + var/list/last_heard + +/// Whether it can be sent to look at a noise: unaware, or suspicious and not yet on its way. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_can_investigate() + switch(stealth_state()) + if(STEALTH_UNAWARE) + return TRUE + if(STEALTH_SUSPICIOUS) + return !investigated && isnull(goto_dest) && goto_purpose != STEALTH_GOTO_BODY + return FALSE + +/// Heard something worth a look at `where`. Suspicious with the heard flag set: same stare, walk and look +/// round as a sighting, a heard line instead of "Hm?", and the heard mark. Already suspicious, it re-aims. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_go_heard(turf/where, again = FALSE) + var/turf/spot = stealth_hear_spot(where, get_turf(pawn)) + if(isnull(spot) || stealth_driven()) + return + if(stealth_state() == STEALTH_SUSPICIOUS) + last_gain = world.time + if(!investigated) + stealth_aim_at(spot) + return + stealth_go_suspicious(spot, STEALTH_GOTO_INVESTIGATE, again ? STEALTH_BARK_HEARD_AGAIN : STEALTH_BARK_HEARD) + suspicion_heard = TRUE + stealth_meter_update() + +/// Turns to face `where` for `time` without leaving its state, route or post. No line: the turn is the read. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_glance(turf/where, time = STEALTH_GLANCE_TIME) + var/mob/living/guard = pawn + if(isnull(where) || stealth_driven() || get_turf(guard) == where) + return + glance_dir = stealth_dir_to(guard, where) + glance_until = max(glance_until, world.time + time) + if(stealth_state() == STEALTH_UNAWARE && !blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + stealth_drop_walk() + guard.setDir(glance_dir) + +/// Stays where it is, wary, facing `where` (sentries, and guards past the responder cap). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_hold(turf/where) + if(stealth_driven()) + return + stealth_set_wary() + if(stealth_state() != STEALTH_UNAWARE) + return + stealth_glance(where, STEALTH_HOLD_TIME) + stealth_bark(STEALTH_BARK_HOLD) + +/** + * Runs to `where` and searches there: an alarm, a friend's shout, a radio call, a missing friend. Wary. + * Not while it fights. Already searching, it moves its search there only if that is somewhere else, and at + * most once per STEALTH_RECENTRE_COOLDOWN. Returns TRUE if it is now searching at or near `where`. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_respond(turf/where) + var/mob/living/guard = pawn + if(isnull(where) || QDELETED(guard) || guard.stat != CONSCIOUS || stealth_driven()) + return FALSE + if(stealth_state() == STEALTH_ALERT || blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + return FALSE + var/turf/spot = stealth_hear_spot(where, get_turf(guard)) + if(stealth_state() == STEALTH_SEARCHING && !calm_until) + if(search_center && get_dist(search_center, spot) <= STEALTH_SEARCH_RADIUS) + return TRUE + if(world.time < next_recentre) + return FALSE + next_recentre = world.time + STEALTH_RECENTRE_COOLDOWN + stealth_go_searching(spot) + return TRUE + +/// Calls for help: a noise its own group hears. It has to be able to speak (tg's can_speak()), so a muted +/// or muzzled guard calls nobody. At most once per STEALTH_SHOUT_INTERVAL. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_shout() + var/mob/living/guard = pawn + if(world.time < next_shout || QDELETED(guard) || stealth_driven() || !human_npc_can_talk(guard)) + return FALSE + next_shout = world.time + STEALTH_SHOUT_INTERVAL + stealth_noise(guard, STEALTH_NOISE_SHOUT, null, guard) + return TRUE + +/// It has just learned something first hand at `where` (a sighting, a touch, a hit from nowhere, a body): +/// it shouts, and calls it in if it carries a radio. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_first_hand(turf/where) + var/mob/living/carbon/human/npc/guard = pawn + if(QDELETED(guard) || guard.stat != CONSCIOUS || stealth_driven() || !stealth_ready) + return + stealth_shout() + if(ishumannpc(guard) && guard.stealth_radio) + stealth_start_call(STEALTH_CALL_ALARM, where || get_turf(guard)) + +// ===== Footsteps ===== + +/** + * How far `walker`'s last step carried to a guard, in tiles, by tg's own footstep rules (the footstep + * element's prepare_step() and play_humanstep()). 0 for silent: walking, silent shoes or any other source of + * TRAIT_SILENT_FOOTSTEPS, in a box, a locker or a mech, buckled, thrown, flying, crawling in a vent, held + * still, or on a turf with no footstep sound. + * + * A running step on plain floor in shoes carries STEALTH_FOOTSTEP_RANGE. Any other floor or footwear scales + * that by how far tg plays its sound to players compared with the plain one (tg's own tables: plating and + * wood ring a little further, bare feet on carpet and the Light Step quirk a little less). A living mob that + * is not a carbon counts as running whenever it moves. + */ +/proc/stealth_footstep_reach(mob/living/walker) + if(SHOULD_DISABLE_FOOTSTEPS(walker)) + return 0 + var/turf/open/ground = walker.loc + if(!istype(ground) || isnull(ground.footstep)) + return 0 + if(walker.buckled || walker.throwing || (walker.movement_type & (VENTCRAWLING | FLYING)) || HAS_TRAIT(walker, TRAIT_IMMOBILIZED)) + return 0 + if(walker.body_position == LYING_DOWN) + return STEALTH_FOOTSTEP_CRAWL_RANGE + if(!iscarbon(walker)) + return STEALTH_FOOTSTEP_RANGE + if(walker.move_intent == MOVE_INTENT_WALK) + return 0 + if(!ishuman(walker)) + return STEALTH_FOOTSTEP_RANGE + var/mob/living/carbon/human/person = walker + // The sound tg plays for this floor and what is on its feet: list(sounds, volume, extra range). + var/list/step_sound + if((person.wear_suit?.body_parts_covered | person.w_uniform?.body_parts_covered | person.shoes?.body_parts_covered) & FEET) + step_sound = GLOB.footstep[ground.footstep] + else + var/obj/item/bodypart/leg/leg = person.get_bodypart(BODY_ZONE_R_LEG) || person.get_bodypart(BODY_ZONE_L_LEG) + switch(leg?.footstep_type) + if(FOOTSTEP_MOB_CLAW) + step_sound = GLOB.clawfootstep[ground.clawfootstep] + if(FOOTSTEP_MOB_BAREFOOT) + step_sound = GLOB.barefootstep[ground.barefootstep] + if(FOOTSTEP_MOB_HEAVY) + step_sound = GLOB.heavyfootstep[ground.heavyfootstep] + if(FOOTSTEP_MOB_SHOE) + step_sound = GLOB.footstep[ground.footstep] + if(length(step_sound) < 3) + return 0 + var/volume = step_sound[2] + // The human footstep element plays at -6 range (human.dm). + var/sound_range = SOUND_RANGE + step_sound[3] - 6 + if(HAS_TRAIT(person, TRAIT_LIGHT_STEP)) + volume *= 0.6 + sound_range -= 2 + if(volume <= SOUND_AUDIBLE_VOLUME_MIN || sound_range <= 1) + return 0 + var/audible = CALCULATE_MAX_SOUND_AUDIBLE_DISTANCE(volume, sound_range, 1, SOUND_FALLOFF_EXPONENT) + return clamp(round(STEALTH_FOOTSTEP_RANGE * audible / STEALTH_FOOTSTEP_PLAYER_RANGE, 1), 0, STEALTH_FOOTSTEP_MAX_RANGE) + +/** + * The scan's ear for footsteps, before it looks. Everyone near whose turf changed since the last scan and + * whose step carries this far (walls and doors muffle it) is heard: no line of sight needed. + * - Unaware or suspicious: their notice gains STEALTH_FOOTSTEP_NOTICE, never past STEALTH_SUSPICIOUS_AT; at + * its shoulder it jumps there at once. At that level it turns to the steps and goes to look. From there + * sight decides: steps alone never make it alert. + * - Searching: the search moves to the steps. Someone hunted who runs is followed by ear; one who walks isn't. + * Footsteps are its own senses, not a dispatch: they open no check and count as no lure. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_hear_footsteps() + heard_now = null + var/mob/living/carbon/human/guard = pawn + var/state = stealth_state() + if(state == STEALTH_ALERT || !isturf(guard.loc) || !guard.can_hear()) + heard_map = null + return + var/turf/here = guard.loc + var/list/was = heard_map + var/list/now = list() + var/list/notice = notice_map + for(var/mob/living/walker as anything in stealth_candidates(guard, STEALTH_FOOTSTEP_MAX_RANGE)) + var/key = REF(walker) + var/turf/where = get_turf(walker) + now[key] = where + var/turf/stood = was?[key] + if(isnull(stood) || stood == where) + continue + var/reach = stealth_footstep_reach(walker) + if(!reach || get_dist(here, where) > reach || stealth_muffled_dist(where, here) > reach) + continue + LAZYSET(heard_now, key, TRUE) + last_heard = list("footsteps", world.time) + if(state == STEALTH_SEARCHING) + if(!calm_until && world.time >= next_recentre && get_dist(search_center, where) > 1) + next_recentre = world.time + STEALTH_RECENTRE_COOLDOWN + stealth_go_searching(where) + state = stealth_state() + continue + var/list/entry = notice[key] + if(isnull(entry)) + entry = list(0, where, 0) + notice[key] = entry + if(entry[STEALTH_ENTRY_NOTICE] < STEALTH_SUSPICIOUS_AT) + var/gained = get_dist(here, where) <= STEALTH_CLOSE_RANGE ? STEALTH_SUSPICIOUS_AT : entry[STEALTH_ENTRY_NOTICE] + STEALTH_FOOTSTEP_NOTICE + entry[STEALTH_ENTRY_NOTICE] = min(gained, STEALTH_SUSPICIOUS_AT) + entry[STEALTH_ENTRY_SEEN_AT] = world.time + if(blackboard[BB_STEALTH_WARY]) + wary_at = world.time + if(entry[STEALTH_ENTRY_NOTICE] >= STEALTH_SUSPICIOUS_AT) + stealth_go_heard(where) + if(state == STEALTH_SUSPICIOUS && investigated && where != here) + // Looking round already: it turns to the steps. + stand_dir = stealth_dir_to(guard, where) + guard.setDir(stand_dir) + state = stealth_state() + heard_map = now diff --git a/voidcrew/modules/stealth/stealth_meter.dm b/voidcrew/modules/stealth/stealth_meter.dm index d2f070ab5fa..07a5f796015 100644 --- a/voidcrew/modules/stealth/stealth_meter.dm +++ b/voidcrew/modules/stealth/stealth_meter.dm @@ -8,6 +8,9 @@ * - Searching: a yellow "?" everyone sees, draining from the top over the search (or until calm_until * after it put its target down). Empty: gone. * - While alert or searching, nobody sees their own "?" on that guard. + * - Suspicious of a noise (stealth_hearing.dm): an empty grey "?" for every player near who has no fill of + * their own on that guard. Someone it has started to see gets their own filling "?" instead, so nothing + * stacks. A glance, a hold and a radio call show no mark: the turn, the raised hand and the line are the read. * * Both are drawn on the guard (vis_contents for the public mark, an image located on the guard for the * private one), so they show only when the guard itself is in view, never through walls; above the @@ -64,7 +67,7 @@ // Alert and searching own the mark even once it has drained: no private "?" in the moment before the scan // sends it back to unaware (and clears its notice). var/public_owned = new_public || state == STEALTH_ALERT || state == STEALTH_SEARCHING - update_private(public_owned ? null : controller.notice_map) + update_private(public_owned ? null : controller.notice_map, !public_owned && stealth_meter_heard(state, controller.suspicion_heard)) schedule_drain() /datum/stealth_meter/proc/set_public(new_state) @@ -83,12 +86,36 @@ guard.vis_contents += mark mark.icon_state = new_state +/// The players near the guard who get the empty grey "?" of a heard noise: every living player within +/// STEALTH_METER_RANGE with no fill of their own in `notice`. +/datum/stealth_meter/proc/heard_viewers(list/notice) + . = list() + var/turf/here = get_turf(guard) + if(isnull(here) || here.z > length(SSmobs.clients_by_zlevel)) + return + for(var/mob/living/viewer as anything in SSmobs.clients_by_zlevel[here.z]) + if(viewer == guard || get_dist(get_turf(viewer), here) > STEALTH_METER_RANGE) + continue + var/list/entry = notice?[REF(viewer)] + if(entry && stealth_meter_notice_state(entry[STEALTH_ENTRY_NOTICE])) + continue + . += viewer + /// Gives each nearby player their own "?" for their notice entry, and takes away the rest. An admin watching -/// the guard's sight gets the fullest one, whoever it is for. -/datum/stealth_meter/proc/update_private(list/notice) +/// the guard's sight gets the fullest one, whoever it is for. `heard`: the guard is suspicious of a noise, so +/// everyone near without a fill of their own gets the empty "?". +/datum/stealth_meter/proc/update_private(list/notice, heard = FALSE) // key => list(icon_state, client to show it to) var/list/wanted = list() var/turf/here = get_turf(guard) + if(heard && here) + for(var/mob/living/viewer as anything in heard_viewers(notice)) + if(viewer.client) + wanted[REF(viewer)] = list(STEALTH_METER_HEARD_STATE, viewer.client) + for(var/datum/stealth_sight_overlay/overlay as anything in controller.watchers) + var/client/admin = overlay.user_ref?.resolve() + if(admin && !wanted[REF(admin.mob)]) + wanted["watch:[admin.ckey]"] = list(STEALTH_METER_HEARD_STATE, admin) if(length(notice) && here) var/top_state var/top_notice = 0 @@ -111,7 +138,7 @@ if(top_state) for(var/datum/stealth_sight_overlay/overlay as anything in controller.watchers) var/client/admin = overlay.user_ref?.resolve() - if(isnull(admin) || wanted[REF(admin.mob)]) + if(isnull(admin) || (wanted[REF(admin.mob)] && wanted[REF(admin.mob)][1] != STEALTH_METER_HEARD_STATE)) continue wanted["watch:[admin.ckey]"] = list(top_state, admin) for(var/key in private_marks.Copy()) @@ -219,6 +246,10 @@ // ===== Pure: state to icon_state ===== +/// Whether a guard in `state` shows the heard "?". +/proc/stealth_meter_heard(state, suspicion_heard) + return suspicion_heard && state == STEALTH_SUSPICIOUS + /// The private "?" for a notice level, or null for none. Fills round to the nearest row. /proc/stealth_meter_notice_state(notice) if(!(notice > 0)) diff --git a/voidcrew/modules/stealth/stealth_noise.dm b/voidcrew/modules/stealth/stealth_noise.dm new file mode 100644 index 00000000000..1ff6aabe530 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_noise.dm @@ -0,0 +1,498 @@ +/** + * # Stealth guards: noise + * + * stealth_noise() is the only way a guard hears anything but footsteps (those its own scan listens for, + * stealth_hearing.dm). The sources are tg's own actions (stealth_noise_sources.dm). + * + * No sound ever gives a guard a target. Hearing turns a guard, moves it, makes it search and makes it wary; + * only sight and touch set BB_BASIC_MOB_CURRENT_TARGET. + * + * A noise reaches the stealth groups of its own level and map region. Walls and closed doors on the straight + * line to each guard eat reach (stealth_muffled_dist()). What the hearers do is decided for the group as a + * whole (dispatch_noise()): a door makes them glance; a small noise sends one guard to look, the next one at + * the same spot two, the third everyone; gunfire, blasts and screams send the nearest few running while + * sentries hold their posts. A guard that went to look and isn't back in STEALTH_CHECKIN_TIME is missed by + * the ones who watched it go. + * + * Cost: with no group alive, one length() check. With no living player on the level, or in airless space, + * the noise is dropped before any guard is looked at. The same kind of noise within STEALTH_NOISE_COALESCE + * and STEALTH_NOISE_COALESCE_RANGE of the last is dropped before any per-guard work. Listeners come from the + * group's roster, never from view() or hearers(). Nothing here runs on a timer: lures, alarms and checks + * are small lists of world.time stamps on the group, pruned when read. + */ + +/// A guard that went to look at a noise, and the ones who know it went. +/datum/stealth_check + /// Weakref to the guard that went + var/datum/weakref/who + /// What its friends call it, or null if it has no name of its own + var/name + /// Where the noise was + var/turf/where + /// world.time it is missed + var/due = 0 + /// Weakrefs to the guards that saw or heard it go + var/list/datum/weakref/waiters = list() + +/datum/stealth_group + /// Noise kind => list(world.time, turf) of the last one its guards heard + var/list/noise_stamps = list() + /// list(turf, world.time) for each small noise it sent someone to + var/list/lures = list() + /// list(world.time, weight) for each alarm it answered (a lure counts half) + var/list/alarms = list() + /// Guards out looking at a noise + var/list/datum/stealth_check/checks = list() + /// world.time the checks are next looked over + var/next_overdue_check = 0 + /// world.time the next radio alarm may go out + var/next_radio_alarm = 0 + /// Admin noise view only: guard => what it made of the noise being dealt with, else null + var/list/noise_notes + /// Reach of the noise being dealt with + var/noise_reach = 0 + +/// list(reach, level, flags) for a STEALTH_NOISE_* kind, or null. +/proc/stealth_noise_profile(kind) + var/static/list/profiles + if(isnull(profiles)) + profiles = list( + STEALTH_NOISE_GUN_QUIET = list(STEALTH_NOISE_RANGE_GUN_QUIET, STEALTH_HEAR_INVESTIGATE, STEALTH_NOISE_LOS_ONLY), + STEALTH_NOISE_GUN_PISTOL = list(STEALTH_NOISE_RANGE_GUN_PISTOL, STEALTH_HEAR_ALARM, STEALTH_NOISE_LOUD), + STEALTH_NOISE_GUN_SMG = list(STEALTH_NOISE_RANGE_GUN_SMG, STEALTH_HEAR_ALARM, STEALTH_NOISE_LOUD), + STEALTH_NOISE_GUN_LONG = list(STEALTH_NOISE_RANGE_GUN_LONG, STEALTH_HEAR_ALARM, STEALTH_NOISE_LOUD), + STEALTH_NOISE_IMPACT = list(STEALTH_NOISE_RANGE_IMPACT, STEALTH_HEAR_INVESTIGATE, NONE), + STEALTH_NOISE_BLAST = list(STEALTH_NOISE_RANGE_BLAST, STEALTH_HEAR_ALARM, STEALTH_NOISE_LOUD), + STEALTH_NOISE_GLASS = list(STEALTH_NOISE_RANGE_GLASS, STEALTH_HEAR_INVESTIGATE, NONE), + STEALTH_NOISE_THROWN = list(STEALTH_NOISE_RANGE_THROWN_SMALL, STEALTH_HEAR_INVESTIGATE, NONE), + STEALTH_NOISE_KNOCK = list(STEALTH_NOISE_RANGE_KNOCK, STEALTH_HEAR_INVESTIGATE, NONE), + STEALTH_NOISE_BASH = list(STEALTH_NOISE_RANGE_BASH, STEALTH_HEAR_INVESTIGATE, NONE), + STEALTH_NOISE_DOOR = list(STEALTH_NOISE_RANGE_DOOR, STEALTH_HEAR_GLANCE, NONE), + STEALTH_NOISE_THUD = list(STEALTH_NOISE_RANGE_THUD, STEALTH_HEAR_INVESTIGATE, STEALTH_NOISE_ALLIES_COUNT), + STEALTH_NOISE_VOICE = list(STEALTH_NOISE_RANGE_VOICE, STEALTH_HEAR_INVESTIGATE, NONE), + STEALTH_NOISE_SCREAM = list(STEALTH_NOISE_RANGE_SCREAM, STEALTH_HEAR_ALARM, STEALTH_NOISE_LOUD | STEALTH_NOISE_ALLIES_COUNT), + STEALTH_NOISE_SHOUT = list(STEALTH_NOISE_RANGE_SHOUT, STEALTH_HEAR_SHOUT, STEALTH_NOISE_LOUD | STEALTH_NOISE_GROUP_ONLY), + ) + return profiles[kind] + +/// Whether `kind` is a gunshot loud enough to be a call for help when one of their own fires it. +/proc/stealth_noise_is_gunfire(kind) + return kind == STEALTH_NOISE_GUN_PISTOL || kind == STEALTH_NOISE_GUN_SMG || kind == STEALTH_NOISE_GUN_LONG + +/** + * Something made a noise guards can hear. Does nothing unless a stealth group has awake members on that level. + * source: where it happened (any atom; its turf is used). kind: STEALTH_NOISE_*. reach: tiles in open air, or + * null for the kind's default. actor: the living mob that made it, if known. only: one group to tell, or null + * for every group in earshot. + * Returns the number of guards that heard it (tests and the admin view). + */ +/proc/stealth_noise(atom/source, kind, reach = null, mob/living/actor = null, datum/stealth_group/only = null) + if(!length(GLOB.stealth_groups)) + return 0 + var/turf/where = get_turf(source) + var/list/profile = stealth_noise_profile(kind) + if(isnull(where) || isnull(profile)) + return 0 + // Nobody to play for: guards sleep with their level. + if(where.z > length(SSmobs.clients_by_zlevel) || !length(SSmobs.clients_by_zlevel[where.z])) + return 0 + if(isnull(reach)) + reach = profile[STEALTH_PROFILE_REACH] + if(reach <= 0) + return 0 + // A door nobody is named for may be one of their own going through. + var/door = isnull(actor) && istype(source, /obj/machinery/door) + var/aired = FALSE + . = 0 + for(var/datum/stealth_group/group as anything in (only ? list(only) : GLOB.stealth_groups.Copy())) + if(QDELETED(group) || group.home?.z != where.z || !group.region_matches(where)) + continue + if(!aired) + aired = TRUE + if(!stealth_noise_carries(where, actor)) + return 0 + . += group.hear(where, kind, reach, profile[STEALTH_PROFILE_LEVEL], profile[STEALTH_PROFILE_FLAGS], actor, door) + +/// Whether there is air at `where` to carry a sound, as for players (playsound_local scales by pressure). A +/// noise on a wall or a window tile is judged where its maker stands. +/proc/stealth_noise_carries(turf/where, mob/living/actor) + var/turf/air_turf = where + if(isclosedturf(air_turf)) + air_turf = get_turf(actor) + if(isnull(air_turf) || isclosedturf(air_turf)) + return TRUE + var/datum/gas_mixture/air = air_turf.return_air() + return !isnull(air) && air.return_pressure() >= SOUND_MINIMUM_PRESSURE + +/** + * How far off a sound from `origin` seems at `ear`: the distance plus STEALTH_MUFFLE_WALL for each wall and + * STEALTH_MUFFLE_DOOR for each closed solid door (or anything else you can't see through) on the straight + * line between them. Glass costs nothing. Loud sounds lose half as much. INFINITY when unheard: more than + * STEALTH_MUFFLE_MAX_BLOCKERS in the way, or any at all for a STEALTH_NOISE_LOS_ONLY sound. The two end + * turfs are never counted, so a knock on a wall is heard on both sides of it. + */ +/proc/stealth_muffled_dist(turf/origin, turf/ear, flags = NONE) + if(isnull(origin) || isnull(ear) || origin.z != ear.z) + return INFINITY + var/dist = get_dist(origin, ear) + if(dist <= 1) + return dist + var/list/line = get_line(origin, ear) + var/blockers = 0 + var/penalty = 0 + for(var/index in 2 to length(line) - 1) + var/turf/between = line[index] + var/cost = 0 + if(isclosedturf(between)) + cost = STEALTH_MUFFLE_WALL + else if(between.directional_opacity == ALL_CARDINALS) + cost = STEALTH_MUFFLE_DOOR + if(!cost) + continue + if(flags & STEALTH_NOISE_LOS_ONLY) + return INFINITY + blockers++ + if(blockers > STEALTH_MUFFLE_MAX_BLOCKERS) + return INFINITY + penalty += cost + if(flags & STEALTH_NOISE_LOUD) + penalty *= STEALTH_MUFFLE_LOUD_MULT + return dist + penalty + +/// Where a guard standing on `listener` goes to look at a noise at `where`: the spot, or, when the spot is a +/// wall or a window tile, the open tile beside it nearest the guard (its own side of the wall). +/proc/stealth_hear_spot(turf/where, turf/listener) + if(isnull(where)) + return null + if(isopenturf(where) && !where.is_blocked_turf(exclude_mobs = TRUE)) + return where + var/turf/best + var/best_dist = INFINITY + for(var/turf/open/near in RANGE_TURFS(1, where)) + if(near == where || near.is_blocked_turf(exclude_mobs = TRUE)) + continue + // Straight-line distance: of two tiles as many steps away, the one more directly on its side. + var/dist = listener ? get_dist_euclidean(near, listener) : 0 + if(dist < best_dist) + best = near + best_dist = dist + return best || where + +// ===== The group's side ===== + +/// Its guards hear a noise at `where`, those that can. Returns how many did. +/datum/stealth_group/proc/hear(turf/where, kind, reach, level, flags, mob/living/actor, door = FALSE) + var/list/views = length(GLOB.stealth_sight_overlays) ? stealth_noise_views(where.z) : null + // The same noise again (full auto, a burst, pellets): one event, not ten. + var/list/stamp = noise_stamps[kind] + if(stamp && world.time - stamp[1] < STEALTH_NOISE_COALESCE && get_dist(stamp[2], where) <= STEALTH_NOISE_COALESCE_RANGE) + for(var/datum/stealth_noise_view/view as anything in views) + view.show(where, kind, reach, null, TRUE) + return 0 + var/list/guards = living_members() + if(!length(guards)) + return 0 + if((flags & STEALTH_NOISE_GROUP_ONLY) && !(actor in guards)) + return 0 + if(door && member_beside(where, guards)) + return 0 + var/mob/living/any_guard = guards[1] + var/ally = !isnull(actor) && any_guard.faction_check_atom(actor) + var/gunfire = stealth_noise_is_gunfire(kind) + // One of their own making an everyday noise. + if(ally && !gunfire && !(flags & (STEALTH_NOISE_ALLIES_COUNT | STEALTH_NOISE_GROUP_ONLY))) + return 0 + // An ally's gunfire means an ally is in a fight: it is a call for help from where they stand. + if(ally && gunfire) + level = STEALTH_HEAR_SHOUT + noise_notes = views ? list() : null + noise_reach = reach + // list(guard, muffled distance), nearest first + var/list/hearers = list() + for(var/mob/living/carbon/human/npc/guard as anything in guards) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + if(guard == actor || !istype(guard_ai)) + continue + var/turf/guard_turf = get_turf(guard) + if(guard_turf?.z != where.z) + continue + var/dist = get_dist(guard_turf, where) + if(dist > reach) + continue + if(guard_ai.ai_status == AI_STATUS_OFF || guard.client || guard.stat != CONSCIOUS || guard_ai.stealth_captive() || guard_ai.blackboard_key_exists(BB_HUMAN_NPC_EXIT)) + note(guard, "busy") + continue + if(!guard.can_hear()) + note(guard, "deaf") + continue + // Fighting: only an alarm made by someone else tells it anything, and that before the line walk. + if(guard_ai.stealth_state() == STEALTH_ALERT && (level != STEALTH_HEAR_ALARM || !isliving(actor))) + note(guard, "busy") + continue + var/muffled = stealth_muffled_dist(where, guard_turf, flags) + if(muffled > reach) + note(guard, muffled == INFINITY ? "muffled" : "muffled [muffled]/[reach]") + continue + var/index = 1 + while(index <= length(hearers) && hearers[index][2] <= muffled) + index++ + hearers.Insert(index, null) + hearers[index] = list(guard, muffled) + guard_ai.last_heard = list(kind, world.time) + note(guard, "heard [muffled]/[reach]") + if(length(hearers)) + noise_stamps[kind] = list(world.time, where) + // Far off, they misjudge the spot: all of them by the same error, so they end up in one place. + var/turf/spot = where + var/list/nearest = hearers[1] + var/fuzz = min(STEALTH_NOISE_FUZZ_MAX, round((nearest[2] - STEALTH_NOISE_EXACT_RANGE) / STEALTH_NOISE_FUZZ_STEP, 1)) + if(fuzz > 0 && level != STEALTH_HEAR_SHOUT) + var/turf/guess = locate(clamp(where.x + rand(-fuzz, fuzz), 1, world.maxx), clamp(where.y + rand(-fuzz, fuzz), 1, world.maxy), where.z) + guess = stealth_open_near(guess, 2) + if(guess && region_matches(guess)) + spot = guess + dispatch_noise(hearers, where, kind, level, actor, spot) + for(var/datum/stealth_noise_view/view as anything in views) + view.show(where, kind, reach, noise_notes, FALSE) + noise_notes = null + return length(hearers) + +/// Admin noise view: what `guard` made of the noise being dealt with. +/datum/stealth_group/proc/note(mob/living/guard, text, append = FALSE) + if(isnull(noise_notes)) + return + noise_notes[guard] = append ? "[noise_notes[guard]] -> [text]" : text + +/// Whether a conscious guard of the group stands within a tile of `where`. +/datum/stealth_group/proc/member_beside(turf/where, list/guards) + for(var/mob/living/guard as anything in guards) + if(guard.stat == CONSCIOUS && guard.z == where.z && get_dist(guard, where) <= 1) + return TRUE + return FALSE + +/// How many small noises it sent someone to within STEALTH_LURE_RADIUS of `where` and STEALTH_LURE_MEMORY. +/datum/stealth_group/proc/lure_count(turf/where) + . = 0 + for(var/list/lure as anything in lures) + if(world.time - lure[2] > STEALTH_LURE_MEMORY) + lures -= list(lure) + continue + if(get_dist(lure[1], where) <= STEALTH_LURE_RADIUS) + .++ + +/// How many alarms it answered within STEALTH_ALARM_MEMORY (a lure counts half). +/datum/stealth_group/proc/alarm_count() + . = 0 + for(var/list/alarm as anything in alarms) + if(world.time - alarm[1] > STEALTH_ALARM_MEMORY) + alarms -= list(alarm) + continue + . += alarm[2] + +/// Forgets every noise (admin tools). +/datum/stealth_group/proc/forget_noises() + noise_stamps = list() + lures = list() + alarms = list() + checks = list() + next_radio_alarm = 0 + +/// Moves every noise stamp back by `time`, as if that long had passed (unit tests, admin tools). +/datum/stealth_group/proc/rewind(time) + for(var/kind in noise_stamps) + var/list/stamp = noise_stamps[kind] + stamp[1] -= time + for(var/list/lure as anything in lures) + lure[2] -= time + for(var/list/alarm as anything in alarms) + alarm[1] -= time + for(var/datum/stealth_check/check as anything in checks) + check.due -= time + next_overdue_check -= time + next_radio_alarm -= time + +/** + * What the guards that heard a noise do, decided for the group. `hearers` is list(guard, muffled distance), + * nearest first. `where` is where it really was (lures are counted there); `spot` is where they think it was. + */ +/datum/stealth_group/proc/dispatch_noise(list/hearers, turf/where, kind, level, mob/living/actor, turf/spot) + spot ||= where + switch(level) + if(STEALTH_HEAR_GLANCE) + for(var/list/hearer as anything in hearers) + var/mob/living/guard = hearer[1] + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + if(guard_ai.stealth_state() == STEALTH_UNAWARE) + guard_ai.stealth_glance(spot) + note(guard, "glance", TRUE) + if(STEALTH_HEAR_INVESTIGATE) + dispatch_investigate(hearers, where, spot) + if(STEALTH_HEAR_ALARM) + dispatch_alarm(hearers, where, spot, kind, actor) + if(STEALTH_HEAR_SHOUT) + dispatch_shout(hearers, spot) + +/// A small noise: one guard goes to look, the rest glance. The second time at one spot two go; from the third +/// everyone who hears it searches there, and they call it in. +/datum/stealth_group/proc/dispatch_investigate(list/hearers, turf/where, turf/spot) + var/earlier = lure_count(where) + lures += list(list(where, world.time)) + alarms += list(list(world.time, 0.5)) + if(earlier >= 2) + var/shouted = FALSE + for(var/list/hearer as anything in hearers) + var/mob/living/carbon/human/npc/guard = hearer[1] + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + // A sentry still doesn't leave its door for something far off. + if(isnull(guard_ai.route_id) && get_dist(guard, spot) > STEALTH_SENTRY_INVESTIGATE_RANGE) + guard_ai.stealth_hold(spot) + note(guard, "holds", TRUE) + else if(guard_ai.stealth_respond(spot)) + note(guard, "searches", TRUE) + if(!shouted) + shouted = TRUE + guard_ai.stealth_bark(STEALTH_BARK_HELP) + guard_ai.stealth_shout() + if(guard.stealth_radio) + guard_ai.stealth_start_call(STEALTH_CALL_ALARM, spot) + return + var/wanted = earlier + 1 + var/list/went = list() + var/list/stayed = list() + for(var/list/hearer as anything in hearers) + var/mob/living/carbon/human/npc/guard = hearer[1] + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + var/sentry_too_far = isnull(guard_ai.route_id) && get_dist(guard, spot) > STEALTH_SENTRY_INVESTIGATE_RANGE + if(length(went) < wanted && !sentry_too_far && guard_ai.stealth_can_investigate()) + guard_ai.stealth_go_heard(spot, earlier >= 1 && !length(went)) + went += guard + note(guard, "goes", TRUE) + if(guard.stealth_radio) + guard_ai.stealth_start_call(STEALTH_CALL_REPORT, spot) + continue + stayed += WEAKREF(guard) + switch(guard_ai.stealth_state()) + if(STEALTH_UNAWARE) + guard_ai.stealth_glance(spot) + note(guard, "glance", TRUE) + if(STEALTH_SEARCHING) + if(guard_ai.stealth_respond(spot)) + note(guard, "searches", TRUE) + for(var/mob/living/carbon/human/npc/guard as anything in went) + var/datum/stealth_check/check = new + check.who = WEAKREF(guard) + check.name = stealth_first_name(guard) + check.where = where + check.due = world.time + STEALTH_CHECKIN_TIME + check.waiters = stayed.Copy() + checks += check + +/// Gunfire, a blast, a scream: the nearest few that aren't sentries run to it and search; every other hearer +/// holds where it is, wary. After two alarms in memory fewer go: it may be a draw. +/datum/stealth_group/proc/dispatch_alarm(list/hearers, turf/where, turf/spot, kind, mob/living/actor) + var/cap = alarm_count() >= 2 ? STEALTH_ALARM_RESPONDERS_LATER : STEALTH_ALARM_RESPONDERS + alarms += list(list(world.time, 1)) + var/responders = 0 + for(var/list/hearer as anything in hearers) + var/mob/living/carbon/human/npc/guard = hearer[1] + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + if(guard_ai.stealth_state() == STEALTH_ALERT) + // Fighting someone else: it now knows there is another one about (never a target from sound). + var/atom/target = guard_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(isliving(actor) && actor != target && bounty_ai_target_for(actor) != target && !guard.faction_check_atom(actor)) + guard_ai.stealth_remember(actor) + note(guard, "notes", TRUE) + continue + if(!isnull(guard_ai.route_id) && responders < cap) + if(guard_ai.stealth_respond(spot)) + if(!responders) + guard_ai.stealth_bark(stealth_noise_is_gunfire(kind) ? STEALTH_BARK_GUNFIRE : STEALTH_BARK_HEARD, spot) + note(guard, "goes", TRUE) + responders++ + else + guard_ai.stealth_hold(spot) + note(guard, "holds", TRUE) + if(guard.stealth_radio) + guard_ai.stealth_start_call(STEALTH_CALL_ALARM, spot) + +/// A friend calling for help from `spot`: whoever hears it and isn't a sentry runs to them. They heard a +/// friend, they saw nobody, so they search where the friend stood. +/datum/stealth_group/proc/dispatch_shout(list/hearers, turf/spot) + for(var/list/hearer as anything in hearers) + var/mob/living/carbon/human/npc/guard = hearer[1] + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + if(guard_ai.stealth_state() == STEALTH_ALERT) + continue + if(isnull(guard_ai.route_id)) + guard_ai.stealth_hold(spot) + note(guard, "holds", TRUE) + else if(guard_ai.stealth_respond(spot)) + note(guard, "goes", TRUE) + if(guard.stealth_radio) + guard_ai.stealth_start_call(STEALTH_CALL_ALARM, spot) + +/** + * The guard who never came back (abuse P6). Run from each member's scan, at most once per + * STEALTH_SCAN_INTERVAL. A guard that went to look and is back on its round, or found someone, closes its + * check. One that is past due and gone, down, cuffed or still out is missed: the nearest two who know it + * went search where it went, and the next noise there brings everyone. + */ +/datum/stealth_group/proc/check_overdue() + if(world.time < next_overdue_check || !length(checks)) + return + next_overdue_check = world.time + STEALTH_SCAN_INTERVAL + for(var/datum/stealth_check/check as anything in checks.Copy()) + var/mob/living/carbon/human/npc/gone = check.who?.resolve() + var/datum/ai_controller/basic_controller/human_npc/stealth/gone_ai = gone?.ai_controller + var/down = QDELETED(gone) || !istype(gone_ai) || gone.stat != CONSCIOUS || HAS_TRAIT(gone, TRAIT_RESTRAINED) + if(!down) + var/state = gone_ai.stealth_state() + if(state == STEALTH_UNAWARE || state == STEALTH_ALERT) + checks -= check + continue + if(world.time < check.due) + continue + checks -= check + // Who misses it: conscious, free, not fighting. Nearest to the spot first. + var/list/missers = list() + for(var/datum/weakref/waiter_ref as anything in check.waiters) + var/mob/living/carbon/human/npc/waiter = waiter_ref.resolve() + var/datum/ai_controller/basic_controller/human_npc/stealth/waiter_ai = waiter?.ai_controller + if(QDELETED(waiter) || waiter == gone || !istype(waiter_ai) || waiter.stat != CONSCIOUS || waiter.client) + continue + if(waiter_ai.ai_status == AI_STATUS_OFF || waiter_ai.stealth_captive() || waiter_ai.stealth_state() == STEALTH_ALERT) + continue + var/dist = get_dist(waiter, check.where) + var/index = 1 + while(index <= length(missers) && get_dist(missers[index], check.where) <= dist) + index++ + missers.Insert(index, waiter) + if(!length(missers)) + continue + // The next noise there brings everyone. + lures += list(list(check.where, world.time), list(check.where, world.time)) + var/sent = 0 + for(var/mob/living/carbon/human/npc/waiter as anything in missers) + var/datum/ai_controller/basic_controller/human_npc/stealth/waiter_ai = waiter.ai_controller + if(sent < 2 && (!isnull(waiter_ai.route_id) || get_dist(waiter, check.where) <= STEALTH_SENTRY_INVESTIGATE_RANGE)) + if(waiter_ai.stealth_respond(check.where)) + sent++ + waiter_ai.stealth_bark(STEALTH_BARK_MISSING, check.where, check.name) + if(waiter.stealth_radio) + waiter_ai.stealth_start_call(STEALTH_CALL_MISSING, check.where, check.name) + +/// A blast anywhere: its own guards hear it if it is near enough. Registered per group, not per guard. +/datum/stealth_group/proc/on_explosion(datum/source, turf/epicenter) + SIGNAL_HANDLER + if(isnull(epicenter) || epicenter.z != home?.z) + return + INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(stealth_noise), epicenter, STEALTH_NOISE_BLAST, null, null, src) + +/// What its friends call `guard`: the first word of its name, or null when it has only its type's name +/// ("Scav Guard"). An NPC's name, never player text. +/proc/stealth_first_name(mob/living/carbon/human/npc/guard) + var/full = guard.real_name + if(!istext(full) || !length(full) || full == guard.npc_name || full == initial(guard.name)) + return null + var/space = findtext(full, " ") + return space ? copytext(full, 1, space) : full diff --git a/voidcrew/modules/stealth/stealth_noise_sources.dm b/voidcrew/modules/stealth/stealth_noise_sources.dm new file mode 100644 index 00000000000..b76fcb454e6 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_noise_sources.dm @@ -0,0 +1,264 @@ +/** + * # Stealth guards: where noise comes from + * + * Every hook that turns one of tg's own sounds into a stealth_noise() guards can hear. Each is a chained + * override: the same proc defined again on the same type in this later-compiled file, calling ..() (the + * model is cyberware_stealth.dm). No upstream file is edited. Each hook costs one call that returns at once + * while no stealth group is alive, and does no work per object in the room. + * + * Every reach is at or under how far a player hears the same tg sound (abuse H2): a guard never hears what + * a player standing in its place could not. + * + * Not hooked: mech and ship weapons (a mech is seen all round anyway), speech, machines. + */ + +// ===== Guns (owner decisions 2 and 7) ===== + +/obj/item/gun + /// How loud it is to stealth guards when it isn't suppressed (STEALTH_NOISE_GUN_*). A gun that sets + /// nothing is as loud as a pistol. + var/stealth_loudness = STEALTH_NOISE_GUN_PISTOL + +// Quiet by nature +/obj/item/gun/ballistic/bow + stealth_loudness = STEALTH_NOISE_GUN_QUIET + +/obj/item/gun/ballistic/rifle/rebarxbow + stealth_loudness = STEALTH_NOISE_GUN_QUIET + +/obj/item/gun/syringe + stealth_loudness = STEALTH_NOISE_GUN_QUIET + +/obj/item/gun/chem + stealth_loudness = STEALTH_NOISE_GUN_QUIET + +// SMGs: the automatic root, with its pistols set back +/obj/item/gun/ballistic/automatic + stealth_loudness = STEALTH_NOISE_GUN_SMG + +/obj/item/gun/ballistic/automatic/pistol + stealth_loudness = STEALTH_NOISE_GUN_PISTOL + +/obj/item/gun/ballistic/automatic/gyropistol + stealth_loudness = STEALTH_NOISE_GUN_PISTOL + +/obj/item/gun/ballistic/automatic/toy + stealth_loudness = STEALTH_NOISE_GUN_QUIET + +// Long guns, launchers and heavy energy +/obj/item/gun/ballistic/rifle + stealth_loudness = STEALTH_NOISE_GUN_LONG + +/obj/item/gun/ballistic/shotgun + stealth_loudness = STEALTH_NOISE_GUN_LONG + +/obj/item/gun/ballistic/shotgun/toy + stealth_loudness = STEALTH_NOISE_GUN_QUIET + +/obj/item/gun/ballistic/automatic/ar + stealth_loudness = STEALTH_NOISE_GUN_LONG + +/obj/item/gun/ballistic/automatic/battle_rifle + stealth_loudness = STEALTH_NOISE_GUN_LONG + +/obj/item/gun/ballistic/automatic/m90 + stealth_loudness = STEALTH_NOISE_GUN_LONG + +/obj/item/gun/ballistic/automatic/l6_saw + stealth_loudness = STEALTH_NOISE_GUN_LONG + +/obj/item/gun/ballistic/automatic/smartgun + stealth_loudness = STEALTH_NOISE_GUN_LONG + +/obj/item/gun/ballistic/rocketlauncher + stealth_loudness = STEALTH_NOISE_GUN_LONG + +/obj/item/gun/ballistic/revolver/grenadelauncher + stealth_loudness = STEALTH_NOISE_GUN_LONG + +/obj/item/gun/grenadelauncher + stealth_loudness = STEALTH_NOISE_GUN_LONG + +/obj/item/gun/blastcannon + stealth_loudness = STEALTH_NOISE_GUN_LONG + +/obj/item/gun/energy/lasercannon + stealth_loudness = STEALTH_NOISE_GUN_LONG + +/obj/item/gun/energy/pulse + stealth_loudness = STEALTH_NOISE_GUN_LONG + +/obj/item/gun/energy/ionrifle + stealth_loudness = STEALTH_NOISE_GUN_LONG + +/obj/item/gun/energy/tesla_cannon + stealth_loudness = STEALTH_NOISE_GUN_LONG + +/obj/item/gun/energy/minigun + stealth_loudness = STEALTH_NOISE_GUN_LONG + +/** + * list(noise kind, reach) for a shot from this gun now. Any suppressed gun is in the quietest tier, whatever + * it is (owner decision 7): a fitted suppressor, an integral one, the syringe gun. The reach is never more + * than how far tg plays the gun's own sound to players, so a quiet custom gun doesn't carry further for + * guards than for people. + */ +/obj/item/gun/proc/stealth_shot_noise() + var/kind = suppressed ? STEALTH_NOISE_GUN_QUIET : stealth_loudness + var/list/profile = stealth_noise_profile(kind) + var/volume = suppressed ? suppressed_volume : fire_sound_volume + if(isnull(profile) || volume <= SOUND_AUDIBLE_VOLUME_MIN) + return list(kind, 0) + // As fire_sounds() plays it. Plain numbers: the macro doesn't bracket its arguments. + var/sound_range = SOUND_RANGE + var/falloff = SOUND_DEFAULT_FALLOFF_DISTANCE + if(suppressed) + sound_range += SILENCED_SOUND_EXTRARANGE + falloff = 0 + var/audible = CALCULATE_MAX_SOUND_AUDIBLE_DISTANCE(volume, sound_range, falloff, SOUND_FALLOFF_EXPONENT) + return list(kind, min(profile[STEALTH_PROFILE_REACH], audible)) + +// Once per shot, bursts included, with the shooter. fire_sounds() is the wrong place: five types override it +// without calling the parent. +/obj/item/gun/shoot_live_shot(mob/living/user, pointblank = FALSE, atom/pbtarget = null, message = TRUE) + . = ..() + if(!length(GLOB.stealth_groups)) + return + var/list/noise = stealth_shot_noise() + stealth_noise(src, noise[1], noise[2], isliving(user) ? user : null) + +// A round striking a wall, a window, a crate. A suppressed round's strike is nearly silent in tg (volume 5), +// so it is no lure; what it breaks is. +/obj/projectile/on_hit(atom/target, blocked = 0, pierce_hit) + . = ..() + if(!length(GLOB.stealth_groups) || isliving(target) || isnull(target)) + return + stealth_noise(target, STEALTH_NOISE_IMPACT, suppressed ? STEALTH_NOISE_RANGE_IMPACT_QUIET : STEALTH_NOISE_RANGE_IMPACT, isliving(firer) ? firer : null) + +// ===== Thrown things ===== + +/obj/item + /// The noise it makes when a throw ends (STEALTH_NOISE_*), or null for a plain landing by its weight + var/stealth_throw_noise + +/// The noise this makes landing from a throw. +/obj/item/proc/stealth_throw_kind() + return stealth_throw_noise || STEALTH_NOISE_THROWN + +// A glass or a bottle smashes; a carton or a plastic bottle only lands. +/obj/item/reagent_containers/cup/glass/stealth_throw_kind() + return isGlass ? STEALTH_NOISE_GLASS : ..() + +// Landing, or hitting something that isn't a person. A throw that lands on a guard is a touch, which the +// guard's own controller deals with. +/obj/item/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum) + // Read first: a bottle is gone once it has smashed. + var/noisy = length(GLOB.stealth_groups) && !isliving(hit_atom) + var/kind = noisy ? stealth_throw_kind() : null + var/size = w_class + . = ..() + if(!noisy) + return + var/reach + if(kind == STEALTH_NOISE_THROWN) + if(size <= WEIGHT_CLASS_SMALL) + reach = STEALTH_NOISE_RANGE_THROWN_SMALL + else if(size == WEIGHT_CLASS_NORMAL) + reach = STEALTH_NOISE_RANGE_THROWN_MEDIUM + else + reach = STEALTH_NOISE_RANGE_THROWN_HEAVY + var/mob/living/thrower = throwingdatum?.get_thrower() + stealth_noise(hit_atom, kind, reach, isliving(thrower) ? thrower : null) + +// ===== Glass ===== + +/obj/structure/window/atom_deconstruct(disassembled = TRUE) + if(!disassembled) + stealth_noise(src, STEALTH_NOISE_GLASS) + return ..() + +// Shot out or smashed: only a tube that was whole makes the sound (tg's own rule). +/obj/machinery/light/break_light_tube(skip_sound_and_sparks = FALSE) + var/whole = !skip_sound_and_sparks && (status == LIGHT_OK || status == LIGHT_BURNED) + . = ..() + if(whole) + stealth_noise(src, STEALTH_NOISE_GLASS) + +// ===== Knocks ===== + +// Knuckles on a window with combat mode off, a fist with it on. Repeats the parent's two guards. +/obj/structure/window/attack_hand(mob/living/user, list/modifiers) + . = ..() + if(. || !length(GLOB.stealth_groups) || !can_be_reached(user)) + return + stealth_noise(src, user.combat_mode ? STEALTH_NOISE_BASH : STEALTH_NOISE_KNOCK, null, user) + +// "You push the wall but nothing happens!" +/turf/closed/wall/attack_hand(mob/user, list/modifiers) + . = ..() + if(. || !length(GLOB.stealth_groups)) + return + stealth_noise(src, STEALTH_NOISE_KNOCK, null, isliving(user) ? user : null) + +// An airlock opening or closing, refusing someone, or being forced. Nobody is named: a door with one of the +// group beside it is one of their own going through (stealth_noise()). +/obj/machinery/door/airlock/animation_effects(animation, force_type = DEFAULT_DOOR_CHECKS) + . = ..() + if(!length(GLOB.stealth_groups)) + return + if(force_type == BYPASS_DOOR_CHECKS) + stealth_noise(src, STEALTH_NOISE_BASH) + return + switch(animation) + if(DOOR_OPENING_ANIMATION, DOOR_CLOSING_ANIMATION) + stealth_noise(src, STEALTH_NOISE_DOOR) + if(DOOR_DENY_ANIMATION) + stealth_noise(src, STEALTH_NOISE_KNOCK) + +// Tools at work: a wrench or a crowbar is a knock, a welder or a drill is louder. Breaking in is a choice +// between slow and quiet, and fast and loud. Guards don't use tools. +/obj/item/play_tool_sound(atom/target, volume = 50) + . = ..() + if(!length(GLOB.stealth_groups) || !target || !usesound || !volume) + return + var/loud = tool_behaviour == TOOL_WELDER || tool_behaviour == TOOL_DRILL || tool_behaviour == TOOL_MINING + stealth_noise(target, loud ? STEALTH_NOISE_BASH : STEALTH_NOISE_KNOCK, null, isliving(loc) ? loc : null) + +// ===== Bodies and voices ===== + +// A body hitting the floor. Someone held in an aggressive grab or tighter is let down by whoever holds them: +// no thud. That is a rule about noise only; what happened to the body is whatever tg did to it. +/turf/handle_fall(mob/faller) + . = ..() + if(!length(GLOB.stealth_groups) || !isliving(faller) || !has_gravity(src)) + return + if(faller.pulledby && faller.pulledby.grab_state >= GRAB_AGGRESSIVE) + return + stealth_noise(src, STEALTH_NOISE_THUD, null, faller) + +// A whistle, a clap, a snap, a cough, a laugh, a scream: any emote whose sound tg plays now, under tg's own +// rules for when it plays (its cooldowns included). +/datum/emote/run_emote(mob/user, params, type_override, intentional = FALSE) + var/sounded = FALSE + if(length(GLOB.stealth_groups) && isliving(user)) + sounded = get_sound(user) && should_play_sound(user, intentional) && TIMER_COOLDOWN_FINISHED(user, "general_emote_audio_cooldown") && TIMER_COOLDOWN_FINISHED(user, type) + . = ..() + if(!sounded || QDELETED(user)) + return + var/kind = STEALTH_NOISE_VOICE + switch(key) + if("scream", "screech") + kind = STEALTH_NOISE_SCREAM + if("deathgasp") + kind = STEALTH_NOISE_THUD + stealth_noise(user, kind, null, user) + +// ===== Blasts ===== +// Explosions: each group listens for COMSIG_GLOB_EXPLOSION (stealth_noise.dm). + +// The parent deletes the grenade, and deafens whoever it catches before anyone hears it. +/obj/item/grenade/flashbang/detonate(mob/living/lanced_by) + var/turf/where = get_turf(src) + . = ..() + if(. && where) + stealth_noise(where, STEALTH_NOISE_BLAST) diff --git a/voidcrew/modules/stealth/stealth_patrol.dm b/voidcrew/modules/stealth/stealth_patrol.dm index 6fe4a9d518b..bcf40901622 100644 --- a/voidcrew/modules/stealth/stealth_patrol.dm +++ b/voidcrew/modules/stealth/stealth_patrol.dm @@ -58,9 +58,16 @@ GLOBAL_VAR_INIT(stealth_group_count, 0) else no_region = TRUE GLOB.stealth_groups += src + RegisterSignal(SSdcs, COMSIG_GLOB_EXPLOSION, PROC_REF(on_explosion)) /datum/stealth_group/Destroy() GLOB.stealth_groups -= src + UnregisterSignal(SSdcs, COMSIG_GLOB_EXPLOSION) + noise_stamps = null + lures = null + alarms = null + checks = null + noise_notes = null if(marker) marker.group = null marker = null @@ -327,6 +334,14 @@ GLOBAL_VAR_INIT(stealth_group_count, 0) if(guard.stat != CONSCIOUS) return if(controller.stealth_state() == STEALTH_UNAWARE && !controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + // Glancing at a noise, or holding for one: it stops and faces it, then carries on. + if(world.time < controller.glance_until) + controller.stealth_drop_walk() + controller.next_turn = controller.glance_until + if(guard.dir != controller.glance_dir) + guard.setDir(controller.glance_dir) + controller.queue_behavior(/datum/ai_behavior/stealth_stand) + return SUBTREE_RETURN_FINISH_PLANNING if(length(controller.stealth_stops())) controller.stealth_plan_route() else diff --git a/voidcrew/modules/stealth/stealth_radio.dm b/voidcrew/modules/stealth/stealth_radio.dm new file mode 100644 index 00000000000..4b024e31ddd --- /dev/null +++ b/voidcrew/modules/stealth/stealth_radio.dm @@ -0,0 +1,149 @@ +/** + * # Stealth guards: radios (owner decision 8) + * + * Some guard types carry an earpiece (`stealth_radio` on the type, and a working headset in its ears). A + * carrier that learns of trouble raises a hand to its earpiece, and STEALTH_RADIO_CALL_TIME later says it + * out loud; every other carrier in its group then knows, wherever it stands, and passes it on by voice to + * whoever stands next to it. + * + * Players stop a call with tg's own tools and nothing else: drop, stun or silence the speaker before the call + * is due; run a radio jammer near the speaker or the receiver; EMP the earpiece (tg switches a radio off for + * 20 s); deafen the receiver. The headset can't be stripped: it is locked gear like the rest of the kit. + * + * No timers: a pending call is a stamp the guard's scan reads. One alarm delivery per group per + * STEALTH_RADIO_GROUP_COOLDOWN, so a den full of carriers doesn't echo itself. + */ + +/mob/living/carbon/human/npc + /// Whether this type is on its group's radio net (it still needs a working headset in its ears) + var/stealth_radio = FALSE + +/// Its working headset, or null: on the net, headset in the ears and switched on, not in a jammer's range. +/mob/living/carbon/human/npc/proc/stealth_radio_ready() + if(!stealth_radio) + return null + var/obj/item/radio/earpiece = ears + if(!istype(earpiece) || !earpiece.is_on() || is_within_radio_jammer_range(src)) + return null + return earpiece + +/** + * Starts a radio call about `where`: a hand to the earpiece now, the call STEALTH_RADIO_CALL_TIME later if it + * can still make it (stealth_deliver_call()). A call already on its way out is kept unless this one is more + * urgent, so a run of noises never puts the call off. Returns TRUE if a call is now pending. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_start_call(kind, turf/where, name) + var/mob/living/carbon/human/npc/guard = pawn + if(!ishumannpc(guard) || !guard.stealth_radio || !istype(guard.ears, /obj/item/radio)) + return FALSE + if(guard.stat != CONSCIOUS || stealth_driven() || isnull(where)) + return FALSE + if(pending_call) + if(pending_call[STEALTH_CALL_KIND] >= kind) + return TRUE + pending_call = list(kind, where, world.time + STEALTH_RADIO_CALL_TIME, name) + guard.visible_message(span_emote("[guard] raises a hand to [guard.p_their()] earpiece.")) + return TRUE + +/// The scan: makes its pending call once it is due, if it still can. A call it can't make is lost, never +/// retried; if only the radio failed, it says so. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_deliver_call() + if(isnull(pending_call) || world.time < pending_call[STEALTH_CALL_DUE]) + return + var/list/call_made = pending_call + pending_call = null + // Its level slept through it: nobody finishes a call that late. + if(world.time > call_made[STEALTH_CALL_DUE] + STEALTH_RADIO_CALL_STALE) + return + var/mob/living/carbon/human/npc/guard = pawn + if(guard.stat != CONSCIOUS || HAS_TRAIT(guard, TRAIT_INCAPACITATED) || !human_npc_can_talk(guard)) + return + if(!guard.stealth_radio_ready()) + stealth_bark(STEALTH_BARK_RADIO_DEAD) + return + var/turf/where = call_made[STEALTH_CALL_WHERE] + var/bark_kind = STEALTH_BARK_RADIO_ALARM + switch(call_made[STEALTH_CALL_KIND]) + if(STEALTH_CALL_REPORT) + bark_kind = STEALTH_BARK_RADIO_REPORT + if(STEALTH_CALL_MISSING) + bark_kind = STEALTH_BARK_RADIO_MISSING + // Said out loud, always: anyone in earshot of the speaker hears where the others are being sent. + stealth_bark(bark_kind, where, call_made[STEALTH_CALL_NAME], TRUE) + group?.radio_call(guard, call_made[STEALTH_CALL_KIND], where) + +/// A call that can't go out any more (the speaker was stunned, dropped or taken over). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_drop_call() + pending_call = null + +/// Whether `guard` can take a radio call now. +/datum/stealth_group/proc/radio_receiver(mob/living/carbon/human/npc/guard) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + if(!istype(guard_ai) || guard.stat != CONSCIOUS || guard.client || guard_ai.ai_status == AI_STATUS_OFF) + return FALSE + return guard.stealth_radio_ready() && guard.can_hear() && !guard_ai.stealth_captive() + +/** + * `speaker` has made its call. Every other member with a working radio that can hear gets it. + * - A report ("checking something"): they know it went, so they miss it if it doesn't come back. Nobody moves. + * - An alarm or a missing friend: at most one per STEALTH_RADIO_GROUP_COOLDOWN. The nearest + * STEALTH_RADIO_RESPONDERS receivers that aren't sentries search at the spot and answer; each brings up to + * STEALTH_RELAY_VOICE_RESPONDERS friends without radios from within earshot of its answer. Sentries and the + * rest hold. + * Returns how many receivers got it. + */ +/datum/stealth_group/proc/radio_call(mob/living/carbon/human/npc/speaker, kind, turf/where) + . = 0 + var/list/guards = living_members() + if(kind == STEALTH_CALL_REPORT) + var/list/speaker_checks = list() + for(var/datum/stealth_check/check as anything in checks) + if(check.who?.resolve() == speaker) + speaker_checks += check + for(var/mob/living/carbon/human/npc/guard as anything in guards) + if(guard == speaker || !radio_receiver(guard)) + continue + .++ + for(var/datum/stealth_check/check as anything in speaker_checks) + check.waiters |= WEAKREF(guard) + return + if(world.time < next_radio_alarm) + return 0 + next_radio_alarm = world.time + STEALTH_RADIO_GROUP_COOLDOWN + // Receivers, nearest to the spot first. + var/list/receivers = list() + for(var/mob/living/carbon/human/npc/guard as anything in guards) + if(guard == speaker || !radio_receiver(guard)) + continue + var/dist = get_dist(guard, where) + var/index = 1 + while(index <= length(receivers) && get_dist(receivers[index], where) <= dist) + index++ + receivers.Insert(index, guard) + var/moved = 0 + for(var/mob/living/carbon/human/npc/receiver as anything in receivers) + .++ + var/datum/ai_controller/basic_controller/human_npc/stealth/receiver_ai = receiver.ai_controller + if(receiver_ai.stealth_state() == STEALTH_ALERT) + continue + if(isnull(receiver_ai.route_id) || moved >= STEALTH_RADIO_RESPONDERS || !receiver_ai.stealth_respond(where)) + receiver_ai.stealth_hold(where) + continue + moved++ + receiver_ai.stealth_bark(STEALTH_BARK_COPY, null, null, TRUE) + // Its answer carries to whoever stands near it. + var/turf/receiver_turf = get_turf(receiver) + var/brought = 0 + for(var/mob/living/carbon/human/npc/friend as anything in guards) + if(brought >= STEALTH_RELAY_VOICE_RESPONDERS) + break + var/datum/ai_controller/basic_controller/human_npc/stealth/friend_ai = friend.ai_controller + if(friend == receiver || friend == speaker || friend.stealth_radio || !istype(friend_ai) || isnull(friend_ai.route_id)) + continue + if(friend.stat != CONSCIOUS || friend.client || friend_ai.ai_status == AI_STATUS_OFF || !friend.can_hear()) + continue + var/turf/friend_turf = get_turf(friend) + if(get_dist(friend_turf, receiver_turf) > STEALTH_RELAY_VOICE_RANGE || stealth_muffled_dist(receiver_turf, friend_turf) > STEALTH_RELAY_VOICE_RANGE) + continue + if(friend_ai.stealth_respond(where)) + brought++ From f1a9046d84285e27859959853bcff93095b9dded Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Mon, 9 Nov 2026 20:54:17 -0800 Subject: [PATCH 15/78] Stealth test room: two lookouts, throwables, a crate of guns and gadgets, a window, a locked door, carpet and plating --- .../JungleRuins/jungle_stealth_test.dmm | 76 ++++++++++++++----- 1 file changed, 57 insertions(+), 19 deletions(-) diff --git a/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm index d882f79dcc5..b802a996b66 100644 --- a/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm +++ b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm @@ -1,10 +1,45 @@ //MAP CONVERTED BY dmm2tgm.py THIS HEADER COMMENT PREVENTS RECONVERSION, DO NOT REMOVE "a" = ( -/obj/effect/spawner/human_npc/ruin/scav{ +/obj/effect/spawner/human_npc/ruin/scav/lookout{ dir = 2 }, /turf/open/floor/iron, /area/ruin/powered) +"b" = ( +/obj/structure/table, +/obj/item/reagent_containers/cup/glass/bottle/beer, +/obj/item/reagent_containers/cup/glass/bottle/beer, +/obj/item/reagent_containers/cup/glass/bottle/beer, +/turf/open/floor/iron, +/area/ruin/powered) +"c" = ( +/obj/structure/table, +/obj/item/storage/toolbox/mechanical, +/obj/item/coin/iron, +/obj/item/coin/iron, +/obj/item/coin/iron, +/turf/open/floor/iron, +/area/ruin/powered) +"d" = ( +/obj/structure/closet/crate, +/obj/item/gun/ballistic/automatic/pistol, +/obj/item/suppressor, +/obj/item/gun/ballistic/automatic/wt550, +/obj/item/gun/ballistic/rifle/boltaction, +/obj/item/gun/ballistic/bow/longbow, +/obj/item/storage/bag/quiver/full, +/obj/item/jammer, +/obj/item/grenade/flashbang, +/obj/item/grenade/empgrenade, +/turf/open/floor/iron, +/area/ruin/powered) +"e" = ( +/obj/machinery/door/airlock/security{ + name = "Strongroom"; + req_access = list("armory") + }, +/turf/open/floor/iron, +/area/ruin/powered) "f" = ( /obj/effect/landmark/stealth_patrol{ route = "b"; @@ -13,6 +48,9 @@ }, /turf/open/floor/plating, /area/ruin/powered) +"g" = ( +/turf/open/floor/carpet, +/area/ruin/powered) "h" = ( /obj/effect/landmark/stealth_patrol{ route = "b"; @@ -93,7 +131,7 @@ order = 2; dir = 4 }, -/obj/effect/spawner/human_npc/ruin/scav/gunner{ +/obj/effect/spawner/human_npc/ruin/scav/lookout{ dir = 8 }, /turf/open/floor/iron, @@ -367,8 +405,8 @@ i (11,1,1) = {" i J -x -x +g +g J P P @@ -391,9 +429,9 @@ i (12,1,1) = {" i J -x -x -J +g +g +p P P P @@ -415,8 +453,8 @@ i (13,1,1) = {" i J -x -x +g +g J P P @@ -494,7 +532,7 @@ J J J J -J +e J J J @@ -511,8 +549,8 @@ i (17,1,1) = {" i J -x -x +P +P J x x @@ -535,8 +573,8 @@ i (18,1,1) = {" i J -x -x +P +P J l x @@ -559,8 +597,8 @@ i (19,1,1) = {" i J -x -x +P +P p x x @@ -599,7 +637,7 @@ x x x x -x +b J i i @@ -623,7 +661,7 @@ x x x x -x +c J i i @@ -695,7 +733,7 @@ x x x x -x +d J i i From 72558e627bdff9dad2d25ceabc89a7b5a0e686f0 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Mon, 9 Nov 2026 21:20:53 -0800 Subject: [PATCH 16/78] Stealth hearing tests: muffling, gun tiers, footsteps, lures, the missing guard, alarms, shouts, radios, and real shots, throws, knocks, falls, emotes and blasts --- voidcrew/modules/unit_tests/_unit_tests.dm | 1 + .../unit_tests/voidcrew_stealth_hearing.dm | 799 ++++++++++++++++++ 2 files changed, 800 insertions(+) create mode 100644 voidcrew/modules/unit_tests/voidcrew_stealth_hearing.dm diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index 19067100870..ccab4290d6d 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -235,6 +235,7 @@ #include "voidcrew_slime_extract_piles.dm" #include "voidcrew_smart_locker.dm" #include "voidcrew_stealth.dm" +#include "voidcrew_stealth_hearing.dm" #include "voidcrew_survey_archive.dm" #include "voidcrew_survey_capabilities.dm" #include "voidcrew_survey_identity.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_hearing.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_hearing.dm new file mode 100644 index 00000000000..641f866b05b --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_hearing.dm @@ -0,0 +1,799 @@ +// Stealth guards: hearing (voidcrew/modules/stealth/stealth_noise.dm and friends). Unit tests compile before +// voidcrew/_DEFINES, so values from there are written out: noise kinds "gun_quiet", "gun_pistol", "gun_smg", +// "gun_long", "impact", "blast", "glass", "thrown", "knock", "bash", "door", "thud", "voice", "scream", "shout"; +// flags LOS_ONLY 1, LOUD 2; call kinds REPORT 1, MISSING 2, ALARM 3; STEALTH_CHECKIN_TIME 30 s, +// STEALTH_RADIO_CALL_TIME 3 s, the heard mark "q_y0". +// +// Every test runs in the walled, lit room of voidcrew_stealth_live with a person on SSmobs' list of players, so +// the level is awake and guards hear. Those down to hear/cleanup never sleep: the AI is on but never gets a +// turn, so they pin what one noise does. The ones after them use real tg actions, and the last three let the +// real AI run. + +#define STEALTH_HEAR_GUARD /mob/living/carbon/human/npc/ruin/trooper/scav +#define STEALTH_HEAR_LOOKOUT /mob/living/carbon/human/npc/ruin/trooper/scav/lookout + +/datum/unit_test/voidcrew_stealth_live/hear + abstract_type = /datum/unit_test/voidcrew_stealth_live/hear + /// Stops handed out on route "a" so far + var/stops_made = 0 + /// The group's marker + var/obj/effect/landmark/stealth_group/marker + +/// The room, its group marker in the top left corner, and a player far off in the bottom right one. +/datum/unit_test/voidcrew_stealth_live/hear/proc/hear_room(width, height) + if(!make_room(width, height)) + return FALSE + marker = allocate(/obj/effect/landmark/stealth_group, at(0, height - 1)) + person_at(width - 1, 0) + return TRUE + +/// Gives the room's floor gravity, for tests where something is thrown or falls (reserved space has none). +/datum/unit_test/voidcrew_stealth_live/hear/proc/ground() + var/turf/corner = room.bottom_left_turfs[1] + var/turf/far_corner = room.top_right_turfs[1] + for(var/turf/open/spot in block(corner.x, corner.y, corner.z, far_corner.x, far_corner.y, corner.z)) + spot.AddElement(/datum/element/forced_gravity, 1) + +/// A sentry at (dx, dy): awake and in the group. +/datum/unit_test/voidcrew_stealth_live/hear/proc/sentry(dx, dy, facing = EAST, guard_type = STEALTH_HEAR_GUARD) + var/mob/living/carbon/human/npc/guard = allocate(guard_type, at(dx, dy)) + guard.setDir(facing) + guard.AddElement(/datum/element/forced_gravity, 1) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = wake(guard) + stealth_ai.stealth_setup() + return guard + +/// A guard with a stop of route "a" under it, so it walks a route (it waits there ten minutes). +/datum/unit_test/voidcrew_stealth_live/hear/proc/walker(dx, dy, facing = EAST, guard_type = STEALTH_HEAR_GUARD) + stop_at(dx, dy, ++stops_made, 10 MINUTES) + return sentry(dx, dy, facing, guard_type) + +/// Back to nothing on its mind, with every clock run out. +/datum/unit_test/voidcrew_stealth_live/hear/proc/settle(mob/living/guard) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + stealth_ai.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + stealth_ai.stealth_go_unaware() + stealth_ai.stealth_clear_wary() + stealth_ai.stealth_drop_call() + stealth_ai.stealth_rewind(2 MINUTES) + stealth_ai.glance_until = 0 + +/datum/unit_test/voidcrew_stealth_live/hear/proc/state_of(mob/living/guard) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + return stealth_ai.stealth_state() + +/datum/unit_test/voidcrew_stealth_live/hear/proc/no_targets(list/guards) + for(var/mob/living/guard as anything in guards) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + TEST_ASSERT(!stealth_ai.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET), "A sound gave [guard] a target") + +/// Walls and doors on the line eat reach; glass and the two ends don't. +/datum/unit_test/voidcrew_stealth_live/hear/muffle + +/datum/unit_test/voidcrew_stealth_live/hear/muffle/Run() + TEST_ASSERT(hear_room(20, 3), "No room for the test") + var/turf/west = at(0, 1) + var/turf/east = at(8, 1) + TEST_ASSERT_EQUAL(stealth_muffled_dist(west, east, 0), 8, "An open line isn't its plain distance") + var/turf/wall_spot = at(4, 1) + wall_spot.ChangeTurf(/turf/closed/wall) + TEST_ASSERT_EQUAL(stealth_muffled_dist(west, east, 0), 11, "One wall didn't cost 3 tiles") + TEST_ASSERT_EQUAL(stealth_muffled_dist(west, east, 2), 9.5, "A loud sound didn't lose half as much to a wall") + TEST_ASSERT_EQUAL(stealth_muffled_dist(west, east, 1), INFINITY, "A line-of-sight sound went through a wall") + TEST_ASSERT_EQUAL(stealth_muffled_dist(wall_spot, west, 0), 4, "A sound on a wall is muffled on its west side") + TEST_ASSERT_EQUAL(stealth_muffled_dist(wall_spot, east, 0), 4, "A sound on a wall is muffled on its east side") + var/obj/machinery/door/airlock/door = allocate(/obj/machinery/door/airlock, at(6, 1)) + TEST_ASSERT(door.density, "The airlock isn't shut") + TEST_ASSERT_EQUAL(stealth_muffled_dist(west, east, 0), 13, "A wall and a closed airlock didn't cost 5 tiles") + qdel(door) + allocate(/obj/structure/window/fulltile, at(6, 1)) + TEST_ASSERT_EQUAL(stealth_muffled_dist(west, east, 0), 11, "A window muffled a sound") + for(var/dx in list(2, 3, 5)) + var/turf/more = at(dx, 1) + more.ChangeTurf(/turf/closed/wall) + TEST_ASSERT_EQUAL(stealth_muffled_dist(west, east, 2), INFINITY, "A sound was heard through four walls") + +/// Every kind has a profile; a gun is never heard further than tg plays its own sound; tiers and suppressors. +/datum/unit_test/voidcrew_stealth_live/hear/guns + +/datum/unit_test/voidcrew_stealth_live/hear/guns/Run() + TEST_ASSERT(hear_room(5, 3), "No room for the test") + for(var/kind in list("gun_quiet", "gun_pistol", "gun_smg", "gun_long", "impact", "blast", "glass", "thrown", "knock", "bash", "door", "thud", "voice", "scream", "shout")) + var/list/profile = stealth_noise_profile(kind) + TEST_ASSERT_EQUAL(length(profile), 3, "Noise kind [kind] has no profile") + TEST_ASSERT(profile[1] > 0 && profile[2] > 0 && isnum(profile[3]), "Noise kind [kind] has a bad profile") + var/turf/here = at(1, 1) + var/list/expected = list( + /obj/item/gun/ballistic/automatic/pistol = "gun_pistol", + /obj/item/gun/ballistic/revolver = "gun_pistol", + /obj/item/gun/energy/laser = "gun_pistol", + /obj/item/gun/ballistic/automatic/c20r = "gun_smg", + /obj/item/gun/ballistic/rifle/boltaction = "gun_long", + /obj/item/gun/ballistic/shotgun = "gun_long", + /obj/item/gun/ballistic/bow/longbow = "gun_quiet", + /obj/item/gun/ballistic/automatic/pistol/suppressed = "gun_quiet", + ) + for(var/gun_type in expected) + var/obj/item/gun/gun = allocate(gun_type, here) + var/list/noise = gun.stealth_shot_noise() + TEST_ASSERT_EQUAL(noise[1], expected[gun_type], "[gun_type] is the wrong loudness") + var/obj/item/gun/ballistic/automatic/pistol/pistol = allocate(/obj/item/gun/ballistic/automatic/pistol, here) + TEST_ASSERT_EQUAL(pistol.stealth_shot_noise()[2], 9, "A pistol's reach isn't 9") + pistol.fire_sound_volume = 10 + TEST_ASSERT(pistol.stealth_shot_noise()[2] < 9, "A quiet custom gun is heard as far as a loud one") + pistol.install_suppressor(new /obj/item/suppressor(pistol)) + var/list/quiet = pistol.stealth_shot_noise() + TEST_ASSERT_EQUAL(quiet[1], "gun_quiet", "A pistol with a suppressor fitted isn't quiet") + TEST_ASSERT_EQUAL(quiet[2], 4, "A suppressed shot's reach isn't 4") + +/// tg's footstep rules: running is heard, walking and every silencer are not. +/datum/unit_test/voidcrew_stealth_live/hear/footstep_reach + +/datum/unit_test/voidcrew_stealth_live/hear/footstep_reach/Run() + TEST_ASSERT(hear_room(6, 3), "No room for the test") + var/mob/living/carbon/human/runner = person_at(1, 1, FALSE) + TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 0, "A walking step is heard") + runner.toggle_move_intent() + TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 5, "A running step barefoot on plain floor doesn't carry 5") + runner.equip_to_slot_or_del(new /obj/item/clothing/shoes/sneakers/black(runner), ITEM_SLOT_FEET) + TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 5, "A running step in shoes on plain floor doesn't carry 5") + var/turf/plating = at(3, 1) + plating.ChangeTurf(/turf/open/floor/plating) + runner.forceMove(plating) + TEST_ASSERT(stealth_footstep_reach(runner) > 5, "Plating is no louder than floor") + runner.forceMove(at(1, 1)) + ADD_TRAIT(runner, TRAIT_LIGHT_STEP, TRAIT_SOURCE_UNIT_TESTS) + TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 3, "A light step doesn't carry 3") + REMOVE_TRAIT(runner, TRAIT_LIGHT_STEP, TRAIT_SOURCE_UNIT_TESTS) + ADD_TRAIT(runner, TRAIT_SILENT_FOOTSTEPS, TRAIT_SOURCE_UNIT_TESTS) + TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 0, "Silent footsteps are heard") + REMOVE_TRAIT(runner, TRAIT_SILENT_FOOTSTEPS, TRAIT_SOURCE_UNIT_TESTS) + runner.set_body_position(LYING_DOWN) + TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 2, "Crawling doesn't carry 2") + runner.set_body_position(STANDING_UP) + var/obj/structure/closet/locker = allocate(/obj/structure/closet, at(1, 1)) + runner.forceMove(locker) + TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 0, "Someone in a locker makes footsteps") + runner.forceMove(at(1, 1)) + // The real shoes. + qdel(runner.shoes) + runner.equip_to_slot_or_del(new /obj/item/clothing/shoes/laceup/winters_loafers(runner), ITEM_SLOT_FEET) + TEST_ASSERT_NOTNULL(runner.shoes, "The loafers didn't go on") + TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 0, "Running in Winter's loafers is heard") + +/// One guard goes, then two, then everyone; somewhere else, one again. No sound gives anyone a target. +/datum/unit_test/voidcrew_stealth_live/hear/dispatch + +/datum/unit_test/voidcrew_stealth_live/hear/dispatch/Run() + TEST_ASSERT(hear_room(30, 3), "No room for the test") + var/mob/living/carbon/human/npc/first = walker(5, 1) + var/mob/living/carbon/human/npc/second = walker(7, 1) + var/mob/living/carbon/human/npc/third = walker(9, 1) + var/datum/ai_controller/basic_controller/human_npc/stealth/first_ai = first.ai_controller + var/datum/ai_controller/basic_controller/human_npc/stealth/second_ai = second.ai_controller + var/datum/ai_controller/basic_controller/human_npc/stealth/third_ai = third.ai_controller + var/datum/stealth_group/group = first_ai.group + TEST_ASSERT_EQUAL(group, marker.group, "The guards didn't join the marker's group") + TEST_ASSERT_NOTNULL(third_ai.route_id, "A guard on a stop claimed no route") + var/turf/spot = at(4, 1) + TEST_ASSERT_EQUAL(stealth_noise(spot, "knock"), 3, "Three guards within 5 tiles didn't all hear a knock") + TEST_ASSERT_EQUAL(first_ai.stealth_state(), "suspicious", "The nearest guard didn't go to look") + TEST_ASSERT(first_ai.suspicion_heard, "A guard that heard something isn't marked as having heard it") + TEST_ASSERT_EQUAL(first_ai.investigate_turf, spot, "It isn't going to where the noise was") + TEST_ASSERT(!first_ai.blackboard["stealth_wary"], "A noise alone made a guard wary") + TEST_ASSERT_EQUAL(second_ai.stealth_state(), "unaware", "A second guard went to the first noise") + TEST_ASSERT(second_ai.glance_until > world.time && third_ai.glance_until > world.time, "The others didn't glance") + TEST_ASSERT_EQUAL(second.dir, WEST, "A glancing guard didn't turn to the noise") + // The same noise at once is the same noise. + TEST_ASSERT_EQUAL(stealth_noise(spot, "knock"), 0, "The same noise in the same moment was heard twice") + group.rewind(2 SECONDS) + stealth_noise(spot, "knock") + TEST_ASSERT_EQUAL(second_ai.stealth_state(), "suspicious", "Two guards didn't go to the second noise") + TEST_ASSERT_EQUAL(third_ai.stealth_state(), "unaware", "Three guards went to the second noise") + group.rewind(2 SECONDS) + stealth_noise(spot, "knock") + for(var/mob/living/guard as anything in list(first, second, third)) + TEST_ASSERT_EQUAL(state_of(guard), "searching", "Not every guard searched at the third noise") + TEST_ASSERT(third_ai.blackboard["stealth_wary"], "A guard searching for a noise isn't wary") + // Ten tiles off it is a new spot. + for(var/mob/living/guard as anything in list(first, second, third)) + settle(guard) + group.rewind(2 SECONDS) + TEST_ASSERT_EQUAL(stealth_noise(at(15, 1), "glass"), 2, "A smash 6 and 8 tiles off wasn't heard by two") + TEST_ASSERT_EQUAL(third_ai.stealth_state(), "suspicious", "Nobody went to a noise somewhere new") + TEST_ASSERT_EQUAL(second_ai.stealth_state(), "unaware", "Two went to the first noise at a new spot") + no_targets(list(first, second, third)) + +/// A sentry leaves its post only for a noise close by. +/datum/unit_test/voidcrew_stealth_live/hear/sentry_rule + +/datum/unit_test/voidcrew_stealth_live/hear/sentry_rule/Run() + TEST_ASSERT(hear_room(20, 3), "No room for the test") + var/mob/living/carbon/human/npc/post_guard = sentry(6, 1) + var/mob/living/carbon/human/npc/route_guard = walker(7, 1) + var/datum/ai_controller/basic_controller/human_npc/stealth/post_ai = post_guard.ai_controller + TEST_ASSERT_NULL(post_ai.route_id, "A guard with no stop near it claimed a route") + TEST_ASSERT_EQUAL(stealth_noise(at(0, 1), "glass"), 2, "Both guards should hear a smash 6 and 7 tiles off") + TEST_ASSERT_EQUAL(state_of(post_guard), "unaware", "A sentry left its post for a noise 6 tiles off") + TEST_ASSERT(post_ai.glance_until > world.time, "The sentry didn't glance") + TEST_ASSERT_EQUAL(state_of(route_guard), "suspicious", "The route guard didn't go in the sentry's place") + settle(post_guard) + settle(route_guard) + post_ai.group.forget_noises() + stealth_noise(at(3, 1), "glass") + TEST_ASSERT_EQUAL(state_of(post_guard), "suspicious", "A sentry didn't look at a noise 3 tiles off") + no_targets(list(post_guard, route_guard)) + +/// The guard who never came back is missed by the ones who watched it go, once it is overdue. +/datum/unit_test/voidcrew_stealth_live/hear/missing + +/datum/unit_test/voidcrew_stealth_live/hear/missing/Run() + TEST_ASSERT(hear_room(20, 3), "No room for the test") + var/mob/living/carbon/human/npc/first = walker(5, 1) + var/mob/living/carbon/human/npc/second = walker(7, 1) + var/mob/living/carbon/human/npc/third = walker(9, 1) + var/datum/ai_controller/basic_controller/human_npc/stealth/first_ai = first.ai_controller + var/datum/stealth_group/group = first_ai.group + var/turf/spot = at(4, 1) + stealth_noise(spot, "knock") + TEST_ASSERT_EQUAL(length(group.checks), 1, "No check was opened on the guard that went") + first.death() + group.check_overdue() + TEST_ASSERT_EQUAL(state_of(second), "unaware", "A guard knew its friend was down before it was overdue") + group.rewind(31 SECONDS) + group.check_overdue() + TEST_ASSERT_EQUAL(state_of(second), "searching", "Nobody came looking for the guard that never came back") + TEST_ASSERT_EQUAL(state_of(third), "searching", "Only one guard came looking") + TEST_ASSERT(group.lure_count(spot) >= 2, "The next noise at that spot won't bring everyone") + TEST_ASSERT_EQUAL(length(group.checks), 0, "A failed check wasn't closed") + // One that comes back closes its check. + settle(second) + settle(third) + group.forget_noises() + stealth_noise(spot, "knock") + TEST_ASSERT_EQUAL(state_of(second), "suspicious", "The next guard didn't go to look") + settle(second) + group.rewind(31 SECONDS) + group.check_overdue() + TEST_ASSERT_EQUAL(state_of(third), "unaware", "A guard was missed after it came back") + no_targets(list(second, third)) + +/// Gunfire: the nearest four that aren't sentries run to it, the rest hold, everyone is wary. After two alarms, two go. +/datum/unit_test/voidcrew_stealth_live/hear/alarm + +/datum/unit_test/voidcrew_stealth_live/hear/alarm/Run() + TEST_ASSERT(hear_room(30, 5), "No room for the test") + // The sentries first: a guard made beside a stop would claim its route. + var/list/sentries = list(sentry(4, 3), sentry(6, 3)) + var/list/route_guards = list() + for(var/dx in 3 to 8) + route_guards += walker(dx, 1) + var/mob/living/any_guard = route_guards[1] + var/datum/ai_controller/basic_controller/human_npc/stealth/any_ai = any_guard.ai_controller + var/datum/stealth_group/group = any_ai.group + var/turf/spot = at(1, 1) + TEST_ASSERT_EQUAL(stealth_noise(spot, "gun_long"), 8, "Eight guards within 14 tiles didn't all hear a rifle") + var/searching = 0 + for(var/mob/living/guard as anything in route_guards) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + TEST_ASSERT(guard_ai.blackboard["stealth_wary"], "A guard that heard gunfire isn't wary") + if(guard_ai.stealth_state() == "searching") + searching++ + TEST_ASSERT_EQUAL(searching, 4, "Not exactly four guards ran to the gunfire") + TEST_ASSERT_EQUAL(state_of(route_guards[1]), "searching", "The nearest guard didn't go") + TEST_ASSERT_EQUAL(state_of(route_guards[6]), "unaware", "The furthest guard didn't hold") + for(var/mob/living/guard as anything in sentries) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "unaware", "A sentry left its post for gunfire") + TEST_ASSERT(guard_ai.blackboard["stealth_wary"], "A sentry that heard gunfire isn't wary") + // A second, then a third: by then they have learned it may be a draw. + for(var/round_number in 2 to 3) + for(var/mob/living/guard as anything in route_guards + sentries) + settle(guard) + group.rewind(2 SECONDS) + stealth_noise(spot, "gun_long") + searching = 0 + for(var/mob/living/guard as anything in route_guards) + if(state_of(guard) == "searching") + searching++ + TEST_ASSERT_EQUAL(searching, 2, "After two alarms in memory, not exactly two guards went to the third") + no_targets(route_guards + sentries) + +/// Their own side: a guard doesn't hear itself, a friend's gunfire is a call for help, their own door is nothing, a friend's fall is heard. +/datum/unit_test/voidcrew_stealth_live/hear/allies + +/datum/unit_test/voidcrew_stealth_live/hear/allies/Run() + TEST_ASSERT(hear_room(20, 3), "No room for the test") + var/mob/living/carbon/human/npc/shooter = walker(3, 1) + var/mob/living/carbon/human/npc/friend = walker(8, 1) + var/datum/ai_controller/basic_controller/human_npc/stealth/friend_ai = friend.ai_controller + TEST_ASSERT_EQUAL(stealth_noise(shooter, "voice", null, shooter), 0, "A guard's whistle was heard by its friend") + TEST_ASSERT_EQUAL(stealth_noise(shooter, "gun_pistol", null, shooter), 1, "A guard's gunfire wasn't heard by its friend") + TEST_ASSERT_EQUAL(state_of(shooter), "unaware", "A guard reacted to its own shot") + TEST_ASSERT_EQUAL(friend_ai.stealth_state(), "searching", "A guard didn't run to a friend's gunfire") + TEST_ASSERT_EQUAL(friend_ai.search_center, get_turf(shooter), "It isn't looking where its friend fired from") + settle(friend) + var/obj/machinery/door/airlock/door = allocate(/obj/machinery/door/airlock, at(9, 1)) + TEST_ASSERT_EQUAL(stealth_noise(door, "door"), 0, "A door with one of their own beside it was heard") + door.forceMove(at(11, 1)) + TEST_ASSERT_EQUAL(stealth_noise(door, "door"), 1, "A door with nobody beside it wasn't heard") + TEST_ASSERT(friend_ai.glance_until > world.time, "A guard didn't glance at a door") + friend_ai.group.forget_noises() + TEST_ASSERT_EQUAL(stealth_noise(at(6, 1), "thud", null, shooter), 1, "A friend's fall wasn't heard") + TEST_ASSERT_EQUAL(friend_ai.stealth_state(), "suspicious", "A guard didn't look at a friend's fall") + no_targets(list(shooter, friend)) + +/// The deaf hear nothing; with no player on the level nothing is heard at all; ten shots in a tick are one noise. +/datum/unit_test/voidcrew_stealth_live/hear/deaf_dormant + +/datum/unit_test/voidcrew_stealth_live/hear/deaf_dormant/Run() + TEST_ASSERT(hear_room(20, 3), "No room for the test") + var/mob/living/carbon/human/npc/guard = walker(5, 1) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + var/datum/stealth_group/group = guard_ai.group + var/turf/spot = at(3, 1) + ADD_TRAIT(guard, TRAIT_DEAF, TRAIT_SOURCE_UNIT_TESTS) + TEST_ASSERT_EQUAL(stealth_noise(spot, "gun_long"), 0, "A deaf guard heard a rifle") + REMOVE_TRAIT(guard, TRAIT_DEAF, TRAIT_SOURCE_UNIT_TESTS) + // Nobody on the level. + var/list/were_listed = players.Copy() + for(var/mob/living/person as anything in were_listed) + SSmobs.clients_by_zlevel[were_listed[person]] -= person + TEST_ASSERT_EQUAL(stealth_noise(spot, "gun_long"), 0, "A guard on an empty level heard a rifle") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "unaware", "A noise on an empty level changed a guard") + for(var/mob/living/person as anything in were_listed) + SSmobs.clients_by_zlevel[were_listed[person]] += person + var/heard = 0 + for(var/shot in 1 to 10) + heard += stealth_noise(at(3 + (shot % 3), 1), "gun_long") + TEST_ASSERT_EQUAL(heard, 1, "Ten shots in one tick weren't one noise") + TEST_ASSERT_EQUAL(length(group.alarms), 1, "Ten shots in one tick were more than one alarm") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "searching", "A guard didn't run to gunfire") + no_targets(list(guard)) + +/// A guard that sees someone shouts; a friend in earshot runs to the shouter and doesn't shout on. A muted guard calls nobody. +/datum/unit_test/voidcrew_stealth_live/hear/shout + +/datum/unit_test/voidcrew_stealth_live/hear/shout/Run() + TEST_ASSERT(hear_room(24, 3), "No room for the test") + var/mob/living/carbon/human/npc/spotter = walker(10, 1, EAST) + var/mob/living/carbon/human/npc/friend = walker(4, 1, WEST) + var/datum/ai_controller/basic_controller/human_npc/stealth/spotter_ai = spotter.ai_controller + var/datum/ai_controller/basic_controller/human_npc/stealth/friend_ai = friend.ai_controller + var/mob/living/carbon/human/intruder = person_at(12, 1, FALSE) + ADD_TRAIT(spotter, TRAIT_MUTE, TRAIT_SOURCE_UNIT_TESTS) + stealth_scans(spotter, 4) + TEST_ASSERT_EQUAL(spotter_ai.stealth_state(), "alert", "A guard isn't alert on someone 2 tiles in front of it") + TEST_ASSERT_EQUAL(friend_ai.stealth_state(), "unaware", "A muted guard called its friend") + REMOVE_TRAIT(spotter, TRAIT_MUTE, TRAIT_SOURCE_UNIT_TESTS) + settle(spotter) + spotter.setDir(EAST) + stealth_scans(spotter, 4) + TEST_ASSERT_EQUAL(spotter_ai.stealth_state(), "alert", "A guard isn't alert on someone 2 tiles in front of it") + TEST_ASSERT_EQUAL(friend_ai.stealth_state(), "searching", "A guard in earshot of a shout didn't come") + TEST_ASSERT_EQUAL(friend_ai.search_center, get_turf(spotter), "It ran to the intruder, not to the friend who shouted") + TEST_ASSERT(!friend_ai.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET), "A shout gave a guard a target") + TEST_ASSERT(!friend_ai.next_shout, "A guard that came for a shout shouted on") + TEST_ASSERT_EQUAL(spotter_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], intruder, "The guard that saw them has no target") + +/// A radio call takes three seconds, reaches the other lookout anywhere, and is stopped by a knockout, a jammer or an EMP. +/datum/unit_test/voidcrew_stealth_live/hear/radio + +/datum/unit_test/voidcrew_stealth_live/hear/radio/Run() + TEST_ASSERT(hear_room(40, 3), "No room for the test") + var/mob/living/carbon/human/npc/speaker = walker(3, 1, WEST, STEALTH_HEAR_LOOKOUT) + var/mob/living/carbon/human/npc/listener = walker(34, 1, EAST, STEALTH_HEAR_LOOKOUT) + var/mob/living/carbon/human/npc/neighbour = walker(31, 1, WEST) + var/datum/ai_controller/basic_controller/human_npc/stealth/speaker_ai = speaker.ai_controller + var/datum/ai_controller/basic_controller/human_npc/stealth/listener_ai = listener.ai_controller + var/datum/stealth_group/group = speaker_ai.group + TEST_ASSERT_NOTNULL(speaker.stealth_radio_ready(), "A lookout has no working radio") + TEST_ASSERT_NULL(neighbour.stealth_radio_ready(), "A plain guard has a radio") + var/turf/spot = at(5, 1) + // The call goes out after three seconds, not before. + TEST_ASSERT(speaker_ai.stealth_start_call(3, spot), "A lookout couldn't start a call") + stealth_scans(speaker, 1) + TEST_ASSERT_EQUAL(listener_ai.stealth_state(), "unaware", "A radio call arrived at once") + speaker_ai.stealth_rewind(3.1 SECONDS) + stealth_scans(speaker, 1) + TEST_ASSERT_NULL(speaker_ai.pending_call, "A call that was made is still pending") + TEST_ASSERT_EQUAL(listener_ai.stealth_state(), "searching", "The other lookout didn't answer a radio alarm") + TEST_ASSERT_EQUAL(state_of(neighbour), "searching", "The guard beside the lookout that answered didn't come") + // Knocked out inside the three seconds. + for(var/mob/living/guard as anything in list(speaker, listener, neighbour)) + settle(guard) + group.forget_noises() + speaker_ai.stealth_start_call(3, spot) + speaker.Unconscious(4 SECONDS) + TEST_ASSERT_NULL(speaker_ai.pending_call, "A knocked-out guard kept its call") + speaker.SetUnconscious(0) + speaker.update_stat() + settle(speaker) + TEST_ASSERT_EQUAL(listener_ai.stealth_state(), "unaware", "A call from a knocked-out guard arrived") + // A jammer beside the speaker. + var/obj/item/jammer/jammer = allocate(/obj/item/jammer, get_turf(speaker)) + GLOB.active_jammers |= jammer + TEST_ASSERT_NULL(speaker.stealth_radio_ready(), "A jammed lookout's radio works") + speaker_ai.stealth_start_call(3, spot) + speaker_ai.stealth_rewind(3.1 SECONDS) + stealth_scans(speaker, 1) + GLOB.active_jammers -= jammer + TEST_ASSERT_EQUAL(listener_ai.stealth_state(), "unaware", "A jammed call arrived") + TEST_ASSERT(speaker_ai.bark_ready_at["stealth_radio_dead"], "A lookout with a dead radio didn't say so") + // The receiver's earpiece hit by an EMP. + settle(speaker) + var/obj/item/radio/earpiece = listener.ears + earpiece.emp_act(EMP_HEAVY) + TEST_ASSERT_NULL(listener.stealth_radio_ready(), "An EMPed earpiece still works") + speaker_ai.stealth_start_call(3, spot) + speaker_ai.stealth_rewind(3.1 SECONDS) + stealth_scans(speaker, 1) + TEST_ASSERT_EQUAL(listener_ai.stealth_state(), "unaware", "A lookout with a dead earpiece got the call") + TEST_ASSERT_EQUAL(state_of(neighbour), "unaware", "The call reached a guard with no radio") + no_targets(list(speaker, listener, neighbour)) + +/// A lone lookout that reports in is missed by the other lookout; a guard with no radio that goes alone is missed by nobody. +/datum/unit_test/voidcrew_stealth_live/hear/report + +/datum/unit_test/voidcrew_stealth_live/hear/report/Run() + TEST_ASSERT(hear_room(40, 3), "No room for the test") + var/mob/living/carbon/human/npc/scout = walker(3, 1, WEST, STEALTH_HEAR_LOOKOUT) + var/mob/living/carbon/human/npc/listener = walker(34, 1, EAST, STEALTH_HEAR_LOOKOUT) + var/mob/living/carbon/human/npc/loner = walker(18, 1, WEST) + var/datum/ai_controller/basic_controller/human_npc/stealth/scout_ai = scout.ai_controller + var/datum/stealth_group/group = scout_ai.group + TEST_ASSERT_EQUAL(stealth_noise(at(5, 1), "knock"), 1, "Only the lookout should hear this knock") + TEST_ASSERT_NOTNULL(scout_ai.pending_call, "A lookout sent to look didn't reach for its radio") + scout_ai.stealth_rewind(3.1 SECONDS) + stealth_scans(scout, 1) + TEST_ASSERT_EQUAL(state_of(listener), "unaware", "A report moved someone") + scout.death() + group.rewind(31 SECONDS) + group.check_overdue() + TEST_ASSERT_EQUAL(state_of(listener), "searching", "A lookout that reported and never came back wasn't missed") + // No radio, nobody else in earshot: nobody knows it went. + settle(listener) + group.forget_noises() + TEST_ASSERT_EQUAL(stealth_noise(at(20, 1), "knock"), 1, "Only the plain guard should hear this knock") + TEST_ASSERT_EQUAL(state_of(loner), "suspicious", "The plain guard didn't go to look") + loner.death() + group.rewind(31 SECONDS) + group.check_overdue() + TEST_ASSERT_EQUAL(state_of(listener), "unaware", "A guard nobody saw leave was missed") + +/// The grey "?" of a heard noise: for players near with no fill of their own, never for a glance, gone when it gives up. +/datum/unit_test/voidcrew_stealth_live/hear/mark + +/datum/unit_test/voidcrew_stealth_live/hear/mark/Run() + TEST_ASSERT(hear_room(20, 3), "No room for the test") + var/mob/living/carbon/human/npc/first = walker(8, 1) + var/mob/living/carbon/human/npc/second = walker(10, 1) + var/datum/ai_controller/basic_controller/human_npc/stealth/first_ai = first.ai_controller + var/datum/ai_controller/basic_controller/human_npc/stealth/second_ai = second.ai_controller + var/mob/living/carbon/human/watcher = person_at(4, 1) + stealth_noise(at(7, 1), "knock") + TEST_ASSERT(first_ai.suspicion_heard, "The guard that went isn't marked as having heard") + TEST_ASSERT(stealth_meter_heard(first_ai.stealth_state(), first_ai.suspicion_heard), "A heard suspicion shows no mark") + TEST_ASSERT_NOTNULL(first_ai.meter, "No mark was built for a heard suspicion with nobody noticed") + TEST_ASSERT(watcher in first_ai.meter.heard_viewers(first_ai.notice_map), "A player near the guard doesn't get the heard mark") + first_ai.notice_map[REF(watcher)] = list(0.5, get_turf(watcher), world.time) + TEST_ASSERT(!(watcher in first_ai.meter.heard_viewers(first_ai.notice_map)), "A player with their own fill gets the heard mark too") + TEST_ASSERT(!second_ai.suspicion_heard, "A glance shows the heard mark") + first_ai.stealth_go_unaware() + TEST_ASSERT(!first_ai.suspicion_heard, "The heard mark outlived the suspicion") + TEST_ASSERT(!stealth_meter_heard(first_ai.stealth_state(), first_ai.suspicion_heard), "An unaware guard shows the heard mark") + +/// Deleting a guard with a call pending and a check open, then its group: nothing left behind. +/datum/unit_test/voidcrew_stealth_live/hear/cleanup + +/datum/unit_test/voidcrew_stealth_live/hear/cleanup/Run() + TEST_ASSERT(hear_room(20, 3), "No room for the test") + stop_at(5, 1, 1, 10 MINUTES) + stop_at(7, 1, 2, 10 MINUTES) + var/mob/living/carbon/human/npc/scout = new STEALTH_HEAR_LOOKOUT(at(5, 1)) + var/mob/living/carbon/human/npc/friend = new STEALTH_HEAR_GUARD(at(7, 1)) + var/datum/ai_controller/basic_controller/human_npc/stealth/scout_ai = wake(scout) + var/datum/ai_controller/basic_controller/human_npc/stealth/friend_ai = wake(friend) + scout_ai.stealth_setup() + friend_ai.stealth_setup() + var/datum/stealth_group/group = scout_ai.group + stealth_noise(at(4, 1), "knock") + TEST_ASSERT_NOTNULL(scout_ai.pending_call, "The lookout has no call pending") + TEST_ASSERT_EQUAL(length(group.checks), 1, "No check is open") + qdel(scout) + group.rewind(31 SECONDS) + group.check_overdue() + TEST_ASSERT_EQUAL(friend_ai.stealth_state(), "searching", "A deleted investigator wasn't missed") + qdel(friend) + QDEL_NULL(marker) + TEST_ASSERT(!(group in GLOB.stealth_groups), "A group with no marker and no guards is still registered") + TEST_ASSERT(QDELETED(group), "The group wasn't deleted") + // The explosion listener went with it. + SEND_GLOBAL_SIGNAL(COMSIG_GLOB_EXPLOSION, at(4, 1), 0, 0, 1) + +// ===== Through the real tg action ===== + +/// A real pistol shot sends a guard running; suppressed, it is unheard at 6 tiles and a curiosity at 3. +/datum/unit_test/voidcrew_stealth_live/hear/real_gunshot + +/datum/unit_test/voidcrew_stealth_live/hear/real_gunshot/Run() + TEST_ASSERT(hear_room(30, 3), "No room for the test") + var/mob/living/carbon/human/npc/guard = walker(3, 1, WEST) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + var/mob/living/carbon/human/shooter = person_at(10, 1, FALSE) + var/obj/item/gun/ballistic/automatic/pistol/pistol = allocate(/obj/item/gun/ballistic/automatic/pistol, get_turf(shooter)) + shooter.put_in_active_hand(pistol) + var/turf/far_wall = at(25, 1) + TEST_ASSERT(pistol.process_fire(far_wall, shooter), "The pistol didn't fire") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "searching", "A guard 7 tiles behind a pistol shot didn't run to it") + TEST_ASSERT(get_dist(guard_ai.search_center, shooter) <= 1, "It isn't searching where the shot came from") + TEST_ASSERT(!guard_ai.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET), "A gunshot gave a guard a target") + // Suppressed, 6 tiles: nothing. + settle(guard) + guard_ai.group.forget_noises() + pistol.install_suppressor(new /obj/item/suppressor(pistol)) + shooter.forceMove(at(9, 1)) + // No time passes in this test: the gun's own delay between shots is cleared by hand. + pistol.reset_fire_cd() + TEST_ASSERT(pistol.process_fire(far_wall, shooter), "The suppressed pistol didn't fire") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "unaware", "A guard heard a suppressed shot 6 tiles off") + // 3 tiles, in the open: it turns to look. + guard_ai.group.forget_noises() + shooter.forceMove(at(6, 1)) + pistol.reset_fire_cd() + TEST_ASSERT(pistol.process_fire(far_wall, shooter), "The suppressed pistol didn't fire again") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "suspicious", "A guard 3 tiles from a suppressed shot didn't look") + TEST_ASSERT(guard_ai.suspicion_heard, "It isn't marked as having heard it") + TEST_ASSERT(!guard_ai.blackboard["stealth_wary"], "A suppressed shot made a guard wary") + +/// A real throw: the guard looks where the thing landed. A bottle smashes and carries further. +/datum/unit_test/voidcrew_stealth_live/hear/real_throw + +/datum/unit_test/voidcrew_stealth_live/hear/real_throw/Run() + TEST_ASSERT(hear_room(30, 7), "No room for the test") + ground() + var/mob/living/carbon/human/npc/guard = sentry(9, 5, EAST) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + var/mob/living/carbon/human/thrower = person_at(0, 2, FALSE) + var/obj/item/coin/iron/coin = allocate(/obj/item/coin/iron, get_turf(thrower)) + var/turf/landing = at(9, 2) + coin.throw_at(landing, 12, 2, thrower) + var/deadline = world.time + 10 SECONDS + while((coin.throwing || guard_ai.stealth_state() == "unaware") && world.time < deadline) + sleep(1) + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "suspicious", "A guard 3 tiles from a thrown coin's landing didn't look (it landed [get_dist(coin, guard)] tiles off)") + TEST_ASSERT(get_dist(guard_ai.investigate_turf, get_turf(coin)) <= 1, "It isn't looking where the coin landed") + TEST_ASSERT_EQUAL(guard_ai.last_heard[1], "thrown", "It heard something other than a landing") + // A bottle, 7 tiles from the guard: only breaking glass carries that far. + settle(guard) + guard_ai.group.forget_noises() + // On a route now: a sentry wouldn't leave its post for something this far off. + guard.forceMove(at(16, 2)) + stop_at(16, 2, 1, 10 MINUTES) + stealth_assign_points() + guard_ai.route_id = "a" + guard_ai.route_index = 1 + guard_ai.home_turf = at(16, 2) + guard.setDir(EAST) + var/obj/item/reagent_containers/cup/glass/bottle/beer/bottle = allocate(/obj/item/reagent_containers/cup/glass/bottle/beer, get_turf(thrower)) + TEST_ASSERT_EQUAL(bottle.stealth_throw_kind(), "glass", "A glass bottle doesn't smash as glass") + bottle.throw_at(landing, 12, 2, thrower) + deadline = world.time + 10 SECONDS + while(guard_ai.stealth_state() == "unaware" && world.time < deadline) + sleep(1) + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "suspicious", "A guard 7 tiles from a smashed bottle didn't look") + TEST_ASSERT_EQUAL(guard_ai.last_heard[1], "glass", "It heard something other than breaking glass") + +/// Knocking on a wall or a window, and a door that refuses: the guard on the far side looks at its own side of it. +/datum/unit_test/voidcrew_stealth_live/hear/real_knock + +/datum/unit_test/voidcrew_stealth_live/hear/real_knock/Run() + TEST_ASSERT(hear_room(20, 5), "No room for the test") + for(var/dy in 0 to 4) + var/turf/wall_spot = at(10, dy) + wall_spot.ChangeTurf(/turf/closed/wall) + var/mob/living/carbon/human/npc/guard = sentry(13, 2, EAST) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + var/mob/living/carbon/human/knocker = person_at(9, 2, FALSE) + var/turf/closed/wall/wall = at(10, 2) + wall.attack_hand(knocker, list()) + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "suspicious", "A guard 3 tiles behind a wall didn't hear a push on it") + TEST_ASSERT_EQUAL(guard_ai.investigate_turf, at(11, 2), "It isn't going to its own side of the wall") + // A window in the wall. + settle(guard) + guard_ai.group.forget_noises() + var/turf/pane_spot = at(10, 3) + pane_spot.ChangeTurf(/turf/open/floor/iron) + var/obj/structure/window/reinforced/fulltile/pane = allocate(/obj/structure/window/reinforced/fulltile, pane_spot) + knocker.forceMove(at(9, 3)) + knocker.set_combat_mode(FALSE) + pane.attack_hand(knocker, list()) + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "suspicious", "A guard didn't hear a knock on a window") + TEST_ASSERT_EQUAL(guard_ai.last_heard[1], "knock", "A knock with combat mode off wasn't a knock") + TEST_ASSERT_EQUAL(guard_ai.investigate_turf?.x, pane_spot.x + 1, "It isn't going to its own side of the window") + // A door that refuses. + settle(guard) + guard_ai.group.forget_noises() + var/turf/door_spot = at(10, 1) + door_spot.ChangeTurf(/turf/open/floor/iron) + var/obj/machinery/door/airlock/door = allocate(/obj/machinery/door/airlock, door_spot) + door.animation_effects(DOOR_DENY_ANIMATION) + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "suspicious", "A guard didn't hear a door refuse someone") + TEST_ASSERT_EQUAL(guard_ai.investigate_turf?.x, door_spot.x + 1, "It isn't going to its own side of the door") + +/// A body that drops is heard; one held when it drops is lowered without a sound. A whistle is heard; a nod is not. +/datum/unit_test/voidcrew_stealth_live/hear/real_fall_emote + +/datum/unit_test/voidcrew_stealth_live/hear/real_fall_emote/Run() + TEST_ASSERT(hear_room(20, 5), "No room for the test") + var/mob/living/carbon/human/npc/guard = sentry(10, 2, EAST) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + var/mob/living/carbon/human/holder = person_at(6, 2, FALSE) + var/mob/living/carbon/human/held = person_at(7, 2, FALSE) + ground() + holder.start_pulling(held) + holder.setGrabState(GRAB_AGGRESSIVE) + TEST_ASSERT_EQUAL(held.pulledby, holder, "The grab didn't take") + held.Knockdown(10 SECONDS) + TEST_ASSERT_EQUAL(held.body_position, LYING_DOWN, "The held one didn't go down") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "unaware", "A body lowered by whoever held it was heard") + var/mob/living/carbon/human/dropped = person_at(7, 3, FALSE) + dropped.Knockdown(10 SECONDS) + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "suspicious", "A body dropping 3 tiles behind a guard wasn't heard") + TEST_ASSERT_EQUAL(guard_ai.last_heard[1], "thud", "It heard something other than a thud") + // Emotes. + settle(guard) + guard_ai.group.forget_noises() + guard.setDir(EAST) + var/mob/living/carbon/human/whistler = person_at(6, 4, FALSE) + whistler.emote("nod") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "unaware", "A silent emote was heard") + whistler.emote("whistle") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "suspicious", "A whistle 4 tiles off wasn't heard") + TEST_ASSERT_EQUAL(guard_ai.last_heard[1], "voice", "It heard something other than a voice") + +/// A real explosion 12 tiles off, the other side of a wall: the guard runs to it. +/datum/unit_test/voidcrew_stealth_live/hear/real_blast + +/datum/unit_test/voidcrew_stealth_live/hear/real_blast/Run() + TEST_ASSERT(hear_room(30, 5), "No room for the test") + for(var/dy in 0 to 4) + var/turf/wall_spot = at(10, dy) + wall_spot.ChangeTurf(/turf/closed/wall) + var/mob/living/carbon/human/npc/guard = walker(16, 2, EAST) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + explosion(at(4, 2), devastation_range = 0, heavy_impact_range = 0, light_impact_range = 1) + var/deadline = world.time + 10 SECONDS + while(guard_ai.stealth_state() != "searching" && world.time < deadline) + sleep(1) + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "searching", "A guard 12 tiles from a blast behind a wall didn't run to it") + TEST_ASSERT_EQUAL(guard_ai.last_heard[1], "blast", "It heard something other than a blast") + TEST_ASSERT(!guard_ai.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET), "A blast gave a guard a target") + +// ===== With the real AI running ===== + +/// A bottle thrown off a guard's route: it walks over, finds nothing, and goes back to its round. +/datum/unit_test/voidcrew_stealth_live/hear/live_lure + +/datum/unit_test/voidcrew_stealth_live/hear/live_lure/Run() + TEST_ASSERT(make_room(34, 9), "No room for the test") + marker = allocate(/obj/effect/landmark/stealth_group, at(0, 8)) + // The player who keeps the level awake, walled off at the far end. + for(var/dy in 0 to 8) + var/turf/wall_spot = at(24, dy) + wall_spot.ChangeTurf(/turf/closed/wall) + person_at(30, 2) + // A wall hides the thrower from the route; the top two rows are open to throw along. + for(var/dy in 0 to 6) + var/turf/wall_spot = at(11, dy) + wall_spot.ChangeTurf(/turf/closed/wall) + ground() + stop_at(2, 2, 1) + stop_at(8, 2, 2) + var/mob/living/carbon/human/npc/guard = guard_at(2, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = wake(guard) + var/mob/living/carbon/human/thrower = person_at(16, 7, FALSE) + sleep(3 SECONDS) + TEST_ASSERT_EQUAL(guard_ai.route_id, "a", "The guard never claimed its route") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "unaware", "A patrolling guard with nobody in sight isn't unaware") + var/turf/landing = at(5, 7) + var/obj/item/reagent_containers/cup/glass/bottle/beer/bottle = allocate(/obj/item/reagent_containers/cup/glass/bottle/beer, get_turf(thrower)) + bottle.throw_at(landing, 14, 2, thrower) + var/start_time = world.time + var/found = FALSE + var/nearest = INFINITY + var/deadline = world.time + 25 SECONDS + while(world.time < deadline) + nearest = min(nearest, get_dist(guard, landing)) + if(nearest <= 1) + found = TRUE + break + sleep(2) + TEST_ASSERT(found, "The guard never walked to the smashed bottle: it got within [nearest] tiles, state [guard_ai.stealth_state()], heard [guard_ai.last_heard ? guard_ai.last_heard[1] : "nothing"]") + var/back = FALSE + deadline = start_time + 60 SECONDS + while(world.time < deadline) + if(guard_ai.stealth_state() == "unaware" && (get_dist(guard, at(2, 2)) <= 1 || get_dist(guard, at(8, 2)) <= 1)) + back = TRUE + break + sleep(2) + TEST_ASSERT(back, "The guard didn't go back to its round: state [guard_ai.stealth_state()], [get_dist(guard, at(2, 2))] and [get_dist(guard, at(8, 2))] tiles from its stops") + TEST_ASSERT(!guard_ai.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET), "A smashed bottle gave a guard a target") + +/// Someone walking up behind a guard is not heard; the same person running makes it turn. +/datum/unit_test/voidcrew_stealth_live/hear/live_footsteps + +/datum/unit_test/voidcrew_stealth_live/hear/live_footsteps/Run() + TEST_ASSERT(make_room(20, 3), "No room for the test") + // The player first: a guard woken on an empty level stays asleep. + var/mob/living/carbon/human/runner = person_at(5, 1) + var/mob/living/carbon/human/npc/guard = guard_at(10, 1, EAST) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = wake(guard) + sleep(2 SECONDS) + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "unaware", "A guard noticed someone standing 5 tiles behind it") + // Walking, to one tile behind it. + for(var/step_number in 1 to 4) + runner.Move(get_step(runner, EAST), EAST) + sleep(3) + TEST_ASSERT_EQUAL(get_dist(runner, guard), 1, "The walker didn't get behind the guard") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "unaware", "A guard heard someone walk up behind it") + // Back, and now running. + runner.forceMove(at(5, 1)) + guard_ai.stealth_go_unaware() + guard_ai.stealth_clear_wary() + guard.setDir(EAST) + sleep(2 SECONDS) + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "unaware", "The guard didn't settle") + runner.toggle_move_intent() + TEST_ASSERT_EQUAL(runner.move_intent, MOVE_INTENT_RUN, "The runner isn't running") + var/heard = FALSE + for(var/step_number in 1 to 3) + runner.Move(get_step(runner, EAST), EAST) + for(var/tick in 1 to 6) + if(guard_ai.stealth_state() != "unaware") + heard = TRUE + break + sleep(1) + if(heard) + break + var/deadline = world.time + 3 SECONDS + while(!heard && world.time < deadline) + heard = guard_ai.stealth_state() != "unaware" + sleep(1) + TEST_ASSERT(heard, "A guard never heard someone run up behind it (they are [get_dist(runner, guard)] tiles off)") + TEST_ASSERT(get_dist(runner, guard) >= 2, "The runner was next to the guard before it turned") + TEST_ASSERT_EQUAL(guard.dir, WEST, "The guard didn't turn to the footsteps") + TEST_ASSERT(guard_ai.last_heard?[1] == "footsteps", "It turned for something other than footsteps") + +/// A lookout that sees someone reaches for its radio; stunned before the call goes out, the other lookout never hears of it. +/datum/unit_test/voidcrew_stealth_live/hear/live_call + +/datum/unit_test/voidcrew_stealth_live/hear/live_call/Run() + TEST_ASSERT(make_room(40, 3), "No room for the test") + marker = allocate(/obj/effect/landmark/stealth_group, at(0, 2)) + var/mob/living/carbon/human/npc/scout = allocate(STEALTH_HEAR_LOOKOUT, at(4, 1)) + scout.setDir(EAST) + scout.AddElement(/datum/element/forced_gravity, 1) + var/mob/living/carbon/human/npc/listener = allocate(STEALTH_HEAR_LOOKOUT, at(36, 1)) + listener.setDir(EAST) + listener.AddElement(/datum/element/forced_gravity, 1) + person_at(6, 1) + var/datum/ai_controller/basic_controller/human_npc/stealth/scout_ai = wake(scout) + var/datum/ai_controller/basic_controller/human_npc/stealth/listener_ai = wake(listener) + var/deadline = world.time + 15 SECONDS + while(isnull(scout_ai.pending_call) && world.time < deadline) + sleep(1) + TEST_ASSERT_EQUAL(scout_ai.stealth_state(), "alert", "A lookout isn't alert on someone 2 tiles in front of it") + TEST_ASSERT_NOTNULL(scout_ai.pending_call, "A lookout that saw someone didn't reach for its radio") + scout.Stun(8 SECONDS) + TEST_ASSERT_NULL(scout_ai.pending_call, "A stunned lookout kept its call") + var/found = FALSE + deadline = world.time + 6 SECONDS + while(world.time < deadline) + if(listener_ai.stealth_state() != "unaware") + found = TRUE + sleep(2) + TEST_ASSERT(!found, "The other lookout heard of a call that was never made") + +#undef STEALTH_HEAR_GUARD +#undef STEALTH_HEAR_LOOKOUT From c42118c2b216eac53903231bc30359b36ce2ab85 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Mon, 9 Nov 2026 21:54:30 -0800 Subject: [PATCH 17/78] An admin watching a guard's sight sees one mark at a time --- voidcrew/modules/stealth/stealth_meter.dm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/voidcrew/modules/stealth/stealth_meter.dm b/voidcrew/modules/stealth/stealth_meter.dm index 07a5f796015..1c1cad1c745 100644 --- a/voidcrew/modules/stealth/stealth_meter.dm +++ b/voidcrew/modules/stealth/stealth_meter.dm @@ -138,8 +138,13 @@ if(top_state) for(var/datum/stealth_sight_overlay/overlay as anything in controller.watchers) var/client/admin = overlay.user_ref?.resolve() - if(isnull(admin) || (wanted[REF(admin.mob)] && wanted[REF(admin.mob)][1] != STEALTH_METER_HEARD_STATE)) + if(isnull(admin)) continue + var/list/own = wanted[REF(admin.mob)] + if(own && own[1] != STEALTH_METER_HEARD_STATE) + continue + // The fullest fill takes the place of the admin's empty heard "?": one glyph at a time. + wanted -= REF(admin.mob) wanted["watch:[admin.ckey]"] = list(top_state, admin) for(var/key in private_marks.Copy()) var/list/held = private_marks[key] From bd574cc36bb77d495fd99a10b69cde50d279a778 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Tue, 10 Nov 2026 12:40:21 -0800 Subject: [PATCH 18/78] Scav guards carry seclites and see someone at their elbow in the dark Guards switch a belt seclite on in the dark and whenever they are on edge; an EMP cuts it out. A body found mid-search is called out, a quick volley from one spot counts as one noise, and sentries keep facing their post. --- tgstation.dme | 1 + voidcrew/_DEFINES/stealth.dm | 12 ++ voidcrew/_DEFINES/stealth_hearing.dm | 4 +- voidcrew/modules/stealth/scav_guards.dm | 5 + voidcrew/modules/stealth/stealth_ai.dm | 29 ++- voidcrew/modules/stealth/stealth_light.dm | 82 +++++++ voidcrew/modules/stealth/stealth_patrol.dm | 3 + .../modules/stealth/stealth_perception.dm | 9 +- voidcrew/modules/unit_tests/_unit_tests.dm | 1 + .../unit_tests/voidcrew_stealth_hearing.dm | 8 +- .../unit_tests/voidcrew_stealth_light.dm | 204 ++++++++++++++++++ 11 files changed, 345 insertions(+), 13 deletions(-) create mode 100644 voidcrew/modules/stealth/stealth_light.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_stealth_light.dm diff --git a/tgstation.dme b/tgstation.dme index 25ed4aac37d..7cb1a1ac6c8 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7733,6 +7733,7 @@ #include "voidcrew\modules\stealth\stealth_admin_noise.dm" #include "voidcrew\modules\stealth\stealth_ai.dm" #include "voidcrew\modules\stealth\stealth_hearing.dm" +#include "voidcrew\modules\stealth\stealth_light.dm" #include "voidcrew\modules\stealth\stealth_meter.dm" #include "voidcrew\modules\stealth\stealth_noise.dm" #include "voidcrew\modules\stealth\stealth_noise_sources.dm" diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index 53bc8633070..fe6fb0255b3 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -53,6 +53,8 @@ #define STEALTH_DARK_LUMCOUNT 0.2 #define STEALTH_DARK_MULT 0.5 #define STEALTH_CLOSE_RANGE 2 +/// Elbow to elbow: someone this close in its cone is seen whatever the light (decision 31) +#define STEALTH_ADJACENT_RANGE 1 #define STEALTH_CONE_HALF_ANGLE 60 #define STEALTH_WARY_HALF_ANGLE 75 #define STEALTH_SEARCH_HALF_ANGLE 90 @@ -91,6 +93,8 @@ #define STEALTH_LOOK_TURN_CHANCE 50 #define STEALTH_LOOK_TURN_ARC 90 #define STEALTH_SENTRY_TURN_INTERVAL (8 SECONDS) +/// How long a sentry looks aside before it faces its post again +#define STEALTH_SENTRY_GLANCE_TIME (2 SECONDS) #define STEALTH_CHATTER_RANGE 3 #define STEALTH_CHATTER_COOLDOWN (45 SECONDS) #define STEALTH_PATROL_MAX_FAILS 3 @@ -127,4 +131,12 @@ #define STEALTH_METER_LYING_Z 29 /// The scav den's side +// ===== Flashlights (decision 31, stealth_light.dm) ===== +/// It keeps its light on this long after it last wanted it +#define STEALTH_LIGHT_HOLD (5 SECONDS) +/// A heavy EMP cuts a guard's seclite out for this long +#define STEALTH_LIGHT_EMP_HEAVY (40 SECONDS) +/// A light EMP cuts a guard's seclite out for this long +#define STEALTH_LIGHT_EMP_LIGHT (20 SECONDS) + #define FACTION_SCAV "scav" diff --git a/voidcrew/_DEFINES/stealth_hearing.dm b/voidcrew/_DEFINES/stealth_hearing.dm index 305e42b692a..4b8d3488bbe 100644 --- a/voidcrew/_DEFINES/stealth_hearing.dm +++ b/voidcrew/_DEFINES/stealth_hearing.dm @@ -118,8 +118,8 @@ /// One tile of error per this many tiles past exact #define STEALTH_NOISE_FUZZ_STEP 3 #define STEALTH_NOISE_FUZZ_MAX 3 -/// The same kind of noise this soon and this near an earlier one is the same noise -#define STEALTH_NOISE_COALESCE (0.5 SECONDS) +/// The same kind of noise this soon and this near an earlier one is the same noise (a volley is one event, decision 31) +#define STEALTH_NOISE_COALESCE (3 SECONDS) #define STEALTH_NOISE_COALESCE_RANGE 3 #define STEALTH_GLANCE_TIME (3 SECONDS) /// How long a guard told to hold faces the noise before it goes back to its round diff --git a/voidcrew/modules/stealth/scav_guards.dm b/voidcrew/modules/stealth/scav_guards.dm index 69f98b05c67..0cfc70dbe50 100644 --- a/voidcrew/modules/stealth/scav_guards.dm +++ b/voidcrew/modules/stealth/scav_guards.dm @@ -93,6 +93,11 @@ npc_voice = /datum/human_npc_voice/scav npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/sword +/// Every scav guard carries a seclite it switches on in the dark (stealth_light.dm, decision 31). +/mob/living/carbon/human/npc/ruin/trooper/scav/npc_dress(datum/human_npc_order/order) + . = ..() + stealth_give_light() + /mob/living/carbon/human/npc/ruin/trooper/scav/gunner npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/pistol diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index 82377896aa5..37d7c475a88 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -154,6 +154,8 @@ var/next_scan = 0 /// world.time of its next look for fallen friends var/next_body_scan = 0 + /// Whether its search is over a fallen friend (it doesn't end it with "Nothing.") + var/search_for_body = FALSE /// Bark kind => world.time it may say that kind again var/list/bark_ready_at = list() /// Its stat at the last change, to tell recovery from crit @@ -304,6 +306,7 @@ if(!stealth_driven()) stealth_set_pace(new_state == STEALTH_ALERT || new_state == STEALTH_SEARCHING) human_npc_set_ai_movement(src, new_state == STEALTH_ALERT ? /datum/ai_movement/basic_avoidance : /datum/ai_movement/jps/stealth) + stealth_update_light() for(var/datum/stealth_sight_overlay/overlay as anything in watchers) overlay.refresh() stealth_meter_update() @@ -408,6 +411,7 @@ if(isnull(where)) where = get_turf(pawn) stealth_set_state(STEALTH_SEARCHING) + search_for_body = FALSE search_center = stealth_leash(where) || get_turf(pawn) search_queue = stealth_search_spots(search_center) search_looking = FALSE @@ -556,7 +560,9 @@ if(world.time >= calm_until) stealth_go_unaware() else if(state == STEALTH_SEARCHING && world.time - blackboard[BB_STEALTH_STATE_SINCE] >= STEALTH_SEARCH_TIME) - stealth_bark(STEALTH_BARK_GIVE_UP) + // "Nothing." over a dead friend reads wrong: a search over a body ends without a word. + if(!search_for_body) + stealth_bark(STEALTH_BARK_GIVE_UP) stealth_go_unaware() else if(state == STEALTH_SUSPICIOUS && world.time - last_gain >= STEALTH_SUSPICIOUS_TIMEOUT) stealth_bark(STEALTH_BARK_GIVE_UP) @@ -575,6 +581,7 @@ if(stealth_state() != STEALTH_ALERT && world.time >= next_body_scan) stealth_check_bodies() heard_now = null + stealth_update_light() for(var/datum/stealth_sight_overlay/overlay as anything in watchers) overlay.refresh() stealth_meter_update() @@ -675,7 +682,9 @@ if(boxed) rate = STEALTH_NOTICE_RATE else if(eyes && !stealth_is_cloaked(candidate) && stealth_in_cone(guard, where, half_angle)) - var/cap = stealth_range_onto(where) + // Elbow to elbow in front of it: seen whatever the light (decision 31). Behind or side-on, the + // close radius below still applies. + var/cap = dist <= STEALTH_ADJACENT_RANGE ? STEALTH_SIGHT_RANGE : stealth_range_onto(where) if(dist <= cap) rate = STEALTH_NOTICE_RATE * clamp((cap + 1 - dist) / cap, STEALTH_NOTICE_MIN_FALLOFF, 1) if(cap < STEALTH_SIGHT_RANGE) @@ -946,10 +955,17 @@ if(!in_sight || !can_see(guard, where, STEALTH_SIGHT_RANGE)) continue seen += key - if((key in group.reported_bodies) || stealth_state() == STEALTH_SEARCHING) + var/news = !(key in group.reported_bodies) + if(news) + group.reported_bodies += key + if(!news || stealth_state() == STEALTH_SEARCHING) stealth_go_searching(where) + search_for_body = TRUE + // Already searching, it still says what it found (decision 31: guards that searched beside a + // body without a word looked blind). + if(news) + stealth_bark(STEALTH_BARK_BODY) else - group.reported_bodies += key stealth_go_suspicious(where, STEALTH_GOTO_BODY) stealth_first_hand(where) return @@ -1234,6 +1250,7 @@ controller.stealth_drop_walk() if(controller.goto_purpose == STEALTH_GOTO_BODY) controller.stealth_go_searching(get_turf(guard)) + controller.search_for_body = TRUE return SUBTREE_RETURN_FINISH_PLANNING controller.stand_dir = stealth_facing(guard) controller.look_until = world.time + STEALTH_LOOK_AROUND_TIME @@ -1396,12 +1413,16 @@ if(state == STEALTH_SUSPICIOUS && !controller.investigated) guard.setDir(controller.stand_dir) return AI_BEHAVIOR_DELAY + // A sentry faces its post and only glances aside now and then (decision 31: it used to spend half its + // time, the first eight seconds included, facing sideways). var/sentry = isnull(controller.route_id) controller.next_turn = world.time + (sentry ? STEALTH_SENTRY_TURN_INTERVAL : STEALTH_LOOK_TURN_INTERVAL) if(guard.dir != controller.stand_dir) guard.setDir(controller.stand_dir) else if(sentry || prob(STEALTH_LOOK_TURN_CHANCE)) guard.setDir(turn(controller.stand_dir, pick(STEALTH_LOOK_TURN_ARC, -STEALTH_LOOK_TURN_ARC))) + if(sentry) + controller.next_turn = world.time + STEALTH_SENTRY_GLANCE_TIME return AI_BEHAVIOR_DELAY #undef STEALTH_HANDLED_SIGNALS diff --git a/voidcrew/modules/stealth/stealth_light.dm b/voidcrew/modules/stealth/stealth_light.dm new file mode 100644 index 00000000000..4974e177df8 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_light.dm @@ -0,0 +1,82 @@ +/** + * # Stealth guards: flashlights (owner decision 31) + * + * A scav guard carries a real seclite clipped to its belt (or its vest, or a pocket). tg's own overlay + * light draws it, cast the way the guard faces, and adds to the lit turfs' dynamic_lumcount, which the + * darkness rule (stealth_tile_is_dark()) already reads. So the light shows a guard what it lights and + * nothing more: there is no "sees in the dark" rule. + * + * The guard switches it with the light's own toggle (its click and all): on when it stands somewhere dark, + * always on while suspicious, alert or searching, off in lit places while unaware so a lit patrol looks + * the same as before. It keeps it on for STEALTH_LIGHT_HOLD after it last wanted it, so walking along the + * edge of a lit room doesn't flick it on and off. + * + * Beating it is tg's: you see the beam coming; an EMP or the saboteur gun cuts it out for a while (the + * scav seclite takes an EMP as tg's saboteur hit; a stock seclite ignores EMPs); a guard that is down, + * stunned, cuffed, asleep or dead doesn't touch it. A light that is gone from its body (deleted, burnt, + * forced off) is gone: the guard goes without. Like the rest of its kit it is locked gear (human NPC + * decision D3), so it can't be stripped or looted. + */ + +/// A guard's seclite: an EMP blinds it for a while, as tg's saboteur gun does. +/obj/item/flashlight/seclite/scav + +/obj/item/flashlight/seclite/scav/emp_act(severity) + . = ..() + if(. & EMP_PROTECT_SELF) + return + on_saboteur(null, severity == EMP_HEAVY ? STEALTH_LIGHT_EMP_HEAVY : STEALTH_LIGHT_EMP_LIGHT) + +/mob/living/carbon/human/npc + /// Weakref to the flashlight a stealth guard switches on in the dark, or null for none + var/datum/weakref/stealth_light + +/// Clips a seclite on: belt, vest, then a pocket. Returns it, or null if there was nowhere to put it. +/mob/living/carbon/human/npc/proc/stealth_give_light() + var/obj/item/flashlight/seclite/scav/light = new(src) + for(var/slot in list(ITEM_SLOT_BELT, ITEM_SLOT_SUITSTORE, ITEM_SLOT_LPOCKET, ITEM_SLOT_RPOCKET)) + if(equip_to_slot_if_possible(light, slot, disable_warning = TRUE)) + stealth_light = WEAKREF(light) + return light + qdel(light) + return null + +/// How much `light` adds to `tile` right now (tg's overlay light: a flat share on every turf it reaches). +/proc/stealth_light_share(obj/item/flashlight/light, turf/tile) + if(!light?.light_on) + return 0 + var/datum/component/overlay_lighting/glow = light.GetComponent(/datum/component/overlay_lighting) + if(isnull(glow) || !(tile in glow.affected_turfs)) + return 0 + return glow.lum_power + +/datum/ai_controller/basic_controller/human_npc/stealth + /// world.time until which it keeps its light on after it last wanted it + var/light_hold_until = 0 + +/// Its flashlight, if it still has it on its body; else null. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_light() + var/mob/living/carbon/human/npc/guard = pawn + if(!ishumannpc(guard)) + return null + var/obj/item/flashlight/light = guard.stealth_light?.resolve() + if(QDELETED(light) || light.loc != guard) + return null + return light + +/// Switches its light on or off for where it stands and what it is doing. Does nothing while it can't use +/// its hands, while a player has the body, or while the light is cut out. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_update_light() + var/mob/living/carbon/human/npc/guard = pawn + if(QDELETED(guard) || guard.stat != CONSCIOUS || stealth_driven() || stealth_captive() || HAS_TRAIT(guard, TRAIT_HANDS_BLOCKED)) + return + var/obj/item/flashlight/light = stealth_light() + if(isnull(light) || !COOLDOWN_FINISHED(light, disabled_time)) + return + var/wanted = stealth_state() != STEALTH_UNAWARE || stealth_tile_is_dark(get_turf(guard), light) + if(wanted) + light_hold_until = world.time + STEALTH_LIGHT_HOLD + else if(world.time < light_hold_until) + return + if(wanted != light.light_on) + light.toggle_light(guard) diff --git a/voidcrew/modules/stealth/stealth_patrol.dm b/voidcrew/modules/stealth/stealth_patrol.dm index bcf40901622..e0c195ca91b 100644 --- a/voidcrew/modules/stealth/stealth_patrol.dm +++ b/voidcrew/modules/stealth/stealth_patrol.dm @@ -224,6 +224,8 @@ GLOBAL_VAR_INIT(stealth_group_count, 0) home_turf = spawn_turf sentry_dir = stealth_facing(guard) stand_dir = sentry_dir + // A sentry's first look aside comes after a full turn at its post, not on its first step. + next_turn = world.time + STEALTH_SENTRY_TURN_INTERVAL group = stealth_group_for(spawn_turf) if(isnull(group)) group = new(spawn_turf) @@ -255,6 +257,7 @@ GLOBAL_VAR_INIT(stealth_group_count, 0) home_turf = where sentry_dir = stealth_facing(pawn) stand_dir = sentry_dir + next_turn = world.time + STEALTH_SENTRY_TURN_INTERVAL /// Its route's stops, or null. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_stops() diff --git a/voidcrew/modules/stealth/stealth_perception.dm b/voidcrew/modules/stealth/stealth_perception.dm index acc23fd0ab9..713b8af189a 100644 --- a/voidcrew/modules/stealth/stealth_perception.dm +++ b/voidcrew/modules/stealth/stealth_perception.dm @@ -57,18 +57,21 @@ GLOBAL_LIST_EMPTY(stealth_test_dark_turfs) * Whether `tile` is dark enough to hide in. A turf with no lighting object (planet ground lit only by its * area's ambient light) reads its area's base light, which get_lumcount() skips (it returns 1 there). * Same rule as the bounty AI's ai_tile_is_dark() (bounty_ai_meek.dm), which is a type proc. + * A flashlight's light counts like any other (tg adds it to dynamic_lumcount). `own_light` leaves out what + * that one light adds, so a guard can tell whether it needs its own (stealth_light.dm). */ -/proc/stealth_tile_is_dark(turf/tile) +/proc/stealth_tile_is_dark(turf/tile, obj/item/flashlight/own_light) if(!isturf(tile)) return FALSE #ifdef UNIT_TESTS if(tile in GLOB.stealth_test_dark_turfs) return GLOB.stealth_test_dark_turfs[tile] #endif + var/own = own_light ? stealth_light_share(own_light, tile) : 0 if(!tile.lighting_object) var/area/tile_area = tile.loc - return (tile_area.base_lighting_alpha / 255) + tile.dynamic_lumcount < STEALTH_DARK_LUMCOUNT - return tile.get_lumcount() < STEALTH_DARK_LUMCOUNT + return (tile_area.base_lighting_alpha / 255) + tile.dynamic_lumcount - own < STEALTH_DARK_LUMCOUNT + return tile.get_lumcount() - own < STEALTH_DARK_LUMCOUNT /** * What `who` is shut inside, as it stands on a turf: the box, locker, bag or car, or the outermost of them. diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index ccab4290d6d..db8e9a41f4e 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -236,6 +236,7 @@ #include "voidcrew_smart_locker.dm" #include "voidcrew_stealth.dm" #include "voidcrew_stealth_hearing.dm" +#include "voidcrew_stealth_light.dm" #include "voidcrew_survey_archive.dm" #include "voidcrew_survey_capabilities.dm" #include "voidcrew_survey_identity.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_hearing.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_hearing.dm index 641f866b05b..d5fc0bfddbe 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_hearing.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_hearing.dm @@ -186,11 +186,11 @@ TEST_ASSERT_EQUAL(second.dir, WEST, "A glancing guard didn't turn to the noise") // The same noise at once is the same noise. TEST_ASSERT_EQUAL(stealth_noise(spot, "knock"), 0, "The same noise in the same moment was heard twice") - group.rewind(2 SECONDS) + group.rewind(4 SECONDS) stealth_noise(spot, "knock") TEST_ASSERT_EQUAL(second_ai.stealth_state(), "suspicious", "Two guards didn't go to the second noise") TEST_ASSERT_EQUAL(third_ai.stealth_state(), "unaware", "Three guards went to the second noise") - group.rewind(2 SECONDS) + group.rewind(4 SECONDS) stealth_noise(spot, "knock") for(var/mob/living/guard as anything in list(first, second, third)) TEST_ASSERT_EQUAL(state_of(guard), "searching", "Not every guard searched at the third noise") @@ -198,7 +198,7 @@ // Ten tiles off it is a new spot. for(var/mob/living/guard as anything in list(first, second, third)) settle(guard) - group.rewind(2 SECONDS) + group.rewind(4 SECONDS) TEST_ASSERT_EQUAL(stealth_noise(at(15, 1), "glass"), 2, "A smash 6 and 8 tiles off wasn't heard by two") TEST_ASSERT_EQUAL(third_ai.stealth_state(), "suspicious", "Nobody went to a noise somewhere new") TEST_ASSERT_EQUAL(second_ai.stealth_state(), "unaware", "Two went to the first noise at a new spot") @@ -290,7 +290,7 @@ for(var/round_number in 2 to 3) for(var/mob/living/guard as anything in route_guards + sentries) settle(guard) - group.rewind(2 SECONDS) + group.rewind(4 SECONDS) stealth_noise(spot, "gun_long") searching = 0 for(var/mob/living/guard as anything in route_guards) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm new file mode 100644 index 00000000000..4b1f5045302 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm @@ -0,0 +1,204 @@ +// Stealth guards: flashlights, elbow-to-elbow sight, volleys and sentry facing (owner decision 31, +// voidcrew/modules/stealth/stealth_light.dm). Values from voidcrew/_DEFINES are written out: STEALTH_LIGHT_HOLD +// 5 s, STEALTH_NOISE_COALESCE 3 s, STEALTH_SENTRY_TURN_INTERVAL 8 s, STEALTH_SENTRY_GLANCE_TIME 2 s. + +/// The guard switches its seclite on in the dark and while on edge, off in the light, and can't while it is cut out. +/datum/unit_test/voidcrew_stealth_light_switch + +/datum/unit_test/voidcrew_stealth_light_switch/Run() + var/datum/turf_reservation/block = stealth_block(9, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/obj/item/flashlight/light = stealth_ai.stealth_light() + TEST_ASSERT_NOTNULL(light, "A scav guard has no flashlight on its body") + TEST_ASSERT(!light.light_on, "A guard's light starts on") + var/turf/here = get_turf(guard) + stealth_ai.stealth_update_light() + TEST_ASSERT(!light.light_on, "An unaware guard in the light switched its light on") + GLOB.stealth_test_dark_turfs[here] = TRUE + stealth_ai.stealth_update_light() + TEST_ASSERT(light.light_on, "A guard standing in the dark didn't switch its light on") + // Back in the light it keeps it on a moment, then switches it off. + GLOB.stealth_test_dark_turfs[here] = FALSE + stealth_ai.stealth_update_light() + TEST_ASSERT(light.light_on, "A guard switched its light off the moment it stepped into the light") + stealth_ai.light_hold_until = 0 + stealth_ai.stealth_update_light() + TEST_ASSERT(!light.light_on, "An unaware guard in the light kept its light on") + // On edge, it is on even in the light. + stealth_ai.stealth_go_suspicious(stealth_at(block, 6, 2)) + TEST_ASSERT(light.light_on, "A suspicious guard's light isn't on") + stealth_ai.stealth_go_searching(stealth_at(block, 6, 2)) + TEST_ASSERT(light.light_on, "A searching guard's light isn't on") + stealth_ai.stealth_go_unaware() + stealth_ai.light_hold_until = 0 + stealth_ai.stealth_update_light() + TEST_ASSERT(!light.light_on, "A calm guard in the light kept its light on") + // An EMP cuts it out, and the guard can't switch it back on until it recovers. + GLOB.stealth_test_dark_turfs[here] = TRUE + stealth_ai.stealth_update_light() + TEST_ASSERT(light.light_on, "The light didn't come on in the dark") + guard.emp_act(EMP_LIGHT) + TEST_ASSERT(!light.light_on, "An EMP didn't cut the guard's light out") + stealth_ai.stealth_update_light() + TEST_ASSERT(!light.light_on, "A guard switched an EMP'd light straight back on") + light.disabled_time = 0 + stealth_ai.stealth_update_light() + TEST_ASSERT(light.light_on, "The light didn't come back on once the EMP wore off") + // Gone from its body, it goes without. + light.forceMove(stealth_at(block, 4, 4)) + TEST_ASSERT_NULL(stealth_ai.stealth_light(), "A guard still counts a light that left its body") + GLOB.stealth_test_dark_turfs[here] = FALSE + qdel(block) + +/// Real lighting: in a dark room the guard sees someone 5 tiles ahead only by its own light. +/datum/unit_test/voidcrew_stealth_light_sight + +/datum/unit_test/voidcrew_stealth_light_sight/Run() + var/datum/turf_reservation/block = stealth_block(12, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + stealth_unlist(block, 12, 5) + var/mob/living/carbon/human/person = stealth_person(block, 6, 2) + var/turf/spot = get_turf(person) + TEST_ASSERT(stealth_tile_is_dark(spot), "Reserved test space isn't dark, so the light can't be tested") + // Without a light: 5 tiles off in the dark is past sight. + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 1, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + qdel(stealth_ai.stealth_light()) + stealth_scans(guard, 5) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard with no light saw someone 5 tiles off in the dark") + qdel(guard) + // With one: it switches it on, the light reaches them, and it notices them. + guard = stealth_guard(block, 1, 2) + stealth_ai = stealth_ai(guard) + var/obj/item/flashlight/light = stealth_ai.stealth_light() + stealth_ai.stealth_update_light() + TEST_ASSERT(light.light_on, "A guard standing in the dark didn't switch its light on") + TEST_ASSERT(!stealth_tile_is_dark(spot), "The guard's light doesn't reach 5 tiles ahead") + TEST_ASSERT(stealth_tile_is_dark(get_turf(guard), light), "A guard counts its own light as the room's") + stealth_scans(guard, 5) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "suspicious", "A guard didn't notice someone its light was on") + qdel(guard) + qdel(block) + +/// Real lighting: a searching guard finds a body in the dark by its light. +/datum/unit_test/voidcrew_stealth_light_body + +/datum/unit_test/voidcrew_stealth_light_body/Run() + var/datum/turf_reservation/block = stealth_block(12, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + stealth_unlist(block, 12, 5) + allocate(/obj/effect/landmark/stealth_group, stealth_at(block, 7, 4)) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 1, 2) + var/mob/living/carbon/human/npc/friend = stealth_guard(block, 6, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/datum/ai_controller/basic_controller/human_npc/stealth/friend_ai = stealth_ai(friend) + stealth_ai.stealth_setup() + friend_ai.stealth_setup() + qdel(friend_ai.stealth_light()) + friend.death() + TEST_ASSERT(stealth_tile_is_dark(get_turf(friend)), "Reserved test space isn't dark, so the light can't be tested") + // Its light cut out, it searches past the body 5 tiles off in the dark. + var/obj/item/flashlight/light = stealth_ai.stealth_light() + light.on_saboteur(null, 1 MINUTES) + stealth_ai.stealth_go_searching(get_turf(guard)) + stealth_ai.stealth_check_bodies() + TEST_ASSERT(!(REF(friend) in stealth_ai.blackboard["stealth_bodies_seen"]), "A guard saw a body 5 tiles off in the dark without a light") + // With it on, it finds it. + light.disabled_time = 0 + stealth_ai.stealth_update_light() + TEST_ASSERT(light.light_on, "A searching guard's light didn't come on") + stealth_ai.next_body_scan = 0 + stealth_ai.stealth_check_bodies() + TEST_ASSERT(REF(friend) in stealth_ai.blackboard["stealth_bodies_seen"], "A searching guard with its light on didn't find the body") + TEST_ASSERT(get_dist(stealth_ai.search_center, friend) <= 1, "The search didn't move to the body") + TEST_ASSERT(stealth_ai.search_for_body, "The search isn't marked as over a body") + qdel(block) + +/// Elbow to elbow: someone on the next tile in front is seen in the dark; behind or side-on is not. +/datum/unit_test/voidcrew_stealth_adjacent + +/datum/unit_test/voidcrew_stealth_adjacent/Run() + var/datum/turf_reservation/block = stealth_block(7, 7) + TEST_ASSERT_NOTNULL(block, "No room for the test") + for(var/dx in 0 to 6) + for(var/dy in 0 to 6) + GLOB.stealth_test_dark_turfs[stealth_at(block, dx, dy)] = TRUE + var/mob/living/carbon/human/person = stealth_person(block, 4, 3) + // offset from the guard => whether two scans make it suspicious + var/list/cases = list( + list(1, 0, TRUE), + list(-1, 0, FALSE), + list(0, 1, FALSE), + list(2, 0, FALSE), + ) + for(var/list/test_case as anything in cases) + person.forceMove(stealth_at(block, 3 + test_case[1], 3 + test_case[2])) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 3, 3) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + stealth_scans(guard, 2) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state() == "suspicious", test_case[3], "Offset ([test_case[1]], [test_case[2]]) in the dark: state [stealth_ai.stealth_state()]") + qdel(guard) + for(var/dx in 0 to 6) + for(var/dy in 0 to 6) + GLOB.stealth_test_dark_turfs[stealth_at(block, dx, dy)] = FALSE + qdel(block) + +/// Takes a test block's turfs off the test light list, so they read the real light. +/datum/unit_test/proc/stealth_unlist(datum/turf_reservation/block, width, height) + for(var/dx in 0 to width - 1) + for(var/dy in 0 to height - 1) + GLOB.stealth_test_dark_turfs -= stealth_at(block, dx, dy) + +/// A quick volley from one spot is one noise; the same gun 3 s later is a new one; a loud gun still alarms. +/datum/unit_test/voidcrew_stealth_live/hear/volley + +/datum/unit_test/voidcrew_stealth_live/hear/volley/Run() + TEST_ASSERT(hear_room(20, 3), "No room for the test") + var/mob/living/carbon/human/npc/first = walker(5, 1) + var/mob/living/carbon/human/npc/second = walker(7, 1) + var/datum/ai_controller/basic_controller/human_npc/stealth/first_ai = first.ai_controller + var/datum/stealth_group/group = first_ai.group + var/turf/spot = at(4, 1) + TEST_ASSERT(stealth_noise(spot, "gun_quiet") > 0, "A suppressed shot a tile off wasn't heard") + for(var/i in 1 to 2) + group.rewind(0.5 SECONDS) + TEST_ASSERT_EQUAL(stealth_noise(spot, "gun_quiet"), 0, "Shot [i + 1] of a volley counted as a new noise") + TEST_ASSERT_EQUAL(group.lure_count(spot), 1, "A volley counted as more than one lure") + TEST_ASSERT_EQUAL(state_of(second), "unaware", "A volley sent a second guard") + // A loud gun from the same spot is still an alarm. + TEST_ASSERT(stealth_noise(spot, "gun_long") > 0, "A rifle after the volley wasn't heard") + TEST_ASSERT_EQUAL(state_of(second), "searching", "A rifle shot after a quiet volley didn't send the guards running") + // The same quiet gun later is a new noise. + settle(first) + settle(second) + group.rewind(3.5 SECONDS) + TEST_ASSERT(stealth_noise(spot, "gun_quiet") > 0, "A shot 3.5 s after the volley was merged into it") + no_targets(list(first, second)) + +/// A sentry faces the way it was placed, glancing aside only now and then. +/datum/unit_test/voidcrew_stealth_live/sentry_facing + +/datum/unit_test/voidcrew_stealth_live/sentry_facing/Run() + TEST_ASSERT(make_room(14, 5), "No room for the test") + person_at(13, 4) + var/mob/living/carbon/human/npc/guard = guard_at(1, 2, SOUTH) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = wake(guard) + var/deadline = world.time + 10 SECONDS + while(!stealth_ai.stealth_ready && world.time < deadline) + sleep(1) + TEST_ASSERT(stealth_ai.stealth_ready, "The sentry never planned") + sleep(1 SECONDS) + TEST_ASSERT_NULL(stealth_ai.route_id, "A guard with no stop near it claimed a route") + TEST_ASSERT_EQUAL(stealth_ai.sentry_dir, SOUTH, "A sentry placed facing south took [dir2text(stealth_ai.sentry_dir)] as its post") + TEST_ASSERT_EQUAL(guard.dir, SOUTH, "A sentry placed facing south faces [dir2text(guard.dir)] a second later") + var/total = 0 + var/count = 0 + for(var/i in 1 to 24) + sleep(0.5 SECONDS) + total++ + if(guard.dir == SOUTH) + count++ + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "The sentry was disturbed during the test") + TEST_ASSERT(count >= total * 0.7, "A sentry faced its post only [count] of [total] looks over 12 s") From 0237c3ad2045a818827b7eda8152229b6770828a Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Tue, 10 Nov 2026 17:45:05 -0800 Subject: [PATCH 19/78] Guards react at once to someone right in front, stay blind behind in the dark, and stop flickering lights Point-blank sight within 2 tiles in the cone is an alert on that look, with a quick look between scans; 3-4 tiles fill three times faster. The close radius behind a guard needs light that isn't its own beam. A guard's own spot is judged without any guard seclites. No missing-friend line over a reported body. An AI-switched light is re-laid as a turn would. Diagonal AI steps cost what a player's do. The test room's east room gets a floor light in the middle. --- .../JungleRuins/jungle_stealth_test.dmm | 6 +- voidcrew/_DEFINES/stealth.dm | 5 + voidcrew/modules/stealth/stealth_ai.dm | 106 +++++++++- voidcrew/modules/stealth/stealth_light.dm | 37 +++- voidcrew/modules/stealth/stealth_noise.dm | 4 + .../modules/stealth/stealth_perception.dm | 15 +- voidcrew/modules/unit_tests/_unit_tests.dm | 1 + .../modules/unit_tests/voidcrew_stealth.dm | 10 +- .../unit_tests/voidcrew_stealth_d32.dm | 189 ++++++++++++++++++ .../unit_tests/voidcrew_stealth_light.dm | 15 +- 10 files changed, 366 insertions(+), 22 deletions(-) create mode 100644 voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm diff --git a/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm index b802a996b66..e3d43e91751 100644 --- a/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm +++ b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm @@ -113,6 +113,10 @@ "x" = ( /turf/open/floor/iron, /area/ruin/powered) +"y" = ( +/obj/machinery/light/floor, +/turf/open/floor/iron, +/area/ruin/powered) "z" = ( /obj/structure/table, /turf/open/floor/iron, @@ -678,7 +682,7 @@ x x x x -x +y x x x diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index fe6fb0255b3..6b6431e79c8 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -55,6 +55,11 @@ #define STEALTH_CLOSE_RANGE 2 /// Elbow to elbow: someone this close in its cone is seen whatever the light (decision 31) #define STEALTH_ADJACENT_RANGE 1 +/// Point-blank (decision 32): someone it can see in its cone this close is an alert on that look +#define STEALTH_POINT_BLANK_RANGE 2 +/// Near (decision 32): in its cone up to this far, notice fills STEALTH_NEAR_MULT times faster +#define STEALTH_NEAR_RANGE 4 +#define STEALTH_NEAR_MULT 3 #define STEALTH_CONE_HALF_ANGLE 60 #define STEALTH_WARY_HALF_ANGLE 75 #define STEALTH_SEARCH_HALF_ANGLE 90 diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index 37d7c475a88..6db4c27db10 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -152,6 +152,8 @@ var/next_switch_at = 0 /// world.time of its next scan var/next_scan = 0 + /// The turf its last AI step ended on, to tell a diagonal step (stealth_step_cost()) + var/turf/last_step_turf /// world.time of its next look for fallen friends var/next_body_scan = 0 /// Whether its search is over a fallen friend (it doesn't end it with "Nothing.") @@ -305,7 +307,7 @@ stealth_drop_walk() if(!stealth_driven()) stealth_set_pace(new_state == STEALTH_ALERT || new_state == STEALTH_SEARCHING) - human_npc_set_ai_movement(src, new_state == STEALTH_ALERT ? /datum/ai_movement/basic_avoidance : /datum/ai_movement/jps/stealth) + human_npc_set_ai_movement(src, new_state == STEALTH_ALERT ? /datum/ai_movement/basic_avoidance/stealth : /datum/ai_movement/jps/stealth) stealth_update_light() for(var/datum/stealth_sight_overlay/overlay as anything in watchers) overlay.refresh() @@ -636,6 +638,11 @@ var/list/was_hidden = hidden_spots var/list/now_hidden var/judged = 0 + // Someone it plainly sees within STEALTH_POINT_BLANK_RANGE: an alert on this look (decision 32). Nearest first. + var/mob/living/point_blank + // The close radius out of its cone works by the light that is there, not by its own beam (decision 32). + var/obj/item/flashlight/own_light = stealth_light() + var/night_vision = HAS_TRAIT(guard, TRAIT_NIGHT_VISION) for(var/mob/living/candidate as anything in stealth_candidates(guard, HUMAN_NPC_SIGHT_RANGE)) // Only those it could perceive count toward the cap, so bystanders it can't see never crowd a player out. if(judged >= STEALTH_MAX_CANDIDATES) @@ -679,6 +686,7 @@ continue judged++ var/rate = 0 + var/plain_sight = FALSE if(boxed) rate = STEALTH_NOTICE_RATE else if(eyes && !stealth_is_cloaked(candidate) && stealth_in_cone(guard, where, half_angle)) @@ -689,8 +697,13 @@ rate = STEALTH_NOTICE_RATE * clamp((cap + 1 - dist) / cap, STEALTH_NOTICE_MIN_FALLOFF, 1) if(cap < STEALTH_SIGHT_RANGE) rate *= STEALTH_DARK_MULT - if(!rate && dist <= STEALTH_CLOSE_RANGE) - // At its shoulder: light doesn't matter (abuse P7). + // Close in front of it, seen plainly: no slow double take (decision 32). + plain_sight = cap == STEALTH_SIGHT_RANGE && dist <= STEALTH_POINT_BLANK_RANGE + if(dist <= STEALTH_NEAR_RANGE) + rate *= STEALTH_NEAR_MULT + if(!rate && dist <= STEALTH_CLOSE_RANGE && (night_vision || !stealth_tile_is_dark(where, own_light))) + // At its shoulder, in light that is there anyway (abuse P7). Its own beam points ahead, so it + // doesn't count here: someone standing still right behind it in the dark is not seen (decision 32). rate = STEALTH_BEHIND_RATE if(!rate) continue @@ -712,6 +725,10 @@ rate *= STEALTH_WARY_MULT wary_at = world.time entry[STEALTH_ENTRY_NOTICE] = min(entry[STEALTH_ENTRY_NOTICE] + rate * scan_seconds, STEALTH_NOTICE_MAX) + if(plain_sight) + entry[STEALTH_ENTRY_NOTICE] = STEALTH_NOTICE_MAX + if(isnull(point_blank)) + point_blank = candidate entry[STEALTH_ENTRY_TURF] = where entry[STEALTH_ENTRY_SEEN_AT] = world.time perceived[key] = candidate @@ -744,6 +761,9 @@ if(alert) stealth_weigh_switch(perceived, strategy) return + if(point_blank) + stealth_spot_point_blank(point_blank) + return // Whoever it sees now decides what it does; a higher entry it can't see no longer speaks for them. var/judged_key = seen_key || best_key if(isnull(judged_key)) @@ -791,6 +811,50 @@ if(calm_until || (new_center && get_dist(new_center, search_center) > 1)) stealth_go_searching(best_turf) +/// Someone it plainly sees right in front of it: it turns on them and fights now, no double take (decision 32). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_spot_point_blank(mob/living/who) + var/mob/living/guard = pawn + stealth_go_alert(who) + if(stealth_state() == STEALTH_ALERT && !QDELETED(guard) && !QDELETED(who)) + guard.face_atom(who) + +/** + * Between scans (planning runs every half second, the scan once a second): someone it plainly sees within + * STEALTH_POINT_BLANK_RANGE is an alert now, not at the next scan. The same rules as the point-blank part of + * stealth_look(): eyes open, not cloaked, on a turf of their own, in its cone, and lit or at its elbow. + * One spatial grid lookup of two tiles; nothing else. Returns TRUE if it went alert. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_quick_look() + var/mob/living/carbon/human/guard = pawn + if(QDELETED(guard) || guard.stat != CONSCIOUS || guard.client || !isturf(guard.loc) || stealth_state() == STEALTH_ALERT) + return FALSE + if(!stealth_eyes_open()) + return FALSE + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) + if(isnull(strategy)) + return FALSE + var/half_angle = stealth_half_angle() + for(var/mob/living/candidate as anything in stealth_candidates(guard, STEALTH_POINT_BLANK_RANGE)) + var/turf/where = candidate.loc + if(!isturf(where) || stealth_is_cloaked(candidate) || !stealth_in_cone(guard, where, half_angle)) + continue + var/dist = get_dist(guard, where) + if(dist > STEALTH_ADJACENT_RANGE && stealth_range_onto(where) < STEALTH_SIGHT_RANGE) + continue + if(!strategy.can_attack(guard, candidate, STEALTH_SIGHT_RANGE)) + continue + var/key = REF(candidate) + var/list/entry = notice_map[key] + if(isnull(entry)) + entry = list(0, null, 0) + notice_map[key] = entry + entry[STEALTH_ENTRY_NOTICE] = STEALTH_NOTICE_MAX + entry[STEALTH_ENTRY_TURF] = where + entry[STEALTH_ENTRY_SEEN_AT] = world.time + stealth_spot_point_blank(candidate) + return TRUE + return FALSE + /** * Alert: whether to turn on someone else it has noticed. They must be at alert-level notice, in reach, and * either clearly nearer than its target or in view while the target is not. Never more than once per @@ -1210,6 +1274,35 @@ /datum/ai_movement/jps/stealth maximum_length = STEALTH_PATROL_MAX_PATH +/datum/ai_movement/jps/stealth/post_move(datum/move_loop/source, succeeded) + . = ..() + stealth_step_cost(source) + +/// tg's plain chase movement, with a diagonal step costing what it costs a player. +/datum/ai_movement/basic_avoidance/stealth + +/datum/ai_movement/basic_avoidance/stealth/post_move(datum/move_loop/source, succeeded) + . = ..() + stealth_step_cost(source) + +/** + * A player's diagonal step waits sqrt(2) times their move delay (tg's client Move()); tg's AI move loops wait + * the plain delay whatever the step, so a guard cutting corners outran a player at the same run speed + * (decision 32, fix 7). After a diagonal step, the loop waits as long as a player would. + */ +/proc/stealth_step_cost(datum/move_loop/source) + var/datum/ai_controller/basic_controller/human_npc/stealth/controller = source.extra_info + var/atom/movable/moving = source.moving + if(!istype(controller) || QDELETED(moving)) + return + var/turf/now = get_turf(moving) + var/turf/before = controller.last_step_turf + controller.last_step_turf = now + if(isnull(before) || isnull(now) || before == now || before.z != now.z || get_dist(before, now) != 1) + return + if(before.x != now.x && before.y != now.y) + source.delay = controller.movement_delay * sqrt(2) + /** * Runs the scan once a second, straight from planning: it never waits in the behaviour queue, where a walk * or tg's idle mode could starve it or be starved by it. First in the list, and never ends planning. With @@ -1224,8 +1317,13 @@ QDEL_NULL(controller.meter) return controller.stealth_setup() - if(world.time >= controller.next_scan && !controller.blackboard_key_exists(BB_HUMAN_NPC_EXIT)) + if(controller.blackboard_key_exists(BB_HUMAN_NPC_EXIT)) + return + if(world.time >= controller.next_scan) controller.stealth_scan_once() + else + // Someone stepping in front of it doesn't wait up to a second for the next scan (decision 32). + controller.stealth_quick_look() /// Suspicious: stare, walk over, look round. Searching: sweep the spots. Ends planning while it acts. /datum/ai_planning_subtree/stealth_react diff --git a/voidcrew/modules/stealth/stealth_light.dm b/voidcrew/modules/stealth/stealth_light.dm index 4974e177df8..58171b43193 100644 --- a/voidcrew/modules/stealth/stealth_light.dm +++ b/voidcrew/modules/stealth/stealth_light.dm @@ -18,9 +18,20 @@ * decision D3), so it can't be stripped or looted. */ +/// Every guard's seclite, so a guard can leave them all out when it judges how dark its spot is +GLOBAL_LIST_EMPTY(stealth_guard_lights) + /// A guard's seclite: an EMP blinds it for a while, as tg's saboteur gun does. /obj/item/flashlight/seclite/scav +/obj/item/flashlight/seclite/scav/Initialize(mapload) + . = ..() + GLOB.stealth_guard_lights += src + +/obj/item/flashlight/seclite/scav/Destroy() + GLOB.stealth_guard_lights -= src + return ..() + /obj/item/flashlight/seclite/scav/emp_act(severity) . = ..() if(. & EMP_PROTECT_SELF) @@ -73,10 +84,34 @@ var/obj/item/flashlight/light = stealth_light() if(isnull(light) || !COOLDOWN_FINISHED(light, disabled_time)) return - var/wanted = stealth_state() != STEALTH_UNAWARE || stealth_tile_is_dark(get_turf(guard), light) + // Its own spot judged by the room's light alone: a friend's passing beam doesn't switch it off (decision 32). + var/wanted = stealth_state() != STEALTH_UNAWARE || stealth_tile_is_dark(get_turf(guard), light, no_guard_lights = TRUE) if(wanted) light_hold_until = world.time + STEALTH_LIGHT_HOLD else if(world.time < light_hold_until) return if(wanted != light.light_on) light.toggle_light(guard) + if(light.light_on) + stealth_redraw_light(light) + +/** + * After switching it on: has tg's light lay its beam out again, as it does when the guard turns. The fl_sentry + * clip (decision 32) caught a light that read on but drew nothing until the guard next turned; turning re-runs + * this same update. Done now and again a tick later, so a facing change in the same tick can't race it. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_redraw_light(obj/item/flashlight/light) + stealth_relay_light(light) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(stealth_relay_light), light), 1) + +/// Re-lays an overlay light that is on: the holder check, then the beam and the lit turfs, as a turn would. +/proc/stealth_relay_light(obj/item/flashlight/light) + if(QDELETED(light) || !light.light_on) + return + var/datum/component/overlay_lighting/glow = light.GetComponent(/datum/component/overlay_lighting) + // (1<<0) is tg's LIGHTING_ON, which overlay_lighting.dm undefines at its end. + if(isnull(glow) || !(glow.overlay_lighting_flags & (1<<0))) + return + glow.recheck_holder() + if(glow.current_holder) + glow.make_luminosity_update() diff --git a/voidcrew/modules/stealth/stealth_noise.dm b/voidcrew/modules/stealth/stealth_noise.dm index 1ff6aabe530..99e25ca69ec 100644 --- a/voidcrew/modules/stealth/stealth_noise.dm +++ b/voidcrew/modules/stealth/stealth_noise.dm @@ -445,6 +445,10 @@ var/mob/living/carbon/human/npc/gone = check.who?.resolve() var/datum/ai_controller/basic_controller/human_npc/stealth/gone_ai = gone?.ai_controller var/down = QDELETED(gone) || !istype(gone_ai) || gone.stat != CONSCIOUS || HAS_TRAIT(gone, TRAIT_RESTRAINED) + // Already found and called out as a body: nobody asks where it got to (decision 32). + if(down && !QDELETED(gone) && (REF(gone) in reported_bodies)) + checks -= check + continue if(!down) var/state = gone_ai.stealth_state() if(state == STEALTH_UNAWARE || state == STEALTH_ALERT) diff --git a/voidcrew/modules/stealth/stealth_perception.dm b/voidcrew/modules/stealth/stealth_perception.dm index 713b8af189a..65d563afc90 100644 --- a/voidcrew/modules/stealth/stealth_perception.dm +++ b/voidcrew/modules/stealth/stealth_perception.dm @@ -58,16 +58,25 @@ GLOBAL_LIST_EMPTY(stealth_test_dark_turfs) * area's ambient light) reads its area's base light, which get_lumcount() skips (it returns 1 there). * Same rule as the bounty AI's ai_tile_is_dark() (bounty_ai_meek.dm), which is a type proc. * A flashlight's light counts like any other (tg adds it to dynamic_lumcount). `own_light` leaves out what - * that one light adds, so a guard can tell whether it needs its own (stealth_light.dm). + * that one light adds: a guard's own beam never lights the tile behind it (decision 32). `no_guard_lights` + * leaves out every guard's seclite, so a guard deciding whether its spot needs a light judges by the room's + * own light, not by a friend walking past with one (decision 32: no flicker when guards meet). */ -/proc/stealth_tile_is_dark(turf/tile, obj/item/flashlight/own_light) +/proc/stealth_tile_is_dark(turf/tile, obj/item/flashlight/own_light, no_guard_lights = FALSE) if(!isturf(tile)) return FALSE #ifdef UNIT_TESTS if(tile in GLOB.stealth_test_dark_turfs) return GLOB.stealth_test_dark_turfs[tile] #endif - var/own = own_light ? stealth_light_share(own_light, tile) : 0 + var/own = 0 + if(no_guard_lights) + for(var/obj/item/flashlight/guard_light as anything in GLOB.stealth_guard_lights) + own += stealth_light_share(guard_light, tile) + if(own_light && !(own_light in GLOB.stealth_guard_lights)) + own += stealth_light_share(own_light, tile) + else if(own_light) + own = stealth_light_share(own_light, tile) if(!tile.lighting_object) var/area/tile_area = tile.loc return (tile_area.base_lighting_alpha / 255) + tile.dynamic_lumcount - own < STEALTH_DARK_LUMCOUNT diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index db8e9a41f4e..4382f84b5fc 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -235,6 +235,7 @@ #include "voidcrew_slime_extract_piles.dm" #include "voidcrew_smart_locker.dm" #include "voidcrew_stealth.dm" +#include "voidcrew_stealth_d32.dm" #include "voidcrew_stealth_hearing.dm" #include "voidcrew_stealth_light.dm" #include "voidcrew_survey_archive.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth.dm b/voidcrew/modules/unit_tests/voidcrew_stealth.dm index 4b5dd0f34c6..3f6ffd357a6 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth.dm @@ -96,14 +96,12 @@ stealth_scans(guard, 10) TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard noticed someone standing 3 tiles behind it") qdel(guard) - // In front, 2 tiles. + // In front, 2 tiles, lit: an alert on the first look (decision 32). guard = stealth_guard(block, 6, 2) stealth_ai = stealth_ai(guard) person.forceMove(stealth_at(block, 8, 2)) - stealth_scans(guard, 2) - TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "suspicious", "A guard wasn't suspicious of someone 2 tiles in front after two scans") - stealth_scans(guard, 2) - TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard wasn't alert on someone 2 tiles in front after four scans") + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard wasn't alert on someone 2 tiles in front after one scan") TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], person, "The alert guard has no target") qdel(guard) // In front, 6 tiles, dark. @@ -508,7 +506,7 @@ var/mob/living/basic/mouse/mouse = allocate(/mob/living/basic/mouse, stealth_at(block, 3, 2)) mouse.faction = list("scav") // FACTION_SCAV stealth_person(block, 5, 2) - stealth_scans(guard, 3) + stealth_scans(guard, 1) TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "suspicious", "A crowd of its own side hid someone 3 tiles in front of a guard") qdel(block) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm new file mode 100644 index 00000000000..a3a30f04c60 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm @@ -0,0 +1,189 @@ +// Stealth guards, owner decision 32 (voidcrew/modules/stealth/): point-blank sight, behind in the dark, the overdue +// line over a body already reported, guards' lights ignoring each other, and a running guard's pace. Values from +// voidcrew/_DEFINES are written out: STEALTH_POINT_BLANK_RANGE 2, STEALTH_NEAR_RANGE 4, STEALTH_NEAR_MULT 3, +// STEALTH_ALERT_AT 2.5, STEALTH_LIGHT_HOLD 5 s. States are written as text: "unaware", "suspicious", "alert". + +/// Point-blank: seen plainly within 2 tiles in front is an alert on that look; 3-4 tiles fill fast; further is as before. +/datum/unit_test/voidcrew_stealth_point_blank + +/datum/unit_test/voidcrew_stealth_point_blank/Run() + var/datum/turf_reservation/block = stealth_block(12, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/person = stealth_person(block, 0, 0) + // Lit, one and two tiles ahead (and two ahead, one aside): alert on the first scan, after them. + for(var/list/offset as anything in list(list(1, 0), list(2, 0), list(2, 1))) + person.forceMove(stealth_at(block, 2 + offset[1], 2 + offset[2])) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "Someone at offset ([offset[1]], [offset[2]]) in the light wasn't an alert on the first look") + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], person, "A point-blank alert has no target") + qdel(guard) + // Three ahead: suspicious on the first look, alert on the second. + person.forceMove(stealth_at(block, 5, 2)) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "suspicious", "Someone 3 tiles ahead in the light: [stealth_ai.stealth_state()] after one look") + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "Someone 3 tiles ahead in the light: [stealth_ai.stealth_state()] after two looks") + qdel(guard) + // Six ahead: unchanged (0.375 a look, so one look is not suspicious). + person.forceMove(stealth_at(block, 8, 2)) + guard = stealth_guard(block, 2, 2) + stealth_ai = stealth_ai(guard) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "Someone 6 tiles ahead was noticed in one look") + qdel(guard) + // Two ahead in the dark (not at its elbow): no instant alert. + var/turf/dark = stealth_at(block, 4, 2) + GLOB.stealth_test_dark_turfs[dark] = TRUE + person.forceMove(dark) + guard = stealth_guard(block, 2, 2) + stealth_ai = stealth_ai(guard) + stealth_scans(guard, 1) + TEST_ASSERT(stealth_ai.stealth_state() != "alert", "Someone 2 tiles ahead in the dark was an alert on the first look") + GLOB.stealth_test_dark_turfs[dark] = FALSE + qdel(guard) + // Between scans: someone who steps in front of it is an alert without waiting for the next scan. + person.forceMove(stealth_at(block, 1, 2)) + guard = stealth_guard(block, 2, 2) + stealth_ai = stealth_ai(guard) + stealth_scans(guard, 1) + TEST_ASSERT(stealth_ai.next_scan > world.time, "The scan didn't set its next time") + TEST_ASSERT(!stealth_ai.stealth_quick_look(), "The quick look saw someone behind it") + person.forceMove(stealth_at(block, 3, 2)) + TEST_ASSERT(stealth_ai.stealth_quick_look(), "The quick look missed someone a tile in front") + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "The quick look didn't make it alert") + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], person, "The quick look's alert has no target") + qdel(guard) + qdel(block) + +/// Real lighting: standing still right behind a guard in the dark, its own light on, is never seen; two ahead is. +/datum/unit_test/voidcrew_stealth_behind_dark + +/datum/unit_test/voidcrew_stealth_behind_dark/Run() + var/datum/turf_reservation/block = stealth_block(9, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + stealth_unlist(block, 9, 5) + var/mob/living/carbon/human/person = stealth_person(block, 3, 2) + var/turf/behind = get_turf(person) + TEST_ASSERT(stealth_tile_is_dark(behind), "Reserved test space isn't dark, so the light can't be tested") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 4, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/obj/item/flashlight/light = stealth_ai.stealth_light() + TEST_ASSERT_NOTNULL(light, "A scav guard has no flashlight") + stealth_ai.stealth_update_light() + TEST_ASSERT(light.light_on, "A guard in the dark didn't switch its light on") + // The trap this guards against: tg counts the tile behind as lit by the guard's own light. + TEST_ASSERT(!stealth_tile_is_dark(behind), "The guard's light doesn't reach the tile behind it, so this test proves nothing") + TEST_ASSERT(stealth_tile_is_dark(behind, light), "Leaving the guard's own light out, the tile behind it isn't dark") + stealth_scans(guard, 10) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard saw someone standing still right behind it in the dark") + var/list/entry = stealth_ai.notice_map[REF(person)] + TEST_ASSERT(isnull(entry) || entry[1] == 0, "A guard built notice on someone right behind it in the dark ([entry?[1]])") + // Two tiles ahead, in its own beam: an alert. + person.forceMove(stealth_at(block, 6, 2)) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard didn't see someone 2 tiles ahead in its own light") + qdel(guard) + qdel(block) + +/// A friend's passing light doesn't make a guard switch its own off: its spot is judged by the room's light. +/datum/unit_test/voidcrew_stealth_light_friends + +/datum/unit_test/voidcrew_stealth_light_friends/Run() + var/datum/turf_reservation/block = stealth_block(12, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + stealth_unlist(block, 12, 5) + var/mob/living/carbon/human/npc/first = stealth_guard(block, 2, 2) + var/mob/living/carbon/human/npc/second = stealth_guard(block, 4, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/first_ai = stealth_ai(first) + var/datum/ai_controller/basic_controller/human_npc/stealth/second_ai = stealth_ai(second) + var/obj/item/flashlight/first_light = first_ai.stealth_light() + var/obj/item/flashlight/second_light = second_ai.stealth_light() + TEST_ASSERT(first_light in GLOB.stealth_guard_lights, "A guard's seclite isn't on the guard light list") + first_ai.stealth_update_light() + TEST_ASSERT(first_light.light_on, "The first guard didn't switch its light on in the dark") + var/turf/spot = get_turf(second) + TEST_ASSERT(!stealth_tile_is_dark(spot, second_light), "The first guard's light doesn't reach the second, so this test proves nothing") + TEST_ASSERT(stealth_tile_is_dark(spot, second_light, no_guard_lights = TRUE), "Without guard lights the second guard's spot isn't dark") + second_ai.stealth_update_light() + TEST_ASSERT(second_light.light_on, "A guard in the dark left its light off because a friend's light was on it") + second_ai.light_hold_until = 0 + second_ai.stealth_update_light() + TEST_ASSERT(second_light.light_on, "A guard switched its light off because a friend's light was on it") + first_ai.light_hold_until = 0 + first_ai.stealth_update_light() + TEST_ASSERT(first_light.light_on, "A guard switched its light off because a friend's light was on it") + qdel(block) + +/// A guard already found and called out as a body is not asked after as missing. +/datum/unit_test/voidcrew_stealth_live/hear/missing_reported + +/datum/unit_test/voidcrew_stealth_live/hear/missing_reported/Run() + TEST_ASSERT(hear_room(20, 3), "No room for the test") + var/mob/living/carbon/human/npc/first = walker(5, 1) + var/mob/living/carbon/human/npc/second = walker(7, 1) + var/mob/living/carbon/human/npc/third = walker(9, 1) + var/datum/ai_controller/basic_controller/human_npc/stealth/first_ai = first.ai_controller + var/datum/stealth_group/group = first_ai.group + stealth_noise(at(4, 1), "knock") + TEST_ASSERT_EQUAL(length(group.checks), 1, "No check was opened on the guard that went") + first.death() + group.reported_bodies += REF(first) + group.rewind(31 SECONDS) + group.check_overdue() + TEST_ASSERT_EQUAL(length(group.checks), 0, "The check on a reported body wasn't closed") + TEST_ASSERT_EQUAL(state_of(second), "unaware", "A guard went looking for a friend whose body was already reported") + TEST_ASSERT_EQUAL(state_of(third), "unaware", "A guard went looking for a friend whose body was already reported") + no_targets(list(second, third)) + +/** + * A running guard never steps faster than a player running: the delay follows its move intent, its kit doesn't + * make it quicker than a bare player, and a diagonal step costs what a player's does. Logs the measured times. + */ +/datum/unit_test/voidcrew_stealth_live/run_speed + +/datum/unit_test/voidcrew_stealth_live/run_speed/Run() + TEST_ASSERT(make_room(16, 16), "No room for the test") + var/mob/living/carbon/human/person = person_at(15, 15, FALSE) + if(person.move_intent != MOVE_INTENT_RUN) + person.toggle_move_intent() + var/player_run = person.cached_multiplicative_slowdown + var/mob/living/carbon/human/npc/guard = guard_at(1, 1) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + stealth_ai.stealth_set_pace(FALSE) + var/walk_delay = stealth_ai.movement_delay + stealth_ai.stealth_set_pace(TRUE) + TEST_ASSERT_EQUAL(guard.move_intent, MOVE_INTENT_RUN, "A running guard isn't on run") + TEST_ASSERT_EQUAL(stealth_ai.movement_delay, guard.cached_multiplicative_slowdown, "The guard's AI step delay didn't follow its move intent") + TEST_ASSERT(stealth_ai.movement_delay < walk_delay, "Running isn't faster than walking for a guard ([stealth_ai.movement_delay] vs [walk_delay])") + TEST_ASSERT(stealth_ai.movement_delay >= player_run, "A running guard's step delay [stealth_ai.movement_delay] is under a running player's [player_run]") + var/stock_diagonal = time_walk(guard, /datum/ai_movement/basic_avoidance, at(1, 1), at(13, 13)) + var/stealth_diagonal = time_walk(guard, /datum/ai_movement/basic_avoidance/stealth, at(1, 1), at(13, 13)) + var/stealth_straight = time_walk(guard, /datum/ai_movement/basic_avoidance/stealth, at(1, 1), at(13, 1)) + // The path movement (jps/stealth) shares stealth_step_cost(); it isn't timed here because tg's JPS loop stops at the + // controller's minimum distance, which with no behaviour running is its whole target range. + TEST_NOTICE(src, "Run speed: player run delay [player_run] ds, guard walk [walk_delay] ds, guard run [stealth_ai.movement_delay] ds. 12 tiles: stock tg diagonal [stock_diagonal] ds, guard diagonal [stealth_diagonal] ds, guard straight [stealth_straight] ds; a player takes [12 * player_run] ds straight, [round(12 * player_run * sqrt(2), 0.1)] ds diagonal.") + TEST_ASSERT(stealth_diagonal >= 0, "The guard never finished the diagonal run") + TEST_ASSERT(stealth_straight >= 0, "The guard never finished the straight run") + // One tick of slack for the move loop's timing. + var/slack = world.tick_lag + TEST_ASSERT(stealth_straight >= 12 * player_run - slack, "12 straight tiles took a running guard [stealth_straight] ds, a player [12 * player_run] ds") + TEST_ASSERT(stealth_diagonal >= 12 * player_run * sqrt(2) - slack, "12 diagonal tiles took a running guard [stealth_diagonal] ds, a player [12 * player_run * sqrt(2)] ds") + +/// Moves `guard` from `start` to `goal` with `movement_type`'s own move loop and returns how long it took, or -1. +/datum/unit_test/voidcrew_stealth_live/run_speed/proc/time_walk(mob/living/carbon/human/npc/guard, movement_type, turf/start, turf/goal) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + guard.forceMove(start) + stealth_ai.last_step_turf = start + var/datum/ai_movement/mover = SSai_movement.movement_types[movement_type] + var/began = world.time + mover.start_moving_towards(stealth_ai, goal, 0) + var/deadline = world.time + 15 SECONDS + while(get_turf(guard) != goal && world.time < deadline) + sleep(world.tick_lag) + var/took = world.time - began + mover.stop_moving_towards(stealth_ai) + return get_turf(guard) == goal ? took : -1 diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm index 4b1f5045302..04df8fc2db3 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm @@ -116,7 +116,8 @@ TEST_ASSERT(stealth_ai.search_for_body, "The search isn't marked as over a body") qdel(block) -/// Elbow to elbow: someone on the next tile in front is seen in the dark; behind or side-on is not. +/// Elbow to elbow: someone on the next tile in front is seen in the dark (an alert, decision 32); behind or side-on +/// is not; two ahead in the dark fills (3x near, decision 32) to suspicious. /datum/unit_test/voidcrew_stealth_adjacent /datum/unit_test/voidcrew_stealth_adjacent/Run() @@ -126,19 +127,19 @@ for(var/dy in 0 to 6) GLOB.stealth_test_dark_turfs[stealth_at(block, dx, dy)] = TRUE var/mob/living/carbon/human/person = stealth_person(block, 4, 3) - // offset from the guard => whether two scans make it suspicious + // offset from the guard => its state after two scans var/list/cases = list( - list(1, 0, TRUE), - list(-1, 0, FALSE), - list(0, 1, FALSE), - list(2, 0, FALSE), + list(1, 0, "alert"), + list(-1, 0, "unaware"), + list(0, 1, "unaware"), + list(2, 0, "suspicious"), ) for(var/list/test_case as anything in cases) person.forceMove(stealth_at(block, 3 + test_case[1], 3 + test_case[2])) var/mob/living/carbon/human/npc/guard = stealth_guard(block, 3, 3) var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) stealth_scans(guard, 2) - TEST_ASSERT_EQUAL(stealth_ai.stealth_state() == "suspicious", test_case[3], "Offset ([test_case[1]], [test_case[2]]) in the dark: state [stealth_ai.stealth_state()]") + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), test_case[3], "Offset ([test_case[1]], [test_case[2]]) in the dark: state [stealth_ai.stealth_state()]") qdel(guard) for(var/dx in 0 to 6) for(var/dy in 0 to 6) From 66a1cfb02365d2b5872d9623b25a4fa50c2fa8e6 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Tue, 10 Nov 2026 20:10:58 -0800 Subject: [PATCH 20/78] Guards open the locker or crate they saw their target get into --- tgstation.dme | 1 + voidcrew/_DEFINES/stealth.dm | 13 + voidcrew/modules/stealth/scav_guards.dm | 2 + voidcrew/modules/stealth/stealth_ai.dm | 25 +- voidcrew/modules/stealth/stealth_closet.dm | 286 ++++++++++++++++++ voidcrew/modules/unit_tests/_unit_tests.dm | 1 + .../unit_tests/voidcrew_stealth_closet.dm | 161 ++++++++++ 7 files changed, 488 insertions(+), 1 deletion(-) create mode 100644 voidcrew/modules/stealth/stealth_closet.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_stealth_closet.dm diff --git a/tgstation.dme b/tgstation.dme index 7cb1a1ac6c8..e06f3afb0de 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7732,6 +7732,7 @@ #include "voidcrew\modules\stealth\stealth_admin.dm" #include "voidcrew\modules\stealth\stealth_admin_noise.dm" #include "voidcrew\modules\stealth\stealth_ai.dm" +#include "voidcrew\modules\stealth\stealth_closet.dm" #include "voidcrew\modules\stealth\stealth_hearing.dm" #include "voidcrew\modules\stealth\stealth_light.dm" #include "voidcrew\modules\stealth\stealth_meter.dm" diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index 6b6431e79c8..ccddb93ce1e 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -37,6 +37,10 @@ #define STEALTH_BARK_CHATTER "stealth_chatter" /// It just put its target down #define STEALTH_BARK_DOWNED "stealth_target_downed" +/// It yanks open the locker or crate it saw its target get into (decision 33) +#define STEALTH_BARK_CLOSET_OPEN "stealth_closet_open" +/// It gives up on a locker or crate it can't get open (decision 33) +#define STEALTH_BARK_CLOSET_GIVE_UP "stealth_closet_give_up" // ===== What a stealth goto is for ===== #define STEALTH_GOTO_PATROL "patrol" @@ -44,6 +48,7 @@ #define STEALTH_GOTO_BODY "body" #define STEALTH_GOTO_SEARCH "search" #define STEALTH_GOTO_HOME "home" +#define STEALTH_GOTO_CLOSET "closet" // ===== Numbers (first playtest defaults; the owner tunes them) ===== #define STEALTH_SCAN_INTERVAL (1 SECONDS) @@ -125,6 +130,14 @@ /// Seconds of search between "Come on out." lines #define STEALTH_SEARCH_BARK_INTERVAL (12 SECONDS) +// Lockers and crates it saw someone get into (decision 33, stealth_closet.dm) +/// Seen on open ground this recently and now in a locker in view: it saw them get in +#define STEALTH_CLOSET_SEEN_WINDOW (1.5 SECONDS) +/// After this long on one locker (walking, opening, bashing) it gives up and searches round it +#define STEALTH_CLOSET_GIVE_UP_TIME (45 SECONDS) +/// A guard that isn't the one opening it stands this close and covers it +#define STEALTH_CLOSET_COVER_RANGE 3 + // The mark over a guard's head (stealth_meter.dm, owner decision 27) /// Pixel rows in the "?" and "!" glyphs: fill and drain steps #define STEALTH_METER_ROWS 7 diff --git a/voidcrew/modules/stealth/scav_guards.dm b/voidcrew/modules/stealth/scav_guards.dm index 0cfc70dbe50..24ec9e2aea9 100644 --- a/voidcrew/modules/stealth/scav_guards.dm +++ b/voidcrew/modules/stealth/scav_guards.dm @@ -19,6 +19,8 @@ STEALTH_BARK_BODY = list("Man down!", "Who did this?"), STEALTH_BARK_CHATTER = list("Shipment's late again.", "My feet are killing me.", "You hear that? No? Good.", "Radio check.", "Quiet tonight. I hate quiet."), STEALTH_BARK_DOWNED = list("Got 'em.", "Stay down.", "That's handled."), + STEALTH_BARK_CLOSET_OPEN = list("Out you come.", "Thought so.", "Found you."), + STEALTH_BARK_CLOSET_GIVE_UP = list("Stay in there, then.", "Fine. Rot in there."), STEALTH_BARK_HEARD = list("What was that?", "You hear that?", "Hm."), STEALTH_BARK_HEARD_AGAIN = list("Again?", "That's twice now."), STEALTH_BARK_GUNFIRE = list("Shots!", "That's gunfire!", "Shots, %SIDE% side!"), diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index 6db4c27db10..d628eb8557d 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -81,6 +81,7 @@ /datum/ai_planning_subtree/human_npc_surrender, /datum/ai_planning_subtree/stealth_react, /datum/ai_planning_subtree/human_npc_arm, + /datum/ai_planning_subtree/stealth_closet, /datum/ai_planning_subtree/human_npc_shoot, /datum/ai_planning_subtree/human_npc_melee, /datum/ai_planning_subtree/stealth_patrol, @@ -219,6 +220,7 @@ ) + STEALTH_HANDLED_SIGNALS + STEALTH_STUN_SIGNALS) group?.remove_member(pawn) group = null + stealth_drop_closet() for(var/datum/stealth_sight_overlay/overlay as anything in watchers?.Copy()) qdel(overlay) watchers = null @@ -247,6 +249,7 @@ . = ..() QDEL_NULL(meter) stealth_drop_call() + stealth_drop_closet() // The player has left the body: it is a guard again, with nothing on its mind. /datum/ai_controller/basic_controller/human_npc/stealth/on_sentience_lost() @@ -296,6 +299,9 @@ blackboard[BB_STEALTH_UNAWARE_LOST_AT] = world.time blackboard[BB_STEALTH_STATE] = new_state blackboard[BB_STEALTH_STATE_SINCE] = world.time + // Only an alert guard goes after a locker it saw someone get into (decision 33). + if(new_state != STEALTH_ALERT) + stealth_drop_closet() look_until = 0 lost_since = 0 calm_until = 0 @@ -434,6 +440,8 @@ last_seen_turf = get_turf(target) blackboard[BB_STEALTH_LAST_SEEN_AT] = world.time set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, target) + // Every alert is first hand: if they are in a locker or a box, it is the one it just saw or felt (decision 33). + stealth_closet_alerted(target) // It has seen or felt them itself: it calls for help (decision 8). if(news) stealth_first_hand(last_seen_turf) @@ -537,6 +545,10 @@ pending_call[STEALTH_CALL_DUE] -= time if(explained_at) explained_at -= time + if(shut_in_at) + shut_in_at -= time + if(target_free_seen_at) + target_free_seen_at -= time for(var/kind in bark_ready_at) bark_ready_at[kind] -= time for(var/key in stop_skip_until) @@ -675,6 +687,11 @@ if(dist > STEALTH_SIGHT_RANGE) continue if(boxed) + // Searching, it saw them on open ground a moment ago, and now they are in a locker it can see (decision 33). + if(state == STEALTH_SEARCHING && eyes && dist <= STEALTH_ALERT_MAX_RANGE && stealth_closet_glimpsed(candidate, stealth_shell_of(candidate))) + if(strategy.can_attack(guard, candidate, STEALTH_SIGHT_RANGE)) + stealth_go_alert(candidate) + return // Hidden, unless the thing they hide in moves at its shoulder (decision 29). if(dist > STEALTH_CLOSE_RANGE + 1) continue @@ -902,8 +919,13 @@ if(QDELETED(remembered)) stealth_go_searching(last_seen_turf) return + // In a locker or a box: tracked only if it saw them get in (decision 33, stealth_closet.dm). + if(stealth_closet_track(remembered)) + return var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) if(strategy?.can_attack(guard, remembered, HUMAN_NPC_SIGHT_RANGE)) + if(isturf(remembered.loc)) + target_free_seen_at = world.time lost_since = 0 last_seen_turf = get_turf(remembered) blackboard[BB_STEALTH_LAST_SEEN_AT] = world.time @@ -970,7 +992,7 @@ return if(best) var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) - if(best_notice >= STEALTH_ALERT_AT && strategy?.can_attack(guard, best, HUMAN_NPC_SIGHT_RANGE)) + if(best_notice >= STEALTH_ALERT_AT && isnull(stealth_shell_of(best)) && strategy?.can_attack(guard, best, HUMAN_NPC_SIGHT_RANGE)) stealth_go_alert(best) else if(best_notice >= STEALTH_ALERT_AT) stealth_go_searching(best_turf) @@ -1226,6 +1248,7 @@ if(new_stat != CONSCIOUS) QDEL_NULL(meter) stealth_drop_call() + stealth_drop_closet() if(new_stat == CONSCIOUS && was != CONSCIOUS && was != DEAD) stealth_came_round() diff --git a/voidcrew/modules/stealth/stealth_closet.dm b/voidcrew/modules/stealth/stealth_closet.dm new file mode 100644 index 00000000000..537bef8e827 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_closet.dm @@ -0,0 +1,286 @@ +/** + * # Lockers and crates a guard saw someone get into (owner decision 33) + * + * An alert guard, or a searching one that glimpses someone, that sees its target get into a locker, a crate, a + * coffin, a body bag or a cardboard box (any /obj/structure/closet), or sees the door shut on them, remembers + * that container. It walks up and opens it with tg's own open(). If it won't open (locked or welded), it hits it + * with what it holds, through tg's click path: point-blank shots with a loaded gun, or its melee weapon when that + * can dent it. A locker that breaks bursts open through tg's atom_break(). It gives up after + * STEALTH_CLOSET_GIVE_UP_TIME and searches round it. + * + * Someone who gets in unseen is still hidden (decision 22): an alert guard whose target is in a container it + * didn't see them get into treats them as out of sight, and never shoots at the container (tg's own + * find_hidden_mobs() would have it shoot any locker its target is in, from across the room). + * + * With several guards on one container the one that claimed it first opens it; the rest stand close and cover it. + */ + +/datum/ai_controller/basic_controller/human_npc/stealth + /// The locker or crate it saw its target get into, or null. Cleared when it is deleted. + var/obj/structure/closet/shut_in + /// Who it saw get in + var/datum/weakref/shut_who + /// world.time it saw them get in + var/shut_in_at = 0 + /// Alert: world.time it last saw its target on open ground + var/target_free_seen_at = 0 + +/// The locker, crate or box `who` is shut in (the outermost, if one is inside another), or null. +/proc/stealth_closet_of(mob/living/who) + if(!isliving(who)) + return null + var/atom/movable/shell = stealth_shell_of(who) + return istype(shell, /obj/structure/closet) ? shell : null + +/// Whether it has `box` in view (all round, as it keeps an alert target in view). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_sees_closet(obj/structure/closet/box) + var/mob/living/guard = pawn + if(QDELETED(box) || !isturf(guard.loc) || get_dist(guard, box) > HUMAN_NPC_SIGHT_RANGE) + return FALSE + return can_see(guard, box, HUMAN_NPC_SIGHT_RANGE) + +/// Remembers that it saw `who` get into `box`. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_claim_closet(obj/structure/closet/box, mob/living/who) + if(shut_in == box) + shut_who = WEAKREF(who) + return + stealth_drop_closet() + shut_in = box + shut_who = WEAKREF(who) + shut_in_at = world.time + RegisterSignal(box, COMSIG_QDELETING, PROC_REF(on_closet_deleted)) + +/// Forgets the container it was after. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_drop_closet() + if(shut_in) + UnregisterSignal(shut_in, COMSIG_QDELETING) + shut_in = null + shut_who = null + shut_in_at = 0 + +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_closet_deleted(datum/source) + SIGNAL_HANDLER + stealth_drop_closet() + +/** + * Its claim, still good: `who` is still inside it (or inside something that went into it, which it then goes + * after instead). Drops a claim that no longer holds and returns null. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_closet_check(mob/living/who) + var/obj/structure/closet/box = shut_in + if(isnull(box)) + return null + if(!isliving(who) || QDELETED(who) || who.stat == DEAD || shut_who?.resolve() != who) + stealth_drop_closet() + return null + var/atom/holder = who.loc + while(holder && holder != box && !isturf(holder)) + holder = holder.loc + var/obj/structure/closet/outer = stealth_closet_of(who) + if(holder != box || isnull(outer)) + // They got out, or someone opened it, or it went into something that isn't a locker. + stealth_drop_closet() + return null + if(outer != box) + // The box it watched was shut inside another one: that is the one to open now. + var/claimed_at = shut_in_at + stealth_claim_closet(outer, who) + shut_in_at = claimed_at + return shut_in + +/// Searching: whether it saw `candidate` on open ground a moment ago, close to the `shell` it can see them in now. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_closet_glimpsed(mob/living/candidate, atom/movable/shell) + if(!istype(shell, /obj/structure/closet)) + return FALSE + var/list/entry = notice_map[REF(candidate)] + if(isnull(entry) || entry[STEALTH_ENTRY_NOTICE] < STEALTH_SUSPICIOUS_AT) + return FALSE + if(world.time - entry[STEALTH_ENTRY_SEEN_AT] > STEALTH_CLOSET_SEEN_WINDOW) + return FALSE + var/turf/was = entry[STEALTH_ENTRY_TURF] + if(isnull(was) || get_dist(was, shell) > 2) + return FALSE + return can_see(pawn, shell, STEALTH_SIGHT_RANGE) + +/// Just went alert on `target` (always first hand: sight, a touch, a hit). If they are in a container, that's the one. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_closet_alerted(atom/target) + var/mob/living/who = target + if(!isliving(who)) + stealth_drop_closet() + return + if(isturf(who.loc)) + stealth_drop_closet() + target_free_seen_at = world.time + return + var/obj/structure/closet/box = stealth_closet_of(who) + if(box && stealth_sees_closet(box)) + stealth_claim_closet(box, who) + else if(shut_in && shut_who?.resolve() != who) + stealth_drop_closet() + +/** + * Alert, from stealth_keep_target(): its target `remembered` is in a container. Returns FALSE if they are not + * (the usual can_attack() tracking goes on). A container it saw them get into is kept in view like the target + * itself; any other hides them, and they are lost after STEALTH_LOSE_TARGET_TIME as if they had run off. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_closet_track(atom/remembered) + var/mob/living/guard = pawn + var/mob/living/who = remembered + var/obj/structure/closet/outer = stealth_closet_of(who) + if(isnull(outer)) + if(shut_in) + stealth_drop_closet() + return FALSE + var/obj/structure/closet/box = stealth_closet_check(who) + // On open ground a moment ago, and the door shut on them in front of it. + if(isnull(box) && world.time - target_free_seen_at <= STEALTH_CLOSET_SEEN_WINDOW && stealth_eyes_open() && stealth_sees_closet(outer)) + stealth_claim_closet(outer, who) + box = outer + if(box && stealth_sees_closet(box)) + lost_since = 0 + last_seen_turf = get_turf(box) + blackboard[BB_STEALTH_LAST_SEEN_AT] = world.time + if(!blackboard[BB_BASIC_MOB_CURRENT_TARGET]) + set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, who) + return TRUE + if(!lost_since) + lost_since = world.time + if(world.time - lost_since < STEALTH_LOSE_TARGET_TIME) + return TRUE + stealth_drop_closet() + clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + stealth_bark(STEALTH_BARK_LOST) + stealth_go_searching(last_seen_turf || get_turf(guard)) + return TRUE + +/// Whether it is the one to open `box`: of its group's guards after it, the one that saw them get in first. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_closet_opener(obj/structure/closet/box) + if(isnull(group)) + return TRUE + var/seen_self = FALSE + for(var/datum/weakref/ref as anything in group.members) + var/mob/living/member = ref?.resolve() + if(isnull(member)) + continue + if(member == pawn) + seen_self = TRUE + continue + var/datum/ai_controller/basic_controller/human_npc/stealth/other = member.ai_controller + if(!istype(other) || other.shut_in != box || member.stat != CONSCIOUS || member.client || other.stealth_captive()) + continue + if(other.shut_in_at < shut_in_at || (other.shut_in_at == shut_in_at && !seen_self)) + return FALSE + return TRUE + +/// Out of time on its container: it says so and searches round it. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_closet_give_up() + var/turf/where = get_turf(shut_in) || last_seen_turf + stealth_drop_closet() + clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + stealth_bark(STEALTH_BARK_CLOSET_GIVE_UP) + stealth_go_searching(where) + // It knows someone is in there: its search doesn't end with "Nothing." + search_for_body = TRUE + +/** + * Beside its container: opens it with tg's open(), as a hand on the door would. Locked or welded shut, it hits + * it once with what it holds, through tg's click path: a point-blank shot from a loaded gun, or its melee + * weapon if that hits hard enough to dent it (a gun butt can't: a secure locker shrugs off anything under its + * damage_deflection). Bare-handed it can only wait. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_try_closet() + var/mob/living/carbon/human/guard = pawn + var/obj/structure/closet/box = shut_in + if(QDELETED(box) || !guard.Adjacent(box) || HAS_TRAIT(guard, TRAIT_HANDS_BLOCKED) || guard.incapacitated) + return + var/mob/living/who = shut_who?.resolve() + guard.face_atom(box) + if(box.open(guard)) + stealth_drop_closet() + stealth_bark(STEALTH_BARK_CLOSET_OPEN) + if(isliving(who) && !QDELETED(who)) + // Out on the floor in front of it, or still in a box that was inside: either way, in plain view. + if(isturf(who.loc)) + target_free_seen_at = world.time + lost_since = 0 + else + stealth_closet_alerted(who) + return + if(world.time < guard.next_move) + return + var/obj/item/gun/gun = human_npc_loaded_gun(guard) + if(gun) + if(world.time < blackboard[BB_HUMAN_NPC_NEXT_SHOT] || !human_npc_ready_item(guard, gun)) + return + guard.zone_selected = BODY_ZONE_CHEST + ai_interact(target = box, combat_mode = TRUE) + set_blackboard_key(BB_HUMAN_NPC_NEXT_SHOT, world.time + (blackboard[BB_HUMAN_NPC_SHOT_DELAY] || 3 SECONDS)) + return + var/obj/item/weapon = human_npc_held_melee_weapon(guard) + if(isnull(weapon) || (weapon.item_flags & NOBLUDGEON) || weapon.force < max(box.damage_deflection, 1)) + return + human_npc_ready_item(guard, weapon) + human_npc_ready_weapon(guard, weapon) + ai_interact(target = box, combat_mode = TRUE) + +/** + * Alert with its target in a container. One it saw them get into: the guard that saw first walks over and opens + * it, the others close in to STEALTH_CLOSET_COVER_RANGE and cover it. One it didn't: it holds its fire and watches + * where it last saw them, rather than shoot whatever its target hides in. Ends planning either way, so the + * shooting and melee subtrees after it never aim at the container from range. + */ +/datum/ai_planning_subtree/stealth_closet + +/datum/ai_planning_subtree/stealth_closet/SelectBehaviors(datum/ai_controller/basic_controller/human_npc/stealth/controller, seconds_per_tick) + if(!istype(controller) || controller.stealth_state() != STEALTH_ALERT) + return + var/mob/living/guard = controller.pawn + if(guard.stat != CONSCIOUS) + return + var/mob/living/who = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] || controller.blackboard[BB_STEALTH_FOCUS] + var/obj/structure/closet/outer = stealth_closet_of(who) + if(isnull(outer)) + return + var/obj/structure/closet/box = controller.stealth_closet_check(who) + if(isnull(box)) + controller.stealth_drop_walk() + var/turf/last = controller.last_seen_turf + if(last && last != get_turf(guard)) + controller.stand_dir = stealth_dir_to(guard, last) + controller.queue_behavior(/datum/ai_behavior/stealth_stand) + return SUBTREE_RETURN_FINISH_PLANNING + if(world.time - controller.shut_in_at >= STEALTH_CLOSET_GIVE_UP_TIME) + controller.stealth_drop_walk() + controller.stealth_closet_give_up() + return SUBTREE_RETURN_FINISH_PLANNING + var/turf/spot = get_turf(box) + if(!controller.stealth_closet_opener(box)) + if(get_dist(guard, box) > STEALTH_CLOSET_COVER_RANGE && !controller.stealth_walk_gave_up(spot)) + controller.stealth_walk(spot, STEALTH_GOTO_CLOSET) + return SUBTREE_RETURN_FINISH_PLANNING + controller.stealth_drop_walk() + if(spot != get_turf(guard)) + controller.stand_dir = stealth_dir_to(guard, box) + controller.queue_behavior(/datum/ai_behavior/stealth_stand) + return SUBTREE_RETURN_FINISH_PLANNING + if(!guard.Adjacent(box)) + if(controller.stealth_walk_gave_up(spot)) + // No way to it: it gives up now rather than stand there. + controller.stealth_drop_walk() + controller.stealth_closet_give_up() + return SUBTREE_RETURN_FINISH_PLANNING + controller.stealth_walk(spot, STEALTH_GOTO_CLOSET) + return SUBTREE_RETURN_FINISH_PLANNING + controller.stealth_drop_walk() + controller.queue_behavior(/datum/ai_behavior/stealth_open_closet) + return SUBTREE_RETURN_FINISH_PLANNING + +/// Beside the container: one try a second (stealth_try_closet()). Never finishes by itself; planning replaces it. +/datum/ai_behavior/stealth_open_closet + action_cooldown = 1 SECONDS + behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/stealth_open_closet/perform(seconds_per_tick, datum/ai_controller/basic_controller/human_npc/stealth/controller) + if(istype(controller)) + controller.stealth_try_closet() + return AI_BEHAVIOR_DELAY diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index 4382f84b5fc..0d2998b9e90 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -235,6 +235,7 @@ #include "voidcrew_slime_extract_piles.dm" #include "voidcrew_smart_locker.dm" #include "voidcrew_stealth.dm" +#include "voidcrew_stealth_closet.dm" #include "voidcrew_stealth_d32.dm" #include "voidcrew_stealth_hearing.dm" #include "voidcrew_stealth_light.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_closet.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_closet.dm new file mode 100644 index 00000000000..b556d50eb61 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_closet.dm @@ -0,0 +1,161 @@ +// Stealth guards, owner decision 33 (voidcrew/modules/stealth/stealth_closet.dm): a guard that saw its target get into +// a locker opens it; one that didn't leaves it shut. Values from voidcrew/_DEFINES are written out: +// STEALTH_LOSE_TARGET_TIME 4 s, STEALTH_CLOSET_SEEN_WINDOW 1.5 s. States are written as text. + +/// Claims, with the AI off: the locker it sees someone in when it goes alert; dropped when they get out, when it is +/// deleted, and when the guard stops being alert. +/datum/unit_test/voidcrew_stealth_closet_claim + +/datum/unit_test/voidcrew_stealth_closet_claim/Run() + var/datum/turf_reservation/block = stealth_block(8, 3) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 1, 1) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 5, 1) + var/obj/structure/closet/locker = allocate(/obj/structure/closet, stealth_at(block, 4, 1)) + person.forceMove(locker) + stealth_ai.stealth_go_alert(person) + TEST_ASSERT_EQUAL(stealth_ai.shut_in, locker, "A guard alerted on someone in a locker in plain view didn't claim it") + // Out of it: the claim goes. + person.forceMove(stealth_at(block, 5, 1)) + TEST_ASSERT_NULL(stealth_ai.stealth_closet_check(person), "A claim held after its target got out") + TEST_ASSERT_NULL(stealth_ai.shut_in, "A guard kept a locker its target had left") + // Back in, then the locker is destroyed. + person.forceMove(locker) + stealth_ai.stealth_go_alert(person) + TEST_ASSERT_EQUAL(stealth_ai.shut_in, locker, "A guard didn't claim the locker the second time") + qdel(locker) + TEST_ASSERT_NULL(stealth_ai.shut_in, "A guard kept a deleted locker") + // A new one, and the guard calms down. + var/obj/structure/closet/second = allocate(/obj/structure/closet, stealth_at(block, 4, 1)) + person.forceMove(second) + stealth_ai.stealth_go_alert(person) + TEST_ASSERT_EQUAL(stealth_ai.shut_in, second, "A guard didn't claim the second locker") + stealth_ai.stealth_go_searching(stealth_at(block, 4, 1)) + TEST_ASSERT_NULL(stealth_ai.shut_in, "A guard that stopped being alert kept its locker") + +/// Real AI: alert on someone who walks into an open locker and pulls the door shut in front of it, it opens the locker. +/datum/unit_test/voidcrew_stealth_live/closet_seen + +/datum/unit_test/voidcrew_stealth_live/closet_seen/Run() + TEST_ASSERT(make_room(12, 5), "No room for the test") + var/mob/living/carbon/human/npc/guard = guard_at(2, 2, EAST) + var/mob/living/carbon/human/person = person_at(6, 2) + var/obj/structure/closet/locker = allocate(/obj/structure/closet, at(7, 2)) + locker.open() + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = wake(guard) + stealth_ai.stealth_go_alert(person) + step(person, EAST) + TEST_ASSERT_EQUAL(get_turf(person), at(7, 2), "The person couldn't step into the open locker") + TEST_ASSERT(locker.close(person), "The person couldn't shut the locker on themselves") + TEST_ASSERT_EQUAL(person.loc, locker, "The person isn't in the locker") + var/start_integrity = locker.get_integrity() + var/deadline = world.time + 30 SECONDS + while(!locker.opened && world.time < deadline) + sleep(2) + TEST_ASSERT(locker.opened, "A guard that saw someone shut themselves in a locker never opened it (claim: [stealth_ai.shut_in ? "yes" : "no"], state [stealth_ai.stealth_state()])") + TEST_ASSERT(get_dist(guard, locker) <= 1, "The locker opened with the guard [get_dist(guard, locker)] tiles away") + TEST_ASSERT_EQUAL(locker.get_integrity(), start_integrity, "A guard hit a locker it could just open") + TEST_ASSERT(isturf(person.loc), "The person is still shut in after the locker opened") + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "The guard isn't alert on whoever was in the locker") + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], person, "The guard isn't after whoever was in the locker") + +/// Real AI: alert on someone who got into a locker behind a wall, it can see the locker once the wall is gone, but +/// leaves it shut: it loses them, searches, and never hits or opens it. +/datum/unit_test/voidcrew_stealth_live/closet_unseen + +/datum/unit_test/voidcrew_stealth_live/closet_unseen/Run() + TEST_ASSERT(make_room(12, 5), "No room for the test") + for(var/dy in 0 to 4) + var/turf/wall_spot = at(6, dy) + wall_spot.ChangeTurf(/turf/closed/wall) + var/mob/living/carbon/human/npc/guard = guard_at(2, 2, EAST) + var/mob/living/carbon/human/person = person_at(9, 2) + var/obj/structure/closet/locker = allocate(/obj/structure/closet, at(9, 2)) + person.forceMove(locker) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = wake(guard) + stealth_ai.stealth_go_alert(person) + TEST_ASSERT_NULL(stealth_ai.shut_in, "A guard claimed a locker behind a wall") + for(var/dy in 0 to 4) + var/turf/gap = at(6, dy) + gap.ChangeTurf(/turf/open/floor/iron) + GLOB.stealth_test_dark_turfs[gap] = FALSE + var/start_integrity = locker.get_integrity() + var/deadline = world.time + 15 SECONDS + while(stealth_ai.stealth_state() == "alert" && world.time < deadline) + sleep(2) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "searching", "A guard whose target hid unseen didn't lose them") + sleep(6 SECONDS) + TEST_ASSERT(!locker.opened, "A guard opened a locker it never saw anyone get into") + TEST_ASSERT_EQUAL(person.loc, locker, "The person was taken out of the locker") + TEST_ASSERT_EQUAL(locker.get_integrity(), start_integrity, "A guard hit a locker it never saw anyone get into") + TEST_ASSERT_NULL(stealth_ai.shut_in, "A searching guard claimed a locker") + +/// Real AI: a gunner that saw someone shut in a locker that is then locked shoots it open from beside it, not from range. +/datum/unit_test/voidcrew_stealth_live/closet_locked + +/datum/unit_test/voidcrew_stealth_live/closet_locked/Run() + TEST_ASSERT(make_room(12, 5), "No room for the test") + var/mob/living/carbon/human/npc/guard = allocate(/mob/living/carbon/human/npc/ruin/trooper/scav/gunner, at(2, 2)) + guard.setDir(EAST) + guard.AddElement(/datum/element/forced_gravity, 1) + var/mob/living/carbon/human/person = person_at(6, 2) + var/obj/structure/closet/secure_closet/locker = allocate(/obj/structure/closet/secure_closet, at(7, 2)) + locker.locked = FALSE + locker.open() + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = wake(guard) + stealth_ai.stealth_go_alert(person) + step(person, EAST) + TEST_ASSERT(locker.close(person), "The person couldn't shut the locker on themselves") + locker.locked = TRUE + locker.update_appearance() + // Near breaking, so the test takes a couple of shots, not a magazine. + locker.update_integrity(locker.max_integrity * locker.integrity_failure + 25) + var/start_integrity = locker.get_integrity() + var/first_hit_dist + var/deadline = world.time + 40 SECONDS + while(!locker.opened && world.time < deadline) + if(isnull(first_hit_dist) && locker.get_integrity() < start_integrity) + first_hit_dist = get_dist(guard, locker) + sleep(1) + TEST_ASSERT(locker.opened, "A gunner never broke open a locked locker it saw someone get into (claim: [stealth_ai.shut_in ? "yes" : "no"], integrity [locker.get_integrity()]/[start_integrity])") + TEST_ASSERT_NOTNULL(first_hit_dist, "The locked locker opened without being hit") + TEST_ASSERT(first_hit_dist <= 1, "A gunner shot a locker from [first_hit_dist] tiles away") + TEST_ASSERT(isturf(person.loc), "The person is still shut in after the locker broke") + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], person, "The gunner isn't after whoever was in the locker") + +/// Real AI: two guards saw it; only one opens the locker, the other covers it. +/datum/unit_test/voidcrew_stealth_live/closet_two_guards + +/datum/unit_test/voidcrew_stealth_live/closet_two_guards/Run() + TEST_ASSERT(make_room(12, 5), "No room for the test") + allocate(/obj/effect/landmark/stealth_group, at(0, 4)) + var/mob/living/carbon/human/npc/first = guard_at(2, 1, EAST) + var/mob/living/carbon/human/npc/second = guard_at(2, 3, EAST) + var/mob/living/carbon/human/person = person_at(6, 2) + var/obj/structure/closet/locker = allocate(/obj/structure/closet, at(7, 2)) + locker.open() + var/datum/ai_controller/basic_controller/human_npc/stealth/first_ai = wake(first) + var/datum/ai_controller/basic_controller/human_npc/stealth/second_ai = wake(second) + first_ai.stealth_setup() + second_ai.stealth_setup() + TEST_ASSERT_NOTNULL(first_ai.group, "The guards have no group") + TEST_ASSERT_EQUAL(first_ai.group, second_ai.group, "The guards aren't in one group") + first_ai.stealth_go_alert(person) + second_ai.stealth_go_alert(person) + step(person, EAST) + TEST_ASSERT(locker.close(person), "The person couldn't shut the locker on themselves") + var/datum/ai_behavior/opening = GET_AI_BEHAVIOR(/datum/ai_behavior/stealth_open_closet) + var/list/openers = list() + var/both_claimed = FALSE + var/deadline = world.time + 30 SECONDS + while(!locker.opened && world.time < deadline) + if(first_ai.shut_in == locker && second_ai.shut_in == locker) + both_claimed = TRUE + for(var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai as anything in list(first_ai, second_ai)) + if(opening in guard_ai.current_behaviors) + openers |= guard_ai + sleep(1) + TEST_ASSERT(locker.opened, "Two guards that saw someone shut in a locker never opened it") + TEST_ASSERT(both_claimed, "The two guards never both went after the locker (the test can't tell one opener from one watcher)") + TEST_ASSERT_EQUAL(length(openers), 1, "[length(openers)] guards tried to open one locker") From f66dc95323d24e9868aabd53a557aaed86e4a6dd Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Tue, 10 Nov 2026 20:43:03 -0800 Subject: [PATCH 21/78] Stealth guards take bigger crits when caught unaware, a head shot can drop them, a matte knife backstabs, and their seclites can be looted --- tgstation.dme | 2 + voidcrew/_DEFINES/stealth.dm | 26 +++ .../modules/hyperviolence/crits/crit_roll.dm | 16 +- voidcrew/modules/stealth/stealth_ai.dm | 17 ++ voidcrew/modules/stealth/stealth_crits.dm | 122 ++++++++++++ voidcrew/modules/stealth/stealth_knife.dm | 13 ++ voidcrew/modules/stealth/stealth_light.dm | 17 +- voidcrew/modules/unit_tests/_unit_tests.dm | 1 + .../unit_tests/voidcrew_stealth_crits.dm | 186 ++++++++++++++++++ 9 files changed, 393 insertions(+), 7 deletions(-) create mode 100644 voidcrew/modules/stealth/stealth_crits.dm create mode 100644 voidcrew/modules/stealth/stealth_knife.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_stealth_crits.dm diff --git a/tgstation.dme b/tgstation.dme index e06f3afb0de..605ee7f38c9 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7733,7 +7733,9 @@ #include "voidcrew\modules\stealth\stealth_admin_noise.dm" #include "voidcrew\modules\stealth\stealth_ai.dm" #include "voidcrew\modules\stealth\stealth_closet.dm" +#include "voidcrew\modules\stealth\stealth_crits.dm" #include "voidcrew\modules\stealth\stealth_hearing.dm" +#include "voidcrew\modules\stealth\stealth_knife.dm" #include "voidcrew\modules\stealth\stealth_light.dm" #include "voidcrew\modules\stealth\stealth_meter.dm" #include "voidcrew\modules\stealth\stealth_noise.dm" diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index ccddb93ce1e..ac36f1e9470 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -13,6 +13,8 @@ #define BB_STEALTH_STATE_SINCE "stealth_state_since" /// world.time the guard last stopped being unaware (stealth_was_unaware()) #define BB_STEALTH_UNAWARE_LOST_AT "stealth_unaware_lost_at" +/// The state before the last change, so a blow can be judged by the state it began in (stealth_state_at_blow()) +#define BB_STEALTH_PREV_STATE "stealth_prev_state" /// TRUE once alerted, searching or hit. Fades after STEALTH_WARY_TIME with nothing new (checked each scan). #define BB_STEALTH_WARY "stealth_wary" /// The candidate with the highest notice @@ -158,3 +160,27 @@ #define STEALTH_LIGHT_EMP_LIGHT (20 SECONDS) #define FACTION_SCAV "scav" + +// ===== Stealth crits and the backstab knife (step 3a, stealth_crits.dm) ===== +// Roll bonuses for hyperviolence's aimed crit roll (crit_roll.dm), on a stealth guard only. They go in before wound armour, +// so armour scales them like the rest of the roll. Numbers argued in data/stealth/STATUS.md, "Step 3a". +/// Added when the guard was unaware of everyone as the blow began +#define STEALTH_CRIT_UNAWARE_BONUS 30 +/// Added when it was only suspicious +#define STEALTH_CRIT_SUSPICIOUS_BONUS 15 +/// Added on top of either when the attacker aimed at the head (head, eyes or mouth) +#define STEALTH_CRIT_HEAD_BONUS 35 +/// Added when the backstab knife strikes from behind (tg's check_behind()), whatever the guard's state +#define STEALTH_BACKSTAB_BONUS 40 +/// The head shot crit (a bullet through the skull) needs a roll this high, and only a stealth hit can roll it +#define STEALTH_HEAD_SHOT_THRESHOLD 80 +/// Least damage after armour a head shot crit needs +#define STEALTH_HEAD_SHOT_MIN_DAMAGE 20 +/// A helmet this good against the bullet (after its armour penetration) stops a head shot crit outright +#define STEALTH_HEAD_SHOT_HELMET_ARMOUR 30 +/// Brain damage a head shot crit deals (brains die at 200) +#define STEALTH_HEAD_SHOT_BRAIN_DAMAGE 40 +/// How long a head shot crit knocks the guard down +#define STEALTH_HEAD_SHOT_KNOCKDOWN (4 SECONDS) +/// A bullet through the head +#define WOUND_SERIES_HV_HEAD_SHOT "wound_series_hv_head_shot" diff --git a/voidcrew/modules/hyperviolence/crits/crit_roll.dm b/voidcrew/modules/hyperviolence/crits/crit_roll.dm index bbcbdc16792..178d70354b9 100644 --- a/voidcrew/modules/hyperviolence/crits/crit_roll.dm +++ b/voidcrew/modules/hyperviolence/crits/crit_roll.dm @@ -18,7 +18,8 @@ // * The roll is tg's own wound roll: rand(1, min(damage, 25) ^ 1.4), so 1 to 90. On top of the // weapon's wound_bonus we add up to +30 for how battered the limb already is (its damage over // its max damage) and +25 if the victim is helpless (lying down, in crit, stunned, cuffed or -// held in an aggressive grab), +15 more if the attacker is the one holding them. Then tg's +// held in an aggressive grab), +15 more if the attacker is the one holding them, plus any +// situation bonus (hv_crit_situation_bonus(): stealth guards caught unaware). Then tg's // check_woundings_mods() adds the limb's existing wound penalties and scales everything by // wound armour (worn WOUND ratings plus the limb's own resistance: head 5%, chest 10%). // * Each crit has a threshold and a minimum damage after armour (crit_types.dm). A fresh, @@ -222,9 +223,14 @@ GLOBAL_LIST_INIT(hv_crits, hv_crit_init_list()) if(attacker && attacker.pulling == src && attacker.grab_state >= GRAB_AGGRESSIVE) . += HV_CRIT_HELD_BONUS -/// The crit roll for this limb. tg's wound roll plus the battered and helpless bonuses, run +/// Roll bonus from how the blow was struck, on top of the helpless bonus: 0 here. The stealth layer adds one for a guard +/// caught unaware or stabbed in the back (voidcrew/modules/stealth/stealth_crits.dm). `source` is the weapon or projectile. +/mob/living/proc/hv_crit_situation_bonus(mob/living/attacker, atom/source, obj/item/bodypart/limb) + return 0 + +/// The crit roll for this limb. tg's wound roll plus the battered, helpless and situation bonuses, run /// through check_woundings_mods() so wound armour and existing wounds count as they do for tg. -/obj/item/bodypart/proc/hv_crit_roll(wounding_type, damage, wound_bonus, exposed_wound_bonus, mob/living/attacker) +/obj/item/bodypart/proc/hv_crit_roll(wounding_type, damage, wound_bonus, exposed_wound_bonus, mob/living/attacker, atom/source) var/easily_wounded = HAS_TRAIT(owner, TRAIT_EASILY_WOUNDED) var/hardly_wounded = HAS_TRAIT(owner, TRAIT_HARDLY_WOUNDED) if(easily_wounded && !hardly_wounded) @@ -234,7 +240,7 @@ GLOBAL_LIST_INIT(hv_crits, hv_crit_init_list()) if(hardly_wounded && !easily_wounded) damage *= 0.85 var/base_roll = rand(1, max(1, round(damage ** WOUND_DAMAGE_EXPONENT))) - var/bonus = wound_bonus + round(HV_CRIT_BATTERED_BONUS * get_damage() / max(max_damage, 1)) + owner.hv_crit_helpless_bonus(attacker) + var/bonus = wound_bonus + round(HV_CRIT_BATTERED_BONUS * get_damage() / max(max_damage, 1)) + owner.hv_crit_helpless_bonus(attacker) + owner.hv_crit_situation_bonus(attacker, source, src) return check_woundings_mods(wounding_type, base_roll, damage, bonus, exposed_wound_bonus, FALSE) // --------------------------------------------------------------------------------------------- @@ -304,7 +310,7 @@ GLOBAL_LIST_INIT(hv_crits, hv_crit_init_list()) if(damage < crit.min_damage) continue if(isnull(roll)) - roll = isnull(forced_roll) ? limb.hv_crit_roll(wounding_type, damage, wound_bonus, exposed_wound_bonus, attacker) : forced_roll + roll = isnull(forced_roll) ? limb.hv_crit_roll(wounding_type, damage, wound_bonus, exposed_wound_bonus, attacker, source) : forced_roll if(roll < crit.threshold) continue if(!crit.apply_carbon(src, limb, damage, attack_direction, source, attacker)) diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index d628eb8557d..fc7af3be449 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -297,6 +297,8 @@ var/old_state = blackboard[BB_STEALTH_STATE] if(old_state == STEALTH_UNAWARE && new_state != STEALTH_UNAWARE) blackboard[BB_STEALTH_UNAWARE_LOST_AT] = world.time + if(old_state != new_state) + blackboard[BB_STEALTH_PREV_STATE] = old_state blackboard[BB_STEALTH_STATE] = new_state blackboard[BB_STEALTH_STATE_SINCE] = world.time // Only an alert guard goes after a locker it saw someone get into (decision 33). @@ -1291,6 +1293,21 @@ return TRUE return stealth_ai.blackboard[BB_STEALTH_UNAWARE_LOST_AT] == world.time +/** + * The state this guard was in when the current blow began (step 3a): unaware if stealth_was_unaware(), else the state + * before a change made this same tick (a bullet's prehit alerts it before the damage lands), else its state now. + * Null for any NPC without the stealth controller. + */ +/mob/living/carbon/human/npc/proc/stealth_state_at_blow() + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = ai_controller + if(!istype(stealth_ai)) + return null + if(stealth_was_unaware()) + return STEALTH_UNAWARE + if(stealth_ai.blackboard[BB_STEALTH_STATE_SINCE] == world.time && !isnull(stealth_ai.blackboard[BB_STEALTH_PREV_STATE])) + return stealth_ai.blackboard[BB_STEALTH_PREV_STATE] + return stealth_ai.stealth_state() + // ===== Planning ===== /// Pathfinding movement with room for a long patrol leg. diff --git a/voidcrew/modules/stealth/stealth_crits.dm b/voidcrew/modules/stealth/stealth_crits.dm new file mode 100644 index 00000000000..f40e86720f4 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_crits.dm @@ -0,0 +1,122 @@ +/** + * # Stealth guards: crits on a guard caught unaware, and the head shot (step 3a, owner decisions 9, 16, 19) + * + * Nothing here deals damage of its own. A blow on a stealth guard that never saw it coming adds to hyperviolence's + * aimed crit roll (crit_roll.dm, hv_crit_situation_bonus()), so it only matters on an aimed hit that could crit + * anyway, it goes in before wound armour scales the roll, and every crit's own armour block still holds. + * + * - Who: a guard with the stealth controller, conscious, not held or cuffed, with no player in the body. Never a + * player (decision 19), never any other NPC. + * - When: by its state as the blow began (stealth_state_at_blow()). Unaware of everyone gets the full bonus; only + * suspicious, a smaller one; searching or alert, none. Searching gets none so that peek, shoot, hide and wait out + * the search can't farm it. + * - Head: aimed at the head, eyes or mouth, the bonus goes up again. + * - Backstab: the matte combat knife (stealth_knife.dm) adds STEALTH_BACKSTAB_BONUS from behind (tg's check_behind()), + * whatever the guard's state. + * + * hyperviolence had no head crit a bullet could cause, so a pistol shot to an unaware guard's head could do nothing a + * shot to an alert one couldn't. The head shot crit below is that crit, and only a stealth hit rolls it: everyone + * else's head shots (players on players included) are exactly as before. Numbers: data/stealth/STATUS.md, "Step 3a". + */ + +/// The roll bonus for this blow (STEALTH_CRIT_* and STEALTH_BACKSTAB_BONUS), or 0. No side effects. +/mob/living/carbon/human/npc/proc/stealth_crit_bonus(mob/living/attacker, atom/source, obj/item/bodypart/limb) + if(isnull(attacker) || attacker == src || client || stat != CONSCIOUS) + return 0 + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = ai_controller + if(!istype(stealth_ai) || stealth_ai.stealth_captive()) + return 0 + . = 0 + switch(stealth_state_at_blow()) + if(STEALTH_UNAWARE) + . = STEALTH_CRIT_UNAWARE_BONUS + if(STEALTH_SUSPICIOUS) + . = STEALTH_CRIT_SUSPICIOUS_BONUS + if(. && limb?.body_zone == BODY_ZONE_HEAD) + . += STEALTH_CRIT_HEAD_BONUS + if(istype(source, /obj/item/knife/combat/matte) && check_behind(attacker, src)) + . += STEALTH_BACKSTAB_BONUS + +/mob/living/carbon/human/npc/hv_crit_situation_bonus(mob/living/attacker, atom/source, obj/item/bodypart/limb) + . = ..() + var/bonus = stealth_crit_bonus(attacker, source, limb) + if(!bonus) + return . + log_combat(attacker, src, "struck a [stealth_state_at_blow()] stealth guard", source, "(crit roll +[bonus], [limb?.body_zone])") + return . + bonus + +// --------------------------------------------------------------------------------------------- +// Shot through the head: a bullet aimed at the head of a guard who didn't see it coming. A good enough helmet stops it. + +/datum/hv_crit/head_shot + name = "shot through the head" + limb_zone = BODY_ZONE_HEAD + aim_zones = list(BODY_ZONE_HEAD, BODY_ZONE_PRECISE_EYES, BODY_ZONE_PRECISE_MOUTH) + wounding_types = list(WOUND_PIERCE) + min_damage = STEALTH_HEAD_SHOT_MIN_DAMAGE + threshold = STEALTH_HEAD_SHOT_THRESHOLD + allow_projectiles = TRUE + wound_type = /datum/wound/pierce/bleed/critical/hv_head_shot + line_severity = HV_LINE_HUGE + line_range = DEFAULT_MESSAGE_RANGE + hit_sound = 'sound/effects/wounds/pierce3.ogg' + shake = 6 + +/datum/hv_crit/head_shot/matches(hit_zone, aimed_zone, wounding_type, from_projectile) + return from_projectile && ..() + +/datum/hv_crit/head_shot/blocked_on_carbon(mob/living/carbon/victim, obj/item/bodypart/limb, atom/source) + if(!ishumannpc(victim) || !isprojectile(source)) + return TRUE + var/mob/living/carbon/human/npc/guard = victim + var/obj/projectile/shot = source + if(!isliving(shot.firer) || guard.stealth_crit_bonus(shot.firer, source, limb) <= 0) + return TRUE + return hv_crit_cover_rating(victim, limb, hv_crit_attack_flag(source), hv_crit_armour_pen(source)) >= STEALTH_HEAD_SHOT_HELMET_ARMOUR + +/datum/hv_crit/head_shot/apply_carbon(mob/living/carbon/victim, obj/item/bodypart/limb, damage, attack_direction, atom/source, mob/living/attacker) + if(!hv_crit_apply_wound(limb, wound_type, attack_direction, source)) + return FALSE + victim.hv_blood_spray(attack_direction, 2) + announce(victim, attack_direction) + return TRUE + +/datum/hv_crit/head_shot/hit_line(mob/living/victim) + return "[victim] is shot through the head!" + +/datum/hv_crit/head_shot/self_line(mob/living/victim) + return "Something punches through your skull!" + +/** + * tg's ruptured cavity on the head, with a knock to the brain: brain damage, a knockdown, confusion and blurred eyes. + * Treated like any critical puncture (gauze, sutures, cautery, surgery); the brain damage heals like any other. + */ +/datum/wound/pierce/bleed/critical/hv_head_shot + name = "Penetrating Head Wound" + undiagnosed_name = "Head Wound" + desc = "Patient has been shot through the skull. The wound is bleeding heavily and the brain is injured." + simple_desc = "A bullet has gone through the skull." + examine_desc = "has a bloody hole punched through it" + occur_text = "is punched through" + +/datum/wound/pierce/bleed/critical/hv_head_shot/wound_injury(datum/wound/old_wound = null, attack_direction = null) + . = ..() + if(!victim) + return + victim.adjustOrganLoss(ORGAN_SLOT_BRAIN, STEALTH_HEAD_SHOT_BRAIN_DAMAGE) + if(victim.stat == DEAD) + return + victim.Knockdown(STEALTH_HEAD_SHOT_KNOCKDOWN) + victim.set_confusion_if_lower(15 SECONDS) + victim.adjust_eye_blur(10 SECONDS) + +/datum/wound_pregen_data/flesh_pierce/hv_head_shot + abstract = FALSE + wound_path_to_generate = /datum/wound/pierce/bleed/critical/hv_head_shot + required_wounding_types = list(WOUND_PIERCE) + wound_series = WOUND_SERIES_HV_HEAD_SHOT + required_limb_biostate = (BIO_FLESH|BIO_BLOODED) + ignore_cannot_bleed = FALSE + viable_zones = list(BODY_ZONE_HEAD) + can_be_randomly_generated = FALSE + threshold_minimum = 100 diff --git a/voidcrew/modules/stealth/stealth_knife.dm b/voidcrew/modules/stealth/stealth_knife.dm new file mode 100644 index 00000000000..83161cb34d5 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_knife.dm @@ -0,0 +1,13 @@ +/** + * # The matte combat knife (step 3a, owner decisions 5 and 12) + * + * tg's combat knife with a blackened blade. Its one difference: struck into a stealth guard from behind (tg's + * check_behind(), the heretic blade's backstab test), it adds STEALTH_BACKSTAB_BONUS to the aimed crit roll + * (stealth_crits.dm). On anyone else, players included, it is a plain combat knife. No new attack or animation. + * + * Players get it as scav den loot (step 4). It has no buy, print or craft route. + */ +/obj/item/knife/combat/matte + name = "matte combat knife" + desc = "A combat knife with a blackened blade that doesn't catch the light." + color = "#6E6E7D" diff --git a/voidcrew/modules/stealth/stealth_light.dm b/voidcrew/modules/stealth/stealth_light.dm index 58171b43193..745db2f5018 100644 --- a/voidcrew/modules/stealth/stealth_light.dm +++ b/voidcrew/modules/stealth/stealth_light.dm @@ -14,8 +14,9 @@ * Beating it is tg's: you see the beam coming; an EMP or the saboteur gun cuts it out for a while (the * scav seclite takes an EMP as tg's saboteur hit; a stock seclite ignores EMPs); a guard that is down, * stunned, cuffed, asleep or dead doesn't touch it. A light that is gone from its body (deleted, burnt, - * forced off) is gone: the guard goes without. Like the rest of its kit it is locked gear (human NPC - * decision D3), so it can't be stripped or looted. + * forced off) is gone: the guard goes without. Unlike the rest of its kit it is not locked gear (decision 34 + * amends human NPC decision D3): it can be stripped, knocked loose and looted like anyone's seclite. Once it has left + * a guard's body it is an ordinary seclite to the guards too (off the guard light list). */ /// Every guard's seclite, so a guard can leave them all out when it judges how dark its spot is @@ -32,6 +33,18 @@ GLOBAL_LIST_EMPTY(stealth_guard_lights) GLOB.stealth_guard_lights -= src return ..() +/// Off a guard's body (looted, stripped, dropped), it is just a seclite: no guard leaves its light out any more. +/obj/item/flashlight/seclite/scav/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE) + . = ..() + if(!ishumannpc(loc)) + GLOB.stealth_guard_lights -= src + +/// Decision 34: a guard's seclite is loot like anyone's, so it is never locked to the body (D3 holds for the rest). +/mob/living/carbon/human/npc/npc_lock_item(obj/item/item) + if(istype(item, /obj/item/flashlight/seclite/scav)) + return FALSE + return ..() + /obj/item/flashlight/seclite/scav/emp_act(severity) . = ..() if(. & EMP_PROTECT_SELF) diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index 0d2998b9e90..f3835654a04 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -236,6 +236,7 @@ #include "voidcrew_smart_locker.dm" #include "voidcrew_stealth.dm" #include "voidcrew_stealth_closet.dm" +#include "voidcrew_stealth_crits.dm" #include "voidcrew_stealth_d32.dm" #include "voidcrew_stealth_hearing.dm" #include "voidcrew_stealth_light.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_crits.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_crits.dm new file mode 100644 index 00000000000..28ba80d29f8 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_crits.dm @@ -0,0 +1,186 @@ +// Stealth crits, the head shot, the backstab knife and lootable seclites (step 3a, voidcrew/modules/stealth/stealth_crits.dm, +// stealth_knife.dm, stealth_light.dm). Values from voidcrew/_DEFINES are written out: STEALTH_CRIT_UNAWARE_BONUS 30, +// STEALTH_CRIT_SUSPICIOUS_BONUS 15, STEALTH_CRIT_HEAD_BONUS 35, STEALTH_BACKSTAB_BONUS 40, STEALTH_HEAD_SHOT_BRAIN_DAMAGE 40. + +/// The bonus by state: full when unaware, smaller when suspicious, none when searching or alert, more on the head; +/// never on a player or an NPC without the stealth controller. +/datum/unit_test/voidcrew_stealth_crit_bonus + +/datum/unit_test/voidcrew_stealth_crit_bonus/Run() + var/datum/turf_reservation/block = stealth_block(8, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 4, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 5, 2) + var/obj/item/knife/combat/knife = allocate(/obj/item/knife/combat) + person.put_in_active_hand(knife) + var/obj/item/bodypart/head = guard.get_bodypart(BODY_ZONE_HEAD) + var/obj/item/bodypart/chest = guard.get_bodypart(BODY_ZONE_CHEST) + TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, chest), 30, "Wrong bonus on an unaware guard") + TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, head), 65, "Wrong bonus on an unaware guard's head") + TEST_ASSERT_EQUAL(guard.hv_crit_situation_bonus(person, knife, head), 65, "The crit roll doesn't get the stealth bonus") + stealth_ai.stealth_go_suspicious(stealth_at(block, 1, 2)) + TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, chest), 30, "A guard that turned suspicious this tick lost the unaware bonus") + stealth_ai.stealth_rewind(1) + TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, chest), 15, "Wrong bonus on a suspicious guard") + TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, head), 50, "Wrong bonus on a suspicious guard's head") + // The blow that alerts it still counts as one on a suspicious guard (a bullet's prehit alerts it first). + stealth_ai.stealth_go_alert(person) + TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, chest), 15, "The blow that alerted a suspicious guard lost its bonus") + stealth_ai.stealth_rewind(1) + TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, head), 0, "An alert guard gives a stealth bonus") + stealth_ai.stealth_go_searching(stealth_at(block, 1, 2)) + stealth_ai.stealth_rewind(1) + TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, head), 0, "A searching guard gives a stealth bonus") + // Unaware, but down or held: the helpless bonus is the one that counts there. + stealth_ai.stealth_go_unaware() + stealth_ai.stealth_rewind(1) + TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, chest), 30, "Back to unaware, no bonus") + var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs) + TEST_ASSERT(guard.equip_to_slot_if_possible(cuffs, ITEM_SLOT_HANDCUFFED), "Test fixture: the guard can't be cuffed") + TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, chest), 0, "A cuffed guard gives a stealth bonus") + // Never on a player, nor on an NPC without the stealth controller. + var/mob/living/carbon/human/player = stealth_person(block, 2, 4) + TEST_ASSERT_EQUAL(player.hv_crit_situation_bonus(person, knife, player.get_bodypart(BODY_ZONE_HEAD)), 0, "A person gets a stealth bonus") + var/mob/living/carbon/human/npc/plain = allocate(/mob/living/carbon/human/npc/ruin/trooper/syndicate, stealth_at(block, 1, 4)) + TEST_ASSERT_EQUAL(plain.stealth_crit_bonus(person, knife, plain.get_bodypart(BODY_ZONE_HEAD)), 0, "An NPC without stealth gets a stealth bonus") + qdel(block) + +/// The matte knife adds its bonus from behind only, on an alert guard too; a plain knife never does. +/datum/unit_test/voidcrew_stealth_backstab + +/datum/unit_test/voidcrew_stealth_backstab/Run() + var/datum/turf_reservation/block = stealth_block(8, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 4, 2) // facing east + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 3, 2) // behind it + var/obj/item/knife/combat/matte/knife = allocate(/obj/item/knife/combat/matte) + var/obj/item/knife/combat/blade = allocate(/obj/item/knife/combat) + person.put_in_active_hand(knife) + var/obj/item/bodypart/head = guard.get_bodypart(BODY_ZONE_HEAD) + var/obj/item/bodypart/chest = guard.get_bodypart(BODY_ZONE_CHEST) + TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, head), 105, "Wrong bonus for a backstab to an unaware guard's head") + stealth_ai.stealth_go_alert(person) + stealth_ai.stealth_rewind(1) + guard.setDir(EAST) + TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, chest), 40, "Wrong backstab bonus on an alert guard") + TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, blade, chest), 0, "A plain knife backstabs") + // From the front and from the side: nothing. + person.forceMove(stealth_at(block, 5, 2)) + TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, chest), 0, "The knife backstabs from the front") + person.forceMove(stealth_at(block, 4, 3)) + TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, chest), 0, "The knife backstabs from the side") + // A player from behind: a plain knife. + var/mob/living/carbon/human/player = stealth_person(block, 6, 4) + player.setDir(EAST) + person.forceMove(stealth_at(block, 5, 4)) + TEST_ASSERT_EQUAL(player.hv_crit_situation_bonus(person, knife, player.get_bodypart(BODY_ZONE_CHEST)), 0, "The knife backstabs a person") + qdel(block) + +/// Wound armour scales the bonus with the rest of the roll, and a helmet stops the head shot outright. +/datum/unit_test/voidcrew_stealth_crit_armour + +/datum/unit_test/voidcrew_stealth_crit_armour/Run() + var/datum/turf_reservation/block = stealth_block(8, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 4, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 6, 2) + var/obj/item/knife/combat/knife = allocate(/obj/item/knife/combat) + person.put_in_active_hand(knife) + var/obj/item/bodypart/head = guard.get_bodypart(BODY_ZONE_HEAD) + if(guard.head) + qdel(guard.head) + // 1 damage makes tg's own roll 1, so the rest of the roll is exact. + var/bare = head.hv_crit_roll(WOUND_SLASH, 1, 0, 0, person, knife) + TEST_ASSERT(bare > 55, "An unaware bare head rolled only [bare]") + var/obj/item/clothing/head/helmet/swat/helmet = new(guard) + TEST_ASSERT(guard.equip_to_slot_if_possible(helmet, ITEM_SLOT_HEAD, disable_warning = TRUE), "Couldn't put a helmet on the guard") + var/armoured = head.hv_crit_roll(WOUND_SLASH, 1, 0, 0, person, knife) + TEST_ASSERT(armoured < bare, "A helmet didn't lower the stealth roll ([armoured] vs [bare])") + // The head shot: a 9mm through a SWAT helmet is stopped; with the helmet off it isn't. + var/datum/hv_crit/head_shot/crit = locate() in GLOB.hv_crits + TEST_ASSERT_NOTNULL(crit, "No head shot crit") + var/obj/projectile/bullet/c9mm/shot = allocate(/obj/projectile/bullet/c9mm) + shot.firer = person + TEST_ASSERT(crit.blocked_on_carbon(guard, head, shot), "A SWAT helmet doesn't stop a 9mm head shot") + qdel(helmet) + TEST_ASSERT(!crit.blocked_on_carbon(guard, head, shot), "A bare-headed unaware guard is safe from a head shot") + // Alert: no stealth hit, so no head shot. + stealth_ai.stealth_go_alert(person) + stealth_ai.stealth_rewind(1) + TEST_ASSERT(crit.blocked_on_carbon(guard, head, shot), "An alert guard can be head shot") + var/roll = head.hv_crit_roll(WOUND_SLASH, 1, 0, 0, person, knife) + TEST_ASSERT(roll < 5, "An alert guard's roll still has a bonus ([roll])") + qdel(block) + +/// A head shot lands on an unaware guard and does real harm through tg's wound; never on a person or an alert guard. +/datum/unit_test/voidcrew_stealth_head_shot + +/datum/unit_test/voidcrew_stealth_head_shot/Run() + var/datum/turf_reservation/block = stealth_block(8, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 4, 2) + var/mob/living/carbon/human/person = stealth_person(block, 1, 2) + var/obj/projectile/bullet/c9mm/shot = allocate(/obj/projectile/bullet/c9mm) + shot.firer = person + if(guard.head) + qdel(guard.head) + var/obj/item/bodypart/head = guard.get_bodypart(BODY_ZONE_HEAD) + var/datum/hv_crit/crit = guard.hv_try_aimed_crit(head, BODY_ZONE_HEAD, WOUND_PIERCE, 30, 0, 0, EAST, shot, person, 500) + TEST_ASSERT(istype(crit, /datum/hv_crit/head_shot), "A forced head shot on an unaware guard didn't land (got [crit])") + TEST_ASSERT_NOTNULL(head.get_wound_type(/datum/wound/pierce/bleed/critical/hv_head_shot), "No head shot wound") + TEST_ASSERT(guard.get_organ_loss(ORGAN_SLOT_BRAIN) >= 40, "The head shot did no brain damage") + TEST_ASSERT(guard.IsKnockdown(), "The head shot didn't knock the guard down") + // Not from a knife. + var/mob/living/carbon/human/npc/second = stealth_guard(block, 6, 3) + if(second.head) + qdel(second.head) + var/obj/item/knife/combat/knife = allocate(/obj/item/knife/combat) + crit = second.hv_try_aimed_crit(second.get_bodypart(BODY_ZONE_HEAD), BODY_ZONE_HEAD, WOUND_PIERCE, 30, 0, 0, EAST, knife, person, 500) + TEST_ASSERT(!istype(crit, /datum/hv_crit/head_shot), "A knife caused a head shot") + // Never on a person. + var/mob/living/carbon/human/player = stealth_person(block, 2, 4) + crit = player.hv_try_aimed_crit(player.get_bodypart(BODY_ZONE_HEAD), BODY_ZONE_HEAD, WOUND_PIERCE, 30, 0, 0, EAST, shot, person, 500) + TEST_ASSERT_NULL(crit, "A person took a head shot crit") + // Never on an alert guard. + var/mob/living/carbon/human/npc/third = stealth_guard(block, 1, 4) + if(third.head) + qdel(third.head) + var/datum/ai_controller/basic_controller/human_npc/stealth/third_ai = stealth_ai(third) + third_ai.stealth_go_alert(person) + third_ai.stealth_rewind(1) + crit = third.hv_try_aimed_crit(third.get_bodypart(BODY_ZONE_HEAD), BODY_ZONE_HEAD, WOUND_PIERCE, 30, 0, 0, EAST, shot, person, 500) + TEST_ASSERT_NULL(crit, "An alert guard took a head shot crit") + qdel(block) + +/// Decision 34: the seclite strips and drops like anyone's; the rest of the kit stays locked; the guard carries on without it. +/datum/unit_test/voidcrew_stealth_seclite_loot + +/datum/unit_test/voidcrew_stealth_seclite_loot/Run() + var/datum/turf_reservation/block = stealth_block(8, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 4, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/obj/item/flashlight/light = stealth_ai.stealth_light() + TEST_ASSERT_NOTNULL(light, "A scav guard has no flashlight") + TEST_ASSERT(!HAS_TRAIT(light, TRAIT_NO_STRIP), "The seclite can't be stripped") + TEST_ASSERT(!human_npc_gear_locked(light), "The seclite is locked gear") + TEST_ASSERT(human_npc_gear_locked(guard.w_uniform), "The rest of the guard's kit isn't locked any more") + TEST_ASSERT(light in GLOB.stealth_guard_lights, "The seclite isn't on the guard light list") + var/mob/living/carbon/human/person = stealth_person(block, 3, 2) + TEST_ASSERT(guard.dropItemToGround(light), "The seclite can't be taken off") + TEST_ASSERT(person.put_in_hands(light), "The seclite can't be picked up") + TEST_ASSERT(!QDELETED(light), "The looted seclite was deleted") + TEST_ASSERT(!(light in GLOB.stealth_guard_lights), "A looted seclite still counts as a guard's") + // The guard goes without: no light to switch, and it still scans and sees. + TEST_ASSERT_NULL(stealth_ai.stealth_light(), "The guard still counts the light it lost") + GLOB.stealth_test_dark_turfs[get_turf(guard)] = TRUE + stealth_ai.stealth_update_light() + TEST_ASSERT(!light.light_on, "The guard switched on a light a player holds") + GLOB.stealth_test_dark_turfs[get_turf(guard)] = FALSE + person.forceMove(stealth_at(block, 5, 2)) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard without its light didn't see someone in front of it") + qdel(block) From 9764ada71082004adf421834147718ce482b8bba Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Wed, 11 Nov 2026 02:27:46 -0800 Subject: [PATCH 22/78] Guards hear glass underfoot, notice doors moving and get sharper by zone Stepping on broken glass or a dropped bulb makes a small noise guards go to look at, even at a walk. Every door a player opens or shuts makes a small noise, and a guard who sees one move goes to look unless one of its own is beside it; a door that keeps moving is only looked at twice in three minutes. Guard skill comes from a green, yellow or red profile picked by the den's zone, a mapper var or an admin action; yellow is the old tuning. A gunner now steps back two tiles to shoot open a locked locker, since a gun beside one only bashes it. --- tgstation.dme | 2 + voidcrew/_DEFINES/stealth.dm | 9 + voidcrew/_DEFINES/stealth_hearing.dm | 7 + .../modules/human_npcs/human_npc_spawning.dm | 6 +- voidcrew/modules/stealth/stealth_admin.dm | 36 ++- voidcrew/modules/stealth/stealth_ai.dm | 77 +++--- voidcrew/modules/stealth/stealth_closet.dm | 53 +++- voidcrew/modules/stealth/stealth_doors.dm | 162 ++++++++++++ voidcrew/modules/stealth/stealth_hearing.dm | 7 +- voidcrew/modules/stealth/stealth_meter.dm | 18 +- voidcrew/modules/stealth/stealth_noise.dm | 21 +- .../modules/stealth/stealth_noise_sources.dm | 35 ++- voidcrew/modules/stealth/stealth_patrol.dm | 2 + voidcrew/modules/stealth/stealth_skill.dm | 162 ++++++++++++ voidcrew/modules/unit_tests/_unit_tests.dm | 1 + .../unit_tests/voidcrew_stealth_closet.dm | 9 +- .../unit_tests/voidcrew_stealth_d37.dm | 237 ++++++++++++++++++ 17 files changed, 767 insertions(+), 77 deletions(-) create mode 100644 voidcrew/modules/stealth/stealth_doors.dm create mode 100644 voidcrew/modules/stealth/stealth_skill.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_stealth_d37.dm diff --git a/tgstation.dme b/tgstation.dme index 605ee7f38c9..c59c35a66a4 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7734,6 +7734,7 @@ #include "voidcrew\modules\stealth\stealth_ai.dm" #include "voidcrew\modules\stealth\stealth_closet.dm" #include "voidcrew\modules\stealth\stealth_crits.dm" +#include "voidcrew\modules\stealth\stealth_doors.dm" #include "voidcrew\modules\stealth\stealth_hearing.dm" #include "voidcrew\modules\stealth\stealth_knife.dm" #include "voidcrew\modules\stealth\stealth_light.dm" @@ -7743,6 +7744,7 @@ #include "voidcrew\modules\stealth\stealth_patrol.dm" #include "voidcrew\modules\stealth\stealth_perception.dm" #include "voidcrew\modules\stealth\stealth_radio.dm" +#include "voidcrew\modules\stealth\stealth_skill.dm" #include "voidcrew\modules\stealth\stealth_test_ruin.dm" #include "voidcrew\modules\storage\smart_locker.dm" #include "voidcrew\modules\storage\wall_locker.dm" diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index ac36f1e9470..e5c63d3e6f3 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -140,6 +140,15 @@ /// A guard that isn't the one opening it stands this close and covers it #define STEALTH_CLOSET_COVER_RANGE 3 +// Doors seen moving (decision 37, stealth_doors.dm) +/// A door one of the group opened: its next close this soon after is theirs too (an airlock shuts itself after 6 s) +#define STEALTH_DOOR_GUARD_MEMORY (20 SECONDS) +/// After a door sent someone to look, it only gets glances for this long +#define STEALTH_DOOR_CUE_COOLDOWN (30 SECONDS) +/// A door that sent someone to look STEALTH_DOOR_CUE_MAX times within this long is ignored for the rest of it +#define STEALTH_DOOR_CUE_MEMORY (3 MINUTES) +#define STEALTH_DOOR_CUE_MAX 2 + // The mark over a guard's head (stealth_meter.dm, owner decision 27) /// Pixel rows in the "?" and "!" glyphs: fill and drain steps #define STEALTH_METER_ROWS 7 diff --git a/voidcrew/_DEFINES/stealth_hearing.dm b/voidcrew/_DEFINES/stealth_hearing.dm index 4b8d3488bbe..6bc724f1052 100644 --- a/voidcrew/_DEFINES/stealth_hearing.dm +++ b/voidcrew/_DEFINES/stealth_hearing.dm @@ -16,6 +16,8 @@ #define STEALTH_NOISE_VOICE "voice" #define STEALTH_NOISE_SCREAM "scream" #define STEALTH_NOISE_SHOUT "shout" +/// A step on broken glass or a dropped bulb (decision 37) +#define STEALTH_NOISE_CRUNCH "crunch" /// Every kind, for the admin verb and the tests #define STEALTH_NOISE_KINDS list(\ @@ -34,6 +36,7 @@ STEALTH_NOISE_VOICE,\ STEALTH_NOISE_SCREAM,\ STEALTH_NOISE_SHOUT,\ + STEALTH_NOISE_CRUNCH,\ ) // ===== What a guard does about a noise ===== @@ -105,6 +108,10 @@ #define STEALTH_NOISE_RANGE_VOICE 5 #define STEALTH_NOISE_RANGE_SCREAM 9 #define STEALTH_NOISE_RANGE_SHOUT 9 +/// A step on glass (tg plays it at 50: a player hears it 12 tiles off) +#define STEALTH_NOISE_RANGE_CRUNCH 4 +/// The same with TRAIT_LIGHT_STEP (tg plays it at 30: 9 tiles) +#define STEALTH_NOISE_RANGE_CRUNCH_LIGHT 2 /// Tiles of reach a wall eats #define STEALTH_MUFFLE_WALL 3 /// Tiles of reach a closed solid door eats diff --git a/voidcrew/modules/human_npcs/human_npc_spawning.dm b/voidcrew/modules/human_npcs/human_npc_spawning.dm index c5f583c9d6b..6a123285c4d 100644 --- a/voidcrew/modules/human_npcs/human_npc_spawning.dm +++ b/voidcrew/modules/human_npcs/human_npc_spawning.dm @@ -288,6 +288,10 @@ SUBSYSTEM_DEF(human_npcs) /// family's own root subtype sets this to itself (tests make one of every type). var/abstract_spawner_type = /obj/effect/spawner/human_npc +/// Called with the NPC once it is built, or null. Must not hold a ref to the spawner: it is gone by then. +/obj/effect/spawner/human_npc/proc/npc_spawned_callback() + return null + /obj/effect/spawner/human_npc/Initialize(mapload) . = ..() if(!ispath(npc_type, /mob/living/carbon/human/npc)) @@ -300,4 +304,4 @@ SUBSYSTEM_DEF(human_npcs) return #endif // The mapped spawner's dir is the way the NPC faces. - spawn_human_npc(npc_type, get_turf(src), name = npc_name, faction = npc_faction, context = get_npc_spawn_context(), dir = dir) + spawn_human_npc(npc_type, get_turf(src), npc_spawned_callback(), name = npc_name, faction = npc_faction, context = get_npc_spawn_context(), dir = dir) diff --git a/voidcrew/modules/stealth/stealth_admin.dm b/voidcrew/modules/stealth/stealth_admin.dm index 3e695d07f17..f3b50b96257 100644 --- a/voidcrew/modules/stealth/stealth_admin.dm +++ b/voidcrew/modules/stealth/stealth_admin.dm @@ -34,8 +34,8 @@ var/state_text = stealth_ai.calm_until ? "[stealth_ai.stealth_state()] (calming)" : stealth_ai.stealth_state() var/wary_text = "calm" if(stealth_ai.blackboard[BB_STEALTH_WARY]) - wary_text = "wary [max(0, round((STEALTH_WARY_TIME - (world.time - stealth_ai.wary_at)) / (1 SECONDS)))]s" - return "[guard.real_name] [REF(guard)] | [stealth_ai.group?.id || "no group"] | [state_text] [since]s | focus [focus_text] | [wary_text] | [route_text] | AI [status_text] | [stealth_guard_hearing_summary(guard, stealth_ai)]" + wary_text = "wary [max(0, round((stealth_ai.stealth_skill().wary_time - (world.time - stealth_ai.wary_at)) / (1 SECONDS)))]s" + return "[guard.real_name] [REF(guard)] | [stealth_ai.group?.id || "no group"] | [stealth_ai.stealth_skill().name][stealth_ai.skill_forced ? " (set)" : ""] | [state_text] [since]s | focus [focus_text] | [wary_text] | [route_text] | AI [status_text] | [stealth_guard_hearing_summary(guard, stealth_ai)]" ADMIN_VERB(stealth_guards, R_DEBUG, "Stealth Guards", "View and force the awareness of stealth guards on your z-level.", ADMIN_CATEGORY_DEBUG) var/turf/here = get_turf(user.mob) @@ -74,7 +74,7 @@ ADMIN_VERB(stealth_guards, R_DEBUG, "Stealth Guards", "View and force the awaren var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller if(QDELETED(guard) || !istype(stealth_ai)) return - var/list/actions = list("Force Unaware", "Force Suspicious at my turf", "Force Alert on me", "Force Alert on a mob I pick", "Force Searching at my turf", "Toggle Wary", "Show its sight", "Jump to it", "Next stop", "Hear a noise here", "Start radio call (alarm at my turf)") + var/list/actions = list("Force Unaware", "Force Suspicious at my turf", "Force Alert on me", "Force Alert on a mob I pick", "Force Searching at my turf", "Toggle Wary", "Show its sight", "Jump to it", "Next stop", "Hear a noise here", "Start radio call (alarm at my turf)", "Set skill") var/action = tgui_input_list(user, stealth_guard_summary(guard), "Stealth Guard", actions) if(isnull(action) || QDELETED(guard)) return @@ -123,6 +123,13 @@ ADMIN_VERB(stealth_guards, R_DEBUG, "Stealth Guards", "View and force the awaren if(!stealth_ai.stealth_start_call(STEALTH_CALL_ALARM, here)) to_chat(user, span_warning("It carries no radio."), confidential = TRUE) return + if("Set skill") + var/list/skills = list("Green" = /datum/stealth_skill/green, "Yellow" = /datum/stealth_skill/yellow, "Red" = /datum/stealth_skill/red, "Back to its zone's (or mapper's)" = null) + var/picked = tgui_input_list(user, "Its skill is [stealth_ai.stealth_skill().name].", "Stealth Guard", skills) + if(isnull(picked) || QDELETED(guard)) + return + stealth_ai.stealth_force_skill(skills[picked]) + action = "Set skill to [stealth_ai.stealth_skill().name]" if("Next stop") var/next = stealth_ai.stealth_next_index() if(next) @@ -132,12 +139,22 @@ ADMIN_VERB(stealth_guards, R_DEBUG, "Stealth Guards", "View and force the awaren stealth_admin_log(user, "[action] on [key_name(guard)]", guard) /proc/stealth_admin_group(client/user, datum/stealth_group/group) - var/list/actions = list("Calm all", "Clear wary", "Alert all on me", "Search all at my turf", "Show every route", "Radio alarm at my turf", "Show noise memory", "Forget noises") + var/list/actions = list("Calm all", "Clear wary", "Alert all on me", "Search all at my turf", "Show every route", "Radio alarm at my turf", "Show noise memory", "Forget noises", "Set skill of all") var/action = tgui_input_list(user, "[group.id]: [length(group.living_members())] guards", "Stealth Group", actions) if(isnull(action) || QDELETED(group)) return var/turf/here = get_turf(user.mob) - if(action == "Show every route") + if(action == "Set skill of all") + var/list/skills = list("Green" = /datum/stealth_skill/green, "Yellow" = /datum/stealth_skill/yellow, "Red" = /datum/stealth_skill/red, "Back to their zone's (or mapper's)" = null) + var/picked = tgui_input_list(user, "Skill for every guard in [group.id]", "Stealth Group", skills) + if(isnull(picked) || QDELETED(group)) + return + for(var/mob/living/guard as anything in group.living_members()) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + if(istype(stealth_ai)) + stealth_ai.stealth_force_skill(skills[picked]) + action = "Set skill of all to [picked]" + else if(action == "Show every route") stealth_show_routes(user, group) else if(action == "Radio alarm at my turf") group.next_radio_alarm = 0 @@ -305,15 +322,16 @@ GLOBAL_LIST_EMPTY(stealth_sight_overlays) var/eyes = stealth_ai.stealth_eyes_open() var/half_angle = stealth_ai.stealth_half_angle() var/night = HAS_TRAIT(guard, TRAIT_NIGHT_VISION) - for(var/turf/tile as anything in RANGE_TURFS(STEALTH_SIGHT_RANGE, center)) + var/datum/stealth_skill/profile = stealth_ai.stealth_skill() + for(var/turf/tile as anything in RANGE_TURFS(profile.sight_range, center)) var/dist = get_dist(center, tile) var/colour - if(eyes && stealth_in_cone(guard, tile, half_angle) && can_see(center, tile, STEALTH_SIGHT_RANGE)) - if(dist <= STEALTH_DARK_SIGHT_RANGE || night) + if(eyes && stealth_in_cone(guard, tile, half_angle) && can_see(center, tile, profile.sight_range)) + if(dist <= profile.dark_sight_range || night) colour = "#3399ff" else colour = "#33cc33" - if(dist <= STEALTH_CLOSE_RANGE) + if(dist <= profile.close_range) colour = colour || "#ffcc00" if(isnull(colour)) continue diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index fc7af3be449..e34a18b8a10 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -35,10 +35,10 @@ * notices others, and turns on someone clearly nearer or on anyone who hits it, at most once per * STEALTH_SWITCH_COOLDOWN (decision 29). * - Searching: runs to where it last saw someone and sweeps the spots round it, then gives up. A glimpse - * of anyone within STEALTH_ALERT_MAX_RANGE while it searches is an alert at once. + * of anyone within its alert range (its skill's alert_max_range) while it searches is an alert at once. * * Wary (BB_STEALTH_WARY) is set by any alert, search, hit or surrender: a wider cone and quicker notice - * (abuse review P4). It fades after STEALTH_WARY_TIME with nothing new: every notice gain, hit, touch and + * (abuse review P4). It fades after its skill's wary_time with nothing new: every notice gain, hit, touch and * scan spent alert or searching starts that clock again (owner decision 23). * * Putting its target down (dead or in crit) with nobody else noticed ends the alarm: a short line, a look @@ -330,14 +330,14 @@ blackboard[BB_STEALTH_WARY] = FALSE wary_at = 0 -/// Each scan: alert or searching keeps it wary; otherwise wary fades once STEALTH_WARY_TIME passes with nothing new. +/// Each scan: alert or searching keeps it wary; otherwise wary fades once its skill's wary_time passes with nothing new. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_update_wary() if(!blackboard[BB_STEALTH_WARY]) return var/state = stealth_state() if(state == STEALTH_ALERT || state == STEALTH_SEARCHING) wary_at = world.time - else if(world.time - wary_at >= STEALTH_WARY_TIME) + else if(world.time - wary_at >= stealth_skill().wary_time) stealth_clear_wary() /// Walks (calm) or runs, through tg's own move intent, as bounty_ai_set_pace() does. @@ -575,7 +575,7 @@ if(state == STEALTH_SEARCHING && calm_until) if(world.time >= calm_until) stealth_go_unaware() - else if(state == STEALTH_SEARCHING && world.time - blackboard[BB_STEALTH_STATE_SINCE] >= STEALTH_SEARCH_TIME) + else if(state == STEALTH_SEARCHING && world.time - blackboard[BB_STEALTH_STATE_SINCE] >= stealth_skill().search_time) // "Nothing." over a dead friend reads wrong: a search over a body ends without a word. if(!search_for_body) stealth_bark(STEALTH_BARK_GIVE_UP) @@ -604,11 +604,12 @@ /// The cone half-angle it sees with now. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_half_angle() + var/datum/stealth_skill/profile = stealth_skill() if(stealth_state() == STEALTH_SEARCHING) - return STEALTH_SEARCH_HALF_ANGLE + return profile.search_half_angle if(blackboard[BB_STEALTH_WARY]) - return STEALTH_WARY_HALF_ANGLE - return STEALTH_CONE_HALF_ANGLE + return profile.wary_half_angle + return profile.cone_half_angle /// Whether its eyes work: not blind, not lying down (the close radius still works either way). /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_eyes_open() @@ -626,9 +627,10 @@ /// How far it sees onto `tile` in its cone: shorter in the dark unless it sees in the dark. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_range_onto(turf/tile) + var/datum/stealth_skill/profile = stealth_skill() if(!HAS_TRAIT(pawn, TRAIT_NIGHT_VISION) && stealth_tile_is_dark(tile)) - return STEALTH_DARK_SIGHT_RANGE - return STEALTH_SIGHT_RANGE + return profile.dark_sight_range + return profile.sight_range /** * Looks for people: raises notice on whoever it perceives, decays the rest, changes state. Alert, it leaves @@ -647,12 +649,15 @@ var/atom/focus = blackboard[BB_STEALTH_FOCUS] var/eyes = stealth_eyes_open() var/half_angle = stealth_half_angle() + var/datum/stealth_skill/profile = stealth_skill() + var/sight_range = profile.sight_range + var/close_range = profile.close_range var/scan_seconds = STEALTH_SCAN_INTERVAL / (1 SECONDS) var/list/perceived = list() var/list/was_hidden = hidden_spots var/list/now_hidden var/judged = 0 - // Someone it plainly sees within STEALTH_POINT_BLANK_RANGE: an alert on this look (decision 32). Nearest first. + // Someone it plainly sees within its point-blank range: an alert on this look (decision 32). Nearest first. var/mob/living/point_blank // The close radius out of its cone works by the light that is there, not by its own beam (decision 32). var/obj/item/flashlight/own_light = stealth_light() @@ -686,41 +691,41 @@ if(candidate == target) continue var/dist = get_dist(guard, where) - if(dist > STEALTH_SIGHT_RANGE) + if(dist > sight_range) continue if(boxed) // Searching, it saw them on open ground a moment ago, and now they are in a locker it can see (decision 33). - if(state == STEALTH_SEARCHING && eyes && dist <= STEALTH_ALERT_MAX_RANGE && stealth_closet_glimpsed(candidate, stealth_shell_of(candidate))) - if(strategy.can_attack(guard, candidate, STEALTH_SIGHT_RANGE)) + if(state == STEALTH_SEARCHING && eyes && dist <= profile.alert_max_range && stealth_closet_glimpsed(candidate, stealth_shell_of(candidate))) + if(strategy.can_attack(guard, candidate, sight_range)) stealth_go_alert(candidate) return // Hidden, unless the thing they hide in moves at its shoulder (decision 29). - if(dist > STEALTH_CLOSE_RANGE + 1) + if(dist > close_range + 1) continue LAZYSET(now_hidden, key, where) var/turf/stood = was_hidden?[key] - if(dist > STEALTH_CLOSE_RANGE || isnull(stood) || stood == where) + if(dist > close_range || isnull(stood) || stood == where) continue - if(!strategy.can_attack(guard, candidate, STEALTH_SIGHT_RANGE)) + if(!strategy.can_attack(guard, candidate, sight_range)) continue judged++ var/rate = 0 var/plain_sight = FALSE if(boxed) - rate = STEALTH_NOTICE_RATE + rate = profile.notice_rate else if(eyes && !stealth_is_cloaked(candidate) && stealth_in_cone(guard, where, half_angle)) // Elbow to elbow in front of it: seen whatever the light (decision 31). Behind or side-on, the // close radius below still applies. - var/cap = dist <= STEALTH_ADJACENT_RANGE ? STEALTH_SIGHT_RANGE : stealth_range_onto(where) + var/cap = dist <= STEALTH_ADJACENT_RANGE ? sight_range : stealth_range_onto(where) if(dist <= cap) - rate = STEALTH_NOTICE_RATE * clamp((cap + 1 - dist) / cap, STEALTH_NOTICE_MIN_FALLOFF, 1) - if(cap < STEALTH_SIGHT_RANGE) + rate = profile.notice_rate * clamp((cap + 1 - dist) / cap, STEALTH_NOTICE_MIN_FALLOFF, 1) + if(cap < sight_range) rate *= STEALTH_DARK_MULT // Close in front of it, seen plainly: no slow double take (decision 32). - plain_sight = cap == STEALTH_SIGHT_RANGE && dist <= STEALTH_POINT_BLANK_RANGE - if(dist <= STEALTH_NEAR_RANGE) - rate *= STEALTH_NEAR_MULT - if(!rate && dist <= STEALTH_CLOSE_RANGE && (night_vision || !stealth_tile_is_dark(where, own_light))) + plain_sight = cap == sight_range && dist <= profile.point_blank_range + if(dist <= profile.near_range) + rate *= profile.near_mult + if(!rate && dist <= close_range && (night_vision || !stealth_tile_is_dark(where, own_light))) // At its shoulder, in light that is there anyway (abuse P7). Its own beam points ahead, so it // doesn't count here: someone standing still right behind it in the dark is not seen (decision 32). rate = STEALTH_BEHIND_RATE @@ -798,7 +803,7 @@ var/turf/best_turf = best_entry[STEALTH_ENTRY_TURF] var/seen_now = !isnull(seen_key) // No alert by sight from off-screen (abuse P8). - var/in_reach = get_dist(guard, best_turf) <= STEALTH_ALERT_MAX_RANGE + var/in_reach = get_dist(guard, best_turf) <= profile.alert_max_range switch(state) if(STEALTH_UNAWARE) if(level >= STEALTH_SUSPICIOUS_AT) @@ -839,7 +844,7 @@ /** * Between scans (planning runs every half second, the scan once a second): someone it plainly sees within - * STEALTH_POINT_BLANK_RANGE is an alert now, not at the next scan. The same rules as the point-blank part of + * its point-blank range is an alert now, not at the next scan. The same rules as the point-blank part of * stealth_look(): eyes open, not cloaked, on a turf of their own, in its cone, and lit or at its elbow. * One spatial grid lookup of two tiles; nothing else. Returns TRUE if it went alert. */ @@ -853,14 +858,15 @@ if(isnull(strategy)) return FALSE var/half_angle = stealth_half_angle() - for(var/mob/living/candidate as anything in stealth_candidates(guard, STEALTH_POINT_BLANK_RANGE)) + var/datum/stealth_skill/profile = stealth_skill() + for(var/mob/living/candidate as anything in stealth_candidates(guard, profile.point_blank_range)) var/turf/where = candidate.loc if(!isturf(where) || stealth_is_cloaked(candidate) || !stealth_in_cone(guard, where, half_angle)) continue var/dist = get_dist(guard, where) - if(dist > STEALTH_ADJACENT_RANGE && stealth_range_onto(where) < STEALTH_SIGHT_RANGE) + if(dist > STEALTH_ADJACENT_RANGE && stealth_range_onto(where) < profile.sight_range) continue - if(!strategy.can_attack(guard, candidate, STEALTH_SIGHT_RANGE)) + if(!strategy.can_attack(guard, candidate, profile.sight_range)) continue var/key = REF(candidate) var/list/entry = notice_map[key] @@ -899,7 +905,7 @@ if(thing == target) continue var/dist = get_dist(guard, thing) - if(dist > STEALTH_ALERT_MAX_RANGE || dist >= pick_dist) + if(dist > stealth_skill().alert_max_range || dist >= pick_dist) continue if(!target_unseen && dist + STEALTH_SWITCH_MARGIN > target_dist) continue @@ -1017,6 +1023,7 @@ var/list/seen = blackboard[BB_STEALTH_BODIES_SEEN] var/eyes = stealth_eyes_open() var/half_angle = stealth_half_angle() + var/sight_range = stealth_skill().sight_range for(var/mob/living/member as anything in group.living_members()) if(member == guard) continue @@ -1035,12 +1042,12 @@ if(isnull(where) || where.z != guard.z) continue var/dist = get_dist(guard, where) - if(dist > STEALTH_SIGHT_RANGE) + if(dist > sight_range) continue - var/in_sight = dist <= STEALTH_CLOSE_RANGE + var/in_sight = dist <= stealth_skill().close_range if(!in_sight && eyes && stealth_in_cone(guard, where, half_angle)) in_sight = dist <= stealth_range_onto(where) - if(!in_sight || !can_see(guard, where, STEALTH_SIGHT_RANGE)) + if(!in_sight || !can_see(guard, where, sight_range)) continue seen += key var/news = !(key in group.reported_bodies) @@ -1376,7 +1383,7 @@ return switch(controller.stealth_state()) if(STEALTH_SUSPICIOUS) - if(world.time < controller.blackboard[BB_STEALTH_STATE_SINCE] + STEALTH_INVESTIGATE_DELAY) + if(world.time < controller.blackboard[BB_STEALTH_STATE_SINCE] + controller.stealth_skill().reaction_delay) controller.queue_behavior(/datum/ai_behavior/stealth_stand) return SUBTREE_RETURN_FINISH_PLANNING if(!controller.investigated) diff --git a/voidcrew/modules/stealth/stealth_closet.dm b/voidcrew/modules/stealth/stealth_closet.dm index 537bef8e827..37afd2bddec 100644 --- a/voidcrew/modules/stealth/stealth_closet.dm +++ b/voidcrew/modules/stealth/stealth_closet.dm @@ -4,8 +4,9 @@ * An alert guard, or a searching one that glimpses someone, that sees its target get into a locker, a crate, a * coffin, a body bag or a cardboard box (any /obj/structure/closet), or sees the door shut on them, remembers * that container. It walks up and opens it with tg's own open(). If it won't open (locked or welded), it hits it - * with what it holds, through tg's click path: point-blank shots with a loaded gun, or its melee weapon when that - * can dent it. A locker that breaks bursts open through tg's atom_break(). It gives up after + * with what it holds, through tg's click path: with a loaded gun it steps back to two tiles off and shoots it (tg + * never fires a gun at a thing beside you: that click is a gun-butt blow, which can't dent a secure locker), or + * it hits it with its melee weapon when that can dent it. A locker that breaks bursts open through tg's atom_break(). It gives up after * STEALTH_CLOSET_GIVE_UP_TIME and searches round it. * * Someone who gets in unseen is still hidden (decision 22): an alert guard whose target is in a container it @@ -24,6 +25,8 @@ var/shut_in_at = 0 /// Alert: world.time it last saw its target on open ground var/target_free_seen_at = 0 + /// Its container wouldn't open for it (locked or welded): a gunner steps back to shoot it + var/closet_stuck = FALSE /// The locker, crate or box `who` is shut in (the outermost, if one is inside another), or null. /proc/stealth_closet_of(mob/living/who) @@ -57,6 +60,7 @@ shut_in = null shut_who = null shut_in_at = 0 + closet_stuck = FALSE /datum/ai_controller/basic_controller/human_npc/stealth/proc/on_closet_deleted(datum/source) SIGNAL_HANDLER @@ -100,7 +104,7 @@ var/turf/was = entry[STEALTH_ENTRY_TURF] if(isnull(was) || get_dist(was, shell) > 2) return FALSE - return can_see(pawn, shell, STEALTH_SIGHT_RANGE) + return can_see(pawn, shell, stealth_skill().sight_range) /// Just went alert on `target` (always first hand: sight, a touch, a hit). If they are in a container, that's the one. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_closet_alerted(atom/target) @@ -191,11 +195,16 @@ /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_try_closet() var/mob/living/carbon/human/guard = pawn var/obj/structure/closet/box = shut_in - if(QDELETED(box) || !guard.Adjacent(box) || HAS_TRAIT(guard, TRAIT_HANDS_BLOCKED) || guard.incapacitated) + if(QDELETED(box) || HAS_TRAIT(guard, TRAIT_HANDS_BLOCKED) || guard.incapacitated) + return + var/obj/item/gun/gun = human_npc_loaded_gun(guard) + var/adjacent = guard.Adjacent(box) + // Stepped back to shoot it (stealth_closet_fire_spot()). + if(!adjacent && !(closet_stuck && gun && stealth_closet_in_fire_spot(box))) return var/mob/living/who = shut_who?.resolve() guard.face_atom(box) - if(box.open(guard)) + if(adjacent && box.open(guard)) stealth_drop_closet() stealth_bark(STEALTH_BARK_CLOSET_OPEN) if(isliving(who) && !QDELETED(who)) @@ -206,11 +215,11 @@ else stealth_closet_alerted(who) return + closet_stuck = TRUE if(world.time < guard.next_move) return - var/obj/item/gun/gun = human_npc_loaded_gun(guard) if(gun) - if(world.time < blackboard[BB_HUMAN_NPC_NEXT_SHOT] || !human_npc_ready_item(guard, gun)) + if(adjacent || world.time < blackboard[BB_HUMAN_NPC_NEXT_SHOT] || !human_npc_ready_item(guard, gun)) return guard.zone_selected = BODY_ZONE_CHEST ai_interact(target = box, combat_mode = TRUE) @@ -223,6 +232,26 @@ human_npc_ready_weapon(guard, weapon) ai_interact(target = box, combat_mode = TRUE) +/// Whether it stands two tiles from `box` with a clear line to it: where it shoots a container that won't open. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_closet_in_fire_spot(obj/structure/closet/box) + var/mob/living/guard = pawn + return isturf(guard.loc) && get_dist(guard, box) == 2 && can_see(guard, box, 2) + +/// The nearest open tile two tiles from `box` with a clear line to it, or null. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_closet_fire_spot(obj/structure/closet/box) + var/mob/living/guard = pawn + var/turf/center = get_turf(box) + var/turf/best + var/best_dist = INFINITY + for(var/turf/open/spot in RANGE_TURFS(2, center)) + if(get_dist(spot, center) != 2 || spot.is_blocked_turf(exclude_mobs = TRUE) || !can_see(spot, center, 2)) + continue + var/dist = get_dist(guard, spot) + if(dist < best_dist) + best = spot + best_dist = dist + return best + /** * Alert with its target in a container. One it saw them get into: the guard that saw first walks over and opens * it, the others close in to STEALTH_CLOSET_COVER_RANGE and cover it. One it didn't: it holds its fire and watches @@ -263,6 +292,16 @@ controller.stand_dir = stealth_dir_to(guard, box) controller.queue_behavior(/datum/ai_behavior/stealth_stand) return SUBTREE_RETURN_FINISH_PLANNING + // It wouldn't open: a gunner shoots it from two tiles off. + if(controller.closet_stuck && human_npc_loaded_gun(guard)) + if(controller.stealth_closet_in_fire_spot(box)) + controller.stealth_drop_walk() + controller.queue_behavior(/datum/ai_behavior/stealth_open_closet) + return SUBTREE_RETURN_FINISH_PLANNING + var/turf/fire_spot = controller.stealth_closet_fire_spot(box) + if(fire_spot && !controller.stealth_walk_gave_up(fire_spot)) + controller.stealth_walk(fire_spot, STEALTH_GOTO_CLOSET) + return SUBTREE_RETURN_FINISH_PLANNING if(!guard.Adjacent(box)) if(controller.stealth_walk_gave_up(spot)) // No way to it: it gives up now rather than stand there. diff --git a/voidcrew/modules/stealth/stealth_doors.dm b/voidcrew/modules/stealth/stealth_doors.dm new file mode 100644 index 00000000000..5a8ca4da848 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_doors.dm @@ -0,0 +1,162 @@ +/** + * # Stealth guards: doors (owner decision 37) + * + * Every door a player opens or shuts makes a small noise (STEALTH_NOISE_DOOR: those who hear it glance), and a + * guard who sees one move in its cone is suspicious and goes to look. The door's own movement is the cue, so it + * works without seeing who moved it. + * + * Doors: airlocks, windoors, shutters and blast doors (every /obj/machinery/door through tg's run_animation()), + * and mineral and wooden doors (their Open() and Close()). Firelocks are left out: they move by themselves on + * every air alarm, and tg plays no sound for them. + * + * Their own doors: a door that moves with one of the group beside it is theirs, and so is its next close within + * STEALTH_DOOR_GUARD_MEMORY (an airlock a guard walked through shuts itself 6 s later, when it is far off). + * + * In the dark a guard sees a door move out to its dark sight range, in the light out to its full sight range: + * a door is no easier to make out in the dark than a person. + * + * Throttle: a door that sent someone to look only gets glances for STEALTH_DOOR_CUE_COOLDOWN, and after + * STEALTH_DOOR_CUE_MAX looks within STEALTH_DOOR_CUE_MEMORY it is ignored for the rest of that time, so a door + * cycling by itself can't keep a guard walking back and forth. The noise is coalesced as any noise is. + * + * Cost: one length() check while no stealth group is alive; otherwise one look per guard of a group on that level. + */ + +/datum/stealth_group + /// REF(door) => world.time one of the group was beside it when it moved + var/list/door_guard_used = list() + /// REF(door) => list of world.time it sent someone to look + var/list/door_cues = list() + +// Opening and closing, on every machinery door. Firelocks excepted (see above). +/obj/machinery/door/run_animation(animation, force_type = DEFAULT_DOOR_CHECKS) + . = ..() + if(!length(GLOB.stealth_groups) || istype(src, /obj/machinery/door/firedoor)) + return + if(animation != DOOR_OPENING_ANIMATION && animation != DOOR_CLOSING_ANIMATION) + return + // Forced open with a crowbar or the like: that is already a bash (stealth_noise_sources.dm). + stealth_door_moved(src, animation == DOOR_OPENING_ANIMATION, force_type != BYPASS_DOOR_CHECKS) + +/obj/structure/mineral_door/Open() + if(length(GLOB.stealth_groups) && !door_opened) + stealth_door_moved(src, TRUE) + return ..() + +/obj/structure/mineral_door/Close() + // tg's Close() does nothing while it is moving, already shut, or someone stands in the doorway. + if(length(GLOB.stealth_groups) && !isSwitchingStates && door_opened && !(locate(/mob/living) in get_turf(src))) + stealth_door_moved(src, FALSE) + return ..() + +/** + * `door` began to open (`opening`) or close. Its noise (unless `noisy` is off), then the guards that see it. + * Returns the number of guards sent to look (tests). + */ +/proc/stealth_door_moved(atom/door, opening, noisy = TRUE) + . = 0 + if(!length(GLOB.stealth_groups)) + return + var/turf/where = get_turf(door) + if(isnull(where)) + return + // Nobody to play for: guards sleep with their level. + if(where.z > length(SSmobs.clients_by_zlevel) || !length(SSmobs.clients_by_zlevel[where.z])) + return + var/key = REF(door) + for(var/datum/stealth_group/group as anything in GLOB.stealth_groups.Copy()) + if(QDELETED(group) || group.home?.z != where.z || !group.region_matches(where)) + continue + if(group.door_is_theirs(key, where, opening)) + continue + if(noisy) + stealth_noise(door, STEALTH_NOISE_DOOR, null, null, group) + . += group.door_seen(key, where) + +/// Whether a door moving at `where` is one of their own going through: one of them beside it, or the close +/// that follows such an opening. Remembers the opening. +/datum/stealth_group/proc/door_is_theirs(key, turf/where, opening) + for(var/stamped in door_guard_used) + if(world.time - door_guard_used[stamped] > STEALTH_DOOR_GUARD_MEMORY) + door_guard_used -= stamped + if(member_beside(where, living_members())) + door_guard_used[key] = world.time + return TRUE + if(!opening && door_guard_used[key]) + door_guard_used -= key + return TRUE + return FALSE + +/** + * The guards who see a door move at `where`: the nearest one free to look goes (suspicious, as at a sighting), + * a searching one moves its search there, the rest of the unaware ones glance. Returns how many went. + */ +/datum/stealth_group/proc/door_seen(key, turf/where) + . = 0 + var/list/stamps = door_cues[key] + if(stamps) + for(var/index in length(stamps) to 1 step -1) + if(world.time - stamps[index] > STEALTH_DOOR_CUE_MEMORY) + stamps.Cut(index, index + 1) + if(!length(stamps)) + door_cues -= key + stamps = null + var/throttled = length(stamps) && (length(stamps) >= STEALTH_DOOR_CUE_MAX || world.time - stamps[length(stamps)] < STEALTH_DOOR_CUE_COOLDOWN) + // Nearest first. + var/list/seers = list() + for(var/mob/living/carbon/human/npc/guard as anything in living_members()) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + if(!istype(guard_ai) || !guard_ai.stealth_sees_door(where)) + continue + var/dist = get_dist(guard, where) + var/index = 1 + while(index <= length(seers) && get_dist(seers[index], where) <= dist) + index++ + seers.Insert(index, guard) + var/went = FALSE + for(var/mob/living/carbon/human/npc/guard as anything in seers) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + var/turf/spot = stealth_hear_spot(where, get_turf(guard)) + if(!throttled && !went && guard_ai.stealth_can_investigate()) + went = TRUE + guard_ai.stealth_door_look(spot) + .++ + continue + switch(guard_ai.stealth_state()) + if(STEALTH_UNAWARE) + guard_ai.stealth_glance(spot) + if(STEALTH_SEARCHING) + if(!throttled && guard_ai.stealth_respond(spot)) + went = TRUE + .++ + if(went) + LAZYADDASSOCLIST(door_cues, key, world.time) + +/// Whether it sees a door move at `where` now: awake, its eyes open, not fighting, in its cone, in view, and +/// within its sight range onto that spot (shorter in the dark). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_sees_door(turf/where) + var/mob/living/guard = pawn + if(QDELETED(guard) || guard.stat != CONSCIOUS || guard.client || ai_status == AI_STATUS_OFF) + return FALSE + if(!isturf(guard.loc) || stealth_captive() || blackboard_key_exists(BB_HUMAN_NPC_EXIT)) + return FALSE + if(!stealth_ready || stealth_state() == STEALTH_ALERT || !stealth_eyes_open()) + return FALSE + var/dist = get_dist(guard, where) + if(dist < 1 || dist > stealth_range_onto(where)) + return FALSE + if(!stealth_in_cone(guard, where, stealth_half_angle())) + return FALSE + return can_see(guard, where, stealth_skill().sight_range) + +/// It saw a door move: suspicious of `spot`, the side of the door it is on, as at a sighting. Already +/// suspicious and not yet on its way, it turns there instead. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_door_look(turf/spot) + if(isnull(spot) || stealth_driven()) + return + if(stealth_state() == STEALTH_SUSPICIOUS) + last_gain = world.time + if(!investigated) + stealth_aim_at(spot) + return + stealth_go_suspicious(spot) diff --git a/voidcrew/modules/stealth/stealth_hearing.dm b/voidcrew/modules/stealth/stealth_hearing.dm index 7d515e7381a..27cc364dd9e 100644 --- a/voidcrew/modules/stealth/stealth_hearing.dm +++ b/voidcrew/modules/stealth/stealth_hearing.dm @@ -201,6 +201,8 @@ var/list/was = heard_map var/list/now = list() var/list/notice = notice_map + var/datum/stealth_skill/profile = stealth_skill() + var/hearing_mult = profile.hearing_mult for(var/mob/living/walker as anything in stealth_candidates(guard, STEALTH_FOOTSTEP_MAX_RANGE)) var/key = REF(walker) var/turf/where = get_turf(walker) @@ -208,7 +210,8 @@ var/turf/stood = was?[key] if(isnull(stood) || stood == where) continue - var/reach = stealth_footstep_reach(walker) + // A sharper or duller ear than the yellow tuning (decision 38), never past the furthest step listened for. + var/reach = min(round(stealth_footstep_reach(walker) * hearing_mult, 1), STEALTH_FOOTSTEP_MAX_RANGE) if(!reach || get_dist(here, where) > reach || stealth_muffled_dist(where, here) > reach) continue LAZYSET(heard_now, key, TRUE) @@ -224,7 +227,7 @@ entry = list(0, where, 0) notice[key] = entry if(entry[STEALTH_ENTRY_NOTICE] < STEALTH_SUSPICIOUS_AT) - var/gained = get_dist(here, where) <= STEALTH_CLOSE_RANGE ? STEALTH_SUSPICIOUS_AT : entry[STEALTH_ENTRY_NOTICE] + STEALTH_FOOTSTEP_NOTICE + var/gained = get_dist(here, where) <= profile.close_range ? STEALTH_SUSPICIOUS_AT : entry[STEALTH_ENTRY_NOTICE] + STEALTH_FOOTSTEP_NOTICE entry[STEALTH_ENTRY_NOTICE] = min(gained, STEALTH_SUSPICIOUS_AT) entry[STEALTH_ENTRY_SEEN_AT] = world.time if(blackboard[BB_STEALTH_WARY]) diff --git a/voidcrew/modules/stealth/stealth_meter.dm b/voidcrew/modules/stealth/stealth_meter.dm index 1c1cad1c745..5695a3842c0 100644 --- a/voidcrew/modules/stealth/stealth_meter.dm +++ b/voidcrew/modules/stealth/stealth_meter.dm @@ -62,7 +62,7 @@ if(QDELETED(guard) || isnull(controller)) return var/state = controller.stealth_state() - var/new_public = stealth_meter_public_state(state, world.time, controller.lost_since, controller.blackboard[BB_STEALTH_STATE_SINCE], controller.calm_until) + var/new_public = stealth_meter_public_state(state, world.time, controller.lost_since, controller.blackboard[BB_STEALTH_STATE_SINCE], controller.calm_until, controller.stealth_skill().search_time) set_public(new_public) // Alert and searching own the mark even once it has drained: no private "?" in the moment before the scan // sends it back to unaware (and clears its notice). @@ -183,7 +183,7 @@ if(drain_timer) deltimer(drain_timer) drain_timer = null - var/delay = stealth_meter_next_step(controller.stealth_state(), world.time, controller.lost_since, controller.blackboard[BB_STEALTH_STATE_SINCE], controller.calm_until) + var/delay = stealth_meter_next_step(controller.stealth_state(), world.time, controller.lost_since, controller.blackboard[BB_STEALTH_STATE_SINCE], controller.calm_until, controller.stealth_skill().search_time) if(delay > 0) drain_timer = addtimer(CALLBACK(src, PROC_REF(on_drain_step)), delay, TIMER_STOPPABLE) @@ -271,35 +271,35 @@ return clamp(CEILING(time_left / total * STEALTH_METER_ROWS - 0.001, 1), 0, STEALTH_METER_ROWS) /// When a public drain ends and how long it lasts, as list(end, total), or null when nothing drains. -/proc/stealth_meter_drain_span(state, lost_since, state_since, calm_until) +/proc/stealth_meter_drain_span(state, lost_since, state_since, calm_until, search_time = STEALTH_SEARCH_TIME) switch(state) if(STEALTH_ALERT) if(lost_since) return list(lost_since + STEALTH_LOSE_TARGET_TIME, STEALTH_LOSE_TARGET_TIME) if(STEALTH_SEARCHING) - var/end = calm_until || (state_since + STEALTH_SEARCH_TIME) + var/end = calm_until || (state_since + search_time) return list(end, end - state_since) return null /// The public mark for a guard's state, or null for none. -/proc/stealth_meter_public_state(state, now, lost_since, state_since, calm_until) +/proc/stealth_meter_public_state(state, now, lost_since, state_since, calm_until, search_time = STEALTH_SEARCH_TIME) switch(state) if(STEALTH_ALERT) if(!lost_since) return "ex_r[STEALTH_METER_ROWS]" - var/list/span = stealth_meter_drain_span(state, lost_since, state_since, calm_until) + var/list/span = stealth_meter_drain_span(state, lost_since, state_since, calm_until, search_time) var/rows = stealth_meter_drain_rows(span[1] - now, span[2]) // Drained: the full searching "?" it is about to become. return rows ? "ex_r[rows]" : "q_y[STEALTH_METER_ROWS]" if(STEALTH_SEARCHING) - var/list/span = stealth_meter_drain_span(state, lost_since, state_since, calm_until) + var/list/span = stealth_meter_drain_span(state, lost_since, state_since, calm_until, search_time) var/rows = stealth_meter_drain_rows(span[1] - now, span[2]) return rows ? "q_y[rows]" : null return null /// Deciseconds until a draining public mark loses its next row, or 0 when nothing drains. -/proc/stealth_meter_next_step(state, now, lost_since, state_since, calm_until) - var/list/span = stealth_meter_drain_span(state, lost_since, state_since, calm_until) +/proc/stealth_meter_next_step(state, now, lost_since, state_since, calm_until, search_time = STEALTH_SEARCH_TIME) + var/list/span = stealth_meter_drain_span(state, lost_since, state_since, calm_until, search_time) if(isnull(span) || span[2] <= 0) return 0 var/time_left = span[1] - now diff --git a/voidcrew/modules/stealth/stealth_noise.dm b/voidcrew/modules/stealth/stealth_noise.dm index 99e25ca69ec..169d8b150f4 100644 --- a/voidcrew/modules/stealth/stealth_noise.dm +++ b/voidcrew/modules/stealth/stealth_noise.dm @@ -72,6 +72,7 @@ STEALTH_NOISE_VOICE = list(STEALTH_NOISE_RANGE_VOICE, STEALTH_HEAR_INVESTIGATE, NONE), STEALTH_NOISE_SCREAM = list(STEALTH_NOISE_RANGE_SCREAM, STEALTH_HEAR_ALARM, STEALTH_NOISE_LOUD | STEALTH_NOISE_ALLIES_COUNT), STEALTH_NOISE_SHOUT = list(STEALTH_NOISE_RANGE_SHOUT, STEALTH_HEAR_SHOUT, STEALTH_NOISE_LOUD | STEALTH_NOISE_GROUP_ONLY), + STEALTH_NOISE_CRUNCH = list(STEALTH_NOISE_RANGE_CRUNCH, STEALTH_HEAR_INVESTIGATE, NONE), ) return profiles[kind] @@ -216,8 +217,12 @@ var/turf/guard_turf = get_turf(guard) if(guard_turf?.z != where.z) continue + // Its ear (decision 38): quiet noises carry further to a sharp guard, less far to a sloppy one. + var/guard_reach = reach + if(!gunfire && !(flags & STEALTH_NOISE_LOUD) && kind != STEALTH_NOISE_GUN_QUIET) + guard_reach = round(reach * guard_ai.stealth_skill().hearing_mult, 1) var/dist = get_dist(guard_turf, where) - if(dist > reach) + if(dist > guard_reach) continue if(guard_ai.ai_status == AI_STATUS_OFF || guard.client || guard.stat != CONSCIOUS || guard_ai.stealth_captive() || guard_ai.blackboard_key_exists(BB_HUMAN_NPC_EXIT)) note(guard, "busy") @@ -230,8 +235,8 @@ note(guard, "busy") continue var/muffled = stealth_muffled_dist(where, guard_turf, flags) - if(muffled > reach) - note(guard, muffled == INFINITY ? "muffled" : "muffled [muffled]/[reach]") + if(muffled > guard_reach) + note(guard, muffled == INFINITY ? "muffled" : "muffled [muffled]/[guard_reach]") continue var/index = 1 while(index <= length(hearers) && hearers[index][2] <= muffled) @@ -239,7 +244,7 @@ hearers.Insert(index, null) hearers[index] = list(guard, muffled) guard_ai.last_heard = list(kind, world.time) - note(guard, "heard [muffled]/[reach]") + note(guard, "heard [muffled]/[guard_reach]") if(length(hearers)) noise_stamps[kind] = list(world.time, where) // Far off, they misjudge the spot: all of them by the same error, so they end up in one place. @@ -296,6 +301,8 @@ alarms = list() checks = list() next_radio_alarm = 0 + door_guard_used = list() + door_cues = list() /// Moves every noise stamp back by `time`, as if that long had passed (unit tests, admin tools). /datum/stealth_group/proc/rewind(time) @@ -310,6 +317,12 @@ check.due -= time next_overdue_check -= time next_radio_alarm -= time + for(var/key in door_guard_used) + door_guard_used[key] -= time + for(var/key in door_cues) + var/list/stamps = door_cues[key] + for(var/index in 1 to length(stamps)) + stamps[index] -= time /** * What the guards that heard a noise do, decided for the group. `hearers` is list(guard, muffled distance), diff --git a/voidcrew/modules/stealth/stealth_noise_sources.dm b/voidcrew/modules/stealth/stealth_noise_sources.dm index b76fcb454e6..23ac4490279 100644 --- a/voidcrew/modules/stealth/stealth_noise_sources.dm +++ b/voidcrew/modules/stealth/stealth_noise_sources.dm @@ -184,6 +184,30 @@ if(whole) stealth_noise(src, STEALTH_NOISE_GLASS) +// Stepping on broken glass (decision 37): tg's own crunch, which plays at a walk too and through shoes. Shards of +// every kind and dropped bulbs and tubes are the things tg plays it for. Broken bottles hurt but make no sound in +// tg, so they make none here; prescription glasses crunch only under a running step, which is heard anyway. +/obj/item/shard/on_entered(datum/source, atom/movable/AM) + . = ..() + stealth_glass_step(src, AM) + +/obj/item/light/on_entered(datum/source, atom/movable/moving_atom) + . = ..() + stealth_glass_step(src, moving_atom) + +/// `stepper` walked onto `glass`: the crunch tg played, under tg's own rule for when it plays. +/proc/stealth_glass_step(atom/glass, atom/movable/stepper) + if(!length(GLOB.stealth_groups) || !isliving(stepper) || QDELETED(glass)) + return + var/mob/living/walker = stepper + if((walker.movement_type & MOVETYPES_NOT_TOUCHING_GROUND) && !walker.buckled) + return + // A mouse or a roach on the glass is no lure: only something that weighs something carries. + if(walker.mob_size <= MOB_SIZE_TINY) + return + var/reach = HAS_TRAIT(walker, TRAIT_LIGHT_STEP) ? STEALTH_NOISE_RANGE_CRUNCH_LIGHT : STEALTH_NOISE_RANGE_CRUNCH + INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(stealth_noise), get_turf(glass), STEALTH_NOISE_CRUNCH, reach, walker) + // ===== Knocks ===== // Knuckles on a window with combat mode off, a fist with it on. Repeats the parent's two guards. @@ -200,8 +224,8 @@ return stealth_noise(src, STEALTH_NOISE_KNOCK, null, isliving(user) ? user : null) -// An airlock opening or closing, refusing someone, or being forced. Nobody is named: a door with one of the -// group beside it is one of their own going through (stealth_noise()). +// An airlock refusing someone, or being forced. Nobody is named: a door with one of the group beside it is one +// of their own going through (stealth_noise()). An airlock opening or closing is every door's hook (stealth_doors.dm). /obj/machinery/door/airlock/animation_effects(animation, force_type = DEFAULT_DOOR_CHECKS) . = ..() if(!length(GLOB.stealth_groups)) @@ -209,11 +233,8 @@ if(force_type == BYPASS_DOOR_CHECKS) stealth_noise(src, STEALTH_NOISE_BASH) return - switch(animation) - if(DOOR_OPENING_ANIMATION, DOOR_CLOSING_ANIMATION) - stealth_noise(src, STEALTH_NOISE_DOOR) - if(DOOR_DENY_ANIMATION) - stealth_noise(src, STEALTH_NOISE_KNOCK) + if(animation == DOOR_DENY_ANIMATION) + stealth_noise(src, STEALTH_NOISE_KNOCK) // Tools at work: a wrench or a crowbar is a knock, a welder or a drill is louder. Breaking in is a choice // between slow and quiet, and fast and loud. Guards don't use tools. diff --git a/voidcrew/modules/stealth/stealth_patrol.dm b/voidcrew/modules/stealth/stealth_patrol.dm index e0c195ca91b..a2f84e79518 100644 --- a/voidcrew/modules/stealth/stealth_patrol.dm +++ b/voidcrew/modules/stealth/stealth_patrol.dm @@ -221,6 +221,8 @@ GLOBAL_VAR_INIT(stealth_group_count, 0) stealth_ready = TRUE var/mob/living/guard = pawn var/turf/spawn_turf = get_turf(guard) + // Its skill comes from where it starts (decision 38), settled now, before it walks anywhere. + stealth_skill() home_turf = spawn_turf sentry_dir = stealth_facing(guard) stand_dir = sentry_dir diff --git a/voidcrew/modules/stealth/stealth_skill.dm b/voidcrew/modules/stealth/stealth_skill.dm new file mode 100644 index 00000000000..507869b9c56 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_skill.dm @@ -0,0 +1,162 @@ +/** + * # Stealth guards: skill by zone (owner decision 38) + * + * How sharp a guard's eyes and ears are. One profile per skill level; yellow is the tuning the den was built + * and playtested on, so a yellow guard behaves exactly as before. The numbers are argued in + * data/stealth/STATUS.md, "Decisions 37-38". + * + * Skill is perception only. It never touches damage, health, armour, aim or fire rate: a red guard sees and + * hears better, it doesn't shoot better or take more killing. Armour and weapons stay the zone's job. + * + * Which profile a guard gets, first that applies: + * 1. an admin's pick (Stealth Guards > the guard > Set skill), which lasts until changed; + * 2. the mapper's `stealth_skill` on the guard, or on the spawner that made it; + * 3. the overmap zone of the planet or ruin it stands on when it first scans; + * 4. yellow, when that place can't be tied to a zone. + */ +/datum/stealth_skill + /// For admins + var/name = "yellow" + /// Tiles it notices someone at in its cone, in the light + var/sight_range = 8 + /// Tiles within which a sighting can turn into an alert (decision 18 holds it at 7 or under: on screen) + var/alert_max_range = 7 + /// Tiles it notices someone at in its cone, in the dark + var/dark_sight_range = 4 + /// Cone half-angle, calm + var/cone_half_angle = 60 + /// Cone half-angle while wary + var/wary_half_angle = 75 + /// Cone half-angle while searching (90 at most: the cone never takes in what is behind it) + var/search_half_angle = 90 + /// Notice gained per second on someone in plain view at its feet (less further off) + var/notice_rate = 1.0 + /// In its cone, seen plainly, this close: an alert on that look (decision 32) + var/point_blank_range = 2 + /// In its cone this close: notice fills near_mult times faster (decision 32) + var/near_range = 4 + var/near_mult = 3 + /// All round, in light that is there anyway, this close: noticed (abuse P7). Never in the dark (decision 32). + var/close_range = 2 + /// Multiplies how far it hears quiet noises (steps, doors, glass, knocks, voices). Gunfire, blasts, screams + /// and shouts are heard as before: they already carry as far as a player hears them (abuse H2). + var/hearing_mult = 1 + /// How long a suspicious guard stares before it walks over to look + var/reaction_delay = 2 SECONDS + /// How long it searches before it gives up + var/search_time = 40 SECONDS + /// How long it stays wary with nothing new + var/wary_time = 60 SECONDS + +/datum/stealth_skill/yellow + +/// Sloppy: a narrower cone, slower to notice, shorter sight and hearing, quicker to give up. +/datum/stealth_skill/green + name = "green" + sight_range = 7 + alert_max_range = 6 + dark_sight_range = 3 + cone_half_angle = 45 + wary_half_angle = 60 + search_half_angle = 75 + notice_rate = 0.7 + point_blank_range = 1 + near_range = 3 + near_mult = 2 + close_range = 1 + hearing_mult = 0.75 + reaction_delay = 3 SECONDS + search_time = 25 SECONDS + wary_time = 40 SECONDS + +/// Sharp: sees further and wider, notices faster, hears more, searches longer. Still blind behind in the dark. +/datum/stealth_skill/red + name = "red" + sight_range = 9 + alert_max_range = 7 + dark_sight_range = 5 + cone_half_angle = 65 + wary_half_angle = 80 + search_half_angle = 90 + notice_rate = 1.3 + point_blank_range = 2 + near_range = 5 + near_mult = 3 + close_range = 2 + hearing_mult = 1.25 + reaction_delay = 1 SECONDS + search_time = 60 SECONDS + wary_time = 90 SECONDS + +/// The shared profile of type `skill_type`, or null if it isn't one. +/proc/stealth_skill_of(skill_type) + var/static/list/profiles = list() + if(!ispath(skill_type, /datum/stealth_skill)) + return null + var/datum/stealth_skill/profile = profiles[skill_type] + if(isnull(profile)) + profile = new skill_type() + profiles[skill_type] = profile + return profile + +/// The profile type for a ZONE_* (yellow when the zone is unknown). +/proc/stealth_skill_type_for_zone(zone) + switch(zone) + if(ZONE_GREEN) + return /datum/stealth_skill/green + if(ZONE_RED) + return /datum/stealth_skill/red + return /datum/stealth_skill/yellow + +/// The ZONE_* of the planet or ruin `where` belongs to, or null when it can't be tied to the overmap. +/proc/stealth_zone_of(turf/where) + if(isnull(where)) + return null + return get_zone_type_for_player_turf(where) + +/mob/living/carbon/human/npc + /// Mapper's override of a stealth guard's skill: a /datum/stealth_skill subtype, or null for its zone's + var/stealth_skill + +/obj/effect/spawner/human_npc + /// Mapper's override of the skill of the stealth guard this makes: a /datum/stealth_skill subtype, or null + var/stealth_skill + +/obj/effect/spawner/human_npc/npc_spawned_callback() + if(ispath(stealth_skill, /datum/stealth_skill)) + return CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(stealth_set_mapped_skill), stealth_skill) + return ..() + +/// A spawner's skill override, handed to the guard it made. A global proc so the order holds no ref to the spawner. +/proc/stealth_set_mapped_skill(skill_type, mob/living/carbon/human/npc/made) + if(!istype(made)) + return + made.stealth_skill = skill_type + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = made.ai_controller + if(istype(stealth_ai) && !stealth_ai.skill_forced) + stealth_ai.skill = null + +/datum/ai_controller/basic_controller/human_npc/stealth + /// Its skill profile (stealth_skill()); null until first asked for + var/datum/stealth_skill/skill + /// Set when an admin picked its skill: the mapper's and the zone's no longer apply + var/skill_forced = FALSE + +/// Its skill profile: an admin's pick, else the mapper's, else its zone's, else yellow. Settled the first time it is asked. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_skill() + if(skill) + return skill + var/mob/living/carbon/human/npc/guard = pawn + var/skill_type = istype(guard) ? guard.stealth_skill : null + if(!ispath(skill_type, /datum/stealth_skill)) + skill_type = stealth_skill_type_for_zone(istype(guard) ? stealth_zone_of(get_turf(guard)) : null) + skill = stealth_skill_of(skill_type) + return skill + +/// Admins: sets its skill to `skill_type`, or back to the mapper's or zone's with null. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_force_skill(skill_type) + skill_forced = ispath(skill_type, /datum/stealth_skill) + skill = skill_forced ? stealth_skill_of(skill_type) : null + stealth_skill() + for(var/datum/stealth_sight_overlay/overlay as anything in watchers) + overlay.refresh() diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index f3835654a04..0838cd728bc 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -238,6 +238,7 @@ #include "voidcrew_stealth_closet.dm" #include "voidcrew_stealth_crits.dm" #include "voidcrew_stealth_d32.dm" +#include "voidcrew_stealth_d37.dm" #include "voidcrew_stealth_hearing.dm" #include "voidcrew_stealth_light.dm" #include "voidcrew_survey_archive.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_closet.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_closet.dm index b556d50eb61..44e2d0e6d90 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_closet.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_closet.dm @@ -24,7 +24,9 @@ person.forceMove(locker) stealth_ai.stealth_go_alert(person) TEST_ASSERT_EQUAL(stealth_ai.shut_in, locker, "A guard didn't claim the locker the second time") - qdel(locker) + // Broken up: tg tips out whoever is inside, then deletes it (a bare qdel would delete them too). + locker.deconstruct(FALSE) + TEST_ASSERT(QDELETED(locker), "The locker wasn't deleted") TEST_ASSERT_NULL(stealth_ai.shut_in, "A guard kept a deleted locker") // A new one, and the guard calms down. var/obj/structure/closet/second = allocate(/obj/structure/closet, stealth_at(block, 4, 1)) @@ -91,7 +93,8 @@ TEST_ASSERT_EQUAL(locker.get_integrity(), start_integrity, "A guard hit a locker it never saw anyone get into") TEST_ASSERT_NULL(stealth_ai.shut_in, "A searching guard claimed a locker") -/// Real AI: a gunner that saw someone shut in a locker that is then locked shoots it open from beside it, not from range. +/// Real AI: a gunner that saw someone shut in a locker that is then locked tries it, steps back two tiles and shoots it +/// open (tg never fires at a thing beside you), never from range. /datum/unit_test/voidcrew_stealth_live/closet_locked /datum/unit_test/voidcrew_stealth_live/closet_locked/Run() @@ -120,7 +123,7 @@ sleep(1) TEST_ASSERT(locker.opened, "A gunner never broke open a locked locker it saw someone get into (claim: [stealth_ai.shut_in ? "yes" : "no"], integrity [locker.get_integrity()]/[start_integrity])") TEST_ASSERT_NOTNULL(first_hit_dist, "The locked locker opened without being hit") - TEST_ASSERT(first_hit_dist <= 1, "A gunner shot a locker from [first_hit_dist] tiles away") + TEST_ASSERT(first_hit_dist <= 2, "A gunner shot a locker from [first_hit_dist] tiles away") TEST_ASSERT(isturf(person.loc), "The person is still shut in after the locker broke") TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], person, "The gunner isn't after whoever was in the locker") diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_d37.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_d37.dm new file mode 100644 index 00000000000..fa942daae64 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_d37.dm @@ -0,0 +1,237 @@ +// Stealth guards, owner decisions 37 (glass and doors) and 38 (skill by zone). voidcrew/modules/stealth/stealth_doors.dm, +// stealth_skill.dm, and the glass step in stealth_noise_sources.dm. Values from voidcrew/_DEFINES are written out: +// STEALTH_NOISE_RANGE_CRUNCH 4, STEALTH_DOOR_CUE_COOLDOWN 30 s, STEALTH_DOOR_CUE_MAX 2, STEALTH_DOOR_GUARD_MEMORY 20 s; +// ZONE_GREEN 1, ZONE_YELLOW 2, ZONE_RED 3. States and noise kinds are written as text. + +/// Stepping on a shard, even at a walk: the guard in earshot goes to look. A guard's own step on one is nothing, +/// and a green guard's duller ear misses a crunch a yellow one hears. +/datum/unit_test/voidcrew_stealth_live/hear/glass_crunch + +/datum/unit_test/voidcrew_stealth_live/hear/glass_crunch/Run() + TEST_ASSERT(hear_room(20, 3), "No room for the test") + var/mob/living/carbon/human/npc/guard = sentry(8, 1, EAST) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + var/obj/item/shard/shard = allocate(/obj/item/shard, at(5, 1)) + var/mob/living/carbon/human/walker = person_at(4, 1, FALSE) + walker.equip_to_slot_or_del(new /obj/item/clothing/shoes/sneakers/black(walker), ITEM_SLOT_FEET) + TEST_ASSERT_EQUAL(walker.move_intent, MOVE_INTENT_WALK, "The walker isn't walking") + walker.forceMove(get_turf(shard)) + TEST_ASSERT_EQUAL(guard_ai.last_heard?[1], "crunch", "A guard 3 tiles off didn't hear a shard stepped on at a walk") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "suspicious", "A crunch didn't send the guard to look") + no_targets(list(guard)) + // One of their own stepping on it. + settle(guard) + guard_ai.group.forget_noises() + guard_ai.last_heard = null + walker.forceMove(at(2, 0)) + var/mob/living/carbon/human/npc/friend = sentry(4, 1, EAST) + friend.forceMove(get_turf(shard)) + TEST_ASSERT_NULL(guard_ai.last_heard, "A guard heard its friend step on glass") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "unaware", "A friend's crunch sent a guard to look") + friend.forceMove(at(0, 0)) + // A bulb on the floor crunches too. + var/obj/item/light/bulb/bulb = allocate(/obj/item/light/bulb, at(6, 2)) + walker.forceMove(get_turf(bulb)) + TEST_ASSERT_EQUAL(guard_ai.last_heard?[1], "crunch", "Stepping on a bulb wasn't heard") + // A green guard 4 tiles off: 4 x 0.75 = 3, out of reach. A yellow one there hears it. + settle(guard) + guard_ai.group.forget_noises() + guard_ai.last_heard = null + guard_ai.stealth_force_skill(/datum/stealth_skill/green) + walker.forceMove(at(3, 1)) + shard.forceMove(at(4, 1)) + walker.forceMove(at(4, 1)) + TEST_ASSERT_NULL(guard_ai.last_heard, "A green guard heard a crunch 4 tiles off") + guard_ai.stealth_force_skill(/datum/stealth_skill/yellow) + guard_ai.group.forget_noises() + walker.forceMove(at(3, 1)) + walker.forceMove(at(4, 1)) + TEST_ASSERT_EQUAL(guard_ai.last_heard?[1], "crunch", "A yellow guard didn't hear a crunch 4 tiles off") + +/// A door seen opening in a guard's cone makes it suspicious of its own side of the door; behind it, out of its +/// dark sight in the dark, or with one of their own beside the door, nothing; a door that keeps moving is throttled. +/datum/unit_test/voidcrew_stealth_live/hear/door_seen + +/datum/unit_test/voidcrew_stealth_live/hear/door_seen/Run() + TEST_ASSERT(hear_room(20, 5), "No room for the test") + var/mob/living/carbon/human/npc/guard = sentry(2, 2, EAST) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + var/turf/door_spot = at(9, 2) + var/obj/machinery/door/poddoor/shutters/shutter = allocate(/obj/machinery/door/poddoor/shutters, door_spot) + TEST_ASSERT(shutter.density, "The shutter isn't shut") + // Seven tiles ahead, lit, opened through tg's own open(): it goes to look at its side of it. + INVOKE_ASYNC(shutter, TYPE_PROC_REF(/obj/machinery/door, open)) + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "suspicious", "A guard didn't react to a shutter opening in front of it") + TEST_ASSERT_EQUAL(guard_ai.investigate_turf, at(8, 2), "It isn't going to its own side of the door") + TEST_ASSERT(!guard_ai.suspicion_heard, "A door it saw counts as one it only heard") + no_targets(list(guard)) + // The same door again at once: throttled, a glance at most. + settle(guard) + TEST_ASSERT_EQUAL(stealth_door_moved(shutter, FALSE), 0, "A door sent someone to look twice within 30 s") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "unaware", "A throttled door made a guard suspicious") + // After the cooldown it works once more; then that door is ignored for the rest of 3 minutes. + // (No forget_noises() here: it forgets doors too.) + guard_ai.group.rewind(31 SECONDS) + TEST_ASSERT_EQUAL(stealth_door_moved(shutter, TRUE), 1, "A door didn't draw a look after its cooldown") + settle(guard) + guard_ai.group.rewind(31 SECONDS) + TEST_ASSERT_EQUAL(stealth_door_moved(shutter, FALSE), 0, "A door drew a third look within 3 minutes") + guard_ai.group.rewind(3 MINUTES) + TEST_ASSERT_EQUAL(stealth_door_moved(shutter, TRUE), 1, "A door was still ignored after 3 minutes") + settle(guard) + guard_ai.group.forget_noises() + guard_ai.group.rewind(31 SECONDS) + // Behind it: nothing. + guard.setDir(WEST) + TEST_ASSERT_EQUAL(stealth_door_moved(shutter, FALSE), 0, "A guard saw a door behind it") + guard.setDir(EAST) + // In the dark, 7 tiles off (past its dark sight of 4): nothing. 3 tiles off: it sees it. + GLOB.stealth_test_dark_turfs[door_spot] = TRUE + TEST_ASSERT_EQUAL(stealth_door_moved(shutter, TRUE), 0, "A guard saw a dark doorway 7 tiles off") + guard.forceMove(at(6, 2)) + TEST_ASSERT_EQUAL(stealth_door_moved(shutter, FALSE), 1, "A guard didn't see a dark doorway 3 tiles off") + GLOB.stealth_test_dark_turfs[door_spot] = FALSE + no_targets(list(guard)) + +/// Their own doors: a door that moves with one of them beside it draws nobody, and neither does the close that +/// follows once that guard has walked on. A wooden door a player opens is seen and heard. +/datum/unit_test/voidcrew_stealth_live/hear/door_own + +/datum/unit_test/voidcrew_stealth_live/hear/door_own/Run() + TEST_ASSERT(hear_room(20, 5), "No room for the test") + var/mob/living/carbon/human/npc/watcher = sentry(2, 2, EAST) + var/datum/ai_controller/basic_controller/human_npc/stealth/watcher_ai = watcher.ai_controller + var/obj/machinery/door/poddoor/shutters/shutter = allocate(/obj/machinery/door/poddoor/shutters, at(8, 2)) + var/mob/living/carbon/human/npc/passer = sentry(9, 2, WEST) + TEST_ASSERT_EQUAL(stealth_door_moved(shutter, TRUE), 0, "A door one of them stood beside drew a look") + TEST_ASSERT_EQUAL(watcher_ai.stealth_state(), "unaware", "A guard was suspicious of its friend's door") + TEST_ASSERT_EQUAL(watcher_ai.glance_until, 0, "A guard glanced at its friend's door") + passer.forceMove(at(15, 2)) + TEST_ASSERT_EQUAL(stealth_door_moved(shutter, FALSE), 0, "The close after a friend's opening drew a look") + TEST_ASSERT_EQUAL(watcher_ai.stealth_state(), "unaware", "A guard was suspicious of its friend's door shutting itself") + // Long after that, a close with nobody beside it is someone else's. + watcher_ai.group.rewind(21 SECONDS) + TEST_ASSERT_EQUAL(stealth_door_moved(shutter, TRUE), 1, "A door with nobody beside it drew no look") + settle(watcher) + watcher_ai.group.forget_noises() + // A wooden door, opened through tg's own Open(). + var/obj/structure/mineral_door/wood/wood = allocate(/obj/structure/mineral_door/wood, at(6, 3)) + INVOKE_ASYNC(wood, TYPE_PROC_REF(/obj/structure/mineral_door, Open)) + TEST_ASSERT_EQUAL(watcher_ai.stealth_state(), "suspicious", "A guard didn't react to a wooden door opening in front of it") + TEST_ASSERT_EQUAL(watcher_ai.last_heard?[1], "door", "A wooden door made no noise") + no_targets(list(watcher, passer)) + +/// The skill profile: yellow is today's tuning; zone, mapper and admin pick it in that order of strength. +/datum/unit_test/voidcrew_stealth_skill + +/datum/unit_test/voidcrew_stealth_skill/Run() + var/datum/stealth_skill/yellow = stealth_skill_of(/datum/stealth_skill/yellow) + // The numbers the den was tuned on (STEALTH_SIGHT_RANGE, STEALTH_CONE_HALF_ANGLE, ... in _DEFINES/stealth.dm). + TEST_ASSERT_EQUAL(yellow.sight_range, 8, "Yellow sight range changed") + TEST_ASSERT_EQUAL(yellow.alert_max_range, 7, "Yellow alert range changed") + TEST_ASSERT_EQUAL(yellow.dark_sight_range, 4, "Yellow dark sight changed") + TEST_ASSERT_EQUAL(yellow.cone_half_angle, 60, "Yellow cone changed") + TEST_ASSERT_EQUAL(yellow.wary_half_angle, 75, "Yellow wary cone changed") + TEST_ASSERT_EQUAL(yellow.search_half_angle, 90, "Yellow search cone changed") + TEST_ASSERT_EQUAL(yellow.notice_rate, 1, "Yellow notice rate changed") + TEST_ASSERT_EQUAL(yellow.point_blank_range, 2, "Yellow point-blank range changed") + TEST_ASSERT_EQUAL(yellow.near_range, 4, "Yellow near range changed") + TEST_ASSERT_EQUAL(yellow.near_mult, 3, "Yellow near multiplier changed") + TEST_ASSERT_EQUAL(yellow.close_range, 2, "Yellow close range changed") + TEST_ASSERT_EQUAL(yellow.hearing_mult, 1, "Yellow hearing changed") + TEST_ASSERT_EQUAL(yellow.reaction_delay, 2 SECONDS, "Yellow reaction delay changed") + TEST_ASSERT_EQUAL(yellow.search_time, 40 SECONDS, "Yellow search time changed") + TEST_ASSERT_EQUAL(yellow.wary_time, 60 SECONDS, "Yellow wary time changed") + // Every profile keeps decision 18 (no alert from off screen) and a cone that never takes in what is behind. + for(var/skill_type in subtypesof(/datum/stealth_skill)) + var/datum/stealth_skill/profile = stealth_skill_of(skill_type) + TEST_ASSERT(profile.alert_max_range <= 7, "[skill_type] goes alert from off screen") + TEST_ASSERT(profile.search_half_angle <= 90, "[skill_type] searches with eyes in the back of its head") + TEST_ASSERT(profile.sight_range <= 9, "[skill_type] sees past the range it gathers people from") + // Zones. + TEST_ASSERT_EQUAL(stealth_skill_type_for_zone(1), /datum/stealth_skill/green, "Green zone isn't green skill") + TEST_ASSERT_EQUAL(stealth_skill_type_for_zone(2), /datum/stealth_skill/yellow, "Yellow zone isn't yellow skill") + TEST_ASSERT_EQUAL(stealth_skill_type_for_zone(3), /datum/stealth_skill/red, "Red zone isn't red skill") + TEST_ASSERT_EQUAL(stealth_skill_type_for_zone(null), /datum/stealth_skill/yellow, "An unknown zone isn't yellow") + var/datum/turf_reservation/block = stealth_block(3, 3) + TEST_ASSERT_NOTNULL(block, "No room for the test") + // Reserved test space belongs to no zone: yellow. + var/mob/living/carbon/human/npc/guard = allocate(/mob/living/carbon/human/npc/ruin/trooper/scav, stealth_at(block, 1, 1)) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + TEST_ASSERT_NULL(stealth_zone_of(get_turf(guard)), "Reserved test space belongs to a zone") + TEST_ASSERT_EQUAL(stealth_ai.stealth_skill().name, "yellow", "A guard with no zone isn't yellow") + // A spawner's pick reaches the guard and beats the zone. + stealth_set_mapped_skill(/datum/stealth_skill/red, guard) + TEST_ASSERT_EQUAL(guard.stealth_skill, /datum/stealth_skill/red, "A spawner's skill didn't reach its guard") + TEST_ASSERT_EQUAL(stealth_ai.stealth_skill().name, "red", "A mapped skill didn't beat the zone") + // An admin's pick beats the mapper's, and lets go again. + stealth_ai.stealth_force_skill(/datum/stealth_skill/green) + TEST_ASSERT_EQUAL(stealth_ai.stealth_skill().name, "green", "An admin's skill didn't beat the mapper's") + stealth_set_mapped_skill(/datum/stealth_skill/red, guard) + TEST_ASSERT_EQUAL(stealth_ai.stealth_skill().name, "green", "A mapper's skill overrode an admin's") + stealth_ai.stealth_force_skill(null) + TEST_ASSERT_EQUAL(stealth_ai.stealth_skill().name, "red", "Clearing an admin's skill didn't go back to the mapper's") + // A spawner hands its pick over without a reference to itself. (The family root places nothing.) + var/obj/effect/spawner/human_npc/spawner = new(stealth_at(block, 0, 0)) + spawner.stealth_skill = /datum/stealth_skill/green + var/datum/callback/handover = spawner.npc_spawned_callback() + TEST_ASSERT_NOTNULL(handover, "A spawner with a skill hands nothing over") + TEST_ASSERT(handover.object == GLOBAL_PROC, "The spawner's handover holds the spawner") + spawner.stealth_skill = null + TEST_ASSERT_NULL(spawner.npc_spawned_callback(), "A spawner without a skill hands something over") + if(!QDELETED(spawner)) + qdel(spawner) + qdel(guard) + qdel(block) + +/// The knobs reach the guard: green is narrower, shorter-sighted, no instant alert at 2 tiles, gives up sooner. +/datum/unit_test/voidcrew_stealth_skill_knobs + +/datum/unit_test/voidcrew_stealth_skill_knobs/Run() + var/datum/turf_reservation/block = stealth_block(14, 7) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/person = stealth_person(block, 0, 0) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 3) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + // Cone: two ahead and three aside is 56 degrees off its facing. + var/turf/aside = stealth_at(block, 4, 6) + TEST_ASSERT(stealth_in_cone(guard, aside, stealth_ai.stealth_half_angle()), "56 degrees is outside a yellow cone") + stealth_ai.stealth_force_skill(/datum/stealth_skill/green) + TEST_ASSERT(!stealth_in_cone(guard, aside, stealth_ai.stealth_half_angle()), "56 degrees is inside a green cone") + TEST_ASSERT_EQUAL(stealth_ai.stealth_range_onto(aside), 7, "A green guard's sight isn't 7") + // Eight ahead in the light: a yellow guard notices, a green one doesn't see that far. + person.forceMove(stealth_at(block, 10, 3)) + stealth_scans(guard, 1) + TEST_ASSERT_NULL(stealth_ai.notice_map[REF(person)], "A green guard noticed someone 8 tiles off") + stealth_ai.stealth_force_skill(/datum/stealth_skill/yellow) + stealth_scans(guard, 1) + TEST_ASSERT_NOTNULL(stealth_ai.notice_map[REF(person)], "A yellow guard didn't notice someone 8 tiles off") + qdel(guard) + // Two ahead in the light: yellow is an alert on that look; green is not (its point-blank is 1). + person.forceMove(stealth_at(block, 4, 3)) + guard = stealth_guard(block, 2, 3) + stealth_ai = stealth_ai(guard) + stealth_ai.stealth_force_skill(/datum/stealth_skill/green) + stealth_scans(guard, 1) + TEST_ASSERT(stealth_ai.stealth_state() != "alert", "A green guard went alert at once at 2 tiles") + qdel(guard) + guard = stealth_guard(block, 2, 3) + stealth_ai = stealth_ai(guard) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A yellow guard didn't go alert at once at 2 tiles") + stealth_ai.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + qdel(guard) + // Search length: 30 s in, a green search is over and a yellow one isn't. + person.forceMove(stealth_at(block, 0, 0)) + guard = stealth_guard(block, 12, 3, WEST) + stealth_ai = stealth_ai(guard) + stealth_scans(guard, 1) + stealth_ai.stealth_go_searching(stealth_at(block, 10, 3)) + stealth_ai.stealth_rewind(30 SECONDS) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "searching", "A yellow search ended within 30 s") + stealth_ai.stealth_force_skill(/datum/stealth_skill/green) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A green search didn't end by 30 s") + qdel(guard) + qdel(block) From b456e258c8bd8d9f0b68f714aa20c8167810d33e Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Wed, 11 Nov 2026 02:54:37 -0800 Subject: [PATCH 23/78] An execution click no longer also clubs the target with the gun --- .../hyperviolence/overlays_exec/executions.dm | 15 +++++++ .../voidcrew_hyperviolence_overlays_exec.dm | 43 +++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/voidcrew/modules/hyperviolence/overlays_exec/executions.dm b/voidcrew/modules/hyperviolence/overlays_exec/executions.dm index ebe29b2d26f..a6bac32bb3d 100644 --- a/voidcrew/modules/hyperviolence/overlays_exec/executions.dm +++ b/voidcrew/modules/hyperviolence/overlays_exec/executions.dm @@ -24,12 +24,26 @@ /obj/item/gun /// While an execution round is being fired: the damage it has dealt to the victim's head var/hv_execution_head_damage = 0 + /// Counts clicks that went to an execution, so try_fire_gun() can tell its own click took that path + var/hv_execution_claims = 0 /obj/item/gun/handle_suicide(mob/living/carbon/human/user, mob/living/carbon/human/target, params, bypass_timer) if(bypass_timer || !hv_execution_possible(user, target)) return ..() + hv_execution_claims++ hv_start_execution(user, target, params) +/** + * tg's fire_gun() returns nothing after the mouth path and after the marked head execution hook, so its click carries + * on down tg's attack chain and the gun also clubs the target (a pistol-whip on top of the execution). A click that + * went to an execution, whether the barrel was held or the wind-up was refused or broken, ends here instead. + */ +/obj/item/gun/try_fire_gun(atom/target, mob/living/user, params) + var/claims_before = hv_execution_claims + . = ..() + if(hv_execution_claims != claims_before) + return TRUE + /// Called by tg's fire_gun() for a point-blank shot, after its own checks (safeties, firing pins, the /// mouth). A head-aimed one at someone who can be executed starts the execution instead of firing. /// Returns TRUE if it did. @@ -38,6 +52,7 @@ return FALSE if(!hv_execution_possible(user, target)) return FALSE + hv_execution_claims++ hv_start_execution(user, target, params) return TRUE diff --git a/voidcrew/modules/unit_tests/voidcrew_hyperviolence_overlays_exec.dm b/voidcrew/modules/unit_tests/voidcrew_hyperviolence_overlays_exec.dm index 59337b0258c..468bab36a49 100644 --- a/voidcrew/modules/unit_tests/voidcrew_hyperviolence_overlays_exec.dm +++ b/voidcrew/modules/unit_tests/voidcrew_hyperviolence_overlays_exec.dm @@ -162,6 +162,49 @@ TEST_ASSERT(head.brute_dam >= round_damage * 1.5, "A head-aimed point-blank shot at a downed target was not an execution ([head.brute_dam] head damage from a [round_damage] round)") TEST_ASSERT(head.hv_skull_wound >= 1, "A head-aimed light execution left no skull wound for its damage") // light: 40 head brute +/// An execution click ends tg's attack chain: the gun isn't also swung at the victim (no pistol-whip), whether the +/// shot went off or the wind-up was refused. +/datum/unit_test/hv_execution_no_pistol_whip + /// Gun blows tg's attack chain landed on the victim + var/bashes = 0 + +/datum/unit_test/hv_execution_no_pistol_whip/Run() + var/mob/living/carbon/human/consistent/gunner = allocate(/mob/living/carbon/human/consistent) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent) + ADD_TRAIT(victim, TRAIT_PIERCEIMMUNE, INNATE_TRAIT) // no stray shrapnel + var/obj/item/gun/ballistic/automatic/pistol/gun = allocate(/obj/item/gun/ballistic/automatic/pistol) + gun.can_misfire = FALSE + gunner.put_in_active_hand(gun, forced = TRUE) + gunner.set_combat_mode(TRUE) + gunner.zone_selected = BODY_ZONE_HEAD + gun.chambered.loaded_projectile.damage = 20 // doubled at the muzzle: 40, under the burst line + victim.Knockdown(30 SECONDS) + TEST_ASSERT(gun.hv_execution_possible(gunner, victim), "Test fixture: the downed victim can't be executed") + RegisterSignal(gun, COMSIG_ITEM_ATTACK, PROC_REF(on_bash)) + // The real click: tg's attack chain, through try_fire_gun(), the wind-up and the shot. + var/obj/item/bodypart/head/head = victim.get_bodypart(BODY_ZONE_HEAD) + TEST_ASSERT(gun.melee_attack_chain(gunner, victim, list()), "The execution click didn't end the attack chain") + TEST_ASSERT(head.brute_dam > 0, "Test fixture: the execution didn't fire") + TEST_ASSERT_EQUAL(bashes, 0, "The gun clubbed the victim after the execution") + // A refused wind-up (the gun still busy) ends the chain too. + gun.fire_cd = TRUE + TEST_ASSERT(gun.melee_attack_chain(gunner, victim, list()), "A refused execution click didn't end the attack chain") + TEST_ASSERT_EQUAL(bashes, 0, "The gun clubbed the victim when the execution was refused") + gun.fire_cd = FALSE + // Someone who can't be executed is still clubbed as tg does (combat mode, point blank, nothing to shoot). + victim.SetKnockdown(0) + victim.fully_heal(HEAL_ALL) + gun.magazine.stored_ammo.Cut() + QDEL_NULL(gun.chambered) + TEST_ASSERT(!gun.hv_execution_possible(gunner, victim), "Test fixture: an empty gun could still execute") + gun.melee_attack_chain(gunner, victim, list()) + TEST_ASSERT_EQUAL(bashes, 1, "Test fixture: an empty gun's point-blank click didn't club, so the counts above prove nothing") + UnregisterSignal(gun, COMSIG_ITEM_ATTACK) + +/datum/unit_test/hv_execution_no_pistol_whip/proc/on_bash(obj/item/source, mob/living/target, mob/living/user) + SIGNAL_HANDLER + bashes++ + /// A human NPC is helpless only in tg's states (stunned, cuffed, held, down), never because of its health. /datum/unit_test/hv_npc_executable_states From 8a7e2763d409af4f40b57658fe1a13a4515cb8fc Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Wed, 11 Nov 2026 02:54:38 -0800 Subject: [PATCH 24/78] Guard flashlights light a real pool ahead, guards lean before they turn, walk their patrols and don't snap-spot right after turning --- .../JungleRuins/jungle_stealth_test.dmm | 15 +- tgstation.dme | 1 + voidcrew/_DEFINES/stealth.dm | 25 +- voidcrew/modules/stealth/stealth_ai.dm | 71 +++-- voidcrew/modules/stealth/stealth_light.dm | 246 +++++++++++++----- voidcrew/modules/stealth/stealth_patrol.dm | 21 +- .../modules/stealth/stealth_perception.dm | 22 +- voidcrew/modules/stealth/stealth_skill.dm | 4 + voidcrew/modules/stealth/stealth_turns.dm | 102 ++++++++ voidcrew/modules/unit_tests/_unit_tests.dm | 1 + .../unit_tests/voidcrew_stealth_crits.dm | 3 +- .../unit_tests/voidcrew_stealth_d32.dm | 91 +++++-- .../unit_tests/voidcrew_stealth_d37.dm | 1 + .../unit_tests/voidcrew_stealth_d39.dm | 115 ++++++++ .../unit_tests/voidcrew_stealth_light.dm | 153 ++++++++--- 15 files changed, 686 insertions(+), 185 deletions(-) create mode 100644 voidcrew/modules/stealth/stealth_turns.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_stealth_d39.dm diff --git a/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm index e3d43e91751..5c97ade5ca5 100644 --- a/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm +++ b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm @@ -43,8 +43,7 @@ "f" = ( /obj/effect/landmark/stealth_patrol{ route = "b"; - order = 3; - dir = 1 + order = 3 }, /turf/open/floor/plating, /area/ruin/powered) @@ -55,7 +54,6 @@ /obj/effect/landmark/stealth_patrol{ route = "b"; order = 1; - dir = 4; route_mode = "pingpong" }, /obj/effect/spawner/human_npc/ruin/scav{ @@ -73,8 +71,7 @@ "o" = ( /obj/effect/landmark/stealth_patrol{ route = "b"; - order = 2; - dir = 8 + order = 2 }, /turf/open/floor/plating, /area/ruin/powered) @@ -86,7 +83,7 @@ /obj/effect/landmark/stealth_patrol{ route = "a"; order = 3; - dir = 2 + facing = 2 }, /obj/effect/spawner/human_npc/ruin/scav{ dir = 2 @@ -105,7 +102,7 @@ /obj/effect/landmark/stealth_patrol{ route = "a"; order = 4; - dir = 4; + facing = 4; chatter = 1 }, /turf/open/floor/iron, @@ -133,7 +130,7 @@ /obj/effect/landmark/stealth_patrol{ route = "a"; order = 2; - dir = 4 + facing = 4 }, /obj/effect/spawner/human_npc/ruin/scav/lookout{ dir = 8 @@ -154,7 +151,7 @@ /obj/effect/landmark/stealth_patrol{ route = "a"; order = 1; - dir = 8 + facing = 8 }, /obj/effect/spawner/human_npc/ruin/scav{ dir = 4 diff --git a/tgstation.dme b/tgstation.dme index c59c35a66a4..377e75fcb6a 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7746,6 +7746,7 @@ #include "voidcrew\modules\stealth\stealth_radio.dm" #include "voidcrew\modules\stealth\stealth_skill.dm" #include "voidcrew\modules\stealth\stealth_test_ruin.dm" +#include "voidcrew\modules\stealth\stealth_turns.dm" #include "voidcrew\modules\storage\smart_locker.dm" #include "voidcrew\modules\storage\wall_locker.dm" #include "voidcrew\modules\surgery\experimental_dissection.dm" diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index e5c63d3e6f3..a8bd768c710 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -102,7 +102,6 @@ #define STEALTH_ROUTE_CLAIM_RANGE 2 #define STEALTH_PATROL_DEFAULT_WAIT (6 SECONDS) #define STEALTH_LOOK_TURN_INTERVAL (3 SECONDS) -#define STEALTH_LOOK_TURN_CHANCE 50 #define STEALTH_LOOK_TURN_ARC 90 #define STEALTH_SENTRY_TURN_INTERVAL (8 SECONDS) /// How long a sentry looks aside before it faces its post again @@ -168,6 +167,30 @@ /// A light EMP cuts a guard's seclite out for this long #define STEALTH_LIGHT_EMP_LIGHT (20 SECONDS) +// ===== Real flashlight pools (decision 39, stealth_light.dm) ===== +/// Tiles ahead its pool lands, when nothing stops it first +#define STEALTH_TORCH_REACH 3 +/// The same, facing a diagonal +#define STEALTH_TORCH_REACH_DIAGONAL 2 +/// The pool's light power (its seclite blue takes it to about 1.2 white) +#define STEALTH_TORCH_POWER 1.5 +/// The pool's light range with its centre 2.5 or more tiles off, 2 or more, and nearer (tg's least useful range) +#define STEALTH_TORCH_RANGE_FAR 2.5 +#define STEALTH_TORCH_RANGE_MID 2 +#define STEALTH_TORCH_RANGE_NEAR MINIMUM_USEFUL_LIGHT_RANGE +/// tg's seclite colour +#define STEALTH_TORCH_COLOR "#99ccff" + +// ===== Readable turns (decision 39, stealth_turns.dm) ===== +/// How long a guard leans towards the side it is about to turn to before it turns +#define STEALTH_TURN_TELL (0.6 SECONDS) +/// Pixels of that lean +#define STEALTH_TURN_LEAN 3 +/// How long the lean takes to show and to go +#define STEALTH_TURN_LEAN_TIME (0.2 SECONDS) +/// After a turn where it stands, nothing is plain to it at a glance for this long (yellow; the skill holds the number) +#define STEALTH_TURN_GRACE (1 SECONDS) + #define FACTION_SCAV "scav" // ===== Stealth crits and the backstab knife (step 3a, stealth_crits.dm) ===== diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index e34a18b8a10..764aa90ca09 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -17,6 +17,13 @@ COMSIG_LIVING_STATUS_UNCONSCIOUS,\ COMSIG_LIVING_STATUS_SLEEP,\ ) +/// Its hands stop or start working, or it is cuffed or freed: its flashlight goes out or may come back. +#define STEALTH_LIGHT_SIGNALS list(\ + SIGNAL_ADDTRAIT(TRAIT_HANDS_BLOCKED),\ + SIGNAL_REMOVETRAIT(TRAIT_HANDS_BLOCKED),\ + SIGNAL_ADDTRAIT(TRAIT_RESTRAINED),\ + SIGNAL_REMOVETRAIT(TRAIT_RESTRAINED),\ +) /** * # Stealth guards: awareness @@ -204,6 +211,8 @@ RegisterSignals(new_pawn, STEALTH_STUN_SIGNALS, PROC_REF(on_stunned)) RegisterSignal(new_pawn, COMSIG_LIVING_STATUS_REMOVED, PROC_REF(on_status_removed)) RegisterSignal(new_pawn, COMSIG_AI_BLACKBOARD_KEY_SET(BB_BASIC_MOB_CURRENT_TARGET), PROC_REF(on_target_set)) + RegisterSignal(new_pawn, COMSIG_ATOM_POST_DIR_CHANGE, PROC_REF(on_pawn_turned)) + RegisterSignals(new_pawn, STEALTH_LIGHT_SIGNALS, PROC_REF(on_light_cue)) /datum/ai_controller/basic_controller/human_npc/stealth/UnpossessPawn(destroy) if(pawn) @@ -217,7 +226,9 @@ COMSIG_MOB_FLASHED, COMSIG_LIVING_STATUS_REMOVED, COMSIG_AI_BLACKBOARD_KEY_SET(BB_BASIC_MOB_CURRENT_TARGET), - ) + STEALTH_HANDLED_SIGNALS + STEALTH_STUN_SIGNALS) + COMSIG_ATOM_POST_DIR_CHANGE, + ) + STEALTH_HANDLED_SIGNALS + STEALTH_STUN_SIGNALS + STEALTH_LIGHT_SIGNALS) + stealth_drop_turn() group?.remove_member(pawn) group = null stealth_drop_closet() @@ -225,6 +236,9 @@ qdel(overlay) watchers = null QDEL_NULL(meter) + QDEL_NULL(torch) + light_lit = FALSE + turned_from = null home_turf = null last_seen_turf = null harm_turf = null @@ -248,6 +262,8 @@ /datum/ai_controller/basic_controller/human_npc/stealth/on_sentience_gained() . = ..() QDEL_NULL(meter) + stealth_drop_turn() + stealth_update_light() stealth_drop_call() stealth_drop_closet() @@ -307,6 +323,7 @@ look_until = 0 lost_since = 0 calm_until = 0 + stealth_drop_turn() suspicion_heard = FALSE if(new_state != STEALTH_UNAWARE) glance_until = 0 @@ -659,8 +676,9 @@ var/judged = 0 // Someone it plainly sees within its point-blank range: an alert on this look (decision 32). Nearest first. var/mob/living/point_blank - // The close radius out of its cone works by the light that is there, not by its own beam (decision 32). - var/obj/item/flashlight/own_light = stealth_light() + // Just turned: nothing is plain to it at a glance and nothing makes it alert for a moment (decision 39); notice + // still fills as usual, so someone still in front of it when the moment passes is seen. + var/turning = stealth_turn_grace() var/night_vision = HAS_TRAIT(guard, TRAIT_NIGHT_VISION) for(var/mob/living/candidate as anything in stealth_candidates(guard, HUMAN_NPC_SIGHT_RANGE)) // Only those it could perceive count toward the cap, so bystanders it can't see never crowd a player out. @@ -721,13 +739,15 @@ rate = profile.notice_rate * clamp((cap + 1 - dist) / cap, STEALTH_NOTICE_MIN_FALLOFF, 1) if(cap < sight_range) rate *= STEALTH_DARK_MULT - // Close in front of it, seen plainly: no slow double take (decision 32). - plain_sight = cap == sight_range && dist <= profile.point_blank_range - if(dist <= profile.near_range) - rate *= profile.near_mult - if(!rate && dist <= close_range && (night_vision || !stealth_tile_is_dark(where, own_light))) - // At its shoulder, in light that is there anyway (abuse P7). Its own beam points ahead, so it - // doesn't count here: someone standing still right behind it in the dark is not seen (decision 32). + // Close in front of it, seen plainly: no slow double take (decision 32). Not in the dark, and not + // in the moment after it turns (decision 39). + else + plain_sight = !turning && dist <= profile.point_blank_range + if(dist <= profile.near_range) + rate *= profile.near_mult + if(!rate && dist <= close_range && (night_vision || !stealth_tile_is_dark(where))) + // At its shoulder, in light that is really there (abuse P7). Its own pool lands ahead of it, so + // someone right behind it in the dark is not seen (decisions 32 and 39). rate = STEALTH_BEHIND_RATE if(!rate) continue @@ -813,7 +833,8 @@ return // It has someone in sight now: their own "?" takes over from the heard one. suspicion_heard = FALSE - if(level >= STEALTH_ALERT_AT && in_reach) + // Just turned: the alert waits for the moment to pass (decision 39), the notice doesn't. + if(level >= STEALTH_ALERT_AT && in_reach && !turning) stealth_go_alert(best) return last_gain = world.time @@ -826,9 +847,10 @@ if(STEALTH_SEARCHING) if(!seen_now || level < STEALTH_SUSPICIOUS_AT) return - // It is primed: a glimpse is enough. + // It is primed: a glimpse is enough, once it isn't in the middle of turning (decision 39). if(in_reach) - stealth_go_alert(best) + if(!turning) + stealth_go_alert(best) return // Too far to be sure: the search moves to where it saw them. var/turf/new_center = stealth_leash(best_turf) @@ -852,7 +874,7 @@ var/mob/living/carbon/human/guard = pawn if(QDELETED(guard) || guard.stat != CONSCIOUS || guard.client || !isturf(guard.loc) || stealth_state() == STEALTH_ALERT) return FALSE - if(!stealth_eyes_open()) + if(!stealth_eyes_open() || stealth_turn_grace()) return FALSE var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) if(isnull(strategy)) @@ -1260,6 +1282,9 @@ stealth_drop_closet() if(new_stat == CONSCIOUS && was != CONSCIOUS && was != DEAD) stealth_came_round() + if(new_stat != CONSCIOUS) + stealth_drop_turn() + stealth_update_light() /datum/ai_controller/basic_controller/human_npc/stealth/proc/on_status_removed(mob/living/source, datum/status_effect/effect) SIGNAL_HANDLER @@ -1547,10 +1572,10 @@ if(!istype(controller) || guard.stat != CONSCIOUS || !isturf(guard.loc)) return AI_BEHAVIOR_DELAY if(world.time < controller.look_until) - // Looking round: two other ways over STEALTH_LOOK_AROUND_TIME. + // Looking round: one side, then the other, over STEALTH_LOOK_AROUND_TIME (decision 39: no random sides). if(world.time >= controller.next_turn) controller.next_turn = world.time + STEALTH_LOOK_AROUND_TIME / 2 - guard.setDir(turn(controller.stand_dir, pick(90, -90, 180))) + controller.stealth_turn_to(turn(controller.stand_dir, STEALTH_LOOK_TURN_ARC * controller.stealth_next_side())) return AI_BEHAVIOR_DELAY if(world.time < controller.next_turn) return AI_BEHAVIOR_DELAY @@ -1559,16 +1584,18 @@ guard.setDir(controller.stand_dir) return AI_BEHAVIOR_DELAY // A sentry faces its post and only glances aside now and then (decision 31: it used to spend half its - // time, the first eight seconds included, facing sideways). + // time, the first eight seconds included, facing sideways). A guard at a stop looks left, back, right, + // back, on a steady beat (decision 39: it used to be a coin toss every 3 s, which no one could read). var/sentry = isnull(controller.route_id) controller.next_turn = world.time + (sentry ? STEALTH_SENTRY_TURN_INTERVAL : STEALTH_LOOK_TURN_INTERVAL) if(guard.dir != controller.stand_dir) - guard.setDir(controller.stand_dir) - else if(sentry || prob(STEALTH_LOOK_TURN_CHANCE)) - guard.setDir(turn(controller.stand_dir, pick(STEALTH_LOOK_TURN_ARC, -STEALTH_LOOK_TURN_ARC))) - if(sentry) - controller.next_turn = world.time + STEALTH_SENTRY_GLANCE_TIME + controller.stealth_turn_to(controller.stand_dir) + return AI_BEHAVIOR_DELAY + controller.stealth_turn_to(turn(controller.stand_dir, STEALTH_LOOK_TURN_ARC * controller.stealth_next_side())) + if(sentry) + controller.next_turn = world.time + STEALTH_SENTRY_GLANCE_TIME return AI_BEHAVIOR_DELAY #undef STEALTH_HANDLED_SIGNALS #undef STEALTH_STUN_SIGNALS +#undef STEALTH_LIGHT_SIGNALS diff --git a/voidcrew/modules/stealth/stealth_light.dm b/voidcrew/modules/stealth/stealth_light.dm index 745db2f5018..aa5c77c2f3a 100644 --- a/voidcrew/modules/stealth/stealth_light.dm +++ b/voidcrew/modules/stealth/stealth_light.dm @@ -1,43 +1,62 @@ /** - * # Stealth guards: flashlights (owner decision 31) + * # Stealth guards: flashlights (owner decisions 31 and 39) * - * A scav guard carries a real seclite clipped to its belt (or its vest, or a pocket). tg's own overlay - * light draws it, cast the way the guard faces, and adds to the lit turfs' dynamic_lumcount, which the - * darkness rule (stealth_tile_is_dark()) already reads. So the light shows a guard what it lights and - * nothing more: there is no "sees in the dark" rule. + * A scav guard carries a real seclite clipped to its belt (or its vest, or a pocket). What it lights is a real + * light (decision 39): a hidden lamp, /obj/effect/abstract/stealth_torch, that sits on the floor a few tiles ahead + * of the guard, where the beam would land, and lights a small pool through tg's own static lighting. Everyone sees + * the pool, around corners too, and the darkness rule (stealth_tile_is_dark()) reads the same light the players + * see, so what looks dark is dark to the guards as well. The seclite item itself stays off and stays a plain tg + * seclite: a looted one works like any other, and nothing draws two beams. * - * The guard switches it with the light's own toggle (its click and all): on when it stands somewhere dark, - * always on while suspicious, alert or searching, off in lit places while unaware so a lit patrol looks - * the same as before. It keeps it on for STEALTH_LIGHT_HOLD after it last wanted it, so walking along the - * edge of a lit room doesn't flick it on and off. + * Where the pool goes: STEALTH_TORCH_REACH tiles ahead along its facing (STEALTH_TORCH_REACH_DIAGONAL on a + * diagonal), or the last open tile before the first wall, opaque thing or closed door. It shines through glass. The + * nearer the pool has to sit, the smaller it is, so it never lights the guard's own back (stealth_torch_range()). + * Facing a wall at its nose it has no pool at all. * - * Beating it is tg's: you see the beam coming; an EMP or the saboteur gun cuts it out for a while (the - * scav seclite takes an EMP as tg's saboteur hit; a stock seclite ignores EMPs); a guard that is down, - * stunned, cuffed, asleep or dead doesn't touch it. A light that is gone from its body (deleted, burnt, - * forced off) is gone: the guard goes without. Unlike the rest of its kit it is not locked gear (decision 34 - * amends human NPC decision D3): it can be stripped, knocked loose and looted like anyone's seclite. Once it has left - * a guard's body it is an ordinary seclite to the guards too (off the guard light list). + * The guard switches it as before: on when it stands somewhere dark (judged without any guard's light, decision 32, + * so two guards never switch each other off), always on while suspicious, alert or searching, off in lit places + * while unaware. It keeps it on for STEALTH_LIGHT_HOLD after it last wanted it, so walking along the edge of a lit + * room doesn't flick it on and off. + * + * Beating it is tg's: you see the pool coming; an EMP or the saboteur gun cuts the seclite out for a while (the scav + * seclite takes an EMP as tg's saboteur hit; a stock seclite ignores EMPs); a guard that is down, stunned, cuffed, + * held, asleep or dead has no light; nor does one whose seclite was taken (decision 34: it can be stripped, knocked + * loose and looted like anyone's seclite). + * + * Cost: the pool moves only when the guard's turf or facing changes, or when it switches on or off (at most once a + * scan). A move is one abstract_move() of the lamp, which queues one static light update. A guard asleep in a + * dormant level moves and scans nothing, so its lamp costs nothing. */ -/// Every guard's seclite, so a guard can leave them all out when it judges how dark its spot is -GLOBAL_LIST_EMPTY(stealth_guard_lights) +/// Every guard's lamp, so a guard can leave them all out when it judges how dark its own spot is (decision 32) +GLOBAL_LIST_EMPTY(stealth_guard_torches) /// A guard's seclite: an EMP blinds it for a while, as tg's saboteur gun does. /obj/item/flashlight/seclite/scav -/obj/item/flashlight/seclite/scav/Initialize(mapload) +/obj/item/flashlight/seclite/scav/emp_act(severity) . = ..() - GLOB.stealth_guard_lights += src + if(. & EMP_PROTECT_SELF) + return + on_saboteur(null, severity == EMP_HEAVY ? STEALTH_LIGHT_EMP_HEAVY : STEALTH_LIGHT_EMP_LIGHT) -/obj/item/flashlight/seclite/scav/Destroy() - GLOB.stealth_guard_lights -= src - return ..() +/obj/item/flashlight/seclite/scav/on_saboteur(datum/source, disrupt_duration) + . = ..() + stealth_tell_holder(loc) -/// Off a guard's body (looted, stripped, dropped), it is just a seclite: no guard leaves its light out any more. +/// Off a guard's body (looted, stripped, dropped), the guard's pool goes out at once. /obj/item/flashlight/seclite/scav/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE) . = ..() - if(!ishumannpc(loc)) - GLOB.stealth_guard_lights -= src + stealth_tell_holder(old_loc) + +/// Tells the guard `holder` (if it is one) that its light changed. +/obj/item/flashlight/seclite/scav/proc/stealth_tell_holder(atom/holder) + if(!ishumannpc(holder)) + return + var/mob/living/carbon/human/npc/guard = holder + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + if(istype(stealth_ai)) + stealth_ai.stealth_update_light() /// Decision 34: a guard's seclite is loot like anyone's, so it is never locked to the body (D3 holds for the rest). /mob/living/carbon/human/npc/npc_lock_item(obj/item/item) @@ -45,12 +64,6 @@ GLOBAL_LIST_EMPTY(stealth_guard_lights) return FALSE return ..() -/obj/item/flashlight/seclite/scav/emp_act(severity) - . = ..() - if(. & EMP_PROTECT_SELF) - return - on_saboteur(null, severity == EMP_HEAVY ? STEALTH_LIGHT_EMP_HEAVY : STEALTH_LIGHT_EMP_LIGHT) - /mob/living/carbon/human/npc /// Weakref to the flashlight a stealth guard switches on in the dark, or null for none var/datum/weakref/stealth_light @@ -65,18 +78,99 @@ GLOBAL_LIST_EMPTY(stealth_guard_lights) qdel(light) return null -/// How much `light` adds to `tile` right now (tg's overlay light: a flat share on every turf it reaches). -/proc/stealth_light_share(obj/item/flashlight/light, turf/tile) - if(!light?.light_on) - return 0 - var/datum/component/overlay_lighting/glow = light.GetComponent(/datum/component/overlay_lighting) - if(isnull(glow) || !(tile in glow.affected_turfs)) - return 0 - return glow.lum_power +/** + * The pool of a guard's flashlight on the floor: a real static light with no sprite. It is never entered into a + * turf (abstract_move()), so it trips nothing, and nothing can touch, move or burn it. + */ +/obj/effect/abstract/stealth_torch + name = "flashlight beam" + icon = null + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + anchored = TRUE + blocks_emissive = EMISSIVE_BLOCK_NONE + light_system = COMPLEX_LIGHT + light_range = STEALTH_TORCH_RANGE_FAR + light_power = STEALTH_TORCH_POWER + light_color = STEALTH_TORCH_COLOR + light_on = FALSE + +/obj/effect/abstract/stealth_torch/Initialize(mapload) + . = ..() + GLOB.stealth_guard_torches += src + +/obj/effect/abstract/stealth_torch/Destroy() + GLOB.stealth_guard_torches -= src + return ..() + +/// How much every guard's lamp adds to `tile` right now, in get_lumcount() units. +/proc/stealth_torch_share(turf/tile) + . = 0 + if(!isturf(tile)) + return + for(var/obj/effect/abstract/stealth_torch/torch as anything in GLOB.stealth_guard_torches) + var/datum/light_source/source = torch.light + var/list/strengths = source?.effect_str + if(!length(strengths) || torch.z != tile.z || get_dist(torch, tile) > STEALTH_TORCH_RANGE_FAR + 1) + continue + var/channels = source.applied_lum_r + source.applied_lum_g + source.applied_lum_b + for(var/datum/lighting_corner/corner as anything in list(tile.lighting_corner_NE, tile.lighting_corner_SE, tile.lighting_corner_SW, tile.lighting_corner_NW)) + if(corner) + . += (strengths[corner] || 0) * channels + . /= 12 // as get_lumcount(): 4 corners, 3 channels each + +/// Whether light passes from `tile` on to `next`, the way `facing` points: not into a wall, an opaque thing or a +/// closed door (glass ones too). Glass passes. A diagonal step needs one of its two sides open. +/proc/stealth_torch_passes(turf/tile, turf/next, facing) + if(isnull(next) || next.z != tile.z || IS_OPAQUE_TURF(next)) + return FALSE + if(facing & (facing - 1)) + var/turf/side_a = get_step(tile, facing & (NORTH | SOUTH)) + var/turf/side_b = get_step(tile, facing & (EAST | WEST)) + if((isnull(side_a) || IS_OPAQUE_TURF(side_a)) && (isnull(side_b) || IS_OPAQUE_TURF(side_b))) + return FALSE + for(var/obj/machinery/door/door in next) + if(door.density) + return FALSE + for(var/obj/structure/mineral_door/door in next) + if(door.density) + return FALSE + // A closed windoor on the edge it leaves by + for(var/obj/machinery/door/window/windoor in tile) + if(windoor.density && (windoor.dir & facing)) + return FALSE + return TRUE + +/// Where the pool of a light carried at `from`, facing `facing`, lands: the furthest open tile within reach, or null. +/proc/stealth_torch_spot(turf/from, facing) + if(!isturf(from) || !facing) + return null + var/reach = (facing & (facing - 1)) ? STEALTH_TORCH_REACH_DIAGONAL : STEALTH_TORCH_REACH + var/turf/tile = from + var/turf/spot + for(var/i in 1 to reach) + var/turf/next = get_step(tile, facing) + if(!stealth_torch_passes(tile, next, facing)) + break + tile = next + spot = next + return spot + +/// How wide the pool is with its centre `distance` tiles from the guard: smaller when it has to sit near, so it +/// never lights the guard's own tile or the tile behind it (numbers in data/stealth/STATUS.md, decision 39). +/proc/stealth_torch_range(distance) + if(distance >= 2.5) + return STEALTH_TORCH_RANGE_FAR + if(distance >= 2) + return STEALTH_TORCH_RANGE_MID + return STEALTH_TORCH_RANGE_NEAR /datum/ai_controller/basic_controller/human_npc/stealth /// world.time until which it keeps its light on after it last wanted it var/light_hold_until = 0 + /// Whether it has its light on (the pool shows when there is room for one ahead) + var/light_lit = FALSE + /// The pool its light makes, made the first time it is switched on + var/obj/effect/abstract/stealth_torch/torch /// Its flashlight, if it still has it on its body; else null. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_light() @@ -88,43 +182,61 @@ GLOBAL_LIST_EMPTY(stealth_guard_lights) return null return light -/// Switches its light on or off for where it stands and what it is doing. Does nothing while it can't use -/// its hands, while a player has the body, or while the light is cut out. -/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_update_light() +/// Whether it can use its light at all: awake, its own, free, hands working, and the seclite on it and not cut out. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_light_usable() var/mob/living/carbon/human/npc/guard = pawn if(QDELETED(guard) || guard.stat != CONSCIOUS || stealth_driven() || stealth_captive() || HAS_TRAIT(guard, TRAIT_HANDS_BLOCKED)) - return + return FALSE var/obj/item/flashlight/light = stealth_light() - if(isnull(light) || !COOLDOWN_FINISHED(light, disabled_time)) + return !isnull(light) && COOLDOWN_FINISHED(light, disabled_time) + +/// Switches its light on or off for where it stands and what it is doing. Off at once when it can't use it. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_update_light() + if(!stealth_light_usable()) + light_hold_until = 0 + stealth_set_light(FALSE) return - // Its own spot judged by the room's light alone: a friend's passing beam doesn't switch it off (decision 32). - var/wanted = stealth_state() != STEALTH_UNAWARE || stealth_tile_is_dark(get_turf(guard), light, no_guard_lights = TRUE) + var/mob/living/guard = pawn + // Its own spot judged by the room's light alone: a friend's passing pool doesn't switch it off (decision 32). + var/wanted = stealth_state() != STEALTH_UNAWARE || stealth_tile_is_dark(get_turf(guard), no_guard_lights = TRUE) if(wanted) light_hold_until = world.time + STEALTH_LIGHT_HOLD else if(world.time < light_hold_until) + stealth_place_torch() return - if(wanted != light.light_on) - light.toggle_light(guard) - if(light.light_on) - stealth_redraw_light(light) + stealth_set_light(wanted) -/** - * After switching it on: has tg's light lay its beam out again, as it does when the guard turns. The fl_sentry - * clip (decision 32) caught a light that read on but drew nothing until the guard next turned; turning re-runs - * this same update. Done now and again a tick later, so a facing change in the same tick can't race it. - */ -/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_redraw_light(obj/item/flashlight/light) - stealth_relay_light(light) - addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(stealth_relay_light), light), 1) +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_set_light(lit) + light_lit = lit + stealth_place_torch() + +/// Puts the pool where its light lands now, or puts it out. Moves the lamp only when the spot changed. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_place_torch() + var/mob/living/guard = pawn + var/turf/spot = (light_lit && !QDELETED(guard)) ? stealth_torch_spot(get_turf(guard), guard.dir) : null + if(isnull(spot)) + if(torch?.light_on) + torch.set_light_on(FALSE) + return + if(QDELETED(torch)) + torch = new(spot) + var/range = stealth_torch_range(get_dist_euclidean(guard, spot)) + if(torch.light_range != range) + torch.set_light_range(range) + if(torch.loc != spot) + torch.abstract_move(spot) + if(!torch.light_on) + torch.set_light_on(TRUE) + +/// Whether its light is on with a pool on the floor (for admins and tests). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_light_shows() + return light_lit && !QDELETED(torch) && torch.light_on -/// Re-lays an overlay light that is on: the holder check, then the beam and the lit turfs, as a turn would. -/proc/stealth_relay_light(obj/item/flashlight/light) - if(QDELETED(light) || !light.light_on) +/// It moved or turned: the pool follows. Nothing to do with its light off. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_light_follow() + if(!light_lit) return - var/datum/component/overlay_lighting/glow = light.GetComponent(/datum/component/overlay_lighting) - // (1<<0) is tg's LIGHTING_ON, which overlay_lighting.dm undefines at its end. - if(isnull(glow) || !(glow.overlay_lighting_flags & (1<<0))) + if(!stealth_light_usable()) + stealth_update_light() return - glow.recheck_holder() - if(glow.current_holder) - glow.make_luminosity_update() + stealth_place_torch() diff --git a/voidcrew/modules/stealth/stealth_patrol.dm b/voidcrew/modules/stealth/stealth_patrol.dm index a2f84e79518..221c82c8799 100644 --- a/voidcrew/modules/stealth/stealth_patrol.dm +++ b/voidcrew/modules/stealth/stealth_patrol.dm @@ -21,7 +21,8 @@ GLOBAL_LIST_EMPTY(stealth_unassigned_points) /datum/stealth_stop var/turf/spot var/wait = STEALTH_PATROL_DEFAULT_WAIT - var/dir = SOUTH + /// The way the guard turns to here, or 0 to keep facing the way it walked in + var/dir = 0 var/chatter = FALSE var/order = 0 @@ -114,7 +115,7 @@ GLOBAL_VAR_INIT(stealth_group_count, 0) var/datum/stealth_stop/stop = new stop.spot = get_turf(point) stop.wait = point.wait < 0 ? STEALTH_PATROL_DEFAULT_WAIT : point.wait - stop.dir = point.dir + stop.dir = point.facing stop.chatter = point.chatter stop.order = point.order var/list/route = routes[point.route] @@ -189,10 +190,13 @@ GLOBAL_VAR_INIT(stealth_group_count, 0) old.prune() return ..() -/// A stop on a guard route. Its dir is the way the guard faces there. +/// A stop on a guard route. A guard arrives facing the way it walked, unless `facing` is set. /obj/effect/landmark/stealth_patrol name = "stealth patrol point" icon_state = "x3" + /// The way the guard turns to at this stop (NORTH, SOUTH, EAST or WEST), or 0 to keep facing the way it walked in + /// (decision 39: turning back on the way it came faced anyone following it) + var/facing = 0 /// The route it belongs to ("a", "b", ...) var/route = "a" /// Its place on the route, from 1 @@ -223,6 +227,10 @@ GLOBAL_VAR_INIT(stealth_group_count, 0) var/turf/spawn_turf = get_turf(guard) // Its skill comes from where it starts (decision 38), settled now, before it walks anywhere. stealth_skill() + // A calm guard walks (decision 39: tg starts every mob at a run, and nothing set the pace before its first + // change of state, so fresh patrols ran their routes). + if(!stealth_driven()) + stealth_set_pace(FALSE) home_turf = spawn_turf sentry_dir = stealth_facing(guard) stand_dir = sentry_dir @@ -421,8 +429,11 @@ GLOBAL_VAR_INIT(stealth_group_count, 0) home_turf = stop.spot stop_fails["[route_index]"] = 0 wait_until = world.time + stop.wait - stand_dir = stop.dir - pawn.setDir(stop.dir) + if(stop.dir) + stand_dir = stop.dir + stealth_turn_to(stop.dir) + else + stand_dir = stealth_facing(pawn) next_turn = world.time + STEALTH_LOOK_TURN_INTERVAL if(!stop.chatter || world.time < group.next_chatter) return diff --git a/voidcrew/modules/stealth/stealth_perception.dm b/voidcrew/modules/stealth/stealth_perception.dm index 65d563afc90..9182272551e 100644 --- a/voidcrew/modules/stealth/stealth_perception.dm +++ b/voidcrew/modules/stealth/stealth_perception.dm @@ -57,30 +57,22 @@ GLOBAL_LIST_EMPTY(stealth_test_dark_turfs) * Whether `tile` is dark enough to hide in. A turf with no lighting object (planet ground lit only by its * area's ambient light) reads its area's base light, which get_lumcount() skips (it returns 1 there). * Same rule as the bounty AI's ai_tile_is_dark() (bounty_ai_meek.dm), which is a type proc. - * A flashlight's light counts like any other (tg adds it to dynamic_lumcount). `own_light` leaves out what - * that one light adds: a guard's own beam never lights the tile behind it (decision 32). `no_guard_lights` - * leaves out every guard's seclite, so a guard deciding whether its spot needs a light judges by the room's - * own light, not by a friend walking past with one (decision 32: no flicker when guards meet). + * Every light counts, a guard's own flashlight pool too: it is real light that players see (decision 39). + * `no_guard_lights` leaves out every guard's pool, so a guard deciding whether its spot needs a light judges by + * the room's own light, not by a friend walking past with one (decision 32: no flicker when guards meet). */ -/proc/stealth_tile_is_dark(turf/tile, obj/item/flashlight/own_light, no_guard_lights = FALSE) +/proc/stealth_tile_is_dark(turf/tile, no_guard_lights = FALSE) if(!isturf(tile)) return FALSE #ifdef UNIT_TESTS if(tile in GLOB.stealth_test_dark_turfs) return GLOB.stealth_test_dark_turfs[tile] #endif - var/own = 0 - if(no_guard_lights) - for(var/obj/item/flashlight/guard_light as anything in GLOB.stealth_guard_lights) - own += stealth_light_share(guard_light, tile) - if(own_light && !(own_light in GLOB.stealth_guard_lights)) - own += stealth_light_share(own_light, tile) - else if(own_light) - own = stealth_light_share(own_light, tile) if(!tile.lighting_object) var/area/tile_area = tile.loc - return (tile_area.base_lighting_alpha / 255) + tile.dynamic_lumcount - own < STEALTH_DARK_LUMCOUNT - return tile.get_lumcount() - own < STEALTH_DARK_LUMCOUNT + return (tile_area.base_lighting_alpha / 255) + tile.dynamic_lumcount < STEALTH_DARK_LUMCOUNT + var/guard_light = no_guard_lights ? stealth_torch_share(tile) : 0 + return tile.get_lumcount() - guard_light < STEALTH_DARK_LUMCOUNT /** * What `who` is shut inside, as it stands on a turf: the box, locker, bag or car, or the outermost of them. diff --git a/voidcrew/modules/stealth/stealth_skill.dm b/voidcrew/modules/stealth/stealth_skill.dm index 507869b9c56..ab202d158c2 100644 --- a/voidcrew/modules/stealth/stealth_skill.dm +++ b/voidcrew/modules/stealth/stealth_skill.dm @@ -47,6 +47,8 @@ var/search_time = 40 SECONDS /// How long it stays wary with nothing new var/wary_time = 60 SECONDS + /// After it turns where it stands, how long before anything is plain to it at a glance (decision 39) + var/turn_grace = 1 SECONDS /datum/stealth_skill/yellow @@ -68,6 +70,7 @@ reaction_delay = 3 SECONDS search_time = 25 SECONDS wary_time = 40 SECONDS + turn_grace = 1.2 SECONDS /// Sharp: sees further and wider, notices faster, hears more, searches longer. Still blind behind in the dark. /datum/stealth_skill/red @@ -87,6 +90,7 @@ reaction_delay = 1 SECONDS search_time = 60 SECONDS wary_time = 90 SECONDS + turn_grace = 0.8 SECONDS /// The shared profile of type `skill_type`, or null if it isn't one. /proc/stealth_skill_of(skill_type) diff --git a/voidcrew/modules/stealth/stealth_turns.dm b/voidcrew/modules/stealth/stealth_turns.dm new file mode 100644 index 00000000000..3eb7655272d --- /dev/null +++ b/voidcrew/modules/stealth/stealth_turns.dm @@ -0,0 +1,102 @@ +/** + * # Stealth guards: readable turns (decision 39, playtest fixes) + * + * A guard that turns on its own (a look aside at a stop, a sentry's glance, the look round when suspicious or + * searching, back to the way it faces) leans a few pixels towards the new side for STEALTH_TURN_TELL first, then + * turns. A player watching it sees which way it is about to look and has a moment to move. + * + * After any turn made where it stands (its own, or one to a noise or a door), nothing is plain to it at a glance for + * its skill's turn_grace: no instant point-blank alert (decision 32), and no alert by sight at all until the moment + * passes. Its notice still fills as usual (it can go "?"), so someone who stays in front of it is seen on the first + * look after. A turn made by stepping is a walk, not a look round, and gives nothing. + * + * Its flashlight pool (stealth_light.dm) follows every turn and step from here. + */ + +/datum/ai_controller/basic_controller/human_npc/stealth + /// world.time of its last turn made standing still, or 0 + var/turned_at = 0 + /// The turf it stood on for that turn + var/turf/turned_from + /// The way it is about to turn while its tell shows, or 0 + var/turn_pending = 0 + /// world.time that turn was planned (tells an old timer from the current one) + var/turn_planned_at = 0 + /// Where it stood when it planned that turn + var/turf/turn_planned_from + /// The lean its tell put on the body (list(pixel_w, pixel_z)), to take back, or null + var/list/turn_lean + /// +1 or -1: the side its next look aside goes (turn() takes positive as anticlockwise) + var/look_side = -1 + +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_pawn_turned(atom/source, old_dir, new_dir) + SIGNAL_HANDLER + if(old_dir == new_dir) + return + // Not before it has set up: a mapper's facing or a test's setDir is not a turn. + if(stealth_ready) + turned_at = world.time + turned_from = get_turf(source) + stealth_light_follow() + +/datum/ai_controller/basic_controller/human_npc/stealth/update_grid(datum/source, datum/spatial_grid_cell/new_cell) + . = ..() + stealth_light_follow() + +/// Its hands or its freedom changed: its light may have to go out or may come back. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_light_cue(datum/source) + SIGNAL_HANDLER + stealth_update_light() + +/// Whether it turned where it stands within its skill's turn_grace: nothing is plain to it at a glance yet. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_turn_grace() + if(!turned_at || world.time >= turned_at + stealth_skill().turn_grace) + return FALSE + return get_turf(pawn) == turned_from + +/// The side of its next look aside: they alternate, so a player can count on the next one. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_next_side() + look_side = -look_side + return look_side + +/// Turns to `new_dir` on its own: leans that way for STEALTH_TURN_TELL, then turns. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_turn_to(new_dir) + var/mob/living/guard = pawn + if(QDELETED(guard) || !new_dir) + return + if(turn_pending) + if(turn_pending == new_dir) + return + stealth_drop_turn() + if(guard.dir == new_dir) + return + turn_pending = new_dir + turn_planned_at = world.time + turn_planned_from = get_turf(guard) + var/lean_w = (new_dir & EAST) ? STEALTH_TURN_LEAN : ((new_dir & WEST) ? -STEALTH_TURN_LEAN : 0) + var/lean_z = (new_dir & NORTH) ? STEALTH_TURN_LEAN : ((new_dir & SOUTH) ? -STEALTH_TURN_LEAN : 0) + turn_lean = list(lean_w, lean_z) + animate(guard, pixel_w = lean_w, pixel_z = lean_z, time = STEALTH_TURN_LEAN_TIME, flags = ANIMATION_RELATIVE | ANIMATION_PARALLEL) + addtimer(CALLBACK(src, PROC_REF(stealth_finish_turn), new_dir, turn_planned_at), STEALTH_TURN_TELL) + +/// The tell is over: it turns, unless the moment has passed (it moved, went down, changed state, or a player took it). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_finish_turn(new_dir, planned_at) + if(turn_pending != new_dir || turn_planned_at != planned_at) + return + var/mob/living/guard = pawn + var/turf/planned_from = turn_planned_from + stealth_drop_turn() + if(QDELETED(guard) || guard.stat != CONSCIOUS || stealth_driven() || get_turf(guard) != planned_from) + return + guard.setDir(new_dir) + +/// Drops a turn it was about to make and takes its lean back. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_drop_turn() + turn_pending = 0 + turn_planned_from = null + if(isnull(turn_lean)) + return + var/mob/living/guard = pawn + if(!QDELETED(guard)) + animate(guard, pixel_w = -turn_lean[1], pixel_z = -turn_lean[2], time = STEALTH_TURN_LEAN_TIME, flags = ANIMATION_RELATIVE | ANIMATION_PARALLEL) + turn_lean = null diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index 0838cd728bc..7783ab633ec 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -239,6 +239,7 @@ #include "voidcrew_stealth_crits.dm" #include "voidcrew_stealth_d32.dm" #include "voidcrew_stealth_d37.dm" +#include "voidcrew_stealth_d39.dm" #include "voidcrew_stealth_hearing.dm" #include "voidcrew_stealth_light.dm" #include "voidcrew_survey_archive.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_crits.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_crits.dm index 28ba80d29f8..73c4bec4391 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_crits.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_crits.dm @@ -168,16 +168,15 @@ TEST_ASSERT(!HAS_TRAIT(light, TRAIT_NO_STRIP), "The seclite can't be stripped") TEST_ASSERT(!human_npc_gear_locked(light), "The seclite is locked gear") TEST_ASSERT(human_npc_gear_locked(guard.w_uniform), "The rest of the guard's kit isn't locked any more") - TEST_ASSERT(light in GLOB.stealth_guard_lights, "The seclite isn't on the guard light list") var/mob/living/carbon/human/person = stealth_person(block, 3, 2) TEST_ASSERT(guard.dropItemToGround(light), "The seclite can't be taken off") TEST_ASSERT(person.put_in_hands(light), "The seclite can't be picked up") TEST_ASSERT(!QDELETED(light), "The looted seclite was deleted") - TEST_ASSERT(!(light in GLOB.stealth_guard_lights), "A looted seclite still counts as a guard's") // The guard goes without: no light to switch, and it still scans and sees. TEST_ASSERT_NULL(stealth_ai.stealth_light(), "The guard still counts the light it lost") GLOB.stealth_test_dark_turfs[get_turf(guard)] = TRUE stealth_ai.stealth_update_light() + TEST_ASSERT(!stealth_ai.stealth_light_shows(), "The guard lights a pool with a light a player holds") TEST_ASSERT(!light.light_on, "The guard switched on a light a player holds") GLOB.stealth_test_dark_turfs[get_turf(guard)] = FALSE person.forceMove(stealth_at(block, 5, 2)) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm index a3a30f04c60..1be25f0cb20 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm @@ -59,37 +59,63 @@ qdel(guard) qdel(block) -/// Real lighting: standing still right behind a guard in the dark, its own light on, is never seen; two ahead is. +/// Real lighting: standing still right behind a guard in the dark, its light on, is never seen; two ahead is. /datum/unit_test/voidcrew_stealth_behind_dark /datum/unit_test/voidcrew_stealth_behind_dark/Run() var/datum/turf_reservation/block = stealth_block(9, 5) TEST_ASSERT_NOTNULL(block, "No room for the test") stealth_unlist(block, 9, 5) - var/mob/living/carbon/human/person = stealth_person(block, 3, 2) + var/mob/living/carbon/human/person = stealth_person(block, 1, 2) var/turf/behind = get_turf(person) TEST_ASSERT(stealth_tile_is_dark(behind), "Reserved test space isn't dark, so the light can't be tested") - var/mob/living/carbon/human/npc/guard = stealth_guard(block, 4, 2) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 2) var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) - var/obj/item/flashlight/light = stealth_ai.stealth_light() - TEST_ASSERT_NOTNULL(light, "A scav guard has no flashlight") stealth_ai.stealth_update_light() - TEST_ASSERT(light.light_on, "A guard in the dark didn't switch its light on") - // The trap this guards against: tg counts the tile behind as lit by the guard's own light. - TEST_ASSERT(!stealth_tile_is_dark(behind), "The guard's light doesn't reach the tile behind it, so this test proves nothing") - TEST_ASSERT(stealth_tile_is_dark(behind, light), "Leaving the guard's own light out, the tile behind it isn't dark") + TEST_ASSERT(stealth_ai.stealth_light_shows(), "A guard in the dark didn't switch its light on") + stealth_settle_light() + // Its pool lands ahead of it (decision 39): the tile behind it stays dark. + TEST_ASSERT(stealth_tile_is_dark(behind), "The guard's pool lights the tile behind it") stealth_scans(guard, 10) TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard saw someone standing still right behind it in the dark") var/list/entry = stealth_ai.notice_map[REF(person)] TEST_ASSERT(isnull(entry) || entry[1] == 0, "A guard built notice on someone right behind it in the dark ([entry?[1]])") - // Two tiles ahead, in its own beam: an alert. - person.forceMove(stealth_at(block, 6, 2)) + // Two tiles ahead, in its pool: an alert. + person.forceMove(stealth_at(block, 4, 2)) + TEST_ASSERT(!stealth_tile_is_dark(get_turf(person)), "The guard's pool doesn't reach 2 tiles ahead") stealth_scans(guard, 1) TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard didn't see someone 2 tiles ahead in its own light") qdel(guard) qdel(block) -/// A friend's passing light doesn't make a guard switch its own off: its spot is judged by the room's light. +/// Decision 39: someone walking about behind a guard in the dark, never touching it, gains no notice at all. +/datum/unit_test/voidcrew_stealth_behind_walking + +/datum/unit_test/voidcrew_stealth_behind_walking/Run() + var/datum/turf_reservation/block = stealth_block(9, 7) + TEST_ASSERT_NOTNULL(block, "No room for the test") + stealth_unlist(block, 9, 7) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 5, 3) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 4, 3) + TEST_ASSERT_EQUAL(person.move_intent, MOVE_INTENT_WALK, "Test fixture: the person isn't walking") + stealth_ai.stealth_update_light() + TEST_ASSERT(stealth_ai.stealth_light_shows(), "A guard in the dark didn't switch its light on") + stealth_settle_light() + // A walk round its back: behind, behind-diagonal and the tiles two back, every step a new tile. + var/list/path = list(list(4, 3), list(4, 4), list(3, 4), list(3, 3), list(3, 2), list(4, 2), list(4, 3), list(3, 3)) + for(var/list/step as anything in path) + var/turf/tile = stealth_at(block, step[1], step[2]) + TEST_ASSERT(stealth_tile_is_dark(tile), "Behind the guard at ([step[1]], [step[2]]) isn't dark") + person.forceMove(tile) + stealth_scans(guard, 1) + var/list/entry = stealth_ai.notice_map[REF(person)] + TEST_ASSERT(isnull(entry) || entry[1] == 0, "Walking behind a guard in the dark at ([step[1]], [step[2]]) built notice ([entry?[1]])") + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard noticed someone walking behind it in the dark") + qdel(block) + +/// A friend's passing light doesn't make a guard switch its own off: its spot is judged by the room's light. Where a +/// friend's pool really lands, it is real light. /datum/unit_test/voidcrew_stealth_light_friends /datum/unit_test/voidcrew_stealth_light_friends/Run() @@ -97,25 +123,24 @@ TEST_ASSERT_NOTNULL(block, "No room for the test") stealth_unlist(block, 12, 5) var/mob/living/carbon/human/npc/first = stealth_guard(block, 2, 2) - var/mob/living/carbon/human/npc/second = stealth_guard(block, 4, 2) + var/mob/living/carbon/human/npc/second = stealth_guard(block, 5, 2) var/datum/ai_controller/basic_controller/human_npc/stealth/first_ai = stealth_ai(first) var/datum/ai_controller/basic_controller/human_npc/stealth/second_ai = stealth_ai(second) - var/obj/item/flashlight/first_light = first_ai.stealth_light() - var/obj/item/flashlight/second_light = second_ai.stealth_light() - TEST_ASSERT(first_light in GLOB.stealth_guard_lights, "A guard's seclite isn't on the guard light list") first_ai.stealth_update_light() - TEST_ASSERT(first_light.light_on, "The first guard didn't switch its light on in the dark") + TEST_ASSERT(first_ai.stealth_light_shows(), "The first guard didn't switch its light on in the dark") + stealth_settle_light() var/turf/spot = get_turf(second) - TEST_ASSERT(!stealth_tile_is_dark(spot, second_light), "The first guard's light doesn't reach the second, so this test proves nothing") - TEST_ASSERT(stealth_tile_is_dark(spot, second_light, no_guard_lights = TRUE), "Without guard lights the second guard's spot isn't dark") + TEST_ASSERT(!stealth_tile_is_dark(spot), "The first guard's pool doesn't reach the second, so this test proves nothing") + TEST_ASSERT(stealth_tile_is_dark(spot, no_guard_lights = TRUE), "Without guard lights the second guard's spot isn't dark") second_ai.stealth_update_light() - TEST_ASSERT(second_light.light_on, "A guard in the dark left its light off because a friend's light was on it") + TEST_ASSERT(second_ai.stealth_light_shows(), "A guard in the dark left its light off because a friend's light was on it") + stealth_settle_light() second_ai.light_hold_until = 0 second_ai.stealth_update_light() - TEST_ASSERT(second_light.light_on, "A guard switched its light off because a friend's light was on it") + TEST_ASSERT(second_ai.stealth_light_shows(), "A guard switched its light off because a friend's light was on it") first_ai.light_hold_until = 0 first_ai.stealth_update_light() - TEST_ASSERT(first_light.light_on, "A guard switched its light off because a friend's light was on it") + TEST_ASSERT(first_ai.stealth_light_shows(), "A guard switched its light off because a friend's light was on it") qdel(block) /// A guard already found and called out as a body is not asked after as missing. @@ -174,7 +199,7 @@ TEST_ASSERT(stealth_diagonal >= 12 * player_run * sqrt(2) - slack, "12 diagonal tiles took a running guard [stealth_diagonal] ds, a player [12 * player_run * sqrt(2)] ds") /// Moves `guard` from `start` to `goal` with `movement_type`'s own move loop and returns how long it took, or -1. -/datum/unit_test/voidcrew_stealth_live/run_speed/proc/time_walk(mob/living/carbon/human/npc/guard, movement_type, turf/start, turf/goal) +/datum/unit_test/voidcrew_stealth_live/proc/time_walk(mob/living/carbon/human/npc/guard, movement_type, turf/start, turf/goal) var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller guard.forceMove(start) stealth_ai.last_step_turf = start @@ -187,3 +212,23 @@ var/took = world.time - began mover.stop_moving_towards(stealth_ai) return get_turf(guard) == goal ? took : -1 + +/// Decision 39: a fresh guard walks its route from its first plan (tg starts every mob at a run), and a diagonal +/// step at a walk still costs what a player's does (decision 32). +/datum/unit_test/voidcrew_stealth_live/walk_pace + +/datum/unit_test/voidcrew_stealth_live/walk_pace/Run() + TEST_ASSERT(make_room(16, 16), "No room for the test") + person_at(15, 15) + var/mob/living/carbon/human/npc/guard = guard_at(1, 1) + TEST_ASSERT_EQUAL(guard.move_intent, MOVE_INTENT_RUN, "Test fixture: tg no longer starts mobs at a run, so this test proves nothing") + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + var/run_delay = stealth_ai.movement_delay + stealth_ai.stealth_setup() + TEST_ASSERT_EQUAL(guard.move_intent, MOVE_INTENT_WALK, "A fresh guard isn't walking once it has set up") + var/walk_delay = stealth_ai.movement_delay + TEST_ASSERT(walk_delay > run_delay, "A walking guard's step delay [walk_delay] isn't over its running one [run_delay]") + var/diagonal = time_walk(guard, /datum/ai_movement/basic_avoidance/stealth, at(1, 1), at(13, 13)) + TEST_NOTICE(src, "Walk pace: guard walk delay [walk_delay] ds, run [run_delay] ds; 12 diagonal tiles at a walk took [diagonal] ds.") + TEST_ASSERT(diagonal >= 0, "The guard never finished the diagonal walk") + TEST_ASSERT(diagonal >= 12 * walk_delay * sqrt(2) - world.tick_lag, "12 diagonal tiles took a walking guard [diagonal] ds, a walking player [12 * walk_delay * sqrt(2)] ds") diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_d37.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_d37.dm index fa942daae64..492a776fd65 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_d37.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_d37.dm @@ -142,6 +142,7 @@ TEST_ASSERT_EQUAL(yellow.reaction_delay, 2 SECONDS, "Yellow reaction delay changed") TEST_ASSERT_EQUAL(yellow.search_time, 40 SECONDS, "Yellow search time changed") TEST_ASSERT_EQUAL(yellow.wary_time, 60 SECONDS, "Yellow wary time changed") + TEST_ASSERT_EQUAL(yellow.turn_grace, 1 SECONDS, "Yellow turn grace changed") // Every profile keeps decision 18 (no alert from off screen) and a cone that never takes in what is behind. for(var/skill_type in subtypesof(/datum/stealth_skill)) var/datum/stealth_skill/profile = stealth_skill_of(skill_type) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_d39.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_d39.dm new file mode 100644 index 00000000000..2034ac36bf4 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_d39.dm @@ -0,0 +1,115 @@ +// Stealth guards, decision 39 and the 2026-11-11 playtest fixes (voidcrew/modules/stealth/stealth_turns.dm, +// stealth_patrol.dm): readable turns, the grace after a turn, stop look-rounds and arrival facing. Values from +// voidcrew/_DEFINES are written out: STEALTH_TURN_TELL 0.6 s, STEALTH_LOOK_TURN_ARC 90; yellow turn_grace 1 s. +// States are written as text. + +/// After a turn where it stands (to a noise, a door or on its own), someone right in front is not an instant alert; +/// notice still fills, and once the moment has passed they are. +/datum/unit_test/voidcrew_stealth_turn_grace + +/datum/unit_test/voidcrew_stealth_turn_grace/Run() + var/datum/turf_reservation/block = stealth_block(7, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/person = stealth_person(block, 4, 2) + // "glance" is a noise or a door's glance; "suspicious" is a door seen moving or a noise worth a look. + for(var/how in list("glance", "suspicious")) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 3, 2, WEST) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + stealth_ai.stealth_setup() + TEST_ASSERT(!stealth_ai.stealth_turn_grace(), "A guard that hasn't turned is in its turn grace") + if(how == "glance") + stealth_ai.stealth_glance(stealth_at(block, 6, 2)) + else + stealth_ai.stealth_go_suspicious(stealth_at(block, 6, 2)) + TEST_ASSERT_EQUAL(guard.dir, EAST, "[how]: the guard didn't turn to face the spot") + TEST_ASSERT(stealth_ai.stealth_turn_grace(), "[how]: a guard that just turned isn't in its turn grace") + TEST_ASSERT(!stealth_ai.stealth_quick_look(), "[how]: the quick look made someone at its elbow an alert the moment it turned") + stealth_scans(guard, 1) + TEST_ASSERT(stealth_ai.stealth_state() != "alert", "[how]: someone at its elbow was an alert on the look right after it turned") + var/list/entry = stealth_ai.notice_map[REF(person)] + TEST_ASSERT(entry && entry[1] > 0, "[how]: notice didn't fill during the turn grace") + // The moment passes: they are seen plainly. + stealth_ai.turned_at = world.time - 2 SECONDS + TEST_ASSERT(!stealth_ai.stealth_turn_grace(), "[how]: the turn grace outlasted its time") + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "[how]: someone at its elbow wasn't an alert once the turn grace was over") + qdel(guard) + // A step is not a look round: turning by walking gives no grace. + var/mob/living/carbon/human/npc/walker = stealth_guard(block, 1, 2, EAST) + var/datum/ai_controller/basic_controller/human_npc/stealth/walker_ai = stealth_ai(walker) + walker_ai.stealth_setup() + walker.Move(stealth_at(block, 1, 3), NORTH) + TEST_ASSERT(!walker_ai.stealth_turn_grace(), "Turning by stepping gave a turn grace") + qdel(block) + +/// A turn on its own shows a lean first and lands after STEALTH_TURN_TELL; a change of state drops it. +/datum/unit_test/voidcrew_stealth_turn_tell + +/datum/unit_test/voidcrew_stealth_turn_tell/Run() + var/datum/turf_reservation/block = stealth_block(5, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 2, EAST) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + stealth_ai.stealth_setup() + stealth_ai.stealth_turn_to(NORTH) + TEST_ASSERT_EQUAL(guard.dir, EAST, "A guard turned on its own with no tell first") + TEST_ASSERT_EQUAL(stealth_ai.turn_pending, NORTH, "No turn is pending after the tell started") + TEST_ASSERT_NOTNULL(stealth_ai.turn_lean, "The tell shows no lean") + sleep(0.8 SECONDS) + TEST_ASSERT_EQUAL(guard.dir, NORTH, "The turn didn't land after its tell") + TEST_ASSERT_NULL(stealth_ai.turn_lean, "The lean stayed on after the turn") + // A turn that is overtaken by events is dropped, lean and all. + stealth_ai.stealth_turn_to(WEST) + stealth_ai.stealth_go_suspicious(stealth_at(block, 2, 0)) + TEST_ASSERT_EQUAL(stealth_ai.turn_pending, 0, "A change of state kept the pending turn") + TEST_ASSERT_NULL(stealth_ai.turn_lean, "A dropped turn left its lean on") + sleep(0.8 SECONDS) + TEST_ASSERT_EQUAL(guard.dir, SOUTH, "A dropped turn still landed") + qdel(block) + +/// At a stop it looks left, back, right, back: a steady beat, not a coin toss. +/datum/unit_test/voidcrew_stealth_look_rounds + +/datum/unit_test/voidcrew_stealth_look_rounds/Run() + var/datum/turf_reservation/block = stealth_block(5, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 2, EAST) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + stealth_ai.stealth_setup() + stealth_ai.route_id = "a" // a route guard, not a sentry + stealth_ai.stand_dir = EAST + var/datum/ai_behavior/stealth_stand/stand = GET_AI_BEHAVIOR(/datum/ai_behavior/stealth_stand) + var/list/seen = list() + for(var/i in 1 to 4) + stealth_ai.next_turn = 0 + stand.perform(1, stealth_ai) + sleep(0.8 SECONDS) + seen += dir2text(guard.dir) + TEST_ASSERT_EQUAL(jointext(seen, ","), "north,east,south,east", "A guard at a stop looked [jointext(seen, ",")] instead of left, back, right, back") + qdel(block) + +/// A guard arrives at a stop facing the way it walked, unless the stop sets a facing (then it turns, with a tell). +/datum/unit_test/voidcrew_stealth_arrival_facing + +/datum/unit_test/voidcrew_stealth_arrival_facing/Run() + var/datum/turf_reservation/block = stealth_block(5, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + allocate(/obj/effect/landmark/stealth_group, stealth_at(block, 4, 4)) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 2, WEST) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + stealth_ai.stealth_setup() + var/datum/stealth_stop/plain = new + plain.spot = get_turf(guard) + stealth_ai.stealth_arrive(plain) + TEST_ASSERT_EQUAL(guard.dir, WEST, "A guard turned at a stop with no facing set") + TEST_ASSERT_EQUAL(stealth_ai.stand_dir, WEST, "A guard at a stop with no facing doesn't keep the way it walked") + TEST_ASSERT_EQUAL(stealth_ai.turn_pending, 0, "A guard at a stop with no facing is about to turn") + var/datum/stealth_stop/faced = new + faced.spot = get_turf(guard) + faced.dir = NORTH + stealth_ai.stealth_arrive(faced) + TEST_ASSERT_EQUAL(stealth_ai.stand_dir, NORTH, "A stop's facing wasn't taken") + TEST_ASSERT_EQUAL(stealth_ai.turn_pending, NORTH, "A guard turned to a stop's facing with no tell") + sleep(0.8 SECONDS) + TEST_ASSERT_EQUAL(guard.dir, NORTH, "A guard didn't turn to its stop's facing") + qdel(block) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm index 04df8fc2db3..5e1f71b25b4 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm @@ -1,8 +1,17 @@ -// Stealth guards: flashlights, elbow-to-elbow sight, volleys and sentry facing (owner decision 31, +// Stealth guards: flashlights, elbow-to-elbow sight, volleys and sentry facing (owner decisions 31 and 39, // voidcrew/modules/stealth/stealth_light.dm). Values from voidcrew/_DEFINES are written out: STEALTH_LIGHT_HOLD -// 5 s, STEALTH_NOISE_COALESCE 3 s, STEALTH_SENTRY_TURN_INTERVAL 8 s, STEALTH_SENTRY_GLANCE_TIME 2 s. +// 5 s, STEALTH_TORCH_REACH 3, STEALTH_TORCH_REACH_DIAGONAL 2, STEALTH_NOISE_COALESCE 3 s, +// STEALTH_SENTRY_TURN_INTERVAL 8 s, STEALTH_SENTRY_GLANCE_TIME 2 s. -/// The guard switches its seclite on in the dark and while on edge, off in the light, and can't while it is cut out. +/// Waits for tg's static lighting to apply what was just switched or moved (it updates on its own subsystem). +/datum/unit_test/proc/stealth_settle_light() + sleep(1) + for(var/i in 1 to 50) + if(!length(SSlighting.sources_queue) && !length(SSlighting.current_sources)) + return + sleep(1) + +/// The guard switches its light on in the dark and while on edge, off in the light, and can't while it is cut out. /datum/unit_test/voidcrew_stealth_light_switch /datum/unit_test/voidcrew_stealth_light_switch/Run() @@ -12,77 +21,135 @@ var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) var/obj/item/flashlight/light = stealth_ai.stealth_light() TEST_ASSERT_NOTNULL(light, "A scav guard has no flashlight on its body") - TEST_ASSERT(!light.light_on, "A guard's light starts on") + TEST_ASSERT(!stealth_ai.stealth_light_shows(), "A guard's light starts on") var/turf/here = get_turf(guard) stealth_ai.stealth_update_light() - TEST_ASSERT(!light.light_on, "An unaware guard in the light switched its light on") + TEST_ASSERT(!stealth_ai.stealth_light_shows(), "An unaware guard in the light switched its light on") GLOB.stealth_test_dark_turfs[here] = TRUE stealth_ai.stealth_update_light() - TEST_ASSERT(light.light_on, "A guard standing in the dark didn't switch its light on") + TEST_ASSERT(stealth_ai.stealth_light_shows(), "A guard standing in the dark didn't switch its light on") + TEST_ASSERT(!light.light_on, "The seclite item lit its own beam as well as the pool") // Back in the light it keeps it on a moment, then switches it off. GLOB.stealth_test_dark_turfs[here] = FALSE stealth_ai.stealth_update_light() - TEST_ASSERT(light.light_on, "A guard switched its light off the moment it stepped into the light") + TEST_ASSERT(stealth_ai.stealth_light_shows(), "A guard switched its light off the moment it stepped into the light") stealth_ai.light_hold_until = 0 stealth_ai.stealth_update_light() - TEST_ASSERT(!light.light_on, "An unaware guard in the light kept its light on") + TEST_ASSERT(!stealth_ai.stealth_light_shows(), "An unaware guard in the light kept its light on") // On edge, it is on even in the light. stealth_ai.stealth_go_suspicious(stealth_at(block, 6, 2)) - TEST_ASSERT(light.light_on, "A suspicious guard's light isn't on") + TEST_ASSERT(stealth_ai.stealth_light_shows(), "A suspicious guard's light isn't on") stealth_ai.stealth_go_searching(stealth_at(block, 6, 2)) - TEST_ASSERT(light.light_on, "A searching guard's light isn't on") + TEST_ASSERT(stealth_ai.stealth_light_shows(), "A searching guard's light isn't on") stealth_ai.stealth_go_unaware() stealth_ai.light_hold_until = 0 stealth_ai.stealth_update_light() - TEST_ASSERT(!light.light_on, "A calm guard in the light kept its light on") - // An EMP cuts it out, and the guard can't switch it back on until it recovers. + TEST_ASSERT(!stealth_ai.stealth_light_shows(), "A calm guard in the light kept its light on") + // An EMP cuts it out at once, and the guard can't switch it back on until it recovers. GLOB.stealth_test_dark_turfs[here] = TRUE stealth_ai.stealth_update_light() - TEST_ASSERT(light.light_on, "The light didn't come on in the dark") + TEST_ASSERT(stealth_ai.stealth_light_shows(), "The light didn't come on in the dark") guard.emp_act(EMP_LIGHT) - TEST_ASSERT(!light.light_on, "An EMP didn't cut the guard's light out") + TEST_ASSERT(!stealth_ai.stealth_light_shows(), "An EMP didn't cut the guard's light out") stealth_ai.stealth_update_light() - TEST_ASSERT(!light.light_on, "A guard switched an EMP'd light straight back on") + TEST_ASSERT(!stealth_ai.stealth_light_shows(), "A guard switched an EMP'd light straight back on") light.disabled_time = 0 stealth_ai.stealth_update_light() - TEST_ASSERT(light.light_on, "The light didn't come back on once the EMP wore off") - // Gone from its body, it goes without. + TEST_ASSERT(stealth_ai.stealth_light_shows(), "The light didn't come back on once the EMP wore off") + // Stunned, it has no light. + guard.Paralyze(5 SECONDS) + TEST_ASSERT(!stealth_ai.stealth_light_shows(), "A stunned guard kept its light on") + guard.SetParalyzed(0) + stealth_ai.stealth_update_light() + TEST_ASSERT(stealth_ai.stealth_light_shows(), "The light didn't come back once the guard was up") + // Gone from its body, it goes out at once. light.forceMove(stealth_at(block, 4, 4)) TEST_ASSERT_NULL(stealth_ai.stealth_light(), "A guard still counts a light that left its body") + TEST_ASSERT(!stealth_ai.stealth_light_shows(), "A guard's pool stayed on after its seclite was taken") GLOB.stealth_test_dark_turfs[here] = FALSE qdel(block) -/// Real lighting: in a dark room the guard sees someone 5 tiles ahead only by its own light. +/// Decision 39: the pool lands 3 tiles ahead (2 on a diagonal), stops short of a wall or a closed door, goes through +/// glass, and follows the guard's turns and steps. +/datum/unit_test/voidcrew_stealth_light_pool + +/datum/unit_test/voidcrew_stealth_light_pool/Run() + var/datum/turf_reservation/block = stealth_block(10, 7) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/turf/from = stealth_at(block, 2, 3) + TEST_ASSERT_EQUAL(stealth_torch_spot(from, EAST), stealth_at(block, 5, 3), "An open floor's pool isn't 3 tiles ahead") + TEST_ASSERT_EQUAL(stealth_torch_spot(from, NORTHEAST), stealth_at(block, 4, 5), "A diagonal pool isn't 2 tiles out") + // A wall 3 ahead: the pool is on the last open tile before it. + var/turf/wall = stealth_at(block, 5, 3) + wall.ChangeTurf(/turf/closed/wall) + TEST_ASSERT_EQUAL(stealth_torch_spot(from, EAST), stealth_at(block, 4, 3), "The pool went into or past a wall") + // Right at its nose: no pool. + var/turf/near_wall = stealth_at(block, 3, 3) + near_wall.ChangeTurf(/turf/closed/wall) + TEST_ASSERT_NULL(stealth_torch_spot(from, EAST), "A guard facing a wall at its nose has a pool") + // A closed glass airlock stops it; glass does not. + var/obj/machinery/door/airlock/glass/door = allocate(/obj/machinery/door/airlock/glass, stealth_at(block, 2, 5)) + TEST_ASSERT(door.density, "Test fixture: the airlock isn't closed") + TEST_ASSERT_EQUAL(stealth_torch_spot(from, NORTH), stealth_at(block, 2, 4), "The pool went through a closed glass door") + allocate(/obj/structure/window/fulltile, stealth_at(block, 2, 1)) + TEST_ASSERT_EQUAL(stealth_torch_spot(from, SOUTH), stealth_at(block, 2, 0), "The pool stopped at a window") + // A guard's pool follows it. + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 3, SOUTH) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + GLOB.stealth_test_dark_turfs[get_turf(guard)] = TRUE + stealth_ai.stealth_update_light() + TEST_ASSERT(stealth_ai.stealth_light_shows(), "A guard in the dark has no pool") + TEST_ASSERT_EQUAL(get_turf(stealth_ai.torch), stealth_at(block, 6, 0), "The pool isn't 3 ahead of a guard facing south") + guard.setDir(EAST) + TEST_ASSERT_EQUAL(get_turf(stealth_ai.torch), stealth_at(block, 9, 3), "The pool didn't follow the guard's turn") + // A wall goes up where the pool was; after its next step the pool sits short of it, and smaller. + var/turf/far_wall = stealth_at(block, 9, 3) + far_wall.ChangeTurf(/turf/closed/wall) + guard.forceMove(stealth_at(block, 7, 3)) + TEST_ASSERT_EQUAL(get_turf(stealth_ai.torch), stealth_at(block, 8, 3), "The pool didn't stop short of a wall after a step") + TEST_ASSERT(stealth_ai.torch.light_range < 2.5, "A pool a tile off is as wide as one 3 off") + var/obj/effect/abstract/stealth_torch/old_torch = stealth_ai.torch + GLOB.stealth_test_dark_turfs[stealth_at(block, 6, 3)] = FALSE + qdel(guard) + TEST_ASSERT(QDELETED(old_torch), "A deleted guard left its pool behind") + qdel(block) + +/// Real lighting: in a dark room the guard's pool lights what it lands on and nothing behind it. /datum/unit_test/voidcrew_stealth_light_sight /datum/unit_test/voidcrew_stealth_light_sight/Run() var/datum/turf_reservation/block = stealth_block(12, 5) TEST_ASSERT_NOTNULL(block, "No room for the test") stealth_unlist(block, 12, 5) - var/mob/living/carbon/human/person = stealth_person(block, 6, 2) + var/mob/living/carbon/human/person = stealth_person(block, 5, 2) var/turf/spot = get_turf(person) TEST_ASSERT(stealth_tile_is_dark(spot), "Reserved test space isn't dark, so the light can't be tested") - // Without a light: 5 tiles off in the dark is past sight. - var/mob/living/carbon/human/npc/guard = stealth_guard(block, 1, 2) + // Without a light: 3 tiles off in the dark fills slowly (no near fill in the dark, decision 39). + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 2) var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) qdel(stealth_ai.stealth_light()) - stealth_scans(guard, 5) - TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard with no light saw someone 5 tiles off in the dark") + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard with no light noticed someone 3 tiles off in the dark in one look") qdel(guard) - // With one: it switches it on, the light reaches them, and it notices them. - guard = stealth_guard(block, 1, 2) + // With one: it switches it on, the pool lands on them, and it notices them. + guard = stealth_guard(block, 2, 2) stealth_ai = stealth_ai(guard) - var/obj/item/flashlight/light = stealth_ai.stealth_light() stealth_ai.stealth_update_light() - TEST_ASSERT(light.light_on, "A guard standing in the dark didn't switch its light on") - TEST_ASSERT(!stealth_tile_is_dark(spot), "The guard's light doesn't reach 5 tiles ahead") - TEST_ASSERT(stealth_tile_is_dark(get_turf(guard), light), "A guard counts its own light as the room's") - stealth_scans(guard, 5) - TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "suspicious", "A guard didn't notice someone its light was on") + TEST_ASSERT(stealth_ai.stealth_light_shows(), "A guard standing in the dark didn't switch its light on") + stealth_settle_light() + TEST_ASSERT(!stealth_tile_is_dark(spot), "The guard's pool doesn't light the tile it lands on") + TEST_ASSERT(!stealth_tile_is_dark(stealth_at(block, 6, 2)), "The guard's pool doesn't light the tile past it") + TEST_ASSERT(stealth_tile_is_dark(get_turf(guard)), "The guard's pool lights its own tile") + TEST_ASSERT(stealth_tile_is_dark(stealth_at(block, 1, 2)), "The guard's pool lights the tile behind it") + TEST_ASSERT(stealth_tile_is_dark(stealth_at(block, 8, 2)), "The guard's pool lights 6 tiles ahead") + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "suspicious", "A guard didn't notice someone its pool was on") qdel(guard) + stealth_settle_light() + TEST_ASSERT(stealth_tile_is_dark(spot), "The pool stayed lit after its guard was gone") qdel(block) -/// Real lighting: a searching guard finds a body in the dark by its light. +/// Real lighting: a searching guard sees as far as in daylight onto the tiles its pool lights. /datum/unit_test/voidcrew_stealth_light_body /datum/unit_test/voidcrew_stealth_light_body/Run() @@ -91,24 +158,28 @@ stealth_unlist(block, 12, 5) allocate(/obj/effect/landmark/stealth_group, stealth_at(block, 7, 4)) var/mob/living/carbon/human/npc/guard = stealth_guard(block, 1, 2) - var/mob/living/carbon/human/npc/friend = stealth_guard(block, 6, 2) + var/mob/living/carbon/human/npc/friend = stealth_guard(block, 4, 2) var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) var/datum/ai_controller/basic_controller/human_npc/stealth/friend_ai = stealth_ai(friend) stealth_ai.stealth_setup() friend_ai.stealth_setup() qdel(friend_ai.stealth_light()) friend.death() - TEST_ASSERT(stealth_tile_is_dark(get_turf(friend)), "Reserved test space isn't dark, so the light can't be tested") - // Its light cut out, it searches past the body 5 tiles off in the dark. + var/turf/body_turf = get_turf(friend) + TEST_ASSERT(stealth_tile_is_dark(body_turf), "Reserved test space isn't dark, so the light can't be tested") + var/datum/stealth_skill/profile = stealth_ai.stealth_skill() + // Its light cut out, the body's tile is dark to it. var/obj/item/flashlight/light = stealth_ai.stealth_light() light.on_saboteur(null, 1 MINUTES) stealth_ai.stealth_go_searching(get_turf(guard)) - stealth_ai.stealth_check_bodies() - TEST_ASSERT(!(REF(friend) in stealth_ai.blackboard["stealth_bodies_seen"]), "A guard saw a body 5 tiles off in the dark without a light") - // With it on, it finds it. + TEST_ASSERT(!stealth_ai.stealth_light_shows(), "A guard's cut-out light shows a pool") + TEST_ASSERT_EQUAL(stealth_ai.stealth_range_onto(body_turf), profile.dark_sight_range, "A guard sees into the dark as if it were lit") + // With it on, it is lit, and it finds the body. light.disabled_time = 0 stealth_ai.stealth_update_light() - TEST_ASSERT(light.light_on, "A searching guard's light didn't come on") + TEST_ASSERT(stealth_ai.stealth_light_shows(), "A searching guard's light didn't come on") + stealth_settle_light() + TEST_ASSERT_EQUAL(stealth_ai.stealth_range_onto(body_turf), profile.sight_range, "A guard's pool doesn't light the body it lands on") stealth_ai.next_body_scan = 0 stealth_ai.stealth_check_bodies() TEST_ASSERT(REF(friend) in stealth_ai.blackboard["stealth_bodies_seen"], "A searching guard with its light on didn't find the body") @@ -117,7 +188,7 @@ qdel(block) /// Elbow to elbow: someone on the next tile in front is seen in the dark (an alert, decision 32); behind or side-on -/// is not; two ahead in the dark fills (3x near, decision 32) to suspicious. +/// is not; two ahead in the dark fills slowly (no near fill in the dark, decision 39). /datum/unit_test/voidcrew_stealth_adjacent /datum/unit_test/voidcrew_stealth_adjacent/Run() @@ -132,7 +203,7 @@ list(1, 0, "alert"), list(-1, 0, "unaware"), list(0, 1, "unaware"), - list(2, 0, "suspicious"), + list(2, 0, "unaware"), ) for(var/list/test_case as anything in cases) person.forceMove(stealth_at(block, 3 + test_case[1], 3 + test_case[2])) From aba4c04622a40e55e8633f466fbd7e357e7724ed Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Wed, 11 Nov 2026 02:59:16 -0800 Subject: [PATCH 25/78] A guard's flashlight pool against a near wall is bright enough to see by --- voidcrew/_DEFINES/stealth.dm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index a8bd768c710..09cd928ecf1 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -174,10 +174,11 @@ #define STEALTH_TORCH_REACH_DIAGONAL 2 /// The pool's light power (its seclite blue takes it to about 1.2 white) #define STEALTH_TORCH_POWER 1.5 -/// The pool's light range with its centre 2.5 or more tiles off, 2 or more, and nearer (tg's least useful range) +/// The pool's light range with its centre 2.5 or more tiles off, 2 or more, and nearer (sized so the guard's own +/// tile stays under the dark line: data/stealth/STATUS.md, decision 39) #define STEALTH_TORCH_RANGE_FAR 2.5 #define STEALTH_TORCH_RANGE_MID 2 -#define STEALTH_TORCH_RANGE_NEAR MINIMUM_USEFUL_LIGHT_RANGE +#define STEALTH_TORCH_RANGE_NEAR 1.7 /// tg's seclite colour #define STEALTH_TORCH_COLOR "#99ccff" From 155e365401fed5e770d6ba0808926a1ff751f7fb Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Wed, 11 Nov 2026 04:12:07 -0800 Subject: [PATCH 26/78] Guard flashlight pools actually light the floor tg's light setters don't rebuild a COMPLEX_LIGHT source, so the hidden lamp never emitted. Call update_light() when it switches or changes range. --- voidcrew/modules/stealth/stealth_light.dm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/voidcrew/modules/stealth/stealth_light.dm b/voidcrew/modules/stealth/stealth_light.dm index aa5c77c2f3a..95e67b51dda 100644 --- a/voidcrew/modules/stealth/stealth_light.dm +++ b/voidcrew/modules/stealth/stealth_light.dm @@ -217,16 +217,19 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) if(isnull(spot)) if(torch?.light_on) torch.set_light_on(FALSE) + torch.update_light() return if(QDELETED(torch)) torch = new(spot) var/range = stealth_torch_range(get_dist_euclidean(guard, spot)) - if(torch.light_range != range) - torch.set_light_range(range) + // tg's light setters don't rebuild a COMPLEX_LIGHT source on their own (see /obj/item/flashlight/update_brightness()): + // update_light() does. A move needs nothing more, the source follows its host's Moved. if(torch.loc != spot) torch.abstract_move(spot) - if(!torch.light_on) + if(torch.light_range != range || !torch.light_on) + torch.set_light_range(range) torch.set_light_on(TRUE) + torch.update_light() /// Whether its light is on with a pool on the floor (for admins and tests). /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_light_shows() From d12af762234429933143dad715116b06f42a7da5 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Wed, 11 Nov 2026 04:12:42 -0800 Subject: [PATCH 27/78] Keep the walk pace test's guard dormant so it doesn't walk back to its post mid-timing --- voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm index 1be25f0cb20..08e9b1f0f1c 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm @@ -219,7 +219,9 @@ /datum/unit_test/voidcrew_stealth_live/walk_pace/Run() TEST_ASSERT(make_room(16, 16), "No room for the test") - person_at(15, 15) + // Not on SSmobs' player list, as in run_speed: an awake guard would walk back to its post and take over the + // movement being timed. + person_at(15, 15, FALSE) var/mob/living/carbon/human/npc/guard = guard_at(1, 1) TEST_ASSERT_EQUAL(guard.move_intent, MOVE_INTENT_RUN, "Test fixture: tg no longer starts mobs at a run, so this test proves nothing") var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller From e8d07fe4f560fb8450fd49ef144bd9a19c8d0002 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Wed, 11 Nov 2026 11:46:36 -0800 Subject: [PATCH 28/78] Make the stealth test room beatable: move the lookout off the door, add a back hatch, let sentries step toward small noises --- .../JungleRuins/jungle_stealth_test.dmm | 12 ++- voidcrew/_DEFINES/stealth_hearing.dm | 3 +- voidcrew/modules/stealth/stealth_hearing.dm | 17 +++-- voidcrew/modules/stealth/stealth_noise.dm | 4 +- .../unit_tests/voidcrew_stealth_hearing.dm | 74 +++++++++++++------ 5 files changed, 75 insertions(+), 35 deletions(-) diff --git a/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm index 5c97ade5ca5..b338c394278 100644 --- a/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm +++ b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm @@ -1,7 +1,7 @@ //MAP CONVERTED BY dmm2tgm.py THIS HEADER COMMENT PREVENTS RECONVERSION, DO NOT REMOVE "a" = ( /obj/effect/spawner/human_npc/ruin/scav/lookout{ - dir = 2 + dir = 8 }, /turf/open/floor/iron, /area/ruin/powered) @@ -140,6 +140,10 @@ "J" = ( /turf/closed/wall, /area/ruin/powered) +"M" = ( +/obj/machinery/door/airlock/maintenance, +/turf/open/floor/plating, +/area/ruin/powered) "P" = ( /turf/open/floor/plating, /area/ruin/powered) @@ -495,7 +499,7 @@ s P P P -J +M i i "} @@ -685,7 +689,7 @@ x x x x -a +x x t i @@ -704,7 +708,7 @@ x x x x -x +a x x x diff --git a/voidcrew/_DEFINES/stealth_hearing.dm b/voidcrew/_DEFINES/stealth_hearing.dm index 6bc724f1052..314e9a8540f 100644 --- a/voidcrew/_DEFINES/stealth_hearing.dm +++ b/voidcrew/_DEFINES/stealth_hearing.dm @@ -136,7 +136,8 @@ /// "The same spot" for counting lures #define STEALTH_LURE_RADIUS 6 #define STEALTH_LURE_MEMORY (3 MINUTES) -/// A sentry leaves its post only for a noise this close +/// How far a sentry walks from its post toward a small noise before it looks round and goes back. A third lure +/// at one spot it holds wary at its post if the noise is farther than this. #define STEALTH_SENTRY_INVESTIGATE_RANGE 4 /// How long a guard that went to look has before its friends miss it #define STEALTH_CHECKIN_TIME (30 SECONDS) diff --git a/voidcrew/modules/stealth/stealth_hearing.dm b/voidcrew/modules/stealth/stealth_hearing.dm index 27cc364dd9e..f19f96912f5 100644 --- a/voidcrew/modules/stealth/stealth_hearing.dm +++ b/voidcrew/modules/stealth/stealth_hearing.dm @@ -54,12 +54,17 @@ return if(stealth_state() == STEALTH_SUSPICIOUS) last_gain = world.time - if(!investigated) - stealth_aim_at(spot) - return - stealth_go_suspicious(spot, STEALTH_GOTO_INVESTIGATE, again ? STEALTH_BARK_HEARD_AGAIN : STEALTH_BARK_HEARD) - suspicion_heard = TRUE - stealth_meter_update() + if(investigated) + return + stealth_aim_at(spot) + else + stealth_go_suspicious(spot, STEALTH_GOTO_INVESTIGATE, again ? STEALTH_BARK_HEARD_AGAIN : STEALTH_BARK_HEARD) + suspicion_heard = TRUE + stealth_meter_update() + // A sentry walks only a few steps toward it, looks round there and goes back to its post and facing. + var/turf/home = home_turf + if(isnull(route_id) && home && investigate_turf?.z == home.z && get_dist(home, investigate_turf) > STEALTH_SENTRY_INVESTIGATE_RANGE) + investigate_turf = stealth_open_near(get_ranged_target_turf_direct(home, investigate_turf, STEALTH_SENTRY_INVESTIGATE_RANGE)) || home /// Turns to face `where` for `time` without leaving its state, route or post. No line: the turn is the read. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_glance(turf/where, time = STEALTH_GLANCE_TIME) diff --git a/voidcrew/modules/stealth/stealth_noise.dm b/voidcrew/modules/stealth/stealth_noise.dm index 169d8b150f4..7ca4c78b2fc 100644 --- a/voidcrew/modules/stealth/stealth_noise.dm +++ b/voidcrew/modules/stealth/stealth_noise.dm @@ -375,8 +375,8 @@ for(var/list/hearer as anything in hearers) var/mob/living/carbon/human/npc/guard = hearer[1] var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller - var/sentry_too_far = isnull(guard_ai.route_id) && get_dist(guard, spot) > STEALTH_SENTRY_INVESTIGATE_RANGE - if(length(went) < wanted && !sentry_too_far && guard_ai.stealth_can_investigate()) + // A sentry goes too, but only a few steps toward it (stealth_go_heard()). + if(length(went) < wanted && guard_ai.stealth_can_investigate()) guard_ai.stealth_go_heard(spot, earlier >= 1 && !length(went)) went += guard note(guard, "goes", TRUE) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_hearing.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_hearing.dm index d5fc0bfddbe..45bff29b12a 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_hearing.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_hearing.dm @@ -6,7 +6,7 @@ // // Every test runs in the walled, lit room of voidcrew_stealth_live with a person on SSmobs' list of players, so // the level is awake and guards hear. Those down to hear/cleanup never sleep: the AI is on but never gets a -// turn, so they pin what one noise does. The ones after them use real tg actions, and the last three let the +// turn, so they pin what one noise does. The ones after them use real tg actions, and the last four let the // real AI run. #define STEALTH_HEAR_GUARD /mob/living/carbon/human/npc/ruin/trooper/scav @@ -31,8 +31,10 @@ /datum/unit_test/voidcrew_stealth_live/hear/proc/ground() var/turf/corner = room.bottom_left_turfs[1] var/turf/far_corner = room.top_right_turfs[1] + // A floor kept from an earlier test's room may still have it. for(var/turf/open/spot in block(corner.x, corner.y, corner.z, far_corner.x, far_corner.y, corner.z)) - spot.AddElement(/datum/element/forced_gravity, 1) + if(!spot.has_gravity()) + spot.AddElement(/datum/element/forced_gravity, 1) /// A sentry at (dx, dy): awake and in the group. /datum/unit_test/voidcrew_stealth_live/hear/proc/sentry(dx, dy, facing = EAST, guard_type = STEALTH_HEAR_GUARD) @@ -204,26 +206,6 @@ TEST_ASSERT_EQUAL(second_ai.stealth_state(), "unaware", "Two went to the first noise at a new spot") no_targets(list(first, second, third)) -/// A sentry leaves its post only for a noise close by. -/datum/unit_test/voidcrew_stealth_live/hear/sentry_rule - -/datum/unit_test/voidcrew_stealth_live/hear/sentry_rule/Run() - TEST_ASSERT(hear_room(20, 3), "No room for the test") - var/mob/living/carbon/human/npc/post_guard = sentry(6, 1) - var/mob/living/carbon/human/npc/route_guard = walker(7, 1) - var/datum/ai_controller/basic_controller/human_npc/stealth/post_ai = post_guard.ai_controller - TEST_ASSERT_NULL(post_ai.route_id, "A guard with no stop near it claimed a route") - TEST_ASSERT_EQUAL(stealth_noise(at(0, 1), "glass"), 2, "Both guards should hear a smash 6 and 7 tiles off") - TEST_ASSERT_EQUAL(state_of(post_guard), "unaware", "A sentry left its post for a noise 6 tiles off") - TEST_ASSERT(post_ai.glance_until > world.time, "The sentry didn't glance") - TEST_ASSERT_EQUAL(state_of(route_guard), "suspicious", "The route guard didn't go in the sentry's place") - settle(post_guard) - settle(route_guard) - post_ai.group.forget_noises() - stealth_noise(at(3, 1), "glass") - TEST_ASSERT_EQUAL(state_of(post_guard), "suspicious", "A sentry didn't look at a noise 3 tiles off") - no_targets(list(post_guard, route_guard)) - /// The guard who never came back is missed by the ones who watched it go, once it is overdue. /datum/unit_test/voidcrew_stealth_live/hear/missing @@ -720,6 +702,54 @@ TEST_ASSERT(back, "The guard didn't go back to its round: state [guard_ai.stealth_state()], [get_dist(guard, at(2, 2))] and [get_dist(guard, at(8, 2))] tiles from its stops") TEST_ASSERT(!guard_ai.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET), "A smashed bottle gave a guard a target") +/// A bottle smashes 5 tiles behind a sentry: it walks a few steps toward it (STEALTH_SENTRY_INVESTIGATE_RANGE, 4), +/// looks round, and walks back to its post and its facing. +/datum/unit_test/voidcrew_stealth_live/hear/sentry_rule + +/datum/unit_test/voidcrew_stealth_live/hear/sentry_rule/Run() + TEST_ASSERT(make_room(34, 7), "No room for the test") + marker = allocate(/obj/effect/landmark/stealth_group, at(0, 6)) + // The player who keeps the level awake, walled off at the far end. + for(var/dy in 0 to 6) + var/turf/wall_spot = at(24, dy) + wall_spot.ChangeTurf(/turf/closed/wall) + person_at(30, 3) + ground() + var/turf/post = at(14, 3) + var/mob/living/carbon/human/npc/guard = guard_at(14, 3, EAST) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = wake(guard) + var/mob/living/carbon/human/thrower = person_at(0, 3, FALSE) + sleep(3 SECONDS) + TEST_ASSERT_NULL(guard_ai.route_id, "A guard with no stop near it claimed a route") + TEST_ASSERT_EQUAL(guard_ai.home_turf, post, "The sentry's post isn't where it spawned") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "unaware", "A sentry with nobody in sight isn't unaware") + var/turf/landing = at(9, 3) + var/obj/item/reagent_containers/cup/glass/bottle/beer/bottle = allocate(/obj/item/reagent_containers/cup/glass/bottle/beer, get_turf(thrower)) + bottle.throw_at(landing, 14, 2, thrower) + // Out of the way before the sentry turns round: this is about the noise, not a sighting. + thrower.forceMove(at(32, 5)) + var/start_time = world.time + var/best_dist = 0 + var/deadline = world.time + 25 SECONDS + while(world.time < deadline) + best_dist = max(best_dist, get_dist(guard, post)) + if(best_dist >= 3) + break + sleep(2) + TEST_ASSERT(best_dist >= 3, "The sentry didn't leave its post for a bottle 5 tiles off: it got [best_dist] tiles away, state [guard_ai.stealth_state()], heard [guard_ai.last_heard ? guard_ai.last_heard[1] : "nothing"]") + var/back = FALSE + deadline = start_time + 60 SECONDS + while(world.time < deadline) + best_dist = max(best_dist, get_dist(guard, post)) + if(guard_ai.stealth_state() == "unaware" && get_turf(guard) == post && guard.dir == EAST) + back = TRUE + break + sleep(2) + TEST_ASSERT(best_dist <= 5, "The sentry went [best_dist] tiles from its post for a small noise") + TEST_ASSERT(back, "The sentry didn't go back to its post: state [guard_ai.stealth_state()], [get_dist(guard, post)] tiles off, facing [dir2text(guard.dir)]") + TEST_ASSERT_EQUAL(guard_ai.sentry_dir, EAST, "The sentry's post facing changed") + TEST_ASSERT(!guard_ai.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET), "A smashed bottle gave a sentry a target") + /// Someone walking up behind a guard is not heard; the same person running makes it turn. /datum/unit_test/voidcrew_stealth_live/hear/live_footsteps From c4be2c20e2823035dd0de947bc45ff56b4b64b6d Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Wed, 11 Nov 2026 14:08:18 -0800 Subject: [PATCH 29/78] Stealth guards check disguises: scav fatigues, a mask and a lootable scav pass fool them by stage, they stop and ask for the pass, and weapons, running, bodies and known faces blow it --- .../JungleRuins/jungle_stealth_test.dmm | 10 +- tgstation.dme | 1 + voidcrew/_DEFINES/stealth.dm | 53 ++ voidcrew/modules/stealth/scav_guards.dm | 24 +- voidcrew/modules/stealth/stealth_admin.dm | 13 + voidcrew/modules/stealth/stealth_ai.dm | 86 +++- voidcrew/modules/stealth/stealth_disguise.dm | 401 +++++++++++++++ voidcrew/modules/stealth/stealth_doors.dm | 8 + voidcrew/modules/stealth/stealth_hearing.dm | 3 + voidcrew/modules/stealth/stealth_light.dm | 5 +- voidcrew/modules/stealth/stealth_patrol.dm | 2 + voidcrew/modules/stealth/stealth_skill.dm | 8 + voidcrew/modules/unit_tests/_unit_tests.dm | 1 + .../unit_tests/voidcrew_human_npcs_ruins.dm | 4 +- .../unit_tests/voidcrew_stealth_crits.dm | 2 +- .../unit_tests/voidcrew_stealth_disguise.dm | 465 ++++++++++++++++++ 16 files changed, 1077 insertions(+), 9 deletions(-) create mode 100644 voidcrew/modules/stealth/stealth_disguise.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_stealth_disguise.dm diff --git a/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm index b338c394278..ae70106f59e 100644 --- a/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm +++ b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm @@ -36,7 +36,7 @@ "e" = ( /obj/machinery/door/airlock/security{ name = "Strongroom"; - req_access = list("armory") + req_one_access = list("armory","scav") }, /turf/open/floor/iron, /area/ruin/powered) @@ -151,6 +151,12 @@ /obj/effect/landmark/stealth_group, /turf/open/floor/iron, /area/ruin/powered) +"R" = ( +/obj/effect/landmark/stealth_restricted{ + reach = 15 + }, +/turf/open/floor/plating, +/area/ruin/powered) "V" = ( /obj/effect/landmark/stealth_patrol{ route = "a"; @@ -347,7 +353,7 @@ P P P P -P +R B P P diff --git a/tgstation.dme b/tgstation.dme index 377e75fcb6a..eb1f4a65e84 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7734,6 +7734,7 @@ #include "voidcrew\modules\stealth\stealth_ai.dm" #include "voidcrew\modules\stealth\stealth_closet.dm" #include "voidcrew\modules\stealth\stealth_crits.dm" +#include "voidcrew\modules\stealth\stealth_disguise.dm" #include "voidcrew\modules\stealth\stealth_doors.dm" #include "voidcrew\modules\stealth\stealth_hearing.dm" #include "voidcrew\modules\stealth\stealth_knife.dm" diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index 09cd928ecf1..c1ca167774b 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -194,6 +194,59 @@ #define FACTION_SCAV "scav" +// ===== Disguises (decision 40, stealth_disguise.dm) ===== +/// The den's own doors +#define ACCESS_SCAV "scav" +// What someone wears of the scavs' own +/// Their face is hidden (tg's get_face_name() finds none) +#define STEALTH_PIECE_MASK (1<<0) +/// The scav fatigues, showing, under nothing the guards don't wear +#define STEALTH_PIECE_CLOTHES (1<<1) +/// A scav pass in the ID slot +#define STEALTH_PIECE_ID (1<<2) +/// What someone wears is worked out again when it is older than this (a mask pulled down, a face wrecked) +#define STEALTH_DISGUISE_CACHE_TIME (2 SECONDS) +/// Share of the usual notice gained in the fatigues, in the fatigues and a mask, and in the whole set inside the +/// guard's near range (beyond it the whole set gains none). Scaled by the guard's skill (`disguise`). +#define STEALTH_DISGUISE_FILL_CLOTHES 0.5 +#define STEALTH_DISGUISE_FILL_MASKED 0.25 +#define STEALTH_DISGUISE_FILL_FULL 0.05 +/// Tiles within which a guard that sees them plainly stops them, for the same three. Its skill and being wary add to it. +#define STEALTH_CHALLENGE_RANGE_CLOTHES 5 +#define STEALTH_CHALLENGE_RANGE_MASKED 3 +#define STEALTH_CHALLENGE_RANGE_FULL 2 +/// It reads a pass from this close +#define STEALTH_CHALLENGE_CHECK_RANGE 2 +/// It reads a pass for this long before it lets them go +#define STEALTH_CHALLENGE_CHECK_TIME (2 SECONDS) +/// With no pass shown, it asks again after this long +#define STEALTH_CHALLENGE_WARN_TIME (3 SECONDS) +/// With no pass shown after this long, the disguise is blown +#define STEALTH_CHALLENGE_FAIL_TIME (6 SECONDS) +/// Further than this from where it stopped them is walking off +#define STEALTH_CHALLENGE_LEASH 2 +/// How long a guard that read their pass lets them be +#define STEALTH_PASS_TIME (5 MINUTES) +/// How long a guard remembers the wearer of a disguise it saw through (a face it remembers for good) +#define STEALTH_MADE_TIME (5 MINUTES) +/// Tiles within which a guard has a word for one of its own +#define STEALTH_GREET_RANGE 4 +#define STEALTH_GREET_COOLDOWN (30 SECONDS) +/// Anything sharp with this much force is a weapon in hand, like any gun or melee weapon +#define STEALTH_WEAPON_FORCE 10 +/// One of its own goes by +#define STEALTH_BARK_GREET "stealth_greet" +/// It asks one of its own for a light +#define STEALTH_BARK_SMOKE "stealth_smoke" +/// It stops someone to see their pass +#define STEALTH_BARK_CHALLENGE "stealth_challenge" +/// The pass is good +#define STEALTH_BARK_ID_PASS "stealth_id_pass" +/// No pass yet: it asks again +#define STEALTH_BARK_ID_FAIL "stealth_id_fail" +/// It has seen through a disguise +#define STEALTH_BARK_BLOWN "stealth_blown" + // ===== Stealth crits and the backstab knife (step 3a, stealth_crits.dm) ===== // Roll bonuses for hyperviolence's aimed crit roll (crit_roll.dm), on a stealth guard only. They go in before wound armour, // so armour scales them like the rest of the roll. Numbers argued in data/stealth/STATUS.md, "Step 3a". diff --git a/voidcrew/modules/stealth/scav_guards.dm b/voidcrew/modules/stealth/scav_guards.dm index 24ec9e2aea9..e7bec0433cd 100644 --- a/voidcrew/modules/stealth/scav_guards.dm +++ b/voidcrew/modules/stealth/scav_guards.dm @@ -32,6 +32,12 @@ STEALTH_BARK_RADIO_MISSING = list("%NAME%, come in.", "%NAME%'s not answering.", "Got one not answering."), STEALTH_BARK_COPY = list("Copy.", "Moving.", "On my way."), STEALTH_BARK_RADIO_DEAD = list("Radio's dead.", "Nothing but static."), + STEALTH_BARK_GREET = list("Evening.", "All quiet?", "Still breathing, then.", "Evening, %NAME%.", "You're late, %NAME%."), + STEALTH_BARK_SMOKE = list("Got a light?", "Spare a smoke?", "You owe me a smoke, %NAME%."), + STEALTH_BARK_CHALLENGE = list("Hold up. Let's see your card.", "Hey. You. Card.", "Stop there. Who are you with?"), + STEALTH_BARK_ID_PASS = list("Fine. Move along.", "All right. Go on.", "Go on, %NAME%."), + STEALTH_BARK_ID_FAIL = list("No card? Don't move.", "Card. Now.", "I said card."), + STEALTH_BARK_BLOWN = list("You're not one of us!", "That's not one of ours!", "Who the hell are you?"), ) emotes = list( HUMAN_NPC_BARK_DOWNED = list("collapses."), @@ -45,6 +51,8 @@ STEALTH_BARK_GUNFIRE = list("flinches."), STEALTH_BARK_HOLD = list("shifts their grip."), STEALTH_BARK_RADIO_DEAD = list("taps their earpiece."), + STEALTH_BARK_GREET = list("nods.", "lifts their chin."), + STEALTH_BARK_SMOKE = list("pats their pockets."), ) chances = list(RUIN_NPC_BARK_SPOT = 100) @@ -95,10 +103,24 @@ npc_voice = /datum/human_npc_voice/scav npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/sword -/// Every scav guard carries a seclite it switches on in the dark (stealth_light.dm, decision 31). +/// Whatever outfit its table picks, a scav guard wears the scavs' own fatigues under it (stealth_disguise.dm, decision 40). +/mob/living/carbon/human/npc/ruin/trooper/scav/equipOutfit(outfit, visuals_only = FALSE) + var/datum/outfit/dressed = ispath(outfit) ? new outfit() : outfit + if(istype(dressed)) + dressed.uniform = /obj/item/clothing/under/syndicate/scav + return ..(dressed, visuals_only) + +/// Every scav guard carries a seclite it switches on in the dark (stealth_light.dm, decision 31), and a pass in its own +/// name; about half wear a balaclava, where nothing else is on their face (decision 40). /mob/living/carbon/human/npc/ruin/trooper/scav/npc_dress(datum/human_npc_order/order) . = ..() stealth_give_light() + if(isnull(wear_mask) && prob(50)) + equip_to_slot_or_del(new /obj/item/clothing/mask/balaclava/scav(src), ITEM_SLOT_MASK) + if(isnull(wear_id) && w_uniform) + var/obj/item/card/id/card = new /obj/item/card/id/advanced/black/scav(src) + card.registered_name = real_name + equip_to_slot_or_del(card, ITEM_SLOT_ID) /mob/living/carbon/human/npc/ruin/trooper/scav/gunner npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/pistol diff --git a/voidcrew/modules/stealth/stealth_admin.dm b/voidcrew/modules/stealth/stealth_admin.dm index f3b50b96257..cd09d5233e4 100644 --- a/voidcrew/modules/stealth/stealth_admin.dm +++ b/voidcrew/modules/stealth/stealth_admin.dm @@ -35,6 +35,19 @@ var/wary_text = "calm" if(stealth_ai.blackboard[BB_STEALTH_WARY]) wary_text = "wary [max(0, round((stealth_ai.stealth_skill().wary_time - (world.time - stealth_ai.wary_at)) / (1 SECONDS)))]s" + // Decision 40: what the one it has stopped, its focus, or else the nearest player wears, and whether it works on this guard. + var/mob/living/stopped = stealth_ai.challenge?.resolve() + var/mob/living/subject = stopped || focus + var/turf/here = get_turf(guard) + if(isnull(subject) && here && here.z <= length(SSmobs.clients_by_zlevel)) + for(var/mob/living/player as anything in SSmobs.clients_by_zlevel[here.z]) + if(get_dist(player, here) <= HUMAN_NPC_SIGHT_RANGE && (isnull(subject) || get_dist(player, here) < get_dist(subject, here))) + subject = player + var/pieces = isliving(subject) ? stealth_disguise_of(subject) : NONE + if(pieces) + var/passed = stealth_ai.passes?[REF(subject)] > world.time + var/works = subject == stopped ? "stopped" : (stealth_ai.stealth_fooled(subject) ? (passed ? "passed" : "holds") : "seen through") + wary_text += " | disguise: [subject] stage [stealth_disguise_stage(pieces)][(pieces & STEALTH_PIECE_ID) ? " +pass" : ""], [works]" return "[guard.real_name] [REF(guard)] | [stealth_ai.group?.id || "no group"] | [stealth_ai.stealth_skill().name][stealth_ai.skill_forced ? " (set)" : ""] | [state_text] [since]s | focus [focus_text] | [wary_text] | [route_text] | AI [status_text] | [stealth_guard_hearing_summary(guard, stealth_ai)]" ADMIN_VERB(stealth_guards, R_DEBUG, "Stealth Guards", "View and force the awareness of stealth guards on your z-level.", ADMIN_CATEGORY_DEBUG) diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index 764aa90ca09..21bcd2434ba 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -251,6 +251,10 @@ pending_call = null heard_map = null heard_now = null + made = null + passes = null + challenge = null + start_turf = null return ..() // With the AI off (nobody on the level, stunned, in crit, a player in the body) nothing scans, so no mark. @@ -323,6 +327,9 @@ look_until = 0 lost_since = 0 calm_until = 0 + // Whoever it had stopped to check is no longer being checked (decision 40). + challenge = null + start_turf = null stealth_drop_turn() suspicion_heard = FALSE if(new_state != STEALTH_UNAWARE) @@ -459,6 +466,8 @@ last_seen_turf = get_turf(target) blackboard[BB_STEALTH_LAST_SEEN_AT] = world.time set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, target) + // It knows that face from now on: a disguise won't hide it, a mask will (decision 40). + stealth_make(ismecha(target) ? bounty_ai_pilot_of(target) : target, FALSE) // Every alert is first hand: if they are in a locker or a box, it is the one it just saw or felt (decision 33). stealth_closet_alerted(target) // It has seen or felt them itself: it calls for help (decision 8). @@ -568,6 +577,9 @@ shut_in_at -= time if(target_free_seen_at) target_free_seen_at -= time + if(checked_at) + checked_at -= time + greeted -= time for(var/kind in bark_ready_at) bark_ready_at[kind] -= time for(var/key in stop_skip_until) @@ -588,6 +600,7 @@ stealth_update_wary() stealth_uncover_eyes() stealth_check_health() + stealth_check_challenge() var/state = stealth_state() if(state == STEALTH_SEARCHING && calm_until) if(world.time >= calm_until) @@ -680,6 +693,11 @@ // still fills as usual, so someone still in front of it when the moment passes is seen. var/turning = stealth_turn_grace() var/night_vision = HAS_TRAIT(guard, TRAIT_NIGHT_VISION) + // Decision 40 (stealth_disguise.dm): REF => TRUE for everyone whose disguise holds this look, the nearest of + // them close enough to stop, and whoever it has stopped already. + var/list/disguised + var/mob/living/suspect + var/mob/living/stopped = challenge?.resolve() for(var/mob/living/candidate as anything in stealth_candidates(guard, HUMAN_NPC_SIGHT_RANGE)) // Only those it could perceive count toward the cap, so bystanders it can't see never crowd a player out. if(judged >= STEALTH_MAX_CANDIDATES) @@ -729,6 +747,8 @@ judged++ var/rate = 0 var/plain_sight = FALSE + // In its cone in light it can use, and not in the moment after a turn + var/clear = FALSE if(boxed) rate = profile.notice_rate else if(eyes && !stealth_is_cloaked(candidate) && stealth_in_cone(guard, where, half_angle)) @@ -742,7 +762,8 @@ // Close in front of it, seen plainly: no slow double take (decision 32). Not in the dark, and not // in the moment after it turns (decision 39). else - plain_sight = !turning && dist <= profile.point_blank_range + clear = !turning + plain_sight = clear && dist <= profile.point_blank_range if(dist <= profile.near_range) rate *= profile.near_mult if(!rate && dist <= close_range && (night_vision || !stealth_tile_is_dark(where))) @@ -751,6 +772,30 @@ rate = STEALTH_BEHIND_RATE if(!rate) continue + // A disguise that holds (decision 40): seen doing what no guard would, it is blown; otherwise notice fills + // slower by stage, never jumps to an alert, and close enough they are stopped and asked instead. + var/pieces = boxed ? NONE : stealth_fooled(candidate) + if(pieces && stealth_breaker(candidate, pieces, where)) + if(stealth_blow(candidate)) + return + pieces = NONE + if(pieces) + LAZYSET(disguised, key, TRUE) + // Being checked: stealth_check_challenge() has them. + if(candidate == stopped) + perceived[key] = candidate + continue + var/passed = (pieces & STEALTH_PIECE_ID) && passes?[key] > world.time + if(clear && dist <= STEALTH_GREET_RANGE && (passed || ((pieces & STEALTH_PIECE_ID) && (pieces & STEALTH_PIECE_MASK)))) + stealth_greet(candidate) + if(passed) + continue + plain_sight = FALSE + if(clear && isnull(suspect) && dist <= stealth_challenge_range(pieces)) + suspect = candidate + rate *= stealth_disguise_mult(pieces, dist) + if(!rate) + continue var/list/entry = notice[key] if(isnull(entry)) entry = list(0, null, 0) @@ -768,7 +813,7 @@ if(wary) rate *= STEALTH_WARY_MULT wary_at = world.time - entry[STEALTH_ENTRY_NOTICE] = min(entry[STEALTH_ENTRY_NOTICE] + rate * scan_seconds, STEALTH_NOTICE_MAX) + entry[STEALTH_ENTRY_NOTICE] = min(entry[STEALTH_ENTRY_NOTICE] + rate * scan_seconds, pieces ? STEALTH_SUSPICIOUS_AT : STEALTH_NOTICE_MAX) if(plain_sight) entry[STEALTH_ENTRY_NOTICE] = STEALTH_NOTICE_MAX if(isnull(point_blank)) @@ -808,6 +853,10 @@ if(point_blank) stealth_spot_point_blank(point_blank) return + // Someone in their colours close enough to stop (decision 40). + if(suspect && isnull(stopped) && !calm_until) + stealth_challenge(suspect) + return // Whoever it sees now decides what it does; a higher entry it can't see no longer speaks for them. var/judged_key = seen_key || best_key if(isnull(judged_key)) @@ -824,6 +873,11 @@ var/seen_now = !isnull(seen_key) // No alert by sight from off-screen (abuse P8). var/in_reach = get_dist(guard, best_turf) <= profile.alert_max_range + // A disguise that holds is stopped and asked once it has drawn enough notice, never taken for an intruder (decision 40). + if(disguised?[judged_key]) + if(seen_now && level >= STEALTH_SUSPICIOUS_AT && isnull(stopped) && !calm_until) + stealth_challenge(best) + return switch(state) if(STEALTH_UNAWARE) if(level >= STEALTH_SUSPICIOUS_AT) @@ -885,6 +939,9 @@ var/turf/where = candidate.loc if(!isturf(where) || stealth_is_cloaked(candidate) || !stealth_in_cone(guard, where, half_angle)) continue + // Someone in their colours is stopped by the scan, not jumped (decision 40). + if(stealth_fooled(candidate)) + continue var/dist = get_dist(guard, where) if(dist > STEALTH_ADJACENT_RANGE && stealth_range_onto(where) < profile.sight_range) continue @@ -1085,6 +1142,12 @@ else stealth_go_suspicious(where, STEALTH_GOTO_BODY) stealth_first_hand(where) + // Someone in their colours standing over it as it is found (decision 40). + for(var/mob/living/carbon/human/near in range(1, where)) + if(near.stat == DEAD || guard.faction_check_atom(near) || !stealth_fooled(near) || !stealth_sees(near)) + continue + stealth_blow(near) + break return // ===== Touches, hits and recovery ===== @@ -1103,6 +1166,9 @@ explained_at = world.time if(ismovable(source) && guard.faction_check_atom(source)) return FALSE + // Whoever of its group sees it happen sees through a disguise (decision 40). + if(isliving(source)) + group?.witness(source, guard) stealth_set_wary() var/atom/who = isliving(source) ? bounty_ai_target_for(source) : source var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) @@ -1141,7 +1207,12 @@ /datum/ai_controller/basic_controller/human_npc/stealth/proc/on_bumped(atom/source, atom/movable/bumper) SIGNAL_HANDLER if(isliving(bumper)) - stealth_touched(bumper) + // One of its own, so it thinks, walking into it: it wants a look at them (decision 40). + var/pieces = stealth_scanning() ? stealth_fooled(bumper) : NONE + if(!pieces) + stealth_touched(bumper) + else if(!((pieces & STEALTH_PIECE_ID) && passes?[REF(bumper)] > world.time)) + stealth_challenge(bumper) return if(!ismovable(bumper)) return @@ -1408,6 +1479,15 @@ return switch(controller.stealth_state()) if(STEALTH_SUSPICIOUS) + // It has stopped someone to see their pass (decision 40): it walks up to them and stands facing them. + var/mob/living/stopped = controller.challenge?.resolve() + if(stopped) + if(get_dist(guard, stopped) <= STEALTH_CHALLENGE_CHECK_RANGE) + controller.stealth_drop_walk() + controller.queue_behavior(/datum/ai_behavior/stealth_stand) + else + controller.stealth_walk(get_turf(stopped), STEALTH_GOTO_INVESTIGATE) + return SUBTREE_RETURN_FINISH_PLANNING if(world.time < controller.blackboard[BB_STEALTH_STATE_SINCE] + controller.stealth_skill().reaction_delay) controller.queue_behavior(/datum/ai_behavior/stealth_stand) return SUBTREE_RETURN_FINISH_PLANNING diff --git a/voidcrew/modules/stealth/stealth_disguise.dm b/voidcrew/modules/stealth/stealth_disguise.dm new file mode 100644 index 00000000000..518162fdc2b --- /dev/null +++ b/voidcrew/modules/stealth/stealth_disguise.dm @@ -0,0 +1,401 @@ +/** + * # Stealth guards: disguises (owner decision 40) + * + * Guards look at what someone wears. It is guard AI perception only: nothing here touches the wearer's body, and + * nothing but the stealth controller reads it, so a disguise does nothing against players or any other NPC. + * + * The pieces (STEALTH_PIECE_*): + * - clothing: the scavs' own fatigues, showing, with nothing over them but what the guards' own outfits wear over + * theirs (stealth_guard_suits()); + * - mask: tg's own "face hidden" (get_face_name() finds no face), whatever hides it; + * - ID: a scav pass in the ID slot. + * + * A disguise holds for a guard while the clothing is on and the guard hasn't seen through it (stealth_fooled()). + * While it holds, notice fills slower by stage (stealth_look()), never jumps to an alert, and stops at suspicious, + * where the guard stops them and asks for their pass instead (stealth_challenge()). In the full set, beyond the + * guard's near range, they are one of its own: no notice, and a nod. + * + * What ends it for a guard (stealth_blow(), stealth_make()): a weapon in hand, pulling a fallen guard, an off-limits + * room, being seen laying hands on a guard, standing over a body as it is found, running in earshot, a failed + * challenge, and a face it has gone alert on before (a mask hides the face). The guard remembers faces for good and a + * blown disguise's wearer for STEALTH_MADE_TIME. Its group keeps the same list, which only a wary guard reads: wary + * is what a shout, a radio call or a hold leaves behind, so word of it reaches exactly the guards the alarm did. + * + * Cost: what someone wears is cached on them (/datum/component/stealth_disguise) and thrown away when they put + * anything on or take anything off; a guard's scan reads two numbers and a list or two. + */ + +// ===== The pieces ===== + +/// The scavs' own clothes: the only uniform guards take for theirs. +/obj/item/clothing/under/syndicate/scav + name = "scav fatigues" + desc = "A patched black turtleneck and cargo trousers. Half the den wears the same pair." + +/obj/item/clothing/mask/balaclava/scav + name = "scav balaclava" + desc = "A black balaclava that has seen a lot of dust." + +/// A guard's card. It opens the den's own doors (ACCESS_SCAV). +/obj/item/card/id/advanced/black/scav + name = "scav pass" + desc = "A scratched black card on a cord, punched with a den's mark." + assignment = "Scav" + access = list(ACCESS_SCAV) + +/obj/item/card/id/advanced/black/scav/update_label() + name = initial(name) + +/// The suit types the guards' own outfits wear over their fatigues: type => TRUE. Read from the scav types' outfit +/// tables, so a new dress is picked up. Not kept in a static: the unit test build has no room for one more +/// (data/stealth/STATUS.md, "Decision 40"), and it is only asked for someone wearing a suit over the fatigues. +/proc/stealth_guard_suits() + var/list/suits = list() + for(var/mob/living/carbon/human/npc/guard_type as anything in typesof(/mob/living/carbon/human/npc/ruin/trooper/scav)) + var/table_type = initial(guard_type.npc_outfit_table) + if(!ispath(table_type, /datum/human_npc_outfit_table)) + continue + var/datum/human_npc_outfit_table/table = human_npc_singleton(table_type) + for(var/list/outfits as anything in list(table.green, table.yellow, table.red)) + for(var/datum/outfit/outfit as anything in outfits) + var/suit = initial(outfit.suit) + if(suit) + suits[suit] = TRUE + return suits + +/// What a human wears of the scavs' own, kept until they change clothes. +/datum/component/stealth_disguise + /// STEALTH_PIECE_* flags, or null when they have changed since it was last worked out + var/pieces + /// The name tg reads off their face, or "" when it can't be seen + var/face + /// world.time it was last worked out + var/checked_at = 0 + +/datum/component/stealth_disguise/Initialize() + if(!ishuman(parent)) + return COMPONENT_INCOMPATIBLE + +/datum/component/stealth_disguise/RegisterWithParent() + RegisterSignals(parent, list(COMSIG_MOB_EQUIPPED_ITEM, COMSIG_MOB_UNEQUIPPED_ITEM), PROC_REF(on_change)) + +/datum/component/stealth_disguise/UnregisterFromParent() + UnregisterSignal(parent, list(COMSIG_MOB_EQUIPPED_ITEM, COMSIG_MOB_UNEQUIPPED_ITEM)) + +/datum/component/stealth_disguise/proc/on_change(datum/source) + SIGNAL_HANDLER + pieces = null + +/datum/component/stealth_disguise/proc/refresh() + var/mob/living/carbon/human/wearer = parent + checked_at = world.time + face = wearer.get_face_name("") + pieces = face ? NONE : STEALTH_PIECE_MASK + if(istype(wearer.w_uniform, /obj/item/clothing/under/syndicate/scav) && !(wearer.check_obscured_slots() & ITEM_SLOT_ICLOTHING)) + if(isnull(wearer.wear_suit) || stealth_guard_suits()[wearer.wear_suit.type]) + pieces |= STEALTH_PIECE_CLOTHES + if(istype(wearer.wear_id?.GetID(), /obj/item/card/id/advanced/black/scav)) + pieces |= STEALTH_PIECE_ID + +/// The cache on `who`, worked out afresh if they changed clothes or it is older than STEALTH_DISGUISE_CACHE_TIME +/// (a mask pulled down, a face wrecked). Null for anyone but a human. +/proc/stealth_disguise_cache(mob/living/carbon/human/who) + if(!ishuman(who)) + return null + var/datum/component/stealth_disguise/cache = who.GetComponent(/datum/component/stealth_disguise) || who.AddComponent(/datum/component/stealth_disguise) + if(isnull(cache.pieces) || world.time - cache.checked_at > STEALTH_DISGUISE_CACHE_TIME) + cache.refresh() + return cache + +/// What `who` wears of the scavs' own: STEALTH_PIECE_* flags, 0 for anyone but a human. +/proc/stealth_disguise_of(mob/living/who) + var/datum/component/stealth_disguise/cache = stealth_disguise_cache(who) + return cache ? cache.pieces : NONE + +/// The stage of `pieces`, for admins and tests: 0 nothing, 1 mask, 2 clothing, 3 clothing and mask, 4 with the pass too. +/proc/stealth_disguise_stage(pieces) + if(!(pieces & STEALTH_PIECE_CLOTHES)) + return (pieces & STEALTH_PIECE_MASK) ? 1 : 0 + if(!(pieces & STEALTH_PIECE_MASK)) + return 2 + return (pieces & STEALTH_PIECE_ID) ? 4 : 3 + +// ===== Off-limits rooms ===== + +/// Marks the room it stands in as off limits: a disguise seen in it is blown. Its room is every open tile it can +/// reach within `reach` without passing a door, a window or a grille. +/obj/effect/landmark/stealth_restricted + name = "stealth off-limits room" + icon_state = "x2" + /// Tiles from here its room is followed, at most + var/reach = 6 + /// Whether wearing a scav pass excuses being here + var/allowed = TRUE + +/datum/stealth_group + /// Face name => TRUE, or REF(mob) => world.time the mark runs out: disguises its guards have seen through. + /// Read only by a guard that is wary (stealth_knows()). + var/list/made + /// Off-limits turf => whether a pass excuses being there. Null until first asked for. + var/list/restricted + +/// Its off-limits tiles, worked out once from the marks in its region. +/datum/stealth_group/proc/off_limits() + if(!isnull(restricted)) + return restricted + restricted = list() + for(var/obj/effect/landmark/stealth_restricted/mark in GLOB.landmarks_list) + var/turf/origin = get_turf(mark) + if(isnull(origin) || origin.z != home?.z || get_dist(origin, home) > STEALTH_GROUP_RADIUS || !region_matches(origin)) + continue + var/list/frontier = list(origin) + restricted[origin] = mark.allowed + while(length(frontier)) + var/turf/here = frontier[1] + frontier.Cut(1, 2) + for(var/turf/open/next as anything in get_adjacent_open_turfs(here)) + if(!isnull(restricted[next]) || get_dist(next, origin) > mark.reach) + continue + if((locate(/obj/machinery/door) in next) || (locate(/obj/structure/window) in next) || (locate(/obj/structure/grille) in next)) + continue + restricted[next] = mark.allowed + frontier += next + return restricted + +/// One of its guards has been touched or hit by `attacker`: every other guard that sees them do it in a disguise +/// that still held sees through it. +/datum/stealth_group/proc/witness(mob/living/attacker, mob/living/victim) + if(!(stealth_disguise_of(attacker) & STEALTH_PIECE_CLOTHES)) + return + for(var/mob/living/friend as anything in living_members()) + var/datum/ai_controller/basic_controller/human_npc/stealth/friend_ai = friend.ai_controller + if(friend == victim || !istype(friend_ai) || friend.client || friend_ai.stealth_captive()) + continue + if(friend_ai.stealth_fooled(attacker) && friend_ai.stealth_sees(attacker)) + friend_ai.stealth_blow(attacker) + +// ===== The guard's side ===== + +/datum/ai_controller/basic_controller/human_npc/stealth + /// Face name => TRUE, or REF(mob) => world.time the mark runs out: disguises it has seen through itself + var/list/made + /// REF(mob) => world.time until which it lets them be, after it checked their pass + var/list/passes + /// Weakref to whoever it has stopped to check + var/datum/weakref/challenge + /// Where they stood when it stopped them + var/turf/start_turf + /// world.time it got near enough to look at their pass, or 0 + var/checked_at = 0 + /// Whether it has asked a second time + var/warned = FALSE + /// world.time it may next greet one of its own + var/greeted = 0 + +/// Whether it sees through `who`: it knows the face, or the wearer of a disguise it saw blown; and, while it is +/// wary, anyone its group does. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_knows(mob/living/who) + var/datum/component/stealth_disguise/cache = stealth_disguise_cache(who) + if(isnull(cache)) + return FALSE + var/key = REF(who) + var/face = cache.face + if(made && ((face && made[face]) || made[key] > world.time)) + return TRUE + var/list/told = blackboard[BB_STEALTH_WARY] ? group?.made : null + return !!(told && ((face && told[face]) || told[key] > world.time)) + +/// `who`'s STEALTH_PIECE_* flags if their disguise holds for this guard: the clothing is on and it hasn't seen +/// through them. 0 otherwise. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_fooled(mob/living/who) + var/pieces = stealth_disguise_of(who) + if(!(pieces & STEALTH_PIECE_CLOTHES) || stealth_knows(who)) + return NONE + return pieces + +/** + * Remembers `who`: their face for good, if it shows. `blown`: also the wearer, face or no face, for + * STEALTH_MADE_TIME (a disguise it saw through; a mask won't fix that). `word`: its group gets the same, for the + * guards an alarm reaches. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_make(mob/living/who, blown = TRUE, word = TRUE) + var/datum/component/stealth_disguise/cache = stealth_disguise_cache(who) + if(isnull(cache)) + return + var/key = REF(who) + if(cache.face) + LAZYSET(made, cache.face, TRUE) + if(word && group) + LAZYSET(group.made, cache.face, TRUE) + if(!blown) + return + LAZYSET(made, key, world.time + STEALTH_MADE_TIME) + if(word && group) + LAZYSET(group.made, key, world.time + STEALTH_MADE_TIME) + if(passes) + passes -= key + +/// Whether it sees `who` plainly now: eyes open, in its cone, in the light it needs, nothing in the way. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_sees(mob/living/who) + var/mob/living/guard = pawn + var/turf/where = who.loc + if(!isturf(where) || !isturf(guard.loc) || guard.stat != CONSCIOUS || !stealth_eyes_open() || stealth_is_cloaked(who)) + return FALSE + var/dist = get_dist(guard, where) + if(dist > STEALTH_ADJACENT_RANGE && dist > stealth_range_onto(where)) + return FALSE + if(!stealth_in_cone(guard, where, stealth_half_angle())) + return FALSE + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) + return !!strategy?.can_attack(guard, who, stealth_skill().sight_range) + +/// Whether `who`, seen on `where` in a disguise of `pieces`, is doing something no guard of the den would: a weapon +/// in hand, pulling a fallen guard, or standing in an off-limits room the pass doesn't excuse. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_breaker(mob/living/carbon/human/who, pieces, turf/where) + for(var/obj/item/held in who.held_items) + if(isgun(held) || istype(held, /obj/item/melee) || (held.force >= STEALTH_WEAPON_FORCE && held.get_sharpness())) + return TRUE + var/mob/living/pulled = who.pulling + var/mob/living/guard = pawn + if(isliving(pulled) && guard.faction_check_atom(pulled) && (pulled.stat != CONSCIOUS || pulled.body_position == LYING_DOWN || HAS_TRAIT(pulled, TRAIT_RESTRAINED))) + return TRUE + var/list/rooms = group?.off_limits() + var/excused = rooms?[where] + return !isnull(excused) && !(excused && (pieces & STEALTH_PIECE_ID)) + +/** + * It has seen through `who`. It remembers them, says so, and goes alert if they are near enough to be sure of and + * can be fought. Already fighting someone, it only remembers them. Returns TRUE if it went alert on them. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_blow(mob/living/who) + var/mob/living/guard = pawn + stealth_make(who) + challenge = null + start_turf = null + if(stealth_state() == STEALTH_ALERT) + stealth_remember(who) + return FALSE + stealth_bark(STEALTH_BARK_BLOWN, null, null, TRUE) + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) + if(get_dist(guard, who) > stealth_skill().alert_max_range || !strategy?.can_attack(guard, who, HUMAN_NPC_SIGHT_RANGE)) + return FALSE + stealth_go_alert(bounty_ai_target_for(who)) + return stealth_state() == STEALTH_ALERT + +/// The tiles within which it stops someone in a disguise of `pieces` that it sees plainly. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_challenge_range(pieces) + . = STEALTH_CHALLENGE_RANGE_CLOTHES + if(pieces & STEALTH_PIECE_MASK) + . = (pieces & STEALTH_PIECE_ID) ? STEALTH_CHALLENGE_RANGE_FULL : STEALTH_CHALLENGE_RANGE_MASKED + . = max(1, . + stealth_skill().challenge + (blackboard[BB_STEALTH_WARY] ? 1 : 0)) + +/// How much of its usual notice someone in a disguise of `pieces` gains at `dist` tiles. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_disguise_mult(pieces, dist) + var/datum/stealth_skill/profile = stealth_skill() + if(!(pieces & STEALTH_PIECE_MASK)) + return STEALTH_DISGUISE_FILL_CLOTHES * profile.disguise + if(!(pieces & STEALTH_PIECE_ID)) + return STEALTH_DISGUISE_FILL_MASKED * profile.disguise + // The whole set: one of its own at a distance, whatever its skill. + return dist > profile.near_range ? 0 : STEALTH_DISGUISE_FILL_FULL * profile.disguise + +/// The name on the pass `who` wears, if it is one of its group's own: what its friends called them. An NPC's +/// name, never player text; null for a pass in nobody's name or a guard with only its type's name. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_card_name(mob/living/carbon/human/who) + var/obj/item/card/id/card = ishuman(who) ? who.wear_id?.GetID() : null + if(!istype(card) || !card.registered_name) + return null + for(var/mob/living/carbon/human/npc/friend as anything in group?.living_members()) + if(friend != pawn && friend.real_name == card.registered_name) + return stealth_first_name(friend) + return null + +/// One of its own goes by (so it thinks): a nod or a word, now and then. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_greet(mob/living/who) + if(world.time < greeted || stealth_state() != STEALTH_UNAWARE) + return + greeted = world.time + STEALTH_GREET_COOLDOWN + stealth_bark(prob(25) ? STEALTH_BARK_SMOKE : STEALTH_BARK_GREET, null, stealth_card_name(who)) + +/** + * Stops `who` to see their pass: suspicious of them, facing and pointing at them, with the challenge line. From + * here stealth_check_challenge() decides, once a scan. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_challenge(mob/living/who) + var/mob/living/guard = pawn + if(QDELETED(who) || stealth_driven() || stealth_state() == STEALTH_ALERT || challenge?.resolve() == who) + return + var/turf/where = get_turf(who) + if(stealth_state() == STEALTH_SUSPICIOUS) + investigated = FALSE + stealth_drop_walk() + stealth_aim_at(where) + stealth_bark(STEALTH_BARK_CHALLENGE, null, null, TRUE) + else + // The line always comes with the stop. + bark_ready_at -= STEALTH_BARK_CHALLENGE + stealth_go_suspicious(where, STEALTH_GOTO_INVESTIGATE, STEALTH_BARK_CHALLENGE) + if(stealth_state() != STEALTH_SUSPICIOUS) + return + challenge = WEAKREF(who) + start_turf = where + checked_at = 0 + warned = FALSE + suspicion_heard = FALSE + goto_purpose = STEALTH_GOTO_INVESTIGATE + stealth_remember(who) + notice_map[REF(who)][STEALTH_ENTRY_NOTICE] = STEALTH_SUSPICIOUS_AT + set_blackboard_key(BB_STEALTH_FOCUS, who) + INVOKE_ASYNC(guard, TYPE_PROC_REF(/mob, _pointed), who) + stealth_meter_update() + +/** + * The scan, while it has someone stopped. Blown: the clothing is off, it knows them now, they run, they are more + * than STEALTH_CHALLENGE_LEASH from where it stopped them, it can't see them, they do what no guard would, or + * they still show no pass STEALTH_CHALLENGE_FAIL_TIME after it got to them. Passed: the pass is on them and it has + * looked at it for STEALTH_CHALLENGE_CHECK_TIME from within STEALTH_CHALLENGE_CHECK_RANGE. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_check_challenge() + var/mob/living/carbon/human/who = challenge?.resolve() + if(isnull(who)) + challenge = null + return + var/mob/living/guard = pawn + if(QDELETED(who) || who.stat == DEAD || stealth_state() != STEALTH_SUSPICIOUS) + challenge = null + start_turf = null + return + var/key = REF(who) + var/list/entry = notice_map[key] + var/turf/where = get_turf(who) + var/pieces = stealth_fooled(who) + // It keeps its eyes on them. + if(get_turf(guard) != where) + stand_dir = stealth_dir_to(guard, where) + guard.setDir(stand_dir) + var/ran = who.move_intent == MOVE_INTENT_RUN && entry && entry[STEALTH_ENTRY_TURF] != where + var/late = checked_at && !(pieces & STEALTH_PIECE_ID) && world.time - checked_at >= STEALTH_CHALLENGE_FAIL_TIME + if(!pieces || ran || late || get_dist(where, start_turf) > STEALTH_CHALLENGE_LEASH || !stealth_sees(who) || stealth_breaker(who, pieces, where)) + if(!stealth_blow(who) && stealth_state() == STEALTH_SUSPICIOUS) + stealth_go_searching(where) + stealth_first_hand(where) + return + last_gain = world.time + investigate_turf = where + last_seen_turf = where + stealth_remember(who) + notice_map[key][STEALTH_ENTRY_NOTICE] = STEALTH_SUSPICIOUS_AT + if(get_dist(guard, where) > STEALTH_CHALLENGE_CHECK_RANGE) + return + if(!checked_at) + checked_at = world.time + if(pieces & STEALTH_PIECE_ID) + if(world.time - checked_at < STEALTH_CHALLENGE_CHECK_TIME) + return + stealth_bark(STEALTH_BARK_ID_PASS, null, stealth_card_name(who), TRUE) + LAZYSET(passes, key, world.time + STEALTH_PASS_TIME) + stealth_go_unaware() + return + if(!warned && world.time - checked_at >= STEALTH_CHALLENGE_WARN_TIME) + warned = TRUE + stealth_bark(STEALTH_BARK_ID_FAIL, null, null, TRUE) diff --git a/voidcrew/modules/stealth/stealth_doors.dm b/voidcrew/modules/stealth/stealth_doors.dm index 5a8ca4da848..f83846dc109 100644 --- a/voidcrew/modules/stealth/stealth_doors.dm +++ b/voidcrew/modules/stealth/stealth_doors.dm @@ -108,6 +108,14 @@ var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller if(!istype(guard_ai) || !guard_ai.stealth_sees_door(where)) continue + // Someone it takes for one of its own at the door: nothing to look at (decision 40). + var/own = FALSE + for(var/mob/living/carbon/human/near in range(1, where)) + if(!guard.faction_check_atom(near) && guard_ai.stealth_fooled(near)) + own = TRUE + break + if(own) + continue var/dist = get_dist(guard, where) var/index = 1 while(index <= length(seers) && get_dist(seers[index], where) <= dist) diff --git a/voidcrew/modules/stealth/stealth_hearing.dm b/voidcrew/modules/stealth/stealth_hearing.dm index f19f96912f5..b7526728644 100644 --- a/voidcrew/modules/stealth/stealth_hearing.dm +++ b/voidcrew/modules/stealth/stealth_hearing.dm @@ -221,6 +221,9 @@ continue LAZYSET(heard_now, key, TRUE) last_heard = list("footsteps", world.time) + // Nobody of the den runs about it: a disguise heard running is done for with this guard (decision 40). + if(walker.body_position != LYING_DOWN && (stealth_disguise_of(walker) & STEALTH_PIECE_CLOTHES)) + stealth_make(walker, TRUE, FALSE) if(state == STEALTH_SEARCHING) if(!calm_until && world.time >= next_recentre && get_dist(search_center, where) > 1) next_recentre = world.time + STEALTH_RECENTRE_COOLDOWN diff --git a/voidcrew/modules/stealth/stealth_light.dm b/voidcrew/modules/stealth/stealth_light.dm index 95e67b51dda..74e9f927798 100644 --- a/voidcrew/modules/stealth/stealth_light.dm +++ b/voidcrew/modules/stealth/stealth_light.dm @@ -59,8 +59,11 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) stealth_ai.stealth_update_light() /// Decision 34: a guard's seclite is loot like anyone's, so it is never locked to the body (D3 holds for the rest). +/// Decision 40: so are the scavs' fatigues, balaclava and pass (stealth_disguise.dm). /mob/living/carbon/human/npc/npc_lock_item(obj/item/item) - if(istype(item, /obj/item/flashlight/seclite/scav)) + if(istype(item, /obj/item/flashlight/seclite/scav) || istype(item, /obj/item/clothing/under/syndicate/scav)) + return FALSE + if(istype(item, /obj/item/clothing/mask/balaclava/scav) || istype(item, /obj/item/card/id/advanced/black/scav)) return FALSE return ..() diff --git a/voidcrew/modules/stealth/stealth_patrol.dm b/voidcrew/modules/stealth/stealth_patrol.dm index 221c82c8799..490a2ed627f 100644 --- a/voidcrew/modules/stealth/stealth_patrol.dm +++ b/voidcrew/modules/stealth/stealth_patrol.dm @@ -75,6 +75,8 @@ GLOBAL_VAR_INIT(stealth_group_count, 0) members = null routes = null home = null + made = null + restricted = null return ..() /// Whether `tile` is in this group's map region. diff --git a/voidcrew/modules/stealth/stealth_skill.dm b/voidcrew/modules/stealth/stealth_skill.dm index ab202d158c2..a11fffb14df 100644 --- a/voidcrew/modules/stealth/stealth_skill.dm +++ b/voidcrew/modules/stealth/stealth_skill.dm @@ -49,6 +49,10 @@ var/wary_time = 60 SECONDS /// After it turns where it stands, how long before anything is plain to it at a glance (decision 39) var/turn_grace = 1 SECONDS + /// Multiplies the notice someone in a disguise still gains: under 1 is easier to fool (decision 40) + var/disguise = 1 + /// Tiles added to the range within which it stops someone in a disguise to see their pass (decision 40) + var/challenge = 0 /datum/stealth_skill/yellow @@ -71,6 +75,8 @@ search_time = 25 SECONDS wary_time = 40 SECONDS turn_grace = 1.2 SECONDS + disguise = 0.6 + challenge = -1 /// Sharp: sees further and wider, notices faster, hears more, searches longer. Still blind behind in the dark. /datum/stealth_skill/red @@ -91,6 +97,8 @@ search_time = 60 SECONDS wary_time = 90 SECONDS turn_grace = 0.8 SECONDS + disguise = 1.6 + challenge = 1 /// The shared profile of type `skill_type`, or null if it isn't one. /proc/stealth_skill_of(skill_type) diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index 7783ab633ec..c7207be5cd1 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -240,6 +240,7 @@ #include "voidcrew_stealth_d32.dm" #include "voidcrew_stealth_d37.dm" #include "voidcrew_stealth_d39.dm" +#include "voidcrew_stealth_disguise.dm" #include "voidcrew_stealth_hearing.dm" #include "voidcrew_stealth_light.dm" #include "voidcrew_survey_archive.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_human_npcs_ruins.dm b/voidcrew/modules/unit_tests/voidcrew_human_npcs_ruins.dm index 390f714e048..6a009143b0f 100644 --- a/voidcrew/modules/unit_tests/voidcrew_human_npcs_ruins.dm +++ b/voidcrew/modules/unit_tests/voidcrew_human_npcs_ruins.dm @@ -26,7 +26,9 @@ if(isnull(npc)) continue TEST_ASSERT_NOTNULL(npc.w_uniform, "[npc_type] has no clothes in zone [zone]") - TEST_ASSERT(human_npc_gear_locked(npc.w_uniform), "[npc_type]'s clothes aren't locked to it in zone [zone]") + // The scavs' fatigues are loot on purpose (stealth_disguise.dm); their boots stand in for the rest of their dress. + var/obj/item/clothes = istype(npc.w_uniform, /obj/item/clothing/under/syndicate/scav) ? npc.shoes : npc.w_uniform + TEST_ASSERT(human_npc_gear_locked(clothes), "[npc_type]'s clothes aren't locked to it in zone [zone]") var/obj/item/gun/gun = human_npc_held_gun(npc) var/unarmed_ok = npc_type == /mob/living/carbon/human/npc/ruin/hermit && zone == 1 if(!unarmed_ok) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_crits.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_crits.dm index 73c4bec4391..5cc0b1c29c1 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_crits.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_crits.dm @@ -167,7 +167,7 @@ TEST_ASSERT_NOTNULL(light, "A scav guard has no flashlight") TEST_ASSERT(!HAS_TRAIT(light, TRAIT_NO_STRIP), "The seclite can't be stripped") TEST_ASSERT(!human_npc_gear_locked(light), "The seclite is locked gear") - TEST_ASSERT(human_npc_gear_locked(guard.w_uniform), "The rest of the guard's kit isn't locked any more") + TEST_ASSERT(human_npc_gear_locked(guard.shoes), "The rest of the guard's kit isn't locked any more") var/mob/living/carbon/human/person = stealth_person(block, 3, 2) TEST_ASSERT(guard.dropItemToGround(light), "The seclite can't be taken off") TEST_ASSERT(person.put_in_hands(light), "The seclite can't be picked up") diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_disguise.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_disguise.dm new file mode 100644 index 00000000000..883a38d51d8 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_disguise.dm @@ -0,0 +1,465 @@ +// Stealth guards, decision 40: disguises (voidcrew/modules/stealth/stealth_disguise.dm). Values from voidcrew/_DEFINES are +// written out: pieces mask 1, clothing 2, pass 4; fill x0.5 clothing, x0.25 with a mask, x0.05 the whole set inside near +// range (4) and 0 beyond; challenge range 5 / 3 / 2; the pass is read for 2 s, asked for again at 3 s, blown at 6 s; +// more than 2 tiles from where they were stopped is walking off. States and bark kinds are written as text. +// The tests down to voidcrew_stealth_disguise_loot call the scan directly; the voidcrew_stealth_live ones run the real AI. + +/// Puts the scavs' own things on `person`: the fatigues, a balaclava, a pass. +/datum/unit_test/proc/stealth_dress(mob/living/carbon/human/person, uniform = TRUE, mask = TRUE, card = TRUE) + if(uniform) + person.equip_to_slot_or_del(new /obj/item/clothing/under/syndicate/scav(person), ITEM_SLOT_ICLOTHING) + if(mask) + person.equip_to_slot_or_del(new /obj/item/clothing/mask/balaclava/scav(person), ITEM_SLOT_MASK) + if(card) + person.equip_to_slot_or_del(new /obj/item/card/id/advanced/black/scav(person), ITEM_SLOT_ID) + +/// The guard's notice of `person`, 0 if it has none. +/datum/unit_test/proc/stealth_notice_of(mob/living/guard, mob/living/person) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + var/list/entry = stealth_ai.notice_map?[REF(person)] + return entry ? entry[1] : 0 + +/// What counts as each piece, and that changing clothes is seen at once. +/datum/unit_test/voidcrew_stealth_disguise_pieces + +/datum/unit_test/voidcrew_stealth_disguise_pieces/Run() + var/datum/turf_reservation/block = stealth_block(3, 3) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/person = stealth_person(block, 1, 1) + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 0, "Someone in nothing of theirs wears a piece") + stealth_dress(person, TRUE, FALSE, FALSE) + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 2, "The fatigues aren't the clothing piece") + stealth_dress(person, FALSE, TRUE, FALSE) + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 3, "A balaclava over the fatigues isn't clothing and mask") + stealth_dress(person, FALSE, FALSE, TRUE) + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 7, "The pass in the ID slot isn't the ID piece") + TEST_ASSERT_EQUAL(stealth_disguise_stage(7), 4, "The whole set isn't stage 4") + TEST_ASSERT_EQUAL(stealth_disguise_stage(3), 3, "Clothing and mask isn't stage 3") + TEST_ASSERT_EQUAL(stealth_disguise_stage(6), 2, "Clothing and pass with a bare face isn't stage 2") + TEST_ASSERT_EQUAL(stealth_disguise_stage(1), 1, "A mask alone isn't stage 1") + // The vest the guards wear over theirs keeps the clothing; a coat they don't wear loses it. + TEST_ASSERT(stealth_guard_suits()[/obj/item/clothing/suit/armor/vest], "The guards' own vest isn't read from their outfits") + var/obj/item/clothing/suit/vest = new /obj/item/clothing/suit/armor/vest(person) + TEST_ASSERT(person.equip_to_slot_if_possible(vest, ITEM_SLOT_OCLOTHING), "The vest wouldn't go on") + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 7, "The guards' own vest over the fatigues lost the clothing piece") + TEST_ASSERT(person.dropItemToGround(vest), "The vest wouldn't come off") + var/obj/item/clothing/suit/coat = new /obj/item/clothing/suit/toggle/labcoat(person) + TEST_ASSERT(person.equip_to_slot_if_possible(coat, ITEM_SLOT_OCLOTHING), "The coat wouldn't go on") + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 5, "A lab coat over the fatigues still passes for the guards' dress") + TEST_ASSERT(person.dropItemToGround(coat), "The coat wouldn't come off") + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 7, "Taking the coat off didn't bring the clothing piece back") + // Any mask that hides the face is the mask; a bare face is none. + TEST_ASSERT(person.dropItemToGround(person.wear_mask), "The balaclava wouldn't come off") + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 6, "A bare face still counts as masked") + person.equip_to_slot_or_del(new /obj/item/clothing/mask/gas(person), ITEM_SLOT_MASK) + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 7, "A gas mask doesn't hide the face") + // The fatigues off: the pass drops with them, and only the mask is left. + TEST_ASSERT(person.dropItemToGround(person.w_uniform), "The fatigues wouldn't come off") + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 1, "With the fatigues off something but the mask still counts") + person.equip_to_slot_or_del(new /obj/item/clothing/under/color/grey(person), ITEM_SLOT_ICLOTHING) + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 1, "A grey jumpsuit passes for the guards' dress") + qdel(block) + +/// Each stage's notice fill at 6 tiles in the light, and the same through the green and red skills. +/datum/unit_test/voidcrew_stealth_disguise_fill + +/datum/unit_test/voidcrew_stealth_disguise_fill/Run() + var/datum/turf_reservation/block = stealth_block(20, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + // uniform, mask, card, share of the plain fill (0.375 a scan for a yellow guard at 6 tiles) + var/list/cases = list( + list(FALSE, FALSE, FALSE, 1), + list(FALSE, TRUE, FALSE, 1), + list(TRUE, FALSE, FALSE, 0.5), + list(TRUE, TRUE, FALSE, 0.25), + list(TRUE, FALSE, TRUE, 0.5), + list(TRUE, TRUE, TRUE, 0), + ) + for(var/list/test_case as anything in cases) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 2) + var/mob/living/carbon/human/person = stealth_person(block, 12, 2) + stealth_dress(person, test_case[1], test_case[2], test_case[3]) + stealth_scans(guard, 1) + var/expected = 0.375 * test_case[4] + var/found = stealth_notice_of(guard, person) + TEST_ASSERT(abs(found - expected) < 0.001, "Fatigues [test_case[1]], mask [test_case[2]], pass [test_case[3]]: one look at 6 tiles gave [found] notice, not [expected]") + qdel(guard) + qdel(person) + // Skill: clothing and mask fills at a quarter of the guard's plain rate, times 0.6 green, 1 yellow, 1.6 red. + var/list/scales = list(/datum/stealth_skill/green = 0.6, /datum/stealth_skill/yellow = 1, /datum/stealth_skill/red = 1.6) + var/last = 0 + for(var/skill_type in scales) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 2) + guard.stealth_skill = skill_type + var/mob/living/carbon/human/person = stealth_person(block, 12, 2) + stealth_scans(guard, 1) + var/plain = stealth_notice_of(guard, person) + qdel(guard) + guard = stealth_guard(block, 6, 2) + guard.stealth_skill = skill_type + stealth_dress(person, TRUE, TRUE, FALSE) + stealth_scans(guard, 1) + var/found = stealth_notice_of(guard, person) + TEST_ASSERT(plain > 0, "[skill_type]: a plain person 6 tiles in front wasn't noticed at all") + TEST_ASSERT(abs(found - plain * 0.25 * scales[skill_type]) < 0.001, "[skill_type]: clothing and mask gave [found] notice against [plain] plain") + TEST_ASSERT(found > last, "[skill_type] is fooled no less than the skill below it") + last = found + qdel(guard) + qdel(person) + qdel(block) + +/// The whole set: one of their own at range, a greeting nearer, and a challenge only for lingering close. +/datum/unit_test/voidcrew_stealth_disguise_friend + +/datum/unit_test/voidcrew_stealth_disguise_friend/Run() + var/datum/turf_reservation/block = stealth_block(20, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 12, 2) + stealth_dress(person) + stealth_scans(guard, 30) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard grew suspicious of someone in the whole set 6 tiles off") + TEST_ASSERT_EQUAL(stealth_notice_of(guard, person), 0, "Someone in the whole set 6 tiles off gained notice") + TEST_ASSERT(guard.npc_last_bark != "stealth_greet" && guard.npc_last_bark != "stealth_smoke", "A guard greeted someone 6 tiles off") + // Three tiles off: inside its near range, outside its challenge range. A word, and a slow fill. + person.forceMove(stealth_at(block, 9, 2)) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard did more than greet someone in the whole set 3 tiles off") + TEST_ASSERT(guard.npc_last_bark == "stealth_greet" || guard.npc_last_bark == "stealth_smoke", "A guard had no word for one of its own 3 tiles off") + var/found = stealth_notice_of(guard, person) + TEST_ASSERT(abs(found - 0.1125) < 0.001, "One look at the whole set 3 tiles off gave [found] notice, not 0.1125") + TEST_ASSERT_NULL(stealth_ai.challenge, "A guard stopped someone in the whole set 3 tiles off on its first look") + // They stay: in the end it stops them. + stealth_scans(guard, 30) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "suspicious", "A guard never stopped someone in the whole set who stood 3 tiles in front of it") + TEST_ASSERT_EQUAL(stealth_ai.challenge?.resolve(), person, "The suspicious guard hasn't stopped the one who lingered") + TEST_ASSERT_NULL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], "A guard took a target in a disguise that held") + qdel(block) + +/// Up close with the pass: stopped, checked for 2 s, waved on, and then left alone by that guard. +/datum/unit_test/voidcrew_stealth_disguise_pass + +/datum/unit_test/voidcrew_stealth_disguise_pass/Run() + var/datum/turf_reservation/block = stealth_block(20, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 8, 2) + stealth_dress(person) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "suspicious", "A guard didn't stop someone in the whole set 2 tiles in front of it") + TEST_ASSERT_EQUAL(stealth_ai.challenge?.resolve(), person, "The guard hasn't stopped the person in front of it") + TEST_ASSERT_EQUAL(guard.npc_last_bark, "stealth_challenge", "The guard stopped them without a word") + TEST_ASSERT_NULL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], "Stopping someone gave the guard a target") + stealth_scans(guard, 1) + TEST_ASSERT(stealth_ai.checked_at, "The guard isn't reading the pass of someone 2 tiles off") + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "suspicious", "The guard was done with the pass in no time") + stealth_ai.stealth_rewind(2 SECONDS) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard that read a good pass for 2 s didn't let them go") + TEST_ASSERT_EQUAL(guard.npc_last_bark, "stealth_id_pass", "The guard let them go without a word") + TEST_ASSERT(stealth_ai.passes[REF(person)] > world.time, "The guard doesn't remember the pass it read") + stealth_scans(guard, 10) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard stopped someone again right after reading their pass") + TEST_ASSERT_EQUAL(stealth_notice_of(guard, person), 0, "Someone it has passed gained notice") + // The pass comes off: the guard's leave goes with it. + TEST_ASSERT(person.dropItemToGround(person.wear_id), "The pass wouldn't come off") + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.challenge?.resolve(), person, "With the pass gone the guard didn't stop them again") + qdel(block) + +/// No pass: asked again at 3 s, blown at 6 s. Walking off or running is blown at once. A pass put on in time passes. +/datum/unit_test/voidcrew_stealth_disguise_fail + +/datum/unit_test/voidcrew_stealth_disguise_fail/Run() + var/datum/turf_reservation/block = stealth_block(20, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + for(var/how in list("waits", "walks off", "runs", "shows a pass")) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 8, 2) + stealth_dress(person, TRUE, TRUE, FALSE) + stealth_scans(guard, 2) + TEST_ASSERT_EQUAL(stealth_ai.challenge?.resolve(), person, "[how]: a guard didn't stop someone in clothing and mask 2 tiles in front of it") + TEST_ASSERT(stealth_ai.checked_at, "[how]: the guard isn't waiting for a pass") + switch(how) + if("waits") + stealth_ai.stealth_rewind(3 SECONDS) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "suspicious", "The guard was past asking after 3 s") + TEST_ASSERT(stealth_ai.warned, "The guard didn't ask a second time after 3 s") + TEST_ASSERT_EQUAL(guard.npc_last_bark, "stealth_id_fail", "The guard asked a second time without a word") + stealth_ai.stealth_rewind(3 SECONDS) + stealth_scans(guard, 1) + if("walks off") + person.forceMove(stealth_at(block, 11, 2)) + stealth_scans(guard, 1) + if("runs") + person.toggle_move_intent() + person.forceMove(stealth_at(block, 9, 2)) + stealth_scans(guard, 1) + if("shows a pass") + stealth_dress(person, FALSE, FALSE, TRUE) + stealth_ai.stealth_rewind(2 SECONDS) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A pass put on while the guard waited didn't pass") + qdel(guard) + qdel(person) + continue + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "[how]: the guard didn't go for someone with no pass") + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], person, "[how]: the alert guard has no target") + TEST_ASSERT(stealth_ai.made[REF(person)] > world.time, "[how]: the guard doesn't remember who it saw through") + TEST_ASSERT(!stealth_ai.stealth_fooled(person), "[how]: the disguise still holds for the guard that blew it") + qdel(guard) + qdel(person) + qdel(block) + +/// What a guard sees that no guard of the den would do: a weapon in hand, a fallen guard pulled along, an off-limits room. +/datum/unit_test/voidcrew_stealth_disguise_breakers + +/datum/unit_test/voidcrew_stealth_disguise_breakers/Run() + var/datum/turf_reservation/block = stealth_block(20, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + // what they hold => whether it blows the whole set at 6 tiles + var/list/cases = list( + /obj/item/gun/ballistic/automatic/pistol = TRUE, + /obj/item/knife/combat/matte = TRUE, + /obj/item/melee/baton/security = TRUE, + /obj/item/storage/toolbox/mechanical = FALSE, + /obj/item/flashlight/seclite = FALSE, + ) + for(var/item_type in cases) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 12, 2) + stealth_dress(person) + stealth_scans(guard, 2) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "[item_type]: empty-handed in the whole set wasn't one of their own") + person.put_in_hands(new item_type(person)) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), cases[item_type] ? "alert" : "unaware", "[item_type] in hand at 6 tiles left the guard [stealth_ai.stealth_state()]") + qdel(guard) + qdel(person) + // Off limits: the pass excuses it, unless the mark says nobody. + for(var/how in list("no pass", "pass", "pass, nobody allowed")) + var/obj/effect/landmark/stealth_restricted/mark = new(stealth_at(block, 12, 2)) + mark.reach = 1 + mark.allowed = how != "pass, nobody allowed" + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 12, 2) + stealth_dress(person, TRUE, TRUE, how != "no pass") + stealth_scans(guard, 2) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), how == "pass" ? "unaware" : "alert", "Off limits, [how]: the guard is [stealth_ai.stealth_state()]") + // Outside the room the same disguise is nothing to look at. + if(how == "no pass") + TEST_ASSERT_NULL(stealth_ai.group.off_limits()[stealth_at(block, 15, 2)], "A mark with a reach of 1 took in a tile 3 off") + qdel(guard) + qdel(person) + qdel(mark) + // Pulling a fallen guard (its look for bodies is held off, so this is the pulling alone). + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + stealth_ai.stealth_setup() + var/mob/living/carbon/human/npc/victim = stealth_guard(block, 12, 3) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = stealth_ai(victim) + guard_ai.stealth_setup() + victim.death() + var/mob/living/carbon/human/person = stealth_person(block, 12, 2) + stealth_dress(person) + person.start_pulling(victim) + TEST_ASSERT_EQUAL(person.pulling, victim, "The body wouldn't be pulled") + stealth_ai.next_body_scan = world.time + 1 MINUTES + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard watched one of its own being dragged off by someone in the whole set") + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], person, "The guard isn't after whoever drags the body") + qdel(guard) + qdel(victim) + qdel(person) + qdel(block) + +/// Standing over a body as it is found, and laying hands on a guard in another's sight. +/datum/unit_test/voidcrew_stealth_disguise_seen + +/datum/unit_test/voidcrew_stealth_disguise_seen/Run() + var/datum/turf_reservation/block = stealth_block(20, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + // A fresh body with them beside it. + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + stealth_ai.stealth_setup() + var/mob/living/carbon/human/npc/victim = stealth_guard(block, 12, 3) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = stealth_ai(victim) + guard_ai.stealth_setup() + TEST_ASSERT_EQUAL(guard_ai.group, stealth_ai.group, "The two guards aren't one group") + var/mob/living/carbon/human/person = stealth_person(block, 12, 2) + stealth_dress(person) + stealth_scans(guard, 2) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "Standing by a living guard in the whole set drew a look") + victim.death() + // Its look for fallen friends comes round again. + stealth_ai.next_body_scan = 0 + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard found a body with someone in the whole set standing over it and let them be") + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], person, "The guard isn't after whoever stood over the body") + qdel(guard) + qdel(victim) + // Hands on a guard: the one touched turns on them, and so does the one that sees it; one that doesn't see it is still fooled. + guard = stealth_guard(block, 6, 2) + stealth_ai = stealth_ai(guard) + stealth_ai.stealth_setup() + victim = stealth_guard(block, 11, 2) + guard_ai = stealth_ai(victim) + guard_ai.stealth_setup() + var/mob/living/carbon/human/npc/other = stealth_guard(block, 2, 2, WEST) + var/datum/ai_controller/basic_controller/human_npc/stealth/friend_ai = stealth_ai(other) + friend_ai.stealth_setup() + person.forceMove(stealth_at(block, 10, 2)) + TEST_ASSERT(stealth_ai.stealth_fooled(person), "The watching guard already sees through them") + guard_ai.stealth_touched(person) + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "alert", "A guard touched from behind by someone in the whole set didn't turn on them") + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard watched one of its own being grabbed and did nothing") + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], person, "The watching guard isn't after the one it saw") + TEST_ASSERT_EQUAL(friend_ai.stealth_state(), "unaware", "A guard with its back to it all reacted") + // Word reaches the third guard only once an alarm has made it wary. + TEST_ASSERT(friend_ai.stealth_fooled(person), "A guard nobody has told sees through them") + friend_ai.stealth_set_wary() + TEST_ASSERT(!friend_ai.stealth_fooled(person), "A guard the alarm reached is still fooled") + qdel(block) + +/// Running in a guard's earshot ends it for that guard; a face it went alert on is known unless a mask hides it. +/datum/unit_test/voidcrew_stealth_disguise_known + +/datum/unit_test/voidcrew_stealth_disguise_known/Run() + var/datum/turf_reservation/block = stealth_block(20, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + // Running three tiles behind it. + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 2, WEST) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 10, 2) + stealth_dress(person) + stealth_scans(guard, 1) + person.forceMove(stealth_at(block, 9, 2)) + stealth_scans(guard, 1) + TEST_ASSERT(stealth_ai.stealth_fooled(person), "Walking behind a guard in the whole set gave them away") + person.toggle_move_intent() + person.forceMove(stealth_at(block, 8, 2)) + stealth_scans(guard, 1) + TEST_ASSERT(!stealth_ai.stealth_fooled(person), "Running three tiles behind a guard didn't give them away") + TEST_ASSERT(!length(stealth_ai.group.made), "Running in one guard's earshot told its whole group") + qdel(guard) + qdel(person) + // A face it has gone alert on. + guard = stealth_guard(block, 6, 2) + stealth_ai = stealth_ai(guard) + person = stealth_person(block, 12, 2) + stealth_ai.stealth_go_alert(person) + stealth_ai.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + stealth_ai.stealth_go_unaware() + stealth_ai.stealth_clear_wary() + stealth_dress(person, TRUE, FALSE, TRUE) + TEST_ASSERT(!stealth_ai.stealth_fooled(person), "A guard didn't know the bare face it had fought") + stealth_scans(guard, 1) + TEST_ASSERT(abs(stealth_notice_of(guard, person) - 0.375) < 0.001, "A known face in the fatigues was still noticed slowly") + stealth_dress(person, FALSE, TRUE, FALSE) + TEST_ASSERT(stealth_ai.stealth_fooled(person), "A mask didn't hide a face the guard knew") + // A disguise it saw through stays seen through, mask or no mask. + stealth_ai.stealth_blow(person) + TEST_ASSERT(!stealth_ai.stealth_fooled(person), "A guard that saw through a masked disguise is fooled by it again") + qdel(guard) + qdel(person) + // Someone it fought masked left no face behind: the disguise holds. + guard = stealth_guard(block, 6, 2) + stealth_ai = stealth_ai(guard) + person = stealth_person(block, 12, 2) + stealth_dress(person, FALSE, TRUE, FALSE) + stealth_ai.stealth_go_alert(person) + stealth_ai.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + stealth_ai.stealth_go_unaware() + stealth_ai.stealth_clear_wary() + stealth_dress(person, TRUE, FALSE, TRUE) + TEST_ASSERT(stealth_ai.stealth_fooled(person), "A guard knew someone it had only ever seen masked") + qdel(block) + +/// The pass, the fatigues and the balaclava come off a guard like anyone's; the rest of its kit stays locked. The pass opens scav doors. +/datum/unit_test/voidcrew_stealth_disguise_loot + +/datum/unit_test/voidcrew_stealth_disguise_loot/Run() + var/datum/turf_reservation/block = stealth_block(5, 3) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 1, 1) + var/mob/living/carbon/human/person = stealth_person(block, 3, 1) + var/obj/item/card/id/card = guard.wear_id + TEST_ASSERT(istype(card, /obj/item/card/id/advanced/black/scav), "A scav guard wears no scav pass") + TEST_ASSERT(("scav" in card.GetAccess()), "The scav pass carries no scav access") + TEST_ASSERT_EQUAL(card.registered_name, guard.real_name, "The pass isn't in the guard's name") + var/obj/item/uniform = guard.w_uniform + TEST_ASSERT(istype(uniform, /obj/item/clothing/under/syndicate/scav), "A scav guard doesn't wear the scav fatigues") + for(var/obj/item/loot as anything in list(card, uniform)) + TEST_ASSERT(!human_npc_gear_locked(loot), "[loot] is locked gear") + TEST_ASSERT(!HAS_TRAIT(loot, TRAIT_NO_STRIP), "[loot] can't be stripped") + TEST_ASSERT(human_npc_gear_locked(guard.shoes), "The guard's boots are loot too") + var/obj/item/mask = new /obj/item/clothing/mask/balaclava/scav(guard) + TEST_ASSERT(!guard.npc_lock_item(mask), "A scav balaclava was locked to the guard") + qdel(mask) + // A door that takes scav access. + var/obj/machinery/door/airlock/door = allocate(/obj/machinery/door/airlock, stealth_at(block, 4, 0)) + door.req_one_access = list("armory", "scav") + TEST_ASSERT(door.check_access(card), "A door set to scav access refuses the scav pass") + // Taken off the guard and worn. + TEST_ASSERT(guard.dropItemToGround(card), "The pass can't be taken off the guard") + TEST_ASSERT(guard.dropItemToGround(uniform), "The fatigues can't be taken off the guard") + TEST_ASSERT(person.equip_to_slot_if_possible(uniform, ITEM_SLOT_ICLOTHING), "The looted fatigues can't be worn") + TEST_ASSERT(person.equip_to_slot_if_possible(card, ITEM_SLOT_ID), "The looted pass can't be worn") + sleep(2) + TEST_ASSERT(!QDELETED(card) && !QDELETED(uniform), "The looted pass or fatigues were deleted") + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 6, "The guard's own fatigues and pass aren't clothing and ID on someone else") + qdel(block) + +/// The real AI: stopped at a distance in the fatigues and a pass, the guard walks up, reads it and goes back to its post. +/datum/unit_test/voidcrew_stealth_live/disguise_pass + +/datum/unit_test/voidcrew_stealth_live/disguise_pass/Run() + TEST_ASSERT(make_room(14, 5), "No room for the test") + var/mob/living/carbon/human/npc/guard = guard_at(1, 2) + var/mob/living/carbon/human/person = person_at(6, 2) + stealth_dress(person, TRUE, FALSE, TRUE) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = wake(guard) + var/turf/post = at(1, 2) + var/stopped = FALSE + var/deadline = world.time + 30 SECONDS + while(world.time < deadline && !(stealth_ai.passes?[REF(person)])) + if(stealth_ai.challenge?.resolve() == person) + stopped = TRUE + sleep(2) + TEST_ASSERT(stopped, "A guard never stopped someone in the fatigues 5 tiles in front of it") + TEST_ASSERT(stealth_ai.passes?[REF(person)], "The guard never let someone with a pass go (state [stealth_ai.stealth_state()], [get_dist(guard, person)] tiles off)") + TEST_ASSERT_NULL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], "The guard took a target during the check") + TEST_ASSERT(get_dist(guard, person) <= 2, "The guard read a pass from [get_dist(guard, person)] tiles off") + deadline = world.time + 30 SECONDS + while(world.time < deadline && get_turf(guard) != post) + sleep(2) + TEST_ASSERT_EQUAL(get_turf(guard), post, "The guard didn't go back to its post after the check") + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "The guard isn't calm after a good pass") + +/// The real AI: stopped with no pass, they stand there; the guard asks again and then goes for them. +/datum/unit_test/voidcrew_stealth_live/disguise_fail + +/datum/unit_test/voidcrew_stealth_live/disguise_fail/Run() + TEST_ASSERT(make_room(14, 5), "No room for the test") + var/mob/living/carbon/human/npc/guard = guard_at(1, 2) + var/mob/living/carbon/human/person = person_at(4, 2) + stealth_dress(person, TRUE, TRUE, FALSE) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = wake(guard) + var/stopped = FALSE + var/start_time = world.time + var/deadline = world.time + 30 SECONDS + while(world.time < deadline && stealth_ai.stealth_state() != "alert") + if(stealth_ai.challenge?.resolve() == person) + stopped = TRUE + sleep(2) + TEST_ASSERT(stopped, "A guard never stopped someone in clothing and mask 3 tiles in front of it") + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard never went for someone who showed no pass") + TEST_ASSERT(world.time - start_time >= 5 SECONDS, "The guard gave someone with no pass only [(world.time - start_time) / 10] s") + TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], person, "The alert guard isn't after them") From 890e7b7e9a29986f75bd95b865fd2bba6aa3390c Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Wed, 11 Nov 2026 14:34:33 -0800 Subject: [PATCH 30/78] Add a temporary Stealth: Test Planet admin verb: picks a zone, builds a jungle planet there, clears the ground and loads the stealth test room, and drops the admin outside in a mortal playtest kit --- tgstation.dme | 1 + .../modules/stealth/stealth_test_planet.dm | 322 ++++++++++++++++++ 2 files changed, 323 insertions(+) create mode 100644 voidcrew/modules/stealth/stealth_test_planet.dm diff --git a/tgstation.dme b/tgstation.dme index eb1f4a65e84..815bf4ac9e5 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7746,6 +7746,7 @@ #include "voidcrew\modules\stealth\stealth_perception.dm" #include "voidcrew\modules\stealth\stealth_radio.dm" #include "voidcrew\modules\stealth\stealth_skill.dm" +#include "voidcrew\modules\stealth\stealth_test_planet.dm" #include "voidcrew\modules\stealth\stealth_test_ruin.dm" #include "voidcrew\modules\stealth\stealth_turns.dm" #include "voidcrew\modules\storage\smart_locker.dm" diff --git a/voidcrew/modules/stealth/stealth_test_planet.dm b/voidcrew/modules/stealth/stealth_test_planet.dm new file mode 100644 index 00000000000..e2df78122d5 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_test_planet.dm @@ -0,0 +1,322 @@ +/** + * TEMPORARY PLAYTEST TOOL for the stealth branch (feature/stealth). Remove before merge, with the stealth test ruin. + * + * "Stealth: Test Planet" (Debug) builds a fresh jungle planet through the normal overmap path and worldgen + * queue, loads the stealth test room on it at a cleared spot, then dresses the admin in a mortal body with + * the baseline stealth kit and drops them in the jungle south of the front airlock. + */ + +/// Cleared ground around the ruin, so the jungle ring, the front door and the back hatch can be reached +#define STEALTH_TEST_MARGIN 3 +/// No ground fauna may spawn this close to the ruin +#define STEALTH_TEST_FAUNA_CLEARANCE 10 +/// The ruin and its cleared margin stay at least this far from the planet's edge +#define STEALTH_TEST_EDGE 5 +/// Structure spawners (nests, tendrils) are removed this close to the ruin +#define STEALTH_TEST_SPAWNER_CLEARANCE 20 +/// How long the planet may take to come up, queue wait included +#define STEALTH_TEST_PLANET_TIMEOUT (8 MINUTES) +/// How long to wait for the guards to spawn before choosing the arrival spot +#define STEALTH_TEST_GUARD_WAIT (20 SECONDS) +/// The front airlock in map-local coordinates (1-based) +#define STEALTH_TEST_DOOR_X 22 +#define STEALTH_TEST_DOOR_Y 3 + +ADMIN_VERB(stealth_test_planet, R_ADMIN|R_DEBUG, "Stealth: Test Planet", "TEMPORARY: build a jungle planet with the stealth test room and drop you outside it in the stealth playtest kit.", ADMIN_CATEGORY_DEBUG) + // The planet's overmap zone sets how sharp the guards are (green, yellow or red skill profile). + var/static/list/zone_choices = list("Green" = ZONE_GREEN, "Yellow" = ZONE_YELLOW, "Red" = ZONE_RED) + var/zone_name = tgui_input_list(user, "Which zone should the planet be in? Guards are sharper in harder zones.", "Stealth: Test Planet", zone_choices, "Yellow") + if(isnull(zone_name) || isnull(zone_choices[zone_name])) + return + message_admins("[key_name_admin(user)] is building a stealth test planet in the [zone_name] zone.") + log_admin("[key_name(user)] is building a stealth test planet in the [zone_name] zone.") + BLACKBOX_LOG_ADMIN_VERB("Stealth Test Planet") + INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(stealth_test_planet_for_client), user, zone_choices[zone_name]) + +/// Builds the site in `zone`, then gives `user` a mortal body there. +/proc/stealth_test_planet_for_client(client/user, zone = ZONE_YELLOW) + var/turf/arrival = stealth_test_planet_build(user, zone) + if(isnull(arrival) || QDELETED(user)) + return + var/mob/living/carbon/human/body = stealth_test_planet_body(user, arrival) + if(isnull(body)) + to_chat(user, span_warning("Stealth test: could not make you a body.")) + return + to_chat(user, span_notice("Stealth test: you are on [get_area_name(arrival, TRUE)], in the jungle south of the compound's front door. The compound's light switch is inside the east room.")) + message_admins("[key_name_admin(user)] arrived at the stealth test planet [ADMIN_VERBOSEJMP(arrival)].") + +/** + * Spawns a jungle planet on the overmap, builds it through load_level() (which queues on the worldgen + * queue), and loads the stealth test room on a clear spot. Returns the arrival turf, or null. + * `feedback` is told how it is going; it may be null (tests). + */ +/proc/stealth_test_planet_build(client/feedback, zone = ZONE_YELLOW) + var/mob/feedback_mob = feedback?.mob + var/datum/map_template/ruin/template + for(var/name in SSmapping.ruins_templates) + var/datum/map_template/ruin/candidate = SSmapping.ruins_templates[name] + if(istype(candidate, /datum/map_template/ruin/jungle/stealth_test)) + template = candidate + break + if(isnull(template) || !template.width || !template.height) + stealth_test_say(feedback, "the stealth test ruin template is missing.", TRUE) + return null + + // strict_band: the guards read the zone from the planet's overmap square, so it must really be in that band. + var/obj/structure/overmap/planet/planet = SSovermap.spawn_dynamic_planet(/obj/structure/overmap/planet/jungle, 1, zone, strict_band = TRUE) + if(isnull(planet)) + stealth_test_say(feedback, "no free overmap square for a planet in that zone.", TRUE) + return null + // Kept until an admin unloads it, so a test run is not torn down while the tester walks around. + planet.preserve_level = TRUE + var/started = world.time + stealth_test_say(feedback, "building [planet.name] at overmap ([planet.x], [planet.y]), [list("green", "yellow", "red")[clamp(SSovermap_zones.get_zone_type_anywhere(get_turf(planet)) || ZONE_GREEN, ZONE_GREEN, ZONE_RED)]] zone. This takes about a minute.") + INVOKE_ASYNC(planet, TYPE_PROC_REF(/obj/structure/overmap/planet, load_level), feedback_mob, 5 MINUTES) + var/next_note = world.time + 30 SECONDS + while(!planet.loaded) + if(QDELETED(planet) || (!planet.loading && !planet.loaded)) + stealth_test_say(feedback, "the planet failed to build (see the mapping log).", TRUE) + return null + if(world.time > started + STEALTH_TEST_PLANET_TIMEOUT) + stealth_test_say(feedback, "gave up waiting for the planet after [DisplayTimeText(world.time - started)].", TRUE) + return null + if(world.time >= next_note) + next_note = world.time + 30 SECONDS + stealth_test_say(feedback, "still building ([DisplayTimeText(world.time - started)] so far).") + sleep(1 SECONDS) + var/datum/map_footprint/footprint = planet.footprint + var/z = footprint?.z_value + if(!z) + stealth_test_say(feedback, "the planet loaded without a footprint.", TRUE) + return null + stealth_test_say(feedback, "planet up in [DisplayTimeText(world.time - started)]. Loading the compound.") + + if(!SSovermap.worldgen_claim(planet, "stealth test room ([planet.name])", feedback_mob, 2 MINUTES)) + stealth_test_say(feedback, "the worldgen queue stayed busy; the planet is up but the compound was not loaded.", TRUE) + return null + var/datum/space_level/level = SSmapping.get_level(z) + var/turf/center = stealth_test_pick_site(planet, level, template) + if(isnull(center)) + SSovermap.worldgen_release(planet) + stealth_test_say(feedback, "found no clear spot for the compound on the planet.", TRUE) + return null + var/area/surface_area = get_area(center) + var/list/ruin_rect = stealth_test_ruin_rect(center, template) + stealth_test_clear_site(ruin_rect, z) + + // Loaded straight over the ground, the way try_to_place() loads a ruin once it has picked a spot. + planet_ruin_area_instancing_begin(z) + var/loaded = template.load(center, centered = TRUE) + planet_ruin_area_instancing_end(z) + if(!loaded) + SSovermap.worldgen_release(planet) + stealth_test_say(feedback, "the compound failed to load at [center.x],[center.y].", TRUE) + return null + template.loaded++ + for(var/turf/ruin_turf as anything in template.get_affected_turfs(center, TRUE)) + ruin_turf.turf_flags |= NO_RUINS + new /obj/effect/landmark/ruin(center, template) + planet.generate_ruin_terrain(level) + planet.light_ruin_terrain(level, surface_area) + footprint.add_planetary_faction_to_existing_mobs() + stealth_test_prune_fauna(planet, ruin_rect) + SSovermap.worldgen_release(planet) + + // The guards come through the human NPC spawn queue a moment after the load. + var/list/door = stealth_test_door_coords(center, template) + var/turf/door_turf = locate(door[1], door[2], z) + var/guard_deadline = world.time + STEALTH_TEST_GUARD_WAIT + var/list/guards = stealth_test_guards_near(door_turf) + while(length(guards) < 5 && world.time < guard_deadline) + sleep(1 SECONDS) + guards = stealth_test_guards_near(door_turf) + + var/turf/arrival + for(var/south in list(5, 4, 6)) + for(var/east in list(0, -1, 1, -2, 2)) + var/turf/spot = locate(door[1] + east, door[2] - south, z) + if(isnull(spot) || spot.is_blocked_turf(exclude_mobs = FALSE) || stealth_test_watched(spot, guards)) + continue + arrival = spot + break + if(arrival) + break + if(isnull(arrival)) + arrival = locate(door[1], door[2] - 5, z) + log_admin("Stealth test planet '[planet.name]' built: compound at [center.x],[center.y],[z], [length(guards)] guards, [DisplayTimeText(world.time - started)].") + return arrival + +/proc/stealth_test_say(client/feedback, text, failed = FALSE) + if(feedback) + to_chat(feedback, failed ? span_warning("Stealth test: [text]") : span_notice("Stealth test: [text]")) + if(failed) + log_admin("Stealth test planet: [text]") + +/// list(low_x, low_y, high_x, high_y) of the ruin when loaded centred on `center` +/proc/stealth_test_ruin_rect(turf/center, datum/map_template/template) + var/low_x = center.x - round(template.width / 2) + var/low_y = center.y - round(template.height / 2) + return list(low_x, low_y, low_x + template.width - 1, low_y + template.height - 1) + +/// World x,y of the front airlock when the ruin is loaded centred on `center` +/proc/stealth_test_door_coords(turf/center, datum/map_template/template) + var/list/rect = stealth_test_ruin_rect(center, template) + return list(rect[1] + STEALTH_TEST_DOOR_X - 1, rect[2] + STEALTH_TEST_DOOR_Y - 1) + +/proc/stealth_test_block(list/rect, pad, z) + return block(rect[1] - pad, rect[2] - pad, z, rect[3] + pad, rect[4] + pad, z) + +/** + * The ruin's centre turf: the middle of the planet, moved up clear of the dock strip if needed, and kept far + * enough in that the ruin and its cleared margin sit at least STEALTH_TEST_EDGE tiles from the planet's edge. + * The load overwrites whatever is there. + */ +/proc/stealth_test_pick_site(obj/structure/overmap/planet/planet, datum/space_level/level, datum/map_template/template) + var/list/bounds = planet.get_terrain_bounds(level) + if(length(bounds) < 4) + return null + var/rect_pad = STEALTH_TEST_MARGIN + STEALTH_TEST_EDGE + var/half_w = round(template.width / 2) + var/half_h = round(template.height / 2) + var/min_x = bounds[1] + rect_pad + half_w + var/max_x = bounds[3] - rect_pad - (template.width - half_w - 1) + var/min_y = bounds[2] + rect_pad + half_h + var/max_y = bounds[4] - rect_pad - (template.height - half_h - 1) + if(min_x > max_x || min_y > max_y) + return null + var/center_x = round((bounds[1] + bounds[3]) / 2) + var/center_y = max(round((bounds[2] + bounds[4]) / 2), planet.get_dock_strip_top_y(level) + 1 + STEALTH_TEST_FAUNA_CLEARANCE + half_h) + return locate(clamp(center_x, min_x, max_x), clamp(center_y, min_y, max_y), level.z_value) + +/// Clears the ruin's block plus the margin to open jungle ground, and fauna and nests further out. +/proc/stealth_test_clear_site(list/rect, z) + for(var/turf/tile as anything in stealth_test_block(rect, STEALTH_TEST_SPAWNER_CLEARANCE, z)) + for(var/atom/movable/thing as anything in tile) + if(thing.GetComponent(/datum/component/spawner) || istype(thing, /obj/structure/spawner)) + qdel(thing) + CHECK_TICK + for(var/turf/tile as anything in stealth_test_block(rect, STEALTH_TEST_FAUNA_CLEARANCE, z)) + for(var/mob/living/critter in tile) + if(!critter.key && !critter.client) + qdel(critter) + CHECK_TICK + // Under the compound and its margin, everything goes but the ground itself: items, structures, machines, + // flora, NPCs and anything a seeded ruin left there. Non-ground turfs (another ruin's walls or floors) + // become jungle grass. Players and abstract effects stay. + for(var/turf/tile as anything in stealth_test_block(rect, STEALTH_TEST_MARGIN, z)) + for(var/atom/movable/thing as anything in tile) + if(ismob(thing)) + var/mob/occupant = thing + if(occupant.key || occupant.client) + continue + else if(!isobj(thing) || istype(thing, /obj/effect/abstract)) + continue + qdel(thing) + if(!istype(tile, /turf/open/misc/grass) && !istype(tile, /turf/open/misc/dirt)) + tile.ChangeTurf(/turf/open/misc/grass/jungle) + CHECK_TICK + +/// Drops this planet's deferred fauna spawn points near the ruin. +/proc/stealth_test_prune_fauna(obj/structure/overmap/planet/planet, list/rect) + var/datum/planet_mob_tracker/tracker = SSplanet_mobs.tracked_planets[planet.planet_key] + if(isnull(tracker)) + return + var/pad = STEALTH_TEST_FAUNA_CLEARANCE + for(var/turf/tile as anything in tracker.surface_spawn_turfs.Copy()) + if(tile.x >= rect[1] - pad && tile.x <= rect[3] + pad && tile.y >= rect[2] - pad && tile.y <= rect[4] + pad) + tracker.surface_spawn_turfs -= tile + +/// Stealth guards near the front door +/proc/stealth_test_guards_near(turf/door_turf) + . = list() + if(isnull(door_turf)) + return + for(var/mob/living/guard as anything in stealth_guards_on_level(door_turf.z)) + if(get_dist(guard, door_turf) <= 30) + . += guard + +/// Whether any of `guards` has `spot` in its sight cone right now +/proc/stealth_test_watched(turf/spot, list/guards) + for(var/mob/living/guard as anything in guards) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = guard.ai_controller + if(!istype(stealth_ai) || !stealth_ai.stealth_eyes_open()) + continue + var/datum/stealth_skill/profile = stealth_ai.stealth_skill() + var/turf/eye = get_turf(guard) + if(get_dist(eye, spot) > profile.sight_range) + continue + if(stealth_in_cone(guard, spot, stealth_ai.stealth_half_angle()) && can_see(eye, spot, profile.sight_range)) + return TRUE + return FALSE + +/** + * Gives `user` a mortal human body at `arrival` in the playtest kit. A living human is re-dressed and healed; + * a ghost, a lobby player or any other mob gets a new body from their character preferences. + */ +/proc/stealth_test_planet_body(client/user, turf/arrival) + var/mob/living/carbon/human/body = user.mob + if(ishuman(body) && body.stat != DEAD) + body.delete_equipment() + body.revive(ADMIN_HEAL_ALL) + body.forceMove(arrival) + else + body = new /mob/living/carbon/human(arrival) + user.prefs.safe_transfer_prefs_to(body, is_antag = TRUE) + body.PossessByPlayer(user.key) + stealth_test_dress(body) + return body + +/// Mortal and dressed in the playtest kit +/proc/stealth_test_dress(mob/living/carbon/human/body) + // Guards ignore godmode targets, so the tester must be mortal. + REMOVE_TRAIT(body, TRAIT_GODMODE, null) + body.equipOutfit(/datum/outfit/stealth_playtest) + +/// The stealth baseline: no night vision, no armour, no cloak. +/datum/outfit/stealth_playtest + name = "Stealth Playtest" + uniform = /obj/item/clothing/under/syndicate/camo + shoes = /obj/item/clothing/shoes/jackboots + gloves = /obj/item/clothing/gloves/fingerless + ears = /obj/item/radio/headset + id = /obj/item/card/id/advanced + id_trim = /datum/id_trim/admin + back = /obj/item/storage/backpack + backpack_contents = list( + /obj/item/gun/ballistic/automatic/pistol = 1, + /obj/item/ammo_box/magazine/m9mm = 3, + /obj/item/reagent_containers/cup/glass/bottle/beer = 3, + /obj/item/storage/medkit/regular = 1, + ) + belt = /obj/item/storage/belt/military + belt_contents = list( + /obj/item/grenade/empgrenade = 1, + /obj/item/grenade/flashbang = 1, + /obj/item/jammer = 1, + /obj/item/restraints/handcuffs/cable/zipties = 1, + /obj/item/weldingtool = 1, + /obj/item/crowbar = 1, + ) + l_pocket = /obj/item/knife/combat/matte + r_pocket = /obj/item/flashlight + +/datum/outfit/stealth_playtest/post_equip(mob/living/carbon/human/user, visuals_only = FALSE) + if(visuals_only) + return + var/obj/item/gun/ballistic/automatic/pistol/pistol = locate() in user.back + if(pistol && !pistol.suppressed) + var/obj/item/suppressor/suppressor = new(pistol) + pistol.install_suppressor(suppressor) + var/obj/item/card/id/card = user.wear_id + if(istype(card)) + card.registered_name = user.real_name + card.update_label() + +#undef STEALTH_TEST_MARGIN +#undef STEALTH_TEST_FAUNA_CLEARANCE +#undef STEALTH_TEST_SPAWNER_CLEARANCE +#undef STEALTH_TEST_EDGE +#undef STEALTH_TEST_PLANET_TIMEOUT +#undef STEALTH_TEST_GUARD_WAIT +#undef STEALTH_TEST_DOOR_X +#undef STEALTH_TEST_DOOR_Y From 0007e040b916988c42aed61efe5141b99b2c8e9e Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Wed, 11 Nov 2026 14:50:19 -0800 Subject: [PATCH 31/78] Add a hallway wing to the stealth test room: a one-tile corridor with a pingpong guard, alcoves and a locker, a cargo hall loop, and a two-tile ring around a storeroom, with guard paths painted on the floor (routes a and b too) --- .../JungleRuins/jungle_stealth_test.dmm | 2292 +++++++++++------ 1 file changed, 1566 insertions(+), 726 deletions(-) diff --git a/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm index ae70106f59e..749963517e4 100644 --- a/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm +++ b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_stealth_test.dmm @@ -1,18 +1,18 @@ //MAP CONVERTED BY dmm2tgm.py THIS HEADER COMMENT PREVENTS RECONVERSION, DO NOT REMOVE -"a" = ( +"aa" = ( /obj/effect/spawner/human_npc/ruin/scav/lookout{ dir = 8 }, /turf/open/floor/iron, /area/ruin/powered) -"b" = ( +"ab" = ( /obj/structure/table, /obj/item/reagent_containers/cup/glass/bottle/beer, /obj/item/reagent_containers/cup/glass/bottle/beer, /obj/item/reagent_containers/cup/glass/bottle/beer, /turf/open/floor/iron, /area/ruin/powered) -"c" = ( +"ac" = ( /obj/structure/table, /obj/item/storage/toolbox/mechanical, /obj/item/coin/iron, @@ -20,7 +20,7 @@ /obj/item/coin/iron, /turf/open/floor/iron, /area/ruin/powered) -"d" = ( +"ad" = ( /obj/structure/closet/crate, /obj/item/gun/ballistic/automatic/pistol, /obj/item/suppressor, @@ -33,100 +33,235 @@ /obj/item/grenade/empgrenade, /turf/open/floor/iron, /area/ruin/powered) -"e" = ( -/obj/machinery/door/airlock/security{ - name = "Strongroom"; - req_one_access = list("armory","scav") - }, -/turf/open/floor/iron, +"ag" = ( +/turf/open/floor/carpet, /area/ruin/powered) -"f" = ( +"ai" = ( +/turf/open/misc/grass/jungle, +/area/overmap_encounter/planet_ruin) +"aj" = ( +/obj/effect/turf_decal/tile/red/full, /obj/effect/landmark/stealth_patrol{ - route = "b"; + route = "e"; order = 3 }, -/turf/open/floor/plating, -/area/ruin/powered) -"g" = ( -/turf/open/floor/carpet, +/turf/open/floor/iron, /area/ruin/powered) -"h" = ( +"ak" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/spawner/human_npc/ruin/scav{ + dir = 4 + }, /obj/effect/landmark/stealth_patrol{ - route = "b"; + route = "c"; order = 1; route_mode = "pingpong" }, -/obj/effect/spawner/human_npc/ruin/scav{ - dir = 4 - }, -/turf/open/floor/plating, +/turf/open/floor/iron, /area/ruin/powered) -"i" = ( -/turf/open/misc/grass/jungle, -/area/overmap_encounter/planet_ruin) -"l" = ( +"al" = ( /obj/machinery/light/directional/north, /turf/open/floor/iron, /area/ruin/powered) -"o" = ( +"am" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/spawner/human_npc/ruin/scav{ + dir = 1 + }, /obj/effect/landmark/stealth_patrol{ - route = "b"; - order = 2 + route = "d"; + order = 1 }, -/turf/open/floor/plating, -/area/ruin/powered) -"p" = ( -/obj/effect/spawner/structure/window, /turf/open/floor/iron, /area/ruin/powered) -"q" = ( +"an" = ( +/obj/effect/turf_decal/tile/red/full, /obj/effect/landmark/stealth_patrol{ - route = "a"; - order = 3; - facing = 2 - }, -/obj/effect/spawner/human_npc/ruin/scav{ - dir = 2 + route = "e"; + order = 4; + wait = 0 }, /turf/open/floor/iron, /area/ruin/powered) -"s" = ( +"ap" = ( +/obj/effect/spawner/structure/window, +/turf/open/floor/iron, +/area/ruin/powered) +"ar" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/machinery/light/small/directional/north, +/turf/open/floor/iron, +/area/ruin/powered) +"as" = ( /obj/structure/closet/crate, /turf/open/floor/plating, /area/ruin/powered) -"t" = ( +"at" = ( /obj/machinery/door/airlock/public, /turf/open/floor/iron, /area/ruin/powered) -"v" = ( +"au" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/spawner/human_npc/ruin/scav/lookout{ + dir = 4 + }, /obj/effect/landmark/stealth_patrol{ - route = "a"; - order = 4; - facing = 4; - chatter = 1 + route = "e"; + order = 1 }, /turf/open/floor/iron, /area/ruin/powered) -"x" = ( +"aw" = ( +/obj/machinery/light/small/directional/south, /turf/open/floor/iron, /area/ruin/powered) -"y" = ( +"ax" = ( +/turf/open/floor/iron, +/area/ruin/powered) +"ay" = ( /obj/machinery/light/floor, /turf/open/floor/iron, /area/ruin/powered) -"z" = ( +"az" = ( /obj/structure/table, /turf/open/floor/iron, /area/ruin/powered) -"B" = ( +"aA" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "e"; + order = 2; + wait = 0 + }, +/turf/open/floor/iron, +/area/ruin/powered) +"aB" = ( /obj/structure/closet/crate/large, /turf/open/floor/plating, /area/ruin/powered) -"F" = ( +"aC" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "d"; + order = 3 + }, +/turf/open/floor/iron, +/area/ruin/powered) +"aD" = ( +/obj/structure/closet/crate/large, +/turf/open/floor/iron, +/area/ruin/powered) +"aE" = ( +/obj/effect/landmark/stealth_restricted, +/turf/open/floor/iron, +/area/ruin/powered) +"aF" = ( /obj/machinery/light_switch/directional/west, /turf/open/floor/iron, /area/ruin/powered) -"I" = ( +"aG" = ( +/obj/structure/closet/crate, +/obj/item/coin/gold, +/obj/item/coin/gold, +/obj/item/stack/spacecash/c200, +/turf/open/floor/iron, +/area/ruin/powered) +"aH" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "d"; + order = 4; + wait = 0 + }, +/turf/open/floor/iron, +/area/ruin/powered) +"aJ" = ( +/turf/closed/wall, +/area/ruin/powered) +"aK" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "d"; + order = 2; + wait = 0 + }, +/turf/open/floor/iron, +/area/ruin/powered) +"aL" = ( +/obj/machinery/light/small/directional/north, +/turf/open/floor/iron, +/area/ruin/powered) +"aM" = ( +/obj/machinery/door/airlock/maintenance, +/turf/open/floor/plating, +/area/ruin/powered) +"aN" = ( +/obj/structure/closet/crate, +/turf/open/floor/iron, +/area/ruin/powered) +"aO" = ( +/obj/structure/rack, +/turf/open/floor/iron, +/area/ruin/powered) +"aP" = ( +/turf/open/floor/plating, +/area/ruin/powered) +"aQ" = ( +/obj/effect/landmark/stealth_group, +/turf/open/floor/iron, +/area/ruin/powered) +"aR" = ( +/obj/effect/landmark/stealth_restricted{ + reach = 15 + }, +/turf/open/floor/plating, +/area/ruin/powered) +"aS" = ( +/obj/effect/turf_decal/tile/red/full, +/turf/open/floor/iron, +/area/ruin/powered) +"aU" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "c"; + order = 2 + }, +/turf/open/floor/iron, +/area/ruin/powered) +"aW" = ( +/obj/machinery/light/directional/south, +/turf/open/floor/iron, +/area/ruin/powered) +"aX" = ( +/obj/structure/closet, +/turf/open/floor/iron, +/area/ruin/powered) +"aY" = ( +/obj/machinery/light/small/directional/east, +/turf/open/floor/iron, +/area/ruin/powered) +"aZ" = ( +/obj/machinery/door/airlock/maintenance{ + name = "Storeroom" + }, +/turf/open/floor/iron, +/area/ruin/powered) +"bJ" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 2.5; + wait = 0 + }, +/turf/open/floor/iron, +/area/ruin/powered) +"ej" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/machinery/light/directional/north, +/turf/open/floor/iron, +/area/ruin/powered) +"eT" = ( +/obj/effect/turf_decal/tile/red/full, /obj/effect/landmark/stealth_patrol{ route = "a"; order = 2; @@ -137,27 +272,114 @@ }, /turf/open/floor/iron, /area/ruin/powered) -"J" = ( -/turf/closed/wall, +"jv" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 4.6; + wait = 0 + }, +/turf/open/floor/plating, /area/ruin/powered) -"M" = ( -/obj/machinery/door/airlock/maintenance, +"jI" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 4.7; + wait = 0 + }, /turf/open/floor/plating, /area/ruin/powered) -"P" = ( +"kR" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "b"; + order = 1.5; + wait = 0 + }, /turf/open/floor/plating, /area/ruin/powered) -"Q" = ( -/obj/effect/landmark/stealth_group, +"np" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 3.5; + wait = 0 + }, /turf/open/floor/iron, /area/ruin/powered) -"R" = ( -/obj/effect/landmark/stealth_restricted{ - reach = 15 +"ud" = ( +/obj/effect/turf_decal/tile/red/full, +/turf/open/floor/carpet, +/area/ruin/powered) +"uV" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "b"; + order = 1; + route_mode = "pingpong" + }, +/obj/effect/spawner/human_npc/ruin/scav{ + dir = 4 + }, +/turf/open/floor/plating, +/area/ruin/powered) +"xt" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 1.5; + wait = 0 + }, +/turf/open/floor/iron, +/area/ruin/powered) +"yR" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 4.5; + wait = 0 + }, +/turf/open/floor/iron, +/area/ruin/powered) +"HJ" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "b"; + order = 2 + }, +/turf/open/floor/plating, +/area/ruin/powered) +"MD" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "b"; + order = 3 }, /turf/open/floor/plating, /area/ruin/powered) -"V" = ( +"MO" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 3; + facing = 2 + }, +/obj/effect/spawner/human_npc/ruin/scav{ + dir = 2 + }, +/turf/open/floor/iron, +/area/ruin/powered) +"Og" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/machinery/door/airlock/security{ + name = "Strongroom"; + req_one_access = list("armory","scav") + }, +/turf/open/floor/iron, +/area/ruin/powered) +"OC" = ( +/obj/effect/turf_decal/tile/red/full, /obj/effect/landmark/stealth_patrol{ route = "a"; order = 1; @@ -168,728 +390,1346 @@ }, /turf/open/floor/iron, /area/ruin/powered) -"W" = ( -/obj/machinery/light/directional/south, +"Qo" = ( +/obj/effect/turf_decal/tile/red/full, +/turf/open/floor/plating, +/area/ruin/powered) +"SA" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 4.8; + wait = 0 + }, +/turf/open/floor/plating, +/area/ruin/powered) +"UV" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 4; + facing = 4; + chatter = 1 + }, +/turf/open/floor/iron, +/area/ruin/powered) +"WX" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 4.9; + wait = 0 + }, +/turf/open/floor/iron, +/area/ruin/powered) +"Zi" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/machinery/door/airlock/public, /turf/open/floor/iron, /area/ruin/powered) +"ZY" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "b"; + order = 2.5; + wait = 0 + }, +/turf/open/floor/plating, +/area/ruin/powered) (1,1,1) = {" -i -i -i -i -i -i -i -i -i -i -i -i -i -i -i -i -i -i -i -i -i -i +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai "} (2,1,1) = {" -i -J -J -J -J -J -J -J -J -J -J -J -J -J -J -J -J -J -J -J -i -i +ai +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +ai +ai "} (3,1,1) = {" -i -J -x -x -J -P -P -P -P -P -P -P -P -P -P -P -P -P -s -J -i -i +ai +aJ +ax +ax +aJ +aP +aP +aP +aP +aP +aP +aP +aP +aP +aP +aP +aP +aP +as +aJ +ai +ai "} (4,1,1) = {" -i -J -l -x -J -P -P -P -P -P -P -s -P -P -P -P -P -P -P -J -i -i +ai +aJ +al +ax +aJ +aP +aP +aP +aP +aP +aP +as +aP +aP +aP +aP +aP +aP +aP +aJ +ai +ai "} (5,1,1) = {" -i -J -x -V -J -P -P -h -P -P -P -P -P -P -P -P -P -P -P -J -i -i +ai +aJ +xt +OC +aJ +aP +aP +uV +Qo +Qo +kR +aP +aP +aP +aP +aP +aP +aP +aP +aJ +ai +ai "} (6,1,1) = {" -i -J -x -x -J -P -P -P -P -P -P -P -P -P -P -P -f -P -P -J -i -i +ai +aJ +aS +aS +aJ +aP +aP +aP +aP +aP +ZY +Qo +Qo +Qo +Qo +Qo +MD +aP +aP +aJ +ai +ai "} (7,1,1) = {" -i -J -x -x -J -P -P -P -P -P -P -P -P -P -P -P -P -P -P -J -i -i +ai +aJ +aS +aS +aJ +aP +aP +aP +aP +aP +Qo +aP +aP +aP +aP +aP +aP +aP +aP +aJ +ai +ai "} (8,1,1) = {" -i -J -x -x -t -P -P -P -P -P -P -R -B -P -P -P -P -P -P -J -i -i +ai +aJ +aS +WX +Zi +SA +aP +aP +aP +aP +Qo +aR +aB +aP +aP +aP +aP +aP +aP +aJ +ai +ai "} (9,1,1) = {" -i -J -x -x -J -P -P -P -P -P -P -P -B -P -P -P -P -P -P -J -i -i +ai +aJ +aS +ax +aJ +Qo +aP +aP +aP +aP +Qo +aP +aB +aP +aP +aP +aP +aP +aP +aJ +ai +ai "} (10,1,1) = {" -i -J -l -x -J -P -B -B -P -P -P -P -P -P -P -P -P -P -P -J -i -i +ai +aJ +ej +ax +aJ +Qo +aB +aB +aP +aP +Qo +aP +aP +aP +aP +aP +aP +aP +aP +aJ +ai +ai "} (11,1,1) = {" -i -J -g -g -J -P -P -P -P -P -P -P -P -P -P -P -P -P -P -J -i -i +ai +aJ +ud +ag +aJ +Qo +aP +aP +aP +aP +Qo +aP +aP +aP +aP +aP +aP +aP +aP +aJ +ai +ai "} (12,1,1) = {" -i -J -g -g -p -P -P -P -P -P -P -P -P -P -P -P -P -P -P -J -i -i +ai +aJ +ud +ag +ap +Qo +aP +aP +aP +aP +Qo +aP +aP +aP +aP +aP +aP +aP +aP +aJ +ai +ai "} (13,1,1) = {" -i -J -g -g -J -P -P -P -P -P -o -P -P -P -P -B -P -P -P -J -i -i +ai +aJ +ud +ag +aJ +Qo +aP +aP +aP +aP +HJ +aP +aP +aP +aP +aB +aP +aP +aP +aJ +ai +ai "} (14,1,1) = {" -i -J -x -x -J -P -P -P -P -P -P -P -P -P -P -s -P -P -P -M -i -i +ai +aJ +aS +ax +aJ +Qo +aP +aP +aP +aP +aP +aP +aP +aP +aP +as +aP +aP +aP +aM +ai +ai "} (15,1,1) = {" -i -J -x -x -J -P -P -P -P -P -P -P -P -P -P -P -P -P -B -J -i -i +ai +aJ +aS +ax +aJ +jI +Qo +Qo +Qo +jv +aP +aP +aP +aP +aP +aP +aP +aP +aB +aJ +ai +ai "} (16,1,1) = {" -i -J -l -x -J -J -J -J -J -e -J -J -J -J -J -J -J -J -J -J -i -i +ai +aJ +ej +ax +aJ +aJ +aJ +aJ +aJ +Og +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +ai +ai "} (17,1,1) = {" -i -J -P -P -J -x -x -x -x -x -Q -x -F -x -x -x -x -x -x -J -i -i +ai +aJ +Qo +aP +aJ +ax +ax +ax +ax +aS +aQ +ax +aF +ax +ax +ax +ax +ax +ax +aJ +ai +ai "} (18,1,1) = {" -i -J -P -P -J -l -x -x -x -x -x -x -x -x -x -x -x -x -W -J -i -i +ai +aJ +Qo +aP +aJ +al +ax +ax +ax +aS +ax +ax +ax +ax +ax +ax +ax +ax +aW +aJ +ai +ai "} (19,1,1) = {" -i -J -P -P -p -x -x -x -x -x -x -x -x -x -v -x -x -x -x -J -i -i +ai +aJ +Qo +aP +ap +ax +ax +np +aS +yR +aS +aS +aS +aS +UV +ax +ax +ax +ax +aJ +ai +ai "} (20,1,1) = {" -i -J -x -x -p -x -x -x -x -x -x -x -x -x -x -x -x -x -b -J -i -i +ai +aJ +aS +ax +ap +ax +ax +aS +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ab +aJ +ai +ai "} (21,1,1) = {" -i -J -x -x -p -x -x -x -x -x -x -x -x -x -x -x -x -x -c -J -i -i +ai +aJ +aS +ax +ap +ax +ax +aS +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ac +aJ +ai +ai "} (22,1,1) = {" -i -J -l -x -J -x -x -x -x -x -x -y -x -x -x -x -x -x -x -t -i -i +ai +aJ +ej +ax +aJ +ax +ax +aS +ax +ax +ax +ay +ax +ax +ax +ax +ax +ax +ax +at +ai +ai "} (23,1,1) = {" -i -J -x -x -J -x -x -x -x -x -x -x -a -x -x -x -x -x -x -J -i -i +ai +aJ +aS +ax +aJ +ax +ax +aS +ax +ax +ax +ax +aa +ax +ax +ax +ax +ax +ax +aJ +ai +ai "} (24,1,1) = {" -i -J -x -x -p -x -x -x -x -x -z -z -x -x -x -x -x -x -d -J -i -i +ai +aJ +aS +ax +ap +ax +ax +aS +ax +ax +az +az +ax +ax +ax +ax +ax +ax +ad +aJ +ai +ai "} (25,1,1) = {" -i -J -x -x -p -x -x -x -x -x -z -z -x -x -x -x -x -x -x -J -i -i +ai +aJ +aS +ax +ap +ax +ax +aS +ax +ax +az +az +ax +ax +ax +ax +ax +ax +ax +aJ +ai +ai "} (26,1,1) = {" -i -J -I -x -p -x -x -x -x -x -x -x -x -x -x -x -x -x -x -J -i -i +ai +aJ +eT +ax +ap +ax +ax +aS +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +aJ +ai +ai "} (27,1,1) = {" -i -J -x -x -t -x -x -q -x -x -x -x -x -x -x -x -x -x -x -J -i -i +ai +aJ +bJ +aS +Zi +aS +aS +MO +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +aJ +ai +ai "} (28,1,1) = {" -i -J -x -x -J -l -x -x -x -x -x -x -x -x -x -x -x -x -W -J -i -i +ai +aJ +ax +ax +aJ +al +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +aW +aJ +ai +ai "} (29,1,1) = {" -i -J -J -J -J -J -J -J -J -J -J -J -J -J -J -J -J -J -J -J -i -i +ai +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +ap +at +aJ +aJ +aJ +aJ +aJ +aJ +aJ +ai +ai "} (30,1,1) = {" -i -i -i -i -i -i -i -i -i -i -i -i -i -i -i -i -i -i -i -i -i -i +ai +aJ +aJ +aJ +ax +aJ +aN +ax +ax +aN +ax +ax +ax +aF +ax +ax +ax +aN +ax +aJ +ai +ai +"} +(31,1,1) = {" +ai +aJ +aJ +aJ +ak +aJ +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +aw +aJ +ai +ai +"} +(32,1,1) = {" +ai +aJ +aJ +aJ +ar +aJ +ax +ax +aK +aS +aS +aS +aS +aS +aS +aS +am +ax +ax +aJ +ai +ai +"} +(33,1,1) = {" +ai +aJ +aJ +aJ +aS +ap +ax +ax +aS +ax +ax +ax +ax +ax +aN +ax +aS +ax +ax +aJ +ai +ai +"} +(34,1,1) = {" +ai +aJ +aJ +aJ +aS +at +ax +ax +aS +ax +ax +aJ +aJ +aJ +ax +ax +aS +ax +ax +aJ +ai +ai +"} +(35,1,1) = {" +ai +aJ +aJ +aJ +aS +aJ +ax +ax +aS +ax +ax +aJ +aJ +aJ +ax +ax +aS +ax +ax +aJ +ai +ai +"} +(36,1,1) = {" +ai +aJ +aJ +aJ +aS +aJ +ax +ax +aS +ax +aD +ax +ax +ax +ax +ax +aS +ax +ax +aJ +ai +ai +"} +(37,1,1) = {" +ai +aJ +aJ +aJ +aS +aJ +ax +ax +aC +aS +aS +aS +aS +aS +aS +aS +aH +ax +ax +aJ +ai +ai +"} +(38,1,1) = {" +ai +aJ +aJ +aJ +aS +aJ +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +aw +aJ +ai +ai +"} +(39,1,1) = {" +ai +aJ +ax +ax +aS +aJ +aO +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +aN +ax +aJ +ai +ai +"} +(40,1,1) = {" +ai +aJ +aJ +aJ +aS +aJ +aJ +aJ +aJ +aJ +aJ +ap +at +aJ +aJ +aJ +aJ +aJ +aJ +aJ +ai +ai +"} +(41,1,1) = {" +ai +aJ +aJ +aJ +aS +aJ +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +aJ +ai +ai +"} +(42,1,1) = {" +ai +aJ +aJ +aX +aS +aJ +ax +au +aS +aS +aS +aS +aS +aS +aS +aS +aS +an +ax +aJ +ai +ai +"} +(43,1,1) = {" +ai +aJ +aJ +aJ +aS +aJ +ax +aS +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aS +ax +aJ +ai +ai +"} +(44,1,1) = {" +ai +aJ +aJ +aJ +aS +aJ +aL +aS +aJ +aJ +aJ +aJ +aJ +ax +aG +ax +aJ +aS +ax +aJ +ai +ai +"} +(45,1,1) = {" +ai +aJ +ax +ax +aS +aJ +ax +aS +aJ +aJ +aJ +aJ +aJ +ax +ax +ax +aJ +aS +ax +aJ +ai +ai +"} +(46,1,1) = {" +ai +aJ +aJ +aJ +aS +aJ +ax +aS +aJ +aJ +aJ +aJ +aJ +ax +ax +ax +aJ +aS +ax +aJ +ai +ai +"} +(47,1,1) = {" +ai +aJ +aJ +aJ +aS +aJ +ax +aS +aJ +aJ +aJ +aJ +aJ +ax +aE +ax +aZ +aS +ax +aJ +ai +ai +"} +(48,1,1) = {" +ai +aJ +aJ +aJ +aS +aJ +ax +aS +aJ +aJ +aJ +aJ +aJ +ax +ax +ax +aJ +aS +ax +aJ +ai +ai +"} +(49,1,1) = {" +ai +aJ +aJ +aJ +aS +aJ +aL +aS +aJ +aJ +aJ +aJ +aJ +ax +ax +ax +aJ +aS +ax +aJ +ai +ai +"} +(50,1,1) = {" +ai +aJ +aJ +aJ +aU +aJ +ax +aS +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aS +ax +aJ +ai +ai +"} +(51,1,1) = {" +ai +aJ +aJ +aJ +aL +aJ +ax +aA +aS +aS +aS +aS +aS +aS +aS +aS +aS +aj +ax +aJ +ai +ai +"} +(52,1,1) = {" +ai +aM +ax +ax +ax +aJ +ax +ax +ax +ax +ax +ax +aY +ax +ax +ax +ax +ax +ax +aJ +ai +ai +"} +(53,1,1) = {" +ai +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +aJ +ai +ai +"} +(54,1,1) = {" +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai +ai "} From e48459849c2eb4ae056e4755d699b402a724ba13 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Wed, 11 Nov 2026 18:16:19 -0800 Subject: [PATCH 32/78] Stealth guard flashlights throw a beam: a wedge from the hand that leads turns, slides with steps, sweeps while searching and sputters when cut out; a lit flashlight behind a guard in the dark draws its notice --- voidcrew/_DEFINES/stealth.dm | 41 ++- voidcrew/modules/stealth/scav_guards.dm | 4 + voidcrew/modules/stealth/stealth_ai.dm | 24 +- voidcrew/modules/stealth/stealth_light.dm | 332 +++++++++++++----- .../modules/stealth/stealth_perception.dm | 25 +- voidcrew/modules/stealth/stealth_turns.dm | 24 +- .../unit_tests/voidcrew_stealth_light.dm | 217 ++++++++++-- 7 files changed, 518 insertions(+), 149 deletions(-) diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index c1ca167774b..8d296d3801b 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -167,20 +167,37 @@ /// A light EMP cuts a guard's seclite out for this long #define STEALTH_LIGHT_EMP_LIGHT (20 SECONDS) -// ===== Real flashlight pools (decision 39, stealth_light.dm) ===== -/// Tiles ahead its pool lands, when nothing stops it first -#define STEALTH_TORCH_REACH 3 -/// The same, facing a diagonal -#define STEALTH_TORCH_REACH_DIAGONAL 2 -/// The pool's light power (its seclite blue takes it to about 1.2 white) -#define STEALTH_TORCH_POWER 1.5 -/// The pool's light range with its centre 2.5 or more tiles off, 2 or more, and nearer (sized so the guard's own -/// tile stays under the dark line: data/stealth/STATUS.md, decision 39) -#define STEALTH_TORCH_RANGE_FAR 2.5 -#define STEALTH_TORCH_RANGE_MID 2 -#define STEALTH_TORCH_RANGE_NEAR 1.7 +// ===== Flashlight beams (decisions 39 and 41, stealth_light.dm) ===== +/// The beam's light range in tiles, from where it starts (lit floor ends 4 tiles ahead: data/stealth/STATUS.md, decision 41) +#define STEALTH_TORCH_RANGE 5 +/// The beam's light power (its seclite blue takes it to about 1.5 white) +#define STEALTH_TORCH_POWER 1.9 +/// Degrees of the beam at full strength; tg fades it to nothing over the next 30 each side +#define STEALTH_TORCH_ANGLE 30 +/// Tiles ahead of the guard's own tile the beam starts (the hand, not the body), so its own tile stays dark +#define STEALTH_TORCH_FORWARD 0.5 /// tg's seclite colour #define STEALTH_TORCH_COLOR "#99ccff" +/// A turn of 90 degrees or more shows the beam halfway for this long before it lands +#define STEALTH_TORCH_TURN_STEP (0.15 SECONDS) +/// A step at a walk shows the beam half a tile back for this long +#define STEALTH_TORCH_HALF_STEP (0.2 SECONDS) +/// Suspicious or searching and standing: the beam swings a side, back, the other side, back, one move per this long +#define STEALTH_TORCH_SWEEP_STEP (0.6 SECONDS) +/// A seclite that is cut out sputters: world.time offsets it flashes on at, and how long each flash lasts +#define STEALTH_TORCH_SPUTTER_AT list(0.2 SECONDS, 0.5 SECONDS) +#define STEALTH_TORCH_SPUTTER_FLASH (0.1 SECONDS) +/// Loudness of the click when a guard switches its light +#define STEALTH_TORCH_CLICK_VOLUME 25 +/// A lit light someone carries within this many tiles of an unaware guard standing in the dark draws its notice +/// even behind it (never further than the light itself reaches) +#define STEALTH_STRAY_LIGHT_RANGE 5 +/// Notice a second from such a light. It only ever fills to suspicious: the guard turns and uses its eyes. +#define STEALTH_STRAY_LIGHT_RATE 0.5 +/// Bark: someone's light is on it +#define STEALTH_BARK_LIGHT "stealth_light" +/// Bark: its own light cut out +#define STEALTH_BARK_LIGHT_DEAD "stealth_light_dead" // ===== Readable turns (decision 39, stealth_turns.dm) ===== /// How long a guard leans towards the side it is about to turn to before it turns diff --git a/voidcrew/modules/stealth/scav_guards.dm b/voidcrew/modules/stealth/scav_guards.dm index e7bec0433cd..5840410ab52 100644 --- a/voidcrew/modules/stealth/scav_guards.dm +++ b/voidcrew/modules/stealth/scav_guards.dm @@ -38,6 +38,8 @@ STEALTH_BARK_ID_PASS = list("Fine. Move along.", "All right. Go on.", "Go on, %NAME%."), STEALTH_BARK_ID_FAIL = list("No card? Don't move.", "Card. Now.", "I said card."), STEALTH_BARK_BLOWN = list("You're not one of us!", "That's not one of ours!", "Who the hell are you?"), + STEALTH_BARK_LIGHT = list("Whose light is that?", "Who's got a light on?", "Kill that light."), + STEALTH_BARK_LIGHT_DEAD = list("Light's dead.", "Come on. Work.", "Cheap junk."), ) emotes = list( HUMAN_NPC_BARK_DOWNED = list("collapses."), @@ -53,6 +55,8 @@ STEALTH_BARK_RADIO_DEAD = list("taps their earpiece."), STEALTH_BARK_GREET = list("nods.", "lifts their chin."), STEALTH_BARK_SMOKE = list("pats their pockets."), + STEALTH_BARK_LIGHT = list("shades their eyes."), + STEALTH_BARK_LIGHT_DEAD = list("smacks their flashlight.", "shakes their flashlight."), ) chances = list(RUIN_NPC_BARK_SPOT = 100) diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index 21bcd2434ba..db0c765351d 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -238,6 +238,11 @@ QDEL_NULL(meter) QDEL_NULL(torch) light_lit = FALSE + sweeping = FALSE + torch_aim = 0 + torch_pass = 0 + torch_serial++ + sputter_serial++ turned_from = null home_turf = null last_seen_turf = null @@ -693,6 +698,10 @@ // still fills as usual, so someone still in front of it when the moment passes is seen. var/turning = stealth_turn_grace() var/night_vision = HAS_TRAIT(guard, TRAIT_NIGHT_VISION) + // Decision 41: unaware and standing somewhere the room leaves dark, a lit light someone carries near it draws + // its notice wherever they stand. REF => TRUE for everyone noticed that way this look. + var/stray_lights = state == STEALTH_UNAWARE && eyes && stealth_room_is_dark(guard.loc) + var/list/by_light // Decision 40 (stealth_disguise.dm): REF => TRUE for everyone whose disguise holds this look, the nearest of // them close enough to stop, and whoever it has stopped already. var/list/disguised @@ -767,9 +776,14 @@ if(dist <= profile.near_range) rate *= profile.near_mult if(!rate && dist <= close_range && (night_vision || !stealth_tile_is_dark(where))) - // At its shoulder, in light that is really there (abuse P7). Its own pool lands ahead of it, so + // At its shoulder, in light that is really there (abuse P7). Its own beam lands ahead of it, so // someone right behind it in the dark is not seen (decisions 32 and 39). rate = STEALTH_BEHIND_RATE + // Someone's light on its back or its side (decision 41). It turns to look; it is never an alert by itself. + var/lit_up = FALSE + if(!rate && stray_lights && !boxed && dist <= min(stealth_carried_light(candidate), STEALTH_STRAY_LIGHT_RANGE)) + rate = STEALTH_STRAY_LIGHT_RATE + lit_up = TRUE if(!rate) continue // A disguise that holds (decision 40): seen doing what no guard would, it is blown; otherwise notice fills @@ -813,7 +827,11 @@ if(wary) rate *= STEALTH_WARY_MULT wary_at = world.time - entry[STEALTH_ENTRY_NOTICE] = min(entry[STEALTH_ENTRY_NOTICE] + rate * scan_seconds, pieces ? STEALTH_SUSPICIOUS_AT : STEALTH_NOTICE_MAX) + if(lit_up) + LAZYSET(by_light, key, TRUE) + entry[STEALTH_ENTRY_NOTICE] = max(entry[STEALTH_ENTRY_NOTICE], min(entry[STEALTH_ENTRY_NOTICE] + rate * scan_seconds, STEALTH_SUSPICIOUS_AT)) + else + entry[STEALTH_ENTRY_NOTICE] = min(entry[STEALTH_ENTRY_NOTICE] + rate * scan_seconds, pieces ? STEALTH_SUSPICIOUS_AT : STEALTH_NOTICE_MAX) if(plain_sight) entry[STEALTH_ENTRY_NOTICE] = STEALTH_NOTICE_MAX if(isnull(point_blank)) @@ -881,7 +899,7 @@ switch(state) if(STEALTH_UNAWARE) if(level >= STEALTH_SUSPICIOUS_AT) - stealth_go_suspicious(best_turf) + stealth_go_suspicious(best_turf, line = by_light?[judged_key] ? STEALTH_BARK_LIGHT : null) if(STEALTH_SUSPICIOUS) if(!seen_now) return diff --git a/voidcrew/modules/stealth/stealth_light.dm b/voidcrew/modules/stealth/stealth_light.dm index 74e9f927798..15d6c1222f6 100644 --- a/voidcrew/modules/stealth/stealth_light.dm +++ b/voidcrew/modules/stealth/stealth_light.dm @@ -1,31 +1,41 @@ /** - * # Stealth guards: flashlights (owner decisions 31 and 39) + * # Stealth guards: flashlights (owner decisions 31, 39 and 41) * * A scav guard carries a real seclite clipped to its belt (or its vest, or a pocket). What it lights is a real - * light (decision 39): a hidden lamp, /obj/effect/abstract/stealth_torch, that sits on the floor a few tiles ahead - * of the guard, where the beam would land, and lights a small pool through tg's own static lighting. Everyone sees - * the pool, around corners too, and the darkness rule (stealth_tile_is_dark()) reads the same light the players - * see, so what looks dark is dark to the guards as well. The seclite item itself stays off and stays a plain tg - * seclite: a looted one works like any other, and nothing draws two beams. + * light (decision 39): a hidden lamp, /obj/effect/abstract/stealth_torch, on the guard's own tile, that throws a + * beam the way it faces through tg's own static lighting (a directional light, as tg's wall lamps are). Everyone + * sees the beam, round corners too, and the darkness rule (stealth_tile_is_dark()) reads the same light the + * players see, so what looks dark is dark to the guards as well. The seclite item itself stays off and stays a + * plain tg seclite: a looted one works like any other, and nothing draws two beams. * - * Where the pool goes: STEALTH_TORCH_REACH tiles ahead along its facing (STEALTH_TORCH_REACH_DIAGONAL on a - * diagonal), or the last open tile before the first wall, opaque thing or closed door. It shines through glass. The - * nearer the pool has to sit, the smaller it is, so it never lights the guard's own back (stealth_torch_range()). - * Facing a wall at its nose it has no pool at all. + * The beam (decision 41): a wedge that starts at the guard's hand, half a tile ahead of it, widens to three tiles + * and lights the floor up to four tiles ahead, brightest two and three tiles out. Its own tile, its sides and its + * back stay dark. tg's lighting stops it at walls and closed solid doors and lets it through glass, like any lamp + * (numbers in data/stealth/STATUS.md, decision 41). + * + * The beam moves like a hand moves it. Before a turn the guard makes on its own, the beam swings halfway there + * while the body leans (stealth_turns.dm), so the light shows where it is about to look. Any other turn of 90 + * degrees or more passes through the halfway point. A step at a walk carries the beam half a tile at a time. A + * guard that is searching, or looking round where it thought it saw something, swings the beam to one side, back, + * and to the other while it stands. * * The guard switches it as before: on when it stands somewhere dark (judged without any guard's light, decision 32, * so two guards never switch each other off), always on while suspicious, alert or searching, off in lit places * while unaware. It keeps it on for STEALTH_LIGHT_HOLD after it last wanted it, so walking along the edge of a lit - * room doesn't flick it on and off. + * room doesn't flick it on and off. The switch clicks. + * + * Beating it is tg's: you see the beam coming; an EMP or the saboteur gun cuts the seclite out for a while (the scav + * seclite takes an EMP as tg's saboteur hit; a stock seclite ignores EMPs), and it sputters twice as it dies; a + * guard that is down, stunned, cuffed, held, asleep or dead has no light; nor does one whose seclite was taken + * (decision 34: it can be stripped, knocked loose and looted like anyone's seclite). * - * Beating it is tg's: you see the pool coming; an EMP or the saboteur gun cuts the seclite out for a while (the scav - * seclite takes an EMP as tg's saboteur hit; a stock seclite ignores EMPs); a guard that is down, stunned, cuffed, - * held, asleep or dead has no light; nor does one whose seclite was taken (decision 34: it can be stripped, knocked - * loose and looted like anyone's seclite). + * Other people's lights (decision 41): a lit light someone carries near an unaware guard that stands in the dark + * draws its notice even from behind (stealth_look()). It only ever makes the guard suspicious: it turns to look. * - * Cost: the pool moves only when the guard's turf or facing changes, or when it switches on or off (at most once a - * scan). A move is one abstract_move() of the lamp, which queues one static light update. A guard asleep in a - * dormant level moves and scans nothing, so its lamp costs nothing. + * Cost: the lamp updates only when the guard's turf or the beam's direction changes, or when it switches. A step + * at a walk is two static light updates (the half step and the landing), a turn one or two, a sweep one per + * STEALTH_TORCH_SWEEP_STEP while the guard is suspicious or searching and standing. A guard asleep in a dormant + * level moves, scans and sweeps nothing, so its lamp costs nothing. */ /// Every guard's lamp, so a guard can leave them all out when it judges how dark its own spot is (decision 32) @@ -44,7 +54,7 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) . = ..() stealth_tell_holder(loc) -/// Off a guard's body (looted, stripped, dropped), the guard's pool goes out at once. +/// Off a guard's body (looted, stripped, dropped), the guard's beam goes out at once. /obj/item/flashlight/seclite/scav/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE) . = ..() stealth_tell_holder(old_loc) @@ -82,8 +92,8 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) return null /** - * The pool of a guard's flashlight on the floor: a real static light with no sprite. It is never entered into a - * turf (abstract_move()), so it trips nothing, and nothing can touch, move or burn it. + * The lamp behind a guard's flashlight beam: a real static light with no sprite, on the guard's own tile. It is + * never entered into a turf (abstract_move()), so it trips nothing, and nothing can touch, move or burn it. */ /obj/effect/abstract/stealth_torch name = "flashlight beam" @@ -92,10 +102,15 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) anchored = TRUE blocks_emissive = EMISSIVE_BLOCK_NONE light_system = COMPLEX_LIGHT - light_range = STEALTH_TORCH_RANGE_FAR + light_range = STEALTH_TORCH_RANGE light_power = STEALTH_TORCH_POWER light_color = STEALTH_TORCH_COLOR + light_angle = STEALTH_TORCH_ANGLE + light_flags = LIGHT_IGNORE_OFFSET light_on = FALSE + /// Where the beam starts, in tiles from the middle of the lamp's tile, as tg's light offset: a negative x is east + var/beam_x = 0 + var/beam_y = 0 /obj/effect/abstract/stealth_torch/Initialize(mapload) . = ..() @@ -105,6 +120,9 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) GLOB.stealth_guard_torches -= src return ..() +/obj/effect/abstract/stealth_torch/get_light_offset() + return list(beam_x, beam_y) + /// How much every guard's lamp adds to `tile` right now, in get_lumcount() units. /proc/stealth_torch_share(turf/tile) . = 0 @@ -113,7 +131,7 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) for(var/obj/effect/abstract/stealth_torch/torch as anything in GLOB.stealth_guard_torches) var/datum/light_source/source = torch.light var/list/strengths = source?.effect_str - if(!length(strengths) || torch.z != tile.z || get_dist(torch, tile) > STEALTH_TORCH_RANGE_FAR + 1) + if(!length(strengths) || torch.z != tile.z || get_dist(torch, tile) > STEALTH_TORCH_RANGE + 2) continue var/channels = source.applied_lum_r + source.applied_lum_g + source.applied_lum_b for(var/datum/lighting_corner/corner as anything in list(tile.lighting_corner_NE, tile.lighting_corner_SE, tile.lighting_corner_SW, tile.lighting_corner_NW)) @@ -121,59 +139,46 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) . += (strengths[corner] || 0) * channels . /= 12 // as get_lumcount(): 4 corners, 3 channels each -/// Whether light passes from `tile` on to `next`, the way `facing` points: not into a wall, an opaque thing or a -/// closed door (glass ones too). Glass passes. A diagonal step needs one of its two sides open. -/proc/stealth_torch_passes(turf/tile, turf/next, facing) - if(isnull(next) || next.z != tile.z || IS_OPAQUE_TURF(next)) - return FALSE - if(facing & (facing - 1)) - var/turf/side_a = get_step(tile, facing & (NORTH | SOUTH)) - var/turf/side_b = get_step(tile, facing & (EAST | WEST)) - if((isnull(side_a) || IS_OPAQUE_TURF(side_a)) && (isnull(side_b) || IS_OPAQUE_TURF(side_b))) - return FALSE - for(var/obj/machinery/door/door in next) - if(door.density) - return FALSE - for(var/obj/structure/mineral_door/door in next) - if(door.density) - return FALSE - // A closed windoor on the edge it leaves by - for(var/obj/machinery/door/window/windoor in tile) - if(windoor.density && (windoor.dir & facing)) - return FALSE - return TRUE - -/// Where the pool of a light carried at `from`, facing `facing`, lands: the furthest open tile within reach, or null. -/proc/stealth_torch_spot(turf/from, facing) - if(!isturf(from) || !facing) - return null - var/reach = (facing & (facing - 1)) ? STEALTH_TORCH_REACH_DIAGONAL : STEALTH_TORCH_REACH - var/turf/tile = from - var/turf/spot - for(var/i in 1 to reach) - var/turf/next = get_step(tile, facing) - if(!stealth_torch_passes(tile, next, facing)) - break - tile = next - spot = next - return spot - -/// How wide the pool is with its centre `distance` tiles from the guard: smaller when it has to sit near, so it -/// never lights the guard's own tile or the tile behind it (numbers in data/stealth/STATUS.md, decision 39). -/proc/stealth_torch_range(distance) - if(distance >= 2.5) - return STEALTH_TORCH_RANGE_FAR - if(distance >= 2) - return STEALTH_TORCH_RANGE_MID - return STEALTH_TORCH_RANGE_NEAR +/// How far the lit light `who` carries reaches, in tiles: a flashlight in a hand or on a belt, a lit PDA, a flare. +/// 0 with nothing lit. +/proc/stealth_carried_light(mob/living/who) + . = 0 + // tg's overlay lights (flashlights, PDAs, helmet lights): light => reach + 1, listed only while lit + for(var/glow in who.affected_dynamic_lights) + . = max(., who.affected_dynamic_lights[glow] - 1) + // tg's static lights carried on the body (flares, lanterns) + for(var/datum/light_source/source as anything in who.light_sources) + if(source.top_atom == who) + . = max(., CEILING(source.light_range, 1)) + +/// The swing between two facings in degrees, -180 to 179: positive when `first` is clockwise of `second`. +/proc/stealth_swing(first, second) + return (dir2angle(first) - dir2angle(second) + 540) % 360 - 180 /datum/ai_controller/basic_controller/human_npc/stealth /// world.time until which it keeps its light on after it last wanted it var/light_hold_until = 0 - /// Whether it has its light on (the pool shows when there is room for one ahead) + /// Whether it has its light on (the beam shows whenever it stands on a turf) var/light_lit = FALSE - /// The pool its light makes, made the first time it is switched on + /// The lamp behind its beam, made the first time it is switched on var/obj/effect/abstract/stealth_torch/torch + /// Where it points the beam off its facing, in 45 degree steps anticlockwise: a sweep, or the lead of a turn + var/torch_aim = 0 + /// The way the beam points for a moment in the middle of a turn, or 0 + var/torch_pass = 0 + /// How far behind its tile the beam still is in the middle of a step, in tiles + var/torch_lag_x = 0 + var/torch_lag_y = 0 + /// Counts beam moves, so a timer from an older one does nothing + var/torch_serial = 0 + /// world.time it last stepped + var/torch_moved_at = 0 + /// Whether its sweep timer is running + var/sweeping = FALSE + /// Where it is in the sweep: 1 one side, 2 back, 3 the other side, 4 back + var/sweep_step = 0 + /// Counts switches, so a light that comes back stops a sputter + var/sputter_serial = 0 /// Its flashlight, if it still has it on its body; else null. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_light() @@ -196,27 +201,49 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) /// Switches its light on or off for where it stands and what it is doing. Off at once when it can't use it. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_update_light() if(!stealth_light_usable()) + var/was_lit = light_lit light_hold_until = 0 stealth_set_light(FALSE) + if(was_lit) + stealth_light_cut() return var/mob/living/guard = pawn - // Its own spot judged by the room's light alone: a friend's passing pool doesn't switch it off (decision 32). + // Its own spot judged by the room's light alone: a friend's passing beam doesn't switch it off (decision 32). var/wanted = stealth_state() != STEALTH_UNAWARE || stealth_tile_is_dark(get_turf(guard), no_guard_lights = TRUE) if(wanted) light_hold_until = world.time + STEALTH_LIGHT_HOLD else if(world.time < light_hold_until) stealth_place_torch() return - stealth_set_light(wanted) + stealth_set_light(wanted, TRUE) + stealth_sweep_check() -/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_set_light(lit) +/// `click`: it worked the switch itself, which is heard. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_set_light(lit, click = FALSE) + if(lit != light_lit) + if(click && !QDELETED(pawn)) + playsound(pawn, lit ? 'sound/items/weapons/magin.ogg' : 'sound/items/weapons/magout.ogg', STEALTH_TORCH_CLICK_VOLUME, TRUE, -4) + sputter_serial++ + torch_serial++ + torch_aim = 0 + torch_pass = 0 + torch_lag_x = 0 + torch_lag_y = 0 light_lit = lit stealth_place_torch() -/// Puts the pool where its light lands now, or puts it out. Moves the lamp only when the spot changed. -/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_place_torch() +/// The way its beam points now: its facing, off to a side in a sweep or ahead of a turn, or halfway through a turn. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_beam_dir() + if(torch_pass) + return torch_pass + var/mob/living/guard = pawn + return torch_aim ? turn(guard.dir, 45 * torch_aim) : guard.dir + +/// Points the lamp where its beam goes now, or puts it out. Touches the light only when something changed. +/// `flash` shows the beam with the light off (a dying seclite's sputter). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_place_torch(flash = FALSE) var/mob/living/guard = pawn - var/turf/spot = (light_lit && !QDELETED(guard)) ? stealth_torch_spot(get_turf(guard), guard.dir) : null + var/turf/spot = ((light_lit || flash) && !QDELETED(guard) && isturf(guard.loc)) ? guard.loc : null if(isnull(spot)) if(torch?.light_on) torch.set_light_on(FALSE) @@ -224,25 +251,158 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) return if(QDELETED(torch)) torch = new(spot) - var/range = stealth_torch_range(get_dist_euclidean(guard, spot)) - // tg's light setters don't rebuild a COMPLEX_LIGHT source on their own (see /obj/item/flashlight/update_brightness()): - // update_light() does. A move needs nothing more, the source follows its host's Moved. + var/beam_dir = stealth_beam_dir() + // The beam starts at its hand, ahead of its own tile, less whatever a step in progress still holds back. + var/start_x = torch_lag_x - STEALTH_TORCH_FORWARD * ((beam_dir & EAST) ? 1 : ((beam_dir & WEST) ? -1 : 0)) + var/start_y = torch_lag_y - STEALTH_TORCH_FORWARD * ((beam_dir & NORTH) ? 1 : ((beam_dir & SOUTH) ? -1 : 0)) + var/changed = !torch.light_on || torch.light_dir != beam_dir || torch.beam_x != start_x || torch.beam_y != start_y + // A move rebuilds the light by itself (the source follows its host's Moved). if(torch.loc != spot) torch.abstract_move(spot) - if(torch.light_range != range || !torch.light_on) - torch.set_light_range(range) - torch.set_light_on(TRUE) - torch.update_light() + if(!changed) + return + torch.beam_x = start_x + torch.beam_y = start_y + torch.set_light_dir(beam_dir) + torch.set_light_on(TRUE) + // tg's light setters don't rebuild a COMPLEX_LIGHT source on their own (see /obj/item/flashlight/update_brightness()). + torch.update_light() -/// Whether its light is on with a pool on the floor (for admins and tests). +/// Whether its light is on with its beam showing (for admins and tests). /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_light_shows() return light_lit && !QDELETED(torch) && torch.light_on -/// It moved or turned: the pool follows. Nothing to do with its light off. -/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_light_follow() +/// It stepped from `old_loc`: the beam follows, half a tile at a time at a walk. Nothing to do with its light off. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_light_stepped(atom/old_loc) + if(!light_lit) + return + if(!stealth_light_usable()) + stealth_update_light() + return + var/mob/living/guard = pawn + torch_moved_at = world.time + torch_aim = 0 + torch_pass = 0 + torch_lag_x = 0 + torch_lag_y = 0 + sweep_step = 0 + torch_serial++ + if(isturf(old_loc) && isturf(guard.loc) && guard.move_intent == MOVE_INTENT_WALK && old_loc.z == guard.z && get_dist(old_loc, guard) == 1) + torch_lag_x = 0.5 * (guard.x - old_loc.x) + torch_lag_y = 0.5 * (guard.y - old_loc.y) + addtimer(CALLBACK(src, PROC_REF(stealth_torch_settle), torch_serial), STEALTH_TORCH_HALF_STEP) + stealth_place_torch() + +/// It turned from `old_dir`: the beam follows, through the halfway point when the turn is 90 degrees or more. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_light_turned(old_dir, new_dir) if(!light_lit) return if(!stealth_light_usable()) stealth_update_light() return + // Where the beam points now: ahead of the turn already, if it led it. + var/was = torch?.light_on ? torch.light_dir : old_dir + torch_aim = 0 + torch_pass = 0 + sweep_step = 0 + var/swing = stealth_swing(was, new_dir) + // Mid-step the half step's timer lands the beam; a turn on the spot gets its own. + if(abs(swing) > 45 && !torch_lag_x && !torch_lag_y) + torch_serial++ + torch_pass = turn(new_dir, swing > 0 ? -45 : 45) + addtimer(CALLBACK(src, PROC_REF(stealth_torch_settle), torch_serial), STEALTH_TORCH_TURN_STEP) + stealth_place_torch() + +/// The beam lands: the half step or the halfway point of a turn is over. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_torch_settle(serial) + if(serial != torch_serial) + return + torch_pass = 0 + torch_lag_x = 0 + torch_lag_y = 0 + stealth_place_torch() + +/// About to turn to `new_dir` on its own (stealth_turn_to()): the beam goes halfway there first. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_torch_lead(new_dir) + if(!light_lit) + return + var/mob/living/guard = pawn + var/swing = stealth_swing(new_dir, guard.dir) + if(!swing) + return + torch_pass = 0 + torch_aim = swing > 0 ? -1 : 1 + stealth_place_torch() + +/// The turn it led never came, or the sweep is over: the beam goes back to its facing. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_torch_straighten() + if(!torch_aim) + return + torch_aim = 0 + stealth_place_torch() + +/// Whether it swings its beam about: searching, or looking round where it thought it saw something. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_sweeps() + if(!light_lit || !stealth_scanning()) + return FALSE + switch(stealth_state()) + if(STEALTH_SEARCHING) + return TRUE + if(STEALTH_SUSPICIOUS) + // Not while it stares at the spot, and not into the face of someone it has stopped (decision 40). + return investigated && isnull(challenge) + return FALSE + +/// Starts its sweep if it should be sweeping and isn't. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_sweep_check() + if(sweeping || !stealth_sweeps()) + return + sweeping = TRUE + sweep_step = 0 + addtimer(CALLBACK(src, PROC_REF(stealth_sweep_tick)), STEALTH_TORCH_SWEEP_STEP) + +/// One move of the sweep: a side, back, the other side, back. It waits out steps and turns, and ends by itself. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_sweep_tick() + if(!stealth_sweeps()) + sweeping = FALSE + sweep_step = 0 + if(!turn_pending) + stealth_torch_straighten() + return + addtimer(CALLBACK(src, PROC_REF(stealth_sweep_tick)), STEALTH_TORCH_SWEEP_STEP) + // Walking, about to turn, or just turned: the beam is spoken for. + if(turn_pending || torch_pass || world.time < torch_moved_at + STEALTH_TORCH_SWEEP_STEP || (turned_at && world.time < turned_at + STEALTH_TORCH_SWEEP_STEP)) + sweep_step = 0 + return + sweep_step = (sweep_step % 4) + 1 + switch(sweep_step) + if(1) + torch_aim = look_side + if(3) + torch_aim = -look_side + else + torch_aim = 0 stealth_place_torch() + +/// Its light went out under it. A seclite that was cut out (an EMP, the saboteur gun) sputters twice, and it says so. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_light_cut() + var/mob/living/guard = pawn + if(QDELETED(guard) || guard.stat != CONSCIOUS || stealth_driven() || stealth_captive() || HAS_TRAIT(guard, TRAIT_HANDS_BLOCKED)) + return + var/obj/item/flashlight/light = stealth_light() + if(isnull(light) || COOLDOWN_FINISHED(light, disabled_time)) + return + var/serial = sputter_serial + for(var/flash_at in STEALTH_TORCH_SPUTTER_AT) + addtimer(CALLBACK(src, PROC_REF(stealth_sputter), serial, TRUE), flash_at) + addtimer(CALLBACK(src, PROC_REF(stealth_sputter), serial, FALSE), flash_at + STEALTH_TORCH_SPUTTER_FLASH) + stealth_bark(STEALTH_BARK_LIGHT_DEAD) + +/// One flash of a dying seclite, on or off again. Nothing if the light is back, gone, or its guard is down. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_sputter(serial, on) + if(serial != sputter_serial || light_lit) + return + var/mob/living/guard = pawn + if(on && (QDELETED(guard) || guard.stat != CONSCIOUS || isnull(stealth_light()))) + return + stealth_place_torch(flash = on) diff --git a/voidcrew/modules/stealth/stealth_perception.dm b/voidcrew/modules/stealth/stealth_perception.dm index 9182272551e..5e498be593b 100644 --- a/voidcrew/modules/stealth/stealth_perception.dm +++ b/voidcrew/modules/stealth/stealth_perception.dm @@ -57,8 +57,8 @@ GLOBAL_LIST_EMPTY(stealth_test_dark_turfs) * Whether `tile` is dark enough to hide in. A turf with no lighting object (planet ground lit only by its * area's ambient light) reads its area's base light, which get_lumcount() skips (it returns 1 there). * Same rule as the bounty AI's ai_tile_is_dark() (bounty_ai_meek.dm), which is a type proc. - * Every light counts, a guard's own flashlight pool too: it is real light that players see (decision 39). - * `no_guard_lights` leaves out every guard's pool, so a guard deciding whether its spot needs a light judges by + * Every light counts, a guard's own flashlight beam too: it is real light that players see (decision 39). + * `no_guard_lights` leaves out every guard's beam, so a guard deciding whether its spot needs a light judges by * the room's own light, not by a friend walking past with one (decision 32: no flicker when guards meet). */ /proc/stealth_tile_is_dark(turf/tile, no_guard_lights = FALSE) @@ -74,6 +74,27 @@ GLOBAL_LIST_EMPTY(stealth_test_dark_turfs) var/guard_light = no_guard_lights ? stealth_torch_share(tile) : 0 return tile.get_lumcount() - guard_light < STEALTH_DARK_LUMCOUNT +/** + * Whether the room itself leaves `tile` dark: its fixed lights only, without any guard's beam and without the + * lights people carry (tg's overlay lights, which get_lumcount() adds on top). A guard standing somewhere like + * that has a reason to wonder whose light it is seeing (decision 41). + */ +/proc/stealth_room_is_dark(turf/tile) + if(!isturf(tile)) + return FALSE +#ifdef UNIT_TESTS + if(tile in GLOB.stealth_test_dark_turfs) + return GLOB.stealth_test_dark_turfs[tile] +#endif + if(!tile.lighting_object) + var/area/tile_area = tile.loc + return (tile_area.base_lighting_alpha / 255) < STEALTH_DARK_LUMCOUNT + var/room = 0 + for(var/datum/lighting_corner/corner as anything in list(tile.lighting_corner_NE, tile.lighting_corner_SE, tile.lighting_corner_SW, tile.lighting_corner_NW)) + if(corner) + room += corner.lum_r + corner.lum_g + corner.lum_b + return room / 12 - stealth_torch_share(tile) < STEALTH_DARK_LUMCOUNT + /** * What `who` is shut inside, as it stands on a turf: the box, locker, bag or car, or the outermost of them. * Null on a turf of their own, or when someone is carrying them (the carrier is the one to see). diff --git a/voidcrew/modules/stealth/stealth_turns.dm b/voidcrew/modules/stealth/stealth_turns.dm index 3eb7655272d..89e434f14a5 100644 --- a/voidcrew/modules/stealth/stealth_turns.dm +++ b/voidcrew/modules/stealth/stealth_turns.dm @@ -10,7 +10,8 @@ * passes. Its notice still fills as usual (it can go "?"), so someone who stays in front of it is seen on the first * look after. A turn made by stepping is a walk, not a look round, and gives nothing. * - * Its flashlight pool (stealth_light.dm) follows every turn and step from here. + * Its flashlight beam (stealth_light.dm) follows every turn and step from here, and goes halfway ahead of a turn it + * makes on its own while it leans (decision 41). */ /datum/ai_controller/basic_controller/human_npc/stealth @@ -37,11 +38,12 @@ if(stealth_ready) turned_at = world.time turned_from = get_turf(source) - stealth_light_follow() + stealth_light_turned(old_dir, new_dir) +// tg hooks this to the pawn's COMSIG_MOVABLE_MOVED: its second argument is where the pawn came from. /datum/ai_controller/basic_controller/human_npc/stealth/update_grid(datum/source, datum/spatial_grid_cell/new_cell) . = ..() - stealth_light_follow() + stealth_light_stepped(new_cell) /// Its hands or its freedom changed: its light may have to go out or may come back. /datum/ai_controller/basic_controller/human_npc/stealth/proc/on_light_cue(datum/source) @@ -77,6 +79,7 @@ var/lean_z = (new_dir & NORTH) ? STEALTH_TURN_LEAN : ((new_dir & SOUTH) ? -STEALTH_TURN_LEAN : 0) turn_lean = list(lean_w, lean_z) animate(guard, pixel_w = lean_w, pixel_z = lean_z, time = STEALTH_TURN_LEAN_TIME, flags = ANIMATION_RELATIVE | ANIMATION_PARALLEL) + stealth_torch_lead(new_dir) addtimer(CALLBACK(src, PROC_REF(stealth_finish_turn), new_dir, turn_planned_at), STEALTH_TURN_TELL) /// The tell is over: it turns, unless the moment has passed (it moved, went down, changed state, or a player took it). @@ -85,13 +88,16 @@ return var/mob/living/guard = pawn var/turf/planned_from = turn_planned_from - stealth_drop_turn() - if(QDELETED(guard) || guard.stat != CONSCIOUS || stealth_driven() || get_turf(guard) != planned_from) - return - guard.setDir(new_dir) + // Its beam is halfway there already and stays there until the body follows. + stealth_drop_turn(TRUE) + if(!QDELETED(guard) && guard.stat == CONSCIOUS && !stealth_driven() && get_turf(guard) == planned_from) + guard.setDir(new_dir) + stealth_torch_straighten() -/// Drops a turn it was about to make and takes its lean back. -/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_drop_turn() +/// Drops a turn it was about to make and takes its lean back, and its beam with it unless it is `turning` now. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_drop_turn(turning = FALSE) + if(turn_pending && !turning) + stealth_torch_straighten() turn_pending = 0 turn_planned_from = null if(isnull(turn_lean)) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm index 5e1f71b25b4..8a3f3a04e51 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm @@ -1,6 +1,6 @@ -// Stealth guards: flashlights, elbow-to-elbow sight, volleys and sentry facing (owner decisions 31 and 39, +// Stealth guards: flashlights, elbow-to-elbow sight, volleys and sentry facing (owner decisions 31, 39 and 41, // voidcrew/modules/stealth/stealth_light.dm). Values from voidcrew/_DEFINES are written out: STEALTH_LIGHT_HOLD -// 5 s, STEALTH_TORCH_REACH 3, STEALTH_TORCH_REACH_DIAGONAL 2, STEALTH_NOISE_COALESCE 3 s, +// 5 s, STEALTH_TORCH_FORWARD 0.5, STEALTH_STRAY_LIGHT_RANGE 5, STEALTH_NOISE_COALESCE 3 s, // STEALTH_SENTRY_TURN_INTERVAL 8 s, STEALTH_SENTRY_GLANCE_TIME 2 s. /// Waits for tg's static lighting to apply what was just switched or moved (it updates on its own subsystem). @@ -51,6 +51,11 @@ TEST_ASSERT(stealth_ai.stealth_light_shows(), "The light didn't come on in the dark") guard.emp_act(EMP_LIGHT) TEST_ASSERT(!stealth_ai.stealth_light_shows(), "An EMP didn't cut the guard's light out") + // It sputters as it dies (decision 41): a flash of the beam with the light counted off, then dark again. + stealth_ai.stealth_sputter(stealth_ai.sputter_serial, TRUE) + TEST_ASSERT(stealth_ai.torch.light_on && !stealth_ai.stealth_light_shows(), "A cut-out seclite doesn't sputter") + stealth_ai.stealth_sputter(stealth_ai.sputter_serial, FALSE) + TEST_ASSERT(!stealth_ai.torch.light_on, "A sputter left the beam on") stealth_ai.stealth_update_light() TEST_ASSERT(!stealth_ai.stealth_light_shows(), "A guard switched an EMP'd light straight back on") light.disabled_time = 0 @@ -69,49 +74,187 @@ GLOB.stealth_test_dark_turfs[here] = FALSE qdel(block) -/// Decision 39: the pool lands 3 tiles ahead (2 on a diagonal), stops short of a wall or a closed door, goes through -/// glass, and follows the guard's turns and steps. +/// Decision 41: the lamp sits on the guard's tile and its beam starts half a tile ahead; a turn passes through the +/// halfway point, a turn of its own is led by the beam, a step at a walk carries the beam half a tile at a time, and +/// a searching guard sweeps it side to side. /datum/unit_test/voidcrew_stealth_light_pool /datum/unit_test/voidcrew_stealth_light_pool/Run() - var/datum/turf_reservation/block = stealth_block(10, 7) + var/datum/turf_reservation/block = stealth_block(12, 7) TEST_ASSERT_NOTNULL(block, "No room for the test") - var/turf/from = stealth_at(block, 2, 3) - TEST_ASSERT_EQUAL(stealth_torch_spot(from, EAST), stealth_at(block, 5, 3), "An open floor's pool isn't 3 tiles ahead") - TEST_ASSERT_EQUAL(stealth_torch_spot(from, NORTHEAST), stealth_at(block, 4, 5), "A diagonal pool isn't 2 tiles out") - // A wall 3 ahead: the pool is on the last open tile before it. - var/turf/wall = stealth_at(block, 5, 3) - wall.ChangeTurf(/turf/closed/wall) - TEST_ASSERT_EQUAL(stealth_torch_spot(from, EAST), stealth_at(block, 4, 3), "The pool went into or past a wall") - // Right at its nose: no pool. - var/turf/near_wall = stealth_at(block, 3, 3) - near_wall.ChangeTurf(/turf/closed/wall) - TEST_ASSERT_NULL(stealth_torch_spot(from, EAST), "A guard facing a wall at its nose has a pool") - // A closed glass airlock stops it; glass does not. - var/obj/machinery/door/airlock/glass/door = allocate(/obj/machinery/door/airlock/glass, stealth_at(block, 2, 5)) - TEST_ASSERT(door.density, "Test fixture: the airlock isn't closed") - TEST_ASSERT_EQUAL(stealth_torch_spot(from, NORTH), stealth_at(block, 2, 4), "The pool went through a closed glass door") - allocate(/obj/structure/window/fulltile, stealth_at(block, 2, 1)) - TEST_ASSERT_EQUAL(stealth_torch_spot(from, SOUTH), stealth_at(block, 2, 0), "The pool stopped at a window") - // A guard's pool follows it. - var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 3, SOUTH) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 3) var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) - GLOB.stealth_test_dark_turfs[get_turf(guard)] = TRUE + if(guard.move_intent == MOVE_INTENT_RUN) + guard.toggle_move_intent() + for(var/dx in 0 to 11) + for(var/dy in 0 to 6) + GLOB.stealth_test_dark_turfs[stealth_at(block, dx, dy)] = TRUE stealth_ai.stealth_update_light() - TEST_ASSERT(stealth_ai.stealth_light_shows(), "A guard in the dark has no pool") - TEST_ASSERT_EQUAL(get_turf(stealth_ai.torch), stealth_at(block, 6, 0), "The pool isn't 3 ahead of a guard facing south") - guard.setDir(EAST) - TEST_ASSERT_EQUAL(get_turf(stealth_ai.torch), stealth_at(block, 9, 3), "The pool didn't follow the guard's turn") - // A wall goes up where the pool was; after its next step the pool sits short of it, and smaller. - var/turf/far_wall = stealth_at(block, 9, 3) - far_wall.ChangeTurf(/turf/closed/wall) + TEST_ASSERT(stealth_ai.stealth_light_shows(), "A guard in the dark has no beam") + var/obj/effect/abstract/stealth_torch/torch = stealth_ai.torch + TEST_ASSERT_EQUAL(get_turf(torch), get_turf(guard), "The lamp isn't on the guard's tile") + TEST_ASSERT_EQUAL(torch.light_dir, EAST, "The beam doesn't point the way the guard faces") + TEST_ASSERT_EQUAL(torch.beam_x, -0.5, "The beam doesn't start half a tile ahead of a guard facing east") + TEST_ASSERT_EQUAL(torch.beam_y, 0, "A beam facing east starts off to one side") + // A turn of 90 degrees shows the beam halfway, then lands. + guard.setDir(NORTH) + TEST_ASSERT_EQUAL(torch.light_dir, NORTHEAST, "A quarter turn didn't pass the beam through the diagonal") + stealth_ai.stealth_torch_settle(stealth_ai.torch_serial) + TEST_ASSERT_EQUAL(torch.light_dir, NORTH, "The beam didn't land on the new facing") + TEST_ASSERT_EQUAL(torch.beam_y, -0.5, "The beam doesn't start half a tile ahead of a guard facing north") + TEST_ASSERT_EQUAL(torch.beam_x, 0, "A beam facing north starts off to one side") + // A turn of its own: the beam goes halfway first, while the body still faces the old way. + stealth_ai.stealth_turn_to(EAST) + TEST_ASSERT_EQUAL(guard.dir, NORTH, "A guard's own turn has no tell") + TEST_ASSERT_EQUAL(torch.light_dir, NORTHEAST, "The beam didn't lead a turn the guard makes on its own") + stealth_ai.stealth_finish_turn(EAST, stealth_ai.turn_planned_at) + TEST_ASSERT_EQUAL(guard.dir, EAST, "The guard didn't finish its turn") + TEST_ASSERT_EQUAL(torch.light_dir, EAST, "The beam didn't land when the led turn finished") + TEST_ASSERT(!stealth_ai.torch_pass, "A led turn passed through the halfway point a second time") + // A turn it drops: the beam goes back. + stealth_ai.stealth_turn_to(SOUTH) + TEST_ASSERT_EQUAL(torch.light_dir, SOUTHEAST, "The beam didn't lead the second turn") + stealth_ai.stealth_drop_turn() + TEST_ASSERT_EQUAL(torch.light_dir, EAST, "A dropped turn left the beam off to the side") + // One step at a walk: the lamp moves at once, the beam half a tile behind it until it settles. + guard.forceMove(stealth_at(block, 3, 3)) + TEST_ASSERT_EQUAL(get_turf(torch), stealth_at(block, 3, 3), "The lamp didn't follow the guard's step") + TEST_ASSERT_EQUAL(torch.beam_x, 0, "A step at a walk didn't hold the beam half a tile back") + stealth_ai.stealth_torch_settle(stealth_ai.torch_serial) + TEST_ASSERT_EQUAL(torch.beam_x, -0.5, "The beam didn't land after the step") + // Further than a step (a shove, a teleport): no half step. + guard.forceMove(stealth_at(block, 6, 3)) + TEST_ASSERT_EQUAL(get_turf(torch), stealth_at(block, 6, 3), "The lamp didn't follow the guard") + TEST_ASSERT_EQUAL(torch.beam_x, -0.5, "A jump of three tiles held the beam back") + // Searching, standing: one side, back, the other side, back. + // Its sweep runs only while its AI does (a dormant level sweeps nothing). + stealth_ai.stealth_go_searching(stealth_at(block, 8, 3)) + TEST_ASSERT(stealth_ai.stealth_scanning() || !stealth_ai.sweeping, "A guard whose AI is off sweeps its beam") + stealth_ai.set_ai_status(AI_STATUS_ON) + stealth_ai.stealth_update_light() + TEST_ASSERT(stealth_ai.sweeping, "A searching guard with its light on doesn't sweep") + stealth_ai.torch_moved_at = 0 + stealth_ai.turned_at = 0 + var/side = stealth_ai.look_side + stealth_ai.stealth_sweep_tick() + TEST_ASSERT_EQUAL(torch.light_dir, turn(EAST, 45 * side), "The sweep's first move isn't 45 degrees to a side") + stealth_ai.stealth_sweep_tick() + TEST_ASSERT_EQUAL(torch.light_dir, EAST, "The sweep didn't come back to the middle") + stealth_ai.stealth_sweep_tick() + TEST_ASSERT_EQUAL(torch.light_dir, turn(EAST, -45 * side), "The sweep didn't go to the other side") + stealth_ai.stealth_sweep_tick() + TEST_ASSERT_EQUAL(torch.light_dir, EAST, "The sweep didn't end in the middle") + // A step interrupts it; calm again, it stops. + stealth_ai.stealth_sweep_tick() guard.forceMove(stealth_at(block, 7, 3)) - TEST_ASSERT_EQUAL(get_turf(stealth_ai.torch), stealth_at(block, 8, 3), "The pool didn't stop short of a wall after a step") - TEST_ASSERT(stealth_ai.torch.light_range < 2.5, "A pool a tile off is as wide as one 3 off") - var/obj/effect/abstract/stealth_torch/old_torch = stealth_ai.torch - GLOB.stealth_test_dark_turfs[stealth_at(block, 6, 3)] = FALSE + TEST_ASSERT_EQUAL(torch.light_dir, EAST, "A step left the beam off to the side") + stealth_ai.stealth_go_unaware() + stealth_ai.stealth_sweep_tick() + TEST_ASSERT(!stealth_ai.sweeping, "A calm guard keeps sweeping") + for(var/dx in 0 to 11) + for(var/dy in 0 to 6) + GLOB.stealth_test_dark_turfs[stealth_at(block, dx, dy)] = FALSE + qdel(guard) + TEST_ASSERT(QDELETED(torch), "A deleted guard left its lamp behind") + qdel(block) + +/// Decision 41, real lighting: the beam is a wedge. It lights 1 to 4 tiles ahead and the tiles beside 2 and 3 +/// ahead; the guard's own tile, its sides, its back, 5 ahead and two tiles off the line stay dark. A wall stops it. +/datum/unit_test/voidcrew_stealth_light_beam + +/datum/unit_test/voidcrew_stealth_light_beam/Run() + var/datum/turf_reservation/block = stealth_block(12, 9) + TEST_ASSERT_NOTNULL(block, "No room for the test") + stealth_unlist(block, 12, 9) + TEST_ASSERT(stealth_tile_is_dark(stealth_at(block, 5, 4)), "Reserved test space isn't dark, so the light can't be tested") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 4) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + stealth_ai.stealth_update_light() + TEST_ASSERT(stealth_ai.stealth_light_shows(), "A guard standing in the dark didn't switch its light on") + stealth_settle_light() + // offsets from the guard (ahead, aside) + var/list/lit = list(list(1, 0), list(2, 0), list(3, 0), list(4, 0), list(2, 1), list(2, -1), list(3, 1), list(3, -1)) + var/list/dark = list(list(0, 0), list(-1, 0), list(0, 1), list(0, -1), list(-1, 1), list(5, 0), list(6, 0), list(3, 2), list(3, -2), list(1, 2)) + for(var/list/offset as anything in lit) + TEST_ASSERT(!stealth_tile_is_dark(stealth_at(block, 2 + offset[1], 4 + offset[2])), "The beam doesn't light [offset[1]] ahead, [offset[2]] aside") + for(var/list/offset as anything in dark) + TEST_ASSERT(stealth_tile_is_dark(stealth_at(block, 2 + offset[1], 4 + offset[2])), "The beam lights [offset[1]] ahead, [offset[2]] aside") + // The beam is what the guard's own "is my spot dark" test leaves out, wherever it lands. + TEST_ASSERT(stealth_tile_is_dark(stealth_at(block, 4, 4), no_guard_lights = TRUE), "A tile lit only by a guard's beam isn't dark without guard lights") + TEST_ASSERT(stealth_room_is_dark(stealth_at(block, 4, 4)), "A tile lit only by a guard's beam isn't dark by the room's light") + // Turned north, the wedge turns with it. + guard.setDir(NORTH) + stealth_ai.stealth_torch_settle(stealth_ai.torch_serial) + stealth_settle_light() + TEST_ASSERT(!stealth_tile_is_dark(stealth_at(block, 2, 6)), "The beam doesn't light 2 ahead of a guard facing north") + TEST_ASSERT(stealth_tile_is_dark(stealth_at(block, 4, 4)), "The beam still lights where the guard used to face") qdel(guard) - TEST_ASSERT(QDELETED(old_torch), "A deleted guard left its pool behind") + stealth_settle_light() + TEST_ASSERT(stealth_tile_is_dark(stealth_at(block, 2, 6)), "The beam stayed lit after its guard was gone") + // A wall two tiles ahead: lit up to it, dark past it. + var/turf/wall = stealth_at(block, 4, 4) + wall.ChangeTurf(/turf/closed/wall) + guard = stealth_guard(block, 2, 4) + stealth_ai = stealth_ai(guard) + stealth_ai.stealth_update_light() + stealth_settle_light() + TEST_ASSERT(!stealth_tile_is_dark(stealth_at(block, 3, 4)), "The beam doesn't light the tile before a wall") + TEST_ASSERT(stealth_tile_is_dark(stealth_at(block, 5, 4)), "The beam lights the tile behind a wall") + qdel(guard) + qdel(block) + +/// Decision 41: a lit flashlight carried behind an unaware guard that stands in the dark makes it suspicious, never +/// alert, and it turns to look. Unlit, out of the light's reach, or in a lit room, it draws nothing. +/datum/unit_test/voidcrew_stealth_stray_light + +/datum/unit_test/voidcrew_stealth_stray_light/Run() + var/datum/turf_reservation/block = stealth_block(14, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + for(var/dx in 0 to 13) + for(var/dy in 0 to 4) + GLOB.stealth_test_dark_turfs[stealth_at(block, dx, dy)] = TRUE + var/mob/living/carbon/human/person = stealth_person(block, 6, 2) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 9, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + TEST_ASSERT_EQUAL(stealth_carried_light(person), 0, "Someone with no light counts as carrying one") + // Three tiles behind it in the dark, no light: nothing. + stealth_scans(guard, 4) + var/list/entry = stealth_ai.notice_map[REF(person)] + TEST_ASSERT(isnull(entry) || entry[1] == 0, "A guard built notice on someone behind it in the dark ([entry?[1]])") + // The same with a lit flashlight in hand. + var/obj/item/flashlight/held = allocate(/obj/item/flashlight, get_turf(person)) + TEST_ASSERT(person.put_in_hands(held), "Test fixture: the flashlight can't be held") + held.attack_self(person) + TEST_ASSERT(held.light_on, "Test fixture: the flashlight didn't switch on") + TEST_ASSERT(stealth_carried_light(person) >= 3, "A lit flashlight in hand reaches [stealth_carried_light(person)] tiles") + for(var/i in 1 to 6) + stealth_scans(guard, 1) + if(stealth_ai.stealth_state() != "unaware") + break + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "suspicious", "A lit flashlight behind a guard in the dark made it [stealth_ai.stealth_state()]") + entry = stealth_ai.notice_map[REF(person)] + TEST_ASSERT(entry[1] <= 1, "A light behind a guard filled its notice past suspicious ([entry[1]])") + TEST_ASSERT_EQUAL(guard.dir, WEST, "The guard didn't turn to the light") + qdel(guard) + // Out of the light's reach: nothing. + person.forceMove(stealth_at(block, 1, 2)) + guard = stealth_guard(block, 9, 2) + stealth_ai = stealth_ai(guard) + stealth_scans(guard, 6) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A light 8 tiles behind a guard drew its notice") + qdel(guard) + // In a lit room a flashlight is nothing to wonder at. + person.forceMove(stealth_at(block, 6, 2)) + GLOB.stealth_test_dark_turfs[stealth_at(block, 9, 2)] = FALSE + guard = stealth_guard(block, 9, 2) + stealth_ai = stealth_ai(guard) + stealth_scans(guard, 6) + TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A flashlight behind a guard in a lit room drew its notice") + entry = stealth_ai.notice_map[REF(person)] + TEST_ASSERT(isnull(entry) || entry[1] == 0, "A flashlight behind a guard in a lit room built notice ([entry?[1]])") + for(var/dx in 0 to 13) + for(var/dy in 0 to 4) + GLOB.stealth_test_dark_turfs[stealth_at(block, dx, dy)] = FALSE qdel(block) /// Real lighting: in a dark room the guard's pool lights what it lands on and nothing behind it. From 655ec01722126efab5083d525e930fa868feebaa Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Wed, 11 Nov 2026 18:59:44 -0800 Subject: [PATCH 33/78] Guards see through a scav pass shown again soon after they waved it on, and drop seven unused stealth defines --- voidcrew/_DEFINES/stealth.dm | 13 ++--- voidcrew/modules/stealth/stealth_ai.dm | 5 ++ voidcrew/modules/stealth/stealth_disguise.dm | 24 +++++++++ .../unit_tests/voidcrew_stealth_disguise.dm | 52 ++++++++++++++++++- 4 files changed, 85 insertions(+), 9 deletions(-) diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index 8d296d3801b..48a06048696 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -56,10 +56,8 @@ #define STEALTH_SCAN_INTERVAL (1 SECONDS) #define STEALTH_SIGHT_RANGE 8 #define STEALTH_ALERT_MAX_RANGE 7 -#define STEALTH_DARK_SIGHT_RANGE 4 #define STEALTH_DARK_LUMCOUNT 0.2 #define STEALTH_DARK_MULT 0.5 -#define STEALTH_CLOSE_RANGE 2 /// Elbow to elbow: someone this close in its cone is seen whatever the light (decision 31) #define STEALTH_ADJACENT_RANGE 1 /// Point-blank (decision 32): someone it can see in its cone this close is an alert on that look @@ -68,9 +66,6 @@ #define STEALTH_NEAR_RANGE 4 #define STEALTH_NEAR_MULT 3 #define STEALTH_CONE_HALF_ANGLE 60 -#define STEALTH_WARY_HALF_ANGLE 75 -#define STEALTH_SEARCH_HALF_ANGLE 90 -#define STEALTH_NOTICE_RATE 1.0 #define STEALTH_NOTICE_MIN_FALLOFF 0.25 #define STEALTH_SUSPICIOUS_AT 1.0 #define STEALTH_ALERT_AT 2.5 @@ -85,7 +80,6 @@ #define STEALTH_SEARCHING_MULT 2 #define STEALTH_WARY_MULT 1.5 #define STEALTH_MAX_CANDIDATES 8 -#define STEALTH_INVESTIGATE_DELAY (2 SECONDS) #define STEALTH_LOOK_AROUND_TIME (4 SECONDS) #define STEALTH_SUSPICIOUS_TIMEOUT (12 SECONDS) #define STEALTH_LOSE_TARGET_TIME (4 SECONDS) @@ -206,8 +200,6 @@ #define STEALTH_TURN_LEAN 3 /// How long the lean takes to show and to go #define STEALTH_TURN_LEAN_TIME (0.2 SECONDS) -/// After a turn where it stands, nothing is plain to it at a glance for this long (yellow; the skill holds the number) -#define STEALTH_TURN_GRACE (1 SECONDS) #define FACTION_SCAV "scav" @@ -244,6 +236,11 @@ #define STEALTH_CHALLENGE_LEASH 2 /// How long a guard that read their pass lets them be #define STEALTH_PASS_TIME (5 MINUTES) +/// Someone it waved on is stopped again (the pass came off and went back on) within STEALTH_PASS_RECHECK_COOLDOWN of a +/// wave, or after STEALTH_PASS_RECHECK_MAX waves within STEALTH_PASS_RECHECK_MEMORY: it sees through them instead. +#define STEALTH_PASS_RECHECK_COOLDOWN (60 SECONDS) +#define STEALTH_PASS_RECHECK_MEMORY (5 MINUTES) +#define STEALTH_PASS_RECHECK_MAX 2 /// How long a guard remembers the wearer of a disguise it saw through (a face it remembers for good) #define STEALTH_MADE_TIME (5 MINUTES) /// Tiles within which a guard has a word for one of its own diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index db0c765351d..50570780044 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -258,6 +258,7 @@ heard_now = null made = null passes = null + waved = null challenge = null start_turf = null return ..() @@ -589,6 +590,10 @@ bark_ready_at[kind] -= time for(var/key in stop_skip_until) stop_skip_until[key] -= time + for(var/key in waved) + var/list/stamps = waved[key] + for(var/index in 1 to length(stamps)) + stamps[index] -= time // ===== The scan ===== diff --git a/voidcrew/modules/stealth/stealth_disguise.dm b/voidcrew/modules/stealth/stealth_disguise.dm index 518162fdc2b..c8bbf53b543 100644 --- a/voidcrew/modules/stealth/stealth_disguise.dm +++ b/voidcrew/modules/stealth/stealth_disguise.dm @@ -181,6 +181,8 @@ var/list/made /// REF(mob) => world.time until which it lets them be, after it checked their pass var/list/passes + /// REF(mob) => list of world.time it waved them on after reading their pass (stealth_rechecked()) + var/list/waved /// Weakref to whoever it has stopped to check var/datum/weakref/challenge /// Where they stood when it stopped them @@ -317,6 +319,23 @@ greeted = world.time + STEALTH_GREET_COOLDOWN stealth_bark(prob(25) ? STEALTH_BARK_SMOKE : STEALTH_BARK_GREET, null, stealth_card_name(who)) +/** + * Whether stopping the one under `key` again is a stop too many: it waved them on within + * STEALTH_PASS_RECHECK_COOLDOWN, or STEALTH_PASS_RECHECK_MAX times within STEALTH_PASS_RECHECK_MEMORY. The same shape + * as a door's cue throttle (stealth_doors.dm), so taking the pass off and on can't pull a guard over again and again. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_rechecked(key) + var/list/stamps = waved?[key] + if(!stamps) + return FALSE + for(var/index in length(stamps) to 1 step -1) + if(world.time - stamps[index] > STEALTH_PASS_RECHECK_MEMORY) + stamps.Cut(index, index + 1) + if(!length(stamps)) + LAZYREMOVE(waved, key) + return FALSE + return length(stamps) >= STEALTH_PASS_RECHECK_MAX || world.time - stamps[length(stamps)] < STEALTH_PASS_RECHECK_COOLDOWN + /** * Stops `who` to see their pass: suspicious of them, facing and pointing at them, with the challenge line. From * here stealth_check_challenge() decides, once a scan. @@ -325,6 +344,10 @@ var/mob/living/guard = pawn if(QDELETED(who) || stealth_driven() || stealth_state() == STEALTH_ALERT || challenge?.resolve() == who) return + // Waved on a moment ago, or too often: a pass that keeps coming off is no pass (decision 40 throttle). + if(stealth_rechecked(REF(who))) + stealth_blow(who) + return var/turf/where = get_turf(who) if(stealth_state() == STEALTH_SUSPICIOUS) investigated = FALSE @@ -394,6 +417,7 @@ return stealth_bark(STEALTH_BARK_ID_PASS, null, stealth_card_name(who), TRUE) LAZYSET(passes, key, world.time + STEALTH_PASS_TIME) + LAZYADDASSOCLIST(waved, key, world.time) stealth_go_unaware() return if(!warned && world.time - checked_at >= STEALTH_CHALLENGE_WARN_TIME) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_disguise.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_disguise.dm index 883a38d51d8..4d2be591355 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_disguise.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_disguise.dm @@ -163,12 +163,62 @@ stealth_scans(guard, 10) TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "unaware", "A guard stopped someone again right after reading their pass") TEST_ASSERT_EQUAL(stealth_notice_of(guard, person), 0, "Someone it has passed gained notice") - // The pass comes off: the guard's leave goes with it. + // The pass comes off a while later: the guard's leave goes with it. + stealth_ai.stealth_rewind(61 SECONDS) TEST_ASSERT(person.dropItemToGround(person.wear_id), "The pass wouldn't come off") stealth_scans(guard, 1) TEST_ASSERT_EQUAL(stealth_ai.challenge?.resolve(), person, "With the pass gone the guard didn't stop them again") qdel(block) +/// Taking the pass off and on to pull a guard over: a second stop within 60 s of a wave, or a third within 5 min, sees +/// through them. Waves older than 5 min are forgotten. +/datum/unit_test/voidcrew_stealth_disguise_recheck + +/datum/unit_test/voidcrew_stealth_disguise_recheck/Run() + var/datum/turf_reservation/block = stealth_block(20, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + for(var/how in list("at once", "third time")) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 8, 2) + stealth_dress(person) + var/waves = how == "at once" ? 1 : 2 + for(var/wave in 1 to waves) + if(wave > 1) + stealth_ai.stealth_rewind(61 SECONDS) + TEST_ASSERT(person.dropItemToGround(person.wear_id), "[how]: the pass wouldn't come off") + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.challenge?.resolve(), person, "[how]: a minute after a wave the guard didn't stop them") + stealth_dress(person, FALSE, FALSE, TRUE) + else + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(stealth_ai.challenge?.resolve(), person, "[how]: the guard didn't stop someone in the whole set") + stealth_scans(guard, 1) + stealth_ai.stealth_rewind(2 SECONDS) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(guard.npc_last_bark, "stealth_id_pass", "[how]: wave [wave] didn't pass") + TEST_ASSERT_EQUAL(length(stealth_ai.waved?[REF(person)]), wave, "[how]: the guard didn't count wave [wave]") + if(how == "third time") + stealth_ai.stealth_rewind(61 SECONDS) + TEST_ASSERT(person.dropItemToGround(person.wear_id), "[how]: the pass wouldn't come off") + stealth_scans(guard, 1) + TEST_ASSERT_NULL(stealth_ai.challenge?.resolve(), "[how]: the guard stopped them once more instead of seeing through it") + TEST_ASSERT(stealth_ai.made?[REF(person)] > world.time, "[how]: the guard doesn't remember who it saw through") + TEST_ASSERT_EQUAL(guard.npc_last_bark, "stealth_blown", "[how]: the guard saw through them without a word") + TEST_ASSERT(!stealth_ai.stealth_fooled(person), "[how]: the disguise still holds for that guard") + qdel(guard) + qdel(person) + // Old waves are forgotten. + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + LAZYADDASSOCLIST(stealth_ai.waved, "someone", world.time) + LAZYADDASSOCLIST(stealth_ai.waved, "someone", world.time) + TEST_ASSERT(stealth_ai.stealth_rechecked("someone"), "Two fresh waves didn't count") + stealth_ai.stealth_rewind(5 MINUTES + 1 SECONDS) + TEST_ASSERT(!stealth_ai.stealth_rechecked("someone"), "Waves over 5 minutes old still counted") + TEST_ASSERT_NULL(stealth_ai.waved?["someone"], "Old waves weren't cleared") + qdel(block) + /// No pass: asked again at 3 s, blown at 6 s. Walking off or running is blown at once. A pass put on in time passes. /datum/unit_test/voidcrew_stealth_disguise_fail From 84b460e7509da40b0ff5317a9d37f9ad52f377a9 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Thu, 12 Nov 2026 08:49:34 -0800 Subject: [PATCH 34/78] A guard that waves someone on doesn't also nod at them straight after; the beam and pass-recheck tests hold when run alone The light beam test walls off the whole room instead of one tile (tg lights a tile by its corners, so a lone pillar leaves the tile behind it half lit) and applies its lamp's light itself when SSlighting is still on the boot backlog. The recheck test reads that the blown line was said from its cooldown, since the spot line follows it at once. --- voidcrew/modules/stealth/stealth_disguise.dm | 2 ++ .../unit_tests/voidcrew_stealth_disguise.dm | 3 ++- .../unit_tests/voidcrew_stealth_light.dm | 22 +++++++++++++------ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/voidcrew/modules/stealth/stealth_disguise.dm b/voidcrew/modules/stealth/stealth_disguise.dm index c8bbf53b543..c56c5d94738 100644 --- a/voidcrew/modules/stealth/stealth_disguise.dm +++ b/voidcrew/modules/stealth/stealth_disguise.dm @@ -416,6 +416,8 @@ if(world.time - checked_at < STEALTH_CHALLENGE_CHECK_TIME) return stealth_bark(STEALTH_BARK_ID_PASS, null, stealth_card_name(who), TRUE) + // Waving them on is the greeting: no nod straight after it. + greeted = world.time + STEALTH_GREET_COOLDOWN LAZYSET(passes, key, world.time + STEALTH_PASS_TIME) LAZYADDASSOCLIST(waved, key, world.time) stealth_go_unaware() diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_disguise.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_disguise.dm index 4d2be591355..f0f20a111a1 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_disguise.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_disguise.dm @@ -204,7 +204,8 @@ stealth_scans(guard, 1) TEST_ASSERT_NULL(stealth_ai.challenge?.resolve(), "[how]: the guard stopped them once more instead of seeing through it") TEST_ASSERT(stealth_ai.made?[REF(person)] > world.time, "[how]: the guard doesn't remember who it saw through") - TEST_ASSERT_EQUAL(guard.npc_last_bark, "stealth_blown", "[how]: the guard saw through them without a word") + // The spot line follows the blown one at once, so the last bark is "spot": the blown line's cooldown shows it was said. + TEST_ASSERT(stealth_ai.bark_ready_at["stealth_blown"] > world.time, "[how]: the guard saw through them without a word") TEST_ASSERT(!stealth_ai.stealth_fooled(person), "[how]: the disguise still holds for that guard") qdel(guard) qdel(person) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm index 8a3f3a04e51..1e4f886708c 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm @@ -4,12 +4,18 @@ // STEALTH_SENTRY_TURN_INTERVAL 8 s, STEALTH_SENTRY_GLANCE_TIME 2 s. /// Waits for tg's static lighting to apply what was just switched or moved (it updates on its own subsystem). -/datum/unit_test/proc/stealth_settle_light() +/// `target`: a lamp whose light is applied here if SSlighting hasn't got to it. A test run first in a world can find +/// SSlighting still holding the whole map's boot backlog (70,000 sources, not fired once 3 minutes in). +/datum/unit_test/proc/stealth_settle_light(atom/movable/target) sleep(1) for(var/i in 1 to 50) if(!length(SSlighting.sources_queue) && !length(SSlighting.current_sources)) return sleep(1) + var/datum/light_source/source = target?.light + if(source?.needs_update) + source.update_corners() + source.needs_update = LIGHTING_NO_UPDATE /// The guard switches its light on in the dark and while on edge, off in the light, and can't while it is cut out. /datum/unit_test/voidcrew_stealth_light_switch @@ -171,7 +177,7 @@ var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) stealth_ai.stealth_update_light() TEST_ASSERT(stealth_ai.stealth_light_shows(), "A guard standing in the dark didn't switch its light on") - stealth_settle_light() + stealth_settle_light(stealth_ai.torch) // offsets from the guard (ahead, aside) var/list/lit = list(list(1, 0), list(2, 0), list(3, 0), list(4, 0), list(2, 1), list(2, -1), list(3, 1), list(3, -1)) var/list/dark = list(list(0, 0), list(-1, 0), list(0, 1), list(0, -1), list(-1, 1), list(5, 0), list(6, 0), list(3, 2), list(3, -2), list(1, 2)) @@ -185,19 +191,21 @@ // Turned north, the wedge turns with it. guard.setDir(NORTH) stealth_ai.stealth_torch_settle(stealth_ai.torch_serial) - stealth_settle_light() + stealth_settle_light(stealth_ai.torch) TEST_ASSERT(!stealth_tile_is_dark(stealth_at(block, 2, 6)), "The beam doesn't light 2 ahead of a guard facing north") TEST_ASSERT(stealth_tile_is_dark(stealth_at(block, 4, 4)), "The beam still lights where the guard used to face") qdel(guard) stealth_settle_light() TEST_ASSERT(stealth_tile_is_dark(stealth_at(block, 2, 6)), "The beam stayed lit after its guard was gone") - // A wall two tiles ahead: lit up to it, dark past it. - var/turf/wall = stealth_at(block, 4, 4) - wall.ChangeTurf(/turf/closed/wall) + // A wall across the room two tiles ahead: lit up to it, dark past it. A lone wall tile wouldn't do: tg lights a + // tile by its corners, and the tiles beside the one behind a pillar still see the beam. + for(var/dy in 1 to 7) + var/turf/wall = stealth_at(block, 4, dy) + wall.ChangeTurf(/turf/closed/wall) guard = stealth_guard(block, 2, 4) stealth_ai = stealth_ai(guard) stealth_ai.stealth_update_light() - stealth_settle_light() + stealth_settle_light(stealth_ai.torch) TEST_ASSERT(!stealth_tile_is_dark(stealth_at(block, 3, 4)), "The beam doesn't light the tile before a wall") TEST_ASSERT(stealth_tile_is_dark(stealth_at(block, 5, 4)), "The beam lights the tile behind a wall") qdel(guard) From d6ab261db8c3efb8581bcb3091645f951044167f Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Thu, 12 Nov 2026 09:44:17 -0800 Subject: [PATCH 35/78] A guard's beam passes through the diagonal when it walks round a corner instead of snapping 90 degrees --- voidcrew/modules/stealth/stealth_light.dm | 22 ++++++++++++++----- .../unit_tests/voidcrew_stealth_light.dm | 13 +++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/voidcrew/modules/stealth/stealth_light.dm b/voidcrew/modules/stealth/stealth_light.dm index 15d6c1222f6..3a48e50cb52 100644 --- a/voidcrew/modules/stealth/stealth_light.dm +++ b/voidcrew/modules/stealth/stealth_light.dm @@ -166,6 +166,8 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) var/torch_aim = 0 /// The way the beam points for a moment in the middle of a turn, or 0 var/torch_pass = 0 + /// world.time of that turn: a step in the same tick (tg turns a walker before it moves) keeps it + var/torch_passed_at = 0 /// How far behind its tile the beam still is in the middle of a step, in tiles var/torch_lag_x = 0 var/torch_lag_y = 0 @@ -280,17 +282,22 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) stealth_update_light() return var/mob/living/guard = pawn + var/walked = isturf(old_loc) && isturf(guard.loc) && guard.move_intent == MOVE_INTENT_WALK && old_loc.z == guard.z && get_dist(old_loc, guard) == 1 torch_moved_at = world.time torch_aim = 0 - torch_pass = 0 + // A step that turns a corner keeps its turn's halfway point, so the beam doesn't snap round the corner. + if(torch_passed_at != world.time) + torch_pass = 0 torch_lag_x = 0 torch_lag_y = 0 sweep_step = 0 torch_serial++ - if(isturf(old_loc) && isturf(guard.loc) && guard.move_intent == MOVE_INTENT_WALK && old_loc.z == guard.z && get_dist(old_loc, guard) == 1) + if(walked) torch_lag_x = 0.5 * (guard.x - old_loc.x) torch_lag_y = 0.5 * (guard.y - old_loc.y) addtimer(CALLBACK(src, PROC_REF(stealth_torch_settle), torch_serial), STEALTH_TORCH_HALF_STEP) + else if(torch_pass) + addtimer(CALLBACK(src, PROC_REF(stealth_torch_settle), torch_serial), STEALTH_TORCH_TURN_STEP) stealth_place_torch() /// It turned from `old_dir`: the beam follows, through the halfway point when the turn is 90 degrees or more. @@ -306,11 +313,14 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) torch_pass = 0 sweep_step = 0 var/swing = stealth_swing(was, new_dir) - // Mid-step the half step's timer lands the beam; a turn on the spot gets its own. - if(abs(swing) > 45 && !torch_lag_x && !torch_lag_y) - torch_serial++ + // Mid-step (a diagonal step turns the walker after it moves) the half step's timer lands the beam; a turn on the + // spot gets its own. + if(abs(swing) > 45) torch_pass = turn(new_dir, swing > 0 ? -45 : 45) - addtimer(CALLBACK(src, PROC_REF(stealth_torch_settle), torch_serial), STEALTH_TORCH_TURN_STEP) + torch_passed_at = world.time + if(!torch_lag_x && !torch_lag_y) + torch_serial++ + addtimer(CALLBACK(src, PROC_REF(stealth_torch_settle), torch_serial), STEALTH_TORCH_TURN_STEP) stealth_place_torch() /// The beam lands: the half step or the halfway point of a turn is over. diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm index 1e4f886708c..92ab046e11f 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm @@ -132,6 +132,19 @@ guard.forceMove(stealth_at(block, 6, 3)) TEST_ASSERT_EQUAL(get_turf(torch), stealth_at(block, 6, 3), "The lamp didn't follow the guard") TEST_ASSERT_EQUAL(torch.beam_x, -0.5, "A jump of three tiles held the beam back") + // A walked corner (tg turns a walker, then moves it, in one tick): the beam passes the diagonal as it steps. + guard.setDir(NORTH) + guard.forceMove(stealth_at(block, 6, 4)) + TEST_ASSERT_EQUAL(torch.light_dir, NORTHEAST, "A step round a corner snapped the beam round") + stealth_ai.stealth_torch_settle(stealth_ai.torch_serial) + TEST_ASSERT_EQUAL(torch.light_dir, NORTH, "The beam didn't land after a step round a corner") + TEST_ASSERT_EQUAL(torch.beam_y, -0.5, "The beam didn't land half a tile ahead after a step round a corner") + // A diagonal step turns the walker after it moves: the beam still passes the diagonal. + guard.forceMove(stealth_at(block, 6, 3)) + guard.setDir(EAST) + TEST_ASSERT_EQUAL(torch.light_dir, NORTHEAST, "A turn just after a step snapped the beam round") + stealth_ai.stealth_torch_settle(stealth_ai.torch_serial) + TEST_ASSERT_EQUAL(torch.light_dir, EAST, "The beam didn't land after a turn just after a step") // Searching, standing: one side, back, the other side, back. // Its sweep runs only while its AI does (a dormant level sweeps nothing). stealth_ai.stealth_go_searching(stealth_at(block, 8, 3)) From c6b3513d929ce754230e67b74b281aadc98d11fd Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Thu, 12 Nov 2026 09:44:18 -0800 Subject: [PATCH 36/78] Light tests that read real lighting apply the guard's lamp themselves when a fresh world's lighting backlog hasn't reached it --- voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm | 8 ++++---- voidcrew/modules/unit_tests/voidcrew_stealth_light.dm | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm index 08e9b1f0f1c..1fb57b7c342 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_d32.dm @@ -73,7 +73,7 @@ var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) stealth_ai.stealth_update_light() TEST_ASSERT(stealth_ai.stealth_light_shows(), "A guard in the dark didn't switch its light on") - stealth_settle_light() + stealth_settle_light(stealth_ai.torch) // Its pool lands ahead of it (decision 39): the tile behind it stays dark. TEST_ASSERT(stealth_tile_is_dark(behind), "The guard's pool lights the tile behind it") stealth_scans(guard, 10) @@ -101,7 +101,7 @@ TEST_ASSERT_EQUAL(person.move_intent, MOVE_INTENT_WALK, "Test fixture: the person isn't walking") stealth_ai.stealth_update_light() TEST_ASSERT(stealth_ai.stealth_light_shows(), "A guard in the dark didn't switch its light on") - stealth_settle_light() + stealth_settle_light(stealth_ai.torch) // A walk round its back: behind, behind-diagonal and the tiles two back, every step a new tile. var/list/path = list(list(4, 3), list(4, 4), list(3, 4), list(3, 3), list(3, 2), list(4, 2), list(4, 3), list(3, 3)) for(var/list/step as anything in path) @@ -128,13 +128,13 @@ var/datum/ai_controller/basic_controller/human_npc/stealth/second_ai = stealth_ai(second) first_ai.stealth_update_light() TEST_ASSERT(first_ai.stealth_light_shows(), "The first guard didn't switch its light on in the dark") - stealth_settle_light() + stealth_settle_light(first_ai.torch) var/turf/spot = get_turf(second) TEST_ASSERT(!stealth_tile_is_dark(spot), "The first guard's pool doesn't reach the second, so this test proves nothing") TEST_ASSERT(stealth_tile_is_dark(spot, no_guard_lights = TRUE), "Without guard lights the second guard's spot isn't dark") second_ai.stealth_update_light() TEST_ASSERT(second_ai.stealth_light_shows(), "A guard in the dark left its light off because a friend's light was on it") - stealth_settle_light() + stealth_settle_light(second_ai.torch) second_ai.light_hold_until = 0 second_ai.stealth_update_light() TEST_ASSERT(second_ai.stealth_light_shows(), "A guard switched its light off because a friend's light was on it") diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm index 92ab046e11f..8c5cf8ff794 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm @@ -300,7 +300,7 @@ stealth_ai = stealth_ai(guard) stealth_ai.stealth_update_light() TEST_ASSERT(stealth_ai.stealth_light_shows(), "A guard standing in the dark didn't switch its light on") - stealth_settle_light() + stealth_settle_light(stealth_ai.torch) TEST_ASSERT(!stealth_tile_is_dark(spot), "The guard's pool doesn't light the tile it lands on") TEST_ASSERT(!stealth_tile_is_dark(stealth_at(block, 6, 2)), "The guard's pool doesn't light the tile past it") TEST_ASSERT(stealth_tile_is_dark(get_turf(guard)), "The guard's pool lights its own tile") @@ -342,7 +342,7 @@ light.disabled_time = 0 stealth_ai.stealth_update_light() TEST_ASSERT(stealth_ai.stealth_light_shows(), "A searching guard's light didn't come on") - stealth_settle_light() + stealth_settle_light(stealth_ai.torch) TEST_ASSERT_EQUAL(stealth_ai.stealth_range_onto(body_turf), profile.sight_range, "A guard's pool doesn't light the body it lands on") stealth_ai.next_body_scan = 0 stealth_ai.stealth_check_bodies() From 852b2e25fd3cc9806356104fb6dd833a6d6ae7dd Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Thu, 12 Nov 2026 11:13:38 -0800 Subject: [PATCH 37/78] Guards' flashlight beams show as a soft cone of light from the lamp, with a small glow at the hand The cone sits on tg's overlay-light plane like tg's own flashlight cones, follows the beam's turns and sweeps, and is cut at the first wall or solid door ahead. It is only for the eye: the real lamp, guard sight and dark tiles are unchanged. --- voidcrew/_DEFINES/stealth.dm | 4 + voidcrew/icons/effects/stealth_beam.dmi | Bin 0 -> 25913 bytes voidcrew/modules/stealth/stealth_ai.dm | 1 + voidcrew/modules/stealth/stealth_light.dm | 93 ++++++++++++++++++ .../unit_tests/voidcrew_stealth_light.dm | 51 ++++++++++ 5 files changed, 149 insertions(+) create mode 100644 voidcrew/icons/effects/stealth_beam.dmi diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index 48a06048696..f578a4a2310 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -183,6 +183,10 @@ #define STEALTH_TORCH_SPUTTER_FLASH (0.1 SECONDS) /// Loudness of the click when a guard switches its light #define STEALTH_TORCH_CLICK_VOLUME 25 +/// The visible cone (decision 42) comes in this many lengths, an eighth of a tile apart; the last is an open beam +#define STEALTH_BEAM_LENGTHS 22 +/// Pixels from the guard's tile centre to its icon's centre (stealth_beam.dmi is 128x192, the guard at its bottom middle) +#define STEALTH_BEAM_PIVOT 96 /// A lit light someone carries within this many tiles of an unaware guard standing in the dark draws its notice /// even behind it (never further than the light itself reaches) #define STEALTH_STRAY_LIGHT_RANGE 5 diff --git a/voidcrew/icons/effects/stealth_beam.dmi b/voidcrew/icons/effects/stealth_beam.dmi new file mode 100644 index 0000000000000000000000000000000000000000..c04a750d95924a1f1e581f0b54bc6040b49c4522 GIT binary patch literal 25913 zcmeFZd011|_68h=id7LQT9GL#x6)QCq9Vu?yjW?gLX|33hNx5#5ds1dAj!d61r%)&+x=U63$+G4exr_ z+I#2B_g|;n{jvS?uI2b;t8#w7<$fa&C%AXSIJ148mA_mR zbRf2xapx%I^SWA@hm6#czdbn0q@wK5(VTO|&o<`^3WjbKrLL>olSXl3+2EnHPcm-x zD>q@U^u6T7BCg0G>cP1eZ>;jWd$jtleeK$dVS83YwQMptu|W4T{hhP#El6JWy~old zcOwH=i}sI%x7ZGA*VT2lVhRp1cdv8LTk>nuJm!&E{`Puzy2QH8&o>#Y{rmZ*kF`&8 zwNHlHCnNOfMSxoJ&Cwk_T?TTUHJst=9&VrA!eD;V`*!oDABeAq+S_+pJjw3mgEk-k z=k}5O;q3l?@|w1fWWdL5A03KX8&(l49SF?(ZaEpdV8^i%m*p-adL!JpXOG-xFX&Fc z@$<9vYvn?jpEw3TA9#I zRe`M=?9I>WO?_@ZVlD-x;C_U!&zySE{f^}^uc6s#l94@yyS4?dh3gX39UZnf&W;FH zr|kENmzU=;WE9A2_PnV-`9(u$L0+Q|rx`+28O{gzL!DRfbaHD;)Orig7RO#!02f<+ zbeI!ID{@U=CVVE0g{;ya?5bmtoNaWqKr;UC5$vFyJ-0>%dSRxAiTsTVHH(vAipBml z7M^VmQYtCIpkgZkQ&!@P?d5#O){F3POh3=YzGg82(!7Jvj3#1OJ99E!w`QVhAO-YDi&!3 z&A6~hp)nDXo2MV-FB2@YJ$J#ntIt%Qbyg>2m>4JMEaLSy*6x(t;{|PBX>d!V!-az8 zpKMq{B{!UH{b7KV^h2#&ft8x2j6{)Ya$6DQbe)qhe#b=iZjc5rrI#VV^z1do8QtgBA(_40^di42U zv81BoZRu`udWJ74u(_P#Cf11@kjDrx#JUB2I8()IGxQ-y>prixxyLU2eI zhj%PvkNB?R!|xrvTowkdQ?>^SGo0{KV`8StCDLZ(x z$T{)~$B0!HHf9=WO1#(#Og975&(1d%Q9L@S>^eIf5>n0o^HjQo!FI9J&ojZBAr5qF;}{ej6YoaVa^Od>F#BLD#pryPmV-8cDGVr#>?f$ej_*vAcy z5eqB~QciH@QH8j{2YSxfI(t-a}rOJ`Yx+&m>qmy&34y*(^-8}Cfe(9n8XS7%Xh zXTsxKi0c++C<}}V>MUQQ-aZ$pa9lQxG!rw{PTry9ty!b9L&_SeXc(yy;*i>z~X#CTvp@8ABLA4s;{WOmKyK*Q1Nd#Ah})# zxpuuX$S9GUC?f1N)wNAc%o<%hIrGFZ$oOl*)HC$m`8XSY%t>^ikIS^{3(U6iVVv(G zg!VZ*=mxI)gnD_0@a3()c*oBN2VM*gY+fhLN_h41@ICvbB-t`yL(o$bgxniz7GM?X z;v!SBEJQUQ!W#qua1FWI$*S;*SA#y0wr8L~Q+((nic&^Q~7l%K`VhQt;uPH2r%m68Z0V9E~(on@rq;;@ZNrldig zafV@}U=d@cX_hXhn5u^pPD$@`D>_d2I`#Y&+bfC3yE)6hbfa(VzBB7#Tvt>EHKOWK zZFi!v@Fj}95rW@6DoDSy_IZw`#hRwy)Cgeg&-l^$1U1CdPtb;x!ep|_5E6bo> z#}~IEAf3Z(79~Ze&#orE#A!u_e+WX%xppM8|I99S0dn3=w$(eRXSUqhfa!``wZ;KW zb?PZ{F@;EU6qUvv)1c&Tiqumd#8U(6bJ4nvRWF{>iVwl+1gr7>|dX_?SqK5|SF z_soRW8Z__UK7$Uc+k#gy*6R*i_76Gt`k9e>sn<$iCCgy`!-nkZP>=@cw5Z|5b%Uqw zjr0!=_5XYtnsnJQC(#a{qoKpvka;zYPKk~$n%dJ*ht&0RUPHAuV#c2aeLSExJ7qr2 zJ5?s$?|TM{8hkKXvdyzJzpjE#4mS#@ETdkNGAh|*!f#4GP=Mg}sE`y77Sq*3U{7o4 zV5q1RZ@YgPOb$OAP2zZ!x5`^1DMBg=W~M`Cs#yWdIMi9jreBX*<0851xbLW=y*j`Q zBTFIqfnJ3!`s)4eQuTj~7<1HaXiQltd9FAx6dJyC@`aV{UEy3i(nzl+)D1Lg!Y*bT#HAZzR;Re_T&{U$RH50Rv>(95hF^gh0vuZDHVY*iS zwI}W)`He!tpxtOz{HvEjhx);Po%iuA7gz@L>ant1tsix?x@RxZlcva|8gMaaKt8!6XY6^+ZC!ESj?uHfXffS(;_;lg$siW#2n!d9v38E^2kw z-)4f1g0BJ|H^Xfd+X#9}=s03u31wd+2#n$^lpfen*eb4v>9DJ4=tlY}6P-z-Gaaq_ zkq{&o9CHn<;vtb(*3kAlSPV8)-@?We zk$=1GGtz3B zCs6;|$r98VrZk*QmzA^oEY=q&oNXz?_4{WRfUpt@M;wnXB=s#I_P0bcjzS!o5{Mp< zt47;~XQ&UYxnMTz4QM1BoK~3*2jseww#6Liz1@Z;y)0i%V3Y&}$T^*HU5b*Nt+shI zLV%)-6z5c#$K+9sefTjqJ5~$q&JKiRIYHim#dB0{hRsw&N(PjCItYuht%U-M21whsmvq|hT zl|Bpj!a1MVuBB56^H8W!H?wUkR@uYl(Wg&>j@{p{5yX8ox=`aWxlJxz6)C&){`-yx-Rk+)TZX+(7z*PAfxbG?te zWt%A5H!)3mOVOxT)WP;Z?| zGE*|5Wn;t?6<$hR*B4+$syc4~_W!``$S#VbJjtuE^j%{bXeJw_0uG+0y4Wa8`Ehxx znJV1OmOZzKvlVoG=www~l#Q@zD{SKCA-1)fg%c>2bR1#=iu>G{0K?{8-}>lK!FAA#Zy zkbXZ@un?)FMN*5B>S2Msl26WBzm8GA^7PM<-F8>Ulvx6}M%>8`rQA9^j3`2?IZGAE z07&X)+f8V3l1XX{sEHT=HGBOvESg_J3*oCS0IB3Y6L)oR=9^}RJiWZ zDF82fSe0P64j!^hs4<@95*5_Z+>i~0QvXW;6$tNHQl`1He;5#8? zVxPHlpG$t4syl@2vJLIU^u=LiO|$@P56d6h1I0ARN!tRNl!Gzz zeiuLG87+zZ%COp7;pQck;dsWyT8p7jiVgWa%Zb{-ajq`x4N3`0`PEjQ#GD*#JSy=j z+ljbD^-&4S7WhHeCw2A$_s1D)!<7fvD{(p2DKUG!dD--|8&GJ#CTHMz(-ZD&>zrmD z+~^AkEZd$1R5;hET}PY)K5}ykx0#qB;H7EM0kLx{UzMB}zT})_nMLMYI4NmVlqSJ$ z6T?h64)6--*UF3vt`XcHp6NEOTg>uh@}NUu=V^ z4t{j#4ce2qj2ur$!iN@o(owpX=+p_F?Z^Xjto8Ay((LBLA>7` zh1bHQ7;Cdt!nN>L?VpbOZtM)-tuj7c5oI)t zUE7^(GVi2#8C|CSPZYb=|H=1`-t$(!tfKpQKy^=zg>4tECeSfiK@?2eI^|bMjEov# zk%gxB%*wQ)a8HFUUEZN2@dgG4RP#?>41B=Ge7>Rp&R#(QXn6_jRL0&q{zJ567;`QB zQw|W9Mt_pSptQ;OpglymW2t8wF#ZqSi9-_@Oh;4S)WB!{t@c> z$}do!$+OlJ#XmMO_;Zo3q~24V`7A);H=!x|P$-l12c64fNVg_X%Hw(s{%-E@dg%sD zR^*ewg_gf>`CzI5aA3GjaEhf$7MOpc_a@OPrfnDNxZ_hEpUZIEYwH*Ftb(n)g=36d zQaLvVHREue)e*`+p3O@apFiyy<#E3GSC_i-db^I}bu3d=N}X-Uyp9(DwDJbMBH!ZJ zBH?{PLLcBa2!;00+S__!?)mvW58% z7++6GSp(Wd*>_~~u8VIod^}R4|6FPB?TV8{_aBVw{qA9$+9I&;2{^L(r1JJtA8)R{ zudcTzTwFaBfy37w(d`BIrqQ|*R2r2XGm3opq{_hN$s(Fm3Fp6-bIqvAJY zB0)`r4^E1khKUVunoAflBeO%)bX?(5rZ4mLzXHpP5iLrX3cC)#0cGGUFkPj z1ls&^jil|<0k&!x4Iwf40j=Lc6VpUvn2&d83r4Y3c#|qv+`EPOV&hIhiD9oRt2?gC zz;J?=PV|μTX$ki*vV zHW725bs8i-bsSipkuD2>X7EXl69^@*S-*QJSx#kORUul&{NZl~N zOQ!~KIT-_-$VY{nGhbZ*qquWg`!`?zmAs`XmwTkX{~L1rmQ6oSO%c&mp_a;p6_0VF z4@Sw%wy;|gyB-r#V6T$5vTq^~r+vI{0%PATAk*I{J_9+se7P;YVX1S$p9!RAONkAp znsBPitnAXEX94FGzrG->uK~->ym)y3X_nqO^68~M6|#~mQ3bQyLiShPebCzY+N39p%`6t(48CG0W%0mOU|jPcbUx730pLm;OH zbY*+8n*0;CFhkN-mh_%V@2Q9K=wPKe5DB@%GUyiW3+iV6qU^iC^H$)B*|8v3wA$p zZAwXW#84JH$xW9^E#NKNjMnn9>s>FkI-61J4HB)J4ao`Es=8DICJ=vBrRW)|_I1-A zCJS-9sl|MVUy(mbA%z-XT#M)>E9XN;(DwANjuA_bJ!PoWsu|;e@C5eEs0ZH`wchRTx}l(R01WBoZ1sg* z-#l1U2Rbzzu=ta=AHcrD(^4f(zzfZvl}l%-l%dtH5r zj{@6a#h0$GH_O-D2`p8H1u8lLevhlKj@LTE;+3;zy->tnF}uv6t(&P*RKpVr9V3cq zNW!~QoH%x-=Cl8?>%mfb{-V(mIH!@OE+kB93t z8*+sOqPKj2gX~s1Pp)f5J~~0rVA@~j5pEh;se5Z6g7nB$2e$>QJxe6wi~&W*GT}`T zBfenJDdxg!<#+jI13hJz82{lH$S)mlI@ytHr^`4l(c^z{6D!BnoJ74Y;E9PxVi4kY zesMVAEf<-LlId{m5&>z*L`t8CT8GyFclGDvy6XO>65^$o|7c3O$ZD@D3~(Gaa=F-n zG_snM&g#)vGUZ9e5qY%ukU2YSE?}{?R&w*K zPO(R6rQZ!V>hWHP_5u7TniJ)leMdfbYg&7tT@Q}()&HPtP1NIPz5BjVIY6=AM67i` z7ZKFzeSV7Q0foJHP_GVnZ{%Uwr6otDE&=h(b*|tWKSz-_xrx(AT(dr=JS^Hx?i}NH zn_y59S@w7(!KMPF1&8}Y>iJ^aVvv&buOxK3I%CC_fp@ew5!z$w8(aE)Uwg`=$v$TU zqql|;(o=gq>T?TAUrg#A2YFV4n{9cyq_g*{Om*;(9=O#AzPYHVs6~9DvqY9*Wco4B zwICvI8a*ej#%(cfG%G|Rr%&+ODZ6n{lQAYtHeaOvPeav(jXveBR=ccF^6~OZVC9u4aLu*#u3gMRPOT zGc?+KD39>K>ed~aZCd*?I-eILFOHSaVy$hEC)F2xe0YoYagMZG#jA1#6g~mh?7iFS zCrQ?nFxYX`XbGo-3(Obc-$4Zp;Q=^hk2yW=u?@u1%ZiHJO%dBte)a>xHB7(IL37KK zP=JKlTR7^Fkq%0spMS=>aP;@2TMa_DPqt(C2{{&!ur!crv}yzA!>uIlhSjPVrXip^B`!iuz>%dyB4RgT9OlfbF|7#RA4- zdOs-v z&TD+(EDy6}F@EmL_t)8g6?PJy-J|1>BxXP4Nt->H zm%0N^gHaxJCD6H32E;$2=C!SR?jMiFOrQ(+rdYHrLU1zC^<-x>bGGAdDiB*qvvW&5 z^^k4=q^oQLB=%BLV(e{?DfN95^YFCWfW8f zG|fQA&uH|y_!aH(euj_x)3CY4nXPw{o3ozB_e3a%`$`VnX7iwO(-Vx2?$ zGuPRdq{UhH3*c7`pT&^2m2d?;bN+f)Gw;gc0_VK1K0bD0`x0{rk@6&j?X2NuSv^iZ zv(n;|2Hz7$qqm!|RxBU>bPIEG~V(XBDt2d_1o#(Y1BOEKJoAI;z_jveU7g0+Foc z2RbJqQ+`Gy0D{j^%C*wiba)>X*OPI z8c&D~HyDCTWMIxI19dz;xc?#J-pF@Xql|P1rpnc6XC8BQw4&86g`%s{Eabo2)Sc8K zFS3`WTt44(f+BV1lbH90^+BBKN^y!ZCcPcC4C z>J}}_DY$eg*ed$R(wE#TE8Xh@G?C~|$?oI7z*=2Q{`^m4PlioI4ccYCvLvM@JE*~9 zII}J_?^PkhD=e?9h)L0d%Fgik#==A0npK90;wntBJxore(M>Pez|YXVEv;X<^sSRI z*@XqOU&a6E_Gl3{!D{wPJTU61{h4MDT7kwn)!4qsG=!+0`S$b&HORflvaulRK3T&+ z`IV1_MEJLaFKVf`kX71A_{}>&q?d(qV!`dSjbD@;HTAL$cw)PY+fjB#>Z(Zy+`vH! zl%@j@MU8rfuf8EY09^l*9sm4abmGb|*>_wQb6nz`l$cKT;5 zqQ=rBcL29X#ijNyy;5c8cb7w?H{iJs$IO^jCaBhHBwo$p&gi?& zNHNe)NNTHv*5blI)U!ex%f6tNb+>G(B6EqKQ@xu+C8E0}&`QXc&wjld>!T=y*L=4c z4qxx$db1hh%o<^q#@N7ZXg$X`I-scwxEz7nP3imxPC4DHn*!!(nTioegUpa(20+r0 zIvG^@YD}BhKkan`YKMujS_ zD`q4cNV^or)Sa}+G@Ol9D&uIUL5AP$2~E4yWQ(R7?FXU@BYu_b#|F!y8}&Mshub%n zM^~4`kNRPAO_APi4p;oD2{}MBz>GYqO&DgToq`YMjF9Ww6*MFDr76FdMAC__#F%@u zA=v*S0#Nqbm^nJF8@bRiebQpW;x*>z;-1zT239?)FOifHHp9;pYogH;?qLK~z?%EM zx_7V(FC}F45&v2q?{-KpLbIrOhG$AR|LgpbSIyhC>s^UaVziEZ>O62DZP}qfRs3*g zs*lkL6j~hh87s4G@!7Zc55N4ph`~MXV6ky|;5j@vU%~i*^iUWr*E;7Cg zDHB)zY^ftP(ja2JQ@ELyG58oJ}v5N3Qjt1=W`y$b&$VL*}XJkan6 zT-0L;=MsS)J>8IM(4+$EpuCRy>-f)@7-Jwmv84_zRZ9Phw}P;-=y;N&c0N@G=mLMW zWu&Atid6blc83EsX+TkOU9zF4Fdu%_+`0bi&1P=Lcki{!^h&)RypZG&c`w|r4o&LM zz~5j9=bO}4;uezxICaXbrKDf~4QMVj%`oDNF&j?dOZ$IyBEsv^5^V%6z&gO&*Lkql zuX~(X=0TU84UCE%ZekTEB{TtF@tI95T(ivgL~SZNj6c77Pq7|xK)NGPr+}hri_ExO zTJh#gtA3J%ZK4rBZS`O;!lV~?wKN21GsS-sOaRZwB{Px*8Vkq-^ws-@3jN&L*Q0IF zQxAjBYHBjeYQ$yT^D9RV8rNFyIzV?$Oz>nz#p>tOv^eCGfC?_YNM|yvC&$)Ka3ZF` z;rBWq)4`8NPN%jm(OM`n(4#YQG{M)RwM)w%y5&Du(0r|WS}zL33^`iN?DsKD+sJGP zI?|qNmeBUGi#>*5na??MAr^*5?G^)z#}nn$vqqv#LF09!4E2)tYsTsDpX=vfuN9%2 zR0HPg2ydEoHV3sSL-=3r%XbzZPt7SyCWg5nX1ESJv{bobS~&1!L`5vxu*WO%B}&PK z&Uk_TaS85iZ2}V-(JDflum3L@CeEHD*Ots_5pNAgxs*t}Kwe<>Q4v*n1aB9W#0~Fm zscP+%#dHt7th(?l`8uSNX&zg%g=P83r|3l6#5*w;8L~|T9QE+G$Go-7&=GdreuS-^Z zSpZj48c?-kR%d=5BfrGVf3JeTeEAKjKj<+W_I%vV-_CT733X`O;t>d4^?p-m+BYWJ zL&k++Q_!sngvv6oilQMYePOUyxWW#Ajp z2G|lWD6ms*H^HuCfpglf6jC$-<_}1->bsT5D&O%fIOC~h(qqSB7`0S2?3*A%K2)(x zB*F>ITafMw=c938D_COS$$so`k?wxs4^w?}9ae4)Shz;ttEp2Ko~9EK+UPu=;xM-o zZ{67-p*bI@=DFBYFiX)^Yhdx;MY6NeAF|mL{PJP^e;20Q^^(@bB32I+@&Y2YjTlF( zvs|A@Qb9K2B1)j$mf10&5%!n3(;azR3m>idbJ%h}?^J7j<6%;`yOpJ{;s}MbrPGE_ zGaAIcfKMcPD1&D@vhVj340LP-1&!!JqzTf1GaP3oJW1E^29VG|7Q^zm zwN*R7K!uytX_+g$F}8{6_~e)w+K}1T3lrTfJ94Wmq^+x=^klHF1-;VF zUTTR4NhQvRTkn_q3L~26xxA>D&;CkQY%0nFKUDXkl^H4-dUMP#8rxySW70F;u0O_U zTIZ)|Uow|4e4T5q*kk7s#&~uiySu$WSEBxp_|XEQd4or1-LqteL+I%y!rvLDaH-O_ zTxFS95nF!0U}P6$e5s?0>pnfe1gxWwK91<)@PRKz#H6#E@7hU-a^i`DDS z$d)9s(qjJ_`h&dauUzNOo%iUNi=PJCtmu%vVI9B}fCnbY$s|kB66yWORHihOWDceZ2qYvnb;n^vp|MTLoW^jrGk&0Tn;^oax#MGd zQVPi*DaixA(qJ}4w;A91Fk93*wKkGb-`S6xQz6f%fp-Srr0wG$LN&r%lE(rwj{J@i zdNaN>#W}XRp;_eQlG+tA#}_yoTRP{5_Cs}9?)iDHJ(oF`%f!LH8O-*04)*4(rYQtHgBY z#F4Yklmp#fS96_z-pQlUY}`Jb;vLf$TK@3}UMxedez>}uM2`QYwrcmYXopRjzkL z-ZE30lLZcXQ?vqqq`}R=(rMqDz5@60SB!h%uEeK=*A6eNbf85i+snEo8&U~U7GZ$J zjd5fc(vkbb_5d!qSlJMV|LAu4-!|J*ilUySl?G@g_p{B=>R8(XRR$^q>Uoif(YtY? ztwG00M-l3CIcM^U|FouVN7RyrpbMk&}GsL7QGHmx6CFo4GGxJ2_mEYYN|PSsmeSryGLfb0=UP~Jv~)D=#si|BwB^rmuOp#@`c7U>+V|NXnL1? zt%#&3rJa>U;mQSNM}Bx_fbJ>kS&%UBoqLpZXNg^$rVeSm030_iH2+}mjydilIQ=&Y z0>yX8{;3}_Z8+rX*QH;erj3lV?u^8^P!o%)#oWV1E<3qr*OmF4idI!pDK!)B`Skjh- zk`#Gys(`SLa53de5nIh#b~d6Yq)zjN;7w z9IR2fUZItiCITN#dWf@svkD(BToRnH=u*5s$$@D{)qX=Rg zcS<&d&*i-UWl2B|9QJq}Zg%;o2lF39bhjWQt$*tbzk**Q*)rI{dk|om=m`EsQqO2T zKK)n+gm||v{xz7gn)$wMr{ZwJs#V`6ffD0XUOMC2EpMTc=b*#3-H4tLESaCkH;zDQ zrzbQ2Hw9x$RndTX?XgvvP6ewgRaaEK!0;S*SDQInJIA4^X!^F3*C=B_3CrNPSQ}7{ z)@NagI}pYODQGMOd1?*7{yK3lgxG3?^hr~X!RK3wMgG1YsnWr8{=3PBZ0W65es4iL z%@tSK!4$=Y)^1Hx-18fDVx2`P!Jhk^(3d$VU3yL}wNpR3_? z$v=g>;S4f2_TpYBQ<9R%Ndf$z+1kGD2Y%3+L{N%ksg^xDhLkPIevJgy$N%1*Hye^`9ViYmSYWsxRlq)rL70t zpIt_`+WJ6$HbIzXNPVArn4~9fP+7v;CUM|x9*=^)H2s`LP^`m9!=jOUAYRXfq278Q zsi1pVS#bK34=LfD7y>rrE6qvlfLZb#`og@EZqNjwfnduaHp*aE&bPv4&duki1XkTac7$tfId~|5wscr5HM|L^> zAC)&>IC|+g8v4E}sEpXEbX&+G>UM4?;T{U)_8RmOcUoqbEte(bqX)`IB#457$X>@8 zUurh`x#m$dK9D?Clc=IUz?R3>&llvlln^x40axV9*DPO-Zqm&)dD?qG-d{zJe4y8< zMoXx?sH2~H>5_c2FhmQ4l3xSjxvK9SJ*(=6I`62!PoY~qX9&7E6wEzI9ey=KkubLZ zNw(yJ0h34+7)Crhdcv9lZ?bEJYIg#u0H+0Un`aB=p(>(~5!6954~1K2a%4dMT;}F& zh%lJXImoAV~qgn&U&8n_E~0#+ur>%zF%jK?O{gRNxhqe{>Z`x1Sa+ zRAugZ4ftpSIm)i4i|452qV?N@^fU8Ty1f~g3zp=4yC675w=;mXfauq@x`tq}GiG_` zdeO;K;d(p>iRm?Pzb>l8_}~^iSH_|nr9U{D4kkIa6}i|7q1_tgFJRea`ez$`ywgI^ zRh1k{AEErKwz@$ewrQv*N1%t&Of1F~g6Ur)0TM{mXmo;_>Q@1jVxBbw#Y-;FT*{ap z3u!yreb!s)X!XKs_V$1!O^QhO5n~#elVkicvaU&1*vH}Q9z+Lu6SsQSqLsf=|{LUW3g4YDcg8RHGXNyE+v zJ+vv_DgWy?x0}?Kb9DYszm7w;Y8#D!9KoRLKOP-P@<_FcAEDl00q(ZZfl*M@2;E={ z3?Gnc_*giUtoJ-hSEzgg(v1tzlYg|3f3%4Ye6-;uT;$d(1^rKR1}-^$ENtT-`M)7l zgAXFRQkx?pGDqJ4#$=m>ltsQKNdHg2!p;q7(xm;(#~oj3z@&Avbc6(B5z2`3%`m`i zZS$7hO;Q#Wygr{t(CuaDJT`$aDT1-~_y>|LDl8_^Iv(ZD9AZXtOU)=;m zqwH#oe04`nIgQKOF9?X#`9*ZD92MD9G{QN6@t=QAf)l`H14+`G6gk1CJ#Z&CBXNZM zPJ`+lchJK`m~lBjabcNT#{;lJ1w{%}d&#Mf4;~IEwsv56UsAq0;S#ybc!s5C#<0>O{niKrU)!fvFxJ z*r}bi#?C^73 zH%8hf7PlZi<4>eo!WN0YO%!ld-zI{at8AM@2jvw>T`__c9qBL+0^x@hBj=D2NVZ)B z5fxBuLC0|t{ynmSHV|e?gJC+8^M&gFIIwLM1&$9)JQYsnh&Q;+J1tjz#dcAdK=dyr zzMEwzl=HnS`A73Kf^Z_u-wWXoozI9vBmEv*;`ry!(Gi4%MTyY5yqWGZb***ya*n)g zQSl;DfASgg`9`?2gGyL{%XcTVL)MAyl33@@|5qaZb zJiO)-oZbYMAM*@XV>)j-4PY_POni}vrHZ#&L^I*Q0OO^)|L+nc-+^gV4a=?-YAVhp z*9qN|?e`pUQ3<+P#u2x- zFl9}BWfsWIBkHmSWI395y?F)ji_$rdLnUq>-fA(nvNAckP9l**i@f|AlkOR+;=chS z7vV6w1J&1DmPE(3ElLnvD#7TdHz0m$wO*nRq_;WdC66;O4&xsHBeapjdQk)IICY2S zZR2zkF2_>B&>fBkl;Ufe>!ze|Zdi+IV~3Y?94NVTU`ZfvKQW{1j4T(moh^`@C#i;R zqUV%WFlMg;h})3bK|Ed)lnd~`T>2r$oB7&!SDL9>g5bc^qTk9XXN!K*Tr}@Irc$B! zuj&fhkczOPbh51)R=>t!E(S|A`E(7#P;jnx5GV0S%%=?<)(C0Z?*5dU&Ab@HSdzLT z`cZvzVJ?;2ku>3RaZ+0YX3xioz`0~Ji10~V+sfJj6AWQ@_JX~LcmR3rh|+aXGXf=Q z!GEU2)2+9+uAcUfwMfe|M2IX_^q?PgXLV@#5W2;a)2+`ms%-tU+u(Gu3%$wc#E=<2 zuL++sWJZ|T&Ydid$HNl+rklv;a_2)ekdHUdOZ`eU(x?c|SG1s>xG@a5HH%5(s^l_y zlN~h?=d0KG966v8tYFA9oOFo%bIh#&y4*3@_gHxghwdB}W!qq^5Tra+V1t1_>yR>l zB~<8ida4bk<5R>tR=2ab4~s$Z*YJ`J#ck=?bGQ_|iY(DfRI1hwye;z-prFEgp8tcO z4xlyuEr~vYVT^8Ywb4t>-QmDthtHf_X zI0NUv5l~##^*Lg03(h9Jy9s}KnQ`hWeXBMHU^+GE{u%#FCbD|DRrk=pK(L05PAg^% zA$>Lvo|Zj4D8<@hcEFfD3fMd0G7Fl7C4eE|cVQFEvh7T|_vDJ$c zOXQ_FF;zk*?&3t}ce2WV`PKImOh-Gh8`)ky6pyP;v(Z`Y4XZ+kS=%F*VOF;mCCjz8 zF~_rd20}qm*oS(_W26N+8fM!WG`Iv{JzL|vy_}+;Jk2Xlclg!6B3u)n8_%GWDZ`%A z()uB%T*CTN!R;I+{x}lw;-ERfMxpt{7>yE*Fdm=OT8)mF@FL8&!d7ETM?%#kNzy`s zjhb;zU@dAao>P_gKl$ERdvfdS1z7T0g%UBcE7Ym?PJ05ja=PxzAJWj$NKHjS0C9G! zSV>vX*OX&h&||=4e2O=Cz<7|-&1cXlnD4cfe7}}2z5j!Jais_xEnri#J@5UAPWdVY`k@M5&Bhu z@(KeDy#QHFQFqZ)@;D3yuUYWi3(4z8cS%s0K3oIl&X`5XzW?*w&`m2#>$`$2pBf6& zwG9Tw`UjwYn#dqAP|HzRziomRKDD|$`UFy&4b+hu)dk(m`-6-GD)BS~(9W@9E?H=W+WR?k|`8pf2?iN%Voj5uQ zo`uW04H9=oe$uIu!ydSd8vX!4)&$8b!bB2wXw1l4Yvga6>Af`uZ0AYz6p>42BDoC% zm}T1{b;ze^Q^CTRu65UT4!5<+2orW20l?k#TFEGK-SOk-aFXlgb2L3UdXkm=`W?DB z`75&Zuad+UvHTwN`=KQA1QRsK+7|kfq20cKEnOGs6c=HgGMYu1+6Z$a_~Xt%ML(v>xxM%93LhZ^(!{~OOlt=H+%b3jl1 z*>cLcqB;RSi3cuh#oHjMd?%gg@~pNv^~3A{F7gUh>M2UB?qRffA=l#S$>SPczvt6K|-1vdKS=76GwwHt_`76@fIELh7dao zB#ijV7A2RXU@6>Vgh|Dz#c_@`SlurH%=^c*-ZRw9SWHa2Zw|XM(zF?^HX_9a!@vdx z^BQ7e;N&8#uF^@Y=Z-&zUHI?!#GfLK=seuAlBs{3 zq}px|7o_E;8EH1A!Ca%CNoP>f0*7u^w??S>!n?LjsKdExYK`T`^*>Jm7uxCw zU5kyL|ByGUlY7RcsQTLg0a~QRR<*7X-Y+&LnP=AsNmkkHCYm3(%9ix(6>v8A1z;gd zZx1{-ti%T+Wpa@|6EqZX2_6{;ftZD&#$CWFP`ajVKIJQzhpbTtzH_+o{|u(1=%^i@ zRkoGJq6Z31g2c(622`~g>5xO!fT~rPfCxigzK`aUuh>59&2+njE}yM9-RW~u7_aX} zW%!h*DxZpED3Vi)x?}_sR(e;A)mfA3i#F%Jf{-g|VZ(yQDhbvT0aB9zYBEZ0v{T>< zowPF)ydO^5WqPAiV z8?vUTOU~&!nE#tQAN5H=5|@)K7l<_aOoU8)C0A*+FeDuDu0*p1h=7K+t@G#~*kC+! zHF1(YYG3O!%7j4c)-F&s(xMbdOHr&u@yWAX!(UTn?KCCh><5S=WZYR>JrS z^FV1Vnzk?hqm_}JN4X=c%onEkG_IhmORy&!Bd?8cnFnHxMNS=+n*lLx?Ig10cKg_G##UBZuSygq9S9?mVv*CV+i_M1wtR!tgB5lAxOj z{+GmdV~j^7M?n?9YN-G^4d^ixjs6wL*<^Yp*ea_=aE$pND@Mic0wtVoeiEu;q`%>v zM#juvwMCX^3TWN2r7h!tJ_SqQ4x_;LA2!q-_C}LyilLy@5A&jpKD^u263Q`_ACw{J zywpnE>DGU5u7XZ;5c1)CL?VUeA;X%z<#c=!O3@9P5%e7CW%%3wX-=Pw5hcg1adLuY zYk8KwW4G!FpmDHph}7)_9VnPL0xt|HN;CZh3{cJ#AkMr1f5>oz_RAXS=^e*iYINiQ zYLadXw7lE4$u8SeUMnm$s%|Bid5C?GfbN$6O^x6ET`wJcfIFBOfT@nBrDE$`6=tI)3 ziF5uyaQ~$~pP7WT6Ej1(siPlP4xo-msGgO{mtiYK>?ZmL80#d)y+GF;96QJh0_WeW zH72_1+oruBqtqp&9BigNIVeFpBcarm;2%C<^i`>7wq9Xe*KX|KEu<~$F57?UsqSZ)_(Ho z*Z+a##PJVi|5yG$`}O~Q!H@k9bN}HF7ho}F_ZB`ZQt<6x_K)|rUCZzE{SW^0`~Pl# z+?{k__yEJ?qg?a*5S!kt1+jhmPe1%F@B9YX#{coNbcf*|yFGrkEctuiS8?PC)J6XN zf4{=|5Jgapdp@;ey(`(KvZ|5&*HJnB9tEb(-v5S%}^nf{Y&zhB?q zvHOSJFFk*jKh-XOt^-@*0((rE&TIeIE8g!0Z9x#54}l9Cpg;kbP|uZU#PM$~Kl)J$ zSe^k(YpXusd{XX{*nhwJE2QhEGk;irl%d9E(Z_VDGAvV8NGTGs*coE7!1W@g2OZxy zY>oq)Txv@Dj^3V8Eqwp@Jz)36u1=-_SYto@{vI5&`*`=8_Z@g`fBXmNs43(!3WE)E zHEM{^Iwaenj=`FTeW1dX->B zwoD(sOaabj2*VHbdOiQf2%Izwsf}3)Je_M^9AC)GyCE5WCOsXGtDITs=?QJ$NR<&H(RHf|z;aKmU$T4WV|ak*`1kp00i_ I>zopr07mJhIRF3v literal 0 HcmV?d00001 diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index 50570780044..12e9dce48a9 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -236,6 +236,7 @@ qdel(overlay) watchers = null QDEL_NULL(meter) + QDEL_NULL(beam) QDEL_NULL(torch) light_lit = FALSE sweeping = FALSE diff --git a/voidcrew/modules/stealth/stealth_light.dm b/voidcrew/modules/stealth/stealth_light.dm index 3a48e50cb52..a83341fdc84 100644 --- a/voidcrew/modules/stealth/stealth_light.dm +++ b/voidcrew/modules/stealth/stealth_light.dm @@ -13,6 +13,9 @@ * back stay dark. tg's lighting stops it at walls and closed solid doors and lets it through glass, like any lamp * (numbers in data/stealth/STATUS.md, decision 41). * + * What the eye sees on top (decision 42): a cone in the air from the guard's lamp and a small glow there + * (/obj/effect/abstract/stealth_beam), so the beam visibly starts at the guard. Only the eye sees it. + * * The beam moves like a hand moves it. Before a turn the guard makes on its own, the beam swings halfway there * while the body leans (stealth_turns.dm), so the light shows where it is about to look. Any other turn of 90 * degrees or more passes through the halfway point. A step at a walk carries the beam half a tile at a time. A @@ -123,6 +126,89 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) /obj/effect/abstract/stealth_torch/get_light_offset() return list(beam_x, beam_y) +/** + * What the eye sees of a guard's beam (decision 42): a cone of light in the air, narrow at its lamp and widening + * ahead, with a small glow at the lamp. It sits on tg's overlay-light plane and adds to the light there, as tg's own + * flashlight cones do, so it brightens what it falls on, shows in the dark and all but vanishes in a lit room. It is + * part of the guard (vis_contents), so it glides with every step. It is only for the eye: guards see, and tiles count + * as lit, by the real lamp alone. It stops at the first wall or solid door ahead (stealth_beam_reach()). + */ +/obj/effect/abstract/stealth_beam + name = "flashlight beam" + icon = 'voidcrew/icons/effects/stealth_beam.dmi' + icon_state = "beam_22" + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + anchored = TRUE + blocks_emissive = EMISSIVE_BLOCK_NONE + blend_mode = BLEND_ADD + appearance_flags = RESET_COLOR | RESET_ALPHA | RESET_TRANSFORM | KEEP_APART | PIXEL_SCALE + // The icon's bottom middle on the guard's tile centre + pixel_x = -48 + pixel_y = 16 + /// The guard it is shown on, or null + var/mob/living/holder + /// The way it points now, or 0 + var/shown_dir = 0 + /// The facing of the guard when it was last aimed (the lamp's place on the body follows that) + var/shown_body_dir = 0 + +/obj/effect/abstract/stealth_beam/Destroy() + stealth_hide() + return ..() + +/// Takes it off its guard. +/obj/effect/abstract/stealth_beam/proc/stealth_hide() + if(holder) + holder.vis_contents -= src + holder = null + shown_dir = 0 + shown_body_dir = 0 + +/// Shows it on `guard`, pointing `beam_dir` and `reach` eighths of a tile long. Touches nothing that is already so. +/obj/effect/abstract/stealth_beam/proc/stealth_show(mob/living/guard, beam_dir, reach) + if(holder != guard) + stealth_hide() + holder = guard + guard.vis_contents += src + SET_PLANE_EXPLICIT(src, O_LIGHTING_VISUAL_PLANE, guard) + // Pointing away from the camera, the guard's body hides the lamp: no glow, and the cone comes out past its back. + var/away = guard.dir & NORTH + var/state = "[away ? "back" : "beam"]_[reach]" + if(icon_state != state) + icon_state = state + if(shown_dir == beam_dir && shown_body_dir == guard.dir) + return + shown_dir = beam_dir + shown_body_dir = guard.dir + // The lamp is at its belt: a little ahead facing away, a little below the middle facing the camera or sideways. + var/forward = away ? 4 : ((guard.dir & SOUTH) ? -6 : 0) + var/drop = (guard.dir & (EAST|WEST)) && !(guard.dir & (NORTH|SOUTH)) ? -3 : 0 + var/matrix/aim = matrix() + aim.Translate(0, STEALTH_BEAM_PIVOT + forward) + aim.Turn(dir2angle(beam_dir)) + aim.Translate(0, drop - STEALTH_BEAM_PIVOT) + transform = aim + +/// How long a guard's visible cone is from `spot` pointing `beam_dir`, in eighths of a tile: up to a little onto the +/// first wall or solid door (what stops tg's light), or STEALTH_BEAM_LENGTHS for nothing in its reach. +/proc/stealth_beam_reach(turf/spot, beam_dir) + var/diagonal = !(beam_dir in GLOB.cardinals) + var/turf/here = spot + for(var/steps in 1 to STEALTH_TORCH_RANGE) + var/turf/next = get_step(here, beam_dir) + var/blocked = isnull(next) || IS_OPAQUE_TURF(next) + if(!blocked && diagonal) + // Light doesn't squeeze between two corners. + var/turf/one_side = get_step(here, beam_dir & (NORTH|SOUTH)) + var/turf/other_side = get_step(here, beam_dir & (EAST|WEST)) + blocked = (isnull(one_side) || IS_OPAQUE_TURF(one_side)) && (isnull(other_side) || IS_OPAQUE_TURF(other_side)) + if(blocked) + // to the blocker's near face, then 6 px onto it + var/pixels = (steps - 0.5) * (diagonal ? 45 : 32) + 6 + return clamp(round(pixels / 8, 1), 1, STEALTH_BEAM_LENGTHS - 1) + here = next + return STEALTH_BEAM_LENGTHS + /// How much every guard's lamp adds to `tile` right now, in get_lumcount() units. /proc/stealth_torch_share(turf/tile) . = 0 @@ -162,6 +248,8 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) var/light_lit = FALSE /// The lamp behind its beam, made the first time it is switched on var/obj/effect/abstract/stealth_torch/torch + /// The cone players see over its beam (decision 42), made with the lamp + var/obj/effect/abstract/stealth_beam/beam /// Where it points the beam off its facing, in 45 degree steps anticlockwise: a sweep, or the lead of a turn var/torch_aim = 0 /// The way the beam points for a moment in the middle of a turn, or 0 @@ -247,13 +335,18 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) var/mob/living/guard = pawn var/turf/spot = ((light_lit || flash) && !QDELETED(guard) && isturf(guard.loc)) ? guard.loc : null if(isnull(spot)) + beam?.stealth_hide() if(torch?.light_on) torch.set_light_on(FALSE) torch.update_light() return if(QDELETED(torch)) torch = new(spot) + if(QDELETED(beam)) + beam = new(null) var/beam_dir = stealth_beam_dir() + // The cone glides with the guard, so it needs no half steps; it is cut where the light is stopped. + beam.stealth_show(guard, beam_dir, stealth_beam_reach(spot, beam_dir)) // The beam starts at its hand, ahead of its own tile, less whatever a step in progress still holds back. var/start_x = torch_lag_x - STEALTH_TORCH_FORWARD * ((beam_dir & EAST) ? 1 : ((beam_dir & WEST) ? -1 : 0)) var/start_y = torch_lag_y - STEALTH_TORCH_FORWARD * ((beam_dir & NORTH) ? 1 : ((beam_dir & SOUTH) ? -1 : 0)) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm index 8c5cf8ff794..00320858280 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm @@ -179,6 +179,57 @@ /// Decision 41, real lighting: the beam is a wedge. It lights 1 to 4 tiles ahead and the tiles beside 2 and 3 /// ahead; the guard's own tile, its sides, its back, 5 ahead and two tiles off the line stay dark. A wall stops it. +/// Decision 42: the cone players see shows and hides with the light, points where the beam points, and stops at a wall. +/datum/unit_test/voidcrew_stealth_light_cone + +/datum/unit_test/voidcrew_stealth_light_cone/Run() + // STEALTH_BEAM_LENGTHS: the unit tests are included before voidcrew/_DEFINES, so the number is written out + var/open_reach = 22 + var/datum/turf_reservation/block = stealth_block(12, 7) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 3) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + for(var/dx in 0 to 11) + for(var/dy in 0 to 6) + GLOB.stealth_test_dark_turfs[stealth_at(block, dx, dy)] = TRUE + guard.setDir(EAST) + stealth_ai.stealth_update_light() + TEST_ASSERT(stealth_ai.stealth_light_shows(), "A guard in the dark has no beam") + var/obj/effect/abstract/stealth_beam/beam = stealth_ai.beam + TEST_ASSERT_NOTNULL(beam, "A lit guard shows no cone") + TEST_ASSERT_EQUAL(beam.holder, guard, "The cone isn't on its guard") + TEST_ASSERT(beam in guard.vis_contents, "The cone isn't drawn on its guard") + TEST_ASSERT_EQUAL(beam.shown_dir, EAST, "The cone doesn't point the way the guard faces") + TEST_ASSERT_EQUAL(beam.icon_state, "beam_[open_reach]", "An open beam's cone is cut short, or has no glow facing sideways") + TEST_ASSERT_EQUAL(PLANE_TO_TRUE(beam.plane), O_LIGHTING_VISUAL_PLANE, "The cone isn't drawn as light") + // It follows the beam through a turn, and facing away the lamp's glow is hidden by the body. + guard.setDir(NORTH) + TEST_ASSERT_EQUAL(beam.shown_dir, NORTHEAST, "The cone didn't pass through the diagonal with the beam") + stealth_ai.stealth_torch_settle(stealth_ai.torch_serial) + TEST_ASSERT_EQUAL(beam.shown_dir, NORTH, "The cone didn't land on the new facing") + TEST_ASSERT(findtext(beam.icon_state, "back_") == 1, "A guard facing away shows its lamp's glow through its body") + // A turn of its own: the cone leads it with the beam. + stealth_ai.stealth_turn_to(EAST) + TEST_ASSERT_EQUAL(beam.shown_dir, NORTHEAST, "The cone didn't lead a turn the guard makes on its own") + stealth_ai.stealth_finish_turn(EAST, stealth_ai.turn_planned_at) + TEST_ASSERT_EQUAL(beam.shown_dir, EAST, "The cone didn't land when the led turn finished") + // A wall two tiles ahead cuts it at the wall. + var/turf/wall = stealth_at(block, 4, 3) + wall.ChangeTurf(/turf/closed/wall) + TEST_ASSERT_EQUAL(stealth_beam_reach(get_turf(guard), EAST), 7, "The cone doesn't stop on a wall two tiles ahead") + TEST_ASSERT_EQUAL(stealth_beam_reach(stealth_at(block, 6, 3), EAST), open_reach, "The cone stops with nothing ahead") + stealth_ai.stealth_place_torch() + TEST_ASSERT_EQUAL(beam.icon_state, "beam_7", "The cone runs through a wall two tiles ahead") + // Off with the light, and gone with the guard. + stealth_ai.stealth_set_light(FALSE) + TEST_ASSERT_NULL(beam.holder, "The cone stayed on with the light off") + TEST_ASSERT(!(beam in guard.vis_contents), "The cone is still drawn with the light off") + stealth_ai.stealth_set_light(TRUE) + TEST_ASSERT_EQUAL(beam.holder, guard, "The cone didn't come back with the light") + qdel(guard) + TEST_ASSERT(QDELETED(beam), "The cone outlived its guard") + qdel(block) + /datum/unit_test/voidcrew_stealth_light_beam /datum/unit_test/voidcrew_stealth_light_beam/Run() From 6bae903d244212a1b50afac20a9c98c3358c1de7 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Thu, 12 Nov 2026 12:01:18 -0800 Subject: [PATCH 38/78] Guards' beam cones wait for the flashlight's light on the floor before turning --- voidcrew/_DEFINES/lighting.dm | 5 ++ voidcrew/edits/lighting.dm | 8 +++ voidcrew/modules/stealth/stealth_light.dm | 69 ++++++++++++++----- .../unit_tests/voidcrew_stealth_light.dm | 22 +++++- 4 files changed, 86 insertions(+), 18 deletions(-) diff --git a/voidcrew/_DEFINES/lighting.dm b/voidcrew/_DEFINES/lighting.dm index 54aff2ff324..a09e99c3f0a 100644 --- a/voidcrew/_DEFINES/lighting.dm +++ b/voidcrew/_DEFINES/lighting.dm @@ -59,3 +59,8 @@ /// alpha. At the stock alpha of 255 this is power 1, which is what the /lit turfs used, /// and it keeps ruin ground level with the surface if the planet is ever tuned dimmer. #define RUIN_DAYLIGHT_POWER(alpha) ((alpha) / 255) + +/// Sent to a static light's owner each time its /datum/light_source has been worked through (applied to its corners, +/// or found unchanged), by SSlighting or a test: () (voidcrew/edits/lighting.dm). Stealth guards' beam cones wait on +/// it so they never show ahead of the light on the floor (voidcrew/modules/stealth/stealth_light.dm). +#define COMSIG_LIGHT_SOURCE_APPLIED "voidcrew_light_source_applied" diff --git a/voidcrew/edits/lighting.dm b/voidcrew/edits/lighting.dm index 157957dc4d3..0587d9f342d 100644 --- a/voidcrew/edits/lighting.dm +++ b/voidcrew/edits/lighting.dm @@ -212,3 +212,11 @@ var/is_target = lighting_object && !is_ambient && !isspaceturf(src) && !istype(src, /turf/cordon) if(was_target != is_target) reconsider_ambient_bleed_neighbors() + +/// Tells the light's owner once its queued update is done (COMSIG_LIGHT_SOURCE_APPLIED). One signal send per source +/// update; nothing listens but a lit stealth guard's lamp. +/datum/light_source/update_corners() + var/atom/host = source_atom + . = ..() + if(host) + SEND_SIGNAL(host, COMSIG_LIGHT_SOURCE_APPLIED) diff --git a/voidcrew/modules/stealth/stealth_light.dm b/voidcrew/modules/stealth/stealth_light.dm index a83341fdc84..1622b0db6d3 100644 --- a/voidcrew/modules/stealth/stealth_light.dm +++ b/voidcrew/modules/stealth/stealth_light.dm @@ -132,6 +132,8 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) * flashlight cones do, so it brightens what it falls on, shows in the dark and all but vanishes in a lit room. It is * part of the guard (vis_contents), so it glides with every step. It is only for the eye: guards see, and tiles count * as lit, by the real lamp alone. It stops at the first wall or solid door ahead (stealth_beam_reach()). + * It never shows ahead of the lamp's light on the floor: a new aim waits until SSlighting has applied the lamp + * (stealth_queue(), COMSIG_LIGHT_SOURCE_APPLIED), so when lighting runs slow the whole flashlight is slow together. */ /obj/effect/abstract/stealth_beam name = "flashlight beam" @@ -151,6 +153,12 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) var/shown_dir = 0 /// The facing of the guard when it was last aimed (the lamp's place on the body follows that) var/shown_body_dir = 0 + /// The guard it waits to be shown on once the lamp's light is applied, or null + var/mob/living/pending_guard + /// What it will show then: the way it points, its length and the guard's facing + var/pending_dir = 0 + var/pending_reach = 0 + var/pending_body_dir = 0 /obj/effect/abstract/stealth_beam/Destroy() stealth_hide() @@ -158,31 +166,50 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) /// Takes it off its guard. /obj/effect/abstract/stealth_beam/proc/stealth_hide() + pending_guard = null if(holder) holder.vis_contents -= src holder = null shown_dir = 0 shown_body_dir = 0 -/// Shows it on `guard`, pointing `beam_dir` and `reach` eighths of a tile long. Touches nothing that is already so. -/obj/effect/abstract/stealth_beam/proc/stealth_show(mob/living/guard, beam_dir, reach) +/// Shows it as stealth_show() once the lamp's light has been applied (stealth_flush()). Until then it stays as it was. +/obj/effect/abstract/stealth_beam/proc/stealth_queue(mob/living/guard, beam_dir, reach) + pending_guard = guard + pending_dir = beam_dir + pending_reach = reach + pending_body_dir = guard.dir + +/// The lamp's light is applied: shows what was waiting for it, if its guard is still about. +/obj/effect/abstract/stealth_beam/proc/stealth_flush() + var/mob/living/guard = pending_guard + pending_guard = null + if(!QDELETED(guard)) + stealth_show(guard, pending_dir, pending_reach, pending_body_dir) + +/// Shows it on `guard`, pointing `beam_dir` and `reach` eighths of a tile long, for the guard facing `body_dir` (its +/// facing now by default). Touches nothing that is already so. +/obj/effect/abstract/stealth_beam/proc/stealth_show(mob/living/guard, beam_dir, reach, body_dir) + pending_guard = null + if(!body_dir) + body_dir = guard.dir if(holder != guard) stealth_hide() holder = guard guard.vis_contents += src SET_PLANE_EXPLICIT(src, O_LIGHTING_VISUAL_PLANE, guard) // Pointing away from the camera, the guard's body hides the lamp: no glow, and the cone comes out past its back. - var/away = guard.dir & NORTH + var/away = body_dir & NORTH var/state = "[away ? "back" : "beam"]_[reach]" if(icon_state != state) icon_state = state - if(shown_dir == beam_dir && shown_body_dir == guard.dir) + if(shown_dir == beam_dir && shown_body_dir == body_dir) return shown_dir = beam_dir - shown_body_dir = guard.dir + shown_body_dir = body_dir // The lamp is at its belt: a little ahead facing away, a little below the middle facing the camera or sideways. - var/forward = away ? 4 : ((guard.dir & SOUTH) ? -6 : 0) - var/drop = (guard.dir & (EAST|WEST)) && !(guard.dir & (NORTH|SOUTH)) ? -3 : 0 + var/forward = away ? 4 : ((body_dir & SOUTH) ? -6 : 0) + var/drop = (body_dir & (EAST|WEST)) && !(body_dir & (NORTH|SOUTH)) ? -3 : 0 var/matrix/aim = matrix() aim.Translate(0, STEALTH_BEAM_PIVOT + forward) aim.Turn(dir2angle(beam_dir)) @@ -342,11 +369,12 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) return if(QDELETED(torch)) torch = new(spot) + RegisterSignal(torch, COMSIG_LIGHT_SOURCE_APPLIED, PROC_REF(stealth_torch_applied)) if(QDELETED(beam)) beam = new(null) var/beam_dir = stealth_beam_dir() // The cone glides with the guard, so it needs no half steps; it is cut where the light is stopped. - beam.stealth_show(guard, beam_dir, stealth_beam_reach(spot, beam_dir)) + var/reach = stealth_beam_reach(spot, beam_dir) // The beam starts at its hand, ahead of its own tile, less whatever a step in progress still holds back. var/start_x = torch_lag_x - STEALTH_TORCH_FORWARD * ((beam_dir & EAST) ? 1 : ((beam_dir & WEST) ? -1 : 0)) var/start_y = torch_lag_y - STEALTH_TORCH_FORWARD * ((beam_dir & NORTH) ? 1 : ((beam_dir & SOUTH) ? -1 : 0)) @@ -354,14 +382,23 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) // A move rebuilds the light by itself (the source follows its host's Moved). if(torch.loc != spot) torch.abstract_move(spot) - if(!changed) - return - torch.beam_x = start_x - torch.beam_y = start_y - torch.set_light_dir(beam_dir) - torch.set_light_on(TRUE) - // tg's light setters don't rebuild a COMPLEX_LIGHT source on their own (see /obj/item/flashlight/update_brightness()). - torch.update_light() + if(changed) + torch.beam_x = start_x + torch.beam_y = start_y + torch.set_light_dir(beam_dir) + torch.set_light_on(TRUE) + // tg's light setters don't rebuild a COMPLEX_LIGHT source on their own (see /obj/item/flashlight/update_brightness()). + torch.update_light() + // The cone never shows ahead of the light on the floor: while the lamp waits on SSlighting, so does the cone. + if(torch.light?.needs_update) + beam.stealth_queue(guard, beam_dir, reach) + else + beam.stealth_show(guard, beam_dir, reach) + +/// SSlighting (or a test) applied its lamp's light: the cone catches up. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_torch_applied(datum/source) + SIGNAL_HANDLER + beam?.stealth_flush() /// Whether its light is on with its beam showing (for admins and tests). /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_light_shows() diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm index 00320858280..13a701a2fc6 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm @@ -17,6 +17,14 @@ source.update_corners() source.needs_update = LIGHTING_NO_UPDATE +/// Applies `lamp`'s queued light now, without waiting, as SSlighting would: for checks that a beam's short timers +/// would outrun. +/datum/unit_test/proc/stealth_apply_light(atom/movable/lamp) + var/datum/light_source/source = lamp?.light + if(source?.needs_update) + source.update_corners() + source.needs_update = LIGHTING_NO_UPDATE + /// The guard switches its light on in the dark and while on edge, off in the light, and can't while it is cut out. /datum/unit_test/voidcrew_stealth_light_switch @@ -197,21 +205,29 @@ TEST_ASSERT(stealth_ai.stealth_light_shows(), "A guard in the dark has no beam") var/obj/effect/abstract/stealth_beam/beam = stealth_ai.beam TEST_ASSERT_NOTNULL(beam, "A lit guard shows no cone") + stealth_settle_light(stealth_ai.torch) TEST_ASSERT_EQUAL(beam.holder, guard, "The cone isn't on its guard") TEST_ASSERT(beam in guard.vis_contents, "The cone isn't drawn on its guard") TEST_ASSERT_EQUAL(beam.shown_dir, EAST, "The cone doesn't point the way the guard faces") TEST_ASSERT_EQUAL(beam.icon_state, "beam_[open_reach]", "An open beam's cone is cut short, or has no glow facing sideways") TEST_ASSERT_EQUAL(PLANE_TO_TRUE(beam.plane), O_LIGHTING_VISUAL_PLANE, "The cone isn't drawn as light") - // It follows the beam through a turn, and facing away the lamp's glow is hidden by the body. + // It follows the beam through a turn, and facing away the lamp's glow is hidden by the body. It never moves ahead + // of the light on the floor: until the lamp's turn is applied, it still points the old way. guard.setDir(NORTH) + TEST_ASSERT(stealth_ai.torch.light?.needs_update, "A turn didn't queue the lamp's light") + TEST_ASSERT_EQUAL(beam.shown_dir, EAST, "The cone turned before the light on the floor did") + stealth_apply_light(stealth_ai.torch) TEST_ASSERT_EQUAL(beam.shown_dir, NORTHEAST, "The cone didn't pass through the diagonal with the beam") stealth_ai.stealth_torch_settle(stealth_ai.torch_serial) + stealth_apply_light(stealth_ai.torch) TEST_ASSERT_EQUAL(beam.shown_dir, NORTH, "The cone didn't land on the new facing") TEST_ASSERT(findtext(beam.icon_state, "back_") == 1, "A guard facing away shows its lamp's glow through its body") // A turn of its own: the cone leads it with the beam. stealth_ai.stealth_turn_to(EAST) + stealth_apply_light(stealth_ai.torch) TEST_ASSERT_EQUAL(beam.shown_dir, NORTHEAST, "The cone didn't lead a turn the guard makes on its own") stealth_ai.stealth_finish_turn(EAST, stealth_ai.turn_planned_at) + stealth_apply_light(stealth_ai.torch) TEST_ASSERT_EQUAL(beam.shown_dir, EAST, "The cone didn't land when the led turn finished") // A wall two tiles ahead cuts it at the wall. var/turf/wall = stealth_at(block, 4, 3) @@ -219,12 +235,14 @@ TEST_ASSERT_EQUAL(stealth_beam_reach(get_turf(guard), EAST), 7, "The cone doesn't stop on a wall two tiles ahead") TEST_ASSERT_EQUAL(stealth_beam_reach(stealth_at(block, 6, 3), EAST), open_reach, "The cone stops with nothing ahead") stealth_ai.stealth_place_torch() + stealth_apply_light(stealth_ai.torch) TEST_ASSERT_EQUAL(beam.icon_state, "beam_7", "The cone runs through a wall two tiles ahead") - // Off with the light, and gone with the guard. + // Off with the light at once, and gone with the guard. stealth_ai.stealth_set_light(FALSE) TEST_ASSERT_NULL(beam.holder, "The cone stayed on with the light off") TEST_ASSERT(!(beam in guard.vis_contents), "The cone is still drawn with the light off") stealth_ai.stealth_set_light(TRUE) + stealth_settle_light(stealth_ai.torch) TEST_ASSERT_EQUAL(beam.holder, guard, "The cone didn't come back with the light") qdel(guard) TEST_ASSERT(QDELETED(beam), "The cone outlived its guard") From c335b14795e071e8bdf92752a354cdfa95ede129 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Thu, 12 Nov 2026 12:22:52 -0800 Subject: [PATCH 39/78] Guards check their lamp each tick while the cone waits, instead of a global lighting hook --- voidcrew/_DEFINES/lighting.dm | 5 --- voidcrew/_DEFINES/stealth.dm | 2 ++ voidcrew/edits/lighting.dm | 8 ----- voidcrew/modules/stealth/stealth_ai.dm | 1 + voidcrew/modules/stealth/stealth_light.dm | 36 +++++++++++++++---- .../unit_tests/voidcrew_stealth_light.dm | 10 ++++++ 6 files changed, 43 insertions(+), 19 deletions(-) diff --git a/voidcrew/_DEFINES/lighting.dm b/voidcrew/_DEFINES/lighting.dm index a09e99c3f0a..54aff2ff324 100644 --- a/voidcrew/_DEFINES/lighting.dm +++ b/voidcrew/_DEFINES/lighting.dm @@ -59,8 +59,3 @@ /// alpha. At the stock alpha of 255 this is power 1, which is what the /lit turfs used, /// and it keeps ruin ground level with the surface if the planet is ever tuned dimmer. #define RUIN_DAYLIGHT_POWER(alpha) ((alpha) / 255) - -/// Sent to a static light's owner each time its /datum/light_source has been worked through (applied to its corners, -/// or found unchanged), by SSlighting or a test: () (voidcrew/edits/lighting.dm). Stealth guards' beam cones wait on -/// it so they never show ahead of the light on the floor (voidcrew/modules/stealth/stealth_light.dm). -#define COMSIG_LIGHT_SOURCE_APPLIED "voidcrew_light_source_applied" diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index f578a4a2310..a28d43d01b8 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -187,6 +187,8 @@ #define STEALTH_BEAM_LENGTHS 22 /// Pixels from the guard's tile centre to its icon's centre (stealth_beam.dmi is 128x192, the guard at its bottom middle) #define STEALTH_BEAM_PIVOT 96 +/// The longest a guard's cone waits for SSlighting to apply its lamp before it shows anyway (decision 42 sync) +#define STEALTH_BEAM_WAIT_CAP (5 SECONDS) /// A lit light someone carries within this many tiles of an unaware guard standing in the dark draws its notice /// even behind it (never further than the light itself reaches) #define STEALTH_STRAY_LIGHT_RANGE 5 diff --git a/voidcrew/edits/lighting.dm b/voidcrew/edits/lighting.dm index 0587d9f342d..157957dc4d3 100644 --- a/voidcrew/edits/lighting.dm +++ b/voidcrew/edits/lighting.dm @@ -212,11 +212,3 @@ var/is_target = lighting_object && !is_ambient && !isspaceturf(src) && !istype(src, /turf/cordon) if(was_target != is_target) reconsider_ambient_bleed_neighbors() - -/// Tells the light's owner once its queued update is done (COMSIG_LIGHT_SOURCE_APPLIED). One signal send per source -/// update; nothing listens but a lit stealth guard's lamp. -/datum/light_source/update_corners() - var/atom/host = source_atom - . = ..() - if(host) - SEND_SIGNAL(host, COMSIG_LIGHT_SOURCE_APPLIED) diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index 12e9dce48a9..a86870fd8a6 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -238,6 +238,7 @@ QDEL_NULL(meter) QDEL_NULL(beam) QDEL_NULL(torch) + stealth_cone_stop() light_lit = FALSE sweeping = FALSE torch_aim = 0 diff --git a/voidcrew/modules/stealth/stealth_light.dm b/voidcrew/modules/stealth/stealth_light.dm index 1622b0db6d3..6a9aea7d603 100644 --- a/voidcrew/modules/stealth/stealth_light.dm +++ b/voidcrew/modules/stealth/stealth_light.dm @@ -114,6 +114,8 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) /// Where the beam starts, in tiles from the middle of the lamp's tile, as tg's light offset: a negative x is east var/beam_x = 0 var/beam_y = 0 + /// The guard's AI that owns it (it deletes the lamp with itself), so a test that applies the light can land its cone + var/datum/ai_controller/basic_controller/human_npc/stealth/owner_ai /obj/effect/abstract/stealth_torch/Initialize(mapload) . = ..() @@ -121,6 +123,7 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) /obj/effect/abstract/stealth_torch/Destroy() GLOB.stealth_guard_torches -= src + owner_ai = null return ..() /obj/effect/abstract/stealth_torch/get_light_offset() @@ -133,7 +136,7 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) * part of the guard (vis_contents), so it glides with every step. It is only for the eye: guards see, and tiles count * as lit, by the real lamp alone. It stops at the first wall or solid door ahead (stealth_beam_reach()). * It never shows ahead of the lamp's light on the floor: a new aim waits until SSlighting has applied the lamp - * (stealth_queue(), COMSIG_LIGHT_SOURCE_APPLIED), so when lighting runs slow the whole flashlight is slow together. + * (stealth_queue(), stealth_cone_check()), so when lighting runs slow the whole flashlight is slow together. */ /obj/effect/abstract/stealth_beam name = "flashlight beam" @@ -296,6 +299,10 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) var/sweep_step = 0 /// Counts switches, so a light that comes back stops a sputter var/sputter_serial = 0 + /// The timer that shows its cone once its lamp's light is applied, or null when nothing waits + var/cone_timer + /// world.time its cone started waiting on the lamp + var/cone_wait_since = 0 /// Its flashlight, if it still has it on its body; else null. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_light() @@ -363,13 +370,14 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) var/turf/spot = ((light_lit || flash) && !QDELETED(guard) && isturf(guard.loc)) ? guard.loc : null if(isnull(spot)) beam?.stealth_hide() + stealth_cone_stop() if(torch?.light_on) torch.set_light_on(FALSE) torch.update_light() return if(QDELETED(torch)) torch = new(spot) - RegisterSignal(torch, COMSIG_LIGHT_SOURCE_APPLIED, PROC_REF(stealth_torch_applied)) + torch.owner_ai = src if(QDELETED(beam)) beam = new(null) var/beam_dir = stealth_beam_dir() @@ -392,13 +400,29 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) // The cone never shows ahead of the light on the floor: while the lamp waits on SSlighting, so does the cone. if(torch.light?.needs_update) beam.stealth_queue(guard, beam_dir, reach) + if(!cone_timer) + cone_wait_since = world.time + cone_timer = addtimer(CALLBACK(src, PROC_REF(stealth_cone_check)), world.tick_lag, TIMER_STOPPABLE) else beam.stealth_show(guard, beam_dir, reach) + stealth_cone_stop() -/// SSlighting (or a test) applied its lamp's light: the cone catches up. -/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_torch_applied(datum/source) - SIGNAL_HANDLER - beam?.stealth_flush() +/// Its cone waits on the lamp: shown once SSlighting has applied the lamp's light (or after STEALTH_BEAM_WAIT_CAP), +/// else looked at again next tick. Runs only while something waits. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_cone_check() + cone_timer = null + if(QDELETED(beam) || isnull(beam.pending_guard)) + return + if(torch?.light?.needs_update && world.time < cone_wait_since + STEALTH_BEAM_WAIT_CAP) + cone_timer = addtimer(CALLBACK(src, PROC_REF(stealth_cone_check)), world.tick_lag, TIMER_STOPPABLE) + return + beam.stealth_flush() + +/// Stops waiting on the lamp (the cone was shown or hidden). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_cone_stop() + if(cone_timer) + deltimer(cone_timer) + cone_timer = null /// Whether its light is on with its beam showing (for admins and tests). /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_light_shows() diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm index 13a701a2fc6..116b31d4617 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm @@ -10,12 +10,14 @@ sleep(1) for(var/i in 1 to 50) if(!length(SSlighting.sources_queue) && !length(SSlighting.current_sources)) + stealth_land_cone(target) return sleep(1) var/datum/light_source/source = target?.light if(source?.needs_update) source.update_corners() source.needs_update = LIGHTING_NO_UPDATE + stealth_land_cone(target) /// Applies `lamp`'s queued light now, without waiting, as SSlighting would: for checks that a beam's short timers /// would outrun. @@ -24,6 +26,14 @@ if(source?.needs_update) source.update_corners() source.needs_update = LIGHTING_NO_UPDATE + stealth_land_cone(lamp) + +/// A guard's cone looks for its lamp's light once a tick; this looks now, so a test needn't wait the tick. +/datum/unit_test/proc/stealth_land_cone(atom/movable/lamp) + var/obj/effect/abstract/stealth_torch/torch = lamp + if(istype(torch) && torch.owner_ai) + torch.owner_ai.stealth_cone_stop() + torch.owner_ai.stealth_cone_check() /// The guard switches its light on in the dark and while on edge, off in the light, and can't while it is cut out. /datum/unit_test/voidcrew_stealth_light_switch From 23705d174e819d55248a2264b8729b8872790bc6 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Thu, 12 Nov 2026 17:37:40 -0800 Subject: [PATCH 40/78] Guards' beam cones stop at walls while they wait on the lamp's light and while the guard is mid-step --- voidcrew/modules/stealth/stealth_light.dm | 50 +++++++++++++++- .../unit_tests/voidcrew_stealth_light.dm | 60 +++++++++++++++++++ 2 files changed, 109 insertions(+), 1 deletion(-) diff --git a/voidcrew/modules/stealth/stealth_light.dm b/voidcrew/modules/stealth/stealth_light.dm index 6a9aea7d603..b9ed901ff08 100644 --- a/voidcrew/modules/stealth/stealth_light.dm +++ b/voidcrew/modules/stealth/stealth_light.dm @@ -156,6 +156,8 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) var/shown_dir = 0 /// The facing of the guard when it was last aimed (the lamp's place on the body follows that) var/shown_body_dir = 0 + /// Its length now, in the icon's steps (STEALTH_BEAM_LENGTHS when nothing stops it), or 0 + var/shown_reach = 0 /// The guard it waits to be shown on once the lamp's light is applied, or null var/mob/living/pending_guard /// What it will show then: the way it points, its length and the guard's facing @@ -175,6 +177,7 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) holder = null shown_dir = 0 shown_body_dir = 0 + shown_reach = 0 /// Shows it as stealth_show() once the lamp's light has been applied (stealth_flush()). Until then it stays as it was. /obj/effect/abstract/stealth_beam/proc/stealth_queue(mob/living/guard, beam_dir, reach) @@ -204,6 +207,7 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) // Pointing away from the camera, the guard's body hides the lamp: no glow, and the cone comes out past its back. var/away = body_dir & NORTH var/state = "[away ? "back" : "beam"]_[reach]" + shown_reach = reach if(icon_state != state) icon_state = state if(shown_dir == beam_dir && shown_body_dir == body_dir) @@ -219,6 +223,17 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) aim.Translate(0, drop - STEALTH_BEAM_PIVOT) transform = aim +/** + * Cuts what it shows now down to `reach` steps; never makes it longer. While a new aim waits on the lamp + * (stealth_queue()) the old cone stays on the guard, who may have walked on or round a corner since: this keeps + * that old cone from running past a wall from where the guard is now. + */ +/obj/effect/abstract/stealth_beam/proc/stealth_trim(reach) + if(isnull(holder) || reach >= shown_reach) + return + shown_reach = reach + icon_state = "[(shown_body_dir & NORTH) ? "back" : "beam"]_[reach]" + /// How long a guard's visible cone is from `spot` pointing `beam_dir`, in eighths of a tile: up to a little onto the /// first wall or solid door (what stops tg's light), or STEALTH_BEAM_LENGTHS for nothing in its reach. /proc/stealth_beam_reach(turf/spot, beam_dir) @@ -303,6 +318,10 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) var/cone_timer /// world.time its cone started waiting on the lamp var/cone_wait_since = 0 + /// The tile it stepped off while its body still glides from it (the cone is drawn on the body), or null + var/turf/torch_from + /// world.time that glide ends + var/torch_from_until = 0 /// Its flashlight, if it still has it on its body; else null. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_light() @@ -382,7 +401,7 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) beam = new(null) var/beam_dir = stealth_beam_dir() // The cone glides with the guard, so it needs no half steps; it is cut where the light is stopped. - var/reach = stealth_beam_reach(spot, beam_dir) + var/reach = stealth_cone_reach(spot, beam_dir) // The beam starts at its hand, ahead of its own tile, less whatever a step in progress still holds back. var/start_x = torch_lag_x - STEALTH_TORCH_FORWARD * ((beam_dir & EAST) ? 1 : ((beam_dir & WEST) ? -1 : 0)) var/start_y = torch_lag_y - STEALTH_TORCH_FORWARD * ((beam_dir & NORTH) ? 1 : ((beam_dir & SOUTH) ? -1 : 0)) @@ -400,6 +419,9 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) // The cone never shows ahead of the light on the floor: while the lamp waits on SSlighting, so does the cone. if(torch.light?.needs_update) beam.stealth_queue(guard, beam_dir, reach) + // What still shows was aimed from where it stood then: cut it at the walls round where it stands now. + if(beam.shown_dir) + beam.stealth_trim(stealth_cone_reach(spot, beam.shown_dir)) if(!cone_timer) cone_wait_since = world.time cone_timer = addtimer(CALLBACK(src, PROC_REF(stealth_cone_check)), world.tick_lag, TIMER_STOPPABLE) @@ -407,6 +429,25 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) beam.stealth_show(guard, beam_dir, reach) stealth_cone_stop() +/** + * How long its cone may be pointing `beam_dir` from `spot`, in the icon's steps: to the first wall or solid door + * (stealth_beam_reach()). Mid-step the body is drawn between the tile it left and `spot`, so the cone also stops at + * whatever is ahead of the tile it left. Without this, a guard backing away from a wall would show its cone through it + * until the glide ended. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_cone_reach(turf/spot, beam_dir) + . = stealth_beam_reach(spot, beam_dir) + if(torch_from && world.time < torch_from_until) + . = min(., stealth_beam_reach(torch_from, beam_dir)) + +/// Its body has finished gliding off the tile it stepped from: the cone may reach as far as the light again. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_cone_landed() + if(isnull(torch_from) || world.time < torch_from_until) + return + torch_from = null + if(light_lit) + stealth_place_torch() + /// Its cone waits on the lamp: shown once SSlighting has applied the lamp's light (or after STEALTH_BEAM_WAIT_CAP), /// else looked at again next tick. Runs only while something waits. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_cone_check() @@ -446,6 +487,13 @@ GLOBAL_LIST_EMPTY(stealth_guard_torches) torch_lag_y = 0 sweep_step = 0 torch_serial++ + // The body glides off the old tile over its step; until it lands the cone also stops at walls ahead of that tile. + torch_from = null + if(isturf(old_loc) && isturf(guard.loc) && old_loc.z == guard.z && get_dist(old_loc, guard) == 1 && guard.glide_size > 0) + var/glide = min(CEILING(ICON_SIZE_ALL / guard.glide_size, 1) * world.tick_lag, 1 SECONDS) + torch_from = old_loc + torch_from_until = world.time + glide + addtimer(CALLBACK(src, PROC_REF(stealth_cone_landed)), glide) if(walked) torch_lag_x = 0.5 * (guard.x - old_loc.x) torch_lag_y = 0.5 * (guard.y - old_loc.y) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm index 116b31d4617..1bab5635a23 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_light.dm @@ -258,6 +258,66 @@ TEST_ASSERT(QDELETED(beam), "The cone outlived its guard") qdel(block) +/// Playtest 2 (owner: "light goes through walls"): while a new aim waits on the lamp, the old cone stays on the guard. +/// Walking toward a wall or round a corner in that wait, the old cone must still stop at the wall from where it is now. +/// Backing away from a wall, it stops there too while the body glides off the old tile. +/datum/unit_test/voidcrew_stealth_light_cone_wall + +/datum/unit_test/voidcrew_stealth_light_cone_wall/Run() + var/open_reach = 22 + var/datum/turf_reservation/block = stealth_block(12, 7) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 2, 3) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + for(var/dx in 0 to 11) + for(var/dy in 0 to 6) + GLOB.stealth_test_dark_turfs[stealth_at(block, dx, dy)] = TRUE + // A wall four tiles ahead. + var/turf/wall = stealth_at(block, 6, 3) + wall.ChangeTurf(/turf/closed/wall) + guard.setDir(EAST) + stealth_ai.stealth_update_light() + TEST_ASSERT(stealth_ai.stealth_light_shows(), "A guard in the dark has no beam") + var/obj/effect/abstract/stealth_beam/beam = stealth_ai.beam + stealth_settle_light(stealth_ai.torch) + TEST_ASSERT_EQUAL(beam.icon_state, "beam_15", "The cone doesn't stop on a wall four tiles ahead") + // One step on toward it, the lamp not yet applied: the old aim waits, cut at the wall from the new tile. + guard.forceMove(stealth_at(block, 3, 3)) + TEST_ASSERT(stealth_ai.torch.light?.needs_update, "A step didn't queue the lamp's light") + TEST_ASSERT_EQUAL(beam.icon_state, "beam_11", "The waiting cone runs through the wall it walked toward") + stealth_apply_light(stealth_ai.torch) + TEST_ASSERT_EQUAL(beam.icon_state, "beam_11", "The cone isn't cut at the wall once the light lands") + // Round a corner: a step north to a tile with a wall right beside it to the east, the cone still pointing east. + var/turf/side_wall = stealth_at(block, 4, 4) + side_wall.ChangeTurf(/turf/closed/wall) + guard.forceMove(stealth_at(block, 3, 4)) + TEST_ASSERT(stealth_ai.torch.light?.needs_update, "A step didn't queue the lamp's light") + TEST_ASSERT_EQUAL(beam.shown_dir, EAST, "Test fixture: the cone turned before the light did") + TEST_ASSERT_EQUAL(beam.icon_state, "beam_3", "The waiting cone runs through the wall beside its new tile") + stealth_apply_light(stealth_ai.torch) + // Backing away from the wall: until the body lands, the cone stops at the wall ahead of the tile it left. + guard.forceMove(stealth_at(block, 3, 3)) + stealth_apply_light(stealth_ai.torch) + stealth_ai.torch_from = null + stealth_ai.stealth_place_torch() + stealth_apply_light(stealth_ai.torch) + TEST_ASSERT_EQUAL(beam.icon_state, "beam_11", "Test fixture: the cone isn't cut at the wall") + guard.set_glide_size(2) + guard.forceMove(stealth_at(block, 2, 3)) + stealth_apply_light(stealth_ai.torch) + TEST_ASSERT_EQUAL(beam.icon_state, "beam_11", "Mid-step backing away, the cone ran past the wall ahead of the tile it left") + stealth_ai.torch_from_until = world.time + stealth_ai.stealth_cone_landed() + stealth_apply_light(stealth_ai.torch) + TEST_ASSERT_EQUAL(beam.icon_state, "beam_15", "Landed, the cone didn't reach the wall again") + // Nothing ahead: full length. + wall.ChangeTurf(/turf/open/floor/iron) + stealth_ai.stealth_place_torch() + stealth_apply_light(stealth_ai.torch) + TEST_ASSERT_EQUAL(beam.icon_state, "beam_[open_reach]", "An open cone is cut short") + qdel(guard) + qdel(block) + /datum/unit_test/voidcrew_stealth_light_beam /datum/unit_test/voidcrew_stealth_light_beam/Run() From 6c7022b9026a887ce9b4d3e71f6af1c779989291 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Thu, 12 Nov 2026 17:38:09 -0800 Subject: [PATCH 41/78] Guards hear running, gunfire and other noises from less far --- voidcrew/_DEFINES/stealth_hearing.dm | 39 ++++++++++--------- .../unit_tests/voidcrew_stealth_d37.dm | 2 +- .../unit_tests/voidcrew_stealth_hearing.dm | 18 ++++----- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/voidcrew/_DEFINES/stealth_hearing.dm b/voidcrew/_DEFINES/stealth_hearing.dm index 314e9a8540f..f8a8cd52ed4 100644 --- a/voidcrew/_DEFINES/stealth_hearing.dm +++ b/voidcrew/_DEFINES/stealth_hearing.dm @@ -89,24 +89,25 @@ #define STEALTH_BARK_RADIO_DEAD "stealth_radio_dead" // ===== Numbers (first playtest defaults; the owner tunes them) ===== -// Reach in open air, in tiles. Each is at or under how far a player hears the same tg sound. -#define STEALTH_NOISE_RANGE_GUN_QUIET 4 -#define STEALTH_NOISE_RANGE_GUN_PISTOL 9 -#define STEALTH_NOISE_RANGE_GUN_SMG 11 -#define STEALTH_NOISE_RANGE_GUN_LONG 14 -#define STEALTH_NOISE_RANGE_IMPACT 5 +// Reach in open air, in tiles. Each is at or under how far a player hears the same tg sound. Lowered in decision 43 +// (playtest 2: "the distance they can hear things from seems a bit absurd, like running for example"). +#define STEALTH_NOISE_RANGE_GUN_QUIET 3 +#define STEALTH_NOISE_RANGE_GUN_PISTOL 8 +#define STEALTH_NOISE_RANGE_GUN_SMG 10 +#define STEALTH_NOISE_RANGE_GUN_LONG 12 +#define STEALTH_NOISE_RANGE_IMPACT 4 #define STEALTH_NOISE_RANGE_IMPACT_QUIET 1 -#define STEALTH_NOISE_RANGE_BLAST 16 -#define STEALTH_NOISE_RANGE_GLASS 8 -#define STEALTH_NOISE_RANGE_THROWN_SMALL 4 -#define STEALTH_NOISE_RANGE_THROWN_MEDIUM 6 -#define STEALTH_NOISE_RANGE_THROWN_HEAVY 8 +#define STEALTH_NOISE_RANGE_BLAST 14 +#define STEALTH_NOISE_RANGE_GLASS 7 +#define STEALTH_NOISE_RANGE_THROWN_SMALL 3 +#define STEALTH_NOISE_RANGE_THROWN_MEDIUM 5 +#define STEALTH_NOISE_RANGE_THROWN_HEAVY 6 #define STEALTH_NOISE_RANGE_KNOCK 5 -#define STEALTH_NOISE_RANGE_BASH 7 -#define STEALTH_NOISE_RANGE_DOOR 4 -#define STEALTH_NOISE_RANGE_THUD 4 -#define STEALTH_NOISE_RANGE_VOICE 5 -#define STEALTH_NOISE_RANGE_SCREAM 9 +#define STEALTH_NOISE_RANGE_BASH 6 +#define STEALTH_NOISE_RANGE_DOOR 3 +#define STEALTH_NOISE_RANGE_THUD 3 +#define STEALTH_NOISE_RANGE_VOICE 4 +#define STEALTH_NOISE_RANGE_SCREAM 8 #define STEALTH_NOISE_RANGE_SHOUT 9 /// A step on glass (tg plays it at 50: a player hears it 12 tiles off) #define STEALTH_NOISE_RANGE_CRUNCH 4 @@ -159,12 +160,12 @@ #define STEALTH_RELAY_VOICE_RANGE 5 #define STEALTH_RELAY_VOICE_RESPONDERS 2 /// How far a running step on plain floor in shoes carries to a guard -#define STEALTH_FOOTSTEP_RANGE 5 +#define STEALTH_FOOTSTEP_RANGE 3 /// How far a player hears that same step (tg: volume 75, range 17 - 1 - 6) #define STEALTH_FOOTSTEP_PLAYER_RANGE 8 /// The furthest any step is listened for -#define STEALTH_FOOTSTEP_MAX_RANGE 7 -#define STEALTH_FOOTSTEP_CRAWL_RANGE 2 +#define STEALTH_FOOTSTEP_MAX_RANGE 5 +#define STEALTH_FOOTSTEP_CRAWL_RANGE 1 /// Notice a heard step adds #define STEALTH_FOOTSTEP_NOTICE 0.5 /// How long the admin noise view keeps one event on screen diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_d37.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_d37.dm index 492a776fd65..1c53d140431 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_d37.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_d37.dm @@ -115,7 +115,7 @@ settle(watcher) watcher_ai.group.forget_noises() // A wooden door, opened through tg's own Open(). - var/obj/structure/mineral_door/wood/wood = allocate(/obj/structure/mineral_door/wood, at(6, 3)) + var/obj/structure/mineral_door/wood/wood = allocate(/obj/structure/mineral_door/wood, at(5, 3)) INVOKE_ASYNC(wood, TYPE_PROC_REF(/obj/structure/mineral_door, Open)) TEST_ASSERT_EQUAL(watcher_ai.stealth_state(), "suspicious", "A guard didn't react to a wooden door opening in front of it") TEST_ASSERT_EQUAL(watcher_ai.last_heard?[1], "door", "A wooden door made no noise") diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_hearing.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_hearing.dm index 45bff29b12a..4c73780cf76 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_hearing.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_hearing.dm @@ -120,13 +120,13 @@ var/list/noise = gun.stealth_shot_noise() TEST_ASSERT_EQUAL(noise[1], expected[gun_type], "[gun_type] is the wrong loudness") var/obj/item/gun/ballistic/automatic/pistol/pistol = allocate(/obj/item/gun/ballistic/automatic/pistol, here) - TEST_ASSERT_EQUAL(pistol.stealth_shot_noise()[2], 9, "A pistol's reach isn't 9") + TEST_ASSERT_EQUAL(pistol.stealth_shot_noise()[2], 8, "A pistol's reach isn't 8") pistol.fire_sound_volume = 10 - TEST_ASSERT(pistol.stealth_shot_noise()[2] < 9, "A quiet custom gun is heard as far as a loud one") + TEST_ASSERT(pistol.stealth_shot_noise()[2] < 8, "A quiet custom gun is heard as far as a loud one") pistol.install_suppressor(new /obj/item/suppressor(pistol)) var/list/quiet = pistol.stealth_shot_noise() TEST_ASSERT_EQUAL(quiet[1], "gun_quiet", "A pistol with a suppressor fitted isn't quiet") - TEST_ASSERT_EQUAL(quiet[2], 4, "A suppressed shot's reach isn't 4") + TEST_ASSERT_EQUAL(quiet[2], 3, "A suppressed shot's reach isn't 3") /// tg's footstep rules: running is heard, walking and every silencer are not. /datum/unit_test/voidcrew_stealth_live/hear/footstep_reach @@ -136,22 +136,22 @@ var/mob/living/carbon/human/runner = person_at(1, 1, FALSE) TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 0, "A walking step is heard") runner.toggle_move_intent() - TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 5, "A running step barefoot on plain floor doesn't carry 5") + TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 3, "A running step barefoot on plain floor doesn't carry 3") runner.equip_to_slot_or_del(new /obj/item/clothing/shoes/sneakers/black(runner), ITEM_SLOT_FEET) - TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 5, "A running step in shoes on plain floor doesn't carry 5") + TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 3, "A running step in shoes on plain floor doesn't carry 3") var/turf/plating = at(3, 1) plating.ChangeTurf(/turf/open/floor/plating) runner.forceMove(plating) - TEST_ASSERT(stealth_footstep_reach(runner) > 5, "Plating is no louder than floor") + TEST_ASSERT(stealth_footstep_reach(runner) > 3, "Plating is no louder than floor") runner.forceMove(at(1, 1)) ADD_TRAIT(runner, TRAIT_LIGHT_STEP, TRAIT_SOURCE_UNIT_TESTS) - TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 3, "A light step doesn't carry 3") + TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 2, "A light step doesn't carry 2") REMOVE_TRAIT(runner, TRAIT_LIGHT_STEP, TRAIT_SOURCE_UNIT_TESTS) ADD_TRAIT(runner, TRAIT_SILENT_FOOTSTEPS, TRAIT_SOURCE_UNIT_TESTS) TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 0, "Silent footsteps are heard") REMOVE_TRAIT(runner, TRAIT_SILENT_FOOTSTEPS, TRAIT_SOURCE_UNIT_TESTS) runner.set_body_position(LYING_DOWN) - TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 2, "Crawling doesn't carry 2") + TEST_ASSERT_EQUAL(stealth_footstep_reach(runner), 1, "Crawling doesn't carry 1") runner.set_body_position(STANDING_UP) var/obj/structure/closet/locker = allocate(/obj/structure/closet, at(1, 1)) runner.forceMove(locker) @@ -201,7 +201,7 @@ for(var/mob/living/guard as anything in list(first, second, third)) settle(guard) group.rewind(4 SECONDS) - TEST_ASSERT_EQUAL(stealth_noise(at(15, 1), "glass"), 2, "A smash 6 and 8 tiles off wasn't heard by two") + TEST_ASSERT_EQUAL(stealth_noise(at(14, 1), "glass"), 2, "A smash 5 and 7 tiles off wasn't heard by two") TEST_ASSERT_EQUAL(third_ai.stealth_state(), "suspicious", "Nobody went to a noise somewhere new") TEST_ASSERT_EQUAL(second_ai.stealth_state(), "unaware", "Two went to the first noise at a new spot") no_targets(list(first, second, third)) From 257faadd68eeba50a7009ac57c50ae18aae71145 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Thu, 12 Nov 2026 18:19:55 -0800 Subject: [PATCH 42/78] Stealth guards lose you when they can't see you, and keep what they know to themselves Alert guards go to where they last saw a target instead of following them through walls, and keep or shoot a target only by the light they could notice someone in. Running in a disguise is heard as footsteps rather than giving it away, a guard knows a face or a blown disguise only from its own eyes or a shout or radio call that reached it, stripping a guard who is out cold is no touch, and a scav pass counts wherever a door would read it. --- voidcrew/modules/stealth/stealth_ai.dm | 86 +++++- voidcrew/modules/stealth/stealth_closet.dm | 4 +- voidcrew/modules/stealth/stealth_disguise.dm | 74 +++-- voidcrew/modules/stealth/stealth_hearing.dm | 5 +- voidcrew/modules/stealth/stealth_noise.dm | 9 +- voidcrew/modules/stealth/stealth_patrol.dm | 1 - voidcrew/modules/stealth/stealth_radio.dm | 6 + voidcrew/modules/unit_tests/_unit_tests.dm | 1 + .../unit_tests/voidcrew_stealth_d44.dm | 290 ++++++++++++++++++ .../unit_tests/voidcrew_stealth_disguise.dm | 13 +- 10 files changed, 443 insertions(+), 46 deletions(-) create mode 100644 voidcrew/modules/unit_tests/voidcrew_stealth_d44.dm diff --git a/voidcrew/modules/stealth/stealth_ai.dm b/voidcrew/modules/stealth/stealth_ai.dm index a86870fd8a6..f04a00641c3 100644 --- a/voidcrew/modules/stealth/stealth_ai.dm +++ b/voidcrew/modules/stealth/stealth_ai.dm @@ -4,7 +4,6 @@ COMSIG_CARBON_CUFF_ATTEMPTED,\ COMSIG_LIVING_TRY_SYRINGE_INJECT,\ COMSIG_LIVING_TRY_SYRINGE_WITHDRAW,\ - COMSIG_BEING_STRIPPED,\ COMSIG_ATOM_ITEM_INTERACTION,\ COMSIG_ATOM_ITEM_INTERACTION_SECONDARY,\ ) @@ -89,6 +88,7 @@ /datum/ai_planning_subtree/stealth_react, /datum/ai_planning_subtree/human_npc_arm, /datum/ai_planning_subtree/stealth_closet, + /datum/ai_planning_subtree/stealth_chase_lost, /datum/ai_planning_subtree/human_npc_shoot, /datum/ai_planning_subtree/human_npc_melee, /datum/ai_planning_subtree/stealth_patrol, @@ -205,6 +205,7 @@ RegisterSignal(new_pawn, COMSIG_LIVING_GET_PULLED, PROC_REF(on_pulled)) RegisterSignal(new_pawn, COMSIG_ATOM_BUMPED, PROC_REF(on_bumped)) RegisterSignals(new_pawn, STEALTH_HANDLED_SIGNALS, PROC_REF(on_handled)) + RegisterSignal(new_pawn, COMSIG_BEING_STRIPPED, PROC_REF(on_stripped)) RegisterSignal(new_pawn, COMSIG_ATOM_PREHITBY, PROC_REF(on_prehitby)) RegisterSignal(new_pawn, COMSIG_PROJECTILE_PREHIT, PROC_REF(on_projectile_prehit)) RegisterSignals(new_pawn, list(COMSIG_ATOM_EX_ACT, COMSIG_LIVING_IGNITED, COMSIG_MOB_FLASHED), PROC_REF(on_harmed)) @@ -219,6 +220,7 @@ UnregisterSignal(pawn, list( COMSIG_LIVING_GET_PULLED, COMSIG_ATOM_BUMPED, + COMSIG_BEING_STRIPPED, COMSIG_ATOM_PREHITBY, COMSIG_PROJECTILE_PREHIT, COMSIG_ATOM_EX_ACT, @@ -1021,8 +1023,37 @@ stealth_switch_target(pick) /** - * Alert: keeps its target with tg's all-round can_attack() at the NPC's sight range (abuse P2). Out of - * sight for STEALTH_LOSE_TARGET_TIME, it searches where it last saw them, not where they are now. + * Alert: whether the light lets it keep `thing` in view (decision 44). All round, since it is hunting them, but by + * the same light as noticing someone: what is lit (the room's lights, anyone's flashlight, its own beam) out to + * its full sight; in the dark only within its dark sight range. Beside it, always. Blind, only what is lit at its + * shoulder. A mech is plain whatever the light (abuse P9). Line of sight is the caller's. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_alert_lit(atom/thing) + var/mob/living/guard = pawn + var/turf/where = get_turf(thing) + if(isnull(where) || !isturf(guard.loc)) + return FALSE + var/dist = get_dist(guard, where) + if(ismecha(thing) || dist <= STEALTH_ADJACENT_RANGE) + return TRUE + var/datum/stealth_skill/profile = stealth_skill() + var/lit = HAS_TRAIT(guard, TRAIT_NIGHT_VISION) || !stealth_tile_is_dark(where) + if(guard.is_blind()) + return lit && dist <= profile.close_range + return lit || dist <= profile.dark_sight_range + +/// Alert: whether it has `thing` in view now, to fight: tg's all-round can_attack() at the NPC's sight range +/// (abuse P2), in light it can see by (stealth_alert_lit()). +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_has_in_view(atom/thing) + if(QDELETED(thing) || !stealth_alert_lit(thing)) + return FALSE + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) + return !!strategy?.can_attack(pawn, thing, HUMAN_NPC_SIGHT_RANGE) + +/** + * Alert: keeps its target while it has them in view (stealth_has_in_view()). Out of view, it goes where it last + * saw them (/datum/ai_planning_subtree/stealth_chase_lost), and after STEALTH_LOSE_TARGET_TIME it searches there, + * not where they are now. */ /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_keep_target() var/mob/living/guard = pawn @@ -1034,8 +1065,7 @@ // In a locker or a box: tracked only if it saw them get in (decision 33, stealth_closet.dm). if(stealth_closet_track(remembered)) return - var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) - if(strategy?.can_attack(guard, remembered, HUMAN_NPC_SIGHT_RANGE)) + if(stealth_has_in_view(remembered)) if(isturf(remembered.loc)) target_free_seen_at = world.time lost_since = 0 @@ -1046,8 +1076,8 @@ if(!target) set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, remembered) return - // In plain sight but no longer worth fighting. - if(get_dist(guard, remembered) <= HUMAN_NPC_SIGHT_RANGE && can_see(guard, remembered, HUMAN_NPC_SIGHT_RANGE)) + // In plain sight but no longer worth fighting. Someone in the dark beyond its dark sight is just out of view. + if(get_dist(guard, remembered) <= HUMAN_NPC_SIGHT_RANGE && stealth_alert_lit(remembered) && can_see(guard, remembered, HUMAN_NPC_SIGHT_RANGE)) clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) clear_blackboard_key(BB_STEALTH_FOCUS) var/mob/living/fallen = remembered @@ -1251,6 +1281,21 @@ if(ismob(toucher)) stealth_touched(toucher) +/** + * A hand in its pockets or on its clothes. Awake, that is being touched. Out cold or helpless, it feels nothing + * (decision 44): whoever of its group sees it done still reacts, through the witness rule here and the body rule + * (stealth_check_bodies()). + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_stripped(mob/living/source, mob/living/stripper) + SIGNAL_HANDLER + if(!ismob(stripper)) + return + if(source.stat != CONSCIOUS || HAS_TRAIT(source, TRAIT_INCAPACITATED)) + if(isliving(stripper) && !source.client && !source.faction_check_atom(stripper)) + group?.witness(stripper, source) + return + stealth_touched(stripper) + /// Anything thrown that lands on it, harmless or not (relay_attackers only reports what hurts). /datum/ai_controller/basic_controller/human_npc/stealth/proc/on_prehitby(atom/source, atom/movable/hit_atom, datum/thrownthing/throwingdatum) SIGNAL_HANDLER @@ -1562,6 +1607,33 @@ controller.stealth_walk(spot, STEALTH_GOTO_SEARCH) return SUBTREE_RETURN_FINISH_PLANNING +/** + * Alert with its target out of view (decision 44): it walks to where it last saw them, never to where they are + * now, and only its own eyes find them again (stealth_has_in_view()). Ends planning, so the shooting and melee + * subtrees after it never walk at or fire on someone it can't see. With them in view it leaves the fight to those. + * Other human NPCs never run this. + */ +/datum/ai_planning_subtree/stealth_chase_lost + +/datum/ai_planning_subtree/stealth_chase_lost/SelectBehaviors(datum/ai_controller/basic_controller/human_npc/stealth/controller, seconds_per_tick) + if(!istype(controller) || controller.stealth_state() != STEALTH_ALERT) + return + var/mob/living/guard = controller.pawn + var/atom/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(guard.stat != CONSCIOUS || QDELETED(target)) + return + if(controller.stealth_has_in_view(target)) + controller.last_seen_turf = get_turf(target) + if(controller.goto_dest) + controller.stealth_drop_walk() + return + var/turf/last = controller.last_seen_turf + if(isnull(last) || controller.stealth_walk_over(last)) + controller.queue_behavior(/datum/ai_behavior/stealth_stand) + return SUBTREE_RETURN_FINISH_PLANNING + controller.stealth_walk(last, STEALTH_GOTO_SEARCH) + return SUBTREE_RETURN_FINISH_PLANNING + // ===== Walking ===== /// Whether its walk to `dest` got there: on the tile, or as near as it could stand. diff --git a/voidcrew/modules/stealth/stealth_closet.dm b/voidcrew/modules/stealth/stealth_closet.dm index 37afd2bddec..91693b33117 100644 --- a/voidcrew/modules/stealth/stealth_closet.dm +++ b/voidcrew/modules/stealth/stealth_closet.dm @@ -35,10 +35,10 @@ var/atom/movable/shell = stealth_shell_of(who) return istype(shell, /obj/structure/closet) ? shell : null -/// Whether it has `box` in view (all round, as it keeps an alert target in view). +/// Whether it has `box` in view (all round, in the light it can see by, as it keeps an alert target in view). /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_sees_closet(obj/structure/closet/box) var/mob/living/guard = pawn - if(QDELETED(box) || !isturf(guard.loc) || get_dist(guard, box) > HUMAN_NPC_SIGHT_RANGE) + if(QDELETED(box) || !isturf(guard.loc) || get_dist(guard, box) > HUMAN_NPC_SIGHT_RANGE || !stealth_alert_lit(box)) return FALSE return can_see(guard, box, HUMAN_NPC_SIGHT_RANGE) diff --git a/voidcrew/modules/stealth/stealth_disguise.dm b/voidcrew/modules/stealth/stealth_disguise.dm index c56c5d94738..d76339ba8c8 100644 --- a/voidcrew/modules/stealth/stealth_disguise.dm +++ b/voidcrew/modules/stealth/stealth_disguise.dm @@ -8,7 +8,7 @@ * - clothing: the scavs' own fatigues, showing, with nothing over them but what the guards' own outfits wear over * theirs (stealth_guard_suits()); * - mask: tg's own "face hidden" (get_face_name() finds no face), whatever hides it; - * - ID: a scav pass in the ID slot. + * - ID: a scav pass where a door would read it (stealth_scav_pass()). * * A disguise holds for a guard while the clothing is on and the guard hasn't seen through it (stealth_fooled()). * While it holds, notice fills slower by stage (stealth_look()), never jumps to an alert, and stops at suspicious, @@ -16,10 +16,10 @@ * guard's near range, they are one of its own: no notice, and a nod. * * What ends it for a guard (stealth_blow(), stealth_make()): a weapon in hand, pulling a fallen guard, an off-limits - * room, being seen laying hands on a guard, standing over a body as it is found, running in earshot, a failed - * challenge, and a face it has gone alert on before (a mask hides the face). The guard remembers faces for good and a - * blown disguise's wearer for STEALTH_MADE_TIME. Its group keeps the same list, which only a wary guard reads: wary - * is what a shout, a radio call or a hold leaves behind, so word of it reaches exactly the guards the alarm did. + * room, being seen laying hands on a guard, standing over a body as it is found, a failed challenge (running while + * stopped is one), and a face it has gone alert on before (a mask hides the face). The guard remembers faces for good + * and a blown disguise's wearer for STEALTH_MADE_TIME. Another guard knows only what it saw itself or what a shout or + * radio call that reached it carried (stealth_tell(), decision 44): nothing spreads through the group by itself. * * Cost: what someone wears is cached on them (/datum/component/stealth_disguise) and thrown away when they put * anything on or take anything off; a guard's scan reads two numbers and a list or two. @@ -94,9 +94,25 @@ if(istype(wearer.w_uniform, /obj/item/clothing/under/syndicate/scav) && !(wearer.check_obscured_slots() & ITEM_SLOT_ICLOTHING)) if(isnull(wearer.wear_suit) || stealth_guard_suits()[wearer.wear_suit.type]) pieces |= STEALTH_PIECE_CLOTHES - if(istype(wearer.wear_id?.GetID(), /obj/item/card/id/advanced/black/scav)) + if(stealth_scav_pass(wearer)) pieces |= STEALTH_PIECE_ID +/** + * The scav pass `who` carries where a door reads a card (tg's get_idcard(): a hand, the ID slot, the belt), a wallet + * read as a door reads it (any card in it) and a PDA by the card in it. Null if none: one in a bag never shows. + */ +/proc/stealth_scav_pass(mob/living/carbon/human/who) + for(var/obj/item/place in who.held_items + list(who.wear_id, who.belt)) + if(istype(place, /obj/item/storage/wallet)) + var/obj/item/card/id/advanced/black/scav/in_wallet = locate() in place + if(in_wallet) + return in_wallet + continue + var/obj/item/card/id/card = place.GetID() + if(istype(card, /obj/item/card/id/advanced/black/scav)) + return card + return null + /// The cache on `who`, worked out afresh if they changed clothes or it is older than STEALTH_DISGUISE_CACHE_TIME /// (a mask pulled down, a face wrecked). Null for anyone but a human. /proc/stealth_disguise_cache(mob/living/carbon/human/who) @@ -133,9 +149,6 @@ var/allowed = TRUE /datum/stealth_group - /// Face name => TRUE, or REF(mob) => world.time the mark runs out: disguises its guards have seen through. - /// Read only by a guard that is wary (stealth_knows()). - var/list/made /// Off-limits turf => whether a pass excuses being there. Null until first asked for. var/list/restricted @@ -194,18 +207,33 @@ /// world.time it may next greet one of its own var/greeted = 0 -/// Whether it sees through `who`: it knows the face, or the wearer of a disguise it saw blown; and, while it is -/// wary, anyone its group does. +/// Whether it sees through `who`: it knows the face, or the wearer of a disguise it saw blown or was told of. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_knows(mob/living/who) + if(!made) + return FALSE var/datum/component/stealth_disguise/cache = stealth_disguise_cache(who) if(isnull(cache)) return FALSE - var/key = REF(who) var/face = cache.face - if(made && ((face && made[face]) || made[key] > world.time)) - return TRUE - var/list/told = blackboard[BB_STEALTH_WARY] ? group?.made : null - return !!(told && ((face && told[face]) || told[key] > world.time)) + return !!((face && made[face]) || made[REF(who)] > world.time) + +/** + * A shout or a radio call of its reached `listener` (dispatch_shout(), radio_call()): the faces it knows and the + * disguises it saw through go with it (decision 44). Nothing else passes word between guards. + */ +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_tell(datum/ai_controller/basic_controller/human_npc/stealth/listener) + if(!made || !istype(listener) || listener == src) + return + for(var/key in made) + var/mark = made[key] + if(mark == TRUE) + LAZYSET(listener.made, key, TRUE) + continue + if(mark <= world.time || listener.made?[key] >= mark) + continue + LAZYSET(listener.made, key, mark) + if(listener.passes) + listener.passes -= key /// `who`'s STEALTH_PIECE_* flags if their disguise holds for this guard: the clothing is on and it hasn't seen /// through them. 0 otherwise. @@ -216,24 +244,20 @@ return pieces /** - * Remembers `who`: their face for good, if it shows. `blown`: also the wearer, face or no face, for - * STEALTH_MADE_TIME (a disguise it saw through; a mask won't fix that). `word`: its group gets the same, for the - * guards an alarm reaches. + * Remembers `who`, seen with its own eyes: their face for good, if it shows. `blown`: also the wearer, face or no + * face, for STEALTH_MADE_TIME (a disguise it saw through; a mask won't fix that). Only it knows, until it tells + * someone (stealth_tell()). */ -/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_make(mob/living/who, blown = TRUE, word = TRUE) +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_make(mob/living/who, blown = TRUE) var/datum/component/stealth_disguise/cache = stealth_disguise_cache(who) if(isnull(cache)) return var/key = REF(who) if(cache.face) LAZYSET(made, cache.face, TRUE) - if(word && group) - LAZYSET(group.made, cache.face, TRUE) if(!blown) return LAZYSET(made, key, world.time + STEALTH_MADE_TIME) - if(word && group) - LAZYSET(group.made, key, world.time + STEALTH_MADE_TIME) if(passes) passes -= key @@ -304,7 +328,7 @@ /// The name on the pass `who` wears, if it is one of its group's own: what its friends called them. An NPC's /// name, never player text; null for a pass in nobody's name or a guard with only its type's name. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_card_name(mob/living/carbon/human/who) - var/obj/item/card/id/card = ishuman(who) ? who.wear_id?.GetID() : null + var/obj/item/card/id/card = ishuman(who) ? (stealth_scav_pass(who) || who.wear_id?.GetID()) : null if(!istype(card) || !card.registered_name) return null for(var/mob/living/carbon/human/npc/friend as anything in group?.living_members()) diff --git a/voidcrew/modules/stealth/stealth_hearing.dm b/voidcrew/modules/stealth/stealth_hearing.dm index b7526728644..cd4e4d41df2 100644 --- a/voidcrew/modules/stealth/stealth_hearing.dm +++ b/voidcrew/modules/stealth/stealth_hearing.dm @@ -221,9 +221,8 @@ continue LAZYSET(heard_now, key, TRUE) last_heard = list("footsteps", world.time) - // Nobody of the den runs about it: a disguise heard running is done for with this guard (decision 40). - if(walker.body_position != LYING_DOWN && (stealth_disguise_of(walker) & STEALTH_PIECE_CLOTHES)) - stealth_make(walker, TRUE, FALSE) + // Running steps are only steps, disguise or not: the ear can't tell who ran. It turns to look, and once it + // sees them in its colours it stops them; running while stopped gives a disguise away (decision 44). if(state == STEALTH_SEARCHING) if(!calm_until && world.time >= next_recentre && get_dist(search_center, where) > 1) next_recentre = world.time + STEALTH_RECENTRE_COOLDOWN diff --git a/voidcrew/modules/stealth/stealth_noise.dm b/voidcrew/modules/stealth/stealth_noise.dm index 7ca4c78b2fc..af8ea362731 100644 --- a/voidcrew/modules/stealth/stealth_noise.dm +++ b/voidcrew/modules/stealth/stealth_noise.dm @@ -343,7 +343,7 @@ if(STEALTH_HEAR_ALARM) dispatch_alarm(hearers, where, spot, kind, actor) if(STEALTH_HEAR_SHOUT) - dispatch_shout(hearers, spot) + dispatch_shout(hearers, spot, actor) /// A small noise: one guard goes to look, the rest glance. The second time at one spot two go; from the third /// everyone who hears it searches there, and they call it in. @@ -429,11 +429,14 @@ guard_ai.stealth_start_call(STEALTH_CALL_ALARM, spot) /// A friend calling for help from `spot`: whoever hears it and isn't a sentry runs to them. They heard a -/// friend, they saw nobody, so they search where the friend stood. -/datum/stealth_group/proc/dispatch_shout(list/hearers, turf/spot) +/// friend, they saw nobody, so they search where the friend stood. Who it was goes with the shout (decision 44). +/datum/stealth_group/proc/dispatch_shout(list/hearers, turf/spot, mob/living/shouter) + var/datum/ai_controller/basic_controller/human_npc/stealth/shouter_ai = shouter?.ai_controller for(var/list/hearer as anything in hearers) var/mob/living/carbon/human/npc/guard = hearer[1] var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = guard.ai_controller + if(istype(shouter_ai)) + shouter_ai.stealth_tell(guard_ai) if(guard_ai.stealth_state() == STEALTH_ALERT) continue if(isnull(guard_ai.route_id)) diff --git a/voidcrew/modules/stealth/stealth_patrol.dm b/voidcrew/modules/stealth/stealth_patrol.dm index 490a2ed627f..b11d1252656 100644 --- a/voidcrew/modules/stealth/stealth_patrol.dm +++ b/voidcrew/modules/stealth/stealth_patrol.dm @@ -75,7 +75,6 @@ GLOBAL_VAR_INIT(stealth_group_count, 0) members = null routes = null home = null - made = null restricted = null return ..() diff --git a/voidcrew/modules/stealth/stealth_radio.dm b/voidcrew/modules/stealth/stealth_radio.dm index 4b024e31ddd..0987296fbf9 100644 --- a/voidcrew/modules/stealth/stealth_radio.dm +++ b/voidcrew/modules/stealth/stealth_radio.dm @@ -107,6 +107,12 @@ for(var/datum/stealth_check/check as anything in speaker_checks) check.waiters |= WEAKREF(guard) return + // Who it was goes out with the alarm to every receiver that got it, even inside the cooldown (decision 44). + var/datum/ai_controller/basic_controller/human_npc/stealth/speaker_ai = speaker.ai_controller + if(istype(speaker_ai)) + for(var/mob/living/carbon/human/npc/guard as anything in guards) + if(guard != speaker && radio_receiver(guard)) + speaker_ai.stealth_tell(guard.ai_controller) if(world.time < next_radio_alarm) return 0 next_radio_alarm = world.time + STEALTH_RADIO_GROUP_COOLDOWN diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index c7207be5cd1..575880487b0 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -240,6 +240,7 @@ #include "voidcrew_stealth_d32.dm" #include "voidcrew_stealth_d37.dm" #include "voidcrew_stealth_d39.dm" +#include "voidcrew_stealth_d44.dm" #include "voidcrew_stealth_disguise.dm" #include "voidcrew_stealth_hearing.dm" #include "voidcrew_stealth_light.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_d44.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_d44.dm new file mode 100644 index 00000000000..7fbdd705ba8 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_d44.dm @@ -0,0 +1,290 @@ +// Stealth guards, owner decision 44 (playtest 2: disguises and tracking). voidcrew/modules/stealth/stealth_disguise.dm, +// stealth_hearing.dm, stealth_noise.dm, stealth_radio.dm, stealth_ai.dm and stealth_closet.dm. Values from voidcrew/_DEFINES +// are written out: STEALTH_LOSE_TARGET_TIME 4 s, STEALTH_RADIO_CALL_TIME 3 s; a yellow guard's dark sight is 4 tiles, its +// close range 2, its challenge range for the whole set 2. Pieces: clothing 2, pass 4. States and the blackboard key +// BB_HUMAN_NPC_NEXT_SHOT ("human_npc_next_shot") are written as text. +// The tests down to voidcrew_stealth_d44_alert_dark call the scan directly; the voidcrew_stealth_live ones run the real AI. + +#define STEALTH_TEST_GUNNER /mob/living/carbon/human/npc/ruin/trooper/scav/gunner +#define STEALTH_TEST_LOOKOUT /mob/living/carbon/human/npc/ruin/trooper/scav/lookout + +/// Running in the whole set behind a guard is only footsteps: it turns, stops them, and running while stopped gives +/// them away. +/datum/unit_test/voidcrew_stealth_d44_run_disguised + +/datum/unit_test/voidcrew_stealth_d44_run_disguised/Run() + var/datum/turf_reservation/block = stealth_block(20, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 2, WEST) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 10, 2) + stealth_dress(person) + person.equip_to_slot_or_del(new /obj/item/clothing/shoes/jackboots(person), ITEM_SLOT_FEET) + stealth_scans(guard, 1) + person.toggle_move_intent() + person.forceMove(stealth_at(block, 8, 2)) + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(guard_ai.last_heard?[1], "footsteps", "The guard didn't hear someone run up two tiles behind it") + TEST_ASSERT(guard_ai.stealth_fooled(person), "Running behind a guard gave the disguise away by ear") + TEST_ASSERT(!length(guard_ai.made), "The guard marked someone it only heard") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "suspicious", "Running two tiles behind a guard drew no look") + TEST_ASSERT_EQUAL(guard.dir, EAST, "The guard didn't turn to the steps") + TEST_ASSERT_NULL(guard_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], "The guard went for someone it only heard") + // The moment after the turn has passed: it sees them in its colours and stops them. + guard_ai.turned_at = 0 + stealth_scans(guard, 1) + TEST_ASSERT_EQUAL(guard_ai.challenge?.resolve(), person, "The guard didn't stop someone in its colours two tiles in front of it") + TEST_ASSERT_NULL(guard_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], "The guard went for someone it stopped") + // Running off while stopped. + person.forceMove(stealth_at(block, 9, 2)) + stealth_scans(guard, 1) + TEST_ASSERT(!guard_ai.stealth_fooled(person), "Running off while stopped didn't give the disguise away") + TEST_ASSERT(guard_ai.made?[REF(person)] > world.time, "The guard doesn't remember who ran off") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "alert", "The guard let someone run off from a stop") + qdel(block) + +/// Stripping a guard that is out cold is no touch: it learns nothing. A friend who sees it done still sees through +/// the disguise; one looking away doesn't. An awake guard being stripped turns on them. +/datum/unit_test/voidcrew_stealth_d44_strip + +/datum/unit_test/voidcrew_stealth_d44_strip/Run() + var/datum/turf_reservation/block = stealth_block(20, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/watcher = stealth_guard(block, 6, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/watcher_ai = stealth_ai(watcher) + watcher_ai.stealth_setup() + var/mob/living/carbon/human/npc/away = stealth_guard(block, 2, 2, WEST) + var/datum/ai_controller/basic_controller/human_npc/stealth/away_ai = stealth_ai(away) + away_ai.stealth_setup() + var/mob/living/carbon/human/npc/victim = stealth_guard(block, 11, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/victim_ai = stealth_ai(victim) + victim_ai.stealth_setup() + TEST_ASSERT_EQUAL(victim_ai.group, watcher_ai.group, "The guards aren't one group") + var/mob/living/carbon/human/person = stealth_person(block, 10, 2) + stealth_dress(person) + victim.Unconscious(100 SECONDS) + TEST_ASSERT(victim.stat != CONSCIOUS || HAS_TRAIT(victim, TRAIT_INCAPACITATED), "The guard isn't out cold") + SEND_SIGNAL(victim, COMSIG_BEING_STRIPPED, person, victim.wear_id) + TEST_ASSERT(!length(victim_ai.made), "A guard out cold learned who stripped it") + TEST_ASSERT_NULL(victim_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], "A guard out cold took a target") + TEST_ASSERT_EQUAL(watcher_ai.stealth_state(), "alert", "A guard watched a friend being stripped and did nothing") + TEST_ASSERT_EQUAL(watcher_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], person, "The watching guard isn't after the one stripping") + TEST_ASSERT(away_ai.stealth_fooled(person), "A guard looking away saw the stripping") + qdel(watcher) + qdel(victim) + // Awake, it is a touch. + var/mob/living/carbon/human/npc/awake = stealth_guard(block, 11, 3) + var/datum/ai_controller/basic_controller/human_npc/stealth/awake_ai = stealth_ai(awake) + awake_ai.stealth_setup() + SEND_SIGNAL(awake, COMSIG_BEING_STRIPPED, person, awake.wear_id) + TEST_ASSERT_EQUAL(awake_ai.stealth_state(), "alert", "An awake guard being stripped didn't turn on them") + qdel(block) + +/// The pass counts where a door would read it: in a hand, in a wallet or a PDA, on the belt. Not in a bag. +/datum/unit_test/voidcrew_stealth_d44_pass_places + +/datum/unit_test/voidcrew_stealth_d44_pass_places/Run() + var/datum/turf_reservation/block = stealth_block(3, 3) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/person = stealth_person(block, 1, 1) + stealth_dress(person, TRUE, FALSE, FALSE) + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 2, "The fatigues alone aren't the clothing piece") + var/obj/item/card/id/advanced/black/scav/pass = new(person) + TEST_ASSERT(person.put_in_hands(pass), "The pass wouldn't go in a hand") + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 6, "A pass held in a hand doesn't count") + TEST_ASSERT(person.dropItemToGround(pass), "The pass wouldn't drop") + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 2, "A pass on the floor still counts") + // In a wallet in the ID slot. + var/obj/item/storage/wallet/wallet = new(person) + pass.forceMove(wallet) + TEST_ASSERT(person.equip_to_slot_if_possible(wallet, ITEM_SLOT_ID), "The wallet wouldn't go on") + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 6, "A pass in a wallet in the ID slot doesn't count") + TEST_ASSERT(person.dropItemToGround(wallet), "The wallet wouldn't come off") + // In a PDA on the belt. + var/obj/item/modular_computer/pda/pda = new(person) + pass.forceMove(person) + pda.InsertID(pass, null) + TEST_ASSERT_EQUAL(pda.computer_id_slot, pass, "The pass didn't go in the PDA") + TEST_ASSERT(person.equip_to_slot_if_possible(pda, ITEM_SLOT_BELT), "The PDA wouldn't go on the belt") + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 6, "A pass in a PDA on the belt doesn't count") + // Deep in a bag. + var/obj/item/storage/backpack/bag = new(person) + TEST_ASSERT(person.equip_to_slot_if_possible(bag, ITEM_SLOT_BACK), "The bag wouldn't go on") + new /obj/item/card/id/advanced/black/scav(bag) + TEST_ASSERT(person.dropItemToGround(pda), "The PDA wouldn't come off") + TEST_ASSERT_EQUAL(stealth_disguise_of(person), 2, "A pass in a bag counts") + qdel(block) + +/// Alert, it keeps its target all round, in the light it can see by: lit, out to its sight; dark, within its dark +/// sight. Lost in the dark long enough, it searches where it last saw them. +/datum/unit_test/voidcrew_stealth_d44_alert_dark + +/datum/unit_test/voidcrew_stealth_d44_alert_dark/Run() + var/datum/turf_reservation/block = stealth_block(20, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 6, 2) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = stealth_ai(guard) + var/mob/living/carbon/human/person = stealth_person(block, 9, 2) + for(var/dx in 0 to 19) + GLOB.stealth_test_dark_turfs[stealth_at(block, dx, 2)] = TRUE + guard_ai.stealth_go_alert(person) + // Three tiles off in the dark: within its dark sight. + guard_ai.stealth_keep_target() + TEST_ASSERT(!guard_ai.lost_since, "An alert guard lost someone three tiles off in the dark") + // Three tiles behind it in the dark: all round. + person.forceMove(stealth_at(block, 3, 2)) + guard_ai.stealth_keep_target() + TEST_ASSERT(!guard_ai.lost_since, "An alert guard lost someone three tiles behind it") + // Six tiles off in the dark: out of view. + person.forceMove(stealth_at(block, 12, 2)) + TEST_ASSERT(!guard_ai.stealth_has_in_view(person), "An alert guard has someone six tiles off in the dark in view") + guard_ai.stealth_keep_target() + TEST_ASSERT(guard_ai.lost_since, "An alert guard kept someone six tiles off in the dark") + // Lit there: back in view. + GLOB.stealth_test_dark_turfs[stealth_at(block, 12, 2)] = FALSE + guard_ai.stealth_keep_target() + TEST_ASSERT(!guard_ai.lost_since, "An alert guard didn't see someone lit six tiles off") + TEST_ASSERT_EQUAL(guard_ai.last_seen_turf, stealth_at(block, 12, 2), "The guard didn't note where it saw them") + // Into the dark further on, and long enough: it searches where it last saw them, not where they are. + person.forceMove(stealth_at(block, 14, 2)) + guard_ai.stealth_keep_target() + TEST_ASSERT(guard_ai.lost_since, "An alert guard kept someone eight tiles off in the dark") + guard_ai.stealth_rewind(5 SECONDS) + guard_ai.stealth_keep_target() + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "searching", "A guard that lost someone in the dark isn't searching") + TEST_ASSERT_EQUAL(guard_ai.last_seen_turf, stealth_at(block, 12, 2), "The guard searches somewhere it never saw them") + TEST_ASSERT_NULL(guard_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], "The guard kept a target it lost") + qdel(block) + +/// A gunner, a lookout or a plain guard at (dx, dy) of the room, as guard_at() places one. +/datum/unit_test/voidcrew_stealth_live/proc/npc_at(npc_type, dx, dy, facing = EAST) + var/mob/living/carbon/human/npc/guard = allocate(npc_type, at(dx, dy)) + guard.setDir(facing) + guard.AddElement(/datum/element/forced_gravity, 1) + return guard + +/// The real AI: a lookout sees through a disguise. The friend in earshot of its shout is told, the friend on the radio +/// is told when the call goes out, and a wary friend neither reached knows nothing. +/datum/unit_test/voidcrew_stealth_live/d44_word + +/datum/unit_test/voidcrew_stealth_live/d44_word/Run() + TEST_ASSERT(make_room(30, 5), "No room for the test") + allocate(/obj/effect/landmark/stealth_group, at(0, 4)) + for(var/dy in 0 to 4) + var/turf/wall_spot = at(14, dy) + wall_spot.ChangeTurf(/turf/closed/wall) + var/mob/living/carbon/human/person = person_at(9, 2) + stealth_dress(person) + var/mob/living/carbon/human/npc/lookout = npc_at(STEALTH_TEST_LOOKOUT, 6, 2, EAST) + var/mob/living/carbon/human/npc/near = guard_at(2, 2, WEST) + var/mob/living/carbon/human/npc/far_radio = npc_at(STEALTH_TEST_LOOKOUT, 22, 2, EAST) + var/mob/living/carbon/human/npc/far_plain = guard_at(26, 2, EAST) + TEST_ASSERT(istype(lookout.ears, /obj/item/radio) && istype(far_radio.ears, /obj/item/radio), "A lookout has no earpiece") + var/datum/ai_controller/basic_controller/human_npc/stealth/lookout_ai = wake(lookout) + var/datum/ai_controller/basic_controller/human_npc/stealth/near_ai = wake(near) + var/datum/ai_controller/basic_controller/human_npc/stealth/far_radio_ai = wake(far_radio) + var/datum/ai_controller/basic_controller/human_npc/stealth/far_plain_ai = wake(far_plain) + sleep(2 SECONDS) + TEST_ASSERT(lookout_ai.group && lookout_ai.group == near_ai.group && lookout_ai.group == far_radio_ai.group && lookout_ai.group == far_plain_ai.group, "The four guards aren't one group") + TEST_ASSERT(lookout_ai.stealth_fooled(person), "The lookout saw through the whole set before anything happened") + far_radio_ai.stealth_set_wary() + far_plain_ai.stealth_set_wary() + var/key = REF(person) + // A gun in hand gives it away. + person.put_in_hands(new /obj/item/gun/ballistic/automatic/pistol(person)) + var/deadline = world.time + 10 SECONDS + while(world.time < deadline && lookout_ai.stealth_state() != "alert") + sleep(1) + TEST_ASSERT_EQUAL(lookout_ai.stealth_state(), "alert", "The lookout never saw through someone in its colours holding a gun") + TEST_ASSERT(lookout_ai.made?[key] > world.time, "The lookout doesn't remember who it saw through") + TEST_ASSERT(near_ai.made?[key] > world.time, "The guard in earshot of the shout wasn't told who it was") + TEST_ASSERT(!far_radio_ai.made?[key], "The guard on the radio knew before the call went out") + TEST_ASSERT(!far_plain_ai.stealth_knows(person), "A wary guard nobody told knew the disguise") + deadline = world.time + 10 SECONDS + while(world.time < deadline && !far_radio_ai.made?[key]) + sleep(1) + TEST_ASSERT(far_radio_ai.made?[key] > world.time, "The radio call didn't tell the guard on the radio who it was") + TEST_ASSERT(!far_plain_ai.made?[key], "A wary guard neither the shout nor the radio reached knew the disguise") + +/// The real AI: an alert gunner loses someone round a corner. It goes to where it last saw them, never toward where +/// they are now, and drops to a search there. +/datum/unit_test/voidcrew_stealth_live/d44_lost_corner + +/datum/unit_test/voidcrew_stealth_live/d44_lost_corner/Run() + TEST_ASSERT(make_room(16, 9), "No room for the test") + // A wall up from the corner tile's west side, and one across the east part of the room: the far corner is + // reached only round the gap at the east end, and seen from neither the guard's side nor the corner. + for(var/dy in 2 to 8) + var/turf/wall_spot = at(8, dy) + wall_spot.ChangeTurf(/turf/closed/wall) + for(var/dx in 9 to 13) + var/turf/wall_spot = at(dx, 4) + wall_spot.ChangeTurf(/turf/closed/wall) + var/turf/corner = at(9, 1) + var/mob/living/carbon/human/person = person_at(9, 1) + var/mob/living/carbon/human/npc/guard = npc_at(STEALTH_TEST_GUNNER, 4, 1, EAST) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = wake(guard) + guard_ai.stealth_go_alert(person) + sleep(2 SECONDS) + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "alert", "The guard isn't alert on someone in plain sight") + TEST_ASSERT_EQUAL(guard_ai.last_seen_turf, corner, "The guard didn't note where it saw them") + // Round the corner and away. + person.forceMove(at(10, 7)) + TEST_ASSERT(!can_see(guard, person, 9), "The test's walls don't hide the far corner from the guard") + var/chased = FALSE + var/strayed = FALSE + var/reached = FALSE + // One plan to catch up: a walk at them from the moment before they moved isn't a chase. + var/settled_at = world.time + 1 SECONDS + var/deadline = world.time + 10 SECONDS + while(world.time < deadline && guard_ai.stealth_state() == "alert") + if(world.time >= settled_at && guard_ai.current_movement_target == person) + chased = TRUE + if(guard.x > corner.x + 2 || guard.y > corner.y + 2) + strayed = TRUE + if(get_dist(guard, corner) <= 1) + reached = TRUE + sleep(1) + TEST_ASSERT(!chased, "A guard that lost someone round a corner walked at where they are now") + TEST_ASSERT(!strayed, "A guard that lost someone round a corner went past where it last saw them") + TEST_ASSERT(reached, "A guard that lost someone round a corner didn't go to where it last saw them (it is [get_dist(guard, corner)] tiles off)") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "searching", "A guard that lost someone round a corner isn't searching") + TEST_ASSERT_EQUAL(guard_ai.last_seen_turf, corner, "The guard searches somewhere it never saw them") + +/// The real AI: an alert gunner behind glass can't shoot someone unlit six tiles off, and loses them. Lit, it shoots. +/datum/unit_test/voidcrew_stealth_live/d44_dark_shot + +/datum/unit_test/voidcrew_stealth_live/d44_dark_shot/Run() + TEST_ASSERT(make_room(14, 5), "No room for the test") + // A glass wall beside it: in sight, out of reach, so the guard can't walk up into its dark sight. + for(var/dy in 0 to 4) + allocate(/obj/structure/window/reinforced/fulltile, at(2, dy)) + var/list/dark_spots = list() + for(var/dx in 3 to 13) + for(var/dy in 0 to 4) + var/turf/spot = at(dx, dy) + GLOB.stealth_test_dark_turfs[spot] = TRUE + dark_spots += spot + var/mob/living/carbon/human/person = person_at(6, 2) + var/mob/living/carbon/human/npc/guard = npc_at(STEALTH_TEST_GUNNER, 0, 2, EAST) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = wake(guard) + guard_ai.stealth_go_alert(person) + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "alert", "The guard didn't go alert") + var/shot_in_dark = FALSE + var/deadline = world.time + 7 SECONDS + while(world.time < deadline) + if(guard_ai.blackboard["human_npc_next_shot"]) + shot_in_dark = TRUE + sleep(1) + TEST_ASSERT(!shot_in_dark, "An alert guard shot at someone unlit six tiles off") + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "searching", "An alert guard didn't lose someone unlit six tiles off") + // The lights come on: it sees them and shoots. + for(var/turf/spot as anything in dark_spots) + GLOB.stealth_test_dark_turfs[spot] = FALSE + deadline = world.time + 20 SECONDS + while(world.time < deadline && !guard_ai.blackboard["human_npc_next_shot"]) + sleep(2) + TEST_ASSERT(guard_ai.blackboard["human_npc_next_shot"], "The guard never shot at someone lit six tiles off (state [guard_ai.stealth_state()]): the test can't tell the dark from a guard that doesn't shoot") + +#undef STEALTH_TEST_GUNNER +#undef STEALTH_TEST_LOOKOUT diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_disguise.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_disguise.dm index f0f20a111a1..012390b11e8 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_disguise.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_disguise.dm @@ -373,13 +373,16 @@ TEST_ASSERT_EQUAL(stealth_ai.stealth_state(), "alert", "A guard watched one of its own being grabbed and did nothing") TEST_ASSERT_EQUAL(stealth_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET], person, "The watching guard isn't after the one it saw") TEST_ASSERT_EQUAL(friend_ai.stealth_state(), "unaware", "A guard with its back to it all reacted") - // Word reaches the third guard only once an alarm has made it wary. + // Word reaches the third guard only through a shout or a call that reaches it (decision 44, voidcrew_stealth_d44.dm): + // being wary is not word. TEST_ASSERT(friend_ai.stealth_fooled(person), "A guard nobody has told sees through them") friend_ai.stealth_set_wary() - TEST_ASSERT(!friend_ai.stealth_fooled(person), "A guard the alarm reached is still fooled") + TEST_ASSERT(friend_ai.stealth_fooled(person), "A wary guard nobody told knows what another guard saw") + stealth_ai.stealth_tell(friend_ai) + TEST_ASSERT(!friend_ai.stealth_fooled(person), "A guard that was told is still fooled") qdel(block) -/// Running in a guard's earshot ends it for that guard; a face it went alert on is known unless a mask hides it. +/// Running in a guard's earshot is only footsteps (decision 44); a face it went alert on is known unless a mask hides it. /datum/unit_test/voidcrew_stealth_disguise_known /datum/unit_test/voidcrew_stealth_disguise_known/Run() @@ -397,8 +400,8 @@ person.toggle_move_intent() person.forceMove(stealth_at(block, 8, 2)) stealth_scans(guard, 1) - TEST_ASSERT(!stealth_ai.stealth_fooled(person), "Running three tiles behind a guard didn't give them away") - TEST_ASSERT(!length(stealth_ai.group.made), "Running in one guard's earshot told its whole group") + TEST_ASSERT(stealth_ai.stealth_fooled(person), "Running three tiles behind a guard gave a disguise away by ear") + TEST_ASSERT(!length(stealth_ai.made), "A guard marked someone it only heard running") qdel(guard) qdel(person) // A face it has gone alert on. From 69fac67c60692c0a850ccf2f12e4ab3e0eb53206 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Thu, 12 Nov 2026 19:35:09 -0800 Subject: [PATCH 43/78] Stealth head shots go by the round and the head's protection, shields don't stop shots in the back, and the matte knife cuts throats from behind --- tgstation.dme | 2 + voidcrew/_DEFINES/stealth.dm | 47 +++- voidcrew/edits/datums/neck_slice_mute.dm | 13 + voidcrew/edits/objects/items/shield_rear.dm | 35 +++ voidcrew/modules/stealth/stealth_crits.dm | 235 +++++++++++----- voidcrew/modules/stealth/stealth_knife.dm | 68 ++++- voidcrew/modules/stealth/stealth_radio.dm | 3 + voidcrew/modules/unit_tests/_unit_tests.dm | 1 + .../unit_tests/voidcrew_stealth_crits.dm | 90 +------ .../unit_tests/voidcrew_stealth_d45.dm | 250 ++++++++++++++++++ 10 files changed, 580 insertions(+), 164 deletions(-) create mode 100644 voidcrew/edits/datums/neck_slice_mute.dm create mode 100644 voidcrew/edits/objects/items/shield_rear.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_stealth_d45.dm diff --git a/tgstation.dme b/tgstation.dme index 815bf4ac9e5..63228436cc9 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -6837,6 +6837,7 @@ #include "voidcrew\edits\controllers\subsystem\weather.dm" #include "voidcrew\edits\controllers\subsystem\networks\bitrunning.dm" #include "voidcrew\edits\datums\alarm.dm" +#include "voidcrew\edits\datums\neck_slice_mute.dm" #include "voidcrew\edits\datums\actions\mobs\charge.dm" #include "voidcrew\edits\datums\components\gps.dm" #include "voidcrew\edits\datums\components\overlay_lighting.dm" @@ -6945,6 +6946,7 @@ #include "voidcrew\edits\objects\items\extinguisher.dm" #include "voidcrew\edits\objects\items\kinetic_accelerator_modkits.dm" #include "voidcrew\edits\objects\items\posibrain.dm" +#include "voidcrew\edits\objects\items\shield_rear.dm" #include "voidcrew\edits\objects\items\weapon_ladder.dm" #include "voidcrew\edits\objects\structures\closet_containment.dm" #include "voidcrew\edits\objects\structures\movable_fixtures.dm" diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index a28d43d01b8..c83709195a2 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -267,7 +267,7 @@ /// It has seen through a disguise #define STEALTH_BARK_BLOWN "stealth_blown" -// ===== Stealth crits and the backstab knife (step 3a, stealth_crits.dm) ===== +// ===== Stealth crits, the head shot and the backstab knife (step 3a, decision 45; stealth_crits.dm, stealth_knife.dm) ===== // Roll bonuses for hyperviolence's aimed crit roll (crit_roll.dm), on a stealth guard only. They go in before wound armour, // so armour scales them like the rest of the roll. Numbers argued in data/stealth/STATUS.md, "Step 3a". /// Added when the guard was unaware of everyone as the blow began @@ -276,17 +276,38 @@ #define STEALTH_CRIT_SUSPICIOUS_BONUS 15 /// Added on top of either when the attacker aimed at the head (head, eyes or mouth) #define STEALTH_CRIT_HEAD_BONUS 35 -/// Added when the backstab knife strikes from behind (tg's check_behind()), whatever the guard's state -#define STEALTH_BACKSTAB_BONUS 40 -/// The head shot crit (a bullet through the skull) needs a roll this high, and only a stealth hit can roll it -#define STEALTH_HEAD_SHOT_THRESHOLD 80 -/// Least damage after armour a head shot crit needs -#define STEALTH_HEAD_SHOT_MIN_DAMAGE 20 -/// A helmet this good against the bullet (after its armour penetration) stops a head shot crit outright -#define STEALTH_HEAD_SHOT_HELMET_ARMOUR 30 -/// Brain damage a head shot crit deals (brains die at 200) -#define STEALTH_HEAD_SHOT_BRAIN_DAMAGE 40 -/// How long a head shot crit knocks the guard down -#define STEALTH_HEAD_SHOT_KNOCKDOWN (4 SECONDS) +// The head shot (decision 45): a bullet aimed at the head of a guard caught off guard. Graded by what the round can do +// against what is on the head. Numbers and the gun table: data/stealth/STATUS.md, "Decision 45". +// The round's power gives burst, down or nothing; each protection step on the head moves it one down the ladder. +/// Nothing happens beyond the hit itself +#define STEALTH_HEAD_SHOT_NONE 0 +/// Stopped short of the skull: knocked out for STEALTH_HEAD_SHOT_HELMET_TIME +#define STEALTH_HEAD_SHOT_HELMET 1 +/// Through the skull: brain damage, a heavy bleed, out cold until the bleed takes him +#define STEALTH_HEAD_SHOT_DOWN 2 +/// The head bursts (hv_burst_head_apart()) +#define STEALTH_HEAD_SHOT_BURST 3 +/// Head protection (tg's armour against the round after its penetration, plus wound armour) for one step down +#define STEALTH_HEAD_SHOT_STEP_ONE 20 +/// For two steps down +#define STEALTH_HEAD_SHOT_STEP_TWO 50 +/// For three steps down: nothing beyond the hit +#define STEALTH_HEAD_SHOT_STEP_THREE 80 +/// Least power for a round through the skull (power: the round's damage, plus half a positive wound bonus, plus the caliber bonus) +#define STEALTH_HEAD_SHOT_MIN_POWER 15 +/// Power at which the head bursts +#define STEALTH_HEAD_SHOT_BURST_POWER 40 +/// Added to the power of a rifle or shotgun round (stealth_heavy_caliber()), once per shot +#define STEALTH_HEAD_SHOT_HEAVY_CALIBER 15 +/// The power of a round from a suppressed gun is multiplied by this +#define STEALTH_HEAD_SHOT_SUPPRESSED_MULT 0.75 +/// Brain damage a round through the skull deals (BRAIN_DAMAGE_SEVERE is 100, brains die at 200) +#define STEALTH_HEAD_SHOT_BRAIN_DAMAGE 120 +/// Blood flow of the wound a round through the skull leaves (tg's critical puncture is 3, a cut throat about 4) +#define STEALTH_HEAD_SHOT_FLOW 8 +/// How long a round through the skull knocks him out: longer than the bleed takes to put him under for good +#define STEALTH_HEAD_SHOT_DOWN_TIME (90 SECONDS) +/// How long a round a helmet stopped knocks him out +#define STEALTH_HEAD_SHOT_HELMET_TIME (6 SECONDS) /// A bullet through the head #define WOUND_SERIES_HV_HEAD_SHOT "wound_series_hv_head_shot" diff --git a/voidcrew/edits/datums/neck_slice_mute.dm b/voidcrew/edits/datums/neck_slice_mute.dm new file mode 100644 index 00000000000..0efa108fd66 --- /dev/null +++ b/voidcrew/edits/datums/neck_slice_mute.dm @@ -0,0 +1,13 @@ +// A cut throat can't speak (owner decision 45, voidcrew/modules/stealth/stealth_knife.dm). tg's neck_slice +// (code/datums/status_effects/debuffs/debuffs.dm) lasts while the throat still bleeds from a bad cut; for that long its +// owner has tg's TRAIT_MUTE, so say(), shouting and radios all fail through tg's own can_speak(). Gasps, gags, chokes and +// other emotes still show. Everyone alike: players and NPCs, however the throat was cut. + +/datum/status_effect/neck_slice/on_apply() + . = ..() + if(.) + ADD_TRAIT(owner, TRAIT_MUTE, TRAIT_STATUS_EFFECT(id)) + +/datum/status_effect/neck_slice/on_remove() + REMOVE_TRAIT(owner, TRAIT_MUTE, TRAIT_STATUS_EFFECT(id)) + return ..() diff --git a/voidcrew/edits/objects/items/shield_rear.dm b/voidcrew/edits/objects/items/shield_rear.dm new file mode 100644 index 00000000000..9bf1b7d10b4 --- /dev/null +++ b/voidcrew/edits/objects/items/shield_rear.dm @@ -0,0 +1,35 @@ +// A shield held in front of you doesn't stop a shot in the back (owner decision 45). Everyone alike: players and NPCs, +// whatever they know. tg blocks a projectile with a held shield in two places, both reached from the victim's +// bullet_act() (code/modules/mob/living/carbon/human/human_defense.dm): the energy shield's reflection +// (check_reflect() -> IsReflect()) and every shield's block (check_block() -> hit_reaction()). While a shot that comes +// from behind is being resolved, neither works. +// +// "From behind": the shot travels the way its victim faces (its angle, so a ricochet counts from where it really came +// from), the same rear arc as tg's check_behind(). Lying down doesn't count as behind here: the shield still covers. + +/mob/living/carbon/human + /// Set while a projectile that hits this human in the back is being resolved + var/vc_shot_in_back = FALSE + +/// Whether `shot` hits `victim` from behind: it travels the way the victim faces. +/proc/vc_shot_from_behind(mob/living/victim, obj/projectile/shot) + if(!istype(shot) || isnull(shot.angle)) + return FALSE + return !!(victim.dir & angle2dir(shot.angle)) + +/mob/living/carbon/human/bullet_act(obj/projectile/bullet, def_zone, piercing_hit = FALSE) + var/was_in_back = vc_shot_in_back + vc_shot_in_back = vc_shot_from_behind(src, bullet) + . = ..() + vc_shot_in_back = was_in_back + +/obj/item/shield/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK, damage_type = BRUTE) + if(attack_type == PROJECTILE_ATTACK && ishuman(owner) && owner.vc_shot_in_back) + return FALSE + return ..() + +/obj/item/shield/energy/IsReflect(def_zone) + var/mob/living/carbon/human/holder = loc + if(ishuman(holder) && holder.vc_shot_in_back) + return FALSE + return ..() diff --git a/voidcrew/modules/stealth/stealth_crits.dm b/voidcrew/modules/stealth/stealth_crits.dm index f40e86720f4..fb5d5d6fdf2 100644 --- a/voidcrew/modules/stealth/stealth_crits.dm +++ b/voidcrew/modules/stealth/stealth_crits.dm @@ -1,9 +1,9 @@ /** - * # Stealth guards: crits on a guard caught unaware, and the head shot (step 3a, owner decisions 9, 16, 19) + * # Stealth guards: crits on a guard caught off guard, and the head shot (step 3a, owner decisions 9, 16, 19, 45) * - * Nothing here deals damage of its own. A blow on a stealth guard that never saw it coming adds to hyperviolence's - * aimed crit roll (crit_roll.dm, hv_crit_situation_bonus()), so it only matters on an aimed hit that could crit - * anyway, it goes in before wound armour scales the roll, and every crit's own armour block still holds. + * A blow on a stealth guard that never saw it coming adds to hyperviolence's aimed crit roll (crit_roll.dm, + * hv_crit_situation_bonus()), so it only matters on an aimed hit that could crit anyway, it goes in before wound + * armour scales the roll, and every crit's own armour block still holds. * * - Who: a guard with the stealth controller, conscious, not held or cuffed, with no player in the body. Never a * player (decision 19), never any other NPC. @@ -11,31 +11,37 @@ * suspicious, a smaller one; searching or alert, none. Searching gets none so that peek, shoot, hide and wait out * the search can't farm it. * - Head: aimed at the head, eyes or mouth, the bonus goes up again. - * - Backstab: the matte combat knife (stealth_knife.dm) adds STEALTH_BACKSTAB_BONUS from behind (tg's check_behind()), - * whatever the guard's state. + * - The matte knife from behind cuts the throat instead (stealth_knife.dm). * - * hyperviolence had no head crit a bullet could cause, so a pistol shot to an unaware guard's head could do nothing a - * shot to an alert one couldn't. The head shot crit below is that crit, and only a stealth hit rolls it: everyone - * else's head shots (players on players included) are exactly as before. Numbers: data/stealth/STATUS.md, "Step 3a". + * The head shot (decision 45) is not a roll. A bullet aimed at the head of a guard caught off guard does what the + * round can do against how well his head is protected (stealth_head_shot()), all through tg's own systems: + * - a strong round: the head bursts (hyperviolence's hv_burst_head_apart(), a real decapitation); + * - a weak round through the skull: a critical puncture with a heavy bleed, real brain damage and tg's + * Unconscious() long enough that the bleed takes him (blood loss, then oxygen loss, then crit and death); + * - stopped short of the skull: the hit as normal, and tg's Unconscious() for STEALTH_HEAD_SHOT_HELMET_TIME; + * - stopped: the hit as normal. + * Protection (helmets, and physiology armour such as dermal cyberware, by tg's own armour numbers) steps it down. + * Players on players, and everyone else's head shots, are exactly as before. Numbers: data/stealth/STATUS.md. */ -/// The roll bonus for this blow (STEALTH_CRIT_* and STEALTH_BACKSTAB_BONUS), or 0. No side effects. -/mob/living/carbon/human/npc/proc/stealth_crit_bonus(mob/living/attacker, atom/source, obj/item/bodypart/limb) +/// TRUE if this guard was caught off guard by `attacker`'s blow: unaware or only suspicious as it began, conscious, +/// not held or cuffed, no player in the body. No side effects. +/mob/living/carbon/human/npc/proc/stealth_caught_off_guard(mob/living/attacker) if(isnull(attacker) || attacker == src || client || stat != CONSCIOUS) - return 0 + return FALSE var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = ai_controller if(!istype(stealth_ai) || stealth_ai.stealth_captive()) + return FALSE + var/state = stealth_state_at_blow() + return state == STEALTH_UNAWARE || state == STEALTH_SUSPICIOUS + +/// The roll bonus for this blow (STEALTH_CRIT_*), or 0. No side effects. +/mob/living/carbon/human/npc/proc/stealth_crit_bonus(mob/living/attacker, atom/source, obj/item/bodypart/limb) + if(!stealth_caught_off_guard(attacker)) return 0 - . = 0 - switch(stealth_state_at_blow()) - if(STEALTH_UNAWARE) - . = STEALTH_CRIT_UNAWARE_BONUS - if(STEALTH_SUSPICIOUS) - . = STEALTH_CRIT_SUSPICIOUS_BONUS - if(. && limb?.body_zone == BODY_ZONE_HEAD) + . = stealth_state_at_blow() == STEALTH_UNAWARE ? STEALTH_CRIT_UNAWARE_BONUS : STEALTH_CRIT_SUSPICIOUS_BONUS + if(limb?.body_zone == BODY_ZONE_HEAD) . += STEALTH_CRIT_HEAD_BONUS - if(istype(source, /obj/item/knife/combat/matte) && check_behind(attacker, src)) - . += STEALTH_BACKSTAB_BONUS /mob/living/carbon/human/npc/hv_crit_situation_bonus(mob/living/attacker, atom/source, obj/item/bodypart/limb) . = ..() @@ -46,50 +52,155 @@ return . + bonus // --------------------------------------------------------------------------------------------- -// Shot through the head: a bullet aimed at the head of a guard who didn't see it coming. A good enough helmet stops it. - -/datum/hv_crit/head_shot - name = "shot through the head" - limb_zone = BODY_ZONE_HEAD - aim_zones = list(BODY_ZONE_HEAD, BODY_ZONE_PRECISE_EYES, BODY_ZONE_PRECISE_MOUTH) - wounding_types = list(WOUND_PIERCE) - min_damage = STEALTH_HEAD_SHOT_MIN_DAMAGE - threshold = STEALTH_HEAD_SHOT_THRESHOLD - allow_projectiles = TRUE - wound_type = /datum/wound/pierce/bleed/critical/hv_head_shot - line_severity = HV_LINE_HUGE - line_range = DEFAULT_MESSAGE_RANGE - hit_sound = 'sound/effects/wounds/pierce3.ogg' - shake = 6 - -/datum/hv_crit/head_shot/matches(hit_zone, aimed_zone, wounding_type, from_projectile) - return from_projectile && ..() - -/datum/hv_crit/head_shot/blocked_on_carbon(mob/living/carbon/victim, obj/item/bodypart/limb, atom/source) - if(!ishumannpc(victim) || !isprojectile(source)) - return TRUE - var/mob/living/carbon/human/npc/guard = victim - var/obj/projectile/shot = source - if(!isliving(shot.firer) || guard.stealth_crit_bonus(shot.firer, source, limb) <= 0) - return TRUE - return hv_crit_cover_rating(victim, limb, hv_crit_attack_flag(source), hv_crit_armour_pen(source)) >= STEALTH_HEAD_SHOT_HELMET_ARMOUR +// The head shot (decision 45) + +/obj/projectile + /// The caliber of the casing this was fired from (stealth head shots), or null. + var/vc_caliber + +/obj/item/ammo_casing/ready_proj(atom/target, mob/living/user, quiet, zone_override = "", atom/fired_from) + . = ..() + if(loaded_projectile) + loaded_projectile.vc_caliber = caliber + +/// Whether a round of this caliber is a rifle or shotgun round, which hits a skull harder than its damage says. +/proc/stealth_heavy_caliber(caliber) + switch(caliber) + if(CALIBER_A223, CALIBER_A7MM, CALIBER_STRILKA310, CALIBER_50BMG, CALIBER_SHOTGUN) + return TRUE + return FALSE + +/// Whether `shot` came from a gun with a suppressor. tg's pellet cloud fires every pellet "quiet", so the gun is asked first. +/proc/stealth_shot_suppressed(obj/projectile/shot) + if(isgun(shot.fired_from)) + var/obj/item/gun/gun = shot.fired_from + return !!gun.suppressed + return !!shot.suppressed + +/mob/living/carbon/human/npc + /// world.time of the head shot being resolved: every pellet of one shot lands in the same tick + var/stealth_head_shot_at = -1 + /// Whether the shot being resolved caught it off guard (decided on its first pellet) + var/stealth_head_shot_open = FALSE + /// Power of the shot being resolved so far, before the caliber bonus and the suppressor + var/stealth_head_shot_power = 0 + /// The worst outcome (STEALTH_HEAD_SHOT_*) the shot being resolved has done so far + var/stealth_head_shot_done = STEALTH_HEAD_SHOT_NONE + +/mob/living/carbon/human/npc/hv_crit_check_hit(damage, def_zone, wound_bonus, exposed_wound_bonus, sharpness, attack_direction, atom/source) + if(stealth_head_shot(damage, def_zone, wound_bonus, attack_direction, source)) + return + return ..() -/datum/hv_crit/head_shot/apply_carbon(mob/living/carbon/victim, obj/item/bodypart/limb, damage, attack_direction, atom/source, mob/living/attacker) - if(!hv_crit_apply_wound(limb, wound_type, attack_direction, source)) +/** + * A round that has just hit this guard's head, after tg dealt its damage. If it was aimed there and caught the guard off + * guard, grades it and does what it earns. Returns TRUE if the hit was a stealth head shot (the aimed crit roll is then + * skipped), FALSE to leave it to the ordinary crit roll. + */ +/mob/living/carbon/human/npc/proc/stealth_head_shot(damage, def_zone, wound_bonus, attack_direction, atom/source) + if(!isprojectile(source) || !isbodypart(def_zone)) + return FALSE + var/obj/item/bodypart/limb = def_zone + if(limb.owner != src || limb.body_zone != BODY_ZONE_HEAD) + return FALSE + var/obj/projectile/shot = source + if(shot.damage_type != BRUTE || shot.stamina > shot.damage) + return FALSE + var/mob/living/carbon/shooter = hv_crit_get_aimer(shot) + if(isnull(shooter) || shooter == src || check_zone(shooter.zone_selected) != BODY_ZONE_HEAD) + return FALSE + if(stealth_head_shot_at != world.time) + stealth_head_shot_at = world.time + stealth_head_shot_power = 0 + stealth_head_shot_done = STEALTH_HEAD_SHOT_NONE + stealth_head_shot_open = stealth_caught_off_guard(shooter) + if(!stealth_head_shot_open) return FALSE - victim.hv_blood_spray(attack_direction, 2) - announce(victim, attack_direction) - return TRUE + var/grade = stealth_head_shot_grade(limb, shot, damage, wound_bonus) + // Bursting a head is an execution: only those hyperviolence lets execute (players and boss NPCs). + if(grade == STEALTH_HEAD_SHOT_BURST && !shooter.hv_can_execute()) + grade = STEALTH_HEAD_SHOT_DOWN + if(grade > stealth_head_shot_done) + stealth_head_shot_apply(grade, limb, shot, shooter, attack_direction || get_dir(shooter, src)) + return stealth_head_shot_done != STEALTH_HEAD_SHOT_NONE -/datum/hv_crit/head_shot/hit_line(mob/living/victim) - return "[victim] is shot through the head!" +/** + * What this round does to this head (STEALTH_HEAD_SHOT_*), counting every pellet of the shot that has landed so far. + * The round's power (its own numbers, before armour) gives burst, down or nothing; then each protection step + * (stealth_head_protection()) moves that one down the ladder: burst, down, knocked out, nothing. + */ +/mob/living/carbon/human/npc/proc/stealth_head_shot_grade(obj/item/bodypart/limb, obj/projectile/shot, damage, wound_bonus) + stealth_head_shot_power += shot.damage + max(0, shot.wound_bonus) / 2 + var/power = stealth_head_shot_power + if(stealth_heavy_caliber(shot.vc_caliber)) + power += STEALTH_HEAD_SHOT_HEAVY_CALIBER + if(stealth_shot_suppressed(shot)) + power *= STEALTH_HEAD_SHOT_SUPPRESSED_MULT + var/grade = STEALTH_HEAD_SHOT_NONE + if(power >= STEALTH_HEAD_SHOT_BURST_POWER) + grade = STEALTH_HEAD_SHOT_BURST + else if(power >= STEALTH_HEAD_SHOT_MIN_POWER) + grade = STEALTH_HEAD_SHOT_DOWN + if(grade == STEALTH_HEAD_SHOT_NONE) + return grade + var/protection = stealth_head_protection(limb, shot) + var/steps = 0 + if(protection >= STEALTH_HEAD_SHOT_STEP_THREE) + steps = 3 + else if(protection >= STEALTH_HEAD_SHOT_STEP_TWO) + steps = 2 + else if(protection >= STEALTH_HEAD_SHOT_STEP_ONE) + steps = 1 + return max(STEALTH_HEAD_SHOT_NONE, grade - steps) -/datum/hv_crit/head_shot/self_line(mob/living/victim) - return "Something punches through your skull!" +/** + * How well this head is protected against this round, with tg's own numbers: the armour tg's damage code uses against it + * (run_armor_check(): covering clothes and physiology armour, where protective cyberware lives, stacked as + * check_armor() stacks them, less the round's penetration), plus the wound armour tg's wound roll uses + * (check_woundings_mods(): covering clothes and physiology), bar the head's own resistance everyone has. + */ +/mob/living/carbon/human/npc/proc/stealth_head_protection(obj/item/bodypart/limb, obj/projectile/shot) + . = run_armor_check(limb, shot.armor_flag, armour_penetration = shot.armour_penetration, silent = TRUE, weak_against_armour = shot.weak_against_armour) + for(var/obj/item/clothing/worn as anything in get_clothing_on_part(limb)) + . += worn.get_armor_rating(WOUND) + . += physiology?.armor.get_rating(WOUND) || 0 + +/// Does what a graded head shot earns, through tg's own systems. +/mob/living/carbon/human/npc/proc/stealth_head_shot_apply(grade, obj/item/bodypart/limb, obj/projectile/shot, mob/living/shooter, shot_dir) + switch(grade) + if(STEALTH_HEAD_SHOT_BURST) + if(hv_burst_head_apart(shot_dir)) + stealth_head_shot_done = grade + log_combat(shooter, src, "burst the head of an unsuspecting stealth guard", shot) + return + // A head that can't come off: a round through the skull instead. + grade = STEALTH_HEAD_SHOT_DOWN + if(STEALTH_HEAD_SHOT_HELMET) + stealth_head_shot_done = grade + Unconscious(STEALTH_HEAD_SHOT_HELMET_TIME) + if(head) + hv_add_hit_line("The shot cracks off [src]'s [head.name]!", HV_LINE_BOLD, "Something cracks off your [head.name]!") + else + hv_add_hit_line("The shot glances off [src]'s skull!", HV_LINE_BOLD, "Something cracks against your skull!") + playsound(src, SFX_RICOCHET, 60, TRUE) + log_combat(shooter, src, "knocked out an unsuspecting stealth guard through head protection", shot) + return + if(grade != STEALTH_HEAD_SHOT_DOWN || stealth_head_shot_done >= grade) + return + if(!hv_crit_apply_wound(limb, /datum/wound/pierce/bleed/critical/hv_head_shot, shot_dir, shot)) + return + stealth_head_shot_done = grade + hv_blood_spray(shot_dir, 2) + hv_add_hit_line("[src] is shot through the head!", HV_LINE_HUGE, "Something punches through your skull!", DEFAULT_MESSAGE_RANGE) + playsound(src, 'sound/effects/wounds/pierce3.ogg', 80, TRUE, falloff_exponent = SOUND_FALLOFF_EXPONENT + 2, ignore_walls = FALSE, falloff_distance = 0) + // He drops and twitches as he goes under (hyperviolence's own twitches). + hv_vis_twitches(4, 8) + log_combat(shooter, src, "shot an unsuspecting stealth guard through the head", shot) /** - * tg's ruptured cavity on the head, with a knock to the brain: brain damage, a knockdown, confusion and blurred eyes. - * Treated like any critical puncture (gauze, sutures, cautery, surgery); the brain damage heals like any other. + * A round through the skull: tg's ruptured cavity on the head with a heavier bleed, real brain damage and tg's + * unconsciousness. Treated like any critical puncture (gauze, sutures, cautery, surgery); the brain damage heals like any + * other. Only a stealth head shot gives it (can_be_randomly_generated is off). */ /datum/wound/pierce/bleed/critical/hv_head_shot name = "Penetrating Head Wound" @@ -98,6 +209,8 @@ simple_desc = "A bullet has gone through the skull." examine_desc = "has a bloody hole punched through it" occur_text = "is punched through" + initial_flow = STEALTH_HEAD_SHOT_FLOW + clot_rate = 0 /datum/wound/pierce/bleed/critical/hv_head_shot/wound_injury(datum/wound/old_wound = null, attack_direction = null) . = ..() @@ -106,9 +219,7 @@ victim.adjustOrganLoss(ORGAN_SLOT_BRAIN, STEALTH_HEAD_SHOT_BRAIN_DAMAGE) if(victim.stat == DEAD) return - victim.Knockdown(STEALTH_HEAD_SHOT_KNOCKDOWN) - victim.set_confusion_if_lower(15 SECONDS) - victim.adjust_eye_blur(10 SECONDS) + victim.Unconscious(STEALTH_HEAD_SHOT_DOWN_TIME) /datum/wound_pregen_data/flesh_pierce/hv_head_shot abstract = FALSE diff --git a/voidcrew/modules/stealth/stealth_knife.dm b/voidcrew/modules/stealth/stealth_knife.dm index 83161cb34d5..e2137694695 100644 --- a/voidcrew/modules/stealth/stealth_knife.dm +++ b/voidcrew/modules/stealth/stealth_knife.dm @@ -1,9 +1,14 @@ /** - * # The matte combat knife (step 3a, owner decisions 5 and 12) + * # The matte combat knife (step 3a, owner decisions 5, 12 and 45) * - * tg's combat knife with a blackened blade. Its one difference: struck into a stealth guard from behind (tg's - * check_behind(), the heretic blade's backstab test), it adds STEALTH_BACKSTAB_BONUS to the aimed crit roll - * (stealth_crits.dm). On anyone else, players included, it is a plain combat knife. No new attack or animation. + * tg's combat knife with a blackened blade. Its one difference: stabbed into a stealth guard from behind (tg's + * check_behind(), the heretic blade's backstab test) while the guard is unaware or only suspicious, it goes for the + * throat whatever zone is aimed at, and the stab is tg's own throat slit (butchering.dm, startNeckSlice()) without the + * grab and the wait: the knife's force to the head, a critical slash on the head and tg's neck_slice. A cut throat + * can't speak, shout or use a radio (voidcrew/edits/datums/neck_slice_mute.dm). Head armour counts as tg counts it: the + * damage goes through its melee armour, and the cut only opens the throat if tg's wound maths lets a critical slash + * through (slit_gets_through()); otherwise it is an ordinary stab to the head. tg's grab slit works as before. + * On anyone else, players included, it is a plain combat knife. No new animation. * * Players get it as scav den loot (step 4). It has no buy, print or craft route. */ @@ -11,3 +16,58 @@ name = "matte combat knife" desc = "A combat knife with a blackened blade that doesn't catch the light." color = "#6E6E7D" + +/obj/item/knife/combat/matte/attack(mob/living/target_mob, mob/living/user, list/modifiers, list/attack_modifiers) + if(!backstab_slits(target_mob, user)) + return ..() + var/mob/living/carbon/human/npc/guard = target_mob + var/obj/item/bodypart/throat = guard.get_bodypart(BODY_ZONE_HEAD) + user.do_attack_animation(guard) + user.changeNext_move(CLICK_CD_MELEE) + playsound(guard, 'sound/effects/butcher.ogg', 50, TRUE, -1) + var/blocked = guard.run_armor_check(throat, MELEE, armour_penetration = armour_penetration, silent = TRUE) + if(!slit_gets_through(guard, throat)) + // A well protected throat: an ordinary stab to the head through its armour, with tg's own wound roll. + guard.visible_message(span_danger("[user] stabs at [guard]'s throat, but the blade turns!"), span_userdanger("[user] stabs at your throat!")) + log_combat(user, guard, "stabbed at the throat of", src, "(stab from behind, protected throat)") + guard.apply_damage(force, BRUTE, throat, blocked, wound_bonus = wound_bonus, exposed_wound_bonus = exposed_wound_bonus, sharpness = get_sharpness(), attack_direction = get_dir(user, guard), attacking_item = src) + else + // tg's throat slit (butchering.dm, startNeckSlice()), from its do_after on, its damage through armour. + guard.visible_message(span_danger("[user] slits [guard]'s throat!"), span_userdanger("[user] slits your throat...")) + log_combat(user, guard, "wounded via throat slitting", src, "(stab from behind)") + guard.apply_damage(force, BRUTE, throat, blocked, wound_bonus = CANT_WOUND) + if(guard.cause_wound_of_type_and_severity(WOUND_SLASH, throat, WOUND_SEVERITY_CRITICAL)) + guard.apply_status_effect(/datum/status_effect/neck_slice) + // The guard felt that: the same signal a normal blow sends (tg's relay_attackers), after the cut. + SEND_SIGNAL(guard, COMSIG_ATOM_AFTER_ATTACKEDBY, src, user, modifiers, attack_modifiers) + add_fingerprint(user) + return TRUE + +/** + * Whether the slit gets through what protects this throat, by tg's own wound maths: a placed cut is the best roll tg's + * wound roll allows (WOUND_MAX_CONSIDERED_DAMAGE to the power WOUND_DAMAGE_EXPONENT), plus this knife's wound bonus, + * through check_woundings_mods() (worn wound armour on the head, physiology wound armour such as dermal cyberware, the + * head's own resistance and its existing wounds). It gets through if that reaches tg's critical slash threshold. + */ +/obj/item/knife/combat/matte/proc/slit_gets_through(mob/living/carbon/human/victim, obj/item/bodypart/throat) + var/datum/wound_pregen_data/critical = GLOB.all_wound_pregen_data[/datum/wound/slash/flesh/critical] + var/best_roll = round(WOUND_MAX_CONSIDERED_DAMAGE ** WOUND_DAMAGE_EXPONENT) + var/roll = throat.check_woundings_mods(WOUND_SLASH, best_roll, force, wound_bonus, exposed_wound_bonus, FALSE) + return roll >= critical.threshold_minimum + +/** + * Whether stabbing `target` now is a throat slit from behind: a stealth guard caught off guard + * (stealth_caught_off_guard()) with the stabber behind it, a combat-mode stab, its throat not already cut, and not + * from tg's own grab slit (an aggressive grab aimed at the head goes tg's way). + */ +/obj/item/knife/combat/matte/proc/backstab_slits(mob/living/target, mob/living/user) + if(!ishumannpc(target) || !istype(user) || !user.combat_mode || !force || !get_sharpness()) + return FALSE + if(HAS_TRAIT(user, TRAIT_PACIFISM) || !target.get_bodypart(BODY_ZONE_HEAD)) + return FALSE + if(user.pulling == target && user.grab_state >= GRAB_AGGRESSIVE) + return FALSE + if(target.has_status_effect(/datum/status_effect/neck_slice)) + return FALSE + var/mob/living/carbon/human/npc/guard = target + return check_behind(user, guard) && guard.stealth_caught_off_guard(user) diff --git a/voidcrew/modules/stealth/stealth_radio.dm b/voidcrew/modules/stealth/stealth_radio.dm index 0987296fbf9..13e1e3f7711 100644 --- a/voidcrew/modules/stealth/stealth_radio.dm +++ b/voidcrew/modules/stealth/stealth_radio.dm @@ -38,6 +38,9 @@ return FALSE if(guard.stat != CONSCIOUS || stealth_driven() || isnull(where)) return FALSE + // A guard that can't speak (a cut throat, a gag) doesn't reach for the earpiece (decision 45). + if(!human_npc_can_talk(guard)) + return FALSE if(pending_call) if(pending_call[STEALTH_CALL_KIND] >= kind) return TRUE diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index 575880487b0..37b4d39b0b8 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -241,6 +241,7 @@ #include "voidcrew_stealth_d37.dm" #include "voidcrew_stealth_d39.dm" #include "voidcrew_stealth_d44.dm" +#include "voidcrew_stealth_d45.dm" #include "voidcrew_stealth_disguise.dm" #include "voidcrew_stealth_hearing.dm" #include "voidcrew_stealth_light.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_crits.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_crits.dm index 5cc0b1c29c1..499b6ca0450 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_crits.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_crits.dm @@ -1,6 +1,6 @@ -// Stealth crits, the head shot, the backstab knife and lootable seclites (step 3a, voidcrew/modules/stealth/stealth_crits.dm, -// stealth_knife.dm, stealth_light.dm). Values from voidcrew/_DEFINES are written out: STEALTH_CRIT_UNAWARE_BONUS 30, -// STEALTH_CRIT_SUSPICIOUS_BONUS 15, STEALTH_CRIT_HEAD_BONUS 35, STEALTH_BACKSTAB_BONUS 40, STEALTH_HEAD_SHOT_BRAIN_DAMAGE 40. +// Stealth crits and lootable seclites (step 3a, voidcrew/modules/stealth/stealth_crits.dm, stealth_light.dm). The head +// shot and the backstab are decision 45 (voidcrew_stealth_d45.dm). Values from voidcrew/_DEFINES are written out: +// STEALTH_CRIT_UNAWARE_BONUS 30, STEALTH_CRIT_SUSPICIOUS_BONUS 15, STEALTH_CRIT_HEAD_BONUS 35. /// The bonus by state: full when unaware, smaller when suspicious, none when searching or alert, more on the head; /// never on a player or an NPC without the stealth controller. @@ -46,39 +46,7 @@ TEST_ASSERT_EQUAL(plain.stealth_crit_bonus(person, knife, plain.get_bodypart(BODY_ZONE_HEAD)), 0, "An NPC without stealth gets a stealth bonus") qdel(block) -/// The matte knife adds its bonus from behind only, on an alert guard too; a plain knife never does. -/datum/unit_test/voidcrew_stealth_backstab - -/datum/unit_test/voidcrew_stealth_backstab/Run() - var/datum/turf_reservation/block = stealth_block(8, 5) - TEST_ASSERT_NOTNULL(block, "No room for the test") - var/mob/living/carbon/human/npc/guard = stealth_guard(block, 4, 2) // facing east - var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) - var/mob/living/carbon/human/person = stealth_person(block, 3, 2) // behind it - var/obj/item/knife/combat/matte/knife = allocate(/obj/item/knife/combat/matte) - var/obj/item/knife/combat/blade = allocate(/obj/item/knife/combat) - person.put_in_active_hand(knife) - var/obj/item/bodypart/head = guard.get_bodypart(BODY_ZONE_HEAD) - var/obj/item/bodypart/chest = guard.get_bodypart(BODY_ZONE_CHEST) - TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, head), 105, "Wrong bonus for a backstab to an unaware guard's head") - stealth_ai.stealth_go_alert(person) - stealth_ai.stealth_rewind(1) - guard.setDir(EAST) - TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, chest), 40, "Wrong backstab bonus on an alert guard") - TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, blade, chest), 0, "A plain knife backstabs") - // From the front and from the side: nothing. - person.forceMove(stealth_at(block, 5, 2)) - TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, chest), 0, "The knife backstabs from the front") - person.forceMove(stealth_at(block, 4, 3)) - TEST_ASSERT_EQUAL(guard.stealth_crit_bonus(person, knife, chest), 0, "The knife backstabs from the side") - // A player from behind: a plain knife. - var/mob/living/carbon/human/player = stealth_person(block, 6, 4) - player.setDir(EAST) - person.forceMove(stealth_at(block, 5, 4)) - TEST_ASSERT_EQUAL(player.hv_crit_situation_bonus(person, knife, player.get_bodypart(BODY_ZONE_CHEST)), 0, "The knife backstabs a person") - qdel(block) - -/// Wound armour scales the bonus with the rest of the roll, and a helmet stops the head shot outright. +/// Wound armour scales the bonus with the rest of the roll. /datum/unit_test/voidcrew_stealth_crit_armour /datum/unit_test/voidcrew_stealth_crit_armour/Run() @@ -99,62 +67,14 @@ TEST_ASSERT(guard.equip_to_slot_if_possible(helmet, ITEM_SLOT_HEAD, disable_warning = TRUE), "Couldn't put a helmet on the guard") var/armoured = head.hv_crit_roll(WOUND_SLASH, 1, 0, 0, person, knife) TEST_ASSERT(armoured < bare, "A helmet didn't lower the stealth roll ([armoured] vs [bare])") - // The head shot: a 9mm through a SWAT helmet is stopped; with the helmet off it isn't. - var/datum/hv_crit/head_shot/crit = locate() in GLOB.hv_crits - TEST_ASSERT_NOTNULL(crit, "No head shot crit") - var/obj/projectile/bullet/c9mm/shot = allocate(/obj/projectile/bullet/c9mm) - shot.firer = person - TEST_ASSERT(crit.blocked_on_carbon(guard, head, shot), "A SWAT helmet doesn't stop a 9mm head shot") qdel(helmet) - TEST_ASSERT(!crit.blocked_on_carbon(guard, head, shot), "A bare-headed unaware guard is safe from a head shot") - // Alert: no stealth hit, so no head shot. + // Alert: no stealth bonus. stealth_ai.stealth_go_alert(person) stealth_ai.stealth_rewind(1) - TEST_ASSERT(crit.blocked_on_carbon(guard, head, shot), "An alert guard can be head shot") var/roll = head.hv_crit_roll(WOUND_SLASH, 1, 0, 0, person, knife) TEST_ASSERT(roll < 5, "An alert guard's roll still has a bonus ([roll])") qdel(block) -/// A head shot lands on an unaware guard and does real harm through tg's wound; never on a person or an alert guard. -/datum/unit_test/voidcrew_stealth_head_shot - -/datum/unit_test/voidcrew_stealth_head_shot/Run() - var/datum/turf_reservation/block = stealth_block(8, 5) - TEST_ASSERT_NOTNULL(block, "No room for the test") - var/mob/living/carbon/human/npc/guard = stealth_guard(block, 4, 2) - var/mob/living/carbon/human/person = stealth_person(block, 1, 2) - var/obj/projectile/bullet/c9mm/shot = allocate(/obj/projectile/bullet/c9mm) - shot.firer = person - if(guard.head) - qdel(guard.head) - var/obj/item/bodypart/head = guard.get_bodypart(BODY_ZONE_HEAD) - var/datum/hv_crit/crit = guard.hv_try_aimed_crit(head, BODY_ZONE_HEAD, WOUND_PIERCE, 30, 0, 0, EAST, shot, person, 500) - TEST_ASSERT(istype(crit, /datum/hv_crit/head_shot), "A forced head shot on an unaware guard didn't land (got [crit])") - TEST_ASSERT_NOTNULL(head.get_wound_type(/datum/wound/pierce/bleed/critical/hv_head_shot), "No head shot wound") - TEST_ASSERT(guard.get_organ_loss(ORGAN_SLOT_BRAIN) >= 40, "The head shot did no brain damage") - TEST_ASSERT(guard.IsKnockdown(), "The head shot didn't knock the guard down") - // Not from a knife. - var/mob/living/carbon/human/npc/second = stealth_guard(block, 6, 3) - if(second.head) - qdel(second.head) - var/obj/item/knife/combat/knife = allocate(/obj/item/knife/combat) - crit = second.hv_try_aimed_crit(second.get_bodypart(BODY_ZONE_HEAD), BODY_ZONE_HEAD, WOUND_PIERCE, 30, 0, 0, EAST, knife, person, 500) - TEST_ASSERT(!istype(crit, /datum/hv_crit/head_shot), "A knife caused a head shot") - // Never on a person. - var/mob/living/carbon/human/player = stealth_person(block, 2, 4) - crit = player.hv_try_aimed_crit(player.get_bodypart(BODY_ZONE_HEAD), BODY_ZONE_HEAD, WOUND_PIERCE, 30, 0, 0, EAST, shot, person, 500) - TEST_ASSERT_NULL(crit, "A person took a head shot crit") - // Never on an alert guard. - var/mob/living/carbon/human/npc/third = stealth_guard(block, 1, 4) - if(third.head) - qdel(third.head) - var/datum/ai_controller/basic_controller/human_npc/stealth/third_ai = stealth_ai(third) - third_ai.stealth_go_alert(person) - third_ai.stealth_rewind(1) - crit = third.hv_try_aimed_crit(third.get_bodypart(BODY_ZONE_HEAD), BODY_ZONE_HEAD, WOUND_PIERCE, 30, 0, 0, EAST, shot, person, 500) - TEST_ASSERT_NULL(crit, "An alert guard took a head shot crit") - qdel(block) - /// Decision 34: the seclite strips and drops like anyone's; the rest of the kit stays locked; the guard carries on without it. /datum/unit_test/voidcrew_stealth_seclite_loot diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_d45.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_d45.dm new file mode 100644 index 00000000000..d4f416ff438 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_d45.dm @@ -0,0 +1,250 @@ +// Decision 45: the stealth head shot graded by the round and the head's protection, shields and shots in the back, and +// the matte knife's throat slit from behind (voidcrew/modules/stealth/stealth_crits.dm, stealth_knife.dm, +// voidcrew/edits/objects/items/shield_rear.dm, voidcrew/edits/datums/neck_slice_mute.dm). Unit tests compile before +// voidcrew/_DEFINES, so values are written out: STEALTH_HEAD_SHOT_BRAIN_DAMAGE 120, STEALTH_CALL_ALARM 3. + +/// A gun of `gun_type` in `shooter`'s hand, aimed at the head. +/datum/unit_test/proc/d45_arm(mob/living/carbon/human/shooter, gun_type, suppressed = FALSE) + var/obj/item/gun/ballistic/gun = allocate(gun_type) + gun.can_misfire = FALSE + if(suppressed) + gun.install_suppressor(new /obj/item/suppressor(gun)) + shooter.put_in_active_hand(gun, forced = TRUE) + shooter.zone_selected = BODY_ZONE_HEAD + return gun + +/// A bare-headed guard (no helmet, no mask) at (dx, dy), facing east. +/datum/unit_test/proc/d45_bare_guard(datum/turf_reservation/block, dx, dy) + var/mob/living/carbon/human/npc/guard = stealth_guard(block, dx, dy) + if(guard.head) + qdel(guard.head) + if(guard.wear_mask) + qdel(guard.wear_mask) + return guard + +/// Puts `helmet_type` on `guard`. +/datum/unit_test/proc/d45_helmet(mob/living/carbon/human/guard, helmet_type) + var/obj/item/clothing/helmet = new helmet_type(guard) + TEST_ASSERT(guard.equip_to_slot_if_possible(helmet, ITEM_SLOT_HEAD, disable_warning = TRUE), "Couldn't put [helmet] on the guard") + +/// (a) A .357 to the back of an unaware guard's bare head bursts it: no head, dead. +/datum/unit_test/voidcrew_stealth_d45_burst + +/datum/unit_test/voidcrew_stealth_d45_burst/Run() + var/datum/turf_reservation/block = stealth_block(8, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = d45_bare_guard(block, 4, 2) + var/mob/living/carbon/human/person = stealth_person(block, 3, 2) + var/obj/item/gun/gun = d45_arm(person, /obj/item/gun/ballistic/revolver) + gun.fire_gun(guard, person, TRUE, null) + TEST_ASSERT_NULL(guard.get_bodypart(BODY_ZONE_HEAD), "A .357 to an unaware guard's bare head didn't burst it") + TEST_ASSERT_EQUAL(guard.stat, DEAD, "A guard whose head burst is alive") + qdel(block) + +/// (b) A suppressed 9mm to an unaware guard's bare head: through the skull, brain damage, a heavy bleed, out cold. A +/// .357 to a guard with Dermal Mesh is stepped down to the same. +/datum/unit_test/voidcrew_stealth_d45_down + +/datum/unit_test/voidcrew_stealth_d45_down/Run() + var/datum/turf_reservation/block = stealth_block(8, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = d45_bare_guard(block, 4, 2) + var/mob/living/carbon/human/person = stealth_person(block, 3, 2) + var/obj/item/gun/gun = d45_arm(person, /obj/item/gun/ballistic/automatic/pistol, suppressed = TRUE) + gun.fire_gun(guard, person, TRUE, null) + var/obj/item/bodypart/head = guard.get_bodypart(BODY_ZONE_HEAD) + TEST_ASSERT_NOTNULL(head, "A suppressed 9mm burst a head") + TEST_ASSERT_NOTNULL(head.get_wound_type(/datum/wound/pierce/bleed/critical/hv_head_shot), "A suppressed 9mm head shot left no wound through the skull") + TEST_ASSERT(guard.get_organ_loss(ORGAN_SLOT_BRAIN) >= 120, "The head shot did too little brain damage ([guard.get_organ_loss(ORGAN_SLOT_BRAIN)])") + TEST_ASSERT(guard.IsUnconscious(), "The guard shot through the head isn't out cold") + TEST_ASSERT(guard.stat >= UNCONSCIOUS, "The guard shot through the head is still conscious") + TEST_ASSERT(guard.get_bleed_rate() >= 5, "The head shot doesn't bleed heavily ([guard.get_bleed_rate()])") + // Dermal Mesh (physiology armour, as the implant applies it) steps a .357 down from a burst to the same. + var/mob/living/carbon/human/npc/meshed = d45_bare_guard(block, 4, 4) + meshed.physiology.armor = meshed.physiology.armor.add_other_armor(/datum/armor/cyberware_dermal_mesh) + var/mob/living/carbon/human/second = stealth_person(block, 3, 4) + gun = d45_arm(second, /obj/item/gun/ballistic/revolver) + gun.fire_gun(meshed, second, TRUE, null) + head = meshed.get_bodypart(BODY_ZONE_HEAD) + TEST_ASSERT_NOTNULL(head, "Dermal Mesh didn't step a .357 down from a burst") + TEST_ASSERT_NOTNULL(head.get_wound_type(/datum/wound/pierce/bleed/critical/hv_head_shot), "A .357 through Dermal Mesh didn't go through the skull") + qdel(block) + +/// (c) A 9mm into a SWAT helmet: knocked out for a few seconds, no wound through the skull. A heavy helmet stops it: only +/// the hit. An alert guard and an ordinary person: only the hit. +/datum/unit_test/voidcrew_stealth_d45_helmet + +/datum/unit_test/voidcrew_stealth_d45_helmet/Run() + var/datum/turf_reservation/block = stealth_block(8, 7) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = d45_bare_guard(block, 4, 1) + d45_helmet(guard, /obj/item/clothing/head/helmet/swat) + var/mob/living/carbon/human/person = stealth_person(block, 3, 1) + var/obj/item/gun/gun = d45_arm(person, /obj/item/gun/ballistic/automatic/pistol) + gun.fire_gun(guard, person, TRUE, null) + var/obj/item/bodypart/head = guard.get_bodypart(BODY_ZONE_HEAD) + TEST_ASSERT_NOTNULL(head, "A 9mm burst a helmeted head") + TEST_ASSERT_NULL(head.get_wound_type(/datum/wound/pierce/bleed/critical/hv_head_shot), "A 9mm went through a SWAT helmet") + TEST_ASSERT(guard.IsUnconscious(), "A 9mm into a SWAT helmet didn't knock the guard out") + TEST_ASSERT(guard.AmountUnconscious() <= 8 SECONDS, "The helmet knockout is too long ([guard.AmountUnconscious()])") + // A heavy helmet (bullet 60): just the hit. + var/mob/living/carbon/human/npc/heavy = d45_bare_guard(block, 4, 3) + d45_helmet(heavy, /obj/item/clothing/head/helmet/alt) + var/mob/living/carbon/human/second = stealth_person(block, 3, 3) + gun = d45_arm(second, /obj/item/gun/ballistic/automatic/pistol) + gun.fire_gun(heavy, second, TRUE, null) + TEST_ASSERT(!heavy.IsUnconscious(), "A 9mm into a heavy helmet knocked the guard out") + TEST_ASSERT(heavy.getBruteLoss() > 0, "Test fixture: the shot into the heavy helmet missed") + // An alert guard, bare headed: just the hit. + var/mob/living/carbon/human/npc/alert = d45_bare_guard(block, 4, 5) + var/datum/ai_controller/basic_controller/human_npc/stealth/alert_ai = stealth_ai(alert) + var/mob/living/carbon/human/third = stealth_person(block, 3, 5) + alert_ai.stealth_go_alert(third) + alert_ai.stealth_rewind(1) + gun = d45_arm(third, /obj/item/gun/ballistic/automatic/pistol) + gun.fire_gun(alert, third, TRUE, null) + TEST_ASSERT(!alert.IsUnconscious(), "An alert guard was knocked out by a head shot") + TEST_ASSERT_NULL(alert.get_bodypart(BODY_ZONE_HEAD)?.get_wound_type(/datum/wound/pierce/bleed/critical/hv_head_shot), "An alert guard was shot through the skull") + // An ordinary person: just the hit. + var/mob/living/carbon/human/victim = stealth_person(block, 6, 1) + victim.setDir(EAST) + var/mob/living/carbon/human/fourth = stealth_person(block, 5, 2) + fourth.forceMove(stealth_at(block, 5, 1)) + gun = d45_arm(fourth, /obj/item/gun/ballistic/automatic/pistol) + gun.fire_gun(victim, fourth, TRUE, null) + TEST_ASSERT(!victim.IsUnconscious(), "A person was knocked out by a stealth head shot") + TEST_ASSERT_NULL(victim.get_bodypart(BODY_ZONE_HEAD)?.get_wound_type(/datum/wound/pierce/bleed/critical/hv_head_shot), "A person was shot through the skull") + qdel(block) + +/// A held shield stops a shot from the front, never one in the back. +/datum/unit_test/voidcrew_stealth_d45_shield + +/datum/unit_test/voidcrew_stealth_d45_shield/Run() + var/datum/turf_reservation/block = stealth_block(8, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/holder = stealth_person(block, 4, 2) + var/obj/item/shield/riot/shield = allocate(/obj/item/shield/riot) + shield.block_chance = 200 + holder.put_in_hands(shield, forced = TRUE) + holder.setDir(EAST) + // From the front: blocked. + var/mob/living/carbon/human/front = stealth_person(block, 5, 2) + var/obj/item/gun/gun = d45_arm(front, /obj/item/gun/ballistic/automatic/pistol) + front.zone_selected = BODY_ZONE_CHEST + holder.setDir(EAST) + gun.fire_gun(holder, front, TRUE, null) + TEST_ASSERT_EQUAL(holder.getBruteLoss(), 0, "A shield didn't stop a shot from the front") + // From behind: through. + var/mob/living/carbon/human/back = stealth_person(block, 3, 2) + gun = d45_arm(back, /obj/item/gun/ballistic/automatic/pistol) + back.zone_selected = BODY_ZONE_CHEST + holder.setDir(EAST) + gun.fire_gun(holder, back, TRUE, null) + TEST_ASSERT(holder.getBruteLoss() > 0, "A shield stopped a shot in the back") + TEST_ASSERT(!holder.vc_shot_in_back, "The shot-in-the-back mark stayed on after the shot") + qdel(block) + +/// The matte knife from behind on an unaware guard slits the throat, whatever is aimed at: tg's critical slash and +/// neck_slice, and the guard can't speak. Not from the front, not a plain knife, not through a SWAT helmet, not when +/// held in a grab (tg's own slit). The mute goes with the cut. +/datum/unit_test/voidcrew_stealth_d45_backstab + +/datum/unit_test/voidcrew_stealth_d45_backstab/Run() + var/datum/turf_reservation/block = stealth_block(8, 7) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = d45_bare_guard(block, 4, 1) + var/mob/living/carbon/human/person = stealth_person(block, 3, 1) + var/obj/item/knife/combat/matte/knife = allocate(/obj/item/knife/combat/matte) + person.put_in_active_hand(knife, forced = TRUE) + person.set_combat_mode(TRUE) + person.zone_selected = BODY_ZONE_CHEST + // From the front: no slit. + person.forceMove(stealth_at(block, 5, 1)) + TEST_ASSERT(!knife.backstab_slits(guard, person), "The knife slits a throat from the front") + person.forceMove(stealth_at(block, 3, 1)) + TEST_ASSERT(knife.backstab_slits(guard, person), "The knife doesn't slit an unaware guard's throat from behind") + // The stab. + knife.attack(guard, person) + TEST_ASSERT(guard.has_status_effect(/datum/status_effect/neck_slice), "A backstab didn't cut the throat") + var/obj/item/bodypart/head = guard.get_bodypart(BODY_ZONE_HEAD) + var/critical_slash = FALSE + for(var/datum/wound/cut as anything in head.wounds) + if(istype(cut, /datum/wound/slash) && cut.severity == WOUND_SEVERITY_CRITICAL) + critical_slash = TRUE + TEST_ASSERT(critical_slash, "A backstab left no critical slash on the head") + TEST_ASSERT(HAS_TRAIT(guard, TRAIT_MUTE), "A cut throat isn't mute") + TEST_ASSERT(!guard.can_speak(), "A guard with a cut throat can speak") + guard.remove_status_effect(/datum/status_effect/neck_slice) + TEST_ASSERT(!HAS_TRAIT(guard, TRAIT_MUTE), "The mute stayed after the cut") + // A plain combat knife is a plain knife. + var/mob/living/carbon/human/npc/second = d45_bare_guard(block, 4, 3) + var/mob/living/carbon/human/stabber = stealth_person(block, 3, 3) + var/obj/item/knife/combat/blade = allocate(/obj/item/knife/combat) + stabber.put_in_active_hand(blade, forced = TRUE) + stabber.set_combat_mode(TRUE) + stabber.zone_selected = BODY_ZONE_CHEST + blade.attack(second, stabber) + TEST_ASSERT(!second.has_status_effect(/datum/status_effect/neck_slice), "A plain knife slit a throat") + // A SWAT helmet (wound 15): tg's wound maths keeps the critical slash out; an ordinary stab to the head. + var/mob/living/carbon/human/npc/helmeted = d45_bare_guard(block, 4, 5) + d45_helmet(helmeted, /obj/item/clothing/head/helmet/swat) + var/mob/living/carbon/human/third = stealth_person(block, 3, 5) + var/obj/item/knife/combat/matte/other_knife = allocate(/obj/item/knife/combat/matte) + third.put_in_active_hand(other_knife, forced = TRUE) + third.set_combat_mode(TRUE) + TEST_ASSERT(!other_knife.slit_gets_through(helmeted, helmeted.get_bodypart(BODY_ZONE_HEAD)), "A slit got through a SWAT helmet") + other_knife.attack(helmeted, third) + TEST_ASSERT(!helmeted.has_status_effect(/datum/status_effect/neck_slice), "A helmeted guard's throat was cut") + TEST_ASSERT(helmeted.get_bodypart(BODY_ZONE_HEAD).brute_dam > 0, "The stab at a protected throat did nothing") + TEST_ASSERT(helmeted.can_speak(), "A guard whose throat was protected can't speak") + // Held in an aggressive grab: tg's own slit, not this one. + var/mob/living/carbon/human/npc/held = d45_bare_guard(block, 6, 5) + third.forceMove(stealth_at(block, 5, 5)) + third.start_pulling(held, supress_message = TRUE) + third.setGrabState(GRAB_AGGRESSIVE) + TEST_ASSERT(!other_knife.backstab_slits(held, third), "The backstab took over tg's grab slit") + third.stop_pulling() + qdel(block) + +/// A lookout with a cut throat makes no radio call and no shout; one with its throat whole does. +/datum/unit_test/voidcrew_stealth_d45_quiet + var/says = 0 + +/datum/unit_test/voidcrew_stealth_d45_quiet/proc/on_say(datum/source) + SIGNAL_HANDLER + says++ + +/datum/unit_test/voidcrew_stealth_d45_quiet/Run() + var/datum/turf_reservation/block = stealth_block(8, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/obj/effect/landmark/stealth_group/marker = allocate(/obj/effect/landmark/stealth_group, stealth_at(block, 6, 4)) + var/datum/stealth_group/group = marker.group + var/mob/living/carbon/human/npc/cut = allocate(/mob/living/carbon/human/npc/ruin/trooper/scav/lookout, stealth_at(block, 2, 2)) + var/mob/living/carbon/human/npc/whole = allocate(/mob/living/carbon/human/npc/ruin/trooper/scav/lookout, stealth_at(block, 5, 2)) + var/datum/ai_controller/basic_controller/human_npc/stealth/cut_ai = cut.ai_controller + var/datum/ai_controller/basic_controller/human_npc/stealth/whole_ai = whole.ai_controller + cut_ai.stealth_setup() + whole_ai.stealth_setup() + TEST_ASSERT(cut_ai.group == group && whole_ai.group == group, "Test fixture: the lookouts aren't in the marker's group") + TEST_ASSERT(cut.stealth_radio_ready() && whole.stealth_radio_ready(), "Test fixture: a lookout's earpiece doesn't work") + cut.apply_status_effect(/datum/status_effect/neck_slice) + TEST_ASSERT(HAS_TRAIT(cut, TRAIT_MUTE), "Test fixture: no throat wound to keep the cut") + var/turf/spot = stealth_at(block, 1, 1) + // The cut throat. + RegisterSignal(cut, COMSIG_MOB_SAY, PROC_REF(on_say)) + TEST_ASSERT(!cut_ai.stealth_shout(), "A guard with a cut throat shouted") + TEST_ASSERT(!cut_ai.stealth_start_call(3, spot), "A guard with a cut throat reached for its earpiece") + cut_ai.pending_call = list(3, spot, world.time, null) + group.next_radio_alarm = 0 + cut_ai.stealth_deliver_call() + TEST_ASSERT_EQUAL(group.next_radio_alarm, 0, "A guard with a cut throat made a radio call") + TEST_ASSERT_EQUAL(says, 0, "A guard with a cut throat said something") + UnregisterSignal(cut, COMSIG_MOB_SAY) + // The whole throat, the same way. + RegisterSignal(whole, COMSIG_MOB_SAY, PROC_REF(on_say)) + whole_ai.pending_call = list(3, spot, world.time, null) + whole_ai.stealth_deliver_call() + TEST_ASSERT(group.next_radio_alarm > 0, "Test fixture: the lookout with a whole throat made no radio call") + TEST_ASSERT(says > 0, "Test fixture: the lookout with a whole throat said nothing") + UnregisterSignal(whole, COMSIG_MOB_SAY) + qdel(block) From c54da03b975bd4aad10ece5ddea67fa02cbf7c00 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Thu, 12 Nov 2026 21:01:18 -0800 Subject: [PATCH 44/78] Knife executions: cut the throat of someone from behind or someone helpless (first pass) --- tgstation.dme | 2 + voidcrew/_DEFINES/hyperviolence.dm | 11 + .../overlays_exec/knife_executions.dm | 172 +++++ .../modules/hyperviolence/visuals/_defines.dm | 49 ++ .../visuals/knife_execution_motion.dm | 695 ++++++++++++++++++ voidcrew/modules/unit_tests/_unit_tests.dm | 1 + .../voidcrew_hv_knife_executions.dm | 151 ++++ 7 files changed, 1081 insertions(+) create mode 100644 voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm create mode 100644 voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_hv_knife_executions.dm diff --git a/tgstation.dme b/tgstation.dme index 815bf4ac9e5..e2cf6db7cbd 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7274,6 +7274,7 @@ #include "voidcrew\modules\hyperviolence\hitlines\npc_blood.dm" #include "voidcrew\modules\hyperviolence\overlays_exec\executions.dm" #include "voidcrew\modules\hyperviolence\overlays_exec\gore_overlays.dm" +#include "voidcrew\modules\hyperviolence\overlays_exec\knife_executions.dm" #include "voidcrew\modules\hyperviolence\visuals\_defines.dm" #include "voidcrew\modules\hyperviolence\visuals\_motion_core.dm" #include "voidcrew\modules\hyperviolence\visuals\blood_motion.dm" @@ -7283,6 +7284,7 @@ #include "voidcrew\modules\hyperviolence\visuals\flying_gore.dm" #include "voidcrew\modules\hyperviolence\visuals\gut_motion.dm" #include "voidcrew\modules\hyperviolence\visuals\hit_reactions.dm" +#include "voidcrew\modules\hyperviolence\visuals\knife_execution_motion.dm" #include "voidcrew\modules\hyperviolence\visuals\npc_motion.dm" #include "voidcrew\modules\intents\_defines.dm" #include "voidcrew\modules\intents\hud_integration.dm" diff --git a/voidcrew/_DEFINES/hyperviolence.dm b/voidcrew/_DEFINES/hyperviolence.dm index 4da2c0d4dee..9f0b34253c9 100644 --- a/voidcrew/_DEFINES/hyperviolence.dm +++ b/voidcrew/_DEFINES/hyperviolence.dm @@ -100,3 +100,14 @@ #define WOUND_SERIES_HV_CAROTID "wound_series_hv_carotid" /// A torn aorta. #define WOUND_SERIES_HV_AORTA "wound_series_hv_aorta" + +// Knife executions (voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm). + +/// Wind-up before a knife execution cuts the throat. +#define HV_KNIFE_EXECUTION_WINDUP (1.5 SECONDS) +/// do_after interaction key for a knife execution wind-up. +#define HV_KNIFE_EXECUTION_DOAFTER "hv_knife_execution" +/// Combined head melee cover below which a knife execution opens a critical slash and slices the neck. +#define HV_KNIFE_EXECUTION_LOW_COVER 20 +/// Combined head melee cover at or above which (or under a sealed helmet) a knife execution leaves only a moderate slash. +#define HV_KNIFE_EXECUTION_HIGH_COVER 50 diff --git a/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm b/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm new file mode 100644 index 00000000000..66b7b13f90f --- /dev/null +++ b/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm @@ -0,0 +1,172 @@ +// Hyperviolence: knife executions. +// +// Modelled on gun executions in executions.dm. A combat-mode click with an edged knife aimed at the +// head or mouth of an adjacent carbon with a head starts a knife execution when the attacker is +// either behind the target (check_behind()) or the target is helpless (hv_can_be_executed()). Only +// players and boss-rank human NPCs execute (hv_can_execute()), never pacifists. +// +// Both hold still for HV_KNIFE_EXECUTION_WINDUP; moving, losing the blade, switching zones or turning +// to face the attacker breaks the wind-up cleanly. If it holds, the knife stabs the head through its +// real attack() path at HV_EXECUTION_POINT_BLANK_MULT force and opens a slash wound on the head whose +// severity is tempered by the head's combined melee cover (worn armour plus physiology armour, such +// as dermal cyberware, minus the blade's armour penetration) and sealed helmets: unarmoured throats +// take a critical slash and tg's neck_slice bleed, light cover downgrades to a severe slash without +// neck_slice, and heavy cover or a sealed helmet leaves only a moderate slash. Nothing extra kills, +// stuns or roots the victim; death comes only from tg's real damage and bleeding. + +/obj/item/knife + /// Set while the execution's own head stab runs through attack(), so our override passes to parent. + var/hv_knife_executing = FALSE + /// Brute and burn damage this knife dealt to the victim's head during an execution stab. + var/hv_knife_execution_head_damage = 0 + +/obj/item/knife/attack(mob/living/target_mob, mob/living/user, list/modifiers, list/attack_modifiers) + if(hv_knife_executing || !hv_knife_execution_possible(user, target_mob)) + return ..() + if(!DOING_INTERACTION(user, HV_KNIFE_EXECUTION_DOAFTER)) + var/list/saved_modifiers = islist(modifiers) ? modifiers.Copy() : null + var/list/saved_attack_modifiers = islist(attack_modifiers) ? attack_modifiers.Copy() : null + INVOKE_ASYNC(src, PROC_REF(hv_start_knife_execution), user, target_mob, saved_modifiers, saved_attack_modifiers) + return TRUE + +/// Whether a melee click with this knife by `user` on `target` starts a knife execution. +/obj/item/knife/proc/hv_knife_execution_possible(mob/living/user, mob/living/target) + if(!isliving(user) || !iscarbon(target) || user == target) + return FALSE + if(!user.combat_mode || HAS_TRAIT(user, TRAIT_PACIFISM) || !user.hv_can_execute()) + return FALSE + if(user.zone_selected != BODY_ZONE_HEAD && user.zone_selected != BODY_ZONE_PRECISE_MOUTH) + return FALSE + if(force <= 0 || !(get_sharpness() & SHARP_EDGED)) + return FALSE + var/mob/living/carbon/victim = target + if(isnull(victim.get_bodypart(BODY_ZONE_HEAD)) || !user.Adjacent(victim)) + return FALSE + return check_behind(user, victim) || victim.hv_can_be_executed() + +/// Grabs the victim, presses the blade to their throat and, if both hold still, cuts. +/obj/item/knife/proc/hv_start_knife_execution(mob/living/user, mob/living/carbon/victim, list/modifiers, list/attack_modifiers) + if(DOING_INTERACTION(user, HV_KNIFE_EXECUTION_DOAFTER) || !hv_knife_execution_possible(user, victim)) + return FALSE + var/from_behind = check_behind(user, victim) + var/unseen = from_behind || victim.is_blind() || !(user in viewers(7, victim)) + if(from_behind) + user.visible_message( + span_danger("[user] grabs [victim] from behind and presses [src] to [victim.p_their()] throat!"), + span_danger("You grab [victim] from behind and press [src] to [victim.p_their()] throat!"), + ignored_mobs = victim, + ) + to_chat(victim, span_userdanger((unseen ? "Someone grabs you from behind and presses cold steel to your throat!" : "[user] grabs you from behind and presses [src] to your throat!"))) + else + user.visible_message( + span_danger("[user] grabs [victim]'s head and presses [src] to [victim.p_their()] throat!"), + span_danger("You grab [victim]'s head and press [src] to [victim.p_their()] throat!"), + ignored_mobs = victim, + ) + to_chat(victim, span_userdanger((unseen ? "Someone grabs your head and presses cold steel to your throat!" : "[user] grabs your head and presses [src] to your throat!"))) + var/held = do_after( + user, + HV_KNIFE_EXECUTION_WINDUP, + victim, + extra_checks = CALLBACK(src, PROC_REF(hv_knife_execution_holds), user, victim), + interaction_key = HV_KNIFE_EXECUTION_DOAFTER, + ) + if(!held || QDELETED(src) || QDELETED(user) || QDELETED(victim)) + return FALSE + return hv_finish_knife_execution(user, victim, modifiers, attack_modifiers) + +/// do_after check: the attacker still holds a sharp knife to an adjacent victim who hasn't turned to face them. +/obj/item/knife/proc/hv_knife_execution_holds(mob/living/user, mob/living/carbon/victim) + if(!user.is_holding(src) || !user.combat_mode || HAS_TRAIT(user, TRAIT_PACIFISM)) + return FALSE + if(force <= 0 || !(get_sharpness() & SHARP_EDGED)) + return FALSE + if(user.zone_selected != BODY_ZONE_HEAD && user.zone_selected != BODY_ZONE_PRECISE_MOUTH) + return FALSE + if(isnull(victim.get_bodypart(BODY_ZONE_HEAD)) || !user.Adjacent(victim)) + return FALSE + return victim.hv_can_be_executed() || check_behind(user, victim) + +/** + * Lands the knife execution: stabs the head through the real attack() path with the point-blank + * multiplier, then opens a head slash wound scaled by the head's combined melee cover and sealed + * headgear, adding neck_slice only when the throat is unarmoured and exposed. Returns TRUE on completion. + */ +/obj/item/knife/proc/hv_finish_knife_execution(mob/living/user, mob/living/carbon/victim, list/modifiers, list/attack_modifiers) + if(!hv_knife_execution_holds(user, victim)) + return FALSE + var/obj/item/bodypart/head/head = victim.get_bodypart(BODY_ZONE_HEAD) + if(isnull(head)) + return FALSE + + var/sealed_helmet = !isnull(victim.is_mouth_covered(ITEM_SLOT_HEAD)) + var/cover = hv_crit_cover_rating(victim, head, MELEE, armour_penetration) + var/wound_severity = WOUND_SEVERITY_CRITICAL + var/slice_neck = TRUE + if(sealed_helmet || cover >= HV_KNIFE_EXECUTION_HIGH_COVER) + wound_severity = WOUND_SEVERITY_MODERATE + slice_neck = FALSE + else if(cover >= HV_KNIFE_EXECUTION_LOW_COVER) + wound_severity = WOUND_SEVERITY_SEVERE + slice_neck = FALSE + + var/list/stab_modifiers = islist(attack_modifiers) ? attack_modifiers.Copy() : list() + MODIFY_ATTACK_FORCE_MULTIPLIER(stab_modifiers, HV_EXECUTION_POINT_BLANK_MULT) + + // Bypass the knife's butchering component for this synchronous hit so an aggressive grab or a + // corpse with butcher results takes the real stab instead of starting startNeckSlice / startButcher. + var/datum/component/butchering/butchering = GetComponent(/datum/component/butchering) + if(butchering) + butchering.UnregisterSignal(src, COMSIG_ITEM_ATTACK) + + var/previous_zone = user.zone_selected + user.zone_selected = BODY_ZONE_HEAD + hv_knife_execution_head_damage = 0 + RegisterSignal(victim, COMSIG_MOB_APPLY_DAMAGE, PROC_REF(hv_knife_execution_hit)) + hv_knife_executing = TRUE + attack(victim, user, modifiers, stab_modifiers) + hv_knife_executing = FALSE + if(!QDELETED(user)) + user.zone_selected = previous_zone + if(!QDELETED(victim)) + UnregisterSignal(victim, COMSIG_MOB_APPLY_DAMAGE) + if(!QDELETED(src) && !QDELETED(butchering)) + butchering.RegisterSignal(src, COMSIG_ITEM_ATTACK, TYPE_PROC_REF(/datum/component/butchering, onItemAttack)) + + if(!QDELETED(victim)) + head = victim.get_bodypart(BODY_ZONE_HEAD) + if(head) + victim.cause_wound_of_type_and_severity(WOUND_SLASH, head, wound_severity, wound_source = src) + if(slice_neck) + var/has_critical_slash = FALSE + for(var/datum/wound/wound as anything in head.wounds) + if(wound.severity >= WOUND_SEVERITY_CRITICAL) + has_critical_slash = TRUE + break + if(has_critical_slash) + victim.apply_status_effect(/datum/status_effect/neck_slice) + victim.hv_add_hit_line("[user] draws [src] across [victim]'s throat!", HV_LINE_HUGE, null, COMBAT_MESSAGE_RANGE) + to_chat(victim, span_userdanger("Cold steel opens your throat!")) + else if(wound_severity == WOUND_SEVERITY_SEVERE) + victim.hv_add_hit_line("[src] cuts deep into [victim]'s neck, turned short of the artery!", HV_LINE_BOLD, null, COMBAT_MESSAGE_RANGE) + else + victim.hv_add_hit_line("[victim]'s protection turns the worst of [src] from [victim.p_their()] throat!", HV_LINE_BOLD, null, COMBAT_MESSAGE_RANGE) + + log_combat(user, victim, "knife-executed", src, "([round(hv_knife_execution_head_damage, 0.1)] damage to the head, slash severity [wound_severity])") + if(!QDELETED(victim)) + hv_execution_witnesses(user, victim) + return TRUE + +/// Sums brute and burn damage this knife deals to the victim's head during an execution stab. +/obj/item/knife/proc/hv_knife_execution_hit(mob/living/source, damage, damagetype, def_zone, blocked, wound_bonus, exposed_wound_bonus, sharpness, attack_direction, atom/attacking_item) + SIGNAL_HANDLER + if(attacking_item != src || (damagetype != BRUTE && damagetype != BURN)) + return + var/zone + if(isbodypart(def_zone)) + var/obj/item/bodypart/limb = def_zone + zone = limb.body_zone + else + zone = check_zone(def_zone) + if(zone == BODY_ZONE_HEAD) + hv_knife_execution_head_damage += damage diff --git a/voidcrew/modules/hyperviolence/visuals/_defines.dm b/voidcrew/modules/hyperviolence/visuals/_defines.dm index 8921320114a..29a93fa6f5e 100644 --- a/voidcrew/modules/hyperviolence/visuals/_defines.dm +++ b/voidcrew/modules/hyperviolence/visuals/_defines.dm @@ -141,3 +141,52 @@ #define HV_VIS_KILL_SHAKE_TIME 4 #define HV_VIS_KILL_SHAKE_STRENGTH 0.12 #define HV_VIS_KILL_SHAKE_RANGE 7 + +// ---- Knife executions ---- + +/// Named animation sequence for the attacker stepping in and out during a knife execution. +#define HV_VIS_TAG_KNIFE_STEP "hv_knife_step" +/// Named animation sequence for the victim's head pull and standing hunch in a knife execution. +#define HV_VIS_TAG_KNIFE_VICTIM "hv_knife_victim" +/// How long the grab and step-in at the start of a knife execution wind-up take. +#define HV_VIS_KNIFE_GRAB_TIME (0.3 SECONDS) +/// How long the blade takes to draw across the victim's throat at the end of the wind-up. +#define HV_VIS_KNIFE_CUT_TIME (0.25 SECONDS) +/// Brief hold at the end of the throat cut before the attacker lets go and the blade prop vanishes. +#define HV_VIS_KNIFE_CUT_HOLD (0.1 SECONDS) +/// How long the attacker takes to step back to zero offset after the cut or a broken wind-up. +#define HV_VIS_KNIFE_RELEASE_TIME (0.25 SECONDS) +/// How long a standing survivor takes to pitch into a forward throat-clutch hunch after release. +#define HV_VIS_KNIFE_HUNCH_IN (0.15 SECONDS) +/// How long a standing survivor holds the forward throat-clutch hunch before returning upright. +#define HV_VIS_KNIFE_HUNCH_HOLD (0.2 SECONDS) +/// How long a standing survivor takes to return from the forward hunch to their true pose. +#define HV_VIS_KNIFE_HUNCH_OUT (0.25 SECONDS) +/// Pixels the attacker steps toward the victim during a knife execution (under a third of a 32 px tile). +#define HV_VIS_KNIFE_STEP_IN 9 +/// Degrees a side-facing standing victim is tilted back toward the attacker about their feet. +#define HV_VIS_KNIFE_TILT_SIDE 8 +/// Degrees a north- or south-facing standing victim's head is cocked back about their feet. +#define HV_VIS_KNIFE_TILT_FRONT 5 +/// Degrees a lying victim is tugged toward the attacker during the wind-up. +#define HV_VIS_KNIFE_TILT_LYING 4 +/// Degrees a standing survivor hunches forward after the throat is cut. +#define HV_VIS_KNIFE_HUNCH_TILT 8 +/// Pixels from the blade prop's centre back along its spine to the grip held in the attacker's hand. +#define HV_VIS_KNIFE_GRIP_BACK 6 +/// Pixels from the blade prop's centre forward along its edge to where the cut begins on the throat. +#define HV_VIS_KNIFE_CUT_START_REACH 2 +/// Pixels from the blade prop's centre forward along its edge to the tip/edge that ends on the throat. +#define HV_VIS_KNIFE_EDGE_REACH 8 +/// Layer for the grabbing far arm behind the victim (above BELOW_MOB_LAYER 3.7, below LYING_MOB_LAYER 3.8). +#define HV_VIS_KNIFE_FAR_ARM_LAYER 3.71 +/// Layer for the knife blade when occluded behind a north-facing victim's head and back. +#define HV_VIS_KNIFE_BEHIND_LAYER 3.72 +/// Layer for the knife hand when occluded behind a north-facing victim's head and back. +#define HV_VIS_KNIFE_BEHIND_HAND_LAYER 3.73 +/// Layer for the throat blood spurt when occluded behind a north-facing victim's neck. +#define HV_VIS_KNIFE_BEHIND_SPURT_LAYER 3.74 +/// Layer for the knife blade when visible in front of the victim's neck (above MOB_LAYER 4.0). +#define HV_VIS_KNIFE_BLADE_LAYER 4.05 +/// Layer for the attacker's knife hand in front of the blade grip and the victim's neck. +#define HV_VIS_KNIFE_HAND_LAYER 4.06 diff --git a/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm b/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm new file mode 100644 index 00000000000..08aa816946a --- /dev/null +++ b/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm @@ -0,0 +1,695 @@ +// Hyperviolence visuals: knife executions (overlays_exec/knife_executions.dm). +// +// Beats over the execution's own wind-up and kill (purely visual; every sequence ends where it began): +// 1. Wind-up grab (0 - 0.3 s): the attacker steps in toward the victim, the off-hand reaches to the +// crown of the head and tilts the victim back about their feet, and the knife hand brings the real +// knife's blade from that hand to the start of the throat cut, grip in the hand every frame. +// 2. Hold (0.3 - 1.5 s): the attacker stays pressed in while the victim trembles and then goes still. +// 3. The cut (1.5 - 1.75 s, held 0.1 s): the blade draws across the drawn throat with its sharp edge +// on the throat the whole way, ending with its edge/tip on the throat; blood spurts from the throat +// point and sprays along the floor in the direction the victim faces once the wound lands. +// 4. Release: the blade prop disappears, the attacker steps back to zero offset, and a survivor still +// on their feet hunches forward clutching their throat before returning; if the blow dropped them, +// tg's own fall and death_falls.dm take over. A broken wind-up releases everything cleanly, no blood. + +/mob/living + /// Suppresses tg's centre-body lunge and floating item flick during the execution's own head stab. + var/hv_vis_knife_executing = FALSE + /// Wind-up start time for the active knife execution pose on this victim. + var/hv_vis_knife_t0 = -1 + /// Time the wind-up head pull reaches its full back-tilt. + var/hv_vis_knife_t1 = -1 + /// Time the throat cut and its short hold finish. + var/hv_vis_knife_t2 = -1 + /// Time a standing survivor's forward hunch reaches its peak. + var/hv_vis_knife_t3 = -1 + /// Time a standing survivor's forward hunch returns to zero. + var/hv_vis_knife_t4 = -1 + /// Clockwise degrees this victim is tilted back during the wind-up and cut. + var/hv_vis_knife_tilt = 0 + /// Clockwise degrees this victim hunches forward after release when still standing. + var/hv_vis_knife_hunch = 0 + /// Until this world.time, a victim felled by the cut is still drawn upright over tg's lying turn. + var/hv_vis_knife_upright_until = -1 + /// Copy of the standing base transform while held upright through the cut. + var/matrix/hv_vis_knife_pose_base + +/obj/item/knife + /// Weakref to the active blade prop (/obj/effect/temp_visual/hv_knife_exec_blade) during a wind-up. + var/datum/weakref/hv_vis_blade_ref + /// Weakref to the attacker's knife-hand forearm prop during a wind-up. + var/datum/weakref/hv_vis_knife_arm_ref + /// Weakref to the attacker's off-hand grabbing forearm prop during a wind-up. + var/datum/weakref/hv_vis_grab_arm_ref + /// Whether the current execution completed its cut so hv_start_knife_execution skips broken cleanup. + var/hv_vis_cut_landed = FALSE + +/obj/item/knife/Destroy() + hv_vis_clear_exec_props() + return ..() + +/mob/living/do_attack_animation(atom/A, visual_effect_icon, obj/item/used_item, no_effect) + if(hv_vis_knife_executing) + return + return ..() + +/mob/living/carbon/hv_vis_on_death(gibbed) + if(world.time >= hv_vis_knife_t2) + hv_vis_knife_clear_pose() + hv_vis_stop(list(HV_VIS_TAG_KNIFE_VICTIM)) + return ..() + +/// Pixel offset list(x, y) of `victim`'s drawn throat from their icon centre at `world.time`'s pose. +/proc/hv_knife_exec_throat_point(mob/living/victim) + if(!isliving(victim)) + return list(0, 0) + var/base_x = (victim.dir & EAST) ? 3 : ((victim.dir & WEST) ? -4 : 0) + var/base_y = 6 + var/angle = victim.hv_vis_knife_pose_angle() + var/held_upright = victim.hv_vis_knife_pose_base && world.time < victim.hv_vis_knife_upright_until + var/matrix/base = held_upright ? matrix(victim.hv_vis_knife_pose_base) : matrix(victim.transform) + var/pivot = held_upright ? (HV_VIS_FEET_Y * victim.current_size) : victim.hv_vis_pivot() + var/matrix/pose = hv_vis_turned(base, angle, pivot) + return list( + round(pose.a * base_x + pose.b * base_y + pose.c, 0.1), + round(pose.d * base_x + pose.e * base_y + pose.f, 0.1), + ) + +/// Current clockwise lean angle (degrees) our knife execution animation adds to this mob at world.time. +/mob/living/proc/hv_vis_knife_pose_angle() + if(hv_vis_knife_t0 < 0 || world.time < hv_vis_knife_t0) + return 0 + if(world.time < hv_vis_knife_t1) + var/span = max(hv_vis_knife_t1 - hv_vis_knife_t0, 1) + var/frac = (world.time - hv_vis_knife_t0) / span + return hv_vis_knife_tilt * (1 - (1 - frac) * (1 - frac)) + if(world.time <= hv_vis_knife_t2) + return hv_vis_knife_tilt + if(hv_vis_knife_hunch && hv_vis_knife_t3 > hv_vis_knife_t2 && world.time < hv_vis_knife_t4) + if(world.time <= hv_vis_knife_t3) + var/in_span = max(hv_vis_knife_t3 - hv_vis_knife_t2, 1) + return LERP(hv_vis_knife_tilt, hv_vis_knife_hunch, (world.time - hv_vis_knife_t2) / in_span) + var/hold_end = min(hv_vis_knife_t3 + HV_VIS_KNIFE_HUNCH_HOLD, hv_vis_knife_t4) + if(world.time <= hold_end) + return hv_vis_knife_hunch + var/out_span = max(hv_vis_knife_t4 - hold_end, 1) + return hv_vis_knife_hunch * (1 - (world.time - hold_end) / out_span) + return 0 + +/// Clears tracked knife execution pose timestamps on this mob. +/mob/living/proc/hv_vis_knife_clear_pose() + hv_vis_knife_t0 = -1 + hv_vis_knife_t1 = -1 + hv_vis_knife_t2 = -1 + hv_vis_knife_t3 = -1 + hv_vis_knife_t4 = -1 + hv_vis_knife_tilt = 0 + hv_vis_knife_hunch = 0 + hv_vis_knife_upright_until = -1 + hv_vis_knife_pose_base = null + +/obj/item/knife/hv_start_knife_execution(mob/living/user, mob/living/carbon/victim, list/modifiers, list/attack_modifiers) + var/staging = !DOING_INTERACTION(user, HV_KNIFE_EXECUTION_DOAFTER) && hv_knife_execution_possible(user, victim) && isturf(user.loc) && isturf(victim.loc) + hv_vis_cut_landed = FALSE + if(staging) + hv_vis_begin_knife_windup(user, victim) + . = ..() + if(!staging) + return + if(!hv_vis_cut_landed) + hv_vis_abort_knife_windup(user, victim) + +/obj/item/knife/hv_finish_knife_execution(mob/living/user, mob/living/carbon/victim, list/modifiers, list/attack_modifiers) + if(!isturf(user?.loc) || !isturf(victim?.loc)) + return ..() + var/was_standing = victim.body_position == STANDING_UP + var/pre_pixel_y = victim.pixel_y + var/matrix/pre_base = matrix(victim.transform) + var/sealed_before = !isnull(victim.is_mouth_covered(ITEM_SLOT_HEAD)) + var/obj/item/bodypart/head/head_before = victim.get_bodypart(BODY_ZONE_HEAD) + var/cover_before = head_before ? hv_crit_cover_rating(victim, head_before, MELEE, armour_penetration) : 100 + + victim.hv_vis_execution_time = world.time + user.hv_vis_knife_executing = TRUE + . = ..() + if(!QDELETED(user)) + user.hv_vis_knife_executing = FALSE + if(!.) + return + + hv_vis_cut_landed = TRUE + hv_vis_play_knife_cut_and_release(user, victim, was_standing, pre_pixel_y, pre_base, sealed_before, cover_before) + +// ---- Wind-up, cut and release choreography ---- + +/// Starts Beats 1 and 2: attacker step-in, victim head-pull + tremble, and blade + forearm props. +/obj/item/knife/proc/hv_vis_begin_knife_windup(mob/living/user, mob/living/carbon/victim) + hv_vis_clear_exec_props() + var/turf/victim_turf = get_turf(victim) + if(!victim_turf) + return + + var/cut_hold_total = HV_KNIFE_EXECUTION_WINDUP + HV_VIS_KNIFE_CUT_TIME + HV_VIS_KNIFE_CUT_HOLD + var/toward = get_dir(user, victim) || user.dir || SOUTH + var/step_px = (HV_VIS_DX(toward) && HV_VIS_DY(toward)) ? round(HV_VIS_KNIFE_STEP_IN * 0.78) : HV_VIS_KNIFE_STEP_IN + var/step_dx = HV_VIS_DX(toward) * step_px + var/step_dy = HV_VIS_DY(toward) * step_px + + // Attacker steps in behind the victim and stays pressed in until the cut releases. + var/matrix/attacker_base = matrix(user.transform) + var/matrix/attacker_lean = hv_vis_turned(attacker_base, HV_VIS_DX(toward) * 4, user.hv_vis_pivot()) + user.hv_vis_play(HV_VIS_TAG_KNIFE_STEP, list( + list(user.pixel_w + step_dx, user.pixel_z + step_dy, attacker_lean, HV_VIS_KNIFE_GRAB_TIME, QUAD_EASING|EASE_OUT), + list(user.pixel_w + step_dx, user.pixel_z + step_dy, attacker_lean, cut_hold_total - HV_VIS_KNIFE_GRAB_TIME + 0.5 SECONDS, LINEAR_EASING), + list(user.pixel_w, user.pixel_z, attacker_base, HV_VIS_KNIFE_RELEASE_TIME, SINE_EASING), + )) + + // Victim is pulled back a few degrees about their feet and trembles until the press pause. + var/tilt = victim.hv_vis_knife_windup_tilt(user) + var/matrix/victim_base = matrix(victim.transform) + var/matrix/victim_tilted = hv_vis_turned(victim_base, tilt, victim.hv_vis_pivot()) + victim.hv_vis_knife_t0 = world.time + victim.hv_vis_knife_t1 = world.time + HV_VIS_KNIFE_GRAB_TIME + victim.hv_vis_knife_t2 = world.time + cut_hold_total + victim.hv_vis_knife_t3 = -1 + victim.hv_vis_knife_t4 = -1 + victim.hv_vis_knife_tilt = tilt + victim.hv_vis_knife_hunch = 0 + victim.hv_vis_knife_upright_until = -1 + victim.hv_vis_knife_pose_base = victim.body_position == STANDING_UP ? matrix(victim_base) : null + + victim.hv_vis_play(HV_VIS_TAG_KNIFE_VICTIM, list( + list(victim.pixel_w, victim.pixel_z, victim_tilted, HV_VIS_KNIFE_GRAB_TIME, QUAD_EASING|EASE_OUT), + list(victim.pixel_w, victim.pixel_z, victim_tilted, cut_hold_total - HV_VIS_KNIFE_GRAB_TIME + 0.5 SECONDS, LINEAR_EASING), + list(victim.pixel_w, victim.pixel_z, victim_base, HV_VIS_KNIFE_RELEASE_TIME, SINE_EASING), + )) + victim.hv_vis_tremble(HV_KNIFE_EXECUTION_WINDUP - HV_VIS_PRESS_PAUSE, 1) + + // Compute the throat target at the full wind-up tilt (t1..t2) so the blade lands on the tilted throat. + var/list/tilted_throat = victim.hv_vis_throat_for_angle(tilt) + var/throat_w = victim.pixel_w + tilted_throat[1] + var/throat_z = victim.pixel_z + tilted_throat[2] + + var/knife_zone = user.get_hand_zone_of_item(src) || BODY_ZONE_R_ARM + var/grab_zone = (knife_zone == BODY_ZONE_R_ARM) ? BODY_ZONE_L_ARM : BODY_ZONE_R_ARM + + // Attacker's real hand and shoulder coordinates in the victim turf's pixel frame. + var/list/knife_hand_start = hv_vis_hand_in_victim_frame(user, victim, knife_zone, 0, 0) + var/list/grab_hand_start = hv_vis_hand_in_victim_frame(user, victim, grab_zone, 0, 0) + var/list/knife_shoulder_in = hv_vis_shoulder_in_victim_frame(user, victim, knife_zone, step_dx, step_dy) + var/list/grab_shoulder_in = hv_vis_shoulder_in_victim_frame(user, victim, grab_zone, step_dx, step_dy) + + var/blade_deg = hv_vis_knife_blade_angle(victim, knife_zone) + var/ux = cos(blade_deg) + var/uy = -sin(blade_deg) + + // Start of Beat 3: heel of the cutting edge rests on the tilted throat; grip sits in the knife hand. + var/cut_start_w = round(throat_w - HV_VIS_KNIFE_CUT_START_REACH * ux, 0.1) + var/cut_start_z = round(throat_z - HV_VIS_KNIFE_CUT_START_REACH * uy, 0.1) + var/fist_in_w = round(cut_start_w - HV_VIS_KNIFE_GRIP_BACK * ux, 0.1) + var/fist_in_z = round(cut_start_z - HV_VIS_KNIFE_GRIP_BACK * uy, 0.1) + + var/north_occluded = (victim.dir & NORTH) != 0 + var/blade_layer = north_occluded ? HV_VIS_KNIFE_BEHIND_LAYER : HV_VIS_KNIFE_BLADE_LAYER + var/knife_arm_layer = north_occluded ? HV_VIS_KNIFE_BEHIND_HAND_LAYER : HV_VIS_KNIFE_HAND_LAYER + + // Spawn the blade at the exact hand holding the knife (grip == hand0), then bring it to the throat. + var/start_blade_w = round(knife_hand_start[1] + HV_VIS_KNIFE_GRIP_BACK * ux, 0.1) + var/start_blade_z = round(knife_hand_start[2] + HV_VIS_KNIFE_GRIP_BACK * uy, 0.1) + var/obj/effect/temp_visual/hv_knife_exec_blade/blade = new( + victim_turf, + src, + victim.pixel_x, + victim.pixel_y, + start_blade_w, + start_blade_z, + blade_deg, + blade_layer, + cut_hold_total + 1 SECONDS, + ) + var/matrix/blade_turn = blade.hv_turn_matrix(blade_deg) + animate(blade, pixel_w = cut_start_w, pixel_z = cut_start_z, transform = blade_turn, time = HV_VIS_KNIFE_GRAB_TIME, easing = QUAD_EASING|EASE_OUT) + hv_vis_blade_ref = WEAKREF(blade) + + // Spawn the knife-hand forearm prop starting at that same hand and tracking the blade's grip. + var/obj/effect/temp_visual/hv_knife_exec_arm/knife_arm = new( + victim_turf, + user, + knife_zone, + victim.pixel_x, + victim.pixel_y, + knife_hand_start[1], + knife_hand_start[2], + knife_shoulder_in[1], + knife_shoulder_in[2], + knife_arm_layer, + cut_hold_total + 1 SECONDS, + ) + knife_arm.hv_animate_to(fist_in_w, fist_in_z, knife_shoulder_in[1], knife_shoulder_in[2], HV_VIS_KNIFE_GRAB_TIME, QUAD_EASING|EASE_OUT) + hv_vis_knife_arm_ref = WEAKREF(knife_arm) + + // Spawn the off-hand grabbing forearm prop behind the victim, reaching to the crown to pull the head back. + var/crown_shift_x = (victim.dir & EAST) ? -2 : ((victim.dir & WEST) ? 2 : ((grab_zone == BODY_ZONE_L_ARM) ? 2 : -2)) + var/crown_w = round(throat_w + crown_shift_x, 0.1) + var/crown_z = round(throat_z + 5, 0.1) + var/obj/effect/temp_visual/hv_knife_exec_arm/grab_arm = new( + victim_turf, + user, + grab_zone, + victim.pixel_x, + victim.pixel_y, + grab_hand_start[1], + grab_hand_start[2], + grab_shoulder_in[1], + grab_shoulder_in[2], + HV_VIS_KNIFE_FAR_ARM_LAYER, + cut_hold_total + 1 SECONDS, + ) + grab_arm.hv_animate_to(crown_w, crown_z, grab_shoulder_in[1], grab_shoulder_in[2], HV_VIS_KNIFE_GRAB_TIME, QUAD_EASING|EASE_OUT) + hv_vis_grab_arm_ref = WEAKREF(grab_arm) + +/// Runs Beats 3 and 4 once the wind-up succeeded and the real stab + slash wound landed. +/obj/item/knife/proc/hv_vis_play_knife_cut_and_release(mob/living/user, mob/living/carbon/victim, was_standing, pre_pixel_y, matrix/pre_base, sealed_before, cover_before) + var/cut_total = HV_VIS_KNIFE_CUT_TIME + HV_VIS_KNIFE_CUT_HOLD + if(!QDELETED(user)) + user.hv_vis_stop(list(HV_VIS_TAG_HITSTOP)) + + if(QDELETED(victim) || !isturf(victim.loc)) + hv_vis_clear_exec_props() + if(!QDELETED(user)) + user.hv_vis_release(HV_VIS_TAG_KNIFE_STEP, HV_VIS_KNIFE_RELEASE_TIME) + return + + // Keep the victim steady in the attacker's grip across the 0.25 s throat draw rather than flinching away early. + victim.hv_vis_stop(list(HV_VIS_TAG_FLINCH, HV_VIS_TAG_TREMBLE)) + victim.hv_vis_flash() + + // If the stab dropped a standing victim into crit (non-dead), hold them upright through the 0.25 s cut + // before tg's own lying fall takes over, matching death_falls.dm's execution hold on lethal cuts. + var/fell_now = was_standing && victim.body_position == LYING_DOWN + if(fell_now && victim.hv_vis_can_hold_fall()) + victim.hv_vis_knife_upright_until = world.time + cut_total + if(victim.stat != DEAD) + victim.hv_vis_stop(list(HV_VIS_TAG_KNIFE_VICTIM)) + var/matrix/tilted_upright = hv_vis_turned(pre_base, victim.hv_vis_knife_tilt, HV_VIS_FEET_Y * victim.current_size) + victim.hv_vis_play_over(list( + list(pre_pixel_y, tilted_upright, 0, LINEAR_EASING), + list(pre_pixel_y, tilted_upright, cut_total, LINEAR_EASING), + list(victim.pixel_y, matrix(victim.transform), 3, QUAD_EASING|EASE_IN), + )) + + // Exact drawn throat at the moment of the cut, through the same transform on the victim. + var/list/throat = hv_knife_exec_throat_point(victim) + var/throat_w = victim.pixel_w + throat[1] + var/throat_z = victim.pixel_z + throat[2] + var/row_pixel_y = (fell_now && victim.hv_vis_can_hold_fall()) ? pre_pixel_y : victim.pixel_y + + var/knife_zone = (!QDELETED(user) && user.get_hand_zone_of_item(src)) || BODY_ZONE_R_ARM + var/grab_zone = (knife_zone == BODY_ZONE_R_ARM) ? BODY_ZONE_L_ARM : BODY_ZONE_R_ARM + var/blade_deg = hv_vis_knife_blade_angle(victim, knife_zone) + var/ux = cos(blade_deg) + var/uy = -sin(blade_deg) + + // End of Beat 3: blade has drawn across the throat so its sharp edge/tip sits right on (throat_w, throat_z). + var/cut_end_w = round(throat_w - HV_VIS_KNIFE_EDGE_REACH * ux, 0.1) + var/cut_end_z = round(throat_z - HV_VIS_KNIFE_EDGE_REACH * uy, 0.1) + var/fist_end_w = round(cut_end_w - HV_VIS_KNIFE_GRIP_BACK * ux, 0.1) + var/fist_end_z = round(cut_end_z - HV_VIS_KNIFE_GRIP_BACK * uy, 0.1) + + var/toward = !QDELETED(user) ? (get_dir(user, victim) || user.dir || SOUTH) : SOUTH + var/step_px = (HV_VIS_DX(toward) && HV_VIS_DY(toward)) ? round(HV_VIS_KNIFE_STEP_IN * 0.78) : HV_VIS_KNIFE_STEP_IN + var/step_dx = HV_VIS_DX(toward) * step_px + var/step_dy = HV_VIS_DY(toward) * step_px + + var/obj/effect/temp_visual/hv_knife_exec_blade/blade = hv_vis_blade_ref?.resolve() + if(blade && !QDELETED(blade)) + blade.pixel_y = row_pixel_y + var/matrix/blade_turn = blade.hv_turn_matrix(blade_deg) + animate(blade, pixel_w = cut_end_w, pixel_z = cut_end_z, transform = blade_turn, time = HV_VIS_KNIFE_CUT_TIME, easing = QUAD_EASING|EASE_OUT) + QDEL_IN(blade, cut_total) + + var/obj/effect/temp_visual/hv_knife_exec_arm/knife_arm = hv_vis_knife_arm_ref?.resolve() + if(knife_arm && !QDELETED(knife_arm) && !QDELETED(user)) + knife_arm.pixel_y = row_pixel_y + var/list/knife_shoulder_in = hv_vis_shoulder_in_victim_frame(user, victim, knife_zone, step_dx, step_dy) + var/list/knife_hand_home = hv_vis_hand_in_victim_frame(user, victim, knife_zone, 0, 0) + var/list/knife_shoulder_home = hv_vis_shoulder_in_victim_frame(user, victim, knife_zone, 0, 0) + knife_arm.hv_animate_cut_and_retract( + fist_end_w, + fist_end_z, + knife_shoulder_in[1], + knife_shoulder_in[2], + knife_hand_home[1], + knife_hand_home[2], + knife_shoulder_home[1], + knife_shoulder_home[2], + ) + else if(knife_arm && !QDELETED(knife_arm)) + QDEL_IN(knife_arm, cut_total) + + var/obj/effect/temp_visual/hv_knife_exec_arm/grab_arm = hv_vis_grab_arm_ref?.resolve() + if(grab_arm && !QDELETED(grab_arm) && !QDELETED(user)) + grab_arm.pixel_y = row_pixel_y + var/list/grab_shoulder_in = hv_vis_shoulder_in_victim_frame(user, victim, grab_zone, step_dx, step_dy) + var/list/grab_hand_home = hv_vis_hand_in_victim_frame(user, victim, grab_zone, 0, 0) + var/list/grab_shoulder_home = hv_vis_shoulder_in_victim_frame(user, victim, grab_zone, 0, 0) + grab_arm.hv_animate_cut_and_retract( + grab_arm.pixel_w, + grab_arm.pixel_z, + grab_shoulder_in[1], + grab_shoulder_in[2], + grab_hand_home[1], + grab_hand_home[2], + grab_shoulder_home[1], + grab_shoulder_home[2], + ) + else if(grab_arm && !QDELETED(grab_arm)) + QDEL_IN(grab_arm, cut_total) + + hv_vis_blade_ref = null + hv_vis_knife_arm_ref = null + hv_vis_grab_arm_ref = null + + // Blood from the throat in the direction the victim faces, starting now as the wound lands. + var/spray_dir = victim.dir || toward || SOUTH + var/obj/item/bodypart/head/head_after = victim.get_bodypart(BODY_ZONE_HEAD) + var/can_bleed_throat = (head_after ? head_after.can_bleed() : victim.can_bleed()) && !(sealed_before && cover_before >= HV_KNIFE_EXECUTION_HIGH_COVER) + if(can_bleed_throat) + var/spray_tiles = 3 + if(sealed_before || cover_before >= HV_KNIFE_EXECUTION_HIGH_COVER) + spray_tiles = 1 + else if(cover_before >= HV_KNIFE_EXECUTION_LOW_COVER) + spray_tiles = 2 + // Allow the throat spray to fire in victim.dir even if the stab just triggered a hit-dir spray. + victim.hv_blood_spray_until = 0 + victim.hv_blood_spray(spray_dir, spray_tiles) + var/spurt_layer = (victim.dir & NORTH) ? HV_VIS_KNIFE_BEHIND_SPURT_LAYER : ABOVE_MOB_LAYER + var/blood_color = get_color_from_blood_list(victim.get_blood_dna_list()) || BLOOD_COLOR_RED + new /obj/effect/temp_visual/hv_throat_spurt( + get_turf(victim), + victim.pixel_x, + row_pixel_y, + throat_w, + throat_z, + spray_dir, + spurt_layer, + blood_color, + spray_tiles, + ) + + // Beat 4 release: attacker steps back to exact zero offset after the cut + hold. + if(!QDELETED(user) && isturf(user.loc)) + var/matrix/attacker_base = matrix(user.transform) + var/matrix/attacker_lean = hv_vis_turned(attacker_base, HV_VIS_DX(toward) * 4, user.hv_vis_pivot()) + user.hv_vis_play(HV_VIS_TAG_KNIFE_STEP, list( + list(user.pixel_w + step_dx, user.pixel_z + step_dy, attacker_lean, cut_total, LINEAR_EASING), + list(user.pixel_w, user.pixel_z, attacker_base, HV_VIS_KNIFE_RELEASE_TIME, SINE_EASING), + )) + + // Beat 4 on the victim: if still standing after the cut, hunch forward clutching the throat, then return. + if(victim.stat != DEAD && victim.body_position == STANDING_UP) + var/hunch_angle = victim.hv_vis_knife_hunch_tilt() + var/lurch_dx = HV_VIS_DX(spray_dir) * 2 + var/lurch_dy = HV_VIS_DY(spray_dir) * 2 - 1 + var/pivot = victim.hv_vis_pivot() + var/matrix/base = matrix(victim.transform) + var/matrix/tilted = hv_vis_turned(base, victim.hv_vis_knife_tilt, pivot) + var/matrix/hunched = hv_vis_turned(base, hunch_angle, pivot) + + victim.hv_vis_knife_t2 = world.time + cut_total + victim.hv_vis_knife_t3 = victim.hv_vis_knife_t2 + HV_VIS_KNIFE_HUNCH_IN + victim.hv_vis_knife_t4 = victim.hv_vis_knife_t3 + HV_VIS_KNIFE_HUNCH_HOLD + HV_VIS_KNIFE_HUNCH_OUT + victim.hv_vis_knife_hunch = hunch_angle + + victim.hv_vis_play(HV_VIS_TAG_KNIFE_VICTIM, list( + list(victim.pixel_w, victim.pixel_z, tilted, cut_total, LINEAR_EASING), + list(victim.pixel_w + lurch_dx, victim.pixel_z + lurch_dy, hunched, HV_VIS_KNIFE_HUNCH_IN, QUAD_EASING|EASE_OUT), + list(victim.pixel_w + lurch_dx, victim.pixel_z + lurch_dy, hunched, HV_VIS_KNIFE_HUNCH_HOLD, LINEAR_EASING), + list(victim.pixel_w, victim.pixel_z, base, HV_VIS_KNIFE_HUNCH_OUT, SINE_EASING), + )) + else if(!fell_now) + victim.hv_vis_knife_t2 = world.time + cut_total + victim.hv_vis_knife_hunch = 0 + var/matrix/base_lying = matrix(victim.transform) + var/matrix/tilted_lying = hv_vis_turned(base_lying, victim.hv_vis_knife_tilt, victim.hv_vis_pivot()) + victim.hv_vis_play(HV_VIS_TAG_KNIFE_VICTIM, list( + list(victim.pixel_w, victim.pixel_z, tilted_lying, cut_total, LINEAR_EASING), + list(victim.pixel_w, victim.pixel_z, base_lying, HV_VIS_KNIFE_RELEASE_TIME, SINE_EASING), + )) + +/// Beat 5: wind-up broke early; ease both bodies straight back to their exact starting poses with no blood. +/obj/item/knife/proc/hv_vis_abort_knife_windup(mob/living/user, mob/living/carbon/victim) + hv_vis_clear_exec_props() + if(!QDELETED(user)) + user.hv_vis_release(HV_VIS_TAG_KNIFE_STEP, 2) + if(!QDELETED(victim)) + victim.hv_vis_knife_clear_pose() + if(victim.stat != DEAD) + victim.hv_vis_release(HV_VIS_TAG_KNIFE_VICTIM, 2) + victim.hv_vis_release(HV_VIS_TAG_TREMBLE, 1) + else + victim.hv_vis_stop(list(HV_VIS_TAG_KNIFE_VICTIM, HV_VIS_TAG_TREMBLE)) + +/// Deletes any active knife execution props tracked by weakref on this knife. +/obj/item/knife/proc/hv_vis_clear_exec_props() + var/atom/blade = hv_vis_blade_ref?.resolve() + if(blade && !QDELETED(blade)) + qdel(blade) + var/atom/knife_arm = hv_vis_knife_arm_ref?.resolve() + if(knife_arm && !QDELETED(knife_arm)) + qdel(knife_arm) + var/atom/grab_arm = hv_vis_grab_arm_ref?.resolve() + if(grab_arm && !QDELETED(grab_arm)) + qdel(grab_arm) + hv_vis_blade_ref = null + hv_vis_knife_arm_ref = null + hv_vis_grab_arm_ref = null + +// ---- Geometry helpers ---- + +/// Throat offset list(x, y) from this mob's icon centre when leaned by `angle` degrees clockwise. +/mob/living/proc/hv_vis_throat_for_angle(angle) + var/base_x = (dir & EAST) ? 3 : ((dir & WEST) ? -4 : 0) + var/base_y = 6 + var/matrix/pose = hv_vis_turned(matrix(transform), angle, hv_vis_pivot()) + return list( + round(pose.a * base_x + pose.b * base_y + pose.c, 0.1), + round(pose.d * base_x + pose.e * base_y + pose.f, 0.1), + ) + +/// Clockwise tilt angle (degrees) that pulls this victim's head back toward `attacker`. +/mob/living/proc/hv_vis_knife_windup_tilt(mob/living/attacker) + if(body_position == LYING_DOWN) + var/toward_attacker = HV_VIS_DX(get_dir(src, attacker)) || -1 + return toward_attacker * HV_VIS_KNIFE_TILT_LYING + if(dir & EAST) + return -HV_VIS_KNIFE_TILT_SIDE + if(dir & WEST) + return HV_VIS_KNIFE_TILT_SIDE + var/back_dx = HV_VIS_DX(get_dir(src, attacker)) + if(back_dx) + return back_dx * HV_VIS_KNIFE_TILT_FRONT + return (dir & NORTH) ? HV_VIS_KNIFE_TILT_FRONT : -HV_VIS_KNIFE_TILT_FRONT + +/// Clockwise tilt angle (degrees) for a standing survivor hunching forward after release. +/mob/living/proc/hv_vis_knife_hunch_tilt() + if(dir & EAST) + return HV_VIS_KNIFE_HUNCH_TILT + if(dir & WEST) + return -HV_VIS_KNIFE_HUNCH_TILT + return hv_vis_knife_tilt >= 0 ? -HV_VIS_KNIFE_HUNCH_TILT * 0.6 : HV_VIS_KNIFE_HUNCH_TILT * 0.6 + +/// Clockwise angle from EAST (0 deg) along which the knife blade points while crossing `victim`'s throat. +/proc/hv_vis_knife_blade_angle(mob/living/victim, knife_zone) + if(victim.dir & EAST) + return -15 + if(victim.dir & WEST) + return 195 + if(victim.dir & NORTH) + return (knife_zone == BODY_ZONE_R_ARM) ? 180 : 0 + return (knife_zone == BODY_ZONE_R_ARM) ? 0 : 180 + +/// Pixel offset list(x, y) of `arm_zone`'s hand from `holder`'s icon centre for `holder.dir`. +/proc/hv_vis_local_hand_offset(mob/living/holder, arm_zone) + var/right_hand = (arm_zone == BODY_ZONE_R_ARM) + switch(holder.dir) + if(NORTH) + return list(right_hand ? 6 : -6, -2) + if(EAST) + return list(right_hand ? 1 : 2, -2) + if(WEST) + return list(right_hand ? -2 : -1, -2) + return list(right_hand ? -6 : 6, -2) + +/// Pixel offset list(x, y) of `arm_zone`'s shoulder from `holder`'s icon centre for `holder.dir`. +/proc/hv_vis_local_shoulder_offset(mob/living/holder, arm_zone) + var/right_hand = (arm_zone == BODY_ZONE_R_ARM) + switch(holder.dir) + if(NORTH) + return list(right_hand ? 6 : -6, 5) + if(EAST) + return list(right_hand ? -1 : 1, 5) + if(WEST) + return list(right_hand ? 1 : -1, 5) + return list(right_hand ? -6 : 6, 5) + +/// Converts `attacker`'s hand position (with optional extra step `step_dx`, `step_dy`) into `victim`'s turf pixel_w/pixel_z frame. +/proc/hv_vis_hand_in_victim_frame(mob/living/attacker, mob/living/victim, arm_zone, step_dx = 0, step_dy = 0) + var/list/local_hand = hv_vis_local_hand_offset(attacker, arm_zone) + var/frame_x = (attacker.x - victim.x) * ICON_SIZE_X + (attacker.pixel_x - victim.pixel_x) + attacker.pixel_w + step_dx + local_hand[1] + var/frame_y = (attacker.y - victim.y) * ICON_SIZE_Y + (attacker.pixel_y - victim.pixel_y) + attacker.pixel_z + step_dy + local_hand[2] + return list(round(frame_x, 0.1), round(frame_y, 0.1)) + +/// Converts `attacker`'s shoulder position (with optional extra step `step_dx`, `step_dy`) into `victim`'s turf pixel_w/pixel_z frame. +/proc/hv_vis_shoulder_in_victim_frame(mob/living/attacker, mob/living/victim, arm_zone, step_dx = 0, step_dy = 0) + var/list/local_shoulder = hv_vis_local_shoulder_offset(attacker, arm_zone) + var/frame_x = (attacker.x - victim.x) * ICON_SIZE_X + (attacker.pixel_x - victim.pixel_x) + attacker.pixel_w + step_dx + local_shoulder[1] + var/frame_y = (attacker.y - victim.y) * ICON_SIZE_Y + (attacker.pixel_y - victim.pixel_y) + attacker.pixel_z + step_dy + local_shoulder[2] + return list(round(frame_x, 0.1), round(frame_y, 0.1)) + +// ---- Visual props ---- + +/// Temporary visual copy of the real knife blade drawn at the attacker's hand and across the throat. +/obj/effect/temp_visual/hv_knife_exec_blade + name = "knife blade" + plane = GAME_PLANE + layer = HV_VIS_KNIFE_BLADE_LAYER + randomdir = FALSE + duration = 25 + /// Marker read by the recording harness to locate the active knife execution blade prop. + var/hv_knife_exec_blade = TRUE + /// Native icon_angle of the source knife so rotations align its blade along any target angle. + var/hv_native_icon_angle = -90 + +/obj/effect/temp_visual/hv_knife_exec_blade/Initialize(mapload, obj/item/knife/source_knife, row_x = 0, row_y = 0, start_w = 0, start_z = 0, blade_deg = 0, draw_layer = HV_VIS_KNIFE_BLADE_LAYER, life = 25) + if(life > 0) + duration = life + . = ..() + if(!istype(source_knife)) + return INITIALIZE_HINT_QDEL + name = source_knife.name + icon = source_knife.icon + icon_state = source_knife.icon_state + color = source_knife.color + alpha = source_knife.alpha + hv_native_icon_angle = source_knife.icon_angle + layer = draw_layer + pixel_x = row_x + pixel_y = row_y + pixel_w = start_w + pixel_z = start_z + transform = hv_turn_matrix(blade_deg) + +/// Matrix orienting this knife's blade along `blade_deg` clockwise from EAST, scaled small enough to read cleanly at the neck. +/obj/effect/temp_visual/hv_knife_exec_blade/proc/hv_turn_matrix(blade_deg) + var/matrix/turned = matrix() + turned.Turn(blade_deg - hv_native_icon_angle) + return turned + +/// Temporary forearm + hand prop built from the attacker's real arm bodypart so skin tone and species match. +/obj/effect/temp_visual/hv_knife_exec_arm + name = "arm" + icon = 'icons/mob/human/bodyparts_greyscale.dmi' + icon_state = "" + plane = GAME_PLANE + layer = HV_VIS_KNIFE_HAND_LAYER + appearance_flags = KEEP_TOGETHER + randomdir = FALSE + duration = 25 + +/obj/effect/temp_visual/hv_knife_exec_arm/Initialize(mapload, mob/living/attacker, arm_zone = BODY_ZONE_R_ARM, row_x = 0, row_y = 0, fist_w = 0, fist_z = 0, shoulder_w = 0, shoulder_z = 8, draw_layer = HV_VIS_KNIFE_HAND_LAYER, life = 25) + if(life > 0) + duration = life + . = ..() + layer = draw_layer + pixel_x = row_x + pixel_y = row_y + pixel_w = fist_w + pixel_z = fist_z + hv_build_limb_overlays(attacker, arm_zone) + transform = hv_aim_arm_matrix(fist_w, fist_z, shoulder_w, shoulder_z) + +/// Copies the attacker's real arm and hand overlays shifted so the fist sits at (0, 0) and the forearm runs +y. +/obj/effect/temp_visual/hv_knife_exec_arm/proc/hv_build_limb_overlays(mob/living/attacker, arm_zone) + if(!iscarbon(attacker)) + return + var/mob/living/carbon/carbon_attacker = attacker + var/obj/item/bodypart/arm = carbon_attacker.get_bodypart(arm_zone) + if(!arm) + return + var/shift_x = (arm.body_zone == BODY_ZONE_R_ARM) ? 6 : -6 + var/shift_y = 2 + var/list/limb_layers = arm.get_limb_icon(dropped = FALSE, update_on = carbon_attacker) + for(var/entry in limb_layers) + if(!entry) + continue + var/mutable_appearance/part = new(entry) + part.plane = FLOAT_PLANE + part.layer = FLOAT_LAYER + part.dir = SOUTH + part.pixel_w += shift_x + part.pixel_z += shift_y + add_overlay(part) + +/// Rotates the forearm around the fist at (0, 0) so its shoulder end points back toward (shoulder_w, shoulder_z). +/obj/effect/temp_visual/hv_knife_exec_arm/proc/hv_aim_arm_matrix(fist_w, fist_z, shoulder_w, shoulder_z) + var/dx = shoulder_w - fist_w + var/dy = shoulder_z - fist_z + var/matrix/aimed = matrix() + if(dx || dy) + // Forearm art runs straight +y (NORTH, 90 deg CCW from EAST) from the fist at (0, 0). + aimed.Turn(90 - ATAN2(dx, dy)) + return aimed + +/// Animates this forearm's fist to `(target_w, target_z)` while aiming its shoulder back toward `(shoulder_w, shoulder_z)`. +/obj/effect/temp_visual/hv_knife_exec_arm/proc/hv_animate_to(target_w, target_z, shoulder_w, shoulder_z, step_time, step_easing = LINEAR_EASING) + var/matrix/aimed = hv_aim_arm_matrix(target_w, target_z, shoulder_w, shoulder_z) + animate(src, pixel_w = target_w, pixel_z = target_z, transform = aimed, time = step_time, easing = step_easing) + +/// Animates the arm through Beat 3's cut + hold and Beat 4's retraction back to the attacker's hand, then deletes it. +/obj/effect/temp_visual/hv_knife_exec_arm/proc/hv_animate_cut_and_retract(cut_w, cut_z, shoulder_in_w, shoulder_in_z, home_w, home_z, shoulder_home_w, shoulder_home_z) + var/matrix/cut_aim = hv_aim_arm_matrix(cut_w, cut_z, shoulder_in_w, shoulder_in_z) + var/matrix/home_aim = hv_aim_arm_matrix(home_w, home_z, shoulder_home_w, shoulder_home_z) + animate(src, pixel_w = cut_w, pixel_z = cut_z, transform = cut_aim, time = HV_VIS_KNIFE_CUT_TIME, easing = QUAD_EASING|EASE_OUT) + animate(pixel_w = cut_w, pixel_z = cut_z, transform = cut_aim, time = HV_VIS_KNIFE_CUT_HOLD, easing = LINEAR_EASING) + animate(pixel_w = home_w, pixel_z = home_z, transform = home_aim, time = HV_VIS_KNIFE_RELEASE_TIME, easing = SINE_EASING, alpha = 0) + QDEL_IN(src, HV_VIS_KNIFE_CUT_TIME + HV_VIS_KNIFE_CUT_HOLD + HV_VIS_KNIFE_RELEASE_TIME) + +/// On-body jet of blood spurting directly out of the victim's drawn throat in the direction they face. +/obj/effect/temp_visual/hv_throat_spurt + name = "arterial spray" + icon = HV_BLOOD_SPRAY_ICON + icon_state = "squirt_greyscale" + plane = GAME_PLANE + layer = ABOVE_MOB_LAYER + randomdir = FALSE + duration = 4 + +/obj/effect/temp_visual/hv_throat_spurt/Initialize(mapload, row_x = 0, row_y = 0, throat_w = 0, throat_z = 0, spray_dir = SOUTH, draw_layer = ABOVE_MOB_LAYER, blood_color = BLOOD_COLOR_RED, strength = 3) + . = ..() + setDir(spray_dir || SOUTH) + layer = draw_layer + color = blood_color + pixel_x = row_x + pixel_y = row_y + pixel_w = throat_w + pixel_z = throat_z + + var/dx = HV_VIS_DX(dir) + var/dy = HV_VIS_DY(dir) + var/reach = 8 + strength * 3 + var/matrix/start = matrix() + start.Scale(0.28, 0.28) + transform = start + + var/matrix/end_mat = matrix() + end_mat.Scale(0.55 + strength * 0.12, 0.55 + strength * 0.12) + animate( + src, + pixel_w = round(throat_w + dx * reach, 0.1), + pixel_z = round(throat_z + dy * reach, 0.1), + transform = end_mat, + alpha = 0, + time = duration, + easing = QUAD_EASING|EASE_OUT, + ) diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index 575880487b0..c23a8e6898a 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -96,6 +96,7 @@ #include "voidcrew_human_npcs_ruins.dm" #include "voidcrew_human_npcs_shared.dm" #include "voidcrew_hv_finishers.dm" +#include "voidcrew_hv_knife_executions.dm" #include "voidcrew_hyperviolence_blood.dm" #include "voidcrew_hyperviolence_braingut.dm" #include "voidcrew_hyperviolence_crits.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_hv_knife_executions.dm b/voidcrew/modules/unit_tests/voidcrew_hv_knife_executions.dm new file mode 100644 index 00000000000..7eee5a1be49 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_hv_knife_executions.dm @@ -0,0 +1,151 @@ +// Knife executions (voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm). Unit tests are included before +// voidcrew/_DEFINES, so these use the module's procs and plain numbers, never its HV_* defines. + +/// Puts `attacker` on the tile west of `victim`'s tile, a combat knife in hand, aiming at the head. +/datum/unit_test/proc/hv_knife_exec_setup(mob/living/carbon/human/attacker, mob/living/carbon/human/victim) + var/turf/east = get_step(attacker, EAST) + victim.forceMove(east) + var/obj/item/knife/combat/knife = allocate(/obj/item/knife/combat) + attacker.put_in_active_hand(knife, forced = TRUE) + attacker.set_combat_mode(TRUE) + attacker.zone_selected = BODY_ZONE_HEAD + attacker.setDir(EAST) + return knife + +/// The slash wound on the head at `severity` or worse, if any. +/proc/hv_knife_exec_test_slash(mob/living/carbon/victim, severity) + var/obj/item/bodypart/head/head = victim.get_bodypart(BODY_ZONE_HEAD) + for(var/datum/wound/slash/cut in head?.wounds) + if(cut.severity >= severity) + return cut + return null + +/// From behind on anyone; from the front only on the helpless. +/datum/unit_test/hv_knife_execution_trigger + +/datum/unit_test/hv_knife_execution_trigger/Run() + var/mob/living/carbon/human/consistent/attacker = allocate(/mob/living/carbon/human/consistent) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent) + var/obj/item/knife/combat/knife = hv_knife_exec_setup(attacker, victim) + + victim.setDir(EAST) // back to the attacker + TEST_ASSERT(knife.hv_knife_execution_possible(attacker, victim), "A knife from behind could not start an execution") + victim.setDir(WEST) // facing him + TEST_ASSERT(!knife.hv_knife_execution_possible(attacker, victim), "A knife from the front started an execution on an aware, standing target") + attacker.zone_selected = BODY_ZONE_CHEST + victim.setDir(EAST) + TEST_ASSERT(!knife.hv_knife_execution_possible(attacker, victim), "A chest-aimed knife started an execution") + attacker.zone_selected = BODY_ZONE_PRECISE_MOUTH + TEST_ASSERT(knife.hv_knife_execution_possible(attacker, victim), "A mouth-aimed knife from behind could not start an execution") + attacker.set_combat_mode(FALSE) + TEST_ASSERT(!knife.hv_knife_execution_possible(attacker, victim), "A knife out of combat mode started an execution") + attacker.set_combat_mode(TRUE) + TEST_ASSERT(!knife.hv_knife_execution_possible(attacker, attacker), "The attacker could execute himself") + + victim.setDir(WEST) + victim.Knockdown(30 SECONDS) + TEST_ASSERT(knife.hv_knife_execution_possible(attacker, victim), "A helpless target could not be executed from the front") + + var/obj/item/knife/plastic/spork = allocate(/obj/item/knife/plastic) + if(!(spork.get_sharpness() & SHARP_EDGED) || spork.force <= 0) + TEST_ASSERT(!spork.hv_knife_execution_possible(attacker, victim), "A blunt plastic knife started an execution") + +/// A held wind-up from behind ends in tg's real throat slit plus a boosted stab to the head. +/datum/unit_test/hv_knife_execution_kill + +/datum/unit_test/hv_knife_execution_kill/Run() + var/mob/living/carbon/human/consistent/attacker = allocate(/mob/living/carbon/human/consistent) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent) + var/obj/item/knife/combat/knife = hv_knife_exec_setup(attacker, victim) + victim.setDir(EAST) + + knife.melee_attack_chain(attacker, victim, list()) + TEST_ASSERT(DOING_INTERACTION(attacker, "hv_knife_execution"), "The knife click did not start the wind-up") + var/obj/item/bodypart/head/head = victim.get_bodypart(BODY_ZONE_HEAD) + TEST_ASSERT_EQUAL(head.brute_dam, 0, "The knife click hurt the victim before the wind-up ended") + sleep(2.5 SECONDS) + TEST_ASSERT(!DOING_INTERACTION(attacker, "hv_knife_execution"), "The wind-up never ended") + TEST_ASSERT(victim.has_status_effect(/datum/status_effect/neck_slice), "An unarmoured victim's neck was not sliced") + TEST_ASSERT_NOTNULL(hv_knife_exec_test_slash(victim, WOUND_SEVERITY_CRITICAL), "An unarmoured victim got no critical slash on the head") + TEST_ASSERT(head.brute_dam >= knife.force * 1.5, "The stab was not boosted ([head.brute_dam] head brute from a [knife.force] force knife)") + TEST_ASSERT_EQUAL(attacker.pixel_w, 0, "The attacker was left offset after the move") + TEST_ASSERT_EQUAL(attacker.pixel_z, 0, "The attacker was left offset after the move") + +/// Turning to face the attacker breaks the wind-up: no cut, no damage. +/datum/unit_test/hv_knife_execution_break + +/datum/unit_test/hv_knife_execution_break/Run() + var/mob/living/carbon/human/consistent/attacker = allocate(/mob/living/carbon/human/consistent) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent) + var/obj/item/knife/combat/knife = hv_knife_exec_setup(attacker, victim) + victim.setDir(EAST) + + knife.melee_attack_chain(attacker, victim, list()) + TEST_ASSERT(DOING_INTERACTION(attacker, "hv_knife_execution"), "The knife click did not start the wind-up") + sleep(0.5 SECONDS) + victim.setDir(WEST) + sleep(2 SECONDS) + TEST_ASSERT(!DOING_INTERACTION(attacker, "hv_knife_execution"), "The wind-up did not stop") + TEST_ASSERT(!victim.has_status_effect(/datum/status_effect/neck_slice), "A broken wind-up still sliced the neck") + TEST_ASSERT_NULL(hv_knife_exec_test_slash(victim, WOUND_SEVERITY_MODERATE), "A broken wind-up still cut the throat") + var/obj/item/bodypart/head/head = victim.get_bodypart(BODY_ZONE_HEAD) + TEST_ASSERT_EQUAL(head.brute_dam, 0, "A broken wind-up still hurt the head") + TEST_ASSERT_EQUAL(attacker.pixel_w, 0, "The attacker was left offset after a broken wind-up") + TEST_ASSERT_EQUAL(victim.pixel_w, 0, "The victim was left offset after a broken wind-up") + + // Walking away breaks it too. + victim.setDir(EAST) + knife.melee_attack_chain(attacker, victim, list()) + TEST_ASSERT(DOING_INTERACTION(attacker, "hv_knife_execution"), "The second knife click did not start the wind-up") + sleep(0.5 SECONDS) + victim.forceMove(get_step(victim, EAST)) + sleep(2 SECONDS) + TEST_ASSERT(!victim.has_status_effect(/datum/status_effect/neck_slice), "Stepping away did not break the wind-up") + +/// A helmet, and dermal plating under the skin, weaken the result. +/datum/unit_test/hv_knife_execution_armour + +/datum/unit_test/hv_knife_execution_armour/Run() + var/mob/living/carbon/human/consistent/attacker = allocate(/mob/living/carbon/human/consistent) + var/mob/living/carbon/human/consistent/bare = allocate(/mob/living/carbon/human/consistent) + var/obj/item/knife/combat/knife = hv_knife_exec_setup(attacker, bare) + bare.setDir(EAST) + TEST_ASSERT(knife.hv_finish_knife_execution(attacker, bare, list(), list()), "The bare execution did not land") + var/bare_brute = bare.get_bodypart(BODY_ZONE_HEAD).brute_dam + + var/mob/living/carbon/human/consistent/helmeted = allocate(/mob/living/carbon/human/consistent) + helmeted.equip_to_slot_or_del(allocate(/obj/item/clothing/head/helmet/sec), ITEM_SLOT_HEAD) + bare.forceMove(run_loc_floor_top_right) + helmeted.forceMove(get_step(attacker, EAST)) + helmeted.setDir(EAST) + TEST_ASSERT(knife.hv_finish_knife_execution(attacker, helmeted, list(), list()), "The helmeted execution did not land") + var/helmet_brute = helmeted.get_bodypart(BODY_ZONE_HEAD).brute_dam + TEST_ASSERT(helmet_brute < bare_brute, "A helmet did not weaken the stab ([helmet_brute] vs [bare_brute])") + TEST_ASSERT(!helmeted.has_status_effect(/datum/status_effect/neck_slice), "A helmet did not keep the neck from being sliced") + TEST_ASSERT_NULL(hv_knife_exec_test_slash(helmeted, WOUND_SEVERITY_CRITICAL), "A helmet did not soften the throat slash") + + var/mob/living/carbon/human/consistent/plated = allocate(/mob/living/carbon/human/consistent) + plated.physiology.armor = plated.physiology.armor.generate_new_with_modifiers(list(MELEE = 30)) + helmeted.forceMove(run_loc_floor_top_right) + plated.forceMove(get_step(attacker, EAST)) + plated.setDir(EAST) + TEST_ASSERT(knife.hv_finish_knife_execution(attacker, plated, list(), list()), "The plated execution did not land") + var/plated_brute = plated.get_bodypart(BODY_ZONE_HEAD).brute_dam + TEST_ASSERT(plated_brute < bare_brute, "Plating under the skin did not weaken the stab ([plated_brute] vs [bare_brute])") + TEST_ASSERT(!plated.has_status_effect(/datum/status_effect/neck_slice), "Plating under the skin did not keep the neck from being sliced") + +/// Human NPCs below boss rank never execute; bosses and players do. +/datum/unit_test/hv_knife_execution_npc_rank + +/datum/unit_test/hv_knife_execution_npc_rank/Run() + var/mob/living/carbon/human/npc/npc = allocate(/mob/living/carbon/human/npc) + QDEL_NULL(npc.ai_controller) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent) + var/obj/item/knife/combat/knife = hv_knife_exec_setup(npc, victim) + victim.setDir(EAST) + TEST_ASSERT(!npc.hv_can_execute(), "Test fixture: a regular NPC can execute") + TEST_ASSERT(!knife.hv_knife_execution_possible(npc, victim), "A regular human NPC started a knife execution") + knife.melee_attack_chain(npc, victim, list()) + TEST_ASSERT(!DOING_INTERACTION(npc, "hv_knife_execution"), "A regular human NPC's knife click started the wind-up") + npc.npc_rank = 2 // HUMAN_NPC_RANK_BOSS + TEST_ASSERT(knife.hv_knife_execution_possible(npc, victim), "A boss NPC could not start a knife execution") From 8fbb83b0fe5a17a69b9196a9a9117304267e74f1 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Thu, 12 Nov 2026 21:41:35 -0800 Subject: [PATCH 45/78] Knife executions: a knife-sized blade held in the hand, hidden behind a north-facing victim, a forward throat spray --- .../overlays_exec/knife_executions.dm | 7 +- .../modules/hyperviolence/visuals/_defines.dm | 30 +- .../visuals/knife_execution_motion.dm | 502 ++++++++++-------- 3 files changed, 283 insertions(+), 256 deletions(-) diff --git a/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm b/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm index 66b7b13f90f..831583dfbe4 100644 --- a/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm +++ b/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm @@ -70,6 +70,7 @@ victim, extra_checks = CALLBACK(src, PROC_REF(hv_knife_execution_holds), user, victim), interaction_key = HV_KNIFE_EXECUTION_DOAFTER, + hidden = TRUE, // no cog over his head: the grab itself is what people see ) if(!held || QDELETED(src) || QDELETED(user) || QDELETED(victim)) return FALSE @@ -145,12 +146,12 @@ break if(has_critical_slash) victim.apply_status_effect(/datum/status_effect/neck_slice) - victim.hv_add_hit_line("[user] draws [src] across [victim]'s throat!", HV_LINE_HUGE, null, COMBAT_MESSAGE_RANGE) + victim.hv_add_hit_line("[user] cuts [victim]'s throat!", HV_LINE_HUGE, null, COMBAT_MESSAGE_RANGE) to_chat(victim, span_userdanger("Cold steel opens your throat!")) else if(wound_severity == WOUND_SEVERITY_SEVERE) - victim.hv_add_hit_line("[src] cuts deep into [victim]'s neck, turned short of the artery!", HV_LINE_BOLD, null, COMBAT_MESSAGE_RANGE) + victim.hv_add_hit_line("[user] slashes [victim]'s neck!", HV_LINE_BOLD, null, COMBAT_MESSAGE_RANGE) else - victim.hv_add_hit_line("[victim]'s protection turns the worst of [src] from [victim.p_their()] throat!", HV_LINE_BOLD, null, COMBAT_MESSAGE_RANGE) + victim.hv_add_hit_line("[src] skids off [victim]'s [(sealed_helmet ? "helmet" : "collar")].", HV_LINE_BOLD, null, COMBAT_MESSAGE_RANGE) log_combat(user, victim, "knife-executed", src, "([round(hv_knife_execution_head_damage, 0.1)] damage to the head, slash severity [wound_severity])") if(!QDELETED(victim)) diff --git a/voidcrew/modules/hyperviolence/visuals/_defines.dm b/voidcrew/modules/hyperviolence/visuals/_defines.dm index 29a93fa6f5e..0f85853193a 100644 --- a/voidcrew/modules/hyperviolence/visuals/_defines.dm +++ b/voidcrew/modules/hyperviolence/visuals/_defines.dm @@ -159,9 +159,9 @@ /// How long a standing survivor takes to pitch into a forward throat-clutch hunch after release. #define HV_VIS_KNIFE_HUNCH_IN (0.15 SECONDS) /// How long a standing survivor holds the forward throat-clutch hunch before returning upright. -#define HV_VIS_KNIFE_HUNCH_HOLD (0.2 SECONDS) +#define HV_VIS_KNIFE_HUNCH_HOLD (0.4 SECONDS) /// How long a standing survivor takes to return from the forward hunch to their true pose. -#define HV_VIS_KNIFE_HUNCH_OUT (0.25 SECONDS) +#define HV_VIS_KNIFE_HUNCH_OUT (0.3 SECONDS) /// Pixels the attacker steps toward the victim during a knife execution (under a third of a 32 px tile). #define HV_VIS_KNIFE_STEP_IN 9 /// Degrees a side-facing standing victim is tilted back toward the attacker about their feet. @@ -170,22 +170,16 @@ #define HV_VIS_KNIFE_TILT_FRONT 5 /// Degrees a lying victim is tugged toward the attacker during the wind-up. #define HV_VIS_KNIFE_TILT_LYING 4 -/// Degrees a standing survivor hunches forward after the throat is cut. -#define HV_VIS_KNIFE_HUNCH_TILT 8 -/// Pixels from the blade prop's centre back along its spine to the grip held in the attacker's hand. -#define HV_VIS_KNIFE_GRIP_BACK 6 -/// Pixels from the blade prop's centre forward along its edge to where the cut begins on the throat. -#define HV_VIS_KNIFE_CUT_START_REACH 2 -/// Pixels from the blade prop's centre forward along its edge to the tip/edge that ends on the throat. -#define HV_VIS_KNIFE_EDGE_REACH 8 -/// Layer for the grabbing far arm behind the victim (above BELOW_MOB_LAYER 3.7, below LYING_MOB_LAYER 3.8). -#define HV_VIS_KNIFE_FAR_ARM_LAYER 3.71 -/// Layer for the knife blade when occluded behind a north-facing victim's head and back. -#define HV_VIS_KNIFE_BEHIND_LAYER 3.72 -/// Layer for the knife hand when occluded behind a north-facing victim's head and back. -#define HV_VIS_KNIFE_BEHIND_HAND_LAYER 3.73 -/// Layer for the throat blood spurt when occluded behind a north-facing victim's neck. -#define HV_VIS_KNIFE_BEHIND_SPURT_LAYER 3.74 +/// Degrees a standing survivor hunches forward about their feet after the throat is cut. +#define HV_VIS_KNIFE_HUNCH_TILT 9 +/// Scale applied to a 32x32 diagonal knife sprite so the prop renders ~11 px long in a 32 px hand. +#define HV_VIS_KNIFE_SCALE 0.28 +/// Unscaled axial sprite coordinate (from 32x32 centre) of a knife's grip under the holder's fist. +#define HV_VIS_KNIFE_SPRITE_GRIP -9.5 +/// Unscaled axial sprite coordinate (from 32x32 centre) of the cutting edge heel where the draw begins. +#define HV_VIS_KNIFE_SPRITE_HEEL -2 +/// Unscaled axial sprite coordinate (from 32x32 centre) of the blade tip that finishes on the throat. +#define HV_VIS_KNIFE_SPRITE_TIP 12.5 /// Layer for the knife blade when visible in front of the victim's neck (above MOB_LAYER 4.0). #define HV_VIS_KNIFE_BLADE_LAYER 4.05 /// Layer for the attacker's knife hand in front of the blade grip and the victim's neck. diff --git a/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm b/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm index 08aa816946a..97bd4b64598 100644 --- a/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm +++ b/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm @@ -1,16 +1,20 @@ // Hyperviolence visuals: knife executions (overlays_exec/knife_executions.dm). // // Beats over the execution's own wind-up and kill (purely visual; every sequence ends where it began): -// 1. Wind-up grab (0 - 0.3 s): the attacker steps in toward the victim, the off-hand reaches to the -// crown of the head and tilts the victim back about their feet, and the knife hand brings the real -// knife's blade from that hand to the start of the throat cut, grip in the hand every frame. +// 1. Wind-up grab (0 - 0.3 s): the attacker steps in toward the victim, the victim's head tilts back +// about their feet, and for S/E/W facings a scaled (~11 px) blade prop and small skin-tinted hand +// prop move from the attacker's real knife hand to the start of the throat cut, grip under the hand +// every frame. When the victim faces NORTH the cut is hidden behind their head, so no blade or hand +// prop is drawn. // 2. Hold (0.3 - 1.5 s): the attacker stays pressed in while the victim trembles and then goes still. -// 3. The cut (1.5 - 1.75 s, held 0.1 s): the blade draws across the drawn throat with its sharp edge -// on the throat the whole way, ending with its edge/tip on the throat; blood spurts from the throat -// point and sprays along the floor in the direction the victim faces once the wound lands. -// 4. Release: the blade prop disappears, the attacker steps back to zero offset, and a survivor still -// on their feet hunches forward clutching their throat before returning; if the blow dropped them, -// tg's own fall and death_falls.dm take over. A broken wind-up releases everything cleanly, no blood. +// 3. The cut (1.5 - 1.75 s, held 0.1 s): the blade draws across the drawn throat from cutting-edge +// heel to tip, ending with the tip on the throat and the hand on the grip; a short jet spurts off +// the front of the neck (S/E/W) and a forward floor spray runs along the victim's facing once the +// wound lands. +// 4. Release: the blade and knife-hand props vanish together, the attacker steps back to zero offset, +// and a survivor still standing hunches 9 deg forward about their feet (0.15 s in, 0.4 s hold, +// 0.3 s out) while their own hand clutches their throat; if the blow dropped them, tg's own fall +// and death_falls.dm take over. A broken wind-up releases everything cleanly with no blood. /mob/living /// Suppresses tg's centre-body lunge and floating item flick during the execution's own head stab. @@ -29,6 +33,9 @@ var/hv_vis_knife_tilt = 0 /// Clockwise degrees this victim hunches forward after release when still standing. var/hv_vis_knife_hunch = 0 + /// Peak x/y pixel lurch of a standing survivor's hunch after release. + var/hv_vis_knife_lurch_x = 0 + var/hv_vis_knife_lurch_y = 0 /// Until this world.time, a victim felled by the cut is still drawn upright over tg's lying turn. var/hv_vis_knife_upright_until = -1 /// Copy of the standing base transform while held upright through the cut. @@ -37,10 +44,8 @@ /obj/item/knife /// Weakref to the active blade prop (/obj/effect/temp_visual/hv_knife_exec_blade) during a wind-up. var/datum/weakref/hv_vis_blade_ref - /// Weakref to the attacker's knife-hand forearm prop during a wind-up. + /// Weakref to the attacker's knife-hand prop (/obj/effect/temp_visual/hv_knife_exec_arm) during a wind-up. var/datum/weakref/hv_vis_knife_arm_ref - /// Weakref to the attacker's off-hand grabbing forearm prop during a wind-up. - var/datum/weakref/hv_vis_grab_arm_ref /// Whether the current execution completed its cut so hv_start_knife_execution skips broken cleanup. var/hv_vis_cut_landed = FALSE @@ -66,13 +71,14 @@ var/base_x = (victim.dir & EAST) ? 3 : ((victim.dir & WEST) ? -4 : 0) var/base_y = 6 var/angle = victim.hv_vis_knife_pose_angle() + var/list/lurch = victim.hv_vis_knife_pose_lurch() var/held_upright = victim.hv_vis_knife_pose_base && world.time < victim.hv_vis_knife_upright_until var/matrix/base = held_upright ? matrix(victim.hv_vis_knife_pose_base) : matrix(victim.transform) var/pivot = held_upright ? (HV_VIS_FEET_Y * victim.current_size) : victim.hv_vis_pivot() var/matrix/pose = hv_vis_turned(base, angle, pivot) return list( - round(pose.a * base_x + pose.b * base_y + pose.c, 0.1), - round(pose.d * base_x + pose.e * base_y + pose.f, 0.1), + round(pose.a * base_x + pose.b * base_y + pose.c + lurch[1], 0.1), + round(pose.d * base_x + pose.e * base_y + pose.f + lurch[2], 0.1), ) /// Current clockwise lean angle (degrees) our knife execution animation adds to this mob at world.time. @@ -96,6 +102,19 @@ return hv_vis_knife_hunch * (1 - (world.time - hold_end) / out_span) return 0 +/// Current list(dx, dy) lurch offset added by a standing survivor's forward hunch at world.time. +/mob/living/proc/hv_vis_knife_pose_lurch() + if(hv_vis_knife_t3 <= hv_vis_knife_t2 || world.time <= hv_vis_knife_t2 || world.time >= hv_vis_knife_t4) + return list(0, 0) + var/weight = 1 + if(world.time < hv_vis_knife_t3) + weight = (world.time - hv_vis_knife_t2) / max(hv_vis_knife_t3 - hv_vis_knife_t2, 1) + else + var/hold_end = min(hv_vis_knife_t3 + HV_VIS_KNIFE_HUNCH_HOLD, hv_vis_knife_t4) + if(world.time > hold_end) + weight = 1 - (world.time - hold_end) / max(hv_vis_knife_t4 - hold_end, 1) + return list(hv_vis_knife_lurch_x * weight, hv_vis_knife_lurch_y * weight) + /// Clears tracked knife execution pose timestamps on this mob. /mob/living/proc/hv_vis_knife_clear_pose() hv_vis_knife_t0 = -1 @@ -105,6 +124,8 @@ hv_vis_knife_t4 = -1 hv_vis_knife_tilt = 0 hv_vis_knife_hunch = 0 + hv_vis_knife_lurch_x = 0 + hv_vis_knife_lurch_y = 0 hv_vis_knife_upright_until = -1 hv_vis_knife_pose_base = null @@ -129,11 +150,20 @@ var/obj/item/bodypart/head/head_before = victim.get_bodypart(BODY_ZONE_HEAD) var/cover_before = head_before ? hv_crit_cover_rating(victim, head_before, MELEE, armour_penetration) : 100 + // Suppress hv_blood_on_damaged's 3-fan hit spray during the stab so we fire our own forward throat spray. + var/prev_spray_until = victim.hv_blood_spray_until + var/prev_spray_strength = victim.hv_blood_spray_strength + victim.hv_blood_spray_until = world.time + HV_BLOOD_SPRAY_WINDOW + victim.hv_blood_spray_strength = HV_BLOOD_MAX_RANGE + victim.hv_vis_execution_time = world.time user.hv_vis_knife_executing = TRUE . = ..() if(!QDELETED(user)) user.hv_vis_knife_executing = FALSE + if(!QDELETED(victim)) + victim.hv_blood_spray_until = prev_spray_until + victim.hv_blood_spray_strength = prev_spray_strength if(!.) return @@ -142,7 +172,7 @@ // ---- Wind-up, cut and release choreography ---- -/// Starts Beats 1 and 2: attacker step-in, victim head-pull + tremble, and blade + forearm props. +/// Starts Beats 1 and 2: attacker step-in, victim head-pull + tremble, and (for S/E/W) scaled blade + hand props. /obj/item/knife/proc/hv_vis_begin_knife_windup(mob/living/user, mob/living/carbon/victim) hv_vis_clear_exec_props() var/turf/victim_turf = get_turf(victim) @@ -151,7 +181,7 @@ var/cut_hold_total = HV_KNIFE_EXECUTION_WINDUP + HV_VIS_KNIFE_CUT_TIME + HV_VIS_KNIFE_CUT_HOLD var/toward = get_dir(user, victim) || user.dir || SOUTH - var/step_px = (HV_VIS_DX(toward) && HV_VIS_DY(toward)) ? round(HV_VIS_KNIFE_STEP_IN * 0.78) : HV_VIS_KNIFE_STEP_IN + var/step_px = (HV_VIS_DX(toward) && HV_VIS_DY(toward)) ? round(HV_VIS_KNIFE_STEP_IN * 0.78, 1) : HV_VIS_KNIFE_STEP_IN var/step_dx = HV_VIS_DX(toward) * step_px var/step_dy = HV_VIS_DY(toward) * step_px @@ -175,6 +205,8 @@ victim.hv_vis_knife_t4 = -1 victim.hv_vis_knife_tilt = tilt victim.hv_vis_knife_hunch = 0 + victim.hv_vis_knife_lurch_x = 0 + victim.hv_vis_knife_lurch_y = 0 victim.hv_vis_knife_upright_until = -1 victim.hv_vis_knife_pose_base = victim.body_position == STANDING_UP ? matrix(victim_base) : null @@ -185,89 +217,64 @@ )) victim.hv_vis_tremble(HV_KNIFE_EXECUTION_WINDUP - HV_VIS_PRESS_PAUSE, 1) - // Compute the throat target at the full wind-up tilt (t1..t2) so the blade lands on the tilted throat. + // Facing NORTH: the throat and reach are completely behind the victim's head and attacker's body. + if(victim.dir & NORTH) + return + + // Compute the throat target at full wind-up tilt (t1..t2) so the blade rests right on the tilted throat. var/list/tilted_throat = victim.hv_vis_throat_for_angle(tilt) var/throat_w = victim.pixel_w + tilted_throat[1] var/throat_z = victim.pixel_z + tilted_throat[2] var/knife_zone = user.get_hand_zone_of_item(src) || BODY_ZONE_R_ARM - var/grab_zone = (knife_zone == BODY_ZONE_R_ARM) ? BODY_ZONE_L_ARM : BODY_ZONE_R_ARM - - // Attacker's real hand and shoulder coordinates in the victim turf's pixel frame. var/list/knife_hand_start = hv_vis_hand_in_victim_frame(user, victim, knife_zone, 0, 0) - var/list/grab_hand_start = hv_vis_hand_in_victim_frame(user, victim, grab_zone, 0, 0) - var/list/knife_shoulder_in = hv_vis_shoulder_in_victim_frame(user, victim, knife_zone, step_dx, step_dy) - var/list/grab_shoulder_in = hv_vis_shoulder_in_victim_frame(user, victim, grab_zone, step_dx, step_dy) - var/blade_deg = hv_vis_knife_blade_angle(victim, knife_zone) - var/ux = cos(blade_deg) - var/uy = -sin(blade_deg) - - // Start of Beat 3: heel of the cutting edge rests on the tilted throat; grip sits in the knife hand. - var/cut_start_w = round(throat_w - HV_VIS_KNIFE_CUT_START_REACH * ux, 0.1) - var/cut_start_z = round(throat_z - HV_VIS_KNIFE_CUT_START_REACH * uy, 0.1) - var/fist_in_w = round(cut_start_w - HV_VIS_KNIFE_GRIP_BACK * ux, 0.1) - var/fist_in_z = round(cut_start_z - HV_VIS_KNIFE_GRIP_BACK * uy, 0.1) - - var/north_occluded = (victim.dir & NORTH) != 0 - var/blade_layer = north_occluded ? HV_VIS_KNIFE_BEHIND_LAYER : HV_VIS_KNIFE_BLADE_LAYER - var/knife_arm_layer = north_occluded ? HV_VIS_KNIFE_BEHIND_HAND_LAYER : HV_VIS_KNIFE_HAND_LAYER - - // Spawn the blade at the exact hand holding the knife (grip == hand0), then bring it to the throat. - var/start_blade_w = round(knife_hand_start[1] + HV_VIS_KNIFE_GRIP_BACK * ux, 0.1) - var/start_blade_z = round(knife_hand_start[2] + HV_VIS_KNIFE_GRIP_BACK * uy, 0.1) + var/obj/effect/temp_visual/hv_knife_exec_blade/blade = new( victim_turf, src, victim.pixel_x, victim.pixel_y, - start_blade_w, - start_blade_z, + 0, + 0, blade_deg, - blade_layer, + HV_VIS_KNIFE_BLADE_LAYER, cut_hold_total + 1 SECONDS, ) + var/list/grip_off = blade.hv_point_offset(blade_deg, HV_VIS_KNIFE_SPRITE_GRIP) + var/list/heel_off = blade.hv_point_offset(blade_deg, HV_VIS_KNIFE_SPRITE_HEEL) + + // Start with the scaled knife's grip at the attacker's real knife hand, then bring the heel to the throat. + var/start_blade_w = round(knife_hand_start[1] - grip_off[1], 1) + var/start_blade_z = round(knife_hand_start[2] - grip_off[2], 1) + var/cut_start_w = round(throat_w - heel_off[1], 1) + var/cut_start_z = round(throat_z - heel_off[2], 1) + var/fist_start_w = round(start_blade_w + grip_off[1], 1) + var/fist_start_z = round(start_blade_z + grip_off[2], 1) + var/fist_in_w = round(cut_start_w + grip_off[1], 1) + var/fist_in_z = round(cut_start_z + grip_off[2], 1) + + blade.pixel_w = start_blade_w + blade.pixel_z = start_blade_z var/matrix/blade_turn = blade.hv_turn_matrix(blade_deg) animate(blade, pixel_w = cut_start_w, pixel_z = cut_start_z, transform = blade_turn, time = HV_VIS_KNIFE_GRAB_TIME, easing = QUAD_EASING|EASE_OUT) hv_vis_blade_ref = WEAKREF(blade) - // Spawn the knife-hand forearm prop starting at that same hand and tracking the blade's grip. + // Small skin-tinted hand prop centred on the fist, locked onto the scaled knife's grip every frame. var/obj/effect/temp_visual/hv_knife_exec_arm/knife_arm = new( victim_turf, user, knife_zone, victim.pixel_x, victim.pixel_y, - knife_hand_start[1], - knife_hand_start[2], - knife_shoulder_in[1], - knife_shoulder_in[2], - knife_arm_layer, + fist_start_w, + fist_start_z, + HV_VIS_KNIFE_HAND_LAYER, cut_hold_total + 1 SECONDS, ) - knife_arm.hv_animate_to(fist_in_w, fist_in_z, knife_shoulder_in[1], knife_shoulder_in[2], HV_VIS_KNIFE_GRAB_TIME, QUAD_EASING|EASE_OUT) + animate(knife_arm, pixel_w = fist_in_w, pixel_z = fist_in_z, time = HV_VIS_KNIFE_GRAB_TIME, easing = QUAD_EASING|EASE_OUT) hv_vis_knife_arm_ref = WEAKREF(knife_arm) - // Spawn the off-hand grabbing forearm prop behind the victim, reaching to the crown to pull the head back. - var/crown_shift_x = (victim.dir & EAST) ? -2 : ((victim.dir & WEST) ? 2 : ((grab_zone == BODY_ZONE_L_ARM) ? 2 : -2)) - var/crown_w = round(throat_w + crown_shift_x, 0.1) - var/crown_z = round(throat_z + 5, 0.1) - var/obj/effect/temp_visual/hv_knife_exec_arm/grab_arm = new( - victim_turf, - user, - grab_zone, - victim.pixel_x, - victim.pixel_y, - grab_hand_start[1], - grab_hand_start[2], - grab_shoulder_in[1], - grab_shoulder_in[2], - HV_VIS_KNIFE_FAR_ARM_LAYER, - cut_hold_total + 1 SECONDS, - ) - grab_arm.hv_animate_to(crown_w, crown_z, grab_shoulder_in[1], grab_shoulder_in[2], HV_VIS_KNIFE_GRAB_TIME, QUAD_EASING|EASE_OUT) - hv_vis_grab_arm_ref = WEAKREF(grab_arm) - /// Runs Beats 3 and 4 once the wind-up succeeded and the real stab + slash wound landed. /obj/item/knife/proc/hv_vis_play_knife_cut_and_release(mob/living/user, mob/living/carbon/victim, was_standing, pre_pixel_y, matrix/pre_base, sealed_before, cover_before) var/cut_total = HV_VIS_KNIFE_CUT_TIME + HV_VIS_KNIFE_CUT_HOLD @@ -305,97 +312,59 @@ var/row_pixel_y = (fell_now && victim.hv_vis_can_hold_fall()) ? pre_pixel_y : victim.pixel_y var/knife_zone = (!QDELETED(user) && user.get_hand_zone_of_item(src)) || BODY_ZONE_R_ARM - var/grab_zone = (knife_zone == BODY_ZONE_R_ARM) ? BODY_ZONE_L_ARM : BODY_ZONE_R_ARM var/blade_deg = hv_vis_knife_blade_angle(victim, knife_zone) - var/ux = cos(blade_deg) - var/uy = -sin(blade_deg) - - // End of Beat 3: blade has drawn across the throat so its sharp edge/tip sits right on (throat_w, throat_z). - var/cut_end_w = round(throat_w - HV_VIS_KNIFE_EDGE_REACH * ux, 0.1) - var/cut_end_z = round(throat_z - HV_VIS_KNIFE_EDGE_REACH * uy, 0.1) - var/fist_end_w = round(cut_end_w - HV_VIS_KNIFE_GRIP_BACK * ux, 0.1) - var/fist_end_z = round(cut_end_z - HV_VIS_KNIFE_GRIP_BACK * uy, 0.1) var/toward = !QDELETED(user) ? (get_dir(user, victim) || user.dir || SOUTH) : SOUTH - var/step_px = (HV_VIS_DX(toward) && HV_VIS_DY(toward)) ? round(HV_VIS_KNIFE_STEP_IN * 0.78) : HV_VIS_KNIFE_STEP_IN + var/step_px = (HV_VIS_DX(toward) && HV_VIS_DY(toward)) ? round(HV_VIS_KNIFE_STEP_IN * 0.78, 1) : HV_VIS_KNIFE_STEP_IN var/step_dx = HV_VIS_DX(toward) * step_px var/step_dy = HV_VIS_DY(toward) * step_px var/obj/effect/temp_visual/hv_knife_exec_blade/blade = hv_vis_blade_ref?.resolve() + var/obj/effect/temp_visual/hv_knife_exec_arm/knife_arm = hv_vis_knife_arm_ref?.resolve() if(blade && !QDELETED(blade)) blade.pixel_y = row_pixel_y + var/list/tip_off = blade.hv_point_offset(blade_deg, HV_VIS_KNIFE_SPRITE_TIP) + var/list/grip_off = blade.hv_point_offset(blade_deg, HV_VIS_KNIFE_SPRITE_GRIP) + // End of Beat 3: blade draws across the throat so the tip lands on (throat_w, throat_z) and grip stays under the hand. + var/cut_end_w = round(throat_w - tip_off[1], 1) + var/cut_end_z = round(throat_z - tip_off[2], 1) + var/fist_end_w = round(cut_end_w + grip_off[1], 1) + var/fist_end_z = round(cut_end_z + grip_off[2], 1) var/matrix/blade_turn = blade.hv_turn_matrix(blade_deg) animate(blade, pixel_w = cut_end_w, pixel_z = cut_end_z, transform = blade_turn, time = HV_VIS_KNIFE_CUT_TIME, easing = QUAD_EASING|EASE_OUT) QDEL_IN(blade, cut_total) - - var/obj/effect/temp_visual/hv_knife_exec_arm/knife_arm = hv_vis_knife_arm_ref?.resolve() - if(knife_arm && !QDELETED(knife_arm) && !QDELETED(user)) - knife_arm.pixel_y = row_pixel_y - var/list/knife_shoulder_in = hv_vis_shoulder_in_victim_frame(user, victim, knife_zone, step_dx, step_dy) - var/list/knife_hand_home = hv_vis_hand_in_victim_frame(user, victim, knife_zone, 0, 0) - var/list/knife_shoulder_home = hv_vis_shoulder_in_victim_frame(user, victim, knife_zone, 0, 0) - knife_arm.hv_animate_cut_and_retract( - fist_end_w, - fist_end_z, - knife_shoulder_in[1], - knife_shoulder_in[2], - knife_hand_home[1], - knife_hand_home[2], - knife_shoulder_home[1], - knife_shoulder_home[2], - ) + if(knife_arm && !QDELETED(knife_arm)) + knife_arm.pixel_y = row_pixel_y + animate(knife_arm, pixel_w = fist_end_w, pixel_z = fist_end_z, time = HV_VIS_KNIFE_CUT_TIME, easing = QUAD_EASING|EASE_OUT) + QDEL_IN(knife_arm, cut_total) else if(knife_arm && !QDELETED(knife_arm)) - QDEL_IN(knife_arm, cut_total) - - var/obj/effect/temp_visual/hv_knife_exec_arm/grab_arm = hv_vis_grab_arm_ref?.resolve() - if(grab_arm && !QDELETED(grab_arm) && !QDELETED(user)) - grab_arm.pixel_y = row_pixel_y - var/list/grab_shoulder_in = hv_vis_shoulder_in_victim_frame(user, victim, grab_zone, step_dx, step_dy) - var/list/grab_hand_home = hv_vis_hand_in_victim_frame(user, victim, grab_zone, 0, 0) - var/list/grab_shoulder_home = hv_vis_shoulder_in_victim_frame(user, victim, grab_zone, 0, 0) - grab_arm.hv_animate_cut_and_retract( - grab_arm.pixel_w, - grab_arm.pixel_z, - grab_shoulder_in[1], - grab_shoulder_in[2], - grab_hand_home[1], - grab_hand_home[2], - grab_shoulder_home[1], - grab_shoulder_home[2], - ) - else if(grab_arm && !QDELETED(grab_arm)) - QDEL_IN(grab_arm, cut_total) + qdel(knife_arm) hv_vis_blade_ref = null hv_vis_knife_arm_ref = null - hv_vis_grab_arm_ref = null // Blood from the throat in the direction the victim faces, starting now as the wound lands. var/spray_dir = victim.dir || toward || SOUTH var/obj/item/bodypart/head/head_after = victim.get_bodypart(BODY_ZONE_HEAD) var/can_bleed_throat = (head_after ? head_after.can_bleed() : victim.can_bleed()) && !(sealed_before && cover_before >= HV_KNIFE_EXECUTION_HIGH_COVER) if(can_bleed_throat) - var/spray_tiles = 3 - if(sealed_before || cover_before >= HV_KNIFE_EXECUTION_HIGH_COVER) - spray_tiles = 1 - else if(cover_before >= HV_KNIFE_EXECUTION_LOW_COVER) - spray_tiles = 2 - // Allow the throat spray to fire in victim.dir even if the stab just triggered a hit-dir spray. + var/spray_tiles = (sealed_before || cover_before >= HV_KNIFE_EXECUTION_LOW_COVER) ? 1 : 2 victim.hv_blood_spray_until = 0 + victim.hv_blood_spray_strength = 0 victim.hv_blood_spray(spray_dir, spray_tiles) - var/spurt_layer = (victim.dir & NORTH) ? HV_VIS_KNIFE_BEHIND_SPURT_LAYER : ABOVE_MOB_LAYER - var/blood_color = get_color_from_blood_list(victim.get_blood_dna_list()) || BLOOD_COLOR_RED - new /obj/effect/temp_visual/hv_throat_spurt( - get_turf(victim), - victim.pixel_x, - row_pixel_y, - throat_w, - throat_z, - spray_dir, - spurt_layer, - blood_color, - spray_tiles, - ) + if(!(victim.dir & NORTH)) + var/blood_color = get_color_from_blood_list(victim.get_blood_dna_list()) || BLOOD_COLOR_RED + new /obj/effect/temp_visual/hv_throat_spurt( + get_turf(victim), + victim.pixel_x, + row_pixel_y, + throat_w, + throat_z, + spray_dir, + ABOVE_MOB_LAYER, + blood_color, + spray_tiles, + ) // Beat 4 release: attacker steps back to exact zero offset after the cut + hold. if(!QDELETED(user) && isturf(user.loc)) @@ -410,16 +379,19 @@ if(victim.stat != DEAD && victim.body_position == STANDING_UP) var/hunch_angle = victim.hv_vis_knife_hunch_tilt() var/lurch_dx = HV_VIS_DX(spray_dir) * 2 - var/lurch_dy = HV_VIS_DY(spray_dir) * 2 - 1 + var/lurch_dy = (victim.dir & SOUTH) ? -2 : ((victim.dir & (EAST|WEST)) ? -1 : 0) var/pivot = victim.hv_vis_pivot() var/matrix/base = matrix(victim.transform) var/matrix/tilted = hv_vis_turned(base, victim.hv_vis_knife_tilt, pivot) var/matrix/hunched = hv_vis_turned(base, hunch_angle, pivot) + var/hunch_total = cut_total + HV_VIS_KNIFE_HUNCH_IN + HV_VIS_KNIFE_HUNCH_HOLD + HV_VIS_KNIFE_HUNCH_OUT victim.hv_vis_knife_t2 = world.time + cut_total victim.hv_vis_knife_t3 = victim.hv_vis_knife_t2 + HV_VIS_KNIFE_HUNCH_IN victim.hv_vis_knife_t4 = victim.hv_vis_knife_t3 + HV_VIS_KNIFE_HUNCH_HOLD + HV_VIS_KNIFE_HUNCH_OUT victim.hv_vis_knife_hunch = hunch_angle + victim.hv_vis_knife_lurch_x = lurch_dx + victim.hv_vis_knife_lurch_y = lurch_dy victim.hv_vis_play(HV_VIS_TAG_KNIFE_VICTIM, list( list(victim.pixel_w, victim.pixel_z, tilted, cut_total, LINEAR_EASING), @@ -427,9 +399,14 @@ list(victim.pixel_w + lurch_dx, victim.pixel_z + lurch_dy, hunched, HV_VIS_KNIFE_HUNCH_HOLD, LINEAR_EASING), list(victim.pixel_w, victim.pixel_z, base, HV_VIS_KNIFE_HUNCH_OUT, SINE_EASING), )) + victim.hv_vis_hold(list(HV_VIS_TAG_KNIFE_VICTIM), HV_VIS_END_LIE|HV_VIS_END_DEATH, hunch_total) + if(!(victim.dir & NORTH)) + addtimer(CALLBACK(victim, TYPE_PROC_REF(/mob/living/carbon, hv_vis_spawn_clutch_hand), hunch_angle, lurch_dx, lurch_dy), cut_total, TIMER_DELETE_ME) else if(!fell_now) victim.hv_vis_knife_t2 = world.time + cut_total victim.hv_vis_knife_hunch = 0 + victim.hv_vis_knife_lurch_x = 0 + victim.hv_vis_knife_lurch_y = 0 var/matrix/base_lying = matrix(victim.transform) var/matrix/tilted_lying = hv_vis_turned(base_lying, victim.hv_vis_knife_tilt, victim.hv_vis_pivot()) victim.hv_vis_play(HV_VIS_TAG_KNIFE_VICTIM, list( @@ -437,6 +414,37 @@ list(victim.pixel_w, victim.pixel_z, base_lying, HV_VIS_KNIFE_RELEASE_TIME, SINE_EASING), )) +/// Spawns a small prop of this standing victim's own visible hand reaching up to clutch their throat during Beat 4. +/mob/living/carbon/proc/hv_vis_spawn_clutch_hand(hunch_angle, lurch_dx = 0, lurch_dy = 0) + if(QDELETED(src) || stat == DEAD || body_position != STANDING_UP || (dir & NORTH) || !isturf(loc)) + return + var/preferred_zone = (dir & WEST) ? BODY_ZONE_L_ARM : BODY_ZONE_R_ARM + var/fallback_zone = (preferred_zone == BODY_ZONE_R_ARM) ? BODY_ZONE_L_ARM : BODY_ZONE_R_ARM + var/clutch_zone = get_bodypart(preferred_zone) ? preferred_zone : (get_bodypart(fallback_zone) ? fallback_zone : null) + if(!clutch_zone) + return + var/list/local_hand = hv_vis_local_hand_offset(src, clutch_zone) + var/start_w = pixel_w + local_hand[1] + var/start_z = pixel_z + local_hand[2] + var/list/hunched_throat = hv_vis_throat_for_angle(hunch_angle) + var/clutch_w = round(pixel_w + lurch_dx + hunched_throat[1], 1) + var/clutch_z = round(pixel_z + lurch_dy + hunched_throat[2], 1) + var/total_life = HV_VIS_KNIFE_HUNCH_IN + HV_VIS_KNIFE_HUNCH_HOLD + HV_VIS_KNIFE_HUNCH_OUT + var/obj/effect/temp_visual/hv_knife_clutch_hand/clutch = new( + get_turf(src), + src, + clutch_zone, + pixel_x, + pixel_y, + start_w, + start_z, + ABOVE_MOB_LAYER, + total_life, + ) + animate(clutch, pixel_w = clutch_w, pixel_z = clutch_z, time = HV_VIS_KNIFE_HUNCH_IN, easing = QUAD_EASING|EASE_OUT) + animate(pixel_w = clutch_w, pixel_z = clutch_z, time = HV_VIS_KNIFE_HUNCH_HOLD, easing = LINEAR_EASING) + animate(pixel_w = start_w, pixel_z = start_z, time = HV_VIS_KNIFE_HUNCH_OUT, easing = SINE_EASING) + /// Beat 5: wind-up broke early; ease both bodies straight back to their exact starting poses with no blood. /obj/item/knife/proc/hv_vis_abort_knife_windup(mob/living/user, mob/living/carbon/victim) hv_vis_clear_exec_props() @@ -458,12 +466,8 @@ var/atom/knife_arm = hv_vis_knife_arm_ref?.resolve() if(knife_arm && !QDELETED(knife_arm)) qdel(knife_arm) - var/atom/grab_arm = hv_vis_grab_arm_ref?.resolve() - if(grab_arm && !QDELETED(grab_arm)) - qdel(grab_arm) hv_vis_blade_ref = null hv_vis_knife_arm_ref = null - hv_vis_grab_arm_ref = null // ---- Geometry helpers ---- @@ -491,65 +495,80 @@ return back_dx * HV_VIS_KNIFE_TILT_FRONT return (dir & NORTH) ? HV_VIS_KNIFE_TILT_FRONT : -HV_VIS_KNIFE_TILT_FRONT -/// Clockwise tilt angle (degrees) for a standing survivor hunching forward after release. +/// Clockwise tilt angle (degrees) for a standing survivor hunching forward about their feet after release. /mob/living/proc/hv_vis_knife_hunch_tilt() if(dir & EAST) return HV_VIS_KNIFE_HUNCH_TILT if(dir & WEST) return -HV_VIS_KNIFE_HUNCH_TILT - return hv_vis_knife_tilt >= 0 ? -HV_VIS_KNIFE_HUNCH_TILT * 0.6 : HV_VIS_KNIFE_HUNCH_TILT * 0.6 + return hv_vis_knife_tilt >= 0 ? -HV_VIS_KNIFE_HUNCH_TILT : HV_VIS_KNIFE_HUNCH_TILT /// Clockwise angle from EAST (0 deg) along which the knife blade points while crossing `victim`'s throat. /proc/hv_vis_knife_blade_angle(mob/living/victim, knife_zone) if(victim.dir & EAST) - return -15 + return -10 if(victim.dir & WEST) - return 195 - if(victim.dir & NORTH) - return (knife_zone == BODY_ZONE_R_ARM) ? 180 : 0 + return 190 return (knife_zone == BODY_ZONE_R_ARM) ? 0 : 180 -/// Pixel offset list(x, y) of `arm_zone`'s hand from `holder`'s icon centre for `holder.dir`. +/// Pixel offset list(x, y) of `arm_zone`'s hand (rows 16-17 in bodyparts_greyscale.dmi) from `holder`'s icon centre. /proc/hv_vis_local_hand_offset(mob/living/holder, arm_zone) var/right_hand = (arm_zone == BODY_ZONE_R_ARM) switch(holder.dir) if(NORTH) - return list(right_hand ? 6 : -6, -2) + return list(right_hand ? 6 : -7, -1) if(EAST) - return list(right_hand ? 1 : 2, -2) + return list(right_hand ? -3 : 2, -1) if(WEST) - return list(right_hand ? -2 : -1, -2) - return list(right_hand ? -6 : 6, -2) - -/// Pixel offset list(x, y) of `arm_zone`'s shoulder from `holder`'s icon centre for `holder.dir`. -/proc/hv_vis_local_shoulder_offset(mob/living/holder, arm_zone) - var/right_hand = (arm_zone == BODY_ZONE_R_ARM) - switch(holder.dir) - if(NORTH) - return list(right_hand ? 6 : -6, 5) - if(EAST) - return list(right_hand ? -1 : 1, 5) - if(WEST) - return list(right_hand ? 1 : -1, 5) - return list(right_hand ? -6 : 6, 5) + return list(right_hand ? -3 : 3, -1) + return list(right_hand ? -7 : 6, -1) /// Converts `attacker`'s hand position (with optional extra step `step_dx`, `step_dy`) into `victim`'s turf pixel_w/pixel_z frame. /proc/hv_vis_hand_in_victim_frame(mob/living/attacker, mob/living/victim, arm_zone, step_dx = 0, step_dy = 0) var/list/local_hand = hv_vis_local_hand_offset(attacker, arm_zone) var/frame_x = (attacker.x - victim.x) * ICON_SIZE_X + (attacker.pixel_x - victim.pixel_x) + attacker.pixel_w + step_dx + local_hand[1] var/frame_y = (attacker.y - victim.y) * ICON_SIZE_Y + (attacker.pixel_y - victim.pixel_y) + attacker.pixel_z + step_dy + local_hand[2] - return list(round(frame_x, 0.1), round(frame_y, 0.1)) - -/// Converts `attacker`'s shoulder position (with optional extra step `step_dx`, `step_dy`) into `victim`'s turf pixel_w/pixel_z frame. -/proc/hv_vis_shoulder_in_victim_frame(mob/living/attacker, mob/living/victim, arm_zone, step_dx = 0, step_dy = 0) - var/list/local_shoulder = hv_vis_local_shoulder_offset(attacker, arm_zone) - var/frame_x = (attacker.x - victim.x) * ICON_SIZE_X + (attacker.pixel_x - victim.pixel_x) + attacker.pixel_w + step_dx + local_shoulder[1] - var/frame_y = (attacker.y - victim.y) * ICON_SIZE_Y + (attacker.pixel_y - victim.pixel_y) + attacker.pixel_z + step_dy + local_shoulder[2] - return list(round(frame_x, 0.1), round(frame_y, 0.1)) + return list(round(frame_x, 1), round(frame_y, 1)) + +/// Builds a small skin-tinted hand mutable_appearance from `holder`'s `arm_zone` shifted so its fist sits on (0, 0). +/proc/hv_vis_build_hand_overlay(mob/living/holder, arm_zone) + if(!iscarbon(holder)) + return null + var/mob/living/carbon/carbon_holder = holder + var/obj/item/bodypart/arm = carbon_holder.get_bodypart(arm_zone) + if(!arm) + return null + var/expected_hand_state = arm.aux_zone ? "[arm.limb_id]_[arm.aux_zone]" : null + var/image/chosen + var/image/fallback_limb + var/list/limb_layers = arm.get_limb_icon(dropped = FALSE, update_on = carbon_holder) + for(var/entry in limb_layers) + if(!istype(entry, /image)) + continue + var/image/img = entry + if(img.plane == EMISSIVE_PLANE) + continue + if(expected_hand_state && img.icon_state == expected_hand_state) + chosen = img + break + if(!fallback_limb && img.icon && img.icon_state) + fallback_limb = img + if(!chosen) + chosen = fallback_limb + if(!chosen) + return null + // In SOUTH, human_r_hand sits at cols 7-10 rows 16-17 (-7, -1) and human_l_hand at cols 20-23 rows 16-17 (+6, -1). + var/mutable_appearance/hand_overlay = mutable_appearance(chosen.icon, chosen.icon_state, FLOAT_LAYER) + hand_overlay.dir = SOUTH + hand_overlay.color = chosen.color + hand_overlay.alpha = chosen.alpha + hand_overlay.pixel_w = (arm.body_zone == BODY_ZONE_R_ARM) ? 7 : -6 + hand_overlay.pixel_z = 1 + return hand_overlay // ---- Visual props ---- -/// Temporary visual copy of the real knife blade drawn at the attacker's hand and across the throat. +/// Temporary visual copy of the real knife blade, scaled to ~11 px and drawn across the victim's throat. /obj/effect/temp_visual/hv_knife_exec_blade name = "knife blade" plane = GAME_PLANE @@ -580,15 +599,31 @@ pixel_z = start_z transform = hv_turn_matrix(blade_deg) -/// Matrix orienting this knife's blade along `blade_deg` clockwise from EAST, scaled small enough to read cleanly at the neck. +/// Matrix scaling this knife to ~11 px overall and orienting its blade along `blade_deg` clockwise from EAST. /obj/effect/temp_visual/hv_knife_exec_blade/proc/hv_turn_matrix(blade_deg) + var/axis_span = max(abs(cos(hv_native_icon_angle)), abs(sin(hv_native_icon_angle)), 0.7071) + var/blade_scale = HV_VIS_KNIFE_SCALE * (axis_span / 0.7071) var/matrix/turned = matrix() + turned.Scale(blade_scale, blade_scale) turned.Turn(blade_deg - hv_native_icon_angle) return turned -/// Temporary forearm + hand prop built from the attacker's real arm bodypart so skin tone and species match. +/// Pixel offset list(dx, dy) from this blade prop's centre for axial sprite point `along_px`, through `hv_turn_matrix`. +/obj/effect/temp_visual/hv_knife_exec_blade/proc/hv_point_offset(blade_deg, along_px) + var/nx = cos(hv_native_icon_angle) + var/ny = -sin(hv_native_icon_angle) + var/axis_span = max(abs(nx), abs(ny), 0.5) + var/local_x = along_px * nx / axis_span + var/local_y = along_px * ny / axis_span + var/matrix/turned = hv_turn_matrix(blade_deg) + return list( + turned.a * local_x + turned.b * local_y + turned.c, + turned.d * local_x + turned.e * local_y + turned.f, + ) + +/// Small skin-tinted hand prop built from the attacker's real arm bodypart, centred on the fist over the knife grip. /obj/effect/temp_visual/hv_knife_exec_arm - name = "arm" + name = "hand" icon = 'icons/mob/human/bodyparts_greyscale.dmi' icon_state = "" plane = GAME_PLANE @@ -597,7 +632,7 @@ randomdir = FALSE duration = 25 -/obj/effect/temp_visual/hv_knife_exec_arm/Initialize(mapload, mob/living/attacker, arm_zone = BODY_ZONE_R_ARM, row_x = 0, row_y = 0, fist_w = 0, fist_z = 0, shoulder_w = 0, shoulder_z = 8, draw_layer = HV_VIS_KNIFE_HAND_LAYER, life = 25) +/obj/effect/temp_visual/hv_knife_exec_arm/Initialize(mapload, mob/living/holder, arm_zone = BODY_ZONE_R_ARM, row_x = 0, row_y = 0, fist_w = 0, fist_z = 0, draw_layer = HV_VIS_KNIFE_HAND_LAYER, life = 25) if(life > 0) duration = life . = ..() @@ -606,56 +641,51 @@ pixel_y = row_y pixel_w = fist_w pixel_z = fist_z - hv_build_limb_overlays(attacker, arm_zone) - transform = hv_aim_arm_matrix(fist_w, fist_z, shoulder_w, shoulder_z) + var/mutable_appearance/hand_overlay = hv_vis_build_hand_overlay(holder, arm_zone) + if(hand_overlay) + add_overlay(hand_overlay) -/// Copies the attacker's real arm and hand overlays shifted so the fist sits at (0, 0) and the forearm runs +y. -/obj/effect/temp_visual/hv_knife_exec_arm/proc/hv_build_limb_overlays(mob/living/attacker, arm_zone) - if(!iscarbon(attacker)) - return - var/mob/living/carbon/carbon_attacker = attacker - var/obj/item/bodypart/arm = carbon_attacker.get_bodypart(arm_zone) - if(!arm) - return - var/shift_x = (arm.body_zone == BODY_ZONE_R_ARM) ? 6 : -6 - var/shift_y = 2 - var/list/limb_layers = arm.get_limb_icon(dropped = FALSE, update_on = carbon_attacker) - for(var/entry in limb_layers) - if(!entry) - continue - var/mutable_appearance/part = new(entry) - part.plane = FLOAT_PLANE - part.layer = FLOAT_LAYER - part.dir = SOUTH - part.pixel_w += shift_x - part.pixel_z += shift_y - add_overlay(part) - -/// Rotates the forearm around the fist at (0, 0) so its shoulder end points back toward (shoulder_w, shoulder_z). -/obj/effect/temp_visual/hv_knife_exec_arm/proc/hv_aim_arm_matrix(fist_w, fist_z, shoulder_w, shoulder_z) - var/dx = shoulder_w - fist_w - var/dy = shoulder_z - fist_z - var/matrix/aimed = matrix() - if(dx || dy) - // Forearm art runs straight +y (NORTH, 90 deg CCW from EAST) from the fist at (0, 0). - aimed.Turn(90 - ATAN2(dx, dy)) - return aimed - -/// Animates this forearm's fist to `(target_w, target_z)` while aiming its shoulder back toward `(shoulder_w, shoulder_z)`. -/obj/effect/temp_visual/hv_knife_exec_arm/proc/hv_animate_to(target_w, target_z, shoulder_w, shoulder_z, step_time, step_easing = LINEAR_EASING) - var/matrix/aimed = hv_aim_arm_matrix(target_w, target_z, shoulder_w, shoulder_z) - animate(src, pixel_w = target_w, pixel_z = target_z, transform = aimed, time = step_time, easing = step_easing) - -/// Animates the arm through Beat 3's cut + hold and Beat 4's retraction back to the attacker's hand, then deletes it. -/obj/effect/temp_visual/hv_knife_exec_arm/proc/hv_animate_cut_and_retract(cut_w, cut_z, shoulder_in_w, shoulder_in_z, home_w, home_z, shoulder_home_w, shoulder_home_z) - var/matrix/cut_aim = hv_aim_arm_matrix(cut_w, cut_z, shoulder_in_w, shoulder_in_z) - var/matrix/home_aim = hv_aim_arm_matrix(home_w, home_z, shoulder_home_w, shoulder_home_z) - animate(src, pixel_w = cut_w, pixel_z = cut_z, transform = cut_aim, time = HV_VIS_KNIFE_CUT_TIME, easing = QUAD_EASING|EASE_OUT) - animate(pixel_w = cut_w, pixel_z = cut_z, transform = cut_aim, time = HV_VIS_KNIFE_CUT_HOLD, easing = LINEAR_EASING) - animate(pixel_w = home_w, pixel_z = home_z, transform = home_aim, time = HV_VIS_KNIFE_RELEASE_TIME, easing = SINE_EASING, alpha = 0) - QDEL_IN(src, HV_VIS_KNIFE_CUT_TIME + HV_VIS_KNIFE_CUT_HOLD + HV_VIS_KNIFE_RELEASE_TIME) - -/// On-body jet of blood spurting directly out of the victim's drawn throat in the direction they face. +/// Small skin-tinted hand prop for a standing survivor clutching their own throat after release; vanishes early if they move or fall. +/obj/effect/temp_visual/hv_knife_clutch_hand + name = "hand" + icon = 'icons/mob/human/bodyparts_greyscale.dmi' + icon_state = "" + plane = GAME_PLANE + layer = ABOVE_MOB_LAYER + appearance_flags = KEEP_TOGETHER + randomdir = FALSE + duration = 9 + /// Weakref to the victim clutching their throat so signals clean up properly. + var/datum/weakref/hv_owner_ref + +/obj/effect/temp_visual/hv_knife_clutch_hand/Initialize(mapload, mob/living/victim, arm_zone = BODY_ZONE_R_ARM, row_x = 0, row_y = 0, fist_w = 0, fist_z = 0, draw_layer = ABOVE_MOB_LAYER, life = 9) + if(life > 0) + duration = life + . = ..() + layer = draw_layer + pixel_x = row_x + pixel_y = row_y + pixel_w = fist_w + pixel_z = fist_z + var/mutable_appearance/hand_overlay = hv_vis_build_hand_overlay(victim, arm_zone) + if(hand_overlay) + add_overlay(hand_overlay) + if(victim) + hv_owner_ref = WEAKREF(victim) + RegisterSignal(victim, list(COMSIG_MOVABLE_MOVED, COMSIG_LIVING_SET_BODY_POSITION, COMSIG_LIVING_DEATH), PROC_REF(hv_drop_clutch)) + +/obj/effect/temp_visual/hv_knife_clutch_hand/Destroy() + var/mob/living/victim = hv_owner_ref?.resolve() + if(victim) + UnregisterSignal(victim, list(COMSIG_MOVABLE_MOVED, COMSIG_LIVING_SET_BODY_POSITION, COMSIG_LIVING_DEATH)) + hv_owner_ref = null + return ..() + +/obj/effect/temp_visual/hv_knife_clutch_hand/proc/hv_drop_clutch(datum/source) + SIGNAL_HANDLER + qdel(src) + +/// Short on-body jet of blood spurting a few pixels off the front of the victim's neck (S, E, W only). /obj/effect/temp_visual/hv_throat_spurt name = "arterial spray" icon = HV_BLOOD_SPRAY_ICON @@ -665,29 +695,31 @@ randomdir = FALSE duration = 4 -/obj/effect/temp_visual/hv_throat_spurt/Initialize(mapload, row_x = 0, row_y = 0, throat_w = 0, throat_z = 0, spray_dir = SOUTH, draw_layer = ABOVE_MOB_LAYER, blood_color = BLOOD_COLOR_RED, strength = 3) +/obj/effect/temp_visual/hv_throat_spurt/Initialize(mapload, row_x = 0, row_y = 0, throat_w = 0, throat_z = 0, spray_dir = SOUTH, draw_layer = ABOVE_MOB_LAYER, blood_color = BLOOD_COLOR_RED, strength = 2) . = ..() setDir(spray_dir || SOUTH) layer = draw_layer color = blood_color pixel_x = row_x pixel_y = row_y - pixel_w = throat_w - pixel_z = throat_z var/dx = HV_VIS_DX(dir) var/dy = HV_VIS_DY(dir) - var/reach = 8 + strength * 3 + var/start_reach = 2 + var/end_reach = (dir & SOUTH) ? (2 + strength) : (3 + strength) + pixel_w = round(throat_w + dx * start_reach, 1) + pixel_z = round(throat_z + dy * start_reach, 1) + var/matrix/start = matrix() - start.Scale(0.28, 0.28) + start.Scale(0.14, 0.14) transform = start var/matrix/end_mat = matrix() - end_mat.Scale(0.55 + strength * 0.12, 0.55 + strength * 0.12) + end_mat.Scale(0.18 + strength * 0.03, 0.18 + strength * 0.03) animate( src, - pixel_w = round(throat_w + dx * reach, 0.1), - pixel_z = round(throat_z + dy * reach, 0.1), + pixel_w = round(throat_w + dx * end_reach, 1), + pixel_z = round(throat_z + dy * end_reach, 1), transform = end_mat, alpha = 0, time = duration, From 8b621c2b912212d03a2b98abf651a88369fa25d6 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Thu, 12 Nov 2026 22:38:06 -0800 Subject: [PATCH 46/78] Knife executions: the cut ends on the throat, a hidden wind-up, plainer lines --- .../overlays_exec/knife_executions.dm | 20 +- .../modules/hyperviolence/visuals/_defines.dm | 22 +- .../visuals/knife_execution_motion.dm | 225 +++++++++++------- 3 files changed, 163 insertions(+), 104 deletions(-) diff --git a/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm b/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm index 831583dfbe4..166512588e2 100644 --- a/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm +++ b/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm @@ -52,18 +52,18 @@ var/unseen = from_behind || victim.is_blind() || !(user in viewers(7, victim)) if(from_behind) user.visible_message( - span_danger("[user] grabs [victim] from behind and presses [src] to [victim.p_their()] throat!"), - span_danger("You grab [victim] from behind and press [src] to [victim.p_their()] throat!"), + span_danger("[user] grabs [victim] from behind and presses [src] to [victim.p_their()] throat."), + span_danger("You grab [victim] from behind and press [src] to [victim.p_their()] throat."), ignored_mobs = victim, ) - to_chat(victim, span_userdanger((unseen ? "Someone grabs you from behind and presses cold steel to your throat!" : "[user] grabs you from behind and presses [src] to your throat!"))) + to_chat(victim, span_userdanger((unseen ? "Someone grabs you from behind and presses a blade to your throat!" : "[user] grabs you from behind and presses [src] to your throat!"))) else user.visible_message( - span_danger("[user] grabs [victim]'s head and presses [src] to [victim.p_their()] throat!"), - span_danger("You grab [victim]'s head and press [src] to [victim.p_their()] throat!"), + span_danger("[user] grabs [victim]'s head and presses [src] to [victim.p_their()] throat."), + span_danger("You grab [victim]'s head and press [src] to [victim.p_their()] throat."), ignored_mobs = victim, ) - to_chat(victim, span_userdanger((unseen ? "Someone grabs your head and presses cold steel to your throat!" : "[user] grabs your head and presses [src] to your throat!"))) + to_chat(victim, span_userdanger((unseen ? "Someone grabs your head and presses a blade to your throat!" : "[user] grabs your head and presses [src] to your throat!"))) var/held = do_after( user, HV_KNIFE_EXECUTION_WINDUP, @@ -146,12 +146,12 @@ break if(has_critical_slash) victim.apply_status_effect(/datum/status_effect/neck_slice) - victim.hv_add_hit_line("[user] cuts [victim]'s throat!", HV_LINE_HUGE, null, COMBAT_MESSAGE_RANGE) - to_chat(victim, span_userdanger("Cold steel opens your throat!")) + victim.hv_add_hit_line("[user] cuts [victim]'s throat!", HV_LINE_HUGE, "[user] cuts your throat!", COMBAT_MESSAGE_RANGE) else if(wound_severity == WOUND_SEVERITY_SEVERE) - victim.hv_add_hit_line("[user] slashes [victim]'s neck!", HV_LINE_BOLD, null, COMBAT_MESSAGE_RANGE) + victim.hv_add_hit_line("[user] slashes [victim]'s neck!", HV_LINE_BOLD, "[user] slashes your neck!", COMBAT_MESSAGE_RANGE) else - victim.hv_add_hit_line("[src] skids off [victim]'s [(sealed_helmet ? "helmet" : "collar")].", HV_LINE_BOLD, null, COMBAT_MESSAGE_RANGE) + var/blocked_by = sealed_helmet ? "helmet" : "collar" + victim.hv_add_hit_line("[src] skids off [victim]'s [blocked_by].", HV_LINE_BOLD, "[src] skids off your [blocked_by].", COMBAT_MESSAGE_RANGE) log_combat(user, victim, "knife-executed", src, "([round(hv_knife_execution_head_damage, 0.1)] damage to the head, slash severity [wound_severity])") if(!QDELETED(victim)) diff --git a/voidcrew/modules/hyperviolence/visuals/_defines.dm b/voidcrew/modules/hyperviolence/visuals/_defines.dm index 0f85853193a..b129af884c1 100644 --- a/voidcrew/modules/hyperviolence/visuals/_defines.dm +++ b/voidcrew/modules/hyperviolence/visuals/_defines.dm @@ -154,8 +154,10 @@ #define HV_VIS_KNIFE_CUT_TIME (0.25 SECONDS) /// Brief hold at the end of the throat cut before the attacker lets go and the blade prop vanishes. #define HV_VIS_KNIFE_CUT_HOLD (0.1 SECONDS) -/// How long the attacker takes to step back to zero offset after the cut or a broken wind-up. +/// How long the attacker takes to step back to zero offset after the cut completes. #define HV_VIS_KNIFE_RELEASE_TIME (0.25 SECONDS) +/// How fast a broken wind-up eases both bodies back to their starting pose (under 0.3 s). +#define HV_VIS_KNIFE_ABORT_TIME (0.2 SECONDS) /// How long a standing survivor takes to pitch into a forward throat-clutch hunch after release. #define HV_VIS_KNIFE_HUNCH_IN (0.15 SECONDS) /// How long a standing survivor holds the forward throat-clutch hunch before returning upright. @@ -165,21 +167,23 @@ /// Pixels the attacker steps toward the victim during a knife execution (under a third of a 32 px tile). #define HV_VIS_KNIFE_STEP_IN 9 /// Degrees a side-facing standing victim is tilted back toward the attacker about their feet. -#define HV_VIS_KNIFE_TILT_SIDE 8 -/// Degrees a north- or south-facing standing victim's head is cocked back about their feet. -#define HV_VIS_KNIFE_TILT_FRONT 5 +#define HV_VIS_KNIFE_TILT_SIDE 2 +/// Degrees a north- or south-facing standing victim leans sideways during the wind-up (0 keeps throat centred). +#define HV_VIS_KNIFE_TILT_FRONT 0 /// Degrees a lying victim is tugged toward the attacker during the wind-up. -#define HV_VIS_KNIFE_TILT_LYING 4 +#define HV_VIS_KNIFE_TILT_LYING 2 /// Degrees a standing survivor hunches forward about their feet after the throat is cut. #define HV_VIS_KNIFE_HUNCH_TILT 9 -/// Scale applied to a 32x32 diagonal knife sprite so the prop renders ~11 px long in a 32 px hand. +/// Scale applied to a 32x32 diagonal knife sprite so the prop renders ~10 px long in a 32 px hand. #define HV_VIS_KNIFE_SCALE 0.28 /// Unscaled axial sprite coordinate (from 32x32 centre) of a knife's grip under the holder's fist. -#define HV_VIS_KNIFE_SPRITE_GRIP -9.5 -/// Unscaled axial sprite coordinate (from 32x32 centre) of the cutting edge heel where the draw begins. +#define HV_VIS_KNIFE_SPRITE_GRIP -8.75 +/// Unscaled axial sprite coordinate (from 32x32 centre) of the cutting edge heel where a front draw begins. #define HV_VIS_KNIFE_SPRITE_HEEL -2 +/// Unscaled axial sprite coordinate resting on a side-facing victim's throat while held (~1.6 px behind tip). +#define HV_VIS_KNIFE_SPRITE_SIDE_HOLD 8 /// Unscaled axial sprite coordinate (from 32x32 centre) of the blade tip that finishes on the throat. -#define HV_VIS_KNIFE_SPRITE_TIP 12.5 +#define HV_VIS_KNIFE_SPRITE_TIP 12 /// Layer for the knife blade when visible in front of the victim's neck (above MOB_LAYER 4.0). #define HV_VIS_KNIFE_BLADE_LAYER 4.05 /// Layer for the attacker's knife hand in front of the blade grip and the victim's neck. diff --git a/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm b/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm index 97bd4b64598..994c5ea5bb7 100644 --- a/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm +++ b/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm @@ -1,20 +1,21 @@ // Hyperviolence visuals: knife executions (overlays_exec/knife_executions.dm). // // Beats over the execution's own wind-up and kill (purely visual; every sequence ends where it began): -// 1. Wind-up grab (0 - 0.3 s): the attacker steps in toward the victim, the victim's head tilts back -// about their feet, and for S/E/W facings a scaled (~11 px) blade prop and small skin-tinted hand -// prop move from the attacker's real knife hand to the start of the throat cut, grip under the hand -// every frame. When the victim faces NORTH the cut is hidden behind their head, so no blade or hand -// prop is drawn. -// 2. Hold (0.3 - 1.5 s): the attacker stays pressed in while the victim trembles and then goes still. -// 3. The cut (1.5 - 1.75 s, held 0.1 s): the blade draws across the drawn throat from cutting-edge -// heel to tip, ending with the tip on the throat and the hand on the grip; a short jet spurts off -// the front of the neck (S/E/W) and a forward floor spray runs along the victim's facing once the -// wound lands. -// 4. Release: the blade and knife-hand props vanish together, the attacker steps back to zero offset, -// and a survivor still standing hunches 9 deg forward about their feet (0.15 s in, 0.4 s hold, -// 0.3 s out) while their own hand clutches their throat; if the blow dropped them, tg's own fall -// and death_falls.dm take over. A broken wind-up releases everything cleanly with no blood. +// 1. Wind-up grab (0 - 0.3 s): the attacker steps in toward the victim, a side-facing victim's head +// tilts back 2 deg about their feet, and for S/E/W facings a scaled (~10 px) blade prop and small +// skin-tinted hand prop move from the attacker's real knife hand to the throat, grip under the hand +// every frame. When a standing victim faces NORTH the cut is hidden behind their head, so no blade +// or hand prop is drawn. +// 2. Hold (0.3 - 1.5 s): attacker, victim, blade and hand hold steady together so the cutting edge +// stays locked on the drawn throat every frame. +// 3. The cut (1.5 - 1.75 s, held 0.1 s): the blade draws across the throat so the edge crosses the +// throat and the sharp tip finishes on the front of the throat with the hand on the grip; a short +// jet spurts off the front of the neck (S/E/W) and a forward floor spray runs along the victim's +// facing once the wound lands. +// 4. Release: the blade and knife-hand props vanish together, the attacker steps back to exact zero +// offset, and a survivor still standing hunches 9 deg forward about their feet (0.15 s in, 0.4 s +// hold, 0.3 s out) while their own hand clutches their throat; if the blow dropped them, tg's own +// fall and death_falls.dm take over. A broken wind-up releases everything in 0.2 s with no blood. /mob/living /// Suppresses tg's centre-body lunge and floating item flick during the execution's own head stab. @@ -59,7 +60,7 @@ return ..() /mob/living/carbon/hv_vis_on_death(gibbed) - if(world.time >= hv_vis_knife_t2) + if(hv_vis_knife_t0 >= 0) hv_vis_knife_clear_pose() hv_vis_stop(list(HV_VIS_TAG_KNIFE_VICTIM)) return ..() @@ -68,8 +69,8 @@ /proc/hv_knife_exec_throat_point(mob/living/victim) if(!isliving(victim)) return list(0, 0) - var/base_x = (victim.dir & EAST) ? 3 : ((victim.dir & WEST) ? -4 : 0) - var/base_y = 6 + var/base_x = (victim.dir & EAST) ? 3.5 : ((victim.dir & WEST) ? -3.5 : -0.5) + var/base_y = 5.5 var/angle = victim.hv_vis_knife_pose_angle() var/list/lurch = victim.hv_vis_knife_pose_lurch() var/held_upright = victim.hv_vis_knife_pose_base && world.time < victim.hv_vis_knife_upright_until @@ -77,8 +78,8 @@ var/pivot = held_upright ? (HV_VIS_FEET_Y * victim.current_size) : victim.hv_vis_pivot() var/matrix/pose = hv_vis_turned(base, angle, pivot) return list( - round(pose.a * base_x + pose.b * base_y + pose.c + lurch[1], 0.1), - round(pose.d * base_x + pose.e * base_y + pose.f + lurch[2], 0.1), + round(pose.a * base_x + pose.b * base_y + pose.c + lurch[1], 0.01), + round(pose.d * base_x + pose.e * base_y + pose.f + lurch[2], 0.01), ) /// Current clockwise lean angle (degrees) our knife execution animation adds to this mob at world.time. @@ -172,7 +173,7 @@ // ---- Wind-up, cut and release choreography ---- -/// Starts Beats 1 and 2: attacker step-in, victim head-pull + tremble, and (for S/E/W) scaled blade + hand props. +/// Starts Beats 1 and 2: attacker step-in, steady victim head-pull, and (for S/E/W) scaled blade + hand props. /obj/item/knife/proc/hv_vis_begin_knife_windup(mob/living/user, mob/living/carbon/victim) hv_vis_clear_exec_props() var/turf/victim_turf = get_turf(victim) @@ -185,6 +186,10 @@ var/step_dx = HV_VIS_DX(toward) * step_px var/step_dy = HV_VIS_DY(toward) * step_px + // Stop any prior sequence on these tags so nothing overlaps when the wind-up starts. + user.hv_vis_stop(list(HV_VIS_TAG_KNIFE_STEP)) + victim.hv_vis_stop(list(HV_VIS_TAG_KNIFE_VICTIM, HV_VIS_TAG_TREMBLE)) + // Attacker steps in behind the victim and stays pressed in until the cut releases. var/matrix/attacker_base = matrix(user.transform) var/matrix/attacker_lean = hv_vis_turned(attacker_base, HV_VIS_DX(toward) * 4, user.hv_vis_pivot()) @@ -194,7 +199,7 @@ list(user.pixel_w, user.pixel_z, attacker_base, HV_VIS_KNIFE_RELEASE_TIME, SINE_EASING), )) - // Victim is pulled back a few degrees about their feet and trembles until the press pause. + // Victim is pulled back about their feet and held steady so the blade edge stays on the throat every frame. var/tilt = victim.hv_vis_knife_windup_tilt(user) var/matrix/victim_base = matrix(victim.transform) var/matrix/victim_tilted = hv_vis_turned(victim_base, tilt, victim.hv_vis_pivot()) @@ -215,20 +220,20 @@ list(victim.pixel_w, victim.pixel_z, victim_tilted, cut_hold_total - HV_VIS_KNIFE_GRAB_TIME + 0.5 SECONDS, LINEAR_EASING), list(victim.pixel_w, victim.pixel_z, victim_base, HV_VIS_KNIFE_RELEASE_TIME, SINE_EASING), )) - victim.hv_vis_tremble(HV_KNIFE_EXECUTION_WINDUP - HV_VIS_PRESS_PAUSE, 1) - // Facing NORTH: the throat and reach are completely behind the victim's head and attacker's body. - if(victim.dir & NORTH) + // Standing victim facing NORTH: the throat and reach are completely behind the victim's head and attacker's body. + if((victim.dir & NORTH) && victim.body_position == STANDING_UP) return - // Compute the throat target at full wind-up tilt (t1..t2) so the blade rests right on the tilted throat. + // Compute the throat target at full wind-up tilt (t1..t2) so the blade edge rests right on the tilted throat. var/list/tilted_throat = victim.hv_vis_throat_for_angle(tilt) var/throat_w = victim.pixel_w + tilted_throat[1] var/throat_z = victim.pixel_z + tilted_throat[2] var/knife_zone = user.get_hand_zone_of_item(src) || BODY_ZONE_R_ARM var/list/knife_hand_start = hv_vis_hand_in_victim_frame(user, victim, knife_zone, 0, 0) - var/blade_deg = hv_vis_knife_blade_angle(victim, knife_zone) + var/hold_deg = hv_vis_knife_hold_angle(victim, knife_zone) + var/hold_along = hv_vis_knife_hold_contact(victim) var/obj/effect/temp_visual/hv_knife_exec_blade/blade = new( victim_turf, @@ -237,27 +242,25 @@ victim.pixel_y, 0, 0, - blade_deg, + hold_deg, HV_VIS_KNIFE_BLADE_LAYER, cut_hold_total + 1 SECONDS, ) - var/list/grip_off = blade.hv_point_offset(blade_deg, HV_VIS_KNIFE_SPRITE_GRIP) - var/list/heel_off = blade.hv_point_offset(blade_deg, HV_VIS_KNIFE_SPRITE_HEEL) - - // Start with the scaled knife's grip at the attacker's real knife hand, then bring the heel to the throat. - var/start_blade_w = round(knife_hand_start[1] - grip_off[1], 1) - var/start_blade_z = round(knife_hand_start[2] - grip_off[2], 1) - var/cut_start_w = round(throat_w - heel_off[1], 1) - var/cut_start_z = round(throat_z - heel_off[2], 1) - var/fist_start_w = round(start_blade_w + grip_off[1], 1) - var/fist_start_z = round(start_blade_z + grip_off[2], 1) - var/fist_in_w = round(cut_start_w + grip_off[1], 1) - var/fist_in_z = round(cut_start_z + grip_off[2], 1) - - blade.pixel_w = start_blade_w - blade.pixel_z = start_blade_z - var/matrix/blade_turn = blade.hv_turn_matrix(blade_deg) - animate(blade, pixel_w = cut_start_w, pixel_z = cut_start_z, transform = blade_turn, time = HV_VIS_KNIFE_GRAB_TIME, easing = QUAD_EASING|EASE_OUT) + var/list/grip_off = blade.hv_point_offset(hold_deg, HV_VIS_KNIFE_SPRITE_GRIP) + var/list/hold_off = blade.hv_point_offset(hold_deg, hold_along) + + // Start with the scaled knife's grip at the attacker's real knife hand, then bring hold_along onto the throat. + var/start_blade_w = knife_hand_start[1] - grip_off[1] + var/start_blade_z = knife_hand_start[2] - grip_off[2] + var/cut_start_w = throat_w - hold_off[1] + var/cut_start_z = throat_z - hold_off[2] + var/fist_start_w = start_blade_w + grip_off[1] + var/fist_start_z = start_blade_z + grip_off[2] + var/fist_in_w = cut_start_w + grip_off[1] + var/fist_in_z = cut_start_z + grip_off[2] + + blade.hv_place_at(start_blade_w, start_blade_z, hold_deg) + blade.hv_animate_to(cut_start_w, cut_start_z, hold_deg, HV_VIS_KNIFE_GRAB_TIME, QUAD_EASING|EASE_OUT) hv_vis_blade_ref = WEAKREF(blade) // Small skin-tinted hand prop centred on the fist, locked onto the scaled knife's grip every frame. @@ -272,7 +275,7 @@ HV_VIS_KNIFE_HAND_LAYER, cut_hold_total + 1 SECONDS, ) - animate(knife_arm, pixel_w = fist_in_w, pixel_z = fist_in_z, time = HV_VIS_KNIFE_GRAB_TIME, easing = QUAD_EASING|EASE_OUT) + knife_arm.hv_animate_to(fist_in_w, fist_in_z, HV_VIS_KNIFE_GRAB_TIME, QUAD_EASING|EASE_OUT) hv_vis_knife_arm_ref = WEAKREF(knife_arm) /// Runs Beats 3 and 4 once the wind-up succeeded and the real stab + slash wound landed. @@ -284,11 +287,11 @@ if(QDELETED(victim) || !isturf(victim.loc)) hv_vis_clear_exec_props() if(!QDELETED(user)) - user.hv_vis_release(HV_VIS_TAG_KNIFE_STEP, HV_VIS_KNIFE_RELEASE_TIME) + user.hv_vis_release(HV_VIS_TAG_KNIFE_STEP, HV_VIS_KNIFE_ABORT_TIME) return - // Keep the victim steady in the attacker's grip across the 0.25 s throat draw rather than flinching away early. - victim.hv_vis_stop(list(HV_VIS_TAG_FLINCH, HV_VIS_TAG_TREMBLE)) + // Stop the wind-up sequence and any hit flinch before starting the cut/release pose on the victim. + victim.hv_vis_stop(list(HV_VIS_TAG_FLINCH, HV_VIS_TAG_TREMBLE, HV_VIS_TAG_KNIFE_VICTIM)) victim.hv_vis_flash() // If the stab dropped a standing victim into crit (non-dead), hold them upright through the 0.25 s cut @@ -297,7 +300,6 @@ if(fell_now && victim.hv_vis_can_hold_fall()) victim.hv_vis_knife_upright_until = world.time + cut_total if(victim.stat != DEAD) - victim.hv_vis_stop(list(HV_VIS_TAG_KNIFE_VICTIM)) var/matrix/tilted_upright = hv_vis_turned(pre_base, victim.hv_vis_knife_tilt, HV_VIS_FEET_Y * victim.current_size) victim.hv_vis_play_over(list( list(pre_pixel_y, tilted_upright, 0, LINEAR_EASING), @@ -312,7 +314,7 @@ var/row_pixel_y = (fell_now && victim.hv_vis_can_hold_fall()) ? pre_pixel_y : victim.pixel_y var/knife_zone = (!QDELETED(user) && user.get_hand_zone_of_item(src)) || BODY_ZONE_R_ARM - var/blade_deg = hv_vis_knife_blade_angle(victim, knife_zone) + var/cut_deg = hv_vis_knife_cut_angle(victim, knife_zone) var/toward = !QDELETED(user) ? (get_dir(user, victim) || user.dir || SOUTH) : SOUTH var/step_px = (HV_VIS_DX(toward) && HV_VIS_DY(toward)) ? round(HV_VIS_KNIFE_STEP_IN * 0.78, 1) : HV_VIS_KNIFE_STEP_IN @@ -323,19 +325,18 @@ var/obj/effect/temp_visual/hv_knife_exec_arm/knife_arm = hv_vis_knife_arm_ref?.resolve() if(blade && !QDELETED(blade)) blade.pixel_y = row_pixel_y - var/list/tip_off = blade.hv_point_offset(blade_deg, HV_VIS_KNIFE_SPRITE_TIP) - var/list/grip_off = blade.hv_point_offset(blade_deg, HV_VIS_KNIFE_SPRITE_GRIP) - // End of Beat 3: blade draws across the throat so the tip lands on (throat_w, throat_z) and grip stays under the hand. - var/cut_end_w = round(throat_w - tip_off[1], 1) - var/cut_end_z = round(throat_z - tip_off[2], 1) - var/fist_end_w = round(cut_end_w + grip_off[1], 1) - var/fist_end_z = round(cut_end_z + grip_off[2], 1) - var/matrix/blade_turn = blade.hv_turn_matrix(blade_deg) - animate(blade, pixel_w = cut_end_w, pixel_z = cut_end_z, transform = blade_turn, time = HV_VIS_KNIFE_CUT_TIME, easing = QUAD_EASING|EASE_OUT) + var/list/tip_off = blade.hv_point_offset(cut_deg, HV_VIS_KNIFE_SPRITE_TIP) + var/list/grip_off = blade.hv_point_offset(cut_deg, HV_VIS_KNIFE_SPRITE_GRIP) + // End of Beat 3: blade draws across the throat so the sharp tip lands on (throat_w, throat_z) and grip stays under the hand. + var/cut_end_w = throat_w - tip_off[1] + var/cut_end_z = throat_z - tip_off[2] + var/fist_end_w = cut_end_w + grip_off[1] + var/fist_end_z = cut_end_z + grip_off[2] + blade.hv_animate_to(cut_end_w, cut_end_z, cut_deg, HV_VIS_KNIFE_CUT_TIME, QUAD_EASING|EASE_OUT) QDEL_IN(blade, cut_total) if(knife_arm && !QDELETED(knife_arm)) knife_arm.pixel_y = row_pixel_y - animate(knife_arm, pixel_w = fist_end_w, pixel_z = fist_end_z, time = HV_VIS_KNIFE_CUT_TIME, easing = QUAD_EASING|EASE_OUT) + knife_arm.hv_animate_to(fist_end_w, fist_end_z, HV_VIS_KNIFE_CUT_TIME, QUAD_EASING|EASE_OUT) QDEL_IN(knife_arm, cut_total) else if(knife_arm && !QDELETED(knife_arm)) qdel(knife_arm) @@ -366,11 +367,13 @@ spray_tiles, ) - // Beat 4 release: attacker steps back to exact zero offset after the cut + hold. + // Beat 4 release: stop the wind-up step tag first, then hold through cut_total and step back to exact zero offset. if(!QDELETED(user) && isturf(user.loc)) + user.hv_vis_stop(list(HV_VIS_TAG_KNIFE_STEP)) var/matrix/attacker_base = matrix(user.transform) var/matrix/attacker_lean = hv_vis_turned(attacker_base, HV_VIS_DX(toward) * 4, user.hv_vis_pivot()) user.hv_vis_play(HV_VIS_TAG_KNIFE_STEP, list( + list(user.pixel_w + step_dx, user.pixel_z + step_dy, attacker_lean, 0, LINEAR_EASING), list(user.pixel_w + step_dx, user.pixel_z + step_dy, attacker_lean, cut_total, LINEAR_EASING), list(user.pixel_w, user.pixel_z, attacker_base, HV_VIS_KNIFE_RELEASE_TIME, SINE_EASING), )) @@ -394,6 +397,7 @@ victim.hv_vis_knife_lurch_y = lurch_dy victim.hv_vis_play(HV_VIS_TAG_KNIFE_VICTIM, list( + list(victim.pixel_w, victim.pixel_z, tilted, 0, LINEAR_EASING), list(victim.pixel_w, victim.pixel_z, tilted, cut_total, LINEAR_EASING), list(victim.pixel_w + lurch_dx, victim.pixel_z + lurch_dy, hunched, HV_VIS_KNIFE_HUNCH_IN, QUAD_EASING|EASE_OUT), list(victim.pixel_w + lurch_dx, victim.pixel_z + lurch_dy, hunched, HV_VIS_KNIFE_HUNCH_HOLD, LINEAR_EASING), @@ -402,7 +406,7 @@ victim.hv_vis_hold(list(HV_VIS_TAG_KNIFE_VICTIM), HV_VIS_END_LIE|HV_VIS_END_DEATH, hunch_total) if(!(victim.dir & NORTH)) addtimer(CALLBACK(victim, TYPE_PROC_REF(/mob/living/carbon, hv_vis_spawn_clutch_hand), hunch_angle, lurch_dx, lurch_dy), cut_total, TIMER_DELETE_ME) - else if(!fell_now) + else if(victim.stat != DEAD && !fell_now) victim.hv_vis_knife_t2 = world.time + cut_total victim.hv_vis_knife_hunch = 0 victim.hv_vis_knife_lurch_x = 0 @@ -410,9 +414,12 @@ var/matrix/base_lying = matrix(victim.transform) var/matrix/tilted_lying = hv_vis_turned(base_lying, victim.hv_vis_knife_tilt, victim.hv_vis_pivot()) victim.hv_vis_play(HV_VIS_TAG_KNIFE_VICTIM, list( + list(victim.pixel_w, victim.pixel_z, tilted_lying, 0, LINEAR_EASING), list(victim.pixel_w, victim.pixel_z, tilted_lying, cut_total, LINEAR_EASING), list(victim.pixel_w, victim.pixel_z, base_lying, HV_VIS_KNIFE_RELEASE_TIME, SINE_EASING), )) + else + victim.hv_vis_knife_clear_pose() /// Spawns a small prop of this standing victim's own visible hand reaching up to clutch their throat during Beat 4. /mob/living/carbon/proc/hv_vis_spawn_clutch_hand(hunch_angle, lurch_dx = 0, lurch_dy = 0) @@ -445,16 +452,16 @@ animate(pixel_w = clutch_w, pixel_z = clutch_z, time = HV_VIS_KNIFE_HUNCH_HOLD, easing = LINEAR_EASING) animate(pixel_w = start_w, pixel_z = start_z, time = HV_VIS_KNIFE_HUNCH_OUT, easing = SINE_EASING) -/// Beat 5: wind-up broke early; ease both bodies straight back to their exact starting poses with no blood. +/// Beat 5: wind-up broke early; ease both bodies straight back to their exact starting poses in under 0.3 s with no blood. /obj/item/knife/proc/hv_vis_abort_knife_windup(mob/living/user, mob/living/carbon/victim) hv_vis_clear_exec_props() if(!QDELETED(user)) - user.hv_vis_release(HV_VIS_TAG_KNIFE_STEP, 2) + user.hv_vis_release(HV_VIS_TAG_KNIFE_STEP, HV_VIS_KNIFE_ABORT_TIME) if(!QDELETED(victim)) victim.hv_vis_knife_clear_pose() if(victim.stat != DEAD) - victim.hv_vis_release(HV_VIS_TAG_KNIFE_VICTIM, 2) - victim.hv_vis_release(HV_VIS_TAG_TREMBLE, 1) + victim.hv_vis_release(HV_VIS_TAG_KNIFE_VICTIM, HV_VIS_KNIFE_ABORT_TIME) + victim.hv_vis_stop(list(HV_VIS_TAG_TREMBLE)) else victim.hv_vis_stop(list(HV_VIS_TAG_KNIFE_VICTIM, HV_VIS_TAG_TREMBLE)) @@ -473,12 +480,12 @@ /// Throat offset list(x, y) from this mob's icon centre when leaned by `angle` degrees clockwise. /mob/living/proc/hv_vis_throat_for_angle(angle) - var/base_x = (dir & EAST) ? 3 : ((dir & WEST) ? -4 : 0) - var/base_y = 6 + var/base_x = (dir & EAST) ? 3.5 : ((dir & WEST) ? -3.5 : -0.5) + var/base_y = 5.5 var/matrix/pose = hv_vis_turned(matrix(transform), angle, hv_vis_pivot()) return list( - round(pose.a * base_x + pose.b * base_y + pose.c, 0.1), - round(pose.d * base_x + pose.e * base_y + pose.f, 0.1), + round(pose.a * base_x + pose.b * base_y + pose.c, 0.01), + round(pose.d * base_x + pose.e * base_y + pose.f, 0.01), ) /// Clockwise tilt angle (degrees) that pulls this victim's head back toward `attacker`. @@ -501,16 +508,32 @@ return HV_VIS_KNIFE_HUNCH_TILT if(dir & WEST) return -HV_VIS_KNIFE_HUNCH_TILT - return hv_vis_knife_tilt >= 0 ? -HV_VIS_KNIFE_HUNCH_TILT : HV_VIS_KNIFE_HUNCH_TILT - -/// Clockwise angle from EAST (0 deg) along which the knife blade points while crossing `victim`'s throat. -/proc/hv_vis_knife_blade_angle(mob/living/victim, knife_zone) - if(victim.dir & EAST) - return -10 - if(victim.dir & WEST) - return 190 + return (dir & NORTH) ? -HV_VIS_KNIFE_HUNCH_TILT : HV_VIS_KNIFE_HUNCH_TILT + +/// Clockwise angle from EAST (0 deg) along which the knife blade points while held against `victim`'s throat. +/proc/hv_vis_knife_hold_angle(mob/living/victim, knife_zone) + if(victim.body_position == STANDING_UP) + if(victim.dir & EAST) + return -12 + if(victim.dir & WEST) + return 192 + return (knife_zone == BODY_ZONE_R_ARM) ? 0 : 180 + +/// Clockwise angle from EAST (0 deg) along which the knife blade finishes at the end of the throat cut. +/proc/hv_vis_knife_cut_angle(mob/living/victim, knife_zone) + if(victim.body_position == STANDING_UP) + if(victim.dir & EAST) + return 6 + if(victim.dir & WEST) + return 174 return (knife_zone == BODY_ZONE_R_ARM) ? 0 : 180 +/// Unscaled axial sprite coordinate on the blade that rests on `victim`'s throat during the wind-up hold. +/proc/hv_vis_knife_hold_contact(mob/living/victim) + if(victim.body_position == STANDING_UP && (victim.dir & (EAST|WEST))) + return HV_VIS_KNIFE_SPRITE_SIDE_HOLD + return HV_VIS_KNIFE_SPRITE_HEEL + /// Pixel offset list(x, y) of `arm_zone`'s hand (rows 16-17 in bodyparts_greyscale.dmi) from `holder`'s icon centre. /proc/hv_vis_local_hand_offset(mob/living/holder, arm_zone) var/right_hand = (arm_zone == BODY_ZONE_R_ARM) @@ -595,19 +618,34 @@ layer = draw_layer pixel_x = row_x pixel_y = row_y - pixel_w = start_w - pixel_z = start_z - transform = hv_turn_matrix(blade_deg) + hv_place_at(start_w, start_z, blade_deg) -/// Matrix scaling this knife to ~11 px overall and orienting its blade along `blade_deg` clockwise from EAST. -/obj/effect/temp_visual/hv_knife_exec_blade/proc/hv_turn_matrix(blade_deg) +/// Matrix scaling this knife to ~10 px overall, orienting its blade along `blade_deg` clockwise from EAST, with optional sub-pixel shift. +/obj/effect/temp_visual/hv_knife_exec_blade/proc/hv_turn_matrix(blade_deg, shift_x = 0, shift_y = 0) var/axis_span = max(abs(cos(hv_native_icon_angle)), abs(sin(hv_native_icon_angle)), 0.7071) var/blade_scale = HV_VIS_KNIFE_SCALE * (axis_span / 0.7071) var/matrix/turned = matrix() turned.Scale(blade_scale, blade_scale) turned.Turn(blade_deg - hv_native_icon_angle) + if(shift_x || shift_y) + turned.Translate(shift_x, shift_y) return turned +/// Places this blade prop at exact float `(exact_w, exact_z)` and `blade_deg`, putting the sub-pixel remainder in `transform`. +/obj/effect/temp_visual/hv_knife_exec_blade/proc/hv_place_at(exact_w, exact_z, blade_deg) + var/int_w = round(exact_w, 1) + var/int_z = round(exact_z, 1) + pixel_w = int_w + pixel_z = int_z + transform = hv_turn_matrix(blade_deg, exact_w - int_w, exact_z - int_z) + +/// Animates this blade prop to exact float `(exact_w, exact_z)` and `blade_deg` with sub-pixel accuracy. +/obj/effect/temp_visual/hv_knife_exec_blade/proc/hv_animate_to(exact_w, exact_z, blade_deg, anim_time, anim_easing) + var/int_w = round(exact_w, 1) + var/int_z = round(exact_z, 1) + var/matrix/blade_turn = hv_turn_matrix(blade_deg, exact_w - int_w, exact_z - int_z) + animate(src, pixel_w = int_w, pixel_z = int_z, transform = blade_turn, time = anim_time, easing = anim_easing) + /// Pixel offset list(dx, dy) from this blade prop's centre for axial sprite point `along_px`, through `hv_turn_matrix`. /obj/effect/temp_visual/hv_knife_exec_blade/proc/hv_point_offset(blade_deg, along_px) var/nx = cos(hv_native_icon_angle) @@ -639,12 +677,29 @@ layer = draw_layer pixel_x = row_x pixel_y = row_y - pixel_w = fist_w - pixel_z = fist_z + var/int_w = round(fist_w, 1) + var/int_z = round(fist_z, 1) + pixel_w = int_w + pixel_z = int_z + transform = hv_shift_matrix(fist_w - int_w, fist_z - int_z) var/mutable_appearance/hand_overlay = hv_vis_build_hand_overlay(holder, arm_zone) if(hand_overlay) add_overlay(hand_overlay) +/// Sub-pixel translation matrix for keeping the hand prop locked to the scaled knife grip. +/obj/effect/temp_visual/hv_knife_exec_arm/proc/hv_shift_matrix(shift_x = 0, shift_y = 0) + var/matrix/shifted = matrix() + if(shift_x || shift_y) + shifted.Translate(shift_x, shift_y) + return shifted + +/// Animates this hand prop to exact float `(exact_w, exact_z)` with sub-pixel accuracy. +/obj/effect/temp_visual/hv_knife_exec_arm/proc/hv_animate_to(exact_w, exact_z, anim_time, anim_easing) + var/int_w = round(exact_w, 1) + var/int_z = round(exact_z, 1) + var/matrix/shifted = hv_shift_matrix(exact_w - int_w, exact_z - int_z) + animate(src, pixel_w = int_w, pixel_z = int_z, transform = shifted, time = anim_time, easing = anim_easing) + /// Small skin-tinted hand prop for a standing survivor clutching their own throat after release; vanishes early if they move or fall. /obj/effect/temp_visual/hv_knife_clutch_hand name = "hand" From 63626a4ff04de4a6d809bdfc9c111b0328d602dd Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Thu, 12 Nov 2026 23:31:51 -0800 Subject: [PATCH 47/78] Knife executions: the attacker holds the victim from behind with his arm across the neck --- .../modules/hyperviolence/visuals/_defines.dm | 22 +- .../visuals/knife_execution_motion.dm | 643 ++++++++++++++---- 2 files changed, 514 insertions(+), 151 deletions(-) diff --git a/voidcrew/modules/hyperviolence/visuals/_defines.dm b/voidcrew/modules/hyperviolence/visuals/_defines.dm index b129af884c1..8f6692f06bd 100644 --- a/voidcrew/modules/hyperviolence/visuals/_defines.dm +++ b/voidcrew/modules/hyperviolence/visuals/_defines.dm @@ -164,16 +164,32 @@ #define HV_VIS_KNIFE_HUNCH_HOLD (0.4 SECONDS) /// How long a standing survivor takes to return from the forward hunch to their true pose. #define HV_VIS_KNIFE_HUNCH_OUT (0.3 SECONDS) -/// Pixels the attacker steps toward the victim during a knife execution (under a third of a 32 px tile). -#define HV_VIS_KNIFE_STEP_IN 9 +/// Pixels a side-on (E/W) attacker steps toward the victim so their chest meets the victim's back. +/// Deliberate exception to _motion_core.dm's "offsets under a third of a tile" rule: pixel_w/pixel_z +/// never change the SIDE_MAP sort row (y + pixel_y), so sort order across tiles is preserved. +#define HV_VIS_KNIFE_STEP_SIDE 19 +/// Pixels a north/south attacker steps toward the victim so their chest meets the victim's back. +/// Deliberate exception to _motion_core.dm's third-of-a-tile rule: pixel_z never changes sort row, +/// so an attacker north of a south-facing victim still sorts behind them. +#define HV_VIS_KNIFE_STEP_FRONT 15 +/// Per-axis pixels a diagonal attacker steps toward a helpless victim. +#define HV_VIS_KNIFE_STEP_DIAG 13 /// Degrees a side-facing standing victim is tilted back toward the attacker about their feet. -#define HV_VIS_KNIFE_TILT_SIDE 2 +#define HV_VIS_KNIFE_TILT_SIDE 7 /// Degrees a north- or south-facing standing victim leans sideways during the wind-up (0 keeps throat centred). #define HV_VIS_KNIFE_TILT_FRONT 0 +/// Pixels a north- or south-facing standing victim shifts back toward the attacker during the wind-up. +#define HV_VIS_KNIFE_PULL_FRONT 2 +/// Feet-anchored vertical stretch added to a north- or south-facing victim so their head draws 1 px up. +#define HV_VIS_KNIFE_HEAD_STRETCH 0.042 /// Degrees a lying victim is tugged toward the attacker during the wind-up. #define HV_VIS_KNIFE_TILT_LYING 2 /// Degrees a standing survivor hunches forward about their feet after the throat is cut. #define HV_VIS_KNIFE_HUNCH_TILT 9 +/// Native pixel length from fist centre (rows 16-17) to shoulder top (row 11) on human arm sprites. +#define HV_VIS_KNIFE_ARM_BASE_LEN 6 +/// Maximum lengthwise stretch factor allowed on the attacker's forearm prop. +#define HV_VIS_KNIFE_ARM_MAX_STRETCH 2 /// Scale applied to a 32x32 diagonal knife sprite so the prop renders ~10 px long in a 32 px hand. #define HV_VIS_KNIFE_SCALE 0.28 /// Unscaled axial sprite coordinate (from 32x32 centre) of a knife's grip under the holder's fist. diff --git a/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm b/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm index 994c5ea5bb7..483d47a0b26 100644 --- a/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm +++ b/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm @@ -1,28 +1,30 @@ // Hyperviolence visuals: knife executions (overlays_exec/knife_executions.dm). // // Beats over the execution's own wind-up and kill (purely visual; every sequence ends where it began): -// 1. Wind-up grab (0 - 0.3 s): the attacker steps in toward the victim, a side-facing victim's head -// tilts back 2 deg about their feet, and for S/E/W facings a scaled (~10 px) blade prop and small -// skin-tinted hand prop move from the attacker's real knife hand to the throat, grip under the hand -// every frame. When a standing victim faces NORTH the cut is hidden behind their head, so no blade -// or hand prop is drawn. -// 2. Hold (0.3 - 1.5 s): attacker, victim, blade and hand hold steady together so the cutting edge -// stays locked on the drawn throat every frame. +// 1. Wind-up grab (0 - 0.3 s): the attacker steps in until their chest meets the victim's back +// (19 px for E/W, 15 px for S/N), the victim's head is pulled back (7 deg about the feet for E/W; +// 2 px toward the attacker plus 1 px head lift for S/N), the attacker's in-hand knife sprite hides, +// and for S/E/W facings a scaled (~10 px) blade prop plus a clothed forearm-and-hand prop built +// from the attacker's real arm + sleeve sprites move to the throat with the hand locked to the grip. +// When a standing victim faces NORTH the cut is hidden behind their head, so no props are drawn. +// 2. Hold (0.3 - 1.5 s): attacker, victim, blade and forearm hold steady together so the cutting edge +// stays locked on the drawn throat and the hand stays on the grip every frame. // 3. The cut (1.5 - 1.75 s, held 0.1 s): the blade draws across the throat so the edge crosses the -// throat and the sharp tip finishes on the front of the throat with the hand on the grip; a short -// jet spurts off the front of the neck (S/E/W) and a forward floor spray runs along the victim's -// facing once the wound lands. -// 4. Release: the blade and knife-hand props vanish together, the attacker steps back to exact zero -// offset, and a survivor still standing hunches 9 deg forward about their feet (0.15 s in, 0.4 s -// hold, 0.3 s out) while their own hand clutches their throat; if the blow dropped them, tg's own -// fall and death_falls.dm take over. A broken wind-up releases everything in 0.2 s with no blood. +// throat and the sharp tip finishes on the front of the throat with the forearm's hand on the grip; +// a short jet spurts off the front of the neck (S/E/W) and a forward floor spray runs along the +// victim's facing once the wound lands. +// 4. Release: the blade and forearm props vanish together as the attacker's held knife sprite restores, +// the attacker steps back to exact zero offset, and a survivor still standing hunches 9 deg forward +// about their feet (0.15 s in, 0.4 s hold, 0.3 s out) while their own hand clutches their throat; if +// the blow dropped them, tg's own fall and death_falls.dm take over. A broken wind-up releases +// everything in 0.2 s with no blood and restores the held knife sprite immediately. /mob/living /// Suppresses tg's centre-body lunge and floating item flick during the execution's own head stab. var/hv_vis_knife_executing = FALSE /// Wind-up start time for the active knife execution pose on this victim. var/hv_vis_knife_t0 = -1 - /// Time the wind-up head pull reaches its full back-tilt. + /// Time the wind-up head pull reaches its full pose. var/hv_vis_knife_t1 = -1 /// Time the throat cut and its short hold finish. var/hv_vis_knife_t2 = -1 @@ -32,6 +34,11 @@ var/hv_vis_knife_t4 = -1 /// Clockwise degrees this victim is tilted back during the wind-up and cut. var/hv_vis_knife_tilt = 0 + /// Pixel x/y shift pulling a standing N/S victim toward the attacker during the wind-up and cut. + var/hv_vis_knife_pull_x = 0 + var/hv_vis_knife_pull_y = 0 + /// Feet-anchored vertical stretch lifting a standing N/S victim's head 1 px up during the wind-up and cut. + var/hv_vis_knife_stretch = 0 /// Clockwise degrees this victim hunches forward after release when still standing. var/hv_vis_knife_hunch = 0 /// Peak x/y pixel lurch of a standing survivor's hunch after release. @@ -43,10 +50,14 @@ var/matrix/hv_vis_knife_pose_base /obj/item/knife - /// Weakref to the active blade prop (/obj/effect/temp_visual/hv_knife_exec_blade) during a wind-up. + /// Weakref to the active blade prop (/obj/effect/temp_visual/hv_knife_exec_blade) while on screen. var/datum/weakref/hv_vis_blade_ref - /// Weakref to the attacker's knife-hand prop (/obj/effect/temp_visual/hv_knife_exec_arm) during a wind-up. + /// Weakref to the attacker's forearm+hand prop (/obj/effect/temp_visual/hv_knife_exec_arm) while on screen. var/datum/weakref/hv_vis_knife_arm_ref + /// Weakref to the mob whose in-hand sprite is hidden while the throat blade prop is out. + var/datum/weakref/hv_vis_holder_ref + /// True only while the throat blade prop is out so build_worn_icon() suppresses the duplicate hip blade. + var/hv_vis_hide_inhand = FALSE /// Whether the current execution completed its cut so hv_start_knife_execution skips broken cleanup. var/hv_vis_cut_landed = FALSE @@ -54,17 +65,83 @@ hv_vis_clear_exec_props() return ..() +/obj/item/knife/dropped(mob/user, silent = FALSE) + if(hv_vis_hide_inhand || hv_vis_blade_ref || hv_vis_knife_arm_ref) + hv_vis_clear_exec_props() + return ..() + +/obj/item/knife/equipped(mob/user, slot, initial = FALSE) + if(!(slot & ITEM_SLOT_HANDS) && (hv_vis_hide_inhand || hv_vis_blade_ref || hv_vis_knife_arm_ref)) + hv_vis_clear_exec_props() + return ..() + +/obj/item/knife/build_worn_icon( + default_layer = 0, + default_icon_file = null, + isinhands = FALSE, + female_uniform = NO_FEMALE_UNIFORM, + override_state = null, + override_file = null, +) + if(isinhands && hv_vis_hide_inhand) + var/layer2use = alternate_worn_layer || default_layer + return mutable_appearance(layer = -layer2use) + return ..() + +/// Hides this knife's in-hand sprite on `holder` for the exact lifetime of the throat blade prop. +/obj/item/knife/proc/hv_vis_hide_held_sprite(mob/living/holder) + if(QDELETED(holder)) + return + var/mob/living/prev_holder = hv_vis_holder_ref?.resolve() + if(prev_holder && prev_holder != holder) + UnregisterSignal(prev_holder, COMSIG_QDELETING) + hv_vis_hide_inhand = TRUE + hv_vis_holder_ref = WEAKREF(holder) + RegisterSignal(holder, COMSIG_QDELETING, PROC_REF(hv_on_holder_qdeleting), override = TRUE) + holder.update_held_items() + +/// Restores this knife's in-hand sprite on its holder and leaves no server var changed. +/obj/item/knife/proc/hv_vis_restore_held_sprite() + var/was_hidden = hv_vis_hide_inhand + hv_vis_hide_inhand = FALSE + var/mob/living/holder = hv_vis_holder_ref?.resolve() + hv_vis_holder_ref = null + if(holder) + UnregisterSignal(holder, COMSIG_QDELETING) + if(was_hidden && !QDELETED(holder)) + holder.update_held_items() + if(was_hidden && ismob(loc) && loc != holder && !QDELETED(loc)) + var/mob/current_mob = loc + current_mob.update_held_items() + +/obj/item/knife/proc/hv_on_holder_qdeleting(datum/source) + SIGNAL_HANDLER + hv_vis_clear_exec_props() + /mob/living/do_attack_animation(atom/A, visual_effect_icon, obj/item/used_item, no_effect) if(hv_vis_knife_executing) return return ..() /mob/living/carbon/hv_vis_on_death(gibbed) - if(hv_vis_knife_t0 >= 0) + if(hv_vis_knife_t0 >= 0 && (gibbed || hv_vis_execution_time != world.time)) hv_vis_knife_clear_pose() hv_vis_stop(list(HV_VIS_TAG_KNIFE_VICTIM)) return ..() +/// Builds a copy of `base` with feet-anchored vertical `stretch` and clockwise `angle` about `pivot_y`. +/proc/hv_vis_knife_pose_matrix(matrix/base, angle = 0, stretch = 0, pivot_y = 0) + var/matrix/posed = matrix(base) + if(!angle && !stretch) + return posed + posed.Translate(0, -pivot_y) + if(stretch) + posed.Scale(1, 1 + stretch) + if(angle) + posed.Turn(angle) + posed.Translate(0, pivot_y) + return posed + /// Pixel offset list(x, y) of `victim`'s drawn throat from their icon centre at `world.time`'s pose. /proc/hv_knife_exec_throat_point(mob/living/victim) if(!isliving(victim)) @@ -72,14 +149,17 @@ var/base_x = (victim.dir & EAST) ? 3.5 : ((victim.dir & WEST) ? -3.5 : -0.5) var/base_y = 5.5 var/angle = victim.hv_vis_knife_pose_angle() + var/pull_weight = victim.hv_vis_knife_pose_pull_weight() var/list/lurch = victim.hv_vis_knife_pose_lurch() var/held_upright = victim.hv_vis_knife_pose_base && world.time < victim.hv_vis_knife_upright_until var/matrix/base = held_upright ? matrix(victim.hv_vis_knife_pose_base) : matrix(victim.transform) var/pivot = held_upright ? (HV_VIS_FEET_Y * victim.current_size) : victim.hv_vis_pivot() - var/matrix/pose = hv_vis_turned(base, angle, pivot) + var/matrix/pose = hv_vis_knife_pose_matrix(base, angle, victim.hv_vis_knife_stretch * pull_weight, pivot) + var/shift_x = victim.hv_vis_knife_pull_x * pull_weight + lurch[1] + var/shift_y = victim.hv_vis_knife_pull_y * pull_weight + lurch[2] return list( - round(pose.a * base_x + pose.b * base_y + pose.c + lurch[1], 0.01), - round(pose.d * base_x + pose.e * base_y + pose.f + lurch[2], 0.01), + round(pose.a * base_x + pose.b * base_y + pose.c + shift_x, 0.01), + round(pose.d * base_x + pose.e * base_y + pose.f + shift_y, 0.01), ) /// Current clockwise lean angle (degrees) our knife execution animation adds to this mob at world.time. @@ -103,6 +183,20 @@ return hv_vis_knife_hunch * (1 - (world.time - hold_end) / out_span) return 0 +/// Weight [0..1] of the wind-up pull shift and head stretch at world.time. +/mob/living/proc/hv_vis_knife_pose_pull_weight() + if(hv_vis_knife_t0 < 0 || world.time < hv_vis_knife_t0) + return 0 + if(world.time < hv_vis_knife_t1) + var/span = max(hv_vis_knife_t1 - hv_vis_knife_t0, 1) + var/frac = (world.time - hv_vis_knife_t0) / span + return 1 - (1 - frac) * (1 - frac) + if(world.time <= hv_vis_knife_t2) + return 1 + if(hv_vis_knife_t3 > hv_vis_knife_t2 && world.time < hv_vis_knife_t3) + return 1 - (world.time - hv_vis_knife_t2) / max(hv_vis_knife_t3 - hv_vis_knife_t2, 1) + return 0 + /// Current list(dx, dy) lurch offset added by a standing survivor's forward hunch at world.time. /mob/living/proc/hv_vis_knife_pose_lurch() if(hv_vis_knife_t3 <= hv_vis_knife_t2 || world.time <= hv_vis_knife_t2 || world.time >= hv_vis_knife_t4) @@ -124,6 +218,9 @@ hv_vis_knife_t3 = -1 hv_vis_knife_t4 = -1 hv_vis_knife_tilt = 0 + hv_vis_knife_pull_x = 0 + hv_vis_knife_pull_y = 0 + hv_vis_knife_stretch = 0 hv_vis_knife_hunch = 0 hv_vis_knife_lurch_x = 0 hv_vis_knife_lurch_y = 0 @@ -166,6 +263,8 @@ victim.hv_blood_spray_until = prev_spray_until victim.hv_blood_spray_strength = prev_spray_strength if(!.) + if(!QDELETED(victim)) + victim.hv_vis_knife_clear_pose() return hv_vis_cut_landed = TRUE @@ -173,7 +272,7 @@ // ---- Wind-up, cut and release choreography ---- -/// Starts Beats 1 and 2: attacker step-in, steady victim head-pull, and (for S/E/W) scaled blade + hand props. +/// Starts Beats 1 and 2: attacker chest-to-back step-in, victim head pull-back, and (for S/E/W) blade + forearm props. /obj/item/knife/proc/hv_vis_begin_knife_windup(mob/living/user, mob/living/carbon/victim) hv_vis_clear_exec_props() var/turf/victim_turf = get_turf(victim) @@ -182,33 +281,42 @@ var/cut_hold_total = HV_KNIFE_EXECUTION_WINDUP + HV_VIS_KNIFE_CUT_TIME + HV_VIS_KNIFE_CUT_HOLD var/toward = get_dir(user, victim) || user.dir || SOUTH - var/step_px = (HV_VIS_DX(toward) && HV_VIS_DY(toward)) ? round(HV_VIS_KNIFE_STEP_IN * 0.78, 1) : HV_VIS_KNIFE_STEP_IN - var/step_dx = HV_VIS_DX(toward) * step_px - var/step_dy = HV_VIS_DY(toward) * step_px + // Deliberate exception to _motion_core.dm's "offsets under a third of a tile" rule: step 19 px (E/W) + // or 15 px (S/N) so the attacker's chest meets the victim's back. pixel_w/pixel_z never change the + // SIDE_MAP sort row (y + pixel_y), so an attacker north of a south-facing victim still sorts behind them. + var/list/step_off = hv_vis_knife_step_offset(toward) + var/step_dx = step_off[1] + var/step_dy = step_off[2] + var/attacker_lean_deg = HV_VIS_DX(toward) * 4 // Stop any prior sequence on these tags so nothing overlaps when the wind-up starts. user.hv_vis_stop(list(HV_VIS_TAG_KNIFE_STEP)) victim.hv_vis_stop(list(HV_VIS_TAG_KNIFE_VICTIM, HV_VIS_TAG_TREMBLE)) - // Attacker steps in behind the victim and stays pressed in until the cut releases. + // Attacker steps in until their chest presses against the victim's back and holds until release. var/matrix/attacker_base = matrix(user.transform) - var/matrix/attacker_lean = hv_vis_turned(attacker_base, HV_VIS_DX(toward) * 4, user.hv_vis_pivot()) + var/matrix/attacker_lean = hv_vis_turned(attacker_base, attacker_lean_deg, user.hv_vis_pivot()) user.hv_vis_play(HV_VIS_TAG_KNIFE_STEP, list( list(user.pixel_w + step_dx, user.pixel_z + step_dy, attacker_lean, HV_VIS_KNIFE_GRAB_TIME, QUAD_EASING|EASE_OUT), list(user.pixel_w + step_dx, user.pixel_z + step_dy, attacker_lean, cut_hold_total - HV_VIS_KNIFE_GRAB_TIME + 0.5 SECONDS, LINEAR_EASING), list(user.pixel_w, user.pixel_z, attacker_base, HV_VIS_KNIFE_RELEASE_TIME, SINE_EASING), )) - // Victim is pulled back about their feet and held steady so the blade edge stays on the throat every frame. + // Victim's head is pulled back (7 deg about feet for E/W; 2 px toward attacker + 1 px head lift for S/N) and held steady. var/tilt = victim.hv_vis_knife_windup_tilt(user) + var/list/pull = victim.hv_vis_knife_windup_pull(user) + var/stretch = victim.hv_vis_knife_windup_stretch() var/matrix/victim_base = matrix(victim.transform) - var/matrix/victim_tilted = hv_vis_turned(victim_base, tilt, victim.hv_vis_pivot()) + var/matrix/victim_pulled = hv_vis_knife_pose_matrix(victim_base, tilt, stretch, victim.hv_vis_pivot()) victim.hv_vis_knife_t0 = world.time victim.hv_vis_knife_t1 = world.time + HV_VIS_KNIFE_GRAB_TIME victim.hv_vis_knife_t2 = world.time + cut_hold_total victim.hv_vis_knife_t3 = -1 victim.hv_vis_knife_t4 = -1 victim.hv_vis_knife_tilt = tilt + victim.hv_vis_knife_pull_x = pull[1] + victim.hv_vis_knife_pull_y = pull[2] + victim.hv_vis_knife_stretch = stretch victim.hv_vis_knife_hunch = 0 victim.hv_vis_knife_lurch_x = 0 victim.hv_vis_knife_lurch_y = 0 @@ -216,8 +324,8 @@ victim.hv_vis_knife_pose_base = victim.body_position == STANDING_UP ? matrix(victim_base) : null victim.hv_vis_play(HV_VIS_TAG_KNIFE_VICTIM, list( - list(victim.pixel_w, victim.pixel_z, victim_tilted, HV_VIS_KNIFE_GRAB_TIME, QUAD_EASING|EASE_OUT), - list(victim.pixel_w, victim.pixel_z, victim_tilted, cut_hold_total - HV_VIS_KNIFE_GRAB_TIME + 0.5 SECONDS, LINEAR_EASING), + list(victim.pixel_w + pull[1], victim.pixel_z + pull[2], victim_pulled, HV_VIS_KNIFE_GRAB_TIME, QUAD_EASING|EASE_OUT), + list(victim.pixel_w + pull[1], victim.pixel_z + pull[2], victim_pulled, cut_hold_total - HV_VIS_KNIFE_GRAB_TIME + 0.5 SECONDS, LINEAR_EASING), list(victim.pixel_w, victim.pixel_z, victim_base, HV_VIS_KNIFE_RELEASE_TIME, SINE_EASING), )) @@ -225,45 +333,61 @@ if((victim.dir & NORTH) && victim.body_position == STANDING_UP) return - // Compute the throat target at full wind-up tilt (t1..t2) so the blade edge rests right on the tilted throat. - var/list/tilted_throat = victim.hv_vis_throat_for_angle(tilt) - var/throat_w = victim.pixel_w + tilted_throat[1] - var/throat_z = victim.pixel_z + tilted_throat[2] + // Compute the throat target on the pulled pose (t1..t2) so the blade edge rests right on the drawn throat. + var/list/pulled_throat = victim.hv_vis_throat_for_pose(tilt, stretch) + var/throat_w = victim.pixel_w + pull[1] + pulled_throat[1] + var/throat_z = victim.pixel_z + pull[2] + pulled_throat[2] var/knife_zone = user.get_hand_zone_of_item(src) || BODY_ZONE_R_ARM - var/list/knife_hand_start = hv_vis_hand_in_victim_frame(user, victim, knife_zone, 0, 0) var/hold_deg = hv_vis_knife_hold_angle(victim, knife_zone) var/hold_along = hv_vis_knife_hold_contact(victim) + var/is_south_wrap = (victim.body_position == STANDING_UP) && (victim.dir & SOUTH) && !(victim.dir & (EAST|WEST)) + + var/list/grip_off = hv_vis_knife_point_offset(icon_angle, hold_deg, HV_VIS_KNIFE_SPRITE_GRIP) + var/list/hold_off = hv_vis_knife_point_offset(icon_angle, hold_deg, hold_along) + var/cut_start_w = throat_w - hold_off[1] + var/cut_start_z = throat_z - hold_off[2] + var/fist_in_w = cut_start_w + grip_off[1] + var/fist_in_z = cut_start_z + grip_off[2] + + var/fist_start_w + var/fist_start_z + var/list/anchor_start + var/list/anchor_in + if(is_south_wrap) + // Facing SOUTH: the attacker's arm wraps around the side of the neck from behind at collar height, + // so only the forearm segment in front of the neck shows and nothing ever crosses the face. + var/right_hand = (knife_zone == BODY_ZONE_R_ARM) + fist_start_w = right_hand ? -8 : 8 + fist_start_z = throat_z - 1.2 + anchor_start = list(right_hand ? -11.5 : 11.5, throat_z - 2.4) + anchor_in = hv_vis_south_neck_anchor(fist_in_w, fist_in_z, right_hand) + else + var/list/knife_hand_start = hv_vis_hand_in_victim_frame(user, victim, knife_zone, 0, 0) + fist_start_w = knife_hand_start[1] + fist_start_z = knife_hand_start[2] + anchor_start = hv_vis_shoulder_in_victim_frame(user, victim, knife_zone, 0, 0, 0) + anchor_in = hv_vis_shoulder_in_victim_frame(user, victim, knife_zone, step_dx, step_dy, attacker_lean_deg) + + var/start_blade_w = fist_start_w - grip_off[1] + var/start_blade_z = fist_start_z - grip_off[2] var/obj/effect/temp_visual/hv_knife_exec_blade/blade = new( victim_turf, src, victim.pixel_x, victim.pixel_y, - 0, - 0, + start_blade_w, + start_blade_z, hold_deg, HV_VIS_KNIFE_BLADE_LAYER, cut_hold_total + 1 SECONDS, ) - var/list/grip_off = blade.hv_point_offset(hold_deg, HV_VIS_KNIFE_SPRITE_GRIP) - var/list/hold_off = blade.hv_point_offset(hold_deg, hold_along) - - // Start with the scaled knife's grip at the attacker's real knife hand, then bring hold_along onto the throat. - var/start_blade_w = knife_hand_start[1] - grip_off[1] - var/start_blade_z = knife_hand_start[2] - grip_off[2] - var/cut_start_w = throat_w - hold_off[1] - var/cut_start_z = throat_z - hold_off[2] - var/fist_start_w = start_blade_w + grip_off[1] - var/fist_start_z = start_blade_z + grip_off[2] - var/fist_in_w = cut_start_w + grip_off[1] - var/fist_in_z = cut_start_z + grip_off[2] - - blade.hv_place_at(start_blade_w, start_blade_z, hold_deg) - blade.hv_animate_to(cut_start_w, cut_start_z, hold_deg, HV_VIS_KNIFE_GRAB_TIME, QUAD_EASING|EASE_OUT) hv_vis_blade_ref = WEAKREF(blade) + hv_vis_hide_held_sprite(user) + blade.hv_animate_to(cut_start_w, cut_start_z, hold_deg, HV_VIS_KNIFE_GRAB_TIME, QUAD_EASING|EASE_OUT) - // Small skin-tinted hand prop centred on the fist, locked onto the scaled knife's grip every frame. + // Clothed forearm-and-hand prop built from the attacker's real arm + sleeves, hand end locked to the grip. var/obj/effect/temp_visual/hv_knife_exec_arm/knife_arm = new( victim_turf, user, @@ -272,10 +396,12 @@ victim.pixel_y, fist_start_w, fist_start_z, + anchor_start[1], + anchor_start[2], HV_VIS_KNIFE_HAND_LAYER, cut_hold_total + 1 SECONDS, ) - knife_arm.hv_animate_to(fist_in_w, fist_in_z, HV_VIS_KNIFE_GRAB_TIME, QUAD_EASING|EASE_OUT) + knife_arm.hv_animate_to(fist_in_w, fist_in_z, anchor_in[1], anchor_in[2], HV_VIS_KNIFE_GRAB_TIME, QUAD_EASING|EASE_OUT) hv_vis_knife_arm_ref = WEAKREF(knife_arm) /// Runs Beats 3 and 4 once the wind-up succeeded and the real stab + slash wound landed. @@ -294,20 +420,34 @@ victim.hv_vis_stop(list(HV_VIS_TAG_FLINCH, HV_VIS_TAG_TREMBLE, HV_VIS_TAG_KNIFE_VICTIM)) victim.hv_vis_flash() - // If the stab dropped a standing victim into crit (non-dead), hold them upright through the 0.25 s cut - // before tg's own lying fall takes over, matching death_falls.dm's execution hold on lethal cuts. + // If the stab dropped a standing victim (crit or dead), keep them in their pulled upright pose through + // the 0.35 s cut + hold before tg's lying fall takes over, so the throat doesn't snap mid-cut. var/fell_now = was_standing && victim.body_position == LYING_DOWN if(fell_now && victim.hv_vis_can_hold_fall()) + victim.hv_vis_knife_t2 = world.time + cut_total + victim.hv_vis_knife_t3 = -1 + victim.hv_vis_knife_t4 = -1 + victim.hv_vis_knife_hunch = 0 + victim.hv_vis_knife_lurch_x = 0 + victim.hv_vis_knife_lurch_y = 0 victim.hv_vis_knife_upright_until = world.time + cut_total - if(victim.stat != DEAD) - var/matrix/tilted_upright = hv_vis_turned(pre_base, victim.hv_vis_knife_tilt, HV_VIS_FEET_Y * victim.current_size) - victim.hv_vis_play_over(list( - list(pre_pixel_y, tilted_upright, 0, LINEAR_EASING), - list(pre_pixel_y, tilted_upright, cut_total, LINEAR_EASING), - list(victim.pixel_y, matrix(victim.transform), 3, QUAD_EASING|EASE_IN), - )) - - // Exact drawn throat at the moment of the cut, through the same transform on the victim. + var/matrix/pulled_upright = hv_vis_knife_pose_matrix( + pre_base, + victim.hv_vis_knife_tilt, + victim.hv_vis_knife_stretch, + HV_VIS_FEET_Y * victim.current_size, + ) + if(victim.hv_vis_knife_pull_x || victim.hv_vis_knife_pull_y) + pulled_upright.Translate(victim.hv_vis_knife_pull_x, victim.hv_vis_knife_pull_y) + victim.hv_vis_play_over(list( + list(pre_pixel_y, pulled_upright, 0, LINEAR_EASING), + list(pre_pixel_y, pulled_upright, cut_total, LINEAR_EASING), + list(victim.pixel_y, matrix(victim.transform), 3, QUAD_EASING|EASE_IN), + )) + else if(fell_now) + victim.hv_vis_knife_clear_pose() + + // Exact drawn throat at the moment of the cut, computed through the same pose transform on the victim. var/list/throat = hv_knife_exec_throat_point(victim) var/throat_w = victim.pixel_w + throat[1] var/throat_z = victim.pixel_z + throat[2] @@ -317,9 +457,10 @@ var/cut_deg = hv_vis_knife_cut_angle(victim, knife_zone) var/toward = !QDELETED(user) ? (get_dir(user, victim) || user.dir || SOUTH) : SOUTH - var/step_px = (HV_VIS_DX(toward) && HV_VIS_DY(toward)) ? round(HV_VIS_KNIFE_STEP_IN * 0.78, 1) : HV_VIS_KNIFE_STEP_IN - var/step_dx = HV_VIS_DX(toward) * step_px - var/step_dy = HV_VIS_DY(toward) * step_px + var/list/step_off = hv_vis_knife_step_offset(toward) + var/step_dx = step_off[1] + var/step_dy = step_off[2] + var/attacker_lean_deg = HV_VIS_DX(toward) * 4 var/obj/effect/temp_visual/hv_knife_exec_blade/blade = hv_vis_blade_ref?.resolve() var/obj/effect/temp_visual/hv_knife_exec_arm/knife_arm = hv_vis_knife_arm_ref?.resolve() @@ -336,13 +477,21 @@ QDEL_IN(blade, cut_total) if(knife_arm && !QDELETED(knife_arm)) knife_arm.pixel_y = row_pixel_y - knife_arm.hv_animate_to(fist_end_w, fist_end_z, HV_VIS_KNIFE_CUT_TIME, QUAD_EASING|EASE_OUT) + var/is_south_wrap = was_standing && (victim.dir & SOUTH) && !(victim.dir & (EAST|WEST)) + var/list/anchor_end + if(is_south_wrap) + anchor_end = hv_vis_south_neck_anchor(fist_end_w, fist_end_z, knife_zone == BODY_ZONE_R_ARM) + else if(!QDELETED(user) && isturf(user.loc)) + anchor_end = hv_vis_shoulder_in_victim_frame(user, victim, knife_zone, step_dx, step_dy, attacker_lean_deg) + else + anchor_end = list(knife_arm.hv_last_anchor_w, knife_arm.hv_last_anchor_z) + knife_arm.hv_animate_to(fist_end_w, fist_end_z, anchor_end[1], anchor_end[2], HV_VIS_KNIFE_CUT_TIME, QUAD_EASING|EASE_OUT) QDEL_IN(knife_arm, cut_total) - else if(knife_arm && !QDELETED(knife_arm)) - qdel(knife_arm) - - hv_vis_blade_ref = null - hv_vis_knife_arm_ref = null + else + if(knife_arm && !QDELETED(knife_arm)) + qdel(knife_arm) + hv_vis_knife_arm_ref = null + hv_vis_restore_held_sprite() // Blood from the throat in the direction the victim faces, starting now as the wound lands. var/spray_dir = victim.dir || toward || SOUTH @@ -371,21 +520,23 @@ if(!QDELETED(user) && isturf(user.loc)) user.hv_vis_stop(list(HV_VIS_TAG_KNIFE_STEP)) var/matrix/attacker_base = matrix(user.transform) - var/matrix/attacker_lean = hv_vis_turned(attacker_base, HV_VIS_DX(toward) * 4, user.hv_vis_pivot()) + var/matrix/attacker_lean = hv_vis_turned(attacker_base, attacker_lean_deg, user.hv_vis_pivot()) user.hv_vis_play(HV_VIS_TAG_KNIFE_STEP, list( list(user.pixel_w + step_dx, user.pixel_z + step_dy, attacker_lean, 0, LINEAR_EASING), list(user.pixel_w + step_dx, user.pixel_z + step_dy, attacker_lean, cut_total, LINEAR_EASING), list(user.pixel_w, user.pixel_z, attacker_base, HV_VIS_KNIFE_RELEASE_TIME, SINE_EASING), )) - // Beat 4 on the victim: if still standing after the cut, hunch forward clutching the throat, then return. + // Beat 4 on the victim: if still standing after the cut, hold pulled pose through cut_total, then hunch and return. if(victim.stat != DEAD && victim.body_position == STANDING_UP) var/hunch_angle = victim.hv_vis_knife_hunch_tilt() var/lurch_dx = HV_VIS_DX(spray_dir) * 2 var/lurch_dy = (victim.dir & SOUTH) ? -2 : ((victim.dir & (EAST|WEST)) ? -1 : 0) + var/pull_x = victim.hv_vis_knife_pull_x + var/pull_y = victim.hv_vis_knife_pull_y var/pivot = victim.hv_vis_pivot() var/matrix/base = matrix(victim.transform) - var/matrix/tilted = hv_vis_turned(base, victim.hv_vis_knife_tilt, pivot) + var/matrix/pulled = hv_vis_knife_pose_matrix(base, victim.hv_vis_knife_tilt, victim.hv_vis_knife_stretch, pivot) var/matrix/hunched = hv_vis_turned(base, hunch_angle, pivot) var/hunch_total = cut_total + HV_VIS_KNIFE_HUNCH_IN + HV_VIS_KNIFE_HUNCH_HOLD + HV_VIS_KNIFE_HUNCH_OUT @@ -397,8 +548,8 @@ victim.hv_vis_knife_lurch_y = lurch_dy victim.hv_vis_play(HV_VIS_TAG_KNIFE_VICTIM, list( - list(victim.pixel_w, victim.pixel_z, tilted, 0, LINEAR_EASING), - list(victim.pixel_w, victim.pixel_z, tilted, cut_total, LINEAR_EASING), + list(victim.pixel_w + pull_x, victim.pixel_z + pull_y, pulled, 0, LINEAR_EASING), + list(victim.pixel_w + pull_x, victim.pixel_z + pull_y, pulled, cut_total, LINEAR_EASING), list(victim.pixel_w + lurch_dx, victim.pixel_z + lurch_dy, hunched, HV_VIS_KNIFE_HUNCH_IN, QUAD_EASING|EASE_OUT), list(victim.pixel_w + lurch_dx, victim.pixel_z + lurch_dy, hunched, HV_VIS_KNIFE_HUNCH_HOLD, LINEAR_EASING), list(victim.pixel_w, victim.pixel_z, base, HV_VIS_KNIFE_HUNCH_OUT, SINE_EASING), @@ -408,17 +559,19 @@ addtimer(CALLBACK(victim, TYPE_PROC_REF(/mob/living/carbon, hv_vis_spawn_clutch_hand), hunch_angle, lurch_dx, lurch_dy), cut_total, TIMER_DELETE_ME) else if(victim.stat != DEAD && !fell_now) victim.hv_vis_knife_t2 = world.time + cut_total + victim.hv_vis_knife_t3 = -1 + victim.hv_vis_knife_t4 = -1 victim.hv_vis_knife_hunch = 0 victim.hv_vis_knife_lurch_x = 0 victim.hv_vis_knife_lurch_y = 0 var/matrix/base_lying = matrix(victim.transform) - var/matrix/tilted_lying = hv_vis_turned(base_lying, victim.hv_vis_knife_tilt, victim.hv_vis_pivot()) + var/matrix/pulled_lying = hv_vis_knife_pose_matrix(base_lying, victim.hv_vis_knife_tilt, victim.hv_vis_knife_stretch, victim.hv_vis_pivot()) victim.hv_vis_play(HV_VIS_TAG_KNIFE_VICTIM, list( - list(victim.pixel_w, victim.pixel_z, tilted_lying, 0, LINEAR_EASING), - list(victim.pixel_w, victim.pixel_z, tilted_lying, cut_total, LINEAR_EASING), + list(victim.pixel_w, victim.pixel_z, pulled_lying, 0, LINEAR_EASING), + list(victim.pixel_w, victim.pixel_z, pulled_lying, cut_total, LINEAR_EASING), list(victim.pixel_w, victim.pixel_z, base_lying, HV_VIS_KNIFE_RELEASE_TIME, SINE_EASING), )) - else + else if(!fell_now) victim.hv_vis_knife_clear_pose() /// Spawns a small prop of this standing victim's own visible hand reaching up to clutch their throat during Beat 4. @@ -433,7 +586,7 @@ var/list/local_hand = hv_vis_local_hand_offset(src, clutch_zone) var/start_w = pixel_w + local_hand[1] var/start_z = pixel_z + local_hand[2] - var/list/hunched_throat = hv_vis_throat_for_angle(hunch_angle) + var/list/hunched_throat = hv_vis_throat_for_pose(hunch_angle, 0) var/clutch_w = round(pixel_w + lurch_dx + hunched_throat[1], 1) var/clutch_z = round(pixel_z + lurch_dy + hunched_throat[2], 1) var/total_life = HV_VIS_KNIFE_HUNCH_IN + HV_VIS_KNIFE_HUNCH_HOLD + HV_VIS_KNIFE_HUNCH_OUT @@ -465,24 +618,38 @@ else victim.hv_vis_stop(list(HV_VIS_TAG_KNIFE_VICTIM, HV_VIS_TAG_TREMBLE)) -/// Deletes any active knife execution props tracked by weakref on this knife. +/// Deletes any active knife execution props and restores the held knife's in-hand sprite. /obj/item/knife/proc/hv_vis_clear_exec_props() var/atom/blade = hv_vis_blade_ref?.resolve() + hv_vis_blade_ref = null if(blade && !QDELETED(blade)) qdel(blade) var/atom/knife_arm = hv_vis_knife_arm_ref?.resolve() + hv_vis_knife_arm_ref = null if(knife_arm && !QDELETED(knife_arm)) qdel(knife_arm) - hv_vis_blade_ref = null - hv_vis_knife_arm_ref = null + hv_vis_restore_held_sprite() // ---- Geometry helpers ---- -/// Throat offset list(x, y) from this mob's icon centre when leaned by `angle` degrees clockwise. -/mob/living/proc/hv_vis_throat_for_angle(angle) +/// Step-in offset list(dx, dy) bringing the attacker's chest up against the victim's back. +/// Deliberate exception to _motion_core.dm's "offsets under a third of a tile" rule: pixel_w and +/// pixel_z never change the SIDE_MAP sort row (y + pixel_y), so an attacker north of a south-facing +/// victim still sorts behind them when stepped 15 px south, and E/W attackers stay on the same row. +/proc/hv_vis_knife_step_offset(toward) + var/dx = HV_VIS_DX(toward) + var/dy = HV_VIS_DY(toward) + if(dx && dy) + return list(dx * HV_VIS_KNIFE_STEP_DIAG, dy * HV_VIS_KNIFE_STEP_DIAG) + if(dx) + return list(dx * HV_VIS_KNIFE_STEP_SIDE, 0) + return list(0, dy * HV_VIS_KNIFE_STEP_FRONT) + +/// Throat offset list(x, y) from this mob's icon centre when posed by `angle` degrees and feet-anchored `stretch`. +/mob/living/proc/hv_vis_throat_for_pose(angle, stretch = 0) var/base_x = (dir & EAST) ? 3.5 : ((dir & WEST) ? -3.5 : -0.5) var/base_y = 5.5 - var/matrix/pose = hv_vis_turned(matrix(transform), angle, hv_vis_pivot()) + var/matrix/pose = hv_vis_knife_pose_matrix(matrix(transform), angle, stretch, hv_vis_pivot()) return list( round(pose.a * base_x + pose.b * base_y + pose.c, 0.01), round(pose.d * base_x + pose.e * base_y + pose.f, 0.01), @@ -493,15 +660,30 @@ if(body_position == LYING_DOWN) var/toward_attacker = HV_VIS_DX(get_dir(src, attacker)) || -1 return toward_attacker * HV_VIS_KNIFE_TILT_LYING - if(dir & EAST) - return -HV_VIS_KNIFE_TILT_SIDE - if(dir & WEST) - return HV_VIS_KNIFE_TILT_SIDE - var/back_dx = HV_VIS_DX(get_dir(src, attacker)) - if(back_dx) - return back_dx * HV_VIS_KNIFE_TILT_FRONT + var/att_dx = HV_VIS_DX(get_dir(src, attacker)) + if(dir & (EAST|WEST)) + var/back_sign = att_dx || -HV_VIS_DX(dir) + return back_sign * HV_VIS_KNIFE_TILT_SIDE + if(att_dx) + return att_dx * HV_VIS_KNIFE_TILT_FRONT return (dir & NORTH) ? HV_VIS_KNIFE_TILT_FRONT : -HV_VIS_KNIFE_TILT_FRONT +/// Pixel shift list(dx, dy) pulling a standing N/S victim 2 px toward `attacker` during wind-up and cut. +/mob/living/proc/hv_vis_knife_windup_pull(mob/living/attacker) + if(body_position != STANDING_UP || (dir & (EAST|WEST))) + return list(0, 0) + var/toward_att = get_dir(src, attacker) || turn(dir, 180) + var/dy = HV_VIS_DY(toward_att) + if(dy) + return list(0, dy * HV_VIS_KNIFE_PULL_FRONT) + return list(HV_VIS_DX(toward_att) * HV_VIS_KNIFE_PULL_FRONT, 0) + +/// Feet-anchored vertical stretch lifting a standing N/S victim's head 1 px up during wind-up and cut. +/mob/living/proc/hv_vis_knife_windup_stretch() + if(body_position != STANDING_UP || (dir & (EAST|WEST))) + return 0 + return HV_VIS_KNIFE_HEAD_STRETCH + /// Clockwise tilt angle (degrees) for a standing survivor hunching forward about their feet after release. /mob/living/proc/hv_vis_knife_hunch_tilt() if(dir & EAST) @@ -546,12 +728,145 @@ return list(right_hand ? -3 : 3, -1) return list(right_hand ? -7 : 6, -1) -/// Converts `attacker`'s hand position (with optional extra step `step_dx`, `step_dy`) into `victim`'s turf pixel_w/pixel_z frame. +/// Pixel offset list(x, y) of `arm_zone`'s shoulder top from `holder`'s icon centre. +/proc/hv_vis_local_shoulder_offset(mob/living/holder, arm_zone) + var/right_hand = (arm_zone == BODY_ZONE_R_ARM) + switch(holder.dir) + if(NORTH) + return list(right_hand ? 6 : -6, 4) + if(EAST) + return list(-2, 4) + if(WEST) + return list(2, 4) + return list(right_hand ? -6 : 6, 4) + +/// Converts `attacker`'s hand position (with optional extra step `step_dx`, `step_dy`) into `victim`'s turf frame. /proc/hv_vis_hand_in_victim_frame(mob/living/attacker, mob/living/victim, arm_zone, step_dx = 0, step_dy = 0) var/list/local_hand = hv_vis_local_hand_offset(attacker, arm_zone) var/frame_x = (attacker.x - victim.x) * ICON_SIZE_X + (attacker.pixel_x - victim.pixel_x) + attacker.pixel_w + step_dx + local_hand[1] var/frame_y = (attacker.y - victim.y) * ICON_SIZE_Y + (attacker.pixel_y - victim.pixel_y) + attacker.pixel_z + step_dy + local_hand[2] - return list(round(frame_x, 1), round(frame_y, 1)) + return list(round(frame_x, 0.01), round(frame_y, 0.01)) + +/// Converts `attacker`'s shoulder position (including `step_dx`, `step_dy` and `lean_deg`) into `victim`'s turf frame. +/proc/hv_vis_shoulder_in_victim_frame(mob/living/attacker, mob/living/victim, arm_zone, step_dx = 0, step_dy = 0, lean_deg = 0) + var/list/local_shoulder = hv_vis_local_shoulder_offset(attacker, arm_zone) + var/matrix/pose = hv_vis_turned(matrix(attacker.transform), lean_deg, attacker.hv_vis_pivot()) + var/rot_x = pose.a * local_shoulder[1] + pose.b * local_shoulder[2] + pose.c + var/rot_y = pose.d * local_shoulder[1] + pose.e * local_shoulder[2] + pose.f + var/frame_x = (attacker.x - victim.x) * ICON_SIZE_X + (attacker.pixel_x - victim.pixel_x) + attacker.pixel_w + step_dx + rot_x + var/frame_y = (attacker.y - victim.y) * ICON_SIZE_Y + (attacker.pixel_y - victim.pixel_y) + attacker.pixel_z + step_dy + rot_y + return list(round(frame_x, 0.01), round(frame_y, 0.01)) + +/// Collar-side wrap point list(x, y) where the attacker's forearm rounds a SOUTH-facing victim's neck from behind, staying below the chin. +/proc/hv_vis_south_neck_anchor(fist_w, fist_z, right_hand) + var/side_w = right_hand ? min(-6.8, fist_w - 4.2) : max(6.8, fist_w + 4.2) + return list(round(side_w, 0.01), round(fist_z - 1.5, 0.01)) + +/// Clones a worn mutable_appearance into SOUTH on FLOAT_PLANE, stripping emissive children so an alpha mask clips cleanly. +/proc/hv_vis_clean_arm_appearance(source_entry, draw_layer) + if(!source_entry) + return null + var/mutable_appearance/copied = new() + copied.appearance = source_entry + if(copied.plane != FLOAT_PLANE) + return null + copied.dir = SOUTH + copied.layer = draw_layer + copied.appearance_flags &= ~RESET_COLOR + if(length(copied.overlays)) + var/list/raw_children = copied.overlays.Copy() + copied.overlays.Cut() + for(var/child in raw_children) + var/mutable_appearance/clean_child = hv_vis_clean_arm_appearance(child, draw_layer) + if(clean_child) + copied.overlays += clean_child + return copied + +/// Appends cleaned SOUTH copies of `slot_entry` (single appearance or list) onto `arm_group` at `draw_layer`. +/proc/hv_vis_append_arm_slot(mutable_appearance/arm_group, slot_entry, draw_layer) + if(!slot_entry) + return + if(islist(slot_entry)) + for(var/sub_entry in slot_entry) + var/mutable_appearance/clean_sub = hv_vis_clean_arm_appearance(sub_entry, draw_layer) + if(clean_sub) + arm_group.overlays += clean_sub + return + var/mutable_appearance/clean_entry = hv_vis_clean_arm_appearance(slot_entry, draw_layer) + if(clean_entry) + arm_group.overlays += clean_entry + +/// Builds a clothed forearm-and-hand mutable_appearance from `holder`'s real `arm_zone` (skin + sleeve + gloves), +/// shifted so its fist sits on `(0, 0)` and its forearm extends 6 px along `+y` toward the shoulder. +/proc/hv_vis_build_forearm_overlay(mob/living/holder, arm_zone) + if(!iscarbon(holder)) + return null + var/mob/living/carbon/carbon_holder = holder + var/obj/item/bodypart/arm = carbon_holder.get_bodypart(arm_zone) + if(!arm) + var/fallback_zone = (arm_zone == BODY_ZONE_R_ARM) ? BODY_ZONE_L_ARM : BODY_ZONE_R_ARM + arm = carbon_holder.get_bodypart(fallback_zone) + if(!arm) + return null + + var/expected_arm_state = arm.is_dimorphic ? "[arm.limb_id]_[arm.body_zone]_[arm.limb_gender]" : "[arm.limb_id]_[arm.body_zone]" + var/expected_hand_state = arm.aux_zone ? "[arm.limb_id]_[arm.aux_zone]" : null + var/image/limb_img + var/image/hand_img + var/image/fallback_img + var/list/limb_layers = arm.get_limb_icon(dropped = FALSE, update_on = carbon_holder) + for(var/entry in limb_layers) + if(!istype(entry, /image)) + continue + var/image/img = entry + if(img.plane == EMISSIVE_PLANE || !img.icon || !img.icon_state) + continue + if(expected_hand_state && img.icon_state == expected_hand_state) + hand_img = img + continue + if(img.icon_state == expected_arm_state) + limb_img = img + continue + if(!fallback_img) + fallback_img = img + if(!limb_img) + limb_img = fallback_img || hand_img + if(!limb_img) + return null + + // In SOUTH, human_r_arm sits at cols 7-10 rows 11-17 (fist at -7, -1) and human_l_arm at cols 20-23 rows 11-17 (fist at +6, -1). + var/mutable_appearance/arm_group = mutable_appearance(layer = FLOAT_LAYER, appearance_flags = KEEP_TOGETHER) + arm_group.pixel_w = (arm.body_zone == BODY_ZONE_R_ARM) ? 7 : -6 + arm_group.pixel_z = 1 + + var/mutable_appearance/skin_arm = mutable_appearance(limb_img.icon, limb_img.icon_state, 1) + skin_arm.dir = SOUTH + skin_arm.color = limb_img.color + skin_arm.alpha = limb_img.alpha + arm_group.overlays += skin_arm + + var/mob/living/carbon/human/human_holder = ishuman(carbon_holder) ? carbon_holder : null + if(human_holder) + if(human_holder.w_uniform) + hv_vis_append_arm_slot(arm_group, human_holder.overlays_standing[UNIFORM_LAYER], 2) + if(human_holder.wear_suit) + hv_vis_append_arm_slot(arm_group, human_holder.overlays_standing[SUIT_LAYER], 3) + + if(hand_img) + var/mutable_appearance/skin_hand = mutable_appearance(hand_img.icon, hand_img.icon_state, 4) + skin_hand.dir = SOUTH + skin_hand.color = hand_img.color + skin_hand.alpha = hand_img.alpha + arm_group.overlays += skin_hand + + if(human_holder && human_holder.gloves) + hv_vis_append_arm_slot(arm_group, human_holder.overlays_standing[GLOVES_LAYER], 5) + + var/icon/mask_icon = icon(limb_img.icon, limb_img.icon_state, SOUTH) + if(hand_img) + mask_icon.Blend(icon(hand_img.icon, hand_img.icon_state, SOUTH), ICON_OVERLAY) + arm_group.filters += filter(type = "alpha", icon = mask_icon) + return arm_group /// Builds a small skin-tinted hand mutable_appearance from `holder`'s `arm_zone` shifted so its fist sits on (0, 0). /proc/hv_vis_build_hand_overlay(mob/living/holder, arm_zone) @@ -591,7 +906,7 @@ // ---- Visual props ---- -/// Temporary visual copy of the real knife blade, scaled to ~11 px and drawn across the victim's throat. +/// Temporary visual copy of the real knife blade, scaled to ~10 px and drawn across the victim's throat. /obj/effect/temp_visual/hv_knife_exec_blade name = "knife blade" plane = GAME_PLANE @@ -602,6 +917,8 @@ var/hv_knife_exec_blade = TRUE /// Native icon_angle of the source knife so rotations align its blade along any target angle. var/hv_native_icon_angle = -90 + /// Weakref to the source knife so destroying this prop always restores its in-hand sprite. + var/datum/weakref/hv_source_knife_ref /obj/effect/temp_visual/hv_knife_exec_blade/Initialize(mapload, obj/item/knife/source_knife, row_x = 0, row_y = 0, start_w = 0, start_z = 0, blade_deg = 0, draw_layer = HV_VIS_KNIFE_BLADE_LAYER, life = 25) if(life > 0) @@ -609,6 +926,7 @@ . = ..() if(!istype(source_knife)) return INITIALIZE_HINT_QDEL + hv_source_knife_ref = WEAKREF(source_knife) name = source_knife.name icon = source_knife.icon icon_state = source_knife.icon_state @@ -618,50 +936,65 @@ layer = draw_layer pixel_x = row_x pixel_y = row_y + pixel_w = 0 + pixel_z = 0 hv_place_at(start_w, start_z, blade_deg) -/// Matrix scaling this knife to ~10 px overall, orienting its blade along `blade_deg` clockwise from EAST, with optional sub-pixel shift. -/obj/effect/temp_visual/hv_knife_exec_blade/proc/hv_turn_matrix(blade_deg, shift_x = 0, shift_y = 0) +/obj/effect/temp_visual/hv_knife_exec_blade/Destroy() + var/obj/item/knife/source_knife = hv_source_knife_ref?.resolve() + hv_source_knife_ref = null + if(source_knife) + var/atom/active_blade = source_knife.hv_vis_blade_ref?.resolve() + if(!active_blade || active_blade == src || QDELETED(active_blade)) + source_knife.hv_vis_blade_ref = null + source_knife.hv_vis_restore_held_sprite() + return ..() + +/// Matrix scaling this knife to ~10 px overall, orienting its blade along `blade_deg` clockwise from EAST, and translating to `(exact_w, exact_z)`. +/obj/effect/temp_visual/hv_knife_exec_blade/proc/hv_turn_matrix(blade_deg, exact_w = 0, exact_z = 0) var/axis_span = max(abs(cos(hv_native_icon_angle)), abs(sin(hv_native_icon_angle)), 0.7071) var/blade_scale = HV_VIS_KNIFE_SCALE * (axis_span / 0.7071) var/matrix/turned = matrix() turned.Scale(blade_scale, blade_scale) turned.Turn(blade_deg - hv_native_icon_angle) - if(shift_x || shift_y) - turned.Translate(shift_x, shift_y) + if(exact_w || exact_z) + turned.Translate(exact_w, exact_z) return turned -/// Places this blade prop at exact float `(exact_w, exact_z)` and `blade_deg`, putting the sub-pixel remainder in `transform`. +/// Places this blade prop at exact float `(exact_w, exact_z)` in `transform` (keeping `pixel_w = pixel_z = 0` to avoid integer rounding jumps). /obj/effect/temp_visual/hv_knife_exec_blade/proc/hv_place_at(exact_w, exact_z, blade_deg) - var/int_w = round(exact_w, 1) - var/int_z = round(exact_z, 1) - pixel_w = int_w - pixel_z = int_z - transform = hv_turn_matrix(blade_deg, exact_w - int_w, exact_z - int_z) + pixel_w = 0 + pixel_z = 0 + transform = hv_turn_matrix(blade_deg, exact_w, exact_z) -/// Animates this blade prop to exact float `(exact_w, exact_z)` and `blade_deg` with sub-pixel accuracy. +/// Animates this blade prop purely through float `transform` so it stays locked to the forearm's hand every frame. /obj/effect/temp_visual/hv_knife_exec_blade/proc/hv_animate_to(exact_w, exact_z, blade_deg, anim_time, anim_easing) - var/int_w = round(exact_w, 1) - var/int_z = round(exact_z, 1) - var/matrix/blade_turn = hv_turn_matrix(blade_deg, exact_w - int_w, exact_z - int_z) - animate(src, pixel_w = int_w, pixel_z = int_z, transform = blade_turn, time = anim_time, easing = anim_easing) - -/// Pixel offset list(dx, dy) from this blade prop's centre for axial sprite point `along_px`, through `hv_turn_matrix`. -/obj/effect/temp_visual/hv_knife_exec_blade/proc/hv_point_offset(blade_deg, along_px) - var/nx = cos(hv_native_icon_angle) - var/ny = -sin(hv_native_icon_angle) - var/axis_span = max(abs(nx), abs(ny), 0.5) + var/matrix/blade_turn = hv_turn_matrix(blade_deg, exact_w, exact_z) + animate(src, transform = blade_turn, time = anim_time, easing = anim_easing) + +/// Pixel offset list(dx, dy) from a scaled knife prop's centre for axial sprite point `along_px` at `blade_deg`. +/proc/hv_vis_knife_point_offset(native_angle, blade_deg, along_px) + var/nx = cos(native_angle) + var/ny = -sin(native_angle) + var/axis_span = max(abs(nx), abs(ny), 0.7071) + var/blade_scale = HV_VIS_KNIFE_SCALE * (axis_span / 0.7071) var/local_x = along_px * nx / axis_span var/local_y = along_px * ny / axis_span - var/matrix/turned = hv_turn_matrix(blade_deg) + var/matrix/turned = matrix() + turned.Scale(blade_scale, blade_scale) + turned.Turn(blade_deg - native_angle) return list( turned.a * local_x + turned.b * local_y + turned.c, turned.d * local_x + turned.e * local_y + turned.f, ) -/// Small skin-tinted hand prop built from the attacker's real arm bodypart, centred on the fist over the knife grip. +/// Pixel offset list(dx, dy) from this blade prop's centre for axial sprite point `along_px`, through `hv_turn_matrix`. +/obj/effect/temp_visual/hv_knife_exec_blade/proc/hv_point_offset(blade_deg, along_px) + return hv_vis_knife_point_offset(hv_native_icon_angle, blade_deg, along_px) + +/// Clothed forearm-and-hand prop built from the attacker's real arm + sleeve sprites, joining the hand on the knife grip to the shoulder. /obj/effect/temp_visual/hv_knife_exec_arm - name = "hand" + name = "forearm" icon = 'icons/mob/human/bodyparts_greyscale.dmi' icon_state = "" plane = GAME_PLANE @@ -669,36 +1002,50 @@ appearance_flags = KEEP_TOGETHER randomdir = FALSE duration = 25 + /// Last shoulder/neck anchor x/y in the victim's turf frame, preserved if the attacker leaves before Beat 3. + var/hv_last_anchor_w = 0 + var/hv_last_anchor_z = 0 -/obj/effect/temp_visual/hv_knife_exec_arm/Initialize(mapload, mob/living/holder, arm_zone = BODY_ZONE_R_ARM, row_x = 0, row_y = 0, fist_w = 0, fist_z = 0, draw_layer = HV_VIS_KNIFE_HAND_LAYER, life = 25) +/obj/effect/temp_visual/hv_knife_exec_arm/Initialize(mapload, mob/living/holder, arm_zone = BODY_ZONE_R_ARM, row_x = 0, row_y = 0, fist_w = 0, fist_z = 0, anchor_w = 0, anchor_z = 6, draw_layer = HV_VIS_KNIFE_HAND_LAYER, life = 25) if(life > 0) duration = life . = ..() layer = draw_layer pixel_x = row_x pixel_y = row_y - var/int_w = round(fist_w, 1) - var/int_z = round(fist_z, 1) - pixel_w = int_w - pixel_z = int_z - transform = hv_shift_matrix(fist_w - int_w, fist_z - int_z) - var/mutable_appearance/hand_overlay = hv_vis_build_hand_overlay(holder, arm_zone) - if(hand_overlay) - add_overlay(hand_overlay) - -/// Sub-pixel translation matrix for keeping the hand prop locked to the scaled knife grip. -/obj/effect/temp_visual/hv_knife_exec_arm/proc/hv_shift_matrix(shift_x = 0, shift_y = 0) - var/matrix/shifted = matrix() - if(shift_x || shift_y) - shifted.Translate(shift_x, shift_y) - return shifted - -/// Animates this hand prop to exact float `(exact_w, exact_z)` with sub-pixel accuracy. -/obj/effect/temp_visual/hv_knife_exec_arm/proc/hv_animate_to(exact_w, exact_z, anim_time, anim_easing) - var/int_w = round(exact_w, 1) - var/int_z = round(exact_z, 1) - var/matrix/shifted = hv_shift_matrix(exact_w - int_w, exact_z - int_z) - animate(src, pixel_w = int_w, pixel_z = int_z, transform = shifted, time = anim_time, easing = anim_easing) + pixel_w = 0 + pixel_z = 0 + hv_last_anchor_w = anchor_w + hv_last_anchor_z = anchor_z + transform = hv_arm_matrix(fist_w, fist_z, anchor_w, anchor_z) + var/mutable_appearance/arm_overlay = hv_vis_build_forearm_overlay(holder, arm_zone) + if(arm_overlay) + add_overlay(arm_overlay) + +/// Float transform placing the fist `(0, 0)` on `(fist_w, fist_z)` and stretching the forearm `(0, +6)` toward `(anchor_w, anchor_z)` (at most 2x). +/obj/effect/temp_visual/hv_knife_exec_arm/proc/hv_arm_matrix(fist_w, fist_z, anchor_w, anchor_z) + var/dx = anchor_w - fist_w + var/dy = anchor_z - fist_z + var/dist = sqrt(dx * dx + dy * dy) + var/len_scale = 1 + var/turn_deg = 0 + if(dist >= 0.25) + len_scale = clamp(dist / HV_VIS_KNIFE_ARM_BASE_LEN, 0.65, HV_VIS_KNIFE_ARM_MAX_STRETCH) + turn_deg = arctan(dy, dx) + var/matrix/arm_mat = matrix() + arm_mat.Scale(1, len_scale) + if(turn_deg) + arm_mat.Turn(turn_deg) + if(fist_w || fist_z) + arm_mat.Translate(fist_w, fist_z) + return arm_mat + +/// Animates this forearm prop purely through float `transform` so its hand `(0, 0)` stays locked to the knife grip every frame. +/obj/effect/temp_visual/hv_knife_exec_arm/proc/hv_animate_to(fist_w, fist_z, anchor_w, anchor_z, anim_time, anim_easing) + hv_last_anchor_w = anchor_w + hv_last_anchor_z = anchor_z + var/matrix/arm_mat = hv_arm_matrix(fist_w, fist_z, anchor_w, anchor_z) + animate(src, transform = arm_mat, time = anim_time, easing = anim_easing) /// Small skin-tinted hand prop for a standing survivor clutching their own throat after release; vanishes early if they move or fall. /obj/effect/temp_visual/hv_knife_clutch_hand From 90393d4a1c670492c8157be9053a5c9677f0d462 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 00:24:25 -0800 Subject: [PATCH 48/78] Knife executions: the whole blade shows in front of the neck, no white flash on the cut --- .../overlays_exec/knife_executions.dm | 6 +----- .../modules/hyperviolence/visuals/_defines.dm | 20 ++++++++----------- .../visuals/knife_execution_motion.dm | 11 ++++------ 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm b/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm index 166512588e2..b94b3abefd0 100644 --- a/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm +++ b/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm @@ -88,11 +88,7 @@ return FALSE return victim.hv_can_be_executed() || check_behind(user, victim) -/** - * Lands the knife execution: stabs the head through the real attack() path with the point-blank - * multiplier, then opens a head slash wound scaled by the head's combined melee cover and sealed - * headgear, adding neck_slice only when the throat is unarmoured and exposed. Returns TRUE on completion. - */ +/// Lands the knife execution: stabs the head at point-blank force, opens a cover-scaled head slash wound, and slices exposed throats. /obj/item/knife/proc/hv_finish_knife_execution(mob/living/user, mob/living/carbon/victim, list/modifiers, list/attack_modifiers) if(!hv_knife_execution_holds(user, victim)) return FALSE diff --git a/voidcrew/modules/hyperviolence/visuals/_defines.dm b/voidcrew/modules/hyperviolence/visuals/_defines.dm index 8f6692f06bd..b9b6af35919 100644 --- a/voidcrew/modules/hyperviolence/visuals/_defines.dm +++ b/voidcrew/modules/hyperviolence/visuals/_defines.dm @@ -143,6 +143,8 @@ #define HV_VIS_KILL_SHAKE_RANGE 7 // ---- Knife executions ---- +// Step-in offsets below are a deliberate exception to _motion_core.dm's third-of-a-tile rule: pixel_w +// and pixel_z never change the SIDE_MAP sort row (y + pixel_y), so cross-tile sort order is preserved. /// Named animation sequence for the attacker stepping in and out during a knife execution. #define HV_VIS_TAG_KNIFE_STEP "hv_knife_step" @@ -152,7 +154,7 @@ #define HV_VIS_KNIFE_GRAB_TIME (0.3 SECONDS) /// How long the blade takes to draw across the victim's throat at the end of the wind-up. #define HV_VIS_KNIFE_CUT_TIME (0.25 SECONDS) -/// Brief hold at the end of the throat cut before the attacker lets go and the blade prop vanishes. +/// Brief hold at the end of the throat cut before the attacker lets go and the props vanish. #define HV_VIS_KNIFE_CUT_HOLD (0.1 SECONDS) /// How long the attacker takes to step back to zero offset after the cut completes. #define HV_VIS_KNIFE_RELEASE_TIME (0.25 SECONDS) @@ -165,19 +167,13 @@ /// How long a standing survivor takes to return from the forward hunch to their true pose. #define HV_VIS_KNIFE_HUNCH_OUT (0.3 SECONDS) /// Pixels a side-on (E/W) attacker steps toward the victim so their chest meets the victim's back. -/// Deliberate exception to _motion_core.dm's "offsets under a third of a tile" rule: pixel_w/pixel_z -/// never change the SIDE_MAP sort row (y + pixel_y), so sort order across tiles is preserved. #define HV_VIS_KNIFE_STEP_SIDE 19 /// Pixels a north/south attacker steps toward the victim so their chest meets the victim's back. -/// Deliberate exception to _motion_core.dm's third-of-a-tile rule: pixel_z never changes sort row, -/// so an attacker north of a south-facing victim still sorts behind them. #define HV_VIS_KNIFE_STEP_FRONT 15 /// Per-axis pixels a diagonal attacker steps toward a helpless victim. #define HV_VIS_KNIFE_STEP_DIAG 13 /// Degrees a side-facing standing victim is tilted back toward the attacker about their feet. #define HV_VIS_KNIFE_TILT_SIDE 7 -/// Degrees a north- or south-facing standing victim leans sideways during the wind-up (0 keeps throat centred). -#define HV_VIS_KNIFE_TILT_FRONT 0 /// Pixels a north- or south-facing standing victim shifts back toward the attacker during the wind-up. #define HV_VIS_KNIFE_PULL_FRONT 2 /// Feet-anchored vertical stretch added to a north- or south-facing victim so their head draws 1 px up. @@ -196,11 +192,11 @@ #define HV_VIS_KNIFE_SPRITE_GRIP -8.75 /// Unscaled axial sprite coordinate (from 32x32 centre) of the cutting edge heel where a front draw begins. #define HV_VIS_KNIFE_SPRITE_HEEL -2 -/// Unscaled axial sprite coordinate resting on a side-facing victim's throat while held (~1.6 px behind tip). +/// Unscaled axial sprite coordinate resting on a side-facing victim's throat while held. #define HV_VIS_KNIFE_SPRITE_SIDE_HOLD 8 /// Unscaled axial sprite coordinate (from 32x32 centre) of the blade tip that finishes on the throat. #define HV_VIS_KNIFE_SPRITE_TIP 12 -/// Layer for the knife blade when visible in front of the victim's neck (above MOB_LAYER 4.0). -#define HV_VIS_KNIFE_BLADE_LAYER 4.05 -/// Layer for the attacker's knife hand in front of the blade grip and the victim's neck. -#define HV_VIS_KNIFE_HAND_LAYER 4.06 +/// Layer for the attacker's clothed forearm and hand in front of the victim's neck (above MOB_LAYER 4.0). +#define HV_VIS_KNIFE_ARM_LAYER 4.05 +/// Layer for the knife blade above the forearm prop so the full blade shows in front of the neck. +#define HV_VIS_KNIFE_BLADE_LAYER 4.06 diff --git a/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm b/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm index 483d47a0b26..f4547d0ae27 100644 --- a/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm +++ b/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm @@ -398,7 +398,7 @@ fist_start_z, anchor_start[1], anchor_start[2], - HV_VIS_KNIFE_HAND_LAYER, + HV_VIS_KNIFE_ARM_LAYER, cut_hold_total + 1 SECONDS, ) knife_arm.hv_animate_to(fist_in_w, fist_in_z, anchor_in[1], anchor_in[2], HV_VIS_KNIFE_GRAB_TIME, QUAD_EASING|EASE_OUT) @@ -418,7 +418,6 @@ // Stop the wind-up sequence and any hit flinch before starting the cut/release pose on the victim. victim.hv_vis_stop(list(HV_VIS_TAG_FLINCH, HV_VIS_TAG_TREMBLE, HV_VIS_TAG_KNIFE_VICTIM)) - victim.hv_vis_flash() // If the stab dropped a standing victim (crit or dead), keep them in their pulled upright pose through // the 0.35 s cut + hold before tg's lying fall takes over, so the throat doesn't snap mid-cut. @@ -664,9 +663,7 @@ if(dir & (EAST|WEST)) var/back_sign = att_dx || -HV_VIS_DX(dir) return back_sign * HV_VIS_KNIFE_TILT_SIDE - if(att_dx) - return att_dx * HV_VIS_KNIFE_TILT_FRONT - return (dir & NORTH) ? HV_VIS_KNIFE_TILT_FRONT : -HV_VIS_KNIFE_TILT_FRONT + return 0 // north/south: the pull is a shift toward the attacker (hv_vis_knife_windup_pull), not a lean /// Pixel shift list(dx, dy) pulling a standing N/S victim 2 px toward `attacker` during wind-up and cut. /mob/living/proc/hv_vis_knife_windup_pull(mob/living/attacker) @@ -998,7 +995,7 @@ icon = 'icons/mob/human/bodyparts_greyscale.dmi' icon_state = "" plane = GAME_PLANE - layer = HV_VIS_KNIFE_HAND_LAYER + layer = HV_VIS_KNIFE_ARM_LAYER appearance_flags = KEEP_TOGETHER randomdir = FALSE duration = 25 @@ -1006,7 +1003,7 @@ var/hv_last_anchor_w = 0 var/hv_last_anchor_z = 0 -/obj/effect/temp_visual/hv_knife_exec_arm/Initialize(mapload, mob/living/holder, arm_zone = BODY_ZONE_R_ARM, row_x = 0, row_y = 0, fist_w = 0, fist_z = 0, anchor_w = 0, anchor_z = 6, draw_layer = HV_VIS_KNIFE_HAND_LAYER, life = 25) +/obj/effect/temp_visual/hv_knife_exec_arm/Initialize(mapload, mob/living/holder, arm_zone = BODY_ZONE_R_ARM, row_x = 0, row_y = 0, fist_w = 0, fist_z = 0, anchor_w = 0, anchor_z = 6, draw_layer = HV_VIS_KNIFE_ARM_LAYER, life = 25) if(life > 0) duration = life . = ..() From 2ec45bf15bf6bbbeaf7cf7695c00601e9ec3f3d5 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 00:35:09 -0800 Subject: [PATCH 49/78] Knife executions: register the throat-clutch hand's signals with RegisterSignals --- .../modules/hyperviolence/visuals/knife_execution_motion.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm b/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm index f4547d0ae27..90de62e5858 100644 --- a/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm +++ b/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm @@ -1071,7 +1071,7 @@ add_overlay(hand_overlay) if(victim) hv_owner_ref = WEAKREF(victim) - RegisterSignal(victim, list(COMSIG_MOVABLE_MOVED, COMSIG_LIVING_SET_BODY_POSITION, COMSIG_LIVING_DEATH), PROC_REF(hv_drop_clutch)) + RegisterSignals(victim, list(COMSIG_MOVABLE_MOVED, COMSIG_LIVING_SET_BODY_POSITION, COMSIG_LIVING_DEATH), PROC_REF(hv_drop_clutch)) /obj/effect/temp_visual/hv_knife_clutch_hand/Destroy() var/mob/living/victim = hv_owner_ref?.resolve() From 5b219572c61a2fce07a94592406fcb2b7f1fcb2e Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 04:18:17 -0800 Subject: [PATCH 50/78] Gun kata chip: hip throw, shoulder flip, wall slam, disarm and human shield from tg's grab, throw and shove; guards stand off against someone holding one of their own --- tgstation.dme | 5 + voidcrew/_DEFINES/stealth_gunfu.dm | 59 ++++ voidcrew/modules/stealth/stealth_gunfu.dm | 289 ++++++++++++++++++ .../modules/stealth/stealth_gunfu_admin.dm | 106 +++++++ .../modules/stealth/stealth_gunfu_motion.dm | 27 ++ voidcrew/modules/stealth/stealth_hostage.dm | 220 +++++++++++++ voidcrew/modules/unit_tests/_unit_tests.dm | 1 + .../unit_tests/voidcrew_stealth_gunfu.dm | 210 +++++++++++++ 8 files changed, 917 insertions(+) create mode 100644 voidcrew/_DEFINES/stealth_gunfu.dm create mode 100644 voidcrew/modules/stealth/stealth_gunfu.dm create mode 100644 voidcrew/modules/stealth/stealth_gunfu_admin.dm create mode 100644 voidcrew/modules/stealth/stealth_gunfu_motion.dm create mode 100644 voidcrew/modules/stealth/stealth_hostage.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_stealth_gunfu.dm diff --git a/tgstation.dme b/tgstation.dme index 63228436cc9..e6b493c31cd 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -6742,6 +6742,7 @@ #include "voidcrew\_DEFINES\shuttles.dm" #include "voidcrew\_DEFINES\sound.dm" #include "voidcrew\_DEFINES\stealth.dm" +#include "voidcrew\_DEFINES\stealth_gunfu.dm" #include "voidcrew\_DEFINES\stealth_hearing.dm" #include "voidcrew\_DEFINES\subsystems.dm" #include "voidcrew\_DEFINES\techweb_nodes.dm" @@ -7738,7 +7739,11 @@ #include "voidcrew\modules\stealth\stealth_crits.dm" #include "voidcrew\modules\stealth\stealth_disguise.dm" #include "voidcrew\modules\stealth\stealth_doors.dm" +#include "voidcrew\modules\stealth\stealth_gunfu.dm" +#include "voidcrew\modules\stealth\stealth_gunfu_admin.dm" +#include "voidcrew\modules\stealth\stealth_gunfu_motion.dm" #include "voidcrew\modules\stealth\stealth_hearing.dm" +#include "voidcrew\modules\stealth\stealth_hostage.dm" #include "voidcrew\modules\stealth\stealth_knife.dm" #include "voidcrew\modules\stealth\stealth_light.dm" #include "voidcrew\modules\stealth\stealth_meter.dm" diff --git a/voidcrew/_DEFINES/stealth_gunfu.dm b/voidcrew/_DEFINES/stealth_gunfu.dm new file mode 100644 index 00000000000..e0f7240158f --- /dev/null +++ b/voidcrew/_DEFINES/stealth_gunfu.dm @@ -0,0 +1,59 @@ +// Gun-fu (stealth step 3c, owner decisions 14-17 and 22). voidcrew/modules/stealth/stealth_gunfu.dm. +// Balance notes for developers; none of these numbers go in player text. + +/// Close-quarters combat chips, head. The gun kata chip; martial arts chips compete for it later (decision 16). +#define ORGAN_SLOT_CYBERWARE_COMBAT_CHIP "cyberware_combat_chip" + +/// The moves, as their admin tool and logs name them. +#define GUNFU_MOVE_HIP_THROW "hip throw" +#define GUNFU_MOVE_FLIP "shoulder flip" +#define GUNFU_MOVE_WALL_SLAM "wall slam" +#define GUNFU_MOVE_DISARM "disarm" +#define GUNFU_MOVE_SHIELD "human shield" + +/// One move every this long, all moves shared. +#define GUNFU_MOVE_COOLDOWN (3 SECONDS) +/// How long after a move the mover's shots on that victim get the gun-fu crit bonus. +#define GUNFU_MARK_TIME (3 SECONDS) +/// Added to the aimed crit roll of the mover's shots on a marked victim (on top of tg's helpless bonus for a body on the floor). +#define GUNFU_CRIT_BONUS 10 +/// Added again when the shot is aimed at the head. +#define GUNFU_CRIT_HEAD_BONUS 10 + +/// Hip throw: how far the victim goes, and how long tg's knockdown holds them when they land. +#define GUNFU_HIP_THROW_RANGE 2 +#define GUNFU_HIP_THROW_KNOCKDOWN (2 SECONDS) +/// Hip throw: brute on landing, through tg's armour (melee). +#define GUNFU_HIP_THROW_DAMAGE 5 + +/// Shoulder flip: lands on the next tile, flat on their back. +#define GUNFU_FLIP_KNOCKDOWN (3 SECONDS) +#define GUNFU_FLIP_DAMAGE 8 + +/// Wall slam: brute from the wall, on top of tg's own shove knockdown into something solid. +#define GUNFU_SLAM_DAMAGE 8 + +/// Disarm: how far the knocked-away item skids. +#define GUNFU_DISARM_THROW_RANGE 2 + +/// Human shield: how far in front of the holder the held body is drawn, in pixels. +#define GUNFU_SHIELD_SHIFT 12 +/// Human shield: shots within this many degrees of the holder's facing hit the held body. +#define GUNFU_SHIELD_ARC 67.5 + +// ---- Hostages (step 5, decision 47+) ---- + +/// Guards never stand closer than this to someone holding one of their own. +#define STEALTH_HOSTAGE_HOLD_RANGE 3 +/// "Back off" sends them to at least this far. +#define STEALTH_HOSTAGE_BACK_OFF_RANGE 6 +/// How far a guard hears a demand. +#define STEALTH_HOSTAGE_DEMAND_RANGE 7 +/// Between standoff lines. +#define STEALTH_HOSTAGE_BARK_INTERVAL (6 SECONDS) + +#define STEALTH_BARK_HOSTAGE "stealth_hostage" +#define STEALTH_BARK_HOSTAGE_DROP "stealth_hostage_drop" +#define STEALTH_BARK_HOSTAGE_BACK "stealth_hostage_back" +#define STEALTH_BARK_HOSTAGE_EXECUTED "stealth_hostage_executed" +#define STEALTH_BARK_HOSTAGE_RELEASED "stealth_hostage_released" diff --git a/voidcrew/modules/stealth/stealth_gunfu.dm b/voidcrew/modules/stealth/stealth_gunfu.dm new file mode 100644 index 00000000000..9886e2a3652 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_gunfu.dm @@ -0,0 +1,289 @@ +/** + * # Gun-fu (stealth step 3c, owner decisions 14-17 and 22) + * + * Close-quarters gunplay from a cyberware chip, the gun kata chip. Only a body with the chip running does the moves + * (decision 16). They are tg's own controls with a gun in the active hand, and no action buttons: + * + * - Hip throw: hold someone in an aggressive grab, throw mode, click a tile. tg would throw the gun; the chip throws + * the person instead, through tg's own throw_at(), toward the click. They land and go down (tg's Knockdown()); a wall + * or a body in the way is tg's own crash. + * - Shoulder flip: the same with a neck grab (they are on your tile). They go over your shoulder onto the next tile + * toward the click, flat on their back: brute through tg's armour and a longer knockdown. + * - Wall slam: right-click (combat mode) someone next to you with the gun, with a wall or anything solid right behind + * them. tg's shove with a weapon (disarm()) knocks them down against it; the chip adds the wall's brute. + * - Disarm: the same right-click with nothing solid behind them. tg's shove moves and staggers them; the chip knocks + * what they hold out of their hand and a couple of tiles away. + * - Human shield: hold someone in a neck grab with the gun out. They are drawn in front of you, and shots coming at + * you from the front hit them instead (the bullet goes through tg's own hit on their body). + * + * After a throw, flip, slam or disarm, the mover's shots on that victim for GUNFU_MARK_TIME add to hyperviolence's + * aimed crit roll (hv_crit_situation_bonus()). Nothing kills by itself: the roll still has to land, it goes in + * before wound armour scales it, and each crit's own armour block still holds (decision 16). On anyone: players and + * NPCs alike (decision 22); every move is logged with the zone. + * + * The motion is visual only (stealth_gunfu_motion.dm, hv_vis_play): nothing in it moves, stuns or hurts anyone. + * An admin can fire any move on demand: "Gun-fu Moves" (stealth_gunfu_admin.dm). + */ + +// --------------------------------------------------------------------------------------------- +// The chip + +/obj/item/organ/cyberimp/cyberware/gun_kata + name = "\improper gun kata chip" + desc = "A combat chip seated at the base of the skull, loaded with close-quarters gunplay. The hands know where to go before you do." + icon_state = "rigger" + zone = BODY_ZONE_HEAD + slot = ORGAN_SLOT_CYBERWARE_COMBAT_CHIP + w_class = WEIGHT_CLASS_SMALL + chrome_load = 4 + tier = CYBERWARE_TIER_3 + +/obj/item/organ/cyberimp/cyberware/gun_kata/on_mob_insert(mob/living/carbon/organ_owner, special = FALSE, movement_flags) + . = ..() + RegisterSignal(organ_owner, COMSIG_ATOM_PRE_BULLET_ACT, PROC_REF(on_owner_shot)) + RegisterSignal(organ_owner, COMSIG_ATOM_DIR_CHANGE, PROC_REF(on_owner_turned)) + +/obj/item/organ/cyberimp/cyberware/gun_kata/on_mob_remove(mob/living/carbon/organ_owner, special = FALSE, movement_flags) + . = ..() + UnregisterSignal(organ_owner, list(COMSIG_ATOM_PRE_BULLET_ACT, COMSIG_ATOM_DIR_CHANGE)) + if(isliving(organ_owner.pulling)) + organ_owner.set_pull_offsets(organ_owner.pulling, organ_owner.grab_state) + +/// Whether the chip is in a head and running (not browned out, EMP-scrambled or broken). +/obj/item/organ/cyberimp/cyberware/gun_kata/proc/running() + var/datum/component/cyberware/chrome = GetComponent(/datum/component/cyberware) + return chrome?.is_running() + +/// A shot coming at the bearer from the front, with a body held up as a shield, goes through to that body. +/obj/item/organ/cyberimp/cyberware/gun_kata/proc/on_owner_shot(mob/living/carbon/human/source, obj/projectile/shot, def_zone, piercing_hit, blocked) + SIGNAL_HANDLER + var/mob/living/shield = source.gunfu_shield_body() + if(isnull(shield) || shot.firer == shield) + return NONE + if(abs(closer_angle_difference(dir2angle(source.dir), REVERSE_ANGLE(shot.angle))) > GUNFU_SHIELD_ARC) + return NONE + if(!shot.can_hit_target(shield, FALSE, TRUE)) + return NONE + log_combat(source, shield, "used as a human shield", shot, "([get_area_name(source, TRUE)])") + // The bullet passes the holder and tg's hit loop picks the next body on the tile: the one held up in front. + return COMPONENT_BULLET_PIERCED + +/obj/item/organ/cyberimp/cyberware/gun_kata/proc/on_owner_turned(mob/living/carbon/human/source, old_dir, new_dir) + SIGNAL_HANDLER + if(old_dir == new_dir || !isliving(source.pulling)) + return + source.set_pull_offsets(source.pulling, source.grab_state) + +// --------------------------------------------------------------------------------------------- +// Who can move + +/mob/living/carbon/human + /// world.time the next gun-fu move is ready. + var/gunfu_next_move = 0 + /// Weak reference to who last put this body through a gun-fu move, and until when their shots get the bonus. + var/datum/weakref/gunfu_marked_by + var/gunfu_mark_until = 0 + +/// The running gun kata chip in this body, or null. +/mob/living/carbon/human/proc/gunfu_chip() + var/obj/item/organ/cyberimp/cyberware/gun_kata/chip = get_organ_slot(ORGAN_SLOT_CYBERWARE_COMBAT_CHIP) + if(!istype(chip) || !chip.running()) + return null + return chip + +/// The gun in the active hand, if this body can do a gun-fu move with it now. `ignore_cooldown` for admin tools. +/mob/living/carbon/human/proc/gunfu_gun(ignore_cooldown = FALSE) + if(stat != CONSCIOUS || incapacitated || body_position != STANDING_UP || !isturf(loc)) + return null + if(HAS_TRAIT(src, TRAIT_PACIFISM) || isnull(gunfu_chip())) + return null + if(!ignore_cooldown && world.time < gunfu_next_move) + return null + var/obj/item/gun/gun = get_active_held_item() + return isgun(gun) ? gun : null + +/// The body this one holds up as a shield now: a neck grab or tighter on someone on its tile, gun out, chip running. +/mob/living/carbon/human/proc/gunfu_shield_body() + var/mob/living/held = pulling + if(!isliving(held) || grab_state < GRAB_NECK || held.loc != loc || held.buckled) + return null + if(stat != CONSCIOUS || HAS_TRAIT(src, TRAIT_PACIFISM) || isnull(gunfu_chip())) + return null + if(!isgun(get_active_held_item()) && !isgun(get_inactive_held_item())) + return null + return held + +/// After a move: the cooldown, the crit mark on the victim, and the log. +/mob/living/carbon/human/proc/gunfu_after_move(mob/living/victim, move) + gunfu_next_move = world.time + GUNFU_MOVE_COOLDOWN + if(ishuman(victim)) + var/mob/living/carbon/human/marked = victim + marked.gunfu_marked_by = WEAKREF(src) + marked.gunfu_mark_until = world.time + GUNFU_MARK_TIME + log_combat(src, victim, "gun-fu [move]", get_active_held_item(), "([get_area_name(src, TRUE)])") + +// --------------------------------------------------------------------------------------------- +// The crit bonus (decision 16) + +/// The gun-fu roll bonus for this blow, or 0: a shot from whoever just put this body through a move. +/mob/living/carbon/human/proc/gunfu_crit_bonus(mob/living/attacker, atom/source, obj/item/bodypart/limb) + if(isnull(attacker) || world.time >= gunfu_mark_until || !isprojectile(source)) + return 0 + if(gunfu_marked_by?.resolve() != attacker) + return 0 + . = GUNFU_CRIT_BONUS + if(limb?.body_zone == BODY_ZONE_HEAD) + . += GUNFU_CRIT_HEAD_BONUS + +/mob/living/carbon/human/hv_crit_situation_bonus(mob/living/attacker, atom/source, obj/item/bodypart/limb) + . = ..() + var/bonus = gunfu_crit_bonus(attacker, source, limb) + if(bonus) + log_combat(attacker, src, "shot after a gun-fu move", source, "(crit roll +[bonus], [limb?.body_zone])") + . += bonus + +// --------------------------------------------------------------------------------------------- +// Throw mode with someone held: the hip throw and the flip + +/mob/living/carbon/human/throw_item(atom/target) + var/mob/living/held = pulling + if(!isliving(held) || grab_state < GRAB_AGGRESSIVE || held.buckled || isnull(target) || isnull(gunfu_gun())) + return ..() + var/turf/toward = get_turf(target) + if(isnull(toward) || toward == get_turf(src)) + return ..() + throw_mode_off(THROW_MODE_TOGGLE) + if(grab_state >= GRAB_NECK && held.loc == loc) + return gunfu_flip(held, toward) + return gunfu_hip_throw(held, toward) + +/// Hip throw: lets go of `victim` and throws them toward `toward` with tg's throw; they go down where they land. +/mob/living/carbon/human/proc/gunfu_hip_throw(mob/living/victim, turf/toward) + stop_pulling() + visible_message( + span_danger("[src] throws [victim] over [p_their()] hip!"), + span_danger("You throw [victim] over your hip!"), + span_hear("You hear a scuffle and a thud!"), COMBAT_MESSAGE_RANGE, victim) + to_chat(victim, span_userdanger("[src] throws you over [p_their()] hip!")) + playsound(src, 'sound/items/weapons/thudswoosh.ogg', 50, TRUE, -1) + gunfu_after_move(victim, GUNFU_MOVE_HIP_THROW) + gunfu_vis_hip_throw(victim, toward) + victim.throw_at(toward, GUNFU_HIP_THROW_RANGE, 1, src, spin = FALSE, callback = CALLBACK(src, PROC_REF(gunfu_landed), victim, GUNFU_HIP_THROW_KNOCKDOWN, GUNFU_HIP_THROW_DAMAGE)) + return TRUE + +/// Shoulder flip: `victim`, held on this tile, goes over onto the next tile toward `toward` and lands flat. +/mob/living/carbon/human/proc/gunfu_flip(mob/living/victim, turf/toward) + var/turf/landing = get_step(src, get_dir(src, toward)) + stop_pulling() + visible_message( + span_danger("[src] flips [victim] over [p_their()] shoulder!"), + span_danger("You flip [victim] over your shoulder!"), + span_hear("You hear a heavy slam!"), COMBAT_MESSAGE_RANGE, victim) + to_chat(victim, span_userdanger("[src] flips you over [p_their()] shoulder!")) + playsound(src, 'sound/items/weapons/thudswoosh.ogg', 60, TRUE, -1) + gunfu_after_move(victim, GUNFU_MOVE_FLIP) + gunfu_vis_flip(victim, landing) + victim.throw_at(landing, 1, 1, src, spin = FALSE, callback = CALLBACK(src, PROC_REF(gunfu_landed), victim, GUNFU_FLIP_KNOCKDOWN, GUNFU_FLIP_DAMAGE, BODY_ZONE_CHEST)) + return TRUE + +/// A thrown or flipped body hits the floor: tg's knockdown and the fall's brute through its armour. A throw that hit +/// a wall or a body already got tg's own crash; the floor still puts them down. +/mob/living/carbon/human/proc/gunfu_landed(mob/living/victim, knockdown, damage, zone) + if(QDELETED(victim) || victim.stat == DEAD) + return + if(damage) + var/hit_zone = zone || pick(BODY_ZONE_CHEST, BODY_ZONE_L_ARM, BODY_ZONE_R_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG) + var/armour = victim.run_armor_check(hit_zone, MELEE, silent = TRUE) + victim.apply_damage(damage, BRUTE, hit_zone, armour) + victim.Knockdown(knockdown) + playsound(victim, 'sound/effects/hit_kick.ogg', 50, TRUE, -1) + +// --------------------------------------------------------------------------------------------- +// Right-click with the gun: the wall slam and the disarm + +/obj/item/gun/attack_secondary(mob/living/victim, mob/living/user, list/modifiers, list/attack_modifiers) + if(ishuman(user) && isliving(victim) && victim != user && user.combat_mode) + var/mob/living/carbon/human/mover = user + if(mover.get_active_held_item() == src && mover.gunfu_gun() && mover.gunfu_shove(victim, src)) + return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN + return ..() + +/// Shoves `victim` with the gun through tg's disarm(): a slam if something solid is right behind them, else a disarm. +/// FALSE if it can't (not next to them, on their tile, or nothing to do). +/mob/living/carbon/human/proc/gunfu_shove(mob/living/victim, obj/item/gun/gun) + if(!Adjacent(victim) || victim.loc == loc || !can_disarm(victim)) + return FALSE + var/shove_dir = get_dir(src, victim) + var/turf/behind = get_step(victim, shove_dir) + if(gunfu_solid_behind(victim, behind, shove_dir)) + return gunfu_wall_slam(victim, gun, behind) + var/obj/item/held = victim.get_active_held_item() || victim.get_inactive_held_item() + if(isnull(held)) + return FALSE + return gunfu_disarm(victim, gun, held) + +/// Whether a shove from `shove_dir` would drive `victim` into something solid on `behind`. +/mob/living/carbon/human/proc/gunfu_solid_behind(mob/living/victim, turf/behind, shove_dir) + if(isnull(behind) || behind.density) + return TRUE + for(var/atom/movable/thing as anything in behind) + if(thing.density && !isliving(thing) && !(thing.flags_1 & ON_BORDER_1)) + return TRUE + if((thing.flags_1 & ON_BORDER_1) && thing.density && thing.dir == REVERSE_DIR(shove_dir)) + return TRUE + return FALSE + +/// Wall slam: tg's shove into something solid knocks them down; the chip adds the wall's brute, through armour. +/mob/living/carbon/human/proc/gunfu_wall_slam(mob/living/victim, obj/item/gun/gun, turf/wall) + gunfu_after_move(victim, GUNFU_MOVE_WALL_SLAM) + gunfu_vis_wall_slam(victim, wall) + disarm(victim, gun) + if(QDELETED(victim)) + return TRUE + var/hit_zone = pick(BODY_ZONE_HEAD, BODY_ZONE_CHEST) + var/armour = victim.run_armor_check(hit_zone, MELEE, silent = TRUE) + victim.apply_damage(GUNFU_SLAM_DAMAGE, BRUTE, hit_zone, armour, attack_direction = get_dir(src, victim)) + return TRUE + +/// Disarm: tg's shove moves and staggers them; the chip knocks `held` out of their hand and a couple of tiles off. +/mob/living/carbon/human/proc/gunfu_disarm(mob/living/victim, obj/item/gun/gun, obj/item/held) + gunfu_after_move(victim, GUNFU_MOVE_DISARM) + gunfu_vis_disarm(victim, held) + disarm(victim, gun) + if(QDELETED(victim) || QDELETED(held) || held.loc != victim) + return TRUE + if(!victim.dropItemToGround(held)) + return TRUE + victim.visible_message(span_danger("[src] knocks [held] out of [victim]'s hand!"), + span_userdanger("[src] knocks [held] out of your hand!"), null, COMBAT_MESSAGE_RANGE, src) + var/turf/away = get_ranged_target_turf(victim, turn(get_dir(src, victim), pick(-45, 45)), GUNFU_DISARM_THROW_RANGE) + held.throw_at(away, GUNFU_DISARM_THROW_RANGE, 2, src, spin = TRUE) + return TRUE + +// --------------------------------------------------------------------------------------------- +// The human shield's pose + +/// A body held up as a shield stands in front of its holder, facing the same way, instead of tg's grab offset. Rows +/// sort before layers (SIDE_MAP), so a step down keeps it drawn in front of the holder side-on. +/mob/living/set_pull_offsets(mob/living/mob_to_set, grab_state = GRAB_PASSIVE, animate = TRUE) + if(!ishuman(src)) + return ..() + var/mob/living/carbon/human/holder = src + if(holder.gunfu_shield_body() != mob_to_set) + return ..() + mob_to_set.remove_offsets(GRABBING_TRAIT, animate = FALSE) + mob_to_set.setDir(dir) + var/shift_x = 0 + var/shift_y = 0 + switch(dir) + if(NORTH) + shift_y = GUNFU_SHIELD_SHIFT + if(SOUTH) + shift_y = -GUNFU_SHIELD_SHIFT + if(EAST) + shift_x = GUNFU_SHIELD_SHIFT + shift_y = -1 + if(WEST) + shift_x = -GUNFU_SHIELD_SHIFT + shift_y = -1 + mob_to_set.add_offsets(GRABBING_TRAIT, x_add = shift_x, y_add = shift_y, animate = animate) diff --git a/voidcrew/modules/stealth/stealth_gunfu_admin.dm b/voidcrew/modules/stealth/stealth_gunfu_admin.dm new file mode 100644 index 00000000000..1bb2925af19 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_gunfu_admin.dm @@ -0,0 +1,106 @@ +/** + * # Gun-fu admin tool (stealth step 3c, decision 15) + * + * "Gun-fu Moves" (Debug): fires any gun-fu move on demand between two people in view, the shoulder flip above all + * (the owner expects it to need a lot of testing). It sets up what the move needs through tg's own procs: the chip + * (installed as an admin install), a pistol in the mover's hand, and the grab (tg's grippedby(), instantly), then + * runs the move itself, cooldown aside. Every use is logged. + */ + +ADMIN_VERB(gunfu_moves, R_DEBUG, "Gun-fu Moves", "Make someone in view do a gun-fu move on someone else, on demand.", ADMIN_CATEGORY_DEBUG) + var/mob/watcher = user.mob + var/list/people = list() + for(var/mob/living/carbon/human/person in view(world.view, get_turf(watcher))) + people["[person] ([person.ckey || "npc"]) [dir2text(get_dir(watcher, person)) || "here"]"] = person + if(length(people) < 2) + to_chat(user, span_warning("You need two people in view."), confidential = TRUE) + return + var/move = tgui_input_list(user, "Which move?", "Gun-fu Moves", list(GUNFU_MOVE_FLIP, GUNFU_MOVE_HIP_THROW, GUNFU_MOVE_WALL_SLAM, GUNFU_MOVE_DISARM, GUNFU_MOVE_SHIELD)) + if(isnull(move)) + return + var/mover_key = tgui_input_list(user, "Who does it?", "Gun-fu Moves", sort_list(people)) + if(isnull(mover_key)) + return + var/mob/living/carbon/human/mover = people[mover_key] + people -= mover_key + var/victim_key = tgui_input_list(user, "On whom?", "Gun-fu Moves", sort_list(people)) + if(isnull(victim_key)) + return + var/mob/living/carbon/human/victim = people[victim_key] + var/direction + if(move == GUNFU_MOVE_FLIP || move == GUNFU_MOVE_HIP_THROW) + direction = tgui_input_list(user, "Which way?", "Gun-fu Moves", list("ahead", "north", "south", "east", "west")) + if(isnull(direction)) + return + if(QDELETED(mover) || QDELETED(victim)) + return + var/result = gunfu_admin_do(mover, victim, move, direction == "ahead" ? null : text2dir(direction)) + to_chat(user, span_notice("Gun-fu [move]: [result]"), confidential = TRUE) + message_admins("[key_name_admin(user)] made [ADMIN_LOOKUPFLW(mover)] do a gun-fu [move] on [ADMIN_LOOKUPFLW(victim)]: [result]") + log_admin("[key_name(user)] made [key_name(mover)] do a gun-fu [move] on [key_name(victim)]: [result]") + BLACKBOX_LOG_ADMIN_VERB("Gun-fu Moves") + +/// Sets up and runs one gun-fu move. `direction` is where a throw or flip goes (null: the way the mover faces). Returns +/// what happened, for the admin. Also used by tests and recordings. +/proc/gunfu_admin_do(mob/living/carbon/human/mover, mob/living/carbon/human/victim, move, direction) + var/setup = gunfu_admin_setup(mover, victim, move) + if(setup) + return setup + switch(move) + if(GUNFU_MOVE_HIP_THROW, GUNFU_MOVE_FLIP) + var/turf/toward = get_ranged_target_turf(mover, direction || mover.dir, GUNFU_HIP_THROW_RANGE) + if(move == GUNFU_MOVE_FLIP) + return mover.gunfu_flip(victim, toward) ? "done" : "refused" + return mover.gunfu_hip_throw(victim, toward) ? "done" : "refused" + if(GUNFU_MOVE_WALL_SLAM, GUNFU_MOVE_DISARM) + var/obj/item/gun/gun = mover.get_active_held_item() + var/shove_dir = get_dir(mover, victim) + var/solid = mover.gunfu_solid_behind(victim, get_step(victim, shove_dir), shove_dir) + if(move == GUNFU_MOVE_WALL_SLAM && !solid) + return "nothing solid behind them" + if(move == GUNFU_MOVE_DISARM && solid) + return "something solid behind them makes it a wall slam" + return mover.gunfu_shove(victim, gun) ? "done" : "refused (are they holding anything?)" + if(GUNFU_MOVE_SHIELD) + return mover.gunfu_shield_body() == victim ? "holding them up" : "refused" + return "unknown move" + +/// Gives `mover` what `move` needs: the chip, a gun in hand, and the grab. Returns a reason it can't, or null. +/proc/gunfu_admin_setup(mob/living/carbon/human/mover, mob/living/carbon/human/victim, move) + if(mover.stat != CONSCIOUS || mover.body_position != STANDING_UP) + return "the mover can't stand and fight" + if(isnull(mover.gunfu_chip())) + var/obj/item/organ/cyberimp/cyberware/gun_kata/chip = new + if(!chip.Insert(mover, special = TRUE)) + qdel(chip) + return "the chip wouldn't go in" + if(!isgun(mover.get_active_held_item())) + var/obj/item/gun/ballistic/automatic/pistol/pistol = new(get_turf(mover)) + if(!mover.put_in_active_hand(pistol)) + qdel(pistol) + return "the mover's active hand is full" + if(get_dist(mover, victim) > 1) + return "they need to be next to each other" + var/wanted = GRAB_PASSIVE + switch(move) + if(GUNFU_MOVE_HIP_THROW) + wanted = GRAB_AGGRESSIVE + if(GUNFU_MOVE_FLIP, GUNFU_MOVE_SHIELD) + wanted = GRAB_NECK + if(GUNFU_MOVE_WALL_SLAM, GUNFU_MOVE_DISARM) + if(mover.pulling == victim) + mover.stop_pulling() + if(victim.loc == mover.loc) + return "they're on the same tile" + return null + if(mover.pulling != victim) + mover.start_pulling(victim, supress_message = TRUE) + var/tries = 0 + while(mover.pulling == victim && mover.grab_state < wanted && tries++ < 3) + victim.grippedby(mover, instant = TRUE) + if(mover.pulling != victim || mover.grab_state < wanted) + return "couldn't get the grab" + mover.gunfu_next_move = 0 + if(move == GUNFU_MOVE_SHIELD) + mover.set_pull_offsets(victim, mover.grab_state) + return null diff --git a/voidcrew/modules/stealth/stealth_gunfu_motion.dm b/voidcrew/modules/stealth/stealth_gunfu_motion.dm new file mode 100644 index 00000000000..ce2e52f13cd --- /dev/null +++ b/voidcrew/modules/stealth/stealth_gunfu_motion.dm @@ -0,0 +1,27 @@ +/** + * # Gun-fu motion (stealth step 3c, decision 17) + * + * The pictures for each gun-fu move (stealth_gunfu.dm). Visual only, under hyperviolence's motion rules + * (voidcrew/modules/hyperviolence/visuals/_motion_core.dm): named hv_vis_play() sequences that end where they began, + * nothing that moves, stuns, roots or hurts anyone. The gameplay has already happened (or is happening through tg's + * throw) when these are called; each only draws it. + * + * Each move is built storyboard -> blocking -> full build (kit rule), in all four facings. A move with no pictures + * yet just plays tg's own throw and shove. + */ + +/// Hip throw: `victim` is being thrown toward `toward` by tg's throw_at() right after this call. +/mob/living/carbon/human/proc/gunfu_vis_hip_throw(mob/living/victim, turf/toward) + return + +/// Shoulder flip: `victim`, on this mob's tile, is thrown onto `landing` right after this call. +/mob/living/carbon/human/proc/gunfu_vis_flip(mob/living/victim, turf/landing) + return + +/// Wall slam: `victim` is about to be shoved into the solid thing on `wall` by tg's disarm(). +/mob/living/carbon/human/proc/gunfu_vis_wall_slam(mob/living/victim, turf/wall) + return + +/// Disarm: `victim` is about to be shoved, and `held` knocked out of their hand. +/mob/living/carbon/human/proc/gunfu_vis_disarm(mob/living/victim, obj/item/held) + return diff --git a/voidcrew/modules/stealth/stealth_hostage.dm b/voidcrew/modules/stealth/stealth_hostage.dm new file mode 100644 index 00000000000..d1854bce1a2 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_hostage.dm @@ -0,0 +1,220 @@ +/** + * # Hostages (stealth step 5, decisions 47+) + * + * Holding one of the guards' own people at gunpoint: tg's neck grab (they are on your tile, held in front of you) + * with a gun in hand. Anyone can do it; the gun kata chip only adds the human shield's bullet catching + * (stealth_gunfu.dm). Everything stays tg's: the grab, the hostage's own struggling (tg's resist, through + * escape_captivity), and a shot into them is a real shot. + * + * A stealth guard alert on whoever holds a friend of his (same faction) goes into a standoff instead of fighting: + * - he holds fire and keeps his distance (never closer than STEALTH_HOSTAGE_HOLD_RANGE), facing the holder, and + * talks ("Let him go!"); + * - told to drop it, he drops what he holds, once; told to back off, he backs off to STEALTH_HOSTAGE_BACK_OFF_RANGE, + * once. Plain words the holder says out loud within STEALTH_HOSTAGE_DEMAND_RANGE; + * - the hostage let go alive, or slipping free: the fight picks up where it was; + * - the holder hurting or killing the hostage, or the hostage dying in his hands: no more deals with that holder, + * ever, for that guard. He fights. + * - out of sight of the holder, he chases as usual and stands off again when he sees them. + * + * Only for their own people. Someone they don't count as one of theirs (a player, a stranger) held up in front is + * no reason to hold fire: they shoot, and the human shield, if the holder has the chip, catches what comes from the + * front. Never a fake state on anyone: the hostage is only held, and the guards only choose not to shoot. + */ + +/datum/ai_controller/basic_controller/human_npc/stealth + /// The holder it is standing off against, and the friend they hold. + var/datum/weakref/standoff_holder + var/datum/weakref/standoff_hostage + /// What it already gave in to this standoff. + var/standoff_dropped = FALSE + var/standoff_backed_off = FALSE + /// world.time of its next standoff line. + var/next_standoff_bark = 0 + /// REFs of holders who hurt or killed a hostage in front of it: it never stands off against them again. + var/list/no_deals + +/datum/ai_controller/basic_controller/human_npc/stealth/init_subtrees() + if(LAZYLEN(planning_subtrees) && !(/datum/ai_planning_subtree/stealth_hostage in planning_subtrees)) + var/list/subtrees = planning_subtrees.Copy() + var/at = subtrees.Find(/datum/ai_planning_subtree/human_npc_arm) + if(at) + subtrees.Insert(at, /datum/ai_planning_subtree/stealth_hostage) + planning_subtrees = subtrees + return ..() + +/// The body `holder` holds at gunpoint now: a neck grab or tighter on a living body on their tile, a gun in a hand. +/proc/stealth_hostage_of(mob/living/holder) + if(!isliving(holder) || holder.stat != CONSCIOUS) + return null + var/mob/living/held = holder.pulling + if(!isliving(held) || held.stat == DEAD || holder.grab_state < GRAB_NECK || held.loc != holder.loc) + return null + if(!isgun(holder.get_active_held_item()) && !isgun(holder.get_inactive_held_item())) + return null + return held + +/// Whether it stands off against `holder` holding `hostage`: one of its own, and a holder it still deals with. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_standoff_with(mob/living/holder, mob/living/hostage) + var/mob/living/guard = pawn + if(isnull(hostage) || hostage == guard || LAZYFIND(no_deals, REF(holder))) + return FALSE + return guard.faction_check_atom(hostage) + +/// Starts (or keeps) the standoff against `holder` holding `hostage`. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_standoff_start(mob/living/holder, mob/living/hostage) + var/mob/living/old_holder = standoff_holder?.resolve() + var/mob/living/old_hostage = standoff_hostage?.resolve() + if(old_holder == holder && old_hostage == hostage) + return + stealth_standoff_end() + standoff_holder = WEAKREF(holder) + standoff_hostage = WEAKREF(hostage) + standoff_dropped = FALSE + standoff_backed_off = FALSE + next_standoff_bark = 0 + stealth_drop_walk() + RegisterSignal(holder, COMSIG_MOB_SAY, PROC_REF(on_standoff_demand)) + RegisterSignal(hostage, COMSIG_MOB_AFTER_APPLY_DAMAGE, PROC_REF(on_hostage_hurt)) + RegisterSignal(hostage, COMSIG_LIVING_DEATH, PROC_REF(on_hostage_died)) + var/mob/living/guard = pawn + log_combat(guard, holder, "held fire on a hostage holder", null, "(hostage [key_name(hostage)], [get_area_name(guard, TRUE)])") + +/// Ends the standoff, if any. `line` is the bark it says as it does. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_standoff_end(line) + var/mob/living/holder = standoff_holder?.resolve() + var/mob/living/hostage = standoff_hostage?.resolve() + if(holder) + UnregisterSignal(holder, COMSIG_MOB_SAY) + if(hostage) + UnregisterSignal(hostage, list(COMSIG_MOB_AFTER_APPLY_DAMAGE, COMSIG_LIVING_DEATH)) + var/was_on = !isnull(standoff_holder) + standoff_holder = null + standoff_hostage = null + if(was_on) + stealth_drop_walk() + if(line) + stealth_bark(line, always = TRUE) + +/// The holder hurt or killed the hostage: no more deals with them. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_standoff_broken(mob/living/holder) + if(holder) + LAZYOR(no_deals, REF(holder)) + var/mob/living/guard = pawn + log_combat(guard, holder, "stopped holding fire: the hostage was hurt", null, "([get_area_name(guard, TRUE)])") + stealth_set_wary() + stealth_standoff_end(STEALTH_BARK_HOSTAGE_EXECUTED) + +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_hostage_hurt(mob/living/source, damage_dealt, damagetype, def_zone, blocked, wound_bonus, exposed_wound_bonus, sharpness, attack_direction, attacking_item) + SIGNAL_HANDLER + if(damage_dealt <= 0) + return + var/mob/living/holder = standoff_holder?.resolve() + if(holder && hv_vis_attacker_of(attacking_item) == holder) + stealth_standoff_broken(holder) + +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_hostage_died(mob/living/source, gibbed) + SIGNAL_HANDLER + var/mob/living/holder = standoff_holder?.resolve() + if(holder?.pulling == source) + stealth_standoff_broken(holder) + else + stealth_standoff_end() + +/// The holder says something. A demand it hears gets done once each: drop the weapon, or back off. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/on_standoff_demand(mob/living/source, list/speech_args) + SIGNAL_HANDLER + var/mob/living/carbon/human/guard = pawn + if(guard.stat != CONSCIOUS || HAS_TRAIT(guard, TRAIT_DEAF) || get_dist(guard, source) > STEALTH_HOSTAGE_DEMAND_RANGE) + return + if(stealth_hostage_of(source) != standoff_hostage?.resolve()) + return + var/message = speech_args[SPEECH_MESSAGE] + if(!istext(message)) + return + var/static/regex/drop_words = regex(@"\b(drop|guns?|weapons?|piece|disarm)\b", "i") + var/static/regex/back_words = regex(@"\b(back|away|off|step|move|leave|go)\b", "i") + if(!standoff_dropped && drop_words.Find(message)) + INVOKE_ASYNC(src, PROC_REF(stealth_standoff_drop)) + else if(!standoff_backed_off && back_words.Find(message)) + standoff_backed_off = TRUE + stealth_drop_walk() + stealth_bark(STEALTH_BARK_HOSTAGE_BACK, always = TRUE) + log_combat(guard, source, "backed off from a hostage holder") + +/// Drops what it holds in its hands, through tg's own drop. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_standoff_drop() + var/mob/living/carbon/human/guard = pawn + if(QDELETED(guard) || standoff_dropped) + return + standoff_dropped = TRUE + var/dropped = FALSE + for(var/obj/item/held in guard.held_items) + if(guard.dropItemToGround(held)) + dropped = TRUE + if(dropped) + stealth_bark(STEALTH_BARK_HOSTAGE_DROP, always = TRUE) + var/mob/living/holder = standoff_holder?.resolve() + log_combat(guard, holder, "dropped their weapon for a hostage holder") + +/// Where it stands in the standoff: the band of distance it keeps from the holder. +/datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_standoff_band() + return standoff_backed_off ? list(STEALTH_HOSTAGE_BACK_OFF_RANGE, STEALTH_HOSTAGE_BACK_OFF_RANGE + 2) : list(STEALTH_HOSTAGE_HOLD_RANGE, STEALTH_HOSTAGE_DEMAND_RANGE - 1) + +/** + * Alert on someone holding one of its own at gunpoint, in view: the standoff. Holds fire (ends planning before the + * arming, shooting and melee subtrees), keeps its distance, faces them and talks. Placed before human_npc_arm, so a + * guard that dropped its weapon doesn't pick another up while the standoff lasts. + */ +/datum/ai_planning_subtree/stealth_hostage + +/datum/ai_planning_subtree/stealth_hostage/SelectBehaviors(datum/ai_controller/basic_controller/human_npc/stealth/controller, seconds_per_tick) + if(!istype(controller)) + return + var/mob/living/carbon/human/guard = controller.pawn + var/mob/living/holder = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] + var/mob/living/hostage = isliving(holder) ? stealth_hostage_of(holder) : null + var/in_standoff = !isnull(controller.standoff_holder) + if(guard.stat != CONSCIOUS || controller.stealth_state() != STEALTH_ALERT || isnull(hostage) \ + || !controller.stealth_standoff_with(holder, hostage) || !controller.stealth_has_in_view(holder)) + if(in_standoff) + var/mob/living/old_hostage = controller.standoff_hostage?.resolve() + var/mob/living/old_holder = controller.standoff_holder?.resolve() + var/released = old_hostage && old_hostage.stat != DEAD && old_holder && stealth_hostage_of(old_holder) != old_hostage + controller.stealth_standoff_end(released ? STEALTH_BARK_HOSTAGE_RELEASED : null) + return + controller.stealth_standoff_start(holder, hostage) + controller.last_seen_turf = get_turf(holder) + controller.stealth_set_wary() + if(world.time >= controller.next_standoff_bark) + controller.next_standoff_bark = world.time + STEALTH_HOSTAGE_BARK_INTERVAL + controller.stealth_bark(STEALTH_BARK_HOSTAGE) + var/list/band = controller.stealth_standoff_band() + var/distance = get_dist(guard, holder) + var/turf/dest + if(distance < band[1]) + dest = stealth_open_near(get_ranged_target_turf_direct(holder, guard, band[1]), 1) + else if(distance > band[2]) + dest = stealth_open_near(get_ranged_target_turf_direct(holder, guard, band[2]), 1) + if(dest && dest != get_turf(guard) && !controller.stealth_walk_over(dest)) + controller.stealth_walk(dest, STEALTH_GOTO_INVESTIGATE) + return SUBTREE_RETURN_FINISH_PLANNING + controller.stealth_drop_walk() + controller.stand_dir = stealth_dir_to(guard, holder) + controller.look_until = 0 + if(guard.dir != controller.stand_dir) + controller.stealth_turn_to(controller.stand_dir) + controller.queue_behavior(/datum/ai_behavior/stealth_stand) + return SUBTREE_RETURN_FINISH_PLANNING + +// --------------------------------------------------------------------------------------------- +// What they say + +/datum/human_npc_voice/scav/New() + . = ..() + lines[STEALTH_BARK_HOSTAGE] = list("Let 'em go!", "Easy. Easy now.", "Put the gun down!", "You won't get far.", "Nobody has to die here.") + lines[STEALTH_BARK_HOSTAGE_DROP] = list("All right! It's down!", "Okay, okay. It's down.", "There. Happy?") + lines[STEALTH_BARK_HOSTAGE_BACK] = list("I'm backing off.", "Okay. Backing up.", "Fine. Fine.") + lines[STEALTH_BARK_HOSTAGE_EXECUTED] = list("You son of a-", "Take them down!", "No more talking!") + lines[STEALTH_BARK_HOSTAGE_RELEASED] = list("Now!", "Take them!", "Get clear!") + emotes[STEALTH_BARK_HOSTAGE] = list("raises a hand slowly.", "keeps their gun low.") + emotes[STEALTH_BARK_HOSTAGE_DROP] = list("lets their weapon fall.") diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index 37b4d39b0b8..6fb10035fd8 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -243,6 +243,7 @@ #include "voidcrew_stealth_d44.dm" #include "voidcrew_stealth_d45.dm" #include "voidcrew_stealth_disguise.dm" +#include "voidcrew_stealth_gunfu.dm" #include "voidcrew_stealth_hearing.dm" #include "voidcrew_stealth_light.dm" #include "voidcrew_survey_archive.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_gunfu.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_gunfu.dm new file mode 100644 index 00000000000..b5a5453d56b --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_gunfu.dm @@ -0,0 +1,210 @@ +// Gun-fu (step 3c, voidcrew/modules/stealth/stealth_gunfu.dm) and hostages (step 5, stealth_hostage.dm). Unit tests +// compile before voidcrew/_DEFINES, so values are written out: GUNFU_CRIT_BONUS 10, GUNFU_CRIT_HEAD_BONUS 10, +// ORGAN_SLOT_CYBERWARE_COMBAT_CHIP "cyberware_combat_chip", state "alert". + +/// `mover` with the gun kata chip and a pistol in the active hand. +/datum/unit_test/proc/gunfu_arm(mob/living/carbon/human/mover) + var/obj/item/organ/cyberimp/cyberware/gun_kata/chip = allocate(/obj/item/organ/cyberimp/cyberware/gun_kata) + TEST_ASSERT(chip.Insert(mover, special = TRUE), "The gun kata chip wouldn't go in") + var/obj/item/gun/ballistic/automatic/pistol/pistol = allocate(/obj/item/gun/ballistic/automatic/pistol) + pistol.can_misfire = FALSE + mover.put_in_active_hand(pistol, forced = TRUE) + return pistol + +/// `holder` holds `victim` at `wanted` grab state through tg's own grab. +/datum/unit_test/proc/gunfu_grab(mob/living/carbon/human/holder, mob/living/victim, wanted) + holder.start_pulling(victim, supress_message = TRUE) + var/tries = 0 + while(holder.pulling == victim && holder.grab_state < wanted && tries++ < 3) + victim.grippedby(holder, instant = TRUE) + TEST_ASSERT_EQUAL(holder.grab_state, wanted, "Test fixture: couldn't get the grab") + +/// Only a running chip and a gun in the active hand make a mover; the chip sits in its own head slot. +/datum/unit_test/voidcrew_stealth_gunfu_ready + +/datum/unit_test/voidcrew_stealth_gunfu_ready/Run() + var/datum/turf_reservation/block = stealth_block(6, 4) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/mover = stealth_person(block, 2, 2) + var/obj/item/gun/ballistic/automatic/pistol/pistol = allocate(/obj/item/gun/ballistic/automatic/pistol) + mover.put_in_active_hand(pistol, forced = TRUE) + TEST_ASSERT_NULL(mover.gunfu_gun(), "Gun-fu without the chip") + qdel(pistol) + gunfu_arm(mover) + var/obj/item/organ/chip = mover.get_organ_slot("cyberware_combat_chip") + TEST_ASSERT(istype(chip, /obj/item/organ/cyberimp/cyberware/gun_kata), "The chip isn't in the combat chip slot") + TEST_ASSERT_EQUAL(chip.zone, BODY_ZONE_HEAD, "The chip isn't in the head") + TEST_ASSERT_NOTNULL(mover.gunfu_gun(), "A chip and a gun didn't make a mover") + mover.swap_hand() + TEST_ASSERT_NULL(mover.gunfu_gun(), "Gun-fu with an empty active hand") + mover.swap_hand() + mover.gunfu_next_move = world.time + 10 + TEST_ASSERT_NULL(mover.gunfu_gun(), "Gun-fu during the cooldown") + mover.gunfu_next_move = 0 + chip.organ_flags |= ORGAN_FAILING + TEST_ASSERT_NULL(mover.gunfu_gun(), "Gun-fu from a failing chip") + chip.organ_flags &= ~ORGAN_FAILING + qdel(block) + +/// Throw mode with someone in an aggressive grab throws them, not the gun; a neck grab flips them. Both mark them, +/// and only the mover's shots on a marked body get the bonus. +/datum/unit_test/voidcrew_stealth_gunfu_throws + +/datum/unit_test/voidcrew_stealth_gunfu_throws/Run() + var/datum/turf_reservation/block = stealth_block(8, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/mover = stealth_person(block, 3, 2) + var/obj/item/gun/gun = gunfu_arm(mover) + var/mob/living/carbon/human/victim = stealth_person(block, 4, 2) + gunfu_grab(mover, victim, GRAB_AGGRESSIVE) + TEST_ASSERT(mover.throw_item(stealth_at(block, 6, 2)), "The hip throw didn't happen") + TEST_ASSERT_EQUAL(gun.loc, mover, "The hip throw threw the gun") + TEST_ASSERT_NULL(mover.pulling, "Still holding them after the hip throw") + TEST_ASSERT(victim.throwing || get_dist(mover, victim) > 1, "The victim wasn't thrown") + TEST_ASSERT(mover.gunfu_next_move > world.time, "No cooldown after the hip throw") + var/obj/projectile/shot = allocate(/obj/projectile/bullet) + shot.firer = mover + var/obj/item/bodypart/head = victim.get_bodypart(BODY_ZONE_HEAD) + var/obj/item/bodypart/chest = victim.get_bodypart(BODY_ZONE_CHEST) + TEST_ASSERT_EQUAL(victim.gunfu_crit_bonus(mover, shot, chest), 10, "Wrong gun-fu bonus on the chest") + TEST_ASSERT_EQUAL(victim.gunfu_crit_bonus(mover, shot, head), 20, "Wrong gun-fu bonus on the head") + TEST_ASSERT_EQUAL(victim.gunfu_crit_bonus(mover, gun, chest), 0, "A gun-fu bonus on a melee blow") + var/mob/living/carbon/human/other = stealth_person(block, 1, 4) + TEST_ASSERT_EQUAL(victim.gunfu_crit_bonus(other, shot, chest), 0, "Someone else's shot got the gun-fu bonus") + victim.gunfu_mark_until = world.time + TEST_ASSERT_EQUAL(victim.gunfu_crit_bonus(mover, shot, chest), 0, "The gun-fu bonus outlasted its time") + // Landing: tg's knockdown and real damage. + victim.throwing?.finalize() + victim.SetKnockdown(0) + mover.gunfu_landed(victim, 2 SECONDS, 5) + TEST_ASSERT(victim.IsKnockdown(), "Landing didn't knock them down") + TEST_ASSERT(victim.getBruteLoss() > 0, "Landing did no damage") + // The flip: a neck grab puts them on the mover's tile; they go onto the next tile. + var/mob/living/carbon/human/flipped = stealth_person(block, 2, 2) + mover.gunfu_next_move = 0 + gunfu_grab(mover, flipped, GRAB_NECK) + TEST_ASSERT_EQUAL(flipped.loc, mover.loc, "Test fixture: the neck grab didn't bring them onto the tile") + TEST_ASSERT(mover.throw_item(stealth_at(block, 3, 4)), "The flip didn't happen") + TEST_ASSERT_NULL(mover.pulling, "Still holding them after the flip") + TEST_ASSERT(flipped.throwing || flipped.loc != mover.loc, "The flipped body didn't leave the tile") + TEST_ASSERT(flipped.gunfu_mark_until > world.time, "The flip didn't mark them") + flipped.throwing?.finalize() + // No chip: tg's own throw, the gun goes. + var/mob/living/carbon/human/plain = stealth_person(block, 6, 4) + var/obj/item/gun/ballistic/automatic/pistol/plain_gun = allocate(/obj/item/gun/ballistic/automatic/pistol) + plain.put_in_active_hand(plain_gun, forced = TRUE) + var/mob/living/carbon/human/held = stealth_person(block, 7, 4) + gunfu_grab(plain, held, GRAB_AGGRESSIVE) + plain.throw_item(stealth_at(block, 7, 1)) + TEST_ASSERT(plain_gun.loc != plain, "Without the chip the throw didn't go to tg (the gun stayed in hand)") + qdel(block) + +/// Right-click with the gun: into a wall it's a slam (tg's knockdown, real brute), in the open it knocks the weapon away. +/datum/unit_test/voidcrew_stealth_gunfu_shoves + +/datum/unit_test/voidcrew_stealth_gunfu_shoves/Run() + var/datum/turf_reservation/block = stealth_block(8, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/turf/wall = stealth_at(block, 5, 2) + wall.ChangeTurf(/turf/closed/wall) + var/mob/living/carbon/human/mover = stealth_person(block, 3, 2) + var/obj/item/gun/gun = gunfu_arm(mover) + mover.set_combat_mode(TRUE) + var/mob/living/carbon/human/victim = stealth_person(block, 4, 2) + TEST_ASSERT(mover.gunfu_shove(victim, gun), "No wall slam") + TEST_ASSERT(victim.IsKnockdown() || victim.body_position == LYING_DOWN, "The wall slam didn't put them down") + TEST_ASSERT(victim.getBruteLoss() > 0, "The wall slam did no damage") + // The disarm, in the open. + var/mob/living/carbon/human/armed = stealth_person(block, 3, 3) + var/obj/item/knife/combat/knife = allocate(/obj/item/knife/combat) + armed.put_in_active_hand(knife, forced = TRUE) + var/mob/living/carbon/human/second = stealth_person(block, 2, 3) + var/obj/item/gun/second_gun = gunfu_arm(second) + second.set_combat_mode(TRUE) + TEST_ASSERT(second.gunfu_shove(armed, second_gun), "No disarm") + TEST_ASSERT(!(knife in armed.held_items), "The disarm left the knife in their hand") + TEST_ASSERT(armed.gunfu_mark_until > world.time, "The disarm didn't mark them") + // Empty-handed, in the open: nothing to do, tg's own gun bash happens instead. + second.gunfu_next_move = 0 + TEST_ASSERT(!second.gunfu_shove(armed, second_gun), "A disarm on someone with nothing in hand") + qdel(block) + +/// A neck grab with the gun out holds them up in front: shots from the front hit them, from behind the holder. +/datum/unit_test/voidcrew_stealth_gunfu_shield + +/datum/unit_test/voidcrew_stealth_gunfu_shield/Run() + var/datum/turf_reservation/block = stealth_block(9, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/holder = stealth_person(block, 4, 2) + gunfu_arm(holder) + var/mob/living/carbon/human/hostage = stealth_person(block, 5, 2) + holder.setDir(EAST) + gunfu_grab(holder, hostage, GRAB_NECK) + holder.setDir(EAST) + TEST_ASSERT_EQUAL(holder.gunfu_shield_body(), hostage, "No human shield") + TEST_ASSERT_EQUAL(hostage.dir, EAST, "The shield doesn't face the holder's way") + var/mob/living/carbon/human/front = stealth_person(block, 5, 2) + var/obj/item/gun/front_gun = d45_arm(front, /obj/item/gun/ballistic/automatic/pistol) + front.zone_selected = BODY_ZONE_CHEST + front_gun.fire_gun(holder, front, TRUE, null) + TEST_ASSERT_EQUAL(holder.getBruteLoss(), 0, "A shot from the front hit the holder") + TEST_ASSERT(hostage.getBruteLoss() > 0, "A shot from the front missed the shield") + var/hostage_before = hostage.getBruteLoss() + var/mob/living/carbon/human/back = stealth_person(block, 3, 2) + var/obj/item/gun/back_gun = d45_arm(back, /obj/item/gun/ballistic/automatic/pistol) + back.zone_selected = BODY_ZONE_CHEST + back_gun.fire_gun(holder, back, TRUE, null) + TEST_ASSERT(holder.getBruteLoss() > 0, "A shot from behind missed the holder") + TEST_ASSERT_EQUAL(hostage.getBruteLoss(), hostage_before, "A shot from behind hit the shield") + holder.stop_pulling() + TEST_ASSERT_NULL(holder.gunfu_shield_body(), "Still a shield after letting go") + qdel(block) + +/// Hostages: a guard alert on someone holding one of its own holds fire and stands off; demands work once each; +/// hurting the hostage ends the deal; a stranger held up is no reason to hold fire. +/datum/unit_test/voidcrew_stealth_hostage + +/datum/unit_test/voidcrew_stealth_hostage/Run() + var/datum/turf_reservation/block = stealth_block(10, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = stealth_guard(block, 8, 2, WEST) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai = stealth_ai(guard) + var/datum/ai_planning_subtree/stealth_hostage/subtree = GLOB.ai_subtrees[/datum/ai_planning_subtree/stealth_hostage] + var/at = stealth_ai.planning_subtrees.Find(subtree) + TEST_ASSERT(at, "The hostage subtree isn't in the guard's planning") + TEST_ASSERT(at < stealth_ai.planning_subtrees.Find(GLOB.ai_subtrees[/datum/ai_planning_subtree/human_npc_shoot]), "The hostage subtree comes after shooting") + var/mob/living/carbon/human/npc/friend = stealth_guard(block, 3, 2, WEST) + var/mob/living/carbon/human/holder = stealth_person(block, 2, 2) + var/obj/item/gun/ballistic/automatic/pistol/pistol = allocate(/obj/item/gun/ballistic/automatic/pistol) + pistol.can_misfire = FALSE + holder.put_in_active_hand(pistol, forced = TRUE) + holder.setDir(EAST) + gunfu_grab(holder, friend, GRAB_NECK) + TEST_ASSERT_EQUAL(stealth_hostage_of(holder), friend, "A neck grab with a gun isn't a hostage") + stealth_ai.stealth_go_alert(holder) + TEST_ASSERT_EQUAL(subtree.SelectBehaviors(stealth_ai, 1), SUBTREE_RETURN_FINISH_PLANNING, "The guard didn't hold fire") + TEST_ASSERT_EQUAL(stealth_ai.standoff_holder?.resolve(), holder, "No standoff") + // Demands, once each. + var/obj/item/held_weapon = guard.get_active_held_item() || guard.get_inactive_held_item() + holder.say("Back off!") + TEST_ASSERT(stealth_ai.standoff_backed_off, "Told to back off, it didn't") + holder.say("Drop the gun!") + TEST_ASSERT(stealth_ai.standoff_dropped, "Told to drop it, it didn't") + if(held_weapon) + TEST_ASSERT(!(held_weapon in guard.held_items), "Told to drop it, it kept its weapon") + // Hurting the hostage ends the deal for good. + pistol.fire_gun(friend, holder, TRUE, null) + TEST_ASSERT_NULL(stealth_ai.standoff_holder, "The standoff outlived a shot into the hostage") + TEST_ASSERT(LAZYFIND(stealth_ai.no_deals, REF(holder)), "No grudge after the hostage was shot") + TEST_ASSERT(isnull(subtree.SelectBehaviors(stealth_ai, 1)), "Stood off again against someone who shot a hostage") + // A stranger held up is no reason to hold fire. + var/mob/living/carbon/human/npc/guard2 = stealth_guard(block, 8, 4, WEST) + var/datum/ai_controller/basic_controller/human_npc/stealth/stealth_ai2 = stealth_ai(guard2) + var/mob/living/carbon/human/stranger = stealth_person(block, 3, 4) + var/mob/living/carbon/human/holder2 = stealth_person(block, 2, 4) + var/obj/item/gun/ballistic/automatic/pistol/pistol2 = allocate(/obj/item/gun/ballistic/automatic/pistol) + holder2.put_in_active_hand(pistol2, forced = TRUE) + gunfu_grab(holder2, stranger, GRAB_NECK) + stealth_ai2.stealth_go_alert(holder2) + TEST_ASSERT(isnull(subtree.SelectBehaviors(stealth_ai2, 1)), "A guard held fire for a stranger") + qdel(block) From 5f3fd39cca4e9df7b4842c2885c8c4999e763a16 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 04:21:04 -0800 Subject: [PATCH 51/78] Gun-fu motion goes in one file per move --- tgstation.dme | 5 ++- voidcrew/_DEFINES/stealth_gunfu.dm | 2 -- voidcrew/modules/stealth/stealth_gunfu.dm | 28 --------------- .../modules/stealth/stealth_gunfu_motion.dm | 27 -------------- .../stealth/stealth_gunfu_motion_flip.dm | 11 ++++++ .../stealth/stealth_gunfu_motion_hip_throw.dm | 11 ++++++ .../stealth/stealth_gunfu_motion_shield.dm | 35 +++++++++++++++++++ .../stealth/stealth_gunfu_motion_shove.dm | 15 ++++++++ 8 files changed, 76 insertions(+), 58 deletions(-) delete mode 100644 voidcrew/modules/stealth/stealth_gunfu_motion.dm create mode 100644 voidcrew/modules/stealth/stealth_gunfu_motion_flip.dm create mode 100644 voidcrew/modules/stealth/stealth_gunfu_motion_hip_throw.dm create mode 100644 voidcrew/modules/stealth/stealth_gunfu_motion_shield.dm create mode 100644 voidcrew/modules/stealth/stealth_gunfu_motion_shove.dm diff --git a/tgstation.dme b/tgstation.dme index e6b493c31cd..73076bb5a27 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7741,7 +7741,10 @@ #include "voidcrew\modules\stealth\stealth_doors.dm" #include "voidcrew\modules\stealth\stealth_gunfu.dm" #include "voidcrew\modules\stealth\stealth_gunfu_admin.dm" -#include "voidcrew\modules\stealth\stealth_gunfu_motion.dm" +#include "voidcrew\modules\stealth\stealth_gunfu_motion_flip.dm" +#include "voidcrew\modules\stealth\stealth_gunfu_motion_hip_throw.dm" +#include "voidcrew\modules\stealth\stealth_gunfu_motion_shield.dm" +#include "voidcrew\modules\stealth\stealth_gunfu_motion_shove.dm" #include "voidcrew\modules\stealth\stealth_hearing.dm" #include "voidcrew\modules\stealth\stealth_hostage.dm" #include "voidcrew\modules\stealth\stealth_knife.dm" diff --git a/voidcrew/_DEFINES/stealth_gunfu.dm b/voidcrew/_DEFINES/stealth_gunfu.dm index e0f7240158f..a84849c25a1 100644 --- a/voidcrew/_DEFINES/stealth_gunfu.dm +++ b/voidcrew/_DEFINES/stealth_gunfu.dm @@ -36,8 +36,6 @@ /// Disarm: how far the knocked-away item skids. #define GUNFU_DISARM_THROW_RANGE 2 -/// Human shield: how far in front of the holder the held body is drawn, in pixels. -#define GUNFU_SHIELD_SHIFT 12 /// Human shield: shots within this many degrees of the holder's facing hit the held body. #define GUNFU_SHIELD_ARC 67.5 diff --git a/voidcrew/modules/stealth/stealth_gunfu.dm b/voidcrew/modules/stealth/stealth_gunfu.dm index 9886e2a3652..d30cca224cc 100644 --- a/voidcrew/modules/stealth/stealth_gunfu.dm +++ b/voidcrew/modules/stealth/stealth_gunfu.dm @@ -259,31 +259,3 @@ var/turf/away = get_ranged_target_turf(victim, turn(get_dir(src, victim), pick(-45, 45)), GUNFU_DISARM_THROW_RANGE) held.throw_at(away, GUNFU_DISARM_THROW_RANGE, 2, src, spin = TRUE) return TRUE - -// --------------------------------------------------------------------------------------------- -// The human shield's pose - -/// A body held up as a shield stands in front of its holder, facing the same way, instead of tg's grab offset. Rows -/// sort before layers (SIDE_MAP), so a step down keeps it drawn in front of the holder side-on. -/mob/living/set_pull_offsets(mob/living/mob_to_set, grab_state = GRAB_PASSIVE, animate = TRUE) - if(!ishuman(src)) - return ..() - var/mob/living/carbon/human/holder = src - if(holder.gunfu_shield_body() != mob_to_set) - return ..() - mob_to_set.remove_offsets(GRABBING_TRAIT, animate = FALSE) - mob_to_set.setDir(dir) - var/shift_x = 0 - var/shift_y = 0 - switch(dir) - if(NORTH) - shift_y = GUNFU_SHIELD_SHIFT - if(SOUTH) - shift_y = -GUNFU_SHIELD_SHIFT - if(EAST) - shift_x = GUNFU_SHIELD_SHIFT - shift_y = -1 - if(WEST) - shift_x = -GUNFU_SHIELD_SHIFT - shift_y = -1 - mob_to_set.add_offsets(GRABBING_TRAIT, x_add = shift_x, y_add = shift_y, animate = animate) diff --git a/voidcrew/modules/stealth/stealth_gunfu_motion.dm b/voidcrew/modules/stealth/stealth_gunfu_motion.dm deleted file mode 100644 index ce2e52f13cd..00000000000 --- a/voidcrew/modules/stealth/stealth_gunfu_motion.dm +++ /dev/null @@ -1,27 +0,0 @@ -/** - * # Gun-fu motion (stealth step 3c, decision 17) - * - * The pictures for each gun-fu move (stealth_gunfu.dm). Visual only, under hyperviolence's motion rules - * (voidcrew/modules/hyperviolence/visuals/_motion_core.dm): named hv_vis_play() sequences that end where they began, - * nothing that moves, stuns, roots or hurts anyone. The gameplay has already happened (or is happening through tg's - * throw) when these are called; each only draws it. - * - * Each move is built storyboard -> blocking -> full build (kit rule), in all four facings. A move with no pictures - * yet just plays tg's own throw and shove. - */ - -/// Hip throw: `victim` is being thrown toward `toward` by tg's throw_at() right after this call. -/mob/living/carbon/human/proc/gunfu_vis_hip_throw(mob/living/victim, turf/toward) - return - -/// Shoulder flip: `victim`, on this mob's tile, is thrown onto `landing` right after this call. -/mob/living/carbon/human/proc/gunfu_vis_flip(mob/living/victim, turf/landing) - return - -/// Wall slam: `victim` is about to be shoved into the solid thing on `wall` by tg's disarm(). -/mob/living/carbon/human/proc/gunfu_vis_wall_slam(mob/living/victim, turf/wall) - return - -/// Disarm: `victim` is about to be shoved, and `held` knocked out of their hand. -/mob/living/carbon/human/proc/gunfu_vis_disarm(mob/living/victim, obj/item/held) - return diff --git a/voidcrew/modules/stealth/stealth_gunfu_motion_flip.dm b/voidcrew/modules/stealth/stealth_gunfu_motion_flip.dm new file mode 100644 index 00000000000..21061780729 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_gunfu_motion_flip.dm @@ -0,0 +1,11 @@ +/** + * # Gun-fu motion: the shoulder flip (stealth step 3c, decision 17) + * + * Visual only, under hyperviolence's motion rules (voidcrew/modules/hyperviolence/visuals/_motion_core.dm): named + * hv_vis_play() sequences that end where they began; nothing here moves, stuns, roots or hurts anyone. Built + * storyboard -> blocking -> full build (kit rule), in all four facings. + */ + +/// Shoulder flip: `victim`, on this mob's tile, is thrown onto `landing` right after this call. +/mob/living/carbon/human/proc/gunfu_vis_flip(mob/living/victim, turf/landing) + return diff --git a/voidcrew/modules/stealth/stealth_gunfu_motion_hip_throw.dm b/voidcrew/modules/stealth/stealth_gunfu_motion_hip_throw.dm new file mode 100644 index 00000000000..dbaa1019ab4 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_gunfu_motion_hip_throw.dm @@ -0,0 +1,11 @@ +/** + * # Gun-fu motion: the hip throw (stealth step 3c, decision 17) + * + * Visual only, under hyperviolence's motion rules (voidcrew/modules/hyperviolence/visuals/_motion_core.dm): named + * hv_vis_play() sequences that end where they began; nothing here moves, stuns, roots or hurts anyone. Built + * storyboard -> blocking -> full build (kit rule), in all four facings. + */ + +/// Hip throw: `victim` is being thrown toward `toward` by tg's throw_at() right after this call. +/mob/living/carbon/human/proc/gunfu_vis_hip_throw(mob/living/victim, turf/toward) + return diff --git a/voidcrew/modules/stealth/stealth_gunfu_motion_shield.dm b/voidcrew/modules/stealth/stealth_gunfu_motion_shield.dm new file mode 100644 index 00000000000..f7cabfb0b5d --- /dev/null +++ b/voidcrew/modules/stealth/stealth_gunfu_motion_shield.dm @@ -0,0 +1,35 @@ +/** + * # Gun-fu motion: the human shield (stealth step 3c, decision 17) + * + * Visual only, under hyperviolence's motion rules (voidcrew/modules/hyperviolence/visuals/_motion_core.dm): named + * hv_vis_play() sequences that end where they began; nothing here moves, stuns, roots or hurts anyone. Built + * storyboard -> blocking -> full build (kit rule), in all four facings. + */ + +/// Human shield: how far in front of the holder the held body is drawn, in pixels. +#define GUNFU_SHIELD_SHIFT 12 + +/// A body held up as a shield stands in front of its holder, facing the same way, instead of tg's grab offset. Rows +/// sort before layers (SIDE_MAP), so a step down keeps it drawn in front of the holder side-on. +/mob/living/set_pull_offsets(mob/living/mob_to_set, grab_state = GRAB_PASSIVE, animate = TRUE) + if(!ishuman(src)) + return ..() + var/mob/living/carbon/human/holder = src + if(holder.gunfu_shield_body() != mob_to_set) + return ..() + mob_to_set.remove_offsets(GRABBING_TRAIT, animate = FALSE) + mob_to_set.setDir(dir) + var/shift_x = 0 + var/shift_y = 0 + switch(dir) + if(NORTH) + shift_y = GUNFU_SHIELD_SHIFT + if(SOUTH) + shift_y = -GUNFU_SHIELD_SHIFT + if(EAST) + shift_x = GUNFU_SHIELD_SHIFT + shift_y = -1 + if(WEST) + shift_x = -GUNFU_SHIELD_SHIFT + shift_y = -1 + mob_to_set.add_offsets(GRABBING_TRAIT, x_add = shift_x, y_add = shift_y, animate = animate) diff --git a/voidcrew/modules/stealth/stealth_gunfu_motion_shove.dm b/voidcrew/modules/stealth/stealth_gunfu_motion_shove.dm new file mode 100644 index 00000000000..8a2639568ef --- /dev/null +++ b/voidcrew/modules/stealth/stealth_gunfu_motion_shove.dm @@ -0,0 +1,15 @@ +/** + * # Gun-fu motion: the wall slam and the disarm (stealth step 3c, decision 17) + * + * Visual only, under hyperviolence's motion rules (voidcrew/modules/hyperviolence/visuals/_motion_core.dm): named + * hv_vis_play() sequences that end where they began; nothing here moves, stuns, roots or hurts anyone. Built + * storyboard -> blocking -> full build (kit rule), in all four facings. + */ + +/// Wall slam: `victim` is about to be shoved into the solid thing on `wall` by tg's disarm(). +/mob/living/carbon/human/proc/gunfu_vis_wall_slam(mob/living/victim, turf/wall) + return + +/// Disarm: `victim` is about to be shoved, and `held` knocked out of their hand. +/mob/living/carbon/human/proc/gunfu_vis_disarm(mob/living/victim, obj/item/held) + return From 98a9c864c6748915c4952f03fd533a2dbd0f22d8 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 04:24:32 -0800 Subject: [PATCH 52/78] Gun-fu throws and flips turn the mover to face where the body goes --- voidcrew/modules/stealth/stealth_gunfu.dm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/voidcrew/modules/stealth/stealth_gunfu.dm b/voidcrew/modules/stealth/stealth_gunfu.dm index d30cca224cc..1a962fdd3e7 100644 --- a/voidcrew/modules/stealth/stealth_gunfu.dm +++ b/voidcrew/modules/stealth/stealth_gunfu.dm @@ -159,6 +159,7 @@ /// Hip throw: lets go of `victim` and throws them toward `toward` with tg's throw; they go down where they land. /mob/living/carbon/human/proc/gunfu_hip_throw(mob/living/victim, turf/toward) + setDir(get_cardinal_dir(src, toward)) stop_pulling() visible_message( span_danger("[src] throws [victim] over [p_their()] hip!"), @@ -171,9 +172,12 @@ victim.throw_at(toward, GUNFU_HIP_THROW_RANGE, 1, src, spin = FALSE, callback = CALLBACK(src, PROC_REF(gunfu_landed), victim, GUNFU_HIP_THROW_KNOCKDOWN, GUNFU_HIP_THROW_DAMAGE)) return TRUE -/// Shoulder flip: `victim`, held on this tile, goes over onto the next tile toward `toward` and lands flat. +/// Shoulder flip: `victim`, held on this tile, goes over onto the next tile toward `toward` (the way the mover turns to +/// face) and lands flat. /mob/living/carbon/human/proc/gunfu_flip(mob/living/victim, turf/toward) - var/turf/landing = get_step(src, get_dir(src, toward)) + var/flip_dir = get_cardinal_dir(src, toward) + var/turf/landing = get_step(src, flip_dir) + setDir(flip_dir) stop_pulling() visible_message( span_danger("[src] flips [victim] over [p_their()] shoulder!"), From 57bd0c0db7b281a776578b79df38582bc32a5b09 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 04:32:08 -0800 Subject: [PATCH 53/78] Gun-fu throws can't chain into a stunlock --- voidcrew/_DEFINES/stealth_gunfu.dm | 3 +++ voidcrew/modules/stealth/stealth_gunfu.dm | 9 ++++++++- voidcrew/modules/unit_tests/voidcrew_stealth_gunfu.dm | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/voidcrew/_DEFINES/stealth_gunfu.dm b/voidcrew/_DEFINES/stealth_gunfu.dm index a84849c25a1..3f24f57704b 100644 --- a/voidcrew/_DEFINES/stealth_gunfu.dm +++ b/voidcrew/_DEFINES/stealth_gunfu.dm @@ -26,6 +26,9 @@ /// Hip throw: brute on landing, through tg's armour (melee). #define GUNFU_HIP_THROW_DAMAGE 5 +/// After a throw or flip knockdown ends, this long before another throw or flip knocks the same body down again. +#define GUNFU_KNOCKDOWN_GRACE (4 SECONDS) + /// Shoulder flip: lands on the next tile, flat on their back. #define GUNFU_FLIP_KNOCKDOWN (3 SECONDS) #define GUNFU_FLIP_DAMAGE 8 diff --git a/voidcrew/modules/stealth/stealth_gunfu.dm b/voidcrew/modules/stealth/stealth_gunfu.dm index 1a962fdd3e7..de2489e2dd5 100644 --- a/voidcrew/modules/stealth/stealth_gunfu.dm +++ b/voidcrew/modules/stealth/stealth_gunfu.dm @@ -77,6 +77,10 @@ // --------------------------------------------------------------------------------------------- // Who can move +/mob/living + /// world.time until which a gun-fu throw or flip lands this body without a fresh knockdown. + var/gunfu_down_grace_until = 0 + /mob/living/carbon/human /// world.time the next gun-fu move is ready. var/gunfu_next_move = 0 @@ -199,7 +203,10 @@ var/hit_zone = zone || pick(BODY_ZONE_CHEST, BODY_ZONE_L_ARM, BODY_ZONE_R_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG) var/armour = victim.run_armor_check(hit_zone, MELEE, silent = TRUE) victim.apply_damage(damage, BRUTE, hit_zone, armour) - victim.Knockdown(knockdown) + // A body just put down by a throw or flip lands without a fresh knockdown, so throws can't chain into a stunlock. + if(world.time >= victim.gunfu_down_grace_until) + victim.Knockdown(knockdown) + victim.gunfu_down_grace_until = world.time + knockdown + GUNFU_KNOCKDOWN_GRACE playsound(victim, 'sound/effects/hit_kick.ogg', 50, TRUE, -1) // --------------------------------------------------------------------------------------------- diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_gunfu.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_gunfu.dm index b5a5453d56b..849aeff8f6d 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_gunfu.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_gunfu.dm @@ -76,9 +76,14 @@ // Landing: tg's knockdown and real damage. victim.throwing?.finalize() victim.SetKnockdown(0) + victim.gunfu_down_grace_until = 0 mover.gunfu_landed(victim, 2 SECONDS, 5) TEST_ASSERT(victim.IsKnockdown(), "Landing didn't knock them down") TEST_ASSERT(victim.getBruteLoss() > 0, "Landing did no damage") + // No stunlock: thrown again straight away, they land without a fresh knockdown. + victim.SetKnockdown(0) + mover.gunfu_landed(victim, 2 SECONDS, 5) + TEST_ASSERT(!victim.IsKnockdown(), "A second throw at once knocked them down again") // The flip: a neck grab puts them on the mover's tile; they go onto the next tile. var/mob/living/carbon/human/flipped = stealth_person(block, 2, 2) mover.gunfu_next_move = 0 From 29fa1056ec749292ab241d3dbfed9a88092b0229 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 05:19:26 -0800 Subject: [PATCH 54/78] A body held at gunpoint in a neck grab stays on its feet --- voidcrew/modules/stealth/stealth_hostage.dm | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/voidcrew/modules/stealth/stealth_hostage.dm b/voidcrew/modules/stealth/stealth_hostage.dm index d1854bce1a2..999099b8d55 100644 --- a/voidcrew/modules/stealth/stealth_hostage.dm +++ b/voidcrew/modules/stealth/stealth_hostage.dm @@ -218,3 +218,26 @@ lines[STEALTH_BARK_HOSTAGE_RELEASED] = list("Now!", "Take them!", "Get clear!") emotes[STEALTH_BARK_HOSTAGE] = list("raises a hand slowly.", "keeps their gun low.") emotes[STEALTH_BARK_HOSTAGE_DROP] = list("lets their weapon fall.") + +// --------------------------------------------------------------------------------------------- +// Held at gunpoint, held upright (decision 62) + +/** + * tg's neck grab floors the held body (TRAIT_FLOORED from CHOKEHOLD_TRAIT). Held at gunpoint as a hostage, it is held + * up on its feet instead: still tg's chokehold (immobilized, hands blocked), only not floored, so it stands in front of + * its holder and takes the shots that come at them (tg's projectiles skip a floored, pinned body). Settled every time + * tg places a held body (the grab, each step, each turn); tg's own release clears the chokehold either way. + */ +/mob/living/set_pull_offsets(mob/living/mob_to_set, grab_state = GRAB_PASSIVE, animate = TRUE) + stealth_hold_upright(mob_to_set) + return ..() + +/// Lifts `held` off the floor while this mob holds it at gunpoint, and puts tg's chokehold floor back when it doesn't. +/mob/living/proc/stealth_hold_upright(mob/living/held) + if(!isliving(held) || pulling != held) + return + if(stealth_hostage_of(src) == held) + if(HAS_TRAIT_FROM(held, TRAIT_FLOORED, CHOKEHOLD_TRAIT)) + REMOVE_TRAIT(held, TRAIT_FLOORED, CHOKEHOLD_TRAIT) + else if(grab_state >= GRAB_NECK && !HAS_TRAIT_FROM(held, TRAIT_FLOORED, CHOKEHOLD_TRAIT)) + ADD_TRAIT(held, TRAIT_FLOORED, CHOKEHOLD_TRAIT) From ed515e215f3ccd4fd4dc3538f42f53a2f9e0c396 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 05:43:12 -0800 Subject: [PATCH 55/78] A hostage held up stands at once, and the shield follows the holder's turn on the same tick --- voidcrew/modules/stealth/stealth_gunfu.dm | 4 ++-- voidcrew/modules/stealth/stealth_hostage.dm | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/voidcrew/modules/stealth/stealth_gunfu.dm b/voidcrew/modules/stealth/stealth_gunfu.dm index de2489e2dd5..dd5c1283274 100644 --- a/voidcrew/modules/stealth/stealth_gunfu.dm +++ b/voidcrew/modules/stealth/stealth_gunfu.dm @@ -41,11 +41,11 @@ /obj/item/organ/cyberimp/cyberware/gun_kata/on_mob_insert(mob/living/carbon/organ_owner, special = FALSE, movement_flags) . = ..() RegisterSignal(organ_owner, COMSIG_ATOM_PRE_BULLET_ACT, PROC_REF(on_owner_shot)) - RegisterSignal(organ_owner, COMSIG_ATOM_DIR_CHANGE, PROC_REF(on_owner_turned)) + RegisterSignal(organ_owner, COMSIG_ATOM_POST_DIR_CHANGE, PROC_REF(on_owner_turned)) /obj/item/organ/cyberimp/cyberware/gun_kata/on_mob_remove(mob/living/carbon/organ_owner, special = FALSE, movement_flags) . = ..() - UnregisterSignal(organ_owner, list(COMSIG_ATOM_PRE_BULLET_ACT, COMSIG_ATOM_DIR_CHANGE)) + UnregisterSignal(organ_owner, list(COMSIG_ATOM_PRE_BULLET_ACT, COMSIG_ATOM_POST_DIR_CHANGE)) if(isliving(organ_owner.pulling)) organ_owner.set_pull_offsets(organ_owner.pulling, organ_owner.grab_state) diff --git a/voidcrew/modules/stealth/stealth_hostage.dm b/voidcrew/modules/stealth/stealth_hostage.dm index 999099b8d55..9d4cd292b07 100644 --- a/voidcrew/modules/stealth/stealth_hostage.dm +++ b/voidcrew/modules/stealth/stealth_hostage.dm @@ -239,5 +239,8 @@ if(stealth_hostage_of(src) == held) if(HAS_TRAIT_FROM(held, TRAIT_FLOORED, CHOKEHOLD_TRAIT)) REMOVE_TRAIT(held, TRAIT_FLOORED, CHOKEHOLD_TRAIT) + // tg's own stand-up after the floor goes is a 1 s do_after; held up, they're on their feet at once. + // get_up() still refuses a body that is resting or floored by anything else (a stun, crit). + held.get_up(instant = TRUE) else if(grab_state >= GRAB_NECK && !HAS_TRAIT_FROM(held, TRAIT_FLOORED, CHOKEHOLD_TRAIT)) ADD_TRAIT(held, TRAIT_FLOORED, CHOKEHOLD_TRAIT) From 1d0354c2c870b5f3fb37f64a044ebf2613fe1223 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 05:50:08 -0800 Subject: [PATCH 56/78] Stealth takedowns: the garrotte and the chokehold, tg's strangle closed fast from behind --- tgstation.dme | 4 + voidcrew/_DEFINES/stealth_takedown.dm | 26 ++ voidcrew/modules/stealth/icons/garrotte.dmi | Bin 0 -> 352 bytes .../modules/stealth/icons/takedown_wire.dmi | Bin 0 -> 217 bytes voidcrew/modules/stealth/stealth_garrotte.dm | 41 +++ voidcrew/modules/stealth/stealth_takedown.dm | 299 ++++++++++++++++++ .../stealth/stealth_takedown_motion.dm | 13 + voidcrew/modules/unit_tests/_unit_tests.dm | 1 + .../unit_tests/voidcrew_stealth_takedown.dm | 131 ++++++++ 9 files changed, 515 insertions(+) create mode 100644 voidcrew/_DEFINES/stealth_takedown.dm create mode 100644 voidcrew/modules/stealth/icons/garrotte.dmi create mode 100644 voidcrew/modules/stealth/icons/takedown_wire.dmi create mode 100644 voidcrew/modules/stealth/stealth_garrotte.dm create mode 100644 voidcrew/modules/stealth/stealth_takedown.dm create mode 100644 voidcrew/modules/stealth/stealth_takedown_motion.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_stealth_takedown.dm diff --git a/tgstation.dme b/tgstation.dme index 63228436cc9..43348c33287 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -6743,6 +6743,7 @@ #include "voidcrew\_DEFINES\sound.dm" #include "voidcrew\_DEFINES\stealth.dm" #include "voidcrew\_DEFINES\stealth_hearing.dm" +#include "voidcrew\_DEFINES\stealth_takedown.dm" #include "voidcrew\_DEFINES\subsystems.dm" #include "voidcrew\_DEFINES\techweb_nodes.dm" #include "voidcrew\_DEFINES\trade.dm" @@ -7737,6 +7738,7 @@ #include "voidcrew\modules\stealth\stealth_closet.dm" #include "voidcrew\modules\stealth\stealth_crits.dm" #include "voidcrew\modules\stealth\stealth_disguise.dm" +#include "voidcrew\modules\stealth\stealth_garrotte.dm" #include "voidcrew\modules\stealth\stealth_doors.dm" #include "voidcrew\modules\stealth\stealth_hearing.dm" #include "voidcrew\modules\stealth\stealth_knife.dm" @@ -7748,6 +7750,8 @@ #include "voidcrew\modules\stealth\stealth_perception.dm" #include "voidcrew\modules\stealth\stealth_radio.dm" #include "voidcrew\modules\stealth\stealth_skill.dm" +#include "voidcrew\modules\stealth\stealth_takedown.dm" +#include "voidcrew\modules\stealth\stealth_takedown_motion.dm" #include "voidcrew\modules\stealth\stealth_test_planet.dm" #include "voidcrew\modules\stealth\stealth_test_ruin.dm" #include "voidcrew\modules\stealth\stealth_turns.dm" diff --git a/voidcrew/_DEFINES/stealth_takedown.dm b/voidcrew/_DEFINES/stealth_takedown.dm new file mode 100644 index 00000000000..ffff18d29a6 --- /dev/null +++ b/voidcrew/_DEFINES/stealth_takedown.dm @@ -0,0 +1,26 @@ +// Stealth step 3b: the garrotte and the chokehold (voidcrew/modules/stealth/stealth_takedown.dm). + +/// Trait source for what a takedown hold puts on its victim (the mute while the airway is shut). +#define STEALTH_TAKEDOWN_TRAIT "stealth_takedown" +/// do_after interaction key for the wind-up. +#define STEALTH_TAKEDOWN_DOAFTER "stealth_takedown" + +/// The wind-up before the hold closes: the wire goes over the head, or the arm round the neck. Turning round ends it. +#define STEALTH_TAKEDOWN_WINDUP (0.8 SECONDS) + +/// Takedown kinds. +#define STEALTH_TAKEDOWN_CHOKE "choke" +#define STEALTH_TAKEDOWN_GARROTTE "garrotte" + +/// Oxygen damage per second the chokehold's arm adds on a bare neck, on top of tg's own strangle (one missed breath +/// per Life tick, about 1.5 a second). Together: out (tg's 50) in about 9 s. +#define STEALTH_CHOKE_OXY_RATE 4 +/// The garrotte's wire per second on a bare neck. Together with tg's strangle: out in about 5 s, dead (oxygen 200) in +/// about 20 s if it is never let go. +#define STEALTH_GARROTTE_OXY_RATE 8 +/// The chokehold lets go once the victim is out and this deep (tg's breathing takes 2.5 a second off again, so he +/// stays out about 10 s after the release). +#define STEALTH_CHOKE_RELEASE_OXY 75 + +/// Neck cover (hv_crit_cover_rating(), melee, worn and physiology armour stacked) at which neither hold can close. +#define STEALTH_TAKEDOWN_MAX_COVER 60 diff --git a/voidcrew/modules/stealth/icons/garrotte.dmi b/voidcrew/modules/stealth/icons/garrotte.dmi new file mode 100644 index 0000000000000000000000000000000000000000..1db8b6eb8967131d529158462d6a57a94eabd278 GIT binary patch literal 352 zcmV-m0iXVfP)V=-0C=2JR&a84_w-Y6@%7{?OD!tS%+FJ>RWQ*r;NmRLOex6#a*U0*I5Sc+ z(=$pSoZ^zil2jm5DLt{MD8Hm6Rf&r;C9|j)C}haRnO2mTn+jnoE4cc(fK3Jfo;VwG zS*aLI00025NkluAFu;HbpCl;ps0EbJEDI8J z01Ql)e_1!5cyiE*d|0q;uX!^CUx2Pwx&3;~?Y9#$F0@9!)wj zDMTT7rOjrI(9UjS)y*p;PMAJ<J9mC*wqu!8PTkMje!p0AI4d>k%82VGqHLEIsNmZtPY?) N22WQ%mvv4FO#qYUP>KKm literal 0 HcmV?d00001 diff --git a/voidcrew/modules/stealth/stealth_garrotte.dm b/voidcrew/modules/stealth/stealth_garrotte.dm new file mode 100644 index 00000000000..d23b35fbc47 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_garrotte.dm @@ -0,0 +1,41 @@ +/** + * # The garrotte (stealth step 3b, owner decision 12) + * + * Two grips and a length of wire, held in both hands. A combat-mode click on someone it can take (stealth_takedown.dm) + * drops the wire over their head and strangles them until they're dead or the garroter lets go. On anyone it can't + * take it does nothing: it has no force. + * + * Players get it as scav den loot (step 4). It has no buy, print or craft route, like the matte knife. + */ +/obj/item/garrotte + name = "garrotte" + desc = "Two wooden grips and a length of wire between them." + icon = 'voidcrew/modules/stealth/icons/garrotte.dmi' + icon_state = "garrotte" + w_class = WEIGHT_CLASS_SMALL + force = 0 + throwforce = 0 + attack_verb_continuous = list("whips") + attack_verb_simple = list("whip") + custom_materials = list(/datum/material/iron = SMALL_MATERIAL_AMOUNT, /datum/material/wood = SMALL_MATERIAL_AMOUNT) + +/obj/item/garrotte/Initialize(mapload) + . = ..() + AddComponent(/datum/component/two_handed, require_twohands = TRUE) + +/obj/item/garrotte/attack(mob/living/target_mob, mob/living/user, list/modifiers, list/attack_modifiers) + if(!ishuman(target_mob) || !user.combat_mode) + return ..() + var/refusal = stealth_takedown_refusal(user, target_mob, STEALTH_TAKEDOWN_GARROTTE, src) + switch(refusal) + if(null) + var/datum/stealth_takedown/hold = new(user, target_mob, STEALTH_TAKEDOWN_GARROTTE, src) + INVOKE_ASYNC(hold, TYPE_PROC_REF(/datum/stealth_takedown, start)) + return TRUE + if("front") + user.balloon_alert(user, "can't get it over [target_mob.p_their()] head!") + return TRUE + if("cover") + user.balloon_alert(user, "the wire won't bite!") + return TRUE + return TRUE diff --git a/voidcrew/modules/stealth/stealth_takedown.dm b/voidcrew/modules/stealth/stealth_takedown.dm new file mode 100644 index 00000000000..0e40f06ba36 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_takedown.dm @@ -0,0 +1,299 @@ +/** + * # Takedowns: the garrotte and the chokehold (stealth step 3b, owner decisions 9, 12, 22, 36) + * + * Both are tg's own strangle (a GRAB_KILL hold: the victim is held on his feet where he stands, can't breathe, and + * struggles out with tg's resist), closed quickly from behind, plus the pressure of the wire or the arm as oxygen + * damage. Knocking out and dying are tg's: TRAIT_KNOCKEDOUT at 50 oxygen loss, crit and death from the same damage. + * + * - Who can be taken: a human with a head, not buckled, not held by someone else, adjacent, and either taken from behind + * (tg's check_behind()) while not on guard, or helpless (hv_is_helpless(): down, cuffed, stunned, held). A stealth + * guard is on guard unless stealth_caught_off_guard(); anyone else (players included, decision 22) counts as off + * guard from behind. Only attackers hv_can_execute() lets (players, boss NPCs), never pacifists. + * - The garrotte (stealth_garrotte.dm), held in both hands, combat-mode click: the lethal one. It holds until the + * victim is dead unless the garroter lets go (tg's own stop-pulling), drops the wire or is pulled off. + * - The chokehold: empty-handed, combat mode, a grab (ctrl-click or the grab intent): the non-lethal one. It lets go by + * itself once the victim is out and STEALTH_CHOKE_RELEASE_OXY deep, so he wakes about 10 s later on tg's breathing. + * - Wind-up (STEALTH_TAKEDOWN_WINDUP): both hold still; the victim turning to face the attacker, either moving or the + * attacker losing the wire or his free hand ends it with nothing done. + * - Protection: the neck's melee cover, worn armour and physiology armour such as dermal cyberware stacked as tg stacks + * them (hv_crit_cover_rating()), slows the wire or the arm in proportion; a sealed helmet or cover at + * STEALTH_TAKEDOWN_MAX_COVER stops it closing at all. tg's own strangle still runs under any cover, as it does + * for any GRAB_KILL. + * - While the hold is on the victim is mute (TRAIT_MUTE): no shout, no radio. tg's can_speak() does the rest. + * - Machines and anything that doesn't breathe (TRAIT_NOBREATH, a breathing tube) take no oxygen damage from it. + * + * Visuals are stealth_takedown_motion.dm and change nothing here. + */ + +/mob/living + /// The takedown this mob is doing, if any. + var/datum/stealth_takedown/stealth_takedown_doing + /// The takedown this mob is caught in, if any. + var/datum/stealth_takedown/stealth_takedown_caught + +/// Why a takedown can't start, or null if it can. `kind` is STEALTH_TAKEDOWN_*. +/proc/stealth_takedown_refusal(mob/living/attacker, mob/living/target, kind, obj/item/garrotte/wire) + if(!isliving(attacker) || !ishuman(target) || attacker == target) + return "no" + var/mob/living/carbon/human/victim = target + if(!attacker.combat_mode || HAS_TRAIT(attacker, TRAIT_PACIFISM) || !attacker.hv_can_execute()) + return "no" + if(attacker.stealth_takedown_doing || victim.stealth_takedown_caught || attacker.incapacitated) + return "no" + if(victim.stat == DEAD || isnull(victim.get_bodypart(BODY_ZONE_HEAD)) || victim.buckled) + return "no" + if(!attacker.Adjacent(victim) || !isturf(attacker.loc) || !isturf(victim.loc)) + return "no" + if(victim.pulledby && victim.pulledby != attacker) + return "no" + if(kind == STEALTH_TAKEDOWN_GARROTTE) + if(isnull(wire) || !attacker.is_holding(wire) || !HAS_TRAIT(wire, TRAIT_WIELDED)) + return "no" + else if(attacker.get_active_held_item()) + return "no" + if(!stealth_takedown_off_guard(attacker, victim)) + return "front" + if(stealth_takedown_neck_cover(victim) >= STEALTH_TAKEDOWN_MAX_COVER) + return "cover" + return null + +/// TRUE if `victim` can be taken by `attacker` now: helpless, or from behind while not on guard. +/proc/stealth_takedown_off_guard(mob/living/attacker, mob/living/carbon/human/victim) + if(victim.hv_is_helpless()) + return TRUE + if(!check_behind(attacker, victim)) + return FALSE + var/mob/living/carbon/human/npc/guard = victim + if(istype(guard) && istype(guard.ai_controller, /datum/ai_controller/basic_controller/human_npc/stealth)) + return guard.stealth_caught_off_guard(attacker) + return TRUE + +/// How well the neck is covered against the wire or the arm (0-100): a sealed helmet is 100, otherwise the head's melee +/// cover from worn and physiology armour, stacked as tg stacks them. +/proc/stealth_takedown_neck_cover(mob/living/carbon/human/victim) + if(victim.is_mouth_covered(ITEM_SLOT_HEAD)) + return 100 + var/obj/item/bodypart/head = victim.get_bodypart(BODY_ZONE_HEAD) + if(isnull(head)) + return 100 + return clamp(hv_crit_cover_rating(victim, head, MELEE), 0, 100) + +// --------------------------------------------------------------------------------------------- +// The chokehold's trigger: tg's grab (ctrl-click, or the grab intent's click) + +/mob/living/grab(mob/living/target) + if(combat_mode && ishuman(target) && pulling != target && !stealth_takedown_refusal(src, target, STEALTH_TAKEDOWN_CHOKE)) + var/datum/stealth_takedown/hold = new(src, target, STEALTH_TAKEDOWN_CHOKE) + INVOKE_ASYNC(hold, TYPE_PROC_REF(/datum/stealth_takedown, start)) + return TRUE + return ..() + +// --------------------------------------------------------------------------------------------- +// The hold + +/datum/stealth_takedown + var/mob/living/attacker + var/mob/living/carbon/human/victim + /// STEALTH_TAKEDOWN_* + var/kind + var/obj/item/garrotte/wire + /// Oxygen damage a second on top of tg's strangle, after the neck's cover. + var/oxy_rate = 0 + /// TRUE once the hold has closed (the GRAB_KILL is on). + var/closed = FALSE + /// TRUE once it has ended, so it ends once. + var/ended = FALSE + /// The timer for the next hold_tick(). + var/tick_timer + +/datum/stealth_takedown/New(mob/living/attacker, mob/living/carbon/human/victim, kind, obj/item/garrotte/wire) + src.attacker = attacker + src.victim = victim + src.kind = kind + src.wire = wire + attacker.stealth_takedown_doing = src + victim.stealth_takedown_caught = src + RegisterSignals(attacker, list(COMSIG_QDELETING, COMSIG_LIVING_DEATH), PROC_REF(on_gone)) + RegisterSignal(victim, COMSIG_QDELETING, PROC_REF(on_gone)) + if(wire) + RegisterSignal(wire, COMSIG_QDELETING, PROC_REF(on_gone)) + +/datum/stealth_takedown/Destroy() + if(!ended) + end(FALSE) + attacker = null + victim = null + wire = null + return ..() + +/datum/stealth_takedown/proc/on_gone(datum/source) + SIGNAL_HANDLER + end(FALSE) + +/// The wind-up, then the hold closes. Runs async. +/datum/stealth_takedown/proc/start() + var/garrotte = kind == STEALTH_TAKEDOWN_GARROTTE + var/unseen = check_behind(attacker, victim) || victim.is_blind() + if(garrotte) + attacker.visible_message( + span_danger("[attacker] drops a wire over [victim]'s head!"), + span_danger("You drop the wire over [victim]'s head."), + ignored_mobs = victim, + vision_distance = COMBAT_MESSAGE_RANGE, + ) + to_chat(victim, span_userdanger((unseen ? "A wire drops over your head!" : "[attacker] drops a wire over your head!"))) + else + attacker.visible_message( + span_danger("[attacker] hooks an arm round [victim]'s neck!"), + span_danger("You hook an arm round [victim]'s neck."), + ignored_mobs = victim, + vision_distance = COMBAT_MESSAGE_RANGE, + ) + to_chat(victim, span_userdanger((unseen ? "An arm locks round your neck!" : "[attacker] locks an arm round your neck!"))) + attacker.changeNext_move(CLICK_CD_GRABBING) + vis_windup() + var/held = do_after( + attacker, + STEALTH_TAKEDOWN_WINDUP, + victim, + extra_checks = CALLBACK(src, PROC_REF(windup_holds)), + interaction_key = STEALTH_TAKEDOWN_DOAFTER, + hidden = TRUE, + ) + if(ended) + return + if(!held || !windup_holds() || !close()) + end(FALSE) + +/// do_after check for the wind-up. +/datum/stealth_takedown/proc/windup_holds() + if(ended || QDELETED(attacker) || QDELETED(victim)) + return FALSE + // The takedown is already registered on both, so check the rest of the refusal by hand. + if(!attacker.combat_mode || attacker.incapacitated || victim.stat == DEAD || victim.buckled || !attacker.Adjacent(victim)) + return FALSE + if(victim.pulledby && victim.pulledby != attacker) + return FALSE + if(kind == STEALTH_TAKEDOWN_GARROTTE) + if(QDELETED(wire) || !attacker.is_holding(wire) || !HAS_TRAIT(wire, TRAIT_WIELDED)) + return FALSE + else if(attacker.get_active_held_item()) + return FALSE + // Turning round to face the attacker ends it; a victim already helpless can't. + return victim.hv_is_helpless() || check_behind(attacker, victim) + +/// tg's strangle, closed at once: the same states grippedby() steps through, in the same order. +/datum/stealth_takedown/proc/close() + if(attacker.pulling != victim && !attacker.start_pulling(victim, supress_message = TRUE)) + return FALSE + if(attacker.pulling != victim) + return FALSE + var/cover = stealth_takedown_neck_cover(victim) + if(cover >= STEALTH_TAKEDOWN_MAX_COVER) + return FALSE + var/base_rate = kind == STEALTH_TAKEDOWN_GARROTTE ? STEALTH_GARROTTE_OXY_RATE : STEALTH_CHOKE_OXY_RATE + oxy_rate = base_rate * (100 - cover) / 100 + if(attacker.grab_state < GRAB_AGGRESSIVE) + attacker.setGrabState(GRAB_AGGRESSIVE) + victim.stop_pulling() + attacker.setGrabState(GRAB_KILL) + // Unlike grippedby(), the victim stays on his own tile and on his feet, held up from behind: tg's neck grab floors + // him (CHOKEHOLD_TRAIT), this takes that one source off again. He can't move or use his hands (tg's aggressive grab + // traits) and goes down by tg's own rules when he passes out. No pull offsets: they would turn him to face the + // attacker; the visuals pull him in instead. + REMOVE_TRAIT(victim, TRAIT_FLOORED, CHOKEHOLD_TRAIT) + victim.update_incapacitated() + closed = TRUE + ADD_TRAIT(victim, TRAIT_MUTE, STEALTH_TAKEDOWN_TRAIT) + playsound(victim, 'sound/items/weapons/thudswoosh.ogg', 50, TRUE, -1) + if(kind == STEALTH_TAKEDOWN_GARROTTE) + victim.visible_message( + span_danger("[attacker] pulls the wire tight round [victim]'s neck!"), + span_userdanger("The wire bites into your neck!"), + span_hear("You hear a struggle."), + COMBAT_MESSAGE_RANGE, + attacker, + ) + to_chat(attacker, span_danger("You pull the wire tight.")) + else + victim.visible_message( + span_danger("[attacker] drags [victim] down in a chokehold!"), + span_userdanger("You can't breathe!"), + span_hear("You hear a struggle."), + COMBAT_MESSAGE_RANGE, + attacker, + ) + to_chat(attacker, span_danger("You squeeze.")) + log_combat(attacker, victim, kind == STEALTH_TAKEDOWN_GARROTTE ? "garrotted" : "choked from behind", wire, "(takedown, neck cover [round(cover)])") + RegisterSignal(attacker, COMSIG_ATOM_NO_LONGER_PULLING, PROC_REF(on_let_go)) + RegisterSignal(attacker, COMSIG_MOVABLE_SET_GRAB_STATE, PROC_REF(on_grab_state)) + vis_close() + tick_timer = addtimer(CALLBACK(src, PROC_REF(timed_tick)), 1 SECONDS, TIMER_STOPPABLE|TIMER_DELETE_ME) + return TRUE + +/// One second of the hold, then the next. A timer, not a processing subsystem, so it runs the same in any runlevel. +/datum/stealth_takedown/proc/timed_tick() + tick_timer = null + if(hold_tick(1) && !ended) + tick_timer = addtimer(CALLBACK(src, PROC_REF(timed_tick)), 1 SECONDS, TIMER_STOPPABLE|TIMER_DELETE_ME) + +/datum/stealth_takedown/proc/on_let_go(datum/source, atom/movable/last_pulled) + SIGNAL_HANDLER + end(FALSE) + +/datum/stealth_takedown/proc/on_grab_state(datum/source, new_state) + SIGNAL_HANDLER + if(new_state < GRAB_KILL) + end(FALSE) + +/// One step of the hold, `seconds_per_tick` long. FALSE once it has ended. +/datum/stealth_takedown/proc/hold_tick(seconds_per_tick) + if(ended) + return FALSE + if(QDELETED(attacker) || QDELETED(victim) || attacker.pulling != victim || attacker.grab_state < GRAB_KILL) + end(FALSE) + return FALSE + if(attacker.incapacitated || attacker.stat != CONSCIOUS) + end(TRUE) + return FALSE + if(kind == STEALTH_TAKEDOWN_GARROTTE && (QDELETED(wire) || !attacker.is_holding(wire) || !HAS_TRAIT(wire, TRAIT_WIELDED))) + end(TRUE) + return FALSE + if(victim.stat == DEAD) + attacker.visible_message(span_danger("[attacker] lets go of [victim]."), span_notice("You let go."), vision_distance = COMBAT_MESSAGE_RANGE) + end(TRUE) + return FALSE + if(!HAS_TRAIT(victim, TRAIT_NOBREATH) && !victim.get_organ_slot(ORGAN_SLOT_BREATHING_TUBE)) + victim.adjustOxyLoss(oxy_rate * seconds_per_tick) + vis_tick() + if(kind == STEALTH_TAKEDOWN_CHOKE && victim.getOxyLoss() >= STEALTH_CHOKE_RELEASE_OXY && HAS_TRAIT(victim, TRAIT_KNOCKEDOUT)) + victim.visible_message(span_danger("[attacker] lets [victim] slump to the floor."), null, null, COMBAT_MESSAGE_RANGE, attacker) + to_chat(attacker, span_notice("You let [victim] slump.")) + end(TRUE) + return FALSE + return TRUE + +/// Ends the takedown. `release` also lets go of the victim (tg's stop_pulling()). +/datum/stealth_takedown/proc/end(release) + if(ended) + return + ended = TRUE + if(tick_timer) + deltimer(tick_timer) + tick_timer = null + vis_end() + if(!isnull(attacker)) + UnregisterSignal(attacker, list(COMSIG_QDELETING, COMSIG_LIVING_DEATH, COMSIG_ATOM_NO_LONGER_PULLING, COMSIG_MOVABLE_SET_GRAB_STATE)) + if(attacker.stealth_takedown_doing == src) + attacker.stealth_takedown_doing = null + if(release && !QDELETED(attacker) && attacker.pulling == victim) + attacker.stop_pulling() + if(!isnull(victim)) + UnregisterSignal(victim, COMSIG_QDELETING) + REMOVE_TRAIT(victim, TRAIT_MUTE, STEALTH_TAKEDOWN_TRAIT) + if(victim.stealth_takedown_caught == src) + victim.stealth_takedown_caught = null + if(!isnull(wire)) + UnregisterSignal(wire, COMSIG_QDELETING) + if(!QDELETED(src)) + qdel(src) diff --git a/voidcrew/modules/stealth/stealth_takedown_motion.dm b/voidcrew/modules/stealth/stealth_takedown_motion.dm new file mode 100644 index 00000000000..5e99d887564 --- /dev/null +++ b/voidcrew/modules/stealth/stealth_takedown_motion.dm @@ -0,0 +1,13 @@ +// Visuals for takedowns (stealth_takedown.dm). Purely visual: nothing here changes a body's state. + +/datum/stealth_takedown/proc/vis_windup() + return + +/datum/stealth_takedown/proc/vis_close() + return + +/datum/stealth_takedown/proc/vis_tick() + return + +/datum/stealth_takedown/proc/vis_end() + return diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index 37b4d39b0b8..045d137aa08 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -245,6 +245,7 @@ #include "voidcrew_stealth_disguise.dm" #include "voidcrew_stealth_hearing.dm" #include "voidcrew_stealth_light.dm" +#include "voidcrew_stealth_takedown.dm" #include "voidcrew_survey_archive.dm" #include "voidcrew_survey_capabilities.dm" #include "voidcrew_survey_identity.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_takedown.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_takedown.dm new file mode 100644 index 00000000000..7aaebe46de7 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_takedown.dm @@ -0,0 +1,131 @@ +// Step 3b: the garrotte and the chokehold (voidcrew/modules/stealth/stealth_takedown.dm, stealth_garrotte.dm). Unit tests +// compile before voidcrew/_DEFINES, so values are written out: the garrotte 8 oxygen a second, the chokehold 4, the +// chokehold lets go at 75, no hold through cover 60. + +/// A garrotte in both of `person`'s hands, combat mode on. +/datum/unit_test/proc/takedown_garrotte(mob/living/carbon/human/person) + var/obj/item/garrotte/wire = allocate(/obj/item/garrotte) + person.put_in_active_hand(wire, forced = TRUE) + person.set_combat_mode(TRUE) + return wire + +/// Who can be taken: from behind an unaware guard, not from the front, not an alert guard, a person from behind, not +/// through a sealed helmet; the chokehold wants an empty hand and the garrotte both. +/datum/unit_test/voidcrew_stealth_takedown_who + +/datum/unit_test/voidcrew_stealth_takedown_who/Run() + var/datum/turf_reservation/block = stealth_block(9, 9) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = d45_bare_guard(block, 4, 1) + var/mob/living/carbon/human/person = stealth_person(block, 3, 1) + var/obj/item/garrotte/wire = takedown_garrotte(person) + TEST_ASSERT(HAS_TRAIT(wire, TRAIT_WIELDED), "The garrotte isn't held in both hands") + TEST_ASSERT_NULL(stealth_takedown_refusal(person, guard, "garrotte", wire), "The garrotte can't take an unaware guard from behind") + person.forceMove(stealth_at(block, 5, 1)) + TEST_ASSERT_EQUAL(stealth_takedown_refusal(person, guard, "garrotte", wire), "front", "The garrotte takes a guard from the front") + person.forceMove(stealth_at(block, 3, 1)) + TEST_ASSERT_EQUAL(stealth_takedown_refusal(person, guard, "choke"), "no", "A chokehold with a garrotte in hand") + // An alert guard is on guard, even from behind. + var/mob/living/carbon/human/npc/alert = d45_bare_guard(block, 4, 3) + var/mob/living/carbon/human/other = stealth_person(block, 3, 3) + other.set_combat_mode(TRUE) + var/datum/ai_controller/basic_controller/human_npc/stealth/alert_ai = stealth_ai(alert) + alert_ai.stealth_go_alert(other) + TEST_ASSERT_EQUAL(stealth_takedown_refusal(other, alert, "choke"), "front", "An alert guard can be choked from behind") + // A person (no awareness) from behind can (decision 22), from the front can't. + var/mob/living/carbon/human/victim = stealth_person(block, 4, 5) + victim.setDir(EAST) + var/mob/living/carbon/human/choker = stealth_person(block, 3, 5) + choker.set_combat_mode(TRUE) + TEST_ASSERT_NULL(stealth_takedown_refusal(choker, victim, "choke"), "A person can't be choked from behind") + victim.setDir(WEST) + TEST_ASSERT_EQUAL(stealth_takedown_refusal(choker, victim, "choke"), "front", "A person facing you can be choked") + // ...unless he is helpless. + victim.Paralyze(10 SECONDS) + TEST_ASSERT_NULL(stealth_takedown_refusal(choker, victim, "choke"), "A paralysed person can't be choked") + victim.SetParalyzed(0) + victim.setDir(EAST) + // A sealed helmet stops both. + var/obj/item/clothing/head/helmet/space/sealed = new(victim) + TEST_ASSERT(victim.equip_to_slot_if_possible(sealed, ITEM_SLOT_HEAD, disable_warning = TRUE), "Couldn't put on the space helmet") + TEST_ASSERT_EQUAL(stealth_takedown_refusal(choker, victim, "choke"), "cover", "A chokehold through a sealed helmet") + // No combat mode, no takedown: a grab is tg's grab. + var/mob/living/carbon/human/npc/calm = d45_bare_guard(block, 4, 7) + var/mob/living/carbon/human/puller = stealth_person(block, 3, 7) + puller.set_combat_mode(FALSE) + puller.grab(calm) + TEST_ASSERT_NULL(puller.stealth_takedown_doing, "A grab out of combat mode started a takedown") + TEST_ASSERT_EQUAL(puller.grab_state, GRAB_PASSIVE, "A grab out of combat mode wasn't tg's pull") + +/// The garrotte closes tg's strangle at once: floored, mute, oxygen loss each second, out at 50, +/// dead if never let go, then let go. Letting go early ends it. +/datum/unit_test/voidcrew_stealth_takedown_garrotte + +/datum/unit_test/voidcrew_stealth_takedown_garrotte/Run() + var/datum/turf_reservation/block = stealth_block(8, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = d45_bare_guard(block, 4, 1) + var/mob/living/carbon/human/person = stealth_person(block, 3, 1) + var/obj/item/garrotte/wire = takedown_garrotte(person) + var/datum/stealth_takedown/hold = new(person, guard, "garrotte", wire) + TEST_ASSERT(hold.close(), "The garrotte didn't close") + TEST_ASSERT_EQUAL(person.grab_state, GRAB_KILL, "The garrotte isn't tg's strangle") + TEST_ASSERT_EQUAL(person.pulling, guard, "The garroter isn't holding the guard") + TEST_ASSERT(!HAS_TRAIT(guard, TRAIT_FLOORED) && guard.body_position == STANDING_UP, "The garrotted guard isn't held on his feet") + TEST_ASSERT(HAS_TRAIT(guard, TRAIT_IMMOBILIZED) && HAS_TRAIT(guard, TRAIT_HANDS_BLOCKED), "The garrotted guard can move or use his hands") + TEST_ASSERT(HAS_TRAIT(guard, TRAIT_MUTE) && !guard.can_speak(), "A garrotted guard can speak") + TEST_ASSERT_EQUAL(hold.oxy_rate, 8, "A bare neck doesn't take the garrotte's full rate") + for(var/i in 1 to 7) + hold.hold_tick(1) + TEST_ASSERT(guard.getOxyLoss() >= 50, "Seven seconds of the garrotte left the guard at [guard.getOxyLoss()] oxygen loss") + TEST_ASSERT(guard.stat >= UNCONSCIOUS, "The garrotte didn't put the guard out") + TEST_ASSERT(guard.body_position == LYING_DOWN, "The guard didn't go down when he passed out") + for(var/i in 1 to 25) + if(QDELETED(hold)) + break + hold.hold_tick(1) + TEST_ASSERT_EQUAL(guard.stat, DEAD, "A garrotte never let go didn't kill") + TEST_ASSERT(QDELETED(hold), "The garrotte held on past death") + TEST_ASSERT_NULL(person.pulling, "The garroter still holds the body") + TEST_ASSERT(!HAS_TRAIT_FROM(guard, TRAIT_MUTE, "stealth_takedown"), "The mute outlived the hold") + // Letting go early: tg's stop_pulling() ends it, and the mute with it. + var/mob/living/carbon/human/npc/second = d45_bare_guard(block, 4, 3) + var/mob/living/carbon/human/strangler = stealth_person(block, 3, 3) + var/obj/item/garrotte/other_wire = takedown_garrotte(strangler) + var/datum/stealth_takedown/other_hold = new(strangler, second, "garrotte", other_wire) + TEST_ASSERT(other_hold.close(), "The second garrotte didn't close") + strangler.stop_pulling() + TEST_ASSERT(QDELETED(other_hold), "Letting go didn't end the garrotte") + TEST_ASSERT(!HAS_TRAIT_FROM(second, TRAIT_MUTE, "stealth_takedown"), "The mute stayed after letting go") + TEST_ASSERT_NULL(strangler.stealth_takedown_doing, "The garroter is still marked busy") + +/// The chokehold puts him out and lets go by itself, alive; a helmet slows the garrotte. +/datum/unit_test/voidcrew_stealth_takedown_choke + +/datum/unit_test/voidcrew_stealth_takedown_choke/Run() + var/datum/turf_reservation/block = stealth_block(8, 5) + TEST_ASSERT_NOTNULL(block, "No room for the test") + var/mob/living/carbon/human/npc/guard = d45_bare_guard(block, 4, 1) + var/mob/living/carbon/human/person = stealth_person(block, 3, 1) + person.set_combat_mode(TRUE) + var/datum/stealth_takedown/hold = new(person, guard, "choke") + TEST_ASSERT(hold.close(), "The chokehold didn't close") + TEST_ASSERT_EQUAL(person.grab_state, GRAB_KILL, "The chokehold isn't tg's strangle") + for(var/i in 1 to 30) + if(QDELETED(hold)) + break + hold.hold_tick(1) + TEST_ASSERT(QDELETED(hold), "The chokehold never let go") + TEST_ASSERT_NULL(person.pulling, "The chokehold let go but still holds him") + TEST_ASSERT(guard.stat != DEAD, "The chokehold killed") + TEST_ASSERT(HAS_TRAIT(guard, TRAIT_KNOCKEDOUT), "The chokehold let go before he was out") + TEST_ASSERT(guard.getOxyLoss() >= 75, "The chokehold let go at [guard.getOxyLoss()] oxygen loss") + // A sec helmet (melee 35) slows the wire to 65%. + var/mob/living/carbon/human/npc/helmeted = d45_bare_guard(block, 4, 3) + d45_helmet(helmeted, /obj/item/clothing/head/helmet/sec) + var/mob/living/carbon/human/strangler = stealth_person(block, 3, 3) + var/obj/item/garrotte/wire = takedown_garrotte(strangler) + var/datum/stealth_takedown/slow = new(strangler, helmeted, "garrotte", wire) + TEST_ASSERT(slow.close(), "The garrotte didn't close on a sec helmet") + TEST_ASSERT(slow.oxy_rate < 8 && slow.oxy_rate > 4, "A sec helmet left the garrotte at [slow.oxy_rate] a second") + strangler.stop_pulling() From e183c4270e5e9b95a6e43afa67f65814d813d312 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 06:31:29 -0800 Subject: [PATCH 57/78] Add the scav den: a rare ruin sold as a contested-lane tip, with named guards, sweeping cameras that sound the alarm, and a vault of chrome --- .../RandomRuins/SpaceRuins/rare_scav_den.dmm | 4202 +++++++++++++++++ tgstation.dme | 2 + voidcrew/_DEFINES/stealth.dm | 2 + voidcrew/icons/effects/scav_camera_cone.dmi | Bin 0 -> 18504 bytes voidcrew/modules/stealth/scav_camera.dm | 401 ++ voidcrew/modules/stealth/scav_den.dm | 233 + voidcrew/modules/trade/rumor_charts.dm | 4 +- .../trade/shop_catalog_black_market.dm | 1 + .../modules/trade/shop_catalog_general.dm | 1 + .../modules/trade/shop_catalog_outfitter.dm | 1 + voidcrew/modules/unit_tests/_unit_tests.dm | 1 + voidcrew/modules/unit_tests/voidcrew_loot.dm | 7 +- .../unit_tests/voidcrew_stealth_den.dm | 128 + 13 files changed, 4979 insertions(+), 4 deletions(-) create mode 100644 _maps/voidcrew/RandomRuins/SpaceRuins/rare_scav_den.dmm create mode 100644 voidcrew/icons/effects/scav_camera_cone.dmi create mode 100644 voidcrew/modules/stealth/scav_camera.dm create mode 100644 voidcrew/modules/stealth/scav_den.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_stealth_den.dm diff --git a/_maps/voidcrew/RandomRuins/SpaceRuins/rare_scav_den.dmm b/_maps/voidcrew/RandomRuins/SpaceRuins/rare_scav_den.dmm new file mode 100644 index 00000000000..0c6e00ff074 --- /dev/null +++ b/_maps/voidcrew/RandomRuins/SpaceRuins/rare_scav_den.dmm @@ -0,0 +1,4202 @@ +//MAP CONVERTED BY dmm2tgm.py THIS HEADER COMMENT PREVENTS RECONVERSION, DO NOT REMOVE +"aa" = ( +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"ab" = ( +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"ac" = ( +/turf/closed/mineral/random, +/area/ruin/space/has_grav/powered) +"ad" = ( +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"ae" = ( +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"af" = ( +/obj/item/stack/rods{ + amount = 4 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"ag" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "b"; + order = 2; + facing = 2 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"ah" = ( +/obj/structure/closet/crate/wooden, +/obj/effect/turf_decal/bot, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"ai" = ( +/obj/machinery/door/airlock/external/ruin{ + name = "External Airlock" + }, +/obj/effect/mapping_helpers/airlock/cyclelink_helper{ + dir = 4 + }, +/obj/structure/fans/tiny, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aj" = ( +/turf/closed/wall, +/area/ruin/space/has_grav/powered) +"ak" = ( +/obj/machinery/door/airlock/medical{ + name = "Theatre"; + req_one_access = list("scav") + }, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"al" = ( +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"am" = ( +/obj/machinery/door/airlock{ + name = "Bunks"; + req_one_access = list("scav") + }, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"an" = ( +/obj/machinery/door/airlock/freezer{ + name = "Cold Room"; + req_one_access = list("scav") + }, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"ao" = ( +/obj/machinery/door/airlock/highsecurity{ + name = "Office"; + req_one_access = list("scav") + }, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"ap" = ( +/obj/machinery/door/airlock/maintenance{ + name = "Chrome Bench" + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aq" = ( +/obj/machinery/power/port_gen/pacman, +/obj/effect/turf_decal/stripes/line{ + dir = 4 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"ar" = ( +/obj/machinery/door/airlock/maintenance{ + name = "Scrap" + }, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"as" = ( +/obj/machinery/door/airlock{ + name = "Back Room" + }, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"at" = ( +/obj/structure/rack, +/obj/item/storage/toolbox/mechanical, +/obj/item/weldingtool{ + pixel_y = 6 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"au" = ( +/obj/effect/spawner/structure/window/reinforced, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"av" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"aw" = ( +/obj/machinery/door/airlock/external/glass/ruin{ + name = "External Airlock" + }, +/obj/effect/mapping_helpers/airlock/cyclelink_helper{ + dir = 8 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"ax" = ( +/turf/template_noop, +/area/template_noop) +"ay" = ( +/obj/structure/grille, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"az" = ( +/obj/machinery/door/airlock/maintenance{ + name = "Back Room" + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aA" = ( +/turf/closed/wall/r_wall, +/area/ruin/space/has_grav/powered) +"aB" = ( +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aC" = ( +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"aD" = ( +/obj/machinery/door/airlock/maintenance{ + name = "Generator"; + req_one_access = list("scav") + }, +/obj/effect/turf_decal/tile/red/full, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aE" = ( +/turf/open/floor/iron/dark/smooth_large, +/area/ruin/space/has_grav/powered) +"aF" = ( +/obj/machinery/door/airlock/maintenance{ + name = "Generator"; + req_one_access = list("scav") + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aG" = ( +/obj/machinery/door/window/left/directional/south{ + name = "cage" + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aH" = ( +/obj/machinery/door/airlock/vault{ + name = "Vault"; + req_access = list("scav_vault") + }, +/turf/open/floor/iron/dark/smooth_large, +/area/ruin/space/has_grav/powered) +"aI" = ( +/turf/closed/wall/rust, +/area/ruin/space/has_grav/powered) +"aJ" = ( +/obj/machinery/door/airlock/maintenance{ + name = "Bay Service" + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aK" = ( +/obj/machinery/door/airlock/external/glass/ruin{ + name = "External Airlock" + }, +/obj/effect/mapping_helpers/airlock/cyclelink_helper{ + dir = 2 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aL" = ( +/obj/effect/turf_decal/tile/red/full, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aM" = ( +/obj/item/clothing/head/utility/welding{ + pixel_y = 6 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aN" = ( +/obj/machinery/door/airlock/maintenance{ + name = "Crawlway" + }, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"aO" = ( +/obj/machinery/door/airlock{ + name = "Mess"; + req_one_access = list("scav") + }, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"aP" = ( +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"aQ" = ( +/obj/machinery/light/small/directional/north, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aR" = ( +/obj/machinery/door/airlock/external/ruin{ + name = "External Airlock" + }, +/obj/effect/mapping_helpers/airlock/cyclelink_helper{ + dir = 1 + }, +/obj/structure/fans/tiny, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aS" = ( +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aT" = ( +/obj/effect/decal/cleanable/blood/oil, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aU" = ( +/obj/machinery/door/airlock/security{ + name = "Pens"; + req_one_access = list("scav") + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aV" = ( +/obj/machinery/door/airlock/maintenance{ + name = "Generator" + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aW" = ( +/obj/structure/sign/poster/contraband/random, +/turf/closed/wall/rust, +/area/ruin/space/has_grav/powered) +"aX" = ( +/obj/structure/reagent_dispensers/fueltank, +/obj/effect/decal/cleanable/blood/oil, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"aY" = ( +/obj/machinery/door/airlock/mining{ + name = "Bay"; + req_one_access = list("scav") + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"aZ" = ( +/obj/effect/decal/cleanable/blood/oil, +/obj/item/wirecutters{ + pixel_x = -4 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"bg" = ( +/obj/item/dice/d6{ + pixel_x = 6 + }, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"bh" = ( +/obj/structure/rack, +/obj/item/coin/gold{ + pixel_x = -5 + }, +/obj/item/coin/silver{ + pixel_x = 5; + pixel_y = 4 + }, +/turf/open/floor/iron/dark/smooth_large, +/area/ruin/space/has_grav/powered) +"bk" = ( +/obj/structure/closet/crate, +/obj/effect/turf_decal/bot, +/obj/item/stack/rods{ + amount = 10 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"bn" = ( +/obj/structure/rack, +/obj/item/storage/briefcase{ + pixel_y = 4 + }, +/obj/effect/turf_decal/bot, +/turf/open/floor/iron/dark/smooth_large, +/area/ruin/space/has_grav/powered) +"br" = ( +/obj/machinery/light/small/directional/north, +/obj/structure/closet/crate/secure/scav_vault, +/obj/effect/turf_decal/bot, +/turf/open/floor/iron/dark/smooth_large, +/area/ruin/space/has_grav/powered) +"bu" = ( +/obj/machinery/light/small/broken/directional/west, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"bv" = ( +/obj/structure/closet/crate/trashcart, +/obj/effect/turf_decal/bot, +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"bw" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "d"; + order = 2; + facing = 1 + }, +/obj/effect/spawner/human_npc/ruin/scav/den/gunner{ + dir = 1 + }, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"cg" = ( +/obj/structure/bed/maint, +/obj/item/bedsheet/brown, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"ch" = ( +/obj/machinery/light/cold/directional/south, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"cj" = ( +/obj/machinery/light/small/directional/east, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"ck" = ( +/obj/effect/turf_decal/stripes/line{ + dir = 4 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"cq" = ( +/obj/effect/turf_decal/tile/red/full, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"ct" = ( +/obj/structure/closet/crate/freezer, +/obj/item/food/meat/slab/human, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"cv" = ( +/obj/structure/closet/crate, +/obj/effect/turf_decal/bot, +/obj/effect/spawner/random/maintenance, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"cL" = ( +/obj/item/bodybag, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"dd" = ( +/obj/effect/decal/cleanable/blood/tracks{ + dir = 1 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"de" = ( +/obj/effect/decal/cleanable/cobweb/cobweb2, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"df" = ( +/obj/item/ammo_box/magazine/m9mm, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"dq" = ( +/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, +/obj/effect/decal/cleanable/blood/oil, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"dB" = ( +/obj/structure/reagent_dispensers/watertank, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"dJ" = ( +/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"dO" = ( +/obj/structure/chair/stool, +/obj/effect/spawner/random/trash/cigbutt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"dR" = ( +/obj/effect/turf_decal/bot, +/obj/effect/decal/cleanable/blood/oil, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"dS" = ( +/obj/structure/chair/wood{ + dir = 1 + }, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"eg" = ( +/obj/structure/sink/directional/south, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"em" = ( +/obj/structure/closet/crate/bin, +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"eO" = ( +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"eW" = ( +/obj/effect/spawner/random/food_or_drink/cups, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"fa" = ( +/obj/effect/turf_decal/stripes/line{ + dir = 2 + }, +/turf/open/floor/iron/dark/smooth_large, +/area/ruin/space/has_grav/powered) +"fE" = ( +/obj/structure/closet/crate/zone_loot/medical, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"fK" = ( +/obj/item/restraints/handcuffs/cable/zipties, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"fN" = ( +/obj/structure/chair{ + dir = 4 + }, +/obj/effect/spawner/random/trash/cigbutt, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"fS" = ( +/obj/effect/decal/cleanable/dirt/dust, +/obj/item/cigbutt, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"ga" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 1 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"gu" = ( +/obj/effect/decal/cleanable/blood/splatter, +/obj/effect/spawner/human_npc/ruin/scav/den{ + dir = 8 + }, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"gG" = ( +/obj/machinery/light/cold/directional/north, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"ha" = ( +/obj/structure/closet/crate/wooden, +/obj/effect/turf_decal/bot, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"hg" = ( +/obj/effect/decal/cleanable/blood/gibs/robot_debris/limb, +/obj/effect/decal/cleanable/blood/oil, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"hi" = ( +/obj/structure/closet/crate/freezer/blood, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"hI" = ( +/obj/structure/closet/crate, +/obj/effect/turf_decal/bot, +/obj/effect/spawner/random/entertainment/money_small, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"hJ" = ( +/obj/item/bedsheet/brown, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"hL" = ( +/obj/structure/chair/office{ + dir = 2 + }, +/obj/effect/spawner/human_npc/ruin/scav/den/boss{ + dir = 2 + }, +/turf/open/floor/carpet/red, +/area/ruin/space/has_grav/powered) +"hN" = ( +/obj/effect/spawner/random/maintenance/two, +/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"hO" = ( +/obj/effect/spawner/random/trash/cigbutt, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"hW" = ( +/obj/effect/decal/cleanable/blood/tracks{ + dir = 8 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"ic" = ( +/obj/machinery/light/small/red/dim/directional/south, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"ik" = ( +/obj/effect/decal/cleanable/dirt, +/obj/item/trash/can{ + pixel_x = 5 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"iz" = ( +/obj/structure/reagent_dispensers/beerkeg, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"iU" = ( +/obj/effect/decal/cleanable/blood/old, +/obj/effect/decal/cleanable/blood/gibs/old, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"jj" = ( +/obj/effect/decal/cleanable/blood/splatter, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"jo" = ( +/obj/effect/spawner/random/trash/garbage, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 8 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"jA" = ( +/obj/structure/table, +/obj/item/restraints/handcuffs/cable/zipties{ + pixel_x = -5 + }, +/obj/item/reagent_containers/cup/glass/mug{ + pixel_x = 6; + pixel_y = 4 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"jE" = ( +/obj/structure/chair/wood{ + dir = 1 + }, +/obj/effect/spawner/random/trash/cigbutt, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"kt" = ( +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"kw" = ( +/obj/machinery/light/small/directional/south, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 8 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"ky" = ( +/obj/machinery/light/small/red/dim/directional/north, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"kL" = ( +/obj/effect/decal/cleanable/blood/footprints{ + dir = 1 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"kM" = ( +/obj/structure/table, +/obj/item/multitool{ + pixel_x = -4 + }, +/obj/item/stack/cable_coil{ + pixel_x = 6 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"kO" = ( +/obj/structure/closet/crate, +/obj/effect/turf_decal/bot, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"kS" = ( +/obj/item/reagent_containers/cup/glass/bottle/beer{ + pixel_x = -6; + pixel_y = 4 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"kW" = ( +/obj/structure/closet/crate, +/obj/effect/turf_decal/bot, +/obj/effect/spawner/random/maintenance, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"li" = ( +/obj/item/reagent_containers/blood/o_minus{ + pixel_x = 5 + }, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"lp" = ( +/obj/effect/spawner/random/structure/chair_flipped, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"lB" = ( +/obj/structure/closet/crate/internals, +/obj/effect/turf_decal/bot, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"lC" = ( +/obj/machinery/light/small/directional/south, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"lY" = ( +/obj/item/clothing/under/color/grey, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"mt" = ( +/obj/structure/closet, +/obj/item/storage/medkit/regular, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"mu" = ( +/obj/structure/sign/warning/no_smoking, +/turf/closed/wall, +/area/ruin/space/has_grav/powered) +"mC" = ( +/obj/structure/table, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = -5; + pixel_y = 6 + }, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = 6; + pixel_y = 4 + }, +/obj/item/reagent_containers/cup/bottle/formaldehyde{ + pixel_y = -5 + }, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"mG" = ( +/obj/effect/spawner/random/trash/cigbutt, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"mS" = ( +/obj/structure/table, +/obj/machinery/microwave{ + pixel_y = 6 + }, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"mW" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "e"; + order = 3; + facing = 4 + }, +/obj/effect/spawner/human_npc/ruin/scav/den/lookout{ + dir = 4 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"nz" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/spawner/random/trash/garbage, +/obj/effect/landmark/stealth_patrol{ + route = "e"; + order = 2; + wait = 0 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"nJ" = ( +/obj/effect/spawner/human_npc/ruin/scav/den/lookout{ + dir = 8 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"nL" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"nV" = ( +/obj/machinery/door/airlock{ + name = "Bunks"; + req_one_access = list("scav") + }, +/obj/effect/turf_decal/tile/red/full, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"oq" = ( +/obj/effect/decal/cleanable/dirt, +/obj/item/ammo_casing/spent{ + pixel_x = 5; + pixel_y = -3 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"oD" = ( +/obj/effect/decal/cleanable/blood/tracks{ + dir = 4 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"oG" = ( +/obj/effect/turf_decal/stripes/line{ + dir = 4 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"oQ" = ( +/obj/item/stack/medical/suture, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"oS" = ( +/obj/structure/closet/crate/freezer, +/obj/item/reagent_containers/blood/random, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"oW" = ( +/obj/effect/decal/cleanable/dirt, +/obj/item/trash/chips, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"oY" = ( +/obj/item/clothing/shoes/sneakers/black, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"pb" = ( +/obj/effect/spawner/human_npc/ruin/scav/den{ + dir = 8 + }, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"pc" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"ph" = ( +/obj/item/radio{ + pixel_x = -4 + }, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"pk" = ( +/obj/machinery/light/cold/dim/directional/south, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"pq" = ( +/obj/structure/table, +/obj/item/circular_saw{ + pixel_y = 4 + }, +/obj/item/cautery{ + pixel_x = 6; + pixel_y = -4 + }, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"pz" = ( +/obj/effect/turf_decal/stripes/line{ + dir = 1 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"pC" = ( +/obj/machinery/light/cold/dim/directional/north, +/obj/structure/closet/crate/freezer, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"pZ" = ( +/obj/effect/decal/cleanable/blood/old, +/obj/item/food/meat/slab/human{ + pixel_x = -4 + }, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"qf" = ( +/obj/effect/decal/remains/robot, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"qh" = ( +/obj/item/stack/rods{ + amount = 2 + }, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"qt" = ( +/obj/structure/table, +/obj/effect/spawner/random/food_or_drink/booze, +/obj/item/reagent_containers/cup/glass/drinkingglass{ + pixel_x = 8 + }, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"qC" = ( +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"qO" = ( +/obj/structure/sign/warning/vacuum/external, +/turf/closed/wall, +/area/ruin/space/has_grav/powered) +"qP" = ( +/obj/item/trash/chips, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"qZ" = ( +/obj/machinery/light/small/dim/directional/north, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"rc" = ( +/obj/machinery/scav_camera/directional/south, +/turf/open/floor/iron/dark/smooth_large, +/area/ruin/space/has_grav/powered) +"rd" = ( +/obj/structure/closet/crate, +/obj/item/bodypart/leg/left/robot, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"re" = ( +/obj/structure/sign/warning/biohazard, +/turf/closed/wall, +/area/ruin/space/has_grav/powered) +"rg" = ( +/obj/structure/reagent_dispensers/water_cooler, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"ro" = ( +/obj/effect/decal/cleanable/cobweb, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"rq" = ( +/obj/effect/decal/cleanable/blood/tracks{ + dir = 8 + }, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"rs" = ( +/obj/structure/chair/stool, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"rF" = ( +/obj/effect/spawner/random/trash/food_packaging, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"rJ" = ( +/obj/effect/spawner/random/structure/crate_abandoned, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"rK" = ( +/obj/structure/table/wood, +/obj/item/flashlight/lamp/green{ + pixel_x = -4; + pixel_y = 6 + }, +/turf/open/floor/carpet/red, +/area/ruin/space/has_grav/powered) +"sf" = ( +/obj/structure/closet/cabinet, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"sh" = ( +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"sq" = ( +/obj/structure/closet/crate/freezer, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"sH" = ( +/obj/effect/decal/cleanable/cobweb, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"sZ" = ( +/obj/effect/decal/remains/human, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"th" = ( +/obj/machinery/light/small/directional/north, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"tk" = ( +/obj/structure/kitchenspike, +/obj/effect/decal/cleanable/blood/old, +/obj/effect/decal/cleanable/blood/gibs/old, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"tn" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 2; + wait = 0 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"tx" = ( +/obj/effect/decal/cleanable/blood/drip, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 8 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"tD" = ( +/obj/machinery/scav_camera/directional/south, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 1 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"tH" = ( +/obj/effect/decal/cleanable/blood/tracks{ + dir = 1 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"tO" = ( +/obj/effect/landmark/stealth_restricted, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"tR" = ( +/obj/structure/closet/crate, +/obj/effect/turf_decal/bot, +/obj/item/stack/sheet/iron{ + amount = 20 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"tT" = ( +/obj/structure/table/optable, +/obj/effect/decal/remains/human, +/obj/effect/decal/cleanable/blood/gibs/old, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"ub" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "c"; + order = 2; + facing = 4 + }, +/obj/effect/spawner/human_npc/ruin/scav/den{ + dir = 4 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"uc" = ( +/obj/machinery/space_heater, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"uf" = ( +/obj/effect/decal/cleanable/dirt, +/obj/effect/spawner/random/trash/cigbutt, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"uj" = ( +/obj/structure/bookcase/random, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"us" = ( +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"uu" = ( +/obj/structure/rack, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = -6; + pixel_y = 6 + }, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = 6; + pixel_y = 6 + }, +/obj/item/reagent_containers/cup/bottle/formaldehyde{ + pixel_x = 2; + pixel_y = -4 + }, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"ux" = ( +/obj/effect/decal/cleanable/blood/oil, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"vh" = ( +/obj/machinery/iv_drip, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"vE" = ( +/obj/item/bedsheet/brown, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"vH" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 3; + wait = 0 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"vI" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 1; + facing = 8 + }, +/obj/effect/spawner/human_npc/ruin/scav/den/gunner{ + dir = 8 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"vO" = ( +/obj/machinery/light/small/directional/west, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 1 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"vX" = ( +/obj/structure/displaycase/noalert, +/turf/open/floor/iron/dark/smooth_large, +/area/ruin/space/has_grav/powered) +"vY" = ( +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"vZ" = ( +/obj/item/cigarette{ + pixel_x = 4; + pixel_y = 6 + }, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"wg" = ( +/obj/item/reagent_containers/cup/glass/bottle/beer{ + pixel_x = 6 + }, +/obj/item/cigarette{ + pixel_x = -6 + }, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"wF" = ( +/obj/structure/sign/poster/contraband/random, +/turf/closed/wall, +/area/ruin/space/has_grav/powered) +"wR" = ( +/obj/structure/kitchenspike, +/obj/effect/decal/cleanable/blood/old, +/obj/effect/decal/cleanable/blood/gibs/old, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"wW" = ( +/obj/structure/table, +/obj/item/organ/liver/cybernetic{ + pixel_x = -4; + pixel_y = 5 + }, +/obj/item/organ/lungs/cybernetic{ + pixel_x = 5; + pixel_y = -2 + }, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"xm" = ( +/obj/item/reagent_containers/cup/glass/bottle/whiskey{ + pixel_x = 4; + pixel_y = -8 + }, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"xp" = ( +/obj/item/flashlight/flare, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"xq" = ( +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"xt" = ( +/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 1 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"xz" = ( +/obj/structure/table, +/obj/item/organ/heart/cybernetic{ + pixel_x = -5; + pixel_y = 4 + }, +/obj/item/organ/eyes/robotic/basic{ + pixel_x = 6 + }, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"xZ" = ( +/obj/structure/closet/crate/large, +/obj/effect/turf_decal/bot, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"yj" = ( +/obj/effect/decal/cleanable/vomit/old, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"yr" = ( +/obj/structure/table/rolling, +/obj/item/surgical_drapes, +/obj/item/stack/medical/gauze, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"yw" = ( +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"yF" = ( +/obj/structure/closet/secure_closet/freezer/fridge, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"yG" = ( +/obj/structure/closet/crate, +/obj/effect/spawner/random/maintenance/two, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"yQ" = ( +/obj/structure/closet/crate/wooden, +/obj/effect/spawner/random/food_or_drink/booze, +/obj/effect/spawner/random/food_or_drink/booze, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"yR" = ( +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"zh" = ( +/obj/structure/rack, +/obj/item/stack/spacecash/c100{ + pixel_y = 4 + }, +/obj/effect/turf_decal/bot, +/turf/open/floor/iron/dark/smooth_large, +/area/ruin/space/has_grav/powered) +"zq" = ( +/obj/effect/spawner/random/trash/cigbutt, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"zw" = ( +/obj/machinery/light/small/directional/south, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"zz" = ( +/obj/effect/decal/cleanable/dirt, +/obj/effect/spawner/random/trash/cigbutt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"zF" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 5; + wait = 0 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"zI" = ( +/obj/item/clothing/suit/apron/surgical, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"zZ" = ( +/obj/structure/closet/crate, +/obj/item/storage/box/lethalshot, +/obj/effect/spawner/random/contraband/narcotics, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Ad" = ( +/obj/effect/turf_decal/bot, +/obj/item/storage/box{ + pixel_x = -4; + pixel_y = 3 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"AG" = ( +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"Be" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 4; + facing = 4 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"Bf" = ( +/obj/effect/decal/cleanable/dirt, +/obj/structure/table, +/obj/effect/spawner/random/food_or_drink/dinner, +/obj/item/kitchen/fork{ + pixel_x = -8 + }, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"Bp" = ( +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"Br" = ( +/obj/item/stack/sheet/cardboard{ + amount = 5 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"BG" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt, +/obj/effect/landmark/stealth_patrol{ + route = "e"; + order = 1; + facing = 1 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"BU" = ( +/obj/structure/table, +/obj/item/bodypart/arm/right/robot{ + pixel_x = -3; + pixel_y = 3 + }, +/obj/item/weldingtool{ + pixel_x = 6; + pixel_y = -6 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Ca" = ( +/obj/structure/closet/crate/freezer/blood, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"CG" = ( +/obj/structure/bed/medical, +/obj/item/restraints/handcuffs/cable/zipties, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"CN" = ( +/obj/structure/reagent_dispensers/fueltank, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Do" = ( +/obj/machinery/computer/operating{ + dir = 2 + }, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"Dt" = ( +/obj/item/cigbutt{ + pixel_x = 4 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Dx" = ( +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"DE" = ( +/obj/effect/decal/cleanable/blood/old, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"DG" = ( +/obj/item/trash/can, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"DK" = ( +/obj/item/reagent_containers/cup/glass/bottle/rum{ + pixel_x = 6 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"DO" = ( +/obj/effect/decal/cleanable/blood/old, +/obj/item/stack/medical/gauze{ + pixel_x = 4 + }, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"DV" = ( +/obj/structure/closet/emcloset, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"DY" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"Eh" = ( +/obj/structure/table, +/obj/item/wrench, +/obj/item/crowbar{ + pixel_y = 6 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Eu" = ( +/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Ev" = ( +/obj/structure/table, +/obj/effect/spawner/random/food_or_drink/booze, +/obj/item/stack/spacecash/c50{ + pixel_x = 4; + pixel_y = -4 + }, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"EG" = ( +/obj/item/clothing/gloves/latex{ + pixel_x = 6 + }, +/obj/effect/decal/cleanable/blood/splatter, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"ET" = ( +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"Fq" = ( +/obj/item/reagent_containers/syringe{ + pixel_x = 6; + pixel_y = 6 + }, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"Fy" = ( +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"FC" = ( +/obj/effect/decal/remains/human, +/obj/effect/decal/cleanable/blood/old, +/obj/item/flashlight{ + pixel_x = 6 + }, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"FH" = ( +/obj/structure/bed/maint, +/obj/effect/spawner/random/bedsheet, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"FM" = ( +/obj/item/reagent_containers/syringe{ + pixel_x = -5 + }, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"FO" = ( +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"Ge" = ( +/obj/structure/table, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = -6; + pixel_y = 5 + }, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = 6; + pixel_y = 7 + }, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = 0; + pixel_y = -3 + }, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"Gh" = ( +/obj/effect/turf_decal/delivery, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Gn" = ( +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"Gp" = ( +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"Gv" = ( +/obj/structure/closet/crate/zone_loot/medical, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"GE" = ( +/obj/item/stack/spacecash/c20{ + pixel_x = 4 + }, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"GH" = ( +/obj/effect/spawner/random/structure/crate_abandoned, +/obj/effect/turf_decal/bot, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"GI" = ( +/obj/structure/table/wood, +/obj/item/reagent_containers/cup/glass/bottle/whiskey{ + pixel_y = 6 + }, +/obj/item/reagent_containers/cup/glass/drinkingglass{ + pixel_x = 8 + }, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"GK" = ( +/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, +/obj/effect/decal/cleanable/blood/oil, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"GO" = ( +/obj/structure/chair/stool, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"Hj" = ( +/obj/structure/table/wood, +/obj/item/stack/spacecash/c500{ + pixel_x = 4 + }, +/obj/item/pen{ + pixel_x = -6 + }, +/obj/item/folder/red{ + pixel_x = -8; + pixel_y = 4 + }, +/turf/open/floor/carpet/red, +/area/ruin/space/has_grav/powered) +"Hp" = ( +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"Hq" = ( +/obj/effect/turf_decal/tile/red/full, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"Ht" = ( +/obj/structure/kitchenspike, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"HH" = ( +/obj/machinery/light/small/broken/directional/north, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"HM" = ( +/obj/effect/decal/cleanable/cobweb, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"HR" = ( +/obj/item/storage/backpack/duffelbag, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"Ik" = ( +/obj/structure/table, +/obj/effect/spawner/random/food_or_drink/snack, +/obj/item/reagent_containers/cup/glass/mug{ + pixel_x = -6 + }, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"Iq" = ( +/obj/structure/kitchenspike, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"Iz" = ( +/obj/effect/decal/cleanable/dirt, +/obj/item/stack/sheet/plastic{ + amount = 5 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"II" = ( +/obj/effect/decal/cleanable/cobweb, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"IL" = ( +/obj/effect/decal/cleanable/dirt/dust, +/obj/effect/decal/cleanable/cobweb/cobweb2, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"JJ" = ( +/obj/structure/table, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = -4; + pixel_y = 6 + }, +/obj/item/clothing/mask/surgical{ + pixel_x = 6; + pixel_y = -4 + }, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"Kb" = ( +/obj/effect/turf_decal/bot, +/obj/effect/spawner/random/structure/crate_abandoned, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"KD" = ( +/obj/structure/sign/warning/secure_area, +/turf/closed/wall/r_wall, +/area/ruin/space/has_grav/powered) +"KS" = ( +/obj/structure/closet, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Lh" = ( +/obj/structure/closet/cabinet, +/obj/item/clothing/head/fedora, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Lp" = ( +/obj/machinery/door/airlock/freezer{ + name = "Cold Room"; + req_one_access = list("scav") + }, +/obj/effect/turf_decal/tile/red/full, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"LH" = ( +/obj/structure/table, +/obj/item/bodypart/arm/left/robot{ + pixel_y = 4 + }, +/obj/item/screwdriver{ + pixel_x = 8 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"LO" = ( +/obj/effect/decal/cleanable/cobweb/cobweb2, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"LZ" = ( +/obj/effect/decal/cleanable/vomit/old, +/obj/item/reagent_containers/cup/bucket, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Md" = ( +/obj/machinery/light/small/broken/directional/south, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"Mi" = ( +/obj/structure/rack, +/obj/item/knife/combat/survival{ + pixel_y = 4 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Mo" = ( +/obj/machinery/iv_drip, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"MI" = ( +/obj/structure/mop_bucket, +/obj/item/mop, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"MJ" = ( +/obj/effect/spawner/random/entertainment/cigarette_pack, +/obj/effect/spawner/random/entertainment/lighter, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"Nc" = ( +/obj/structure/chair/comfy/black{ + dir = 4 + }, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"Nu" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "b"; + order = 1; + facing = 1; + route_mode = "pingpong" + }, +/obj/effect/spawner/human_npc/ruin/scav/den{ + dir = 1 + }, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"NB" = ( +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"NH" = ( +/obj/structure/table, +/obj/item/surgicaldrill{ + pixel_y = 3 + }, +/obj/item/clothing/gloves/latex{ + pixel_x = -6; + pixel_y = -5 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"NO" = ( +/obj/machinery/light/warm/directional/north, +/obj/structure/table, +/obj/item/storage/box/donkpockets{ + pixel_y = 4 + }, +/obj/item/kitchen/fork{ + pixel_x = 8 + }, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"NP" = ( +/obj/structure/chair/stool, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Od" = ( +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"Ok" = ( +/obj/structure/table, +/obj/item/toy/cards/deck{ + pixel_y = 4 + }, +/obj/item/reagent_containers/cup/glass/bottle/vodka{ + pixel_x = -8; + pixel_y = 8 + }, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"Os" = ( +/obj/effect/decal/cleanable/blood/oil, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"OP" = ( +/obj/structure/table, +/obj/item/stack/cable_coil{ + pixel_x = -4 + }, +/obj/item/screwdriver{ + pixel_x = 6; + pixel_y = 4 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"OT" = ( +/obj/effect/spawner/random/entertainment/cigarette_pack, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Pc" = ( +/obj/structure/closet, +/obj/effect/spawner/random/maintenance, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"Pf" = ( +/obj/structure/bed/maint, +/obj/item/bedsheet/brown, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Pg" = ( +/obj/item/clothing/head/soft/black{ + pixel_y = 6 + }, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"Pp" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt/dust, +/obj/effect/landmark/stealth_patrol{ + route = "e"; + order = 4; + wait = 0 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"Pq" = ( +/obj/item/storage/belt/utility, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Ps" = ( +/obj/effect/spawner/random/trash/cigbutt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Pw" = ( +/obj/effect/turf_decal/tile/red/full, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"PF" = ( +/obj/structure/table, +/obj/item/reagent_containers/cup/glass/bottle/whiskey{ + pixel_x = -6; + pixel_y = 8 + }, +/obj/item/toy/cards/deck{ + pixel_x = 5 + }, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"PS" = ( +/obj/effect/landmark/stealth_group, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"QF" = ( +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"QP" = ( +/obj/structure/table, +/obj/item/scalpel{ + pixel_x = -6; + pixel_y = 4 + }, +/obj/item/hemostat{ + pixel_x = 4 + }, +/obj/item/retractor{ + pixel_y = -5 + }, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"QT" = ( +/obj/structure/filingcabinet, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"Ru" = ( +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"Ry" = ( +/obj/structure/rack, +/obj/item/tank/internals/oxygen{ + pixel_x = -4 + }, +/obj/item/tank/internals/oxygen{ + pixel_x = 4 + }, +/obj/item/clothing/mask/breath, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"RD" = ( +/obj/machinery/scav_camera/directional/south, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Sa" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "d"; + order = 1; + facing = 4; + chatter = 1; + route_mode = "pingpong" + }, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"Sm" = ( +/obj/structure/closet/crate/freezer, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"SR" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"SV" = ( +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"SW" = ( +/obj/machinery/smartfridge/organ, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"Ta" = ( +/obj/effect/spawner/random/trash/food_packaging, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"Tl" = ( +/obj/effect/decal/cleanable/blood/old, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"Tr" = ( +/obj/structure/ore_box, +/obj/effect/turf_decal/bot, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Tw" = ( +/turf/open/floor/carpet/red, +/area/ruin/space/has_grav/powered) +"TH" = ( +/obj/machinery/light/warm/directional/east, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"TJ" = ( +/obj/structure/closet/secure_closet/freezer/meat, +/turf/open/floor/iron/freezer, +/area/ruin/space/has_grav/powered) +"TV" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "c"; + order = 1; + facing = 8; + route_mode = "pingpong" + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"UF" = ( +/obj/effect/decal/cleanable/cobweb/cobweb2, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"UM" = ( +/obj/structure/closet/crate/bin, +/obj/effect/decal/cleanable/cobweb, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"UW" = ( +/obj/structure/closet/crate/wooden, +/obj/effect/spawner/random/food_or_drink/booze, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"VG" = ( +/obj/effect/turf_decal/tile/red/full, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"VN" = ( +/obj/item/clothing/suit/apron/surgical{ + pixel_y = -4 + }, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"VQ" = ( +/obj/structure/closet/crate, +/obj/effect/turf_decal/bot, +/obj/item/stack/sheet/mineral/plasma{ + amount = 10 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"VX" = ( +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/cobweb, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"VY" = ( +/obj/item/storage/briefcase{ + pixel_x = -4 + }, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"Wc" = ( +/obj/item/kirbyplants/random, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"Wg" = ( +/obj/structure/rack, +/obj/item/bodypart/arm/left/robot, +/obj/item/bodypart/arm/right/robot{ + pixel_y = 6 + }, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"Wu" = ( +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"WJ" = ( +/obj/effect/landmark/stealth_restricted{ + allowed = 0 + }, +/turf/open/floor/iron/dark/smooth_large, +/area/ruin/space/has_grav/powered) +"Xe" = ( +/obj/effect/turf_decal/stripes/line{ + dir = 8 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Xg" = ( +/obj/item/ammo_casing/spent{ + pixel_x = -6; + pixel_y = 2 + }, +/obj/effect/spawner/random/trash/cigbutt, +/obj/effect/spawner/human_npc/ruin/scav/den/gunner{ + dir = 2 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Xn" = ( +/obj/machinery/scav_camera/directional/north, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"Xz" = ( +/obj/structure/closet/crate, +/obj/effect/turf_decal/bot, +/obj/effect/spawner/random/maintenance/two, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"XE" = ( +/obj/machinery/light/small/red/dim/directional/north, +/obj/effect/turf_decal/stripes/line{ + dir = 4 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"XI" = ( +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/iron/dark/smooth_large, +/area/ruin/space/has_grav/powered) +"XJ" = ( +/obj/effect/decal/cleanable/blood/tracks{ + dir = 4 + }, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"XK" = ( +/obj/effect/spawner/random/trash/graffiti, +/turf/closed/wall, +/area/ruin/space/has_grav/powered) +"XO" = ( +/obj/effect/decal/cleanable/cobweb, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"Yd" = ( +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"Yj" = ( +/obj/item/storage/box/bodybags, +/obj/item/storage/organbox{ + pixel_y = 8 + }, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"Yx" = ( +/obj/effect/decal/remains/human, +/obj/effect/decal/cleanable/blood/splatter, +/obj/item/restraints/handcuffs/cable/zipties, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"YE" = ( +/obj/machinery/light/small/directional/west, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"YK" = ( +/obj/structure/rack, +/obj/item/bodypart/leg/right, +/obj/item/bodypart/arm/left, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Zk" = ( +/obj/structure/bed/maint, +/obj/item/bedsheet/brown, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"Zo" = ( +/obj/structure/table, +/obj/item/knife/butcher{ + pixel_y = 5 + }, +/obj/item/stack/spacecash/c200{ + pixel_x = -6; + pixel_y = -4 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"ZB" = ( +/obj/structure/table/optable, +/obj/effect/mob_spawn/corpse/human, +/obj/effect/decal/cleanable/blood/splatter, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"ZF" = ( +/obj/machinery/light/small/directional/south, +/turf/open/floor/wood, +/area/ruin/space/has_grav/powered) +"ZV" = ( +/obj/structure/table/wood, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = 0; + pixel_y = 6 + }, +/obj/item/paper/crumpled/bloody{ + pixel_x = -6; + pixel_y = -4 + }, +/obj/item/paper{ + name = "price list"; + default_raw_text = "Hearts 4000. Livers 2500. Lungs 2000. Eyes 1500 the pair. Chrome by weight. No refunds."; + pixel_x = 8; + pixel_y = 2 + }, +/turf/open/floor/carpet/red, +/area/ruin/space/has_grav/powered) +"ZX" = ( +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) + +(1,1,1) = {" +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +"} +(2,1,1) = {" +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +aj +ai +aj +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +"} +(3,1,1) = {" +ax +ax +ax +ax +ax +ax +ax +ac +ax +ax +ax +ac +ac +ac +ac +ac +ac +ax +ax +ac +ac +ac +ac +ac +ac +ac +ac +qO +XE +aj +ac +ac +ac +ac +ac +ax +ax +ax +ax +ax +"} +(4,1,1) = {" +ax +ax +ax +ax +ax +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +aj +aw +aj +ac +ac +ac +ac +ac +ac +ax +ax +ax +ax +"} +(5,1,1) = {" +ax +ax +ax +ax +ax +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +IL +aP +FC +AG +bu +aP +AG +FO +aP +fS +kt +II +AG +ac +ac +ac +ac +ac +ac +ac +ac +ac +ax +ax +"} +(6,1,1) = {" +ax +ax +ax +ax +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +aP +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ax +ax +"} +(7,1,1) = {" +ax +ax +ax +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +kt +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ax +ax +"} +(8,1,1) = {" +ax +ax +ax +ac +ac +ac +ac +aj +aj +aj +aj +wF +aj +aj +aj +aj +aN +aj +aj +aj +aj +aj +re +aj +aj +aj +aj +aj +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ax +ax +"} +(9,1,1) = {" +ax +ax +ax +ac +ac +ac +ac +aj +FH +ro +GO +ae +lY +FH +aj +XO +Dx +aj +SW +HM +xq +ad +TJ +ad +xz +ad +fE +aj +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ax +ax +"} +(10,1,1) = {" +ax +ax +ax +ac +ac +ac +ac +aj +ae +wg +Ok +ae +zq +ae +wF +al +Wu +aj +oS +ad +sh +ad +Fq +ad +ad +cL +Ca +aj +ac +ac +aI +aI +aI +aW +aI +aI +aI +ac +ax +ax +"} +(11,1,1) = {" +ax +ax +ax +ac +ac +ac +ac +aj +FH +ae +GO +ae +bg +ae +aj +vY +al +aj +pC +ad +DO +yw +ad +yr +ad +ad +Sm +aj +ac +ac +aI +at +aS +aq +aX +aS +aI +ac +ac +ax +"} +(12,1,1) = {" +ax +ax +ac +ac +ac +ac +ac +aj +qZ +HR +ae +bw +ae +ae +am +Wu +al +aj +Sm +ad +ad +ad +ad +ad +ad +yj +ct +aj +aI +aI +aI +aQ +aB +aS +aZ +af +aI +ac +ac +ax +"} +(13,1,1) = {" +ax +ax +ac +ac +ac +ac +ac +aj +Zk +ae +ph +cq +Ta +ae +aj +Wu +hO +aj +ad +ad +Nu +Pw +Pw +Pw +Pw +Pw +Pw +Lp +VX +av +aD +aL +aL +aL +ag +aS +aI +ac +ac +ax +"} +(14,1,1) = {" +ax +ax +ac +ac +ac +ac +ac +aj +ae +QF +MJ +cq +ae +Yd +aj +HH +al +XK +Ht +xq +ad +xq +ad +ad +ad +ad +ad +aj +aI +aI +aI +aM +aS +aT +aS +aS +aW +ac +ac +ax +"} +(15,1,1) = {" +ax +ax +ac +ac +ac +ac +ac +aj +FH +Pg +ae +cq +ae +cg +aj +al +lp +aj +tk +Tl +ad +rq +ad +ad +ad +ad +pk +aj +ac +ac +aI +OP +aS +uc +aS +ah +aI +ac +ac +ax +"} +(16,1,1) = {" +ax +ax +ac +ac +ac +ac +ac +aj +Pc +ae +QF +cq +ae +mt +aj +Dx +al +aj +Iq +pZ +ad +rq +ad +ad +ad +mC +wW +aj +ac +ac +aI +aS +yR +zz +aS +VQ +aI +ac +ac +ax +"} +(17,1,1) = {" +ax +ax +ac +ac +ac +ac +ac +aj +aj +aj +aj +nV +aj +aj +aj +al +al +aj +aj +wF +aj +aj +an +aj +aj +wF +aj +aj +aj +aj +aI +aI +aV +aI +aI +aI +aI +ac +ac +ax +"} +(18,1,1) = {" +ax +ax +ac +ac +ac +ac +ac +aj +yF +aC +oW +VG +rF +ET +aj +XO +Wu +al +vY +Wu +Wu +oD +dd +vO +dd +xt +dd +tD +aj +dB +ux +YE +aS +aS +Br +UM +aj +ac +ac +ax +"} +(19,1,1) = {" +ax +ax +ac +ac +ac +ac +ac +aj +mS +aC +rs +VG +mG +aC +wF +Wu +tn +Hq +Hq +nL +Hq +Hq +vI +Hq +nL +Hq +zF +hW +wF +lB +us +aS +pz +GH +kO +aS +aj +ac +ac +ax +"} +(20,1,1) = {" +ax +ax +ac +ac +ac +ac +ac +aj +NO +rs +mG +VG +aC +aC +aj +al +DY +aj +aj +re +aj +ak +aj +wF +aj +aj +Hq +jo +aj +ah +aS +TV +pz +aS +kO +aS +aj +ac +ac +ax +"} +(21,1,1) = {" +ax +ax +ac +ac +ac +ac +ac +aj +qt +aC +aC +Sa +rF +aC +aj +Wu +Hq +aj +wR +VN +Bp +ZX +FM +aa +hi +aj +nL +kw +aj +Ry +aS +aL +pz +xZ +aS +zw +aj +ac +ac +ax +"} +(22,1,1) = {" +ax +ax +ax +ac +ac +ac +ac +aj +iz +Gn +rs +PF +aC +aC +aO +al +DY +au +Ge +aa +Mo +Hp +QP +aa +sq +au +Hq +hW +aj +aS +aS +aL +pz +xZ +dR +aS +aj +ac +ac +ax +"} +(23,1,1) = {" +ax +ax +ax +ac +ac +ac +ac +aj +aC +DG +aC +Ik +rs +aC +aj +Wu +nL +aj +gG +jj +Do +ZB +aa +aa +Yj +aj +Hq +hW +aj +aQ +Dt +aL +pz +Xz +aT +zz +aj +ac +ac +ax +"} +(24,1,1) = {" +ax +ax +ax +ac +ac +ac +ac +aj +aC +Bf +kS +pb +aC +rs +wF +al +Hq +wF +JJ +aa +aa +gu +aa +Hp +MI +aj +Hq +tx +aj +Xg +aS +ga +pz +aS +aS +fK +aj +ac +ac +ax +"} +(25,1,1) = {" +ax +ax +ax +ac +ac +ac +ac +aj +rg +rs +eW +aC +TH +Ev +aj +Wu +Hq +aj +eg +Bp +PS +Ru +EG +aa +ch +aj +pc +SV +aY +yR +eO +ga +eO +Fy +eO +aS +aj +ac +ac +ax +"} +(26,1,1) = {" +ax +ax +ax +ac +ac +ac +ac +aI +aI +aI +aI +aI +aI +aI +aI +al +Hq +wF +aa +Od +aa +DE +pq +Ru +aa +mu +Hq +vY +aj +eO +aS +aL +aS +Tr +Ad +RD +aj +ac +ac +ax +"} +(27,1,1) = {" +ax +ax +ax +ac +ac +ac +ac +aI +LH +yR +BU +Zo +Eh +aS +aI +Dx +DY +aj +gG +Od +aa +tT +aa +li +aa +aj +nL +al +aj +aS +tR +aL +aS +bv +aS +aS +aj +ac +ac +ax +"} +(28,1,1) = {" +ax +ax +ax +ac +ac +ac +ac +aI +kM +aS +aS +NP +aS +hg +aI +al +Hq +au +uu +aa +vh +XJ +NH +aa +zI +au +Hq +uf +aj +aS +kW +aL +aS +Kb +aS +Xe +qO +aj +aj +ax +"} +(29,1,1) = {" +ax +ax +ac +ac +ac +ac +ac +aI +aS +yR +aS +Pq +aS +aS +ap +al +Hq +aj +Gv +aa +aa +XJ +Ru +oQ +CG +aj +nL +al +wF +aS +aS +aL +oq +aS +pz +Gh +aK +ck +aR +ax +"} +(30,1,1) = {" +ax +ax +ac +ac +ac +ac +ac +aI +aQ +aS +dq +aS +Iz +aS +au +hO +Hq +aj +aj +wF +aj +ak +aj +wF +aj +aj +Hq +al +aj +aS +kL +ub +aS +bk +aS +oG +aj +aj +aj +ax +"} +(31,1,1) = {" +ax +ax +ac +ac +ac +ac +ac +aI +yG +aS +aT +aS +Eu +df +aI +al +vH +nL +Hq +Hq +Hq +DY +Hq +nL +DY +nL +Be +al +aj +CN +ik +yR +aS +xZ +aS +aS +aj +ac +ac +ax +"} +(32,1,1) = {" +ax +ax +ac +ac +ac +ac +ac +aI +YK +aS +aS +aS +aS +em +aI +Xn +Wu +vY +al +al +cj +hW +dd +dd +xt +dd +dd +Os +aj +DV +aS +aS +aS +aB +aB +UF +aj +ac +ac +ax +"} +(33,1,1) = {" +ax +ac +ac +ac +ac +ac +ac +aA +aj +aj +aj +wF +aj +aj +aj +vY +al +aj +aj +aj +aj +aI +aI +au +aI +aI +aU +aI +aI +aj +aj +aj +aJ +aj +aj +aj +aj +ac +ac +ax +"} +(34,1,1) = {" +ax +ac +ac +aA +aA +aA +aA +aA +QT +VY +uj +Nc +GI +Wc +aj +al +al +al +fN +vY +cv +aI +ky +sZ +ay +eO +aS +dO +aI +ac +ac +ac +II +ac +ac +ac +ac +ac +ac +ax +"} +(35,1,1) = {" +ax +ac +ac +aA +zh +XI +aE +aA +QT +ab +tO +vZ +xm +ZF +aj +th +al +al +al +Wu +ha +aI +hJ +qP +aG +tH +aS +Ps +aI +ac +ac +ac +kt +ac +ac +ac +ac +ac +ac +ax +"} +(36,1,1) = {" +ax +ac +ac +aA +bn +aE +rc +KD +Wc +qC +Tw +Tw +rK +dS +aj +al +BG +DY +DY +Pp +al +aW +aI +aI +aI +aS +eO +Fy +aI +ac +ac +ac +aP +ac +ac +ac +ac +ac +ac +ax +"} +(37,1,1) = {" +ax +ac +ac +aA +aE +WJ +fa +aH +ab +ab +Tw +hL +ZV +ab +ao +al +nL +Dx +al +Hq +Wu +aI +LZ +aS +ay +aS +yR +ic +aI +ac +ac +ac +AG +ac +ac +ac +ac +ac +ac +ax +"} +(38,1,1) = {" +ax +ac +ac +aA +br +aE +XI +aA +ab +NB +Tw +Tw +Hj +jE +aj +al +Hq +aW +aI +nL +al +aI +aS +Yx +aG +tH +aS +aS +aI +ac +ac +ac +kt +ac +ac +ac +ac +ac +ac +ax +"} +(39,1,1) = {" +ax +ac +ac +aA +vX +bh +aE +aA +LO +ab +ab +ab +ab +GE +aj +hO +Hq +aI +aI +nL +al +aI +aI +aI +aI +aS +eO +aS +aI +ac +ac +ac +aP +ac +ac +ac +ac +ac +ac +ax +"} +(40,1,1) = {" +ax +ac +ac +aA +aA +aA +aA +aA +ab +ab +ab +ab +ab +sf +wF +Dx +SR +aI +aI +Hq +lC +aI +ky +vE +ay +eO +aS +jA +aI +ac +ac +ac +Md +ac +ac +ac +ac +ac +ac +ax +"} +(41,1,1) = {" +ax +ax +ac +ac +ac +ac +ac +aA +aI +aI +as +aI +aI +aI +aI +Wu +Hq +aI +aW +Hq +Wu +aI +iU +oY +aG +aS +nJ +KS +aI +ac +ac +ac +AG +ac +ac +ac +ac +ac +ac +ax +"} +(42,1,1) = {" +ax +ax +ac +ac +ac +ac +ac +aI +sH +us +aS +aS +Ps +Lh +aI +Dx +Hq +al +al +Hq +al +aI +aI +aI +aW +aI +aI +aI +aI +ac +ac +ac +aP +ac +ac +ac +ac +ac +ac +ax +"} +(43,1,1) = {" +ax +ax +ac +ac +ac +ac +ac +aI +Mi +aS +aS +aB +aS +aS +az +al +nz +Hq +Hq +mW +al +aj +aI +Wg +aP +qf +aP +hN +aI +ac +ac +ac +FO +ac +ac +ac +ac +ac +ac +ax +"} +(44,1,1) = {" +ax +ax +ax +ac +ac +ac +ac +aI +zZ +OT +DK +aS +aS +yR +aI +Wu +al +Dx +Dx +Wu +hI +wF +aI +rJ +aP +GK +aP +aP +aI +ac +ac +ac +FO +ac +ac +ac +ac +ac +ac +ax +"} +(45,1,1) = {" +ax +ax +ax +ac +ac +ac +ac +aI +Pf +xp +aS +yQ +aS +UW +aI +al +al +vY +Wu +al +al +aj +aI +de +aP +aP +aP +rd +aI +ac +ac +ac +AG +ac +ac +ac +ac +ac +ac +ax +"} +(46,1,1) = {" +ax +ax +ax +ac +ac +ac +ac +aI +aI +aI +aW +aI +aI +aI +aI +aj +aj +aj +aj +aS +aj +aj +aI +aI +aI +ar +aI +aI +aI +ac +ac +ac +aP +ac +ac +ac +ac +ac +ax +ax +"} +(47,1,1) = {" +ax +ax +ax +ax +ax +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +kt +ac +ac +ac +ac +ac +kt +ac +ac +ac +ac +ac +ac +kt +ac +ac +ac +ac +ac +ax +ax +"} +(48,1,1) = {" +ax +ax +ax +ax +ax +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +de +aP +Gp +dJ +aP +kt +aP +kt +aP +qh +aP +kt +AG +de +ac +ac +ac +ac +ax +ax +ax +"} +(49,1,1) = {" +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ac +ax +ax +ax +ax +ax +"} +(50,1,1) = {" +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +ax +"} diff --git a/tgstation.dme b/tgstation.dme index 63228436cc9..d24c9f4058c 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7730,6 +7730,8 @@ #include "voidcrew\modules\shuttle\survey\survey_data_disk.dm" #include "voidcrew\modules\shuttle\survey\survey_designs.dm" #include "voidcrew\modules\slime_extract_piles\slime_extract_piles.dm" +#include "voidcrew\modules\stealth\scav_camera.dm" +#include "voidcrew\modules\stealth\scav_den.dm" #include "voidcrew\modules\stealth\scav_guards.dm" #include "voidcrew\modules\stealth\stealth_admin.dm" #include "voidcrew\modules\stealth\stealth_admin_noise.dm" diff --git a/voidcrew/_DEFINES/stealth.dm b/voidcrew/_DEFINES/stealth.dm index c83709195a2..7678f671fc3 100644 --- a/voidcrew/_DEFINES/stealth.dm +++ b/voidcrew/_DEFINES/stealth.dm @@ -212,6 +212,8 @@ // ===== Disguises (decision 40, stealth_disguise.dm) ===== /// The den's own doors #define ACCESS_SCAV "scav" +/// The den boss's vault (scav_den.dm): only his pass opens it +#define ACCESS_SCAV_VAULT "scav_vault" // What someone wears of the scavs' own /// Their face is hidden (tg's get_face_name() finds none) #define STEALTH_PIECE_MASK (1<<0) diff --git a/voidcrew/icons/effects/scav_camera_cone.dmi b/voidcrew/icons/effects/scav_camera_cone.dmi new file mode 100644 index 0000000000000000000000000000000000000000..fad0ef6497fa28a8b9c9243cb7869578af2d4b8a GIT binary patch literal 18504 zcmd_Rd0f)z`aZ5^P1)j9>NG7n(@cw|*k+3x%`}~++$u6t5Gu#YOi{^P5U{4kQ=VjI zN=Z{_Q^pEO3lSBe9HXRUQWFaVjgSl#0TEf>zqgjtIdf(^pV#-lpRZRCg3of__jTRZ zeLoLpc7$%7=`i2H#>Qsmwy(e1Wn(iP{I3mn>J;#C+L!W|;8SJh?!Cvpip9jF#3dbz zLnqqUq!*uStDJRm<%bW{EWOjr{_p5l?{^>gNwRJ2(Hc zEyXGI-0@>l!}>Ld>fWj!`RfqX@~TCoaKs+W#|~AWE!y;D_63`5wyk!bPx*T0_X|G> zn9;YtlQXLPL0OFsq!^||Ed^o$zi%Yh&Foj>~H z;^&{|T>UAx;c$@_AcUY?i$W^Be_Xo3{`9u>E!B&Ai&iZOd4#IsX|pRm32||Ikt+_I z(`C*ZGtK{>enwum-C6&B!`b>&-;!C4(?^H<+LF^}J8*w}YZKzRc2Uq3?;_nbls7Le zJ!HAfq=`2-)tp(Z=sB^ZWo!N>qGLUfOl*4k!3CW3hE3qHgVxtaowIExKKjYm;jfB4 z;w48ct*P)t<}>vark^C!f(*L1=(H5un|hNMD0!W{2Rg#Wgxico==e{z&6X>7AQ2U; z`jG~hvbRHziDN#I0Ff@Y_ejn?@PBQ8zNs+U^^^KaU%ocL>-Zwd%- zz7PpziZK~+mMHcTspLylt0r6sy<_jc(;R)ikx@7hYd7pQ2s9?3OKAW8r}+fMS+0&fA%I zgS=Crs87p?GciNW177Bl;xL-uZbg8|H%-L8KtM;%z#q@ib+STWg$sSr7*D;9ww)`G zWc)e|R~GD?t|(xN5A973WQt#mz)1w53r1>ygqZ z&Rz%45uN&JX}4C3aCj_VchtQz)R_Pm&RjzhULY_Fn&EB7dGd0tal}hLP*!nCRQ>#< z=KR^0a6X5b>6Si>6j@Y<@%bQ z+S-2om2|ATd@$BG>84ZGImwsFI8nLqpdhBYtUA;=3w!n=liX65Q><8uqZfY29tjLm zk}5<&YJJU)b?C0%4f*$ccn$Auw(0vb8dXPX5DYGK`W6g@{=)7T7(>mDAsXE~=q?-f z4N>S~OZPOk?k)wo|F1EuU&$&rT{!#UU zf9c=A`Kr%d=ju{X*ISPqWYs_OIW3KEp_T!mA=lYAG52a#>2yWq9KGi(ls2j+=y}zh zhjk-XxBhSD3@7EdcLy<1wF95=IlKq!?w+;K_{8)sT)N$aiELJf>UK_iPy>ua zT?!NsE&l>h=$>+8ZQZjM?v(+|!WEbfCj5mI!(^?yCfPOQdY0oApZA1z{v@14>X0^9 zUNifx*QLE-w85t~6uoyv5{%l`=fb{@&9XO#2jYx(g;yoCT#j5$o-kDBL`Hv}pNMBn|$+|0Ir}CJuPBJpOxT&F_w#F|F zCy49ZF@+2#N3D;jEr}X*x48OJYg!Vv280hk?_GK+kdNrYCR*AP6lIpdD^3Vb0ht}Z zV8sk}obE1FU{A?{d(skF;Zp}K*RpR0m@fZ1>qx|Cm+zJ2gbY=Zg50KV7U?P|URlm2 zUCo^@hgzK;Gh(IiPRZn%i~6a9oD0gvW!3BYkzre%W>ovv`(2 zbI>(!5y5k11js>V$un2S(20q!0mAP7Zrkj1~Zp^im^&&=qFwDjfb1ungCuQ7{K`ZT($qL9B=|7f%`CE&8|J+zeYA zF_cge#Vo`Y)0%FVr#60NxN+!(>cv%6du{1URm}jl(7Mq_UByHlA6VN>p3~DV6C~(w z@A#$e*|1bnPRG!RhZyJg-qs*`qZ;Y zM8^3qlnD(&D>74DF5ISyS3G^iNg%L;tgtdk4oT981s=*?K#i{%!^qnpU|;WD?_WFh zJ;8HdtXB0*DY?KN*>jNZOKpo&uhZ$UkeL)_LfI{Lnb?%E*>-f#lJ1^aa;d~_NO(?k zCs(-j2S7cg4Ucub#_VM7)S9sg-)6DNQltFppmxaV!iD2P6)mz!Rxpn{~;AQJ)lWj`_J&iLpQJc_*fYDTSlYg zYC0}DAbK=fD?Jbtm)yyBn(q<7HaV>AL^FV1+0HjL6#bHm&xy$|e_ z;a0ZL&|XXC!*vCCc&x-nfswbOl>$?y_mXb@RxU}z-hIQ1?k7%m=znoijmSuYkc{gv z9Tx}+2Ton#R4)MiN;OLKv(l4lV6)SYMB}3Q?QW?HRR}Xp81S$6>`n{Z78Z9Xr1DVE z#u{W|f}-GL$BQ3Tt+kmM)n?OAkFrxKy`a|Cn zq=9duy$L*^L)f+kn7WT|(j#W4D+SZ#vUZ~AP5>`o_{5o@wCqCj%fei1!VPfSiAo}y zmAEasy$~+Mh&nXl47NYBg8DCJ^$^_Kn|5>hKWOeJ=|@ARrPrvPx_tysJ#0~a7JY$S z5U~Vs({GJ;W3K>R35_zncJ^Wuz1cvARIAj{M2{`OE1C7LZeKmc8UDZ%1{)$q_ybRn zpS?%2XX^G@3&J)lQso%e#N9SgMMe?KJm78#?Mgi2H?qOPEVkL`)<4_2 zUB%%265XEu^nS}87%YtxN?GsnEk9MRmDbwSr`Doz##)VmHz3u8KJU~l7Mq$1Mbnp747C80C2XfeE3 zQgsSnT%%!X|Y1fkrwiiqAb59y&FE+9}l!UDDm)^g(= zxbe9hT9r!iz__O;ZO|BTXSb34?3-?uzEJXIkGchfbu&fv538HLsfe%I^!B+fBG{Jm z;04tB@xcNfU!I{fe7C@y%zL4ViI8LYl$pO$S$5=>ProTQV+Z7=I?$S4dxk@M5g5bf zp6lkXbrH)aeKh%U>Ed{HMfi(I>rShd|y!;5iRCClyeKt@i|CfsH&S8a`4|*TohOSH54z zHqz?u*0t5~9U)x@-x%XPai>hX&nRkAq9eaD>{+)l%u$lucc}amjB3{}&s*bZ%uNyx zMTcB!G-9JNyVwV;7rx{8#be(zC z4w~K(|3*|mUIcm5Mwq`=9<>br>L*va~eev#!&u#Y2omIjmhRh(czn z1QV?^IC}54L&9#+NNznt+2s}NUStrxC^grt&Ddhs zy(DH%QU-v{?;?3x)W3+SHsa!6WAPV}_hDzB4rHR2phU>WD64}_175}sK8+uvz8k&{ zf6QIy;x-8ydt(%P^UEaF=Y6HTpO&!`ORT=PJc&X+v=cK8Va)~k1k}QZU1J(UH(Ea` zbpv3tB0?t(me|)1XT|HRw_2Nzwh3l4TTs7Z{B@smFzy>|(JmgNv^$fv72P)`4n*Tg;4)+Uxk@5?ECyP16qpGaL6)%wGa^Lg>?%7 zHo<VRot@>t(s!14ZmsmpYDw91nk`vyr2ioI%M1msyL*O|u zQFwH3372zOQYZ@c5{{`u^5PTId`o%<30b8-Zq3;fch%oxhZrZ&?LE)){eLY`7n zqb)_5&Ki|;z1-K}XH^PM%YdyCKu_}tNE;BmfoS#tGvBm?8lLbX4XWUqBrg;u6jqNVge0B4u=S6R@ub0~k^>G1s zOFc}qe!W3|d*yQ`-dy|IFWi$xF+~SEXZJR9;Rr3ymc68e5leQ5l?sx({Mb`oLD^wo zyrS9b76Qr)K+5b8e8IGC#19_gFrYCD7eFb)t|SA28EtM+@z0E&xwfm(-jyb5tJ~P#dgu8?BVbCIIXQp_#ED zXzPrts;%PWelz}9F2&Yu#7h4)xUSx??_ATzV1UUnHIP}~)bXRLGN$XLQ>QjCt5hQl zo_!TTc)fx1z~}s{j^IT2O@$9kY7M7;(M-ssJd~=Tdf(+J?>slx4hDxrVUn3GPsP7@&F<|w_NxrCnhePE(4-+RxGnY8z$Xuyf4UR8Z#_c z48Jbpwmj`gK&iBpFATN5*kyw(8m`+tLh~jdBd6f0kBCf9L&2<)CM}s4>2W|>+rKKp z0WTMxFq=k*X1Zcj>c%5Tt;uGTK+S>b1UvP{7EUs(pgep5#HlL4VG7p!WQen8 zwbK`68qk;mrCc&Ci8kP^YKyt?`e~Ftl>UK%Aa>NGnT5RXWKt8sP&8zf^7Mf47tOM)pslU|Y$+0GvKPuQYFoP{PlcF6 z9-Y^{|G?^quuszyK2Cqbst#2|!Hu-(9NoIRWtT0t9dq=L2sgyZxr@KVVCAF*JtZ>R;FdCLQ;ZC}%bxzUeBRQl_4t&+ams-acf0J*@c zR1l@I?`BP72sc#hwGJV`qKCvWF9M`vI})&6>H(7#=)o$6USu zTrUEU9*9eH%7iOBTu#9iatzuFNZg1k*(=N(Ok0aT7qF$fL%xK)M8#5;r5w&bA^c{Y zo^R<$RgGqT4-S46>FNziaUgLa0M412QQtqBX67v5y?e{gx(IN*GQp(cH)%vLJkU4^ z%qcM-(SmI$m1czE)+*btOUn3JVlUPTDp3uJ(VVQTtNjw z^Kqo@+@QJaH^SB&QGFwiKzs#!WFSZ#K~Hk@1QpN#5X_Qp6Tnl={tODRS3-dS{rimP zdSm&lL4!WxJm(gcx>!0h#CZ)|E-n9ZsA$?fo%V60pIVOzAGTy>!*i0^k6^YN<3M4T^{6;|5F^~606MRdel+u(|;S^oFB!xvbi{SQFar!OtHg3>)Le7~p z9Nj6YCd+dYu~b?$++MWKH2CH~LgduL&N#XkP=Q0aV`{=7G~NbCy+o2fp431IAiJ*y zWTw-4K;L5lO!%?L<^)3O0bmpl{vvN8!`8&A({6mv+TGa?c1P24?W6^Ax23trkw$e_ zE_b@yB)^FEqb1eBlOS%u?PQ~BN3b~{Gx?Pg~BPl&U}CEOMKKK(3D%67RAWXL{u`-Q4Qx zLA49tep#M+e(se?OSuw1fR!3#AS&_8--IEcTdZxSEuexkGFBpwo3Vi23N(NSGzjzr zDWKG!R9C5h#u>eHWM@3RLYLheMs$D;!D!w)7ZT)LZW67B3+T3RgBOUc0+Ae9PdB zCUhMdP^}~(Ck1W!g~cnW4GG(JtYWIU;uU~{f_Wb0wm{VavKVv&81%YI_25E4s{d9t z@doFbY=X$LZ#ub6iVo}brvwUulLrFwiNZ{>EA7m!pe0ftD*agu5dL|9>QWln4v{tE zXkR){uaA9(n;GDLjw)D%P(R5f_HlGi3Yl;jz8tq}uQ{+6jE~Rf#GY>WQ`^AT3 zi&B7s4r94knHuX#%j#V%DvE9O2DXmzTC>*v?>tGjO;8&b<}^1(Z#3ohdZWKwT8oT7 zasVA^wbWOB=YRf+y?I9ehsj2lvH6CGxQ^gUNy@Evt~w=SXL zQK@eJ8$<1ZrJF!gzb6@!Ri)r?MhyZ1fVb*Z9N9G>pqd11dVA(5se6TeVlRLLWLb@- z)=>$bHN8rh(~OS@PAc)$xtyei%48&gPhuD=L1t(#XAX&cyE0E6ZMOd@MGAIkZ8+5z zqCYCYCZfp8z6W@?oqzKwZRxwSG&IUwvf@Zf^m-;D%HzWkr?sR4IH$dwe{Xa8>>52O zJK%J8qw|vP%u5fn4iuPEq#ri0As; zZxxG^qNdfTR}En@N1n9DAFeQqJklWvFx(~C%<6!|#lvUK*j#S>(o_0gLjUrq`d3oj z{2zc`%ld<>(pZRPz%o#|c8^lPuFK{;z;Pkawh%x+R0Ahugd!Qx@{ZNAv2o6s!s72v z%QYF9N8L>$#l7TZPg?CS8>^X}5kaLxk^`zAS@e7Mohs92Fp#&*H>md6bupAQ1}iy^)#*bslW)iq?8}f)ZJmYP705aUSb zWTc029rbI9zUjk%yiG&@#sRTvErkM@%?bq+3d{_%=sEAY5J}#&lZlZ=S`e3(8Z`GL zTmVxR8sQ(|d3=;N5$=NH$e0eZTot8zW zpHq|z&ru!e)9L3O=VtRQlICk`)3Tm@%v_BQv4LpIQ47H1S(XOPN*qk_FdRBhSoa?f zz}x{a$&NRz(=l5+I62L(M>9^)Ni50>ZE4P|KM zk5b21V6T-krskK9Ww>#(TPcrB;{t?2HmV5kYKg%?4L`g5>Oqx3ta0I;mP@o8uyB3d zDm|+~mp@MLTN@6Jnw=+FO(va>d+<^v{zfWM91cKL?XhCyQlIk#Ec(vwk$_vp_Wlue ziCuw(<~xs|m;U1cI5S~!P^pKH-0~K59URPR_seHc#eRN0cfzeOyTn0#Ic_~EsPIrg zLRz9xDOLp(lyR%c@retl$OX+5<|ED_XbXE?Ge7o005O2MNTXT?9MuSx{>KAh&cv>0 z;hn`rFJE9h+^BeShn!_6MV!I(4KvgiF|e;-&?(2_?x(Q*V<8H%H0^N+cHj}s6u)v> zly&n4-fuhyzJ!wAMJ91&xY<&l6d2(G26z^^p!TPY;4gfWS*g~HvZ;@G7C)Dx)G}&^ zvKP4(wlOR^B9MSHl`G%)ld98FJdSPnkC2#{2YO~=^xdRPe%t=ul(5+~{`8Rib?_!B zJ^ZOYKHO!|bdHQw&e6j5HCx2ZSCPn=H>o?M2Okd>DK1^IF%QJAwdnnRe{|x+=)1z+ zB;;q4LSb9FOQ+q|84zlwf4*R6n9(bjvz?2JitT1CPP+M%U%ocoKs{oioXhGh16iC>+hOm6Pa zIbF_)wXF%aT6P5_8W`<@=S4??upE-I*^&vi*`Oh}{7Bits22_8LTBjUR)gZl2?M9&)u$+_4*%H!u>-nNC2p3V6|as+$G&+$aA+@rLbFKH|_4lwQu>IIp{U zVf)%H#@u7{k`E;&1Wa`3jVklE(K{Z@gb&|_aQD-w^L~n@tQOi$w>!u|FH7~(A46&J z(VVj2i${)dMlLqr%?fy&Pf)tw#uVzT97B8jDT9S^kV4DA-FiZJ)O!38VbSkzihq8(YUjq+>vt$` z93w#GTi)v|;h*Yc06B~ipf)q;k^^49KHRP%mz(-&O?|>mdvS9W1jw7*T|0zbewHK0 zHEX;@!6ExA=%QTmBM$b3g#FuOGGTS-KY{C0z`|{x_i5>#zO;&|^~W+EB{#`A1z-;* zCv_=4aa}~wt?AsLE!|Z%W{g4$q{X~Z?Hvv9box%1<@HzrW%?t@Ya&JlpJD*ncLN7A zD9upPpMgD_>RS@3&>W0@pp15<70&YyUy1Oz{)|s>CP8t=c8}Aoz^Ww7oAL%)A2-IJ zr#kyt6ldb@#XJaTJ4F~R+T%~SyBLUXX2e3`tI%DFqycaDSJE)+^H-FR|9${AyzKz^ zV?iuG#du;vqt~x3;A`F8w%5;qoHp?XZV9N>m+&xC zrOtObnt+DE{)w$7=}eKCrJOuM0Xwmw(lICTO}4@-niQd3&8MMKvgI6TG5eHd)K*55*FP@D17v_ z&yVn5N!_ZS+rQTR?y|=10nB^5w*F*?A;U0Vz7|4K!k2Wbvkn(Cn~PD)nmMTXe1-OD zWhZ#Z&cn|@C{r;s$(-AL9OmyN#|bd`!N$R~&k<(RTV?~aZg>(h83HyA-hg_dO%c?? zgjn*Zj>H6`G8&jv;|T;-9gT+4?S?EPcg&dI=JttXpb8#O2AvF$hr?3XIsmf}TM?nD zzZs+Wyj$BREPTX`wH>9NQ5Z2-Z4jYG8Y)OWpiHTp#?@Qq)%dh!qe~AhXowz>+%Eau z_!}1$s<5|{#Pl%3jV161Z^v^wSkt}oY1iBwa<*(!(=nx-OE;&JbN=yhji;r$%r-0^ zAEXeOvo_)&4&0mrFI6B%r1mlKUhaSdVk$4^=myGGcO7}t05U{A{&(47+-jW9#wlVS zQ7)~u_h;fkWyaqe_J|o{*LTI!eub?x_~s732zv;15+#gKchziQKDZziOmC8wCmg)Q zim3>{%T@%^DTm^)uLyNG2oU^7Q~A9mx{+^g^hbhMg5Q|Vk@&pg73hN42Ku=CN38K)eqg4m#rVP4BmpD>O(bxVzdr9=`sz@A^!RKLBnQt}y3Oy`O2)IchcPC6s`C*h;7hFha#q0?Utp?dak^1`4>x zw72&$`olp&^<|vp%Hsy1g;Awa^|7DMa$*c56Mn|tLOx>lsH_P1dNAFy|9k2QCe44+0uI>ZY!lA}F*oFE0ZE$$uQT zAT!JwXNL4?;QhGUL#pTTz&UI&{7|a`W_8HAG1aULo;{j%iE@zqQgOf_xN7zrla)Ko zJ{FxCuuT_$X`m}_E%vzz`~3gm6R+eb@9in`ZG9_v0w$DzJ^q%;O0hrZ!Y-ip)(o># zjBUC<8l(q4JD_Dt4~Nmreugms=M_#|B1w~KaZA*j9cw^y-u9AwkoZSDJ|2MtH~b0k z?i`oA$Tw_r49lO+*xo?9FKtJe8y=&q4L`9sRTazZh*XAL+A4S!^Nda-54=3yVSZ-u z!W<45;R8Bg`tK;h_u5eUR@Pw2R=?e`f~w(2`X!Ia%;0<+XI%?l&Kbl=*0n)ZiZ*H( z3e1j*0D^sc#sat7Gk@^aauo6V)Ymw#2+%*m<#<4d#))&EAnH7lP!18EhbxxWF;XFy4)tZDO3D=iFG z+Fd>;>1Jmn3CD4wYVgwPflvKDg-8D)X|(T7fu}#Vk_bzGSJ}NY1~AiotjRKT2l^!ydUZ;bA^ zH$yCoatmeU4G40twF^eVQ!_v~|dLZaF~o_zkVtOH6)Y4(_C zAKKoWqVj$ghll_ruvXomdnK*x+*pvsaZIV!~knunht-4me?KX3@k3mOQK+*h} zl-yZ=ik-Ir+A*d)kRj1FR$a<`5`Ruo_%tGcj5D+bn=R_I=?QvqXT_RZ4C}bP| zV)G!aM2x3PWK-oBJppi#gyO=41XPp_nDz(%i*hyz2{dOd`42t#PH9L%KTTHddWSTLaLI zi#T5y1E(Aw^gaPB{H}+3&QBva{fL7Sh(5Wl_=~^z%rOD;F2nt;h-nvpuULLhjpP4A zeK9sigtxVWdZp6;kf$zx@_qCYF8}AqE!~z4d#F|R{w^oL3;$c8s6oHLmeCrWR*e8# zJnFkkfc-Bk-za3Pzu}NE4|j*3D-{^c+Tc~`Aw8p%*U{6Gnx+@1VF<<``fWg<9F z{-tupYH$5>Vs>EsYJ_oae01JMB9fYAev+^VVd;WtP9$ekbkrHMg1qc4M9>UtO} z&HTJ9&>MH@b*6908)cr3_2UpeI&jK$&n$e!b}krfFQneYHKCINp)JfWe-hrS(7I7K zkYL$N4=RAiA`GhE??nB^9n76z5F#ag$9zdXj?<|fg231wX2w|I3YJC`Q+RK9s9j*# zaI`XuqGq&b9vxBaoSXf8+27d+{n*#$8WnOWj{U*gkMlmxrNkI82v?zSNq3dmuV4z# zZ7E0mQ}9E}v(rzW7Epj@llaDtW?X(-CcoY~#tr#Io#JOxwpkzacf7u0(U(Cem~au* zb@RugjCT?EV(+j;x68&=pj@3)4l$L45fF)Kfe~gAOM9%ht*^bv1{-Lp*YrFv;nMx* zUPdhiYVGU6>#(jtR@3iySl%h#i5hXpZs@DN_$R{7+5uFPTWq)GT??XmF;Hof1u=tE z+q`(_N|8<0t+O1!qXJmBbHu#RI`6R10HPf3w22c?_BS{9{FNKRrlJ|eG}q3et-d|y zmxgzngkLk`mOF4cA5p=UQSzLj9T)t8nqq5YJ^}cN!q)>`y{NEc*XdkgR`J)7%L{;6 ze^i_PCOkGz=aw|lX{bZd3k~a5C1oMET%MrM>N95IGpBBhS`W?HKdRq9&-yg|A}6{9 z;H{higgbr9K@>PP3G4`7CM!p2R=RVAPT73ke9C64-(TmHaoak2*`zsfdK;=6o52f8 zC5wm7kFPr6Az?sYTlrNKvcfHBb`r(lmTShdg3T7(RWsbglY{wj(64|X2Yd~}rmo8R zx(DKz4OU9<--#elge-v0RDERKe=u5ED-nf&-!qzb)I zcztx8%sM2N0BQL^e_hk*$>MMzIHs62q$8f=JdO_t~1VeD~M1dh)_&%+B+ zg~8dL&{^h2xwaZ-9FF7jLfW>CEk7aFO3Br#*XllSjeUB@6F5f#uh;Cc#vW9N2}t!? zFdMCLGLQs4CXnHPUB%Vr;N!PkuVu|LK+pVT%6Lo5H8zM-Qt-}uUlb@(jqpZpcLTsdT4k>!Rb0`{ zdb&C7Pm1jKY&{;fcy^2U0iY zx1o6YOcg-?0oZUa)pMvKyx<;REC-?tMEVIvGt~Zj;BBbbEJQoU2v_*FR*OzLs%Mt;h#t=XDRp8c` zUp@hjradI|1$6H%_OnVq1D?`JahxD)GAqH71*->Cejpf!5Qe(;BCFpPYue(!RH^^Q z)(EsVeX*)Hj+br84Tv!q${Opgu$JW2din(46%F2oiIDvrcr z01T&~WFx}qM9$UzNEhHi>tz|B)6)6kAh2dLq`tHO46WNT(H1qXd78m#7I4t2J;&BbwCa{cIH$Vzww#jEdmC zw(-5o2a&P?EC-qiNYkt_S2z&?mb5cqCI0uQ6ckN8le@nw|8fVqkI6s;A|uUSRD6Z| zBw<_jA*$VH1lQwcN*D*}z#Y#Scz0W1K(iMx?J`@&B3;__d3TEOrVL2cx@r4;LJ0-H z-%^zm`f}2AE=<%>Bmtdl6z{FbJ+XPGWB6O z6J|9Ip`Tdnzdk+V;w8H*>kCl#U!UqpAY;rx2dJk((z_%e zow=6>fEPa#z^DrYA@SE`Gw|IWDn(ys~T8}f9LaQD2 zfu{jN{x<@3y{D}s*yfk+Smsa(IUktLWoOzMj3w62A7dJSu_&|UbdZ^)5 z)+Om809^=FUbD$+IA^B(EzLKPMfTbtS6Nx9xJa`v;%ru|L8*Vao5Z!Qo6*RLE`yR) zdcm0kdn4z$PG`fKB)vKXT@7}(&T<8h04d0>ZgYt`JwFu?fb1G%1=mnym-Ivp7!CR? zj-T`&|GV)Ihh#1k3YqRuJG>{sq5y~8o1TYRH3~g@Rkhb_%8X1q>W^Yq)VtC1fh2cZ z644#>Gk_RIX_)+ktr`NwOezCrkwgy(gul(?Z}C=8PCVhpN6DNXO8xkhYXro0j-rip zAfwofeSOj9vE{FG;%_t{SWRvRHIcJ*M=;^mvP~5_le~emoA^AlCBl0bXYt=D1%6Xr zbK-1kAZ-=y!q5=gLBnhP3qg|wx_&!{En1USC>mU2-~|59qo&)|Y>n3>2K>PEv_*%L zz@|vy3zxzFDTLk~tAU&qb#p4BAe(t(8Bl$e3tL@ zbczR0-cb-LAi2E=h!%6m_Vov`y%3BDw-gZm$-&rf!2h0h^f#7i@<<#PDkftb_?Si+ zpiPlh+W3>B1m&Hk^uNtv6B+xc24u4^_S83h90H=b9$>so29zlj=)p3Z6+qzs#X0n2 z^N_sc114gVa3|QDoyNVUtsP^5jF%g&W7$XXvwe5fC_E7sJ!9SM(UJcJfbZxC7@XW4 zMhRRLMuo9Lc>j2mcCiNUX`Mw%RlH10@SF^!Y{XS`5Ks3&&uWt$k|I3^3vI;pRO7%oUKgQG0b-RpFz9M;KVCCk length(SSmobs.clients_by_zlevel) || !length(SSmobs.clients_by_zlevel[eye.z])) + return + if(cam_state == SCAV_CAM_OFF) + if(feed_cut || (machine_stat & BROKEN) || emp_until > world.time) + return + cam_state = SCAV_CAM_SCAN + aim = scav_cam_facing() + update_appearance(UPDATE_ICON_STATE) + scav_cam_draw(TRUE) + if(isnull(profile)) + profile = stealth_skill_of(stealth_skill_type_for_zone(stealth_zone_of(eye))) + + var/mob/living/target = watched?.resolve() + if(!QDELETED(target) && !scav_cam_sees(target, eye)) + target = null + if(isnull(target)) + target = scav_cam_find(eye) + + if(target) + watched = WEAKREF(target) + last_seen_at = world.time + scav_cam_follow(target, eye, seconds_per_tick) + if(cam_state == SCAV_CAM_SCAN) + cam_state = SCAV_CAM_TRACK + playsound(src, 'sound/machines/beep/twobeep.ogg', 30, FALSE, -3) + update_appearance(UPDATE_ICON_STATE) + if(cam_state == SCAV_CAM_TRACK) + var/rate = (profile?.notice_rate || 1) / SCAV_CAM_FILL_TIME + if(get_dist(eye, target) <= SCAV_CAM_NEAR_RANGE) + rate *= SCAV_CAM_NEAR_MULT + notice = min(1, notice + rate * seconds_per_tick) + if(notice >= 1 && world.time >= alarm_ready_at) + scav_cam_alarm(target) + else + notice = max(0, notice - SCAV_CAM_DECAY * seconds_per_tick) + if(cam_state == SCAV_CAM_TRACK && !notice && world.time - last_seen_at > SCAV_CAM_LOST_HOLD) + cam_state = SCAV_CAM_SCAN + watched = null + update_appearance(UPDATE_ICON_STATE) + + if(cam_state == SCAV_CAM_ALARM && world.time >= alarm_until) + cam_state = target ? SCAV_CAM_TRACK : SCAV_CAM_SCAN + notice = 0 + update_appearance(UPDATE_ICON_STATE) + if(cam_state == SCAV_CAM_SCAN) + scav_cam_sweep(seconds_per_tick) + scav_cam_draw() + +/// Moves its aim along the sweep, pausing at each end. +/obj/machinery/scav_camera/proc/scav_cam_sweep(seconds_per_tick) + if(world.time < paused_until) + return + var/facing = scav_cam_facing() + var/offset = closer_angle_difference(facing, aim) + offset += heading * (2 * sweep / max(sweep_time, 0.5)) * seconds_per_tick + if(abs(offset) >= sweep) + offset = clamp(offset, -sweep, sweep) + heading = -heading + paused_until = world.time + SCAV_CAM_END_PAUSE + aim = SIMPLIFY_DEGREES(facing + offset) + +/// Turns its aim toward `target`, no further round than a little past its sweep. +/obj/machinery/scav_camera/proc/scav_cam_follow(mob/living/target, turf/eye, seconds_per_tick) + var/turf/spot = get_turf(target) + var/wanted = delta_to_angle(spot.x - eye.x, spot.y - eye.y) + var/turn = closer_angle_difference(aim, wanted) + var/step = SCAV_CAM_TRACK_SPEED * seconds_per_tick + aim = SIMPLIFY_DEGREES(aim + clamp(turn, -step, step)) + var/facing = scav_cam_facing() + var/offset = closer_angle_difference(facing, aim) + if(abs(offset) > sweep + view_half) + aim = SIMPLIFY_DEGREES(facing + clamp(offset, -(sweep + view_half), sweep + view_half)) + +/// The nearest person (or player-driven mob) it sees now, or null. +/obj/machinery/scav_camera/proc/scav_cam_find(turf/eye) + var/mob/living/best + var/best_dist = INFINITY + for(var/mob/living/found in SSspatial_grid.orthogonal_range_search(eye, SPATIAL_GRID_CONTENTS_TYPE_HEARING, view_range)) + // People and anyone a player drives; not rats and roaches. + if(!found.ckey && !ishuman(found)) + continue + var/dist = get_dist(eye, found) + if(dist >= best_dist || !scav_cam_sees(found, eye)) + continue + best = found + best_dist = dist + return best + +/// Whether it sees `who` from `eye` now. +/obj/machinery/scav_camera/proc/scav_cam_sees(mob/living/who, turf/eye) + if(!istype(who) || who.stat == DEAD || (FACTION_SCAV in who.faction)) + return FALSE + var/turf/spot = get_turf(who) + if(isnull(spot) || spot.z != eye.z || spot == eye) + return FALSE + var/dist = get_dist(eye, spot) + if(dist > view_range) + return FALSE + if(abs(closer_angle_difference(aim, delta_to_angle(spot.x - eye.x, spot.y - eye.y))) > view_half) + return FALSE + if(stealth_shell_of(who) || stealth_is_cloaked(who)) + return FALSE + if(dist > 1 && stealth_tile_is_dark(spot)) + return FALSE + if(!can_see(eye, spot, view_range)) + return FALSE + return !scav_cam_waves_through(who, spot) + +/// Whether a scav disguise gets `who` past it: fatigues and a mask, anywhere but an off-limits room (a pass excuses +/// one that allows it). +/obj/machinery/scav_camera/proc/scav_cam_waves_through(mob/living/who, turf/spot) + var/pieces = stealth_disguise_of(who) + if(stealth_disguise_stage(pieces) < 3) + return FALSE + var/datum/stealth_group/group = scav_cam_group() + var/list/off_limits = group?.off_limits() + if(isnull(off_limits) || isnull(off_limits[spot])) + return TRUE + return off_limits[spot] && (pieces & STEALTH_PIECE_ID) + +/// Sounds the siren and sends the guards to `target`'s spot. +/obj/machinery/scav_camera/proc/scav_cam_alarm(mob/living/target) + cam_state = SCAV_CAM_ALARM + alarm_until = world.time + SCAV_CAM_ALARM_TIME + alarm_ready_at = world.time + SCAV_CAM_ALARM_COOLDOWN + update_appearance(UPDATE_ICON_STATE) + playsound(src, 'sound/effects/siren.ogg', 70, FALSE, 6) + var/turf/spot = get_turf(target) + target.log_message("was seen by [src] at [AREACOORD(spot)], which sounded the den's alarm.", LOG_GAME) + var/datum/stealth_group/group = scav_cam_group() + if(group) + // Wired to the whole compound: every guard of the den hears it, as if it went off where they were seen. + stealth_noise(spot, STEALTH_NOISE_BLAST, STEALTH_GROUP_RADIUS, target, group) + +/// Points and colours the cone to match its aim and state. `instant` skips the glide. +/obj/machinery/scav_camera/proc/scav_cam_draw(instant = FALSE) + if(isnull(cone)) + return + if(cam_state == SCAV_CAM_OFF) + cone.alpha = 0 + return + var/wanted_color = cam_state == SCAV_CAM_SCAN ? SCAV_CAM_COLOR_SCAN : (cam_state == SCAV_CAM_TRACK ? SCAV_CAM_COLOR_TRACK : SCAV_CAM_COLOR_ALARM) + if(cone.color != wanted_color) + cone.color = wanted_color + var/wanted_alpha = cam_state == SCAV_CAM_ALARM ? (round(world.time / (3 DECISECONDS)) % 2 ? 255 : 120) : 220 + cone.alpha = wanted_alpha + var/state = "beam_[scav_cam_reach()]" + if(cone.icon_state != state) + cone.icon_state = state + var/matrix/pointing = matrix() + pointing.Scale(SCAV_CAM_CONE_SCALE, 1) + pointing.Translate(0, STEALTH_BEAM_PIVOT - SCAV_CAM_LENS_BACK) + pointing.Turn(aim) + // The lens sits back toward the wall it hangs on. + pointing.Translate(0, -STEALTH_BEAM_PIVOT) + if(instant) + animate(cone, transform = pointing, time = 0) + else + animate(cone, transform = pointing, time = 2 DECISECONDS) + +/// How long the drawn cone is along its aim, in quarter tiles: to the first wall or solid door, at most the beam's full length. +/obj/machinery/scav_camera/proc/scav_cam_reach() + var/turf/eye = get_turf(src) + if(isnull(eye)) + return STEALTH_BEAM_LENGTHS + var/dx = sin(aim) + var/dy = cos(aim) + var/lens = SCAV_CAM_LENS_BACK / 32 + for(var/step in 1 to STEALTH_BEAM_LENGTHS) + // a step is a quarter tile, the beam icon's own unit + var/along = step / 4 - lens + var/turf/at = locate(eye.x + round(dx * along, 1), eye.y + round(dy * along, 1), eye.z) + if(isnull(at) || (at != eye && IS_OPAQUE_TURF(at))) + return clamp(step, 1, STEALTH_BEAM_LENGTHS) + return STEALTH_BEAM_LENGTHS + +/// The drawn cone of a den camera: light on the lighting visual plane, lighting nothing. +/obj/effect/abstract/scav_camera_cone + name = "camera sweep" + // The guards' flashlight cone (stealth_beam.dmi) made white and about 4x as opaque, so a tint shows it. + icon = 'voidcrew/icons/effects/scav_camera_cone.dmi' + icon_state = "beam_22" + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + anchored = TRUE + blocks_emissive = EMISSIVE_BLOCK_NONE + blend_mode = BLEND_ADD + appearance_flags = RESET_COLOR | RESET_ALPHA | RESET_TRANSFORM | KEEP_APART | PIXEL_SCALE + vis_flags = NONE + // The icon's bottom middle on the camera tile's centre + pixel_x = -48 + pixel_y = 16 + +#undef SCAV_CAM_SCAN +#undef SCAV_CAM_TRACK +#undef SCAV_CAM_ALARM +#undef SCAV_CAM_OFF +#undef SCAV_CAM_FILL_TIME +#undef SCAV_CAM_NEAR_RANGE +#undef SCAV_CAM_NEAR_MULT +#undef SCAV_CAM_DECAY +#undef SCAV_CAM_TRACK_SPEED +#undef SCAV_CAM_ALARM_TIME +#undef SCAV_CAM_ALARM_COOLDOWN +#undef SCAV_CAM_LOST_HOLD +#undef SCAV_CAM_END_PAUSE +#undef SCAV_CAM_COLOR_SCAN +#undef SCAV_CAM_COLOR_TRACK +#undef SCAV_CAM_COLOR_ALARM +#undef SCAV_CAM_CONE_SCALE +#undef SCAV_CAM_LENS_BACK diff --git a/voidcrew/modules/stealth/scav_den.dm b/voidcrew/modules/stealth/scav_den.dm new file mode 100644 index 00000000000..3afb5811a82 --- /dev/null +++ b/voidcrew/modules/stealth/scav_den.dm @@ -0,0 +1,233 @@ +/** + * # The scav den (stealth step 4, owner decisions 3, 6, 10, 11, 21, 38) + * + * A compound of organ and cyberware harvesters dug into an asteroid on the contested lanes. It is a rare space ruin: + * it never seeds by itself, and the only road to it is a rumor chart bought from an outpost trader and revealed from + * the helm (rumor_charts.dm), like every other named tip. One den is on the overmap at a time: while one is out there + * the tip is off the shelf and a sealed chart can't be revealed (it stays sealed and can be revealed once that den is + * cleaned out). + * + * The den's guards are the stealth guards of scav_guards.dm with names of their own, so their friends can call them + * by name on the radio and over a body. Their skill comes from the den's zone (decision 38): a den revealed in the + * contested lanes is yellow. The boss, a lookout, carries the only vault pass. The vault's crate rolls cyberware by + * the den's zone, plus one piece of stealth gear from scav_vault_stealth_loot() (the matte knife here; other modules add theirs). + * + * Cameras: scav_camera.dm. + */ + +// ===== The ruin ===== + +/datum/map_template/ruin/space/rare/scav_den + id = "rare_scav_den" + suffix = "rare_scav_den.dmm" + name = "Scav Chop Shop" + description = "A scav crew's den dug into a hollow rock. They take spacers apart for their organs and their chrome, and the best of it sits in the boss's vault." + +/// The live den on the overmap, if there is one +/proc/scav_den_on_map() + for(var/obj/structure/overmap/space_ruin/ruin as anything in GLOB.space_ruin_signals) + if(!QDELETED(ruin) && istype(ruin.ruin_template, /datum/map_template/ruin/space/rare/scav_den)) + return ruin + return null + +// ===== The tip ===== + +/datum/shop_sku/ruin_chart/scav_den + name = "contested-lane tip: scav chop shop" + desc = "A scav crew working out of a hollow rock, buying people off the lanes and selling them back in pieces. They keep their best chrome in the boss's vault. Uploaded sealed to your helm." + price_vouchers = 1 + price_credits = 3600 + spawn_zone = ZONE_YELLOW + ruin_template_path = /datum/map_template/ruin/space/rare/scav_den + chart_type = /datum/rumor_chart/scav_den + rumor_name = "Scav chop shop" + rumor_desc = "Scavs in a hollow rock on the contested lanes, buying people and selling them back in pieces. The boss keeps the good chrome locked up." + +/datum/shop_sku/ruin_chart/scav_den/get_denial_reason(mob/living/user) + . = ..() + if(.) + return + if(scav_den_on_map()) + return "That crew's already been sold out. Wait for the dust to settle." + +/// A sealed den chart. It only opens while no other den is on the overmap. +/datum/rumor_chart/scav_den + +/datum/rumor_chart/scav_den/reveal(obj/structure/overmap/ship/ship) + if(scav_den_on_map()) + return null + return ..() + +// ===== Guards with names ===== + +/// Den guards keep the random name their look gave them instead of their type's ("Scav Guard"), so the radio and +/// their friends can name them (stealth_first_name()). +/mob/living/carbon/human/npc/ruin/trooper/scav/den + npc_name = null + +/mob/living/carbon/human/npc/ruin/trooper/scav/den/npc_dress(datum/human_npc_order/order) + . = ..() + scav_den_name_self() + +/mob/living/carbon/human/npc/ruin/trooper/scav/gunner/den + npc_name = null + +/mob/living/carbon/human/npc/ruin/trooper/scav/gunner/den/npc_dress(datum/human_npc_order/order) + . = ..() + scav_den_name_self() + +/mob/living/carbon/human/npc/ruin/trooper/scav/lookout/den + npc_name = null + +/mob/living/carbon/human/npc/ruin/trooper/scav/lookout/den/npc_dress(datum/human_npc_order/order) + . = ..() + scav_den_name_self() + +/// The den's boss: a lookout with the vault pass. +/mob/living/carbon/human/npc/ruin/trooper/scav/lookout/den/boss + +/mob/living/carbon/human/npc/ruin/trooper/scav/lookout/den/boss/npc_dress(datum/human_npc_order/order) + . = ..() + var/obj/item/card/id/card = wear_id + if(istype(card) && !istype(card, /obj/item/card/id/advanced/black/scav/vault)) + var/obj/item/card/id/vault_card = new /obj/item/card/id/advanced/black/scav/vault(src) + vault_card.registered_name = real_name + qdel(card) + equip_to_slot_or_del(vault_card, ITEM_SLOT_ID) + +/** + * Gives a den guard a person's name if its look left it without one. Its look (a random person) names it, and with + * npc_name null that name stays; its pass is made out to it. + */ +/mob/living/carbon/human/npc/proc/scav_den_name_self() + if(real_name && real_name != initial(name) && real_name != "Unknown") + return + fully_replace_character_name(real_name, generate_random_mob_name()) + var/obj/item/card/id/card = wear_id?.GetID() + if(istype(card, /obj/item/card/id/advanced/black/scav)) + card.registered_name = real_name + +/obj/effect/spawner/human_npc/ruin/scav/den + name = "den guard spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/scav/den + +/obj/effect/spawner/human_npc/ruin/scav/den/gunner + name = "den gunner spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/scav/gunner/den + +/obj/effect/spawner/human_npc/ruin/scav/den/lookout + name = "den lookout spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/scav/lookout/den + +/obj/effect/spawner/human_npc/ruin/scav/den/boss + name = "den boss spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/scav/lookout/den/boss + +// ===== The vault ===== + +/// The boss's pass: the den's doors and the vault. +/obj/item/card/id/advanced/black/scav/vault + name = "scav pass" + desc = "A scratched black card on a cord, punched with a den's mark. This one has a second hole punched through it." + access = list(ACCESS_SCAV, ACCESS_SCAV_VAULT) + +/** + * The boss's crate. Rolls when first opened, by the zone of the den it was mapped in (moving it doesn't change it): + * cyberware the harvesters pulled or bought, more and better further out, and one piece of stealth gear when + * scav_vault_stealth_loot() has any. Everything in it can be found or bought elsewhere too. + */ +/obj/structure/closet/crate/secure/scav_vault + name = "chrome crate" + desc = "A heavy crate lined with foam. Somebody has scratched a tally of names into the lid." + icon_state = "weaponcrate" + base_icon_state = "weaponcrate" + req_access = list(ACCESS_SCAV_VAULT) + /// The turf it was mapped on: its zone is read there + var/turf/spawn_turf + /// Set once it has rolled + var/vault_rolled = FALSE + +/obj/structure/closet/crate/secure/scav_vault/Initialize(mapload) + spawn_turf = get_turf(src) + return ..() + +/obj/structure/closet/crate/secure/scav_vault/Destroy() + spawn_turf = null + return ..() + +/obj/structure/closet/crate/secure/scav_vault/PopulateContents() + . = ..() + if(vault_rolled) + return + vault_rolled = TRUE + var/zone = SSovermap_zones?.get_zone_type_anywhere(spawn_turf) || ZONE_GREEN + spawn_turf = null + scav_vault_roll(zone) + +/** + * The stealth-gear hook: typepath => weight of stealth gear a vault may pay, one piece per vault. Here only the matte + * knife. Other modules (the garrotte, the gun-fu chip) add theirs by overriding this proc on this type with `. = ..()` + * and adding entries to the list. + */ +/obj/structure/closet/crate/secure/scav_vault/proc/scav_vault_stealth_loot() + return list(/obj/item/knife/combat/matte = 1) + +/** + * Fills it with a den vault's take for `zone`: cyberware drawn without repeats (2 in green, 3 in yellow, 4 in red), + * the better shelf more often further out, and one stealth piece if there are any. Returns what it made. + */ +/obj/structure/closet/crate/secure/scav_vault/proc/scav_vault_roll(zone) + var/atom/destination = src + . = list() + var/list/street = list( + /obj/item/organ/cyberimp/cyberware/gecko = 4, + /obj/item/organ/cyberimp/cyberware/dermal_mesh = 4, + /obj/item/organ/cyberimp/cyberware/shock_coils = 4, + /obj/item/organ/cyberimp/cyberware/chromatic_dermis = 4, + /obj/item/organ/cyberimp/cyberware/cargo_cavity = 4, + /obj/item/organ/cyberimp/cyberware/second_wind = 4, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/rockjaw = 4, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/fixers = 4, + /obj/item/organ/eyes/robotic/cyberware/prospector = 3, + /obj/item/organ/heart/cybernetic = 3, + /obj/item/organ/liver/cybernetic/tier2 = 3, + /obj/item/organ/lungs/cybernetic/tier2 = 3, + ) + var/list/pro = list( + /obj/item/organ/cyberimp/cyberware/slipwire = 3, + /obj/item/organ/cyberimp/cyberware/slabskin = 3, + /obj/item/organ/cyberimp/cyberware/hemoglass = 3, + /obj/item/organ/cyberimp/cyberware/doppler = 3, + /obj/item/organ/cyberimp/cyberware/dead_channel = 3, + /obj/item/organ/eyes/robotic/cyberware/nightshade = 3, + /obj/item/organ/eyes/robotic/cyberware/deadeye = 3, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/icepick = 3, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/skyhook = 3, + /obj/item/organ/cyberimp/arm/toolkit/cyberware/angler = 3, + /obj/item/organ/cyberimp/cyberware/ghostskin = 2, + /obj/item/organ/cyberimp/cyberware/hopper = 2, + /obj/item/organ/cyberimp/cyberware/atlas = 2, + ) + var/draws = 2 + var/pro_chance = 25 + switch(zone) + if(ZONE_YELLOW) + draws = 3 + pro_chance = 40 + if(ZONE_RED) + draws = 4 + pro_chance = 60 + for(var/draw in 1 to draws) + var/list/shelf = (prob(pro_chance) && length(pro)) ? pro : street + if(!length(shelf)) + shelf = length(pro) ? pro : street + if(!length(shelf)) + break + var/picked = pick_weight(shelf) + shelf -= picked + . += new picked(destination) + var/list/stealth = scav_vault_stealth_loot() + if(length(stealth)) + var/stealth_path = pick_weight(stealth) + if(ispath(stealth_path, /atom/movable)) + . += new stealth_path(destination) diff --git a/voidcrew/modules/trade/rumor_charts.dm b/voidcrew/modules/trade/rumor_charts.dm index cf0a41507c5..757cfc03f6e 100644 --- a/voidcrew/modules/trade/rumor_charts.dm +++ b/voidcrew/modules/trade/rumor_charts.dm @@ -147,6 +147,8 @@ var/rumor_desc /// Zone band the ruin spawns in on reveal var/spawn_zone = ZONE_RED + /// The sealed rumor a purchase uploads (a subtype can refuse to reveal, e.g. the one-at-a-time scav den) + var/chart_type = /datum/rumor_chart /datum/shop_sku/ruin_chart/get_denial_reason(mob/living/user) . = ..() @@ -178,7 +180,7 @@ stock-- - var/datum/rumor_chart/chart = new + var/datum/rumor_chart/chart = new chart_type chart.name = rumor_name || name chart.desc = rumor_desc || desc chart.ruin_template_path = ruin_template_path diff --git a/voidcrew/modules/trade/shop_catalog_black_market.dm b/voidcrew/modules/trade/shop_catalog_black_market.dm index 317a6578920..53f1ffdcedb 100644 --- a/voidcrew/modules/trade/shop_catalog_black_market.dm +++ b/voidcrew/modules/trade/shop_catalog_black_market.dm @@ -133,6 +133,7 @@ /datum/shop_sku/ruin_chart/survey, /datum/shop_sku/ruin_chart/blacksite, /datum/shop_sku/ruin_chart/bitrunner_den, + /datum/shop_sku/ruin_chart/scav_den, ) chart_picks = 3 rotating_pool = list( diff --git a/voidcrew/modules/trade/shop_catalog_general.dm b/voidcrew/modules/trade/shop_catalog_general.dm index da06e70f6c6..6d25c5f2678 100644 --- a/voidcrew/modules/trade/shop_catalog_general.dm +++ b/voidcrew/modules/trade/shop_catalog_general.dm @@ -150,6 +150,7 @@ /datum/shop_sku/ruin_chart/survey, /datum/shop_sku/ruin_chart/blacksite, /datum/shop_sku/ruin_chart/bitrunner_den, + /datum/shop_sku/ruin_chart/scav_den, ) chart_picks = 3 // Barnaby buys honest prospecting hauls at honest prices, plus whatever diff --git a/voidcrew/modules/trade/shop_catalog_outfitter.dm b/voidcrew/modules/trade/shop_catalog_outfitter.dm index ebc5f8198b7..14f8c3b0e8a 100644 --- a/voidcrew/modules/trade/shop_catalog_outfitter.dm +++ b/voidcrew/modules/trade/shop_catalog_outfitter.dm @@ -138,6 +138,7 @@ /datum/shop_sku/ruin_chart/survey, /datum/shop_sku/ruin_chart/blacksite, /datum/shop_sku/ruin_chart/bitrunner_den, + /datum/shop_sku/ruin_chart/scav_den, ) chart_picks = 3 rotating_pool = list( diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index 37b4d39b0b8..9be3eac5358 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -242,6 +242,7 @@ #include "voidcrew_stealth_d39.dm" #include "voidcrew_stealth_d44.dm" #include "voidcrew_stealth_d45.dm" +#include "voidcrew_stealth_den.dm" #include "voidcrew_stealth_disguise.dm" #include "voidcrew_stealth_hearing.dm" #include "voidcrew_stealth_light.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_loot.dm b/voidcrew/modules/unit_tests/voidcrew_loot.dm index 7b50fde4674..32cb6badf64 100644 --- a/voidcrew/modules/unit_tests/voidcrew_loot.dm +++ b/voidcrew/modules/unit_tests/voidcrew_loot.dm @@ -198,7 +198,8 @@ // a hand-placed setpiece (elite, or an arena's megafauna) counts as // the guard/boss, e.g. Pandora's ruin, the blood-drunk shrines var/has_setpiece = has_megafauna || findtext(text, "/mob/living/simple_animal/hostile/asteroid/elite") - if(!findtext(text, "/obj/effect/zone_mobs") && !has_setpiece) + // Human NPC guards (a stealth den's scavs) defend a cache as well as a zone_mobs marker does. + if(!findtext(text, "/obj/effect/zone_mobs") && !findtext(text, "/obj/effect/spawner/human_npc") && !has_setpiece) TEST_FAIL("[map_file] places a loot cache but no zone_mobs guard marker or hand-placed setpiece") // ---- rumor charts point at real, stocked, guarded ruins ---- @@ -235,8 +236,8 @@ chart_caches++ if(!chart_caches) TEST_FAIL("[map_path] (rumor chart [chart_path]) contains no zone loot caches. The chart sells an empty prize") - if(!findtext(text, "/obj/effect/zone_mobs")) - TEST_FAIL("[map_path] (rumor chart [chart_path]) has no zone_mobs guards") + if(!findtext(text, "/obj/effect/zone_mobs") && !findtext(text, "/obj/effect/spawner/human_npc")) + TEST_FAIL("[map_path] (rumor chart [chart_path]) has no zone_mobs or human NPC guards") var/chart_has_boss = findtext(text, "/boss,") || findtext(text, "/boss{") || findtext(text, "/boss)") var/chart_setpiece = findtext(text, "/mob/living/simple_animal/hostile/megafauna") \ || findtext(text, "/mob/living/basic/boss") \ diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_den.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_den.dm new file mode 100644 index 00000000000..df84caba970 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_den.dm @@ -0,0 +1,128 @@ +// Stealth step 4: the scav den (voidcrew/modules/stealth/scav_den.dm, scav_camera.dm). Unit tests compile before +// voidcrew/_DEFINES, so values are written out: ACCESS_SCAV_VAULT "scav_vault", ZONE_GREEN/YELLOW/RED 1/2/3, camera +// states SCAN 1, TRACK 2, ALARM 3, OFF 4. + +/// Den guards carry a person's name, their pass is in it, and their friends can call them by it. The boss's pass opens the vault. +/datum/unit_test/voidcrew_stealth_den_names + +/datum/unit_test/voidcrew_stealth_den_names/Run() + for(var/guard_type in list(/mob/living/carbon/human/npc/ruin/trooper/scav/den, /mob/living/carbon/human/npc/ruin/trooper/scav/gunner/den, /mob/living/carbon/human/npc/ruin/trooper/scav/lookout/den)) + var/mob/living/carbon/human/npc/guard = allocate(guard_type, run_loc_floor_bottom_left) + TEST_ASSERT(guard.real_name && guard.real_name != "Scav Guard" && guard.real_name != "Scav Lookout", "[guard_type] has no name of its own ([guard.real_name])") + TEST_ASSERT_NOTNULL(stealth_first_name(guard), "[guard_type]'s friends can't call it by name") + var/obj/item/card/id/card = guard.wear_id?.GetID() + TEST_ASSERT(istype(card, /obj/item/card/id/advanced/black/scav), "[guard_type] has no scav pass") + TEST_ASSERT_EQUAL(card.registered_name, guard.real_name, "[guard_type]'s pass is in someone else's name") + var/mob/living/carbon/human/npc/boss = allocate(/mob/living/carbon/human/npc/ruin/trooper/scav/lookout/den/boss, run_loc_floor_bottom_left) + var/obj/item/card/id/boss_card = boss.wear_id?.GetID() + TEST_ASSERT(istype(boss_card, /obj/item/card/id/advanced/black/scav/vault), "The den boss has no vault pass") + TEST_ASSERT(("scav_vault" in boss_card.access) && ("scav" in boss_card.access), "The vault pass doesn't open the vault and the den") + TEST_ASSERT_EQUAL(boss_card.registered_name, boss.real_name, "The boss's pass is in someone else's name") + TEST_ASSERT(boss.stealth_radio, "The den boss has no radio") + +/// The vault rolls cyberware by zone, never the same piece twice, plus one piece of stealth gear from its hook. +/datum/unit_test/voidcrew_stealth_den_vault + +/datum/unit_test/voidcrew_stealth_den_vault/Run() + var/list/expected = list(2, 3, 4) + for(var/zone in 1 to 3) + var/obj/structure/closet/crate/secure/scav_vault/crate = allocate(/obj/structure/closet/crate/secure/scav_vault, run_loc_floor_bottom_left) + var/list/made = crate.scav_vault_roll(zone) + TEST_ASSERT_EQUAL(length(made), expected[zone] + 1, "A zone [zone] vault paid the wrong number of pieces") + var/list/seen = list() + var/stealth_pieces = 0 + for(var/obj/item/piece as anything in made) + if(crate.scav_vault_stealth_loot()[piece.type]) + stealth_pieces++ + continue + TEST_ASSERT(istype(piece, /obj/item/organ), "A vault paid [piece.type], which isn't chrome") + TEST_ASSERT(!seen[piece.type], "A vault paid [piece.type] twice") + seen[piece.type] = TRUE + TEST_ASSERT_EQUAL(piece.loc, crate, "A vault piece landed outside the crate") + TEST_ASSERT_EQUAL(stealth_pieces, 1, "A vault didn't pay one piece of stealth gear") + var/obj/structure/closet/crate/secure/scav_vault/locked = allocate(/obj/structure/closet/crate/secure/scav_vault, run_loc_floor_bottom_left) + TEST_ASSERT(locked.locked, "The vault crate isn't locked") + TEST_ASSERT("scav_vault" in locked.req_access, "The vault crate doesn't want the vault pass") + +/// The tip points at a registered den in the contested lanes, and a sealed den chart won't open while a den is out there. +/datum/unit_test/voidcrew_stealth_den_chart + +/datum/unit_test/voidcrew_stealth_den_chart/Run() + var/datum/map_template/ruin/space/template + for(var/template_name in SSmapping.space_ruins_templates) + var/datum/map_template/ruin/space/candidate = SSmapping.space_ruins_templates[template_name] + if(candidate.type == /datum/map_template/ruin/space/rare/scav_den) + template = candidate + TEST_ASSERT_NOTNULL(template, "The scav den template isn't registered") + TEST_ASSERT(template.width && template.height, "The scav den map didn't load its size") + TEST_ASSERT(template.unpickable, "The scav den can seed by itself") + TEST_ASSERT_EQUAL(/datum/shop_sku/ruin_chart/scav_den::spawn_zone, 2, "The den tip doesn't point at the contested lanes") + TEST_ASSERT_EQUAL(/datum/shop_sku/ruin_chart/scav_den::chart_type, /datum/rumor_chart/scav_den, "The den tip uploads a chart that ignores the one-den rule") + TEST_ASSERT_NULL(scav_den_on_map(), "A den is on the map before any was revealed") + var/obj/structure/overmap/space_ruin/den = allocate(/obj/structure/overmap/space_ruin, run_loc_floor_bottom_left) + den.set_ruin_template(template) + TEST_ASSERT_EQUAL(scav_den_on_map(), den, "A den on the map isn't found") + var/datum/rumor_chart/scav_den/chart = allocate(/datum/rumor_chart/scav_den) + chart.ruin_template_path = /datum/map_template/ruin/space/rare/scav_den + chart.spawn_zone = 2 + TEST_ASSERT_NULL(chart.reveal(null), "A second den opened while one was out there") + TEST_ASSERT(!chart.revealed, "A refused den chart was used up") + +/// The camera sees a person in its cone in light, not in the dark, not out of its cone, not through a wall, and lets a +/// scav disguise by; held on someone long enough it sounds the alarm, and the den's guard goes to look. +/datum/unit_test/voidcrew_stealth_live/den_camera + +/datum/unit_test/voidcrew_stealth_live/den_camera/Run() + TEST_ASSERT(make_room(11, 9), "No room for the test") + allocate(/obj/effect/landmark/stealth_group, at(0, 0)) + // Hung on the north wall, looking south. + var/obj/machinery/scav_camera/camera = allocate(/obj/machinery/scav_camera/directional/north, at(5, 8)) + var/turf/eye = get_turf(camera) + TEST_ASSERT_EQUAL(camera.aim, 180, "A camera hung on the north wall doesn't look south") + var/mob/living/carbon/human/person = person_at(5, 4) + TEST_ASSERT(camera.scav_cam_sees(person, eye), "The camera doesn't see a person in front of it") + GLOB.stealth_test_dark_turfs[get_turf(person)] = TRUE + TEST_ASSERT(!camera.scav_cam_sees(person, eye), "The camera sees a person standing in the dark") + GLOB.stealth_test_dark_turfs[get_turf(person)] = FALSE + person.forceMove(at(10, 7)) + TEST_ASSERT(!camera.scav_cam_sees(person, eye), "The camera sees a person off to its side") + person.forceMove(at(5, 4)) + var/turf/wall_spot = at(5, 6) + wall_spot.ChangeTurf(/turf/closed/wall) + TEST_ASSERT(!camera.scav_cam_sees(person, eye), "The camera sees through a wall") + wall_spot.ChangeTurf(/turf/open/floor/iron) + GLOB.stealth_test_dark_turfs[wall_spot] = FALSE + var/obj/item/clothing/under/syndicate/scav/fatigues = allocate(/obj/item/clothing/under/syndicate/scav) + var/obj/item/clothing/mask/balaclava/scav/mask = allocate(/obj/item/clothing/mask/balaclava/scav) + var/obj/item/clothing/under/own_clothes = person.w_uniform + if(own_clothes) + person.temporarilyRemoveItemFromInventory(own_clothes, force = TRUE) + person.equip_to_slot_if_possible(fatigues, ITEM_SLOT_ICLOTHING, disable_warning = TRUE) + person.equip_to_slot_if_possible(mask, ITEM_SLOT_MASK, disable_warning = TRUE) + var/datum/component/stealth_disguise/cache = stealth_disguise_cache(person) + cache.refresh() + TEST_ASSERT(!camera.scav_cam_sees(person, eye), "The camera doesn't let a scav disguise by") + person.temporarilyRemoveItemFromInventory(mask, force = TRUE) + cache.refresh() + TEST_ASSERT(camera.scav_cam_sees(person, eye), "The camera lets fatigues alone by") + + // The alarm. + var/mob/living/carbon/human/npc/guard = guard_at(1, 1, WEST) + var/datum/ai_controller/basic_controller/human_npc/stealth/guard_ai = wake(guard) + sleep(1 SECONDS) + TEST_ASSERT_EQUAL(guard_ai.stealth_state(), "unaware", "The guard isn't unaware before the alarm") + person.forceMove(at(5, 4)) + for(var/tick in 1 to 15) + camera.process(0.2) + if(camera.cam_state == 3) + break + TEST_ASSERT_EQUAL(camera.cam_state, 3, "Two seconds in plain view didn't sound the camera's alarm") + var/deadline = world.time + 5 SECONDS + while(guard_ai.stealth_state() == "unaware" && world.time < deadline) + sleep(1) + TEST_ASSERT(guard_ai.stealth_state() != "unaware", "The den's guard didn't answer the camera's alarm") + + // An EMP shuts it off and hides its cone. + camera.emp_act(EMP_LIGHT) + TEST_ASSERT_EQUAL(camera.cam_state, 4, "An EMP didn't shut the camera off") + TEST_ASSERT_EQUAL(camera.cone.alpha, 0, "An EMP'd camera still shows its cone") From 811d72560e077b9d54f3003a6c3f86f166dc859f Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 06:51:47 -0800 Subject: [PATCH 58/78] A destroyed garrotte lets go of the neck --- voidcrew/modules/stealth/stealth_takedown.dm | 7 ++++++- .../modules/unit_tests/voidcrew_stealth_takedown.dm | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/voidcrew/modules/stealth/stealth_takedown.dm b/voidcrew/modules/stealth/stealth_takedown.dm index 0e40f06ba36..1ab6521860e 100644 --- a/voidcrew/modules/stealth/stealth_takedown.dm +++ b/voidcrew/modules/stealth/stealth_takedown.dm @@ -116,7 +116,7 @@ RegisterSignals(attacker, list(COMSIG_QDELETING, COMSIG_LIVING_DEATH), PROC_REF(on_gone)) RegisterSignal(victim, COMSIG_QDELETING, PROC_REF(on_gone)) if(wire) - RegisterSignal(wire, COMSIG_QDELETING, PROC_REF(on_gone)) + RegisterSignal(wire, COMSIG_QDELETING, PROC_REF(on_wire_gone)) /datum/stealth_takedown/Destroy() if(!ended) @@ -130,6 +130,11 @@ SIGNAL_HANDLER end(FALSE) +/// The wire is gone, so the hold on the neck goes with it. +/datum/stealth_takedown/proc/on_wire_gone(datum/source) + SIGNAL_HANDLER + end(TRUE) + /// The wind-up, then the hold closes. Runs async. /datum/stealth_takedown/proc/start() var/garrotte = kind == STEALTH_TAKEDOWN_GARROTTE diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_takedown.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_takedown.dm index 7aaebe46de7..cac26a1ee66 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_takedown.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_takedown.dm @@ -98,6 +98,16 @@ TEST_ASSERT(QDELETED(other_hold), "Letting go didn't end the garrotte") TEST_ASSERT(!HAS_TRAIT_FROM(second, TRAIT_MUTE, "stealth_takedown"), "The mute stayed after letting go") TEST_ASSERT_NULL(strangler.stealth_takedown_doing, "The garroter is still marked busy") + // A wire that's destroyed lets go too. + var/mob/living/carbon/human/npc/third = d45_bare_guard(block, 7, 3) + var/mob/living/carbon/human/cutter = stealth_person(block, 6, 3) + var/obj/item/garrotte/third_wire = takedown_garrotte(cutter) + var/datum/stealth_takedown/third_hold = new(cutter, third, "garrotte", third_wire) + TEST_ASSERT(third_hold.close(), "The third garrotte didn't close") + qdel(third_wire) + TEST_ASSERT(QDELETED(third_hold), "A destroyed garrotte didn't end the hold") + TEST_ASSERT_NULL(cutter.pulling, "A destroyed garrotte still holds him") + TEST_ASSERT(!HAS_TRAIT_FROM(third, TRAIT_MUTE, "stealth_takedown"), "The mute stayed after the wire was destroyed") /// The chokehold puts him out and lets go by itself, alive; a helmet slows the garrotte. /datum/unit_test/voidcrew_stealth_takedown_choke From 04ebf6b25991f6dfd85222cf62e7009dff703d03 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 06:54:26 -0800 Subject: [PATCH 59/78] A scav den nobody docks at within an hour leaves the overmap and frees the den slot --- voidcrew/modules/stealth/scav_den.dm | 16 ++++++++++++++-- .../modules/unit_tests/voidcrew_stealth_den.dm | 4 ++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/voidcrew/modules/stealth/scav_den.dm b/voidcrew/modules/stealth/scav_den.dm index 3afb5811a82..cbefd9a51e4 100644 --- a/voidcrew/modules/stealth/scav_den.dm +++ b/voidcrew/modules/stealth/scav_den.dm @@ -5,7 +5,8 @@ * it never seeds by itself, and the only road to it is a rumor chart bought from an outpost trader and revealed from * the helm (rumor_charts.dm), like every other named tip. One den is on the overmap at a time: while one is out there * the tip is off the shelf and a sealed chart can't be revealed (it stays sealed and can be revealed once that den is - * cleaned out). + * cleaned out). A den nobody docks at within an hour of its reveal leaves the overmap, so an unvisited one can't hold + * the slot all round. * * The den's guards are the stealth guards of scav_guards.dm with names of their own, so their friends can call them * by name on the radio and over a body. Their skill comes from the den's zone (decision 38): a den revealed in the @@ -56,7 +57,18 @@ /datum/rumor_chart/scav_den/reveal(obj/structure/overmap/ship/ship) if(scav_den_on_map()) return null - return ..() + . = ..() + if(.) + // A den nobody ever flies to would hold the one-den slot for the round: the scavs move on. + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(scav_den_move_on), WEAKREF(.)), 60 MINUTES) + +/// Takes a revealed den off the overmap if nobody has docked at it (its interior was never built) in the hour since. +/proc/scav_den_move_on(datum/weakref/den_ref) + var/obj/structure/overmap/space_ruin/den = den_ref?.resolve() + if(QDELETED(den) || den.mapzone || den.loading || den.loaded) + return + log_mapping("Scav den '[den.name]' at ([den.x], [den.y]) was never visited and moved on.") + qdel(den) // ===== Guards with names ===== diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_den.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_den.dm index df84caba970..fdd84fb47b9 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_den.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_den.dm @@ -67,6 +67,10 @@ chart.spawn_zone = 2 TEST_ASSERT_NULL(chart.reveal(null), "A second den opened while one was out there") TEST_ASSERT(!chart.revealed, "A refused den chart was used up") + // Nobody docked within the hour: it leaves and frees the slot. + scav_den_move_on(WEAKREF(den)) + TEST_ASSERT(QDELETED(den), "An unvisited den stayed on the overmap") + TEST_ASSERT_NULL(scav_den_on_map(), "A den that moved on still holds the slot") /// The camera sees a person in its cone in light, not in the dark, not out of its cone, not through a wall, and lets a /// scav disguise by; held on someone long enough it sounds the alarm, and the den's guard goes to look. From 988edf2482f1e8f35c136289582ab1177beb8cc7 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 07:18:08 -0800 Subject: [PATCH 60/78] Contracts can't hold a scav den on the chart, and the den's crawlways get red work lights --- .../RandomRuins/SpaceRuins/rare_scav_den.dmm | 2369 +++++++++-------- voidcrew/modules/stealth/scav_den.dm | 10 +- .../unit_tests/voidcrew_stealth_den.dm | 3 + 3 files changed, 1206 insertions(+), 1176 deletions(-) diff --git a/_maps/voidcrew/RandomRuins/SpaceRuins/rare_scav_den.dmm b/_maps/voidcrew/RandomRuins/SpaceRuins/rare_scav_den.dmm index 0c6e00ff074..8bc482030f7 100644 --- a/_maps/voidcrew/RandomRuins/SpaceRuins/rare_scav_den.dmm +++ b/_maps/voidcrew/RandomRuins/SpaceRuins/rare_scav_den.dmm @@ -287,21 +287,13 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "bg" = ( -/obj/item/dice/d6{ - pixel_x = 6 - }, -/obj/effect/decal/cleanable/dirt/dust, +/obj/effect/spawner/random/trash/cigbutt, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "bh" = ( -/obj/structure/rack, -/obj/item/coin/gold{ - pixel_x = -5 - }, -/obj/item/coin/silver{ - pixel_x = 5; - pixel_y = 4 - }, +/obj/machinery/light/small/directional/north, +/obj/structure/closet/crate/secure/scav_vault, +/obj/effect/turf_decal/bot, /turf/open/floor/iron/dark/smooth_large, /area/ruin/space/has_grav/powered) "bk" = ( @@ -313,21 +305,19 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "bn" = ( -/obj/structure/rack, -/obj/item/storage/briefcase{ - pixel_y = 4 - }, -/obj/effect/turf_decal/bot, -/turf/open/floor/iron/dark/smooth_large, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "br" = ( -/obj/machinery/light/small/directional/north, -/obj/structure/closet/crate/secure/scav_vault, -/obj/effect/turf_decal/bot, -/turf/open/floor/iron/dark/smooth_large, +/obj/structure/chair/wood{ + dir = 1 + }, +/obj/effect/spawner/random/trash/cigbutt, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "bu" = ( -/obj/machinery/light/small/broken/directional/west, +/obj/effect/decal/cleanable/dirt/dust, +/obj/item/cigbutt, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "bv" = ( @@ -337,30 +327,31 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "bw" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/landmark/stealth_patrol{ - route = "d"; - order = 2; - facing = 1 +/obj/structure/table, +/obj/item/toy/cards/deck{ + pixel_y = 4 }, -/obj/effect/spawner/human_npc/ruin/scav/den/gunner{ - dir = 1 +/obj/item/reagent_containers/cup/glass/bottle/vodka{ + pixel_x = -8; + pixel_y = 8 }, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "cg" = ( -/obj/structure/bed/maint, -/obj/item/bedsheet/brown, /obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "ch" = ( -/obj/machinery/light/cold/directional/south, -/obj/effect/decal/cleanable/dirt, -/turf/open/floor/iron/white, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "cj" = ( -/obj/machinery/light/small/directional/east, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 3; + wait = 0 + }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "ck" = ( @@ -368,47 +359,56 @@ dir = 4 }, /obj/effect/decal/cleanable/dirt, +/obj/machinery/light/small/red/dim/directional/west, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "cq" = ( -/obj/effect/turf_decal/tile/red/full, +/obj/item/storage/backpack/duffelbag, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "ct" = ( +/obj/machinery/light/cold/dim/directional/north, /obj/structure/closet/crate/freezer, -/obj/item/food/meat/slab/human, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "cv" = ( -/obj/structure/closet/crate, -/obj/effect/turf_decal/bot, -/obj/effect/spawner/random/maintenance, -/obj/effect/decal/cleanable/dirt, -/turf/open/floor/iron/dark, +/obj/effect/decal/remains/human, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "cL" = ( -/obj/item/bodybag, -/obj/effect/decal/cleanable/dirt, -/turf/open/floor/iron/freezer, +/obj/effect/decal/cleanable/cobweb, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "dd" = ( -/obj/effect/decal/cleanable/blood/tracks{ - dir = 1 - }, -/turf/open/floor/iron/dark, +/obj/structure/kitchenspike, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "de" = ( -/obj/effect/decal/cleanable/cobweb/cobweb2, +/obj/effect/decal/cleanable/dirt/dust, +/obj/machinery/light/small/red/directional/south, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "df" = ( -/obj/item/ammo_box/magazine/m9mm, -/obj/effect/decal/cleanable/dirt, +/obj/item/storage/belt/utility, +/obj/effect/decal/cleanable/dirt/dust, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "dq" = ( -/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, -/obj/effect/decal/cleanable/blood/oil, +/obj/structure/table, +/obj/item/multitool{ + pixel_x = -4 + }, +/obj/item/stack/cable_coil{ + pixel_x = 6 + }, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"dA" = ( +/obj/structure/closet/crate/wooden, +/obj/effect/spawner/random/food_or_drink/booze, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "dB" = ( @@ -416,14 +416,13 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "dJ" = ( -/obj/effect/decal/cleanable/dirt, -/obj/effect/decal/cleanable/blood/drip, +/obj/structure/closet/crate, +/obj/item/bodypart/leg/left/robot, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "dO" = ( -/obj/structure/chair/stool, -/obj/effect/spawner/random/trash/cigbutt, -/turf/open/floor/plating, +/obj/machinery/light/small/directional/east, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "dR" = ( /obj/effect/turf_decal/bot, @@ -431,19 +430,16 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "dS" = ( -/obj/structure/chair/wood{ - dir = 1 - }, +/obj/effect/landmark/stealth_restricted, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "eg" = ( -/obj/structure/sink/directional/south, -/obj/effect/decal/cleanable/blood/old, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "em" = ( -/obj/structure/closet/crate/bin, -/obj/effect/spawner/random/trash/garbage, +/obj/item/ammo_box/magazine/m9mm, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "eO" = ( @@ -451,18 +447,26 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "eW" = ( -/obj/effect/spawner/random/food_or_drink/cups, +/obj/effect/decal/cleanable/dirt, +/obj/structure/table, +/obj/effect/spawner/random/food_or_drink/dinner, +/obj/item/kitchen/fork{ + pixel_x = -8 + }, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "fa" = ( -/obj/effect/turf_decal/stripes/line{ - dir = 2 +/obj/structure/rack, +/obj/item/storage/briefcase{ + pixel_y = 4 }, +/obj/effect/turf_decal/bot, /turf/open/floor/iron/dark/smooth_large, /area/ruin/space/has_grav/powered) "fE" = ( -/obj/structure/closet/crate/zone_loot/medical, -/turf/open/floor/iron/freezer, +/obj/effect/decal/cleanable/dirt/dust, +/obj/effect/decal/cleanable/cobweb/cobweb2, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "fK" = ( /obj/item/restraints/handcuffs/cable/zipties, @@ -470,16 +474,15 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "fN" = ( -/obj/structure/chair{ - dir = 4 - }, -/obj/effect/spawner/random/trash/cigbutt, -/turf/open/floor/iron/dark, +/obj/machinery/light/small/red/dim/directional/north, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "fS" = ( -/obj/effect/decal/cleanable/dirt/dust, -/obj/item/cigbutt, -/turf/open/floor/plating/rust, +/obj/machinery/light/small/red/dim/directional/north, +/obj/effect/turf_decal/stripes/line{ + dir = 4 + }, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "ga" = ( /obj/effect/turf_decal/tile/red/full, @@ -489,69 +492,84 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "gu" = ( -/obj/effect/decal/cleanable/blood/splatter, -/obj/effect/spawner/human_npc/ruin/scav/den{ +/obj/effect/decal/cleanable/blood/drip, +/obj/effect/decal/cleanable/blood/tracks{ dir = 8 }, -/turf/open/floor/iron/white, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "gG" = ( -/obj/machinery/light/cold/directional/north, +/obj/machinery/computer/operating{ + dir = 2 + }, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "ha" = ( -/obj/structure/closet/crate/wooden, -/obj/effect/turf_decal/bot, -/turf/open/floor/iron/dark, +/obj/item/trash/chips, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "hg" = ( -/obj/effect/decal/cleanable/blood/gibs/robot_debris/limb, -/obj/effect/decal/cleanable/blood/oil, +/obj/structure/table, +/obj/item/knife/butcher{ + pixel_y = 5 + }, +/obj/item/stack/spacecash/c200{ + pixel_x = -6; + pixel_y = -4 + }, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "hi" = ( -/obj/structure/closet/crate/freezer/blood, +/obj/effect/turf_decal/tile/red/full, /obj/effect/decal/cleanable/dirt/dust, -/turf/open/floor/iron/white, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"ht" = ( +/obj/structure/bed/maint, +/obj/item/bedsheet/brown, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "hI" = ( -/obj/structure/closet/crate, -/obj/effect/turf_decal/bot, -/obj/effect/spawner/random/entertainment/money_small, -/turf/open/floor/iron/dark, +/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, +/obj/effect/decal/cleanable/blood/oil, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "hJ" = ( -/obj/item/bedsheet/brown, -/obj/effect/decal/cleanable/blood/drip, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 1 + }, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "hL" = ( -/obj/structure/chair/office{ - dir = 2 - }, -/obj/effect/spawner/human_npc/ruin/scav/den/boss{ - dir = 2 - }, -/turf/open/floor/carpet/red, +/obj/machinery/scav_camera/directional/south, +/turf/open/floor/iron/dark/smooth_large, /area/ruin/space/has_grav/powered) "hN" = ( -/obj/effect/spawner/random/maintenance/two, -/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, -/turf/open/floor/plating/rust, +/obj/item/clothing/shoes/sneakers/black, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "hO" = ( -/obj/effect/spawner/random/trash/cigbutt, -/turf/open/floor/iron/dark, +/obj/effect/turf_decal/tile/red/full, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "hW" = ( +/obj/machinery/light/small/directional/west, /obj/effect/decal/cleanable/blood/tracks{ - dir = 8 + dir = 1 }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "ic" = ( -/obj/machinery/light/small/red/dim/directional/south, -/turf/open/floor/plating, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt/dust, +/obj/effect/landmark/stealth_patrol{ + route = "e"; + order = 4; + wait = 0 + }, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "ik" = ( /obj/effect/decal/cleanable/dirt, @@ -561,56 +579,67 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "iz" = ( -/obj/structure/reagent_dispensers/beerkeg, +/obj/structure/table, +/obj/effect/spawner/random/food_or_drink/booze, +/obj/item/reagent_containers/cup/glass/drinkingglass{ + pixel_x = 8 + }, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "iU" = ( -/obj/effect/decal/cleanable/blood/old, -/obj/effect/decal/cleanable/blood/gibs/old, +/obj/effect/spawner/human_npc/ruin/scav/den/lookout{ + dir = 8 + }, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "jj" = ( +/obj/structure/table/optable, +/obj/effect/mob_spawn/corpse/human, /obj/effect/decal/cleanable/blood/splatter, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "jo" = ( -/obj/effect/spawner/random/trash/garbage, -/obj/effect/decal/cleanable/blood/tracks{ - dir = 8 - }, -/turf/open/floor/iron/dark, -/area/ruin/space/has_grav/powered) -"jA" = ( -/obj/structure/table, -/obj/item/restraints/handcuffs/cable/zipties{ - pixel_x = -5 +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 1; + facing = 8 }, -/obj/item/reagent_containers/cup/glass/mug{ - pixel_x = 6; - pixel_y = 4 +/obj/effect/spawner/human_npc/ruin/scav/den/gunner{ + dir = 8 }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"jA" = ( +/obj/effect/decal/cleanable/vomit/old, +/obj/item/reagent_containers/cup/bucket, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "jE" = ( -/obj/structure/chair/wood{ - dir = 1 +/obj/structure/chair/office{ + dir = 2 }, -/obj/effect/spawner/random/trash/cigbutt, -/turf/open/floor/wood, +/obj/effect/spawner/human_npc/ruin/scav/den/boss{ + dir = 2 + }, +/turf/open/floor/carpet/red, /area/ruin/space/has_grav/powered) "kt" = ( +/obj/machinery/light/small/red/directional/south, /obj/effect/decal/cleanable/dirt, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "kw" = ( -/obj/machinery/light/small/directional/south, +/obj/effect/spawner/random/trash/garbage, /obj/effect/decal/cleanable/blood/tracks{ dir = 8 }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "ky" = ( -/obj/machinery/light/small/red/dim/directional/north, +/obj/structure/chair/stool, +/obj/effect/spawner/random/trash/cigbutt, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "kL" = ( @@ -621,11 +650,11 @@ /area/ruin/space/has_grav/powered) "kM" = ( /obj/structure/table, -/obj/item/multitool{ - pixel_x = -4 +/obj/item/bodypart/arm/left/robot{ + pixel_y = 4 }, -/obj/item/stack/cable_coil{ - pixel_x = 6 +/obj/item/screwdriver{ + pixel_x = 8 }, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) @@ -635,11 +664,11 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "kS" = ( -/obj/item/reagent_containers/cup/glass/bottle/beer{ - pixel_x = -6; - pixel_y = 4 +/obj/structure/table, +/obj/effect/spawner/random/food_or_drink/snack, +/obj/item/reagent_containers/cup/glass/mug{ + pixel_x = -6 }, -/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "kW" = ( @@ -649,15 +678,14 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "li" = ( -/obj/item/reagent_containers/blood/o_minus{ - pixel_x = 5 - }, +/obj/effect/decal/cleanable/blood/old, /obj/effect/decal/cleanable/blood/drip, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "lp" = ( -/obj/effect/spawner/random/structure/chair_flipped, -/turf/open/floor/iron/dark, +/obj/effect/decal/cleanable/blood/old, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "lB" = ( /obj/structure/closet/crate/internals, @@ -665,88 +693,73 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "lC" = ( -/obj/machinery/light/small/directional/south, -/turf/open/floor/iron/dark, +/obj/structure/table, +/obj/item/restraints/handcuffs/cable/zipties{ + pixel_x = -5 + }, +/obj/item/reagent_containers/cup/glass/mug{ + pixel_x = 6; + pixel_y = 4 + }, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "lY" = ( -/obj/item/clothing/under/color/grey, /obj/effect/decal/cleanable/dirt, -/turf/open/floor/iron/grimy, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "mt" = ( -/obj/structure/closet, -/obj/item/storage/medkit/regular, +/obj/effect/spawner/random/trash/garbage, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "mu" = ( -/obj/structure/sign/warning/no_smoking, -/turf/closed/wall, +/obj/effect/landmark/stealth_group, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "mC" = ( -/obj/structure/table, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = -5; - pixel_y = 6 - }, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = 6; - pixel_y = 4 - }, -/obj/item/reagent_containers/cup/bottle/formaldehyde{ - pixel_y = -5 - }, -/turf/open/floor/iron/freezer, +/obj/effect/spawner/random/structure/chair_flipped, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "mG" = ( -/obj/effect/spawner/random/trash/cigbutt, +/obj/effect/turf_decal/tile/red/full, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "mS" = ( -/obj/structure/table, -/obj/machinery/microwave{ - pixel_y = 6 - }, +/obj/structure/closet/secure_closet/freezer/fridge, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "mW" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/landmark/stealth_patrol{ - route = "e"; - order = 3; - facing = 4 - }, -/obj/effect/spawner/human_npc/ruin/scav/den/lookout{ - dir = 4 - }, -/turf/open/floor/iron/dark, +/obj/effect/decal/remains/robot, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "nz" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/spawner/random/trash/garbage, -/obj/effect/landmark/stealth_patrol{ - route = "e"; - order = 2; - wait = 0 +/obj/structure/rack, +/obj/item/bodypart/arm/left/robot, +/obj/item/bodypart/arm/right/robot{ + pixel_y = 6 }, -/turf/open/floor/iron/dark, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "nJ" = ( -/obj/effect/spawner/human_npc/ruin/scav/den/lookout{ - dir = 8 - }, -/turf/open/floor/plating, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "nL" = ( /obj/effect/turf_decal/tile/red/full, /obj/effect/decal/cleanable/dirt, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 5; + wait = 0 + }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "nV" = ( -/obj/machinery/door/airlock{ - name = "Bunks"; - req_one_access = list("scav") +/obj/item/clothing/head/soft/black{ + pixel_y = 6 }, -/obj/effect/turf_decal/tile/red/full, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "oq" = ( @@ -758,8 +771,9 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "oD" = ( +/obj/effect/decal/cleanable/dirt, /obj/effect/decal/cleanable/blood/tracks{ - dir = 4 + dir = 1 }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) @@ -770,55 +784,70 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "oQ" = ( -/obj/item/stack/medical/suture, -/obj/effect/decal/cleanable/blood/old, +/obj/structure/rack, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = -6; + pixel_y = 6 + }, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = 6; + pixel_y = 6 + }, +/obj/item/reagent_containers/cup/bottle/formaldehyde{ + pixel_x = 2; + pixel_y = -4 + }, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "oS" = ( -/obj/structure/closet/crate/freezer, -/obj/item/reagent_containers/blood/random, +/obj/item/reagent_containers/syringe{ + pixel_x = 6; + pixel_y = 6 + }, +/obj/effect/decal/cleanable/blood/old, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "oW" = ( -/obj/effect/decal/cleanable/dirt, -/obj/item/trash/chips, +/obj/effect/spawner/random/trash/garbage, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) +"oX" = ( +/obj/item/flashlight/flare, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) "oY" = ( -/obj/item/clothing/shoes/sneakers/black, -/obj/effect/decal/cleanable/blood/old, +/obj/structure/closet, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "pb" = ( -/obj/effect/spawner/human_npc/ruin/scav/den{ - dir = 8 - }, +/obj/structure/reagent_dispensers/beerkeg, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "pc" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/decal/cleanable/blood/drip, -/turf/open/floor/iron/dark, +/obj/structure/table, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = -4; + pixel_y = 6 + }, +/obj/item/clothing/mask/surgical{ + pixel_x = 6; + pixel_y = -4 + }, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "ph" = ( -/obj/item/radio{ - pixel_x = -4 - }, +/obj/machinery/light/small/dim/directional/north, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "pk" = ( -/obj/machinery/light/cold/dim/directional/south, -/turf/open/floor/iron/freezer, +/obj/effect/spawner/random/trash/graffiti, +/turf/closed/wall, /area/ruin/space/has_grav/powered) "pq" = ( -/obj/structure/table, -/obj/item/circular_saw{ - pixel_y = 4 - }, -/obj/item/cautery{ - pixel_x = 6; - pixel_y = -4 - }, +/obj/structure/sink/directional/south, +/obj/effect/decal/cleanable/blood/old, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "pz" = ( @@ -828,37 +857,43 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "pC" = ( -/obj/machinery/light/cold/dim/directional/north, -/obj/structure/closet/crate/freezer, +/obj/effect/spawner/random/trash/garbage, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "pZ" = ( -/obj/effect/decal/cleanable/blood/old, -/obj/item/food/meat/slab/human{ - pixel_x = -4 +/obj/structure/table, +/obj/item/organ/liver/cybernetic{ + pixel_x = -4; + pixel_y = 5 + }, +/obj/item/organ/lungs/cybernetic{ + pixel_x = 5; + pixel_y = -2 }, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "qf" = ( -/obj/effect/decal/remains/robot, -/turf/open/floor/plating/rust, +/obj/effect/decal/cleanable/blood/old, +/obj/effect/decal/cleanable/blood/gibs/old, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "qh" = ( -/obj/item/stack/rods{ - amount = 2 - }, -/turf/open/floor/plating/rust, +/obj/structure/closet/crate, +/obj/effect/turf_decal/bot, +/obj/effect/spawner/random/entertainment/money_small, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "qt" = ( /obj/structure/table, -/obj/effect/spawner/random/food_or_drink/booze, -/obj/item/reagent_containers/cup/glass/drinkingglass{ - pixel_x = 8 +/obj/machinery/microwave{ + pixel_y = 6 }, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "qC" = ( -/obj/effect/decal/cleanable/dirt, +/obj/structure/chair/wood{ + dir = 1 + }, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "qO" = ( @@ -866,124 +901,132 @@ /turf/closed/wall, /area/ruin/space/has_grav/powered) "qP" = ( -/obj/item/trash/chips, -/obj/effect/decal/cleanable/dirt, +/obj/effect/spawner/random/trash/cigbutt, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "qZ" = ( -/obj/machinery/light/small/dim/directional/north, +/obj/item/dice/d6{ + pixel_x = 6 + }, +/obj/effect/decal/cleanable/dirt/dust, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "rc" = ( -/obj/machinery/scav_camera/directional/south, -/turf/open/floor/iron/dark/smooth_large, +/turf/open/floor/carpet/red, /area/ruin/space/has_grav/powered) "rd" = ( -/obj/structure/closet/crate, -/obj/item/bodypart/leg/left/robot, +/obj/effect/spawner/random/structure/crate_abandoned, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "re" = ( -/obj/structure/sign/warning/biohazard, -/turf/closed/wall, +/obj/effect/decal/remains/human, +/obj/effect/decal/cleanable/blood/old, +/obj/item/flashlight{ + pixel_x = 6 + }, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "rg" = ( -/obj/structure/reagent_dispensers/water_cooler, +/obj/structure/table, +/obj/effect/spawner/random/food_or_drink/booze, +/obj/item/stack/spacecash/c50{ + pixel_x = 4; + pixel_y = -4 + }, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "ro" = ( -/obj/effect/decal/cleanable/cobweb, +/obj/structure/bed/maint, +/obj/effect/spawner/random/bedsheet, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "rq" = ( -/obj/effect/decal/cleanable/blood/tracks{ - dir = 8 - }, -/turf/open/floor/iron/freezer, +/obj/machinery/light/small/broken/directional/north, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "rs" = ( -/obj/structure/chair/stool, +/obj/effect/decal/cleanable/dirt, +/obj/item/trash/chips, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "rF" = ( -/obj/effect/spawner/random/trash/food_packaging, -/turf/open/floor/iron/cafeteria, +/obj/structure/closet, +/obj/effect/spawner/random/maintenance, +/turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "rJ" = ( -/obj/effect/spawner/random/structure/crate_abandoned, -/turf/open/floor/plating/rust, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/spawner/random/trash/garbage, +/obj/effect/landmark/stealth_patrol{ + route = "e"; + order = 2; + wait = 0 + }, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "rK" = ( -/obj/structure/table/wood, -/obj/item/flashlight/lamp/green{ - pixel_x = -4; - pixel_y = 6 - }, -/turf/open/floor/carpet/red, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/iron/dark/smooth_large, /area/ruin/space/has_grav/powered) "sf" = ( -/obj/structure/closet/cabinet, +/obj/effect/decal/cleanable/cobweb/cobweb2, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "sh" = ( +/obj/item/bodybag, /obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "sq" = ( -/obj/structure/closet/crate/freezer, +/obj/item/clothing/suit/apron/surgical{ + pixel_y = -4 + }, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "sH" = ( -/obj/effect/decal/cleanable/cobweb, -/turf/open/floor/plating, +/obj/structure/displaycase/noalert, +/turf/open/floor/iron/dark/smooth_large, /area/ruin/space/has_grav/powered) "sZ" = ( -/obj/effect/decal/remains/human, -/obj/effect/decal/cleanable/blood/old, -/turf/open/floor/plating, +/obj/machinery/scav_camera/directional/north, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "th" = ( -/obj/machinery/light/small/directional/north, -/turf/open/floor/iron/dark, +/obj/item/bedsheet/brown, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "tk" = ( -/obj/structure/kitchenspike, -/obj/effect/decal/cleanable/blood/old, -/obj/effect/decal/cleanable/blood/gibs/old, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 8 + }, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "tn" = ( /obj/effect/turf_decal/tile/red/full, /obj/effect/decal/cleanable/dirt, -/obj/effect/landmark/stealth_patrol{ - route = "a"; - order = 2; - wait = 0 - }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "tx" = ( -/obj/effect/decal/cleanable/blood/drip, -/obj/effect/decal/cleanable/blood/tracks{ - dir = 8 - }, -/turf/open/floor/iron/dark, +/obj/effect/decal/cleanable/blood/splatter, +/turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "tD" = ( -/obj/machinery/scav_camera/directional/south, -/obj/effect/decal/cleanable/blood/tracks{ - dir = 1 +/obj/effect/decal/cleanable/blood/old, +/obj/item/food/meat/slab/human{ + pixel_x = -4 }, -/turf/open/floor/iron/dark, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "tH" = ( -/obj/effect/decal/cleanable/blood/tracks{ - dir = 1 +/obj/structure/chair{ + dir = 4 }, -/turf/open/floor/plating, +/obj/effect/spawner/random/trash/cigbutt, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "tO" = ( -/obj/effect/landmark/stealth_restricted, +/obj/machinery/light/small/directional/south, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "tR" = ( @@ -995,9 +1038,7 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "tT" = ( -/obj/structure/table/optable, -/obj/effect/decal/remains/human, -/obj/effect/decal/cleanable/blood/gibs/old, +/obj/effect/decal/cleanable/blood/drip, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "ub" = ( @@ -1017,12 +1058,14 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "uf" = ( -/obj/effect/decal/cleanable/dirt, -/obj/effect/spawner/random/trash/cigbutt, -/turf/open/floor/iron/dark, +/obj/item/reagent_containers/blood/o_minus{ + pixel_x = 5 + }, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "uj" = ( -/obj/structure/bookcase/random, +/obj/item/kirbyplants/random, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "us" = ( @@ -1030,18 +1073,8 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "uu" = ( -/obj/structure/rack, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = -6; - pixel_y = 6 - }, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = 6; - pixel_y = 6 - }, -/obj/item/reagent_containers/cup/bottle/formaldehyde{ - pixel_x = 2; - pixel_y = -4 +/obj/effect/decal/cleanable/blood/tracks{ + dir = 4 }, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) @@ -1051,113 +1084,86 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "vh" = ( -/obj/machinery/iv_drip, -/obj/effect/decal/cleanable/blood/old, +/obj/structure/table, +/obj/item/surgicaldrill{ + pixel_y = 3 + }, +/obj/item/clothing/gloves/latex{ + pixel_x = -6; + pixel_y = -5 + }, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "vE" = ( -/obj/item/bedsheet/brown, -/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/remains/human, +/obj/effect/decal/cleanable/blood/splatter, +/obj/item/restraints/handcuffs/cable/zipties, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "vH" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/landmark/stealth_patrol{ - route = "a"; - order = 3; - wait = 0 - }, -/turf/open/floor/iron/dark, +/obj/structure/closet/crate/zone_loot/medical, +/turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "vI" = ( /obj/effect/turf_decal/tile/red/full, -/obj/effect/decal/cleanable/dirt, -/obj/effect/landmark/stealth_patrol{ - route = "a"; - order = 1; - facing = 8 - }, -/obj/effect/spawner/human_npc/ruin/scav/den/gunner{ - dir = 8 - }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "vO" = ( -/obj/machinery/light/small/directional/west, /obj/effect/decal/cleanable/blood/tracks{ dir = 1 }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "vX" = ( -/obj/structure/displaycase/noalert, -/turf/open/floor/iron/dark/smooth_large, +/obj/item/stack/spacecash/c20{ + pixel_x = 4 + }, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "vY" = ( -/obj/effect/spawner/random/trash/garbage, -/turf/open/floor/iron/dark, +/obj/effect/decal/cleanable/blood/old, +/obj/item/stack/medical/gauze{ + pixel_x = 4 + }, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "vZ" = ( -/obj/item/cigarette{ - pixel_x = 4; - pixel_y = 6 - }, +/obj/structure/filingcabinet, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "wg" = ( -/obj/item/reagent_containers/cup/glass/bottle/beer{ - pixel_x = 6 - }, -/obj/item/cigarette{ - pixel_x = -6 - }, +/obj/effect/decal/cleanable/cobweb, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "wF" = ( -/obj/structure/sign/poster/contraband/random, -/turf/closed/wall, +/obj/structure/closet/crate/freezer, +/obj/item/reagent_containers/blood/random, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "wR" = ( -/obj/structure/kitchenspike, -/obj/effect/decal/cleanable/blood/old, -/obj/effect/decal/cleanable/blood/gibs/old, +/obj/effect/decal/cleanable/dirt/dust, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "wW" = ( -/obj/structure/table, -/obj/item/organ/liver/cybernetic{ - pixel_x = -4; - pixel_y = 5 - }, -/obj/item/organ/lungs/cybernetic{ - pixel_x = 5; - pixel_y = -2 - }, +/obj/structure/kitchenspike, +/obj/effect/decal/cleanable/blood/old, +/obj/effect/decal/cleanable/blood/gibs/old, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "xm" = ( -/obj/item/reagent_containers/cup/glass/bottle/whiskey{ - pixel_x = 4; - pixel_y = -8 +/obj/item/storage/briefcase{ + pixel_x = -4 }, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "xp" = ( -/obj/item/flashlight/flare, +/obj/effect/spawner/random/entertainment/cigarette_pack, +/obj/effect/decal/cleanable/dirt/dust, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "xq" = ( -/obj/effect/decal/cleanable/blood/drip, -/turf/open/floor/iron/freezer, -/area/ruin/space/has_grav/powered) -"xt" = ( -/obj/effect/decal/cleanable/dirt, -/obj/effect/decal/cleanable/blood/tracks{ - dir = 1 - }, -/turf/open/floor/iron/dark, -/area/ruin/space/has_grav/powered) -"xz" = ( /obj/structure/table, /obj/item/organ/heart/cybernetic{ pixel_x = -5; @@ -1168,38 +1174,48 @@ }, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) -"xZ" = ( -/obj/structure/closet/crate/large, -/obj/effect/turf_decal/bot, -/turf/open/floor/plating, -/area/ruin/space/has_grav/powered) -"yj" = ( -/obj/effect/decal/cleanable/vomit/old, -/turf/open/floor/iron/freezer, -/area/ruin/space/has_grav/powered) +"xt" = ( +/obj/machinery/scav_camera/directional/south, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 1 + }, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"xz" = ( +/obj/structure/sign/warning/biohazard, +/turf/closed/wall, +/area/ruin/space/has_grav/powered) +"xZ" = ( +/obj/structure/closet/crate/large, +/obj/effect/turf_decal/bot, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"yj" = ( +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) "yr" = ( -/obj/structure/table/rolling, -/obj/item/surgical_drapes, -/obj/item/stack/medical/gauze, -/turf/open/floor/iron/freezer, +/obj/structure/sign/poster/contraband/random, +/turf/closed/wall, /area/ruin/space/has_grav/powered) "yw" = ( -/obj/effect/spawner/random/trash/garbage, +/obj/structure/closet/crate/freezer, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "yF" = ( -/obj/structure/closet/secure_closet/freezer/fridge, +/obj/effect/spawner/random/trash/food_packaging, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "yG" = ( -/obj/structure/closet/crate, -/obj/effect/spawner/random/maintenance/two, +/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, +/obj/effect/decal/cleanable/blood/oil, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "yQ" = ( -/obj/structure/closet/crate/wooden, -/obj/effect/spawner/random/food_or_drink/booze, -/obj/effect/spawner/random/food_or_drink/booze, +/obj/item/reagent_containers/cup/glass/bottle/rum{ + pixel_x = 6 + }, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "yR" = ( @@ -1207,15 +1223,15 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "zh" = ( -/obj/structure/rack, -/obj/item/stack/spacecash/c100{ - pixel_y = 4 +/obj/item/cigarette{ + pixel_x = 4; + pixel_y = 6 }, -/obj/effect/turf_decal/bot, -/turf/open/floor/iron/dark/smooth_large, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "zq" = ( -/obj/effect/spawner/random/trash/cigbutt, +/obj/item/clothing/under/color/grey, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "zw" = ( @@ -1228,24 +1244,19 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "zF" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/decal/cleanable/dirt, -/obj/effect/landmark/stealth_patrol{ - route = "a"; - order = 5; - wait = 0 +/obj/effect/decal/cleanable/blood/tracks{ + dir = 4 }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "zI" = ( -/obj/item/clothing/suit/apron/surgical, -/obj/effect/decal/cleanable/blood/drip, +/obj/structure/table/optable, +/obj/effect/decal/remains/human, +/obj/effect/decal/cleanable/blood/gibs/old, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "zZ" = ( -/obj/structure/closet/crate, -/obj/item/storage/box/lethalshot, -/obj/effect/spawner/random/contraband/narcotics, +/obj/effect/decal/cleanable/cobweb, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Ad" = ( @@ -1261,25 +1272,19 @@ /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "Be" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/landmark/stealth_patrol{ - route = "a"; - order = 4; - facing = 4 - }, -/turf/open/floor/iron/dark, +/obj/item/stack/medical/suture, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "Bf" = ( -/obj/effect/decal/cleanable/dirt, -/obj/structure/table, -/obj/effect/spawner/random/food_or_drink/dinner, -/obj/item/kitchen/fork{ - pixel_x = -8 - }, +/obj/item/trash/can, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "Bp" = ( -/obj/effect/decal/cleanable/dirt/dust, +/obj/item/reagent_containers/syringe{ + pixel_x = -5 + }, +/obj/effect/decal/cleanable/blood/drip, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "Br" = ( @@ -1290,34 +1295,19 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "BG" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/decal/cleanable/dirt, -/obj/effect/landmark/stealth_patrol{ - route = "e"; - order = 1; - facing = 1 - }, +/obj/machinery/light/small/directional/north, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "BU" = ( -/obj/structure/table, -/obj/item/bodypart/arm/right/robot{ - pixel_x = -3; - pixel_y = 3 - }, -/obj/item/weldingtool{ - pixel_x = 6; - pixel_y = -6 - }, -/turf/open/floor/plating, +/obj/structure/reagent_dispensers/water_cooler, +/turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "Ca" = ( -/obj/structure/closet/crate/freezer/blood, -/turf/open/floor/iron/freezer, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "CG" = ( -/obj/structure/bed/medical, -/obj/item/restraints/handcuffs/cable/zipties, +/obj/machinery/iv_drip, /obj/effect/decal/cleanable/blood/old, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) @@ -1326,8 +1316,9 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Do" = ( -/obj/machinery/computer/operating{ - dir = 2 +/obj/item/storage/box/bodybags, +/obj/item/storage/organbox{ + pixel_y = 8 }, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) @@ -1339,30 +1330,26 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Dx" = ( -/obj/effect/decal/cleanable/dirt/dust, -/turf/open/floor/iron/dark, +/obj/effect/decal/cleanable/cobweb, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "DE" = ( -/obj/effect/decal/cleanable/blood/old, -/obj/effect/decal/cleanable/blood/drip, -/turf/open/floor/iron/white, +/obj/structure/sign/warning/no_smoking, +/turf/closed/wall, /area/ruin/space/has_grav/powered) "DG" = ( -/obj/item/trash/can, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "DK" = ( -/obj/item/reagent_containers/cup/glass/bottle/rum{ - pixel_x = 6 - }, -/obj/effect/decal/cleanable/dirt, +/obj/structure/closet/cabinet, +/obj/item/clothing/head/fedora, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "DO" = ( -/obj/effect/decal/cleanable/blood/old, -/obj/item/stack/medical/gauze{ - pixel_x = 4 - }, +/obj/structure/table/rolling, +/obj/item/surgical_drapes, +/obj/item/stack/medical/gauze, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "DV" = ( @@ -1371,47 +1358,43 @@ /area/ruin/space/has_grav/powered) "DY" = ( /obj/effect/turf_decal/tile/red/full, -/obj/effect/decal/cleanable/dirt/dust, +/obj/effect/decal/cleanable/dirt, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 2; + wait = 0 + }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "Eh" = ( -/obj/structure/table, -/obj/item/wrench, -/obj/item/crowbar{ - pixel_y = 6 - }, -/turf/open/floor/plating, +/obj/machinery/light/warm/directional/east, +/turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "Eu" = ( -/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, +/obj/effect/decal/cleanable/dirt, +/obj/item/stack/sheet/plastic{ + amount = 5 + }, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Ev" = ( -/obj/structure/table, -/obj/effect/spawner/random/food_or_drink/booze, -/obj/item/stack/spacecash/c50{ - pixel_x = 4; - pixel_y = -4 +/obj/effect/spawner/human_npc/ruin/scav/den{ + dir = 8 }, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "EG" = ( -/obj/item/clothing/gloves/latex{ - pixel_x = 6 - }, -/obj/effect/decal/cleanable/blood/splatter, -/turf/open/floor/iron/white, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "ET" = ( -/obj/effect/spawner/random/trash/garbage, -/turf/open/floor/iron/cafeteria, +/obj/structure/closet, +/obj/item/storage/medkit/regular, +/turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "Fq" = ( -/obj/item/reagent_containers/syringe{ - pixel_x = 6; - pixel_y = 6 - }, -/obj/effect/decal/cleanable/blood/old, +/obj/structure/closet/crate/freezer/blood, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "Fy" = ( @@ -1419,43 +1402,26 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "FC" = ( -/obj/effect/decal/remains/human, -/obj/effect/decal/cleanable/blood/old, -/obj/item/flashlight{ - pixel_x = 6 - }, +/obj/machinery/light/small/red/directional/west, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "FH" = ( -/obj/structure/bed/maint, -/obj/effect/spawner/random/bedsheet, -/turf/open/floor/iron/grimy, +/obj/machinery/light/small/red/directional/east, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "FM" = ( -/obj/item/reagent_containers/syringe{ - pixel_x = -5 +/obj/machinery/light/small/directional/south, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 8 }, -/obj/effect/decal/cleanable/blood/drip, -/turf/open/floor/iron/white, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "FO" = ( /obj/effect/spawner/random/trash/garbage, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "Ge" = ( -/obj/structure/table, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = -6; - pixel_y = 5 - }, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = 6; - pixel_y = 7 - }, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = 0; - pixel_y = -3 - }, +/obj/effect/decal/cleanable/blood/old, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "Gh" = ( @@ -1464,23 +1430,42 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Gn" = ( -/obj/effect/decal/cleanable/dirt, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "d"; + order = 1; + facing = 4; + chatter = 1; + route_mode = "pingpong" + }, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "Gp" = ( -/obj/effect/decal/cleanable/blood/drip, +/obj/machinery/light/small/red/directional/east, +/obj/item/stack/rods{ + amount = 2 + }, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "Gv" = ( -/obj/structure/closet/crate/zone_loot/medical, +/obj/structure/bed/medical, +/obj/item/restraints/handcuffs/cable/zipties, +/obj/effect/decal/cleanable/blood/old, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "GE" = ( -/obj/item/stack/spacecash/c20{ +/obj/structure/table/wood, +/obj/item/stack/spacecash/c500{ pixel_x = 4 }, -/obj/effect/decal/cleanable/dirt/dust, -/turf/open/floor/wood, +/obj/item/pen{ + pixel_x = -6 + }, +/obj/item/folder/red{ + pixel_x = -8; + pixel_y = 4 + }, +/turf/open/floor/carpet/red, /area/ruin/space/has_grav/powered) "GH" = ( /obj/effect/spawner/random/structure/crate_abandoned, @@ -1488,82 +1473,101 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "GI" = ( -/obj/structure/table/wood, -/obj/item/reagent_containers/cup/glass/bottle/whiskey{ - pixel_y = 6 - }, -/obj/item/reagent_containers/cup/glass/drinkingglass{ - pixel_x = 8 - }, -/turf/open/floor/wood, +/obj/structure/closet/crate/bin, +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "GK" = ( -/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, -/obj/effect/decal/cleanable/blood/oil, -/turf/open/floor/plating/rust, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "e"; + order = 3; + facing = 4 + }, +/obj/effect/spawner/human_npc/ruin/scav/den/lookout{ + dir = 4 + }, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "GO" = ( -/obj/structure/chair/stool, -/turf/open/floor/iron/grimy, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "Hj" = ( -/obj/structure/table/wood, -/obj/item/stack/spacecash/c500{ - pixel_x = 4 - }, -/obj/item/pen{ - pixel_x = -6 - }, -/obj/item/folder/red{ - pixel_x = -8; - pixel_y = 4 +/obj/effect/turf_decal/stripes/line{ + dir = 2 }, -/turf/open/floor/carpet/red, +/turf/open/floor/iron/dark/smooth_large, /area/ruin/space/has_grav/powered) "Hp" = ( -/obj/effect/decal/cleanable/blood/old, +/obj/structure/closet/crate/freezer, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "Hq" = ( -/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 8 + }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "Ht" = ( -/obj/structure/kitchenspike, -/obj/effect/decal/cleanable/blood/drip, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "b"; + order = 1; + facing = 1; + route_mode = "pingpong" + }, +/obj/effect/spawner/human_npc/ruin/scav/den{ + dir = 1 + }, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "HH" = ( -/obj/machinery/light/small/broken/directional/north, -/turf/open/floor/iron/dark, +/obj/structure/kitchenspike, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "HM" = ( -/obj/effect/decal/cleanable/cobweb, +/obj/structure/closet/secure_closet/freezer/meat, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "HR" = ( -/obj/item/storage/backpack/duffelbag, -/obj/effect/decal/cleanable/dirt, +/obj/item/reagent_containers/cup/glass/bottle/beer{ + pixel_x = 6 + }, +/obj/item/cigarette{ + pixel_x = -6 + }, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "Ik" = ( /obj/structure/table, -/obj/effect/spawner/random/food_or_drink/snack, -/obj/item/reagent_containers/cup/glass/mug{ - pixel_x = -6 +/obj/item/reagent_containers/cup/glass/bottle/whiskey{ + pixel_x = -6; + pixel_y = 8 + }, +/obj/item/toy/cards/deck{ + pixel_x = 5 }, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "Iq" = ( -/obj/structure/kitchenspike, -/obj/effect/decal/cleanable/blood/old, +/obj/structure/table, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = -5; + pixel_y = 6 + }, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = 6; + pixel_y = 4 + }, +/obj/item/reagent_containers/cup/bottle/formaldehyde{ + pixel_y = -5 + }, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "Iz" = ( -/obj/effect/decal/cleanable/dirt, -/obj/item/stack/sheet/plastic{ - amount = 5 - }, +/obj/structure/chair/stool, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "II" = ( @@ -1572,20 +1576,12 @@ /area/ruin/space/has_grav/powered) "IL" = ( /obj/effect/decal/cleanable/dirt/dust, -/obj/effect/decal/cleanable/cobweb/cobweb2, +/obj/machinery/light/small/red/directional/west, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "JJ" = ( -/obj/structure/table, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = -4; - pixel_y = 6 - }, -/obj/item/clothing/mask/surgical{ - pixel_x = 6; - pixel_y = -4 - }, -/obj/effect/decal/cleanable/dirt/dust, +/obj/structure/mop_bucket, +/obj/item/mop, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "Kb" = ( @@ -1594,140 +1590,150 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "KD" = ( -/obj/structure/sign/warning/secure_area, -/turf/closed/wall/r_wall, +/obj/structure/table/wood, +/obj/item/flashlight/lamp/green{ + pixel_x = -4; + pixel_y = 6 + }, +/turf/open/floor/carpet/red, /area/ruin/space/has_grav/powered) "KS" = ( -/obj/structure/closet, -/obj/effect/decal/cleanable/dirt, -/turf/open/floor/plating, +/obj/machinery/light/small/directional/south, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "Lh" = ( -/obj/structure/closet/cabinet, -/obj/item/clothing/head/fedora, -/turf/open/floor/plating, +/obj/structure/rack, +/obj/item/coin/gold{ + pixel_x = -5 + }, +/obj/item/coin/silver{ + pixel_x = 5; + pixel_y = 4 + }, +/turf/open/floor/iron/dark/smooth_large, /area/ruin/space/has_grav/powered) "Lp" = ( -/obj/machinery/door/airlock/freezer{ - name = "Cold Room"; - req_one_access = list("scav") - }, -/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/vomit/old, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "LH" = ( /obj/structure/table, -/obj/item/bodypart/arm/left/robot{ - pixel_y = 4 - }, -/obj/item/screwdriver{ - pixel_x = 8 +/obj/item/wrench, +/obj/item/crowbar{ + pixel_y = 6 }, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "LO" = ( -/obj/effect/decal/cleanable/cobweb/cobweb2, +/obj/effect/decal/cleanable/dirt/dust, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "LZ" = ( -/obj/effect/decal/cleanable/vomit/old, -/obj/item/reagent_containers/cup/bucket, -/turf/open/floor/plating, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt, +/obj/effect/landmark/stealth_patrol{ + route = "e"; + order = 1; + facing = 1 + }, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "Md" = ( -/obj/machinery/light/small/broken/directional/south, /obj/effect/decal/cleanable/dirt, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "Mi" = ( -/obj/structure/rack, -/obj/item/knife/combat/survival{ - pixel_y = 4 - }, -/turf/open/floor/plating, +/obj/structure/closet/cabinet, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "Mo" = ( -/obj/machinery/iv_drip, -/obj/effect/decal/cleanable/blood/drip, +/obj/structure/table, +/obj/item/scalpel{ + pixel_x = -6; + pixel_y = 4 + }, +/obj/item/hemostat{ + pixel_x = 4 + }, +/obj/item/retractor{ + pixel_y = -5 + }, +/obj/effect/decal/cleanable/dirt/dust, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "MI" = ( -/obj/structure/mop_bucket, -/obj/item/mop, +/obj/machinery/light/cold/directional/north, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "MJ" = ( -/obj/effect/spawner/random/entertainment/cigarette_pack, -/obj/effect/spawner/random/entertainment/lighter, +/obj/item/radio{ + pixel_x = -4 + }, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "Nc" = ( -/obj/structure/chair/comfy/black{ - dir = 4 - }, -/turf/open/floor/wood, +/obj/structure/rack, +/obj/item/bodypart/leg/right, +/obj/item/bodypart/arm/left, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Nu" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/landmark/stealth_patrol{ - route = "b"; - order = 1; - facing = 1; - route_mode = "pingpong" - }, -/obj/effect/spawner/human_npc/ruin/scav/den{ - dir = 1 +/obj/machinery/door/airlock/freezer{ + name = "Cold Room"; + req_one_access = list("scav") }, +/obj/effect/turf_decal/tile/red/full, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "NB" = ( -/obj/effect/decal/cleanable/dirt/dust, -/turf/open/floor/wood, +/obj/effect/landmark/stealth_restricted{ + allowed = 0 + }, +/turf/open/floor/iron/dark/smooth_large, /area/ruin/space/has_grav/powered) "NH" = ( -/obj/structure/table, -/obj/item/surgicaldrill{ - pixel_y = 3 - }, -/obj/item/clothing/gloves/latex{ - pixel_x = -6; - pixel_y = -5 - }, /obj/effect/decal/cleanable/dirt, -/turf/open/floor/iron/white, +/obj/effect/spawner/random/trash/cigbutt, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "NO" = ( -/obj/machinery/light/warm/directional/north, -/obj/structure/table, -/obj/item/storage/box/donkpockets{ - pixel_y = 4 - }, -/obj/item/kitchen/fork{ - pixel_x = 8 - }, +/obj/effect/spawner/random/trash/cigbutt, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "NP" = ( -/obj/structure/chair/stool, +/obj/structure/table, +/obj/item/bodypart/arm/right/robot{ + pixel_x = -3; + pixel_y = 3 + }, +/obj/item/weldingtool{ + pixel_x = 6; + pixel_y = -6 + }, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Od" = ( -/obj/effect/decal/cleanable/blood/drip, -/turf/open/floor/iron/white, -/area/ruin/space/has_grav/powered) -"Ok" = ( /obj/structure/table, -/obj/item/toy/cards/deck{ +/obj/item/circular_saw{ pixel_y = 4 }, -/obj/item/reagent_containers/cup/glass/bottle/vodka{ - pixel_x = -8; - pixel_y = 8 +/obj/item/cautery{ + pixel_x = 6; + pixel_y = -4 }, +/turf/open/floor/iron/white, +/area/ruin/space/has_grav/powered) +"Ok" = ( +/obj/structure/chair/stool, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "Os" = ( -/obj/effect/decal/cleanable/blood/oil, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 4; + facing = 4 + }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "OP" = ( @@ -1742,89 +1748,87 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "OT" = ( -/obj/effect/spawner/random/entertainment/cigarette_pack, -/obj/effect/decal/cleanable/dirt/dust, +/obj/machinery/light/small/red/dim/directional/west, +/obj/effect/spawner/random/trash/cigbutt, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Pc" = ( -/obj/structure/closet, -/obj/effect/spawner/random/maintenance, +/obj/structure/bed/maint, +/obj/item/bedsheet/brown, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "Pf" = ( -/obj/structure/bed/maint, -/obj/item/bedsheet/brown, +/obj/structure/closet/crate, +/obj/item/storage/box/lethalshot, +/obj/effect/spawner/random/contraband/narcotics, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Pg" = ( -/obj/item/clothing/head/soft/black{ - pixel_y = 6 - }, -/turf/open/floor/iron/grimy, -/area/ruin/space/has_grav/powered) -"Pp" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/decal/cleanable/dirt/dust, -/obj/effect/landmark/stealth_patrol{ - route = "e"; - order = 4; - wait = 0 - }, +/obj/effect/spawner/random/entertainment/cigarette_pack, +/obj/effect/spawner/random/entertainment/lighter, +/turf/open/floor/iron/grimy, +/area/ruin/space/has_grav/powered) +"Pp" = ( +/obj/structure/closet/crate/wooden, +/obj/effect/turf_decal/bot, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "Pq" = ( -/obj/item/storage/belt/utility, -/obj/effect/decal/cleanable/dirt/dust, +/obj/effect/decal/cleanable/blood/gibs/robot_debris/limb, +/obj/effect/decal/cleanable/blood/oil, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Ps" = ( -/obj/effect/spawner/random/trash/cigbutt, -/turf/open/floor/plating, +/obj/structure/closet/crate, +/obj/effect/turf_decal/bot, +/obj/effect/spawner/random/maintenance, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "Pw" = ( /obj/effect/turf_decal/tile/red/full, -/turf/open/floor/iron/freezer, +/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/cobweb, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "PF" = ( +/obj/machinery/light/warm/directional/north, /obj/structure/table, -/obj/item/reagent_containers/cup/glass/bottle/whiskey{ - pixel_x = -6; - pixel_y = 8 +/obj/item/storage/box/donkpockets{ + pixel_y = 4 }, -/obj/item/toy/cards/deck{ - pixel_x = 5 +/obj/item/kitchen/fork{ + pixel_x = 8 }, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "PS" = ( -/obj/effect/landmark/stealth_group, -/obj/effect/decal/cleanable/blood/drip, +/obj/item/clothing/gloves/latex{ + pixel_x = 6 + }, +/obj/effect/decal/cleanable/blood/splatter, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "QF" = ( -/obj/effect/spawner/random/trash/garbage, +/obj/structure/bed/maint, +/obj/item/bedsheet/brown, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "QP" = ( -/obj/structure/table, -/obj/item/scalpel{ - pixel_x = -6; - pixel_y = 4 - }, -/obj/item/hemostat{ - pixel_x = 4 - }, -/obj/item/retractor{ - pixel_y = -5 - }, -/obj/effect/decal/cleanable/dirt/dust, +/obj/structure/kitchenspike, +/obj/effect/decal/cleanable/blood/old, +/obj/effect/decal/cleanable/blood/gibs/old, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "QT" = ( -/obj/structure/filingcabinet, +/obj/structure/chair/comfy/black{ + dir = 4 + }, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "Ru" = ( +/obj/machinery/light/cold/directional/south, /obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) @@ -1844,40 +1848,43 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Sa" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/landmark/stealth_patrol{ - route = "d"; - order = 1; - facing = 4; - chatter = 1; - route_mode = "pingpong" - }, +/obj/structure/chair/stool, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "Sm" = ( -/obj/structure/closet/crate/freezer, -/turf/open/floor/iron/freezer, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "SR" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/spawner/random/trash/garbage, -/turf/open/floor/iron/dark, +/obj/item/bedsheet/brown, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "SV" = ( -/obj/effect/decal/cleanable/blood/old, -/turf/open/floor/iron/dark, +/obj/effect/decal/cleanable/blood/splatter, +/obj/effect/spawner/human_npc/ruin/scav/den{ + dir = 8 + }, +/turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "SW" = ( -/obj/machinery/smartfridge/organ, +/obj/effect/decal/cleanable/blood/drip, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "Ta" = ( -/obj/effect/spawner/random/trash/food_packaging, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "d"; + order = 2; + facing = 1 + }, +/obj/effect/spawner/human_npc/ruin/scav/den/gunner{ + dir = 1 + }, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "Tl" = ( -/obj/effect/decal/cleanable/blood/old, -/obj/effect/decal/cleanable/blood/drip, +/obj/machinery/light/cold/dim/directional/south, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "Tr" = ( @@ -1886,14 +1893,23 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Tw" = ( -/turf/open/floor/carpet/red, +/obj/structure/rack, +/obj/item/stack/spacecash/c100{ + pixel_y = 4 + }, +/obj/effect/turf_decal/bot, +/turf/open/floor/iron/dark/smooth_large, /area/ruin/space/has_grav/powered) "TH" = ( -/obj/machinery/light/warm/directional/east, +/obj/item/reagent_containers/cup/glass/bottle/beer{ + pixel_x = -6; + pixel_y = 4 + }, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "TJ" = ( -/obj/structure/closet/secure_closet/freezer/meat, +/obj/structure/closet/crate/zone_loot/medical, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "TV" = ( @@ -1910,24 +1926,34 @@ /obj/effect/decal/cleanable/cobweb/cobweb2, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) +"UH" = ( +/obj/structure/closet/crate/wooden, +/obj/effect/spawner/random/food_or_drink/booze, +/obj/effect/spawner/random/food_or_drink/booze, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) "UM" = ( /obj/structure/closet/crate/bin, /obj/effect/decal/cleanable/cobweb, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "UW" = ( -/obj/structure/closet/crate/wooden, -/obj/effect/spawner/random/food_or_drink/booze, +/obj/structure/rack, +/obj/item/knife/combat/survival{ + pixel_y = 4 + }, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "VG" = ( +/obj/machinery/door/airlock{ + name = "Bunks"; + req_one_access = list("scav") + }, /obj/effect/turf_decal/tile/red/full, -/turf/open/floor/iron/cafeteria, +/turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "VN" = ( -/obj/item/clothing/suit/apron/surgical{ - pixel_y = -4 - }, +/obj/effect/spawner/random/trash/garbage, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "VQ" = ( @@ -1939,38 +1965,51 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "VX" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/decal/cleanable/dirt, -/obj/effect/decal/cleanable/cobweb, -/turf/open/floor/plating/rust, +/obj/structure/closet/crate/freezer, +/obj/item/food/meat/slab/human, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "VY" = ( -/obj/item/storage/briefcase{ - pixel_x = -4 +/obj/structure/table/wood, +/obj/item/reagent_containers/cup/glass/bottle/whiskey{ + pixel_y = 6 + }, +/obj/item/reagent_containers/cup/glass/drinkingglass{ + pixel_x = 8 }, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "Wc" = ( -/obj/item/kirbyplants/random, -/turf/open/floor/wood, +/obj/structure/closet/crate, +/obj/effect/spawner/random/maintenance/two, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Wg" = ( -/obj/structure/rack, -/obj/item/bodypart/arm/left/robot, -/obj/item/bodypart/arm/right/robot{ - pixel_y = 6 - }, +/obj/effect/spawner/random/maintenance/two, +/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "Wu" = ( /obj/effect/decal/cleanable/dirt, -/turf/open/floor/iron/dark, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "WJ" = ( -/obj/effect/landmark/stealth_restricted{ - allowed = 0 +/obj/structure/table/wood, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = 0; + pixel_y = 6 }, -/turf/open/floor/iron/dark/smooth_large, +/obj/item/paper/crumpled/bloody{ + pixel_x = -6; + pixel_y = -4 + }, +/obj/item/paper{ + name = "price list"; + default_raw_text = "Hearts 4000. Livers 2500. Lungs 2000. Eyes 1500 the pair. Chrome by weight. No refunds."; + pixel_x = 8; + pixel_y = 2 + }, +/turf/open/floor/carpet/red, /area/ruin/space/has_grav/powered) "Xe" = ( /obj/effect/turf_decal/stripes/line{ @@ -1990,7 +2029,7 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Xn" = ( -/obj/machinery/scav_camera/directional/north, +/obj/effect/decal/cleanable/blood/oil, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "Xz" = ( @@ -2000,45 +2039,40 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "XE" = ( -/obj/machinery/light/small/red/dim/directional/north, -/obj/effect/turf_decal/stripes/line{ - dir = 4 - }, -/turf/open/floor/plating, +/obj/effect/decal/cleanable/cobweb/cobweb2, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "XI" = ( -/obj/effect/decal/cleanable/dirt/dust, -/turf/open/floor/iron/dark/smooth_large, +/obj/item/reagent_containers/cup/glass/bottle/whiskey{ + pixel_x = 4; + pixel_y = -8 + }, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "XJ" = ( -/obj/effect/decal/cleanable/blood/tracks{ - dir = 4 - }, +/obj/item/clothing/suit/apron/surgical, +/obj/effect/decal/cleanable/blood/drip, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "XK" = ( -/obj/effect/spawner/random/trash/graffiti, -/turf/closed/wall, +/obj/effect/spawner/random/trash/cigbutt, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "XO" = ( -/obj/effect/decal/cleanable/cobweb, -/turf/open/floor/iron/dark, +/obj/machinery/smartfridge/organ, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "Yd" = ( -/obj/effect/decal/cleanable/dirt, +/obj/effect/turf_decal/tile/red/full, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "Yj" = ( -/obj/item/storage/box/bodybags, -/obj/item/storage/organbox{ - pixel_y = 8 - }, +/obj/machinery/iv_drip, +/obj/effect/decal/cleanable/blood/drip, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "Yx" = ( -/obj/effect/decal/remains/human, -/obj/effect/decal/cleanable/blood/splatter, -/obj/item/restraints/handcuffs/cable/zipties, +/obj/machinery/light/small/red/dim/directional/south, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "YE" = ( @@ -2046,57 +2080,44 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "YK" = ( -/obj/structure/rack, -/obj/item/bodypart/leg/right, -/obj/item/bodypart/arm/left, +/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Zk" = ( -/obj/structure/bed/maint, -/obj/item/bedsheet/brown, +/obj/effect/spawner/random/trash/food_packaging, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "Zo" = ( +/obj/effect/spawner/random/food_or_drink/cups, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) +"ZB" = ( /obj/structure/table, -/obj/item/knife/butcher{ +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = -6; pixel_y = 5 }, -/obj/item/stack/spacecash/c200{ - pixel_x = -6; - pixel_y = -4 +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = 6; + pixel_y = 7 + }, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = 0; + pixel_y = -3 }, -/turf/open/floor/plating, -/area/ruin/space/has_grav/powered) -"ZB" = ( -/obj/structure/table/optable, -/obj/effect/mob_spawn/corpse/human, -/obj/effect/decal/cleanable/blood/splatter, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "ZF" = ( -/obj/machinery/light/small/directional/south, +/obj/structure/bookcase/random, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "ZV" = ( -/obj/structure/table/wood, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = 0; - pixel_y = 6 - }, -/obj/item/paper/crumpled/bloody{ - pixel_x = -6; - pixel_y = -4 - }, -/obj/item/paper{ - name = "price list"; - default_raw_text = "Hearts 4000. Livers 2500. Lungs 2000. Eyes 1500 the pair. Chrome by weight. No refunds."; - pixel_x = 8; - pixel_y = 2 - }, -/turf/open/floor/carpet/red, +/obj/structure/sign/warning/secure_area, +/turf/closed/wall/r_wall, /area/ruin/space/has_grav/powered) "ZX" = ( -/obj/effect/spawner/random/trash/garbage, +/obj/structure/closet/crate/freezer/blood, +/obj/effect/decal/cleanable/dirt/dust, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) @@ -2213,7 +2234,7 @@ ac ac ac qO -XE +fS aj ac ac @@ -2285,17 +2306,17 @@ ac ac ac ac +fE +aP +re IL aP -FC -AG -bu aP AG FO -aP -fS -kt +FC +bu +Md II AG ac @@ -2369,7 +2390,7 @@ ac ac ac ac -kt +Md ac ac ac @@ -2406,7 +2427,7 @@ aj aj aj aj -wF +yr aj aj aj @@ -2417,7 +2438,7 @@ aj aj aj aj -re +xz aj aj aj @@ -2445,25 +2466,25 @@ ac ac ac aj -FH ro -GO +wg +Ok ae -lY -FH +zq +ro +aj +cL +Ca aj XO Dx -aj SW +ad HM +ad xq ad TJ -ad -xz -ad -fE aj ac ac @@ -2488,24 +2509,24 @@ ac ac aj ae -wg -Ok +HR +bw ae -zq +bg ae -wF +yr al -Wu +Sm aj -oS +wF ad -sh +Wu ad -Fq +oS ad ad -cL -Ca +sh +Fq aj ac ac @@ -2529,25 +2550,25 @@ ac ac ac aj -FH +ro ae -GO +Ok ae -bg +qZ ae aj -vY +yj al aj +ct +ad +vY pC ad DO -yw -ad -yr ad ad -Sm +yw aj ac ac @@ -2571,25 +2592,25 @@ ac ac ac aj -qZ -HR +ph +cq ae -bw +Ta ae ae am -Wu +Sm al aj -Sm +yw ad ad ad ad ad ad -yj -ct +Lp +VX aj aI aI @@ -2613,27 +2634,27 @@ ac ac ac aj -Zk +QF ae -ph -cq -Ta +MJ +Yd +Zk ae aj -Wu -hO +Sm +XK aj ad ad +Ht +hO +hO +hO +hO +hO +hO Nu Pw -Pw -Pw -Pw -Pw -Pw -Lp -VX av aD aL @@ -2656,19 +2677,19 @@ ac ac aj ae -QF -MJ -cq -ae +mt +Pg Yd +ae +cg aj -HH +rq al -XK -Ht -xq +pk +HH +SW ad -xq +SW ad ad ad @@ -2697,25 +2718,25 @@ ac ac ac aj -FH -Pg +ro +nV ae -cq +Yd ae -cg +Pc aj al -lp +mC aj -tk -Tl +wW +lp ad -rq +tk ad ad ad ad -pk +Tl aj ac ac @@ -2739,25 +2760,25 @@ ac ac ac aj -Pc -ae -QF -cq +rF ae mt +Yd +ae +ET aj -Dx +Ca al aj -Iq -pZ +dd +tD ad -rq +tk ad ad ad -mC -wW +Iq +pZ aj ac ac @@ -2784,7 +2805,7 @@ aj aj aj aj -nV +VG aj aj aj @@ -2792,13 +2813,13 @@ al al aj aj -wF +yr aj aj an aj aj -wF +yr aj aj aj @@ -2823,26 +2844,26 @@ ac ac ac aj -yF +mS aC +rs +mG +yF oW -VG -rF -ET aj -XO -Wu +cL +Sm al -vY -Wu -Wu +yj +Sm +Sm +zF +vO +hW +vO oD -dd vO -dd xt -dd -tD aj dB ux @@ -2865,27 +2886,27 @@ ac ac ac aj -mS +qt aC -rs -VG +Sa mG +NO aC -wF -Wu +yr +Sm +DY +vI +vI +tn +vI +vI +jo +vI tn -Hq -Hq -nL -Hq -Hq vI -Hq nL Hq -zF -hW -wF +yr lB us aS @@ -2907,26 +2928,26 @@ ac ac ac aj +PF +Sa NO -rs mG -VG aC aC aj al -DY +hi aj aj -re +xz aj ak aj -wF +yr aj aj -Hq -jo +vI +kw aj ah aS @@ -2949,26 +2970,26 @@ ac ac ac aj -qt +iz aC aC -Sa -rF +Gn +yF aC aj -Wu -Hq +Sm +vI aj +QP +sq wR VN Bp -ZX -FM aa -hi +ZX aj -nL -kw +tn +FM aj Ry aS @@ -2991,26 +3012,26 @@ ac ac ac aj -iz -Gn -rs -PF +pb +DG +Sa +Ik aC aC aO al -DY +hi au -Ge +ZB aa +Yj +Ge Mo -Hp -QP aa -sq +Hp au +vI Hq -hW aj aS aS @@ -3034,25 +3055,25 @@ ac ac aj aC -DG +Bf aC -Ik -rs +kS +Sa aC aj -Wu -nL +Sm +tn aj +MI +tx gG jj -Do -ZB aa aa -Yj +Do aj +vI Hq -hW aj aQ Dt @@ -3076,25 +3097,25 @@ ac ac aj aC -Bf -kS -pb +eW +TH +Ev aC -rs -wF +Sa +yr al -Hq -wF -JJ +vI +yr +pc aa aa -gu +SV aa -Hp -MI +Ge +JJ aj -Hq -tx +vI +gu aj Xg aS @@ -3117,26 +3138,26 @@ ac ac ac aj -rg -rs -eW +BU +Sa +Zo aC -TH -Ev +Eh +rg aj -Wu -Hq +Sm +vI aj +pq +wR +mu eg -Bp PS +aa Ru +aj EG -aa ch -aj -pc -SV aY yR eO @@ -3167,18 +3188,18 @@ aI aI aI al -Hq -wF +vI +yr +aa +tT aa +li Od +eg aa DE -pq -Ru -aa -mu -Hq -vY +vI +yj aj eO aS @@ -3201,25 +3222,25 @@ ac ac ac aI -LH +kM yR -BU -Zo -Eh +NP +hg +LH aS aI -Dx -DY +Ca +hi aj -gG -Od -aa +MI tT aa -li +zI +aa +uf aa aj -nL +tn al aj aS @@ -3243,26 +3264,26 @@ ac ac ac aI -kM +dq aS aS -NP +Iz aS -hg +Pq aI al -Hq +vI au -uu +oQ aa +CG +uu vh -XJ -NH aa -zI +XJ au -Hq -uf +vI +NH aj aS kW @@ -3288,24 +3309,24 @@ aI aS yR aS -Pq +df aS aS ap al -Hq +vI aj -Gv +vH aa aa -XJ -Ru -oQ -CG +uu +eg +Be +Gv aj -nL +tn al -wF +yr aS aS aL @@ -3329,23 +3350,23 @@ ac aI aQ aS -dq +yG aS -Iz +Eu aS au -hO -Hq +XK +vI aj aj -wF +yr aj ak aj -wF +yr aj aj -Hq +vI al aj aS @@ -3369,25 +3390,25 @@ ac ac ac aI -yG +Wc aS aT aS -Eu -df +YK +em aI al -vH -nL -Hq -Hq -Hq -DY -Hq -nL -DY -nL -Be +cj +tn +vI +vI +vI +hi +vI +tn +hi +tn +Os al aj CN @@ -3411,26 +3432,26 @@ ac ac ac aI -YK +Nc aS aS aS aS -em +GI aI -Xn -Wu -vY +sZ +Sm +yj al al -cj -hW -dd -dd -xt -dd -dd -Os +dO +Hq +vO +vO +oD +vO +vO +Xn aj DV aS @@ -3456,11 +3477,11 @@ aA aj aj aj -wF +yr aj aj aj -vY +yj al aj aj @@ -3495,26 +3516,26 @@ aA aA aA aA +vZ +xm +ZF QT VY uj -Nc -GI -Wc aj al al al +tH +yj +Ps +aI fN -vY cv -aI -ky -sZ ay eO aS -dO +ky aI ac ac @@ -3533,30 +3554,30 @@ ax ac ac aA -zh -XI +Tw +rK aE aA -QT +vZ ab +dS +zh +XI tO -vZ -xm -ZF aj -th +BG al al al -Wu -ha +Sm +Pp aI -hJ -qP +th +ha aG -tH +hJ aS -Ps +qP aI ac ac @@ -3575,22 +3596,22 @@ ax ac ac aA -bn +fa aE +hL +ZV +uj +bn +rc rc KD -Wc qC -Tw -Tw -rK -dS aj al -BG -DY -DY -Pp +LZ +hi +hi +ic al aW aI @@ -3618,29 +3639,29 @@ ac ac aA aE -WJ -fa +NB +Hj aH ab ab -Tw -hL -ZV +rc +jE +WJ ab ao al -nL -Dx +tn +Ca al -Hq -Wu +vI +Sm aI -LZ +jA aS ay aS yR -ic +Yx aI ac ac @@ -3659,35 +3680,35 @@ ax ac ac aA -br +bh aE -XI +rK aA ab -NB -Tw -Tw -Hj -jE +LO +rc +rc +GE +br aj al -Hq +vI aW aI -nL +tn al aI aS -Yx +vE aG -tH +hJ aS aS aI ac ac ac -kt +Md ac ac ac @@ -3701,22 +3722,22 @@ ax ac ac aA -vX -bh +sH +Lh aE aA -LO +sf ab ab ab ab -GE +vX aj -hO -Hq +XK +vI aI aI -nL +tn al aI aI @@ -3752,26 +3773,26 @@ ab ab ab ab -sf -wF -Dx -SR +Mi +yr +Ca +nJ aI aI -Hq -lC +vI +KS aI -ky -vE +fN +SR ay eO aS -jA +lC aI ac ac ac -Md +kt ac ac ac @@ -3796,19 +3817,19 @@ aI aI aI aI -Wu -Hq +Sm +vI aI aW -Hq -Wu +vI +Sm aI -iU -oY +qf +hN aG aS -nJ -KS +iU +oY aI ac ac @@ -3831,18 +3852,18 @@ ac ac ac aI -sH +zZ us aS aS -Ps -Lh +OT +DK aI -Dx -Hq +Ca +vI al al -Hq +vI al aI aI @@ -3873,7 +3894,7 @@ ac ac ac aI -Mi +UW aS aS aB @@ -3881,18 +3902,18 @@ aS aS az al -nz -Hq -Hq -mW +rJ +vI +vI +GK al aj aI -Wg +nz aP -qf +mW aP -hN +Wg aI ac ac @@ -3915,24 +3936,24 @@ ac ac ac aI -zZ -OT -DK +Pf +xp +yQ aS aS yR aI -Wu +Sm al -Dx -Dx -Wu -hI -wF +Ca +Ca +Sm +qh +yr aI -rJ +rd aP -GK +hI aP aP aI @@ -3957,31 +3978,31 @@ ac ac ac aI -Pf -xp +ht +oX aS -yQ +UH aS -UW +dA aI al al -vY -Wu +yj +Sm al al aj aI -de +XE aP aP aP -rd +dJ aI ac ac ac -AG +de ac ac ac @@ -4052,20 +4073,20 @@ ac ac ac ac -kt +Md ac ac ac ac ac -kt +Md ac ac ac ac ac ac -kt +Md ac ac ac @@ -4094,20 +4115,20 @@ ac ac ac ac -de -aP -Gp -dJ +XE aP -kt +GO +lY +FH +Md aP -kt +Md aP -qh +Gp aP -kt +Md AG -de +XE ac ac ac diff --git a/voidcrew/modules/stealth/scav_den.dm b/voidcrew/modules/stealth/scav_den.dm index cbefd9a51e4..93ac5a3848b 100644 --- a/voidcrew/modules/stealth/scav_den.dm +++ b/voidcrew/modules/stealth/scav_den.dm @@ -59,8 +59,14 @@ return null . = ..() if(.) - // A den nobody ever flies to would hold the one-den slot for the round: the scavs move on. - addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(scav_den_move_on), WEAKREF(.)), 60 MINUTES) + scav_den_claim(.) + +/// Sets up a den the moment it's revealed. +/proc/scav_den_claim(obj/structure/overmap/space_ruin/den) + // No contract may hold it on the chart: a held den would rebuild fresh (guards, vault and all) on the next visit. + den.mission_exclusive = TRUE + // A den nobody ever flies to would hold the one-den slot for the round: the scavs move on. + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(scav_den_move_on), WEAKREF(den)), 60 MINUTES) /// Takes a revealed den off the overmap if nobody has docked at it (its interior was never built) in the hour since. /proc/scav_den_move_on(datum/weakref/den_ref) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_den.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_den.dm index fdd84fb47b9..3d3001151f3 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_den.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_den.dm @@ -67,6 +67,9 @@ chart.spawn_zone = 2 TEST_ASSERT_NULL(chart.reveal(null), "A second den opened while one was out there") TEST_ASSERT(!chart.revealed, "A refused den chart was used up") + // A revealed den is never a contract's site (a held den would rebuild with a fresh vault). + scav_den_claim(den) + TEST_ASSERT(den.mission_exclusive, "A revealed den can be held by a contract") // Nobody docked within the hour: it leaves and frees the slot. scav_den_move_on(WEAKREF(den)) TEST_ASSERT(QDELETED(den), "An unvisited den stayed on the overmap") From e195aac17ca6b795fee53a5e8d2b2e6c7cda5980 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 07:21:45 -0800 Subject: [PATCH 61/78] The shoulder flip's slam sound comes from its picture --- voidcrew/modules/stealth/stealth_gunfu.dm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/voidcrew/modules/stealth/stealth_gunfu.dm b/voidcrew/modules/stealth/stealth_gunfu.dm index dd5c1283274..60f49cd78f9 100644 --- a/voidcrew/modules/stealth/stealth_gunfu.dm +++ b/voidcrew/modules/stealth/stealth_gunfu.dm @@ -191,12 +191,12 @@ playsound(src, 'sound/items/weapons/thudswoosh.ogg', 60, TRUE, -1) gunfu_after_move(victim, GUNFU_MOVE_FLIP) gunfu_vis_flip(victim, landing) - victim.throw_at(landing, 1, 1, src, spin = FALSE, callback = CALLBACK(src, PROC_REF(gunfu_landed), victim, GUNFU_FLIP_KNOCKDOWN, GUNFU_FLIP_DAMAGE, BODY_ZONE_CHEST)) + victim.throw_at(landing, 1, 1, src, spin = FALSE, callback = CALLBACK(src, PROC_REF(gunfu_landed), victim, GUNFU_FLIP_KNOCKDOWN, GUNFU_FLIP_DAMAGE, BODY_ZONE_CHEST, FALSE)) return TRUE /// A thrown or flipped body hits the floor: tg's knockdown and the fall's brute through its armour. A throw that hit /// a wall or a body already got tg's own crash; the floor still puts them down. -/mob/living/carbon/human/proc/gunfu_landed(mob/living/victim, knockdown, damage, zone) +/mob/living/carbon/human/proc/gunfu_landed(mob/living/victim, knockdown, damage, zone, thud = TRUE) if(QDELETED(victim) || victim.stat == DEAD) return if(damage) @@ -207,7 +207,9 @@ if(world.time >= victim.gunfu_down_grace_until) victim.Knockdown(knockdown) victim.gunfu_down_grace_until = world.time + knockdown + GUNFU_KNOCKDOWN_GRACE - playsound(victim, 'sound/effects/hit_kick.ogg', 50, TRUE, -1) + // The flip's slam sound is played by its picture, on the frame the body hits the floor (stealth_gunfu_motion_flip.dm). + if(thud) + playsound(victim, 'sound/effects/hit_kick.ogg', 50, TRUE, -1) // --------------------------------------------------------------------------------------------- // Right-click with the gun: the wall slam and the disarm From caf30fa7c7e57d9adda52f2bbdd291ec1fa41cb6 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 08:37:58 -0800 Subject: [PATCH 62/78] Den cameras tween their cone straight instead of swinging it the long way, and the corridor-corner camera looks along both corridors --- _maps/voidcrew/RandomRuins/SpaceRuins/rare_scav_den.dmm | 5 ++++- voidcrew/modules/stealth/scav_camera.dm | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/_maps/voidcrew/RandomRuins/SpaceRuins/rare_scav_den.dmm b/_maps/voidcrew/RandomRuins/SpaceRuins/rare_scav_den.dmm index 8bc482030f7..12fb23ed33d 100644 --- a/_maps/voidcrew/RandomRuins/SpaceRuins/rare_scav_den.dmm +++ b/_maps/voidcrew/RandomRuins/SpaceRuins/rare_scav_den.dmm @@ -1175,7 +1175,10 @@ /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "xt" = ( -/obj/machinery/scav_camera/directional/south, +/obj/machinery/scav_camera/directional/south{ + facing_offset = 45; + sweep = 45 + }, /obj/effect/decal/cleanable/blood/tracks{ dir = 1 }, diff --git a/voidcrew/modules/stealth/scav_camera.dm b/voidcrew/modules/stealth/scav_camera.dm index a279a324545..37a2a172a87 100644 --- a/voidcrew/modules/stealth/scav_camera.dm +++ b/voidcrew/modules/stealth/scav_camera.dm @@ -69,6 +69,8 @@ armor_type = /datum/armor/machinery_camera /// Degrees each side of its facing that it sweeps var/sweep = 50 + /// Degrees clockwise its mount is turned from straight out of its wall (a corner camera looks along both corridors) + var/facing_offset = 0 /// Degrees each side of its aim that it sees var/view_half = 18 /// Tiles it sees @@ -125,7 +127,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/scav_camera, 0) /// The way it looks out from its wall, in degrees clockwise from north (a camera hung on the north wall faces south) /obj/machinery/scav_camera/proc/scav_cam_facing() - return dir2angle(REVERSE_DIR(dir)) + return SIMPLIFY_DEGREES(dir2angle(REVERSE_DIR(dir)) + facing_offset) /obj/machinery/scav_camera/examine(mob/user) . = ..() @@ -347,7 +349,8 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/scav_camera, 0) if(instant) animate(cone, transform = pointing, time = 0) else - animate(cone, transform = pointing, time = 2 DECISECONDS) + // Linear: a turned and stretched matrix tweened by angle can flip and swing the cone the long way round. + animate(cone, transform = pointing, time = 2 DECISECONDS, flags = ANIMATION_LINEAR_TRANSFORM) /// How long the drawn cone is along its aim, in quarter tiles: to the first wall or solid door, at most the beam's full length. /obj/machinery/scav_camera/proc/scav_cam_reach() From 482c9deb80817fde29e94162a1b5ba644ae96795 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 08:38:54 -0800 Subject: [PATCH 63/78] Takedown hold keeps the victim standing and facing away when it closes tg's pull turned him to face the attacker and shifted him 6 px, and the neck grab's floor trait laid him down for a second before he got up again. The pull offsets come off and his facing is restored in the same tick, and he is forced standing for the instant the floor trait is added and taken off. --- voidcrew/modules/stealth/stealth_takedown.dm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/voidcrew/modules/stealth/stealth_takedown.dm b/voidcrew/modules/stealth/stealth_takedown.dm index 1ab6521860e..c486da136a2 100644 --- a/voidcrew/modules/stealth/stealth_takedown.dm +++ b/voidcrew/modules/stealth/stealth_takedown.dm @@ -189,10 +189,15 @@ /// tg's strangle, closed at once: the same states grippedby() steps through, in the same order. /datum/stealth_takedown/proc/close() + var/facing = victim.dir + var/standing = victim.body_position == STANDING_UP if(attacker.pulling != victim && !attacker.start_pulling(victim, supress_message = TRUE)) return FALSE if(attacker.pulling != victim) return FALSE + // tg's pull turns him to face the puller and shifts him toward him: he stays as he stood, facing away. + victim.remove_offsets(GRABBING_TRAIT, animate = FALSE) + victim.setDir(facing) var/cover = stealth_takedown_neck_cover(victim) if(cover >= STEALTH_TAKEDOWN_MAX_COVER) return FALSE @@ -201,12 +206,15 @@ if(attacker.grab_state < GRAB_AGGRESSIVE) attacker.setGrabState(GRAB_AGGRESSIVE) victim.stop_pulling() - attacker.setGrabState(GRAB_KILL) // Unlike grippedby(), the victim stays on his own tile and on his feet, held up from behind: tg's neck grab floors - // him (CHOKEHOLD_TRAIT), this takes that one source off again. He can't move or use his hands (tg's aggressive grab - // traits) and goes down by tg's own rules when he passes out. No pull offsets: they would turn him to face the - // attacker; the visuals pull him in instead. + // him (CHOKEHOLD_TRAIT), this takes that one source off again, and TRAIT_FORCED_STANDING for the same moment stops + // him dropping and getting back up a second later. He can't move or use his hands (tg's aggressive grab traits) and + // goes down by tg's own rules when he passes out. No pull offsets; the visuals pull him in instead. + if(standing) + ADD_TRAIT(victim, TRAIT_FORCED_STANDING, STEALTH_TAKEDOWN_TRAIT) + attacker.setGrabState(GRAB_KILL) REMOVE_TRAIT(victim, TRAIT_FLOORED, CHOKEHOLD_TRAIT) + REMOVE_TRAIT(victim, TRAIT_FORCED_STANDING, STEALTH_TAKEDOWN_TRAIT) victim.update_incapacitated() closed = TRUE ADD_TRAIT(victim, TRAIT_MUTE, STEALTH_TAKEDOWN_TRAIT) From ceb22c0b3421557691d2e0f33d33530672dcd2fc Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 09:09:18 -0800 Subject: [PATCH 64/78] Dim red work lights along the den's back ways and corridors --- .../RandomRuins/SpaceRuins/rare_scav_den.dmm | 2526 +++++++++-------- 1 file changed, 1281 insertions(+), 1245 deletions(-) diff --git a/_maps/voidcrew/RandomRuins/SpaceRuins/rare_scav_den.dmm b/_maps/voidcrew/RandomRuins/SpaceRuins/rare_scav_den.dmm index 12fb23ed33d..89e081aa242 100644 --- a/_maps/voidcrew/RandomRuins/SpaceRuins/rare_scav_den.dmm +++ b/_maps/voidcrew/RandomRuins/SpaceRuins/rare_scav_den.dmm @@ -287,14 +287,26 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "bg" = ( -/obj/effect/spawner/random/trash/cigbutt, -/turf/open/floor/iron/grimy, +/obj/machinery/light/small/red/directional/east, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "bh" = ( -/obj/machinery/light/small/directional/north, -/obj/structure/closet/crate/secure/scav_vault, -/obj/effect/turf_decal/bot, -/turf/open/floor/iron/dark/smooth_large, +/obj/structure/table/wood, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = 0; + pixel_y = 6 + }, +/obj/item/paper/crumpled/bloody{ + pixel_x = -6; + pixel_y = -4 + }, +/obj/item/paper{ + name = "price list"; + default_raw_text = "Hearts 4000. Livers 2500. Lungs 2000. Eyes 1500 the pair. Chrome by weight. No refunds."; + pixel_x = 8; + pixel_y = 2 + }, +/turf/open/floor/carpet/red, /area/ruin/space/has_grav/powered) "bk" = ( /obj/structure/closet/crate, @@ -305,20 +317,22 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "bn" = ( -/obj/effect/decal/cleanable/dirt, +/obj/item/cigarette{ + pixel_x = 4; + pixel_y = 6 + }, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "br" = ( -/obj/structure/chair/wood{ - dir = 1 - }, -/obj/effect/spawner/random/trash/cigbutt, -/turf/open/floor/wood, +/obj/structure/sign/warning/secure_area, +/turf/closed/wall/r_wall, /area/ruin/space/has_grav/powered) "bu" = ( -/obj/effect/decal/cleanable/dirt/dust, -/obj/item/cigbutt, -/turf/open/floor/plating/rust, +/obj/machinery/light/small/red/dim/directional/north, +/obj/effect/turf_decal/stripes/line{ + dir = 4 + }, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "bv" = ( /obj/structure/closet/crate/trashcart, @@ -327,32 +341,44 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "bw" = ( -/obj/structure/table, -/obj/item/toy/cards/deck{ - pixel_y = 4 - }, -/obj/item/reagent_containers/cup/glass/bottle/vodka{ - pixel_x = -8; - pixel_y = 8 - }, -/turf/open/floor/iron/grimy, +/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "cg" = ( -/obj/effect/decal/cleanable/dirt, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "d"; + order = 2; + facing = 1 + }, +/obj/effect/spawner/human_npc/ruin/scav/den/gunner{ + dir = 1 + }, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "ch" = ( -/obj/effect/decal/cleanable/blood/old, +/obj/effect/decal/cleanable/blood/drip, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 8 + }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "cj" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/landmark/stealth_patrol{ - route = "a"; - order = 3; - wait = 0 +/obj/structure/rack, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = -6; + pixel_y = 6 }, -/turf/open/floor/iron/dark, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = 6; + pixel_y = 6 + }, +/obj/item/reagent_containers/cup/bottle/formaldehyde{ + pixel_x = 2; + pixel_y = -4 + }, +/turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "ck" = ( /obj/effect/turf_decal/stripes/line{ @@ -363,52 +389,57 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "cq" = ( -/obj/item/storage/backpack/duffelbag, -/obj/effect/decal/cleanable/dirt, +/obj/structure/chair/stool, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "ct" = ( -/obj/machinery/light/cold/dim/directional/north, /obj/structure/closet/crate/freezer, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "cv" = ( -/obj/effect/decal/remains/human, -/obj/effect/decal/cleanable/blood/old, -/turf/open/floor/plating, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 3; + wait = 0 + }, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "cL" = ( /obj/effect/decal/cleanable/cobweb, -/turf/open/floor/iron/dark, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "dd" = ( -/obj/structure/kitchenspike, -/obj/effect/decal/cleanable/blood/old, +/obj/structure/table, +/obj/item/organ/liver/cybernetic{ + pixel_x = -4; + pixel_y = 5 + }, +/obj/item/organ/lungs/cybernetic{ + pixel_x = 5; + pixel_y = -2 + }, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "de" = ( -/obj/effect/decal/cleanable/dirt/dust, -/obj/machinery/light/small/red/directional/south, +/obj/effect/spawner/random/trash/garbage, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "df" = ( -/obj/item/storage/belt/utility, -/obj/effect/decal/cleanable/dirt/dust, -/turf/open/floor/plating, -/area/ruin/space/has_grav/powered) -"dq" = ( /obj/structure/table, -/obj/item/multitool{ - pixel_x = -4 - }, -/obj/item/stack/cable_coil{ - pixel_x = 6 +/obj/item/wrench, +/obj/item/crowbar{ + pixel_y = 6 }, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) +"dq" = ( +/obj/structure/reagent_dispensers/water_cooler, +/turf/open/floor/iron/cafeteria, +/area/ruin/space/has_grav/powered) "dA" = ( -/obj/structure/closet/crate/wooden, -/obj/effect/spawner/random/food_or_drink/booze, +/obj/structure/closet/cabinet, +/obj/item/clothing/head/fedora, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "dB" = ( @@ -416,13 +447,17 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "dJ" = ( -/obj/structure/closet/crate, -/obj/item/bodypart/leg/left/robot, +/obj/structure/rack, +/obj/item/bodypart/arm/left/robot, +/obj/item/bodypart/arm/right/robot{ + pixel_y = 6 + }, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "dO" = ( -/obj/machinery/light/small/directional/east, -/turf/open/floor/iron/dark, +/obj/item/stack/medical/suture, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "dR" = ( /obj/effect/turf_decal/bot, @@ -430,16 +465,23 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "dS" = ( -/obj/effect/landmark/stealth_restricted, +/obj/structure/chair/comfy/black{ + dir = 4 + }, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "eg" = ( -/obj/effect/decal/cleanable/dirt, -/turf/open/floor/iron/white, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "em" = ( -/obj/item/ammo_box/magazine/m9mm, -/obj/effect/decal/cleanable/dirt, +/obj/structure/table, +/obj/item/bodypart/arm/left/robot{ + pixel_y = 4 + }, +/obj/item/screwdriver{ + pixel_x = 8 + }, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "eO" = ( @@ -447,17 +489,19 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "eW" = ( -/obj/effect/decal/cleanable/dirt, /obj/structure/table, -/obj/effect/spawner/random/food_or_drink/dinner, -/obj/item/kitchen/fork{ - pixel_x = -8 +/obj/item/reagent_containers/cup/glass/bottle/whiskey{ + pixel_x = -6; + pixel_y = 8 + }, +/obj/item/toy/cards/deck{ + pixel_x = 5 }, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "fa" = ( /obj/structure/rack, -/obj/item/storage/briefcase{ +/obj/item/stack/spacecash/c100{ pixel_y = 4 }, /obj/effect/turf_decal/bot, @@ -465,7 +509,7 @@ /area/ruin/space/has_grav/powered) "fE" = ( /obj/effect/decal/cleanable/dirt/dust, -/obj/effect/decal/cleanable/cobweb/cobweb2, +/obj/machinery/light/small/red/directional/west, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "fK" = ( @@ -474,15 +518,12 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "fN" = ( -/obj/machinery/light/small/red/dim/directional/north, -/turf/open/floor/plating, +/obj/effect/decal/cleanable/blood/oil, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "fS" = ( -/obj/machinery/light/small/red/dim/directional/north, -/obj/effect/turf_decal/stripes/line{ - dir = 4 - }, -/turf/open/floor/plating, +/obj/effect/decal/cleanable/cobweb/cobweb2, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "ga" = ( /obj/effect/turf_decal/tile/red/full, @@ -492,84 +533,87 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "gu" = ( -/obj/effect/decal/cleanable/blood/drip, -/obj/effect/decal/cleanable/blood/tracks{ - dir = 8 - }, -/turf/open/floor/iron/dark, +/obj/structure/table/optable, +/obj/effect/mob_spawn/corpse/human, +/obj/effect/decal/cleanable/blood/splatter, +/turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "gG" = ( -/obj/machinery/computer/operating{ - dir = 2 - }, +/obj/machinery/iv_drip, +/obj/effect/decal/cleanable/blood/drip, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "ha" = ( -/obj/item/trash/chips, -/obj/effect/decal/cleanable/dirt, +/obj/machinery/light/small/red/dim/directional/north, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "hg" = ( -/obj/structure/table, -/obj/item/knife/butcher{ - pixel_y = 5 - }, -/obj/item/stack/spacecash/c200{ +/obj/item/reagent_containers/cup/glass/bottle/beer{ pixel_x = -6; - pixel_y = -4 + pixel_y = 4 }, -/turf/open/floor/plating, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "hi" = ( /obj/effect/turf_decal/tile/red/full, -/obj/effect/decal/cleanable/dirt/dust, +/obj/effect/decal/cleanable/dirt, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 1; + facing = 8 + }, +/obj/effect/spawner/human_npc/ruin/scav/den/gunner{ + dir = 8 + }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "ht" = ( -/obj/structure/bed/maint, -/obj/item/bedsheet/brown, +/obj/structure/rack, +/obj/item/knife/combat/survival{ + pixel_y = 4 + }, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "hI" = ( -/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, -/obj/effect/decal/cleanable/blood/oil, -/turf/open/floor/plating/rust, +/obj/effect/decal/cleanable/blood/old, +/obj/effect/decal/cleanable/blood/gibs/old, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "hJ" = ( -/obj/effect/decal/cleanable/blood/tracks{ - dir = 1 - }, +/obj/effect/decal/remains/human, +/obj/effect/decal/cleanable/blood/old, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "hL" = ( -/obj/machinery/scav_camera/directional/south, +/obj/effect/decal/cleanable/dirt/dust, /turf/open/floor/iron/dark/smooth_large, /area/ruin/space/has_grav/powered) "hN" = ( -/obj/item/clothing/shoes/sneakers/black, -/obj/effect/decal/cleanable/blood/old, +/obj/item/bedsheet/brown, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "hO" = ( -/obj/effect/turf_decal/tile/red/full, +/obj/structure/closet/crate/freezer, +/obj/item/food/meat/slab/human, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "hW" = ( -/obj/machinery/light/small/directional/west, +/obj/machinery/scav_camera/directional/south{ + facing_offset = 45; + sweep = 45 + }, /obj/effect/decal/cleanable/blood/tracks{ dir = 1 }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "ic" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/decal/cleanable/dirt/dust, -/obj/effect/landmark/stealth_patrol{ - route = "e"; - order = 4; - wait = 0 +/obj/effect/decal/cleanable/blood/tracks{ + dir = 1 }, -/turf/open/floor/iron/dark, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "ik" = ( /obj/effect/decal/cleanable/dirt, @@ -579,23 +623,23 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "iz" = ( -/obj/structure/table, -/obj/effect/spawner/random/food_or_drink/booze, -/obj/item/reagent_containers/cup/glass/drinkingglass{ - pixel_x = 8 - }, +/obj/effect/decal/cleanable/dirt, +/obj/item/trash/chips, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "iU" = ( -/obj/effect/spawner/human_npc/ruin/scav/den/lookout{ - dir = 8 +/obj/structure/table, +/obj/item/restraints/handcuffs/cable/zipties{ + pixel_x = -5 + }, +/obj/item/reagent_containers/cup/glass/mug{ + pixel_x = 6; + pixel_y = 4 }, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "jj" = ( -/obj/structure/table/optable, -/obj/effect/mob_spawn/corpse/human, -/obj/effect/decal/cleanable/blood/splatter, +/obj/effect/decal/cleanable/blood/old, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "jo" = ( @@ -603,44 +647,41 @@ /obj/effect/decal/cleanable/dirt, /obj/effect/landmark/stealth_patrol{ route = "a"; - order = 1; - facing = 8 - }, -/obj/effect/spawner/human_npc/ruin/scav/den/gunner{ - dir = 8 + order = 5; + wait = 0 }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "jA" = ( -/obj/effect/decal/cleanable/vomit/old, -/obj/item/reagent_containers/cup/bucket, -/turf/open/floor/plating, +/obj/structure/closet/crate/wooden, +/obj/effect/turf_decal/bot, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "jE" = ( -/obj/structure/chair/office{ - dir = 2 - }, -/obj/effect/spawner/human_npc/ruin/scav/den/boss{ - dir = 2 +/obj/structure/table/wood, +/obj/item/flashlight/lamp/green{ + pixel_x = -4; + pixel_y = 6 }, /turf/open/floor/carpet/red, /area/ruin/space/has_grav/powered) "kt" = ( -/obj/machinery/light/small/red/directional/south, -/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/cobweb, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "kw" = ( -/obj/effect/spawner/random/trash/garbage, -/obj/effect/decal/cleanable/blood/tracks{ - dir = 8 - }, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "ky" = ( -/obj/structure/chair/stool, -/obj/effect/spawner/random/trash/cigbutt, -/turf/open/floor/plating, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 4; + facing = 4 + }, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "kL" = ( /obj/effect/decal/cleanable/blood/footprints{ @@ -650,13 +691,12 @@ /area/ruin/space/has_grav/powered) "kM" = ( /obj/structure/table, -/obj/item/bodypart/arm/left/robot{ - pixel_y = 4 - }, -/obj/item/screwdriver{ - pixel_x = 8 +/obj/effect/spawner/random/food_or_drink/booze, +/obj/item/stack/spacecash/c50{ + pixel_x = 4; + pixel_y = -4 }, -/turf/open/floor/plating, +/turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "kO" = ( /obj/structure/closet/crate, @@ -665,9 +705,8 @@ /area/ruin/space/has_grav/powered) "kS" = ( /obj/structure/table, -/obj/effect/spawner/random/food_or_drink/snack, -/obj/item/reagent_containers/cup/glass/mug{ - pixel_x = -6 +/obj/machinery/microwave{ + pixel_y = 6 }, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) @@ -678,14 +717,13 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "li" = ( -/obj/effect/decal/cleanable/blood/old, +/obj/effect/landmark/stealth_group, /obj/effect/decal/cleanable/blood/drip, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "lp" = ( -/obj/effect/decal/cleanable/blood/old, -/obj/effect/decal/cleanable/blood/drip, -/turf/open/floor/iron/freezer, +/obj/effect/spawner/random/trash/graffiti, +/turf/closed/wall, /area/ruin/space/has_grav/powered) "lB" = ( /obj/structure/closet/crate/internals, @@ -693,73 +731,70 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "lC" = ( -/obj/structure/table, -/obj/item/restraints/handcuffs/cable/zipties{ - pixel_x = -5 - }, -/obj/item/reagent_containers/cup/glass/mug{ - pixel_x = 6; - pixel_y = 4 +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt/dust, +/obj/effect/landmark/stealth_patrol{ + route = "e"; + order = 4; + wait = 0 }, -/turf/open/floor/plating, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "lY" = ( -/obj/effect/decal/cleanable/dirt, -/obj/effect/decal/cleanable/blood/drip, +/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, +/obj/effect/decal/cleanable/blood/oil, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "mt" = ( -/obj/effect/spawner/random/trash/garbage, +/obj/machinery/light/small/dim/directional/north, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "mu" = ( -/obj/effect/landmark/stealth_group, +/obj/effect/turf_decal/tile/red/full, /obj/effect/decal/cleanable/blood/drip, -/turf/open/floor/iron/white, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "mC" = ( -/obj/effect/spawner/random/structure/chair_flipped, -/turf/open/floor/iron/dark, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 8 + }, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "mG" = ( -/obj/effect/turf_decal/tile/red/full, -/turf/open/floor/iron/cafeteria, +/obj/structure/bed/maint, +/obj/item/bedsheet/brown, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "mS" = ( -/obj/structure/closet/secure_closet/freezer/fridge, -/turf/open/floor/iron/cafeteria, +/obj/structure/closet, +/obj/item/storage/medkit/regular, +/turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "mW" = ( -/obj/effect/decal/remains/robot, -/turf/open/floor/plating/rust, +/obj/machinery/light/small/red/dim/directional/north, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "nz" = ( -/obj/structure/rack, -/obj/item/bodypart/arm/left/robot, -/obj/item/bodypart/arm/right/robot{ - pixel_y = 6 - }, -/turf/open/floor/plating/rust, +/obj/structure/closet, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "nJ" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/spawner/random/trash/garbage, -/turf/open/floor/iron/dark, +/obj/effect/decal/cleanable/vomit/old, +/obj/item/reagent_containers/cup/bucket, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "nL" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/decal/cleanable/dirt, -/obj/effect/landmark/stealth_patrol{ - route = "a"; - order = 5; - wait = 0 +/obj/machinery/light/small/directional/west, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 1 }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "nV" = ( -/obj/item/clothing/head/soft/black{ - pixel_y = 6 - }, +/obj/effect/turf_decal/tile/red/full, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "oq" = ( @@ -771,11 +806,9 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "oD" = ( -/obj/effect/decal/cleanable/dirt, -/obj/effect/decal/cleanable/blood/tracks{ - dir = 1 - }, -/turf/open/floor/iron/dark, +/obj/structure/kitchenspike, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "oG" = ( /obj/effect/turf_decal/stripes/line{ @@ -784,70 +817,54 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "oQ" = ( -/obj/structure/rack, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = -6; - pixel_y = 6 - }, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = 6; - pixel_y = 6 - }, -/obj/item/reagent_containers/cup/bottle/formaldehyde{ - pixel_x = 2; - pixel_y = -4 - }, -/turf/open/floor/iron/white, +/obj/effect/decal/cleanable/dirt, +/obj/effect/spawner/random/trash/cigbutt, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "oS" = ( -/obj/item/reagent_containers/syringe{ - pixel_x = 6; - pixel_y = 6 - }, -/obj/effect/decal/cleanable/blood/old, -/turf/open/floor/iron/freezer, +/obj/effect/decal/cleanable/cobweb, +/turf/open/floor/iron/dark, +/area/ruin/space/has_grav/powered) +"oU" = ( +/obj/structure/closet/crate, +/obj/item/storage/box/lethalshot, +/obj/effect/spawner/random/contraband/narcotics, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "oW" = ( -/obj/effect/spawner/random/trash/garbage, -/turf/open/floor/iron/cafeteria, +/obj/effect/spawner/random/entertainment/cigarette_pack, +/obj/effect/spawner/random/entertainment/lighter, +/turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "oX" = ( -/obj/item/flashlight/flare, +/obj/effect/decal/cleanable/cobweb, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "oY" = ( -/obj/structure/closet, -/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/remains/human, +/obj/effect/decal/cleanable/blood/splatter, +/obj/item/restraints/handcuffs/cable/zipties, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "pb" = ( -/obj/structure/reagent_dispensers/beerkeg, +/obj/structure/chair/stool, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "pc" = ( -/obj/structure/table, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = -4; - pixel_y = 6 - }, -/obj/item/clothing/mask/surgical{ - pixel_x = 6; - pixel_y = -4 - }, -/obj/effect/decal/cleanable/dirt/dust, +/obj/machinery/light/cold/directional/north, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "ph" = ( -/obj/machinery/light/small/dim/directional/north, +/obj/effect/decal/cleanable/cobweb, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "pk" = ( -/obj/effect/spawner/random/trash/graffiti, -/turf/closed/wall, +/obj/effect/turf_decal/tile/red/full, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "pq" = ( -/obj/structure/sink/directional/south, -/obj/effect/decal/cleanable/blood/old, +/obj/machinery/light/cold/directional/south, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "pz" = ( @@ -857,43 +874,35 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "pC" = ( -/obj/effect/spawner/random/trash/garbage, -/turf/open/floor/iron/freezer, +/obj/machinery/light/small/red/dim/directional/north, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) -"pZ" = ( -/obj/structure/table, -/obj/item/organ/liver/cybernetic{ - pixel_x = -4; - pixel_y = 5 - }, -/obj/item/organ/lungs/cybernetic{ - pixel_x = 5; - pixel_y = -2 +"pR" = ( +/obj/item/reagent_containers/cup/glass/bottle/rum{ + pixel_x = 6 }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"pZ" = ( +/obj/effect/decal/cleanable/blood/old, +/obj/effect/decal/cleanable/blood/drip, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "qf" = ( -/obj/effect/decal/cleanable/blood/old, -/obj/effect/decal/cleanable/blood/gibs/old, -/turf/open/floor/plating, +/obj/machinery/light/small/directional/south, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "qh" = ( -/obj/structure/closet/crate, -/obj/effect/turf_decal/bot, -/obj/effect/spawner/random/entertainment/money_small, -/turf/open/floor/iron/dark, +/obj/effect/decal/remains/robot, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "qt" = ( -/obj/structure/table, -/obj/machinery/microwave{ - pixel_y = 6 - }, +/obj/effect/spawner/random/trash/garbage, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "qC" = ( -/obj/structure/chair/wood{ - dir = 1 - }, +/obj/structure/filingcabinet, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "qO" = ( @@ -901,133 +910,158 @@ /turf/closed/wall, /area/ruin/space/has_grav/powered) "qP" = ( +/obj/structure/chair/stool, /obj/effect/spawner/random/trash/cigbutt, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) +"qX" = ( +/obj/item/flashlight/flare, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) "qZ" = ( -/obj/item/dice/d6{ - pixel_x = 6 - }, -/obj/effect/decal/cleanable/dirt/dust, +/obj/structure/bed/maint, +/obj/effect/spawner/random/bedsheet, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "rc" = ( -/turf/open/floor/carpet/red, +/obj/item/reagent_containers/cup/glass/bottle/whiskey{ + pixel_x = 4; + pixel_y = -8 + }, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "rd" = ( -/obj/effect/spawner/random/structure/crate_abandoned, +/obj/effect/spawner/random/maintenance/two, +/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "re" = ( -/obj/effect/decal/remains/human, -/obj/effect/decal/cleanable/blood/old, -/obj/item/flashlight{ - pixel_x = 6 - }, +/obj/machinery/light/small/red/directional/west, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "rg" = ( -/obj/structure/table, -/obj/effect/spawner/random/food_or_drink/booze, -/obj/item/stack/spacecash/c50{ - pixel_x = 4; - pixel_y = -4 - }, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) +"rm" = ( +/obj/effect/spawner/random/entertainment/cigarette_pack, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) "ro" = ( -/obj/structure/bed/maint, -/obj/effect/spawner/random/bedsheet, -/turf/open/floor/iron/grimy, +/obj/structure/closet/crate, +/obj/effect/turf_decal/bot, +/obj/effect/spawner/random/entertainment/money_small, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "rq" = ( -/obj/machinery/light/small/broken/directional/north, -/turf/open/floor/iron/dark, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "b"; + order = 1; + facing = 1; + route_mode = "pingpong" + }, +/obj/effect/spawner/human_npc/ruin/scav/den{ + dir = 1 + }, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "rs" = ( -/obj/effect/decal/cleanable/dirt, -/obj/item/trash/chips, -/turf/open/floor/iron/cafeteria, +/obj/item/clothing/head/soft/black{ + pixel_y = 6 + }, +/turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "rF" = ( -/obj/structure/closet, -/obj/effect/spawner/random/maintenance, +/obj/structure/bed/maint, +/obj/item/bedsheet/brown, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "rJ" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/spawner/random/trash/garbage, -/obj/effect/landmark/stealth_patrol{ - route = "e"; - order = 2; - wait = 0 - }, -/turf/open/floor/iron/dark, +/obj/item/clothing/shoes/sneakers/black, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "rK" = ( -/obj/effect/decal/cleanable/dirt/dust, -/turf/open/floor/iron/dark/smooth_large, +/obj/structure/bookcase/random, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "sf" = ( -/obj/effect/decal/cleanable/cobweb/cobweb2, -/turf/open/floor/wood, +/obj/effect/turf_decal/stripes/line{ + dir = 2 + }, +/turf/open/floor/iron/dark/smooth_large, /area/ruin/space/has_grav/powered) "sh" = ( -/obj/item/bodybag, -/obj/effect/decal/cleanable/dirt, -/turf/open/floor/iron/freezer, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "sq" = ( -/obj/item/clothing/suit/apron/surgical{ - pixel_y = -4 +/obj/item/reagent_containers/syringe{ + pixel_x = -5 }, +/obj/effect/decal/cleanable/blood/drip, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "sH" = ( -/obj/structure/displaycase/noalert, -/turf/open/floor/iron/dark/smooth_large, +/obj/structure/chair/wood{ + dir = 1 + }, +/obj/effect/spawner/random/trash/cigbutt, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "sZ" = ( -/obj/machinery/scav_camera/directional/north, -/turf/open/floor/iron/dark, +/obj/structure/closet/crate/zone_loot/medical, +/turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "th" = ( -/obj/item/bedsheet/brown, -/obj/effect/decal/cleanable/blood/drip, -/turf/open/floor/plating, +/obj/structure/closet/crate, +/obj/effect/turf_decal/bot, +/obj/effect/spawner/random/maintenance, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "tk" = ( -/obj/effect/decal/cleanable/blood/tracks{ - dir = 8 - }, +/obj/structure/kitchenspike, +/obj/effect/decal/cleanable/blood/drip, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "tn" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 8 + }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "tx" = ( -/obj/effect/decal/cleanable/blood/splatter, +/obj/structure/table, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = -6; + pixel_y = 5 + }, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = 6; + pixel_y = 7 + }, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = 0; + pixel_y = -3 + }, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "tD" = ( -/obj/effect/decal/cleanable/blood/old, -/obj/item/food/meat/slab/human{ - pixel_x = -4 - }, -/turf/open/floor/iron/freezer, +/obj/effect/spawner/random/structure/chair_flipped, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "tH" = ( -/obj/structure/chair{ - dir = 4 - }, -/obj/effect/spawner/random/trash/cigbutt, +/obj/machinery/scav_camera/directional/north, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "tO" = ( -/obj/machinery/light/small/directional/south, -/turf/open/floor/wood, +/obj/structure/rack, +/obj/item/bodypart/leg/right, +/obj/item/bodypart/arm/left, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "tR" = ( /obj/structure/closet/crate, @@ -1038,7 +1072,8 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "tT" = ( -/obj/effect/decal/cleanable/blood/drip, +/obj/structure/sink/directional/south, +/obj/effect/decal/cleanable/blood/old, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "ub" = ( @@ -1058,24 +1093,24 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "uf" = ( -/obj/item/reagent_containers/blood/o_minus{ - pixel_x = 5 - }, -/obj/effect/decal/cleanable/blood/drip, -/turf/open/floor/iron/white, +/obj/structure/sign/warning/no_smoking, +/turf/closed/wall, /area/ruin/space/has_grav/powered) "uj" = ( -/obj/item/kirbyplants/random, -/turf/open/floor/wood, +/obj/effect/decal/cleanable/dirt, +/obj/item/stack/sheet/plastic{ + amount = 5 + }, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "us" = ( /obj/effect/spawner/random/trash/garbage, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "uu" = ( -/obj/effect/decal/cleanable/blood/tracks{ - dir = 4 - }, +/obj/structure/table/optable, +/obj/effect/decal/remains/human, +/obj/effect/decal/cleanable/blood/gibs/old, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "ux" = ( @@ -1084,109 +1119,110 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "vh" = ( -/obj/structure/table, -/obj/item/surgicaldrill{ - pixel_y = 3 - }, -/obj/item/clothing/gloves/latex{ - pixel_x = -6; - pixel_y = -5 +/obj/item/reagent_containers/blood/o_minus{ + pixel_x = 5 }, -/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/blood/drip, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "vE" = ( -/obj/effect/decal/remains/human, -/obj/effect/decal/cleanable/blood/splatter, -/obj/item/restraints/handcuffs/cable/zipties, -/turf/open/floor/plating, +/obj/machinery/light/small/directional/north, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "vH" = ( -/obj/structure/closet/crate/zone_loot/medical, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 4 + }, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "vI" = ( -/obj/effect/turf_decal/tile/red/full, -/turf/open/floor/iron/dark, -/area/ruin/space/has_grav/powered) -"vO" = ( /obj/effect/decal/cleanable/blood/tracks{ - dir = 1 + dir = 4 }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) -"vX" = ( -/obj/item/stack/spacecash/c20{ - pixel_x = 4 - }, -/obj/effect/decal/cleanable/dirt/dust, -/turf/open/floor/wood, -/area/ruin/space/has_grav/powered) -"vY" = ( +"vO" = ( /obj/effect/decal/cleanable/blood/old, -/obj/item/stack/medical/gauze{ - pixel_x = 4 +/obj/item/food/meat/slab/human{ + pixel_x = -4 }, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) +"vX" = ( +/obj/structure/chair/office{ + dir = 2 + }, +/obj/effect/spawner/human_npc/ruin/scav/den/boss{ + dir = 2 + }, +/turf/open/floor/carpet/red, +/area/ruin/space/has_grav/powered) +"vY" = ( +/obj/structure/sign/poster/contraband/random, +/turf/closed/wall, +/area/ruin/space/has_grav/powered) "vZ" = ( -/obj/structure/filingcabinet, -/turf/open/floor/wood, +/obj/structure/closet/crate/bin, +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "wg" = ( -/obj/effect/decal/cleanable/cobweb, -/turf/open/floor/iron/grimy, +/obj/machinery/light/small/red/directional/east, +/obj/item/stack/rods{ + amount = 2 + }, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "wF" = ( -/obj/structure/closet/crate/freezer, -/obj/item/reagent_containers/blood/random, +/obj/item/bodybag, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "wR" = ( +/obj/structure/closet/crate/freezer/blood, /obj/effect/decal/cleanable/dirt/dust, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "wW" = ( -/obj/structure/kitchenspike, -/obj/effect/decal/cleanable/blood/old, -/obj/effect/decal/cleanable/blood/gibs/old, +/obj/machinery/light/cold/dim/directional/south, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "xm" = ( -/obj/item/storage/briefcase{ - pixel_x = -4 - }, -/turf/open/floor/wood, +/obj/structure/closet/crate, +/obj/effect/spawner/random/maintenance/two, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "xp" = ( -/obj/effect/spawner/random/entertainment/cigarette_pack, -/obj/effect/decal/cleanable/dirt/dust, -/turf/open/floor/plating, +/obj/structure/displaycase/noalert, +/turf/open/floor/iron/dark/smooth_large, /area/ruin/space/has_grav/powered) "xq" = ( +/obj/effect/decal/cleanable/dirt, +/obj/machinery/light/small/red/dim/directional/north, +/turf/open/floor/plating/rust, +/area/ruin/space/has_grav/powered) +"xt" = ( /obj/structure/table, -/obj/item/organ/heart/cybernetic{ +/obj/item/reagent_containers/cup/beaker/organ_jar{ pixel_x = -5; + pixel_y = 6 + }, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = 6; pixel_y = 4 }, -/obj/item/organ/eyes/robotic/basic{ - pixel_x = 6 +/obj/item/reagent_containers/cup/bottle/formaldehyde{ + pixel_y = -5 }, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) -"xt" = ( -/obj/machinery/scav_camera/directional/south{ - facing_offset = 45; - sweep = 45 - }, -/obj/effect/decal/cleanable/blood/tracks{ - dir = 1 - }, -/turf/open/floor/iron/dark, -/area/ruin/space/has_grav/powered) "xz" = ( -/obj/structure/sign/warning/biohazard, -/turf/closed/wall, +/obj/effect/decal/remains/human, +/obj/effect/decal/cleanable/blood/old, +/obj/item/flashlight{ + pixel_x = 6 + }, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "xZ" = ( /obj/structure/closet/crate/large, @@ -1194,48 +1230,65 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "yj" = ( -/obj/effect/spawner/random/trash/garbage, -/turf/open/floor/iron/dark, +/obj/structure/table/rolling, +/obj/item/surgical_drapes, +/obj/item/stack/medical/gauze, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "yr" = ( -/obj/structure/sign/poster/contraband/random, -/turf/closed/wall, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "yw" = ( /obj/structure/closet/crate/freezer, +/obj/item/reagent_containers/blood/random, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "yF" = ( -/obj/effect/spawner/random/trash/food_packaging, -/turf/open/floor/iron/cafeteria, +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "yG" = ( -/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, -/obj/effect/decal/cleanable/blood/oil, +/obj/structure/table, +/obj/item/bodypart/arm/right/robot{ + pixel_x = -3; + pixel_y = 3 + }, +/obj/item/weldingtool{ + pixel_x = 6; + pixel_y = -6 + }, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "yQ" = ( -/obj/item/reagent_containers/cup/glass/bottle/rum{ - pixel_x = 6 +/obj/structure/rack, +/obj/item/coin/gold{ + pixel_x = -5 }, -/obj/effect/decal/cleanable/dirt, -/turf/open/floor/plating, +/obj/item/coin/silver{ + pixel_x = 5; + pixel_y = 4 + }, +/turf/open/floor/iron/dark/smooth_large, /area/ruin/space/has_grav/powered) "yR" = ( /obj/effect/decal/cleanable/dirt, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "zh" = ( -/obj/item/cigarette{ - pixel_x = 4; +/obj/structure/table/wood, +/obj/item/reagent_containers/cup/glass/bottle/whiskey{ pixel_y = 6 }, +/obj/item/reagent_containers/cup/glass/drinkingglass{ + pixel_x = 8 + }, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "zq" = ( -/obj/item/clothing/under/color/grey, -/obj/effect/decal/cleanable/dirt, -/turf/open/floor/iron/grimy, +/obj/structure/closet/crate, +/obj/item/bodypart/leg/left/robot, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "zw" = ( /obj/machinery/light/small/directional/south, @@ -1248,19 +1301,27 @@ /area/ruin/space/has_grav/powered) "zF" = ( /obj/effect/decal/cleanable/blood/tracks{ - dir = 4 + dir = 1 }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "zI" = ( -/obj/structure/table/optable, -/obj/effect/decal/remains/human, -/obj/effect/decal/cleanable/blood/gibs/old, +/obj/structure/table, +/obj/item/circular_saw{ + pixel_y = 4 + }, +/obj/item/cautery{ + pixel_x = 6; + pixel_y = -4 + }, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "zZ" = ( -/obj/effect/decal/cleanable/cobweb, -/turf/open/floor/plating, +/obj/item/stack/spacecash/c20{ + pixel_x = 4 + }, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "Ad" = ( /obj/effect/turf_decal/bot, @@ -1271,24 +1332,37 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "AG" = ( -/obj/effect/decal/cleanable/dirt/dust, +/obj/machinery/light/small/red/directional/south, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "Be" = ( -/obj/item/stack/medical/suture, -/obj/effect/decal/cleanable/blood/old, +/obj/structure/table, +/obj/item/surgicaldrill{ + pixel_y = 3 + }, +/obj/item/clothing/gloves/latex{ + pixel_x = -6; + pixel_y = -5 + }, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "Bf" = ( -/obj/item/trash/can, +/obj/machinery/light/warm/directional/north, +/obj/structure/table, +/obj/item/storage/box/donkpockets{ + pixel_y = 4 + }, +/obj/item/kitchen/fork{ + pixel_x = 8 + }, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "Bp" = ( -/obj/item/reagent_containers/syringe{ - pixel_x = -5 - }, -/obj/effect/decal/cleanable/blood/drip, -/turf/open/floor/iron/white, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "Br" = ( /obj/item/stack/sheet/cardboard{ @@ -1298,31 +1372,39 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "BG" = ( -/obj/machinery/light/small/directional/north, -/turf/open/floor/iron/dark, +/obj/effect/spawner/random/trash/cigbutt, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "BU" = ( -/obj/structure/reagent_dispensers/water_cooler, +/obj/item/trash/can, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "Ca" = ( -/obj/effect/decal/cleanable/dirt/dust, -/turf/open/floor/iron/dark, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "CG" = ( -/obj/machinery/iv_drip, -/obj/effect/decal/cleanable/blood/old, -/turf/open/floor/iron/white, +/obj/effect/decal/cleanable/dirt/dust, +/obj/machinery/light/small/red/dim/directional/north, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "CN" = ( /obj/structure/reagent_dispensers/fueltank, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Do" = ( -/obj/item/storage/box/bodybags, -/obj/item/storage/organbox{ - pixel_y = 8 +/obj/structure/table, +/obj/item/scalpel{ + pixel_x = -6; + pixel_y = 4 + }, +/obj/item/hemostat{ + pixel_x = 4 + }, +/obj/item/retractor{ + pixel_y = -5 }, +/obj/effect/decal/cleanable/dirt/dust, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "Dt" = ( @@ -1333,71 +1415,83 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Dx" = ( -/obj/effect/decal/cleanable/cobweb, +/obj/structure/table, +/obj/item/organ/heart/cybernetic{ + pixel_x = -5; + pixel_y = 4 + }, +/obj/item/organ/eyes/robotic/basic{ + pixel_x = 6 + }, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "DE" = ( -/obj/structure/sign/warning/no_smoking, -/turf/closed/wall, +/obj/item/clothing/gloves/latex{ + pixel_x = 6 + }, +/obj/effect/decal/cleanable/blood/splatter, +/turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "DG" = ( -/obj/effect/decal/cleanable/dirt, +/obj/effect/spawner/random/trash/cigbutt, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "DK" = ( -/obj/structure/closet/cabinet, -/obj/item/clothing/head/fedora, -/turf/open/floor/plating, +/obj/effect/decal/cleanable/dirt/dust, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "DO" = ( -/obj/structure/table/rolling, -/obj/item/surgical_drapes, -/obj/item/stack/medical/gauze, -/turf/open/floor/iron/freezer, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "DV" = ( -/obj/structure/closet/emcloset, +/obj/effect/decal/cleanable/dirt/dust, +/obj/machinery/light/small/red/dim/directional/east, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "DY" = ( /obj/effect/turf_decal/tile/red/full, -/obj/effect/decal/cleanable/dirt, -/obj/effect/landmark/stealth_patrol{ - route = "a"; - order = 2; - wait = 0 - }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "Eh" = ( -/obj/machinery/light/warm/directional/east, +/obj/structure/reagent_dispensers/beerkeg, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "Eu" = ( -/obj/effect/decal/cleanable/dirt, -/obj/item/stack/sheet/plastic{ - amount = 5 +/obj/structure/table, +/obj/item/knife/butcher{ + pixel_y = 5 + }, +/obj/item/stack/spacecash/c200{ + pixel_x = -6; + pixel_y = -4 }, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Ev" = ( -/obj/effect/spawner/human_npc/ruin/scav/den{ - dir = 8 +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "d"; + order = 1; + facing = 4; + chatter = 1; + route_mode = "pingpong" }, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "EG" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/decal/cleanable/blood/drip, -/turf/open/floor/iron/dark, +/obj/structure/mop_bucket, +/obj/item/mop, +/turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "ET" = ( -/obj/structure/closet, -/obj/item/storage/medkit/regular, +/obj/item/radio{ + pixel_x = -4 + }, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "Fq" = ( -/obj/structure/closet/crate/freezer/blood, +/obj/machinery/smartfridge/organ, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "Fy" = ( @@ -1405,26 +1499,38 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "FC" = ( -/obj/machinery/light/small/red/directional/west, +/obj/effect/decal/cleanable/cobweb, +/obj/machinery/light/small/red/dim/directional/west, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "FH" = ( -/obj/machinery/light/small/red/directional/east, -/turf/open/floor/plating/rust, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/spawner/random/trash/garbage, +/obj/effect/landmark/stealth_patrol{ + route = "e"; + order = 2; + wait = 0 + }, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "FM" = ( -/obj/machinery/light/small/directional/south, -/obj/effect/decal/cleanable/blood/tracks{ - dir = 8 +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt, +/obj/effect/landmark/stealth_patrol{ + route = "a"; + order = 2; + wait = 0 }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "FO" = ( -/obj/effect/spawner/random/trash/garbage, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "Ge" = ( +/obj/structure/kitchenspike, /obj/effect/decal/cleanable/blood/old, +/obj/effect/decal/cleanable/blood/gibs/old, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "Gh" = ( @@ -1434,41 +1540,33 @@ /area/ruin/space/has_grav/powered) "Gn" = ( /obj/effect/turf_decal/tile/red/full, -/obj/effect/landmark/stealth_patrol{ - route = "d"; - order = 1; - facing = 4; - chatter = 1; - route_mode = "pingpong" - }, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "Gp" = ( -/obj/machinery/light/small/red/directional/east, -/obj/item/stack/rods{ - amount = 2 +/obj/effect/turf_decal/tile/red/full, +/obj/effect/landmark/stealth_patrol{ + route = "e"; + order = 3; + facing = 4 }, -/turf/open/floor/plating/rust, +/obj/effect/spawner/human_npc/ruin/scav/den/lookout{ + dir = 4 + }, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "Gv" = ( -/obj/structure/bed/medical, -/obj/item/restraints/handcuffs/cable/zipties, -/obj/effect/decal/cleanable/blood/old, +/obj/item/clothing/suit/apron/surgical, +/obj/effect/decal/cleanable/blood/drip, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) +"Gx" = ( +/obj/structure/bed/maint, +/obj/item/bedsheet/brown, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) "GE" = ( -/obj/structure/table/wood, -/obj/item/stack/spacecash/c500{ - pixel_x = 4 - }, -/obj/item/pen{ - pixel_x = -6 - }, -/obj/item/folder/red{ - pixel_x = -8; - pixel_y = 4 - }, -/turf/open/floor/carpet/red, +/obj/machinery/scav_camera/directional/south, +/turf/open/floor/iron/dark/smooth_large, /area/ruin/space/has_grav/powered) "GH" = ( /obj/effect/spawner/random/structure/crate_abandoned, @@ -1476,115 +1574,92 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "GI" = ( -/obj/structure/closet/crate/bin, -/obj/effect/spawner/random/trash/garbage, +/obj/structure/table, +/obj/item/multitool{ + pixel_x = -4 + }, +/obj/item/stack/cable_coil{ + pixel_x = 6 + }, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "GK" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/landmark/stealth_patrol{ - route = "e"; - order = 3; - facing = 4 - }, /obj/effect/spawner/human_npc/ruin/scav/den/lookout{ - dir = 4 + dir = 8 }, -/turf/open/floor/iron/dark, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "GO" = ( -/obj/effect/decal/cleanable/blood/drip, +/obj/effect/spawner/random/structure/crate_abandoned, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "Hj" = ( -/obj/effect/turf_decal/stripes/line{ - dir = 2 - }, -/turf/open/floor/iron/dark/smooth_large, +/turf/open/floor/carpet/red, /area/ruin/space/has_grav/powered) "Hp" = ( -/obj/structure/closet/crate/freezer, +/obj/effect/decal/cleanable/dirt/dust, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "Hq" = ( +/obj/effect/decal/cleanable/dirt, /obj/effect/decal/cleanable/blood/tracks{ - dir = 8 + dir = 1 }, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "Ht" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/landmark/stealth_patrol{ - route = "b"; - order = 1; - facing = 1; - route_mode = "pingpong" - }, -/obj/effect/spawner/human_npc/ruin/scav/den{ - dir = 1 - }, +/obj/effect/decal/cleanable/vomit/old, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "HH" = ( -/obj/structure/kitchenspike, -/obj/effect/decal/cleanable/blood/drip, +/obj/machinery/door/airlock/freezer{ + name = "Cold Room"; + req_one_access = list("scav") + }, +/obj/effect/turf_decal/tile/red/full, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "HM" = ( -/obj/structure/closet/secure_closet/freezer/meat, -/turf/open/floor/iron/freezer, +/obj/structure/sign/warning/biohazard, +/turf/closed/wall, /area/ruin/space/has_grav/powered) "HR" = ( -/obj/item/reagent_containers/cup/glass/bottle/beer{ - pixel_x = 6 - }, -/obj/item/cigarette{ - pixel_x = -6 - }, -/turf/open/floor/iron/grimy, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "Ik" = ( -/obj/structure/table, -/obj/item/reagent_containers/cup/glass/bottle/whiskey{ - pixel_x = -6; - pixel_y = 8 - }, -/obj/item/toy/cards/deck{ - pixel_x = 5 - }, +/obj/structure/closet/secure_closet/freezer/fridge, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "Iq" = ( -/obj/structure/table, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = -5; - pixel_y = 6 - }, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = 6; - pixel_y = 4 - }, -/obj/item/reagent_containers/cup/bottle/formaldehyde{ - pixel_y = -5 - }, +/obj/structure/kitchenspike, +/obj/effect/decal/cleanable/blood/old, +/obj/effect/decal/cleanable/blood/gibs/old, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "Iz" = ( -/obj/structure/chair/stool, -/turf/open/floor/plating, +/obj/effect/spawner/random/food_or_drink/cups, +/turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "II" = ( -/obj/effect/decal/cleanable/cobweb, -/turf/open/floor/plating/rust, +/obj/structure/closet/emcloset, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "IL" = ( /obj/effect/decal/cleanable/dirt/dust, -/obj/machinery/light/small/red/directional/west, +/obj/item/cigbutt, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) +"IN" = ( +/obj/structure/closet/crate/wooden, +/obj/effect/spawner/random/food_or_drink/booze, +/obj/effect/spawner/random/food_or_drink/booze, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) "JJ" = ( -/obj/structure/mop_bucket, -/obj/item/mop, +/obj/machinery/computer/operating{ + dir = 2 + }, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "Kb" = ( @@ -1593,151 +1668,130 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "KD" = ( -/obj/structure/table/wood, -/obj/item/flashlight/lamp/green{ - pixel_x = -4; - pixel_y = 6 - }, -/turf/open/floor/carpet/red, +/obj/machinery/light/small/directional/south, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "KS" = ( -/obj/machinery/light/small/directional/south, -/turf/open/floor/iron/dark, +/obj/machinery/light/small/red/dim/directional/south, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Lh" = ( -/obj/structure/rack, -/obj/item/coin/gold{ - pixel_x = -5 - }, -/obj/item/coin/silver{ - pixel_x = 5; - pixel_y = 4 +/obj/effect/landmark/stealth_restricted{ + allowed = 0 }, /turf/open/floor/iron/dark/smooth_large, /area/ruin/space/has_grav/powered) "Lp" = ( -/obj/effect/decal/cleanable/vomit/old, +/obj/effect/decal/cleanable/blood/old, +/obj/item/stack/medical/gauze{ + pixel_x = 4 + }, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "LH" = ( -/obj/structure/table, -/obj/item/wrench, -/obj/item/crowbar{ - pixel_y = 6 +/obj/effect/spawner/human_npc/ruin/scav/den{ + dir = 8 }, -/turf/open/floor/plating, +/turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "LO" = ( -/obj/effect/decal/cleanable/dirt/dust, -/turf/open/floor/wood, +/obj/structure/rack, +/obj/item/storage/briefcase{ + pixel_y = 4 + }, +/obj/effect/turf_decal/bot, +/turf/open/floor/iron/dark/smooth_large, /area/ruin/space/has_grav/powered) "LZ" = ( -/obj/effect/turf_decal/tile/red/full, +/obj/item/trash/chips, /obj/effect/decal/cleanable/dirt, -/obj/effect/landmark/stealth_patrol{ - route = "e"; - order = 1; - facing = 1 - }, -/turf/open/floor/iron/dark, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Md" = ( -/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/dirt/dust, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "Mi" = ( -/obj/structure/closet/cabinet, -/turf/open/floor/wood, -/area/ruin/space/has_grav/powered) -"Mo" = ( -/obj/structure/table, -/obj/item/scalpel{ - pixel_x = -6; - pixel_y = 4 - }, -/obj/item/hemostat{ +/obj/structure/table/wood, +/obj/item/stack/spacecash/c500{ pixel_x = 4 }, -/obj/item/retractor{ - pixel_y = -5 +/obj/item/pen{ + pixel_x = -6 + }, +/obj/item/folder/red{ + pixel_x = -8; + pixel_y = 4 + }, +/turf/open/floor/carpet/red, +/area/ruin/space/has_grav/powered) +"Mo" = ( +/obj/item/clothing/suit/apron/surgical{ + pixel_y = -4 }, -/obj/effect/decal/cleanable/dirt/dust, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "MI" = ( -/obj/machinery/light/cold/directional/north, +/obj/item/storage/box/bodybags, +/obj/item/storage/organbox{ + pixel_y = 8 + }, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "MJ" = ( -/obj/item/radio{ - pixel_x = -4 +/obj/item/reagent_containers/cup/glass/bottle/beer{ + pixel_x = 6 + }, +/obj/item/cigarette{ + pixel_x = -6 }, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "Nc" = ( -/obj/structure/rack, -/obj/item/bodypart/leg/right, -/obj/item/bodypart/arm/left, +/obj/item/storage/belt/utility, +/obj/effect/decal/cleanable/dirt/dust, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Nu" = ( -/obj/machinery/door/airlock/freezer{ - name = "Cold Room"; - req_one_access = list("scav") - }, -/obj/effect/turf_decal/tile/red/full, -/turf/open/floor/iron/freezer, +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "NB" = ( -/obj/effect/landmark/stealth_restricted{ - allowed = 0 - }, -/turf/open/floor/iron/dark/smooth_large, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "NH" = ( -/obj/effect/decal/cleanable/dirt, -/obj/effect/spawner/random/trash/cigbutt, -/turf/open/floor/iron/dark, +/obj/effect/decal/cleanable/blood/old, +/obj/effect/decal/cleanable/blood/drip, +/turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "NO" = ( -/obj/effect/spawner/random/trash/cigbutt, -/turf/open/floor/iron/cafeteria, +/obj/structure/closet, +/obj/effect/spawner/random/maintenance, +/turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "NP" = ( +/obj/effect/decal/cleanable/dirt, /obj/structure/table, -/obj/item/bodypart/arm/right/robot{ - pixel_x = -3; - pixel_y = 3 - }, -/obj/item/weldingtool{ - pixel_x = 6; - pixel_y = -6 +/obj/effect/spawner/random/food_or_drink/dinner, +/obj/item/kitchen/fork{ + pixel_x = -8 }, -/turf/open/floor/plating, +/turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "Od" = ( -/obj/structure/table, -/obj/item/circular_saw{ - pixel_y = 4 - }, -/obj/item/cautery{ - pixel_x = 6; - pixel_y = -4 - }, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "Ok" = ( -/obj/structure/chair/stool, -/turf/open/floor/iron/grimy, +/obj/machinery/light/small/red/dim/directional/east, +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "Os" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/landmark/stealth_patrol{ - route = "a"; - order = 4; - facing = 4 - }, -/turf/open/floor/iron/dark, +/obj/machinery/iv_drip, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "OP" = ( /obj/structure/table, @@ -1751,88 +1805,87 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "OT" = ( -/obj/machinery/light/small/red/dim/directional/west, -/obj/effect/spawner/random/trash/cigbutt, -/turf/open/floor/plating, +/obj/machinery/light/small/directional/north, +/obj/structure/closet/crate/secure/scav_vault, +/obj/effect/turf_decal/bot, +/turf/open/floor/iron/dark/smooth_large, /area/ruin/space/has_grav/powered) "Pc" = ( -/obj/structure/bed/maint, -/obj/item/bedsheet/brown, -/obj/effect/decal/cleanable/dirt, +/obj/effect/spawner/random/trash/food_packaging, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "Pf" = ( -/obj/structure/closet/crate, -/obj/item/storage/box/lethalshot, -/obj/effect/spawner/random/contraband/narcotics, -/turf/open/floor/plating, +/obj/structure/closet/cabinet, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "Pg" = ( -/obj/effect/spawner/random/entertainment/cigarette_pack, -/obj/effect/spawner/random/entertainment/lighter, +/obj/item/storage/backpack/duffelbag, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "Pp" = ( -/obj/structure/closet/crate/wooden, -/obj/effect/turf_decal/bot, +/obj/structure/chair{ + dir = 4 + }, +/obj/effect/spawner/random/trash/cigbutt, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "Pq" = ( -/obj/effect/decal/cleanable/blood/gibs/robot_debris/limb, -/obj/effect/decal/cleanable/blood/oil, -/turf/open/floor/plating, +/obj/machinery/light/warm/directional/east, +/turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "Ps" = ( -/obj/structure/closet/crate, -/obj/effect/turf_decal/bot, -/obj/effect/spawner/random/maintenance, -/obj/effect/decal/cleanable/dirt, +/obj/machinery/light/small/directional/east, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "Pw" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/decal/cleanable/dirt, -/obj/effect/decal/cleanable/cobweb, -/turf/open/floor/plating/rust, +/obj/machinery/light/cold/dim/directional/north, +/obj/structure/closet/crate/freezer, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "PF" = ( -/obj/machinery/light/warm/directional/north, -/obj/structure/table, -/obj/item/storage/box/donkpockets{ - pixel_y = 4 - }, -/obj/item/kitchen/fork{ - pixel_x = 8 - }, +/obj/effect/spawner/random/trash/food_packaging, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "PS" = ( -/obj/item/clothing/gloves/latex{ - pixel_x = 6 +/obj/structure/table, +/obj/item/reagent_containers/cup/beaker/organ_jar{ + pixel_x = -4; + pixel_y = 6 }, -/obj/effect/decal/cleanable/blood/splatter, +/obj/item/clothing/mask/surgical{ + pixel_x = 6; + pixel_y = -4 + }, +/obj/effect/decal/cleanable/dirt/dust, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "QF" = ( -/obj/structure/bed/maint, -/obj/item/bedsheet/brown, +/obj/item/dice/d6{ + pixel_x = 6 + }, +/obj/effect/decal/cleanable/dirt/dust, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "QP" = ( -/obj/structure/kitchenspike, -/obj/effect/decal/cleanable/blood/old, -/obj/effect/decal/cleanable/blood/gibs/old, +/obj/effect/spawner/random/trash/garbage, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "QT" = ( -/obj/structure/chair/comfy/black{ - dir = 4 - }, -/turf/open/floor/wood, +/obj/item/ammo_box/magazine/m9mm, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating, +/area/ruin/space/has_grav/powered) +"Rj" = ( +/obj/structure/closet/crate/wooden, +/obj/effect/spawner/random/food_or_drink/booze, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Ru" = ( -/obj/machinery/light/cold/directional/south, -/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/blood/splatter, +/obj/effect/spawner/human_npc/ruin/scav/den{ + dir = 8 + }, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "Ry" = ( @@ -1851,44 +1904,47 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Sa" = ( -/obj/structure/chair/stool, -/turf/open/floor/iron/cafeteria, +/obj/machinery/door/airlock{ + name = "Bunks"; + req_one_access = list("scav") + }, +/obj/effect/turf_decal/tile/red/full, +/turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "Sm" = ( -/obj/effect/decal/cleanable/dirt, -/turf/open/floor/iron/dark, +/obj/item/reagent_containers/syringe{ + pixel_x = 6; + pixel_y = 6 + }, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "SR" = ( -/obj/item/bedsheet/brown, +/obj/effect/turf_decal/tile/red/full, /obj/effect/decal/cleanable/dirt, -/turf/open/floor/plating, +/obj/effect/landmark/stealth_patrol{ + route = "e"; + order = 1; + facing = 1 + }, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "SV" = ( /obj/effect/decal/cleanable/blood/splatter, -/obj/effect/spawner/human_npc/ruin/scav/den{ - dir = 8 - }, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "SW" = ( -/obj/effect/decal/cleanable/blood/drip, +/obj/structure/closet/crate/zone_loot/medical, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "Ta" = ( -/obj/effect/turf_decal/tile/red/full, -/obj/effect/landmark/stealth_patrol{ - route = "d"; - order = 2; - facing = 1 - }, -/obj/effect/spawner/human_npc/ruin/scav/den/gunner{ - dir = 1 - }, +/obj/item/clothing/under/color/grey, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "Tl" = ( -/obj/machinery/light/cold/dim/directional/south, -/turf/open/floor/iron/freezer, +/obj/effect/spawner/random/trash/cigbutt, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "Tr" = ( /obj/structure/ore_box, @@ -1896,24 +1952,23 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Tw" = ( -/obj/structure/rack, -/obj/item/stack/spacecash/c100{ - pixel_y = 4 +/obj/item/storage/briefcase{ + pixel_x = -4 }, -/obj/effect/turf_decal/bot, -/turf/open/floor/iron/dark/smooth_large, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "TH" = ( -/obj/item/reagent_containers/cup/glass/bottle/beer{ - pixel_x = -6; - pixel_y = 4 +/obj/structure/table, +/obj/effect/spawner/random/food_or_drink/booze, +/obj/item/reagent_containers/cup/glass/drinkingglass{ + pixel_x = 8 }, -/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "TJ" = ( -/obj/structure/closet/crate/zone_loot/medical, -/turf/open/floor/iron/freezer, +/obj/effect/decal/cleanable/dirt/dust, +/obj/effect/decal/cleanable/cobweb/cobweb2, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "TV" = ( /obj/effect/turf_decal/tile/red/full, @@ -1930,9 +1985,8 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "UH" = ( -/obj/structure/closet/crate/wooden, -/obj/effect/spawner/random/food_or_drink/booze, -/obj/effect/spawner/random/food_or_drink/booze, +/obj/machinery/light/small/red/dim/directional/west, +/obj/effect/spawner/random/trash/cigbutt, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "UM" = ( @@ -1941,23 +1995,20 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "UW" = ( -/obj/structure/rack, -/obj/item/knife/combat/survival{ - pixel_y = 4 - }, -/turf/open/floor/plating, +/obj/effect/decal/cleanable/cobweb/cobweb2, +/obj/machinery/light/small/red/dim/directional/north, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "VG" = ( -/obj/machinery/door/airlock{ - name = "Bunks"; - req_one_access = list("scav") - }, -/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "VN" = ( -/obj/effect/spawner/random/trash/garbage, -/turf/open/floor/iron/white, +/obj/machinery/light/small/directional/south, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 8 + }, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "VQ" = ( /obj/structure/closet/crate, @@ -1968,51 +2019,32 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "VX" = ( -/obj/structure/closet/crate/freezer, -/obj/item/food/meat/slab/human, +/obj/effect/spawner/random/trash/garbage, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "VY" = ( -/obj/structure/table/wood, -/obj/item/reagent_containers/cup/glass/bottle/whiskey{ - pixel_y = 6 - }, -/obj/item/reagent_containers/cup/glass/drinkingglass{ - pixel_x = 8 - }, -/turf/open/floor/wood, +/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, +/obj/effect/decal/cleanable/blood/oil, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Wc" = ( -/obj/structure/closet/crate, -/obj/effect/spawner/random/maintenance/two, +/obj/structure/chair/stool, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Wg" = ( -/obj/effect/spawner/random/maintenance/two, -/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, -/turf/open/floor/plating/rust, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/spawner/random/trash/garbage, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "Wu" = ( -/obj/effect/decal/cleanable/dirt, +/obj/structure/closet/crate/freezer/blood, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "WJ" = ( -/obj/structure/table/wood, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = 0; - pixel_y = 6 - }, -/obj/item/paper/crumpled/bloody{ - pixel_x = -6; - pixel_y = -4 - }, -/obj/item/paper{ - name = "price list"; - default_raw_text = "Hearts 4000. Livers 2500. Lungs 2000. Eyes 1500 the pair. Chrome by weight. No refunds."; - pixel_x = 8; - pixel_y = 2 +/obj/structure/chair/wood{ + dir = 1 }, -/turf/open/floor/carpet/red, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "Xe" = ( /obj/effect/turf_decal/stripes/line{ @@ -2032,8 +2064,10 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Xn" = ( -/obj/effect/decal/cleanable/blood/oil, -/turf/open/floor/iron/dark, +/obj/structure/bed/medical, +/obj/item/restraints/handcuffs/cable/zipties, +/obj/effect/decal/cleanable/blood/old, +/turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "Xz" = ( /obj/structure/closet/crate, @@ -2042,40 +2076,47 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "XE" = ( -/obj/effect/decal/cleanable/cobweb/cobweb2, +/obj/effect/decal/cleanable/dirt/dust, +/obj/machinery/light/small/red/directional/south, /turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "XI" = ( -/obj/item/reagent_containers/cup/glass/bottle/whiskey{ - pixel_x = 4; - pixel_y = -8 - }, +/obj/item/kirbyplants/random, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "XJ" = ( -/obj/item/clothing/suit/apron/surgical, /obj/effect/decal/cleanable/blood/drip, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "XK" = ( -/obj/effect/spawner/random/trash/cigbutt, -/turf/open/floor/iron/dark, +/obj/effect/turf_decal/tile/red/full, +/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/cobweb, +/turf/open/floor/plating/rust, /area/ruin/space/has_grav/powered) "XO" = ( -/obj/machinery/smartfridge/organ, +/obj/structure/closet/secure_closet/freezer/meat, /turf/open/floor/iron/freezer, /area/ruin/space/has_grav/powered) "Yd" = ( -/obj/effect/turf_decal/tile/red/full, +/obj/structure/table, +/obj/item/toy/cards/deck{ + pixel_y = 4 + }, +/obj/item/reagent_containers/cup/glass/bottle/vodka{ + pixel_x = -8; + pixel_y = 8 + }, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "Yj" = ( -/obj/machinery/iv_drip, -/obj/effect/decal/cleanable/blood/drip, -/turf/open/floor/iron/white, +/obj/machinery/light/small/red/dim/directional/north, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) "Yx" = ( -/obj/machinery/light/small/red/dim/directional/south, +/obj/item/bedsheet/brown, +/obj/effect/decal/cleanable/blood/drip, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "YE" = ( @@ -2083,45 +2124,40 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "YK" = ( -/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, +/obj/effect/decal/cleanable/blood/gibs/robot_debris/limb, +/obj/effect/decal/cleanable/blood/oil, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Zk" = ( -/obj/effect/spawner/random/trash/food_packaging, +/obj/effect/spawner/random/trash/cigbutt, /turf/open/floor/iron/grimy, /area/ruin/space/has_grav/powered) "Zo" = ( -/obj/effect/spawner/random/food_or_drink/cups, +/obj/structure/table, +/obj/effect/spawner/random/food_or_drink/snack, +/obj/item/reagent_containers/cup/glass/mug{ + pixel_x = -6 + }, /turf/open/floor/iron/cafeteria, /area/ruin/space/has_grav/powered) "ZB" = ( -/obj/structure/table, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = -6; - pixel_y = 5 - }, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = 6; - pixel_y = 7 - }, -/obj/item/reagent_containers/cup/beaker/organ_jar{ - pixel_x = 0; - pixel_y = -3 - }, +/obj/structure/closet/crate/freezer, /turf/open/floor/iron/white, /area/ruin/space/has_grav/powered) "ZF" = ( -/obj/structure/bookcase/random, -/turf/open/floor/wood, +/obj/effect/decal/cleanable/blood/gibs/robot_debris/old, +/turf/open/floor/plating, /area/ruin/space/has_grav/powered) "ZV" = ( -/obj/structure/sign/warning/secure_area, -/turf/closed/wall/r_wall, +/obj/effect/landmark/stealth_restricted, +/turf/open/floor/wood, /area/ruin/space/has_grav/powered) "ZX" = ( -/obj/structure/closet/crate/freezer/blood, -/obj/effect/decal/cleanable/dirt/dust, -/turf/open/floor/iron/white, +/obj/effect/spawner/random/trash/garbage, +/obj/effect/decal/cleanable/blood/tracks{ + dir = 8 + }, +/turf/open/floor/iron/dark, /area/ruin/space/has_grav/powered) (1,1,1) = {" @@ -2237,7 +2273,7 @@ ac ac ac qO -fS +bu aj ac ac @@ -2309,19 +2345,19 @@ ac ac ac ac +TJ +aP +xz fE aP +aP +Md +de re IL -aP -aP -AG FO FC -bu Md -II -AG ac ac ac @@ -2393,7 +2429,7 @@ ac ac ac ac -Md +xq ac ac ac @@ -2430,7 +2466,7 @@ aj aj aj aj -yr +vY aj aj aj @@ -2441,7 +2477,7 @@ aj aj aj aj -xz +HM aj aj aj @@ -2469,25 +2505,25 @@ ac ac ac aj -ro -wg -Ok +qZ +ph +cq ae -zq -ro +Ta +qZ +aj +oS +sh aj +Fq cL Ca -aj -XO -Dx -SW ad -HM +XO ad -xq +Dx ad -TJ +SW aj ac ac @@ -2512,24 +2548,24 @@ ac ac aj ae -HR -bw +MJ +Yd ae -bg +Zk ae -yr -al -Sm +vY +pC +DO aj -wF +yw ad -Wu +yr ad -oS +Sm ad ad -sh -Fq +wF +Wu aj ac ac @@ -2553,25 +2589,25 @@ ac ac ac aj -ro +qZ ae -Ok +cq ae -qZ +QF ae aj -yj +Nu al aj -ct +Pw ad -vY -pC +Lp +VX ad -DO +yj ad ad -yw +ct aj ac ac @@ -2595,25 +2631,25 @@ ac ac ac aj -ph -cq +mt +Pg ae -Ta +cg ae ae am -Sm +DO al aj -yw +ct ad ad ad ad ad ad -Lp -VX +Ht +hO aj aI aI @@ -2637,27 +2673,27 @@ ac ac ac aj -QF +rF ae -MJ -Yd -Zk +ET +nV +Pc ae aj -Sm -XK +DO +Tl aj ad ad -Ht -hO -hO -hO -hO -hO -hO -Nu -Pw +rq +pk +pk +pk +pk +pk +pk +HH +XK av aD aL @@ -2680,19 +2716,19 @@ ac ac aj ae -mt -Pg -Yd +yF +oW +nV ae -cg +VG aj -rq +pC al -pk -HH -SW +lp +tk +Ca ad -SW +Ca ad ad ad @@ -2721,25 +2757,25 @@ ac ac ac aj -ro -nV +qZ +rs ae -Yd +nV ae -Pc +mG aj al -mC +tD aj -wW -lp +Iq +pZ ad -tk +mC ad ad ad ad -Tl +wW aj ac ac @@ -2763,25 +2799,25 @@ ac ac ac aj -rF +NO ae -mt -Yd +yF +nV ae -ET +mS aj -Ca +sh al aj -dd -tD +oD +vO ad -tk +mC ad ad ad -Iq -pZ +xt +dd aj ac ac @@ -2808,7 +2844,7 @@ aj aj aj aj -VG +Sa aj aj aj @@ -2816,13 +2852,13 @@ al al aj aj -yr +vY aj aj an aj aj -yr +vY aj aj aj @@ -2847,26 +2883,26 @@ ac ac ac aj -mS +Ik aC -rs -mG -yF -oW +iz +Gn +PF +qt aj -cL -Sm +oS +DO al -yj -Sm -Sm +Nu +DO +DO +vI +zF +nL +zF +Hq zF -vO hW -vO -oD -vO -xt aj dB ux @@ -2889,27 +2925,27 @@ ac ac ac aj -qt +kS aC -Sa -mG -NO +pb +Gn +DG aC -yr -Sm +vY +DO +FM +DY +DY +kw +DY +DY +hi +DY +kw DY -vI -vI -tn -vI -vI jo -vI tn -vI -nL -Hq -yr +vY lB us aS @@ -2931,26 +2967,26 @@ ac ac ac aj -PF -Sa -NO -mG +Bf +pb +DG +Gn aC aC aj al -hi +Bp aj aj -xz +HM aj ak aj -yr +vY aj aj -vI -kw +DY +ZX aj ah aS @@ -2973,26 +3009,26 @@ ac ac ac aj -iz +TH aC aC -Gn -yF +Ev +PF aC aj -Sm -vI +Yj +DY aj +Ge +Mo +Hp QP sq -wR -VN -Bp aa -ZX +wR aj -tn -FM +kw +VN aj Ry aS @@ -3015,26 +3051,26 @@ ac ac ac aj +Eh +rg pb -DG -Sa -Ik +eW aC aC aO al -hi +Bp au -ZB +tx aa -Yj -Ge -Mo +gG +jj +Do aa -Hp +ZB au -vI -Hq +DY +tn aj aS aS @@ -3058,25 +3094,25 @@ ac ac aj aC -Bf +BU aC -kS -Sa +Zo +pb aC aj -Sm -tn +DO +kw aj -MI -tx -gG -jj +pc +SV +JJ +gu aa aa -Do +MI aj -vI -Hq +DY +tn aj aQ Dt @@ -3100,25 +3136,25 @@ ac ac aj aC -eW -TH -Ev +NP +hg +LH aC -Sa -yr +pb +vY al -vI -yr -pc +DY +vY +PS aa aa -SV +Ru aa -Ge -JJ +jj +EG aj -vI -gu +DY +ch aj Xg aS @@ -3141,26 +3177,26 @@ ac ac ac aj -BU -Sa -Zo +dq +pb +Iz aC -Eh -rg +Pq +kM aj -Sm -vI +DO +DY aj +tT +Hp +li +Od +DE +aa pq -wR +aj mu eg -PS -aa -Ru -aj -EG -ch aY yR eO @@ -3191,18 +3227,18 @@ aI aI aI al -vI -yr +DY +vY aa -tT +XJ aa -li +NH +zI Od -eg aa -DE -vI -yj +uf +DY +Nu aj eO aS @@ -3225,25 +3261,25 @@ ac ac ac aI -kM +em yR -NP -hg -LH +yG +Eu +df aS aI -Ca -hi +CG +Bp aj -MI -tT +pc +XJ aa -zI +uu aa -uf +vh aa aj -tn +kw al aj aS @@ -3267,26 +3303,26 @@ ac ac ac aI -dq +GI aS aS -Iz +Wc aS -Pq +YK aI al -vI +DY au -oQ +cj aa -CG -uu -vh +Os +vH +Be aa -XJ +Gv au -vI -NH +DY +oQ aj aS kW @@ -3312,24 +3348,24 @@ aI aS yR aS -df +Nc aS aS ap al -vI +DY aj -vH +sZ aa aa -uu -eg -Be -Gv +vH +Od +dO +Xn aj -tn +kw al -yr +vY aS aS aL @@ -3353,23 +3389,23 @@ ac aI aQ aS -yG +VY aS -Eu +uj aS au -XK -vI +Tl +DY aj aj -yr +vY aj ak aj -yr +vY aj aj -vI +DY al aj aS @@ -3393,25 +3429,25 @@ ac ac ac aI -Wc +xm aS aT aS -YK -em +ZF +QT aI al -cj -tn -vI -vI -vI -hi -vI -tn -hi -tn -Os +cv +kw +DY +DY +DY +Bp +DY +kw +Bp +kw +ky al aj CN @@ -3435,33 +3471,33 @@ ac ac ac aI -Nc +tO aS aS aS aS -GI +vZ aI -sZ -Sm -yj +tH +DO +Nu al al -dO +Ps +tn +zF +zF Hq -vO -vO -oD -vO -vO -Xn +zF +zF +fN aj -DV +II aS aS aS aB -aB +DV UF aj ac @@ -3480,11 +3516,11 @@ aA aj aj aj -yr +vY aj aj aj -yj +Nu al aj aj @@ -3519,31 +3555,31 @@ aA aA aA aA -vZ -xm -ZF -QT -VY -uj +qC +Tw +rK +dS +zh +XI aj al al al -tH -yj -Ps +Pp +Nu +th aI -fN -cv +ha +hJ ay eO aS -ky +qP aI ac ac ac -II +kt ac ac ac @@ -3557,35 +3593,35 @@ ax ac ac aA -Tw -rK +fa +hL aE aA -vZ +qC ab -dS -zh -XI -tO +ZV +bn +rc +KD aj -BG +vE al al al -Sm -Pp +DO +jA aI -th -ha +Yx +LZ aG -hJ +ic aS -qP +BG aI ac ac ac -kt +AG ac ac ac @@ -3599,22 +3635,22 @@ ax ac ac aA -fa +LO aE -hL -ZV -uj -bn -rc -rc -KD -qC +GE +br +XI +NB +Hj +Hj +jE +WJ aj al -LZ -hi -hi -ic +SR +Bp +Bp +lC al aW aI @@ -3642,34 +3678,34 @@ ac ac aA aE -NB -Hj +Lh +sf aH ab ab -rc -jE -WJ +Hj +vX +bh ab ao al -tn -Ca +kw +sh al -vI -Sm +DY +DO aI -jA +nJ aS ay aS yR -Yx +KS aI ac ac ac -AG +Md ac ac ac @@ -3683,35 +3719,35 @@ ax ac ac aA -bh +OT aE -rK +hL aA ab -LO -rc -rc -GE -br +DK +Hj +Hj +Mi +sH aj al -vI +DY aW aI -tn +kw al aI aS -vE +oY aG -hJ +ic aS aS aI ac ac ac -Md +FO ac ac ac @@ -3725,22 +3761,22 @@ ax ac ac aA -sH -Lh +xp +yQ aE aA -sf +UW ab ab ab ab -vX +zZ aj -XK -vI +Tl +DY aI aI -tn +kw al aI aI @@ -3776,26 +3812,26 @@ ab ab ab ab -Mi -yr -Ca -nJ +Pf +vY +mW +Wg aI aI -vI -KS +DY +qf aI -fN -SR +ha +hN ay eO aS -lC +iU aI ac ac ac -kt +AG ac ac ac @@ -3820,24 +3856,24 @@ aI aI aI aI -Sm -vI +DO +DY aI aW -vI -Sm +DY +DO aI -qf -hN +hI +rJ aG aS -iU -oY +GK +nz aI ac ac ac -AG +Md ac ac ac @@ -3855,18 +3891,18 @@ ac ac ac aI -zZ +oX us aS aS -OT -DK +UH +dA aI -Ca -vI +sh +DY al al -vI +DY al aI aI @@ -3897,7 +3933,7 @@ ac ac ac aI -UW +ht aS aS aB @@ -3905,23 +3941,23 @@ aS aS az al -rJ -vI -vI -GK +FH +DY +DY +Gp al aj aI -nz +dJ aP -mW +qh aP -Wg +rd aI ac ac ac -FO +de ac ac ac @@ -3939,31 +3975,31 @@ ac ac ac aI -Pf -xp -yQ +oU +rm +pR aS aS yR aI -Sm +DO al -Ca -Ca -Sm -qh -yr +sh +sh +DO +ro +vY aI -rd +GO aP -hI +lY aP aP aI ac ac ac -FO +de ac ac ac @@ -3981,31 +4017,31 @@ ac ac ac aI -ht -oX +Gx +qX aS -UH +IN aS -dA +Rj aI al al -yj -Sm +Ok +DO al al aj aI -XE +fS aP aP aP -dJ +zq aI ac ac ac -de +XE ac ac ac @@ -4034,7 +4070,7 @@ aj aj aj aj -aS +ha aj aj aI @@ -4076,20 +4112,20 @@ ac ac ac ac -Md +FO ac ac ac ac ac -Md +FO ac ac ac ac ac ac -Md +FO ac ac ac @@ -4118,20 +4154,20 @@ ac ac ac ac -XE +fS aP -GO -lY -FH -Md +HR +bw +bg +FO aP -Md +FO aP -Gp +wg aP +FO Md -AG -XE +fS ac ac ac From d72b5cf9979ad173dfd6b12f6a24d63b16980668 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 10:01:05 -0800 Subject: [PATCH 65/78] One knife backstab: any sharp knife cuts the throat from behind with tg's slit maths, a takedown keeps its hold when the attacker turns or drags, and den vaults can pay a garrotte or a gun kata chip --- tgstation.dme | 2 +- voidcrew/_DEFINES/hyperviolence.dm | 4 - .../overlays_exec/knife_executions.dm | 168 ++++++++++-------- .../visuals/knife_execution_motion.dm | 12 +- voidcrew/modules/stealth/stealth_garrotte.dm | 5 + voidcrew/modules/stealth/stealth_gunfu.dm | 5 + voidcrew/modules/stealth/stealth_knife.dm | 69 +------ voidcrew/modules/stealth/stealth_takedown.dm | 12 ++ .../voidcrew_hv_knife_executions.dm | 22 ++- .../unit_tests/voidcrew_stealth_d45.dm | 34 ++-- 10 files changed, 161 insertions(+), 172 deletions(-) diff --git a/tgstation.dme b/tgstation.dme index 8aeb6159cae..70279875082 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7743,8 +7743,8 @@ #include "voidcrew\modules\stealth\stealth_closet.dm" #include "voidcrew\modules\stealth\stealth_crits.dm" #include "voidcrew\modules\stealth\stealth_disguise.dm" -#include "voidcrew\modules\stealth\stealth_garrotte.dm" #include "voidcrew\modules\stealth\stealth_doors.dm" +#include "voidcrew\modules\stealth\stealth_garrotte.dm" #include "voidcrew\modules\stealth\stealth_gunfu.dm" #include "voidcrew\modules\stealth\stealth_gunfu_admin.dm" #include "voidcrew\modules\stealth\stealth_gunfu_motion_flip.dm" diff --git a/voidcrew/_DEFINES/hyperviolence.dm b/voidcrew/_DEFINES/hyperviolence.dm index 9f0b34253c9..03bd563104e 100644 --- a/voidcrew/_DEFINES/hyperviolence.dm +++ b/voidcrew/_DEFINES/hyperviolence.dm @@ -107,7 +107,3 @@ #define HV_KNIFE_EXECUTION_WINDUP (1.5 SECONDS) /// do_after interaction key for a knife execution wind-up. #define HV_KNIFE_EXECUTION_DOAFTER "hv_knife_execution" -/// Combined head melee cover below which a knife execution opens a critical slash and slices the neck. -#define HV_KNIFE_EXECUTION_LOW_COVER 20 -/// Combined head melee cover at or above which (or under a sealed helmet) a knife execution leaves only a moderate slash. -#define HV_KNIFE_EXECUTION_HIGH_COVER 50 diff --git a/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm b/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm index b94b3abefd0..dc3bb718594 100644 --- a/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm +++ b/voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm @@ -1,27 +1,25 @@ -// Hyperviolence: knife executions. +// Hyperviolence: knife executions, the one backstab path (decisions 45 and 46). // -// Modelled on gun executions in executions.dm. A combat-mode click with an edged knife aimed at the -// head or mouth of an adjacent carbon with a head starts a knife execution when the attacker is -// either behind the target (check_behind()) or the target is helpless (hv_can_be_executed()). Only -// players and boss-rank human NPCs execute (hv_can_execute()), never pacifists. +// A combat-mode click with any sharp-edged knife on an adjacent carbon with a head starts it when: +// - the target is a stealth guard caught off guard (stealth_caught_off_guard()) and the attacker is behind it +// (check_behind()), whatever zone is aimed at (decision 45); +// - or anyone else is taken from behind, or anyone is helpless (hv_can_be_executed()), with the head or mouth aimed at. +// Never on a body the attacker holds in an aggressive grab or tighter (that is tg's own slow throat slit), never on a +// throat already cut. Only players and boss-rank human NPCs do it (hv_can_execute()), never pacifists. // -// Both hold still for HV_KNIFE_EXECUTION_WINDUP; moving, losing the blade, switching zones or turning -// to face the attacker breaks the wind-up cleanly. If it holds, the knife stabs the head through its -// real attack() path at HV_EXECUTION_POINT_BLANK_MULT force and opens a slash wound on the head whose -// severity is tempered by the head's combined melee cover (worn armour plus physiology armour, such -// as dermal cyberware, minus the blade's armour penetration) and sealed helmets: unarmoured throats -// take a critical slash and tg's neck_slice bleed, light cover downgrades to a severe slash without -// neck_slice, and heavy cover or a sealed helmet leaves only a moderate slash. Nothing extra kills, -// stuns or roots the victim; death comes only from tg's real damage and bleeding. +// Both hold still for HV_KNIFE_EXECUTION_WINDUP; moving, losing the blade or turning to face the attacker breaks the +// wind-up cleanly. If it holds, the cut is decision 45's: tg's throat slit maths (hv_finish_knife_execution()). The +// throat blood follows the wound that landed (hv_knife_exec_spray). Nothing extra kills, stuns or roots the victim; +// death comes only from tg's real damage and bleeding. A cut throat is mute (voidcrew/edits/datums/neck_slice_mute.dm). /obj/item/knife - /// Set while the execution's own head stab runs through attack(), so our override passes to parent. - var/hv_knife_executing = FALSE /// Brute and burn damage this knife dealt to the victim's head during an execution stab. var/hv_knife_execution_head_damage = 0 + /// How far the last execution's throat blood sprays (0-2 tiles), by the worst cut it left on the head. + var/hv_knife_exec_spray = 0 /obj/item/knife/attack(mob/living/target_mob, mob/living/user, list/modifiers, list/attack_modifiers) - if(hv_knife_executing || !hv_knife_execution_possible(user, target_mob)) + if(!hv_knife_execution_possible(user, target_mob)) return ..() if(!DOING_INTERACTION(user, HV_KNIFE_EXECUTION_DOAFTER)) var/list/saved_modifiers = islist(modifiers) ? modifiers.Copy() : null @@ -29,20 +27,41 @@ INVOKE_ASYNC(src, PROC_REF(hv_start_knife_execution), user, target_mob, saved_modifiers, saved_attack_modifiers) return TRUE -/// Whether a melee click with this knife by `user` on `target` starts a knife execution. +/// Whether a melee click with this knife by `user` on `target` starts a knife execution (the one backstab path). /obj/item/knife/proc/hv_knife_execution_possible(mob/living/user, mob/living/target) if(!isliving(user) || !iscarbon(target) || user == target) return FALSE if(!user.combat_mode || HAS_TRAIT(user, TRAIT_PACIFISM) || !user.hv_can_execute()) return FALSE - if(user.zone_selected != BODY_ZONE_HEAD && user.zone_selected != BODY_ZONE_PRECISE_MOUTH) - return FALSE if(force <= 0 || !(get_sharpness() & SHARP_EDGED)) return FALSE var/mob/living/carbon/victim = target if(isnull(victim.get_bodypart(BODY_ZONE_HEAD)) || !user.Adjacent(victim)) return FALSE - return check_behind(user, victim) || victim.hv_can_be_executed() + // Held in an aggressive grab or tighter: tg's own slow throat slit (butchering.dm), not this. + if(user.pulling == victim && user.grab_state >= GRAB_AGGRESSIVE) + return FALSE + if(victim.has_status_effect(/datum/status_effect/neck_slice)) + return FALSE + var/behind = check_behind(user, victim) + // A stealth guard caught off guard from behind: the throat whatever is aimed at (decision 45). On guard, only helpless. + if(hv_knife_is_stealth_guard(victim)) + var/mob/living/carbon/human/npc/guard = victim + if(behind && guard.stealth_caught_off_guard(user)) + return TRUE + return hv_knife_aims_at_throat(user) && victim.hv_can_be_executed() + if(!hv_knife_aims_at_throat(user)) + return FALSE + return behind || victim.hv_can_be_executed() + +/// Whether `user` aims at the head or the mouth. +/obj/item/knife/proc/hv_knife_aims_at_throat(mob/living/user) + return user.zone_selected == BODY_ZONE_HEAD || user.zone_selected == BODY_ZONE_PRECISE_MOUTH + +/// Whether `victim` is a stealth guard (its awareness decides a backstab, decision 45). +/obj/item/knife/proc/hv_knife_is_stealth_guard(mob/living/victim) + var/mob/living/carbon/human/npc/guard = victim + return istype(guard) && istype(guard.ai_controller, /datum/ai_controller/basic_controller/human_npc/stealth) /// Grabs the victim, presses the blade to their throat and, if both hold still, cuts. /obj/item/knife/proc/hv_start_knife_execution(mob/living/user, mob/living/carbon/victim, list/modifiers, list/attack_modifiers) @@ -82,78 +101,79 @@ return FALSE if(force <= 0 || !(get_sharpness() & SHARP_EDGED)) return FALSE - if(user.zone_selected != BODY_ZONE_HEAD && user.zone_selected != BODY_ZONE_PRECISE_MOUTH) - return FALSE if(isnull(victim.get_bodypart(BODY_ZONE_HEAD)) || !user.Adjacent(victim)) return FALSE + if(user.pulling == victim && user.grab_state >= GRAB_AGGRESSIVE) + return FALSE + // A stealth guard taken from behind goes for the throat whatever is aimed at; anyone else needs the head or mouth. + if(!hv_knife_is_stealth_guard(victim) && !hv_knife_aims_at_throat(user)) + return FALSE return victim.hv_can_be_executed() || check_behind(user, victim) -/// Lands the knife execution: stabs the head at point-blank force, opens a cover-scaled head slash wound, and slices exposed throats. +/** + * Lands the knife execution: tg's throat slit (butchering.dm, startNeckSlice()) from its do_after on, as decision 45 built + * it. The knife's force goes to the head through its melee armour; if tg's wound maths lets a critical cut through what + * protects the head (slit_gets_through()), a critical slash and tg's neck_slice (mute, neck_slice_mute.dm). Otherwise + * the blade turns: an ordinary stab to the head with tg's own wound roll, and he can still shout. + */ /obj/item/knife/proc/hv_finish_knife_execution(mob/living/user, mob/living/carbon/victim, list/modifiers, list/attack_modifiers) if(!hv_knife_execution_holds(user, victim)) return FALSE var/obj/item/bodypart/head/head = victim.get_bodypart(BODY_ZONE_HEAD) if(isnull(head)) return FALSE - - var/sealed_helmet = !isnull(victim.is_mouth_covered(ITEM_SLOT_HEAD)) - var/cover = hv_crit_cover_rating(victim, head, MELEE, armour_penetration) - var/wound_severity = WOUND_SEVERITY_CRITICAL - var/slice_neck = TRUE - if(sealed_helmet || cover >= HV_KNIFE_EXECUTION_HIGH_COVER) - wound_severity = WOUND_SEVERITY_MODERATE - slice_neck = FALSE - else if(cover >= HV_KNIFE_EXECUTION_LOW_COVER) - wound_severity = WOUND_SEVERITY_SEVERE - slice_neck = FALSE - - var/list/stab_modifiers = islist(attack_modifiers) ? attack_modifiers.Copy() : list() - MODIFY_ATTACK_FORCE_MULTIPLIER(stab_modifiers, HV_EXECUTION_POINT_BLANK_MULT) - - // Bypass the knife's butchering component for this synchronous hit so an aggressive grab or a - // corpse with butcher results takes the real stab instead of starting startNeckSlice / startButcher. - var/datum/component/butchering/butchering = GetComponent(/datum/component/butchering) - if(butchering) - butchering.UnregisterSignal(src, COMSIG_ITEM_ATTACK) - - var/previous_zone = user.zone_selected - user.zone_selected = BODY_ZONE_HEAD + hv_knife_exec_spray = 0 hv_knife_execution_head_damage = 0 RegisterSignal(victim, COMSIG_MOB_APPLY_DAMAGE, PROC_REF(hv_knife_execution_hit)) - hv_knife_executing = TRUE - attack(victim, user, modifiers, stab_modifiers) - hv_knife_executing = FALSE - if(!QDELETED(user)) - user.zone_selected = previous_zone + user.do_attack_animation(victim) + user.changeNext_move(CLICK_CD_MELEE) + playsound(victim, 'sound/effects/butcher.ogg', 50, TRUE, -1) + var/blocked = victim.run_armor_check(head, MELEE, armour_penetration = armour_penetration, silent = TRUE) + var/slit = slit_gets_through(victim, head) + if(slit) + log_combat(user, victim, "wounded via throat slitting", src, "(knife execution)") + victim.apply_damage(force, BRUTE, head, blocked, wound_bonus = CANT_WOUND, attack_direction = get_dir(user, victim), attacking_item = src) + if(victim.cause_wound_of_type_and_severity(WOUND_SLASH, head, WOUND_SEVERITY_CRITICAL, wound_source = src)) + victim.apply_status_effect(/datum/status_effect/neck_slice) + else + log_combat(user, victim, "stabbed at the throat of", src, "(knife execution, protected throat)") + victim.apply_damage(force, BRUTE, head, blocked, wound_bonus = wound_bonus, exposed_wound_bonus = exposed_wound_bonus, sharpness = get_sharpness(), attack_direction = get_dir(user, victim), attacking_item = src) if(!QDELETED(victim)) UnregisterSignal(victim, COMSIG_MOB_APPLY_DAMAGE) - if(!QDELETED(src) && !QDELETED(butchering)) - butchering.RegisterSignal(src, COMSIG_ITEM_ATTACK, TYPE_PROC_REF(/datum/component/butchering, onItemAttack)) - - if(!QDELETED(victim)) head = victim.get_bodypart(BODY_ZONE_HEAD) - if(head) - victim.cause_wound_of_type_and_severity(WOUND_SLASH, head, wound_severity, wound_source = src) - if(slice_neck) - var/has_critical_slash = FALSE - for(var/datum/wound/wound as anything in head.wounds) - if(wound.severity >= WOUND_SEVERITY_CRITICAL) - has_critical_slash = TRUE - break - if(has_critical_slash) - victim.apply_status_effect(/datum/status_effect/neck_slice) - victim.hv_add_hit_line("[user] cuts [victim]'s throat!", HV_LINE_HUGE, "[user] cuts your throat!", COMBAT_MESSAGE_RANGE) - else if(wound_severity == WOUND_SEVERITY_SEVERE) - victim.hv_add_hit_line("[user] slashes [victim]'s neck!", HV_LINE_BOLD, "[user] slashes your neck!", COMBAT_MESSAGE_RANGE) - else - var/blocked_by = sealed_helmet ? "helmet" : "collar" - victim.hv_add_hit_line("[src] skids off [victim]'s [blocked_by].", HV_LINE_BOLD, "[src] skids off your [blocked_by].", COMBAT_MESSAGE_RANGE) - - log_combat(user, victim, "knife-executed", src, "([round(hv_knife_execution_head_damage, 0.1)] damage to the head, slash severity [wound_severity])") - if(!QDELETED(victim)) + // The blood follows the wound that landed: a cut throat sprays, a lesser cut runs, no wound no spray. + var/worst = 0 + for(var/datum/wound/cut as anything in head?.wounds) + if((istype(cut, /datum/wound/slash) || istype(cut, /datum/wound/pierce)) && cut.severity > worst) + worst = cut.severity + if(worst >= WOUND_SEVERITY_CRITICAL) + hv_knife_exec_spray = 2 + else if(worst >= WOUND_SEVERITY_MODERATE) + hv_knife_exec_spray = 1 + if(victim.has_status_effect(/datum/status_effect/neck_slice)) + victim.hv_add_hit_line("[user] cuts [victim]'s throat!", HV_LINE_HUGE, "[user] cuts your throat!", COMBAT_MESSAGE_RANGE) + else + victim.hv_add_hit_line("[user] stabs at [victim]'s throat, but the blade turns!", HV_LINE_BOLD, "[user] stabs at your throat!", COMBAT_MESSAGE_RANGE) + // The victim felt that: the same signal a normal blow sends (tg's relay_attackers), after the cut. + SEND_SIGNAL(victim, COMSIG_ATOM_AFTER_ATTACKEDBY, src, user, modifiers, attack_modifiers) hv_execution_witnesses(user, victim) + add_fingerprint(user) + log_combat(user, victim, "knife-executed", src, "([round(hv_knife_execution_head_damage, 0.1)] damage to the head, throat [slit ? "cut" : "protected"])") return TRUE +/** + * Whether the slit gets through what protects this throat, by tg's own wound maths (decision 45): a placed cut is the + * best roll tg's wound roll allows (WOUND_MAX_CONSIDERED_DAMAGE to the power WOUND_DAMAGE_EXPONENT), plus this knife's + * wound bonus, through check_woundings_mods() (worn wound armour on the head, physiology wound armour such as dermal + * cyberware, the head's own resistance and its existing wounds). It gets through if that reaches tg's critical slash + * threshold. + */ +/obj/item/knife/proc/slit_gets_through(mob/living/carbon/victim, obj/item/bodypart/throat) + var/datum/wound_pregen_data/critical = GLOB.all_wound_pregen_data[/datum/wound/slash/flesh/critical] + var/best_roll = round(WOUND_MAX_CONSIDERED_DAMAGE ** WOUND_DAMAGE_EXPONENT) + var/roll = throat.check_woundings_mods(WOUND_SLASH, best_roll, force, wound_bonus, exposed_wound_bonus, FALSE) + return roll >= critical.threshold_minimum + /// Sums brute and burn damage this knife deals to the victim's head during an execution stab. /obj/item/knife/proc/hv_knife_execution_hit(mob/living/source, damage, damagetype, def_zone, blocked, wound_bonus, exposed_wound_bonus, sharpness, attack_direction, atom/attacking_item) SIGNAL_HANDLER diff --git a/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm b/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm index 90de62e5858..d68fcff6612 100644 --- a/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm +++ b/voidcrew/modules/hyperviolence/visuals/knife_execution_motion.dm @@ -244,9 +244,6 @@ var/was_standing = victim.body_position == STANDING_UP var/pre_pixel_y = victim.pixel_y var/matrix/pre_base = matrix(victim.transform) - var/sealed_before = !isnull(victim.is_mouth_covered(ITEM_SLOT_HEAD)) - var/obj/item/bodypart/head/head_before = victim.get_bodypart(BODY_ZONE_HEAD) - var/cover_before = head_before ? hv_crit_cover_rating(victim, head_before, MELEE, armour_penetration) : 100 // Suppress hv_blood_on_damaged's 3-fan hit spray during the stab so we fire our own forward throat spray. var/prev_spray_until = victim.hv_blood_spray_until @@ -268,7 +265,7 @@ return hv_vis_cut_landed = TRUE - hv_vis_play_knife_cut_and_release(user, victim, was_standing, pre_pixel_y, pre_base, sealed_before, cover_before) + hv_vis_play_knife_cut_and_release(user, victim, was_standing, pre_pixel_y, pre_base) // ---- Wind-up, cut and release choreography ---- @@ -405,7 +402,7 @@ hv_vis_knife_arm_ref = WEAKREF(knife_arm) /// Runs Beats 3 and 4 once the wind-up succeeded and the real stab + slash wound landed. -/obj/item/knife/proc/hv_vis_play_knife_cut_and_release(mob/living/user, mob/living/carbon/victim, was_standing, pre_pixel_y, matrix/pre_base, sealed_before, cover_before) +/obj/item/knife/proc/hv_vis_play_knife_cut_and_release(mob/living/user, mob/living/carbon/victim, was_standing, pre_pixel_y, matrix/pre_base) var/cut_total = HV_VIS_KNIFE_CUT_TIME + HV_VIS_KNIFE_CUT_HOLD if(!QDELETED(user)) user.hv_vis_stop(list(HV_VIS_TAG_HITSTOP)) @@ -495,9 +492,10 @@ // Blood from the throat in the direction the victim faces, starting now as the wound lands. var/spray_dir = victim.dir || toward || SOUTH var/obj/item/bodypart/head/head_after = victim.get_bodypart(BODY_ZONE_HEAD) - var/can_bleed_throat = (head_after ? head_after.can_bleed() : victim.can_bleed()) && !(sealed_before && cover_before >= HV_KNIFE_EXECUTION_HIGH_COVER) + // As much blood as the wound that landed (hv_finish_knife_execution() sets hv_knife_exec_spray): none without one. + var/spray_tiles = hv_knife_exec_spray + var/can_bleed_throat = spray_tiles > 0 && (head_after ? head_after.can_bleed() : victim.can_bleed()) if(can_bleed_throat) - var/spray_tiles = (sealed_before || cover_before >= HV_KNIFE_EXECUTION_LOW_COVER) ? 1 : 2 victim.hv_blood_spray_until = 0 victim.hv_blood_spray_strength = 0 victim.hv_blood_spray(spray_dir, spray_tiles) diff --git a/voidcrew/modules/stealth/stealth_garrotte.dm b/voidcrew/modules/stealth/stealth_garrotte.dm index d23b35fbc47..92a1acce7fb 100644 --- a/voidcrew/modules/stealth/stealth_garrotte.dm +++ b/voidcrew/modules/stealth/stealth_garrotte.dm @@ -39,3 +39,8 @@ user.balloon_alert(user, "the wire won't bite!") return TRUE return TRUE + +/// Scav den loot (decision 51's hook, 3b.7): a den vault may pay a garrotte. +/obj/structure/closet/crate/secure/scav_vault/scav_vault_stealth_loot() + . = ..() + .[/obj/item/garrotte] = 1 diff --git a/voidcrew/modules/stealth/stealth_gunfu.dm b/voidcrew/modules/stealth/stealth_gunfu.dm index 60f49cd78f9..c9d08766867 100644 --- a/voidcrew/modules/stealth/stealth_gunfu.dm +++ b/voidcrew/modules/stealth/stealth_gunfu.dm @@ -272,3 +272,8 @@ var/turf/away = get_ranged_target_turf(victim, turn(get_dir(src, victim), pick(-45, 45)), GUNFU_DISARM_THROW_RANGE) held.throw_at(away, GUNFU_DISARM_THROW_RANGE, 2, src, spin = TRUE) return TRUE + +/// Scav den loot (decision 51's hook, decision 54): a den vault may pay the gun kata chip. +/obj/structure/closet/crate/secure/scav_vault/scav_vault_stealth_loot() + . = ..() + .[/obj/item/organ/cyberimp/cyberware/gun_kata] = 2 diff --git a/voidcrew/modules/stealth/stealth_knife.dm b/voidcrew/modules/stealth/stealth_knife.dm index e2137694695..1e0a01ab1d1 100644 --- a/voidcrew/modules/stealth/stealth_knife.dm +++ b/voidcrew/modules/stealth/stealth_knife.dm @@ -1,14 +1,10 @@ /** - * # The matte combat knife (step 3a, owner decisions 5, 12 and 45) + * # The matte combat knife (step 3a, owner decisions 5, 12, 45 and 46) * - * tg's combat knife with a blackened blade. Its one difference: stabbed into a stealth guard from behind (tg's - * check_behind(), the heretic blade's backstab test) while the guard is unaware or only suspicious, it goes for the - * throat whatever zone is aimed at, and the stab is tg's own throat slit (butchering.dm, startNeckSlice()) without the - * grab and the wait: the knife's force to the head, a critical slash on the head and tg's neck_slice. A cut throat - * can't speak, shout or use a radio (voidcrew/edits/datums/neck_slice_mute.dm). Head armour counts as tg counts it: the - * damage goes through its melee armour, and the cut only opens the throat if tg's wound maths lets a critical slash - * through (slit_gets_through()); otherwise it is an ordinary stab to the head. tg's grab slit works as before. - * On anyone else, players included, it is a plain combat knife. No new animation. + * tg's combat knife with a blackened blade. Its backstab is the one every sharp-edged knife has (the knife execution, + * voidcrew/modules/hyperviolence/overlays_exec/knife_executions.dm): from behind on a stealth guard caught off guard, + * whatever zone is aimed at, it is tg's throat slit without the grab, after a short hold; a cut throat can't speak, + * shout or use a radio (voidcrew/edits/datums/neck_slice_mute.dm). tg's grab slit works as before. * * Players get it as scav den loot (step 4). It has no buy, print or craft route. */ @@ -16,58 +12,3 @@ name = "matte combat knife" desc = "A combat knife with a blackened blade that doesn't catch the light." color = "#6E6E7D" - -/obj/item/knife/combat/matte/attack(mob/living/target_mob, mob/living/user, list/modifiers, list/attack_modifiers) - if(!backstab_slits(target_mob, user)) - return ..() - var/mob/living/carbon/human/npc/guard = target_mob - var/obj/item/bodypart/throat = guard.get_bodypart(BODY_ZONE_HEAD) - user.do_attack_animation(guard) - user.changeNext_move(CLICK_CD_MELEE) - playsound(guard, 'sound/effects/butcher.ogg', 50, TRUE, -1) - var/blocked = guard.run_armor_check(throat, MELEE, armour_penetration = armour_penetration, silent = TRUE) - if(!slit_gets_through(guard, throat)) - // A well protected throat: an ordinary stab to the head through its armour, with tg's own wound roll. - guard.visible_message(span_danger("[user] stabs at [guard]'s throat, but the blade turns!"), span_userdanger("[user] stabs at your throat!")) - log_combat(user, guard, "stabbed at the throat of", src, "(stab from behind, protected throat)") - guard.apply_damage(force, BRUTE, throat, blocked, wound_bonus = wound_bonus, exposed_wound_bonus = exposed_wound_bonus, sharpness = get_sharpness(), attack_direction = get_dir(user, guard), attacking_item = src) - else - // tg's throat slit (butchering.dm, startNeckSlice()), from its do_after on, its damage through armour. - guard.visible_message(span_danger("[user] slits [guard]'s throat!"), span_userdanger("[user] slits your throat...")) - log_combat(user, guard, "wounded via throat slitting", src, "(stab from behind)") - guard.apply_damage(force, BRUTE, throat, blocked, wound_bonus = CANT_WOUND) - if(guard.cause_wound_of_type_and_severity(WOUND_SLASH, throat, WOUND_SEVERITY_CRITICAL)) - guard.apply_status_effect(/datum/status_effect/neck_slice) - // The guard felt that: the same signal a normal blow sends (tg's relay_attackers), after the cut. - SEND_SIGNAL(guard, COMSIG_ATOM_AFTER_ATTACKEDBY, src, user, modifiers, attack_modifiers) - add_fingerprint(user) - return TRUE - -/** - * Whether the slit gets through what protects this throat, by tg's own wound maths: a placed cut is the best roll tg's - * wound roll allows (WOUND_MAX_CONSIDERED_DAMAGE to the power WOUND_DAMAGE_EXPONENT), plus this knife's wound bonus, - * through check_woundings_mods() (worn wound armour on the head, physiology wound armour such as dermal cyberware, the - * head's own resistance and its existing wounds). It gets through if that reaches tg's critical slash threshold. - */ -/obj/item/knife/combat/matte/proc/slit_gets_through(mob/living/carbon/human/victim, obj/item/bodypart/throat) - var/datum/wound_pregen_data/critical = GLOB.all_wound_pregen_data[/datum/wound/slash/flesh/critical] - var/best_roll = round(WOUND_MAX_CONSIDERED_DAMAGE ** WOUND_DAMAGE_EXPONENT) - var/roll = throat.check_woundings_mods(WOUND_SLASH, best_roll, force, wound_bonus, exposed_wound_bonus, FALSE) - return roll >= critical.threshold_minimum - -/** - * Whether stabbing `target` now is a throat slit from behind: a stealth guard caught off guard - * (stealth_caught_off_guard()) with the stabber behind it, a combat-mode stab, its throat not already cut, and not - * from tg's own grab slit (an aggressive grab aimed at the head goes tg's way). - */ -/obj/item/knife/combat/matte/proc/backstab_slits(mob/living/target, mob/living/user) - if(!ishumannpc(target) || !istype(user) || !user.combat_mode || !force || !get_sharpness()) - return FALSE - if(HAS_TRAIT(user, TRAIT_PACIFISM) || !target.get_bodypart(BODY_ZONE_HEAD)) - return FALSE - if(user.pulling == target && user.grab_state >= GRAB_AGGRESSIVE) - return FALSE - if(target.has_status_effect(/datum/status_effect/neck_slice)) - return FALSE - var/mob/living/carbon/human/npc/guard = target - return check_behind(user, guard) && guard.stealth_caught_off_guard(user) diff --git a/voidcrew/modules/stealth/stealth_takedown.dm b/voidcrew/modules/stealth/stealth_takedown.dm index c486da136a2..b80b4bedf8d 100644 --- a/voidcrew/modules/stealth/stealth_takedown.dm +++ b/voidcrew/modules/stealth/stealth_takedown.dm @@ -310,3 +310,15 @@ UnregisterSignal(wire, COMSIG_QDELETING) if(!QDELETED(src)) qdel(src) + +/** + * A closed takedown holds the victim on his own tile and on his feet, facing away, with no pull offsets (close()). tg + * places a held body again on every drag step or turn (set_pull_offsets()), which would turn him round and, through the + * hostage's upright rule (stealth_hostage.dm), floor him again as an ordinary neck grab. The takedown keeps him as it + * holds him; a hostage is on the holder's own tile and is never a takedown's victim. + */ +/mob/living/set_pull_offsets(mob/living/mob_to_set, grab_state = GRAB_PASSIVE, animate = TRUE) + var/datum/stealth_takedown/hold = mob_to_set?.stealth_takedown_caught + if(hold?.closed && !hold.ended && hold.attacker == src) + return + return ..() diff --git a/voidcrew/modules/unit_tests/voidcrew_hv_knife_executions.dm b/voidcrew/modules/unit_tests/voidcrew_hv_knife_executions.dm index 7eee5a1be49..9b630593284 100644 --- a/voidcrew/modules/unit_tests/voidcrew_hv_knife_executions.dm +++ b/voidcrew/modules/unit_tests/voidcrew_hv_knife_executions.dm @@ -41,6 +41,10 @@ TEST_ASSERT(!knife.hv_knife_execution_possible(attacker, victim), "A knife out of combat mode started an execution") attacker.set_combat_mode(TRUE) TEST_ASSERT(!knife.hv_knife_execution_possible(attacker, attacker), "The attacker could execute himself") + attacker.start_pulling(victim, supress_message = TRUE) + attacker.setGrabState(GRAB_AGGRESSIVE) + TEST_ASSERT(!knife.hv_knife_execution_possible(attacker, victim), "A knife execution took over tg's grab slit") + attacker.stop_pulling() victim.setDir(WEST) victim.Knockdown(30 SECONDS) @@ -50,7 +54,7 @@ if(!(spork.get_sharpness() & SHARP_EDGED) || spork.force <= 0) TEST_ASSERT(!spork.hv_knife_execution_possible(attacker, victim), "A blunt plastic knife started an execution") -/// A held wind-up from behind ends in tg's real throat slit plus a boosted stab to the head. +/// A held wind-up from behind ends in tg's real throat slit (decision 45's maths). /datum/unit_test/hv_knife_execution_kill /datum/unit_test/hv_knife_execution_kill/Run() @@ -67,7 +71,7 @@ TEST_ASSERT(!DOING_INTERACTION(attacker, "hv_knife_execution"), "The wind-up never ended") TEST_ASSERT(victim.has_status_effect(/datum/status_effect/neck_slice), "An unarmoured victim's neck was not sliced") TEST_ASSERT_NOTNULL(hv_knife_exec_test_slash(victim, WOUND_SEVERITY_CRITICAL), "An unarmoured victim got no critical slash on the head") - TEST_ASSERT(head.brute_dam >= knife.force * 1.5, "The stab was not boosted ([head.brute_dam] head brute from a [knife.force] force knife)") + TEST_ASSERT(head.brute_dam > 0, "The cut did no damage to the head") TEST_ASSERT_EQUAL(attacker.pixel_w, 0, "The attacker was left offset after the move") TEST_ASSERT_EQUAL(attacker.pixel_z, 0, "The attacker was left offset after the move") @@ -102,7 +106,8 @@ sleep(2 SECONDS) TEST_ASSERT(!victim.has_status_effect(/datum/status_effect/neck_slice), "Stepping away did not break the wind-up") -/// A helmet, and dermal plating under the skin, weaken the result. +/// Head protection works as tg's slit maths says (decision 45): melee armour weakens the stab, wound armour (worn, or +/// physiology armour such as dermal cyberware) keeps the throat from being cut. /datum/unit_test/hv_knife_execution_armour /datum/unit_test/hv_knife_execution_armour/Run() @@ -112,27 +117,28 @@ bare.setDir(EAST) TEST_ASSERT(knife.hv_finish_knife_execution(attacker, bare, list(), list()), "The bare execution did not land") var/bare_brute = bare.get_bodypart(BODY_ZONE_HEAD).brute_dam + TEST_ASSERT(bare.has_status_effect(/datum/status_effect/neck_slice), "A bare throat was not cut") var/mob/living/carbon/human/consistent/helmeted = allocate(/mob/living/carbon/human/consistent) - helmeted.equip_to_slot_or_del(allocate(/obj/item/clothing/head/helmet/sec), ITEM_SLOT_HEAD) + helmeted.equip_to_slot_or_del(allocate(/obj/item/clothing/head/helmet/swat), ITEM_SLOT_HEAD) bare.forceMove(run_loc_floor_top_right) helmeted.forceMove(get_step(attacker, EAST)) helmeted.setDir(EAST) TEST_ASSERT(knife.hv_finish_knife_execution(attacker, helmeted, list(), list()), "The helmeted execution did not land") var/helmet_brute = helmeted.get_bodypart(BODY_ZONE_HEAD).brute_dam TEST_ASSERT(helmet_brute < bare_brute, "A helmet did not weaken the stab ([helmet_brute] vs [bare_brute])") - TEST_ASSERT(!helmeted.has_status_effect(/datum/status_effect/neck_slice), "A helmet did not keep the neck from being sliced") - TEST_ASSERT_NULL(hv_knife_exec_test_slash(helmeted, WOUND_SEVERITY_CRITICAL), "A helmet did not soften the throat slash") + TEST_ASSERT(!helmeted.has_status_effect(/datum/status_effect/neck_slice), "A SWAT helmet did not keep the neck from being cut") + TEST_ASSERT_NULL(hv_knife_exec_test_slash(helmeted, WOUND_SEVERITY_CRITICAL), "A SWAT helmet did not keep the critical slash out") var/mob/living/carbon/human/consistent/plated = allocate(/mob/living/carbon/human/consistent) - plated.physiology.armor = plated.physiology.armor.generate_new_with_modifiers(list(MELEE = 30)) + plated.physiology.armor = plated.physiology.armor.generate_new_with_modifiers(list(MELEE = 30, WOUND = 20)) helmeted.forceMove(run_loc_floor_top_right) plated.forceMove(get_step(attacker, EAST)) plated.setDir(EAST) TEST_ASSERT(knife.hv_finish_knife_execution(attacker, plated, list(), list()), "The plated execution did not land") var/plated_brute = plated.get_bodypart(BODY_ZONE_HEAD).brute_dam TEST_ASSERT(plated_brute < bare_brute, "Plating under the skin did not weaken the stab ([plated_brute] vs [bare_brute])") - TEST_ASSERT(!plated.has_status_effect(/datum/status_effect/neck_slice), "Plating under the skin did not keep the neck from being sliced") + TEST_ASSERT(!plated.has_status_effect(/datum/status_effect/neck_slice), "Plating under the skin did not keep the neck from being cut") /// Human NPCs below boss rank never execute; bosses and players do. /datum/unit_test/hv_knife_execution_npc_rank diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_d45.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_d45.dm index d4f416ff438..930564adc23 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_d45.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_d45.dm @@ -1,5 +1,5 @@ // Decision 45: the stealth head shot graded by the round and the head's protection, shields and shots in the back, and -// the matte knife's throat slit from behind (voidcrew/modules/stealth/stealth_crits.dm, stealth_knife.dm, +// the throat cut from behind (voidcrew/modules/stealth/stealth_crits.dm, hyperviolence/overlays_exec/knife_executions.dm, // voidcrew/edits/objects/items/shield_rear.dm, voidcrew/edits/datums/neck_slice_mute.dm). Unit tests compile before // voidcrew/_DEFINES, so values are written out: STEALTH_HEAD_SHOT_BRAIN_DAMAGE 120, STEALTH_CALL_ALARM 3. @@ -144,9 +144,10 @@ TEST_ASSERT(!holder.vc_shot_in_back, "The shot-in-the-back mark stayed on after the shot") qdel(block) -/// The matte knife from behind on an unaware guard slits the throat, whatever is aimed at: tg's critical slash and -/// neck_slice, and the guard can't speak. Not from the front, not a plain knife, not through a SWAT helmet, not when -/// held in a grab (tg's own slit). The mute goes with the cut. +/// The backstab (one path for every sharp knife, the knife execution): from behind on an unaware guard it goes for the +/// throat whatever is aimed at, and the cut is tg's critical slash and neck_slice; the guard can't speak. Not from the +/// front, not a blunt blade, not through a SWAT helmet, not when held in a grab (tg's own slit). The mute goes with the +/// cut. The finish is called straight, so the wind-up's timing doesn't decide the test (hv_knife_execution_kill does). /datum/unit_test/voidcrew_stealth_d45_backstab /datum/unit_test/voidcrew_stealth_d45_backstab/Run() @@ -158,13 +159,13 @@ person.put_in_active_hand(knife, forced = TRUE) person.set_combat_mode(TRUE) person.zone_selected = BODY_ZONE_CHEST - // From the front: no slit. + // From the front: no backstab. person.forceMove(stealth_at(block, 5, 1)) - TEST_ASSERT(!knife.backstab_slits(guard, person), "The knife slits a throat from the front") + TEST_ASSERT(!knife.hv_knife_execution_possible(person, guard), "The knife backstabs from the front") person.forceMove(stealth_at(block, 3, 1)) - TEST_ASSERT(knife.backstab_slits(guard, person), "The knife doesn't slit an unaware guard's throat from behind") - // The stab. - knife.attack(guard, person) + TEST_ASSERT(knife.hv_knife_execution_possible(person, guard), "The knife doesn't backstab an unaware guard from behind with the chest aimed at") + // The cut. + TEST_ASSERT(knife.hv_finish_knife_execution(person, guard, list(), list()), "The backstab didn't land") TEST_ASSERT(guard.has_status_effect(/datum/status_effect/neck_slice), "A backstab didn't cut the throat") var/obj/item/bodypart/head = guard.get_bodypart(BODY_ZONE_HEAD) var/critical_slash = FALSE @@ -172,19 +173,23 @@ if(istype(cut, /datum/wound/slash) && cut.severity == WOUND_SEVERITY_CRITICAL) critical_slash = TRUE TEST_ASSERT(critical_slash, "A backstab left no critical slash on the head") + TEST_ASSERT_EQUAL(knife.hv_knife_exec_spray, 2, "A cut throat didn't spray the most blood") TEST_ASSERT(HAS_TRAIT(guard, TRAIT_MUTE), "A cut throat isn't mute") TEST_ASSERT(!guard.can_speak(), "A guard with a cut throat can speak") + TEST_ASSERT(!knife.hv_knife_execution_possible(person, guard), "A cut throat can be cut again") guard.remove_status_effect(/datum/status_effect/neck_slice) TEST_ASSERT(!HAS_TRAIT(guard, TRAIT_MUTE), "The mute stayed after the cut") - // A plain combat knife is a plain knife. + // Any sharp-edged knife backstabs; a blunt one doesn't. var/mob/living/carbon/human/npc/second = d45_bare_guard(block, 4, 3) var/mob/living/carbon/human/stabber = stealth_person(block, 3, 3) var/obj/item/knife/combat/blade = allocate(/obj/item/knife/combat) stabber.put_in_active_hand(blade, forced = TRUE) stabber.set_combat_mode(TRUE) stabber.zone_selected = BODY_ZONE_CHEST - blade.attack(second, stabber) - TEST_ASSERT(!second.has_status_effect(/datum/status_effect/neck_slice), "A plain knife slit a throat") + TEST_ASSERT(blade.hv_knife_execution_possible(stabber, second), "A plain combat knife doesn't backstab") + var/obj/item/knife/plastic/spork = allocate(/obj/item/knife/plastic) + if(!(spork.get_sharpness() & SHARP_EDGED) || spork.force <= 0) + TEST_ASSERT(!spork.hv_knife_execution_possible(stabber, second), "A blunt plastic knife backstabs") // A SWAT helmet (wound 15): tg's wound maths keeps the critical slash out; an ordinary stab to the head. var/mob/living/carbon/human/npc/helmeted = d45_bare_guard(block, 4, 5) d45_helmet(helmeted, /obj/item/clothing/head/helmet/swat) @@ -193,16 +198,17 @@ third.put_in_active_hand(other_knife, forced = TRUE) third.set_combat_mode(TRUE) TEST_ASSERT(!other_knife.slit_gets_through(helmeted, helmeted.get_bodypart(BODY_ZONE_HEAD)), "A slit got through a SWAT helmet") - other_knife.attack(helmeted, third) + TEST_ASSERT(other_knife.hv_finish_knife_execution(third, helmeted, list(), list()), "The stab at a helmeted guard didn't land") TEST_ASSERT(!helmeted.has_status_effect(/datum/status_effect/neck_slice), "A helmeted guard's throat was cut") TEST_ASSERT(helmeted.get_bodypart(BODY_ZONE_HEAD).brute_dam > 0, "The stab at a protected throat did nothing") + TEST_ASSERT(other_knife.hv_knife_exec_spray < 2, "A protected throat sprayed like a cut one") TEST_ASSERT(helmeted.can_speak(), "A guard whose throat was protected can't speak") // Held in an aggressive grab: tg's own slit, not this one. var/mob/living/carbon/human/npc/held = d45_bare_guard(block, 6, 5) third.forceMove(stealth_at(block, 5, 5)) third.start_pulling(held, supress_message = TRUE) third.setGrabState(GRAB_AGGRESSIVE) - TEST_ASSERT(!other_knife.backstab_slits(held, third), "The backstab took over tg's grab slit") + TEST_ASSERT(!other_knife.hv_knife_execution_possible(third, held), "The backstab took over tg's grab slit") third.stop_pulling() qdel(block) From b94b50e6680dd6076a71774c745315fcd2728438 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 10:48:15 -0800 Subject: [PATCH 66/78] A human shield only catches point-blank shots from the front, a guard told to drop his locked gun puts it away, and the takedown test lets the alert settle --- voidcrew/modules/stealth/stealth_gunfu.dm | 12 +++++++++++- voidcrew/modules/stealth/stealth_hostage.dm | 7 ++++--- .../modules/unit_tests/voidcrew_stealth_takedown.dm | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/voidcrew/modules/stealth/stealth_gunfu.dm b/voidcrew/modules/stealth/stealth_gunfu.dm index c9d08766867..88e7e0a8374 100644 --- a/voidcrew/modules/stealth/stealth_gunfu.dm +++ b/voidcrew/modules/stealth/stealth_gunfu.dm @@ -60,7 +60,17 @@ var/mob/living/shield = source.gunfu_shield_body() if(isnull(shield) || shot.firer == shield) return NONE - if(abs(closer_angle_difference(dir2angle(source.dir), REVERSE_ANGLE(shot.angle))) > GUNFU_SHIELD_ARC) + // Where the shot comes from. A point-blank shot (tg's fire(), from the next tile) hits before it has an angle, so + // that one is taken from where the bullet is. + var/from_angle + if(isnum(shot.angle)) + from_angle = REVERSE_ANGLE(shot.angle) + else + var/turf/shot_turf = get_turf(shot) + if(isnull(shot_turf) || shot_turf == get_turf(source)) + return NONE + from_angle = get_angle(source, shot_turf) + if(abs(closer_angle_difference(dir2angle(source.dir), from_angle)) > GUNFU_SHIELD_ARC) return NONE if(!shot.can_hit_target(shield, FALSE, TRUE)) return NONE diff --git a/voidcrew/modules/stealth/stealth_hostage.dm b/voidcrew/modules/stealth/stealth_hostage.dm index 9d4cd292b07..ab2fc021ccb 100644 --- a/voidcrew/modules/stealth/stealth_hostage.dm +++ b/voidcrew/modules/stealth/stealth_hostage.dm @@ -141,7 +141,8 @@ stealth_bark(STEALTH_BARK_HOSTAGE_BACK, always = TRUE) log_combat(guard, source, "backed off from a hostage holder") -/// Drops what it holds in its hands, through tg's own drop. +/// Drops what it holds in its hands, through tg's own drop. Gear locked to its body (human_npc_gear.dm, decision D3) +/// can't leave it, so that goes away onto its belt, back or suit instead: empty hands either way, and no loot. /datum/ai_controller/basic_controller/human_npc/stealth/proc/stealth_standoff_drop() var/mob/living/carbon/human/guard = pawn if(QDELETED(guard) || standoff_dropped) @@ -149,7 +150,7 @@ standoff_dropped = TRUE var/dropped = FALSE for(var/obj/item/held in guard.held_items) - if(guard.dropItemToGround(held)) + if(guard.dropItemToGround(held) || guard.equip_to_appropriate_slot(held)) dropped = TRUE if(dropped) stealth_bark(STEALTH_BARK_HOSTAGE_DROP, always = TRUE) @@ -217,7 +218,7 @@ lines[STEALTH_BARK_HOSTAGE_EXECUTED] = list("You son of a-", "Take them down!", "No more talking!") lines[STEALTH_BARK_HOSTAGE_RELEASED] = list("Now!", "Take them!", "Get clear!") emotes[STEALTH_BARK_HOSTAGE] = list("raises a hand slowly.", "keeps their gun low.") - emotes[STEALTH_BARK_HOSTAGE_DROP] = list("lets their weapon fall.") + emotes[STEALTH_BARK_HOSTAGE_DROP] = list("puts their weapon down.") // --------------------------------------------------------------------------------------------- // Held at gunpoint, held upright (decision 62) diff --git a/voidcrew/modules/unit_tests/voidcrew_stealth_takedown.dm b/voidcrew/modules/unit_tests/voidcrew_stealth_takedown.dm index cac26a1ee66..00564a276c2 100644 --- a/voidcrew/modules/unit_tests/voidcrew_stealth_takedown.dm +++ b/voidcrew/modules/unit_tests/voidcrew_stealth_takedown.dm @@ -31,6 +31,7 @@ other.set_combat_mode(TRUE) var/datum/ai_controller/basic_controller/human_npc/stealth/alert_ai = stealth_ai(alert) alert_ai.stealth_go_alert(other) + alert_ai.stealth_rewind(1) // alerted before this blow, not by it TEST_ASSERT_EQUAL(stealth_takedown_refusal(other, alert, "choke"), "front", "An alert guard can be choked from behind") // A person (no awareness) from behind can (decision 22), from the front can't. var/mob/living/carbon/human/victim = stealth_person(block, 4, 5) From 4d22c5203c59c95d67edb2869b27139a86e064d7 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Fri, 13 Nov 2026 13:00:12 -0800 Subject: [PATCH 67/78] Knife executions: the attacker holds the victim with his own arms and cuts with the knife from his hand The hold from behind is redrawn. The attacker steps in chest to back, his arms are stand-ins built from his own picture (his real arms are hidden while they show), one hand takes the victim's shoulder and the other brings his held knife to the throat. The victim is hauled back, fights the hold, and a survivor stumbles clear with a hand at his throat. Bodies and arms are tweened through the same moments so hands stay on what they hold, and both bodies end on the middle of their own tiles. A broken wind-up eases everything back. Blood follows hv_knife_exec_spray (worked out here until this branch meets feature/stealth's knife_executions.dm): a critical cut sprays two tiles ahead, a shallower one throws no spray of its own. The stab no longer opens the skull wound picture. A lying victim, or an attacker at a back corner, gets a plain lean-in and jab. --- .../icons/knife_exec_mask_arm_l.dmi | Bin 0 -> 224 bytes .../icons/knife_exec_mask_arm_r.dmi | Bin 0 -> 221 bytes .../icons/knife_exec_mask_arms.dmi | Bin 0 -> 223 bytes .../icons/knife_exec_mask_far_e.dmi | Bin 0 -> 211 bytes .../icons/knife_exec_mask_far_w.dmi | Bin 0 -> 208 bytes .../overlays_exec/icons/knife_exec_px.dmi | Bin 0 -> 203 bytes .../modules/hyperviolence/visuals/_defines.dm | 114 +- .../visuals/knife_execution_motion.dm | 2085 +++++++++-------- .../voidcrew_hv_knife_executions.dm | 52 + 9 files changed, 1218 insertions(+), 1033 deletions(-) create mode 100644 voidcrew/modules/hyperviolence/overlays_exec/icons/knife_exec_mask_arm_l.dmi create mode 100644 voidcrew/modules/hyperviolence/overlays_exec/icons/knife_exec_mask_arm_r.dmi create mode 100644 voidcrew/modules/hyperviolence/overlays_exec/icons/knife_exec_mask_arms.dmi create mode 100644 voidcrew/modules/hyperviolence/overlays_exec/icons/knife_exec_mask_far_e.dmi create mode 100644 voidcrew/modules/hyperviolence/overlays_exec/icons/knife_exec_mask_far_w.dmi create mode 100644 voidcrew/modules/hyperviolence/overlays_exec/icons/knife_exec_px.dmi diff --git a/voidcrew/modules/hyperviolence/overlays_exec/icons/knife_exec_mask_arm_l.dmi b/voidcrew/modules/hyperviolence/overlays_exec/icons/knife_exec_mask_arm_l.dmi new file mode 100644 index 0000000000000000000000000000000000000000..fb534204f28abc677059e5d1e57ad27de276703f GIT binary patch literal 224 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJl&X-35|`BC)e_1!5cyiE*d|0q;uX!^CUx2Pwx&3;~?Y9#$F0@9!)wj zDMTUIv$NY+b@K{|6DCg{`DlBc@on8ORW#;r%mFnfhFRMsxNBE8Is@%9_jGX#shIQj zoFNy30gqGQ*}v~|p6fMEb87pyU272w!-4mAT0J*SeY>rGaU6fqgOJRKLI(zhvr*oc WSOn%~NAUxVVDNPHb6Mw<&;$TyW>z); literal 0 HcmV?d00001 diff --git a/voidcrew/modules/hyperviolence/overlays_exec/icons/knife_exec_mask_arm_r.dmi b/voidcrew/modules/hyperviolence/overlays_exec/icons/knife_exec_mask_arm_r.dmi new file mode 100644 index 0000000000000000000000000000000000000000..6d99a2d1c267a1a5b4631b0c6cb4e7822036cda8 GIT binary patch literal 221 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJl&X-35|`BC)e_1!5cyiE*d|0q;uX!^CUx2Pwx&3;~?Y9#$F0@9!)wj zDMTUIv$NY+b@K{|6DCg{`DlBc@on8ORW#;r%mFnfhFRMsxNBE8Is@%9@pN$vshIQj z;znKu1s>)N)Be}<8FLE@IlpC|e;pMN=gh?{2cdz$_&evr=#d=wvA%VI2FpB_# SuCyvpKZB>MpUXO@geCx=|4;b< literal 0 HcmV?d00001 diff --git a/voidcrew/modules/hyperviolence/overlays_exec/icons/knife_exec_mask_arms.dmi b/voidcrew/modules/hyperviolence/overlays_exec/icons/knife_exec_mask_arms.dmi new file mode 100644 index 0000000000000000000000000000000000000000..528d0c0c2f8efaa34ae3a64512b215348f9cced6 GIT binary patch literal 223 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJl&X-35|`BC)e_1!5cyiE*d|0q;uX!^CUx2Pwx&3;~?Y9#$F0@9!)wj zDMTUIv$NY+b@K{|6DCg{`DlBc@on8ORW#;r%mFnfhFRMsxNBE8Is@%9^K@|xshIQj zq9GrH0|%4ihyV4*ZXJ6xOZ!e{>k$@ChKARBWGAPzyfyuQNwYT0MnP?d9V5d6M(_C? V0)CHmjDRLEc)I$ztaD0e0s!4yR2BdL literal 0 HcmV?d00001 diff --git a/voidcrew/modules/hyperviolence/overlays_exec/icons/knife_exec_mask_far_e.dmi b/voidcrew/modules/hyperviolence/overlays_exec/icons/knife_exec_mask_far_e.dmi new file mode 100644 index 0000000000000000000000000000000000000000..94bf360b9fc427f246b4b31d857fed1a685512e6 GIT binary patch literal 211 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJl&X-35|`BC)e_1!5cyiE*d|0q;uX!^CUx2Pwx&3;~?Y9#$F0@9!)wj zDMTUIv$NY+b@K{|6DCg{`DlBc@on8ORW#;r%mFnfhFRMsxNBE8Is@&~@^o)e_1!5cyiE*d|0q;uX!^CUx2Pwx&3;~?Y9#$F0@9!)wj zDMTUIv$NY+b@K{|6DCg{`DlBc@on8ORW#;r%mFnfhFRMsxNBE8Is@%f_jGX#shIQj z+(AwT1`g(pkN#O-mt>iLlHs^21B1+#+<9lqFEB7zM$M>aVJ=S*`vug(;OXk;vd$@? F2>_hMOg{hs literal 0 HcmV?d00001 diff --git a/voidcrew/modules/hyperviolence/overlays_exec/icons/knife_exec_px.dmi b/voidcrew/modules/hyperviolence/overlays_exec/icons/knife_exec_px.dmi new file mode 100644 index 0000000000000000000000000000000000000000..c254f818706142637b2d0a3f67db06f00528cbdc GIT binary patch literal 203 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJw5pJZ5|`BC)e_1!5cyiE*d|0q;uX!^CUx2Pwx&3;~?Y9#$F0@9!)wj zDMTT7*4k<*u!o_Me%