From 66187e971d22d3e19ce0e00f691415bf2854f43f Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sun, 15 Nov 2026 15:07:39 -0800 Subject: [PATCH 01/13] Human NPCs: a real human body with AI, gear, soft crit, surrender and throttled spawning /mob/living/carbon/human/npc is a human body driven by an AI controller. Crit, stamina, stuns, cuffs, wounds, bleeding, medicine, death and revival are tg's own, the same as on a player. - Gear the NPC wears stays with it; ship keys and designed death loot drop. - It draws, reloads and treats itself, pleads and surrenders when downed, and stays where it falls. - Only elite and boss NPCs land aimed crits, and only bosses execute. - Outfit tables dress an NPC by zone, with cold and vacuum gear where it spawns. - Spawns are queued and built a few per tick; bodies with no player on their level pause. - Combat sense (cover from stun fire, a carried stimulant) for the NPC types that opt in. - Hull turrets shoot human NPCs and weather reaches them. No NPC in the game is converted here; admins can spawn the sample types with Spawn Human NPCs. --- code/controllers/subsystem/weather.dm | 3 +- code/datums/weather/weather.dm | 3 +- code/modules/unit_tests/surgeries.dm | 12 +- tgstation.dme | 14 + voidcrew/_DEFINES/human_npcs.dm | 163 +++++ voidcrew/edits/mobs/ladder_outfits.dm | 10 +- voidcrew/machinery/ship_defense_turret.dm | 12 +- voidcrew/modules/human_npcs/human_npc.dm | 665 ++++++++++++++++++ .../modules/human_npcs/human_npc_admin.dm | 30 + voidcrew/modules/human_npcs/human_npc_ai.dm | 540 ++++++++++++++ .../modules/human_npcs/human_npc_barks.dm | 203 ++++++ .../human_npcs/human_npc_combat_sense.dm | 633 +++++++++++++++++ voidcrew/modules/human_npcs/human_npc_gear.dm | 247 +++++++ .../modules/human_npcs/human_npc_outfits.dm | 251 +++++++ .../modules/human_npcs/human_npc_samples.dm | 162 +++++ .../modules/human_npcs/human_npc_soft_crit.dm | 162 +++++ .../modules/human_npcs/human_npc_spawning.dm | 303 ++++++++ .../human_npcs/human_npc_spike_harness.dm | 568 +++++++++++++++ .../modules/human_npcs/human_npc_states.dm | 108 +++ .../modules/human_npcs/human_npc_surrender.dm | 161 +++++ .../hyperviolence/finishers/finisher_ai.dm | 1 + voidcrew/modules/unit_tests/_unit_tests.dm | 2 + .../modules/unit_tests/voidcrew_human_npcs.dm | 431 ++++++++++++ .../unit_tests/voidcrew_human_npcs_shared.dm | 433 ++++++++++++ .../voidcrew_hyperviolence_overlays_exec.dm | 13 + 25 files changed, 5121 insertions(+), 9 deletions(-) create mode 100644 voidcrew/_DEFINES/human_npcs.dm create mode 100644 voidcrew/modules/human_npcs/human_npc.dm create mode 100644 voidcrew/modules/human_npcs/human_npc_admin.dm create mode 100644 voidcrew/modules/human_npcs/human_npc_ai.dm create mode 100644 voidcrew/modules/human_npcs/human_npc_barks.dm create mode 100644 voidcrew/modules/human_npcs/human_npc_combat_sense.dm create mode 100644 voidcrew/modules/human_npcs/human_npc_gear.dm create mode 100644 voidcrew/modules/human_npcs/human_npc_outfits.dm create mode 100644 voidcrew/modules/human_npcs/human_npc_samples.dm create mode 100644 voidcrew/modules/human_npcs/human_npc_soft_crit.dm create mode 100644 voidcrew/modules/human_npcs/human_npc_spawning.dm create mode 100644 voidcrew/modules/human_npcs/human_npc_spike_harness.dm create mode 100644 voidcrew/modules/human_npcs/human_npc_states.dm create mode 100644 voidcrew/modules/human_npcs/human_npc_surrender.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_human_npcs.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_human_npcs_shared.dm diff --git a/code/controllers/subsystem/weather.dm b/code/controllers/subsystem/weather.dm index ffd151171cc..b2c35e62947 100644 --- a/code/controllers/subsystem/weather.dm +++ b/code/controllers/subsystem/weather.dm @@ -38,7 +38,8 @@ SUBSYSTEM_DEF(weather) mobs_by_z_cache_fire = times_fired for(var/mob/living/candidate as anything in GLOB.mob_living_list) // Weather is player-facing; ordinary planetary fauna should never enter its work list. - if(!candidate.mind && !candidate.ever_had_mind) + // Human NPCs (voidcrew/modules/human_npcs/) are people: weathered like players while awake. + if(!candidate.mind && !candidate.ever_had_mind && !human_npc_weathered(candidate)) continue var/candidate_z = candidate.z if(!candidate_z) // contained mobs report z = 0 diff --git a/code/datums/weather/weather.dm b/code/datums/weather/weather.dm index b1820c4d40b..cf6f55fec98 100644 --- a/code/datums/weather/weather.dm +++ b/code/datums/weather/weather.dm @@ -425,7 +425,8 @@ // VOIDCREW EDIT START - PR #123: ship systems and overmap integration. /datum/weather/proc/can_weather_act_mob(mob/living/mob_to_check) // Preserve effects on abandoned player bodies while excluding ordinary fauna. - if(!mob_to_check.mind && !mob_to_check.ever_had_mind) + // Human NPCs (voidcrew/modules/human_npcs/) are weathered like players while awake. + if(!mob_to_check.mind && !mob_to_check.ever_had_mind && !human_npc_weathered(mob_to_check)) return var/turf/mob_turf = get_turf(mob_to_check) diff --git a/code/modules/unit_tests/surgeries.dm b/code/modules/unit_tests/surgeries.dm index 8d2901bf77f..3af5e2df669 100644 --- a/code/modules/unit_tests/surgeries.dm +++ b/code/modules/unit_tests/surgeries.dm @@ -130,4 +130,14 @@ basic_brute_heal.success(user, naked_patient, BODY_ZONE_CHEST) basic_brute_heal.success(user, clothed_patient, BODY_ZONE_CHEST) - TEST_ASSERT(naked_patient.getBruteLoss() < clothed_patient.getBruteLoss(), "Naked patient did not heal more from wounds tending than a clothed patient") + // VOIDCREW EDIT CHANGE START: Voidcrew's tend wounds works through clothing (VOIDCREW EDIT REMOVAL in + // code/modules/surgery/healing.dm), so both heal alike. Compared as raw limb damage: the tended limb is + // picked at random, and limbs count less towards getBruteLoss() than the head and chest. + var/naked_brute = 0 + for(var/obj/item/bodypart/part as anything in naked_patient.bodyparts) + naked_brute += part.brute_dam + var/clothed_brute = 0 + for(var/obj/item/bodypart/part as anything in clothed_patient.bodyparts) + clothed_brute += part.brute_dam + TEST_ASSERT(abs(naked_brute - clothed_brute) < 0.5, "Tending wounds healed a clothed patient differently from a naked one ([naked_brute] vs [clothed_brute] brute left)") + // VOIDCREW EDIT CHANGE END diff --git a/tgstation.dme b/tgstation.dme index ae0dc79f405..a9282662bc2 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -6696,6 +6696,7 @@ #include "voidcrew\_DEFINES\dynamic_events.dm" #include "voidcrew\_DEFINES\flags.dm" #include "voidcrew\_DEFINES\hud.dm" +#include "voidcrew\_DEFINES\human_npcs.dm" #include "voidcrew\_DEFINES\job_categories.dm" #include "voidcrew\_DEFINES\keybindings.dm" #include "voidcrew\_DEFINES\lich.dm" @@ -7234,6 +7235,19 @@ #include "voidcrew\modules\dynamic_events\events\wormholes.dm" #include "voidcrew\modules\food_and_drinks\drinks\bottles.dm" #include "voidcrew\modules\holopads\ship_holocall.dm" +#include "voidcrew\modules\human_npcs\human_npc.dm" +#include "voidcrew\modules\human_npcs\human_npc_admin.dm" +#include "voidcrew\modules\human_npcs\human_npc_ai.dm" +#include "voidcrew\modules\human_npcs\human_npc_barks.dm" +#include "voidcrew\modules\human_npcs\human_npc_combat_sense.dm" +#include "voidcrew\modules\human_npcs\human_npc_gear.dm" +#include "voidcrew\modules\human_npcs\human_npc_outfits.dm" +#include "voidcrew\modules\human_npcs\human_npc_samples.dm" +#include "voidcrew\modules\human_npcs\human_npc_soft_crit.dm" +#include "voidcrew\modules\human_npcs\human_npc_spawning.dm" +#include "voidcrew\modules\human_npcs\human_npc_spike_harness.dm" +#include "voidcrew\modules\human_npcs\human_npc_states.dm" +#include "voidcrew\modules\human_npcs\human_npc_surrender.dm" #include "voidcrew\modules\hyperviolence\_core.dm" #include "voidcrew\modules\hyperviolence\blood\_blood_defines.dm" #include "voidcrew\modules\hyperviolence\blood\blood_pools.dm" diff --git a/voidcrew/_DEFINES/human_npcs.dm b/voidcrew/_DEFINES/human_npcs.dm new file mode 100644 index 00000000000..f638a23ad71 --- /dev/null +++ b/voidcrew/_DEFINES/human_npcs.dm @@ -0,0 +1,163 @@ +// Human NPCs: real /mob/living/carbon/human bodies driven by an AI (voidcrew/modules/human_npcs/). +// Unit tests are included before voidcrew/_DEFINES, so nothing here is visible to them. + +/// Returns TRUE if `thing` is a human NPC body. +#define ishumannpc(thing) istype(thing, /mob/living/carbon/human/npc) + +// npc_rank: who may land hyperviolence aimed crits and gun executions (owner decision D4). +/// An ordinary NPC. Its hits never become aimed crits or executions. +#define HUMAN_NPC_RANK_REGULAR 0 +/// An elite NPC. Lands aimed crits and executions the way a player does. +#define HUMAN_NPC_RANK_ELITE 1 +/// A boss NPC. Lands aimed crits and executions the way a player does. +#define HUMAN_NPC_RANK_BOSS 2 + +/// On every item locked to a human NPC's body (human_npc_gear.dm). +#define TRAIT_HUMAN_NPC_GEAR "human_npc_gear" +/// On a consumable issued to a human NPC: it may leave the body, but never becomes loot (human_npc_gear.dm). +#define TRAIT_HUMAN_NPC_CONSUMABLE "human_npc_consumable" +/// On locked gear that went somewhere it may not be, and is deleted on the next tick unless it comes back. +#define TRAIT_HUMAN_NPC_GEAR_LOST "human_npc_gear_lost" + +/// Default for how far a human NPC spots hostiles, in tiles (BB_AGGRO_RANGE). +#define HUMAN_NPC_SIGHT_RANGE 9 + +/// Human NPCs the spawn queue makes per fire of SShuman_npcs. One human costs about 11 ms to make. +#define HUMAN_NPC_SPAWNS_PER_FIRE 1 +/// How often SShuman_npcs looks over the corpses it tracks. +#define HUMAN_NPC_CORPSE_SWEEP_INTERVAL (30 SECONDS) +/// Default time a human NPC corpse lies before it may be cleaned up (npc_corpse_lifetime). +#define HUMAN_NPC_CORPSE_LIFETIME (10 MINUTES) +/// A corpse or loose body part with a player this close is never cleaned up. +#define HUMAN_NPC_CORPSE_WATCH_RANGE 10 +/// Corpses deleted per fire at most, so a big sweep doesn't stall a tick. +#define HUMAN_NPC_CORPSE_DELETES_PER_FIRE 2 + +// Blackboard keys (human_npc_ai.dm). +/// Deciseconds between two pulls of the trigger. +#define BB_HUMAN_NPC_SHOT_DELAY "human_npc_shot_delay" +/// world.time the NPC may next pull the trigger. +#define BB_HUMAN_NPC_NEXT_SHOT "human_npc_next_shot" +/// Furthest a gunner shoots from, in tiles. Further than this it closes in. +#define BB_HUMAN_NPC_FIRE_RANGE "human_npc_fire_range" +/// A gunner steps back from a target closer than this, in tiles. 0 never steps back. +#define BB_HUMAN_NPC_KEEP_AWAY "human_npc_keep_away" +/// world.time the NPC may next try to reload or change weapons, after a try that got nowhere. +#define BB_HUMAN_NPC_ARMING_RETRY_AT "human_npc_arming_retry_at" +/// world.time a reload in progress gives up. +#define BB_HUMAN_NPC_RELOAD_UNTIL "human_npc_reload_until" +/// The item the NPC is drawing (human_npc_draw). +#define BB_HUMAN_NPC_DRAW_ITEM "human_npc_draw_item" + +// ===== Phase A2: shared pieces for pirates, ruin NPCs, hermits and criminals ===== + +// npc_target_stat: the worst state a target can be in and still get attacked (BB_TARGET_MINIMUM_STAT). +/// Pirates, troopers, hermits, raiders, NT customs: keep shooting someone in crit, as tg troopers do. +#define HUMAN_NPC_FINISHES_DOWNED HARD_CRIT +/// Criminals, companions, bosses, prisoners, guards: stop once a target is in crit. +#define HUMAN_NPC_SPARES_DOWNED CONSCIOUS + +// Bark kinds (human_npc_barks.dm). Families supply the lines through a /datum/human_npc_voice. +/// Entered crit. Whispered in soft crit; hard crit gets the emote only. +#define HUMAN_NPC_BARK_DOWNED "downed" +/// Left crit, or got up from stamcrit. +#define HUMAN_NPC_BARK_RECOVER "recover" +/// Now and then while it crawls in soft crit. Falls back to the downed lines. +#define HUMAN_NPC_BARK_PLEAD "plead" +/// Handcuffs went on. +#define HUMAN_NPC_BARK_CUFFED "cuffed" +/// Started working at its cuffs (tg's cuff_resist). +#define HUMAN_NPC_BARK_SLIPPING "slipping_cuffs" +/// Its cuffs came off, by its own work or someone else's. +#define HUMAN_NPC_BARK_UNCUFFED "uncuffed" +/// Broke out of a grab or off someone's shoulders by resisting. +#define HUMAN_NPC_BARK_PULLED_FREE "pulled_free" +/// Gave up (human_npc_surrender.dm). Always said. +#define HUMAN_NPC_BARK_SURRENDER "surrender" +/// Died. Emote only: the dead don't talk. +#define HUMAN_NPC_BARK_DEATH "death" +/// Default seconds between two barks from one NPC. +#define HUMAN_NPC_BARK_COOLDOWN (4 SECONDS) +/// How often an NPC crawling in soft crit pleads, at most. +#define HUMAN_NPC_PLEAD_INTERVAL (12 SECONDS) + +// Sites (human_npc_outfits.dm): what the air where an NPC is dressed asks of its kit. +/// Too little pressure to live in: a sealed suit and helmet and its own air. +#define HUMAN_NPC_SITE_VACUUM (1<<0) +/// Pressure is fine but the air isn't: a mask and a tank. +#define HUMAN_NPC_SITE_BAD_AIR (1<<1) +/// Cold enough to freeze an unprotected person: cold-weather wear. +#define HUMAN_NPC_SITE_COLD (1<<2) +/// Air colder than this, in kelvin, is a cold site. +#define HUMAN_NPC_SITE_COLD_TEMP (T0C - 10) +/// Oxygen partial pressure below this, in kPa, is not breathable (tg's safe minimum). +#define HUMAN_NPC_SITE_MIN_OXYGEN 16 +/// How much better than its lungs' limits (kPa) the air must be before an NPC on internals closes its valve. +#define HUMAN_NPC_AIR_MARGIN 2 +/// A queued NPC dressed by an outfit table waits this long for its spawn zone to resolve, then takes green. +#define HUMAN_NPC_ZONE_WAIT (60 SECONDS) + +// Leaving (human_npc_states.dm). +/// How often SShuman_npcs checks whether an NPC walking out may be deleted. +#define HUMAN_NPC_LEAVER_SWEEP_INTERVAL (1 SECONDS) + +// Signals sent on a human NPC. +/// It gave up: tg's *surrender is running. () +#define COMSIG_HUMAN_NPC_SURRENDERED "human_npc_surrendered" +/// Its surrender's paralysis ended and nobody had cuffed it. () +#define COMSIG_HUMAN_NPC_SURRENDER_ENDED "human_npc_surrender_ended" +/// It entered crit. () +#define COMSIG_HUMAN_NPC_DOWNED "human_npc_downed" +/// It left crit, or got up from stamcrit. () +#define COMSIG_HUMAN_NPC_RECOVERED "human_npc_recovered" +/// It walked out and is about to be deleted (human_npc_states.dm). () +#define COMSIG_HUMAN_NPC_LEFT "human_npc_left" + +// More blackboard keys. +/// A mob it is running from (surrender flight, soft-crit crawl). +#define BB_HUMAN_NPC_FLEE_FROM "human_npc_flee_from" +/// world.time it stops fleeing after deciding not to give up again. +#define BB_HUMAN_NPC_FLEE_UNTIL "human_npc_flee_until" +/// The item it is using on itself (human_npc_treat_self). +#define BB_HUMAN_NPC_TREAT_ITEM "human_npc_treat_item" +/// world.time it may next treat itself. +#define BB_HUMAN_NPC_NEXT_TREAT "human_npc_next_treat" +/// The turf it is walking out to (npc_walk_out()). +#define BB_HUMAN_NPC_EXIT "human_npc_exit" + +// ===== Combat sense (human_npc_combat_sense.dm) ===== +// Armed hostile NPCs that opt in (npc_combat_sense) inject a stimulant they carry when they tire, and +// stop standing in the open when they are hit by stun fire. Defaults for /datum/npc_combat_sense. + +/// Stamina loss, as a share of what stamcrits the body, at which it reaches for a stimulant it carries. +#define HUMAN_NPC_SENSE_STIM_SHARE 0.5 +/// How long after its last stun hit it keeps reacting to stun fire. +#define HUMAN_NPC_SENSE_REACT_TIME (8 SECONDS) +/// The furthest it walks to cover, in steps. +#define HUMAN_NPC_SENSE_COVER_STEPS 4 +/// How long it keeps its head down in cover before it looks out again. +#define HUMAN_NPC_SENSE_PEEK_AFTER (2.5 SECONDS) +/// The longest it stays in cover while it is winded (stamina loss past the stimulant share). +#define HUMAN_NPC_SENSE_MAX_HOLD (10 SECONDS) +/// How many times it runs for cover in one exchange of fire before it stands and fights. +#define HUMAN_NPC_SENSE_COVER_MOVES 3 +/// A fighter that hits from this many tiles or fewer closes in on a stun shooter instead of taking cover. +#define HUMAN_NPC_SENSE_CLOSE_IN_REACH 3 +/// It gives up on reaching its cover after this long per step of the way, plus a second. +#define HUMAN_NPC_SENSE_COVER_STEP_TIME (0.6 SECONDS) +/// How long it leaves its stimulants alone after a try that got nowhere (no hand free, the pen gone). +#define HUMAN_NPC_SENSE_STIM_RETRY (5 SECONDS) + +/// Blackboard: the cover turf it is walking to. +#define BB_HUMAN_NPC_COVER "human_npc_cover" +/// Blackboard: the stimulant pen it is using on itself. +#define BB_HUMAN_NPC_STIM_ITEM "human_npc_stim_item" +/// Blackboard: whoever shot it with stun fire, for the close-in. +#define BB_HUMAN_NPC_STUN_SHOOTER "human_npc_stun_shooter" + +/// Bark kind: it injects a stimulant it carries (faction pirate voices already have emotes for it). +#define HUMAN_NPC_BARK_STIMULANT "stimulant" +/// Bark kind: it runs for cover from stun fire. +#define HUMAN_NPC_BARK_TAKE_COVER "take_cover" +/// Bark kind: it charges whoever shot it with stun fire. +#define HUMAN_NPC_BARK_CHARGE "charge" diff --git a/voidcrew/edits/mobs/ladder_outfits.dm b/voidcrew/edits/mobs/ladder_outfits.dm index c2925461fe3..6a6f83726c6 100644 --- a/voidcrew/edits/mobs/ladder_outfits.dm +++ b/voidcrew/edits/mobs/ladder_outfits.dm @@ -20,6 +20,11 @@ . = ..() ladder_add_survival_knife() +// The combat-ready kit fills its bag already: equip() below hands the knife over instead. +/datum/outfit/job/miner/equipped/combat/pre_equip(mob/living/carbon/human/H, visuals_only = FALSE) + . = ..() + backpack_contents -= /obj/item/knife/combat/survival + /datum/outfit/job/security/pre_equip(mob/living/carbon/human/H, visuals_only = FALSE) . = ..() ladder_add_survival_knife() @@ -59,10 +64,11 @@ // Corpse and ghost-role outfits are also fixed starting placements. // Appearance dummies are left alone: get_dynamic_human_appearance() dresses one through the // spawner to draw an NPC's look (a gunner holding its gun) and deletes it straight after, so -// nothing on it can ever be picked up. +// nothing on it can ever be picked up. Human NPCs (voidcrew/modules/human_npcs/) are left alone +// too: their kit is locked to the body and never becomes loot, and it's what they fight with. /obj/effect/mob_spawn/equip(mob/living/spawned_mob) . = ..() - if(ishuman(spawned_mob) && !istype(spawned_mob, /mob/living/carbon/human/dummy)) + if(ishuman(spawned_mob) && !istype(spawned_mob, /mob/living/carbon/human/dummy) && !ishumannpc(spawned_mob)) remove_ladder_starting_weapons(spawned_mob, list()) /datum/voucher_set/mining/crusher_kit diff --git a/voidcrew/machinery/ship_defense_turret.dm b/voidcrew/machinery/ship_defense_turret.dm index 13c244dcdc6..a0223d00be2 100644 --- a/voidcrew/machinery/ship_defense_turret.dm +++ b/voidcrew/machinery/ship_defense_turret.dm @@ -284,21 +284,25 @@ * which is the whole job. */ /obj/machinery/porta_turret/ship_defense/proc/valid_target(mob/living/creature) - if(creature.stat == DEAD) + // Dead, in crit or cuffed: out of the fight (human_npc_out_of_fight(), owner ruling OC-7), so a + // boarder the crew has taken down or captured is left alone. A basic mob is out only once dead. + if(human_npc_out_of_fight(creature)) return FALSE if(creature.client || creature.mind) // Anything a player is driving, or was driving. return FALSE - if(iscarbon(creature) || issilicon(creature)) // People, monkeys, xenos, borgs, pAIs. + // People, monkeys, xenos, borgs, pAIs. Human NPCs (voidcrew/modules/human_npcs/) are bodies no + // player drives, the human boarders that replace troopers, so they are fair game like them. + if(issilicon(creature) || (iscarbon(creature) && !ishumannpc(creature))) return FALSE if(creature.invisibility > SEE_INVISIBLE_LIVING) return FALSE if(in_faction(creature)) // Bots, pets and other turrets. return FALSE // With wildlife targeting off the turret only watches for boarding parties, which are - // all trooper-type humanoids (pirates and their kin). Lets the crew hunt the local + // all trooper-type humanoids or human NPCs (pirates and their kin). Lets the crew hunt the local // fauna themselves without the turret stealing every kill. // Escaped outpost prisoners count as boarders (outpost_prison_riot.dm). - if(!target_wildlife && !istype(creature, /mob/living/basic/trooper) && !is_loose_outpost_prisoner(creature)) + if(!target_wildlife && !istype(creature, /mob/living/basic/trooper) && !ishumannpc(creature) && !is_loose_outpost_prisoner(creature)) return FALSE if(!is_hostile_creature(creature)) // Livestock, pets and passive fauna get left alone. return FALSE diff --git a/voidcrew/modules/human_npcs/human_npc.dm b/voidcrew/modules/human_npcs/human_npc.dm new file mode 100644 index 00000000000..aec6ce77173 --- /dev/null +++ b/voidcrew/modules/human_npcs/human_npc.dm @@ -0,0 +1,665 @@ +/** + * # Human NPCs + * + * A human NPC is a real /mob/living/carbon/human driven by an AI (human_npc_ai.dm). Everything a + * player's body does, it does through the same tg code: wounds, bleeding, dismemberment, soft and hard + * crit, suffocation, stamina damage and stamcrit, stuns, cuffs, grabs, pulling, death, revival, + * organ decay, and the hyperviolence gore and executions. There are no stand-in states, health + * pools or heals. Phases B-E of the human NPC migration build pirates, troopers, hermits and bounty + * criminals on this type; the developer notes are in the kit vault (modules/human_npcs.md). + * + * Making one: spawn_human_npc() (human_npc_spawning.dm) queues it, so a wave is built a body or two + * per tick, never all at once. Maps place /obj/effect/spawner/human_npc. A subtype sets its look, + * outfit, name, faction, rank, toughness and death drops with the vars below. + * + * What differs from a player's body, and why. These are the only deviations: + * - Dormancy (performance). Life() does nothing while no player is on the NPC's z-level, alive or + * dead (npc_dormant()), the same test tg uses to switch the AI off. While dormant nothing in Life() + * runs: bleeding, wound and organ processing, metabolism, breathing, body temperature, pressure, + * crit oxygen loss, natural healing, disease. A dormant NPC is frozen in time; a wounded one doesn't + * bleed out until someone arrives. A corpse that wakes catches up the organ decay it missed while + * dormant (npc_catch_up_decay()), so the defib window and organ rot match a player's corpse; its + * body temperature is not caught up. Stamina recovery is a timer, not Life(), so it is not paused. + * A space suit's thermal regulator is switched off while it is dormant and back on when it wakes + * (npc_set_suit_heating()), so a cell doesn't run flat keeping a frozen-in-time body warm. + * This has to be a guard on this type's own Life(): COMSIG_LIVING_LIFE's cancel flag only stops + * /mob/living/Life(), and carbon and human Life() run organs, wounds, limbs and temperature around it. + * - No mood datum and TRAIT_NOHUNGER (performance, and an NPC never eats over a 6 hour round). + * - Gear lock (owner decision D3, human_npc_gear.dm): its kit can't be stripped, dropped or looted. + * - Aimed crits and gun executions only from elites and bosses (owner decision D4, npc_rank). + */ +/mob/living/carbon/human/npc + name = "stranger" + faction = list(FACTION_HOSTILE) + ai_controller = /datum/ai_controller/basic_controller/human_npc + /// What it wears and holds: an outfit typepath. Weapons go in its r_hand and l_hand, spare + /// magazines in pockets or belt_contents, an air tank with internals_slot set. + var/datum/outfit/npc_outfit + /** + * How it looks. Null: an ordinary random person of the default species. A + * /obj/effect/mob_spawn typepath: that spawner's species, hair and skin, and its outfit if + * npc_outfit is unset (the corpse spawners of today's NPCs). spawn_human_npc(look =) also takes a + * /datum/bounty_look or a /datum/bounty_record. + */ + var/npc_look + /// Its name. Null keeps the random name its look rolled. + var/npc_name + /// HUMAN_NPC_RANK_*. Only elites and bosses land aimed crits and gun executions. + var/npc_rank = HUMAN_NPC_RANK_REGULAR + /** + * Toughness: brute and burn damage taken is multiplied by this, through the body's physiology, + * as species and cyberware do it for players. Never touches stamina or stuns. 1 is a person. + * Change it on a live NPC with set_npc_toughness(). + */ + var/npc_damage_taken = 1 + /// A /datum/armor added to the body's own physiology armour (dermal plating on a player). Null for none. + var/datum/armor/npc_body_armor + /** + * Cyberware organ typepaths installed at spawn (voidcrew/modules/cyberware/). It works as it does + * in a player: a dodge shunt dodges, plating armours, a brownout browns out. It burns out to scrap + * when the NPC dies or the ware is taken out of it (owner ruling), so it is never salvaged working. + */ + var/list/npc_cyberware + /** + * Handles its own air the way a person does (npc_update_internals()): opens a tank it carries when + * the air it would breathe is bad and it has a mask or helmet that takes one, and closes the valve + * again once the air is fine, so its tank doesn't run dry in a breathable room. + */ + var/npc_internals = TRUE + /// Typepaths spawned under it the first time it dies (its designed loot). Never a second time. + var/list/npc_death_loot + /// Credits dropped as a holochip the first time it dies. + var/npc_death_cash = 0 + /// How long its corpse lies before SShuman_npcs may delete it once nobody is near. 0: never; the + /// system that owns the NPC cleans it up. + var/npc_corpse_lifetime = HUMAN_NPC_CORPSE_LIFETIME + /// Apply the dormancy and life trims. Only the measurement harness turns this off. + var/npc_trim_life = TRUE + + // ===== Per-family behaviour (phase A2). A family sets these on its own subtype. ===== + /** + * Picks its outfit by zone and rank when npc_outfit is unset: a /datum/human_npc_outfit_table typepath + * (human_npc_outfits.dm). spawn_human_npc(outfit =) also takes a table. + */ + var/datum/human_npc_outfit_table/npc_outfit_table + /// HUMAN_NPC_SITE_* flags it always dresses for, on top of the air where it spawns: a boarder that + /// crosses vacuum sets HUMAN_NPC_SITE_VACUUM so it carries a sealed suit even when it spawns indoors. + var/npc_always_site = NONE + /// What it says when things happen to it: a /datum/human_npc_voice typepath (human_npc_barks.dm), or + /// null for nothing. Override npc_bark() to voice it another way. + var/datum/human_npc_voice/npc_voice + /// When it gives up: a /datum/human_npc_surrender typepath (human_npc_surrender.dm), or null if it never does. + var/datum/human_npc_surrender/npc_surrender + /** + * The worst state a target can be in and still get attacked, written into its AI's + * BB_TARGET_MINIMUM_STAT at spawn: HUMAN_NPC_FINISHES_DOWNED (pirates, troopers, hermits) or + * HUMAN_NPC_SPARES_DOWNED (criminals, bosses, prisoners, guards). + */ + var/npc_target_stat = HUMAN_NPC_FINISHES_DOWNED + /// D3: its kit is locked to its body. Prisoners turn this off (owner ruling OC-11): their jumpsuits, + /// contraband and shivs are ordinary items that shakedowns and confiscation work on. + var/npc_gear_locked = TRUE + /** + * How it fights stun weapons (human_npc_combat_sense.dm): its family's /datum/npc_combat_sense typepath, + * or null for none. Only armed hostiles set it, never civilians, townsfolk or prisoners. Its controller + * must list /datum/ai_planning_subtree/npc_combat_sense. + */ + var/datum/npc_combat_sense/npc_combat_sense + + /// The HUMAN_NPC_SITE_* flags it was dressed for + var/npc_site = NONE + /// The bark kind it last gave, for tests and admins + var/npc_last_bark + COOLDOWN_DECLARE(npc_bark_cooldown) + /// world.time it may next plead while down in soft crit + var/npc_next_plead = 0 + /// TRUE while the paralysis of its own *surrender runs + var/npc_surrendering = FALSE + /// Set when a surrender's paralysis ended with nobody cuffing it: it decides again at once + var/npc_surrender_redecide = FALSE + /// world.time it may next roll to surrender + var/npc_next_surrender_roll = 0 + /// How many times it has rolled to give up, and how many times it did + var/npc_surrender_rolls = 0 + var/npc_surrender_count = 0 + /// Weakref to whoever held it when it last resisted, and the world.time it did + var/datum/weakref/npc_resisted_hold + var/npc_resisted_at = 0 + /// The turf it is walking out to (npc_walk_out()), or null + var/turf/npc_exit + /// Called with it just before it is deleted on walking out + var/datum/callback/npc_on_left + + /// TRUE once its death loot has dropped + var/npc_loot_dropped = FALSE + /// world.time it last died, or 0 + var/npc_died_at = 0 + /// world.time its current dormant spell began, or 0 while awake + var/npc_dormant_since = 0 + /// The damage multiplier set_npc_toughness() last applied + var/npc_damage_taken_applied = 1 + /// Weakrefs to limbs and organs that came off it, cleaned up with its corpse + var/list/datum/weakref/npc_remains + +/mob/living/carbon/human/npc/Initialize(mapload, datum/human_npc_order/order) + . = ..() + if(npc_trim_life) + ADD_TRAIT(src, TRAIT_NOHUNGER, INNATE_TRAIT) + npc_dress(order) + for(var/ware_type in npc_cyberware) + npc_install_cyberware(ware_type) + npc_conceal_presence() + if(npc_gear_locked) + npc_lock_all_gear() + for(var/obj/item/held as anything in held_items) + if(held) + human_npc_ready_weapon(src, held) + npc_update_internals() + npc_set_suit_heating(TRUE) + set_npc_toughness(npc_damage_taken) + if(npc_body_armor) + physiology.armor = physiology.armor.add_other_armor(npc_body_armor) + if(istype(ai_controller)) + ai_controller.set_blackboard_key(BB_TARGET_MINIMUM_STAT, npc_target_stat) + AddElement(/datum/element/human_npc_body) + AddElement(/datum/element/human_npc_reactions) + if(ispath(npc_combat_sense, /datum/npc_combat_sense)) + AddComponent(/datum/component/npc_combat_sense, npc_combat_sense) + +/mob/living/carbon/human/npc/Destroy() + SShuman_npcs?.forget_corpse(src) + SShuman_npcs?.leavers -= src + npc_remains = null + npc_resisted_hold = null + npc_exit = null + npc_on_left = null + return ..() + +/mob/living/carbon/human/npc/setup_mood() + if(npc_trim_life) + return + return ..() + +// ===== DORMANCY ===== + +/mob/living/carbon/human/npc/Life(seconds_per_tick = SSMOBS_DT, times_fired) + if(npc_trim_life) + if(npc_dormant()) + if(!npc_dormant_since) + npc_dormant_since = world.time + npc_set_suit_heating(FALSE) + return FALSE + if(npc_dormant_since) + npc_catch_up_decay((world.time - npc_dormant_since) / (1 SECONDS), times_fired) + npc_dormant_since = 0 + npc_set_suit_heating(TRUE) + // Before the breath this Life() takes: a person who steps into bad air reaches for the valve. + if(stat != DEAD) + npc_update_internals() +#ifdef HUMAN_NPC_SPIKE_HARNESS + GLOB.human_npc_spike_life_passes++ +#endif + return ..() + +/// TRUE while this NPC's Life() should not run: no player is on its z-level. +/mob/living/carbon/human/npc/proc/npc_dormant() + return !npc_players_on_level() + +/// Whether any living player shares this NPC's z-level. Same test as get_expected_ai_status(). +/mob/living/carbon/human/npc/proc/npc_players_on_level() + var/turf/our_turf = get_turf(src) + if(isnull(our_turf)) + return FALSE + return length(SSmobs.clients_by_zlevel[our_turf.z]) > 0 + +/** + * A corpse that slept for `slept_seconds` decays its organs for that long at once, through tg's own + * handle_organs() (which skips frozen and robotic organs and bodies kept in formaldehyde or + * cryostylane), so its defib window closes when a player's would. A living NPC catches nothing up. + */ +/mob/living/carbon/human/npc/proc/npc_catch_up_decay(slept_seconds, times_fired) + if(stat != DEAD || slept_seconds <= 0 || HAS_TRAIT(src, TRAIT_STASIS)) + return + handle_organs(slept_seconds, times_fired) + +// ===== DRESSING ===== + +/** + * Puts on its look, outfit, name and faction. `order` may override the type's own. + * + * The outfit is, first found: the order's outfit, npc_outfit, a pick from npc_outfit_table, or the + * outfit of a spawner look. An outfit table (as the order's outfit or npc_outfit_table) picks by the + * zone it spawns in and its rank. Then the site layers go on (human_npc_outfits.dm): where the air + * can't keep it alive it gets a sealed suit and a tank, where it is cold it gets cold-weather wear, so + * no NPC suffocates or freezes on the spot it was made. Species that don't need them (skeletons in + * vacuum) are left as they are. + */ +/mob/living/carbon/human/npc/proc/npc_dress(datum/human_npc_order/order) + var/look = order?.look || npc_look + var/outfit = order?.outfit || npc_outfit + var/datum/human_npc_outfit_table/table + if(ispath(outfit, /datum/human_npc_outfit_table)) + table = outfit + outfit = null + else if(isnull(outfit) && ispath(npc_outfit_table, /datum/human_npc_outfit_table)) + table = npc_outfit_table + var/datum/bounty_record/record + if(istype(look, /datum/bounty_record)) + record = look + look = bounty_ensure_look(record) + var/spawner_outfit + if(ispath(look, /obj/effect/mob_spawn)) + spawner_outfit = npc_apply_spawner_look(look) + else if(istype(look, /datum/bounty_look)) + npc_apply_bounty_look(look) + else + npc_apply_random_look() + // Plasmamen and other species that need their own kit to live get it first, as from a spawner. + dna.species.give_important_for_life(src) + if(table) + table = human_npc_singleton(table) + outfit = table.pick_outfit(src, order ? order.resolve_zone() : npc_spawn_zone()) + outfit ||= spawner_outfit + // Dressed directly, not through /obj/effect/mob_spawn/equip(), whose ladder strip + // (voidcrew/edits/mobs/ladder_outfits.dm) would delete the guns an NPC fights with. + if(outfit) + outfit = npc_fit_outfit_to_site(outfit, table) + equipOutfit(outfit) + if(record) + bounty_wear_features(src, record.features) + var/new_name = order?.name || npc_name + if(new_name) + fully_replace_character_name(real_name, new_name) + if(length(order?.faction)) + faction = order.faction.Copy() + +/// An ordinary random person, as tg's corpse spawners make them. +/mob/living/carbon/human/npc/proc/npc_apply_random_look() + randomize_human_normie(src, update_body = FALSE) + update_body(is_creating = TRUE) + +/// The look of a /obj/effect/mob_spawn typepath, applied the way its special() applies it. Returns its outfit. +/mob/living/carbon/human/npc/proc/npc_apply_spawner_look(obj/effect/mob_spawn/spawner) + var/datum/species/species = initial(spawner.mob_species) + if(ispath(species, /datum/species) && dna.species.type != species) + set_species(species) + underwear = "Nude" + undershirt = "Nude" + socks = "Nude" + randomize_human_normie(src, update_body = FALSE) + var/hairstyle = initial(spawner.hairstyle) + if(hairstyle) + set_hairstyle(hairstyle, update = FALSE) + var/facial_hairstyle = initial(spawner.facial_hairstyle) + if(facial_hairstyle) + set_facial_hairstyle(facial_hairstyle, update = FALSE) + var/haircolor = initial(spawner.haircolor) + if(haircolor) + set_haircolor(haircolor, update = FALSE) + var/facial_haircolor = initial(spawner.facial_haircolor) + if(facial_haircolor) + set_facial_haircolor(facial_haircolor, update = FALSE) + var/spawner_skin = initial(spawner.skin_tone) + if(spawner_skin) + skin_tone = spawner_skin + update_body(is_creating = TRUE) + return initial(spawner.outfit) + +/// A bounty record's face (voidcrew/modules/bounties/), applied in the order bounty_dress_dummy() uses. +/mob/living/carbon/human/npc/proc/npc_apply_bounty_look(datum/bounty_look/look) + // Before the species: its visible organs take their shape from dna.features as they go in. + for(var/feature in look.features) + dna.features[feature] = look.features[feature] + gender = look.physique == FEMALE ? FEMALE : MALE + physique = gender + if(ispath(look.species, /datum/species) && dna.species.type != look.species) + set_species(look.species) + if(look.skin_tone) + skin_tone = look.skin_tone + set_hairstyle(look.hairstyle || "Bald", update = FALSE) + if(look.hair_color) + set_haircolor(look.hair_color, update = FALSE) + set_facial_hairstyle(look.facial_hairstyle || "Shaved", update = FALSE) + if(look.facial_hair_color || look.hair_color) + set_facial_haircolor(look.facial_hair_color || look.hair_color, update = FALSE) + if(look.eye_color) + set_eye_color(look.eye_color) + underwear = "Nude" + undershirt = "Nude" + socks = "Nude" + update_body(is_creating = TRUE) + +/// Keeps its PDA off messenger lists and its suit sensors off crew monitors, as corpse spawners do. +/mob/living/carbon/human/npc/proc/npc_conceal_presence() + var/obj/item/modular_computer/pda/messenger = locate() in src + if(messenger) + var/datum/computer_file/program/messenger/message_app = locate() in messenger.stored_files + if(message_app) + message_app.invisible = TRUE + var/obj/item/clothing/under/sensor_clothes = w_uniform + if(istype(sensor_clothes)) + sensor_clothes.sensor_mode = SENSOR_OFF + update_suit_sensors() + +/** + * Opens or closes its internals for the air where it stands, as a person minds their valve: open while + * the air would hurt it (too thin, short of what its lungs need, poisonous), closed while it is fine. A + * conscious NPC only; one that can't use its hands (cuffs, a stun) leaves the valve as it is, as would a + * person. Species that don't breathe, or that only live on what's in their tank (plasmamen), keep it + * as it is. Called from Life() and when it is dressed. + */ +/mob/living/carbon/human/npc/proc/npc_update_internals() + if(!npc_internals || HAS_TRAIT(src, TRAIT_NOBREATH)) + return + if(stat > SOFT_CRIT || HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)) + return + var/obj/item/organ/lungs/lungs = get_organ_slot(ORGAN_SLOT_LUNGS) + if(isnull(lungs)) + return + // Lungs that need something ordinary air doesn't have: whatever it was dressed with stays on. + if(lungs.safe_plasma_min > 0 || lungs.safe_nitro_min > 0) + return + var/bad_air = human_npc_air_hurts(get_turf(src), lungs, margin = internal ? HUMAN_NPC_AIR_MARGIN : 0) + if(bad_air) + if(!internal) + npc_open_internals() + else if(internal && !external) + close_internals() + +/// Turns on an air tank it wears, if it has something to breathe it through, the way a player does. +/mob/living/carbon/human/npc/proc/npc_open_internals() + if(internal || !can_breathe_internals()) + return + for(var/obj/item/tank/internals/tank in get_equipped_items(INCLUDE_POCKETS | INCLUDE_HELD)) + if(tank.air_contents?.return_pressure() <= 0) + continue + if(open_internals(tank)) + return + +/** + * Whether breathing the air at `spot` would hurt someone with `lungs`: pressure too low or too high, + * too little oxygen, or too much plasma, carbon dioxide or sleeping gas, by those lungs' own limits. + * `margin` (kPa) asks for that much better than the limit before the air counts as fine again, so a + * valve isn't worked every breath at the edge. + */ +/proc/human_npc_air_hurts(turf/spot, obj/item/organ/lungs/lungs, margin = 0) + var/datum/gas_mixture/air = spot?.return_air() + if(isnull(air)) + return TRUE + var/pressure = air.return_pressure() + if(pressure < HAZARD_LOW_PRESSURE + margin * 4 || pressure > HAZARD_HIGH_PRESSURE) + return TRUE + if(lungs.safe_oxygen_min && human_npc_partial_pressure(air, /datum/gas/oxygen, pressure) < lungs.safe_oxygen_min + margin) + return TRUE + if(lungs.safe_plasma_max && human_npc_partial_pressure(air, /datum/gas/plasma, pressure) > max(lungs.safe_plasma_max - margin * 0.01, 0)) + return TRUE + if(lungs.safe_co2_max && human_npc_partial_pressure(air, /datum/gas/carbon_dioxide, pressure) > lungs.safe_co2_max - margin) + return TRUE + if(lungs.n2o_para_min && human_npc_partial_pressure(air, /datum/gas/nitrous_oxide, pressure) >= lungs.n2o_para_min) + return TRUE + return FALSE + +/** + * Sets how much brute and burn damage it takes, as a multiple of a person's. Scales the + * physiology mods it set before, so other changes to them (species, implants) are kept. + */ +/mob/living/carbon/human/npc/proc/set_npc_toughness(damage_taken) + if(damage_taken <= 0) + CRASH("[src] ([type]) was given a damage multiplier of [damage_taken]") + var/change = damage_taken / npc_damage_taken_applied + physiology.brute_mod *= change + physiology.burn_mod *= change + npc_damage_taken_applied = damage_taken + npc_damage_taken = damage_taken + +// ===== RULES OF ENGAGEMENT ===== + +// The strip menu works as on anyone, but locked gear (D3) carries TRAIT_NO_STRIP, so its slots read as +// empty and can't be emptied. What isn't gear (a ship key, bounty proof, a paper) can be taken from a +// cuffed, downed or careless NPC the way it could from a person. An NPC whose gear isn't locked +// (prisoners, OC-11) is searched and stripped like anyone. + +// D4: an NPC's hits become aimed crits and executions only if it is an elite or a boss, or a +// person is driving the body. +/mob/living/carbon/human/npc/hv_can_land_aimed_crits() + return client || npc_rank >= HUMAN_NPC_RANK_ELITE + +// Gun executions are rarer still: bosses only, as a deliberate move (owner ruling OC-9). +/mob/living/carbon/human/npc/hv_can_execute() + return client || npc_rank >= HUMAN_NPC_RANK_BOSS + +/mob/living/carbon/human/npc/Login() + . = ..() + // A player in control of the body (a brain transplant) can't keep its gear (D3). Admins + // driving an NPC for an event keep it. + if(!. || isnull(client) || client.holder) + return + npc_delete_locked_gear() + +// ===== DEATH AND REMAINS ===== + +/mob/living/carbon/human/npc/death(gibbed) + if(stat == DEAD) + return ..() + . = ..() + if(stat != DEAD) + return + npc_died_at = world.time + npc_drop_death_loot() + npc_drop_not_gear() + npc_burn_out_chrome() + if(!gibbed && npc_corpse_lifetime && !QDELING(src)) + SShuman_npcs.track_corpse(src) + +/// Drops its designed loot under it, once in its life however often it dies. +/mob/living/carbon/human/npc/proc/npc_drop_death_loot() + if(npc_loot_dropped) + return + npc_loot_dropped = TRUE + var/atom/drop_spot = drop_location() + if(isnull(drop_spot)) + return + // As death_drops does for basic mobs (voidcrew/edits/mobs/weapon_drops.dm): admin-spawned NPCs drop no guns. + var/no_guns = (flags_1 & ADMIN_SPAWNED_1) || npc_spawn_context?.suppress_gun_loot + for(var/loot_type in npc_roll_death_loot()) + if(no_guns && ispath(loot_type, /obj/item/gun)) + continue + new loot_type(drop_spot) + if(npc_death_cash > 0) + new /obj/item/holochip(drop_spot, npc_death_cash) + +/// The typepaths it drops on its first death. Override to roll them (zone ladders, rare pools). +/mob/living/carbon/human/npc/proc/npc_roll_death_loot() + return npc_death_loot + +/// Back from the dead (defib, strange reagent): no longer a corpse to clean up. +/mob/living/carbon/human/npc/proc/npc_revived() + npc_died_at = 0 + SShuman_npcs.forget_corpse(src) + +/// A limb or organ came off: remember it, so it goes when the corpse does. +/mob/living/carbon/human/npc/proc/npc_lost_part(obj/item/part) + LAZYADD(npc_remains, WEAKREF(part)) + +// ===== CYBERWARE ===== + +/** + * Installs a cyberware organ at spawn, the way the cyberware code's own staging inserts do + * (special = TRUE skips the install-context gate; the brownout monitor still applies). Returns the + * organ, or null if it didn't go in. + */ +/mob/living/carbon/human/npc/proc/npc_install_cyberware(ware_type) + var/obj/item/organ/ware = new ware_type() + if(!ware.GetComponent(/datum/component/cyberware)) + stack_trace("[type] was given [ware_type] as cyberware, which isn't chrome") + qdel(ware) + return null + if(!ware.Insert(src, special = TRUE)) + qdel(ware) + return null + return ware + +/// Owner ruling: an NPC's chrome burns out when it dies. Every piece comes out and turns to scrap. +/mob/living/carbon/human/npc/proc/npc_burn_out_chrome() + var/atom/drop_spot = drop_location() + var/burnt = 0 + for(var/obj/item/organ/ware in organs.Copy()) + if(!ware.GetComponent(/datum/component/cyberware)) + continue + ware.Remove(src, special = TRUE) + if(drop_spot) + ware.forceMove(drop_spot) + human_npc_burn_out_chrome(ware) + burnt++ + if(burnt && drop_spot) + do_sparks(min(burnt, 3), TRUE, src) + visible_message(span_warning("[src]'s chrome sparks and goes dead.")) + +/// Turns a piece of a human NPC's chrome that has left its body into scrap where it lies. +/proc/human_npc_burn_out_chrome(obj/item/organ/ware) + if(QDELETED(ware) || ware.owner) + return + var/turf/floor = get_turf(ware) + if(isnull(floor)) + qdel(ware) + return + var/mob/living/holder = ismob(ware.loc) ? ware.loc : null + var/obj/item/burnt_chrome/scrap = new(floor, ware) + qdel(ware) + holder?.put_in_hands(scrap) + +/// What a human NPC's cyberware leaves once it burns out: scrap, never a working implant. +/obj/item/burnt_chrome + name = "burnt-out chrome" + desc = "Cyberware fused black inside. Only good for scrap." + icon = 'voidcrew/modules/cyberware/icons/cyberware.dmi' + icon_state = "scrapper" + w_class = WEIGHT_CLASS_SMALL + color = "#4a4a4a" + custom_materials = list(/datum/material/iron = SMALL_MATERIAL_AMOUNT) + +/obj/item/burnt_chrome/Initialize(mapload, obj/item/organ/ware) + . = ..() + if(isnull(ware)) + return + name = "burnt-out [format_text(ware.name)]" + icon = ware.icon + icon_state = ware.icon_state + +/** + * Listens to a human NPC's body for the base type. An element, not RegisterSignal(src) on the mob, + * so a subtype can register these signals on itself without replacing the base's handlers. + */ +/datum/element/human_npc_body + element_flags = ELEMENT_DETACH_ON_HOST_DESTROY + +/datum/element/human_npc_body/Attach(datum/target) + . = ..() + if(!ishumannpc(target)) + return ELEMENT_INCOMPATIBLE + RegisterSignal(target, COMSIG_CARBON_REMOVE_LIMB, PROC_REF(on_lost_limb)) + RegisterSignal(target, COMSIG_CARBON_LOSE_ORGAN, PROC_REF(on_lost_organ)) + RegisterSignal(target, COMSIG_LIVING_REVIVE, PROC_REF(on_revived)) + +/datum/element/human_npc_body/Detach(datum/source) + UnregisterSignal(source, list(COMSIG_CARBON_REMOVE_LIMB, COMSIG_CARBON_LOSE_ORGAN, COMSIG_LIVING_REVIVE)) + return ..() + +/datum/element/human_npc_body/proc/on_lost_limb(mob/living/carbon/human/npc/source, obj/item/bodypart/limb, special, dismembered) + SIGNAL_HANDLER + if(!special) + source.npc_lost_part(limb) + +/datum/element/human_npc_body/proc/on_lost_organ(mob/living/carbon/human/npc/source, obj/item/organ/organ, special) + SIGNAL_HANDLER + // Chrome taken out of an NPC, by surgery, a lost limb, gibbing or dusting, burns out like it does at + // death. Next tick, once whatever moved it has put it down. + if(organ.GetComponent(/datum/component/cyberware)) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(human_npc_burn_out_chrome), organ), 0) + return + if(!special) + source.npc_lost_part(organ) + +/datum/element/human_npc_body/proc/on_revived(mob/living/carbon/human/npc/source, full_heal_flags) + SIGNAL_HANDLER + source.npc_revived() + +/** + * Whether its corpse may be cleaned up now: dead for npc_corpse_lifetime, with no player within + * HUMAN_NPC_CORPSE_WATCH_RANGE, and not being dragged, carried or held. + */ +/mob/living/carbon/human/npc/proc/npc_corpse_expired() + if(stat != DEAD || !npc_corpse_lifetime || !npc_died_at) + return FALSE + if(world.time < npc_died_at + npc_corpse_lifetime) + return FALSE + if(pulledby || buckled || ismob(loc)) + return FALSE + return !human_npc_watched(src) + +/// Deletes its corpse, and the limbs and organs it lost that lie unwatched on the floor. +/mob/living/carbon/human/npc/proc/npc_fade() + for(var/datum/weakref/remain_ref as anything in npc_remains) + var/obj/item/remain = remain_ref.resolve() + if(QDELETED(remain) || !isturf(remain.loc) || remain.pulledby) + continue + var/obj/item/bodypart/limb = remain + if(istype(limb) && limb.owner) + continue + var/obj/item/organ/organ = remain + if(istype(organ) && organ.owner) + continue + if(human_npc_watched(remain)) + continue + qdel(remain) + npc_remains = null + qdel(src) + +/// Whether a player is within HUMAN_NPC_CORPSE_WATCH_RANGE of `thing`. +/proc/human_npc_watched(atom/thing) + var/turf/spot = get_turf(thing) + if(isnull(spot) || !length(SSmobs.clients_by_zlevel[spot.z])) + return FALSE + for(var/mob/viewer as anything in SSspatial_grid.orthogonal_range_search(spot, SPATIAL_GRID_CONTENTS_TYPE_CLIENTS, HUMAN_NPC_CORPSE_WATCH_RANGE)) + if(get_dist(viewer, spot) <= HUMAN_NPC_CORPSE_WATCH_RANGE) + return TRUE + return FALSE + +/// Whether tg weather should act on `candidate`, a mob that has never had a mind: a human NPC that +/// isn't dormant. Read by the mind gates in tg's weather code. +/proc/human_npc_weathered(mob/living/candidate) + if(!ishumannpc(candidate)) + return FALSE + var/mob/living/carbon/human/npc/npc = candidate + return !npc.npc_dormant() + +/// Shared instances of the per-family rule datums (voices, surrender rules, outfit tables, site layers), +/// one per type, made on first use. +GLOBAL_LIST_EMPTY(human_npc_singletons) + +/// The shared instance of `datum_type`. +/proc/human_npc_singleton(datum_type) + var/datum/instance = GLOB.human_npc_singletons[datum_type] + if(isnull(instance)) + instance = new datum_type() + GLOB.human_npc_singletons[datum_type] = instance + return instance + +/** + * The zone it was made in, for outfit tables: its spawn context's zone, else the zone of where it + * stands (a ship's overmap tile when aboard one), else green, the weakest. + */ +/mob/living/carbon/human/npc/proc/npc_spawn_zone() + return npc_spawn_context?.zone_type || get_zone_type_for_player_turf(get_turf(src)) || ZONE_GREEN + +/** + * Switches its space suit's thermal regulator on or off, as a player does with the suit's button. On only + * where it was dressed for vacuum or cold, and never for a corpse. Off while dormant (see the top of this + * file). + */ +/mob/living/carbon/human/npc/proc/npc_set_suit_heating(on) + if(on && (stat == DEAD || !(npc_site & (HUMAN_NPC_SITE_VACUUM | HUMAN_NPC_SITE_COLD)))) + return + var/obj/item/clothing/suit/space/suit = wear_suit + if(istype(suit) && suit.thermal_on != !!on) + suit.toggle_spacesuit(src) diff --git a/voidcrew/modules/human_npcs/human_npc_admin.dm b/voidcrew/modules/human_npcs/human_npc_admin.dm new file mode 100644 index 00000000000..88da89ce822 --- /dev/null +++ b/voidcrew/modules/human_npcs/human_npc_admin.dm @@ -0,0 +1,30 @@ +// Admin debug tool: spawn human NPCs around yourself, through the same throttled queue the game uses. + +ADMIN_VERB(spawn_human_npcs, R_SPAWN|R_DEBUG, "Spawn Human NPCs", "Spawn human NPCs of one type around you, built a few per tick.", ADMIN_CATEGORY_DEBUG) + var/turf/center = get_turf(user.mob) + if(isnull(center)) + to_chat(user, span_warning("You need to be standing somewhere."), confidential = TRUE) + return + var/list/choices = list() + for(var/npc_type in subtypesof(/mob/living/carbon/human/npc)) + var/mob/living/carbon/human/npc/npc_path = npc_type + choices["[initial(npc_path.npc_name) || initial(npc_path.name)] ([npc_type])"] = npc_type + var/choice = tgui_input_list(user, "Which human NPC?", "Spawn Human NPCs", sort_list(choices)) + if(isnull(choice) || isnull(choices[choice])) + return + var/count = tgui_input_number(user, "How many?", "Spawn Human NPCs", 1, 50, 1) + if(!count) + return + var/list/spots = list() + for(var/turf/open/spot in RANGE_TURFS(3, center)) + if(!spot.is_blocked_turf(exclude_mobs = TRUE)) + spots += spot + if(!length(spots)) + spots += center + var/npc_type = choices[choice] + var/datum/callback/mark = CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(human_npc_mark_admin_spawned)) + for(var/i in 1 to count) + spawn_human_npc(npc_type, pick(spots), on_spawned = mark) + log_admin("[key_name(user)] spawned [count] [npc_type] at [AREACOORD(center)]") + message_admins("[key_name_admin(user)] spawned [count] [npc_type] at [ADMIN_VERBOSEJMP(center)]") + BLACKBOX_LOG_ADMIN_VERB("Spawn Human NPCs") diff --git a/voidcrew/modules/human_npcs/human_npc_ai.dm b/voidcrew/modules/human_npcs/human_npc_ai.dm new file mode 100644 index 00000000000..4d6675b26b8 --- /dev/null +++ b/voidcrew/modules/human_npcs/human_npc_ai.dm @@ -0,0 +1,540 @@ +/** + * # Human NPC AI + * + * Fights through the body's own hands, the way a player does. Everything goes through + * controller.ai_interact(), which is a player's click (tg's monkey AI and ranged_skirmish use it too): + * - a gun is fired by clicking the target with it, so the gun's real fire path runs: fire delay, + * firing pin, projectile, casing, recoil, wounds and the hyperviolence executions; + * - a melee weapon (or a fist) hits through the real attack chain; + * - a reload is the player's reload: the spare magazine comes out of a pocket, belt or bag into the + * free hand, the gun is clicked with it (tg's insert or tactical reload), the bolt is racked by + * using the gun, and the empty magazine is dropped. Nothing refills from nowhere. When the spares + * run out it draws another weapon it carries, or fights with what it holds. + * + * tg's basic controller already stops the AI at any stat above CONSCIOUS and while stunned, knocked + * out, in stamcrit or in stasis. It also stops while cuffed, which would keep tg's escape_captivity + * subtree from ever working the cuffs; get_able_to_run() below lets a cuffed or grabbed NPC struggle the + * way a player does (resist), and do_after()s pause it so a breakout isn't cut short by walking. It also + * lets the AI run in soft crit, where only the soft-crit subtree plans (human_npc_soft_crit.dm). + * + * The AI goes off with the body's dormancy: tg switches it off while no player is on the z-level, the + * same test human_npc.dm uses for Life(). + * + * Planning order: soft crit (plead, medipen, elites fire wild), escape captivity, walk out (human_npc_states.dm), + * surrender (human_npc_surrender.dm), then find a target, combat sense for the types that have it + * (human_npc_combat_sense.dm), arm, shoot, melee. + * + * Phase B (PR #500's pirate crews) can drop these subtrees into its own planning lists: + * human_npc_arm, human_npc_shoot and human_npc_melee need only BB_BASIC_MOB_CURRENT_TARGET and + * BB_TARGETING_STRATEGY; the shooting keys have defaults. The helper procs at the bottom are for + * any behaviour that has to handle a human NPC's weapons. + */ + +/datum/ai_controller/basic_controller/human_npc + 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, + ) + ai_movement = /datum/ai_movement/basic_avoidance + idle_behavior = /datum/idle_behavior/idle_random_walk/less_walking + 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/simple_find_target, + /datum/ai_planning_subtree/npc_combat_sense, + /datum/ai_planning_subtree/human_npc_arm, + /datum/ai_planning_subtree/human_npc_shoot, + /datum/ai_planning_subtree/human_npc_melee, + ) + +/datum/ai_controller/basic_controller/human_npc/TryPossessPawn(atom/new_pawn) + if(!ishuman(new_pawn)) + return AI_CONTROLLER_INCOMPATIBLE + // Relays who hit us, so we turn on someone shooting from where we weren't looking + new_pawn.AddElement(/datum/element/relay_attackers) + RegisterSignal(new_pawn, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_pawn_attacked)) + return ..() + +/datum/ai_controller/basic_controller/human_npc/UnpossessPawn(destroy) + if(pawn) + UnregisterSignal(pawn, COMSIG_ATOM_WAS_ATTACKED) + return ..() + +// The basic controller's own check, except that cuffs and soft crit don't stop us (see the top of this +// file, and human_npc_soft_crit.dm). +/datum/ai_controller/basic_controller/human_npc/get_able_to_run() + return human_npc_ai_able_to_run(src) + +/datum/ai_controller/basic_controller/human_npc/on_stat_changed(mob/living/source, new_stat) + . = ..() + human_npc_ai_stat_changed(src, new_stat) + +/// Someone hit us: with nothing else to fight, fight them, if we can see them. +/datum/ai_controller/basic_controller/human_npc/proc/on_pawn_attacked(mob/living/source, atom/attacker, attack_flags) + SIGNAL_HANDLER + if(source == attacker || QDELETED(attacker) || blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + return + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(blackboard[BB_TARGETING_STRATEGY]) + if(strategy?.can_attack(source, attacker)) + set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, attacker) + +// ===== TARGETING ===== + +/** + * tg's basic targeting, but a check made without a range (target finding filters its candidates + * that way) uses the NPC's sight range instead of can_see()'s default of 5 tiles. It also never + * picks someone in another packed encounter on the same z-level, who can't be reached across the + * cordon (the containment the old simple-animal hostiles have in ListTargetsLazy()). + */ +/datum/targeting_strategy/basic/human_npc + +/datum/targeting_strategy/basic/human_npc/can_attack(mob/living/living_mob, atom/the_target, vision_range) + if(isnull(vision_range)) + vision_range = living_mob.ai_controller?.blackboard[BB_AGGRO_RANGE] || HUMAN_NPC_SIGHT_RANGE + if(!..(living_mob, the_target, vision_range)) + return FALSE + return !map_region_excludes_turf(map_region_for_turf(get_turf(living_mob)), get_turf(the_target)) + +// ===== ARMING: RELOAD OR DRAW ===== + +/// Keeps a usable weapon in hand: reloads a spent gun from the magazines it carries, or draws another weapon. +/datum/ai_planning_subtree/human_npc_arm + +/datum/ai_planning_subtree/human_npc_arm/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/npc = controller.pawn + if(HAS_TRAIT(npc, TRAIT_HANDS_BLOCKED) || LAZYLEN(npc.do_afters)) + return + if(world.time < controller.blackboard[BB_HUMAN_NPC_ARMING_RETRY_AT]) + return + var/obj/item/gun/gun = human_npc_held_gun(npc) + if(gun?.can_shoot()) + return + if(human_npc_can_reload(npc, gun)) + controller.queue_behavior(/datum/ai_behavior/human_npc_reload) + return SUBTREE_RETURN_FINISH_PLANNING + if(human_npc_held_melee_weapon(npc)) + return + var/obj/item/backup = human_npc_backup_weapon(npc) + if(isnull(backup)) + return + controller.set_blackboard_key(BB_HUMAN_NPC_DRAW_ITEM, backup) + controller.queue_behavior(/datum/ai_behavior/human_npc_draw, BB_HUMAN_NPC_DRAW_ITEM) + return SUBTREE_RETURN_FINISH_PLANNING + +/** + * A player's reload, one step per action: drop the spent magazine, rack a loaded gun, take a spare + * into the free hand, click the gun with it. Fails, and the NPC fights on with something else, if + * it has no spare or no hand free. + */ +/datum/ai_behavior/human_npc_reload + action_cooldown = 0.8 SECONDS + /// Gives up after this long, so a gun that won't take what it carries can't hold the NPC forever + var/give_up_after = 8 SECONDS + +/datum/ai_behavior/human_npc_reload/setup(datum/ai_controller/controller) + . = ..() + var/mob/living/carbon/npc = controller.pawn + var/obj/item/gun/ballistic/gun = human_npc_held_gun(npc) + if(!istype(gun)) + return FALSE + controller.set_blackboard_key(BB_HUMAN_NPC_RELOAD_UNTIL, world.time + give_up_after) + npc.visible_message(span_notice("[npc] reloads [gun].")) + +/datum/ai_behavior/human_npc_reload/perform(seconds_per_tick, datum/ai_controller/controller) + var/mob/living/carbon/npc = controller.pawn + var/obj/item/gun/ballistic/gun = human_npc_held_gun(npc) + if(!istype(gun) || world.time >= controller.blackboard[BB_HUMAN_NPC_RELOAD_UNTIL]) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + var/obj/item/spent = human_npc_spent_ammo_in_hand(npc, gun) + if(spent) + npc.dropItemToGround(spent, force = TRUE) + return AI_BEHAVIOR_DELAY + if(gun.can_shoot()) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + if(human_npc_gun_needs_rack(gun)) + if(!human_npc_ready_item(npc, gun)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + controller.ai_interact(target = gun, combat_mode = FALSE) + return AI_BEHAVIOR_DELAY + var/obj/item/ammo = human_npc_find_ammo(npc, gun) + if(isnull(ammo)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(!npc.is_holding(ammo)) + if(!human_npc_take_in_hand(npc, ammo)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_DELAY + if(!human_npc_ready_item(npc, ammo)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + controller.ai_interact(target = gun, combat_mode = FALSE) + return AI_BEHAVIOR_DELAY + +/datum/ai_behavior/human_npc_reload/finish_action(datum/ai_controller/controller, succeeded) + . = ..() + // A reload that got nowhere isn't tried again straight away; the NPC fights with what it has. + controller.set_blackboard_key(BB_HUMAN_NPC_ARMING_RETRY_AT, succeeded ? 0 : world.time + 10 SECONDS) + +/// Takes another weapon it carries into hand: a loaded gun, or failing that a melee weapon. +/datum/ai_behavior/human_npc_draw + action_cooldown = 0.6 SECONDS + +/datum/ai_behavior/human_npc_draw/perform(seconds_per_tick, datum/ai_controller/controller, item_key) + var/mob/living/carbon/npc = controller.pawn + var/obj/item/weapon = controller.blackboard[item_key] + if(QDELETED(weapon) || human_npc_holding(weapon) != npc) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(!npc.is_holding(weapon)) + if(!length(npc.get_empty_held_indexes())) + // Both hands full: holster the spent gun first, if it has somewhere to go. + var/obj/item/gun/spent = human_npc_held_gun(npc) + if(isnull(spent) || spent.can_shoot() || !spent.equip_to_best_slot(npc)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_DELAY + if(!human_npc_take_in_hand(npc, weapon)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + human_npc_ready_item(npc, weapon) + human_npc_ready_weapon(npc, weapon) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + +/datum/ai_behavior/human_npc_draw/finish_action(datum/ai_controller/controller, succeeded, item_key) + . = ..() + controller.clear_blackboard_key(item_key) + if(!succeeded) + controller.set_blackboard_key(BB_HUMAN_NPC_ARMING_RETRY_AT, world.time + 10 SECONDS) + +// ===== SHOOTING ===== + +/** + * With a loaded gun in hand: shoots the target from up to BB_HUMAN_NPC_FIRE_RANGE, stepping back + * from anyone closer than BB_HUMAN_NPC_KEEP_AWAY, and closes in when it can't see them or they are + * too far. + */ +/datum/ai_planning_subtree/human_npc_shoot + +/datum/ai_planning_subtree/human_npc_shoot/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/atom/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(QDELETED(target)) + return + var/mob/living/carbon/npc = controller.pawn + if(HAS_TRAIT(npc, TRAIT_HANDS_BLOCKED) || isnull(human_npc_loaded_gun(npc))) + return + var/fire_range = controller.blackboard[BB_HUMAN_NPC_FIRE_RANGE] || 7 + var/distance = get_dist(npc, target) + if(distance <= fire_range && can_see(npc, target, fire_range)) + var/keep_away = controller.blackboard[BB_HUMAN_NPC_KEEP_AWAY] + if(keep_away && distance < keep_away && !LAZYLEN(npc.do_afters)) + controller.queue_behavior(/datum/ai_behavior/step_away, BB_BASIC_MOB_CURRENT_TARGET) + controller.queue_behavior(/datum/ai_behavior/human_npc_shoot, BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETING_STRATEGY, BB_BASIC_MOB_CURRENT_TARGET_HIDING_LOCATION) + else + controller.queue_behavior(/datum/ai_behavior/human_npc_close_in, BB_BASIC_MOB_CURRENT_TARGET, fire_range) + return SUBTREE_RETURN_FINISH_PLANNING + +/// One pull of the trigger, then a wait of BB_HUMAN_NPC_SHOT_DELAY. Doesn't hold up planning. +/datum/ai_behavior/human_npc_shoot + action_cooldown = 0.5 SECONDS + behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/human_npc_shoot/perform(seconds_per_tick, datum/ai_controller/controller, target_key, targeting_strategy_key, hiding_location_key) + var/mob/living/carbon/npc = controller.pawn + var/atom/target = controller.blackboard[target_key] + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(controller.blackboard[targeting_strategy_key]) + if(QDELETED(target) || !strategy?.can_attack(npc, target)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + var/obj/item/gun/gun = human_npc_loaded_gun(npc) + if(isnull(gun)) + // Empty now: the next plan reloads or changes weapon. + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + if(world.time < controller.blackboard[BB_HUMAN_NPC_NEXT_SHOT]) + return AI_BEHAVIOR_DELAY + var/atom/hiding_target = strategy.find_hidden_mobs(npc, target) + controller.set_blackboard_key(hiding_location_key, hiding_target) + var/atom/final_target = hiding_target || target + if(human_npc_ally_in_line(npc, final_target)) + human_npc_sidestep(npc, final_target) + return AI_BEHAVIOR_DELAY + if(!human_npc_ready_item(npc, gun)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + npc.zone_selected = human_npc_pick_aim_zone() + controller.ai_interact(target = final_target, combat_mode = TRUE) + controller.set_blackboard_key(BB_HUMAN_NPC_NEXT_SHOT, world.time + (controller.blackboard[BB_HUMAN_NPC_SHOT_DELAY] || 3 SECONDS)) + return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED + +/// Walks at the target until it is within `range` and in sight. +/datum/ai_behavior/human_npc_close_in + behavior_flags = AI_BEHAVIOR_REQUIRE_MOVEMENT | AI_BEHAVIOR_MOVE_AND_PERFORM | AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/human_npc_close_in/setup(datum/ai_controller/controller, target_key, range) + . = ..() + var/atom/target = controller.blackboard[target_key] + if(QDELETED(target)) + return FALSE + set_movement_target(controller, target) + +/datum/ai_behavior/human_npc_close_in/perform(seconds_per_tick, datum/ai_controller/controller, target_key, range) + var/atom/target = controller.blackboard[target_key] + if(QDELETED(target)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(get_dist(controller.pawn, target) <= range && can_see(controller.pawn, target, range)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + return AI_BEHAVIOR_INSTANT + +// ===== MELEE ===== + +/// With no loaded gun: walks up and hits with the best melee weapon held, or a fist. +/datum/ai_planning_subtree/human_npc_melee + +/datum/ai_planning_subtree/human_npc_melee/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + if(!controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + return + controller.queue_behavior(/datum/ai_behavior/basic_melee_attack/human_npc, BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETING_STRATEGY, BB_BASIC_MOB_CURRENT_TARGET_HIDING_LOCATION) + return SUBTREE_RETURN_FINISH_PLANNING + +// tg's basic melee attack already clicks the target through ai_interact(); this picks what to hit with and where. +/datum/ai_behavior/basic_melee_attack/human_npc + +/datum/ai_behavior/basic_melee_attack/human_npc/perform(seconds_per_tick, datum/ai_controller/controller, target_key, targeting_strategy_key, hiding_location_key) + var/mob/living/carbon/npc = controller.pawn + var/obj/item/weapon = human_npc_held_melee_weapon(npc) + if(weapon) + human_npc_ready_item(npc, weapon) + human_npc_ready_weapon(npc, weapon) // a two-hander let go of with one hand is gripped again + else + human_npc_ready_empty_hand(npc) + npc.zone_selected = human_npc_pick_aim_zone() + return ..() + +// ===== HELPERS ===== + +/// Body zones an NPC aims at, weighted. A player picks their own zone; an NPC's hits spread out. +/proc/human_npc_pick_aim_zone() + var/static/list/aim_zones = list( + BODY_ZONE_CHEST = 40, + BODY_ZONE_HEAD = 15, + BODY_ZONE_L_ARM = 10, + BODY_ZONE_R_ARM = 10, + BODY_ZONE_L_LEG = 10, + BODY_ZONE_R_LEG = 10, + BODY_ZONE_PRECISE_GROIN = 5, + ) + return pick_weight(aim_zones) + +/// Makes `item` the active hand. Returns FALSE if `npc` isn't holding it. +/proc/human_npc_ready_item(mob/living/carbon/npc, obj/item/item) + if(isnull(item)) + return FALSE + if(npc.get_active_held_item() == item) + return TRUE + var/index = npc.get_held_index_of_item(item) + if(!index) + return FALSE + npc.swap_hand(index, silent = TRUE) + return npc.get_active_held_item() == item + +/// Makes an empty hand the active one, for a punch. Returns FALSE if both hands are full. +/proc/human_npc_ready_empty_hand(mob/living/carbon/npc) + if(isnull(npc.get_active_held_item())) + return TRUE + var/list/empty = npc.get_empty_held_indexes() + if(!length(empty)) + return FALSE + npc.swap_hand(empty[1], silent = TRUE) + return isnull(npc.get_active_held_item()) + +/// Switches on or wields a weapon in hand the way its user would: energy blades, batons, two-handed weapons. +/proc/human_npc_ready_weapon(mob/living/carbon/npc, obj/item/weapon) + if(QDELETED(weapon) || !npc.is_holding(weapon)) + return + if(weapon.GetComponent(/datum/component/transforming)) + if(!HAS_TRAIT(weapon, TRAIT_TRANSFORM_ACTIVE)) + weapon.attack_self(npc) + return + if(istype(weapon, /obj/item/melee/baton/security)) + var/obj/item/melee/baton/security/baton = weapon + if(!baton.active) + baton.attack_self(npc) + return + if(weapon.GetComponent(/datum/component/two_handed) && !HAS_TRAIT(weapon, TRAIT_WIELDED) && length(npc.get_empty_held_indexes())) + // Wielding takes the weapon's own hand as the active one and the other hand free, as for a player + if(human_npc_ready_item(npc, weapon)) + weapon.attack_self(npc) + +/// The gun it holds, preferring one that can fire. +/proc/human_npc_held_gun(mob/living/carbon/npc) + var/obj/item/gun/found + for(var/obj/item/gun/gun in npc.held_items) + if(gun.can_shoot()) + return gun + found ||= gun + return found + +/// A gun it holds that can fire right now, or null. +/proc/human_npc_loaded_gun(mob/living/carbon/npc) + for(var/obj/item/gun/gun in npc.held_items) + if(gun.can_shoot()) + return gun + return null + +/// Whether `item` is any use as a melee weapon. +/proc/human_npc_is_melee_weapon(obj/item/item) + if(isnull(item) || isgun(item) || isbodypart(item) || isorgan(item) || (item.item_flags & ABSTRACT)) + return FALSE + // Energy blades and batons are weak until switched on. + return human_npc_melee_force(item) >= 10 || item.GetComponent(/datum/component/transforming) || istype(item, /obj/item/melee/baton) + +/// What `item` hits for once readied: a two-handed weapon (a fireaxe) counts wielded, as human_npc_ready_weapon() swings it. +/proc/human_npc_melee_force(obj/item/item) + var/datum/component/two_handed/two_handed = item.GetComponent(/datum/component/two_handed) + if(two_handed && !HAS_TRAIT(item, TRAIT_WIELDED)) + return max(item.force, two_handed.force_wielded, item.force * two_handed.force_multiplier) + return item.force + +/// The best melee weapon it holds, or null. +/proc/human_npc_held_melee_weapon(mob/living/carbon/npc) + var/obj/item/best + for(var/obj/item/held in npc.held_items) + if(human_npc_is_melee_weapon(held) && (isnull(best) || human_npc_melee_force(held) > human_npc_melee_force(best))) + best = held + return best + +/// Something better to fight with that it carries but doesn't hold: a loaded gun first, then the strongest melee weapon. +/proc/human_npc_backup_weapon(mob/living/carbon/npc) + var/obj/item/best_melee + for(var/obj/item/thing as anything in npc.get_all_contents_type(/obj/item)) + if(npc.is_holding(thing) || !human_npc_can_draw(npc, thing)) + continue + if(isgun(thing)) + var/obj/item/gun/spare = thing + if(spare.can_shoot()) + return spare + continue + if(human_npc_is_melee_weapon(thing) && (isnull(best_melee) || human_npc_melee_force(thing) > human_npc_melee_force(best_melee))) + best_melee = thing + return best_melee + +/// Whether `item` is somewhere a person can take it from in a moment: a worn slot, or a bag or pouch it wears. +/proc/human_npc_can_draw(mob/living/carbon/npc, obj/item/item) + if(isbodypart(item) || isorgan(item) || istype(item, /obj/item/implant)) + return FALSE + if(item.loc == npc) + return !isnull(npc.get_slot_by_item(item)) + var/obj/item/container = item.loc + return istype(container) && !isnull(container.atom_storage) && human_npc_holding(container) == npc + +/// Takes `item` out of a slot or a bag into a free hand. Returns TRUE if it ends up held. +/proc/human_npc_take_in_hand(mob/living/carbon/npc, obj/item/item) + if(npc.is_holding(item)) + return TRUE + if(!length(npc.get_empty_held_indexes()) || !human_npc_can_draw(npc, item)) + return FALSE + if(item.loc == npc) + if(!npc.temporarilyRemoveItemFromInventory(item)) + return FALSE + else + var/obj/item/container = item.loc + if(!container.atom_storage.attempt_remove(item, npc, silent = TRUE)) + return FALSE + if(npc.put_in_hands(item)) + return TRUE + npc.equip_to_appropriate_slot(item) + return FALSE + +/// Live rounds in a magazine, box or casing. +/proc/human_npc_live_rounds(obj/item/ammo) + if(isammocasing(ammo)) + var/obj/item/ammo_casing/casing = ammo + return casing.loaded_projectile ? 1 : 0 + if(istype(ammo, /obj/item/ammo_box/magazine)) + var/obj/item/ammo_box/magazine/magazine = ammo + return magazine.ammo_count(FALSE) + var/obj/item/ammo_box/box = ammo + if(!istype(box)) + return 0 + . = 0 + for(var/obj/item/ammo_casing/round as anything in box.stored_ammo) + if(ispath(round) || round.loaded_projectile) + .++ + +/// Whether a ballistic gun has live rounds loaded but none chambered, so using it (rack, pump, drop the bolt) readies it. +/proc/human_npc_gun_needs_rack(obj/item/gun/ballistic/gun) + if(gun.bolt_type == BOLT_TYPE_NO_BOLT || gun.chambered?.loaded_projectile) + return FALSE + return gun.magazine && human_npc_live_rounds(gun.magazine) > 0 + +/// Spare ammunition it carries that `gun` takes: a loaded magazine for a detachable-magazine gun, +/// or a box, clip, speedloader or loose round of its calibre for one with an internal magazine. +/proc/human_npc_find_ammo(mob/living/carbon/npc, obj/item/gun/ballistic/gun) + if(!istype(gun)) + return null + // Whatever is already in hand first, then pockets, belt and bags. + for(var/obj/item/held in npc.held_items) + if(held != gun && human_npc_ammo_fits(gun, held)) + return held + for(var/obj/item/thing as anything in npc.get_all_contents_type(/obj/item)) + if(npc.is_holding(thing) || thing == gun.magazine || thing.loc == gun || !human_npc_can_draw(npc, thing)) + continue + if(human_npc_ammo_fits(gun, thing)) + return thing + return null + +/// Whether `ammo` loads `gun` and has a live round in it. +/proc/human_npc_ammo_fits(obj/item/gun/ballistic/gun, obj/item/ammo) + if(!gun.internal_magazine) + return istype(ammo, gun.accepted_magazine_type) && human_npc_live_rounds(ammo) > 0 + var/caliber = gun.magazine?.caliber + if(isnull(caliber)) + return FALSE + if(istype(ammo, /obj/item/ammo_box)) + var/obj/item/ammo_box/box = ammo + return box.caliber == caliber && human_npc_live_rounds(box) > 0 + if(isammocasing(ammo)) + var/obj/item/ammo_casing/casing = ammo + return casing.caliber == caliber && !isnull(casing.loaded_projectile) + return FALSE + +/// Whether it carries anything that makes `gun` fire again. +/proc/human_npc_can_reload(mob/living/carbon/npc, obj/item/gun/ballistic/gun) + if(!istype(gun)) + return FALSE + return human_npc_gun_needs_rack(gun) || !isnull(human_npc_find_ammo(npc, gun)) + +/// A spent magazine, empty box or spent casing in its hands that's no use to `gun`. +/proc/human_npc_spent_ammo_in_hand(mob/living/carbon/npc, obj/item/gun/ballistic/gun) + for(var/obj/item/held in npc.held_items) + if(held == gun || !(istype(held, /obj/item/ammo_box) || isammocasing(held))) + continue + if(!human_npc_live_rounds(held)) + return held + return null + +/// Whether an ally stands between `shooter` and `target`. Shots pass over anyone lying down. +/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)) + if(line_turf == shooter_turf || line_turf == target_turf) + continue + for(var/mob/living/other in line_turf) + if(other.stat == DEAD || other.body_position == LYING_DOWN) + continue + if(shooter.faction_check_atom(other)) + return TRUE + return FALSE + +/// 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) + var/list/possible_turfs = list() + for(var/direction in GLOB.alldirs) + var/turf/step_turf = get_step(our_turf, direction) + if(isnull(step_turf) || step_turf.is_blocked_turf() || get_dist(step_turf, target) > get_dist(shooter, target)) + continue + possible_turfs += step_turf + if(!length(possible_turfs)) + return + var/turf/picked = pick(possible_turfs) + step(shooter, get_dir(shooter, picked)) diff --git a/voidcrew/modules/human_npcs/human_npc_barks.dm b/voidcrew/modules/human_npcs/human_npc_barks.dm new file mode 100644 index 00000000000..4aa4ea541e8 --- /dev/null +++ b/voidcrew/modules/human_npcs/human_npc_barks.dm @@ -0,0 +1,203 @@ +/** + * # Human NPC barks (N3) + * + * What a human NPC says when something real happens to its body. Every hook hangs on a tg state change, + * never on a stand-in state: entering crit (TRAIT_CRITICAL_CONDITION), leaving crit or getting up from + * stamcrit, handcuffs going on and coming off (TRAIT_RESTRAINED), starting to work at its cuffs (tg's + * cuff_resist(), COMSIG_MOB_REMOVING_CUFFS), breaking out of a grab or off someone's shoulders by + * resisting, giving up (human_npc_surrender.dm) and dying. + * + * A family supplies its lines with a /datum/human_npc_voice subtype on the NPC's npc_voice. A voice has + * spoken `lines` and third-person `emotes` ("collapses.") per kind (HUMAN_NPC_BARK_*, or any kind of the + * family's own: npc_bark("alert") works the same). Speech goes through say() without `forced`, so a gag or + * a mute works on an NPC as on a player, and tg whispers it in soft crit. In hard crit and after death it + * can't speak, so only the emote shows. One NPC barks at most once per voice `cooldown`; surrender and + * death always come through. A family that already has its own voice system (bounty criminals' + * bounty_say()) overrides npc_bark() instead. + * + * Death also plays the hyperviolence death throes (HV-21, hv_death_throes(), a shudder as the body + * falls). The deathgasp itself is tg's: carbons always give it. + */ + +/// Says or shows its line for `kind` (HUMAN_NPC_BARK_*). `force` skips the cooldown and the voice's chance. +/// Returns TRUE if it said or did anything. Override to voice a family another way. +/mob/living/carbon/human/npc/proc/npc_bark(kind, force = FALSE) + if(QDELETED(src) || !ispath(npc_voice, /datum/human_npc_voice)) + return FALSE + var/datum/human_npc_voice/voice = human_npc_singleton(npc_voice) + return voice.bark(src, kind, force) + +/** + * A family's lines. Lists are kind => list of strings. Emotes are third person without the name + * ("collapses.", "groans and tries to get up."). Keep them short and in character (kit rules, "Writing + * for players"): no mechanics, no hints. + */ +/datum/human_npc_voice + /// Spoken lines by kind + var/list/lines = list() + /// Emotes by kind, shown before the line, and alone when it can't speak + var/list/emotes = list() + /// Percent chance it barks at all, by kind. A kind not listed always barks (cooldown allowing). + var/list/chances = list() + /// Seconds between two barks from one NPC + var/cooldown = HUMAN_NPC_BARK_COOLDOWN + +/// The spoken lines for `kind`. Pleading falls back to the downed lines. +/datum/human_npc_voice/proc/lines_for(kind) + . = lines[kind] + if(!length(.) && kind == HUMAN_NPC_BARK_PLEAD) + . = lines[HUMAN_NPC_BARK_DOWNED] + +/// The emotes for `kind`. +/datum/human_npc_voice/proc/emotes_for(kind) + return emotes[kind] + +/datum/human_npc_voice/proc/bark(mob/living/carbon/human/npc/speaker, kind, force = FALSE) + if(!force && !COOLDOWN_FINISHED(speaker, npc_bark_cooldown)) + return FALSE + if(!force && (kind in chances) && !prob(chances[kind])) + return FALSE + var/list/acts = emotes_for(kind) + var/list/spoken = lines_for(kind) + var/can_talk = length(spoken) && human_npc_can_talk(speaker) + if(!length(acts) && !can_talk) + return FALSE + if(length(acts)) + speaker.visible_message(span_emote("[speaker] [pick(acts)]")) + if(can_talk) + INVOKE_ASYNC(speaker, TYPE_PROC_REF(/atom/movable, say), pick(spoken)) + speaker.npc_last_bark = kind + COOLDOWN_START(speaker, npc_bark_cooldown, cooldown) + return TRUE + +/// Whether `speaker` can speak out loud or whisper now. Never in hard crit: tg turns that into last words. +/proc/human_npc_can_talk(mob/living/speaker) + if(speaker.stat != CONSCIOUS && speaker.stat != SOFT_CRIT) + return FALSE + return speaker.can_speak() + +/** + * Relays the tg state changes the barks hang on to the NPC's own procs, so a family can override what + * happens (npc_on_downed() and so on) without touching the signals. An element, so a subtype can listen + * to the same signals on itself. + */ +/datum/element/human_npc_reactions + element_flags = ELEMENT_DETACH_ON_HOST_DESTROY + +/datum/element/human_npc_reactions/Attach(datum/target) + . = ..() + if(!ishumannpc(target)) + return ELEMENT_INCOMPATIBLE + RegisterSignal(target, SIGNAL_ADDTRAIT(TRAIT_CRITICAL_CONDITION), PROC_REF(on_crit_started)) + RegisterSignal(target, SIGNAL_REMOVETRAIT(TRAIT_CRITICAL_CONDITION), PROC_REF(on_crit_ended)) + RegisterSignal(target, COMSIG_LIVING_STATUS_REMOVED, PROC_REF(on_status_removed)) + RegisterSignal(target, SIGNAL_ADDTRAIT(TRAIT_RESTRAINED), PROC_REF(on_restrained)) + RegisterSignal(target, SIGNAL_REMOVETRAIT(TRAIT_RESTRAINED), PROC_REF(on_unrestrained)) + RegisterSignal(target, COMSIG_MOB_REMOVING_CUFFS, PROC_REF(on_working_cuffs)) + RegisterSignal(target, COMSIG_LIVING_RESIST, PROC_REF(on_resist)) + RegisterSignal(target, COMSIG_ATOM_NO_LONGER_PULLED, PROC_REF(on_let_go)) + RegisterSignal(target, COMSIG_LIVING_SET_BUCKLED, PROC_REF(on_buckled)) + RegisterSignal(target, COMSIG_LIVING_DEATH, PROC_REF(on_death)) + +/datum/element/human_npc_reactions/Detach(datum/source) + UnregisterSignal(source, list( + SIGNAL_ADDTRAIT(TRAIT_CRITICAL_CONDITION), + SIGNAL_REMOVETRAIT(TRAIT_CRITICAL_CONDITION), + COMSIG_LIVING_STATUS_REMOVED, + SIGNAL_ADDTRAIT(TRAIT_RESTRAINED), + SIGNAL_REMOVETRAIT(TRAIT_RESTRAINED), + COMSIG_MOB_REMOVING_CUFFS, + COMSIG_LIVING_RESIST, + COMSIG_ATOM_NO_LONGER_PULLED, + COMSIG_LIVING_SET_BUCKLED, + COMSIG_LIVING_DEATH, + )) + return ..() + +/datum/element/human_npc_reactions/proc/on_crit_started(mob/living/carbon/human/npc/source) + SIGNAL_HANDLER + if(source.stat != DEAD) + source.npc_on_downed() + +/datum/element/human_npc_reactions/proc/on_crit_ended(mob/living/carbon/human/npc/source) + SIGNAL_HANDLER + // tg drops the trait on death too; only a living body that came out of crit has recovered. + if(source.stat != DEAD && !QDELING(source)) + source.npc_on_recovered() + +/datum/element/human_npc_reactions/proc/on_status_removed(mob/living/carbon/human/npc/source, datum/status_effect/effect) + SIGNAL_HANDLER + if(source.stat == DEAD || QDELING(source)) + return + if(istype(effect, /datum/status_effect/incapacitating/stamcrit)) + if(source.stat == CONSCIOUS) + source.npc_on_recovered() + return + if(istype(effect, /datum/status_effect/incapacitating/paralyzed) && source.npc_surrendering) + source.npc_surrender_ended() + +/datum/element/human_npc_reactions/proc/on_restrained(mob/living/carbon/human/npc/source) + SIGNAL_HANDLER + if(source.handcuffed && source.stat != DEAD) + source.npc_bark(HUMAN_NPC_BARK_CUFFED) + +/datum/element/human_npc_reactions/proc/on_unrestrained(mob/living/carbon/human/npc/source) + SIGNAL_HANDLER + if(source.stat != DEAD && !QDELING(source)) + source.npc_bark(HUMAN_NPC_BARK_UNCUFFED) + +/datum/element/human_npc_reactions/proc/on_working_cuffs(mob/living/carbon/human/npc/source, obj/item/cuffs) + SIGNAL_HANDLER + source.npc_bark(HUMAN_NPC_BARK_SLIPPING) + +/// Notes who held it as it resisted. tg's resist_grab() lets go in the same call when it works. +/datum/element/human_npc_reactions/proc/on_resist(mob/living/carbon/human/npc/source) + SIGNAL_HANDLER + var/atom/movable/holder = source.pulledby || (ismob(source.buckled) ? source.buckled : null) + if(isnull(holder) || HAS_TRAIT(source, TRAIT_RESTRAINED)) + return + source.npc_resisted_hold = WEAKREF(holder) + source.npc_resisted_at = world.time + +/datum/element/human_npc_reactions/proc/on_let_go(mob/living/carbon/human/npc/source, atom/movable/puller) + SIGNAL_HANDLER + source.npc_check_pulled_free(puller) + +/datum/element/human_npc_reactions/proc/on_buckled(mob/living/carbon/human/npc/source, atom/movable/new_buckled) + SIGNAL_HANDLER + // Squirming off a carrier's shoulders can take a moment; a grab breaks in the same call. + if(isnull(new_buckled)) + source.npc_check_pulled_free(within = 6 SECONDS) + +/datum/element/human_npc_reactions/proc/on_death(mob/living/carbon/human/npc/source, gibbed) + SIGNAL_HANDLER + source.npc_surrendering = FALSE + if(gibbed) + return + source.hv_death_throes() + source.npc_bark(HUMAN_NPC_BARK_DEATH, force = TRUE) + +// ===== What it does when those things happen. Families override these. ===== + +/// It entered crit. +/mob/living/carbon/human/npc/proc/npc_on_downed() + npc_surrendering = FALSE + npc_bark(HUMAN_NPC_BARK_DOWNED, force = TRUE) + npc_next_plead = world.time + HUMAN_NPC_PLEAD_INTERVAL + SEND_SIGNAL(src, COMSIG_HUMAN_NPC_DOWNED) + +/// It left crit, or got up from stamcrit. +/mob/living/carbon/human/npc/proc/npc_on_recovered() + npc_bark(HUMAN_NPC_BARK_RECOVER) + SEND_SIGNAL(src, COMSIG_HUMAN_NPC_RECOVERED) + +/// It stopped being held. If it resisted its way out (this tick, or `within` that long ago), it pulled free. +/mob/living/carbon/human/npc/proc/npc_check_pulled_free(atom/movable/holder, within = 0) + if(!npc_resisted_at || world.time > npc_resisted_at + within) + return + var/atom/movable/resisted = npc_resisted_hold?.resolve() + npc_resisted_hold = null + npc_resisted_at = 0 + if(holder && resisted != holder) + return + npc_bark(HUMAN_NPC_BARK_PULLED_FREE) diff --git a/voidcrew/modules/human_npcs/human_npc_combat_sense.dm b/voidcrew/modules/human_npcs/human_npc_combat_sense.dm new file mode 100644 index 00000000000..c1cc0f02860 --- /dev/null +++ b/voidcrew/modules/human_npcs/human_npc_combat_sense.dm @@ -0,0 +1,633 @@ +/** + * # Combat sense + * + * Armed hostile human NPCs that opt in fight back against stun weapons the way a player does, through + * the body's own systems. Two parts: + * - A stimulant when it tires. Past HUMAN_NPC_SENSE_STIM_SHARE of the stamina loss that would stamcrit + * it, and still in a fight, it takes a stimulant pen it carries into a free hand and uses it (tg's + * use in hand, so the pen's real reagents go in). Only what it carries, and never while a stimulant + * is already in its blood. What a family carries is its outfit's business: see each family's file. + * - Stun fire. Hit by a shot that does stamina damage (a disabler bolt, a rubber round), it stops + * standing in the open. A gunner runs to the nearest tile out of the shooter's line of fire + * (human_npc_find_cover()) and keeps its head down for a moment, longer while it is winded (which is + * when tg's own stamina recovery catches up with it). Then the family's own fight subtrees walk it + * back out to shoot: it peeks. Three runs for cover in one exchange, then it stands and fights. A + * fighter that hits from close (a blade, fists, a shotgun) charges the shooter instead. + * + * Every move goes through the AI's movement (the controller's own movement type, so a family's leash + * pathing applies, at the body's real move delay: basic controllers track cached_multiplicative_slowdown). + * Every reaction shows in the world first ("ducks for cover!"). A family's rules say which tiles it may + * use (tile_ok(): a criminal's leash, a pirate crew's battlefield, a guard's wing). + * + * Nothing here touches the body: no immunity, no stamina, health or stun change, no stand-in state. + * Cuffed, in crit, stunned, in stamcrit, knocked down, grabbed, giving up or walking out, it does nothing + * (can_act(); tg's controller also stops the AI in stamcrit and stuns). + * + * Opting in: a human NPC type sets npc_combat_sense to a /datum/npc_combat_sense typepath (its family's + * rules), and its controller lists /datum/ai_planning_subtree/npc_combat_sense where it should plan: after + * soft crit, breaking free, walking out, surrender and finding a target, and before arming and attacking. + * Civilians, townsfolk and prisoners never set it. Anything else may AddComponent(/datum/component/ + * npc_combat_sense, rules_type) on a human NPC whose controller lists the subtree, and subclass + * /datum/npc_combat_sense to change the numbers or any step (a bounty boss, say). + */ + +// ===== THE RULES ===== + +/** + * How a family uses its combat sense. One shared instance per type (human_npc_singleton()). The vars are + * the numbers; each proc is a step a family may override. + */ +/datum/npc_combat_sense + /// Whether it uses stimulant pens it carries when it tires + var/use_stims = TRUE + /// Stamina loss, as a share of what stamcrits it, at which it reaches for a stimulant + var/stim_share = HUMAN_NPC_SENSE_STIM_SHARE + /// Whether stun fire makes it move at all + var/react_to_stun_fire = TRUE + /// How long after its last stun hit it keeps reacting + var/react_time = HUMAN_NPC_SENSE_REACT_TIME + /// The furthest it walks to cover, in steps + var/cover_steps = HUMAN_NPC_SENSE_COVER_STEPS + /// How long it keeps its head down before it looks out + var/peek_after = HUMAN_NPC_SENSE_PEEK_AFTER + /// The longest it stays down while winded + var/max_hold = HUMAN_NPC_SENSE_MAX_HOLD + /// Runs for cover per exchange of fire before it stands and fights + var/cover_moves = HUMAN_NPC_SENSE_COVER_MOVES + /// A fighter that hits from this close charges the shooter instead of taking cover. 0: it never charges. + var/close_in_reach = HUMAN_NPC_SENSE_CLOSE_IN_REACH + +/** + * Whether it can do anything about a fight right now: on its feet and free. Never cuffed, grabbed, + * buckled, stunned, knocked down, in crit, busy with a do_after, giving up or walking out. + */ +/datum/npc_combat_sense/proc/can_act(mob/living/carbon/human/npc, datum/ai_controller/controller) + if(npc.stat != CONSCIOUS || !isturf(npc.loc) || npc.buckled || npc.pulledby) + return FALSE + if(HAS_TRAIT(npc, TRAIT_RESTRAINED) || HAS_TRAIT(npc, TRAIT_HANDS_BLOCKED) || HAS_TRAIT(npc, TRAIT_INCAPACITATED)) + return FALSE + if(HAS_TRAIT(npc, TRAIT_IMMOBILIZED) || HAS_TRAIT(npc, TRAIT_FLOORED) || npc.body_position == LYING_DOWN) + return FALSE + if(LAZYLEN(npc.do_afters)) + return FALSE + var/mob/living/carbon/human/npc/human_npc = npc + if(istype(human_npc) && (human_npc.npc_surrendering || human_npc.npc_exit)) + return FALSE + return TRUE + +/// Whether it is in a fight: it has a target, or someone is shooting stun rounds at it. +/datum/npc_combat_sense/proc/in_fight(mob/living/carbon/human/npc, datum/ai_controller/controller, datum/component/npc_combat_sense/sense) + return controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET) || sense.under_fire() + +/// Whether it is winded: stamina loss past stim_share of what would stamcrit it. +/datum/npc_combat_sense/proc/winded(mob/living/carbon/human/npc) + return npc.getStaminaLoss() >= stim_share * (npc.maxHealth - npc.crit_threshold) + +/// A stimulant pen it carries and could take out now, or null. +/datum/npc_combat_sense/proc/find_stim(mob/living/carbon/human/npc) + return human_npc_find_stim(npc) + +/// Whether the one who fired `shooter`'s stun shot is on its side, so the shot is friendly fire. +/datum/npc_combat_sense/proc/allied(mob/living/carbon/human/npc, atom/shooter) + return isliving(shooter) && npc.faction_check_atom(shooter) + +/// Whether a stun shot from `shooter` is one to react to: a person or a mech, not itself, not a friend. +/datum/npc_combat_sense/proc/threat_ok(mob/living/carbon/human/npc, atom/shooter) + if(QDELETED(shooter) || shooter == npc || !(isliving(shooter) || ismecha(shooter))) + return FALSE + return !allied(npc, shooter) + +/** + * How close it fights from, in tiles: its gun's range if it holds or carries one that fires (the shooting + * subtrees' BB_HUMAN_NPC_FIRE_RANGE), else 1. At or under close_in_reach it charges; over it, it takes cover. + */ +/datum/npc_combat_sense/proc/reach(mob/living/carbon/human/npc, datum/ai_controller/controller) + if(HAS_TRAIT(npc, TRAIT_NOGUNS)) + return 1 + if(human_npc_held_gun(npc) || isgun(human_npc_backup_weapon(npc))) + return controller.blackboard[BB_HUMAN_NPC_FIRE_RANGE] || 7 + return 1 + +/// Whether it may leave where it stands for this fight at all (a pirate holding the helm's line doesn't). +/datum/npc_combat_sense/proc/may_move(mob/living/carbon/human/npc, datum/ai_controller/controller) + return TRUE + +/** + * Whether it may stand on `tile` (and walk through it on the way to cover): open floor that is safe to + * cross, in the NPC's own map region. Families add their leash. + */ +/datum/npc_combat_sense/proc/tile_ok(mob/living/carbon/human/npc, datum/ai_controller/controller, turf/tile) + if(!isopenturf(tile) || isspaceturf(tile) || isopenspaceturf(tile) || isgroundlessturf(tile) || islava(tile) || ischasm(tile)) + return FALSE + if(!tile.can_cross_safely(npc)) + return FALSE + return !map_region_excludes_turf(map_region_for_turf(get_turf(npc)), tile) + +/// The nearest tile it may reach that is out of a shot's line from `threat_turf`, or null. +/datum/npc_combat_sense/proc/find_cover(mob/living/carbon/human/npc, datum/ai_controller/controller, turf/threat_turf, pass_flags) + return human_npc_find_cover(npc, threat_turf, cover_steps, pass_flags, CALLBACK(src, PROC_REF(tile_ok), npc, controller)) + +/// How long it keeps down in cover it reached at `arrived_at`: peek_after, or up to max_hold while winded. +/datum/npc_combat_sense/proc/hold_until(mob/living/carbon/human/npc, datum/component/npc_combat_sense/sense) + return sense.arrived_at + (winded(npc) ? max_hold : peek_after) + +/** + * What the people around see it do, before it does it (and a line from its voice, if its family has one + * for `kind`). In the world and in character: no rules, no numbers. + */ +/datum/npc_combat_sense/proc/telegraph(mob/living/carbon/human/npc, kind, atom/about, obj/item/used) + switch(kind) + if(HUMAN_NPC_BARK_TAKE_COVER) + npc.visible_message(span_warning("[npc] ducks for cover!")) + if(HUMAN_NPC_BARK_CHARGE) + npc.visible_message(span_warning("[npc] charges at [about]!")) + if(HUMAN_NPC_BARK_STIMULANT) + npc.visible_message(span_warning("[npc] jabs [used] into [npc.p_their()] thigh.")) + return + var/mob/living/carbon/human/npc/human_npc = npc + if(istype(human_npc)) + human_npc.npc_bark(kind) + +// ===== PLANNING ===== + +/** + * One plan. Under stun fire a gunner gets out of the line of fire first and uses its stimulant from + * cover; out of cover's reach (none near, out of runs, looking out) it uses the stimulant where it is. + * A close fighter takes its stimulant first, then charges. Returns SUBTREE_RETURN_FINISH_PLANNING while it + * is doing something about it, so the attacks below wait. + */ +/datum/npc_combat_sense/proc/plan(mob/living/carbon/human/npc, datum/ai_controller/controller, datum/component/npc_combat_sense/sense) + if(!can_act(npc, controller)) + sense.stand_down(controller) + return + var/under_fire = sense.under_fire() + if(!under_fire && sense.hits) + sense.end_exchange(controller) + var/reacting = under_fire && react_to_stun_fire && may_move(npc, controller) + var/close_fighter = reacting && close_in_reach && reach(npc, controller) <= close_in_reach + if(reacting && !close_fighter) + . = plan_cover(npc, controller, sense) + if(.) + return + if(plan_stim(npc, controller, sense)) + return SUBTREE_RETURN_FINISH_PLANNING + if(close_fighter) + return plan_close_in(npc, controller, sense) + +/// Queues the stimulant it wants now, if any. Returns TRUE if it did. +/datum/npc_combat_sense/proc/plan_stim(mob/living/carbon/human/npc, datum/ai_controller/controller, datum/component/npc_combat_sense/sense) + var/obj/item/reagent_containers/hypospray/medipen/stim = wants_stim(npc, controller, sense) + if(isnull(stim)) + return FALSE + controller.set_blackboard_key(BB_HUMAN_NPC_STIM_ITEM, stim) + controller.queue_behavior(/datum/ai_behavior/npc_combat_sense_stim, BB_HUMAN_NPC_STIM_ITEM) + return TRUE + +/// The stimulant pen it should use now, or null: the one in hand from the last plan, or one it carries while winded in a fight. +/datum/npc_combat_sense/proc/wants_stim(mob/living/carbon/human/npc, datum/ai_controller/controller, datum/component/npc_combat_sense/sense) + if(!use_stims || world.time < sense.next_stim_at) + return null + var/obj/item/reagent_containers/hypospray/medipen/using = controller.blackboard[BB_HUMAN_NPC_STIM_ITEM] + if(istype(using) && !QDELETED(using) && human_npc_is_stim(using) && human_npc_holding(using) == npc) + return using + if(!winded(npc) || !in_fight(npc, controller, sense) || human_npc_stimmed(npc)) + return null + . = find_stim(npc) + // Nothing on it: don't turn its pockets out again every plan + if(isnull(.)) + sense.next_stim_at = world.time + HUMAN_NPC_SENSE_STIM_RETRY + +/** + * A gunner under stun fire: on the way to cover, it keeps going; in cover, it keeps down (using its + * stimulant or reloading there if it needs to) until it is time to look out or the shooter can see it + * there anyway; in the open, each new stun hit is weighed once, and it runs for the nearest cover if it + * has runs left. Returns null when it has nothing to do about it here. + */ +/datum/npc_combat_sense/proc/plan_cover(mob/living/carbon/human/npc, datum/ai_controller/controller, datum/component/npc_combat_sense/sense) + var/turf/here = get_turf(npc) + var/turf/threat_turf = sense.threat_turf(npc) + if(isnull(here) || isnull(threat_turf)) + return + if(sense.cover) + var/blown = human_npc_line_of_fire(threat_turf, sense.cover, sense.shot_pass_flags) + if(here == sense.cover) + sense.arrived_at ||= world.time + // Whoever it is fighting at arm's length gets fought, cover or not + var/atom/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(target && get_dist(npc, target) <= 1) + blown = TRUE + if(!blown && world.time < hold_until(npc, sense)) + // Hits taken getting here or in here were answered by being here + sense.decided_at = world.time + // Its stimulant or a fresh magazine while it is out of sight, else it keeps its head down + if(!plan_stim(npc, controller, sense) && !human_npc_cover_reload(npc, controller)) + controller.queue_behavior(/datum/ai_behavior/npc_combat_sense_hold) + return SUBTREE_RETURN_FINISH_PLANNING + // Time to look out, or it is seen here anyway: the fight subtrees take it from here + sense.stand_down(controller) + return + if(!blown && world.time < sense.cover_deadline && tile_ok(npc, controller, sense.cover)) + sense.decided_at = world.time + controller.queue_behavior(/datum/ai_behavior/npc_combat_sense_take_cover, BB_HUMAN_NPC_COVER) + return SUBTREE_RETURN_FINISH_PLANNING + sense.stand_down(controller) + return + if(sense.last_hit_at <= sense.decided_at) + return + sense.decided_at = world.time + if(sense.cover_moves >= cover_moves || !human_npc_line_of_fire(threat_turf, here, sense.shot_pass_flags)) + return + var/turf/spot = find_cover(npc, controller, threat_turf, sense.shot_pass_flags) + if(isnull(spot)) + return + sense.take_cover(controller, spot) + telegraph(npc, HUMAN_NPC_BARK_TAKE_COVER, sense.threat()) + controller.queue_behavior(/datum/ai_behavior/npc_combat_sense_take_cover, BB_HUMAN_NPC_COVER) + return SUBTREE_RETURN_FINISH_PLANNING + +/** + * A close fighter under stun fire: it runs at the shooter, if the shooter is who it is already fighting, + * until it is close enough to hit. Then the family's attacks take over. + */ +/datum/npc_combat_sense/proc/plan_close_in(mob/living/carbon/human/npc, datum/ai_controller/controller, datum/component/npc_combat_sense/sense) + var/atom/shooter = sense.threat() + if(isnull(shooter) || shooter != controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET]) + return + var/reach = max(reach(npc, controller), 1) + if(get_dist(npc, shooter) <= reach && can_see(npc, shooter, reach)) + return + if(world.time - sense.charged_at > react_time) + telegraph(npc, HUMAN_NPC_BARK_CHARGE, shooter) + sense.charged_at = world.time + sense.decided_at = world.time + controller.set_blackboard_key(BB_HUMAN_NPC_STUN_SHOOTER, shooter) + controller.queue_behavior(/datum/ai_behavior/human_npc_close_in, BB_HUMAN_NPC_STUN_SHOOTER, reach) + return SUBTREE_RETURN_FINISH_PLANNING + +/// Plans the combat sense of a pawn that has one. Controllers that support it list this where it should run. +/datum/ai_planning_subtree/npc_combat_sense + +/datum/ai_planning_subtree/npc_combat_sense/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/human/npc = controller.pawn + if(!istype(npc)) + return + var/datum/component/npc_combat_sense/sense = npc.GetComponent(/datum/component/npc_combat_sense) + if(isnull(sense)) + return + return sense.rules.plan(npc, controller, sense) + +// ===== THE COMPONENT: what it noticed ===== + +/** + * On a human NPC with combat sense: notes stun hits (who, from where, what the shot could pass) and keeps + * the state of the current exchange. The decisions are its rules' (plan()). + */ +/datum/component/npc_combat_sense + dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS + /// The family's rules, a shared instance + var/datum/npc_combat_sense/rules + /// Whoever last shot it with stun fire + var/datum/weakref/shooter_ref + /// Where that shot was fired from + var/turf/shot_from + /// What that shot could fly through (glass, tables, grilles), to judge cover against the next one + var/shot_pass_flags = PASSTABLE + /// world.time of its last stun hit + var/last_hit_at = 0 + /// Stun hits taken in this exchange + var/hits = 0 + /// world.time it last answered a stun hit (ran for cover, charged, or chose to stand) + var/decided_at = 0 + /// The cover it is going to or keeping down in + var/turf/cover + /// world.time it gives up on reaching that cover + var/cover_deadline = 0 + /// world.time it got there, or 0 + var/arrived_at = 0 + /// Runs for cover in this exchange + var/cover_moves = 0 + /// world.time it last charged a shooter + var/charged_at = 0 + /// Stimulants it has used + var/stims_used = 0 + /// world.time it may next reach for a stimulant, after a try that got nowhere + var/next_stim_at = 0 + +/datum/component/npc_combat_sense/Initialize(rules_type = /datum/npc_combat_sense) + if(!ishumannpc(parent) || !ispath(rules_type, /datum/npc_combat_sense)) + return COMPONENT_INCOMPATIBLE + rules = human_npc_singleton(rules_type) + +/datum/component/npc_combat_sense/InheritComponent(datum/component/new_comp, i_am_original, rules_type = /datum/npc_combat_sense) + if(ispath(rules_type, /datum/npc_combat_sense)) + rules = human_npc_singleton(rules_type) + +/datum/component/npc_combat_sense/RegisterWithParent() + RegisterSignal(parent, COMSIG_ATOM_BULLET_ACT, PROC_REF(on_shot)) + RegisterSignal(parent, COMSIG_LIVING_DEATH, PROC_REF(on_death)) + +/datum/component/npc_combat_sense/UnregisterFromParent() + UnregisterSignal(parent, list(COMSIG_ATOM_BULLET_ACT, COMSIG_LIVING_DEATH)) + +/datum/component/npc_combat_sense/Destroy(force) + rules = null + shooter_ref = null + shot_from = null + cover = null + return ..() + +/// A shot landed. Stun fire is noted; the next plan decides what to do about it. +/datum/component/npc_combat_sense/proc/on_shot(mob/living/carbon/human/source, obj/projectile/shot, def_zone, piercing_hit, blocked) + SIGNAL_HANDLER + if(source.stat == DEAD || !human_npc_stun_projectile(shot)) + return + var/atom/shooter = shot.firer + if(!rules.threat_ok(source, shooter)) + return + if(!under_fire()) + hits = 0 + cover_moves = 0 + shooter_ref = WEAKREF(shooter) + shot_from = get_turf(shot.starting) || get_turf(shooter) + shot_pass_flags = shot.pass_flags + last_hit_at = world.time + hits++ + +/datum/component/npc_combat_sense/proc/on_death(mob/living/source, gibbed) + SIGNAL_HANDLER + end_exchange(source.ai_controller) + +/// Whether stun fire hit it recently enough to still react. +/datum/component/npc_combat_sense/proc/under_fire() + return last_hit_at && world.time - last_hit_at <= rules.react_time + +/// The one shooting stun rounds at it, if they are still about on its level. +/datum/component/npc_combat_sense/proc/threat() + var/atom/shooter = shooter_ref?.resolve() + if(QDELETED(shooter)) + return null + var/turf/shooter_turf = get_turf(shooter) + var/turf/our_turf = get_turf(parent) + if(isnull(shooter_turf) || shooter_turf.z != our_turf?.z) + return null + return shooter + +/// Where the stun fire comes from: the shooter's tile while it can tell, else where the last shot was fired from. +/datum/component/npc_combat_sense/proc/threat_turf(mob/living/npc) + var/atom/shooter = threat() + if(shooter && can_see(npc, shooter, HUMAN_NPC_SIGHT_RANGE)) + return get_turf(shooter) + return shot_from + +/// Sets off for `spot`. +/datum/component/npc_combat_sense/proc/take_cover(datum/ai_controller/controller, turf/spot) + cover = spot + arrived_at = 0 + cover_moves++ + cover_deadline = world.time + 1 SECONDS + get_dist(parent, spot) * HUMAN_NPC_SENSE_COVER_STEP_TIME + controller.set_blackboard_key(BB_HUMAN_NPC_COVER, spot) + +/// Leaves its cover plan (it is going back to the fight, or can't do anything). +/datum/component/npc_combat_sense/proc/stand_down(datum/ai_controller/controller) + cover = null + arrived_at = 0 + cover_deadline = 0 + controller?.clear_blackboard_key(BB_HUMAN_NPC_COVER) + +/// The exchange of fire is over: next time starts afresh. +/datum/component/npc_combat_sense/proc/end_exchange(datum/ai_controller/controller) + stand_down(controller) + hits = 0 + cover_moves = 0 + last_hit_at = 0 + decided_at = 0 + shooter_ref = null + shot_from = null + +// ===== BEHAVIOURS ===== + +/// Walks to the cover turf in `cover_key`. The plan holds it there once it arrives. +/datum/ai_behavior/npc_combat_sense_take_cover + required_distance = 0 + action_cooldown = 0.2 SECONDS + behavior_flags = AI_BEHAVIOR_REQUIRE_MOVEMENT | AI_BEHAVIOR_MOVE_AND_PERFORM | AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/npc_combat_sense_take_cover/setup(datum/ai_controller/controller, cover_key) + . = ..() + var/turf/spot = controller.blackboard[cover_key] + if(!isturf(spot)) + return FALSE + set_movement_target(controller, spot) + +/datum/ai_behavior/npc_combat_sense_take_cover/perform(seconds_per_tick, datum/ai_controller/controller, cover_key) + var/turf/spot = controller.blackboard[cover_key] + if(!isturf(spot)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(get_turf(controller.pawn) == spot) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + return AI_BEHAVIOR_DELAY + +/// Keeps its head down where it is. Ends when the plan stops asking for it. +/datum/ai_behavior/npc_combat_sense_hold + action_cooldown = 0.5 SECONDS + behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/npc_combat_sense_hold/perform(seconds_per_tick, datum/ai_controller/controller) + return AI_BEHAVIOR_DELAY + +/** + * Uses the stimulant pen in `item_key` on itself the way a player does: takes it in a free hand (letting + * go of a two-handed grip, or putting away a spent gun, if both are full), then use in hand. The spent pen + * is dropped and its weapons taken up again. + */ +/datum/ai_behavior/npc_combat_sense_stim + action_cooldown = 0.5 SECONDS + behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/npc_combat_sense_stim/perform(seconds_per_tick, datum/ai_controller/controller, item_key) + var/mob/living/carbon/human/npc = controller.pawn + var/obj/item/reagent_containers/hypospray/medipen/pen = controller.blackboard[item_key] + if(!istype(pen) || QDELETED(pen) || human_npc_holding(pen) != npc || npc.stat != CONSCIOUS || HAS_TRAIT(npc, TRAIT_HANDS_BLOCKED)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(!human_npc_is_stim(pen)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(!npc.is_holding(pen)) + if(!human_npc_free_a_hand(npc) || !human_npc_take_in_hand(npc, pen)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_DELAY + if(!human_npc_ready_item(npc, pen) || npc.next_move > world.time) + return AI_BEHAVIOR_DELAY + var/datum/component/npc_combat_sense/sense = npc.GetComponent(/datum/component/npc_combat_sense) + sense?.rules.telegraph(npc, HUMAN_NPC_BARK_STIMULANT, null, pen) + npc.execute_mode() + if(!pen.used_up) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(sense) + sense.stims_used++ + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + +/datum/ai_behavior/npc_combat_sense_stim/finish_action(datum/ai_controller/controller, succeeded, item_key) + var/mob/living/carbon/human/npc = controller.pawn + var/obj/item/reagent_containers/hypospray/medipen/pen = controller.blackboard[item_key] + . = ..() + controller.clear_blackboard_key(item_key) + if(!istype(npc)) + return + if(istype(pen) && !QDELETED(pen) && npc.is_holding(pen)) + if(pen.used_up) + npc.dropItemToGround(pen) + else + // Cut short (the plan moved on): back where it came from + pen.equip_to_best_slot(npc) + for(var/obj/item/held in npc.held_items) + human_npc_ready_weapon(npc, held) + if(!succeeded) + var/datum/component/npc_combat_sense/sense = npc.GetComponent(/datum/component/npc_combat_sense) + if(sense) + sense.next_stim_at = world.time + HUMAN_NPC_SENSE_STIM_RETRY + +// ===== HELPERS (API) ===== + +/// Reagents that count as a stimulant: what a person takes to keep going through a fight. +GLOBAL_LIST_INIT(human_npc_stim_reagents, typecacheof(list( + /datum/reagent/medicine/stimulants, + /datum/reagent/medicine/ephedrine, + /datum/reagent/drug/methamphetamine, +))) + +/// Whether `shot` does stamina damage: a disabler bolt, a rubber round. +/proc/human_npc_stun_projectile(obj/projectile/shot) + if(!istype(shot)) + return FALSE + return (shot.damage_type == STAMINA && shot.damage > 0) || shot.stamina > 0 + +/// Whether `pen` is an unspent medipen with a stimulant in it. +/proc/human_npc_is_stim(obj/item/reagent_containers/hypospray/medipen/pen) + if(!istype(pen) || pen.used_up || !pen.reagents?.total_volume) + return FALSE + for(var/datum/reagent/reagent as anything in pen.reagents.reagent_list) + if(is_type_in_typecache(reagent, GLOB.human_npc_stim_reagents)) + return TRUE + return FALSE + +/// Whether a stimulant is already in `body`'s blood. +/proc/human_npc_stimmed(mob/living/carbon/body) + for(var/datum/reagent/reagent as anything in body.reagents?.reagent_list) + if(is_type_in_typecache(reagent, GLOB.human_npc_stim_reagents)) + return TRUE + return FALSE + +/// A stimulant pen `npc` holds, or carries somewhere it can take it from in a moment, or null. +/proc/human_npc_find_stim(mob/living/carbon/npc) + for(var/obj/item/reagent_containers/hypospray/medipen/pen in npc.get_all_contents_type(/obj/item/reagent_containers/hypospray/medipen)) + if(human_npc_is_stim(pen) && (npc.is_holding(pen) || human_npc_can_draw(npc, pen))) + return pen + return null + +/// Frees a hand: lets go of a two-handed grip, else puts away a gun that can't fire. Returns TRUE if a hand is free. +/proc/human_npc_free_a_hand(mob/living/carbon/npc) + if(length(npc.get_empty_held_indexes())) + return TRUE + for(var/obj/item/held in npc.held_items) + if(HAS_TRAIT(held, TRAIT_WIELDED)) + held.attack_self(npc) + break + if(length(npc.get_empty_held_indexes())) + return TRUE + var/obj/item/gun/spent = human_npc_held_gun(npc) + if(spent && !spent.can_shoot()) + spent.equip_to_best_slot(npc) + return length(npc.get_empty_held_indexes()) > 0 + +/** + * Whether a shot from `from_turf` could fly straight to `to_turf`: nothing on the way between the two tile + * centres that blocks it. Walls, closed doors, machines and anything opaque block; glass, tables and grilles + * only stop a shot that can't pass them (`pass_flags`, the projectile's). Directional things (windoors, + * railings) are ignored. A rough line, like a person judging cover by eye. + */ +/proc/human_npc_line_of_fire(turf/from_turf, turf/to_turf, pass_flags = PASSTABLE) + if(isnull(from_turf) || isnull(to_turf) || from_turf.z != to_turf.z) + return FALSE + var/dx = to_turf.x - from_turf.x + var/dy = to_turf.y - from_turf.y + // Four looks per tile along the segment, each at the tile under that point + var/samples = max(abs(dx), abs(dy)) * 4 + var/turf/last = from_turf + for(var/sample in 1 to samples - 1) + var/turf/step = locate(round(from_turf.x + dx * sample / samples + 0.5), round(from_turf.y + dy * sample / samples + 0.5), from_turf.z) + if(step == last || step == to_turf) + continue + last = step + if(isnull(step) || step.density || step.opacity) + return FALSE + for(var/obj/thing in step) + if(thing.opacity) + return FALSE + if(!thing.density || (thing.flags_1 & ON_BORDER_1) || (thing.pass_flags_self & pass_flags)) + continue + return FALSE + return TRUE + +/// Whether someone else is standing on `tile`, so `npc` can't take cover there. +/proc/human_npc_cover_taken(turf/tile, mob/living/npc) + for(var/mob/living/other in tile) + if(other != npc && other.density) + return TRUE + return FALSE + +/** + * The nearest tile `npc` can walk to within `max_steps` that is out of a shot's line from `threat_turf`, + * or null. One flood from where it stands, with the pathfinder's own step check (walls, windows, doors it + * has no access for), never onto or through a tile `tile_ok` (a callback taking the turf) refuses. Of the + * nearest, the one closest to the threat, so it can look out again. Cheap enough to run once per stun + * hit: it never sleeps. + */ +/proc/human_npc_find_cover(mob/living/npc, turf/threat_turf, max_steps = HUMAN_NPC_SENSE_COVER_STEPS, pass_flags = PASSTABLE, datum/callback/tile_ok) + var/turf/start = get_turf(npc) + if(isnull(start) || isnull(threat_turf) || start.z != threat_turf.z) + return null + var/datum/can_pass_info/pass_info = new(npc, npc.ai_controller?.get_access()) + var/list/steps_to = list() + steps_to[start] = 0 + var/list/queue = list(start) + var/index = 1 + var/turf/best + var/best_steps = INFINITY + var/best_distance = INFINITY + while(index <= length(queue)) + var/turf/current = queue[index++] + var/steps = steps_to[current] + // Breadth first: everything from here on is further than the cover already found + if(steps >= best_steps || steps >= max_steps) + break + for(var/direction in GLOB.alldirs) + var/turf/next = get_step(current, direction) + if(isnull(next) || !isnull(steps_to[next]) || next.density) + continue + if(current.LinkBlockedWithAccess(next, pass_info)) + continue + steps_to[next] = steps + 1 + if(tile_ok && !tile_ok.Invoke(next)) + continue + queue += next + if(human_npc_cover_taken(next, npc) || human_npc_line_of_fire(threat_turf, next, pass_flags)) + continue + var/distance = get_dist(next, threat_turf) + if(steps + 1 < best_steps || distance < best_distance) + best = next + best_steps = steps + 1 + best_distance = distance + return best + +/** + * In cover with a gun that ran dry and a magazine to put in it: queues the human NPC base's reload (the + * player's reload) and returns TRUE. Guns loaded a round at a time wait for the family's own arming. + */ +/proc/human_npc_cover_reload(mob/living/carbon/npc, datum/ai_controller/controller) + if(world.time < controller.blackboard[BB_HUMAN_NPC_ARMING_RETRY_AT]) + return FALSE + var/obj/item/gun/ballistic/gun = human_npc_held_gun(npc) + if(!istype(gun) || gun.internal_magazine || gun.can_shoot() || !human_npc_can_reload(npc, gun)) + return FALSE + controller.queue_behavior(/datum/ai_behavior/human_npc_reload) + return TRUE diff --git a/voidcrew/modules/human_npcs/human_npc_gear.dm b/voidcrew/modules/human_npcs/human_npc_gear.dm new file mode 100644 index 00000000000..557828ce6ab --- /dev/null +++ b/voidcrew/modules/human_npcs/human_npc_gear.dm @@ -0,0 +1,247 @@ +// Human NPC gear lock (owner decision D3): everything a human NPC wears or holds stays on its body +// and never becomes loot. Its designed death drops (human_npc.dm, npc_drop_death_loot()) are the +// only things a player gets from killing one. +// +// How it holds, using tg's own inventory paths rather than special cases per route: +// * A drop that would put the item anywhere but on a human NPC is refused (COMSIG_ITEM_PRE_UNEQUIP): +// disarm shoves, a held item dropped on a knockdown, gib item drops, a stray transferItemToLoc(). +// The NPC's own moves inside its inventory (magazine into its gun, gun into its holster, a tank +// into its suit storage) still work, because they end on the NPC. +// * Locked items carry TRAIT_NO_STRIP: tg's strip menu shows their slots as empty and won't take them. +// The menu still opens, so what isn't gear (a captain's ship key in his pocket) can be taken off a +// cuffed or downed NPC as off a person. +// * Anything that forces the item out of the body anyway (an arm cut off still holding the gun, a +// head knocked off with the helmet on, species changes, admin undress) lands outside the NPC, and +// the item is deleted on the next tick (COMSIG_MOVABLE_MOVED). The wait lets tg code that moves an +// item twice in one call finish: a tactical reload drops the old magazine on the floor and then +// puts it back in the NPC's hand. +// * Locked items can't be sold (COMSIG_ITEM_PRE_EXPORT) and carry no materials, so an NPC corpse put +// through the cargo shuttle or an emagged recycler yields nothing for its kit. +// * When the body is deleted (corpse cleanup, gibbing, a site unloading) the gear goes with it, +// since /atom/movable/Destroy() deletes contents. +// * A player who ends up in control of an NPC body (a brain transplant) loses its gear at once +// (human_npc.dm, Login()). +// +// Organs and body parts are the body, not gear: they come off and can be harvested the way a +// player's do (cyberware is the exception: it burns out to scrap, human_npc.dm). Ammunition casings +// are not locked either, so spent brass stays on the floor. +// +// The exceptions, explicit and tested: +// * GLOB.human_npc_not_gear: items whose loss would break something outside the NPC (a ship key, a +// contract's recovery item, bounty proof, a paper someone has to read). Never locked; they drop at +// the NPC's feet when it dies. +// * GLOB.human_npc_consumable_gear: things an NPC uses up (grenades, barrier grenades, bottles, syringe +// darts, medipens, pills, bandages and other medical stacks, thrown spears, stars and bolas). They +// may leave its body the way a person's would: thrown, fired, dropped or knocked out of its hand. +// They still never become loot: in anyone's hands or bags but a human NPC's they are deleted, and +// loose ones go when the NPC that carried them does. +// * NPCs with npc_gear_locked = FALSE lock nothing at all (owner ruling OC-11: prisoners' jumpsuits, +// contraband and shivs are ordinary items, so shakedowns, confiscation and uniform swaps work). Their +// guards keep the lock. + +/// Items an NPC carries that aren't its gear: never locked, dropped when it dies. Their loss would +/// break something outside the NPC (the cryo pod refuses to delete the first two for the same reason). +GLOBAL_LIST_INIT(human_npc_not_gear, typecacheof(list( + /obj/item/ship_key, + /obj/item/mission_recovery, + /obj/item/bounty_proof, + /obj/item/paper, +))) + +/// Items an NPC uses up: they leave its body like a person's would, but never become loot. +GLOBAL_LIST_INIT(human_npc_consumable_gear, typecacheof(list( + /obj/item/grenade, + /obj/item/reagent_containers/cup/glass/bottle, + /obj/item/reagent_containers/syringe, + /obj/item/reagent_containers/hypospray/medipen, + /obj/item/reagent_containers/applicator/pill, + /obj/item/stack/medical, + /obj/item/spear, + /obj/item/throwing_star, + /obj/item/restraints/legcuffs/bola, +))) + +/// Trait source for the gear lock's traits, shared by the element and the consumable component. +#define HUMAN_NPC_GEAR_TRAIT_SOURCE "human_npc_gear_lock" + +/// Locks an item to the human NPC body that carries it. Safe to call again on a locked item. +/datum/element/human_npc_gear + element_flags = ELEMENT_DETACH_ON_HOST_DESTROY + +/datum/element/human_npc_gear/Attach(datum/target) + . = ..() + if(!isitem(target)) + return ELEMENT_INCOMPATIBLE + var/obj/item/gear = target + gear.add_traits(list(TRAIT_HUMAN_NPC_GEAR, TRAIT_NO_STRIP), HUMAN_NPC_GEAR_TRAIT_SOURCE) + RegisterSignal(gear, COMSIG_ITEM_PRE_UNEQUIP, PROC_REF(on_pre_unequip)) + RegisterSignal(gear, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved)) + RegisterSignal(gear, COMSIG_ITEM_PRE_EXPORT, PROC_REF(on_pre_export)) + human_npc_gear_strip_materials(gear) + +/datum/element/human_npc_gear/Detach(datum/source) + UnregisterSignal(source, list(COMSIG_ITEM_PRE_UNEQUIP, COMSIG_MOVABLE_MOVED, COMSIG_ITEM_PRE_EXPORT)) + source.remove_traits(list(TRAIT_HUMAN_NPC_GEAR, TRAIT_NO_STRIP), HUMAN_NPC_GEAR_TRAIT_SOURCE) + return ..() + +/// Refuses any drop or hand-over that would leave the NPC's body. Forced moves are let through and +/// caught by on_moved(). +/datum/element/human_npc_gear/proc/on_pre_unequip(obj/item/source, force, atom/newloc, no_move, invdrop, silent) + SIGNAL_HANDLER + if(force || isnull(newloc) || human_npc_holding(newloc)) + return NONE + return COMPONENT_ITEM_BLOCK_UNEQUIP + +/datum/element/human_npc_gear/proc/on_moved(obj/item/source, atom/old_loc, dir, forced, list/old_locs) + SIGNAL_HANDLER + human_npc_gear_check(source) + +/datum/element/human_npc_gear/proc/on_pre_export(obj/item/source) + SIGNAL_HANDLER + return COMPONENT_STOP_EXPORT + +/** + * Something an NPC uses up (GLOB.human_npc_consumable_gear). It leaves the body like anyone's would: + * thrown, fired from a dart gun, dropped, knocked from a hand. Lying loose or in flight it stays; in + * anyone's hands or bags but a human NPC's it is deleted; loose, it goes when its NPC does. + */ +/datum/component/human_npc_consumable + /// The NPC it was issued to + var/mob/living/carbon/human/npc/owner + +/datum/component/human_npc_consumable/Initialize(mob/living/carbon/human/npc/owner) + if(!isitem(parent) || !ishumannpc(owner)) + return COMPONENT_INCOMPATIBLE + src.owner = owner + RegisterSignal(owner, COMSIG_QDELETING, PROC_REF(on_owner_deleted)) + human_npc_gear_strip_materials(parent) + +/datum/component/human_npc_consumable/RegisterWithParent() + var/obj/item/item = parent + item.add_traits(list(TRAIT_HUMAN_NPC_CONSUMABLE, TRAIT_NO_STRIP), HUMAN_NPC_GEAR_TRAIT_SOURCE) + RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved)) + RegisterSignal(parent, COMSIG_ITEM_PRE_EXPORT, PROC_REF(on_pre_export)) + +/datum/component/human_npc_consumable/UnregisterFromParent() + var/obj/item/item = parent + item.remove_traits(list(TRAIT_HUMAN_NPC_CONSUMABLE, TRAIT_NO_STRIP), HUMAN_NPC_GEAR_TRAIT_SOURCE) + UnregisterSignal(parent, list(COMSIG_MOVABLE_MOVED, COMSIG_ITEM_PRE_EXPORT)) + +/datum/component/human_npc_consumable/Destroy(force) + if(owner) + UnregisterSignal(owner, COMSIG_QDELETING) + owner = null + return ..() + +/datum/component/human_npc_consumable/proc/on_moved(obj/item/source, atom/old_loc, dir, forced, list/old_locs) + SIGNAL_HANDLER + human_npc_gear_check(source) + +/datum/component/human_npc_consumable/proc/on_pre_export(obj/item/source) + SIGNAL_HANDLER + return COMPONENT_STOP_EXPORT + +/// Its NPC is gone: a loose one goes too. One still on the NPC is deleted with it anyway. +/datum/component/human_npc_consumable/proc/on_owner_deleted(datum/source) + SIGNAL_HANDLER + var/obj/item/item = parent + UnregisterSignal(owner, COMSIG_QDELETING) + owner = null + if(!QDELETED(item) && !human_npc_holding(item)) + qdel(item) + +/// The human NPC that `place` is, or is carried by at any depth (a gun in its hand, a magazine in a +/// pouch on its belt, its body in a bag). Null when the chain ends on a turf or in nullspace first. +/proc/human_npc_holding(atom/place) + while(place && !isturf(place)) + if(ishumannpc(place)) + return place + place = place.loc + return null + +/// Whether `item` may be where it is: on a human NPC, or for a consumable, also loose or in flight. +/proc/human_npc_gear_allowed_at(obj/item/item) + if(human_npc_holding(item.loc)) + return TRUE + if(!HAS_TRAIT(item, TRAIT_HUMAN_NPC_CONSUMABLE)) + return FALSE + return isturf(item.loc) || istype(item.loc, /obj/projectile) + +/// After a move: locked gear that ended up somewhere it may not be is deleted on the next tick, unless +/// it is back where it may be by then. +/proc/human_npc_gear_check(obj/item/item) + if(QDELING(item) || human_npc_gear_allowed_at(item) || HAS_TRAIT(item, TRAIT_HUMAN_NPC_GEAR_LOST)) + return + ADD_TRAIT(item, TRAIT_HUMAN_NPC_GEAR_LOST, HUMAN_NPC_GEAR_TRAIT_SOURCE) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(human_npc_gear_settle), item), 0) + +/// A locked item that went somewhere it may not be last tick: deleted, unless it is back by now. +/proc/human_npc_gear_settle(obj/item/gear) + if(QDELETED(gear)) + return + REMOVE_TRAIT(gear, TRAIT_HUMAN_NPC_GEAR_LOST, HUMAN_NPC_GEAR_TRAIT_SOURCE) + if(human_npc_gear_allowed_at(gear)) + return + qdel(gear) + +/// Locked gear keeps no salvage value. Material effects (a plasteel helmet's colour and armour) live in +/// custom_materials, so only plain items lose theirs. +/proc/human_npc_gear_strip_materials(obj/item/gear) + if(length(gear.custom_materials) && !(gear.material_flags & MATERIAL_EFFECTS)) + gear.set_custom_materials(null) + +/// Whether `item` is locked to a human NPC's body. For tests and admin tools. +/proc/human_npc_gear_locked(obj/item/item) + return !QDELETED(item) && HAS_TRAIT(item, TRAIT_HUMAN_NPC_GEAR) + +/// Whether `item` is a consumable issued to a human NPC. For tests and admin tools. +/proc/human_npc_gear_consumable(obj/item/item) + return !QDELETED(item) && HAS_TRAIT(item, TRAIT_HUMAN_NPC_CONSUMABLE) + +/** + * Locks `item` to this NPC's body, or issues it as a consumable, by the lists above. Items that aren't + * gear, body parts, organs, ammunition casings and abstract items are left alone, and so is everything + * on an NPC whose gear isn't locked (npc_gear_locked). Use it for anything handed to an NPC after it + * spawned. Returns TRUE if the item is now locked or issued. + */ +/mob/living/carbon/human/npc/proc/npc_lock_item(obj/item/item) + if(!npc_gear_locked || QDELETED(item) || isbodypart(item) || isorgan(item) || isammocasing(item) || (item.item_flags & ABSTRACT)) + return FALSE + if(is_type_in_typecache(item, GLOB.human_npc_not_gear)) + return FALSE + if(HAS_TRAIT(item, TRAIT_HUMAN_NPC_GEAR) || HAS_TRAIT(item, TRAIT_HUMAN_NPC_CONSUMABLE)) + return TRUE + if(is_type_in_typecache(item, GLOB.human_npc_consumable_gear)) + item.AddComponent(/datum/component/human_npc_consumable, src) + else + item.AddElement(/datum/element/human_npc_gear) + return TRUE + +/// Locks everything the NPC carries: worn, held, in pockets and bags, implants and skillchips. +/mob/living/carbon/human/npc/proc/npc_lock_all_gear() + for(var/obj/item/item as anything in get_all_contents_type(/obj/item)) + npc_lock_item(item) + +/// Deletes every locked or issued item the NPC carries. Used when a player takes over the body. +/mob/living/carbon/human/npc/proc/npc_delete_locked_gear() + for(var/obj/item/item as anything in get_all_contents_type(/obj/item)) + if(QDELETED(item)) + continue + if(HAS_TRAIT(item, TRAIT_HUMAN_NPC_GEAR) || HAS_TRAIT(item, TRAIT_HUMAN_NPC_CONSUMABLE)) + qdel(item) + +/// Drops what it carries that isn't gear (GLOB.human_npc_not_gear) at its feet, as anyone's would be +/// found on them. Called when it dies, since nobody can search an NPC's pockets. +/mob/living/carbon/human/npc/proc/npc_drop_not_gear() + var/atom/drop_spot = drop_location() + if(isnull(drop_spot)) + return + for(var/obj/item/item as anything in get_all_contents_type(/obj/item)) + if(QDELETED(item) || !is_type_in_typecache(item, GLOB.human_npc_not_gear)) + continue + if(item.loc == src) + dropItemToGround(item, force = TRUE) + else + item.forceMove(drop_spot) + +#undef HUMAN_NPC_GEAR_TRAIT_SOURCE diff --git a/voidcrew/modules/human_npcs/human_npc_outfits.dm b/voidcrew/modules/human_npcs/human_npc_outfits.dm new file mode 100644 index 00000000000..c228e62a787 --- /dev/null +++ b/voidcrew/modules/human_npcs/human_npc_outfits.dm @@ -0,0 +1,251 @@ +/** + * # Human NPC outfits by zone, rank and site (N7) + * + * Toughness for human NPCs comes from what they wear (defaults 1.5), so harder zones get better kit, + * not more health: rags in green, a vest in yellow, a vest and helmet in red, better guns as you go. + * + * An outfit table (/datum/human_npc_outfit_table) picks a /datum/outfit for one NPC from weighted lists + * per zone and rank. Use one by setting npc_outfit_table on the NPC type, or by passing the table + * typepath as spawn_human_npc(outfit =). The zone is the spawn context's (spawn_npc_in_zone()), else + * the zone of the spawn turf (a ship's overmap tile when aboard one), else green. A queued order whose + * zone isn't known yet waits for it in the queue, up to HUMAN_NPC_ZONE_WAIT (human_npc_spawning.dm). + * + * Whatever the outfit, the site layers then make sure the NPC can live where it is made (decision D5 + * and defaults 1.12: real suits and tanks, never immunity traits). human_npc_site_at() reads the air on + * the spawn turf: + * - HUMAN_NPC_SITE_VACUUM (too little pressure): if the outfit's suit and helmet aren't both sealed, + * the table's vacuum_layer replaces them with a sealed suit and helmet; it also gets a tank. A MODsuit + * on its back counts as sealed: tg's outfit path deploys and seals it (quick_activation()). + * - HUMAN_NPC_SITE_BAD_AIR (pressure fine, air not): a breath mask if nothing it wears takes internals, + * and a tank. + * - HUMAN_NPC_SITE_COLD: the table's cold_layer fills the slots the outfit leaves empty with cold-weather + * wear and swaps the shoes for winter boots. An outfit meant for ice planets should bring its own. + * A table's always_site, and the NPC's npc_always_site, add sites regardless of the air (boarders that + * cross vacuum). Species that need none of it (skeletons) are left alone. Resisting low pressure isn't + * enough on its own: vacuum is as cold as space, and only a space suit keeps that out (tg insulation), + * so a pressure-proof species that feels the cold (silverscale, lustrous) is still sealed; one that + * doesn't breathe gets no tank. The NPC then opens its tank and switches on its suit's thermal + * regulator, as a player would. + */ + +/** + * Weighted outfits for one family. Lists are outfit typepath => weight. A zone left null uses the zone + * below it; elites and bosses fall back to the zone's regulars. Override outfits_for() to pick by + * anything else the NPC carries (a bounty's tier, a faction's role). + */ +/datum/human_npc_outfit_table + /// Regulars in the green zone + var/list/green + /// Regulars in the yellow zone. Null: green's. + var/list/yellow + /// Regulars in the red zone. Null: yellow's. + var/list/red + /// Elites in any zone. Null: the zone's regulars. + var/list/elite + /// Bosses in any zone. Null: elite's. + var/list/boss + /// HUMAN_NPC_SITE_* flags every NPC it dresses gets, whatever the air where it spawns + var/always_site = NONE + /// What goes over an outfit that isn't sealed, in vacuum (a /datum/human_npc_layer typepath) + var/datum/human_npc_layer/vacuum_layer = /datum/human_npc_layer/eva + /// What goes over an outfit in the cold + var/datum/human_npc_layer/cold_layer = /datum/human_npc_layer/cold + +/// The weighted outfits `npc` may get in `zone` (ZONE_*). +/datum/human_npc_outfit_table/proc/outfits_for(mob/living/carbon/human/npc/npc, zone) + var/rank = npc?.npc_rank || HUMAN_NPC_RANK_REGULAR + if(rank >= HUMAN_NPC_RANK_BOSS && length(boss)) + return boss + if(rank >= HUMAN_NPC_RANK_ELITE && length(elite)) + return elite + if(zone == ZONE_RED && length(red)) + return red + if(zone >= ZONE_YELLOW && length(yellow)) + return yellow + return green + +/// One outfit typepath for `npc` in `zone`, or null if the table has nothing for it. +/datum/human_npc_outfit_table/proc/pick_outfit(mob/living/carbon/human/npc/npc, zone) + var/list/choices = outfits_for(npc, zone) + if(!length(choices)) + return null + return pick_weight(choices) + +/** + * What `spot` asks of a person standing there: HUMAN_NPC_SITE_* flags read from its air. Space and + * anything under tg's hazard pressure is vacuum; too little oxygen or a lungful of plasma or carbon + * dioxide is bad air; air below HUMAN_NPC_SITE_COLD_TEMP is cold. Only reads the air, so a planet tile + * keeps sharing its planet's mix (return_air_readonly(), planetary_shared_air.dm). + */ +/proc/human_npc_site_at(turf/spot) + if(isnull(spot)) + return NONE + var/datum/gas_mixture/air = spot.return_air_readonly() + if(isnull(air)) + return HUMAN_NPC_SITE_VACUUM | HUMAN_NPC_SITE_COLD + . = NONE + var/pressure = air.return_pressure() + if(pressure < HAZARD_LOW_PRESSURE) + . |= HUMAN_NPC_SITE_VACUUM + else + var/oxygen = human_npc_partial_pressure(air, /datum/gas/oxygen, pressure) + var/plasma = human_npc_partial_pressure(air, /datum/gas/plasma, pressure) + var/carbon_dioxide = human_npc_partial_pressure(air, /datum/gas/carbon_dioxide, pressure) + if(oxygen < HUMAN_NPC_SITE_MIN_OXYGEN || plasma > 0.5 || carbon_dioxide > 10) + . |= HUMAN_NPC_SITE_BAD_AIR + if(air.temperature < HUMAN_NPC_SITE_COLD_TEMP) + . |= HUMAN_NPC_SITE_COLD + +/// The partial pressure of `gas_type` in `air`, in kPa, given the mix's total `pressure`. +/proc/human_npc_partial_pressure(datum/gas_mixture/air, gas_type, pressure) + var/list/entry = air.gases[gas_type] + var/total = air.total_moles() + if(!entry || !total) + return 0 + return pressure * entry[MOLES] / total + +/** + * Its outfit, with whatever the site needs layered on (see the top of this file). Returns `outfit` + * unchanged when nothing is needed, else an outfit instance (an instance passed in is changed in place). + */ +/mob/living/carbon/human/npc/proc/npc_fit_outfit_to_site(outfit, datum/human_npc_outfit_table/table) + npc_site = human_npc_site_at(get_turf(src)) | npc_always_site | table?.always_site + // The cold of vacuum gets through anything but a space suit (SPACE_SUIT_MIN_TEMP_PROTECT) + var/needs_seal = (npc_site & HUMAN_NPC_SITE_VACUUM) && !(HAS_TRAIT(src, TRAIT_RESISTLOWPRESSURE) && HAS_TRAIT(src, TRAIT_RESISTCOLD)) + var/needs_air = (npc_site & (HUMAN_NPC_SITE_VACUUM | HUMAN_NPC_SITE_BAD_AIR)) && !HAS_TRAIT(src, TRAIT_NOBREATH) + var/needs_warmth = (npc_site & HUMAN_NPC_SITE_COLD) && !HAS_TRAIT(src, TRAIT_RESISTCOLD) + if(!needs_seal && !needs_air && !needs_warmth) + return outfit + var/datum/outfit/dressed = ispath(outfit) ? new outfit() : outfit + if(!istype(dressed)) + return outfit + if(needs_seal && !human_npc_outfit_sealed(dressed)) + var/datum/human_npc_layer/seal = human_npc_singleton(table?.vacuum_layer || /datum/human_npc_layer/eva) + seal.apply(dressed) + if(needs_air && !human_npc_outfit_has_air(dressed)) + if(!human_npc_outfit_can_breathe(dressed)) + dressed.mask = /obj/item/clothing/mask/breath + human_npc_outfit_add_tank(dressed) + // A sealed suit with its heating on keeps out the cold of space; warm clothes go on where it isn't sealed. + if(needs_warmth && !(needs_seal && human_npc_outfit_sealed(dressed))) + var/datum/human_npc_layer/warmth = human_npc_singleton(table?.cold_layer || /datum/human_npc_layer/cold) + warmth.apply(dressed) + return dressed + +/// Whether the outfit's suit and helmet both hold pressure and keep out the cold of space. A fire suit or a +/// tactical vest holds pressure too, but a person freezes in one out there (tg's cold protection). A space +/// suit keeps it out with its thermal regulator, which comes on as an outfit puts it on if it has a cell +/// (on_outfit_equip()). +/proc/human_npc_outfit_sealed(datum/outfit/outfit) + // A MODsuit on its back deploys and seals head to toe as the outfit puts it on (quick_activation()) + if(ispath(outfit.back, /obj/item/mod/control)) + return TRUE + // Typed as a space suit only to read its cell; any suit that holds pressure is checked + var/obj/item/clothing/suit/space/suit = outfit.suit + var/obj/item/clothing/head = outfit.head + if(!ispath(suit, /obj/item/clothing) || !ispath(head, /obj/item/clothing)) + return FALSE + if(!(initial(suit.clothing_flags) & STOPSPRESSUREDAMAGE) || !(initial(head.clothing_flags) & STOPSPRESSUREDAMAGE)) + return FALSE + var/suit_cold = (ispath(suit, /obj/item/clothing/suit/space) && initial(suit.cell)) ? SPACE_SUIT_MIN_TEMP_PROTECT : initial(suit.min_cold_protection_temperature) + var/head_cold = initial(head.min_cold_protection_temperature) + return suit_cold && suit_cold <= SPACE_SUIT_MIN_TEMP_PROTECT && head_cold && head_cold <= SPACE_HELM_MIN_TEMP_PROTECT + +/// Whether it wears something it can breathe a tank through: a mask or a helmet that takes internals. +/proc/human_npc_outfit_can_breathe(datum/outfit/outfit) + // A MODsuit's helmet takes internals once sealed + if(ispath(outfit.back, /obj/item/mod/control)) + return TRUE + var/obj/item/clothing/mask = outfit.mask + var/obj/item/clothing/head = outfit.head + if(ispath(mask, /obj/item/clothing) && (initial(mask.clothing_flags) & MASKINTERNALS)) + return TRUE + return ispath(head, /obj/item/clothing) && (initial(head.clothing_flags) & HEADINTERNALS) + +/// Whether it carries a tank where it can open it and can breathe through something. +/proc/human_npc_outfit_has_air(datum/outfit/outfit) + if(!human_npc_outfit_can_breathe(outfit)) + return FALSE + for(var/carried in list(outfit.suit_store, outfit.back, outfit.belt, outfit.l_pocket, outfit.r_pocket)) + if(ispath(carried, /obj/item/tank/internals)) + return TRUE + return FALSE + +/// Gives the outfit an air tank and opens it: in a space suit's or a MODsuit chestplate's storage, else a +/// pocket, else the back or the belt. Returns TRUE if it found a place. +/proc/human_npc_outfit_add_tank(datum/outfit/outfit) + if(isnull(outfit.suit_store) && (ispath(outfit.suit, /obj/item/clothing/suit/space) || ispath(outfit.back, /obj/item/mod/control))) + outfit.suit_store = /obj/item/tank/internals/oxygen + outfit.internals_slot = ITEM_SLOT_SUITSTORE + return TRUE + if(isnull(outfit.l_pocket)) + outfit.l_pocket = /obj/item/tank/internals/emergency_oxygen/double + outfit.internals_slot = ITEM_SLOT_LPOCKET + return TRUE + if(isnull(outfit.r_pocket)) + outfit.r_pocket = /obj/item/tank/internals/emergency_oxygen/double + outfit.internals_slot = ITEM_SLOT_RPOCKET + return TRUE + if(isnull(outfit.back)) + outfit.back = /obj/item/tank/internals/oxygen + outfit.internals_slot = ITEM_SLOT_BACK + return TRUE + if(isnull(outfit.belt)) + outfit.belt = /obj/item/tank/internals/emergency_oxygen/double + outfit.internals_slot = ITEM_SLOT_BELT + return TRUE + stack_trace("[outfit.type] has nowhere to carry an air tank") + return FALSE + +/** + * Clothing layered over an outfit for a site. Slots it sets are filled where the outfit leaves them + * empty, or always for the slots in `replace_slots` (ITEM_SLOT_* flags). Anything in suit storage that + * a replaced suit can't hold moves to the backpack, if there is one. + */ +/datum/human_npc_layer + var/suit + var/head + var/mask + var/gloves + var/shoes + var/neck + /// ITEM_SLOT_* flags of slots it takes over even when the outfit fills them + var/replace_slots = NONE + +/datum/human_npc_layer/proc/apply(datum/outfit/outfit) + if(suit && (isnull(outfit.suit) || (replace_slots & ITEM_SLOT_OCLOTHING))) + if(outfit.suit_store && outfit.suit != suit) + if(outfit.back) + LAZYADDASSOC(outfit.backpack_contents, outfit.suit_store, 1) + outfit.suit_store = null + outfit.suit = suit + if(head && (isnull(outfit.head) || (replace_slots & ITEM_SLOT_HEAD))) + outfit.head = head + if(mask && (isnull(outfit.mask) || (replace_slots & ITEM_SLOT_MASK))) + outfit.mask = mask + if(gloves && (isnull(outfit.gloves) || (replace_slots & ITEM_SLOT_GLOVES))) + outfit.gloves = gloves + if(shoes && (isnull(outfit.shoes) || (replace_slots & ITEM_SLOT_FEET))) + outfit.shoes = shoes + if(neck && (isnull(outfit.neck) || (replace_slots & ITEM_SLOT_NECK))) + outfit.neck = neck + +/// A plain sealed EVA suit and helmet, the fallback for any family in vacuum. +/datum/human_npc_layer/eva + suit = /obj/item/clothing/suit/space/eva + head = /obj/item/clothing/head/helmet/space/eva + replace_slots = ITEM_SLOT_OCLOTHING | ITEM_SLOT_HEAD + +/// Pirates' own space suit: lighter, armoured, and it holds a gun. +/datum/human_npc_layer/eva/pirate + suit = /obj/item/clothing/suit/space/pirate + head = /obj/item/clothing/head/helmet/space/pirate + +/// Cold-weather wear for whatever an outfit leaves bare. +/datum/human_npc_layer/cold + suit = /obj/item/clothing/suit/hooded/wintercoat + head = /obj/item/clothing/head/costume/ushanka + gloves = /obj/item/clothing/gloves/color/black + shoes = /obj/item/clothing/shoes/winterboots + neck = /obj/item/clothing/neck/scarf + replace_slots = ITEM_SLOT_FEET diff --git a/voidcrew/modules/human_npcs/human_npc_samples.dm b/voidcrew/modules/human_npcs/human_npc_samples.dm new file mode 100644 index 00000000000..216b76347d8 --- /dev/null +++ b/voidcrew/modules/human_npcs/human_npc_samples.dm @@ -0,0 +1,162 @@ +// Sample human NPCs: the reference kit for the base (admin spawns, tests, the measurement harness). +// Phases B-E make their own types (pirate factions, troopers, hermits, criminals) and replace these. +// The ranged samples carry their spare ammunition, and the spacer its own air: no NPC refills from +// nothing or breathes vacuum. + +/datum/outfit/human_npc + name = "Human NPC" + +/datum/outfit/human_npc/pirate_gunner + name = "Human NPC: pirate gunner" + uniform = /obj/item/clothing/under/costume/pirate + suit = /obj/item/clothing/suit/costume/pirate/armored + head = /obj/item/clothing/head/costume/pirate/armored + glasses = /obj/item/clothing/glasses/eyepatch + gloves = /obj/item/clothing/gloves/color/black + shoes = /obj/item/clothing/shoes/jackboots + belt = /obj/item/storage/belt/military + belt_contents = list( + /obj/item/ammo_box/magazine/m9mm = 2, + /obj/item/knife/combat/survival = 1, + ) + r_hand = /obj/item/gun/ballistic/automatic/pistol + +/datum/outfit/human_npc/pirate_laser + name = "Human NPC: pirate laser gunner" + uniform = /obj/item/clothing/under/costume/pirate + suit = /obj/item/clothing/suit/costume/pirate/armored + head = /obj/item/clothing/head/costume/pirate/armored + glasses = /obj/item/clothing/glasses/eyepatch + shoes = /obj/item/clothing/shoes/jackboots + belt = /obj/item/storage/belt/military + belt_contents = list(/obj/item/knife/combat/survival = 1) + r_hand = /obj/item/gun/energy/laser + +/datum/outfit/human_npc/pirate_swashbuckler + name = "Human NPC: pirate swashbuckler" + uniform = /obj/item/clothing/under/costume/pirate + head = /obj/item/clothing/head/costume/pirate/bandana/armored + glasses = /obj/item/clothing/glasses/eyepatch + shoes = /obj/item/clothing/shoes/jackboots + r_hand = /obj/item/melee/energy/sword/pirate + +/// For hulls and ruins open to space: a sealed suit and its own air. +/datum/outfit/human_npc/pirate_spacer + name = "Human NPC: pirate spacer" + uniform = /obj/item/clothing/under/costume/pirate + suit = /obj/item/clothing/suit/space/pirate + head = /obj/item/clothing/head/helmet/space/pirate + gloves = /obj/item/clothing/gloves/color/black + shoes = /obj/item/clothing/shoes/jackboots + suit_store = /obj/item/tank/internals/oxygen + internals_slot = ITEM_SLOT_SUITSTORE + belt = /obj/item/storage/belt/military + belt_contents = list(/obj/item/knife/combat/survival = 1) + r_hand = /obj/item/gun/energy/laser + +/mob/living/carbon/human/npc/sample + faction = list(FACTION_PIRATE) + npc_name = "Pirate" + +/mob/living/carbon/human/npc/sample/gunner + npc_name = "Pirate Gunner" + npc_outfit = /datum/outfit/human_npc/pirate_gunner + npc_death_cash = 100 + +/mob/living/carbon/human/npc/sample/laser + npc_name = "Pirate Gunner" + npc_outfit = /datum/outfit/human_npc/pirate_laser + npc_death_cash = 100 + +/mob/living/carbon/human/npc/sample/swashbuckler + npc_name = "Pirate Swashbuckler" + npc_outfit = /datum/outfit/human_npc/pirate_swashbuckler + npc_death_cash = 100 + +/mob/living/carbon/human/npc/sample/spacer + npc_name = "Pirate Spacer" + npc_outfit = /datum/outfit/human_npc/pirate_spacer + npc_death_cash = 100 + +/// An elite: lands aimed crits and executions, and takes a quarter less brute and burn. +/mob/living/carbon/human/npc/sample/elite + npc_name = "Pirate Bosun" + npc_outfit = /datum/outfit/human_npc/pirate_gunner + npc_rank = HUMAN_NPC_RANK_ELITE + npc_damage_taken = 0.75 + npc_death_cash = 300 + +// ===== Phase A2 samples: a voice, surrender rules and a zone table, for tests and admin spawns ===== + +/datum/human_npc_voice/sample + lines = list( + HUMAN_NPC_BARK_DOWNED = list("I'm hit! I'm hit!", "Not like this..."), + HUMAN_NPC_BARK_RECOVER = list("Still breathing.", "That all you've got?"), + HUMAN_NPC_BARK_PLEAD = list("Please... don't.", "I give, I give..."), + HUMAN_NPC_BARK_CUFFED = list("These are too tight."), + HUMAN_NPC_BARK_SLIPPING = list("Almost got it..."), + HUMAN_NPC_BARK_UNCUFFED = list("Hands free."), + HUMAN_NPC_BARK_PULLED_FREE = list("Hands off!"), + HUMAN_NPC_BARK_SURRENDER = list("Alright! I give up!", "Don't shoot!"), + ) + emotes = list( + HUMAN_NPC_BARK_DOWNED = list("collapses."), + ) + +/datum/human_npc_surrender/sample + +/mob/living/carbon/human/npc/sample + npc_voice = /datum/human_npc_voice/sample + +/// Gives up when it is losing, and stops shooting anyone already down: the shape of a criminal. +/mob/living/carbon/human/npc/sample/thug + npc_name = "Thug" + npc_outfit = /datum/outfit/human_npc/thug + npc_surrender = /datum/human_npc_surrender/sample + npc_target_stat = HUMAN_NPC_SPARES_DOWNED + npc_death_cash = 100 + +/// Dressed by zone: rags in green, a vest in yellow, a vest, helmet and SMG in red. +/mob/living/carbon/human/npc/sample/raider + npc_name = "Raider" + npc_outfit_table = /datum/human_npc_outfit_table/sample_raiders + npc_death_cash = 100 + +/datum/human_npc_outfit_table/sample_raiders + green = list(/datum/outfit/human_npc/raider = 1) + yellow = list(/datum/outfit/human_npc/raider/vest = 1) + red = list(/datum/outfit/human_npc/raider/armoured = 1) + elite = list(/datum/outfit/human_npc/pirate_gunner = 1) + vacuum_layer = /datum/human_npc_layer/eva/pirate + +/datum/outfit/human_npc/raider + name = "Human NPC: raider" + uniform = /obj/item/clothing/under/costume/pirate + head = /obj/item/clothing/head/costume/pirate/bandana/armored + shoes = /obj/item/clothing/shoes/jackboots + r_hand = /obj/item/gun/ballistic/automatic/pistol + l_pocket = /obj/item/ammo_box/magazine/m9mm + +/datum/outfit/human_npc/raider/vest + name = "Human NPC: raider in a vest" + suit = /obj/item/clothing/suit/armor/vest + r_pocket = /obj/item/ammo_box/magazine/m9mm + +/datum/outfit/human_npc/raider/armoured + name = "Human NPC: armoured raider" + suit = /obj/item/clothing/suit/armor/vest + head = /obj/item/clothing/head/helmet + r_hand = /obj/item/gun/ballistic/automatic/mini_uzi + l_pocket = /obj/item/ammo_box/magazine/uzim9mm + r_pocket = /obj/item/ammo_box/magazine/uzim9mm + +/// A pistol and somewhere to holster it, so it has somewhere to put the gun when it gives up. +/datum/outfit/human_npc/thug + name = "Human NPC: thug" + uniform = /obj/item/clothing/under/costume/pirate + shoes = /obj/item/clothing/shoes/jackboots + gloves = /obj/item/clothing/gloves/color/black + belt = /obj/item/storage/belt/holster + r_hand = /obj/item/gun/ballistic/automatic/pistol + l_pocket = /obj/item/ammo_box/magazine/m9mm + r_pocket = /obj/item/reagent_containers/hypospray/medipen diff --git a/voidcrew/modules/human_npcs/human_npc_soft_crit.dm b/voidcrew/modules/human_npcs/human_npc_soft_crit.dm new file mode 100644 index 00000000000..e60c6715fef --- /dev/null +++ b/voidcrew/modules/human_npcs/human_npc_soft_crit.dm @@ -0,0 +1,162 @@ +/** + * # Human NPCs in soft crit (N5) + * + * A person in soft crit is on the floor and (Voidcrew's soft-crit item use, PR #284, + * voidcrew/edits/modules/mob/mob.dm) can use what is on them at a quarter of the speed. An NPC stays + * where it fell (the owner didn't want NPCs crawling about), pleads now and then, and injects a + * medipen it carries. Elites and bosses also fire wild from the floor, at the ground around their + * attacker, the way a player shooting from crit does. Everything goes through tg: the medipen is the player's "use in hand" (execute_mode()), the shot is a click with the gun. + * Brute packs and other medical stacks need a do_after, which tg refuses to anyone incapacitated, so a + * person in soft crit can't use them, and neither can an NPC. + * + * tg's basic controller turns the AI off at any stat above CONSCIOUS. human_npc_ai_able_to_run() lets a + * human NPC's AI run in soft crit; this subtree must then come first in its planning list, so nothing + * else plans while it is down. Hard crit, unconscious and dead still stop the AI. + * + * Who a family keeps attacking is npc_target_stat on the NPC (HUMAN_NPC_FINISHES_DOWNED or + * HUMAN_NPC_SPARES_DOWNED), written into BB_TARGET_MINIMUM_STAT at spawn. + */ + +/** + * The run check for any controller whose pawn is a human NPC: the basic controller's, except that cuffs + * don't stop it (so escape_captivity can work at them, phase A) and soft crit doesn't either (so the + * soft-crit subtree runs). A controller of another type (PR #500's pirate crew) calls this from its own + * get_able_to_run(). + */ +/proc/human_npc_ai_able_to_run(datum/ai_controller/controller) + var/mob/living/living_pawn = controller.pawn + if(HAS_TRAIT(living_pawn, TRAIT_AI_PAUSED) || world.time < controller.paused_until) + return AI_UNABLE_TO_RUN + if(living_pawn.stat && living_pawn.stat != SOFT_CRIT && !(controller.ai_traits & CAN_ACT_WHILE_DEAD)) + return AI_UNABLE_TO_RUN + var/ignore_incap_flags = INCAPABLE_RESTRAINTS + if(controller.ai_traits & CAN_ACT_IN_STASIS) + ignore_incap_flags |= INCAPABLE_STASIS + if(controller.ai_traits & CAN_ACT_WHILE_GRABBED) + ignore_incap_flags |= INCAPABLE_GRAB + // The same test the click code uses in soft crit: crit's own incapacitation doesn't count, a stun does. + if(living_pawn.incapacitated_except_softcrit(ignore_incap_flags)) + return AI_UNABLE_TO_RUN + if((controller.ai_traits & PAUSE_DURING_DO_AFTER) && LAZYLEN(living_pawn.do_afters)) + return AI_UNABLE_TO_RUN | AI_PREVENT_CANCEL_ACTIONS + return NONE + +/// For a human NPC controller's on_stat_changed(): falling into soft crit drops whatever it was doing +/// on its feet (a reload, a shot, a chase), so only the soft-crit subtree's behaviours run. +/proc/human_npc_ai_stat_changed(datum/ai_controller/controller, new_stat) + if(new_stat == SOFT_CRIT) + controller.CancelActions() + +/// In soft crit: treat itself, fire wild (elites and bosses), plead. It stays where it fell. Must come first. +/datum/ai_planning_subtree/human_npc_soft_crit + +/datum/ai_planning_subtree/human_npc_soft_crit/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/npc = controller.pawn + if(npc.stat != SOFT_CRIT) + return + var/mob/living/carbon/human/npc/human_npc = ishumannpc(npc) ? npc : null + if(human_npc && world.time >= human_npc.npc_next_plead) + human_npc.npc_next_plead = world.time + HUMAN_NPC_PLEAD_INTERVAL + human_npc.npc_bark(HUMAN_NPC_BARK_PLEAD) + if(world.time >= controller.blackboard[BB_HUMAN_NPC_NEXT_TREAT]) + var/obj/item/treatment = human_npc_soft_crit_treatment(npc) + if(treatment) + controller.set_blackboard_key(BB_HUMAN_NPC_TREAT_ITEM, treatment) + controller.queue_behavior(/datum/ai_behavior/human_npc_treat_self, BB_HUMAN_NPC_TREAT_ITEM) + return SUBTREE_RETURN_FINISH_PLANNING + var/mob/living/threat = human_npc_nearest_threat(controller) + if(isnull(threat)) + return SUBTREE_RETURN_FINISH_PLANNING + controller.set_blackboard_key(BB_HUMAN_NPC_FLEE_FROM, threat) + if(human_npc?.npc_rank >= HUMAN_NPC_RANK_ELITE && !isnull(human_npc_loaded_gun(npc))) + controller.queue_behavior(/datum/ai_behavior/human_npc_fire_wild, BB_HUMAN_NPC_FLEE_FROM) + return SUBTREE_RETURN_FINISH_PLANNING + +/// Something it carries that it can use on itself in soft crit: a medipen with something in it. +/proc/human_npc_soft_crit_treatment(mob/living/carbon/npc) + for(var/obj/item/reagent_containers/hypospray/medipen/pen in npc.get_all_contents_type(/obj/item/reagent_containers/hypospray/medipen)) + if(pen.used_up || !pen.reagents?.total_volume) + continue + if(npc.is_holding(pen) || human_npc_can_draw(npc, pen)) + return pen + return null + +/// The closest mob it can see that it would fight, whatever state that mob is in. Its target first. +/proc/human_npc_nearest_threat(datum/ai_controller/controller) + var/mob/living/npc = controller.pawn + var/atom/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(isliving(target) && !QDELETED(target) && target.z == npc.z && can_see(npc, target, HUMAN_NPC_SIGHT_RANGE)) + return target + var/mob/living/closest + var/closest_distance = INFINITY + for(var/mob/living/other in oview(HUMAN_NPC_SIGHT_RANGE, npc)) + if(other.stat == DEAD || npc.faction_check_atom(other)) + continue + var/distance = get_dist(npc, other) + if(distance < closest_distance) + closest = other + closest_distance = distance + return closest + +/** + * Uses a medipen on itself the way a player in soft crit does: takes it in hand (holstering its gun if + * both hands are full), then "use in hand", then lets the empty pen fall. + */ +/datum/ai_behavior/human_npc_treat_self + action_cooldown = 1 SECONDS + behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/human_npc_treat_self/perform(seconds_per_tick, datum/ai_controller/controller, item_key) + var/mob/living/carbon/npc = controller.pawn + var/obj/item/reagent_containers/hypospray/medipen/pen = controller.blackboard[item_key] + if(!istype(pen) || QDELETED(pen) || human_npc_holding(pen) != npc) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(pen.used_up) + if(npc.is_holding(pen)) + npc.dropItemToGround(pen) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + if(!npc.is_holding(pen)) + if(!length(npc.get_empty_held_indexes())) + var/obj/item/gun/gun = human_npc_held_gun(npc) + if(isnull(gun) || !gun.equip_to_best_slot(npc)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_DELAY + if(!human_npc_take_in_hand(npc, pen)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_DELAY + if(!human_npc_ready_item(npc, pen)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(npc.next_move > world.time) + return AI_BEHAVIOR_DELAY + npc.execute_mode() + return AI_BEHAVIOR_DELAY + +/datum/ai_behavior/human_npc_treat_self/finish_action(datum/ai_controller/controller, succeeded, item_key) + . = ..() + controller.clear_blackboard_key(item_key) + controller.set_blackboard_key(BB_HUMAN_NPC_NEXT_TREAT, world.time + (succeeded ? 30 SECONDS : 10 SECONDS)) + +/** + * Fires its gun from the floor at the ground around `target`, not at the person: it can barely aim. + * Half the rate of a standing shooter. Only for elites and bosses (the soft-crit subtree decides). + */ +/datum/ai_behavior/human_npc_fire_wild + action_cooldown = 0.5 SECONDS + behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/human_npc_fire_wild/perform(seconds_per_tick, datum/ai_controller/controller, target_key) + var/mob/living/carbon/npc = controller.pawn + var/atom/target = controller.blackboard[target_key] + if(npc.stat != SOFT_CRIT || QDELETED(target) || !can_see(npc, target, controller.blackboard[BB_HUMAN_NPC_FIRE_RANGE] || 7)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + var/obj/item/gun/gun = human_npc_loaded_gun(npc) + if(isnull(gun)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + if(world.time < controller.blackboard[BB_HUMAN_NPC_NEXT_SHOT] || npc.next_move > world.time) + return AI_BEHAVIOR_DELAY + if(!human_npc_ready_item(npc, gun)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + var/turf/aim = pick(RANGE_TURFS(1, get_turf(target))) + controller.ai_interact(target = aim, combat_mode = TRUE) + controller.set_blackboard_key(BB_HUMAN_NPC_NEXT_SHOT, world.time + 2 * (controller.blackboard[BB_HUMAN_NPC_SHOT_DELAY] || 3 SECONDS)) + return AI_BEHAVIOR_DELAY diff --git a/voidcrew/modules/human_npcs/human_npc_spawning.dm b/voidcrew/modules/human_npcs/human_npc_spawning.dm new file mode 100644 index 00000000000..c5f583c9d6b --- /dev/null +++ b/voidcrew/modules/human_npcs/human_npc_spawning.dm @@ -0,0 +1,303 @@ +/** + * # Making human NPCs, and clearing their bodies away + * + * A human costs about 11 ms to build (spike measurement), so a boarding wave of eight built in one + * tick stalls the server for two. Every human NPC goes through spawn_human_npc(), which queues an + * order; SShuman_npcs builds HUMAN_NPC_SPAWNS_PER_FIRE of them per fire. + * + * The same subsystem cleans up corpses so they don't pile up over a 6 hour round: a body dead for + * its npc_corpse_lifetime is deleted the first time a sweep finds no player near it, with the limbs + * and organs it lost that lie unwatched on the floor. Bodies being dragged, carried or watched stay. + * An NPC whose own system cleans it up sets npc_corpse_lifetime = 0. It also deletes living NPCs that + * are walking out (npc_walk_out(), human_npc_states.dm) once they may go. + * + * An order dressed by an outfit table (human_npc_outfits.dm) needs its zone. While its spawn context + * is still resolving the zone (a planet level registering late), the order waits in the queue, up to + * HUMAN_NPC_ZONE_WAIT, and is then dressed for green. + */ + +/** + * Queues a human NPC to be built at `where`. Returns the order; qdel() it to cancel. + * + * * npc_type - a /mob/living/carbon/human/npc typepath + * * where - where it appears (its turf is used) + * * on_spawned - called with the new mob straight after it is built, the same tick + * * look - overrides the type's npc_look: a /obj/effect/mob_spawn typepath, a /datum/bounty_look or a + * /datum/bounty_record + * * outfit - overrides the type's npc_outfit: an outfit typepath, or a /datum/human_npc_outfit_table + * typepath to pick one by zone and rank + * * name - overrides the type's npc_name + * * faction - overrides the type's faction list + * * context - a /datum/npc_spawn_context (voidcrew/modules/npc_scaling/); the body is built through + * spawn_npc_in_zone() and the context finalised after on_spawned + * * immediate - build it now instead of queueing it (admin tools, tests) + * * dir - the way it faces when it appears (a mapped spawner's dir), or NONE for its own + */ +/proc/spawn_human_npc(npc_type, atom/where, datum/callback/on_spawned, look, outfit, name, list/faction, datum/npc_spawn_context/context, immediate = FALSE, dir = NONE) + var/datum/human_npc_order/order = new(npc_type, where, on_spawned, look, outfit, name, faction, context) + order.dir = dir + if(immediate) + order.fulfil() + else + SShuman_npcs.queue += order + return order + +/// One queued human NPC. Holds what spawn_human_npc() was given until the body is built. +/datum/human_npc_order + var/npc_type + var/turf/where + var/datum/callback/on_spawned + var/look + var/datum/outfit/outfit + var/name + var/list/faction + var/datum/npc_spawn_context/context + /// The way it faces when built, or NONE + var/dir = NONE + /// The area its spot was in when queued: the order is dropped if the spot has been reused since + var/area/where_area + /// Weakref to the map region its spot was in when queued (a packed encounter's footprint or a + /// reservation), for the same check; null on a level that isn't packed + var/datum/weakref/where_region + /// The ZONE_* it is dressed for, once known (resolve_zone()) + var/zone + /// world.time it was queued + var/queued_at = 0 + /// world.time it may next look up a zone it is waiting for + var/next_zone_check = 0 + /// Weakref to the mob once it is built + var/datum/weakref/spawned_ref + /// Set once fulfil() has run, whether or not it made a mob + var/done = FALSE + +/datum/human_npc_order/New(npc_type, atom/where, datum/callback/on_spawned, look, outfit, name, list/faction, datum/npc_spawn_context/context) + if(!ispath(npc_type, /mob/living/carbon/human/npc)) + CRASH("spawn_human_npc() was given [npc_type], which is not a human NPC type") + src.npc_type = npc_type + src.where = get_turf(where) + src.where_area = src.where?.loc + var/datum/region = map_region_for_turf(src.where) + src.where_region = region ? WEAKREF(region) : null + src.on_spawned = on_spawned + src.look = look + src.outfit = outfit + src.name = name + src.faction = faction?.Copy() + src.context = context + queued_at = world.time + +/datum/human_npc_order/Destroy(force) + SShuman_npcs.queue -= src + release() + return ..() + +/// Drops what the order held, so a fulfilled order keeps nothing alive. +/datum/human_npc_order/proc/release() + where = null + where_area = null + where_region = null + on_spawned = null + look = null + outfit = null + faction = null + context = null + +/// Whether its body is dressed from an outfit table, and so needs to know its zone first. +/datum/human_npc_order/proc/needs_zone() + if(ispath(outfit, /datum/human_npc_outfit_table)) + return TRUE + if(outfit) + return FALSE + var/mob/living/carbon/human/npc/npc_path = npc_type + return !initial(npc_path.npc_outfit) && ispath(initial(npc_path.npc_outfit_table), /datum/human_npc_outfit_table) + +/** + * The zone to dress it for, or null while it is still unknown and worth waiting for: its context's + * zone, else the zone of its spawn turf (a ship's overmap tile when aboard one). `now` settles for + * green instead of waiting, as does an order that has waited HUMAN_NPC_ZONE_WAIT. + */ +/datum/human_npc_order/proc/resolve_zone(now = TRUE) + if(!isnull(zone)) + return zone + zone = context?.zone_type || get_zone_type_for_player_turf(where) + if(isnull(zone) && (now || isnull(context) || world.time >= queued_at + HUMAN_NPC_ZONE_WAIT)) + zone = ZONE_GREEN + return zone + +/// Whether it can be built now: it doesn't need a zone, or its zone is known. A waiting order looks +/// its zone up at most once a second. +/datum/human_npc_order/proc/ready() + if(!isnull(zone) || !needs_zone()) + return TRUE + if(world.time < next_zone_check) + return FALSE + next_zone_check = world.time + 1 SECONDS + return !isnull(resolve_zone(now = FALSE)) + +/** + * Whether the spot it was queued for is still the same place. An order can wait in the queue (up to + * HUMAN_NPC_ZONE_WAIT for its zone); by then the ruin or planet it was for may have unloaded and its + * turfs been reused by something else. The spot must still exist, be in the same area and the same + * packed map region, and not have become a wall. + */ +/datum/human_npc_order/proc/spot_still_valid() + if(isnull(where) || QDELETED(where)) + return FALSE + if(where.loc != where_area) + return FALSE + // A region that registers after the spot was queued (a planet level coming up late) is fine; one + // that has gone, or been replaced by another, means the ground was recycled. + if(where_region && map_region_for_turf(where) != where_region.resolve()) + return FALSE + return !isclosedturf(where) + +/// Builds the NPC now. Returns it, or null if it couldn't be built. +/datum/human_npc_order/proc/fulfil() + if(done) + return spawned_ref?.resolve() + done = TRUE + SShuman_npcs.queue -= src + var/mob/living/carbon/human/npc/npc + if(spot_still_valid()) + if(context) + npc = spawn_npc_in_zone(npc_type, where, context, finalize = FALSE, constructor_args = list(src)) + else + npc = new npc_type(where, src) + if(QDELETED(npc)) + release() + return null + spawned_ref = WEAKREF(npc) + if(dir) + npc.setDir(dir) + SShuman_npcs.spawned_total++ + on_spawned?.Invoke(npc) + context?.finalize() + release() + return npc + +/// Marks a human NPC as admin-spawned (spawn_human_npcs verb). +/proc/human_npc_mark_admin_spawned(mob/living/carbon/human/npc/npc) + npc.flags_1 |= ADMIN_SPAWNED_1 + +SUBSYSTEM_DEF(human_npcs) + name = "Human NPCs" + flags = SS_NO_INIT + wait = 1 + runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT + /// Orders waiting to be built, oldest first + var/list/datum/human_npc_order/queue = list() + /// Dead human NPCs whose corpses may be cleaned up + var/list/mob/living/carbon/human/npc/corpses = list() + /// The corpses this sweep still has to look at + var/list/mob/living/carbon/human/npc/corpse_run = list() + /// world.time of the next corpse sweep + var/next_sweep = 0 + /// Human NPCs built this round + var/spawned_total = 0 + /// Corpses cleaned up this round + var/faded_total = 0 + /// Living NPCs walking out (npc_walk_out()) + var/list/mob/living/carbon/human/npc/leavers = list() + /// world.time of the next check of the leavers + var/next_leaver_sweep = 0 + /// NPCs that walked out this round + var/left_total = 0 + +/datum/controller/subsystem/human_npcs/stat_entry(msg) + msg = "Q:[length(queue)]|Made:[spawned_total]|Bodies:[length(corpses)]|Faded:[faded_total]|Leaving:[length(leavers)]|Left:[left_total]" + return ..() + +/datum/controller/subsystem/human_npcs/fire(resumed = FALSE) + if(length(queue)) + process_spawns(HUMAN_NPC_SPAWNS_PER_FIRE) + if(MC_TICK_CHECK) + return + if(length(leavers) && world.time >= next_leaver_sweep) + next_leaver_sweep = world.time + HUMAN_NPC_LEAVER_SWEEP_INTERVAL + sweep_leavers() + if(MC_TICK_CHECK) + return + if(!length(corpse_run)) + if(world.time < next_sweep || !length(corpses)) + return + next_sweep = world.time + HUMAN_NPC_CORPSE_SWEEP_INTERVAL + corpse_run = corpses.Copy() + var/deleted = 0 + while(length(corpse_run)) + var/mob/living/carbon/human/npc/body = corpse_run[length(corpse_run)] + corpse_run.len-- + if(QDELETED(body)) + corpses -= body + continue + if(body.npc_corpse_expired()) + body.npc_fade() + faded_total++ + deleted++ + if(deleted >= HUMAN_NPC_CORPSE_DELETES_PER_FIRE || MC_TICK_CHECK) + return + +/// Builds up to `budget` queued NPCs, oldest first, passing over orders still waiting for their zone. +/// Returns how many it built. +/datum/controller/subsystem/human_npcs/proc/process_spawns(budget = HUMAN_NPC_SPAWNS_PER_FIRE) + . = 0 + var/index = 1 + while(index <= length(queue) && . < budget) + var/datum/human_npc_order/order = queue[index] + if(QDELETED(order) || order.done) + queue.Cut(index, index + 1) + continue + if(!order.ready()) + index++ + continue + queue.Cut(index, index + 1) + if(order.fulfil()) + .++ + +/// Deletes the NPCs walking out that may go now (npc_may_vanish()). +/datum/controller/subsystem/human_npcs/proc/sweep_leavers() + for(var/mob/living/carbon/human/npc/leaver as anything in leavers.Copy()) + if(QDELETED(leaver) || leaver.stat == DEAD) + leavers -= leaver + continue + if(leaver.npc_may_vanish()) + leaver.npc_vanish() + left_total++ + +/datum/controller/subsystem/human_npcs/proc/track_corpse(mob/living/carbon/human/npc/body) + corpses |= body + +/datum/controller/subsystem/human_npcs/proc/forget_corpse(mob/living/carbon/human/npc/body) + corpses -= body + corpse_run -= body + +/** + * Map placement for a human NPC: queues `npc_type` here when the map loads, so a ruin full of them + * builds over several ticks. + */ +/obj/effect/spawner/human_npc + name = "human NPC spawner" + icon = 'icons/effects/mapping_helpers.dmi' + icon_state = "mobspawner" + /// The /mob/living/carbon/human/npc typepath to spawn + var/npc_type + /// A name for this one NPC (a mapped character), or null for its type's + var/npc_name + /// Factions for this one NPC (a mapped camp's own side), or null for its type's + var/list/npc_faction + /// The family root this type is: never mapped and places nothing, so it may have no npc_type. A + /// family's own root subtype sets this to itself (tests make one of every type). + var/abstract_spawner_type = /obj/effect/spawner/human_npc + +/obj/effect/spawner/human_npc/Initialize(mapload) + . = ..() + if(!ispath(npc_type, /mob/living/carbon/human/npc)) + if(type != abstract_spawner_type) + stack_trace("[type] at [AREACOORD(src)] has no human NPC type to spawn") + return +#ifdef UNIT_TESTS + // The create-and-destroy test makes one of every type on one tile; it isn't a map, so place nothing. + if(GLOB.running_create_and_destroy) + 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) diff --git a/voidcrew/modules/human_npcs/human_npc_spike_harness.dm b/voidcrew/modules/human_npcs/human_npc_spike_harness.dm new file mode 100644 index 00000000000..894b95afc05 --- /dev/null +++ b/voidcrew/modules/human_npcs/human_npc_spike_harness.dm @@ -0,0 +1,568 @@ +// Measurement harness for the human NPC spike. Compiled only with -DHUMAN_NPC_SPIKE_HARNESS; +// nothing here exists in a normal build. +// +// Boots a clientless world, starts the round, builds a walled, lit, breathable test room in a +// turf reservation, then spawns NPCs of one kind (world.params "spike_kind": human, +// human_untrimmed or trooper) in steps of 20, 50 and 100. At each step it measures them dormant +// (no player on their z-level), awake with nothing to fight, and in combat against damage-proof +// human dummies; then their corpses; then a 25 vs 25 fight to the death. Results go to +// data/human_npc_spike__*: a CSV of per-phase numbers, BYOND profiler dumps, and instance +// censuses. The current phase name is written to data/human_npc_spike__phase.txt so an +// outside sampler can tag process memory readings with it. +#ifdef HUMAN_NPC_SPIKE_HARNESS + +/// Mobs the harness spawned and controls, assoc mob -> TRUE. +GLOBAL_LIST_EMPTY(human_npc_spike_mobs) +/// Whether the harness pretends a player is on the test room's z-level. +GLOBAL_VAR_INIT(human_npc_spike_awake, FALSE) +/// Human NPC Life() calls that got past the dormancy guard (counted in human_npc.dm under this define). +GLOBAL_VAR_INIT(human_npc_spike_life_passes, 0) + +/// Same NPC with every Life() trim switched off, to measure what the trims save. +/mob/living/carbon/human/npc/sample/laser/spike_untrimmed + npc_trim_life = FALSE + +/mob/living/carbon/human/npc/npc_players_on_level() + if(GLOB.human_npc_spike_mobs[src]) + return GLOB.human_npc_spike_awake + return ..() + +// A clientless world has no clients on any z-level, so every AI would be off. While "awake", the +// harness's own mobs get the status a mob near a player would get. +/datum/ai_controller/get_expected_ai_status() + if(GLOB.human_npc_spike_awake && GLOB.human_npc_spike_mobs[pawn]) + var/mob/living/living_pawn = pawn + if(living_pawn.stat != DEAD && able_to_run && !on_failed_planning_timeout && isturf(living_pawn.loc) && !living_pawn.client) + return AI_STATUS_ON + return ..() + +#define SPIKE_ROOM_W 30 +#define SPIKE_ROOM_H 36 + +SUBSYSTEM_DEF(human_npc_spike) + name = "Human NPC Spike Harness" + flags = SS_NO_FIRE + /// human, human_untrimmed or trooper + var/kind = "human" + var/mob_type + var/out_prefix + var/csv_path + var/phase_path + var/datum/turf_reservation/reservation + /// Bottom-left floor turf of the test room. + var/turf/origin + var/list/turf/room_turfs = list() + var/list/mob/living/npcs = list() + var/list/mob/living/dummies = list() + +/datum/controller/subsystem/human_npc_spike/Initialize() + Master.sleep_offline_after_initializations = FALSE + var/list/params = world.params + kind = params?["spike_kind"] || "human" + switch(kind) + if("trooper") + mob_type = /mob/living/basic/trooper/pirate/ranged + if("human_untrimmed") + mob_type = /mob/living/carbon/human/npc/sample/laser/spike_untrimmed + else + kind = "human" + mob_type = /mob/living/carbon/human/npc/sample/laser + if(params?["spike_mode"] == "dormancy") + kind = "[kind]_dormancy" + out_prefix = "data/human_npc_spike_[kind]" + csv_path = "[out_prefix]_results.csv" + phase_path = "[out_prefix]_phase.txt" + fdel(csv_path) + rustg_file_write("kind,phase,n,metric,value\n", csv_path) + set_phase("init") + SSticker.start_immediately = TRUE + if(params?["spike_mode"] == "dormancy") + INVOKE_ASYNC(src, PROC_REF(run_dormancy_proof)) + else + INVOKE_ASYNC(src, PROC_REF(run_spike)) + return SS_INIT_SUCCESS + +/datum/controller/subsystem/human_npc_spike/proc/set_phase(label) + rustg_file_write(label, phase_path) + log_world("human_npc_spike: phase [label]") + +/datum/controller/subsystem/human_npc_spike/proc/record(phase, n, metric, value) + rustg_file_append("[kind],[phase],[n],[metric],[value]\n", csv_path) + +/datum/controller/subsystem/human_npc_spike/proc/run_spike() + UNTIL(SSticker.current_state == GAME_STATE_PLAYING) + SSticker.delay_end = TRUE + SSprofiler.can_fire = FALSE + world.Profile(PROFILE_STOP) + set_phase("settle_roundstart") + sleep(60 SECONDS) + if(!build_room()) + set_phase("failed_room") + return + sleep(10 SECONDS) + census("baseline") + measure("baseline", 0, 30 SECONDS) + profile("baseline", 0, 15 SECONDS) + + for(var/n in list(20, 50, 100)) + spawn_npcs_to(n) + set_awake(FALSE) + settle("spawned", n, 20 SECONDS) + if(n == 100) + census("spawned_100") + measure("dormant", n, 30 SECONDS) + set_awake(TRUE) + settle("awake_settle", n, 10 SECONDS) + measure("awake", n, 30 SECONDS) + profile("awake", n, 15 SECONDS) + spawn_dummies() + settle("combat_settle", n, 10 SECONDS) + measure("combat", n, 45 SECONDS) + profile("combat", n, 15 SECONDS) + clear_dummies() + set_awake(FALSE) + settle("post_combat", n, 10 SECONDS) + clear_debris() + + bulk_memory(400) + + // Corpses: kill every NPC the way a fight would, then measure the bodies left behind. + set_awake(TRUE) + kill_npcs() + settle("corpse_settle", 100, 20 SECONDS) + census("corpses_100") + measure("corpses_awake", 100, 30 SECONDS) + profile("corpses_awake", 100, 15 SECONDS) + set_awake(FALSE) + measure("corpses_dormant", 100, 30 SECONDS) + clear_room() + settle("cleared", 0, 20 SECONDS) + census("cleared") + + team_fight(25) + settle("after_fight", 0, 10 SECONDS) + clear_room() + settle("cleared_fight", 0, 15 SECONDS) + + bench_spawn_and_kill(20) + clear_room() + settle("cleared_bench", 0, 10 SECONDS) + bench_hits(/obj/projectile/bullet/c9mm, 150) + bench_hits(/obj/projectile/beam/laser, 150) + clear_room() + settle("cleared_hits", 0, 15 SECONDS) + + // The same fight again under the profiler, to see where its time goes. + world.Profile(PROFILE_CLEAR) + world.Profile(PROFILE_START) + team_fight(25, "fight_profiled") + var/fight_profile = world.Profile(PROFILE_REFRESH, format = "json") + world.Profile(PROFILE_STOP) + rustg_file_write(fight_profile, "[out_prefix]_profile_fight_25.json") + settle("after_fight_profiled", 0, 10 SECONDS) + set_phase("done") + +/** + * spike_mode=dormancy: a short run for the production base. Queues 100 NPCs through + * spawn_human_npc() and records how many were built per tick, then measures their Life() and AI + * cost dormant, awake, and as corpses without and with a player on the z-level, counting the Life() + * calls that got past the dormancy guard in each phase, and checks that a waking corpse catches up + * the organ decay it slept through. + */ +/datum/controller/subsystem/human_npc_spike/proc/run_dormancy_proof() + UNTIL(SSticker.current_state == GAME_STATE_PLAYING) + SSticker.delay_end = TRUE + SSprofiler.can_fire = FALSE + world.Profile(PROFILE_STOP) + set_phase("settle_roundstart") + sleep(45 SECONDS) + if(!build_room()) + set_phase("failed_room") + return + sleep(10 SECONDS) + census("baseline") + measure("baseline", 0, 20 SECONDS) + queue_npcs(100) + set_awake(FALSE) + settle("spawned", 100, 15 SECONDS) + life_phase("dormant", 100, 30 SECONDS) + set_awake(TRUE) + settle("awake_settle", 100, 5 SECONDS) + life_phase("awake", 100, 30 SECONDS) + kill_npcs() + set_awake(FALSE) + settle("corpse_settle", 100, 10 SECONDS) + life_phase("corpses_dormant", 100, 30 SECONDS) + var/mob/living/carbon/human/sample_corpse + for(var/mob/living/carbon/human/npc/body as anything in npcs) + if(!QDELETED(body) && body.stat == DEAD) + sample_corpse = body + break + var/obj/item/organ/brain/brain = sample_corpse?.get_organ_slot(ORGAN_SLOT_BRAIN) + record("decay", 100, "brain_damage_asleep", brain?.damage) + set_awake(TRUE) + life_phase("corpses_awake", 100, 30 SECONDS) + record("decay", 100, "brain_damage_after_waking", brain?.damage) + set_phase("done") + +/// Queues `count` NPCs through the production spawn queue and records how fast it builds them. +/datum/controller/subsystem/human_npc_spike/proc/queue_npcs(count) + set_phase("queueing_[count]") + var/start_built = SShuman_npcs.spawned_total + var/start_time = world.time + var/first_slot = length(npcs) + for(var/i in 1 to count) + spawn_human_npc(mob_type, npc_slot(first_slot + i), on_spawned = CALLBACK(src, PROC_REF(adopt_npc))) + var/most_in_one_tick = 0 + var/last_built = start_built + var/ticks = 0 + while(SShuman_npcs.spawned_total - start_built < count && ticks < 4000) + sleep(world.tick_lag) + ticks++ + most_in_one_tick = max(most_in_one_tick, SShuman_npcs.spawned_total - last_built) + last_built = SShuman_npcs.spawned_total + record("spawn_queue", count, "built", SShuman_npcs.spawned_total - start_built) + record("spawn_queue", count, "ticks", ticks) + record("spawn_queue", count, "seconds", (world.time - start_time) / 10) + record("spawn_queue", count, "most_built_in_one_tick", most_in_one_tick) + +/datum/controller/subsystem/human_npc_spike/proc/adopt_npc(mob/living/npc) + npcs += npc + GLOB.human_npc_spike_mobs[npc] = TRUE + RegisterSignal(npc, COMSIG_QDELETING, PROC_REF(forget_mob)) + +/// measure(), plus how many Life() calls got past the dormancy guard. +/datum/controller/subsystem/human_npc_spike/proc/life_phase(label, n, duration) + GLOB.human_npc_spike_life_passes = 0 + var/start = world.time + measure(label, n, duration) + var/seconds = max((world.time - start) / 10, 1) + record(label, n, "life_passes", GLOB.human_npc_spike_life_passes) + record(label, n, "life_passes_per_npc_per_s", GLOB.human_npc_spike_life_passes / max(n, 1) / seconds) + +/datum/controller/subsystem/human_npc_spike/proc/settle(label, n, duration) + set_phase("[label]_[n]") + sleep(duration) + +/datum/controller/subsystem/human_npc_spike/proc/build_room() + reservation = SSmapping.request_turf_block_reservation(SPIKE_ROOM_W + 8, SPIKE_ROOM_H + 8, requester = "human NPC spike harness") + if(!reservation) + log_world("human_npc_spike: no reservation") + return FALSE + var/turf/bottom_left = reservation.bottom_left_turfs[1] + origin = locate(bottom_left.x + 4, bottom_left.y + 4, bottom_left.z) + var/area/misc/testroom/room_area = GLOB.areas_by_type[/area/misc/testroom] || new + for(var/dx in -1 to SPIKE_ROOM_W) + for(var/dy in -1 to SPIKE_ROOM_H) + var/turf/spot = locate(origin.x + dx, origin.y + dy, origin.z) + var/edge = dx == -1 || dy == -1 || dx == SPIKE_ROOM_W || dy == SPIKE_ROOM_H + if(edge) + spot = spot.ChangeTurf(/turf/closed/indestructible) + else + spot = spot.ChangeTurf(/turf/open/floor/iron) + room_turfs += spot + spot.change_area(spot.loc, room_area) + CHECK_TICK + record("room", 0, "z", origin.z) + return TRUE + +/// Spawn slot `index` (1-100): four columns, 25 rows, front column first. +/datum/controller/subsystem/human_npc_spike/proc/npc_slot(index, x_front = 9, x_step = -1) + var/col = round((index - 1) / 25) + var/row = (index - 1) % 25 + return locate(origin.x + x_front + col * x_step, origin.y + 5 + row, origin.z) + +/datum/controller/subsystem/human_npc_spike/proc/add_npc(turf/where, list/faction) + var/mob/living/npc = new mob_type(where) + if(faction) + npc.faction = faction.Copy() + npcs += npc + GLOB.human_npc_spike_mobs[npc] = TRUE + RegisterSignal(npc, COMSIG_QDELETING, PROC_REF(forget_mob)) + return npc + +/datum/controller/subsystem/human_npc_spike/proc/forget_mob(mob/living/gone) + SIGNAL_HANDLER + npcs -= gone + dummies -= gone + GLOB.human_npc_spike_mobs -= gone + +/datum/controller/subsystem/human_npc_spike/proc/spawn_npcs_to(n) + set_phase("spawning_[n]") + while(length(npcs) < n) + add_npc(npc_slot(length(npcs) + 1)) + CHECK_TICK + record("spawn", n, "npcs", length(npcs)) + if(length(npcs)) + var/mob/living/sample = npcs[1] + record("spawn", n, "atoms_in_one_npc", length(sample.get_all_contents())) + +/datum/controller/subsystem/human_npc_spike/proc/set_awake(awake) + GLOB.human_npc_spike_awake = awake + for(var/mob/living/npc as anything in GLOB.human_npc_spike_mobs) + var/datum/ai_controller/controller = npc.ai_controller + if(!controller) + continue + controller.can_idle = !awake + controller.reset_ai_status() + +/// BYOND reuses freed heap, so a few dozen mobs barely move the process's private bytes. Spawns +/// `count` more dormant NPCs in the free half of the room so the outside sampler sees a real step, +/// counts the world, then deletes them again. +/datum/controller/subsystem/human_npc_spike/proc/bulk_memory(count) + set_phase("bulk_spawning") + set_awake(FALSE) + var/list/bulk = list() + for(var/i in 1 to count) + var/turf/where = locate(origin.x + 12 + (i - 1) % 18, origin.y + round((i - 1) / 18), origin.z) + bulk += add_npc(where) + CHECK_TICK + settle("bulk", length(npcs), 25 SECONDS) + census("bulk_[length(npcs)]") + settle("bulk_after_census", length(npcs), 15 SECONDS) + set_phase("bulk_deleting") + for(var/mob/living/npc as anything in bulk) + qdel(npc) + CHECK_TICK + settle("bulk_deleted", length(npcs), 30 SECONDS) + +/// Damage-proof clientless humans the NPCs see as hostile. Every hit lands and is processed, but +/// deals nothing, so they never fall and the fight never ends. +/datum/controller/subsystem/human_npc_spike/proc/spawn_dummies() + for(var/k in 0 to 4) + var/turf/where = locate(origin.x + 11, origin.y + 6 + k * 6, origin.z) + var/mob/living/carbon/human/dummy_target = new(where) + dummy_target.faction = list("spike_target") + var/datum/physiology/body = dummy_target.physiology + body.brute_mod = 0 + body.burn_mod = 0 + body.tox_mod = 0 + body.oxy_mod = 0 + body.stamina_mod = 0 + body.bleed_mod = 0 + dummies += dummy_target + RegisterSignal(dummy_target, COMSIG_QDELETING, PROC_REF(forget_mob)) + +/datum/controller/subsystem/human_npc_spike/proc/clear_dummies() + for(var/mob/living/dummy_target as anything in dummies.Copy()) + qdel(dummy_target) + dummies.Cut() + +/// Deletes blood, casings, dropped items and scorch marks left on the floor. +/datum/controller/subsystem/human_npc_spike/proc/clear_debris() + var/removed = 0 + for(var/turf/spot as anything in room_turfs) + for(var/atom/movable/thing as anything in spot) + if(istype(thing, /obj/effect/decal) || isitem(thing)) + qdel(thing) + removed++ + CHECK_TICK + record("debris", length(npcs), "removed", removed) + +/// Deletes everything in the room that isn't a client's mob. +/datum/controller/subsystem/human_npc_spike/proc/clear_room() + for(var/turf/spot as anything in room_turfs) + for(var/atom/movable/thing as anything in spot) + if(ismob(thing)) + var/mob/thing_mob = thing + if(thing_mob.client) + continue + qdel(thing) + CHECK_TICK + npcs.Cut() + GLOB.human_npc_spike_mobs.Cut() + +/// Kills every NPC with a big chest hit, as a fight would. Troopers leave their human corpse. +/datum/controller/subsystem/human_npc_spike/proc/kill_npcs() + set_phase("killing") + for(var/mob/living/npc as anything in npcs.Copy()) + if(QDELETED(npc)) + continue + npc.apply_damage(300, BRUTE, BODY_ZONE_CHEST) + if(!QDELETED(npc) && npc.stat != DEAD) + npc.death() + CHECK_TICK + var/corpses = 0 + for(var/turf/spot as anything in room_turfs) + for(var/mob/living/body in spot) + if(body.stat == DEAD) + corpses++ + record("corpses", 100, "corpses_in_room", corpses) + +/// Times making `count` NPCs one by one, then killing each with one big hit (a trooper's kill +/// includes building its human corpse). A synchronous call can't span ticks, so the tick usage +/// delta of each call is its whole cost. +/datum/controller/subsystem/human_npc_spike/proc/bench_spawn_and_kill(count) + set_phase("bench_spawn_kill") + set_awake(FALSE) + var/list/made = list() + var/spawn_usage = 0 + for(var/i in 1 to count) + var/turf/where = npc_slot(i) + var/start = TICK_USAGE_REAL + made += add_npc(where) + spawn_usage += TICK_USAGE_REAL - start + stoplag() + var/kill_usage = 0 + for(var/mob/living/npc as anything in made) + if(QDELETED(npc)) + continue + var/start = TICK_USAGE_REAL + npc.apply_damage(300, BRUTE, BODY_ZONE_CHEST) + if(!QDELETED(npc) && npc.stat != DEAD) + npc.death() + kill_usage += TICK_USAGE_REAL - start + stoplag() + record("bench", count, "ms_per_spawn", TICK_DELTA_TO_MS(spawn_usage) / count) + record("bench", count, "ms_per_kill", TICK_DELTA_TO_MS(kill_usage) / count) + +/// Times `hits` hits of `projectile_type` from a human shooter on NPCs of the kind under test, +/// aimed at random zones. Each hit is processed the way a fired projectile's impact is (armour +/// check, bullet_act, wounds, gore). Damage carries between hits; an NPC that drops to hard crit +/// or dies is replaced, untimed. +/datum/controller/subsystem/human_npc_spike/proc/bench_hits(projectile_type, hits) + set_phase("bench_hits") + set_awake(FALSE) + var/turf/shooter_turf = locate(origin.x + 20, origin.y + 18, origin.z) + var/turf/target_turf = locate(origin.x + 20, origin.y + 20, origin.z) + var/mob/living/carbon/human/shooter = new(shooter_turf) + shooter.faction = list("spike_shooter") + var/mob/living/target + var/usage = 0 + var/replaced = 0 + for(var/i in 1 to hits) + if(QDELETED(target) || target.stat >= HARD_CRIT) + if(!QDELETED(target)) + qdel(target) + target = add_npc(target_turf) + replaced++ + var/obj/projectile/shot = new projectile_type(target_turf) + shot.firer = shooter + shot.fired_from = shooter + shot.starting = shooter_turf + shot.def_zone = human_npc_pick_aim_zone() + var/start = TICK_USAGE_REAL + target.projectile_hit(shot, shot.def_zone) + usage += TICK_USAGE_REAL - start + qdel(shot) + stoplag() + qdel(shooter) + var/projectile_name = replacetext("[projectile_type]", "/obj/projectile/", "") + record("bench", hits, "ms_per_hit:[projectile_name]", TICK_DELTA_TO_MS(usage) / hits) + record("bench", hits, "targets_used:[projectile_name]", replaced) + +/// Two teams of `per_side`, the kind under test on both, fight until one side is down. +/datum/controller/subsystem/human_npc_spike/proc/team_fight(per_side, label = "fight") + var/list/team_a = list() + var/list/team_b = list() + for(var/i in 1 to per_side) + team_a += add_npc(npc_slot(i, x_front = 9, x_step = -1), list("spike_a")) + team_b += add_npc(npc_slot(i, x_front = 13, x_step = 1), list("spike_b")) + settle("[label]_spawned", per_side, 10 SECONDS) + set_awake(TRUE) + var/datum/callback/fight_over = CALLBACK(src, PROC_REF(fight_over), team_a, team_b) + measure(label, per_side, 180 SECONDS, fight_over) + record(label, per_side, "a_standing", count_standing(team_a)) + record(label, per_side, "b_standing", count_standing(team_b)) + var/dead = 0 + for(var/turf/spot as anything in room_turfs) + for(var/mob/living/body in spot) + if(body.stat == DEAD) + dead++ + record(label, per_side, "dead_bodies", dead) + set_awake(FALSE) + +/datum/controller/subsystem/human_npc_spike/proc/count_standing(list/team) + . = 0 + for(var/mob/living/member as anything in team) + if(!QDELETED(member) && member.stat == CONSCIOUS) + .++ + +/datum/controller/subsystem/human_npc_spike/proc/fight_over(list/team_a, list/team_b) + return !count_standing(team_a) || !count_standing(team_b) + +/// Measures `duration` of play: world.cpu per tick, time dilation, and each subsystem's CPU time +/// from the MC's rolling usage, which records the real tick usage of every fire. +/datum/controller/subsystem/human_npc_spike/proc/measure(label, n, duration, datum/callback/stop_when) + set_phase("[label]_[n]") + for(var/datum/controller/subsystem/subsystem as anything in Master.subsystems) + subsystem.rolling_usage = list() + Master.rolling_usage_length = 30 MINUTES + Master.use_rolling_usage = TRUE + var/start_time = world.time + var/start_real = REALTIMEOFDAY + var/end_time = world.time + duration + var/list/cpu_samples = list() + var/map_cpu_sum = 0 + while(world.time < end_time) + sleep(world.tick_lag) + cpu_samples += world.cpu + map_cpu_sum += world.map_cpu + if(stop_when?.Invoke()) + break + Master.use_rolling_usage = FALSE + var/game_seconds = max((world.time - start_time) / 10, 0.1) + var/real_seconds = max((REALTIMEOFDAY - start_real) / 10, 0.1) + var/samples = max(length(cpu_samples), 1) + var/cpu_sum = 0 + for(var/sample in cpu_samples) + cpu_sum += sample + sortTim(cpu_samples, cmp = GLOBAL_PROC_REF(cmp_numeric_asc)) + record(label, n, "game_seconds", game_seconds) + record(label, n, "real_seconds", real_seconds) + record(label, n, "cpu_avg", cpu_sum / samples) + record(label, n, "cpu_p95", length(cpu_samples) ? cpu_samples[max(1, round(length(cpu_samples) * 0.95))] : 0) + record(label, n, "cpu_max", length(cpu_samples) ? cpu_samples[length(cpu_samples)] : 0) + record(label, n, "map_cpu_avg", map_cpu_sum / samples) + record(label, n, "mob_living_list", length(GLOB.mob_living_list)) + record(label, n, "ai_on", length(GLOB.ai_controllers_by_status[AI_STATUS_ON])) + record(label, n, "npcs_alive", count_alive()) + var/total_ms = 0 + for(var/datum/controller/subsystem/subsystem as anything in Master.subsystems) + var/list/usage = subsystem.rolling_usage + var/sum = 0 + for(var/i in 2 to length(usage) step 2) + sum += usage[i] + subsystem.rolling_usage = list() + if(!sum) + continue + var/ms_per_second = TICK_DELTA_TO_MS(sum) / game_seconds + total_ms += ms_per_second + record(label, n, "ss_ms_per_s:[subsystem.name]", ms_per_second) + record(label, n, "ss_total_ms_per_s", total_ms) + +/datum/controller/subsystem/human_npc_spike/proc/count_alive() + . = 0 + for(var/mob/living/npc as anything in npcs) + if(!QDELETED(npc) && npc.stat != DEAD) + .++ + +/// Runs the BYOND profiler for `duration` and saves its JSON. +/datum/controller/subsystem/human_npc_spike/proc/profile(label, n, duration) + set_phase("profile_[label]_[n]") + world.Profile(PROFILE_CLEAR) + world.Profile(PROFILE_START) + sleep(duration) + var/data = world.Profile(PROFILE_REFRESH, format = "json") + world.Profile(PROFILE_STOP) + rustg_file_write(data, "[out_prefix]_profile_[label]_[n].json") + +/// Counts every atom and datum in the world by type and saves the totals. +/datum/controller/subsystem/human_npc_spike/proc/census(label) + set_phase("census_[label]") + var/list/atoms = count_atoms() + var/list/datums = count_datums() + var/atom_total = 0 + for(var/key in atoms) + atom_total += atoms[key] + var/datum_total = 0 + for(var/key in datums) + datum_total += datums[key] + record("census_[label]", 0, "atoms_total", atom_total) + record("census_[label]", 0, "datums_total", datum_total) + rustg_file_write(json_encode(list("atoms" = atoms, "datums" = datums)), "[out_prefix]_census_[label].json") + +#undef SPIKE_ROOM_W +#undef SPIKE_ROOM_H + +#endif diff --git a/voidcrew/modules/human_npcs/human_npc_states.dm b/voidcrew/modules/human_npcs/human_npc_states.dm new file mode 100644 index 00000000000..279cc850d6e --- /dev/null +++ b/voidcrew/modules/human_npcs/human_npc_states.dm @@ -0,0 +1,108 @@ +/** + * # Shared state rules for human NPCs + * + * N4, out of the fight: one test for "this body isn't fighting any more", read from tg state, used by + * boarding waves and the pirate pool slot (owner ruling OC-7), hull turrets, bounty pay, and AI morale. + * + * N8, walking out: a living NPC that leaves (a goon running off, a decoy heading for the lift, a crewman + * abandoning a fight) walks to its exit for real. Shots land, wounds slow it, cuffs and grabs stop it. + * It is deleted only when it stands on its exit tile, or when no player is near enough to see it + * (human_npc_watched()), and never while it is down, cuffed, dragged, carried or buckled. There is no + * godmode beam. SShuman_npcs checks the NPCs that are leaving once a second. + */ + +/** + * Whether `body` is out of the fight: dead, in crit (tg's TRAIT_CRITICAL_CONDITION, soft or hard, + * asleep or not), or restrained (handcuffs, a straitjacket). Stamcrit and stuns pass, so they don't + * count. Works on any mob; a basic mob is out only once dead. + */ +/proc/human_npc_out_of_fight(mob/living/body) + if(QDELETED(body) || body.stat == DEAD) + return TRUE + return HAS_TRAIT(body, TRAIT_CRITICAL_CONDITION) || HAS_TRAIT(body, TRAIT_RESTRAINED) + +// ===== Walking out ===== + +/** + * Sends it walking to `exit` (an atom; its turf is used). It is deleted on that tile, or wherever nobody + * can see it (npc_may_vanish()). `on_left`, if given, is called with it just before it goes, after + * COMSIG_HUMAN_NPC_LEFT. Call npc_stop_leaving() to call it back. + */ +/mob/living/carbon/human/npc/proc/npc_walk_out(atom/exit, datum/callback/on_left) + var/turf/exit_turf = get_turf(exit) + if(isnull(exit_turf) || stat == DEAD) + return FALSE + npc_exit = exit_turf + npc_on_left = on_left + SShuman_npcs.leavers |= src + if(istype(ai_controller)) + ai_controller.set_blackboard_key(BB_HUMAN_NPC_EXIT, exit_turf) + // The way out may be round corners: walk it with a pathfinder, as a person would. + human_npc_set_ai_movement(ai_controller, /datum/ai_movement/jps) + return TRUE + +/// Calls off its walk out. +/mob/living/carbon/human/npc/proc/npc_stop_leaving() + npc_exit = null + npc_on_left = null + SShuman_npcs.leavers -= src + if(istype(ai_controller)) + ai_controller.clear_blackboard_key(BB_HUMAN_NPC_EXIT) + human_npc_set_ai_movement(ai_controller, initial(ai_controller.ai_movement)) + +/** + * Whether a living NPC that is leaving may be deleted now: up and free (not in crit, not cuffed, not + * stunned, not dragged, carried or buckled, standing on a turf), and either on its exit tile or out of + * sight of every player. + */ +/mob/living/carbon/human/npc/proc/npc_may_vanish() + if(isnull(npc_exit) || stat != CONSCIOUS || human_npc_out_of_fight(src)) + return FALSE + if(INCAPACITATED_IGNORING(src, NONE) || pulledby || buckled || !isturf(loc)) + return FALSE + return get_turf(src) == npc_exit || !human_npc_watched(src) + +/// Switches a controller's movement type, stopping any walk the old one was doing. +/proc/human_npc_set_ai_movement(datum/ai_controller/controller, datum/ai_movement/movement_type) + if(!ispath(movement_type, /datum/ai_movement)) + return + if(controller.ai_movement?.moving_controllers[controller]) + controller.ai_movement.stop_moving_towards(controller) + controller.change_ai_movement_type(movement_type) + +/// It has left: what it carries that isn't gear drops where it stood, and it is deleted with its kit. +/mob/living/carbon/human/npc/proc/npc_vanish() + SShuman_npcs.leavers -= src + SEND_SIGNAL(src, COMSIG_HUMAN_NPC_LEFT) + npc_on_left?.Invoke(src) + npc_on_left = null + npc_drop_not_gear() + qdel(src) + +/// While it has somewhere to walk out to, it walks there and does nothing else. +/datum/ai_planning_subtree/human_npc_walk_out + +/datum/ai_planning_subtree/human_npc_walk_out/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/npc = controller.pawn + if(npc.stat != CONSCIOUS || !controller.blackboard_key_exists(BB_HUMAN_NPC_EXIT)) + return + controller.queue_behavior(/datum/ai_behavior/human_npc_walk_out, BB_HUMAN_NPC_EXIT) + return SUBTREE_RETURN_FINISH_PLANNING + +/// Walks to the exit. SShuman_npcs deletes it when it may go (npc_may_vanish()). +/datum/ai_behavior/human_npc_walk_out + required_distance = 0 + action_cooldown = 1 SECONDS + behavior_flags = AI_BEHAVIOR_REQUIRE_MOVEMENT | AI_BEHAVIOR_MOVE_AND_PERFORM | AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/human_npc_walk_out/setup(datum/ai_controller/controller, exit_key) + . = ..() + var/turf/exit = controller.blackboard[exit_key] + if(isnull(exit)) + return FALSE + set_movement_target(controller, exit) + +/datum/ai_behavior/human_npc_walk_out/perform(seconds_per_tick, datum/ai_controller/controller, exit_key) + if(!controller.blackboard_key_exists(exit_key)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_DELAY diff --git a/voidcrew/modules/human_npcs/human_npc_surrender.dm b/voidcrew/modules/human_npcs/human_npc_surrender.dm new file mode 100644 index 00000000000..93c8f3b7f9b --- /dev/null +++ b/voidcrew/modules/human_npcs/human_npc_surrender.dm @@ -0,0 +1,161 @@ +/** + * # Human NPC surrender (N2) + * + * Giving up is an AI choice followed by the same action a player takes (defaults 1.3, decision D3): + * 1. The NPC weighs its odds (a /datum/human_npc_surrender on its npc_surrender: how hurt it is, how many + * hostiles are on it, how many friends are still standing). + * 2. On a yes it stows the weapons in its hands in its own belt, bag, holster or suit storage. Its gear + * is locked (D3), so it never drops them; one with nowhere to put a gun keeps holding it, hands blocked. + * 3. It says its surrender line and runs tg's *surrender emote, a real 20 second Paralyze. That is the + * cuff window: tg cuffs (4 s) work on it like on anyone. + * 4. When the Paralyze ends and nobody cuffed it, it decides again at once: give up again, or (if its + * rules say so) run from the nearest hostile for a while, or fight on. + * There is no surrender state, trait or mark: what players see and act on is tg's Paralyze and cuffs. + * + * A family picks the numbers with a subtype, and overrides hurt_enough(), should_consider() or odds() + * for its own rules (the kingpin only once his crew is down; convicts the moment they are sighted, so + * hurt_enough() is always TRUE for them). Code that wants an NPC to give up at once calls + * npc_surrender() itself. + */ + +/// A family's surrender rules. One shared instance per type (human_npc_singleton()). +/datum/human_npc_surrender + /// Percent chance on the first roll of a fight + var/chance = 60 + /// Percent chance on later rolls + var/retry_chance = 25 + /// Percent taken off the chance for each friend still standing near it + var/ally_penalty = 20 + /// It considers giving up only at or below this share of its health + var/health_share = 0.4 + /// ...and only with at least this many hostiles near it + var/hostiles_needed = 2 + /// How far it looks for hostiles and friends, in tiles + var/range = 7 + /// Time between two rolls + var/retry_delay = 5 SECONDS + /// When a surrender's paralysis ends uncuffed and it decides not to give up again: run (TRUE), or fight on + var/flees = TRUE + /// How long it runs for + var/flee_time = 20 SECONDS + +/// Whether `npc` is in a bad enough way to think about giving up. Cheap: checked before it looks around. +/datum/human_npc_surrender/proc/hurt_enough(mob/living/carbon/human/npc/npc) + return npc.health <= npc.maxHealth * health_share + +/// Whether, having looked around, it thinks about giving up. +/datum/human_npc_surrender/proc/should_consider(mob/living/carbon/human/npc/npc, list/hostiles, list/allies) + return length(hostiles) >= hostiles_needed + +/// Percent chance it gives up on this roll. `first` is TRUE for its first roll of the fight. +/datum/human_npc_surrender/proc/odds(mob/living/carbon/human/npc/npc, list/hostiles, list/allies, first) + if(!length(hostiles)) + return 0 + return clamp((first ? chance : retry_chance) - ally_penalty * length(allies), 0, 100) + +/// The living hostiles near `npc` that are still in the fight and that it can see. +/datum/human_npc_surrender/proc/hostiles_near(mob/living/carbon/human/npc/npc) + . = list() + for(var/mob/living/other in oview(range, npc)) + if(other.faction_check_atom(npc) || human_npc_out_of_fight(other)) + continue + if(other.client || other.ai_controller?.blackboard[BB_BASIC_MOB_CURRENT_TARGET] == npc || npc.ai_controller?.blackboard[BB_BASIC_MOB_CURRENT_TARGET] == other) + . += other + +/// Its friends near it that are still standing. +/datum/human_npc_surrender/proc/allies_near(mob/living/carbon/human/npc/npc) + . = list() + for(var/mob/living/other in oview(range, npc)) + if(other.client || !npc.faction_check_atom(other) || human_npc_out_of_fight(other)) + continue + if(other.body_position == LYING_DOWN) + continue + . += other + +/// The rules it surrenders by, or null if it never does. +/mob/living/carbon/human/npc/proc/npc_surrender_rules() + if(!ispath(npc_surrender, /datum/human_npc_surrender)) + return null + return human_npc_singleton(npc_surrender) + +/** + * Gives up now, the way a player does: weapons stowed, its surrender line, tg's *surrender (a 20 second + * Paralyze). Returns TRUE if it is lying there with its hands on its head. + */ +/mob/living/carbon/human/npc/proc/npc_surrender() + if(stat != CONSCIOUS || HAS_TRAIT(src, TRAIT_RESTRAINED) || npc_surrendering) + return FALSE + npc_stow_weapons() + npc_bark(HUMAN_NPC_BARK_SURRENDER, force = TRUE) + npc_surrendering = TRUE + emote("surrender", intentional = TRUE) + if(!IsParalyzed()) + npc_surrendering = FALSE + return FALSE + npc_surrender_count++ + SEND_SIGNAL(src, COMSIG_HUMAN_NPC_SURRENDERED) + return TRUE + +/// Puts the weapons in its hands away on its body. D3: never on the floor. +/mob/living/carbon/human/npc/proc/npc_stow_weapons() + for(var/obj/item/held in held_items) + if(isgun(held) || human_npc_is_melee_weapon(held)) + held.equip_to_best_slot(src) + +/// Its surrender's paralysis is over. Cuffed: taken, nothing to decide. Otherwise it decides again. +/mob/living/carbon/human/npc/proc/npc_surrender_ended() + if(IsParalyzed()) + return + npc_surrendering = FALSE + if(stat != CONSCIOUS || HAS_TRAIT(src, TRAIT_RESTRAINED)) + return + npc_surrender_redecide = TRUE + SEND_SIGNAL(src, COMSIG_HUMAN_NPC_SURRENDER_ENDED) + +/** + * Rolls to give up when its rules say it is losing, and decides again straight after a surrender + * nobody took. Put it after escape_captivity and before targeting in any controller whose pawn is a + * human NPC. + */ +/datum/ai_planning_subtree/human_npc_surrender + +/datum/ai_planning_subtree/human_npc_surrender/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/human/npc/npc = controller.pawn + if(!ishumannpc(npc) || npc.stat != CONSCIOUS || HAS_TRAIT(npc, TRAIT_RESTRAINED)) + return + var/datum/human_npc_surrender/rules = npc.npc_surrender_rules() + if(isnull(rules)) + return + // Running after walking away from a surrender. + if(world.time < controller.blackboard[BB_HUMAN_NPC_FLEE_UNTIL] && controller.blackboard_key_exists(BB_HUMAN_NPC_FLEE_FROM)) + controller.queue_behavior(/datum/ai_behavior/run_away_from_target, BB_HUMAN_NPC_FLEE_FROM) + return SUBTREE_RETURN_FINISH_PLANNING + var/redecide = npc.npc_surrender_redecide + if(!redecide && (world.time < npc.npc_next_surrender_roll || !rules.hurt_enough(npc))) + return + // Looking around costs, so it looks at most once per retry_delay. + npc.npc_next_surrender_roll = world.time + rules.retry_delay + npc.npc_surrender_redecide = FALSE + var/list/hostiles = rules.hostiles_near(npc) + var/list/allies = rules.allies_near(npc) + if(!redecide && !rules.should_consider(npc, hostiles, allies)) + return + var/first = !npc.npc_surrender_rolls + npc.npc_surrender_rolls++ + if(prob(rules.odds(npc, hostiles, allies, first))) + controller.queue_behavior(/datum/ai_behavior/human_npc_surrender) + return SUBTREE_RETURN_FINISH_PLANNING + if(redecide && rules.flees && length(hostiles)) + controller.set_blackboard_key(BB_HUMAN_NPC_FLEE_FROM, get_closest_atom(/mob/living, hostiles, npc)) + controller.set_blackboard_key(BB_HUMAN_NPC_FLEE_UNTIL, world.time + rules.flee_time) + controller.queue_behavior(/datum/ai_behavior/run_away_from_target, BB_HUMAN_NPC_FLEE_FROM) + return SUBTREE_RETURN_FINISH_PLANNING + +/// Gives up (npc_surrender()). +/datum/ai_behavior/human_npc_surrender + +/datum/ai_behavior/human_npc_surrender/perform(seconds_per_tick, datum/ai_controller/controller) + var/mob/living/carbon/human/npc/npc = controller.pawn + if(!ishumannpc(npc) || !npc.npc_surrender()) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED diff --git a/voidcrew/modules/hyperviolence/finishers/finisher_ai.dm b/voidcrew/modules/hyperviolence/finishers/finisher_ai.dm index eae237a1596..a02648f4ab3 100644 --- a/voidcrew/modules/hyperviolence/finishers/finisher_ai.dm +++ b/voidcrew/modules/hyperviolence/finishers/finisher_ai.dm @@ -67,6 +67,7 @@ /proc/hv_finisher_add_subtree(datum/ai_controller/controller) var/static/list/goes_first = typecacheof(list( /datum/ai_planning_subtree/call_reinforcements, + /datum/ai_planning_subtree/human_npc_soft_crit, /datum/ai_planning_subtree/pirate_crew_find_target, /datum/ai_planning_subtree/escape_captivity, /datum/ai_planning_subtree/pet_planning, diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index cdd44f88f78..e54bb378b3d 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -95,6 +95,8 @@ #include "voidcrew_helpers.dm" #include "voidcrew_hull_containment.dm" #include "voidcrew_hull_survey.dm" +#include "voidcrew_human_npcs.dm" +#include "voidcrew_human_npcs_shared.dm" #include "voidcrew_hv_finishers.dm" #include "voidcrew_hyperviolence_blood.dm" #include "voidcrew_hyperviolence_braingut.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_human_npcs.dm b/voidcrew/modules/unit_tests/voidcrew_human_npcs.dm new file mode 100644 index 00000000000..3bd38e8919e --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_human_npcs.dm @@ -0,0 +1,431 @@ +// Human NPC base (voidcrew/modules/human_npcs/). Unit tests are included before voidcrew/_DEFINES, so +// these use the sample types and the module's procs, never its HUMAN_NPC_* defines. + +/// Waits up to a second for `thing` to be deleted. Locked gear that leaves its NPC goes on the next tick. +/datum/unit_test/proc/human_npc_wait_deleted(datum/thing) + for(var/i in 1 to 10) + if(QDELETED(thing)) + return TRUE + sleep(1) + return QDELETED(thing) + +/// Life() does nothing while no player is on the z-level and runs once one is; a corpse is dormant +/// the same way, and when it wakes it catches up the organ decay it slept through. +/datum/unit_test/voidcrew_human_npc_dormancy + +/datum/unit_test/voidcrew_human_npc_dormancy/Run() + var/mob/living/carbon/human/npc/sample/swashbuckler/npc = allocate(/mob/living/carbon/human/npc/sample/swashbuckler) + var/turf/here = get_turf(npc) + TEST_ASSERT(!length(SSmobs.clients_by_zlevel[here.z]), "Test fixture: a client is on the test z-level") + TEST_ASSERT(npc.npc_dormant(), "An NPC with no player on its z-level is not dormant") + + npc.bodytemperature = 250 + npc.Life(SSMOBS_DT, 1) + TEST_ASSERT_EQUAL(npc.bodytemperature, 250, "A dormant NPC's Life() ran its body temperature") + TEST_ASSERT(npc.npc_dormant_since, "A dormant NPC did not note when it fell asleep") + + // A player arrives. The NPC stands in for them in the z-level's client list for the length of + // one Life() call; nothing else runs in between. + SSmobs.clients_by_zlevel[here.z] += npc + var/awake = !npc.npc_dormant() + npc.Life(SSMOBS_DT, 2) + SSmobs.clients_by_zlevel[here.z] -= npc + TEST_ASSERT(awake, "An NPC with a player on its z-level is dormant") + TEST_ASSERT(npc.bodytemperature != 250, "An awake NPC's Life() did not run") + TEST_ASSERT(!npc.npc_dormant_since, "An NPC that woke still thinks it is asleep") + + // Dead: dormant without a player, and a corpse that slept an hour has the organs of one dead an hour. + npc.death() + npc.bodytemperature = BODYTEMP_NORMAL + var/obj/item/organ/heart/heart = npc.get_organ_slot(ORGAN_SLOT_HEART) + TEST_ASSERT_NOTNULL(heart, "Test fixture: the NPC has no heart") + npc.Life(SSMOBS_DT, 3) + TEST_ASSERT(!(heart.organ_flags & ORGAN_FAILING), "A fresh corpse's heart has already failed") + TEST_ASSERT(npc.npc_dormant_since, "A dormant corpse did not note when it fell asleep") + npc.npc_dormant_since = world.time - 1 HOURS + SSmobs.clients_by_zlevel[here.z] += npc + npc.Life(SSMOBS_DT, 4) + SSmobs.clients_by_zlevel[here.z] -= npc + TEST_ASSERT(heart.organ_flags & ORGAN_FAILING, "A corpse that slept for an hour woke with a working heart") + TEST_ASSERT(npc.can_defib() != DEFIB_POSSIBLE, "A corpse dead for an hour could still be defibrillated") + +/// No mood and no hunger, and nothing done to stamina or stuns: a baton works on an NPC as on a player. +/datum/unit_test/voidcrew_human_npc_body_trims + +/datum/unit_test/voidcrew_human_npc_body_trims/Run() + var/mob/living/carbon/human/npc/sample/gunner/npc = allocate(/mob/living/carbon/human/npc/sample/gunner) + TEST_ASSERT_NULL(npc.mob_mood, "A human NPC has a mood datum") + TEST_ASSERT(HAS_TRAIT(npc, TRAIT_NOHUNGER), "A human NPC gets hungry") + TEST_ASSERT_EQUAL(npc.physiology.stamina_mod, 1, "A human NPC's stamina damage is scaled") + TEST_ASSERT_EQUAL(npc.physiology.stun_mod, 1, "A human NPC's stuns are scaled") + TEST_ASSERT_EQUAL(npc.physiology.brute_mod, 1, "A regular human NPC takes scaled brute damage") + + var/mob/living/carbon/human/npc/sample/elite/elite = allocate(/mob/living/carbon/human/npc/sample/elite) + TEST_ASSERT_EQUAL(elite.physiology.brute_mod, 0.75, "The elite's toughness did not reach its brute mod") + TEST_ASSERT_EQUAL(elite.physiology.burn_mod, 0.75, "The elite's toughness did not reach its burn mod") + TEST_ASSERT_EQUAL(elite.physiology.stamina_mod, 1, "Toughness changed stamina damage") + elite.set_npc_toughness(0.5) + TEST_ASSERT_EQUAL(elite.physiology.brute_mod, 0.5, "set_npc_toughness() did not replace the old multiplier") + + npc.adjustStaminaLoss(200) + TEST_ASSERT(npc.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "200 stamina damage did not stamcrit a human NPC") + TEST_ASSERT(npc.ai_controller.get_able_to_run() & AI_UNABLE_TO_RUN, "A stamcrit human NPC's AI can still act") + +/// The NPC never lets go of its kit, the strip menu shows none of it, and kit forced off it is deleted, +/// unless it is straight back on the NPC (a tactical reload drops the old magazine and catches it). +/// What isn't gear (a paper, a ship key) can be taken off it through the strip menu like off anyone. +/datum/unit_test/voidcrew_human_npc_gear_lock + +/datum/unit_test/voidcrew_human_npc_gear_lock/Run() + var/mob/living/carbon/human/npc/sample/gunner/npc = allocate(/mob/living/carbon/human/npc/sample/gunner) + var/mob/living/carbon/human/consistent/player = allocate(/mob/living/carbon/human/consistent) + var/obj/item/gun/gun = locate() in npc.held_items + TEST_ASSERT_NOTNULL(gun, "The sample gunner holds no gun") + var/obj/item/ammo_box/magazine/spare = locate() in npc.belt + TEST_ASSERT_NOTNULL(spare, "The sample gunner carries no spare magazine") + for(var/obj/item/kit as anything in list(gun, spare, npc.w_uniform, npc.wear_suit, npc.head, npc.shoes, npc.belt)) + TEST_ASSERT(human_npc_gear_locked(kit), "[kit] is not locked to the NPC") + TEST_ASSERT(!human_npc_gear_locked(npc.get_bodypart(BODY_ZONE_CHEST)), "A body part was locked as gear") + + // The strip menu opens, but every piece of kit reads as an empty slot and can't be taken. + TEST_ASSERT(npc.should_strip(player), "The strip menu would not open on a human NPC") + for(var/obj/item/kit as anything in list(gun, spare, npc.w_uniform, npc.wear_suit)) + TEST_ASSERT(HAS_TRAIT(kit, TRAIT_NO_STRIP), "[kit] shows in the strip menu") + var/datum/strippable_item/suit_slot = GLOB.strippable_human_items[STRIPPABLE_ITEM_SUIT] + TEST_ASSERT(!suit_slot.start_unequip(npc, player), "The strip menu would start taking a human NPC's armour") + // A paper in its pocket isn't gear: it comes out like anyone's. + var/obj/item/paper/note = allocate(/obj/item/paper) + if(!npc.equip_to_slot_if_possible(note, ITEM_SLOT_LPOCKET, disable_warning = TRUE)) + npc.equip_to_slot_if_possible(note, ITEM_SLOT_RPOCKET, disable_warning = TRUE) + TEST_ASSERT(npc.get_slot_by_item(note) & ITEM_SLOT_POCKETS, "No pocket of the sample gunner took a paper") + TEST_ASSERT(!HAS_TRAIT(note, TRAIT_NO_STRIP), "A paper in a human NPC's pocket is hidden from the strip menu") + var/datum/strippable_item/pocket = GLOB.strippable_human_items[npc.l_store == note ? STRIPPABLE_ITEM_LPOCKET : STRIPPABLE_ITEM_RPOCKET] + TEST_ASSERT(pocket.try_unequip(npc, player), "The strip menu would refuse a paper in a human NPC's pocket") + pocket.finish_unequip(npc, player) + TEST_ASSERT(isturf(note.loc), "Stripping a paper from a human NPC's pocket did not take it out") + TEST_ASSERT(!npc.dropItemToGround(gun), "A human NPC let go of its gun") + TEST_ASSERT(npc.is_holding(gun), "The gun left the NPC's hand") + TEST_ASSERT(!npc.transferItemToLoc(gun, player), "A human NPC handed its gun over") + TEST_ASSERT(!npc.dropItemToGround(npc.wear_suit), "A human NPC took off its armour") + TEST_ASSERT(SEND_SIGNAL(gun, COMSIG_ITEM_PRE_EXPORT) & COMPONENT_STOP_EXPORT, "A human NPC's gun can be sold") + + // Moves that end on the NPC still work. + TEST_ASSERT(npc.temporarilyRemoveItemFromInventory(gun), "The NPC could not move its own gun") + TEST_ASSERT(npc.put_in_hands(gun), "The NPC could not take its gun back") + + // Forced out and straight back: kept. + spare.forceMove(get_turf(npc)) + TEST_ASSERT(npc.put_in_hands(spare), "The NPC could not catch its magazine") + sleep(2) + TEST_ASSERT(!QDELETED(spare), "A magazine that left the NPC and came straight back was deleted") + + // Forced out for good: deleted. + npc.dropItemToGround(gun, force = TRUE) + TEST_ASSERT(isturf(gun.loc), "A forced drop did not put the gun on the floor") + TEST_ASSERT(human_npc_wait_deleted(gun), "A human NPC's gun forced out of its hand was left lying around") + +/// Cutting off the gun arm or the head, death and gibbing never leave the NPC's kit for players; the +/// limbs and gore stay. Its designed death cash drops once, however often it dies. +/datum/unit_test/voidcrew_human_npc_gear_body + +/datum/unit_test/voidcrew_human_npc_gear_body/Run() + var/mob/living/carbon/human/npc/sample/gunner/npc = allocate(/mob/living/carbon/human/npc/sample/gunner) + var/obj/item/gun/gun = locate() in npc.held_items + var/obj/item/bodypart/arm = npc.hand_bodyparts[npc.get_held_index_of_item(gun)] + TEST_ASSERT_NOTNULL(arm, "Test fixture: the gun is in no hand") + TEST_ASSERT(arm.dismember(), "The gun arm would not come off") + TEST_ASSERT(isturf(arm.loc), "The severed arm is not on the floor") + TEST_ASSERT(human_npc_wait_deleted(gun), "A severed arm handed over the NPC's gun") + + var/obj/item/hat = npc.head + var/obj/item/bodypart/head/head = npc.get_bodypart(BODY_ZONE_HEAD) + TEST_ASSERT(head.dismember(), "The NPC's head would not come off") + TEST_ASSERT(human_npc_wait_deleted(hat), "The NPC's hat was left behind when its head came off") + + // Death keeps everything on the body. + // On its own tile: the first NPC died when its head came off, and dropped its own cash. + var/turf/floor = locate(run_loc_floor_bottom_left.x + 2, run_loc_floor_bottom_left.y + 2, run_loc_floor_bottom_left.z) + var/mob/living/carbon/human/npc/sample/gunner/victim = allocate(/mob/living/carbon/human/npc/sample/gunner, floor) + var/list/kit = victim.get_equipped_items(INCLUDE_POCKETS | INCLUDE_HELD) + victim.death() + for(var/obj/item/worn as anything in kit) + TEST_ASSERT(!QDELETED(worn) && human_npc_holding(worn) == victim, "[worn] came off the NPC when it died") + var/obj/item/holochip/cash = locate() in floor + TEST_ASSERT_NOTNULL(cash, "The NPC's death cash did not drop") + qdel(cash) + victim.revive(HEAL_ALL) + victim.death() + TEST_ASSERT_NULL(locate(/obj/item/holochip) in floor, "The NPC's death cash dropped a second time") + + // Gibbing deletes the kit with the body. + var/mob/living/carbon/human/npc/sample/gunner/gibbed = allocate(/mob/living/carbon/human/npc/sample/gunner) + var/list/gibbed_kit = list() + for(var/obj/item/item as anything in gibbed.get_all_contents_type(/obj/item)) + if(human_npc_gear_locked(item)) + gibbed_kit += item + TEST_ASSERT(length(gibbed_kit), "Test fixture: the gibbed NPC carried nothing locked") + gibbed.gib(DROP_ALL_REMAINS) + for(var/obj/item/item as anything in gibbed_kit) + TEST_ASSERT(human_npc_wait_deleted(item), "[item] survived its NPC being gibbed") + +/// D4: only elite and boss human NPCs land aimed crits; only bosses execute (OC-9). Players always can. +/datum/unit_test/voidcrew_human_npc_crit_policy + +/datum/unit_test/voidcrew_human_npc_crit_policy/Run() + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent) + var/mob/living/carbon/human/npc/sample/gunner/regular = allocate(/mob/living/carbon/human/npc/sample/gunner) + var/mob/living/carbon/human/npc/sample/elite/elite = allocate(/mob/living/carbon/human/npc/sample/elite) + var/obj/item/bodypart/head = victim.get_bodypart(BODY_ZONE_HEAD) + var/obj/item/spear/spear = allocate(/obj/item/spear) + + TEST_ASSERT(regular.put_in_hands(spear), "Test fixture: the regular NPC can't hold a spear") + TEST_ASSERT_NULL(hv_crit_get_aimer(spear), "A regular human NPC counts as aiming its hits") + regular.zone_selected = BODY_ZONE_PRECISE_EYES + // As in the crit tests: +90 keeps the roll over the eye threshold and under a dismember. + victim.apply_damage(15, BRUTE, head, wound_bonus = 90, sharpness = SHARP_POINTY, attacking_item = spear) + TEST_ASSERT_NULL(head.get_wound_type(/datum/wound/pierce/bleed/severe/eye/hv_gouged), "A regular human NPC tore an eye out") + + TEST_ASSERT(regular.dropItemToGround(spear), "Test fixture: the NPC kept a spear it was handed") + TEST_ASSERT(elite.put_in_hands(spear), "Test fixture: the elite can't hold a spear") + TEST_ASSERT_EQUAL(hv_crit_get_aimer(spear), elite, "An elite human NPC doesn't count as aiming its hits") + elite.zone_selected = BODY_ZONE_PRECISE_EYES + victim.apply_damage(15, BRUTE, head, wound_bonus = 90, sharpness = SHARP_POINTY, attacking_item = spear) + TEST_ASSERT_NOTNULL(head.get_wound_type(/datum/wound/pierce/bleed/severe/eye/hv_gouged), "An elite human NPC could not land an eye crit") + + var/obj/item/gun/regular_gun = locate() in regular.held_items + var/obj/item/gun/elite_gun = locate() in elite.held_items + victim.Knockdown(30 SECONDS) + TEST_ASSERT(!regular_gun.hv_execution_possible(regular, victim), "A regular human NPC can execute a downed player") + TEST_ASSERT(!elite_gun.hv_execution_possible(elite, victim), "An elite human NPC can execute a downed player; only bosses may") + elite.npc_rank = 2 // HUMAN_NPC_RANK_BOSS; tests compile before voidcrew defines + TEST_ASSERT(elite_gun.hv_execution_possible(elite, victim), "A boss human NPC can't execute a downed player") + +/// spawn_human_npc() queues bodies; the subsystem builds them a budget at a time, and a cancelled +/// order builds nothing. +/datum/unit_test/voidcrew_human_npc_spawn_queue + +/datum/unit_test/voidcrew_human_npc_spawn_queue/Run() + TEST_ASSERT(!length(SSmobs.clients_by_zlevel[run_loc_floor_bottom_left.z]), "Test fixture: a client is on the test z-level") + TEST_ASSERT(!length(SShuman_npcs.queue), "Test fixture: the human NPC queue is not empty") + var/list/datum/human_npc_order/orders = list() + for(var/i in 1 to 3) + orders += spawn_human_npc(/mob/living/carbon/human/npc/sample/swashbuckler, run_loc_floor_bottom_left) + for(var/datum/human_npc_order/order as anything in orders) + TEST_ASSERT_NULL(order.spawned_ref, "spawn_human_npc() built a body at once") + TEST_ASSERT_EQUAL(SShuman_npcs.process_spawns(1), 1, "A budget of one built [length(orders) - length(SShuman_npcs.queue)] bodies") + TEST_ASSERT_EQUAL(length(SShuman_npcs.queue), 2, "The queue did not keep the rest") + TEST_ASSERT_EQUAL(SShuman_npcs.process_spawns(10), 2, "The queue did not build the rest") + for(var/datum/human_npc_order/order as anything in orders) + var/mob/living/carbon/human/npc/built = order.spawned_ref?.resolve() + TEST_ASSERT(istype(built, /mob/living/carbon/human/npc/sample/swashbuckler), "An order built [built || "nothing"]") + TEST_ASSERT_EQUAL(get_turf(built), run_loc_floor_bottom_left, "A queued NPC appeared in the wrong place") + allocated += built + + var/datum/human_npc_order/cancelled = spawn_human_npc(/mob/living/carbon/human/npc/sample/swashbuckler, run_loc_floor_bottom_left) + qdel(cancelled) + TEST_ASSERT_EQUAL(SShuman_npcs.process_spawns(5), 0, "A cancelled order was built") + + // An order's overrides reach the body, and a spawner path dresses it. + var/datum/human_npc_order/dressed = spawn_human_npc(/mob/living/carbon/human/npc/sample/gunner, run_loc_floor_bottom_left, name = "Test Name", faction = list("human_npc_test"), immediate = TRUE) + var/mob/living/carbon/human/npc/dressed_npc = dressed.spawned_ref?.resolve() + TEST_ASSERT_NOTNULL(dressed_npc, "An immediate order built nothing") + allocated += dressed_npc + TEST_ASSERT_EQUAL(dressed_npc.real_name, "Test Name", "The order's name did not stick") + TEST_ASSERT(("human_npc_test" in dressed_npc.faction) && !(FACTION_PIRATE in dressed_npc.faction), "The order's faction did not replace the type's") + + var/datum/human_npc_order/skeleton = spawn_human_npc(/mob/living/carbon/human/npc/sample/swashbuckler, run_loc_floor_bottom_left, look = /obj/effect/mob_spawn/corpse/human/old_pirate_captain, immediate = TRUE) + var/mob/living/carbon/human/npc/skeleton_npc = skeleton.spawned_ref?.resolve() + allocated += skeleton_npc + TEST_ASSERT(istype(skeleton_npc?.dna.species, /datum/species/skeleton), "A spawner look did not give the spawner's species") + +/// Human NPCs take wounds, bleed, lose limbs and have their heads burst as a player does. +/datum/unit_test/voidcrew_human_npc_gore + +/datum/unit_test/voidcrew_human_npc_gore/Run() + var/mob/living/carbon/human/npc/sample/swashbuckler/npc = allocate(/mob/living/carbon/human/npc/sample/swashbuckler) + var/obj/item/bodypart/arm = npc.get_bodypart(BODY_ZONE_L_ARM) + npc.apply_damage(25, BRUTE, arm, wound_bonus = 60, sharpness = SHARP_EDGED) + TEST_ASSERT(length(arm.wounds), "A heavy cut left no wound on a human NPC") + var/blood_before = npc.blood_volume + npc.bleed(20) + TEST_ASSERT(npc.blood_volume < blood_before, "A human NPC did not lose blood") + TEST_ASSERT(arm.dismember(), "A human NPC's arm would not come off") + TEST_ASSERT_NULL(npc.get_bodypart(BODY_ZONE_L_ARM), "The arm is still on") + + npc.death() + var/obj/item/organ/brain/brain = npc.get_organ_slot(ORGAN_SLOT_BRAIN) + TEST_ASSERT(npc.hv_burst_head(NORTH), "A dead human NPC's head would not burst") + TEST_ASSERT_NULL(npc.get_bodypart(BODY_ZONE_HEAD), "The burst head is still on") + TEST_ASSERT(!QDELETED(brain) && isturf(brain.loc), "The burst head did not throw its brain out") + +/// The AI keeps working the cuffs when cuffed (tg's escape_captivity) and reloads its gun from the +/// magazines it carries through the gun's own reload path, then fires the real gun. +/datum/unit_test/voidcrew_human_npc_ai_hands + +/datum/unit_test/voidcrew_human_npc_ai_hands/Run() + var/mob/living/carbon/human/npc/sample/swashbuckler/cuffed = allocate(/mob/living/carbon/human/npc/sample/swashbuckler) + var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs) + TEST_ASSERT(cuffed.equip_to_slot_if_possible(cuffs, ITEM_SLOT_HANDCUFFED), "Test fixture: the NPC could not be cuffed") + TEST_ASSERT(HAS_TRAIT(cuffed, TRAIT_RESTRAINED), "A cuffed NPC isn't restrained") + TEST_ASSERT(!(cuffed.ai_controller.get_able_to_run() & AI_UNABLE_TO_RUN), "A cuffed NPC's AI stopped, so it can't work at the cuffs") + + var/mob/living/carbon/human/npc/sample/gunner/npc = allocate(/mob/living/carbon/human/npc/sample/gunner) + var/obj/item/gun/ballistic/automatic/pistol/gun = locate() in npc.held_items + TEST_ASSERT_NOTNULL(gun, "The sample gunner holds no pistol") + gun.can_misfire = FALSE + var/obj/item/ammo_box/magazine/first_mag = gun.magazine + // Spend it, as firing it dry would. + var/obj/item/ammo_casing/round = first_mag.get_round() + while(round) + qdel(round) + round = first_mag.get_round() + QDEL_NULL(gun.chambered) + TEST_ASSERT(!gun.can_shoot(), "Test fixture: the pistol can still fire") + var/obj/item/ammo_box/magazine/spare = human_npc_find_ammo(npc, gun) + TEST_ASSERT_NOTNULL(spare, "The gunner can't find its spare magazines") + + var/datum/ai_controller/controller = npc.ai_controller + var/datum/ai_behavior/human_npc_reload/reload = GET_AI_BEHAVIOR(/datum/ai_behavior/human_npc_reload) + TEST_ASSERT(reload.setup(controller), "The reload would not start") + var/finished = FALSE + for(var/step in 1 to 10) + // The waits between steps that the controller's cooldowns would give + npc.next_click = 0 + npc.next_move = 0 + var/result = reload.perform(1, controller) + TEST_ASSERT(!(result & AI_BEHAVIOR_FAILED), "The reload failed at step [step]") + if(result & AI_BEHAVIOR_SUCCEEDED) + finished = TRUE + break + TEST_ASSERT(finished, "The reload never finished") + TEST_ASSERT(gun.can_shoot(), "The reload left the pistol unable to fire") + TEST_ASSERT_EQUAL(gun.magazine, spare, "The pistol doesn't hold the spare magazine") + TEST_ASSERT(!npc.is_holding(first_mag), "The NPC kept hold of the empty magazine") + TEST_ASSERT(human_npc_wait_deleted(first_mag), "The dropped empty magazine was left for players") + + // One click fires the real gun. + var/mob/living/carbon/human/consistent/target = allocate(/mob/living/carbon/human/consistent, locate(run_loc_floor_bottom_left.x + 2, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)) + var/rounds_before = spare.ammo_count(FALSE) + npc.next_click = 0 + npc.next_move = 0 + human_npc_ready_item(npc, gun) + controller.ai_interact(target = target, combat_mode = TRUE) + TEST_ASSERT(spare.ammo_count(FALSE) < rounds_before || !gun.chambered?.loaded_projectile, "A click with the pistol did not fire it") + +/// Corpses are cleaned up after their lifetime when nobody is near, with the limbs they lost, but +/// never while dragged. +/datum/unit_test/voidcrew_human_npc_corpse_cleanup + +/datum/unit_test/voidcrew_human_npc_corpse_cleanup/Run() + var/mob/living/carbon/human/npc/sample/swashbuckler/npc = allocate(/mob/living/carbon/human/npc/sample/swashbuckler) + TEST_ASSERT(!npc.npc_corpse_expired(), "A living NPC can be cleaned up") + var/obj/item/bodypart/leg = npc.get_bodypart(BODY_ZONE_L_LEG) + TEST_ASSERT(leg.dismember(), "Test fixture: the leg would not come off") + npc.death() + TEST_ASSERT(npc in SShuman_npcs.corpses, "A dead NPC's corpse is not tracked") + TEST_ASSERT(!npc.npc_corpse_expired(), "A fresh corpse can be cleaned up") + npc.npc_died_at = world.time - npc.npc_corpse_lifetime - 1 + TEST_ASSERT(npc.npc_corpse_expired(), "An old corpse nobody is near can't be cleaned up") + + var/mob/living/carbon/human/consistent/dragger = allocate(/mob/living/carbon/human/consistent) + dragger.start_pulling(npc) + TEST_ASSERT(!npc.npc_corpse_expired(), "A corpse being dragged can be cleaned up") + dragger.stop_pulling() + + npc.revive(HEAL_ALL) + TEST_ASSERT(!(npc in SShuman_npcs.corpses), "A revived NPC is still tracked as a corpse") + npc.death() + npc.npc_died_at = world.time - npc.npc_corpse_lifetime - 1 + npc.npc_fade() + TEST_ASSERT(QDELETED(npc), "npc_fade() left the corpse") + TEST_ASSERT(QDELETED(leg), "npc_fade() left the leg the NPC lost") + +/// Systems built for basic-mob NPCs treat human NPCs as the NPCs they are: hull turrets shoot them, +/// weather reaches them while they are awake, and pirate crews can take them on. +/datum/unit_test/voidcrew_human_npc_world_gates + +/datum/unit_test/voidcrew_human_npc_world_gates/Run() + var/obj/machinery/porta_turret/ship_defense/turret = allocate(/obj/machinery/porta_turret/ship_defense) + var/mob/living/carbon/human/npc/sample/gunner/npc = allocate(/mob/living/carbon/human/npc/sample/gunner) + var/mob/living/carbon/human/consistent/person = allocate(/mob/living/carbon/human/consistent) + TEST_ASSERT(turret.valid_target(npc), "A hull turret won't shoot a human NPC boarder") + TEST_ASSERT(!turret.valid_target(person), "A hull turret would shoot a person") + var/mob/living/carbon/human/npc/sample/gunner/possessed = allocate(/mob/living/carbon/human/npc/sample/gunner) + possessed.mind_initialize() + TEST_ASSERT(!turret.valid_target(possessed), "A hull turret would shoot a human NPC body with a mind in it") + + TEST_ASSERT(!human_npc_weathered(npc), "Weather reaches a dormant human NPC") + var/turf/here = get_turf(npc) + SSmobs.clients_by_zlevel[here.z] += npc + var/weathered = human_npc_weathered(npc) + SSmobs.clients_by_zlevel[here.z] -= npc + TEST_ASSERT(weathered, "Weather doesn't reach an awake human NPC") + TEST_ASSERT(!human_npc_weathered(person), "human_npc_weathered() took in a person") + +/// D3's exceptions: a ship key isn't gear and drops when the NPC dies; a grenade is a consumable the NPC +/// can drop and throw, that no player can keep, and that goes when its NPC does. +/datum/unit_test/voidcrew_human_npc_gear_exceptions + +/datum/unit_test/voidcrew_human_npc_gear_exceptions/Run() + var/mob/living/carbon/human/npc/sample/gunner/npc = allocate(/mob/living/carbon/human/npc/sample/gunner) + var/mob/living/carbon/human/consistent/player = 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)) + var/obj/item/ship_key/key = allocate(/obj/item/ship_key) + TEST_ASSERT(npc.equip_to_slot_if_possible(key, ITEM_SLOT_LPOCKET), "Test fixture: the key would not go in the NPC's pocket") + TEST_ASSERT(!npc.npc_lock_item(key), "A ship key was locked to an NPC as gear") + TEST_ASSERT(!human_npc_gear_locked(key) && !human_npc_gear_consumable(key), "A ship key was locked to an NPC") + + var/obj/item/grenade/smokebomb/grenade = allocate(/obj/item/grenade/smokebomb) + TEST_ASSERT(npc.put_in_hands(grenade), "Test fixture: the NPC could not hold a grenade") + TEST_ASSERT(npc.npc_lock_item(grenade), "A grenade handed to an NPC was not issued") + TEST_ASSERT(human_npc_gear_consumable(grenade) && !human_npc_gear_locked(grenade), "A grenade was locked like gear instead of issued as a consumable") + TEST_ASSERT(HAS_TRAIT(npc, TRAIT_CAN_THROW_ITEMS), "Test fixture: the NPC can't throw") + TEST_ASSERT(human_npc_ready_item(npc, grenade), "Test fixture: the grenade is not in the NPC's hand") + npc.throw_item(locate(run_loc_floor_bottom_left.x + 3, run_loc_floor_bottom_left.y + 3, run_loc_floor_bottom_left.z)) + TEST_ASSERT(!npc.is_holding(grenade), "The NPC could not throw its grenade") + sleep(1 SECONDS) + TEST_ASSERT(!QDELETED(grenade) && isturf(grenade.loc), "A thrown grenade was deleted where it landed") + player.put_in_hands(grenade) + TEST_ASSERT(human_npc_wait_deleted(grenade), "A player kept an NPC's grenade") + + // Dropped like anyone's, and gone with its NPC. + var/obj/item/grenade/smokebomb/dropped = allocate(/obj/item/grenade/smokebomb) + npc.put_in_hands(dropped) + npc.npc_lock_item(dropped) + TEST_ASSERT(npc.dropItemToGround(dropped), "An NPC could not let go of a grenade") + sleep(2) + TEST_ASSERT(!QDELETED(dropped), "A grenade an NPC dropped was deleted on the floor") + + var/obj/item/gun/gun = locate() in npc.held_items + npc.death() + TEST_ASSERT(isturf(key.loc), "The ship key did not drop when the NPC died") + TEST_ASSERT(human_npc_holding(gun) == npc, "The NPC's gun came off when it died") + qdel(npc) + TEST_ASSERT(QDELETED(dropped), "A loose grenade outlived the NPC that carried it") + +/// Owner ruling: an NPC's chrome works like a player's in life (a dodge shunt dodges) and burns out to +/// scrap when it dies or the ware is taken out of it. +/datum/unit_test/voidcrew_human_npc_chrome + +/datum/unit_test/voidcrew_human_npc_chrome/Run() + var/mob/living/carbon/human/npc/sample/swashbuckler/npc = allocate(/mob/living/carbon/human/npc/sample/swashbuckler) + var/obj/item/organ/cyberimp/cyberware/slipwire/shunt = npc.npc_install_cyberware(/obj/item/organ/cyberimp/cyberware/slipwire) + TEST_ASSERT_NOTNULL(shunt, "A dodge shunt would not install in an NPC") + TEST_ASSERT_EQUAL(shunt.owner, npc, "The dodge shunt is not in the NPC") + TEST_ASSERT_NOTNULL(npc.GetComponent(/datum/component/cyberware_dodge), "An NPC's dodge shunt registered no dodge") + TEST_ASSERT(shunt.get_dodge_chance() > 0, "An NPC's working dodge shunt gives no dodge chance") + + var/turf/floor = get_turf(npc) + npc.death() + TEST_ASSERT(QDELETED(shunt), "An NPC's chrome came through its death working") + TEST_ASSERT_NOTNULL(locate(/obj/item/burnt_chrome) in floor, "An NPC's chrome left no scrap") + TEST_ASSERT_NULL(npc.GetComponent(/datum/component/cyberware_dodge), "A dead NPC still dodges") + + // Taken out of a living NPC: scrap too. + var/turf/elsewhere = locate(run_loc_floor_bottom_left.x + 2, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z) + var/mob/living/carbon/human/npc/sample/swashbuckler/patient = allocate(/mob/living/carbon/human/npc/sample/swashbuckler, elsewhere) + var/obj/item/organ/ware = patient.npc_install_cyberware(/obj/item/organ/cyberimp/cyberware/slipwire) + TEST_ASSERT_NOTNULL(ware, "Test fixture: the second shunt would not install") + ware.Remove(patient) + 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") diff --git a/voidcrew/modules/unit_tests/voidcrew_human_npcs_shared.dm b/voidcrew/modules/unit_tests/voidcrew_human_npcs_shared.dm new file mode 100644 index 00000000000..de6e5d5f785 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_human_npcs_shared.dm @@ -0,0 +1,433 @@ +// Human NPC shared pieces, phase A2 (voidcrew/modules/human_npcs/). Unit tests compile before +// voidcrew/_DEFINES, so values from there are written out: zones ZONE_GREEN 1, ZONE_YELLOW 2, +// ZONE_RED 3; sites HUMAN_NPC_SITE_VACUUM 1, _BAD_AIR 2, _COLD 4; blackboard keys and bark kinds by +// their strings. + +/// A voice with a death line, for the death hook. +/datum/human_npc_voice/unit_test + emotes = list("death" = list("goes still.")) + +/// Dressed for vacuum wherever it spawns. +/mob/living/carbon/human/npc/sample/raider/unit_test_spacer + npc_always_site = 1 + +/// Dressed for the cold wherever it spawns. +/mob/living/carbon/human/npc/sample/raider/unit_test_cold + npc_always_site = 4 + +/// A skeleton dressed for vacuum: its species needs nothing. +/mob/living/carbon/human/npc/sample/raider/unit_test_skeleton + npc_always_site = 1 + npc_look = /obj/effect/mob_spawn/corpse/human/old_pirate_captain + +/// A prisoner: nothing it carries is locked (owner ruling OC-11). +/mob/living/carbon/human/npc/sample/gunner/unit_test_prisoner + npc_gear_locked = FALSE + +/// N4: dead, in crit or cuffed is out of the fight; stamcrit isn't; a basic mob is out only once dead. +/datum/unit_test/voidcrew_human_npc_out_of_fight + +/datum/unit_test/voidcrew_human_npc_out_of_fight/Run() + var/mob/living/carbon/human/npc/sample/gunner/npc = allocate(/mob/living/carbon/human/npc/sample/gunner) + TEST_ASSERT(!human_npc_out_of_fight(npc), "A healthy human NPC counts as out of the fight") + npc.adjustStaminaLoss(200) + TEST_ASSERT(npc.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "Test fixture: 200 stamina damage did not stamcrit the NPC") + TEST_ASSERT(!human_npc_out_of_fight(npc), "A stamcrit NPC counts as out of the fight") + npc.setStaminaLoss(0) + + npc.adjustToxLoss(110) // toxin, not oxygen: 50 oxygen damage knocks a carbon out (tg check_passout()) + TEST_ASSERT_EQUAL(npc.stat, SOFT_CRIT, "Test fixture: 110 toxin damage did not put the NPC in soft crit") + TEST_ASSERT(human_npc_out_of_fight(npc), "An NPC in soft crit is still in the fight") + npc.setToxLoss(0) + TEST_ASSERT(!human_npc_out_of_fight(npc), "An NPC healed out of crit is still out of the fight") + + var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs) + TEST_ASSERT(npc.equip_to_slot_if_possible(cuffs, ITEM_SLOT_HANDCUFFED), "Test fixture: the NPC could not be cuffed") + TEST_ASSERT(human_npc_out_of_fight(npc), "A cuffed NPC is still in the fight") + npc.uncuff() + + npc.death() + TEST_ASSERT(human_npc_out_of_fight(npc), "A dead NPC is still in the fight") + var/mob/living/basic/mouse/mouse = allocate(/mob/living/basic/mouse) + TEST_ASSERT(!human_npc_out_of_fight(mouse), "A living basic mob counts as out of the fight") + +/// Builds a human NPC on the test floor dressed for `zone`, whatever zone the test level has. +/datum/unit_test/proc/human_npc_build_in_zone(npc_type, zone) + var/datum/human_npc_order/order = new /datum/human_npc_order(npc_type, run_loc_floor_bottom_left) + order.zone = zone + var/mob/living/carbon/human/npc/npc = order.fulfil() + qdel(order) + if(npc) + allocated += npc + return npc + +/// N5: pirate-family NPCs keep shooting someone in crit; criminal-family NPCs stop. +/datum/unit_test/voidcrew_human_npc_target_stat + +/datum/unit_test/voidcrew_human_npc_target_stat/Run() + var/mob/living/carbon/human/npc/sample/gunner/finisher = allocate(/mob/living/carbon/human/npc/sample/gunner) + var/mob/living/carbon/human/npc/sample/thug/spare = allocate(/mob/living/carbon/human/npc/sample/thug, locate(run_loc_floor_bottom_left.x, run_loc_floor_bottom_left.y + 1, run_loc_floor_bottom_left.z)) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, locate(run_loc_floor_bottom_left.x + 2, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)) + TEST_ASSERT_EQUAL(finisher.ai_controller.blackboard[BB_TARGET_MINIMUM_STAT], HARD_CRIT, "A pirate-family NPC's AI didn't get its target stat") + TEST_ASSERT_EQUAL(spare.ai_controller.blackboard[BB_TARGET_MINIMUM_STAT], CONSCIOUS, "A criminal-family NPC's AI didn't get its target stat") + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(/datum/targeting_strategy/basic/human_npc) + TEST_ASSERT(strategy.can_attack(finisher, victim), "Test fixture: the pirate-family NPC won't fight a healthy person") + TEST_ASSERT(strategy.can_attack(spare, victim), "Test fixture: the criminal-family NPC won't fight a healthy person") + victim.adjustToxLoss(110) // awake in soft crit; 50 oxygen damage would knock them out + TEST_ASSERT_EQUAL(victim.stat, SOFT_CRIT, "Test fixture: the victim is not in soft crit") + TEST_ASSERT(strategy.can_attack(finisher, victim), "A pirate-family NPC stopped attacking someone in soft crit") + TEST_ASSERT(!strategy.can_attack(spare, victim), "A criminal-family NPC keeps attacking someone in crit") + +/// N3: barks fire on real tg changes (crit, stamcrit, cuffs, working the cuffs, breaking a grab, death), +/// are rate-limited, and a mute NPC only shows its emotes. +/datum/unit_test/voidcrew_human_npc_barks + +/datum/unit_test/voidcrew_human_npc_barks/Run() + var/mob/living/carbon/human/npc/sample/gunner/npc = allocate(/mob/living/carbon/human/npc/sample/gunner) + npc.adjustOxyLoss(110) + TEST_ASSERT_EQUAL(npc.npc_last_bark, "downed", "Entering crit gave no downed line") + npc.npc_bark_cooldown = 0 + npc.setOxyLoss(0) + TEST_ASSERT_EQUAL(npc.npc_last_bark, "recover", "Leaving crit gave no recover line") + + npc.npc_last_bark = null + npc.npc_bark_cooldown = 0 + npc.adjustStaminaLoss(200) + npc.setStaminaLoss(0) + TEST_ASSERT(!npc.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "Test fixture: stamcrit did not end") + TEST_ASSERT_EQUAL(npc.npc_last_bark, "recover", "Getting up from stamcrit gave no recover line") + + npc.npc_bark_cooldown = 0 + var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs) + TEST_ASSERT(npc.equip_to_slot_if_possible(cuffs, ITEM_SLOT_HANDCUFFED), "Test fixture: the NPC could not be cuffed") + TEST_ASSERT_EQUAL(npc.npc_last_bark, "cuffed", "Being cuffed gave no cuffed line") + npc.npc_bark_cooldown = 0 + SEND_SIGNAL(npc, COMSIG_MOB_REMOVING_CUFFS, cuffs) + TEST_ASSERT_EQUAL(npc.npc_last_bark, "slipping_cuffs", "Working at its cuffs gave no line") + npc.npc_bark_cooldown = 0 + npc.uncuff() + TEST_ASSERT_EQUAL(npc.npc_last_bark, "uncuffed", "Its cuffs coming off gave no line") + + // A passive grab breaks on the first resist, in the same call, for someone on their feet (prone, it + // takes a roll). tg's get-up after the stamcrit is a second's do_after the test doesn't wait for. + npc.get_up(instant = TRUE) + TEST_ASSERT_EQUAL(npc.body_position, STANDING_UP, "Test fixture: the NPC did not get back up") + var/mob/living/carbon/human/consistent/grabber = 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)) + grabber.start_pulling(npc) + TEST_ASSERT_EQUAL(npc.pulledby, grabber, "Test fixture: the grab didn't take") + npc.npc_bark_cooldown = 0 + npc.next_move = 0 + npc.execute_resist() + TEST_ASSERT_NULL(npc.pulledby, "Test fixture: resisting did not break the grab") + TEST_ASSERT_EQUAL(npc.npc_last_bark, "pulled_free", "Pulling free of a grab gave no line") + + // Rate limit: straight after a line, the next waits; surrender and death don't. + TEST_ASSERT(!npc.npc_bark("cuffed"), "A bark ignored the cooldown") + TEST_ASSERT(npc.npc_bark("cuffed", force = TRUE), "A forced bark was held back by the cooldown") + + // Mute: a kind with only spoken lines gives nothing, one with an emote still shows it. + npc.npc_bark_cooldown = 0 + ADD_TRAIT(npc, TRAIT_MUTE, TRAIT_SOURCE_UNIT_TESTS) + TEST_ASSERT(!npc.npc_bark("cuffed"), "A mute NPC spoke") + TEST_ASSERT(npc.npc_bark("downed"), "A mute NPC didn't show its emote") + REMOVE_TRAIT(npc, TRAIT_MUTE, TRAIT_SOURCE_UNIT_TESTS) + + npc.npc_voice = /datum/human_npc_voice/unit_test + npc.death() + TEST_ASSERT_EQUAL(npc.npc_last_bark, "death", "Dying gave no death line") + +/// N2: giving up stows the weapon (D3: never dropped), says the line and runs tg's *surrender; when the +/// paralysis ends uncuffed it decides again; cuffed, it doesn't. +/datum/unit_test/voidcrew_human_npc_surrender + +/datum/unit_test/voidcrew_human_npc_surrender/Run() + var/mob/living/carbon/human/npc/sample/thug/npc = allocate(/mob/living/carbon/human/npc/sample/thug) + var/obj/item/gun/gun = locate() in npc.held_items + TEST_ASSERT_NOTNULL(gun, "Test fixture: the thug holds no gun") + var/datum/human_npc_surrender/rules = npc.npc_surrender_rules() + TEST_ASSERT_NOTNULL(rules, "The thug has no surrender rules") + + TEST_ASSERT(!rules.hurt_enough(npc), "A healthy NPC thinks about giving up") + npc.adjustToxLoss(70) // awake at 30 health; 50 oxygen damage would knock it out + TEST_ASSERT(rules.hurt_enough(npc), "An NPC at 30 health doesn't think about giving up") + TEST_ASSERT(!rules.should_consider(npc, list(1), list()), "One hostile is enough to make it think about giving up") + TEST_ASSERT(rules.should_consider(npc, list(1, 2), list()), "Two hostiles aren't enough to make it think about giving up") + TEST_ASSERT_EQUAL(rules.odds(npc, list(1, 2), list(), TRUE), 60, "The first roll's odds are wrong") + TEST_ASSERT_EQUAL(rules.odds(npc, list(1, 2), list(1), TRUE), 40, "A standing friend doesn't lower the odds") + TEST_ASSERT_EQUAL(rules.odds(npc, list(1, 2), list(), FALSE), 25, "A later roll's odds are wrong") + TEST_ASSERT_EQUAL(rules.odds(npc, list(), list(), TRUE), 0, "It would give up with nobody there") + + TEST_ASSERT(npc.npc_surrender(), "The NPC would not give up") + TEST_ASSERT(npc.IsParalyzed(), "*surrender did not paralyse the NPC") + TEST_ASSERT_EQUAL(npc.npc_last_bark, "surrender", "Giving up gave no surrender line") + TEST_ASSERT(!npc.is_holding(gun), "The NPC kept its gun in hand when it gave up") + TEST_ASSERT_EQUAL(human_npc_holding(gun), npc, "The NPC's gun left its body when it gave up") + TEST_ASSERT(!npc.npc_surrender(), "The NPC gave up twice at once") + + npc.SetParalyzed(0) + TEST_ASSERT(!npc.npc_surrendering, "The NPC still counts as surrendering after the paralysis") + TEST_ASSERT(npc.npc_surrender_redecide, "Uncuffed after the paralysis, the NPC did not decide again") + + // Given up and cuffed: taken, nothing to decide. + npc.npc_surrender_redecide = FALSE + npc.emotes_used = null // the emote spam limit, not a game rule + TEST_ASSERT(npc.npc_surrender(), "The NPC would not give up a second time") + var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs) + TEST_ASSERT(npc.equip_to_slot_if_possible(cuffs, ITEM_SLOT_HANDCUFFED), "Test fixture: the NPC could not be cuffed") + npc.SetParalyzed(0) + TEST_ASSERT(!npc.npc_surrender_redecide, "A cuffed NPC decided again after giving up") + TEST_ASSERT(!npc.npc_surrender(), "A cuffed NPC gave up again") + +/// N5: in soft crit the AI keeps running and does only soft-crit things: a medipen and firing wild (elites). +/// It never crawls away. Hard crit stops it. +/datum/unit_test/voidcrew_human_npc_soft_crit + +/datum/unit_test/voidcrew_human_npc_soft_crit/Run() + var/mob/living/carbon/human/npc/sample/thug/npc = allocate(/mob/living/carbon/human/npc/sample/thug) + var/datum/ai_controller/controller = npc.ai_controller + npc.adjustToxLoss(110) // awake in soft crit; 50 oxygen damage would knock it out + TEST_ASSERT_EQUAL(npc.stat, SOFT_CRIT, "Test fixture: the NPC is not in soft crit") + TEST_ASSERT(!(controller.get_able_to_run() & AI_UNABLE_TO_RUN), "A human NPC's AI can't run in soft crit") + var/obj/item/reagent_containers/hypospray/medipen/pen = human_npc_soft_crit_treatment(npc) + TEST_ASSERT_NOTNULL(pen, "The NPC doesn't find the medipen in its pocket") + TEST_ASSERT(human_npc_gear_consumable(pen), "The medipen wasn't issued as a consumable") + + var/datum/ai_planning_subtree/human_npc_soft_crit/soft = new + TEST_ASSERT_EQUAL(soft.SelectBehaviors(controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "The soft-crit subtree let other subtrees plan") + var/datum/ai_behavior/human_npc_treat_self/treat = GET_AI_BEHAVIOR(/datum/ai_behavior/human_npc_treat_self) + TEST_ASSERT(controller.current_behaviors[treat], "In soft crit with a medipen, the NPC didn't plan to use it") + + var/finished = FALSE + for(var/step in 1 to 10) + npc.next_move = 0 + npc.next_click = 0 + var/result = treat.perform(1, controller, "human_npc_treat_item") + TEST_ASSERT(!(result & AI_BEHAVIOR_FAILED), "Using the medipen failed at step [step]") + if(result & AI_BEHAVIOR_SUCCEEDED) + finished = TRUE + break + TEST_ASSERT(finished, "The NPC never finished using its medipen") + TEST_ASSERT(npc.reagents.has_reagent(/datum/reagent/medicine/epinephrine), "The medipen's epinephrine isn't in the NPC") + TEST_ASSERT(pen.used_up, "The medipen isn't spent") + + npc.adjustOxyLoss(40) + TEST_ASSERT_EQUAL(npc.stat, HARD_CRIT, "Test fixture: the NPC is not in hard crit") + TEST_ASSERT(controller.get_able_to_run() & AI_UNABLE_TO_RUN, "A human NPC's AI runs in hard crit") + + // An elite fires from the floor at the ground around its attacker; a regular stays put. + var/mob/living/carbon/human/consistent/target = allocate(/mob/living/carbon/human/consistent, locate(run_loc_floor_bottom_left.x + 4, run_loc_floor_bottom_left.y + 2, run_loc_floor_bottom_left.z)) + var/mob/living/carbon/human/npc/sample/elite/elite = allocate(/mob/living/carbon/human/npc/sample/elite, locate(run_loc_floor_bottom_left.x, run_loc_floor_bottom_left.y + 2, run_loc_floor_bottom_left.z)) + var/mob/living/carbon/human/npc/sample/gunner/regular = allocate(/mob/living/carbon/human/npc/sample/gunner, locate(run_loc_floor_bottom_left.x, run_loc_floor_bottom_left.y + 3, run_loc_floor_bottom_left.z)) + var/datum/ai_behavior/human_npc_fire_wild/wild = GET_AI_BEHAVIOR(/datum/ai_behavior/human_npc_fire_wild) + for(var/mob/living/carbon/human/npc/downed as anything in list(elite, regular)) + downed.adjustToxLoss(110) + TEST_ASSERT_EQUAL(downed.stat, SOFT_CRIT, "Test fixture: [downed] is not in soft crit") + downed.ai_controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, target) + soft.SelectBehaviors(downed.ai_controller, 1) + TEST_ASSERT(elite.ai_controller.current_behaviors[wild], "An elite in soft crit doesn't fire from the floor") + TEST_ASSERT(!regular.ai_controller.current_behaviors[wild], "A regular NPC in soft crit fires from the floor") + TEST_ASSERT(!regular.ai_controller.current_behaviors[GET_AI_BEHAVIOR(/datum/ai_behavior/run_away_from_target)], "A downed NPC crawls away") + + var/obj/item/gun/ballistic/elite_gun = locate() in elite.held_items + TEST_ASSERT_NOTNULL(elite_gun, "Test fixture: the elite holds no ballistic gun") + elite_gun.can_misfire = FALSE + var/rounds_before = elite_gun.magazine.ammo_count(FALSE) + elite.next_move = 0 + elite.next_click = 0 + wild.perform(1, elite.ai_controller, "human_npc_flee_from") + TEST_ASSERT(elite_gun.magazine.ammo_count(FALSE) < rounds_before || !elite_gun.chambered?.loaded_projectile, "The elite in soft crit did not fire") + +/// N7: outfit tables pick by zone and rank; every pirate table dresses every rank in every zone, with a +/// real weapon and the ammunition it takes. +/datum/unit_test/voidcrew_human_npc_outfit_tables + +/datum/unit_test/voidcrew_human_npc_outfit_tables/Run() + var/datum/human_npc_outfit_table/raiders = human_npc_singleton(/datum/human_npc_outfit_table/sample_raiders) + TEST_ASSERT_EQUAL(raiders.pick_outfit(null, 1), /datum/outfit/human_npc/raider, "Green raiders aren't in rags") + TEST_ASSERT_EQUAL(raiders.pick_outfit(null, 2), /datum/outfit/human_npc/raider/vest, "Yellow raiders have no vest") + TEST_ASSERT_EQUAL(raiders.pick_outfit(null, 3), /datum/outfit/human_npc/raider/armoured, "Red raiders aren't armoured") + var/mob/living/carbon/human/npc/sample/elite/elite = allocate(/mob/living/carbon/human/npc/sample/elite) + TEST_ASSERT_EQUAL(raiders.pick_outfit(elite, 1), /datum/outfit/human_npc/pirate_gunner, "An elite didn't get the elite outfit") + + // An order that knows its zone dresses for it. + var/mob/living/carbon/human/npc/red_raider = human_npc_build_in_zone(/mob/living/carbon/human/npc/sample/raider, 3) + TEST_ASSERT(istype(red_raider?.wear_suit, /obj/item/clothing/suit/armor/vest), "A red-zone raider wears no vest") + TEST_ASSERT(istype(red_raider?.head, /obj/item/clothing/head/helmet), "A red-zone raider wears no helmet") + TEST_ASSERT_NOTNULL(locate(/obj/item/gun/ballistic/automatic/mini_uzi) in red_raider?.held_items, "A red-zone raider holds no SMG") + + // A spawn context's zone reaches the outfit, and the zone multipliers never touch a human. + var/datum/npc_spawn_context/context = new /datum/npc_spawn_context(run_loc_floor_bottom_left, 2) + var/mob/living/carbon/human/npc/yellow_raider = spawn_npc_in_zone(/mob/living/carbon/human/npc/sample/raider, run_loc_floor_bottom_left, context) + allocated += yellow_raider + TEST_ASSERT(istype(yellow_raider?.wear_suit, /obj/item/clothing/suit/armor/vest), "A raider made in a yellow-zone context wears no vest") + TEST_ASSERT(!istype(yellow_raider?.head, /obj/item/clothing/head/helmet), "A yellow-zone raider got the red-zone helmet") + TEST_ASSERT_EQUAL(yellow_raider?.maxHealth, 100, "A human NPC's max health was changed by its zone") + TEST_ASSERT(!yellow_raider?.npc_zone_applied, "A zone profile was applied to a human NPC") + + // An order whose context is still resolving its zone waits, then settles for green. + var/turf_zone = get_zone_type_for_player_turf(run_loc_floor_bottom_left) + var/datum/npc_spawn_context/unresolved = new /datum/npc_spawn_context(run_loc_floor_bottom_left) + var/datum/human_npc_order/waiting = new /datum/human_npc_order(/mob/living/carbon/human/npc/sample/raider, run_loc_floor_bottom_left, null, null, null, null, null, unresolved) + if(isnull(turf_zone)) + TEST_ASSERT(!waiting.ready(), "An order waiting on its zone was ready to build") + waiting.queued_at = world.time - 61 SECONDS + waiting.next_zone_check = 0 + TEST_ASSERT(waiting.ready(), "An order that waited a minute for its zone still isn't ready") + TEST_ASSERT_EQUAL(waiting.zone, 1, "An order that gave up waiting wasn't dressed for green") + else + TEST_ASSERT(waiting.ready(), "An order on a turf with a zone wasn't ready") + qdel(waiting) + qdel(unresolved) + +/// N7: where the air can't keep a person alive the NPC gets a sealed suit and a tank; in the cold it gets +/// cold-weather wear; a species that needs neither is left alone. It minds its valve like a person: open +/// while the air would hurt it, shut while the air is fine (so the tank doesn't run dry in a good room). +/datum/unit_test/voidcrew_human_npc_site_layers + +/datum/unit_test/voidcrew_human_npc_site_layers/Run() + var/turf/open/floor = run_loc_floor_bottom_left + TEST_ASSERT_EQUAL(human_npc_site_at(floor), 0, "The test room's air counts as hostile") + var/datum/gas_mixture/air = floor.return_air() + var/old_temperature = air.temperature + air.temperature = 200 + var/cold_site = human_npc_site_at(floor) + air.temperature = old_temperature + TEST_ASSERT(cold_site & 4, "Air at 200 K doesn't count as cold") + + var/datum/outfit/human_npc/pirate_spacer/sealed_outfit = new() + var/datum/outfit/human_npc/raider/rags_outfit = new() + TEST_ASSERT(human_npc_outfit_sealed(sealed_outfit), "The pirate spacer's suit doesn't count as sealed") + TEST_ASSERT(!human_npc_outfit_sealed(rags_outfit), "Rags count as sealed") + // A fire suit holds pressure, but a person freezes in one in space + var/datum/outfit/fire_outfit = new() + fire_outfit.suit = /obj/item/clothing/suit/utility/fire/firefighter + fire_outfit.head = /obj/item/clothing/head/utility/hardhat/red + TEST_ASSERT(!human_npc_outfit_sealed(fire_outfit), "A fire suit and hard hat count as sealed for space") + qdel(fire_outfit) + TEST_ASSERT(human_npc_outfit_has_air(sealed_outfit), "The pirate spacer doesn't count as carrying air") + + var/mob/living/carbon/human/npc/sample/raider/unit_test_spacer/spacer = human_npc_build_in_zone(/mob/living/carbon/human/npc/sample/raider/unit_test_spacer, 1) + TEST_ASSERT(istype(spacer.wear_suit, /obj/item/clothing/suit/space/pirate), "An NPC dressed for vacuum has no space suit") + TEST_ASSERT(istype(spacer.head, /obj/item/clothing/head/helmet/space), "An NPC dressed for vacuum has no space helmet") + TEST_ASSERT(istype(spacer.s_store, /obj/item/tank/internals), "An NPC dressed for vacuum carries no tank") + TEST_ASSERT(spacer.can_breathe_internals(), "An NPC dressed for vacuum has nothing to breathe its tank through") + TEST_ASSERT_NULL(spacer.internal, "An NPC dressed for vacuum keeps its tank open in good air") + var/turf/spacer_turf = get_turf(spacer) + var/datum/gas_mixture/room_air = spacer_turf.return_air() + var/datum/gas_mixture/saved_air = room_air.copy() + room_air.remove_ratio(1) + spacer.npc_update_internals() + TEST_ASSERT_NOTNULL(spacer.internal, "An NPC in vacuum didn't open its tank") + room_air.copy_from(saved_air) + spacer.npc_update_internals() + TEST_ASSERT_NULL(spacer.internal, "An NPC back in good air didn't shut its tank") + var/obj/item/clothing/suit/space/suit = spacer.wear_suit + TEST_ASSERT(suit?.thermal_on, "An NPC dressed for vacuum didn't switch on its suit's heating") + // Dormant, the regulator is off so the cell lasts; awake, it goes back on. + var/turf/here = get_turf(spacer) + spacer.Life(SSMOBS_DT, 1) + TEST_ASSERT(!suit?.thermal_on, "A dormant NPC kept its suit's heating running") + SSmobs.clients_by_zlevel[here.z] += spacer + spacer.Life(SSMOBS_DT, 2) + SSmobs.clients_by_zlevel[here.z] -= spacer + TEST_ASSERT(suit?.thermal_on, "An NPC that woke didn't switch its suit's heating back on") + TEST_ASSERT(human_npc_gear_locked(spacer.s_store), "The NPC's tank isn't locked to it") + TEST_ASSERT_NOTNULL(human_npc_held_gun(spacer), "The suit layer took the NPC's gun") + + var/mob/living/carbon/human/npc/sample/raider/unit_test_cold/cold = human_npc_build_in_zone(/mob/living/carbon/human/npc/sample/raider/unit_test_cold, 1) + TEST_ASSERT(istype(cold.wear_suit, /obj/item/clothing/suit/hooded/wintercoat), "An NPC dressed for the cold has no coat") + TEST_ASSERT(istype(cold.shoes, /obj/item/clothing/shoes/winterboots), "An NPC dressed for the cold has no winter boots") + TEST_ASSERT_NOTNULL(cold.gloves, "An NPC dressed for the cold has bare hands") + + var/mob/living/carbon/human/npc/sample/raider/unit_test_skeleton/skeleton = human_npc_build_in_zone(/mob/living/carbon/human/npc/sample/raider/unit_test_skeleton, 1) + TEST_ASSERT(istype(skeleton.dna.species, /datum/species/skeleton), "Test fixture: the skeleton isn't a skeleton") + TEST_ASSERT(!istype(skeleton.wear_suit, /obj/item/clothing/suit/space), "A skeleton was put in a space suit it doesn't need") + +/// N8: a living NPC walking out is deleted on its exit or out of sight, never while down, cuffed or +/// dragged; what isn't gear drops where it stood. +/datum/unit_test/voidcrew_human_npc_walk_out + var/left_called = FALSE + +/datum/unit_test/voidcrew_human_npc_walk_out/proc/on_left(mob/living/carbon/human/npc/leaver) + left_called = TRUE + +/datum/unit_test/voidcrew_human_npc_walk_out/Run() + var/turf/exit = locate(run_loc_floor_bottom_left.x + 3, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z) + var/mob/living/carbon/human/npc/sample/gunner/npc = allocate(/mob/living/carbon/human/npc/sample/gunner) + var/obj/item/ship_key/key = allocate(/obj/item/ship_key) + TEST_ASSERT(npc.equip_to_slot_if_possible(key, ITEM_SLOT_LPOCKET), "Test fixture: the key would not go in the NPC's pocket") + TEST_ASSERT(!npc.npc_may_vanish(), "An NPC that isn't leaving may vanish") + TEST_ASSERT(npc.npc_walk_out(exit, CALLBACK(src, PROC_REF(on_left))), "The NPC would not walk out") + TEST_ASSERT(npc in SShuman_npcs.leavers, "A leaving NPC isn't tracked") + TEST_ASSERT_EQUAL(npc.ai_controller.blackboard["human_npc_exit"], exit, "The NPC's AI doesn't know its exit") + + var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs) + TEST_ASSERT(npc.equip_to_slot_if_possible(cuffs, ITEM_SLOT_HANDCUFFED), "Test fixture: the NPC could not be cuffed") + TEST_ASSERT(!npc.npc_may_vanish(), "A cuffed NPC may vanish") + npc.uncuff() + var/mob/living/carbon/human/consistent/dragger = 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)) + dragger.start_pulling(npc) + TEST_ASSERT(!npc.npc_may_vanish(), "An NPC being dragged may vanish") + dragger.stop_pulling() + npc.adjustOxyLoss(110) + TEST_ASSERT(!npc.npc_may_vanish(), "An NPC in crit may vanish") + npc.setOxyLoss(0) + + // Free and with no player on the test level to see it: it may go. + TEST_ASSERT(npc.npc_may_vanish(), "A free NPC nobody can see may not vanish") + npc.npc_stop_leaving() + TEST_ASSERT(!npc.npc_may_vanish(), "An NPC called back may still vanish") + TEST_ASSERT(!(npc in SShuman_npcs.leavers), "An NPC called back is still tracked as leaving") + + npc.npc_walk_out(exit, CALLBACK(src, PROC_REF(on_left))) + SShuman_npcs.sweep_leavers() + TEST_ASSERT(QDELETED(npc), "The sweep left a free, unwatched NPC that was walking out") + TEST_ASSERT(left_called, "Walking out didn't call back") + TEST_ASSERT(!QDELETED(key) && isturf(key.loc), "The ship key went with the NPC that walked out") + +/// N1 and OC-11: papers aren't gear and drop when the NPC dies; medical stacks are consumables; an NPC +/// whose gear isn't locked (a prisoner) carries ordinary items players can take. +/datum/unit_test/voidcrew_human_npc_gear_rules + +/datum/unit_test/voidcrew_human_npc_gear_rules/Run() + var/mob/living/carbon/human/npc/sample/gunner/npc = allocate(/mob/living/carbon/human/npc/sample/gunner) + var/obj/item/paper/note = allocate(/obj/item/paper) + TEST_ASSERT(npc.equip_to_slot_if_possible(note, ITEM_SLOT_LPOCKET), "Test fixture: the paper would not go in the NPC's pocket") + TEST_ASSERT(!npc.npc_lock_item(note), "A paper was locked to an NPC as gear") + var/obj/item/stack/medical/bruise_pack/pack = allocate(/obj/item/stack/medical/bruise_pack) + TEST_ASSERT(npc.put_in_hands(pack), "Test fixture: the NPC could not hold a bruise pack") + TEST_ASSERT(npc.npc_lock_item(pack) && human_npc_gear_consumable(pack), "A bruise pack wasn't issued as a consumable") + npc.death() + TEST_ASSERT(!QDELETED(note) && isturf(note.loc), "A paper didn't drop when its NPC died") + + var/mob/living/carbon/human/npc/sample/gunner/unit_test_prisoner/prisoner = allocate(/mob/living/carbon/human/npc/sample/gunner/unit_test_prisoner, locate(run_loc_floor_bottom_left.x + 1, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z)) + var/mob/living/carbon/human/consistent/guard = allocate(/mob/living/carbon/human/consistent) + var/obj/item/gun/gun = locate() in prisoner.held_items + TEST_ASSERT_NOTNULL(gun, "Test fixture: the prisoner holds nothing") + TEST_ASSERT(!human_npc_gear_locked(gun), "An unlocked NPC's gun is locked") + TEST_ASSERT(!human_npc_gear_locked(prisoner.w_uniform), "An unlocked NPC's jumpsuit is locked") + TEST_ASSERT(prisoner.should_strip(guard), "An unlocked NPC can't be searched") + TEST_ASSERT(prisoner.dropItemToGround(gun), "An unlocked NPC can't let go of its gun") + sleep(2) + TEST_ASSERT(!QDELETED(gun) && isturf(gun.loc), "An unlocked NPC's dropped gun was deleted") + +/** + * Phase E follow-ups to the spawn queue: an order built later checks that its spot is still the place it + * was queued for (a ruin unloaded while it waited), and the NPC faces the way it was told (a mapped + * spawner's dir). + */ +/datum/unit_test/voidcrew_human_npc_order_spot + +/datum/unit_test/voidcrew_human_npc_order_spot/Run() + var/datum/human_npc_order/facing = spawn_human_npc(/mob/living/carbon/human/npc/sample/gunner, run_loc_floor_bottom_left, immediate = TRUE, dir = EAST) + var/mob/living/carbon/human/npc/facer = facing.spawned_ref?.resolve() + TEST_ASSERT_NOTNULL(facer, "An order for the test floor built nothing") + if(facer) + allocated += facer + TEST_ASSERT_EQUAL(facer.dir, EAST, "An NPC built with a dir doesn't face it") + var/datum/human_npc_order/moved_on = new /datum/human_npc_order(/mob/living/carbon/human/npc/sample/gunner, run_loc_floor_bottom_left) + TEST_ASSERT(moved_on.spot_still_valid(), "A fresh order's spot doesn't count as its own") + // The ground was reused while it waited: its area is not the one it was queued in. + moved_on.where_area = null + TEST_ASSERT_NULL(moved_on.fulfil(), "An order whose spot was reused still built its NPC there") + qdel(moved_on) diff --git a/voidcrew/modules/unit_tests/voidcrew_hyperviolence_overlays_exec.dm b/voidcrew/modules/unit_tests/voidcrew_hyperviolence_overlays_exec.dm index 63e4346d160..15677552d34 100644 --- a/voidcrew/modules/unit_tests/voidcrew_hyperviolence_overlays_exec.dm +++ b/voidcrew/modules/unit_tests/voidcrew_hyperviolence_overlays_exec.dm @@ -163,6 +163,19 @@ 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 +/// 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 + +/datum/unit_test/hv_npc_executable_states/Run() + var/mob/living/carbon/human/npc/npc = allocate(/mob/living/carbon/human/npc) + QDEL_NULL(npc.ai_controller) + TEST_ASSERT(!npc.hv_can_be_executed(), "An NPC at full health could be executed") + npc.apply_damage(85, BRUTE, BODY_ZONE_CHEST, wound_bonus = CANT_WOUND) + TEST_ASSERT(npc.stat == CONSCIOUS, "The test NPC fell over at 15 health") + TEST_ASSERT(!npc.hv_can_be_executed(), "An NPC on its feet at 15 health could be executed") + npc.Paralyze(30 SECONDS) + TEST_ASSERT(npc.hv_can_be_executed(), "A paralysed NPC could not be executed") + /// The death throes, given by every human NPC that dies (human_npc_barks.dm), end where they began: the /// body's real transform and offsets are untouched, so tg's lying pose stays right. /datum/unit_test/hv_death_throes_end_where_they_began From f73eed6f30bcd309ea3163a6f1d10d3e32a7ab72 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sun, 15 Nov 2026 15:29:02 -0800 Subject: [PATCH 02/13] Pirate crews, boarders, ruin troopers, hermits and mission NPCs are people These NPCs are now human NPCs (/mob/living/carbon/human/npc): real human bodies with tg's own crit, wounds, cuffs, medicine and death. - NPC-ship pirate crews and boarders of every faction, their captains and bosses, on the pirate crew AI, with real guns, magazines and reloads. Boarders wear their faction's space suits. - NT customs crews, boarders and the Compliance Director. - Ruin, planet and mission troopers (pirate, Syndicate, Nanotrasen, Russian), hermits, poachers, portal storm shocktroopers and shuttle-loan hijackers. They dress by zone, with cold and vacuum gear where they spawn. - Ruin maps place them with /obj/effect/spawner/human_npc/ruin spawners. - Pirate bosses perform the boss finishers; armed pirates take cover from stun fire and use a stimulant. - The basic-mob pirate, hermit and customs types are removed, and tg's trooper file is back to upstream. --- .../RandomRuins/BeachRuins/fishing_hut.dmm | 4 +- .../RandomRuins/BeachRuins/push_it.dmm | 28 +- .../icemoon_underground_syndielab.dmm | 4 +- .../RandomRuins/JungleRuins/jungle_pirate.dmm | 12 +- .../JungleRuins/jungle_syndicate.dmm | 4 +- .../RandomRuins/SpaceRuins/caravanambush.dmm | 22 +- .../SpaceRuins/derelict_construction.dmm | 4 +- .../RandomRuins/SpaceRuins/forgottenship.dmm | 8 +- .../RandomRuins/SpaceRuins/garbagetruck2.dmm | 2 +- .../RandomRuins/SpaceRuins/garbagetruck3.dmm | 2 +- .../SpaceRuins/rare_pirate_cove.dmm | 12 +- .../RandomRuins/SpaceRuins/the_faceoff.dmm | 2 +- .../RandomRuins/SpaceRuins/waystation.dmm | 10 +- .../wasteland_fortress_of_solitide.dmm | 2 +- .../WastelandRuins/wasteland_pod.dmm | 2 +- .../WastelandRuins/wasteland_soviet.dmm | 6 +- .../wasteland_surface_camp_adobe.dmm | 32 +- .../wasteland_surface_camp_drugstore.dmm | 2 +- .../wasteland_surface_camp_saloon.dmm | 22 +- .../wasteland_surface_chokepoint.dmm | 18 +- .../wasteland_surface_crash_bar.dmm | 25 +- .../wasteland_surface_crash_cargo.dmm | 10 +- .../wasteland_surface_onlyaspoonful.dmm | 10 +- .../wasteland_surface_starfurycrash.dmm | 6 +- _maps/voidcrew/ships/ship_hightide.dmm | 6 +- .../voidcrew/shuttles/ruin_caravan_victim.dmm | 1225 +++++++++++++++++ .../voidcrew/shuttles/ruin_pirate_cutter.dmm | 1177 ++++++++++++++++ .../shuttles/ruin_syndicate_dropship.dmm | 620 +++++++++ .../shuttles/ruin_syndicate_fighter_shiv.dmm | 156 +++ .../mob/living/basic/trooper/trooper.dm | 3 +- .../unit_tests/simple_animal_freeze.dm | 6 - tgstation.dme | 11 +- voidcrew/controllers/subsystem/planet_mobs.dm | 2 +- voidcrew/datums/mapgen/PlanetGenerator.dm | 2 +- voidcrew/datums/mapgen/biomes/_biome.dm | 2 +- voidcrew/datums/mapgen/biomes/beach_biomes.dm | 8 +- .../datums/mapgen/biomes/wasteland_biomes.dm | 8 +- voidcrew/edits/mobs/weapon_drops.dm | 9 +- .../mob/living/basic/trooper/trooper.dm | 5 - .../modules/cargo/shipping/_shuttle_loan.dm | 17 +- .../dynamic_events/events/portal_storm.dm | 23 +- .../human_npcs/human_npc_outfits_pirates.dm | 398 ++++++ .../modules/human_npcs/ruins/ruin_npc_base.dm | 145 ++ .../human_npcs/ruins/ruin_npc_hermits.dm | 89 ++ .../human_npcs/ruins/ruin_npc_spawners.dm | 111 ++ .../human_npcs/ruins/ruin_npc_troopers.dm | 596 ++++++++ voidcrew/modules/lich/lich_spells.dm | 7 +- voidcrew/modules/loot/themes/plunder.dm | 44 +- voidcrew/modules/loot/zone_mobs.dm | 2 +- .../modules/missions/missions/poacher_bust.dm | 104 +- .../modules/missions/missions/recovery.dm | 43 +- .../modules/missions/objectives/combat.dm | 72 +- .../living/simple_animal/hostile/pirate.dm | 23 - .../hostile/wasteland/hermits.dm | 92 -- voidcrew/modules/npc_ships/code/_defines.dm | 39 + .../modules/npc_ships/code/admin_verbs.dm | 72 +- .../code/behaviors/ship_combat_behaviors.dm | 18 +- .../modules/npc_ships/code/boarding_pod.dm | 89 +- .../faction_pirates/faction_pirate_corpses.dm | 4 +- .../faction_pirates/faction_pirate_humans.dm | 834 +++++++++++ .../faction_pirates/faction_pirate_mobs.dm | 64 +- .../faction_pirates/faction_pirate_ships.dm | 71 +- .../code/faction_pirates/nt_patrol.dm | 284 ++-- voidcrew/modules/npc_ships/code/mob_patrol.dm | 27 +- voidcrew/modules/npc_ships/code/npc_ship.dm | 155 ++- .../npc_ships/code/npc_ship_controller.dm | 152 +- .../modules/npc_ships/code/pirate_crew.dm | 129 +- .../modules/npc_ships/code/pirate_crew_ai.dm | 71 +- .../code/pirate_crew_combat_sense.dm | 47 + .../npc_ships/code/pirate_crew_human.dm | 503 +++++++ .../modules/npc_ships/code/pirate_guns.dm | 419 ++---- .../npc_ships/code/spawner_subsystem.dm | 10 +- voidcrew/modules/unit_tests/_unit_tests.dm | 3 + .../modules/unit_tests/voidcrew_human_npcs.dm | 2 + .../voidcrew_human_npcs_nt_customs.dm | 73 + .../unit_tests/voidcrew_human_npcs_ruins.dm | 271 ++++ .../unit_tests/voidcrew_human_npcs_shared.dm | 25 + .../voidcrew_mission_console_rewards.dm | 13 +- .../modules/unit_tests/voidcrew_missions.dm | 1 - .../unit_tests/voidcrew_npc_zone_profiles.dm | 7 +- .../unit_tests/voidcrew_pirate_crew_ai.dm | 140 +- .../unit_tests/voidcrew_pirate_crew_human.dm | 487 +++++++ .../unit_tests/voidcrew_planetary_factions.dm | 7 +- .../unit_tests/voidcrew_simple_mob_ai.dm | 6 +- voidcrew/objects/structures/spawner.dm | 7 +- 85 files changed, 8047 insertions(+), 1238 deletions(-) create mode 100644 _maps/voidcrew/shuttles/ruin_caravan_victim.dmm create mode 100644 _maps/voidcrew/shuttles/ruin_pirate_cutter.dmm create mode 100644 _maps/voidcrew/shuttles/ruin_syndicate_dropship.dmm create mode 100644 _maps/voidcrew/shuttles/ruin_syndicate_fighter_shiv.dmm delete mode 100644 voidcrew/edits/modules/mob/living/basic/trooper/trooper.dm create mode 100644 voidcrew/modules/human_npcs/human_npc_outfits_pirates.dm create mode 100644 voidcrew/modules/human_npcs/ruins/ruin_npc_base.dm create mode 100644 voidcrew/modules/human_npcs/ruins/ruin_npc_hermits.dm create mode 100644 voidcrew/modules/human_npcs/ruins/ruin_npc_spawners.dm create mode 100644 voidcrew/modules/human_npcs/ruins/ruin_npc_troopers.dm delete mode 100644 voidcrew/modules/mob/living/simple_animal/hostile/pirate.dm delete mode 100644 voidcrew/modules/mob/living/simple_animal/hostile/wasteland/hermits.dm create mode 100644 voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_humans.dm create mode 100644 voidcrew/modules/npc_ships/code/pirate_crew_combat_sense.dm create mode 100644 voidcrew/modules/npc_ships/code/pirate_crew_human.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_human_npcs_nt_customs.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_human_npcs_ruins.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_pirate_crew_human.dm diff --git a/_maps/voidcrew/RandomRuins/BeachRuins/fishing_hut.dmm b/_maps/voidcrew/RandomRuins/BeachRuins/fishing_hut.dmm index 8f5cad05fc2..1905f78ca0a 100644 --- a/_maps/voidcrew/RandomRuins/BeachRuins/fishing_hut.dmm +++ b/_maps/voidcrew/RandomRuins/BeachRuins/fishing_hut.dmm @@ -372,7 +372,7 @@ /turf/template_noop, /area/template_noop) "qU" = ( -/mob/living/basic/trooper/pirate/melee, +/obj/effect/spawner/human_npc/ruin/pirate, /obj/structure/chair/stool/directional/west, /turf/open/floor/bamboo/tatami, /area/ruin/powered{ @@ -853,7 +853,7 @@ /turf/open/misc/asteroid/sand/beach, /area/overmap_encounter/planetoid/beach) "Mn" = ( -/mob/living/basic/trooper/pirate/ranged, +/obj/effect/spawner/human_npc/ruin/pirate/gunner, /obj/structure/chair/stool/directional/east, /turf/open/floor/bamboo/tatami, /area/ruin/powered{ diff --git a/_maps/voidcrew/RandomRuins/BeachRuins/push_it.dmm b/_maps/voidcrew/RandomRuins/BeachRuins/push_it.dmm index 611652c7469..74926bbff22 100644 --- a/_maps/voidcrew/RandomRuins/BeachRuins/push_it.dmm +++ b/_maps/voidcrew/RandomRuins/BeachRuins/push_it.dmm @@ -157,7 +157,7 @@ /area/overmap_encounter/planetoid/beach) "dG" = ( /obj/structure/chair, -/mob/living/basic/trooper/russian/ranged, +/obj/effect/spawner/human_npc/ruin/russian/gunner, /obj/effect/turf_decal/siding/thinplating_new/dark{ dir = 8 }, @@ -244,7 +244,7 @@ /obj/structure/chair{ dir = 4 }, -/mob/living/basic/trooper/russian/ranged, +/obj/effect/spawner/human_npc/ruin/russian/gunner, /turf/open/floor/iron/dark, /area/ruin/powered) "ia" = ( @@ -338,7 +338,7 @@ /turf/template_noop, /area/template_noop) "mf" = ( -/mob/living/basic/trooper/russian, +/obj/effect/spawner/human_npc/ruin/russian, /turf/open/floor/carpet/neon/simple/violet/nodots, /area/ruin/powered) "ms" = ( @@ -365,7 +365,7 @@ /turf/open/floor/carpet/neon/simple/violet, /area/ruin/powered) "mK" = ( -/mob/living/basic/trooper/russian, +/obj/effect/spawner/human_npc/ruin/russian, /obj/effect/turf_decal/siding/thinplating_new/dark{ dir = 1 }, @@ -532,7 +532,7 @@ /area/ruin/powered) "sv" = ( /obj/structure/chair/stool/directional/north, -/mob/living/basic/trooper/russian, +/obj/effect/spawner/human_npc/ruin/russian, /turf/open/floor/carpet/neon/simple/violet/nodots, /area/ruin/powered) "sP" = ( @@ -602,7 +602,7 @@ /area/ruin/powered) "ve" = ( /obj/structure/toilet, -/mob/living/basic/trooper/russian, +/obj/effect/spawner/human_npc/ruin/russian, /obj/machinery/light/small/directional/north, /turf/open/floor/iron/dark/smooth_large, /area/ruin/powered) @@ -738,7 +738,7 @@ /obj/structure/chair/sofa/corp/right{ dir = 1 }, -/mob/living/basic/trooper/russian/ranged, +/obj/effect/spawner/human_npc/ruin/russian/gunner, /turf/open/floor/carpet/neon/simple/violet, /area/ruin/powered) "Cz" = ( @@ -817,7 +817,7 @@ /obj/effect/turf_decal/siding/thinplating_new/dark{ dir = 1 }, -/mob/living/basic/trooper/russian/ranged, +/obj/effect/spawner/human_npc/ruin/russian/gunner, /turf/open/floor/iron/dark/smooth_large, /area/ruin/powered) "Fw" = ( @@ -1065,7 +1065,7 @@ /turf/open/floor/iron/dark, /area/ruin/powered) "Pl" = ( -/mob/living/basic/trooper/russian/ranged, +/obj/effect/spawner/human_npc/ruin/russian/gunner, /turf/open/floor/light/colour_cycle/dancefloor_a, /area/ruin/powered) "Pq" = ( @@ -1085,7 +1085,7 @@ /area/template_noop) "Qw" = ( /obj/structure/chair/sofa/corp/corner, -/mob/living/basic/trooper/russian, +/obj/effect/spawner/human_npc/ruin/russian, /turf/open/floor/carpet/neon/simple/violet, /area/ruin/powered) "QN" = ( @@ -1169,7 +1169,7 @@ "SV" = ( /obj/structure/mirror/directional/north, /obj/structure/sink/directional/south, -/mob/living/basic/trooper/russian/ranged, +/obj/effect/spawner/human_npc/ruin/russian/gunner, /obj/machinery/light/blacklight/directional/west, /turf/open/floor/iron/dark/smooth_large, /area/ruin/powered) @@ -1218,7 +1218,7 @@ /turf/open/floor/carpet/neon/simple/violet, /area/ruin/powered) "Ux" = ( -/mob/living/basic/trooper/russian, +/obj/effect/spawner/human_npc/ruin/russian, /turf/open/floor/light/colour_cycle/dancefloor_a, /area/ruin/powered) "UU" = ( @@ -1257,7 +1257,7 @@ /obj/structure/chair/sofa/corp/corner{ dir = 8 }, -/mob/living/basic/trooper/russian, +/obj/effect/spawner/human_npc/ruin/russian, /turf/open/floor/iron/dark/smooth_large, /area/ruin/powered) "VX" = ( @@ -1292,7 +1292,7 @@ /obj/structure/chair{ dir = 1 }, -/mob/living/basic/trooper/russian, +/obj/effect/spawner/human_npc/ruin/russian, /obj/effect/turf_decal/siding/thinplating_new/dark{ dir = 8 }, diff --git a/_maps/voidcrew/RandomRuins/IceRuins/icemoon_underground_syndielab.dmm b/_maps/voidcrew/RandomRuins/IceRuins/icemoon_underground_syndielab.dmm index 384d19ad3bf..4bb94e40177 100644 --- a/_maps/voidcrew/RandomRuins/IceRuins/icemoon_underground_syndielab.dmm +++ b/_maps/voidcrew/RandomRuins/IceRuins/icemoon_underground_syndielab.dmm @@ -18,13 +18,13 @@ /turf/open/floor/mineral/plastitanium/red, /area/ruin/syndielab) "ae" = ( -/mob/living/basic/trooper/syndicate/ranged, +/obj/effect/spawner/human_npc/ruin/syndicate/gunner, /obj/structure/cable/layer1, /turf/open/floor/iron/dark/textured, /area/ruin/syndielab) "af" = ( /obj/structure/chair/sofa/corp/right, -/mob/living/basic/trooper/syndicate/ranged, +/obj/effect/spawner/human_npc/ruin/syndicate/gunner, /obj/machinery/light/warm/directional/north, /obj/structure/cable/layer1, /turf/open/floor/iron/dark/textured, diff --git a/_maps/voidcrew/RandomRuins/JungleRuins/jungle_pirate.dmm b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_pirate.dmm index c702a41efa4..3dc2f3b3ac2 100644 --- a/_maps/voidcrew/RandomRuins/JungleRuins/jungle_pirate.dmm +++ b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_pirate.dmm @@ -167,7 +167,7 @@ /obj/structure/railing{ dir = 4 }, -/mob/living/basic/trooper/pirate/ranged, +/obj/effect/spawner/human_npc/ruin/pirate/gunner, /turf/open/floor/wood, /area/ruin/unpowered) "rc" = ( @@ -242,11 +242,11 @@ /turf/open/floor/wood, /area/ruin/unpowered) "DH" = ( -/mob/living/basic/trooper/pirate/ranged/space, +/obj/effect/spawner/human_npc/ruin/pirate/space/gunner, /turf/open/floor/carpet/red, /area/ruin/unpowered) "DS" = ( -/mob/living/basic/trooper/pirate/ranged, +/obj/effect/spawner/human_npc/ruin/pirate/gunner, /turf/open/floor/wood, /area/ruin/unpowered) "DV" = ( @@ -296,7 +296,7 @@ /turf/open/floor/wood, /area/ruin/unpowered) "LT" = ( -/mob/living/basic/trooper/pirate/melee, +/obj/effect/spawner/human_npc/ruin/pirate, /obj/structure/chair/wood, /obj/effect/decal/cleanable/dirt, /turf/open/floor/wood, @@ -366,7 +366,7 @@ /turf/open/misc/dirt/jungle, /area/ruin/unpowered) "UX" = ( -/mob/living/basic/trooper/pirate/melee, +/obj/effect/spawner/human_npc/ruin/pirate, /turf/open/floor/wood, /area/ruin/unpowered) "Vf" = ( @@ -396,7 +396,7 @@ /turf/open/floor/carpet/red, /area/ruin/unpowered) "XA" = ( -/mob/living/basic/trooper/pirate/melee, +/obj/effect/spawner/human_npc/ruin/pirate, /obj/effect/decal/cleanable/dirt, /turf/open/floor/wood, /area/ruin/unpowered) diff --git a/_maps/voidcrew/RandomRuins/JungleRuins/jungle_syndicate.dmm b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_syndicate.dmm index 22c2ce8c137..1d7fb523f84 100644 --- a/_maps/voidcrew/RandomRuins/JungleRuins/jungle_syndicate.dmm +++ b/_maps/voidcrew/RandomRuins/JungleRuins/jungle_syndicate.dmm @@ -129,7 +129,7 @@ /area/ruin/powered) "G" = ( /obj/structure/cable, -/mob/living/basic/trooper/syndicate, +/obj/effect/spawner/human_npc/ruin/syndicate, /turf/open/floor/plating, /area/ruin/powered) "H" = ( @@ -148,7 +148,7 @@ /area/ruin/unpowered) "K" = ( /obj/structure/chair/plastic, -/mob/living/basic/trooper/syndicate/ranged, +/obj/effect/spawner/human_npc/ruin/syndicate/gunner, /turf/open/floor/plating, /area/ruin/powered) "M" = ( diff --git a/_maps/voidcrew/RandomRuins/SpaceRuins/caravanambush.dmm b/_maps/voidcrew/RandomRuins/SpaceRuins/caravanambush.dmm index 0189b72e62b..9c3bd502369 100644 --- a/_maps/voidcrew/RandomRuins/SpaceRuins/caravanambush.dmm +++ b/_maps/voidcrew/RandomRuins/SpaceRuins/caravanambush.dmm @@ -29,9 +29,7 @@ /area/template_noop) "ah" = ( /obj/structure/lattice/catwalk, -/mob/living/basic/trooper/pirate/ranged/space{ - environment_smash = 0 - }, +/obj/effect/spawner/human_npc/ruin/pirate/space/gunner, /turf/template_noop, /area/template_noop) "ai" = ( @@ -60,7 +58,7 @@ /area/shuttle/ruin/caravan/freighter2) "al" = ( /obj/effect/decal/cleanable/dirt, -/mob/living/basic/trooper/syndicate/ranged/space, +/obj/effect/spawner/human_npc/ruin/syndicate/commando/gunner, /turf/open/floor/iron/airless, /area/shuttle/ruin/caravan/freighter3) "am" = ( @@ -74,7 +72,7 @@ dir = 4 }, /obj/effect/decal/cleanable/dirt, -/mob/living/basic/trooper/syndicate/ranged/space, +/obj/effect/spawner/human_npc/ruin/syndicate/commando/gunner, /turf/open/floor/iron/airless, /area/shuttle/ruin/caravan/freighter3) "ao" = ( @@ -85,7 +83,7 @@ /obj/effect/turf_decal/box/white/corners{ dir = 4 }, -/mob/living/basic/trooper/syndicate/ranged/space, +/obj/effect/spawner/human_npc/ruin/syndicate/commando/gunner, /turf/open/floor/iron/dark/airless, /area/shuttle/ruin/caravan/freighter3) "aD" = ( @@ -623,9 +621,7 @@ dir = 4 }, /obj/effect/decal/cleanable/dirt, -/mob/living/basic/trooper/pirate/ranged/space{ - environment_smash = 0 - }, +/obj/effect/spawner/human_npc/ruin/pirate/space/gunner, /turf/open/floor/iron/airless, /area/shuttle/ruin/caravan/freighter2) "wC" = ( @@ -755,9 +751,7 @@ /area/ruin/space/has_grav) "Fr" = ( /obj/effect/decal/cleanable/dirt, -/mob/living/basic/trooper/pirate/ranged/space{ - environment_smash = 0 - }, +/obj/effect/spawner/human_npc/ruin/pirate/space/gunner, /turf/open/floor/plating/airless, /area/shuttle/ruin/caravan/freighter2) "FG" = ( @@ -956,9 +950,7 @@ "Nm" = ( /obj/machinery/atmospherics/components/unary/vent_pump/on, /obj/effect/decal/cleanable/dirt, -/mob/living/basic/trooper/pirate/ranged/space{ - environment_smash = 0 - }, +/obj/effect/spawner/human_npc/ruin/pirate/space/gunner, /turf/open/floor/iron/airless, /area/shuttle/ruin/caravan/freighter2) "NJ" = ( diff --git a/_maps/voidcrew/RandomRuins/SpaceRuins/derelict_construction.dmm b/_maps/voidcrew/RandomRuins/SpaceRuins/derelict_construction.dmm index cfaca1c8c3b..9dc7a53c439 100644 --- a/_maps/voidcrew/RandomRuins/SpaceRuins/derelict_construction.dmm +++ b/_maps/voidcrew/RandomRuins/SpaceRuins/derelict_construction.dmm @@ -36,7 +36,7 @@ /area/ruin/space/has_grav/derelictconstruction) "fa" = ( /obj/structure/lattice, -/mob/living/basic/trooper/pirate/ranged/space, +/obj/effect/spawner/human_npc/ruin/pirate/space/gunner, /turf/template_noop, /area/space/nearstation) "gi" = ( @@ -438,7 +438,7 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/derelictconstruction) "Za" = ( -/mob/living/basic/trooper/pirate/melee/space, +/obj/effect/spawner/human_npc/ruin/pirate/space, /obj/structure/lattice/catwalk, /turf/template_noop, /area/ruin/space/has_grav/derelictconstruction) diff --git a/_maps/voidcrew/RandomRuins/SpaceRuins/forgottenship.dmm b/_maps/voidcrew/RandomRuins/SpaceRuins/forgottenship.dmm index 9e743c22eb0..fd8752ec4a3 100644 --- a/_maps/voidcrew/RandomRuins/SpaceRuins/forgottenship.dmm +++ b/_maps/voidcrew/RandomRuins/SpaceRuins/forgottenship.dmm @@ -168,7 +168,7 @@ /turf/open/floor/mineral/plastitanium, /area/ruin/space/has_grav/syndicate_forgotten_ship) "aG" = ( -/mob/living/basic/trooper/nanotrasen/ranged, +/obj/effect/spawner/human_npc/ruin/nanotrasen, /turf/open/floor/mineral/plastitanium/red, /area/ruin/space/has_grav/syndicate_forgotten_ship) "aH" = ( @@ -190,7 +190,7 @@ dir = 10 }, /obj/item/wrench, -/mob/living/basic/trooper/nanotrasen/ranged, +/obj/effect/spawner/human_npc/ruin/nanotrasen, /turf/open/floor/mineral/plastitanium/red, /area/ruin/space/has_grav/syndicate_forgotten_ship) "aK" = ( @@ -214,7 +214,7 @@ /area/ruin/space/has_grav/syndicate_forgotten_ship) "aN" = ( /obj/machinery/light/directional/south, -/mob/living/basic/trooper/nanotrasen/ranged, +/obj/effect/spawner/human_npc/ruin/nanotrasen, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/syndicate_forgotten_ship) "aO" = ( @@ -299,7 +299,7 @@ /obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ dir = 4 }, -/mob/living/basic/trooper/nanotrasen/ranged, +/obj/effect/spawner/human_npc/ruin/nanotrasen, /turf/open/floor/mineral/plastitanium, /area/ruin/space/has_grav/syndicate_forgotten_ship) "bd" = ( diff --git a/_maps/voidcrew/RandomRuins/SpaceRuins/garbagetruck2.dmm b/_maps/voidcrew/RandomRuins/SpaceRuins/garbagetruck2.dmm index fd128120432..d16dfe16136 100644 --- a/_maps/voidcrew/RandomRuins/SpaceRuins/garbagetruck2.dmm +++ b/_maps/voidcrew/RandomRuins/SpaceRuins/garbagetruck2.dmm @@ -262,7 +262,7 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/garbagetruck/medicalwaste) "wh" = ( -/mob/living/basic/trooper/syndicate/ranged, +/obj/effect/spawner/human_npc/ruin/syndicate/gunner, /turf/open/floor/plating, /area/ruin/space/has_grav/garbagetruck/medicalwaste) "wk" = ( diff --git a/_maps/voidcrew/RandomRuins/SpaceRuins/garbagetruck3.dmm b/_maps/voidcrew/RandomRuins/SpaceRuins/garbagetruck3.dmm index 6575a90d588..a9db1cac58f 100644 --- a/_maps/voidcrew/RandomRuins/SpaceRuins/garbagetruck3.dmm +++ b/_maps/voidcrew/RandomRuins/SpaceRuins/garbagetruck3.dmm @@ -708,7 +708,7 @@ "JR" = ( /obj/effect/decal/cleanable/ash, /obj/effect/decal/cleanable/blood/splatter/oil, -/mob/living/basic/trooper/russian, +/obj/effect/spawner/human_npc/ruin/russian, /turf/open/floor/plating/dumpsterair, /area/ruin/space/has_grav/garbagetruck/squat) "JW" = ( diff --git a/_maps/voidcrew/RandomRuins/SpaceRuins/rare_pirate_cove.dmm b/_maps/voidcrew/RandomRuins/SpaceRuins/rare_pirate_cove.dmm index 070986d9901..81402127f2c 100644 --- a/_maps/voidcrew/RandomRuins/SpaceRuins/rare_pirate_cove.dmm +++ b/_maps/voidcrew/RandomRuins/SpaceRuins/rare_pirate_cove.dmm @@ -68,7 +68,7 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "ao" = ( -/mob/living/basic/trooper/pirate/melee/space, +/obj/effect/spawner/human_npc/ruin/pirate/space, /turf/open/misc/asteroid, /area/ruin/space/has_grav/powered) "ap" = ( @@ -176,7 +176,7 @@ /turf/open/misc/asteroid, /area/ruin/space/has_grav/powered) "aL" = ( -/mob/living/basic/trooper/pirate/ranged, +/obj/effect/spawner/human_npc/ruin/pirate/gunner, /turf/open/misc/asteroid, /area/ruin/space/has_grav/powered) "aM" = ( @@ -406,7 +406,7 @@ /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "pn" = ( -/mob/living/basic/trooper/pirate/ranged, +/obj/effect/spawner/human_npc/ruin/pirate/gunner, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "rS" = ( @@ -523,7 +523,7 @@ /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "Ej" = ( -/mob/living/basic/trooper/pirate/melee, +/obj/effect/spawner/human_npc/ruin/pirate, /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "Fd" = ( @@ -541,7 +541,7 @@ /turf/open/floor/wood, /area/ruin/space/has_grav/powered) "Hx" = ( -/mob/living/basic/trooper/pirate/ranged/space, +/obj/effect/spawner/human_npc/ruin/pirate/space/gunner, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "JH" = ( @@ -640,7 +640,7 @@ /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "Uv" = ( -/mob/living/basic/trooper/pirate/ranged, +/obj/effect/spawner/human_npc/ruin/pirate/gunner, /turf/open/floor/plating, /area/ruin/space/has_grav/powered) "UQ" = ( diff --git a/_maps/voidcrew/RandomRuins/SpaceRuins/the_faceoff.dmm b/_maps/voidcrew/RandomRuins/SpaceRuins/the_faceoff.dmm index f2e9240f637..a19a80247cc 100644 --- a/_maps/voidcrew/RandomRuins/SpaceRuins/the_faceoff.dmm +++ b/_maps/voidcrew/RandomRuins/SpaceRuins/the_faceoff.dmm @@ -189,7 +189,7 @@ pixel_x = -1; pixel_y = 5 }, -/mob/living/basic/trooper/syndicate/melee/space, +/obj/effect/spawner/human_npc/ruin/syndicate/commando, /turf/open/floor/iron/dark/airless, /area/ruin/space) "eU" = ( diff --git a/_maps/voidcrew/RandomRuins/SpaceRuins/waystation.dmm b/_maps/voidcrew/RandomRuins/SpaceRuins/waystation.dmm index 6faae6d9085..ca04e714348 100644 --- a/_maps/voidcrew/RandomRuins/SpaceRuins/waystation.dmm +++ b/_maps/voidcrew/RandomRuins/SpaceRuins/waystation.dmm @@ -18,7 +18,7 @@ /turf/open/floor/iron, /area/ruin/space/has_grav/waystation/cargobay) "ad" = ( -/mob/living/basic/trooper/syndicate/ranged/space, +/obj/effect/spawner/human_npc/ruin/syndicate/commando/gunner, /obj/item/ammo_casing/shotgun/buckshot/spent{ pixel_x = 3; pixel_y = 10 @@ -35,14 +35,14 @@ /area/ruin/space/has_grav/waystation/dorms) "ae" = ( /obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden/layer4, -/mob/living/basic/trooper/syndicate/ranged/space, +/obj/effect/spawner/human_npc/ruin/syndicate/commando/gunner, /obj/structure/cable, /turf/open/floor/iron, /area/ruin/space/has_grav/waystation/cargooffice) "af" = ( /obj/effect/turf_decal/loading_area/red, /obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden/layer4, -/mob/living/basic/trooper/syndicate/ranged/space, +/obj/effect/spawner/human_npc/ruin/syndicate/commando/gunner, /obj/structure/cable, /turf/open/floor/iron, /area/ruin/space/has_grav/waystation/cargobay) @@ -98,11 +98,11 @@ /turf/open/floor/iron/dark, /area/ruin/space/has_grav/waystation/securestorage) "ah" = ( -/mob/living/basic/trooper/syndicate/melee/space, +/obj/effect/spawner/human_npc/ruin/syndicate/commando, /turf/open/floor/iron/dark, /area/ruin/space/has_grav/waystation/securestorage) "ai" = ( -/mob/living/basic/trooper/syndicate/ranged/space, +/obj/effect/spawner/human_npc/ruin/syndicate/commando/gunner, /turf/open/floor/iron, /area/ruin/space/has_grav/waystation/cargobay) "aj" = ( diff --git a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_fortress_of_solitide.dmm b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_fortress_of_solitide.dmm index 7c2663ddb2e..a65c7b18f99 100644 --- a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_fortress_of_solitide.dmm +++ b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_fortress_of_solitide.dmm @@ -2017,7 +2017,7 @@ /obj/structure/chair/wood{ dir = 8 }, -/mob/living/basic/trooper/russian{ +/obj/effect/spawner/human_npc/ruin/russian{ dir = 8 }, /turf/open/floor/wood, diff --git a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_pod.dmm b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_pod.dmm index 986dda90c83..9cc06996557 100644 --- a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_pod.dmm +++ b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_pod.dmm @@ -81,7 +81,7 @@ /area/overmap_encounter/planetoid/wasteland) "K" = ( /obj/effect/decal/cleanable/dirt, -/mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter, +/obj/effect/spawner/human_npc/ruin/hermit/hunter, /turf/open/floor/pod/dark, /area/overmap_encounter/planetoid/wasteland) "M" = ( diff --git a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_soviet.dmm b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_soviet.dmm index 0d6dae8b6c3..fc1decc8833 100644 --- a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_soviet.dmm +++ b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_soviet.dmm @@ -101,7 +101,7 @@ "sr" = ( /obj/effect/decal/cleanable/wrapping, /obj/structure/cable, -/mob/living/basic/trooper/russian, +/obj/effect/spawner/human_npc/ruin/russian, /turf/open/floor/plating/rust, /area/ruin) "sV" = ( @@ -191,7 +191,7 @@ /area/ruin) "Fg" = ( /obj/structure/chair/comfy/beige, -/mob/living/basic/trooper/russian/ranged, +/obj/effect/spawner/human_npc/ruin/russian/gunner, /obj/structure/closet/crate/zone_loot/armory, /turf/open/floor/wood, /area/ruin) @@ -265,7 +265,7 @@ /turf/open/misc/wasteland/lit, /area/overmap_encounter/planetoid/wasteland) "VS" = ( -/mob/living/basic/trooper/russian/ranged, +/obj/effect/spawner/human_npc/ruin/russian/gunner, /turf/open/floor/plating, /area/ruin) "WB" = ( diff --git a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_camp_adobe.dmm b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_camp_adobe.dmm index 60616fa2f46..254293218d9 100644 --- a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_camp_adobe.dmm +++ b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_camp_adobe.dmm @@ -22,8 +22,8 @@ /turf/open/floor/plating/rust, /area/ruin/unpowered) "af" = ( -/mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter{ - faction = list("adobe") +/obj/effect/spawner/human_npc/ruin/hermit/hunter{ + npc_faction = list("adobe") }, /turf/open/floor/plating/rust, /area/ruin/unpowered) @@ -50,9 +50,9 @@ /turf/open/floor/plating, /area/ruin/unpowered) "al" = ( -/mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter{ +/obj/effect/spawner/human_npc/ruin/hermit/hunter{ dir = 4; - faction = list("adobe") + npc_faction = list("adobe") }, /turf/open/floor/plating/rust, /area/ruin/unpowered) @@ -104,17 +104,17 @@ /turf/open/floor/plating/rust, /area/ruin/unpowered) "aw" = ( -/mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter{ +/obj/effect/spawner/human_npc/ruin/hermit/hunter{ dir = 4; - faction = list("adobe") + npc_faction = list("adobe") }, /obj/effect/decal/cleanable/dirt, /turf/open/floor/plating, /area/ruin/unpowered) "ax" = ( -/mob/living/simple_animal/hostile/asteroid/hermit/survivor{ +/obj/effect/spawner/human_npc/ruin/hermit{ dir = 4; - faction = list("adobe") + npc_faction = list("adobe") }, /turf/open/misc/wasteland/lit, /area/overmap_encounter/planetoid/wasteland) @@ -144,23 +144,23 @@ /area/ruin/unpowered) "aC" = ( /obj/structure/chair/plastic, -/mob/living/simple_animal/hostile/asteroid/hermit/survivor{ - faction = list("adobe") +/obj/effect/spawner/human_npc/ruin/hermit{ + npc_faction = list("adobe") }, /obj/effect/decal/cleanable/dirt, /turf/open/misc/wasteland/lit, /area/overmap_encounter/planetoid/wasteland) "aD" = ( -/mob/living/simple_animal/hostile/asteroid/hermit/ranged/gunslinger{ +/obj/effect/spawner/human_npc/ruin/hermit/gunslinger{ dir = 4; - faction = list("adobe") + npc_faction = list("adobe") }, /turf/open/floor/plating/rust, /area/ruin/unpowered) "aE" = ( -/mob/living/simple_animal/hostile/asteroid/hermit/survivor{ +/obj/effect/spawner/human_npc/ruin/hermit{ dir = 1; - faction = list("adobe") + npc_faction = list("adobe") }, /obj/effect/decal/cleanable/dirt, /obj/structure/closet/crate/zone_loot/wardrobe, @@ -215,9 +215,9 @@ /obj/structure/chair/plastic{ dir = 4 }, -/mob/living/simple_animal/hostile/asteroid/hermit/survivor{ +/obj/effect/spawner/human_npc/ruin/hermit{ dir = 4; - faction = list("adobe") + npc_faction = list("adobe") }, /obj/effect/decal/cleanable/dirt, /turf/open/misc/wasteland/lit, diff --git a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_camp_drugstore.dmm b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_camp_drugstore.dmm index d5efef03e0c..71ad41c0cac 100644 --- a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_camp_drugstore.dmm +++ b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_camp_drugstore.dmm @@ -54,7 +54,7 @@ /turf/open/floor/wood, /area/ruin/unpowered) "n" = ( -/mob/living/simple_animal/hostile/asteroid/hermit/survivor{ +/obj/effect/spawner/human_npc/ruin/hermit{ dir = 4 }, /turf/open/floor/wood{ diff --git a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_camp_saloon.dmm b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_camp_saloon.dmm index 74e10504e99..1d83e0ededd 100644 --- a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_camp_saloon.dmm +++ b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_camp_saloon.dmm @@ -121,9 +121,9 @@ "hL" = ( /obj/effect/decal/cleanable/dirt, /obj/effect/decal/cleanable/blood/old, -/mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter{ - faction = list("saloon"); - name = "Whitesands Bartender" +/obj/effect/spawner/human_npc/ruin/hermit/hunter{ + npc_faction = list("saloon"); + npc_name = "Whitesands Bartender" }, /turf/open/floor/wood{ broken = 1 @@ -191,9 +191,9 @@ /area/ruin/unpowered) "mr" = ( /obj/structure/chair/stool/bar, -/mob/living/simple_animal/hostile/asteroid/hermit/survivor{ +/obj/effect/spawner/human_npc/ruin/hermit{ dir = 8; - faction = list("saloon") + npc_faction = list("saloon") }, /turf/open/floor/wood{ broken = 1 @@ -205,9 +205,9 @@ /area/ruin/unpowered) "nE" = ( /obj/structure/chair/stool/bar, -/mob/living/simple_animal/hostile/asteroid/hermit/survivor{ +/obj/effect/spawner/human_npc/ruin/hermit{ dir = 1; - faction = list("saloon") + npc_faction = list("saloon") }, /turf/open/floor/wood, /area/ruin/unpowered) @@ -477,9 +477,9 @@ "Ov" = ( /obj/structure/chair/stool/bar, /obj/effect/decal/cleanable/dirt, -/mob/living/simple_animal/hostile/asteroid/hermit/survivor{ +/obj/effect/spawner/human_npc/ruin/hermit{ dir = 8; - faction = list("saloon") + npc_faction = list("saloon") }, /turf/open/floor/wood, /area/ruin/unpowered) @@ -559,9 +559,9 @@ /area/ruin/unpowered) "Xb" = ( /obj/item/chair/stool/bar, -/mob/living/simple_animal/hostile/asteroid/hermit/survivor{ +/obj/effect/spawner/human_npc/ruin/hermit{ dir = 1; - faction = list("saloon") + npc_faction = list("saloon") }, /turf/open/floor/wood, /area/ruin/unpowered) diff --git a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_chokepoint.dmm b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_chokepoint.dmm index 349d0f5e9f0..1ffa9ecc108 100644 --- a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_chokepoint.dmm +++ b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_chokepoint.dmm @@ -31,10 +31,8 @@ "g" = ( /obj/structure/bed, /obj/item/bedsheet/hos, -/mob/living/basic/trooper/nanotrasen/ranged{ - atmos_requirements = list("min_oxy" = 5, "max_oxy" = 0, "min_tox" = 0, "max_tox" = 0, "min_co2" = 0, "max_co2" = 999, "min_n2" = 0, "max_n2" = 0); - damage_coeff = list("brute" = 1, "fire" = 1, "toxin" = 1, "clone" = 1, "stamina" = 0, "oxygen" = 0); - name = "\improper NanoTrasen Stranded Security Officer" +/obj/effect/spawner/human_npc/ruin/nanotrasen{ + npc_name = "NanoTrasen Stranded Security Officer" }, /obj/effect/decal/cleanable/dirt, /turf/open/floor/plating{ @@ -42,11 +40,9 @@ }, /area/ruin/unpowered) "h" = ( -/mob/living/basic/trooper/nanotrasen/ranged{ - atmos_requirements = list("min_oxy" = 5, "max_oxy" = 0, "min_tox" = 0, "max_tox" = 0, "min_co2" = 0, "max_co2" = 999, "min_n2" = 0, "max_n2" = 0); - damage_coeff = list("brute" = 1, "fire" = 1, "toxin" = 1, "clone" = 1, "stamina" = 0, "oxygen" = 0); +/obj/effect/spawner/human_npc/ruin/nanotrasen{ dir = 4; - name = "\improper NanoTrasen Stranded Security Officer" + npc_name = "NanoTrasen Stranded Security Officer" }, /turf/open/misc/wasteland/lit, /area/overmap_encounter/planetoid/wasteland) @@ -75,11 +71,9 @@ /turf/open/misc/dust/lit, /area/overmap_encounter/planetoid/wasteland) "v" = ( -/mob/living/basic/trooper/nanotrasen/ranged{ - atmos_requirements = list("min_oxy" = 5, "max_oxy" = 0, "min_tox" = 0, "max_tox" = 0, "min_co2" = 0, "max_co2" = 999, "min_n2" = 0, "max_n2" = 0); - damage_coeff = list("brute" = 1, "fire" = 1, "toxin" = 1, "clone" = 1, "stamina" = 0, "oxygen" = 0); +/obj/effect/spawner/human_npc/ruin/nanotrasen{ dir = 8; - name = "\improper NanoTrasen Stranded Security Officer" + npc_name = "NanoTrasen Stranded Security Officer" }, /turf/open/misc/wasteland/lit, /area/overmap_encounter/planetoid/wasteland) diff --git a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_crash_bar.dmm b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_crash_bar.dmm index 28d2c66731e..f4832b7e84d 100644 --- a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_crash_bar.dmm +++ b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_crash_bar.dmm @@ -1,8 +1,7 @@ //MAP CONVERTED BY dmm2tgm.py THIS HEADER COMMENT PREVENTS RECONVERSION, DO NOT REMOVE "aa" = ( -/mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter{ - desc = "One of the few survivors on the planet with working weaponry. Doesn't seem as friendly as the bartenders you're used to."; - faction = list("saloon") +/obj/effect/spawner/human_npc/ruin/hermit/hunter{ + npc_faction = list("saloon") }, /turf/open/floor/wood{ broken = 1 @@ -51,8 +50,8 @@ /obj/machinery/atmospherics/pipe/smart/simple/scrubbers/hidden/layer4{ dir = 10 }, -/mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter{ - faction = list("saloon") +/obj/effect/spawner/human_npc/ruin/hermit/hunter{ + npc_faction = list("saloon") }, /turf/open/floor/plating{ burnt = 1 @@ -220,8 +219,8 @@ /turf/open/floor/plating, /area/ruin/unpowered) "hm" = ( -/mob/living/simple_animal/hostile/asteroid/hermit/survivor{ - faction = list("saloon") +/obj/effect/spawner/human_npc/ruin/hermit{ + npc_faction = list("saloon") }, /turf/open/floor/plating, /area/ruin/unpowered) @@ -430,8 +429,8 @@ }, /area/ruin/unpowered) "vR" = ( -/mob/living/simple_animal/hostile/asteroid/hermit/survivor{ - faction = list("saloon") +/obj/effect/spawner/human_npc/ruin/hermit{ + npc_faction = list("saloon") }, /turf/open/floor/iron/dark, /area/ruin/unpowered) @@ -443,8 +442,8 @@ /area/ruin/unpowered) "wL" = ( /obj/effect/decal/cleanable/dirt, -/mob/living/simple_animal/hostile/asteroid/hermit/survivor{ - faction = list("saloon") +/obj/effect/spawner/human_npc/ruin/hermit{ + npc_faction = list("saloon") }, /turf/open/floor/plating, /area/ruin/unpowered) @@ -1039,8 +1038,8 @@ /turf/open/floor/wood, /area/ruin/unpowered) "ZU" = ( -/mob/living/simple_animal/hostile/asteroid/hermit/survivor{ - faction = list("saloon") +/obj/effect/spawner/human_npc/ruin/hermit{ + npc_faction = list("saloon") }, /turf/open/floor/plating{ broken = 1 diff --git a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_crash_cargo.dmm b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_crash_cargo.dmm index 473b45b1284..eef0eeed63d 100644 --- a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_crash_cargo.dmm +++ b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_crash_cargo.dmm @@ -111,7 +111,7 @@ /turf/open/floor/plating, /area/ruin/unpowered) "kO" = ( -/mob/living/basic/trooper/pirate/melee, +/obj/effect/spawner/human_npc/ruin/pirate, /turf/open/floor/plating{ burnt = 1 }, @@ -424,7 +424,7 @@ /turf/open/floor/iron/dark, /area/ruin/unpowered) "Gs" = ( -/mob/living/basic/trooper/pirate/melee, +/obj/effect/spawner/human_npc/ruin/pirate, /turf/open/floor/plating{ broken = 1 }, @@ -461,7 +461,7 @@ dir = 8 }, /obj/structure/cable, -/mob/living/basic/trooper/pirate/ranged, +/obj/effect/spawner/human_npc/ruin/pirate/gunner, /turf/open/floor/plating, /area/ruin/unpowered) "Iv" = ( @@ -483,7 +483,7 @@ /turf/open/floor/plating, /area/ruin/unpowered) "Ku" = ( -/mob/living/basic/trooper/pirate/melee, +/obj/effect/spawner/human_npc/ruin/pirate, /turf/open/floor/mineral/titanium{ broken = 1 }, @@ -639,7 +639,7 @@ /area/ruin/unpowered) "RQ" = ( /obj/effect/decal/cleanable/dirt/dust, -/mob/living/basic/trooper/pirate/ranged, +/obj/effect/spawner/human_npc/ruin/pirate/gunner, /turf/open/floor/iron/dark, /area/ruin/unpowered) "RV" = ( diff --git a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_onlyaspoonful.dmm b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_onlyaspoonful.dmm index 729906e4db5..b3f7d1cbf67 100644 --- a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_onlyaspoonful.dmm +++ b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_onlyaspoonful.dmm @@ -26,7 +26,7 @@ pixel_y = 9 }, /obj/effect/decal/cleanable/blood/tracks, -/mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter, +/obj/effect/spawner/human_npc/ruin/hermit/hunter, /turf/open/floor/plastic, /area/ruin/powered) "ae" = ( @@ -92,7 +92,7 @@ /area/ruin/powered) "ew" = ( /obj/effect/decal/cleanable/dirt/dust, -/mob/living/simple_animal/hostile/asteroid/hermit/survivor, +/obj/effect/spawner/human_npc/ruin/hermit, /turf/open/floor/plastic, /area/ruin/powered) "eH" = ( @@ -184,7 +184,7 @@ /turf/open/floor/plastic, /area/ruin/powered) "hw" = ( -/mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter, +/obj/effect/spawner/human_npc/ruin/hermit/hunter, /turf/open/floor/plastic, /area/ruin/powered) "hA" = ( @@ -470,7 +470,7 @@ /turf/open/floor/material, /area/ruin/powered) "EC" = ( -/mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter, +/obj/effect/spawner/human_npc/ruin/hermit/hunter, /turf/open/misc/wasteland/lit, /area/overmap_encounter/planetoid/wasteland) "Fi" = ( @@ -596,7 +596,7 @@ /area/ruin/powered) "NU" = ( /obj/effect/decal/cleanable/dirt/dust, -/mob/living/simple_animal/hostile/asteroid/hermit/survivor, +/obj/effect/spawner/human_npc/ruin/hermit, /turf/open/floor/material, /area/ruin/powered) "Oo" = ( diff --git a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_starfurycrash.dmm b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_starfurycrash.dmm index 6e0af1a52f6..fddbbd2cf2f 100644 --- a/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_starfurycrash.dmm +++ b/_maps/voidcrew/RandomRuins/WastelandRuins/wasteland_surface_starfurycrash.dmm @@ -27,7 +27,7 @@ /turf/open/floor/plating, /area/ruin/unpowered) "ag" = ( -/mob/living/basic/trooper/syndicate/ranged/space, +/obj/effect/spawner/human_npc/ruin/syndicate/commando/gunner, /turf/open/floor/iron/dark, /area/ruin/unpowered) "ah" = ( @@ -42,7 +42,7 @@ }, /area/ruin/unpowered) "ai" = ( -/mob/living/basic/trooper/syndicate/ranged/space, +/obj/effect/spawner/human_npc/ruin/syndicate/commando/gunner, /turf/open/misc/dust/lit, /area/overmap_encounter/planetoid/wasteland) "aj" = ( @@ -191,7 +191,7 @@ /turf/closed/wall/r_wall/plastitanium/syndicate/nodiagonal, /area/ruin/unpowered) "CW" = ( -/mob/living/basic/trooper/syndicate/ranged/space, +/obj/effect/spawner/human_npc/ruin/syndicate/commando/gunner, /turf/open/floor/plating, /area/ruin/unpowered) "Dz" = ( diff --git a/_maps/voidcrew/ships/ship_hightide.dmm b/_maps/voidcrew/ships/ship_hightide.dmm index 4fe02ee2122..724818b48d5 100644 --- a/_maps/voidcrew/ships/ship_hightide.dmm +++ b/_maps/voidcrew/ships/ship_hightide.dmm @@ -976,11 +976,7 @@ /turf/open/floor/plating, /area/shuttle/voidcrew/hightide/maintenance/cargo) "RI" = ( -/mob/living/basic/trooper/pirate/ranged{ - desc = "Timmy is a classic pirate cosplayer. He was locked in this room by the previous owner. He's survived by eating the rats, this is why there are ZERO rats in the universe."; - health = 25; - name = "Timothy" - }, +/obj/effect/spawner/human_npc/ruin/pirate/cosplayer, /obj/effect/decal/cleanable/dirt/dust, /obj/effect/decal/cleanable/greenglow, /turf/open/floor/plating, diff --git a/_maps/voidcrew/shuttles/ruin_caravan_victim.dmm b/_maps/voidcrew/shuttles/ruin_caravan_victim.dmm new file mode 100644 index 00000000000..46e644d1e04 --- /dev/null +++ b/_maps/voidcrew/shuttles/ruin_caravan_victim.dmm @@ -0,0 +1,1225 @@ +//MAP CONVERTED BY dmm2tgm.py THIS HEADER COMMENT PREVENTS RECONVERSION, DO NOT REMOVE +"aj" = ( +/obj/effect/turf_decal/box/white/corners{ + dir = 8 + }, +/obj/structure/closet/crate, +/obj/item/stack/sheet/plasteel/twenty, +/obj/item/stack/sheet/plasteel/twenty, +/obj/effect/mapping_helpers/broken_floor, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"co" = ( +/turf/closed/wall/mineral/titanium/nodiagonal, +/area/shuttle/ruin/caravan/freighter1) +"cu" = ( +/obj/effect/spawner/human_npc/ruin/syndicate/commando/smg, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"cC" = ( +/obj/machinery/firealarm/directional/north, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 1 + }, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"cJ" = ( +/obj/structure/table, +/obj/item/storage/toolbox/mechanical, +/obj/item/multitool, +/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"dv" = ( +/obj/machinery/power/shuttle_engine/propulsion/burst/right{ + dir = 8 + }, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"ex" = ( +/obj/structure/lattice, +/obj/item/stack/sheet/mineral/titanium, +/turf/template_noop, +/area/shuttle/ruin/caravan/freighter1) +"eN" = ( +/obj/effect/turf_decal/box/white/corners{ + dir = 4 + }, +/obj/effect/mapping_helpers/broken_floor, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"fJ" = ( +/obj/effect/decal/cleanable/dirt, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 10 + }, +/obj/effect/decal/cleanable/blood, +/obj/effect/turf_decal/tile/yellow/half/contrasted{ + dir = 1 + }, +/turf/open/floor/iron{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"fR" = ( +/obj/effect/turf_decal/bot, +/obj/machinery/atmospherics/components/tank/air{ + dir = 4 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"hM" = ( +/obj/structure/rack, +/obj/item/tank/internals/oxygen, +/obj/item/radio, +/obj/item/clothing/mask/gas, +/obj/effect/turf_decal/tile/blue{ + dir = 4 + }, +/turf/open/floor/iron{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"hS" = ( +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"hZ" = ( +/obj/machinery/door/firedoor, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/machinery/door/airlock/command{ + name = "Bridge" + }, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"iB" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/effect/mapping_helpers/burnt_floor, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"jz" = ( +/obj/structure/closet/crate, +/obj/item/stack/sheet/mineral/silver{ + amount = 25 + }, +/obj/item/stack/sheet/mineral/silver{ + amount = 25 + }, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"jQ" = ( +/obj/structure/table, +/obj/machinery/cell_charger, +/obj/machinery/firealarm/directional/north, +/obj/item/stack/cable_coil{ + pixel_x = 12; + pixel_y = 4 + }, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"kg" = ( +/obj/machinery/door/poddoor{ + id = "caravantrade1_cargo"; + name = "Cargo Blast Door" + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"ll" = ( +/obj/machinery/power/port_gen/pacman{ + anchored = 1 + }, +/obj/item/wrench, +/obj/machinery/power/terminal, +/obj/effect/turf_decal/stripes/line{ + dir = 5 + }, +/obj/effect/decal/cleanable/dirt, +/obj/structure/cable, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"lD" = ( +/obj/structure/closet/crate/preopen, +/obj/item/stack/sheet/iron/fifty, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"lK" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/effect/turf_decal/tile/yellow{ + dir = 4 + }, +/turf/open/floor/iron{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"mb" = ( +/obj/machinery/light/small/directional/south, +/obj/effect/decal/cleanable/dirt, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/effect/turf_decal/tile/yellow/half/contrasted{ + dir = 1 + }, +/turf/open/floor/iron{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"mx" = ( +/obj/effect/decal/cleanable/dirt, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"nj" = ( +/obj/machinery/airalarm/directional/west, +/obj/effect/mapping_helpers/airalarm/all_access, +/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/blood, +/obj/machinery/atmospherics/components/unary/vent_pump/on, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"nI" = ( +/turf/template_noop, +/area/shuttle/ruin/caravan/freighter1) +"nO" = ( +/obj/machinery/airalarm/directional/east, +/obj/effect/mapping_helpers/airalarm/all_access, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden, +/obj/effect/mapping_helpers/broken_floor, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"oJ" = ( +/obj/effect/decal/cleanable/dirt, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 1 + }, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"pj" = ( +/obj/machinery/suit_storage_unit/standard_unit, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"px" = ( +/obj/machinery/light/directional/north, +/obj/structure/table, +/obj/item/stack/package_wrap, +/obj/item/crowbar, +/obj/item/flashlight{ + pixel_x = 1; + pixel_y = 5 + }, +/obj/machinery/airalarm/directional/north, +/obj/effect/mapping_helpers/airalarm/all_access, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"rt" = ( +/obj/effect/decal/cleanable/dirt, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden, +/obj/effect/turf_decal/tile/blue/half/contrasted{ + dir = 4 + }, +/turf/open/floor/iron{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"rz" = ( +/obj/effect/turf_decal/box/white/corners{ + dir = 4 + }, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"rC" = ( +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"su" = ( +/obj/structure/table, +/obj/machinery/microwave{ + pixel_y = 5 + }, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"sJ" = ( +/obj/effect/decal/cleanable/dirt, +/obj/structure/table/reinforced, +/obj/item/paper_bin{ + pixel_x = 6; + pixel_y = 6 + }, +/obj/item/pen{ + pixel_x = 6; + pixel_y = 6 + }, +/obj/item/folder/yellow{ + pixel_x = -6 + }, +/obj/effect/turf_decal/tile/blue/anticorner/contrasted, +/turf/open/floor/iron/dark{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"tp" = ( +/obj/machinery/door/airlock{ + id_tag = "caravantrade1_cabin1"; + name = "Cabin 1" + }, +/obj/effect/decal/cleanable/dirt, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"tH" = ( +/obj/structure/chair/stool/directional/west, +/obj/effect/turf_decal/tile/yellow/half/contrasted{ + dir = 4 + }, +/turf/open/floor/iron{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"tT" = ( +/obj/machinery/door/poddoor{ + id = "caravantrade1_cargo"; + name = "Cargo Blast Door" + }, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"uE" = ( +/obj/structure/table, +/obj/item/storage/box/donkpockets{ + pixel_x = 6; + pixel_y = 6 + }, +/obj/item/plate{ + pixel_x = -5; + pixel_y = -3 + }, +/obj/effect/decal/cleanable/dirt, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"uZ" = ( +/obj/effect/turf_decal/box/white/corners{ + dir = 1 + }, +/obj/structure/closet/crate, +/obj/item/stack/sheet/mineral/uranium{ + amount = 10 + }, +/obj/item/stack/sheet/mineral/uranium{ + amount = 10 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"vG" = ( +/obj/structure/table/reinforced, +/obj/machinery/button/door{ + id = "caravantrade1_bridge"; + name = "Ship Blast Door Control" + }, +/obj/effect/turf_decal/tile/blue/anticorner/contrasted{ + dir = 4 + }, +/turf/open/floor/iron/dark{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"wC" = ( +/obj/effect/turf_decal/box/white/corners{ + dir = 4 + }, +/obj/effect/decal/cleanable/dirt, +/obj/structure/closet/crate, +/obj/item/stack/sheet/mineral/gold{ + amount = 25 + }, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"yv" = ( +/obj/effect/turf_decal/bot_white, +/obj/structure/closet/emcloset, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"zV" = ( +/obj/structure/lattice, +/obj/structure/broken_flooring/singular/directional/south, +/turf/template_noop, +/area/shuttle/ruin/caravan/freighter1) +"Bh" = ( +/obj/machinery/power/shuttle_engine/heater{ + dir = 8 + }, +/obj/structure/window/reinforced/spawner/directional/east, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"Bp" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 10 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"BC" = ( +/obj/structure/lattice, +/turf/template_noop, +/area/shuttle/ruin/caravan/freighter1) +"BY" = ( +/obj/effect/decal/cleanable/dirt, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 8 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"CA" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 8 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"Da" = ( +/obj/machinery/door/poddoor{ + id = "caravantrade1_cargo"; + name = "Cargo Blast Door" + }, +/obj/effect/decal/cleanable/dirt, +/obj/effect/mapping_helpers/broken_floor, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"Dg" = ( +/obj/effect/decal/cleanable/dirt, +/obj/machinery/computer/camera_advanced/shuttle_docker/caravan/trade1{ + dir = 8 + }, +/obj/effect/turf_decal/tile/blue/anticorner/contrasted{ + dir = 1 + }, +/turf/open/floor/iron/dark{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"DV" = ( +/obj/effect/decal/cleanable/dirt, +/obj/machinery/computer/shuttle/caravan/trade1{ + dir = 8 + }, +/obj/effect/turf_decal/tile/blue/anticorner/contrasted{ + dir = 8 + }, +/turf/open/floor/iron/dark{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"Eh" = ( +/obj/effect/turf_decal/box/white/corners{ + dir = 1 + }, +/obj/effect/mapping_helpers/broken_floor, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"EO" = ( +/obj/effect/spawner/structure/window/reinforced/shuttle, +/obj/machinery/door/poddoor{ + id = "caravantrade1_bridge" + }, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/freighter1) +"Fb" = ( +/obj/machinery/light/small/directional/east, +/obj/machinery/firealarm/directional/east, +/obj/effect/decal/cleanable/blood, +/obj/machinery/atmospherics/components/unary/vent_pump/on{ + dir = 8 + }, +/obj/effect/spawner/human_npc/ruin/syndicate/commando/smg, +/obj/effect/turf_decal/tile/yellow{ + dir = 4 + }, +/turf/open/floor/iron{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"Fu" = ( +/obj/effect/decal/cleanable/blood, +/obj/effect/spawner/human_npc/ruin/syndicate/stormtrooper/sword, +/obj/effect/turf_decal/tile/blue{ + dir = 4 + }, +/turf/open/floor/iron/dark{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"FQ" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 8 + }, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"Gq" = ( +/obj/structure/girder, +/obj/effect/mapping_helpers/broken_floor, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"He" = ( +/obj/machinery/door/airlock{ + id_tag = "caravantrade1_cabin2"; + name = "Cabin 2" + }, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"Hz" = ( +/obj/machinery/door/firedoor, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden, +/obj/structure/door_assembly/door_assembly_min{ + anchored = 1; + density = 0; + name = "broken airlock" + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"HF" = ( +/obj/effect/turf_decal/box/white/corners{ + dir = 8 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"HY" = ( +/obj/machinery/light/small/directional/west, +/obj/machinery/firealarm/directional/west, +/obj/effect/decal/cleanable/dirt, +/obj/structure/rack, +/obj/item/storage/toolbox/emergency, +/obj/item/wrench, +/obj/effect/turf_decal/tile/blue/anticorner/contrasted{ + dir = 1 + }, +/turf/open/floor/iron/dark{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"Id" = ( +/obj/structure/rack, +/obj/item/storage/belt/utility, +/obj/structure/extinguisher_cabinet/directional/north, +/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"Ix" = ( +/obj/machinery/light/small/directional/south, +/obj/structure/bed{ + dir = 4 + }, +/obj/item/bedsheet{ + dir = 4 + }, +/obj/effect/decal/cleanable/dirt, +/obj/machinery/airalarm/directional/east, +/obj/effect/mapping_helpers/airalarm/all_access, +/obj/machinery/atmospherics/components/unary/vent_pump/on{ + dir = 1 + }, +/obj/machinery/button/door/directional/west{ + id = "caravantrade1_cabin2"; + name = "Cabin Bolt Control"; + normaldoorcontrol = 1; + specialfunctions = 4 + }, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"IA" = ( +/obj/machinery/atmospherics/components/unary/vent_pump/on, +/obj/machinery/button/door/directional/west{ + id = "caravantrade1_bolt"; + name = "External Bolt Control"; + normaldoorcontrol = 1; + pixel_y = 8; + specialfunctions = 4 + }, +/obj/effect/turf_decal/tile/blue, +/turf/open/floor/iron{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"IY" = ( +/obj/machinery/door/airlock{ + name = "Restroom" + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/showroomfloor{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"Jv" = ( +/turf/template_noop, +/area/template_noop) +"JH" = ( +/obj/effect/decal/cleanable/dirt, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"JU" = ( +/obj/item/stack/sheet/iron/fifty, +/obj/effect/mapping_helpers/burnt_floor, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"JW" = ( +/turf/closed/wall/mineral/titanium, +/area/shuttle/ruin/caravan/freighter1) +"KD" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/effect/spawner/human_npc/ruin/syndicate/commando/smg, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"Ld" = ( +/obj/effect/decal/cleanable/dirt, +/obj/effect/mapping_helpers/broken_floor, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"Lo" = ( +/obj/effect/turf_decal/box/white/corners{ + dir = 1 + }, +/obj/structure/closet/crate, +/obj/item/stack/sheet/rglass{ + amount = 20 + }, +/obj/item/stack/sheet/rglass{ + amount = 20 + }, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"LI" = ( +/obj/machinery/airalarm/directional/north, +/obj/effect/mapping_helpers/airalarm/all_access, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 1 + }, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"LL" = ( +/obj/machinery/power/shuttle_engine/propulsion/burst{ + dir = 8 + }, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"LO" = ( +/obj/effect/turf_decal/box/white/corners{ + dir = 8 + }, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"Mc" = ( +/obj/machinery/light/small/directional/west, +/obj/structure/sign/warning/vacuum/directional/east, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/freighter1) +"Mr" = ( +/obj/machinery/light/small/directional/north, +/obj/machinery/airalarm/directional/north, +/obj/effect/mapping_helpers/airalarm/all_access, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"ME" = ( +/obj/effect/turf_decal/box/white/corners, +/obj/structure/closet/crate, +/obj/item/stack/sheet/glass/fifty, +/obj/item/stack/sheet/glass/fifty, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"Ni" = ( +/obj/machinery/light/small/directional/south, +/obj/structure/bed, +/obj/item/bedsheet, +/obj/effect/decal/cleanable/dirt, +/obj/machinery/airalarm/directional/east, +/obj/effect/mapping_helpers/airalarm/all_access, +/obj/machinery/atmospherics/components/unary/vent_pump/on{ + dir = 1 + }, +/obj/machinery/button/door/directional/west{ + id = "caravantrade1_cabin1"; + name = "Cabin Bolt Control"; + normaldoorcontrol = 1; + specialfunctions = 4 + }, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"NQ" = ( +/obj/effect/mapping_helpers/airlock/cyclelink_helper{ + dir = 1 + }, +/obj/effect/mapping_helpers/airlock/locked, +/obj/machinery/door/airlock/external/ruin{ + id_tag = "caravantrade1_bolt" + }, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/freighter1) +"Op" = ( +/obj/machinery/door/firedoor, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/machinery/door/airlock/engineering{ + name = "Engine Room" + }, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"OW" = ( +/obj/structure/chair/comfy/shuttle{ + dir = 4 + }, +/obj/effect/decal/cleanable/dirt, +/obj/effect/mob_spawn/corpse/human/cargo_tech, +/obj/effect/decal/cleanable/blood, +/obj/effect/turf_decal/tile/blue, +/turf/open/floor/iron/dark{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"Pf" = ( +/obj/machinery/light/small/directional/east, +/obj/machinery/power/apc/auto_name/directional/east, +/obj/effect/decal/cleanable/dirt, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden, +/obj/structure/cable, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"Qi" = ( +/obj/machinery/airalarm/directional/west, +/obj/effect/mapping_helpers/airalarm/all_access, +/obj/effect/decal/cleanable/dirt, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden, +/obj/effect/mob_spawn/corpse/human/cargo_tech, +/obj/effect/decal/cleanable/blood, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"Ql" = ( +/obj/machinery/light/small/directional/south, +/obj/effect/turf_decal/box/white/corners, +/obj/structure/closet/crate, +/obj/item/stack/sheet/mineral/diamond{ + amount = 5 + }, +/obj/machinery/button/door/directional/south{ + id = "caravantrade1_cargo"; + name = "Cargo Blast Door Control" + }, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"Qu" = ( +/obj/machinery/door/airlock{ + name = "Crew Quarters" + }, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"QH" = ( +/obj/effect/turf_decal/bot, +/obj/machinery/space_heater, +/obj/effect/decal/cleanable/dirt, +/obj/machinery/atmospherics/components/unary/vent_pump/on{ + dir = 4 + }, +/obj/effect/mapping_helpers/broken_floor, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"Rv" = ( +/obj/effect/decal/cleanable/dirt, +/obj/effect/mapping_helpers/broken_floor, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"Tb" = ( +/obj/machinery/power/smes, +/obj/effect/turf_decal/stripes/line{ + dir = 4 + }, +/obj/structure/cable, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"To" = ( +/obj/machinery/door/airlock{ + name = "Crew Cabins" + }, +/obj/effect/decal/cleanable/dirt, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"Tq" = ( +/obj/structure/closet/crate, +/obj/item/stack/sheet/mineral/titanium{ + amount = 20 + }, +/obj/item/stack/sheet/mineral/titanium{ + amount = 20 + }, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"Tu" = ( +/obj/effect/mapping_helpers/airlock/cyclelink_helper, +/obj/effect/mapping_helpers/airlock/locked, +/obj/machinery/door/airlock/external/ruin{ + id_tag = "caravantrade1_bolt" + }, +/obj/docking_port/mobile{ + callTime = 250; + dir = 2; + shuttle_id = "caravantrade1"; + movement_force = list("KNOCKDOWN" = 0, "THROW" = 0); + name = "Small Freighter"; + port_direction = 8; + preferred_direction = 4 + }, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/freighter1) +"Tx" = ( +/obj/machinery/light/small/directional/west, +/obj/effect/decal/cleanable/dirt, +/obj/structure/rack, +/obj/item/storage/medkit/regular, +/obj/effect/turf_decal/tile/blue/anticorner/contrasted{ + dir = 8 + }, +/turf/open/floor/iron/dark{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"TY" = ( +/obj/machinery/atmospherics/components/unary/vent_pump/on{ + dir = 1 + }, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"Uz" = ( +/obj/structure/toilet{ + dir = 4 + }, +/obj/structure/sink/directional/south, +/obj/machinery/light/small/directional/south, +/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/showroomfloor{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"UK" = ( +/obj/structure/closet/secure_closet/freezer{ + locked = 0; + name = "fridge" + }, +/obj/item/reagent_containers/cup/glass/bottle/beer{ + pixel_x = -3; + pixel_y = 3 + }, +/obj/item/reagent_containers/cup/glass/bottle/beer, +/obj/item/reagent_containers/cup/glass/bottle/beer{ + pixel_x = 3; + pixel_y = -3 + }, +/obj/item/reagent_containers/cup/glass/waterbottle{ + pixel_x = -3; + pixel_y = 3 + }, +/obj/item/reagent_containers/cup/glass/waterbottle, +/obj/item/reagent_containers/cup/glass/waterbottle{ + pixel_x = 3; + pixel_y = -3 + }, +/obj/item/food/pizzaslice/margherita{ + pixel_x = -3; + pixel_y = 3 + }, +/obj/item/food/pizzaslice/margherita, +/obj/item/food/chocolatebar, +/obj/effect/turf_decal/tile/yellow/anticorner/contrasted{ + dir = 4 + }, +/turf/open/floor/iron{ + initial_gas_mix = "TEMP=2.7" + }, +/area/shuttle/ruin/caravan/freighter1) +"VA" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 9 + }, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"Xq" = ( +/obj/effect/decal/cleanable/dirt, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden, +/obj/machinery/meter, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"XE" = ( +/obj/machinery/light/small/directional/south, +/obj/effect/decal/cleanable/dirt, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"XM" = ( +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"XN" = ( +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"Yt" = ( +/obj/item/stack/sheet/mineral/titanium, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/effect/mapping_helpers/broken_floor, +/turf/open/floor/iron/airless, +/area/shuttle/ruin/caravan/freighter1) +"YG" = ( +/obj/effect/decal/cleanable/dirt, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"Zq" = ( +/obj/structure/closet/crate, +/obj/item/stack/sheet/iron/twenty, +/obj/item/stack/sheet/glass{ + amount = 10 + }, +/obj/item/stack/rods/ten, +/obj/item/storage/box/lights/bulbs, +/obj/effect/decal/cleanable/dirt, +/obj/effect/turf_decal/stripes/line{ + dir = 6 + }, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) +"ZA" = ( +/obj/effect/turf_decal/bot_white, +/obj/effect/decal/cleanable/dirt, +/obj/machinery/atmospherics/components/unary/vent_pump/on{ + dir = 1 + }, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark/airless, +/area/shuttle/ruin/caravan/freighter1) +"ZG" = ( +/obj/machinery/power/shuttle_engine/propulsion/burst/left{ + dir = 8 + }, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/freighter1) + +(1,1,1) = {" +Jv +ZG +LL +LL +LL +dv +JW +Jv +Jv +Jv +Jv +"} +(2,1,1) = {" +JW +Bh +Bh +Bh +Bh +Bh +co +ZG +LL +dv +Jv +"} +(3,1,1) = {" +co +QH +ll +Tb +Zq +fR +co +Bh +Bh +Bh +JW +"} +(4,1,1) = {" +co +oJ +YG +Pf +nO +Xq +co +uZ +jz +HF +co +"} +(5,1,1) = {" +co +Op +co +co +co +Op +co +wC +rC +Ql +co +"} +(6,1,1) = {" +co +cC +He +Ix +co +Bp +BY +TY +cu +XM +kg +"} +(7,1,1) = {" +EO +XE +co +co +co +Id +iB +Lo +hS +LO +Da +"} +(8,1,1) = {" +co +LI +tp +Ni +JW +px +JH +rz +hS +ME +tT +"} +(9,1,1) = {" +co +To +co +co +co +jQ +KD +JU +Tq +Rv +kg +"} +(10,1,1) = {" +co +lK +co +Uz +co +cJ +mx +Eh +lD +aj +tT +"} +(11,1,1) = {" +EO +mb +co +IY +co +co +iB +eN +Rv +BC +Ld +"} +(12,1,1) = {" +EO +fJ +Qi +FQ +CA +Hz +Yt +ZA +zV +nI +ex +"} +(13,1,1) = {" +EO +UK +tH +Fb +JH +co +yv +XN +BC +nI +nI +"} +(14,1,1) = {" +co +su +uE +co +Qu +co +co +Gq +nI +nI +Jv +"} +(15,1,1) = {" +co +co +co +co +Mr +pj +co +Jv +Jv +Jv +Jv +"} +(16,1,1) = {" +Tu +Mc +NQ +IA +rt +hM +EO +Jv +Jv +Jv +Jv +"} +(17,1,1) = {" +JW +co +co +co +hZ +co +co +Jv +Jv +Jv +Jv +"} +(18,1,1) = {" +Jv +co +Tx +nj +VA +HY +co +Jv +Jv +Jv +Jv +"} +(19,1,1) = {" +Jv +EO +sJ +Fu +OW +vG +EO +Jv +Jv +Jv +Jv +"} +(20,1,1) = {" +Jv +EO +EO +Dg +DV +EO +EO +Jv +Jv +Jv +Jv +"} +(21,1,1) = {" +Jv +Jv +EO +EO +EO +EO +Jv +Jv +Jv +Jv +Jv +"} diff --git a/_maps/voidcrew/shuttles/ruin_pirate_cutter.dmm b/_maps/voidcrew/shuttles/ruin_pirate_cutter.dmm new file mode 100644 index 00000000000..1007292411e --- /dev/null +++ b/_maps/voidcrew/shuttles/ruin_pirate_cutter.dmm @@ -0,0 +1,1177 @@ +//MAP CONVERTED BY dmm2tgm.py THIS HEADER COMMENT PREVENTS RECONVERSION, DO NOT REMOVE +"cf" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 1 + }, +/turf/open/floor/iron/white/side{ + dir = 1 + }, +/area/shuttle/ruin/caravan/pirate) +"co" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/effect/turf_decal/tile/red/half/contrasted, +/turf/open/floor/iron, +/area/shuttle/ruin/caravan/pirate) +"dS" = ( +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"es" = ( +/obj/machinery/power/port_gen/pacman{ + anchored = 1 + }, +/obj/item/wrench, +/obj/effect/turf_decal/stripes/line{ + dir = 6 + }, +/obj/structure/cable, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"fb" = ( +/obj/structure/table, +/obj/item/reagent_containers/cup/glass/bottle/rum{ + pixel_x = 3; + pixel_y = 6 + }, +/obj/item/reagent_containers/cup/glass/bottle/rum, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"ge" = ( +/obj/machinery/atmospherics/components/unary/vent_pump/on, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron, +/area/shuttle/ruin/caravan/pirate) +"gS" = ( +/obj/structure/closet{ + name = "pirate outfits" + }, +/obj/item/clothing/head/collectable/pirate, +/obj/item/clothing/suit/costume/pirate, +/obj/item/clothing/under/costume/pirate, +/obj/item/clothing/shoes/jackboots, +/obj/item/clothing/head/costume/pirate/bandana, +/turf/open/floor/iron/dark/side{ + dir = 5 + }, +/area/shuttle/ruin/caravan/pirate) +"hi" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/machinery/button/door/directional/south{ + id = "caravanpirate_bolt_starboard"; + name = "External Bolt Control"; + normaldoorcontrol = 1; + specialfunctions = 4 + }, +/obj/effect/turf_decal/tile/red/half/contrasted, +/turf/open/floor/iron, +/area/shuttle/ruin/caravan/pirate) +"iM" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden, +/obj/structure/cable, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"iN" = ( +/obj/effect/spawner/human_npc/ruin/pirate, +/turf/open/floor/iron, +/area/shuttle/ruin/caravan/pirate) +"jc" = ( +/obj/machinery/light/small/directional/east, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 9 + }, +/obj/effect/turf_decal/tile/red/half/contrasted, +/turf/open/floor/iron, +/area/shuttle/ruin/caravan/pirate) +"jk" = ( +/obj/structure/table/reinforced, +/obj/machinery/recharger, +/obj/item/melee/baton, +/obj/effect/turf_decal/tile/red, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"jn" = ( +/obj/machinery/power/shuttle_engine/propulsion/burst/left{ + dir = 8 + }, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/pirate) +"jx" = ( +/obj/machinery/suit_storage_unit/open, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"ka" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/machinery/door/firedoor, +/obj/machinery/door/airlock/security{ + name = "Armory" + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron, +/area/shuttle/ruin/caravan/pirate) +"kU" = ( +/obj/machinery/atmospherics/components/unary/vent_pump/on{ + dir = 1 + }, +/turf/open/floor/iron, +/area/shuttle/ruin/caravan/pirate) +"lD" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden, +/obj/effect/turf_decal/tile/red/half/contrasted, +/turf/open/floor/iron, +/area/shuttle/ruin/caravan/pirate) +"lN" = ( +/obj/structure/chair/office{ + dir = 4 + }, +/obj/machinery/turretid{ + icon_state = "control_kill"; + lethal = 1; + locked = 0; + pixel_y = -30; + req_access = null + }, +/obj/effect/spawner/human_npc/ruin/pirate/gunner, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"me" = ( +/obj/effect/mapping_helpers/airlock/cyclelink_helper, +/obj/effect/mapping_helpers/airlock/locked, +/obj/machinery/door/airlock/external/ruin{ + id_tag = "caravanpirate_bolt_starboard" + }, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"ms" = ( +/obj/structure/table, +/obj/item/storage/fancy/donut_box{ + pixel_y = 18 + }, +/obj/item/storage/box/donkpockets{ + pixel_x = -3; + pixel_y = 7 + }, +/obj/item/storage/box/donkpockets{ + pixel_x = -6 + }, +/obj/item/reagent_containers/cup/glass/bottle/rum{ + pixel_x = 8; + pixel_y = 3 + }, +/obj/structure/sign/poster/contraband/red_rum/directional/east, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"nN" = ( +/obj/structure/table, +/obj/item/retractor, +/obj/item/hemostat, +/turf/open/floor/iron/white, +/area/shuttle/ruin/caravan/pirate) +"nT" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"pe" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/effect/turf_decal/tile/red/anticorner/contrasted{ + dir = 8 + }, +/turf/open/floor/iron, +/area/shuttle/ruin/caravan/pirate) +"pg" = ( +/obj/structure/closet{ + name = "pirate outfits" + }, +/obj/item/clothing/head/collectable/pirate, +/obj/item/clothing/suit/costume/pirate, +/obj/item/clothing/under/costume/pirate, +/obj/item/clothing/shoes/jackboots, +/obj/item/clothing/head/costume/pirate/bandana, +/obj/effect/turf_decal/tile/red{ + dir = 1 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"ph" = ( +/obj/machinery/door/poddoor{ + id = "caravanpirate_bridge" + }, +/obj/effect/spawner/structure/window/reinforced/plasma/plastitanium, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"pR" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"qB" = ( +/obj/effect/mapping_helpers/airlock/cyclelink_helper{ + dir = 1 + }, +/obj/effect/mapping_helpers/airlock/locked, +/obj/machinery/door/airlock/external/ruin{ + id_tag = "caravanpirate_bolt_starboard" + }, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"qU" = ( +/obj/structure/table, +/obj/machinery/light/small/directional/west, +/obj/item/stack/spacecash/c200, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"se" = ( +/obj/machinery/light/small/directional/east, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden, +/obj/structure/cable, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"sR" = ( +/obj/structure/table, +/obj/machinery/microwave{ + pixel_y = 5 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"sW" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/machinery/button/door/directional/north{ + id = "caravanpirate_bolt_port"; + name = "External Bolt Control"; + normaldoorcontrol = 1; + specialfunctions = 4 + }, +/turf/open/floor/iron/white/side{ + dir = 1 + }, +/area/shuttle/ruin/caravan/pirate) +"ti" = ( +/obj/structure/table, +/obj/machinery/cell_charger, +/obj/item/stack/cable_coil, +/obj/item/stock_parts/power_store/cell/high, +/obj/effect/turf_decal/bot, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"ua" = ( +/obj/structure/table, +/obj/item/storage/box/lethalshot, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"ug" = ( +/obj/machinery/porta_turret/syndicate/pod{ + dir = 10; + faction = list("pirate") + }, +/turf/closed/wall/mineral/plastitanium, +/area/shuttle/ruin/caravan/pirate) +"uV" = ( +/obj/structure/reagent_dispensers/watertank, +/obj/item/reagent_containers/cup/bucket, +/obj/item/mop, +/obj/effect/turf_decal/stripes/line{ + dir = 5 + }, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"vT" = ( +/obj/structure/table, +/obj/item/circular_saw, +/obj/item/scalpel{ + pixel_y = 12 + }, +/obj/item/cautery{ + pixel_x = 4 + }, +/obj/machinery/light/small/directional/west, +/turf/open/floor/iron/white/side{ + dir = 8 + }, +/area/shuttle/ruin/caravan/pirate) +"wg" = ( +/obj/machinery/light/small/directional/east, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"wh" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"wE" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/machinery/door/firedoor, +/obj/machinery/door/airlock/medical/glass{ + name = "Medbay" + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron, +/area/shuttle/ruin/caravan/pirate) +"wP" = ( +/obj/structure/closet/crate/freezer/surplus_limbs, +/obj/effect/turf_decal/bot, +/turf/open/floor/iron/white, +/area/shuttle/ruin/caravan/pirate) +"wR" = ( +/obj/machinery/porta_turret/syndicate/pod{ + dir = 5; + faction = list("pirate") + }, +/turf/closed/wall/mineral/plastitanium, +/area/shuttle/ruin/caravan/pirate) +"wV" = ( +/obj/machinery/light/small/directional/north, +/obj/structure/bed, +/obj/item/bedsheet/pirate, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"xb" = ( +/obj/machinery/atmospherics/components/unary/vent_pump/on{ + dir = 4 + }, +/obj/machinery/space_heater, +/obj/effect/turf_decal/stripes/line{ + dir = 6 + }, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"xq" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden, +/obj/machinery/airalarm/directional/east, +/obj/effect/mapping_helpers/airalarm/all_access, +/obj/structure/cable, +/obj/machinery/power/apc/auto_name/directional/west, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"ya" = ( +/obj/structure/table/reinforced, +/obj/machinery/button/door{ + id = "caravanpirate_bridge"; + name = "Bridge Blast Door Control"; + pixel_x = -16 + }, +/obj/effect/turf_decal/tile/red/half/contrasted, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"yR" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"Aj" = ( +/obj/machinery/computer/shuttle/caravan/pirate{ + dir = 8 + }, +/obj/effect/turf_decal/tile/red/half/contrasted{ + dir = 8 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"An" = ( +/obj/item/stack/sheet/mineral/gold{ + amount = 25 + }, +/obj/item/stack/sheet/mineral/bananium{ + amount = 5 + }, +/obj/item/stack/sheet/mineral/silver{ + amount = 25 + }, +/obj/item/stack/sheet/mineral/uranium{ + amount = 10 + }, +/obj/item/stack/sheet/mineral/diamond{ + amount = 5 + }, +/obj/structure/closet/crate, +/obj/item/coin/silver, +/obj/item/coin/silver, +/obj/item/coin/silver, +/obj/item/coin/gold, +/obj/item/coin/gold, +/obj/effect/turf_decal/tile/blue, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"AS" = ( +/obj/machinery/porta_turret/syndicate/pod{ + dir = 9; + faction = list("pirate") + }, +/turf/closed/wall/mineral/plastitanium, +/area/shuttle/ruin/caravan/pirate) +"AW" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 6 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron, +/area/shuttle/ruin/caravan/pirate) +"BX" = ( +/obj/structure/closet/crate/secure/loot, +/obj/machinery/airalarm/directional/north, +/obj/effect/mapping_helpers/airalarm/all_access, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"CI" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 9 + }, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"Di" = ( +/obj/structure/table, +/obj/item/storage/medkit/brute{ + pixel_x = 3; + pixel_y = 3 + }, +/obj/item/storage/medkit/fire, +/obj/machinery/firealarm/directional/south, +/turf/open/floor/iron/white, +/area/shuttle/ruin/caravan/pirate) +"DQ" = ( +/obj/structure/reagent_dispensers/fueltank, +/obj/effect/turf_decal/stripes/line{ + dir = 4 + }, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"Eh" = ( +/obj/machinery/atmospherics/components/unary/vent_pump/on, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"Fn" = ( +/obj/machinery/light/small/directional/west, +/obj/effect/turf_decal/tile/red/half/contrasted{ + dir = 8 + }, +/turf/open/floor/iron, +/area/shuttle/ruin/caravan/pirate) +"FB" = ( +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron, +/area/shuttle/ruin/caravan/pirate) +"FI" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/machinery/door/firedoor, +/obj/machinery/door/airlock/engineering{ + name = "Engineering" + }, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"FX" = ( +/obj/machinery/power/shuttle_engine/propulsion/burst/right{ + dir = 8 + }, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/pirate) +"Gj" = ( +/obj/structure/tank_dispenser/oxygen, +/obj/machinery/firealarm/directional/north, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"GL" = ( +/obj/structure/bed{ + dir = 4 + }, +/obj/item/bedsheet/pirate{ + dir = 4 + }, +/obj/machinery/airalarm/directional/west, +/obj/effect/mapping_helpers/airalarm/all_access, +/obj/effect/turf_decal/tile/red{ + dir = 8 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"Ha" = ( +/obj/machinery/light/small/directional/south, +/obj/structure/bed, +/obj/item/bedsheet/pirate, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"Hb" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 5 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron, +/area/shuttle/ruin/caravan/pirate) +"Hl" = ( +/obj/machinery/porta_turret/syndicate/pod{ + dir = 6; + faction = list("pirate") + }, +/turf/closed/wall/mineral/plastitanium, +/area/shuttle/ruin/caravan/pirate) +"Hu" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/machinery/door/firedoor, +/obj/machinery/door/airlock/command{ + name = "Bridge" + }, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"Ir" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 8 + }, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"Iu" = ( +/obj/structure/table, +/obj/machinery/door/window/right/directional/south{ + name = "Weapon Storage" + }, +/obj/item/gun/energy/laser, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"Jv" = ( +/turf/template_noop, +/area/template_noop) +"JJ" = ( +/obj/structure/table/optable, +/obj/effect/turf_decal/bot, +/turf/open/floor/iron/white, +/area/shuttle/ruin/caravan/pirate) +"JP" = ( +/obj/machinery/computer/camera_advanced/shuttle_docker/caravan/pirate, +/obj/effect/turf_decal/tile/red/half/contrasted{ + dir = 1 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"Kc" = ( +/turf/closed/wall/mineral/plastitanium/nodiagonal, +/area/shuttle/ruin/caravan/pirate) +"KL" = ( +/obj/machinery/power/shuttle_engine/propulsion/burst{ + dir = 8 + }, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/pirate) +"Ll" = ( +/obj/structure/rack, +/obj/item/storage/toolbox/emergency, +/obj/item/weldingtool, +/obj/effect/turf_decal/tile/red{ + dir = 4 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"Mk" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/effect/turf_decal/tile/red/half/contrasted{ + dir = 8 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"Ms" = ( +/obj/effect/mapping_helpers/airlock/cyclelink_helper, +/obj/effect/mapping_helpers/airlock/locked, +/obj/machinery/door/airlock/external/ruin{ + id_tag = "caravanpirate_bolt_port" + }, +/obj/docking_port/mobile{ + callTime = 150; + dir = 2; + shuttle_id = "caravanpirate"; + movement_force = list("KNOCKDOWN"=0,"THROW"=0); + name = "Pirate Cutter"; + port_direction = 8; + preferred_direction = 4 + }, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"Ns" = ( +/obj/machinery/light/small/directional/east, +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 10 + }, +/turf/open/floor/iron/white/side{ + dir = 1 + }, +/area/shuttle/ruin/caravan/pirate) +"Oo" = ( +/obj/machinery/light/small/directional/west, +/obj/structure/sign/warning/vacuum/directional/west, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"Or" = ( +/obj/structure/chair/office{ + dir = 8 + }, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"OO" = ( +/obj/machinery/sleeper{ + dir = 1 + }, +/obj/effect/turf_decal/delivery, +/obj/machinery/airalarm/directional/south, +/obj/effect/mapping_helpers/airalarm/all_access, +/turf/open/floor/iron/white, +/area/shuttle/ruin/caravan/pirate) +"Po" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/turf/open/floor/iron/dark/side{ + dir = 4 + }, +/area/shuttle/ruin/caravan/pirate) +"PC" = ( +/obj/machinery/power/terminal{ + dir = 1 + }, +/obj/structure/closet/crate, +/obj/item/stack/sheet/iron/twenty, +/obj/item/stack/sheet/glass{ + amount = 10 + }, +/obj/item/storage/toolbox/mechanical, +/obj/item/flashlight{ + pixel_x = 3; + pixel_y = 3 + }, +/obj/item/stack/sheet/mineral/plasma{ + amount = 20 + }, +/obj/effect/turf_decal/stripes/line{ + dir = 4 + }, +/obj/structure/cable, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"Qb" = ( +/obj/structure/sign/departments/medbay/alt, +/turf/closed/wall/mineral/plastitanium/nodiagonal, +/area/shuttle/ruin/caravan/pirate) +"Rb" = ( +/obj/structure/table, +/obj/structure/window/reinforced/spawner/directional/west, +/obj/machinery/door/window/left/directional/south{ + name = "Weapon Storage" + }, +/obj/item/grenade/smokebomb{ + pixel_x = -4 + }, +/obj/item/grenade/smokebomb{ + pixel_x = 2 + }, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"Ry" = ( +/obj/structure/rack, +/obj/item/storage/bag/money/vault, +/mob/living/basic/parrot{ + faction = list("pirate"); + name = "Pegwing" + }, +/obj/effect/turf_decal/tile/blue{ + dir = 4 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"SU" = ( +/obj/machinery/power/shuttle_engine/heater{ + dir = 8 + }, +/obj/structure/window/reinforced/spawner/directional/east, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/pirate) +"UH" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/obj/effect/turf_decal/tile/blue/half/contrasted{ + dir = 4 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"Vh" = ( +/obj/structure/sign/departments/engineering, +/turf/closed/wall/mineral/plastitanium/nodiagonal, +/area/shuttle/ruin/caravan/pirate) +"Vs" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/turf/open/floor/iron/white/side{ + dir = 1 + }, +/area/shuttle/ruin/caravan/pirate) +"Vz" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 9 + }, +/obj/machinery/firealarm/directional/south, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"VF" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 4 + }, +/turf/open/floor/iron/white/side{ + dir = 9 + }, +/area/shuttle/ruin/caravan/pirate) +"We" = ( +/obj/machinery/power/smes/super/full, +/obj/effect/turf_decal/stripes/line{ + dir = 5 + }, +/obj/structure/cable, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"Wi" = ( +/obj/effect/mapping_helpers/airlock/cyclelink_helper{ + dir = 1 + }, +/obj/effect/mapping_helpers/airlock/locked, +/obj/machinery/door/airlock/external/ruin{ + id_tag = "caravanpirate_bolt_port" + }, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"Wo" = ( +/obj/machinery/light/small/directional/west, +/obj/structure/closet/crate/secure/loot, +/obj/machinery/atmospherics/components/unary/vent_pump/on{ + dir = 4 + }, +/obj/structure/extinguisher_cabinet{ + pixel_x = -27 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"WV" = ( +/obj/effect/decal/cleanable/dirt, +/obj/effect/spawner/human_npc/ruin/pirate/gunner, +/turf/open/floor/iron, +/area/shuttle/ruin/caravan/pirate) +"Xw" = ( +/obj/structure/table, +/obj/machinery/airalarm/directional/north, +/obj/effect/mapping_helpers/airalarm/all_access, +/obj/item/ammo_box/a40mm, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"XF" = ( +/obj/structure/table, +/obj/item/coin/gold, +/obj/item/coin/silver, +/obj/item/coin/silver, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"Yc" = ( +/turf/closed/wall/mineral/plastitanium, +/area/shuttle/ruin/caravan/pirate) +"Ye" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 10 + }, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/pirate) +"Yi" = ( +/obj/effect/spawner/structure/window/reinforced/plasma/plastitanium, +/obj/machinery/door/poddoor{ + id = "caravanpirate_bridge" + }, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"Yy" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 8 + }, +/obj/machinery/meter, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"Zp" = ( +/obj/machinery/atmospherics/components/tank/air, +/obj/effect/turf_decal/bot, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) +"Zq" = ( +/obj/structure/bed{ + dir = 4 + }, +/obj/item/bedsheet/pirate{ + dir = 4 + }, +/obj/machinery/firealarm/directional/west, +/turf/open/floor/iron/dark/side{ + dir = 6 + }, +/area/shuttle/ruin/caravan/pirate) +"ZU" = ( +/obj/machinery/atmospherics/pipe/smart/manifold4w/supply/hidden{ + dir = 5 + }, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/pirate) + +(1,1,1) = {" +Jv +Jv +Jv +jn +KL +FX +Jv +jn +KL +FX +Jv +Jv +Jv +"} +(2,1,1) = {" +Jv +Jv +Yc +SU +SU +SU +Kc +SU +SU +SU +Yc +Jv +Jv +"} +(3,1,1) = {" +Jv +AS +Kc +uV +DQ +xb +Kc +We +PC +es +Kc +ug +Jv +"} +(4,1,1) = {" +Jv +Kc +Zp +Yy +wg +pR +xq +iM +se +ZU +ti +Kc +Jv +"} +(5,1,1) = {" +Jv +Kc +Kc +FI +Vh +Kc +Kc +Kc +Vh +FI +Kc +Kc +Jv +"} +(6,1,1) = {" +Jv +Kc +jx +VF +vT +nN +Kc +ua +Fn +pe +jx +Kc +Jv +"} +(7,1,1) = {" +Yc +Kc +Kc +Vs +FB +JJ +Kc +Xw +WV +co +Kc +Kc +Yc +"} +(8,1,1) = {" +Ms +Oo +Wi +cf +kU +Di +Kc +Gj +ge +lD +me +Oo +qB +"} +(9,1,1) = {" +Yc +Kc +Kc +sW +FB +OO +Kc +Rb +iN +hi +Kc +Kc +Yc +"} +(10,1,1) = {" +Jv +Yi +jx +Ns +Hb +wP +Kc +Iu +AW +jc +jx +ph +Jv +"} +(11,1,1) = {" +Jv +Yc +Kc +Qb +wE +Kc +Kc +Kc +ka +Kc +Kc +Yc +Jv +"} +(12,1,1) = {" +Jv +Jv +Kc +gS +Po +Zq +Wo +GL +Mk +pg +Kc +Jv +Jv +"} +(13,1,1) = {" +Jv +Jv +Kc +wV +Ye +nT +wh +Ir +CI +Ha +Kc +Jv +Jv +"} +(14,1,1) = {" +Jv +Jv +wR +Kc +sR +ms +An +UH +Ry +Kc +Hl +Jv +Jv +"} +(15,1,1) = {" +Jv +Jv +Jv +Yc +Kc +Kc +Kc +Hu +Kc +Yc +Jv +Jv +Jv +"} +(16,1,1) = {" +Jv +Jv +Jv +Jv +Kc +fb +qU +yR +Kc +Jv +Jv +Jv +Jv +"} +(17,1,1) = {" +Jv +Jv +Jv +Jv +Kc +XF +Or +yR +Kc +Jv +Jv +Jv +Jv +"} +(18,1,1) = {" +Jv +Jv +Jv +Jv +Kc +BX +Eh +Vz +Kc +Jv +Jv +Jv +Jv +"} +(19,1,1) = {" +Jv +Jv +Jv +Jv +Kc +Ll +dS +jk +Kc +Jv +Jv +Jv +Jv +"} +(20,1,1) = {" +Jv +Jv +Jv +Jv +ph +JP +lN +ya +Yi +Jv +Jv +Jv +Jv +"} +(21,1,1) = {" +Jv +Jv +Jv +Jv +Yi +Yi +Aj +Yi +Yi +Jv +Jv +Jv +Jv +"} +(22,1,1) = {" +Jv +Jv +Jv +Jv +Jv +Yi +Yi +Yi +Jv +Jv +Jv +Jv +Jv +"} diff --git a/_maps/voidcrew/shuttles/ruin_syndicate_dropship.dmm b/_maps/voidcrew/shuttles/ruin_syndicate_dropship.dmm new file mode 100644 index 00000000000..31ca89403cd --- /dev/null +++ b/_maps/voidcrew/shuttles/ruin_syndicate_dropship.dmm @@ -0,0 +1,620 @@ +//MAP CONVERTED BY dmm2tgm.py THIS HEADER COMMENT PREVENTS RECONVERSION, DO NOT REMOVE +"bh" = ( +/obj/machinery/door/airlock/hatch{ + id_tag = "caravansyndicate3_bolt_port"; + name = "External Airlock"; + normalspeed = 0 + }, +/obj/docking_port/mobile{ + dir = 2; + shuttle_id = "caravansyndicate3"; + name = "Syndicate Drop Ship"; + port_direction = 8; + preferred_direction = 4 + }, +/obj/effect/mapping_helpers/airlock/cyclelink_helper, +/obj/effect/mapping_helpers/airlock/access/all/syndicate/general, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/syndicate3) +"bt" = ( +/obj/effect/turf_decal/stripes/line{ + dir = 8 + }, +/obj/structure/sign/warning/vacuum/directional/south, +/obj/effect/decal/cleanable/dirt, +/obj/structure/closet/syndicate{ + anchored = 1 + }, +/obj/item/clothing/under/syndicate/combat, +/obj/item/storage/belt/military, +/turf/open/floor/mineral/plastitanium, +/area/shuttle/ruin/caravan/syndicate3) +"bX" = ( +/obj/machinery/porta_turret/syndicate/energy{ + dir = 1 + }, +/turf/closed/wall/mineral/plastitanium/nodiagonal, +/area/shuttle/ruin/caravan/syndicate3) +"co" = ( +/obj/machinery/power/shuttle_engine/heater{ + dir = 8 + }, +/obj/structure/window/reinforced/spawner/directional/east, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/syndicate3) +"dt" = ( +/obj/effect/turf_decal/stripes/line{ + dir = 6 + }, +/obj/machinery/power/port_gen/pacman{ + anchored = 1 + }, +/obj/item/wrench, +/obj/effect/decal/cleanable/dirt, +/obj/structure/cable, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/syndicate3) +"dy" = ( +/obj/effect/turf_decal/stripes/line{ + dir = 8 + }, +/obj/structure/closet/syndicate{ + anchored = 1 + }, +/obj/structure/sign/warning/vacuum/directional/north, +/obj/effect/decal/cleanable/dirt, +/obj/item/clothing/shoes/sneakers/black, +/turf/open/floor/mineral/plastitanium, +/area/shuttle/ruin/caravan/syndicate3) +"eV" = ( +/obj/machinery/power/shuttle_engine/propulsion/burst/left{ + dir = 8 + }, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/syndicate3) +"fU" = ( +/obj/machinery/power/shuttle_engine/propulsion/burst{ + dir = 8 + }, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/syndicate3) +"gv" = ( +/obj/structure/table/reinforced, +/obj/machinery/recharger, +/obj/machinery/light/small/directional/west, +/obj/effect/turf_decal/tile/red/anticorner/contrasted{ + dir = 8 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"gz" = ( +/obj/structure/table/reinforced, +/obj/item/storage/toolbox/emergency, +/obj/item/wrench, +/obj/machinery/light/small/directional/west, +/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/dirt, +/obj/effect/turf_decal/tile/red/anticorner/contrasted{ + dir = 1 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"id" = ( +/obj/effect/turf_decal/stripes/line{ + dir = 10 + }, +/obj/structure/closet/syndicate{ + anchored = 1 + }, +/obj/item/clothing/under/syndicate/combat, +/turf/open/floor/mineral/plastitanium, +/area/shuttle/ruin/caravan/syndicate3) +"im" = ( +/obj/effect/decal/cleanable/dirt, +/obj/machinery/computer/camera_advanced/shuttle_docker/caravan/syndicate3{ + dir = 8 + }, +/obj/effect/turf_decal/tile/red/anticorner/contrasted{ + dir = 8 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"iN" = ( +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"kc" = ( +/obj/effect/decal/cleanable/dirt, +/obj/effect/turf_decal/tile/red/half/contrasted, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"kk" = ( +/obj/effect/spawner/structure/window/reinforced/plasma/plastitanium, +/obj/machinery/door/poddoor{ + id = "caravansyndicate3_bridge" + }, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/syndicate3) +"kR" = ( +/obj/effect/turf_decal/stripes/line{ + dir = 8 + }, +/obj/machinery/light/small/directional/east, +/obj/structure/closet/syndicate{ + anchored = 1 + }, +/obj/item/clothing/under/syndicate, +/obj/item/clothing/glasses/night, +/turf/open/floor/mineral/plastitanium, +/area/shuttle/ruin/caravan/syndicate3) +"mq" = ( +/obj/effect/turf_decal/stripes/line{ + dir = 10 + }, +/obj/effect/decal/cleanable/dirt, +/obj/structure/closet/syndicate{ + anchored = 1 + }, +/obj/item/clothing/under/syndicate/combat, +/obj/item/clothing/shoes/jackboots, +/obj/item/storage/belt/military, +/obj/item/crowbar/red, +/turf/open/floor/mineral/plastitanium, +/area/shuttle/ruin/caravan/syndicate3) +"nv" = ( +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"oW" = ( +/obj/machinery/light/small/directional/west, +/obj/machinery/button/door/directional/west{ + id = "caravansyndicate3_bolt_port"; + name = "External Bolt Control"; + normaldoorcontrol = 1; + req_access = list("syndicate"); + specialfunctions = 4 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"pY" = ( +/obj/structure/chair/comfy/shuttle{ + dir = 1 + }, +/obj/effect/decal/cleanable/dirt, +/obj/machinery/light/small/directional/south, +/turf/open/floor/pod/dark, +/area/shuttle/ruin/caravan/syndicate3) +"rQ" = ( +/obj/effect/turf_decal/stripes/line{ + dir = 9 + }, +/obj/effect/decal/cleanable/dirt, +/obj/structure/closet/syndicate{ + anchored = 1 + }, +/obj/item/clothing/under/syndicate, +/obj/item/clothing/shoes/sneakers/black, +/turf/open/floor/mineral/plastitanium, +/area/shuttle/ruin/caravan/syndicate3) +"sk" = ( +/obj/structure/chair/comfy/shuttle{ + dir = 4 + }, +/obj/effect/turf_decal/tile/red, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"ts" = ( +/obj/machinery/airalarm/directional/west, +/obj/effect/mapping_helpers/airalarm/syndicate_access, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"uv" = ( +/obj/structure/chair/comfy/shuttle{ + dir = 4 + }, +/obj/effect/spawner/human_npc/ruin/syndicate/gunner/pilot, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"uI" = ( +/turf/closed/wall/mineral/plastitanium/nodiagonal, +/area/shuttle/ruin/caravan/syndicate3) +"wl" = ( +/obj/machinery/airalarm/directional/west, +/obj/effect/mapping_helpers/airalarm/syndicate_access, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"wS" = ( +/obj/machinery/door/airlock/hatch{ + id_tag = "caravansyndicate3_bolt_starboard"; + name = "External Airlock"; + normalspeed = 0 + }, +/obj/effect/mapping_helpers/airlock/cyclelink_helper{ + dir = 1 + }, +/obj/effect/mapping_helpers/airlock/access/all/syndicate/general, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/syndicate3) +"zB" = ( +/obj/structure/chair/comfy/shuttle, +/obj/machinery/light/small/directional/north, +/obj/machinery/power/apc/auto_name/directional/west, +/obj/effect/mapping_helpers/apc/syndicate_access, +/obj/effect/decal/cleanable/dirt, +/obj/structure/cable, +/turf/open/floor/pod/dark, +/area/shuttle/ruin/caravan/syndicate3) +"zP" = ( +/obj/machinery/computer/crew{ + dir = 8 + }, +/obj/effect/decal/cleanable/dirt, +/obj/effect/turf_decal/tile/red/anticorner/contrasted{ + dir = 1 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"DF" = ( +/obj/machinery/computer/shuttle/caravan/syndicate3{ + dir = 8 + }, +/obj/effect/turf_decal/tile/red/half/contrasted{ + dir = 8 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"GU" = ( +/obj/effect/decal/cleanable/dirt, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"HI" = ( +/obj/effect/turf_decal/stripes/line{ + dir = 4 + }, +/obj/structure/closet/crate, +/obj/machinery/power/terminal{ + dir = 1 + }, +/obj/item/stack/sheet/iron/twenty, +/obj/item/stack/sheet/glass{ + amount = 10 + }, +/obj/item/stack/sheet/mineral/plastitanium{ + amount = 20 + }, +/obj/item/storage/box/lights/bulbs, +/obj/item/storage/toolbox/mechanical, +/obj/item/stack/sheet/mineral/plasma{ + amount = 20 + }, +/obj/structure/cable, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/syndicate3) +"Ib" = ( +/obj/effect/turf_decal/tile/red/half/contrasted{ + dir = 1 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"Ie" = ( +/obj/structure/table/reinforced, +/obj/machinery/button/door{ + id = "caravansyndicate3_bridge"; + name = "Bridge Blast Door Control"; + pixel_x = -16; + pixel_y = 5; + req_access = list("syndicate") + }, +/obj/machinery/button/door{ + id = "caravansyndicate3_bolt_bridge"; + name = "Bridge Bolt Control"; + normaldoorcontrol = 1; + pixel_x = -16; + pixel_y = -5; + req_access = list("syndicate"); + specialfunctions = 4 + }, +/obj/effect/decal/cleanable/dirt, +/obj/effect/turf_decal/tile/red/anticorner/contrasted, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"Jv" = ( +/turf/template_noop, +/area/template_noop) +"JK" = ( +/obj/effect/turf_decal/stripes/line{ + dir = 8 + }, +/obj/machinery/light/small/directional/east, +/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/dirt, +/obj/structure/closet/syndicate{ + anchored = 1 + }, +/obj/item/storage/box/syndie_kit/chameleon, +/obj/item/crowbar/red, +/turf/open/floor/mineral/plastitanium, +/area/shuttle/ruin/caravan/syndicate3) +"JT" = ( +/obj/machinery/light/small/directional/west, +/obj/machinery/button/door/directional/west{ + id = "caravansyndicate3_bolt_starboard"; + name = "External Bolt Control"; + normaldoorcontrol = 1; + req_access = list("syndicate"); + specialfunctions = 4 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"KN" = ( +/obj/machinery/firealarm/directional/west, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"KW" = ( +/turf/closed/wall/mineral/plastitanium, +/area/shuttle/ruin/caravan/syndicate3) +"LF" = ( +/obj/structure/chair/comfy/shuttle, +/obj/machinery/airalarm/directional/north, +/obj/effect/mapping_helpers/airalarm/syndicate_access, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/pod/dark, +/area/shuttle/ruin/caravan/syndicate3) +"Mc" = ( +/obj/effect/turf_decal/tile/red/half/contrasted, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"Nn" = ( +/obj/structure/chair/comfy/shuttle{ + dir = 1 + }, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/pod/dark, +/area/shuttle/ruin/caravan/syndicate3) +"Oe" = ( +/obj/machinery/power/smes/super/full, +/obj/effect/turf_decal/stripes/line{ + dir = 5 + }, +/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/dirt, +/obj/structure/cable, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/syndicate3) +"Pp" = ( +/obj/effect/turf_decal/stripes/line{ + dir = 9 + }, +/obj/effect/decal/cleanable/dirt, +/obj/structure/closet/syndicate{ + anchored = 1 + }, +/obj/item/clothing/shoes/jackboots, +/obj/item/crowbar/red, +/turf/open/floor/mineral/plastitanium, +/area/shuttle/ruin/caravan/syndicate3) +"Ry" = ( +/obj/machinery/door/airlock/hatch{ + name = "Ready Room" + }, +/obj/effect/mapping_helpers/airlock/cyclelink_helper{ + dir = 4 + }, +/obj/effect/mapping_helpers/airlock/access/all/syndicate/general, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"RT" = ( +/obj/effect/decal/cleanable/dirt, +/obj/structure/cable, +/obj/effect/turf_decal/tile/red/half/contrasted{ + dir = 1 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"SU" = ( +/obj/effect/mapping_helpers/airlock/locked, +/obj/machinery/door/airlock/hatch{ + id_tag = "caravansyndicate3_bolt_bridge"; + name = "Bridge" + }, +/obj/effect/mapping_helpers/airlock/cyclelink_helper{ + dir = 8 + }, +/obj/effect/mapping_helpers/airlock/access/all/syndicate/general, +/obj/effect/turf_decal/tile/neutral/fourcorners, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"Te" = ( +/obj/machinery/power/shuttle_engine/propulsion/burst/right{ + dir = 8 + }, +/turf/open/floor/plating/airless, +/area/shuttle/ruin/caravan/syndicate3) +"TT" = ( +/obj/machinery/turretid{ + ailock = 1; + desc = "A specially designed set of turret controls. Looks to be covered in protective casing to prevent AI interfacing."; + icon_state = "control_kill"; + lethal = 1; + name = "Shuttle turret control"; + pixel_y = 34; + req_access = list("syndicate") + }, +/obj/structure/chair/comfy/shuttle{ + dir = 4 + }, +/obj/effect/turf_decal/tile/red{ + dir = 4 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"UI" = ( +/obj/machinery/porta_turret/syndicate/energy, +/turf/closed/wall/mineral/plastitanium/nodiagonal, +/area/shuttle/ruin/caravan/syndicate3) +"UV" = ( +/obj/structure/table/reinforced, +/obj/item/storage/medkit/regular, +/obj/item/assembly/flash/handheld, +/obj/effect/decal/cleanable/dirt, +/obj/effect/turf_decal/tile/red/anticorner/contrasted{ + dir = 4 + }, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"Vh" = ( +/obj/structure/chair/comfy/shuttle, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/pod/dark, +/area/shuttle/ruin/caravan/syndicate3) +"Vp" = ( +/obj/machinery/firealarm/directional/west, +/turf/open/floor/iron/dark, +/area/shuttle/ruin/caravan/syndicate3) +"ZF" = ( +/obj/structure/chair/comfy/shuttle{ + dir = 1 + }, +/obj/machinery/firealarm/directional/south, +/obj/effect/decal/cleanable/dirt, +/turf/open/floor/pod/dark, +/area/shuttle/ruin/caravan/syndicate3) + +(1,1,1) = {" +Jv +eV +fU +fU +fU +Te +Jv +"} +(2,1,1) = {" +KW +co +co +co +co +co +KW +"} +(3,1,1) = {" +uI +uI +Oe +HI +dt +uI +uI +"} +(4,1,1) = {" +uI +zB +RT +nv +Mc +pY +uI +"} +(5,1,1) = {" +uI +LF +Ib +iN +Mc +ZF +uI +"} +(6,1,1) = {" +uI +Vh +Ib +iN +kc +Nn +uI +"} +(7,1,1) = {" +uI +kR +mq +iN +rQ +JK +uI +"} +(8,1,1) = {" +bX +uI +uI +Ry +uI +uI +UI +"} +(9,1,1) = {" +bh +oW +wl +iN +Vp +JT +wS +"} +(10,1,1) = {" +uI +dy +id +GU +Pp +bt +uI +"} +(11,1,1) = {" +uI +uI +uI +SU +uI +uI +uI +"} +(12,1,1) = {" +uI +gv +ts +iN +KN +gz +uI +"} +(13,1,1) = {" +kk +Ie +TT +uv +sk +UV +kk +"} +(14,1,1) = {" +kk +kk +im +DF +zP +kk +kk +"} +(15,1,1) = {" +Jv +kk +kk +kk +kk +kk +Jv +"} diff --git a/_maps/voidcrew/shuttles/ruin_syndicate_fighter_shiv.dmm b/_maps/voidcrew/shuttles/ruin_syndicate_fighter_shiv.dmm new file mode 100644 index 00000000000..9ca923f4561 --- /dev/null +++ b/_maps/voidcrew/shuttles/ruin_syndicate_fighter_shiv.dmm @@ -0,0 +1,156 @@ +//MAP CONVERTED BY dmm2tgm.py THIS HEADER COMMENT PREVENTS RECONVERSION, DO NOT REMOVE +"cZ" = ( +/obj/machinery/porta_turret/syndicate/energy{ + dir = 4 + }, +/turf/closed/wall/mineral/plastitanium, +/area/shuttle/ruin/caravan/syndicate1) +"dc" = ( +/obj/structure/chair/comfy/shuttle{ + dir = 4 + }, +/obj/machinery/turretid{ + ailock = 1; + desc = "A specially designed set of turret controls. Looks to be covered in protective casing to prevent AI interfacing."; + icon_state = "control_kill"; + lethal = 1; + name = "Shuttle turret control"; + pixel_x = 32; + pixel_y = -28; + req_access = list("syndicate") + }, +/obj/structure/cable, +/obj/effect/spawner/human_npc/ruin/syndicate/gunner/pilot, +/turf/open/floor/mineral/plastitanium/red, +/area/shuttle/ruin/caravan/syndicate1) +"ie" = ( +/turf/closed/wall/mineral/plastitanium, +/area/shuttle/ruin/caravan/syndicate1) +"qe" = ( +/obj/effect/decal/cleanable/dirt, +/obj/effect/decal/cleanable/dirt, +/obj/machinery/computer/shuttle/caravan/syndicate1{ + dir = 8 + }, +/turf/open/floor/mineral/plastitanium/red, +/area/shuttle/ruin/caravan/syndicate1) +"qu" = ( +/turf/closed/wall/mineral/plastitanium/nodiagonal, +/area/shuttle/ruin/caravan/syndicate1) +"tO" = ( +/obj/effect/decal/cleanable/dirt, +/obj/machinery/computer/camera_advanced/shuttle_docker/caravan/syndicate1, +/obj/machinery/button/door/directional/west{ + id = "caravansyndicate1_bolt"; + name = "External Bolt Control"; + normaldoorcontrol = 1; + req_access = list("syndicate"); + specialfunctions = 4 + }, +/turf/open/floor/mineral/plastitanium/red, +/area/shuttle/ruin/caravan/syndicate1) +"Jv" = ( +/turf/template_noop, +/area/template_noop) +"UZ" = ( +/obj/machinery/power/shuttle_engine/propulsion/burst{ + dir = 8 + }, +/turf/closed/wall/mineral/plastitanium, +/area/shuttle/ruin/caravan/syndicate1) +"Ve" = ( +/obj/machinery/camera/xray/directional/west{ + c_tag = "External View"; + network = list("caravansyndicate1"); + pixel_x = 32 + }, +/turf/closed/wall/mineral/plastitanium/nodiagonal, +/area/shuttle/ruin/caravan/syndicate1) +"Yi" = ( +/obj/effect/mapping_helpers/airlock/locked, +/obj/machinery/door/airlock/hatch{ + id_tag = "caravansyndicate1_bolt"; + name = "External Airlock"; + normalspeed = 0 + }, +/obj/effect/decal/cleanable/dirt, +/obj/docking_port/mobile{ + callTime = 50; + dir = 4; + shuttle_id = "caravansyndicate1"; + ignitionTime = 25; + name = "Syndicate Fighter"; + port_direction = 2; + preferred_direction = 4 + }, +/obj/structure/cable, +/obj/effect/mapping_helpers/airlock/access/all/syndicate/general, +/turf/open/floor/plating, +/area/shuttle/ruin/caravan/syndicate1) +"YY" = ( +/obj/machinery/power/apc/auto_name/directional/west, +/obj/effect/mapping_helpers/apc/syndicate_access, +/obj/effect/mapping_helpers/apc/cell_10k, +/obj/machinery/computer/security{ + dir = 1; + network = list("caravansyndicate1") + }, +/obj/structure/cable, +/turf/open/floor/mineral/plastitanium/red, +/area/shuttle/ruin/caravan/syndicate1) + +(1,1,1) = {" +Jv +Jv +UZ +qu +Yi +qu +UZ +Jv +Jv +"} +(2,1,1) = {" +Jv +UZ +qu +tO +dc +YY +qu +UZ +Jv +"} +(3,1,1) = {" +ie +qu +qu +qu +qe +qu +qu +qu +ie +"} +(4,1,1) = {" +qu +ie +Jv +cZ +Ve +cZ +Jv +ie +qu +"} +(5,1,1) = {" +cZ +Jv +Jv +Jv +Jv +Jv +Jv +Jv +cZ +"} diff --git a/code/modules/mob/living/basic/trooper/trooper.dm b/code/modules/mob/living/basic/trooper/trooper.dm index 32829923d23..779c2469457 100644 --- a/code/modules/mob/living/basic/trooper/trooper.dm +++ b/code/modules/mob/living/basic/trooper/trooper.dm @@ -32,8 +32,7 @@ /mob/living/basic/trooper/Initialize(mapload) . = ..() - if(use_dynamic_appearance) // VOIDCREW EDIT - apply_dynamic_human_appearance(src, mob_spawn_path = mob_spawner, r_hand = r_hand, l_hand = l_hand) // VOIDCREW EDIT: trooper appearance integration: respect static fork sprites (voidcrew/edits/modules/mob/living/basic/trooper/trooper.dm) + apply_dynamic_human_appearance(src, mob_spawn_path = mob_spawner, r_hand = r_hand, l_hand = l_hand) // VOIDCREW EDIT CHANGE: unconditional again; the static-sprite opt-out went with the human NPC migration (voidcrew/modules/human_npcs) if(LAZYLEN(loot) || corpse) LAZYOR(loot, corpse) loot = string_list(loot) diff --git a/code/modules/unit_tests/simple_animal_freeze.dm b/code/modules/unit_tests/simple_animal_freeze.dm index daefc29f871..457b208f62e 100644 --- a/code/modules/unit_tests/simple_animal_freeze.dm +++ b/code/modules/unit_tests/simple_animal_freeze.dm @@ -33,12 +33,6 @@ // mob set, grandfathered here so the freeze still catches genuinely new // simple animals. They are queued for the basic mob refactor like the rest. // VOIDCREW EDIT START: unit_tests retains the existing mining fauna during basic-mob migration. - /mob/living/simple_animal/hostile/asteroid/hermit, - /mob/living/simple_animal/hostile/asteroid/hermit/ranged, - /mob/living/simple_animal/hostile/asteroid/hermit/ranged/gunslinger, - /mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter, - /mob/living/simple_animal/hostile/asteroid/hermit/survivor, - /mob/living/simple_animal/hostile/asteroid/hermit/survivor/random, /mob/living/simple_animal/hostile/asteroid/old_demon, // VOIDCREW EDIT END /mob/living/simple_animal/hostile/asteroid/polarbear, diff --git a/tgstation.dme b/tgstation.dme index a9282662bc2..c15906369fe 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -6921,7 +6921,6 @@ #include "voidcrew\edits\modules\mob\mob.dm" #include "voidcrew\edits\modules\mob\mob_defines.dm" #include "voidcrew\edits\modules\mob\living\basic\lavaland\legion\spawn_legions.dm" -#include "voidcrew\edits\modules\mob\living\basic\trooper\trooper.dm" #include "voidcrew\edits\modules\mob\living\carbon\inventory.dm" #include "voidcrew\edits\modules\mod\modules\modules_supply.dm" #include "voidcrew\edits\modules\modular_computers\file_system\programs\budgetordering.dm" @@ -7242,12 +7241,17 @@ #include "voidcrew\modules\human_npcs\human_npc_combat_sense.dm" #include "voidcrew\modules\human_npcs\human_npc_gear.dm" #include "voidcrew\modules\human_npcs\human_npc_outfits.dm" +#include "voidcrew\modules\human_npcs\human_npc_outfits_pirates.dm" #include "voidcrew\modules\human_npcs\human_npc_samples.dm" #include "voidcrew\modules\human_npcs\human_npc_soft_crit.dm" #include "voidcrew\modules\human_npcs\human_npc_spawning.dm" #include "voidcrew\modules\human_npcs\human_npc_spike_harness.dm" #include "voidcrew\modules\human_npcs\human_npc_states.dm" #include "voidcrew\modules\human_npcs\human_npc_surrender.dm" +#include "voidcrew\modules\human_npcs\ruins\ruin_npc_base.dm" +#include "voidcrew\modules\human_npcs\ruins\ruin_npc_hermits.dm" +#include "voidcrew\modules\human_npcs\ruins\ruin_npc_spawners.dm" +#include "voidcrew\modules\human_npcs\ruins\ruin_npc_troopers.dm" #include "voidcrew\modules\hyperviolence\_core.dm" #include "voidcrew\modules\hyperviolence\blood\_blood_defines.dm" #include "voidcrew\modules\hyperviolence\blood\blood_pools.dm" @@ -7398,7 +7402,6 @@ #include "voidcrew\modules\mob\living\simple_animal\hostile\hivebot.dm" #include "voidcrew\modules\mob\living\simple_animal\hostile\killertomato.dm" #include "voidcrew\modules\mob\living\simple_animal\hostile\mushroom.dm" -#include "voidcrew\modules\mob\living\simple_animal\hostile\pirate.dm" #include "voidcrew\modules\mob\living\simple_animal\hostile\wumborian_fugu.dm" #include "voidcrew\modules\mob\living\simple_animal\hostile\jungle\mega_arachnid.dm" #include "voidcrew\modules\mob\living\simple_animal\hostile\mining_mobs\basilisk.dm" @@ -7407,7 +7410,6 @@ #include "voidcrew\modules\mob\living\simple_animal\hostile\mining_mobs\ice_demon.dm" #include "voidcrew\modules\mob\living\simple_animal\hostile\mining_mobs\polarbear.dm" #include "voidcrew\modules\mob\living\simple_animal\hostile\mining_mobs\wolf.dm" -#include "voidcrew\modules\mob\living\simple_animal\hostile\wasteland\hermits.dm" #include "voidcrew\modules\mob\living\simple_animal\slime\slime.dm" #include "voidcrew\modules\mob_spawn\corpses\wasteland_corpses.dm" #include "voidcrew\modules\mob_spawn\ghost_roles\skeleton_roles.dm" @@ -7456,6 +7458,8 @@ #include "voidcrew\modules\npc_ships\code\overmap_pathfinding.dm" #include "voidcrew\modules\npc_ships\code\pirate_crew.dm" #include "voidcrew\modules\npc_ships\code\pirate_crew_ai.dm" +#include "voidcrew\modules\npc_ships\code\pirate_crew_combat_sense.dm" +#include "voidcrew\modules\npc_ships\code\pirate_crew_human.dm" #include "voidcrew\modules\npc_ships\code\pirate_guns.dm" #include "voidcrew\modules\npc_ships\code\ship_key.dm" #include "voidcrew\modules\npc_ships\code\spawner_subsystem.dm" @@ -7467,6 +7471,7 @@ #include "voidcrew\modules\npc_ships\code\faction_pirates\faction_pirate_bosses.dm" #include "voidcrew\modules\npc_ships\code\faction_pirates\faction_pirate_corpses.dm" #include "voidcrew\modules\npc_ships\code\faction_pirates\faction_pirate_equipment.dm" +#include "voidcrew\modules\npc_ships\code\faction_pirates\faction_pirate_humans.dm" #include "voidcrew\modules\npc_ships\code\faction_pirates\faction_pirate_mobs.dm" #include "voidcrew\modules\npc_ships\code\faction_pirates\faction_pirate_ships.dm" #include "voidcrew\modules\npc_ships\code\faction_pirates\nt_patrol.dm" diff --git a/voidcrew/controllers/subsystem/planet_mobs.dm b/voidcrew/controllers/subsystem/planet_mobs.dm index ba6718aa84a..f772ec5db19 100644 --- a/voidcrew/controllers/subsystem/planet_mobs.dm +++ b/voidcrew/controllers/subsystem/planet_mobs.dm @@ -351,7 +351,7 @@ SUBSYSTEM_DEF(planet_mobs) continue var/datum/npc_spawn_context/context = new(tracker, tracker.zone_band, source_turf = candidate) - spawn_npc_in_zone(mob_type, candidate, context) + spawn_npc_in_zone_or_queue(mob_type, candidate, context) spawned++ total_managed_mobs++ diff --git a/voidcrew/datums/mapgen/PlanetGenerator.dm b/voidcrew/datums/mapgen/PlanetGenerator.dm index 4bfb47df656..9b5c02e7fa1 100644 --- a/voidcrew/datums/mapgen/PlanetGenerator.dm +++ b/voidcrew/datums/mapgen/PlanetGenerator.dm @@ -552,7 +552,7 @@ if(can_spawn) var/datum/npc_spawn_context/context = new(src, zone_band, "auto", source_turf = target_turf) - spawn_npc_in_zone(picked_mob, target_turf, context) + spawn_npc_in_zone_or_queue(picked_mob, target_turf, context) spawned_something = TRUE // The expensive half of a planet build - every iteration runs several range() // scans - and the one that most needs to stop hogging the tick. See diff --git a/voidcrew/datums/mapgen/biomes/_biome.dm b/voidcrew/datums/mapgen/biomes/_biome.dm index 6ef081c4196..80c1637c63d 100644 --- a/voidcrew/datums/mapgen/biomes/_biome.dm +++ b/voidcrew/datums/mapgen/biomes/_biome.dm @@ -126,7 +126,7 @@ if(can_spawn) var/datum/npc_spawn_context/context = new(src, source_turf = new_turf) - spawn_npc_in_zone(picked_mob, new_turf, context) + spawn_npc_in_zone_or_queue(picked_mob, new_turf, context) new_turf.flags_1 |= NO_LAVA_GEN diff --git a/voidcrew/datums/mapgen/biomes/beach_biomes.dm b/voidcrew/datums/mapgen/biomes/beach_biomes.dm index 6b7d8ffa634..ce3af2a53ca 100644 --- a/voidcrew/datums/mapgen/biomes/beach_biomes.dm +++ b/voidcrew/datums/mapgen/biomes/beach_biomes.dm @@ -94,7 +94,7 @@ dangerous_mob_spawn_list = list( /mob/living/basic/carp/beach = 3, /mob/living/basic/carp/mega/beach = 1, - /mob/living/basic/trooper/pirate/melee/beach/boat = 1, + /mob/living/carbon/human/npc/ruin/trooper/pirate/beach = 1, ) flora_spawn_list = list( /obj/structure/flora/rock/beach = 1, @@ -111,12 +111,12 @@ /mob/living/basic/carp/beach = 6, /mob/living/basic/carp/beach/small = 5, /mob/living/basic/carp/mega/beach = 2, - /mob/living/basic/trooper/pirate/melee/beach/boat = 3, - /mob/living/basic/trooper/pirate/ranged/beach/boat = 1 + /mob/living/carbon/human/npc/ruin/trooper/pirate/beach = 3, + /mob/living/carbon/human/npc/ruin/trooper/pirate/beach/gunner = 1 ) dangerous_mob_spawn_list = list( /mob/living/basic/carp/mega/beach = 2, - /mob/living/basic/trooper/pirate/ranged/beach/boat = 1, + /mob/living/carbon/human/npc/ruin/trooper/pirate/beach/gunner = 1, ) feature_spawn_chance = 0.1 feature_spawn_list = list( diff --git a/voidcrew/datums/mapgen/biomes/wasteland_biomes.dm b/voidcrew/datums/mapgen/biomes/wasteland_biomes.dm index 2a0736c2fba..c2ff36d4115 100644 --- a/voidcrew/datums/mapgen/biomes/wasteland_biomes.dm +++ b/voidcrew/datums/mapgen/biomes/wasteland_biomes.dm @@ -24,14 +24,14 @@ feature_spawn_chance = 3 mob_spawn_chance = 7 mob_spawn_list = list( - /mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter = 10, + /mob/living/carbon/human/npc/ruin/hermit/hunter = 10, /mob/living/basic/spider/giant/wasteland = 1, /mob/living/basic/spider/giant/tarantula/wasteland = 1, /mob/living/basic/mining/legion/wasteland = 3 ) // Meaner tier for dangerous-zone planets (see dangerous_mob_spawn_list) dangerous_mob_spawn_list = list( - /mob/living/simple_animal/hostile/asteroid/hermit/ranged/gunslinger = 5, + /mob/living/carbon/human/npc/ruin/hermit/gunslinger = 5, /mob/living/basic/mining/legion/wasteland = 3, /mob/living/basic/spider/giant/tarantula/wasteland = 2, /mob/living/basic/spider/giant/wasteland = 2, @@ -92,13 +92,13 @@ flora_spawn_list = list(/obj/structure/flora/rock/wasteland = 30, /obj/effect/decal/cleanable/greenglow = 30, /obj/structure/elite_tumor = 1) mob_spawn_chance = 20 mob_spawn_list = list( - /mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter = 17, + /mob/living/carbon/human/npc/ruin/hermit/hunter = 17, /mob/living/basic/hivebot/range = 5, /mob/living/basic/spider/giant/wasteland = 1, /mob/living/basic/spider/giant/tarantula/wasteland = 1 ) dangerous_mob_spawn_list = list( - /mob/living/simple_animal/hostile/asteroid/hermit/ranged/gunslinger = 7, + /mob/living/carbon/human/npc/ruin/hermit/gunslinger = 7, /mob/living/basic/hivebot/rapid/wasteland = 3, /mob/living/basic/spider/giant/tarantula/wasteland = 1, ) diff --git a/voidcrew/edits/mobs/weapon_drops.dm b/voidcrew/edits/mobs/weapon_drops.dm index 077bbe65666..ecf94506ea9 100644 --- a/voidcrew/edits/mobs/weapon_drops.dm +++ b/voidcrew/edits/mobs/weapon_drops.dm @@ -59,8 +59,7 @@ if(istype(src, /mob/living/basic/trooper/nanotrasen/ranged)) if((zone == ZONE_GREEN && (istype(src, /mob/living/basic/trooper/nanotrasen/ranged/smg) || istype(src, /mob/living/basic/trooper/nanotrasen/ranged/assault))) || (zone != ZONE_RED && istype(src, /mob/living/basic/trooper/nanotrasen/ranged/elite))) pistol_type = /mob/living/basic/trooper/nanotrasen/ranged - if(zone != ZONE_RED && (istype(src, /mob/living/basic/trooper/nanotrasen/ranged/smg/customs) || istype(src, /mob/living/basic/trooper/nanotrasen/ranged/assault/customs))) - pistol_type = /mob/living/basic/trooper/nanotrasen/ranged + // NT customs are human NPCs now: their ladder pistol is in their outfit table (faction_pirates/nt_patrol.dm) else if(istype(src, /mob/living/basic/trooper/syndicate/ranged)) if(zone != ZONE_RED && (istype(src, /mob/living/basic/trooper/syndicate/ranged/smg) || istype(src, /mob/living/basic/trooper/syndicate/ranged/shotgun) || (zone == ZONE_GREEN && istype(src, /mob/living/basic/trooper/syndicate/ranged/space/stormtrooper)))) pistol_type = /mob/living/basic/trooper/syndicate/ranged @@ -76,8 +75,7 @@ r_hand = /obj/item/knife/combat/survival l_hand = null set_light(0) - if(use_dynamic_appearance) - apply_dynamic_human_appearance(src, mob_spawn_path = mob_spawner, r_hand = r_hand) + apply_dynamic_human_appearance(src, mob_spawn_path = mob_spawner, r_hand = r_hand) return TRUE /mob/living/basic/trooper/proc/use_ladder_pistol(mob/living/basic/trooper/profile) @@ -102,8 +100,7 @@ QDEL_NULL(ai_controller) ai_controller = new /datum/ai_controller/basic_controller/trooper/ranged(src) r_hand = initial(profile.r_hand) - if(use_dynamic_appearance) - apply_dynamic_human_appearance(src, mob_spawn_path = mob_spawner, r_hand = r_hand, l_hand = l_hand) + apply_dynamic_human_appearance(src, mob_spawn_path = mob_spawner, r_hand = r_hand, l_hand = l_hand) // Copy both lists before trimming them: crusher kills must use the very same // construction-time roll, and must keep trophies and the mining accelerator. diff --git a/voidcrew/edits/modules/mob/living/basic/trooper/trooper.dm b/voidcrew/edits/modules/mob/living/basic/trooper/trooper.dm deleted file mode 100644 index 595da62d1af..00000000000 --- a/voidcrew/edits/modules/mob/living/basic/trooper/trooper.dm +++ /dev/null @@ -1,5 +0,0 @@ -// Voidcrew extensions to code/modules/mob/living/basic/trooper/trooper.dm. - -/mob/living/basic/trooper - /// VOIDCREW EDIT: subtypes with bespoke static sprites (e.g. boat pirates) set this FALSE to keep their own icon. - var/use_dynamic_appearance = TRUE diff --git a/voidcrew/modules/cargo/shipping/_shuttle_loan.dm b/voidcrew/modules/cargo/shipping/_shuttle_loan.dm index 49ee78bb71a..87b3d32db60 100644 --- a/voidcrew/modules/cargo/shipping/_shuttle_loan.dm +++ b/voidcrew/modules/cargo/shipping/_shuttle_loan.dm @@ -210,13 +210,14 @@ GLOBAL_LIST_INIT(voidcrew_shuttle_loans, list( qdel(item) return delivery -/// The cargo bay can be off-map; its host ship supplies the encounter band. +/// The cargo bay can be off-map; its host ship supplies the encounter band. People (human NPCs) are queued +/// and built a body a tick (spawn_npc_in_zone_or_queue()). /datum/voidcrew_shuttle_loan/proc/spawn_hostile(mob_type, turf/location, datum/voidcrew_cargo_shuttle/shuttle) if(!npc_source) var/turf/source_turf = get_turf(shuttle.target_ship) npc_source = new(shuttle, SSovermap_zones.get_zone_type_anywhere(source_turf) || ZONE_GREEN, source_turf = source_turf) var/datum/npc_spawn_context/context = new(shuttle, npc_source.zone_type, "ordinary", source_turf = npc_source.source_turf) - return spawn_npc_in_zone(mob_type, location, context) + return spawn_npc_in_zone_or_queue(mob_type, location, context) /// Department resupply - free supplies, no bonus /datum/voidcrew_shuttle_loan/department_resupply @@ -449,13 +450,13 @@ GLOBAL_LIST_INIT(voidcrew_shuttle_loans, list( for(var/i in 1 to 2) if(!length(cargo_turfs)) break - spawn_hostile(/mob/living/basic/trooper/syndicate/ranged/infiltrator, pick_n_take(cargo_turfs), shuttle) + spawn_hostile(/mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/infiltrator, pick_n_take(cargo_turfs), shuttle) // Chance for more if(prob(75) && length(cargo_turfs)) - spawn_hostile(/mob/living/basic/trooper/syndicate/ranged/infiltrator, pick_n_take(cargo_turfs), shuttle) + spawn_hostile(/mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/infiltrator, pick_n_take(cargo_turfs), shuttle) if(prob(50) && length(cargo_turfs)) - spawn_hostile(/mob/living/basic/trooper/syndicate/ranged/infiltrator, pick_n_take(cargo_turfs), shuttle) + spawn_hostile(/mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/infiltrator, pick_n_take(cargo_turfs), shuttle) /// Lots of bees - Toxic bees and beekeeping equipment /datum/voidcrew_shuttle_loan/lots_of_bees @@ -580,15 +581,15 @@ GLOBAL_LIST_INIT(voidcrew_shuttle_loans, list( // The Russians if(length(cargo_turfs)) - spawn_hostile(/mob/living/basic/trooper/russian, pick_n_take(cargo_turfs), shuttle) + spawn_hostile(/mob/living/carbon/human/npc/ruin/trooper/russian, pick_n_take(cargo_turfs), shuttle) if(length(cargo_turfs)) - spawn_hostile(/mob/living/basic/trooper/russian/ranged, pick_n_take(cargo_turfs), shuttle) // This one drops a mateba + spawn_hostile(/mob/living/carbon/human/npc/ruin/trooper/russian/gunner, pick_n_take(cargo_turfs), shuttle) // This one drops a Nagant if(length(cargo_turfs)) spawn_hostile(/mob/living/basic/bear/russian, pick_n_take(cargo_turfs), shuttle) // Chance for more if(prob(75) && length(cargo_turfs)) - spawn_hostile(/mob/living/basic/trooper/russian, pick_n_take(cargo_turfs), shuttle) + spawn_hostile(/mob/living/carbon/human/npc/ruin/trooper/russian, pick_n_take(cargo_turfs), shuttle) if(prob(50) && length(cargo_turfs)) spawn_hostile(/mob/living/basic/bear/russian, pick_n_take(cargo_turfs), shuttle) diff --git a/voidcrew/modules/dynamic_events/events/portal_storm.dm b/voidcrew/modules/dynamic_events/events/portal_storm.dm index 98b221070a6..7dee9a0a9e1 100644 --- a/voidcrew/modules/dynamic_events/events/portal_storm.dm +++ b/voidcrew/modules/dynamic_events/events/portal_storm.dm @@ -179,12 +179,24 @@ if(!spawn_turf || !target_ship.is_aboard(spawn_turf)) continue var/datum/npc_spawn_context/context = new(target_ship, npc_spawn_zone, role, source_turf = npc_source_turf) + // People (human NPCs) are queued and step out of the portal as they are built, a body a tick. + if(ispath(mob_type, /mob/living/carbon/human/npc)) + spawn_human_npc(mob_type, spawn_turf, CALLBACK(src, PROC_REF(human_stepped_out)), context = context) + spawned_mobs++ + continue var/mob/living/new_hostile = spawn_npc_in_zone(mob_type, spawn_turf, context) if(QDELETED(new_hostile)) continue spawned_mobs++ spawn_effects(spawn_turf) +/// A queued boarder is built: the portal flashes where it steps out, if it is still aboard. +/datum/round_event/voidcrew/portal_storm/proc/human_stepped_out(mob/living/carbon/human/npc/boarder) + var/turf/spot = get_turf(boarder) + if(!spot || !target_valid() || !target_ship.is_aboard(spot)) + return + spawn_effects(spot) + /// Plays TG's portal flash and sound without allowing the shifted visual off-ship. /datum/round_event/voidcrew/portal_storm/proc/spawn_effects(turf/spawn_turf) if(!target_valid() || !spawn_turf || !target_ship.is_aboard(spawn_turf)) @@ -194,16 +206,17 @@ if(!target_ship.is_aboard(effect_turf)) effect_turf = spawn_turf var/appearance_index = GET_TURF_PLANE_OFFSET(effect_turf) + 1 - if(appearance_index <= length(storm_appearances)) + if(appearance_index <= length(storm_appearances) && storm_appearances[appearance_index]) effect_turf.flick_overlay_static(storm_appearances[appearance_index], 15) playsound(effect_turf, 'sound/effects/magic/lightningbolt.ogg', rand(80, 100), TRUE) -/// Syndicate commandos, with a stormtrooper occupying the optional boss slot. +/// Syndicate commandos, with a stormtrooper occupying the optional boss slot: people in sealed suits +/// (human NPCs, voidcrew/modules/human_npcs/ruins/ruin_npc_troopers.dm), armed for the zone they board in. /datum/round_event/voidcrew/portal_storm/syndicate_shocktroop - boss_types = list(/mob/living/basic/trooper/syndicate/melee/space/stormtrooper = 2) + boss_types = list(/mob/living/carbon/human/npc/ruin/trooper/syndicate/stormtrooper/sword = 2) hostile_types = list( - /mob/living/basic/trooper/syndicate/melee/space = 8, - /mob/living/basic/trooper/syndicate/ranged/space = 2, + /mob/living/carbon/human/npc/ruin/trooper/syndicate/commando = 8, + /mob/living/carbon/human/npc/ruin/trooper/syndicate/commando/gunner = 2, ) /// Hostile cult constructs using the same pulse and population limits. diff --git a/voidcrew/modules/human_npcs/human_npc_outfits_pirates.dm b/voidcrew/modules/human_npcs/human_npc_outfits_pirates.dm new file mode 100644 index 00000000000..199f63e5af5 --- /dev/null +++ b/voidcrew/modules/human_npcs/human_npc_outfits_pirates.dm @@ -0,0 +1,398 @@ +/** + * # Pirate faction outfits for human NPCs (N7, for phase B) + * + * The faction looks are today's faction pirate corpse outfits (voidcrew/modules/npc_ships/code/ + * faction_pirates/faction_pirate_corpses.dm), so a human pirate looks like the pirate players already + * know. These subtypes add what the basic mob only drew: the real weapon in hand, and the real spare + * magazines, shells or backup knife it fights on with (human_npc_ai.dm reloads from them the way a player + * does). Energy guns can't be reloaded by hand, so energy gunners carry a knife. + * + * Guns per faction follow PR #500's crew gun weights; melee weapons, captains and bosses hold what the + * basic mobs hold today, the bosses' with their own attack verbs (faction_pirate_humans.dm). The melee + * crew carry a crowbar for unpowered doors. The ship crews that wear these are in + * voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_humans.dm. + * + * Tables (one per faction): /datum/human_npc_outfit_table/pirate/ dresses a mixed crew (melee + * and gunners, the faction's captain for elites and its boss for bosses); + * /datum/human_npc_outfit_table/pirate//gunners only gunners. The ship crews add a boarding + * table per faction (sealed for vacuum) and pick by their crew_role (faction_pirate_humans.dm). In vacuum + * each faction gets its own space suit (vacuum_layer). + */ + +/datum/human_npc_outfit_table/pirate + vacuum_layer = /datum/human_npc_layer/eva/pirate + /// Melee crew outfits: outfit typepath => weight + var/list/melee + /// Gunner outfits: outfit typepath => weight, as the faction's crew guns + var/list/gunners + /// Dress only gunners + var/gunners_only = FALSE + +/datum/human_npc_outfit_table/pirate/New() + . = ..() + if(!isnull(green)) + return + green = gunners?.Copy() || list() + if(gunners_only) + return + for(var/outfit_type in melee) + green[outfit_type] = melee[outfit_type] + +// ===== SILVERSCALE ===== + +/datum/human_npc_layer/eva/silverscale + suit = /obj/item/clothing/suit/space/pirate/silverscale + head = /obj/item/clothing/head/helmet/space/pirate/tophat + +/datum/human_npc_outfit_table/pirate/silverscale + vacuum_layer = /datum/human_npc_layer/eva/silverscale + melee = list(/datum/outfit/piratecorpse/faction/silverscale/melee/armed = 4) + gunners = list( + /datum/outfit/piratecorpse/faction/silverscale/ranged/energy_gun = 3, + /datum/outfit/piratecorpse/faction/silverscale/ranged/laser_rifle = 2, + /datum/outfit/piratecorpse/faction/silverscale/ranged/pistol = 3, + /datum/outfit/piratecorpse/faction/silverscale/ranged/shotgun = 1, + ) + elite = list(/datum/outfit/piratecorpse/faction/silverscale/captain/armed = 1) + boss = list(/datum/outfit/piratecorpse/faction/silverscale/highlord/armed = 1) + +/datum/human_npc_outfit_table/pirate/silverscale/gunners + gunners_only = TRUE + +/datum/outfit/piratecorpse/faction/silverscale/melee/armed + name = "Human NPC: Silverscale Duelist" + r_hand = /obj/item/melee/energy/sword/pirate + l_pocket = /obj/item/crowbar + +/datum/outfit/piratecorpse/faction/silverscale/ranged/energy_gun + name = "Human NPC: Silverscale Marksman (energy gun)" + r_hand = /obj/item/gun/energy/e_gun/lethal + l_pocket = /obj/item/knife/combat/survival + +/datum/outfit/piratecorpse/faction/silverscale/ranged/laser_rifle + name = "Human NPC: Silverscale Marksman (laser rifle)" + r_hand = /obj/item/gun/energy/laser + l_pocket = /obj/item/knife/combat/survival + +/datum/outfit/piratecorpse/faction/silverscale/ranged/pistol + name = "Human NPC: Silverscale Marksman (pistol)" + r_hand = /obj/item/gun/ballistic/automatic/pistol + l_pocket = /obj/item/ammo_box/magazine/m9mm + r_pocket = /obj/item/ammo_box/magazine/m9mm + +/datum/outfit/piratecorpse/faction/silverscale/ranged/shotgun + name = "Human NPC: Silverscale Marksman (shotgun)" + r_hand = /obj/item/gun/ballistic/shotgun/lethal + belt = /obj/item/storage/belt/bandolier + belt_contents = list(/obj/item/ammo_casing/shotgun/buckshot = 8) + +/datum/outfit/piratecorpse/faction/silverscale/captain/armed + name = "Human NPC: Silverscale Noble" + r_hand = /obj/item/melee/sabre + +/datum/outfit/piratecorpse/faction/silverscale/highlord/armed + name = "Human NPC: Silverscale Highlord" + r_hand = /obj/item/melee/energy/sword/pirate/boss + +// ===== SKELETON ===== + +/datum/human_npc_layer/eva/pirate/bandana + head = /obj/item/clothing/head/helmet/space/pirate/bandana + +// Skeletons don't breathe and shrug off vacuum and cold (their species), so they rarely need the suit. +/datum/human_npc_outfit_table/pirate/skeleton + vacuum_layer = /datum/human_npc_layer/eva/pirate/bandana + melee = list(/datum/outfit/piratecorpse/faction/skeleton/melee/armed = 4) + gunners = list( + /datum/outfit/piratecorpse/faction/skeleton/ranged/laser_rifle = 1, + /datum/outfit/piratecorpse/faction/skeleton/ranged/pistol = 2, + /datum/outfit/piratecorpse/faction/skeleton/ranged/smg = 2, + /datum/outfit/piratecorpse/faction/skeleton/ranged/shotgun = 3, + ) + elite = list(/datum/outfit/piratecorpse/faction/skeleton/captain/armed = 1) + boss = list(/datum/outfit/piratecorpse/faction/skeleton/davyjones/armed = 1) + +/datum/human_npc_outfit_table/pirate/skeleton/gunners + gunners_only = TRUE + +/datum/outfit/piratecorpse/faction/skeleton/melee/armed + name = "Human NPC: Skeleton Swashbuckler" + r_hand = /obj/item/melee/energy/sword/pirate + l_pocket = /obj/item/crowbar + +/datum/outfit/piratecorpse/faction/skeleton/ranged/laser_rifle + name = "Human NPC: Skeleton Gunner (laser rifle)" + r_hand = /obj/item/gun/energy/laser + l_pocket = /obj/item/knife/combat/survival + +/datum/outfit/piratecorpse/faction/skeleton/ranged/pistol + name = "Human NPC: Skeleton Gunner (pistol)" + r_hand = /obj/item/gun/ballistic/automatic/pistol + l_pocket = /obj/item/ammo_box/magazine/m9mm + r_pocket = /obj/item/ammo_box/magazine/m9mm + +/datum/outfit/piratecorpse/faction/skeleton/ranged/smg + name = "Human NPC: Skeleton Gunner (SMG)" + r_hand = /obj/item/gun/ballistic/automatic/mini_uzi + l_pocket = /obj/item/ammo_box/magazine/uzim9mm + r_pocket = /obj/item/ammo_box/magazine/uzim9mm + +/datum/outfit/piratecorpse/faction/skeleton/ranged/shotgun + name = "Human NPC: Skeleton Gunner (shotgun)" + r_hand = /obj/item/gun/ballistic/shotgun/lethal + belt = /obj/item/storage/belt/bandolier + belt_contents = list(/obj/item/ammo_casing/shotgun/buckshot = 8) + +/datum/outfit/piratecorpse/faction/skeleton/captain/armed + name = "Human NPC: Skeleton Captain" + r_hand = /obj/item/claymore/cutlass + +// His flask of cursed grog (voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_humans.dm) where +// the corpse kept a doubloon. +/datum/outfit/piratecorpse/faction/skeleton/davyjones/armed + name = "Human NPC: Davy Jones" + r_hand = /obj/item/claymore/cutlass/davy_jones + l_pocket = /obj/item/reagent_containers/cup/glass/flask/davy_jones + +// ===== GREY TIDE ===== + +// Assistants in the station's grey EVA suits: slow, but sealed. +/datum/human_npc_outfit_table/pirate/grey + vacuum_layer = /datum/human_npc_layer/eva + melee = list(/datum/outfit/piratecorpse/faction/grey/melee/armed = 4) + gunners = list( + /datum/outfit/piratecorpse/faction/grey/ranged/energy_gun = 3, + /datum/outfit/piratecorpse/faction/grey/ranged/laser_rifle = 3, + /datum/outfit/piratecorpse/faction/grey/ranged/smg = 1, + ) + elite = list(/datum/outfit/piratecorpse/faction/grey/captain/armed = 1) + boss = list(/datum/outfit/piratecorpse/faction/grey/robust/armed = 1) + +/datum/human_npc_outfit_table/pirate/grey/gunners + gunners_only = TRUE + +/datum/outfit/piratecorpse/faction/grey/melee/armed + name = "Human NPC: Grey Tider" + r_hand = /obj/item/storage/toolbox/mechanical + l_pocket = /obj/item/crowbar + +/datum/outfit/piratecorpse/faction/grey/ranged/energy_gun + name = "Human NPC: Grey Tider Gunner (energy gun)" + r_hand = /obj/item/gun/energy/e_gun/lethal + l_pocket = /obj/item/knife/combat/survival + +/datum/outfit/piratecorpse/faction/grey/ranged/laser_rifle + name = "Human NPC: Grey Tider Gunner (laser rifle)" + r_hand = /obj/item/gun/energy/laser + l_pocket = /obj/item/knife/combat/survival + +/datum/outfit/piratecorpse/faction/grey/ranged/smg + name = "Human NPC: Grey Tider Gunner (SMG)" + r_hand = /obj/item/gun/ballistic/automatic/mini_uzi + l_pocket = /obj/item/ammo_box/magazine/uzim9mm + r_pocket = /obj/item/ammo_box/magazine/uzim9mm + +/datum/outfit/piratecorpse/faction/grey/captain/armed + name = "Human NPC: Tidemaster" + r_hand = /obj/item/storage/toolbox/syndicate + +/datum/outfit/piratecorpse/faction/grey/robust/armed + name = "Human NPC: The Robust One" + r_hand = /obj/item/storage/toolbox/mechanical/old/clean/robust_one + +// ===== LUSTROUS ===== + +/datum/human_npc_outfit_table/pirate/lustrous + melee = list(/datum/outfit/piratecorpse/faction/lustrous/melee/armed = 4) + gunners = list( + /datum/outfit/piratecorpse/faction/lustrous/ranged/energy_gun = 3, + /datum/outfit/piratecorpse/faction/lustrous/ranged/laser_rifle = 3, + /datum/outfit/piratecorpse/faction/lustrous/ranged/pistol = 1, + ) + elite = list(/datum/outfit/piratecorpse/faction/lustrous/captain/armed = 1) + boss = list(/datum/outfit/piratecorpse/faction/lustrous/radiant/armed = 1) + +/datum/human_npc_outfit_table/pirate/lustrous/gunners + gunners_only = TRUE + +/datum/outfit/piratecorpse/faction/lustrous/melee/armed + name = "Human NPC: Lustrous Scintillant" + r_hand = /obj/item/switchblade + l_pocket = /obj/item/crowbar + +/datum/outfit/piratecorpse/faction/lustrous/ranged/energy_gun + name = "Human NPC: Lustrous Coruscant (energy gun)" + r_hand = /obj/item/gun/energy/e_gun/lethal + l_pocket = /obj/item/knife/combat/survival + +/datum/outfit/piratecorpse/faction/lustrous/ranged/laser_rifle + name = "Human NPC: Lustrous Coruscant (laser rifle)" + r_hand = /obj/item/gun/energy/laser + l_pocket = /obj/item/knife/combat/survival + +/datum/outfit/piratecorpse/faction/lustrous/ranged/pistol + name = "Human NPC: Lustrous Coruscant (pistol)" + r_hand = /obj/item/gun/ballistic/automatic/pistol + l_pocket = /obj/item/ammo_box/magazine/m9mm + r_pocket = /obj/item/ammo_box/magazine/m9mm + +/datum/outfit/piratecorpse/faction/lustrous/captain/armed + name = "Human NPC: Lustrous Radiant" + r_hand = /obj/item/melee/energy/sword/pirate + +/datum/outfit/piratecorpse/faction/lustrous/radiant/armed + name = "Human NPC: The Radiant One" + r_hand = /obj/item/melee/energy/sword/pirate/boss/radiant + +// ===== INTERDYNE ===== + +/datum/human_npc_layer/eva/interdyne + suit = /obj/item/clothing/suit/space/syndicate/black/med + head = /obj/item/clothing/head/helmet/space/syndicate/black/med + +/datum/human_npc_outfit_table/pirate/interdyne + vacuum_layer = /datum/human_npc_layer/eva/interdyne + melee = list(/datum/outfit/piratecorpse/faction/interdyne/melee/armed = 4) + gunners = list( + /datum/outfit/piratecorpse/faction/interdyne/ranged/energy_gun = 2, + /datum/outfit/piratecorpse/faction/interdyne/ranged/pistol = 2, + /datum/outfit/piratecorpse/faction/interdyne/ranged/smg = 3, + /datum/outfit/piratecorpse/faction/interdyne/ranged/shotgun = 1, + ) + elite = list(/datum/outfit/piratecorpse/faction/interdyne/captain/armed = 1) + boss = list(/datum/outfit/piratecorpse/faction/interdyne/prime/armed = 1) + +/datum/human_npc_outfit_table/pirate/interdyne/gunners + gunners_only = TRUE + +/datum/outfit/piratecorpse/faction/interdyne/melee/armed + name = "Human NPC: Interdyne Enforcer" + r_hand = /obj/item/scalpel + l_pocket = /obj/item/crowbar + +/datum/outfit/piratecorpse/faction/interdyne/ranged/energy_gun + name = "Human NPC: Interdyne Pharmacist (energy gun)" + r_hand = /obj/item/gun/energy/e_gun/lethal + l_pocket = /obj/item/knife/combat/survival + +/datum/outfit/piratecorpse/faction/interdyne/ranged/pistol + name = "Human NPC: Interdyne Pharmacist (pistol)" + r_hand = /obj/item/gun/ballistic/automatic/pistol + l_pocket = /obj/item/ammo_box/magazine/m9mm + r_pocket = /obj/item/ammo_box/magazine/m9mm + +/datum/outfit/piratecorpse/faction/interdyne/ranged/smg + name = "Human NPC: Interdyne Pharmacist (SMG)" + r_hand = /obj/item/gun/ballistic/automatic/mini_uzi + l_pocket = /obj/item/ammo_box/magazine/uzim9mm + r_pocket = /obj/item/ammo_box/magazine/uzim9mm + +/datum/outfit/piratecorpse/faction/interdyne/ranged/shotgun + name = "Human NPC: Interdyne Pharmacist (shotgun)" + r_hand = /obj/item/gun/ballistic/shotgun/lethal + belt = /obj/item/storage/belt/bandolier + belt_contents = list(/obj/item/ammo_casing/shotgun/buckshot = 8) + +/datum/outfit/piratecorpse/faction/interdyne/captain/armed + name = "Human NPC: Interdyne Director" + r_hand = /obj/item/melee/energy/sword/pirate + +// Today's Director Prime shoots lasers from its body; the human one holds the gun, with its combat +// hypospray in a pocket for phase B's self-treatment. +/datum/outfit/piratecorpse/faction/interdyne/prime/armed + name = "Human NPC: Interdyne Director Prime" + r_hand = /obj/item/gun/energy/e_gun/lethal + l_pocket = /obj/item/knife/combat/survival + r_pocket = /obj/item/reagent_containers/hypospray/combat + +// ===== IRS ===== + +/datum/human_npc_layer/eva/irs + suit = /obj/item/clothing/suit/space/syndicate/black + head = /obj/item/clothing/head/helmet/space/syndicate/black + +/datum/human_npc_outfit_table/pirate/irs + vacuum_layer = /datum/human_npc_layer/eva/irs + melee = list(/datum/outfit/piratecorpse/faction/irs/melee/armed = 4) + gunners = list( + /datum/outfit/piratecorpse/faction/irs/ranged/energy_gun = 1, + /datum/outfit/piratecorpse/faction/irs/ranged/pistol = 3, + /datum/outfit/piratecorpse/faction/irs/ranged/smg = 2, + /datum/outfit/piratecorpse/faction/irs/ranged/shotgun = 2, + ) + elite = list(/datum/outfit/piratecorpse/faction/irs/captain/armed = 1) + boss = list(/datum/outfit/piratecorpse/faction/irs/chief/armed = 1) + +/datum/human_npc_outfit_table/pirate/irs/gunners + gunners_only = TRUE + +// A real telescopic baton: it knocks people down, where the basic mob's only did brute. +/datum/outfit/piratecorpse/faction/irs/melee/armed + name = "Human NPC: IRS Enforcer" + r_hand = /obj/item/melee/baton/telescopic + l_pocket = /obj/item/crowbar + +/datum/outfit/piratecorpse/faction/irs/ranged/energy_gun + name = "Human NPC: IRS Agent (energy gun)" + r_hand = /obj/item/gun/energy/e_gun/lethal + l_pocket = /obj/item/knife/combat/survival + +/datum/outfit/piratecorpse/faction/irs/ranged/pistol + name = "Human NPC: IRS Agent (pistol)" + r_hand = /obj/item/gun/ballistic/automatic/pistol + l_pocket = /obj/item/ammo_box/magazine/m9mm + r_pocket = /obj/item/ammo_box/magazine/m9mm + +/datum/outfit/piratecorpse/faction/irs/ranged/smg + name = "Human NPC: IRS Agent (SMG)" + r_hand = /obj/item/gun/ballistic/automatic/mini_uzi + l_pocket = /obj/item/ammo_box/magazine/uzim9mm + r_pocket = /obj/item/ammo_box/magazine/uzim9mm + +/datum/outfit/piratecorpse/faction/irs/ranged/shotgun + name = "Human NPC: IRS Agent (shotgun)" + r_hand = /obj/item/gun/ballistic/shotgun/lethal + belt = /obj/item/storage/belt/bandolier + belt_contents = list(/obj/item/ammo_casing/shotgun/buckshot = 8) + +/datum/outfit/piratecorpse/faction/irs/captain/armed + name = "Human NPC: IRS Head Auditor" + r_hand = /obj/item/gun/energy/e_gun/lethal + l_pocket = /obj/item/knife/combat/survival + +/datum/outfit/piratecorpse/faction/irs/chief/armed + name = "Human NPC: IRS Chief Auditor" + r_hand = /obj/item/gun/energy/e_gun/lethal + l_pocket = /obj/item/knife/combat/survival + r_pocket = /obj/item/reagent_containers/hypospray/medipen/stimulants + +// ===== MEDIEVAL ===== + +// Footsoldiers and the warlord hate guns (TRAIT_NOGUNS, set by phase B on their types); only the +// crossbowmen shoot, and their crossbows recharge by themselves. +/datum/human_npc_outfit_table/pirate/medieval + melee = list(/datum/outfit/piratecorpse/faction/medieval/melee/armed = 2) + gunners = list(/datum/outfit/piratecorpse/faction/medieval/ranged/crossbow = 1) + elite = list(/datum/outfit/piratecorpse/faction/medieval/captain/armed = 1) + boss = list(/datum/outfit/piratecorpse/faction/medieval/blackknight/armed = 1) + +/datum/human_npc_outfit_table/pirate/medieval/gunners + gunners_only = TRUE + +/datum/outfit/piratecorpse/faction/medieval/melee/armed + name = "Human NPC: Medieval Footsoldier" + r_hand = /obj/item/claymore/shortsword + l_pocket = /obj/item/crowbar + +/datum/outfit/piratecorpse/faction/medieval/ranged/crossbow + name = "Human NPC: Medieval Crossbowman" + r_hand = /obj/item/gun/energy/recharge/ebow/large + l_pocket = /obj/item/knife/combat/survival + +/datum/outfit/piratecorpse/faction/medieval/captain/armed + name = "Human NPC: Medieval Warlord" + r_hand = /obj/item/fireaxe/boardingaxe/warlord + +/datum/outfit/piratecorpse/faction/medieval/blackknight/armed + name = "Human NPC: The Black Knight" + r_hand = /obj/item/claymore/black_knight diff --git a/voidcrew/modules/human_npcs/ruins/ruin_npc_base.dm b/voidcrew/modules/human_npcs/ruins/ruin_npc_base.dm new file mode 100644 index 00000000000..23e2866be79 --- /dev/null +++ b/voidcrew/modules/human_npcs/ruins/ruin_npc_base.dm @@ -0,0 +1,145 @@ +/** + * # Ruin, planet and mission human NPCs (phase C of the human NPC migration) + * + * The people found in ruins, on planets and at mission sites: tg's troopers (space pirates, Syndicate + * operatives, Nanotrasen security, Russian mobsters), the beach and boat pirates, and the wasteland hermits + * and poacher squads. The faction pirate crews squatting in ruins or named in kill contracts are the same + * faction pirates that crew NPC ships (/mob/living/carbon/human/npc/faction_pirate, + * voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_humans.dm), which do the same things for + * themselves (planet alliance, spot line, contract cash). They were + * basic and simple mobs that swapped to a corpse on death; now they are real + * /mob/living/carbon/human/npc bodies (voidcrew/modules/human_npcs/), so wounds, crit, bleeding, + * medicine, cuffs and revival work on them as on players. Developer notes: kit vault modules/human_npcs.md. + * + * What the families share (this root): + * - They belong where they spawn. On a planet they join its fauna's alliance (map_footprint.dm), as the + * mobs they replace did, so hermits and beach pirates don't fight the local wildlife. Anywhere else they + * keep their own factions. + * - A "spot" line when they pick someone new to fight (RUIN_NPC_BARK_SPOT). + * - Zone outfit tables (/datum/human_npc_outfit_table/ruin): more armour, better guns and a medipen in + * the yellow and red zones, never more health, and outfits of their own on cold sites. + * - spawn_npc_in_zone_or_queue(): planet, biome and marker spawners queue human types through + * spawn_human_npc() instead of building a dozen bodies in one tick. + * - A kill contract's cash entitlement (npc_payout_mission): a named target pays its cash once per + * contract, as the faction pirates did. + */ + +/// Bark kind: it picked someone new to fight. +#define RUIN_NPC_BARK_SPOT "spot" + +/mob/living/carbon/human/npc/ruin + npc_target_stat = HUMAN_NPC_FINISHES_DOWNED + /// Weakref to the /datum/mission whose named target this is; its death cash pays only if that + /// contract can still claim it (/datum/mission/proc/claim_boss_cash()). + var/datum/weakref/npc_payout_mission + /// Weakref to the last mob it called out, so one fight gives one "spot" line + var/datum/weakref/npc_spotted + /// The ZONE_* its spawn order dressed it for, or null if it was made without one + var/npc_dressed_zone + +/mob/living/carbon/human/npc/ruin/Initialize(mapload, datum/human_npc_order/order) + . = ..() + npc_dressed_zone = order?.resolve_zone() + // tg's Initialize gave it the planet's alliance before it was dressed; a mapped or ordered faction + // list has replaced its factions since, so it rejoins here. + inherit_planetary_faction(src) + AddElement(/datum/element/human_npc_spot_bark) + +/mob/living/carbon/human/npc/ruin/Destroy() + npc_payout_mission = null + npc_spotted = null + return ..() + +/** + * The zone it belongs to, for zone-laddered loot: its spawn context's, which may have resolved after it + * was made (a ruin loading before its planet registered), else the zone it was dressed for, else where + * it stands. + */ +/mob/living/carbon/human/npc/ruin/proc/npc_home_zone() + return npc_spawn_context?.zone_type || npc_dressed_zone || npc_spawn_zone() + +// Natives of the planet they spawn on, like the fauna they share it with. +/mob/living/carbon/human/npc/ruin/should_inherit_planetary_faction() + return TRUE + +// A named contract target's cash goes to the contract once (the faction pirates' rule): if the +// contract is gone or has already paid, the body carries none. +/mob/living/carbon/human/npc/ruin/npc_drop_death_loot() + if(!npc_loot_dropped && npc_death_cash > 0 && npc_payout_mission) + var/datum/mission/mission = npc_payout_mission.resolve() + if(!mission?.claim_boss_cash()) + npc_death_cash = 0 + return ..() + +/** + * Says the family's spot line when the NPC picks someone new to fight. An element, so the NPC's own + * types can listen to the same blackboard signal. + */ +/datum/element/human_npc_spot_bark + element_flags = ELEMENT_DETACH_ON_HOST_DESTROY + +/datum/element/human_npc_spot_bark/Attach(datum/target) + . = ..() + if(!istype(target, /mob/living/carbon/human/npc/ruin)) + return ELEMENT_INCOMPATIBLE + RegisterSignal(target, COMSIG_AI_BLACKBOARD_KEY_SET(BB_BASIC_MOB_CURRENT_TARGET), PROC_REF(on_target_set)) + +/datum/element/human_npc_spot_bark/Detach(datum/source) + UnregisterSignal(source, COMSIG_AI_BLACKBOARD_KEY_SET(BB_BASIC_MOB_CURRENT_TARGET)) + return ..() + +/datum/element/human_npc_spot_bark/proc/on_target_set(mob/living/carbon/human/npc/ruin/source) + SIGNAL_HANDLER + var/mob/living/target = source.ai_controller?.blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(!isliving(target) || source.stat != CONSCIOUS) + return + if(source.npc_spotted?.resolve() == target) + return + source.npc_spotted = WEAKREF(target) + source.npc_bark(RUIN_NPC_BARK_SPOT) + +/** + * Outfit tables for the ruin families. Green regulars wear what they always did; yellow adds armour; red + * adds a helmet or better gun and a medipen (used in soft crit, human_npc_soft_crit.dm). Families that + * are found on cold sites set a cold_layer that swaps their suit for a cold-weather one (the base cold + * layer only fills empty slots, which leaves an armour vest's wearer to freeze). + */ +/datum/human_npc_outfit_table/ruin + +/// Cold-weather wear that also replaces the suit: for outfits whose suit is armour with no warmth in it. +/datum/human_npc_layer/cold/coat + replace_slots = ITEM_SLOT_FEET | ITEM_SLOT_OCLOTHING + +/** + * spawn_npc_in_zone() for spawners that roll many mobs at once (planet population, biome terrain, zone + * markers): a human NPC type is queued through spawn_human_npc() with the same context, so it is built + * over the next ticks instead of now. Returns the mob, or the human NPC order. + */ +/proc/spawn_npc_in_zone_or_queue(spawn_type, atom/location, datum/npc_spawn_context/context) + if(ispath(spawn_type, /mob/living/carbon/human/npc)) + return spawn_human_npc(spawn_type, location, context = context) + return spawn_npc_in_zone(spawn_type, location, context) + +/// Map spawners for the ruin families (ruin_npc_spawners.dm). Each subtype names the NPC it places; +/// npc_name and npc_faction set one mapped NPC's own name and side. +/obj/effect/spawner/human_npc/ruin + name = "ruin NPC spawner" + // The family's own type places nothing (it is never mapped; tests create every type once). + abstract_spawner_type = /obj/effect/spawner/human_npc/ruin + +// ===== Derelict shuttles inside space ruins ===== +// The caravan ambush ruin docks four upstream derelict shuttles (code/datums/shuttles/ruin.dm) that +// carried trooper mobs. Following the space ruins' copy-and-redirect scheme (voidcrew/datums/ruins/space.dm), +// voidcrew copies of those maps with human NPC spawners live in _maps/voidcrew/shuttles/, and these +// prefixes point the upstream templates at them. The upstream maps stay as merge reference. +/datum/map_template/shuttle/ruin/caravan_victim + prefix = "_maps/voidcrew/shuttles/" + +/datum/map_template/shuttle/ruin/pirate_cutter + prefix = "_maps/voidcrew/shuttles/" + +/datum/map_template/shuttle/ruin/syndicate_dropship + prefix = "_maps/voidcrew/shuttles/" + +/datum/map_template/shuttle/ruin/syndicate_fighter_shiv + prefix = "_maps/voidcrew/shuttles/" diff --git a/voidcrew/modules/human_npcs/ruins/ruin_npc_hermits.dm b/voidcrew/modules/human_npcs/ruins/ruin_npc_hermits.dm new file mode 100644 index 00000000000..fcd6c135127 --- /dev/null +++ b/voidcrew/modules/human_npcs/ruins/ruin_npc_hermits.dm @@ -0,0 +1,89 @@ +/** + * # Wasteland hermits and poacher squads (AM-9, AM-3) + * + * The wild-eyed people of the sandworlds, in their tattered survival gear (the wasteland corpse outfits, + * voidcrew/modules/mob_spawn/corpses/wasteland_corpses.dm): wanderers who fight with their fists or a + * knife, hunters with a .38 revolver and speedloaders, and soldiers with a WT-550 and spare magazines. + * They spawn from the wasteland biomes, wasteland ruins and the poacher bust contract, which renames them. + * + * Their survival suits keep the cold off their bodies; on a cold site the cold layer adds a hat, scarf and + * winter boots (a poacher camp on an ice planet), and a bad-air site a mask and tank. Nothing makes them + * immune to the weather: a storm that hurts a player hurts them. + */ + +/datum/human_npc_voice/ruin_hermit + lines = list( + RUIN_NPC_BARK_SPOT = list( + "The sun... The sun...", + "You'll do...", + "All mine...", + "Gg..free..", + "Drink.. need drink...", + "I can smell... you..", + "G-g...", + "Taste..the salt.", + ), + HUMAN_NPC_BARK_DOWNED = list("G-g...", "The sun..."), + HUMAN_NPC_BARK_PLEAD = list("Drink... need drink..."), + ) + emotes = list( + HUMAN_NPC_BARK_DOWNED = list("collapses."), + ) + chances = list(RUIN_NPC_BARK_SPOT = 50) + +/datum/outfit/hermit/survivor/knife + name = "Wasteland Survivor (knife)" + r_hand = /obj/item/knife/combat/survival + +/datum/outfit/hermit/survivor/knife/red + name = "Wasteland Survivor (knife, red zone)" + l_pocket = /obj/item/reagent_containers/hypospray/medipen + +/// A .38 revolver and two speedloaders. +/datum/outfit/hermit/survivor/hunter/armed + name = "Wasteland Hunter (armed)" + r_hand = /obj/item/gun/ballistic/revolver/c38 + backpack_contents = list(/obj/item/ammo_box/c38 = 2) + +/datum/outfit/hermit/survivor/hunter/armed/red + name = "Wasteland Hunter (armed, red zone)" + backpack_contents = list(/obj/item/ammo_box/c38 = 2, /obj/item/reagent_containers/hypospray/medipen = 1) + +/// A WT-550 and two spare magazines. +/datum/outfit/hermit/survivor/gunslinger/armed + name = "Wasteland Gunslinger (armed)" + r_hand = /obj/item/gun/ballistic/automatic/wt550 + backpack_contents = list(/obj/item/ammo_box/magazine/wt550m9 = 2) + +/datum/outfit/hermit/survivor/gunslinger/armed/red + name = "Wasteland Gunslinger (armed, red zone)" + backpack_contents = list(/obj/item/ammo_box/magazine/wt550m9 = 2, /obj/item/reagent_containers/hypospray/medipen = 1) + +/datum/human_npc_outfit_table/ruin/hermit + green = list(/datum/outfit/hermit/survivor = 1) + yellow = list(/datum/outfit/hermit/survivor/knife = 1) + red = list(/datum/outfit/hermit/survivor/knife/red = 1) + +/datum/human_npc_outfit_table/ruin/hermit/hunter + green = list(/datum/outfit/hermit/survivor/hunter/armed = 1) + yellow = list(/datum/outfit/hermit/survivor/hunter/armed = 1) + red = list(/datum/outfit/hermit/survivor/hunter/armed/red = 1) + +/datum/human_npc_outfit_table/ruin/hermit/gunslinger + green = list(/datum/outfit/hermit/survivor/gunslinger/armed = 1) + yellow = list(/datum/outfit/hermit/survivor/gunslinger/armed = 1) + red = list(/datum/outfit/hermit/survivor/gunslinger/armed/red = 1) + +/mob/living/carbon/human/npc/ruin/hermit + npc_name = "Hermit Wanderer" + faction = list("hermit", FACTION_WASTELAND) + npc_voice = /datum/human_npc_voice/ruin_hermit + npc_outfit_table = /datum/human_npc_outfit_table/ruin/hermit + +/mob/living/carbon/human/npc/ruin/hermit/hunter + npc_name = "Hermit Hunter" + npc_outfit_table = /datum/human_npc_outfit_table/ruin/hermit/hunter + +/mob/living/carbon/human/npc/ruin/hermit/gunslinger + npc_name = "Hermit Soldier" + npc_outfit_table = /datum/human_npc_outfit_table/ruin/hermit/gunslinger diff --git a/voidcrew/modules/human_npcs/ruins/ruin_npc_spawners.dm b/voidcrew/modules/human_npcs/ruins/ruin_npc_spawners.dm new file mode 100644 index 00000000000..1185c09b221 --- /dev/null +++ b/voidcrew/modules/human_npcs/ruins/ruin_npc_spawners.dm @@ -0,0 +1,111 @@ +// Map spawners for the ruin, planet and mission human NPCs. Each one queues its NPC when the map loads +// (spawn_human_npc(), a body per tick), dressed for the zone the ruin landed in. Set npc_name or +// npc_faction on a placed spawner for one NPC's own name or side (a camp's private faction). + +// ===== Pirates ===== + +/obj/effect/spawner/human_npc/ruin/pirate + name = "pirate swashbuckler spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/pirate + +/obj/effect/spawner/human_npc/ruin/pirate/gunner + name = "pirate gunner spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/pirate/gunner + +/obj/effect/spawner/human_npc/ruin/pirate/space + name = "space pirate swashbuckler spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/pirate/space + +/obj/effect/spawner/human_npc/ruin/pirate/space/gunner + name = "space pirate gunner spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/pirate/space/gunner + +/obj/effect/spawner/human_npc/ruin/pirate/beach + name = "beach pirate swashbuckler spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/pirate/beach + +/obj/effect/spawner/human_npc/ruin/pirate/beach/gunner + name = "beach pirate gunner spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/pirate/beach/gunner + +/obj/effect/spawner/human_npc/ruin/pirate/cosplayer + name = "pirate cosplayer spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/pirate/cosplayer + +// ===== Syndicate ===== + +/obj/effect/spawner/human_npc/ruin/syndicate + name = "Syndicate operative spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/syndicate + +/obj/effect/spawner/human_npc/ruin/syndicate/sword + name = "Syndicate sword guard spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/syndicate/sword + +/obj/effect/spawner/human_npc/ruin/syndicate/gunner + name = "Syndicate gunner spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner + +/obj/effect/spawner/human_npc/ruin/syndicate/gunner/smg + name = "Syndicate SMG gunner spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/smg + +/obj/effect/spawner/human_npc/ruin/syndicate/gunner/shotgun + name = "Syndicate shotgunner spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/shotgun + +/obj/effect/spawner/human_npc/ruin/syndicate/gunner/pilot + name = "Syndicate salvage pilot spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/pilot + +/obj/effect/spawner/human_npc/ruin/syndicate/commando + name = "Syndicate commando spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/syndicate/commando + +/obj/effect/spawner/human_npc/ruin/syndicate/commando/gunner + name = "Syndicate commando gunner spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/syndicate/commando/gunner + +/obj/effect/spawner/human_npc/ruin/syndicate/commando/smg + name = "Syndicate commando SMG gunner spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/syndicate/commando/smg + +/obj/effect/spawner/human_npc/ruin/syndicate/stormtrooper + name = "Syndicate stormtrooper spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/syndicate/stormtrooper + +/obj/effect/spawner/human_npc/ruin/syndicate/stormtrooper/shotgun + name = "Syndicate stormtrooper shotgunner spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/syndicate/stormtrooper/shotgun + +/obj/effect/spawner/human_npc/ruin/syndicate/stormtrooper/sword + name = "Syndicate stormtrooper sword guard spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/syndicate/stormtrooper/sword + +// ===== Nanotrasen and Russians ===== + +/obj/effect/spawner/human_npc/ruin/nanotrasen + name = "Nanotrasen security officer spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/nanotrasen + +/obj/effect/spawner/human_npc/ruin/russian + name = "Russian mobster spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/russian + +/obj/effect/spawner/human_npc/ruin/russian/gunner + name = "Russian gunner spawner" + npc_type = /mob/living/carbon/human/npc/ruin/trooper/russian/gunner + +// ===== Hermits ===== + +/obj/effect/spawner/human_npc/ruin/hermit + name = "hermit wanderer spawner" + npc_type = /mob/living/carbon/human/npc/ruin/hermit + +/obj/effect/spawner/human_npc/ruin/hermit/hunter + name = "hermit hunter spawner" + npc_type = /mob/living/carbon/human/npc/ruin/hermit/hunter + +/obj/effect/spawner/human_npc/ruin/hermit/gunslinger + name = "hermit soldier spawner" + npc_type = /mob/living/carbon/human/npc/ruin/hermit/gunslinger diff --git a/voidcrew/modules/human_npcs/ruins/ruin_npc_troopers.dm b/voidcrew/modules/human_npcs/ruins/ruin_npc_troopers.dm new file mode 100644 index 00000000000..565a8c5b3a7 --- /dev/null +++ b/voidcrew/modules/human_npcs/ruins/ruin_npc_troopers.dm @@ -0,0 +1,596 @@ +/** + * # Troopers as human NPCs: pirates, Syndicate operatives, Nanotrasen security, Russian mobsters + * + * The human versions of tg's /mob/living/basic/trooper families placed in Voidcrew ruins, ruin shuttles, + * beaches and zone markers. Each keeps its trooper's name, faction and look (today's corpse outfits), + * holds the weapon the trooper only drew, and carries real spare ammunition. + * + * Zones (/datum/human_npc_outfit_table/ruin): green wears what the trooper wore; yellow adds armour; red + * adds a helmet and a medipen. The trooper weapon ladder (voidcrew/edits/mobs/weapon_drops.dm) lives in + * the tables: Syndicate SMGs and shotguns are pistols outside the red zone (stormtroopers' SMGs only in + * the green), and the Syndicate sword guard has only a knife in the green. Nanotrasen officers only ever + * carried the M1911 in Voidcrew maps. + * + * Designed drops stay as the troopers had them: only the Russians carried any (a kitchen knife, a Nagant + * revolver). Their clothes and guns are gear (decision D3) and never loot. The pirates' coin-snatching + * hits are gone: an NPC hits like a person. + */ + +// ===== VOICES ===== + +/datum/human_npc_voice/ruin_pirate + lines = list( + RUIN_NPC_BARK_SPOT = list("Yarr! Fresh meat!", "Ahoy, landlubber!", "Cut 'em down!", "Avast!"), + HUMAN_NPC_BARK_DOWNED = list("Arr... me guts...", "Not like this..."), + HUMAN_NPC_BARK_RECOVER = list("Still breathin'!", "That all ye got?"), + HUMAN_NPC_BARK_PLEAD = list("Mercy, matey..."), + HUMAN_NPC_BARK_CUFFED = list("Ye'll hang for this."), + ) + emotes = list( + HUMAN_NPC_BARK_DOWNED = list("collapses."), + ) + chances = list(RUIN_NPC_BARK_SPOT = 60) + +/datum/human_npc_voice/ruin_syndicate + lines = list( + RUIN_NPC_BARK_SPOT = list("Contact!", "Hostile sighted.", "Engaging.", "Death to Nanotrasen!"), + HUMAN_NPC_BARK_DOWNED = list("Man down...", "I'm hit..."), + HUMAN_NPC_BARK_RECOVER = list("Back in it.", "Still in the fight."), + HUMAN_NPC_BARK_CUFFED = list("I'm not telling you anything."), + ) + emotes = list( + HUMAN_NPC_BARK_DOWNED = list("collapses."), + ) + chances = list(RUIN_NPC_BARK_SPOT = 50) + +/datum/human_npc_voice/ruin_nanotrasen + lines = list( + RUIN_NPC_BARK_SPOT = list("Halt! Private security!", "Hostile in sight.", "Stop right there!"), + HUMAN_NPC_BARK_DOWNED = list("Officer down...", "Need a medic..."), + HUMAN_NPC_BARK_RECOVER = list("Still standing."), + HUMAN_NPC_BARK_CUFFED = list("You'll answer to Central for this."), + ) + emotes = list( + HUMAN_NPC_BARK_DOWNED = list("collapses."), + ) + chances = list(RUIN_NPC_BARK_SPOT = 50) + +/datum/human_npc_voice/ruin_russian + lines = list( + RUIN_NPC_BARK_SPOT = list("Hey! You!", "Who let you in?", "For the Motherland!"), + HUMAN_NPC_BARK_DOWNED = list("Ugh... not good...", "Someone... help..."), + HUMAN_NPC_BARK_RECOVER = list("Is that all?"), + ) + emotes = list( + HUMAN_NPC_BARK_DOWNED = list("collapses."), + ) + chances = list(RUIN_NPC_BARK_SPOT = 50) + +// ===== FAMILY ROOT ===== + +/mob/living/carbon/human/npc/ruin/trooper + name = "trooper" + // Armed hostiles: cover from stun fire, and a stimulant if one carries it (human_npc_combat_sense.dm) + npc_combat_sense = /datum/npc_combat_sense + +// ===== SPACE PIRATES (tg's pirate troopers) ===== + +/datum/outfit/ruin_npc + name = "Ruin NPC" + +/// The swashbuckler: a pirate's rags, an eyepatch and an energy cutlass. +/datum/outfit/ruin_npc/pirate + name = "Ruin NPC: pirate swashbuckler" + uniform = /obj/item/clothing/under/costume/pirate + shoes = /obj/item/clothing/shoes/jackboots + glasses = /obj/item/clothing/glasses/eyepatch + head = /obj/item/clothing/head/costume/pirate/bandana/armored + r_hand = /obj/item/melee/energy/sword/pirate + +/datum/outfit/ruin_npc/pirate/coat + name = "Ruin NPC: pirate swashbuckler in a coat" + suit = /obj/item/clothing/suit/costume/pirate/armored + +/datum/outfit/ruin_npc/pirate/coat/red + name = "Ruin NPC: pirate swashbuckler, red zone" + gloves = /obj/item/clothing/gloves/color/black + l_pocket = /obj/item/reagent_containers/hypospray/medipen + +/// The gunner: a laser gun and the armoured captain's hat. +/datum/outfit/ruin_npc/pirate/gunner + name = "Ruin NPC: pirate gunner" + head = /obj/item/clothing/head/costume/pirate/armored + r_hand = /obj/item/gun/energy/laser + +/datum/outfit/ruin_npc/pirate/gunner/coat + name = "Ruin NPC: pirate gunner in a coat" + suit = /obj/item/clothing/suit/costume/pirate/armored + +/datum/outfit/ruin_npc/pirate/gunner/coat/red + name = "Ruin NPC: pirate gunner, red zone" + gloves = /obj/item/clothing/gloves/color/black + l_pocket = /obj/item/reagent_containers/hypospray/medipen + +/// Space pirates fight in breached hulls: the pirate space suit and its own air. +/datum/outfit/ruin_npc/pirate/space + name = "Ruin NPC: space pirate swashbuckler" + suit = /obj/item/clothing/suit/space/pirate + head = /obj/item/clothing/head/helmet/space/pirate/bandana + gloves = /obj/item/clothing/gloves/color/black + suit_store = /obj/item/tank/internals/oxygen + internals_slot = ITEM_SLOT_SUITSTORE + +/datum/outfit/ruin_npc/pirate/space/red + name = "Ruin NPC: space pirate swashbuckler, red zone" + l_pocket = /obj/item/reagent_containers/hypospray/medipen + +/datum/outfit/ruin_npc/pirate/space/gunner + name = "Ruin NPC: space pirate gunner" + head = /obj/item/clothing/head/helmet/space/pirate + r_hand = /obj/item/gun/energy/e_gun/lethal + +/datum/outfit/ruin_npc/pirate/space/gunner/red + name = "Ruin NPC: space pirate gunner, red zone" + l_pocket = /obj/item/reagent_containers/hypospray/medipen + +/// Timothy, the pirate cosplayer locked in the Hightide's kitchen: the costume, not the armour. +/datum/outfit/ruin_npc/pirate/cosplayer + name = "Ruin NPC: pirate cosplayer" + head = /obj/item/clothing/head/costume/pirate + suit = /obj/item/clothing/suit/costume/pirate + shoes = /obj/item/clothing/shoes/sneakers/black + r_hand = /obj/item/gun/energy/laser + +/datum/human_npc_outfit_table/ruin/pirate + vacuum_layer = /datum/human_npc_layer/eva/pirate + green = list(/datum/outfit/ruin_npc/pirate = 1) + yellow = list(/datum/outfit/ruin_npc/pirate/coat = 1) + red = list(/datum/outfit/ruin_npc/pirate/coat/red = 1) + +/datum/human_npc_outfit_table/ruin/pirate/gunner + green = list(/datum/outfit/ruin_npc/pirate/gunner = 1) + yellow = list(/datum/outfit/ruin_npc/pirate/gunner/coat = 1) + red = list(/datum/outfit/ruin_npc/pirate/gunner/coat/red = 1) + +/datum/human_npc_outfit_table/ruin/pirate/space + green = list(/datum/outfit/ruin_npc/pirate/space = 1) + yellow = list(/datum/outfit/ruin_npc/pirate/space = 1) + red = list(/datum/outfit/ruin_npc/pirate/space/red = 1) + +/datum/human_npc_outfit_table/ruin/pirate/space/gunner + green = list(/datum/outfit/ruin_npc/pirate/space/gunner = 1) + yellow = list(/datum/outfit/ruin_npc/pirate/space/gunner = 1) + red = list(/datum/outfit/ruin_npc/pirate/space/gunner/red = 1) + +/mob/living/carbon/human/npc/ruin/trooper/pirate + npc_name = "Pirate Swashbuckler" + faction = list(FACTION_PIRATE) + npc_voice = /datum/human_npc_voice/ruin_pirate + npc_outfit_table = /datum/human_npc_outfit_table/ruin/pirate + +/mob/living/carbon/human/npc/ruin/trooper/pirate/gunner + npc_name = "Pirate Gunner" + npc_outfit_table = /datum/human_npc_outfit_table/ruin/pirate/gunner + +/mob/living/carbon/human/npc/ruin/trooper/pirate/space + npc_name = "Space Pirate Swashbuckler" + npc_outfit_table = /datum/human_npc_outfit_table/ruin/pirate/space + +/mob/living/carbon/human/npc/ruin/trooper/pirate/space/gunner + npc_name = "Space Pirate Gunner" + npc_outfit_table = /datum/human_npc_outfit_table/ruin/pirate/space/gunner + +/// The beach's own pirates, sided with the shore's wildlife: the barrel spawners' crews, and the boat +/// pirates of the deep water, who now wade (the old boat sprite was this same costume in a boat). +/mob/living/carbon/human/npc/ruin/trooper/pirate/beach + faction = list(FACTION_BEACH) + +/mob/living/carbon/human/npc/ruin/trooper/pirate/beach/gunner + npc_name = "Pirate Gunner" + npc_outfit_table = /datum/human_npc_outfit_table/ruin/pirate/gunner + +/// Timothy. He survived on the rats, which shows: he goes down twice as fast as anyone else. +/mob/living/carbon/human/npc/ruin/trooper/pirate/cosplayer + npc_name = "Timothy" + npc_outfit_table = null + npc_outfit = /datum/outfit/ruin_npc/pirate/cosplayer + npc_damage_taken = 2 + +// ===== SYNDICATE OPERATIVES ===== + +/// A Syndicate operative with a knife. +/datum/outfit/ruin_npc/syndicate + name = "Ruin NPC: Syndicate operative" + uniform = /obj/item/clothing/under/syndicate + shoes = /obj/item/clothing/shoes/combat + gloves = /obj/item/clothing/gloves/combat + r_hand = /obj/item/knife/combat/survival + +/datum/outfit/ruin_npc/syndicate/vest + name = "Ruin NPC: Syndicate operative in a vest" + suit = /obj/item/clothing/suit/armor/vest + +/datum/outfit/ruin_npc/syndicate/vest/helmet + name = "Ruin NPC: Syndicate operative, red zone" + head = /obj/item/clothing/head/helmet/swat + l_pocket = /obj/item/reagent_containers/hypospray/medipen + +/// The sword guard: an energy sword and an energy shield. +/datum/outfit/ruin_npc/syndicate/vest/sword + name = "Ruin NPC: Syndicate sword guard" + r_hand = /obj/item/melee/energy/sword/saber/red + l_hand = /obj/item/shield/energy + +/datum/outfit/ruin_npc/syndicate/vest/sword/helmet + name = "Ruin NPC: Syndicate sword guard, red zone" + head = /obj/item/clothing/head/helmet/swat + l_pocket = /obj/item/reagent_containers/hypospray/medipen + +/// A Makarov and two spare magazines. +/datum/outfit/ruin_npc/syndicate/pistol + name = "Ruin NPC: Syndicate gunner" + r_hand = /obj/item/gun/ballistic/automatic/pistol + l_pocket = /obj/item/ammo_box/magazine/m9mm + r_pocket = /obj/item/ammo_box/magazine/m9mm + +/datum/outfit/ruin_npc/syndicate/pistol/vest + name = "Ruin NPC: Syndicate gunner in a vest" + suit = /obj/item/clothing/suit/armor/vest + +/datum/outfit/ruin_npc/syndicate/pistol/vest/helmet + name = "Ruin NPC: Syndicate gunner, red zone" + head = /obj/item/clothing/head/helmet/swat + belt = /obj/item/storage/belt/military + belt_contents = list(/obj/item/reagent_containers/hypospray/medipen = 1) + +/// The C-20r, in the red zone only. +/datum/outfit/ruin_npc/syndicate/pistol/vest/helmet/smg + name = "Ruin NPC: Syndicate SMG gunner" + r_hand = /obj/item/gun/ballistic/automatic/c20r/unrestricted + l_pocket = /obj/item/ammo_box/magazine/smgm45 + r_pocket = /obj/item/ammo_box/magazine/smgm45 + +/// The Bulldog, in the red zone only. +/datum/outfit/ruin_npc/syndicate/pistol/vest/helmet/shotgun + name = "Ruin NPC: Syndicate shotgunner" + r_hand = /obj/item/gun/ballistic/shotgun/bulldog/unrestricted + l_pocket = /obj/item/ammo_box/magazine/m12g + r_pocket = /obj/item/ammo_box/magazine/m12g + +/// The hijack team a cargo shuttle loan brings aboard (voidcrew/modules/cargo/shipping/_shuttle_loan.dm): +/// a suppressed Makarov and two spare magazines. +/datum/outfit/ruin_npc/syndicate/pistol/infiltrator + name = "Ruin NPC: Syndicate infiltrator" + r_hand = /obj/item/gun/ballistic/automatic/pistol/suppressed + +/datum/outfit/ruin_npc/syndicate/pistol/infiltrator/vest + name = "Ruin NPC: Syndicate infiltrator in a vest" + suit = /obj/item/clothing/suit/armor/vest + +/datum/outfit/ruin_npc/syndicate/pistol/infiltrator/vest/helmet + name = "Ruin NPC: Syndicate infiltrator, red zone" + head = /obj/item/clothing/head/helmet/swat + belt = /obj/item/storage/belt/military + belt_contents = list(/obj/item/reagent_containers/hypospray/medipen = 1) + +/// The salvage pilots of the caravan ambush: flight scarf and goggles over the armour. +/datum/outfit/ruin_npc/syndicate/pistol/pilot + name = "Ruin NPC: Syndicate salvage pilot" + suit = /obj/item/clothing/suit/armor/vest/alt + neck = /obj/item/clothing/neck/large_scarf/syndie + glasses = /obj/item/clothing/glasses/cold + +/datum/outfit/ruin_npc/syndicate/pistol/pilot/smg + name = "Ruin NPC: Syndicate salvage pilot, red zone" + head = /obj/item/clothing/head/helmet/swat + r_hand = /obj/item/gun/ballistic/automatic/c20r/unrestricted + l_pocket = /obj/item/ammo_box/magazine/smgm45 + r_pocket = /obj/item/ammo_box/magazine/smgm45 + +/// Commandos: the black Syndicate space suit and its own air. +/datum/outfit/ruin_npc/syndicate/commando + name = "Ruin NPC: Syndicate commando" + suit = /obj/item/clothing/suit/space/syndicate/black + head = /obj/item/clothing/head/helmet/space/syndicate/black + suit_store = /obj/item/tank/internals/oxygen + internals_slot = ITEM_SLOT_SUITSTORE + +/datum/outfit/ruin_npc/syndicate/commando/red + name = "Ruin NPC: Syndicate commando, red zone" + l_pocket = /obj/item/reagent_containers/hypospray/medipen + +/datum/outfit/ruin_npc/syndicate/commando/pistol + name = "Ruin NPC: Syndicate commando gunner" + r_hand = /obj/item/gun/ballistic/automatic/pistol + l_pocket = /obj/item/ammo_box/magazine/m9mm + r_pocket = /obj/item/ammo_box/magazine/m9mm + +/datum/outfit/ruin_npc/syndicate/commando/pistol/red + name = "Ruin NPC: Syndicate commando gunner, red zone" + belt = /obj/item/storage/belt/military + belt_contents = list(/obj/item/reagent_containers/hypospray/medipen = 1) + +/datum/outfit/ruin_npc/syndicate/commando/pistol/red/smg + name = "Ruin NPC: Syndicate commando SMG gunner" + r_hand = /obj/item/gun/ballistic/automatic/c20r/unrestricted + l_pocket = /obj/item/ammo_box/magazine/smgm45 + r_pocket = /obj/item/ammo_box/magazine/smgm45 + +/datum/outfit/ruin_npc/syndicate/commando/pistol/red/shotgun + name = "Ruin NPC: Syndicate commando shotgunner" + r_hand = /obj/item/gun/ballistic/shotgun/bulldog/unrestricted + l_pocket = /obj/item/ammo_box/magazine/m12g + r_pocket = /obj/item/ammo_box/magazine/m12g + +/datum/outfit/ruin_npc/syndicate/commando/sword + name = "Ruin NPC: Syndicate commando sword guard" + r_hand = /obj/item/melee/energy/sword/saber/red + l_hand = /obj/item/shield/energy + +/// Stormtroopers: the blood-red Syndicate space suit. +/datum/outfit/ruin_npc/syndicate/commando/stormtrooper + name = "Ruin NPC: Syndicate stormtrooper" + suit = /obj/item/clothing/suit/space/syndicate/black/red + head = /obj/item/clothing/head/helmet/space/syndicate/black/red + r_hand = /obj/item/gun/ballistic/automatic/pistol + l_pocket = /obj/item/ammo_box/magazine/m9mm + r_pocket = /obj/item/ammo_box/magazine/m9mm + +/datum/outfit/ruin_npc/syndicate/commando/stormtrooper/smg + name = "Ruin NPC: Syndicate stormtrooper SMG gunner" + r_hand = /obj/item/gun/ballistic/automatic/c20r/unrestricted + l_pocket = /obj/item/ammo_box/magazine/smgm45 + r_pocket = /obj/item/ammo_box/magazine/smgm45 + belt = /obj/item/storage/belt/military + belt_contents = list(/obj/item/reagent_containers/hypospray/medipen = 1) + +/datum/outfit/ruin_npc/syndicate/commando/stormtrooper/shotgun + name = "Ruin NPC: Syndicate stormtrooper shotgunner" + r_hand = /obj/item/gun/ballistic/shotgun/bulldog/unrestricted + l_pocket = /obj/item/ammo_box/magazine/m12g + r_pocket = /obj/item/ammo_box/magazine/m12g + belt = /obj/item/storage/belt/military + belt_contents = list(/obj/item/reagent_containers/hypospray/medipen = 1) + +/datum/outfit/ruin_npc/syndicate/commando/stormtrooper/sword + name = "Ruin NPC: Syndicate stormtrooper sword guard" + r_hand = /obj/item/melee/energy/sword/saber/red + l_hand = /obj/item/shield/energy + l_pocket = /obj/item/reagent_containers/hypospray/medipen + r_pocket = null + +/// Operatives on the ice wear the Syndicate's armoured explorer suit over their kit. +/datum/human_npc_layer/cold/coat/syndicate + suit = /obj/item/clothing/suit/hooded/explorer/syndicate + +/datum/human_npc_outfit_table/ruin/syndicate + vacuum_layer = /datum/human_npc_layer/eva/syndicate + cold_layer = /datum/human_npc_layer/cold/coat/syndicate + green = list(/datum/outfit/ruin_npc/syndicate = 1) + yellow = list(/datum/outfit/ruin_npc/syndicate/vest = 1) + red = list(/datum/outfit/ruin_npc/syndicate/vest/helmet = 1) + +/// The sword guard has only a knife in the green zone (the trooper weapon ladder). +/datum/human_npc_outfit_table/ruin/syndicate/sword + green = list(/datum/outfit/ruin_npc/syndicate = 1) + yellow = list(/datum/outfit/ruin_npc/syndicate/vest/sword = 1) + red = list(/datum/outfit/ruin_npc/syndicate/vest/sword/helmet = 1) + +/datum/human_npc_outfit_table/ruin/syndicate/pistol + green = list(/datum/outfit/ruin_npc/syndicate/pistol = 1) + yellow = list(/datum/outfit/ruin_npc/syndicate/pistol/vest = 1) + red = list(/datum/outfit/ruin_npc/syndicate/pistol/vest/helmet = 1) + +/// SMGs and shotguns are pistols outside the red zone (the trooper weapon ladder). +/datum/human_npc_outfit_table/ruin/syndicate/pistol/smg + red = list(/datum/outfit/ruin_npc/syndicate/pistol/vest/helmet/smg = 1) + +/datum/human_npc_outfit_table/ruin/syndicate/pistol/shotgun + red = list(/datum/outfit/ruin_npc/syndicate/pistol/vest/helmet/shotgun = 1) + +/datum/human_npc_outfit_table/ruin/syndicate/infiltrator + green = list(/datum/outfit/ruin_npc/syndicate/pistol/infiltrator = 1) + yellow = list(/datum/outfit/ruin_npc/syndicate/pistol/infiltrator/vest = 1) + red = list(/datum/outfit/ruin_npc/syndicate/pistol/infiltrator/vest/helmet = 1) + +/datum/human_npc_outfit_table/ruin/syndicate/pilot + green = list(/datum/outfit/ruin_npc/syndicate/pistol/pilot = 1) + yellow = list(/datum/outfit/ruin_npc/syndicate/pistol/pilot = 1) + red = list(/datum/outfit/ruin_npc/syndicate/pistol/pilot/smg = 1) + +/datum/human_npc_outfit_table/ruin/syndicate/commando + green = list(/datum/outfit/ruin_npc/syndicate/commando = 1) + yellow = list(/datum/outfit/ruin_npc/syndicate/commando = 1) + red = list(/datum/outfit/ruin_npc/syndicate/commando/red = 1) + +/datum/human_npc_outfit_table/ruin/syndicate/commando/pistol + green = list(/datum/outfit/ruin_npc/syndicate/commando/pistol = 1) + yellow = list(/datum/outfit/ruin_npc/syndicate/commando/pistol = 1) + red = list(/datum/outfit/ruin_npc/syndicate/commando/pistol/red = 1) + +/datum/human_npc_outfit_table/ruin/syndicate/commando/smg + green = list(/datum/outfit/ruin_npc/syndicate/commando/pistol = 1) + yellow = list(/datum/outfit/ruin_npc/syndicate/commando/pistol = 1) + red = list(/datum/outfit/ruin_npc/syndicate/commando/pistol/red/smg = 1) + +/// Stormtroopers are elites but follow the zone ladder like the regulars, so their tables pick by zone +/// alone: SMG stormtroopers carry pistols in the green zone, shotgunners outside the red. +/datum/human_npc_outfit_table/ruin/syndicate/stormtrooper + +/datum/human_npc_outfit_table/ruin/syndicate/stormtrooper/outfits_for(mob/living/carbon/human/npc/npc, zone) + if(zone == ZONE_RED && length(red)) + return red + if(zone >= ZONE_YELLOW && length(yellow)) + return yellow + return green + +/datum/human_npc_outfit_table/ruin/syndicate/stormtrooper/smg + green = list(/datum/outfit/ruin_npc/syndicate/commando/stormtrooper = 1) + yellow = list(/datum/outfit/ruin_npc/syndicate/commando/stormtrooper/smg = 1) + red = list(/datum/outfit/ruin_npc/syndicate/commando/stormtrooper/smg = 1) + +/datum/human_npc_outfit_table/ruin/syndicate/stormtrooper/shotgun + green = list(/datum/outfit/ruin_npc/syndicate/commando/stormtrooper = 1) + yellow = list(/datum/outfit/ruin_npc/syndicate/commando/stormtrooper = 1) + red = list(/datum/outfit/ruin_npc/syndicate/commando/stormtrooper/shotgun = 1) + +/datum/human_npc_outfit_table/ruin/syndicate/stormtrooper/sword + green = list(/datum/outfit/ruin_npc/syndicate/commando/stormtrooper/sword = 1) + yellow = list(/datum/outfit/ruin_npc/syndicate/commando/stormtrooper/sword = 1) + red = list(/datum/outfit/ruin_npc/syndicate/commando/stormtrooper/sword = 1) + +/// Space Syndicate kit: the black suit. +/datum/human_npc_layer/eva/syndicate + suit = /obj/item/clothing/suit/space/syndicate/black + head = /obj/item/clothing/head/helmet/space/syndicate/black + +/mob/living/carbon/human/npc/ruin/trooper/syndicate + npc_name = "Syndicate Operative" + faction = list(ROLE_SYNDICATE) + npc_voice = /datum/human_npc_voice/ruin_syndicate + npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate + +/mob/living/carbon/human/npc/ruin/trooper/syndicate/sword + npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/sword + +/mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner + npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/pistol + +/mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/smg + npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/pistol/smg + +/mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/shotgun + npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/pistol/shotgun + +/// The hijack team a cargo shuttle loan brings aboard. +/mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/infiltrator + npc_name = "Syndicate Infiltrator" + npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/infiltrator + +/mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/pilot + npc_name = "Syndicate Salvage Pilot" + npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/pilot + +/mob/living/carbon/human/npc/ruin/trooper/syndicate/commando + npc_name = "Syndicate Commando" + npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/commando + +/mob/living/carbon/human/npc/ruin/trooper/syndicate/commando/gunner + npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/commando/pistol + +/mob/living/carbon/human/npc/ruin/trooper/syndicate/commando/smg + npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/commando/smg + +/// Stormtroopers: elites in the blood-red suit. They take a fifth less brute and burn, and land aimed hits. +/mob/living/carbon/human/npc/ruin/trooper/syndicate/stormtrooper + npc_name = "Syndicate Stormtrooper" + npc_rank = HUMAN_NPC_RANK_ELITE + npc_damage_taken = 0.8 + npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/stormtrooper/smg + +/mob/living/carbon/human/npc/ruin/trooper/syndicate/stormtrooper/shotgun + npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/stormtrooper/shotgun + +/mob/living/carbon/human/npc/ruin/trooper/syndicate/stormtrooper/sword + npc_outfit_table = /datum/human_npc_outfit_table/ruin/syndicate/stormtrooper/sword + +// ===== NANOTRASEN PRIVATE SECURITY ===== + +/// An M1911 and two spare magazines, in security blues. +/datum/outfit/ruin_npc/nanotrasen + name = "Ruin NPC: Nanotrasen security officer" + uniform = /obj/item/clothing/under/rank/security/officer + shoes = /obj/item/clothing/shoes/combat + gloves = /obj/item/clothing/gloves/combat + back = /obj/item/storage/backpack/security + r_hand = /obj/item/gun/ballistic/automatic/pistol/m1911 + l_pocket = /obj/item/ammo_box/magazine/m45 + r_pocket = /obj/item/ammo_box/magazine/m45 + +/datum/outfit/ruin_npc/nanotrasen/vest + name = "Ruin NPC: Nanotrasen security officer in a vest" + suit = /obj/item/clothing/suit/armor/vest + +/datum/outfit/ruin_npc/nanotrasen/vest/helmet + name = "Ruin NPC: Nanotrasen security officer, red zone" + head = /obj/item/clothing/head/helmet/swat/nanotrasen + backpack_contents = list(/obj/item/reagent_containers/hypospray/medipen = 1) + +/datum/human_npc_outfit_table/ruin/nanotrasen + green = list(/datum/outfit/ruin_npc/nanotrasen = 1) + yellow = list(/datum/outfit/ruin_npc/nanotrasen/vest = 1) + red = list(/datum/outfit/ruin_npc/nanotrasen/vest/helmet = 1) + +/mob/living/carbon/human/npc/ruin/trooper/nanotrasen + npc_name = "Nanotrasen Private Security Officer" + faction = list(ROLE_DEATHSQUAD) + npc_voice = /datum/human_npc_voice/ruin_nanotrasen + npc_outfit_table = /datum/human_npc_outfit_table/ruin/nanotrasen + +// ===== RUSSIAN MOBSTERS ===== + +/// A soviet uniform, a bear pelt and a kitchen knife. +/datum/outfit/ruin_npc/russian + name = "Ruin NPC: Russian mobster" + uniform = /obj/item/clothing/under/costume/soviet + shoes = /obj/item/clothing/shoes/jackboots + head = /obj/item/clothing/head/costume/bearpelt + gloves = /obj/item/clothing/gloves/color/black + r_hand = /obj/item/knife/kitchen + +/datum/outfit/ruin_npc/russian/vest + name = "Ruin NPC: Russian mobster in a vest" + suit = /obj/item/clothing/suit/armor/vest + +/// The red zone's Russians are troopers: camo, a bulletproof vest and a helmet. +/datum/outfit/ruin_npc/russian/trooper + name = "Ruin NPC: Russian trooper" + uniform = /obj/item/clothing/under/syndicate/camo + suit = /obj/item/clothing/suit/armor/bulletproof + head = /obj/item/clothing/head/helmet/alt + shoes = /obj/item/clothing/shoes/combat + gloves = /obj/item/clothing/gloves/combat + l_pocket = /obj/item/reagent_containers/hypospray/medipen + +/// A Makarov and two spare magazines, under an ushanka. +/datum/outfit/ruin_npc/russian/gunner + name = "Ruin NPC: Russian gunner" + head = /obj/item/clothing/head/costume/ushanka + r_hand = /obj/item/gun/ballistic/automatic/pistol + l_pocket = /obj/item/ammo_box/magazine/m9mm + r_pocket = /obj/item/ammo_box/magazine/m9mm + +/datum/outfit/ruin_npc/russian/gunner/vest + name = "Ruin NPC: Russian gunner in a vest" + suit = /obj/item/clothing/suit/armor/vest + +/datum/outfit/ruin_npc/russian/gunner/trooper + name = "Ruin NPC: Russian trooper gunner" + uniform = /obj/item/clothing/under/syndicate/camo + suit = /obj/item/clothing/suit/armor/bulletproof + head = /obj/item/clothing/head/helmet/alt + shoes = /obj/item/clothing/shoes/combat + gloves = /obj/item/clothing/gloves/combat + belt = /obj/item/storage/belt/military + belt_contents = list(/obj/item/reagent_containers/hypospray/medipen = 1) + +/datum/human_npc_outfit_table/ruin/russian + green = list(/datum/outfit/ruin_npc/russian = 1) + yellow = list(/datum/outfit/ruin_npc/russian/vest = 1) + red = list(/datum/outfit/ruin_npc/russian/trooper = 1) + +/datum/human_npc_outfit_table/ruin/russian/gunner + green = list(/datum/outfit/ruin_npc/russian/gunner = 1) + yellow = list(/datum/outfit/ruin_npc/russian/gunner/vest = 1) + red = list(/datum/outfit/ruin_npc/russian/gunner/trooper = 1) + +/mob/living/carbon/human/npc/ruin/trooper/russian + npc_name = "Russian Mobster" + faction = list(FACTION_RUSSIAN) + npc_voice = /datum/human_npc_voice/ruin_russian + npc_outfit_table = /datum/human_npc_outfit_table/ruin/russian + npc_death_loot = list(/obj/item/knife/kitchen) + +/mob/living/carbon/human/npc/ruin/trooper/russian/gunner + npc_outfit_table = /datum/human_npc_outfit_table/ruin/russian/gunner + npc_death_loot = list(/obj/item/gun/ballistic/revolver/nagant) diff --git a/voidcrew/modules/lich/lich_spells.dm b/voidcrew/modules/lich/lich_spells.dm index 096c68d95f2..0a4d2d0761b 100644 --- a/voidcrew/modules/lich/lich_spells.dm +++ b/voidcrew/modules/lich/lich_spells.dm @@ -332,7 +332,7 @@ mend_the_dead(victim) return - victim.adjustToxLoss(VERDIGRIS_BOLT_ROT, forced = TRUE) + victim.adjustToxLoss(VERDIGRIS_BOLT_ROT) victim.visible_message( span_danger("The green soaks into [victim] and starts to rot [victim.p_them()]."), span_userdanger("Something green gets under your skin and starts rotting you."), @@ -636,7 +636,8 @@ return stung = TRUE - attacker.adjustBruteLoss(npc_zone_damage(VERDIGRIS_MIRAGE_STING, src)) + // Through the arm that struck it, as the message says (a body without arms takes it anywhere). + attacker.apply_damage(npc_zone_damage(VERDIGRIS_MIRAGE_STING, src), BRUTE, attacker.get_active_hand() || null) to_chat(attacker, span_userdanger("The mirage bursts, spraying green light through your arm!")) new /obj/effect/temp_visual/small_smoke/halfsecond(get_turf(src)) QDEL_IN(src, 0) @@ -701,7 +702,7 @@ /obj/item/book/granter/action/spell/verdigris_bolt/recoil(mob/living/user) . = ..() user.visible_message(span_warning("[src] coughs out a wash of green, and the air around [user] starts to smell like wet soil.")) - user.adjustToxLoss(15, forced = TRUE) + user.adjustToxLoss(15) /obj/item/book/granter/action/spell/grave_mirage name = "codex of the fourth corpse" diff --git a/voidcrew/modules/loot/themes/plunder.dm b/voidcrew/modules/loot/themes/plunder.dm index b142f73c2ae..d0cc0e26036 100644 --- a/voidcrew/modules/loot/themes/plunder.dm +++ b/voidcrew/modules/loot/themes/plunder.dm @@ -97,40 +97,40 @@ /obj/effect/zone_mobs/pirate name = "zone mob spawner (pirate)" mobs_green = list( - /mob/living/basic/trooper/pirate/faction/grey/melee = 10, - /mob/living/basic/trooper/pirate/faction/skeleton/melee = 8, - /mob/living/basic/trooper/pirate/faction/silverscale/melee = 6, + /mob/living/carbon/human/npc/faction_pirate/grey/melee = 10, + /mob/living/carbon/human/npc/faction_pirate/skeleton/melee = 8, + /mob/living/carbon/human/npc/faction_pirate/silverscale/melee = 6, ) mobs_yellow = list( - /mob/living/basic/trooper/pirate/faction/grey/ranged = 8, - /mob/living/basic/trooper/pirate/faction/skeleton/ranged = 8, - /mob/living/basic/trooper/pirate/faction/silverscale/melee = 6, - /mob/living/basic/trooper/pirate/faction/lustrous/ranged = 5, + /mob/living/carbon/human/npc/faction_pirate/grey/ranged = 8, + /mob/living/carbon/human/npc/faction_pirate/skeleton/ranged = 8, + /mob/living/carbon/human/npc/faction_pirate/silverscale/melee = 6, + /mob/living/carbon/human/npc/faction_pirate/lustrous/ranged = 5, ) mobs_red = list( - /mob/living/basic/trooper/pirate/faction/silverscale/ranged = 8, - /mob/living/basic/trooper/pirate/faction/lustrous/ranged = 8, - /mob/living/basic/trooper/pirate/faction/interdyne/ranged = 6, - /mob/living/basic/trooper/pirate/faction/skeleton/captain = 4, - /mob/living/basic/trooper/pirate/faction/grey/captain = 4, + /mob/living/carbon/human/npc/faction_pirate/silverscale/ranged = 8, + /mob/living/carbon/human/npc/faction_pirate/lustrous/ranged = 8, + /mob/living/carbon/human/npc/faction_pirate/interdyne/ranged = 6, + /mob/living/carbon/human/npc/faction_pirate/skeleton/captain = 4, + /mob/living/carbon/human/npc/faction_pirate/grey/captain = 4, ) /// The pirate setpiece: a captain holding the vault, a proper boss in the red. /obj/effect/zone_mobs/pirate/boss name = "zone mob spawner (pirate boss)" mobs_green = list( - /mob/living/basic/trooper/pirate/faction/grey/captain = 1, - /mob/living/basic/trooper/pirate/faction/skeleton/captain = 1, + /mob/living/carbon/human/npc/faction_pirate/grey/captain = 1, + /mob/living/carbon/human/npc/faction_pirate/skeleton/captain = 1, ) mobs_yellow = list( - /mob/living/basic/trooper/pirate/faction/silverscale/captain = 1, - /mob/living/basic/trooper/pirate/faction/lustrous/captain = 1, - /mob/living/basic/trooper/pirate/faction/interdyne/captain = 1, + /mob/living/carbon/human/npc/faction_pirate/silverscale/captain = 1, + /mob/living/carbon/human/npc/faction_pirate/lustrous/captain = 1, + /mob/living/carbon/human/npc/faction_pirate/interdyne/captain = 1, ) mobs_red = list( - /mob/living/basic/trooper/pirate/faction/boss/silverscale = 1, - /mob/living/basic/trooper/pirate/faction/boss/skeleton = 1, - /mob/living/basic/trooper/pirate/faction/boss/grey = 1, - /mob/living/basic/trooper/pirate/faction/boss/lustrous = 1, - /mob/living/basic/trooper/pirate/faction/boss/interdyne = 1, + /mob/living/carbon/human/npc/faction_pirate/silverscale/boss = 1, + /mob/living/carbon/human/npc/faction_pirate/skeleton/boss = 1, + /mob/living/carbon/human/npc/faction_pirate/grey/boss = 1, + /mob/living/carbon/human/npc/faction_pirate/lustrous/boss = 1, + /mob/living/carbon/human/npc/faction_pirate/interdyne/boss = 1, ) diff --git a/voidcrew/modules/loot/zone_mobs.dm b/voidcrew/modules/loot/zone_mobs.dm index 284115aa4f7..d84add286aa 100644 --- a/voidcrew/modules/loot/zone_mobs.dm +++ b/voidcrew/modules/loot/zone_mobs.dm @@ -107,7 +107,7 @@ continue var/turf/spot = length(open_turfs) ? pick_n_take(open_turfs) : get_turf(src) var/datum/npc_spawn_context/context = new(src, zone_type, npc_role) - spawn_npc_in_zone(mob_path, spot, context) + spawn_npc_in_zone_or_queue(mob_path, spot, context) /** * Open, unblocked turfs around the marker the pack can scatter onto. diff --git a/voidcrew/modules/missions/missions/poacher_bust.dm b/voidcrew/modules/missions/missions/poacher_bust.dm index 07cf53dc8f8..e664c33b809 100644 --- a/voidcrew/modules/missions/missions/poacher_bust.dm +++ b/voidcrew/modules/missions/missions/poacher_bust.dm @@ -12,9 +12,11 @@ * filter on the planet target), and the protected species, terrain and * evidence all come from a per-planet table. * - * The squad is the fork's hermit family (simple_animal humanoids): scruffy - * wild-country gunmen with working c38/c46x30mm casing fire, each renamed to - * a generated poacher on spawn. Every death is attributed suppression-style + * The squad is the wasteland hermits as human NPCs + * (voidcrew/modules/human_npcs/ruins/ruin_npc_hermits.dm): scruffy wild-country + * gunmen with real .38 revolvers and WT-550s and their spare ammunition, each + * renamed to a generated poacher on spawn. They are queued and built a body a + * tick; on an ice planet they are dressed for the cold. Every death is attributed suppression-style * (last-attacker ckey or a living crew member in confirm range); unattributed * deaths still count - dead is dead, and the telemetry logs it - so the wipe * can never stall on a weather or wildlife kill. @@ -194,26 +196,25 @@ wipe = new // The squad scales with the zone: green gets rifles and a knife, deeper - // zones add the trailboss's SMG and more guns. Exact subtypes only, the - // /survivor/random variant self-replaces on Initialize and would escape - // tracking. + // zones add the trailboss's SMG and more guns. Exact types only: a type + // that replaces itself on Initialize would escape tracking. var/list/squad_types = list() switch(difficulty) if(MISSION_DIFFICULTY_MEDIUM) - squad_types += /mob/living/simple_animal/hostile/asteroid/hermit/ranged/gunslinger - squad_types += /mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter - squad_types += /mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter - squad_types += /mob/living/simple_animal/hostile/asteroid/hermit/survivor + squad_types += /mob/living/carbon/human/npc/ruin/hermit/gunslinger + squad_types += /mob/living/carbon/human/npc/ruin/hermit/hunter + squad_types += /mob/living/carbon/human/npc/ruin/hermit/hunter + squad_types += /mob/living/carbon/human/npc/ruin/hermit if(MISSION_DIFFICULTY_HARD) - squad_types += /mob/living/simple_animal/hostile/asteroid/hermit/ranged/gunslinger - squad_types += /mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter - squad_types += /mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter - squad_types += /mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter - squad_types += /mob/living/simple_animal/hostile/asteroid/hermit/survivor + squad_types += /mob/living/carbon/human/npc/ruin/hermit/gunslinger + squad_types += /mob/living/carbon/human/npc/ruin/hermit/hunter + squad_types += /mob/living/carbon/human/npc/ruin/hermit/hunter + squad_types += /mob/living/carbon/human/npc/ruin/hermit/hunter + squad_types += /mob/living/carbon/human/npc/ruin/hermit else - squad_types += /mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter - squad_types += /mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter - squad_types += /mob/living/simple_animal/hostile/asteroid/hermit/survivor + squad_types += /mob/living/carbon/human/npc/ruin/hermit/hunter + squad_types += /mob/living/carbon/human/npc/ruin/hermit/hunter + squad_types += /mob/living/carbon/human/npc/ruin/hermit wipe.squad_types = squad_types wipe.squad_names = squad_names wipe.evidence_names = bust_row["evidence"] @@ -264,6 +265,8 @@ var/list/squad_names /// Live squad members still being tracked var/list/mob/living/squad = list() + /// Queued orders for human NPC poachers not built yet (voidcrew/modules/human_npcs/) + var/list/datum/human_npc_order/pending_poachers = list() /// Total squad size at spawn / members down so far var/squad_size = 0 var/squad_down = 0 @@ -301,29 +304,39 @@ squad_size = 0 cache = null -/// Stops tracking every remaining squad member (mission over / reset) +/// Stops tracking every remaining squad member (mission over / reset), and cancels the ones still queued /datum/mission_objective/field/wipe_camp/proc/release_squad() for(var/mob/living/poacher as anything in squad) UnregisterSignal(poacher, list(COMSIG_LIVING_DEATH, COMSIG_QDELETING)) squad.Cut() + for(var/datum/human_npc_order/order as anything in pending_poachers) + qdel(order) + pending_poachers.Cut() /datum/mission_objective/field/wipe_camp/spawn_field_objects(turf/camp_turf) - // The squad, scattered around the campsite + // The squad, scattered around the campsite. Human poachers are queued and join + // the squad as they are built; the head count includes them from the start. for(var/i in 1 to length(squad_types)) var/poacher_type = squad_types[i] - var/mob/living/simple_animal/poacher = spawn_field_npc(poacher_type, get_nearby_open_turf(camp_turf, 3), finalize = FALSE) - if(i <= length(squad_names)) - poacher.name = squad_names[i] + var/poacher_name = i <= length(squad_names) ? squad_names[i] : null + var/turf/poacher_spot = get_nearby_open_turf(camp_turf, 3) + if(ispath(poacher_type, /mob/living/carbon/human/npc)) + // Their outfits keep an ice-planet camp from freezing (human_npc_outfits.dm site layers). + var/datum/npc_spawn_context/context = new(mission?.target || src, mission?.target?.get_zone_type(), "auto", source_turf = poacher_spot) + pending_poachers += spawn_human_npc(poacher_type, poacher_spot, CALLBACK(src, PROC_REF(on_human_poacher_built)), name = poacher_name, context = context) + continue + var/mob/living/simple_animal/poacher = spawn_field_npc(poacher_type, poacher_spot, finalize = FALSE) + if(poacher_name) + poacher.name = poacher_name poacher.desc += " The kit is professional: snare wire, skinning knives, and the brand of [mission.objective_name] burned into the stock." // Outfitted expedition: cold-weather gear keeps an ice-planet camp // from freezing to death before the crew arrives poacher.minbodytemp = 0 poacher.npc_spawn_context.finalize() - protect_field_mob(poacher) - RegisterSignal(poacher, COMSIG_LIVING_DEATH, PROC_REF(on_poacher_death)) - RegisterSignal(poacher, COMSIG_QDELETING, PROC_REF(on_poacher_removed)) - squad += poacher - squad_size = length(squad) + enlist_poacher(poacher) + squad_size = length(squad) + length(pending_poachers) + if(length(pending_poachers)) + addtimer(CALLBACK(src, PROC_REF(check_pending_poachers)), HUMAN_NPC_ZONE_WAIT + 10 SECONDS) // Camp dressing: fire, crude cover, bedrolls. The dense prelit bonfire // can't be pathed into, so the squad won't cook itself. @@ -366,6 +379,41 @@ notify_crew("[mission.objective_name] camp sighted - [squad_size] armed poachers holding a sealed trophy cache. The case beacon marks the cache ([mission.gps_tag]).", type = SHIP_NOTIFY_WARNING, sound = 'voidcrew/sound/notify2.ogg') +/// Tracks a squad member: spared by the planet's fauna sweep, counted when it dies. +/datum/mission_objective/field/wipe_camp/proc/enlist_poacher(mob/living/poacher) + protect_field_mob(poacher) + RegisterSignal(poacher, COMSIG_LIVING_DEATH, PROC_REF(on_poacher_death)) + RegisterSignal(poacher, COMSIG_QDELETING, PROC_REF(on_poacher_removed)) + squad += poacher + +/// A queued human poacher was built: it joins the squad. +/datum/mission_objective/field/wipe_camp/proc/on_human_poacher_built(mob/living/carbon/human/npc/poacher) + for(var/datum/human_npc_order/order as anything in pending_poachers) + if(order.spawned_ref?.resolve() == poacher) + pending_poachers -= order + break + if(!active || !mission || mission.failed || mission.completed) + return + enlist_poacher(poacher) + +/** + * A queued poacher that was never built (its spot became unusable) leaves the head count, so the wipe + * can still finish. Orders still waiting are looked at again later. + */ +/datum/mission_objective/field/wipe_camp/proc/check_pending_poachers() + if(!active || !mission || mission.failed || mission.completed) + return + for(var/datum/human_npc_order/order as anything in pending_poachers.Copy()) + if(QDELETED(order) || (order.done && !order.spawned_ref?.resolve())) + pending_poachers -= order + squad_size-- + if(length(pending_poachers)) + addtimer(CALLBACK(src, PROC_REF(check_pending_poachers)), 10 SECONDS) + return + if(squad_size > 0 && squad_down >= squad_size) + unlock_cache() + complete() + /** * A named poacher died: always counts toward the wipe (attribution only * flavors the line - dead is dead and the telemetry logs it, so a weather or diff --git a/voidcrew/modules/missions/missions/recovery.dm b/voidcrew/modules/missions/missions/recovery.dm index a018e34a098..9973774908a 100644 --- a/voidcrew/modules/missions/missions/recovery.dm +++ b/voidcrew/modules/missions/missions/recovery.dm @@ -70,39 +70,40 @@ mission_limit = 2 gps_tag_prefix = "HUNT" - /// Mob type pools per difficulty (space-capable faction pirates). + /// Mob type pools per difficulty: faction pirates as human NPCs + /// (voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_humans.dm), in space suits where the site is airless. /// Hard pool is the real faction bosses. Red-zone bounties are the /// named monsters of the sector, not just another captain. var/static/list/easy_targets = list( - /mob/living/basic/trooper/pirate/faction/silverscale/melee, - /mob/living/basic/trooper/pirate/faction/skeleton/melee, - /mob/living/basic/trooper/pirate/faction/grey/melee, + /mob/living/carbon/human/npc/faction_pirate/silverscale/melee, + /mob/living/carbon/human/npc/faction_pirate/skeleton/melee, + /mob/living/carbon/human/npc/faction_pirate/grey/melee, ) var/static/list/medium_targets = list( - /mob/living/basic/trooper/pirate/faction/silverscale/ranged, - /mob/living/basic/trooper/pirate/faction/skeleton/ranged, - /mob/living/basic/trooper/pirate/faction/lustrous/ranged, - /mob/living/basic/trooper/pirate/faction/grey/captain, + /mob/living/carbon/human/npc/faction_pirate/silverscale/ranged, + /mob/living/carbon/human/npc/faction_pirate/skeleton/ranged, + /mob/living/carbon/human/npc/faction_pirate/lustrous/ranged, + /mob/living/carbon/human/npc/faction_pirate/grey/captain, ) var/static/list/hard_targets = list( - /mob/living/basic/trooper/pirate/faction/boss/silverscale, - /mob/living/basic/trooper/pirate/faction/boss/skeleton, - /mob/living/basic/trooper/pirate/faction/boss/grey, - /mob/living/basic/trooper/pirate/faction/boss/lustrous, - /mob/living/basic/trooper/pirate/faction/boss/interdyne, - /mob/living/basic/trooper/pirate/faction/boss/medieval, + /mob/living/carbon/human/npc/faction_pirate/silverscale/boss, + /mob/living/carbon/human/npc/faction_pirate/skeleton/boss, + /mob/living/carbon/human/npc/faction_pirate/grey/boss, + /mob/living/carbon/human/npc/faction_pirate/lustrous/boss, + /mob/living/carbon/human/npc/faction_pirate/interdyne/boss, + /mob/living/carbon/human/npc/faction_pirate/medieval/boss, ) /// Entourage pools: bounty targets above easy keep hired muscle around var/static/list/medium_guards = list( - /mob/living/basic/trooper/pirate/faction/grey/melee, - /mob/living/basic/trooper/pirate/faction/skeleton/melee, - /mob/living/basic/trooper/pirate/faction/silverscale/melee, + /mob/living/carbon/human/npc/faction_pirate/grey/melee, + /mob/living/carbon/human/npc/faction_pirate/skeleton/melee, + /mob/living/carbon/human/npc/faction_pirate/silverscale/melee, ) var/static/list/hard_guards = list( - /mob/living/basic/trooper/pirate/faction/silverscale/ranged, - /mob/living/basic/trooper/pirate/faction/skeleton/ranged, - /mob/living/basic/trooper/pirate/faction/lustrous/ranged, - /mob/living/basic/trooper/pirate/faction/interdyne/ranged, + /mob/living/carbon/human/npc/faction_pirate/silverscale/ranged, + /mob/living/carbon/human/npc/faction_pirate/skeleton/ranged, + /mob/living/carbon/human/npc/faction_pirate/lustrous/ranged, + /mob/living/carbon/human/npc/faction_pirate/interdyne/ranged, ) /datum/mission/recovery/kill/generate_details() diff --git a/voidcrew/modules/missions/objectives/combat.dm b/voidcrew/modules/missions/objectives/combat.dm index a9f08365fff..72cf2024bc2 100644 --- a/voidcrew/modules/missions/objectives/combat.dm +++ b/voidcrew/modules/missions/objectives/combat.dm @@ -158,8 +158,12 @@ var/proof_type = /obj/item/mission_recovery/proof /// The live target, while they're alive var/mob/living/target_mob + /// The queued order building a human NPC target (voidcrew/modules/human_npcs/), until it is built + var/datum/human_npc_order/quarry_order /datum/mission_objective/field/kill_named/deactivate() + // A target still waiting in the spawn queue is never built. + QDEL_NULL(quarry_order) if(target_mob) UnregisterSignal(target_mob, COMSIG_LIVING_DEATH) target_mob = null @@ -174,6 +178,9 @@ create_proof(spawn_turf) complete() return + if(ispath(target_mob_type, /mob/living/carbon/human/npc)) + spawn_human_quarry(spawn_turf) + return var/mob/living/target = spawn_field_npc(target_mob_type, spawn_turf, finalize = FALSE) target.name = mission.objective_name target.desc += " They look like they're worth something dead." @@ -186,6 +193,31 @@ guard.desc += " They're on somebody's payroll." guard.npc_spawn_context.finalize() +/** + * A human NPC target (voidcrew/modules/human_npcs/) and its guards are queued, a body a tick, not built + * on the spot. The target carries the contract's name and is tracked once it exists; the guards are + * untracked muscle, as above. + */ +/datum/mission_objective/field/kill_named/proc/spawn_human_quarry(turf/spawn_turf) + var/datum/npc_spawn_context/context = new(mission?.target || src, mission?.target?.get_zone_type(), "auto", source_turf = spawn_turf) + quarry_order = spawn_human_npc(target_mob_type, spawn_turf, CALLBACK(src, PROC_REF(on_quarry_built)), name = mission.objective_name, context = context) + for(var/guard_type in guard_types) + var/turf/guard_spot = get_nearby_open_turf(spawn_turf) + if(ispath(guard_type, /mob/living/carbon/human/npc)) + var/datum/npc_spawn_context/guard_context = new(mission?.target || src, mission?.target?.get_zone_type(), "auto", source_turf = guard_spot) + spawn_human_npc(guard_type, guard_spot, context = guard_context) + continue + var/mob/living/guard = spawn_field_npc(guard_type, guard_spot, finalize = FALSE) + guard.desc += " They're on somebody's payroll." + guard.npc_spawn_context.finalize() + +/// The queued target exists now: track it, unless the contract moved on while it waited. +/datum/mission_objective/field/kill_named/proc/on_quarry_built(mob/living/quarry) + quarry_order = null + if(!active || !mission || mission.failed || mission.completed || mission.named_kill_completed) + return + track_target(quarry) + /// Keep death tracking and the cash entitlement attached to the same mission. /datum/mission_objective/field/kill_named/proc/track_target(mob/living/target) target_mob = target @@ -193,6 +225,12 @@ if(istype(target, /mob/living/basic/trooper/pirate/faction)) var/mob/living/basic/trooper/pirate/faction/pirate = target pirate.mission_payout_ref = WEAKREF(mission) + else if(istype(target, /mob/living/carbon/human/npc/ruin)) + var/mob/living/carbon/human/npc/ruin/quarry = target + quarry.npc_payout_mission = WEAKREF(mission) + else if(istype(target, /mob/living/carbon/human/npc/faction_pirate)) + var/mob/living/carbon/human/npc/faction_pirate/pirate_quarry = target + pirate_quarry.npc_payout_mission = WEAKREF(mission) RegisterSignal(target, COMSIG_LIVING_DEATH, PROC_REF(on_target_death)) mission.register_quest_atom(target) @@ -239,8 +277,9 @@ * turn-in item - the mission auto-completes like a survey. */ /datum/mission_objective/kill_count - /// Base typepath of mobs that count - var/mob_base_type = /mob/living/basic/trooper/pirate/faction + /// Base typepaths of basic mobs that count (the basic faction pirates). Human NPCs count by the pirate + /// flag they sail under (counts_victim()): ruin pirates and NPC ship crews alike. + var/list/mob_base_types = list(/mob/living/basic/trooper/pirate/faction) /// Minimum zone the kill must happen in (design guard: no green farming) var/minimum_zone = ZONE_YELLOW /// Kills required / confirmed @@ -248,10 +287,13 @@ var/kill_count = 0 /// How close (tiles) a living crew member must be to confirm a kill var/confirm_range = 9 + /// Weakrefs to every body already counted: one revived and killed again counts once + var/list/datum/weakref/counted_kills = list() /datum/mission_objective/kill_count/reset() . = ..() kill_count = 0 + counted_kills.Cut() /datum/mission_objective/kill_count/activate() . = ..() @@ -263,16 +305,17 @@ /datum/mission_objective/kill_count/proc/on_any_death(datum/source, mob/living/victim, gibbed) SIGNAL_HANDLER - if(completed || !istype(victim, mob_base_type)) + if(completed || !counts_victim(victim)) return - var/turf/where = get_turf(victim) - if(!where) + var/datum/weakref/victim_ref = WEAKREF(victim) + if(victim_ref in counted_kills) return - var/zone_type = SSovermap_zones?.get_zone_type_anywhere(where) - if(isnull(zone_type) || zone_type < minimum_zone) + var/turf/where = get_turf(victim) + if(!where || !kill_zone_counts(where)) return if(!kill_attributable_to_crew(victim, where)) return + counted_kills += victim_ref kill_count++ if(kill_count >= required_kills) notify_crew("Suppression sweep complete.") @@ -280,6 +323,21 @@ return notify_crew("Kill confirmed: [kill_count]/[required_kills].", sound = 'voidcrew/sound/notify2.ogg') +/// Whether a kill at `where` is deep enough to count (design guard: no green farming). +/datum/mission_objective/kill_count/proc/kill_zone_counts(turf/where) + var/zone_type = SSovermap_zones?.get_zone_type_anywhere(where) + return !isnull(zone_type) && zone_type >= minimum_zone + +/** + * Whether `victim` is a mob this sweep counts: the basic faction pirates, and human NPCs + * (voidcrew/modules/human_npcs/) that sail under the pirate flag: ruin and mission pirates and the crews + * of NPC pirate ships. Each body counts once (counted_kills). + */ +/datum/mission_objective/kill_count/proc/counts_victim(mob/living/victim) + if(is_type_in_list(victim, mob_base_types)) + return TRUE + return ishumannpc(victim) && (FACTION_PIRATE in victim.faction) + /** * Whether this kill belongs to the servant crew: the last attacker's ckey is * a crew member's, or a living crew member is close enough to have done it diff --git a/voidcrew/modules/mob/living/simple_animal/hostile/pirate.dm b/voidcrew/modules/mob/living/simple_animal/hostile/pirate.dm deleted file mode 100644 index c44867a13e0..00000000000 --- a/voidcrew/modules/mob/living/simple_animal/hostile/pirate.dm +++ /dev/null @@ -1,23 +0,0 @@ -/mob/living/basic/trooper/pirate/melee/beach - faction = list(FACTION_BEACH) - -/mob/living/basic/trooper/pirate/ranged/beach - faction = list(FACTION_BEACH) - -/mob/living/basic/trooper/pirate/melee/beach/boat - icon = 'voidcrew/icons/mob/boat_pirates.dmi' - icon_state = "piratemelee" - icon_living = "piratemelee" - use_dynamic_appearance = FALSE - faction = list(FACTION_BEACH) - unsuitable_atmos_damage = 0 - minimum_survivable_temperature = 0 - -/mob/living/basic/trooper/pirate/ranged/beach/boat - icon = 'voidcrew/icons/mob/boat_pirates.dmi' - icon_state = "pirateranged" - icon_living = "pirateranged" - use_dynamic_appearance = FALSE - faction = list(FACTION_BEACH) - unsuitable_atmos_damage = 0 - minimum_survivable_temperature = 0 diff --git a/voidcrew/modules/mob/living/simple_animal/hostile/wasteland/hermits.dm b/voidcrew/modules/mob/living/simple_animal/hostile/wasteland/hermits.dm deleted file mode 100644 index e59848796f3..00000000000 --- a/voidcrew/modules/mob/living/simple_animal/hostile/wasteland/hermits.dm +++ /dev/null @@ -1,92 +0,0 @@ -/mob/living/simple_animal/hostile/asteroid/hermit - name = "Wasteland Inhabitant" - desc = "If you can read this, yell at a coder!" - icon = 'voidcrew/icons/mob/simple_human.dmi' - icon_state = "survivor_base" - icon_living = "survivor_base" - icon_dead = null - icon_gib = null - mob_biotypes = MOB_ORGANIC - minbodytemp = 180 - unsuitable_atmos_damage = 15 - atmos_requirements = list("min_oxy" = 1, "max_oxy" = 0, "min_tox" = 0, "max_tox" = 0, "min_co2" = 0, "max_co2" = 999, "min_n2" = 0, "max_n2" = 0) - speak_chance = 20 - turns_per_move = 5 - response_help_continuous = "pushes" - response_help_simple = "push" - speed = 0 - maxHealth = 100 - health = 100 - harm_intent_damage = 5 - melee_damage_lower = 10 - melee_damage_upper = 10 - attack_verb_continuous = "punches" - attack_verb_simple = "punch" - attack_sound = 'sound/items/weapons/punch1.ogg' - combat_mode = TRUE - unsuitable_atmos_damage = 15 - speak_emote = list( - "The sun... The sun...", - "You'll do...", - "All mine...", - "Gg..free..", - "Drink.. need drink...", - "I can smell... you..", - "G-g...", - "Taste..the salt.", - ) - loot = list( - /obj/effect/mob_spawn/corpse/human/hermit/survivor - ) - del_on_death = 1 - faction = list("hermit", "wasteland") - -/mob/living/simple_animal/hostile/asteroid/hermit/death(gibbed) - move_force = MOVE_FORCE_DEFAULT - move_resist = MOVE_RESIST_DEFAULT - pull_force = PULL_FORCE_DEFAULT - return ..() - -/mob/living/simple_animal/hostile/asteroid/hermit/survivor - name = "Hermit Wanderer" - desc =" A wild-eyed figure, wearing tattered mining equipment and boasting a malformed body, twisted by the heavy metals and high background radiation of the sandworlds." - -/mob/living/simple_animal/hostile/asteroid/hermit/survivor/random/Initialize() - . = ..() - if(prob(10)) - spawn_npc_in_zone(/mob/living/simple_animal/hostile/asteroid/hermit/ranged/gunslinger, loc, get_npc_spawn_context(), FALSE) - return INITIALIZE_HINT_QDEL - if(prob(35)) - spawn_npc_in_zone(/mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter, loc, get_npc_spawn_context(), FALSE) - return INITIALIZE_HINT_QDEL - -/mob/living/simple_animal/hostile/asteroid/hermit/ranged - icon_state = "survivor_hunter" - icon_living = "survivor_hunter" - casingtype = /obj/item/ammo_casing/c38 - projectilesound = 'sound/items/weapons/gun/rifle/shot.ogg' - ranged = 1 - rapid_fire_delay = 6 - retreat_distance = 5 - minimum_distance = 5 - -/mob/living/simple_animal/hostile/asteroid/hermit/ranged/hunter - name = "Hermit Hunter" - desc ="A wild-eyed figure. Watch out- he has a gun, and he remembers just enough of his old life to use it!" - loot = list( - /obj/effect/mob_spawn/corpse/human/hermit/survivor/hunter - ) - -/mob/living/simple_animal/hostile/asteroid/hermit/ranged/gunslinger - name = "Hermit Soldier" - desc = "The miner's rebellion, though mostly underground, recieved a few good weapon shipments from an off-sector source. You should probably start running." - icon_state = "survivor_gunslinger" - icon_living = "survivor_gunslinger" - casingtype = /obj/item/ammo_casing/c46x30mm - projectilesound = 'sound/items/weapons/gun/smg/shot.ogg' - speed = 1 - rapid = 4 - rapid_fire_delay = 3 - loot = list( - /obj/effect/mob_spawn/corpse/human/hermit/survivor/gunslinger - ) diff --git a/voidcrew/modules/npc_ships/code/_defines.dm b/voidcrew/modules/npc_ships/code/_defines.dm index 42a56952e19..f6d0946fb93 100644 --- a/voidcrew/modules/npc_ships/code/_defines.dm +++ b/voidcrew/modules/npc_ships/code/_defines.dm @@ -307,6 +307,10 @@ GLOBAL_LIST_EMPTY(door_to_rooms) // ship_ref -> list(door_ref -> list(room_id_ #define BB_PIRATE_POST_TURF "pirate_post_turf" /// Where a mob that strayed is walking back to #define BB_PIRATE_RETURN_TURF "pirate_return_turf" +/// Where a pirate with no crew was put (a ruin's, a planet's, a contract's): it keeps near it +#define BB_PIRATE_CREWLESS_HOME "pirate_crewless_home" +/// A pirate with no crew and nothing to fight walks home once it is this many tiles from it +#define PIRATE_CREWLESS_LEASH 10 /// The door (or wrecked door frame) this mob is breaking through #define BB_PIRATE_BREACH_TARGET "pirate_breach_target" /// The turf it breaks the door from @@ -390,3 +394,38 @@ GLOBAL_LIST_EMPTY(door_to_rooms) // ship_ref -> list(door_ref -> list(room_id_ #define PIRATE_CREW_CROSS_BARK_CREW (30 SECONDS) /// How often a pirate with no target looks around for one #define PIRATE_CREW_SCAN_COOLDOWN (1 SECONDS) + +// ========== HUMAN SHIP CREWS (faction_pirate_humans.dm, pirate_crew_human.dm) ========== +// NPC ship crews and their boarders are real human NPCs (voidcrew/modules/human_npcs/). Unit tests +// can't see these; they use the literals. + +/// A crewman who fights hand to hand (ship_crew/var/crew_role); its faction table dresses it from the melee outfits +#define SHIP_CREW_ROLE_MELEE "melee" +/// A crewman who fights with a gun; its faction table dresses it from the gunner outfits +#define SHIP_CREW_ROLE_GUNNER "gunner" + +/// Pulls of the trigger left in the volley a human gunner is firing +#define BB_PIRATE_VOLLEY_LEFT "pirate_volley_left" +/// world.time a gunner's spin-up or aim ends; a hit before then spoils it +#define BB_PIRATE_WINDUP_UNTIL "pirate_windup_until" +/// world.time the door being broken last lost integrity, so a breach that gets somewhere isn't given up on +#define BB_PIRATE_BREACH_PROGRESS_AT "pirate_breach_progress_at" +/// The door's integrity when it was last looked at +#define BB_PIRATE_BREACH_INTEGRITY "pirate_breach_integrity" +/// The item an elite or boss is using on itself (its stimulant, a flask) +#define BB_PIRATE_SELF_ITEM "pirate_self_item" +/// world.time a boss may next drink from its flask +#define BB_PIRATE_NEXT_DRINK "pirate_next_drink" +/// world.time a boss gunner may next put its gun to a downed hunter's head +#define BB_PIRATE_NEXT_EXECUTION "pirate_next_execution" + +/// A crew member adrift in space, out of sight of every player, this long is cleaned up (pirate_crew.dm) +#define PIRATE_CREW_ADRIFT_TIME (2 MINUTES) +/// A boss gunner waits this long between executions +#define PIRATE_CREW_EXECUTION_COOLDOWN (60 SECONDS) +/// A boss with a flask drinks from it no more often than this, and only once it is this hurt +#define PIRATE_CREW_DRINK_COOLDOWN (20 SECONDS) +#define PIRATE_CREW_DRINK_HEALTH_SHARE 0.7 +/// Elites' and bosses' toughness by rank (npc_damage_taken). Starting values for the balance pass. +#define SHIP_CREW_ELITE_DAMAGE_TAKEN 0.8 +#define SHIP_CREW_BOSS_DAMAGE_TAKEN 0.6 diff --git a/voidcrew/modules/npc_ships/code/admin_verbs.dm b/voidcrew/modules/npc_ships/code/admin_verbs.dm index dd3bd2d8a1b..c62568887a6 100644 --- a/voidcrew/modules/npc_ships/code/admin_verbs.dm +++ b/voidcrew/modules/npc_ships/code/admin_verbs.dm @@ -2,49 +2,49 @@ * Admin verbs for NPC pirate mob spawning */ -/// Mapping of faction names to their mob types +/// Mapping of faction names to their mob types: the human NPC ship crews (faction_pirate_humans.dm) GLOBAL_LIST_INIT(npc_pirate_factions, list( "Silverscale" = list( - "Melee (Duelist)" = /mob/living/basic/trooper/pirate/faction/silverscale/melee, - "Ranged (Marksman)" = /mob/living/basic/trooper/pirate/faction/silverscale/ranged, - "Captain (Noble)" = /mob/living/basic/trooper/pirate/faction/silverscale/captain, - "Boss (Highlord)" = /mob/living/basic/trooper/pirate/faction/boss/silverscale, + "Melee (Duelist)" = /mob/living/carbon/human/npc/faction_pirate/silverscale/melee, + "Ranged (Marksman)" = /mob/living/carbon/human/npc/faction_pirate/silverscale/ranged, + "Captain (Noble)" = /mob/living/carbon/human/npc/faction_pirate/silverscale/captain, + "Boss (Highlord)" = /mob/living/carbon/human/npc/faction_pirate/silverscale/boss, ), "Skeleton" = list( - "Melee (Swashbuckler)" = /mob/living/basic/trooper/pirate/faction/skeleton/melee, - "Ranged (Gunner)" = /mob/living/basic/trooper/pirate/faction/skeleton/ranged, - "Captain" = /mob/living/basic/trooper/pirate/faction/skeleton/captain, - "Boss (Davy Jones)" = /mob/living/basic/trooper/pirate/faction/boss/skeleton, + "Melee (Swashbuckler)" = /mob/living/carbon/human/npc/faction_pirate/skeleton/melee, + "Ranged (Gunner)" = /mob/living/carbon/human/npc/faction_pirate/skeleton/ranged, + "Captain" = /mob/living/carbon/human/npc/faction_pirate/skeleton/captain, + "Boss (Davy Jones)" = /mob/living/carbon/human/npc/faction_pirate/skeleton/boss, ), "Grey Tide" = list( - "Melee (Grey Tider)" = /mob/living/basic/trooper/pirate/faction/grey/melee, - "Ranged (Gunner)" = /mob/living/basic/trooper/pirate/faction/grey/ranged, - "Captain (Tidemaster)" = /mob/living/basic/trooper/pirate/faction/grey/captain, - "Boss (The Robust One)" = /mob/living/basic/trooper/pirate/faction/boss/grey, + "Melee (Grey Tider)" = /mob/living/carbon/human/npc/faction_pirate/grey/melee, + "Ranged (Gunner)" = /mob/living/carbon/human/npc/faction_pirate/grey/ranged, + "Captain (Tidemaster)" = /mob/living/carbon/human/npc/faction_pirate/grey/captain, + "Boss (The Robust One)" = /mob/living/carbon/human/npc/faction_pirate/grey/boss, ), "Lustrous" = list( - "Melee (Scintillant)" = /mob/living/basic/trooper/pirate/faction/lustrous/melee, - "Ranged (Coruscant)" = /mob/living/basic/trooper/pirate/faction/lustrous/ranged, - "Captain (Radiant)" = /mob/living/basic/trooper/pirate/faction/lustrous/captain, - "Boss (The Radiant One)" = /mob/living/basic/trooper/pirate/faction/boss/lustrous, + "Melee (Scintillant)" = /mob/living/carbon/human/npc/faction_pirate/lustrous/melee, + "Ranged (Coruscant)" = /mob/living/carbon/human/npc/faction_pirate/lustrous/ranged, + "Captain (Radiant)" = /mob/living/carbon/human/npc/faction_pirate/lustrous/captain, + "Boss (The Radiant One)" = /mob/living/carbon/human/npc/faction_pirate/lustrous/boss, ), "Interdyne" = list( - "Melee (Enforcer)" = /mob/living/basic/trooper/pirate/faction/interdyne/melee, - "Ranged (Pharmacist)" = /mob/living/basic/trooper/pirate/faction/interdyne/ranged, - "Captain (Director)" = /mob/living/basic/trooper/pirate/faction/interdyne/captain, - "Boss (Director Prime)" = /mob/living/basic/trooper/pirate/faction/boss/interdyne, + "Melee (Enforcer)" = /mob/living/carbon/human/npc/faction_pirate/interdyne/melee, + "Ranged (Pharmacist)" = /mob/living/carbon/human/npc/faction_pirate/interdyne/ranged, + "Captain (Director)" = /mob/living/carbon/human/npc/faction_pirate/interdyne/captain, + "Boss (Director Prime)" = /mob/living/carbon/human/npc/faction_pirate/interdyne/boss, ), "IRS" = list( - "Melee (Enforcer)" = /mob/living/basic/trooper/pirate/faction/irs/melee, - "Ranged (Agent)" = /mob/living/basic/trooper/pirate/faction/irs/ranged, - "Captain (Head Auditor)" = /mob/living/basic/trooper/pirate/faction/irs/captain, - "Boss (Chief Auditor)" = /mob/living/basic/trooper/pirate/faction/boss/irs, + "Melee (Enforcer)" = /mob/living/carbon/human/npc/faction_pirate/irs/melee, + "Ranged (Agent)" = /mob/living/carbon/human/npc/faction_pirate/irs/ranged, + "Captain (Head Auditor)" = /mob/living/carbon/human/npc/faction_pirate/irs/captain, + "Boss (Chief Auditor)" = /mob/living/carbon/human/npc/faction_pirate/irs/boss, ), "Medieval" = list( - "Melee (Footsoldier)" = /mob/living/basic/trooper/pirate/faction/medieval/melee, - "Ranged (Crossbowman)" = /mob/living/basic/trooper/pirate/faction/medieval/ranged, - "Captain (Warlord)" = /mob/living/basic/trooper/pirate/faction/medieval/captain, - "Boss (The Black Knight)" = /mob/living/basic/trooper/pirate/faction/boss/medieval, + "Melee (Footsoldier)" = /mob/living/carbon/human/npc/faction_pirate/medieval/melee, + "Ranged (Crossbowman)" = /mob/living/carbon/human/npc/faction_pirate/medieval/ranged, + "Captain (Warlord)" = /mob/living/carbon/human/npc/faction_pirate/medieval/captain, + "Boss (The Black Knight)" = /mob/living/carbon/human/npc/faction_pirate/medieval/boss, ), )) @@ -90,9 +90,16 @@ ADMIN_VERB(spawn_npc_pirate, R_SPAWN|R_DEBUG, "Spawn NPC Pirate", "Spawn an NPC // Step 3: Ask whether it boards the ship we're standing on var/setup_raid = tgui_alert(user, "Send it after the crew of the ship you're standing on, as a boarder?", "Boarder AI", list("Yes", "No")) - // Spawn the pirate + // Spawn the pirate: a human NPC is built at once, dressed as a boarder if it is boarding var/datum/npc_spawn_context/context = new(spawn_turf, null, "ordinary") - var/mob/living/basic/trooper/pirate/spawned_pirate = spawn_npc_in_zone(mob_path, spawn_turf, context, FALSE) + var/mob/living/spawned_pirate + if(ispath(mob_path, /mob/living/carbon/human/npc)) + var/datum/human_npc_order/order = spawn_human_npc(mob_path, spawn_turf, outfit = (setup_raid == "Yes" ? boarding_outfit_for(mob_path) : null), context = context, immediate = TRUE) + spawned_pirate = order?.spawned_ref?.resolve() + if(spawned_pirate) + spawned_pirate.flags_1 |= ADMIN_SPAWNED_1 + else + spawned_pirate = spawn_npc_in_zone(mob_path, spawn_turf, context, FALSE) if(!spawned_pirate) to_chat(user, span_warning("Failed to spawn pirate.")) return @@ -118,7 +125,8 @@ ADMIN_VERB(spawn_npc_pirate, R_SPAWN|R_DEBUG, "Spawn NPC Pirate", "Spawn an NPC else to_chat(user, span_notice("Spawned [spawned_pirate.name] ([selected_faction] - [selected_type]) with its own AI.")) - context.finalize() + if(!ispath(mob_path, /mob/living/carbon/human/npc)) + context.finalize() message_admins("[key_name_admin(user)] spawned NPC pirate: [spawned_pirate.name] ([selected_faction] - [selected_type]) at [AREACOORD(spawn_turf)]") log_admin("[key_name(user)] spawned NPC pirate: [spawned_pirate.name] ([selected_faction] - [selected_type]) at [AREACOORD(spawn_turf)]") BLACKBOX_LOG_ADMIN_VERB("Spawn NPC Pirate") diff --git a/voidcrew/modules/npc_ships/code/behaviors/ship_combat_behaviors.dm b/voidcrew/modules/npc_ships/code/behaviors/ship_combat_behaviors.dm index 0b5c1916e1c..fcdb81f058b 100644 --- a/voidcrew/modules/npc_ships/code/behaviors/ship_combat_behaviors.dm +++ b/voidcrew/modules/npc_ships/code/behaviors/ship_combat_behaviors.dm @@ -704,18 +704,20 @@ return AI_BEHAVIOR_DELAY /** - * Count hostile mobs (pirate troopers) currently on a target ship. - * Used to enforce the max boarder cap during ship combat. + * Count the boarders on a target ship still in the fight: the raid's members aboard it (pirate_crew.dm), + * human or basic, whatever their faction. Used to enforce the max boarder cap during ship combat. */ /datum/ai_behavior/npc_ship/fire_boarding_pods/proc/count_hostile_mobs_on_ship(obj/structure/overmap/ship/target) - if(!target?.shuttle?.shuttle_areas) + var/list/shuttle_areas = target?.shuttle?.shuttle_areas + var/datum/pirate_crew/raid = pirate_crew_of(target, TRUE) + if(!length(shuttle_areas) || !raid) return 0 - var/count = 0 - for(var/area/shuttle_area as anything in target.shuttle.shuttle_areas) - for(var/mob/living/basic/trooper/pirate/boarder in shuttle_area) - if(boarder.stat != DEAD) - count++ + for(var/mob/living/boarder as anything in raid.members) + if(human_npc_out_of_fight(boarder)) + continue + if(shuttle_areas[get_area(boarder)]) + count++ return count // ========== USE INTERDICTOR ========== diff --git a/voidcrew/modules/npc_ships/code/boarding_pod.dm b/voidcrew/modules/npc_ships/code/boarding_pod.dm index e54b2177e0e..d737e88b670 100644 --- a/voidcrew/modules/npc_ships/code/boarding_pod.dm +++ b/voidcrew/modules/npc_ships/code/boarding_pod.dm @@ -3,15 +3,24 @@ * * Uses the existing supplypod/landing zone system for the dramatic drop-from-above effect. * Pod lands, opens to reveal the boarder, then vanishes. + * + * Human NPC boarders (the NPC ship crews, faction_pirate_humans.dm) are built through the spawn queue + * (spawn_human_npc(), a body at a time) aboard the pirate's own hull, dressed from their faction's + * boarding table (a sealed suit and air), and only then put in their pod and launched + * (boarding_pod_launch()). A basic-mob boarder is built straight into its pod as before. Either way the + * caller hears about the boarder through `on_boarder`, called with it once it is in its pod. */ /// Tracks spawn index for distributing boarders along patrol path GLOBAL_VAR_INIT(boarding_spawn_index, 0) GLOBAL_VAR_INIT(boarding_spawn_total, 1) -/// Global proc to create a boarding pod drop at a target location -/// Returns the boarder mob so the caller can register signals (e.g. death tracking) -/proc/create_boarding_pod(turf/target_turf, obj/structure/overmap/ship/target_ship, obj/structure/overmap/ship/npc/source_ship, mob_type, datum/npc_spawn_context/encounter, budget_reserved = FALSE) +/** + * Launches a boarding pod at `target_turf` carrying a `mob_type`. Returns the boarder (a basic mob, built + * now), the /datum/human_npc_order of a human boarder still in the spawn queue, or null if nothing was + * sent. `on_boarder` is called with the boarder once it is in its pod. + */ +/proc/create_boarding_pod(turf/target_turf, obj/structure/overmap/ship/target_ship, obj/structure/overmap/ship/npc/source_ship, mob_type, datum/npc_spawn_context/encounter, budget_reserved = FALSE, datum/callback/on_boarder) if(!target_turf || !mob_type) return null // Combat volleys call this on a timer; the target may have docked since firing. @@ -28,6 +37,12 @@ GLOBAL_VAR_INIT(boarding_spawn_total, 1) return null var/datum/npc_spawn_context/context = new(target_ship, controller.boarding_context.zone_type, "ordinary", source_turf = controller.boarding_context.source_turf) + if(ispath(mob_type, /mob/living/carbon/human/npc)) + var/datum/callback/launch = CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(boarding_pod_launch), /obj/structure/closet/supplypod/boarding, target_turf, target_ship, source_ship, on_boarder) + var/datum/human_npc_order/order = spawn_human_npc(mob_type, boarding_pod_build_turf(source_ship, target_turf), launch, outfit = boarding_outfit_for(mob_type), context = context) + controller.track_boarding_order(order) + return order + // Create the boarding pod with the mob inside var/obj/structure/closet/supplypod/boarding/pod = new() @@ -37,17 +52,52 @@ GLOBAL_VAR_INIT(boarding_spawn_total, 1) qdel(pod) return null - // Store references for the pod + boarding_pod_send(pod, boarder, target_turf, target_ship, source_ship) + on_boarder?.Invoke(boarder) + return boarder + +/// Where a human boarder is built before it goes in its pod: aboard the pirate's own hull, where it +/// climbs into the pod, else (a hull with no dock) the landing spot itself. It is in its pod the same tick. +/proc/boarding_pod_build_turf(obj/structure/overmap/ship/npc/source_ship, turf/target_turf) + return get_turf(source_ship?.shuttle) || target_turf + +/// The boarding outfit table for a human ship crewman (its faction's table sealed for vacuum), or null +/// for anything else. +/proc/boarding_outfit_for(mob_type) + if(!ispath(mob_type, /mob/living/carbon/human/npc/faction_pirate)) + return null + var/mob/living/carbon/human/npc/faction_pirate/crew_type = mob_type + return initial(crew_type.boarding_outfit_table) + +/** + * A human boarder is built (the spawn queue's callback): if the raid it was sent on still stands, it goes + * in its pod and the pod launches; if the target docked or the raid ended meanwhile, the delivery is + * cancelled and the boarder deleted before anyone saw it. A boss learns which hull it boarded for. + */ +/proc/boarding_pod_launch(pod_type, turf/target_turf, obj/structure/overmap/ship/target_ship, obj/structure/overmap/ship/npc/source_ship, datum/callback/on_boarder, mob/living/boarder) + if(QDELETED(boarder)) + return + var/datum/ai_controller/npc_ship/controller = source_ship?.ai_controller + if(QDELETED(target_ship) || QDELETED(source_ship) || target_ship.state != OVERMAP_SHIP_FLYING || source_ship.state != OVERMAP_SHIP_FLYING || !istype(controller) || controller.get_target() != target_ship) + qdel(boarder) + return + var/obj/structure/closet/supplypod/boarding/pod = new pod_type() + boarder.forceMove(pod) + var/mob/living/carbon/human/npc/faction_pirate/crewman = boarder + if(istype(crewman) && ispath(pod_type, /obj/structure/closet/supplypod/boarding/boss)) + crewman.parent_ship = source_ship + boarding_pod_send(pod, boarder, target_turf, target_ship, source_ship) + on_boarder?.Invoke(boarder) + +/// Sends `pod`, with `boarder` already inside, falling onto `target_turf`. +/proc/boarding_pod_send(obj/structure/closet/supplypod/boarding/pod, mob/living/boarder, turf/target_turf, obj/structure/overmap/ship/target_ship, obj/structure/overmap/ship/npc/source_ship) pod.target_ship = target_ship pod.source_ship = source_ship pod.boarder_ref = WEAKREF(boarder) pod.spawn_index = GLOB.boarding_spawn_index++ - // Create the landing zone - this handles the whole falling animation new /obj/effect/pod_landingzone/boarding(target_turf, pod, target_ship, source_ship) - return boarder - /** * Boarding Pod - A supplypod variant for delivering hostile boarders * @@ -162,9 +212,12 @@ GLOBAL_VAR_INIT(boarding_spawn_total, 1) // ========== BOSS BOARDING POD ========== -/// Global proc to create a boss boarding pod drop at a target location -/// Returns the boss mob so the caller can register signals and track it -/proc/create_boss_boarding_pod(turf/target_turf, obj/structure/overmap/ship/target_ship, obj/structure/overmap/ship/npc/source_ship, mob_type) +/** + * Launches the boss's heavy boarding pod at `target_turf`. Returns the boss (a basic mob), the order of a + * human boss still in the spawn queue, or null. `on_boss` is called with the boss once it is in its pod. + * A human boss keeps its own look (it is dressed from its faction's ordinary table, with a mask and air). + */ +/proc/create_boss_boarding_pod(turf/target_turf, obj/structure/overmap/ship/target_ship, obj/structure/overmap/ship/npc/source_ship, mob_type, datum/callback/on_boss) if(!target_turf || !mob_type) return null if(QDELETED(target_ship) || QDELETED(source_ship) || target_ship.state != OVERMAP_SHIP_FLYING || source_ship.state != OVERMAP_SHIP_FLYING) @@ -179,6 +232,12 @@ GLOBAL_VAR_INIT(boarding_spawn_total, 1) controller.boarding_boss_sent = TRUE var/datum/npc_spawn_context/context = new(target_ship, controller.boarding_context.zone_type, "boss", source_turf = controller.boarding_context.source_turf) + if(ispath(mob_type, /mob/living/carbon/human/npc)) + var/datum/callback/launch = CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(boarding_pod_launch), /obj/structure/closet/supplypod/boarding/boss, target_turf, target_ship, source_ship, on_boss) + var/datum/human_npc_order/order = spawn_human_npc(mob_type, boarding_pod_build_turf(source_ship, target_turf), launch, context = context) + controller.track_boarding_order(order) + return order + // Create the boss boarding pod var/obj/structure/closet/supplypod/boarding/boss/pod = new() @@ -192,14 +251,8 @@ GLOBAL_VAR_INIT(boarding_spawn_total, 1) boss.parent_ship = source_ship context.finalize() - // Store references for the pod - pod.target_ship = target_ship - pod.source_ship = source_ship - pod.boarder_ref = WEAKREF(boss) - - // Create the landing zone - this handles the whole falling animation - new /obj/effect/pod_landingzone/boarding(target_turf, pod, target_ship, source_ship) - + boarding_pod_send(pod, boss, target_turf, target_ship, source_ship) + on_boss?.Invoke(boss) return boss /** diff --git a/voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_corpses.dm b/voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_corpses.dm index 441ce006666..8cb174b72ea 100644 --- a/voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_corpses.dm +++ b/voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_corpses.dm @@ -168,7 +168,9 @@ outfit = /datum/outfit/piratecorpse/faction/lustrous /obj/effect/mob_spawn/corpse/human/pirate/faction/lustrous/special(mob/living/carbon/human/spawned_human) - // Prevent the ethereal heart's crystal revival mechanic from reviving NPC pirate corpses + // Only for bodies that start dead: the corpse a basic lustrous pirate leaves, and appearance dummies. A + // clientless prop revived by its crystal would be nobody. Living lustrous pirates are human NPCs that + // take only this spawner's look, never this proc, and crystallise as players do (defaults PI-6). ADD_TRAIT(spawned_human, TRAIT_CANNOT_CRYSTALIZE, TRAIT_GENERIC) return ..() diff --git a/voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_humans.dm b/voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_humans.dm new file mode 100644 index 00000000000..060544beed2 --- /dev/null +++ b/voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_humans.dm @@ -0,0 +1,834 @@ +/** + * # Faction pirates as human NPCs + * + * The seven pirate factions (Silverscale, the skeletons, the grey tide, the Lustrous, Interdyne, the IRS + * and the medieval knights) as real human NPCs (voidcrew/modules/human_npcs/): real bodies with real + * crit, stamina, wounds, cuffs, bleeding and revival, holding the real weapons they fight with. One type + * per faction and rank, /mob/living/carbon/human/npc/faction_pirate//, + * used wherever a faction pirate turns up: + * - aboard NPC pirate ships, as the hull's crew and the boarders it sends (phase B). The ship enlists them + * in a /datum/pirate_crew (pirate_crew.dm); boarders are dressed from the faction's boarding table; + * a boarding boss learns its hull (parent_ship); + * - in ruins and on planets, scattered by the pirate zone markers (voidcrew/modules/loot/themes/plunder.dm), + * and as kill contract targets and their guards (voidcrew/modules/missions/missions/recovery.dm) + * (phase C). There they belong to the planet's alliance like the fauna, and a contract target pays its + * cash once per contract (npc_payout_mission). + * Their AI is PR #500's pirate crew on the human base (pirate_crew_human.dm), crew or no crew: one with no + * crew fights what it sees and calls out who it spotted. + * + * Every faction keeps its look, lines and guns: + * - the look (species, hair, skin) comes from the faction corpse spawner (npc_look), the clothes and + * weapons from the faction's outfit table (human_npc_outfits_pirates.dm), picked by crew_role and rank; + * in vacuum the faction's own space suit, whatever outfit it wears; + * - toughness comes from what they wear plus npc_damage_taken by rank (captains 0.8, bosses 0.6), never + * from a health pool; + * - captains and bosses carry a real stimulant and inject it when their fight starts (the old stun + * immunity), Davy Jones drinks from a flask of cursed grog (his old regeneration), the Black Knight has + * tg's hulk and gigantism (his size and his shrugging off batons), the Radiant One is a real ethereal; + * - medieval footsoldiers, the warlord and the Black Knight refuse guns (TRAIT_NOGUNS), as before; + * - the designed loot rolls (the zone ladder, the red-zone 25% piece, boss uniques, the plunder of 25, 300, + * 1000 or 3000 credits) drop once at death, by the zone it belongs to (npc_home_zone()). What they wear + * and hold is locked to the body (D3) and never loot. A ship captain's key is not gear: it drops when he + * dies. + * + * Their ID card carries their name, so one whose helmet hides its face is still "Silverscale Duelist" and + * not "Unknown". It is locked gear like the rest and opens nothing. + */ + +/// What a faction pirate says when things happen to its body (human_npc_barks.dm). "spot" is said when one +/// with no crew picks someone new to fight; a crew calls out its own (pirate_crew.dm). +/datum/human_npc_voice/faction_pirate + lines = list( + PIRATE_BARK_SPOT = list("There!", "Over here!", "Found one!", "Contact!"), + HUMAN_NPC_BARK_DOWNED = list("I'm hit!", "Agh! Man down!", "Not like this..."), + HUMAN_NPC_BARK_PLEAD = list("Don't... don't.", "Quarter... give quarter..."), + HUMAN_NPC_BARK_RECOVER = list("Still breathing.", "Back on my feet."), + HUMAN_NPC_BARK_CUFFED = list("The captain will hear of this.", "Get these off me!", "You'll hang for this."), + HUMAN_NPC_BARK_SLIPPING = list("Almost..."), + HUMAN_NPC_BARK_PULLED_FREE = list("Hands off!"), + HUMAN_NPC_BARK_SURRENDER = list("Alright! Alright, I'm done!", "Don't shoot! I yield!", "Quarter! I'm out!"), + ) + emotes = list( + HUMAN_NPC_BARK_DOWNED = list("collapses."), + "stimulant" = list("jabs a needle into their neck."), + "drink" = list("takes a long pull from a battered flask."), + ) + chances = list(PIRATE_BARK_SPOT = 60) + +/datum/human_npc_voice/faction_pirate/skeleton + lines = list( + PIRATE_BARK_SPOT = list("There ye are!", "I see ye!", "Over here, lads!"), + HUMAN_NPC_BARK_DOWNED = list("Back to the deep..."), + HUMAN_NPC_BARK_PLEAD = list("Mercy, matey..."), + HUMAN_NPC_BARK_RECOVER = list("The dead don't stay down."), + HUMAN_NPC_BARK_CUFFED = list("Irons won't hold the dead."), + HUMAN_NPC_BARK_SLIPPING = list("Almost..."), + HUMAN_NPC_BARK_PULLED_FREE = list("Unhand me!"), + ) + emotes = list( + HUMAN_NPC_BARK_DOWNED = list("clatters to the floor."), + "stimulant" = list("jabs a needle between their ribs."), + "drink" = list("takes a long pull from a battered flask."), + ) + +/datum/human_npc_voice/faction_pirate/grey + lines = list( + PIRATE_BARK_SPOT = list("Get 'em!", "That one, there!", "Over here!"), + HUMAN_NPC_BARK_DOWNED = list("I want my toolbox..."), + HUMAN_NPC_BARK_PLEAD = list("I didn't do nothing!"), + HUMAN_NPC_BARK_RECOVER = list("Robust!"), + HUMAN_NPC_BARK_CUFFED = list("I didn't take nothing!"), + HUMAN_NPC_BARK_SLIPPING = list("Almost..."), + HUMAN_NPC_BARK_PULLED_FREE = list("Hands off!"), + HUMAN_NPC_BARK_SURRENDER = list("Okay! Okay! I give!", "Not the face! I'm done!", "I didn't do nothing! I give up!"), + ) + +/datum/human_npc_voice/faction_pirate/irs + lines = list( + PIRATE_BARK_SPOT = list("There's the taxpayer!", "Stop right there.", "You're overdue."), + HUMAN_NPC_BARK_DOWNED = list("This will be... noted..."), + HUMAN_NPC_BARK_PLEAD = list("I'm only an auditor..."), + HUMAN_NPC_BARK_RECOVER = list("Where were we."), + HUMAN_NPC_BARK_CUFFED = list("Obstruction of an audit. Noted."), + HUMAN_NPC_BARK_SLIPPING = list("Almost..."), + HUMAN_NPC_BARK_PULLED_FREE = list("Hands off!"), + HUMAN_NPC_BARK_SURRENDER = list("I'm unarmed! I'm an accountant!", "Fine! The audit is suspended!", "I yield! Pending review!"), + ) + +/datum/human_npc_voice/faction_pirate/medieval + lines = list( + PIRATE_BARK_SPOT = list("Have at thee!", "There, the coward!", "Halt!"), + HUMAN_NPC_BARK_DOWNED = list("I am slain!", "'Tis but a scratch..."), + HUMAN_NPC_BARK_PLEAD = list("Quarter! I beg quarter!"), + HUMAN_NPC_BARK_RECOVER = list("I yet stand!"), + HUMAN_NPC_BARK_CUFFED = list("Thou shalt pay for this dishonour."), + HUMAN_NPC_BARK_SLIPPING = list("Almost..."), + HUMAN_NPC_BARK_PULLED_FREE = list("Unhand me, cur!"), + HUMAN_NPC_BARK_SURRENDER = list("I yield! I yield!", "Quarter! I beg quarter!"), + ) + +/** + * When a pirate with no crew gives up (human_npc_surrender.dm): a ruin's, a planet's or a contract's. A crew + * aboard a ship fights on together, and its ship decides what is left of it (pirate_crew.dm). Bosses never + * give up; captains seldom. + */ +/datum/human_npc_surrender/faction_pirate + chance = 50 + retry_chance = 20 + +/datum/human_npc_surrender/faction_pirate/hurt_enough(mob/living/carbon/human/npc/npc) + if(npc.npc_rank >= HUMAN_NPC_RANK_BOSS) + return FALSE + return ..() + +/datum/human_npc_surrender/faction_pirate/odds(mob/living/carbon/human/npc/npc, list/hostiles, list/allies, first) + . = ..() + if(npc.npc_rank >= HUMAN_NPC_RANK_ELITE) + . = round(. / 2) + +/// Knights and their kind: they beg quarter less often, and never run. +/datum/human_npc_surrender/faction_pirate/stubborn + chance = 30 + retry_chance = 10 + flees = FALSE + +/// Auditors and tiders: one gun on them is enough, and they run when they can. +/datum/human_npc_surrender/faction_pirate/meek + chance = 70 + retry_chance = 35 + hostiles_needed = 1 + health_share = 0.5 + +/mob/living/carbon/human/npc/faction_pirate + name = "pirate" + faction = list(FACTION_PIRATE) + ai_controller = /datum/ai_controller/basic_controller/pirate_crew/human + npc_voice = /datum/human_npc_voice/faction_pirate + npc_target_stat = HUMAN_NPC_FINISHES_DOWNED + // Read only while it has no crew (pirate_crew_human.dm) + npc_surrender = /datum/human_npc_surrender/faction_pirate + /// SHIP_CREW_ROLE_MELEE or SHIP_CREW_ROLE_GUNNER: which of its faction's outfits a regular wears + var/crew_role + /// Its faction's table with a sealed suit added, for boarders (an outfit table typepath) + var/datum/human_npc_outfit_table/boarding_outfit_table + /// One line about it on examine, in character + var/crew_desc + /// What this faction shouts when its ship's crew goes on alert (pirate_crew.dm). Null: the generic lines. + var/list/crew_alert_lines + /// What it shouts when it spots someone. Null: the generic lines. + var/list/crew_spot_lines + /// The ZONE_* its spawn order dressed it for, or null if it was made without one + var/npc_dressed_zone + + // ===== Designed loot, as the basic faction pirates roll it (faction_pirate_mobs.dm) ===== + /// Always dropped + var/list/loot_pool + /// Each rolled once at spawn against npc_ladder_red_drop() + var/list/rare_loot_pool + /// What the rare roll gave + var/list/rolled_rare_loot + /// With any of these set, it drops one zone-laddered weapon (pirate_roll_ladder_weapon()) + var/list/random_loot = list( + /obj/item/knife/combat/survival, + /obj/item/spear, + /obj/item/melee/baseball_bat, + ) + /// One of these is always dropped + var/list/random_loot_2 = list( + /obj/item/storage/medkit/regular, + /obj/item/storage/toolbox/mechanical, + /obj/item/flashlight/seclite, + /obj/item/reagent_containers/hypospray/medipen, + /obj/item/stack/telecrystal, + ) + /// A captain whose zone ladder drops a melee weapon (Silverscale, Lustrous and Interdyne captains) + var/captain_ladder_melee = FALSE + /// Weakref to the /datum/mission whose named target this is; its death cash pays only if that contract + /// can still claim it (/datum/mission/proc/claim_boss_cash()) + var/datum/weakref/npc_payout_mission + + // ===== Elites and bosses ===== + /// The medipen it injects when its fight starts, or null. Elites and bosses get one by rank. + var/obj/item/reagent_containers/hypospray/medipen/stimulant_type + /// The NPC hull this is the boarding boss of; killing or taking it disables the hull + var/obj/structure/overmap/ship/npc/pirate/parent_ship + +/mob/living/carbon/human/npc/faction_pirate/Initialize(mapload, datum/human_npc_order/order) + switch(npc_rank) + if(HUMAN_NPC_RANK_ELITE) + // A type that sets its own toughness keeps it + if(npc_damage_taken == 1) + npc_damage_taken = SHIP_CREW_ELITE_DAMAGE_TAKEN + stimulant_type ||= /obj/item/reagent_containers/hypospray/medipen/stimpack/traitor + if(HUMAN_NPC_RANK_BOSS) + if(npc_damage_taken == 1) + npc_damage_taken = SHIP_CREW_BOSS_DAMAGE_TAKEN + . = ..() + npc_dressed_zone = order?.resolve_zone() + // Where it was put: a pirate with no crew keeps near it (pirate_crew_human.dm) + if(istype(ai_controller)) + ai_controller.set_blackboard_key(BB_PIRATE_CREWLESS_HOME, get_turf(src)) + // tg's Initialize gave it the planet's alliance before it was dressed; an ordered faction list may + // have replaced its factions since, so it rejoins here. Off a planet this does nothing. + inherit_planetary_faction(src) + rolled_rare_loot = list() + for(var/item_type in rare_loot_pool) + if(npc_ladder_red_drop()) + rolled_rare_loot += item_type + crew_issue_id() + if(stimulant_type) + var/obj/item/stimulant = new stimulant_type(src) + if(!crew_give(stimulant)) + qdel(stimulant) + +/mob/living/carbon/human/npc/faction_pirate/Destroy() + parent_ship = null + npc_payout_mission = null + return ..() + +// Natives of the planet they are found on, like the fauna they share it with. +/mob/living/carbon/human/npc/faction_pirate/should_inherit_planetary_faction() + return TRUE + +// In vacuum, the faction's own space suit, even over an outfit it was handed directly. +/mob/living/carbon/human/npc/faction_pirate/npc_fit_outfit_to_site(outfit, datum/human_npc_outfit_table/table) + if(isnull(table) && ispath(npc_outfit_table, /datum/human_npc_outfit_table)) + table = human_npc_singleton(npc_outfit_table) + return ..(outfit, table) + +/mob/living/carbon/human/npc/faction_pirate/examine(mob/user) + . = ..() + if(crew_desc && stat != DEAD) + . += span_notice(crew_desc) + +/// An ID card with its name on it, so a helmet that hides its face doesn't make it "Unknown". +/mob/living/carbon/human/npc/faction_pirate/proc/crew_issue_id() + if(wear_id) + return + var/obj/item/card/id/advanced/black/card = new(src) + card.registered_name = real_name + card.assignment = real_name + card.update_label() + if(!equip_to_slot_if_possible(card, ITEM_SLOT_ID, disable_warning = TRUE)) + qdel(card) + return + npc_lock_item(card) + +/** + * Puts `thing` somewhere on its body it can take it from: a free pocket, else its backpack or belt. + * Locks or issues it by the gear rules (a ship key isn't gear, a medipen is a consumable). Returns TRUE + * if it is on the body; FALSE leaves it where it was, for the caller to deal with. + */ +/mob/living/carbon/human/npc/faction_pirate/proc/crew_give(obj/item/thing) + if(QDELETED(thing)) + return FALSE + if(equip_to_slot_if_possible(thing, ITEM_SLOT_LPOCKET, disable_warning = TRUE) || equip_to_slot_if_possible(thing, ITEM_SLOT_RPOCKET, disable_warning = TRUE)) + npc_lock_item(thing) + return TRUE + for(var/obj/item/container in list(back, belt)) + if(container.atom_storage?.attempt_insert(thing, src, override = TRUE, messages = FALSE)) + npc_lock_item(thing) + return TRUE + return FALSE + +/** + * Puts something that isn't gear (its ship's key) in a pocket, where a crew that has it cuffed or down can + * pick it out (the strip menu, human_npc.dm). A full pocket is emptied into its bag or belt first. Falls + * back to crew_give() if neither pocket can be had. + */ +/mob/living/carbon/human/npc/faction_pirate/proc/crew_pocket(obj/item/thing) + if(QDELETED(thing)) + return FALSE + for(var/slot in list(ITEM_SLOT_LPOCKET, ITEM_SLOT_RPOCKET)) + if(equip_to_slot_if_possible(thing, slot, disable_warning = TRUE)) + npc_lock_item(thing) + return TRUE + for(var/slot in list(ITEM_SLOT_LPOCKET, ITEM_SLOT_RPOCKET)) + var/obj/item/in_pocket = get_item_by_slot(slot) + if(isnull(in_pocket)) + continue + for(var/obj/item/container in list(back, belt)) + if(!container.atom_storage?.attempt_insert(in_pocket, src, override = TRUE, messages = FALSE)) + continue + if(equip_to_slot_if_possible(thing, slot, disable_warning = TRUE)) + npc_lock_item(thing) + return TRUE + break + return crew_give(thing) + +/** + * The zone it belongs to, for zone-laddered loot: its spawn context's, which may have resolved after it + * was made (a ruin loading before its planet registered), else the zone it was dressed for, else where + * it stands. + */ +/mob/living/carbon/human/npc/faction_pirate/proc/npc_home_zone() + return npc_spawn_context?.zone_type || npc_dressed_zone || npc_spawn_zone() + +// ===== Death and its designed drops ===== + +/mob/living/carbon/human/npc/faction_pirate/npc_roll_death_loot() + var/zone = npc_home_zone() + . = list() + if(length(loot_pool)) + . += loot_pool + if(length(rolled_rare_loot)) + . += rolled_rare_loot + if(length(random_loot)) + . += pirate_roll_ladder_weapon(zone) + if(captain_ladder_melee) + if(zone == ZONE_YELLOW) + . += /obj/item/claymore/shortsword + else if(zone == ZONE_RED) + . += pick(npc_ladder_yellow_melee()) + if(length(random_loot_2)) + . += pick(random_loot_2) + +// A named contract target's cash goes to the contract once: if the contract is gone or has already paid, +// the body carries none. +/mob/living/carbon/human/npc/faction_pirate/npc_drop_death_loot() + if(!npc_loot_dropped && npc_death_cash > 0 && npc_payout_mission) + var/datum/mission/mission = npc_payout_mission.resolve() + if(!mission?.claim_boss_cash()) + npc_death_cash = 0 + return ..() + +/mob/living/carbon/human/npc/faction_pirate/death(gibbed) + var/was_alive = stat != DEAD + . = ..() + if(was_alive && stat == DEAD) + crew_report_boss_down() + +/// The hull this boarded for hears its boss is down (PI-22: the boss's fall disables the hull). +/mob/living/carbon/human/npc/faction_pirate/proc/crew_report_boss_down() + var/datum/ai_controller/npc_ship/controller = parent_ship?.ai_controller + if(istype(controller)) + SEND_SIGNAL(controller, COMSIG_BOARDING_BOSS_KILLED, src) + +// ===== The factions ===== + +// ----- Silverscale (aristocratic lizards) ----- + +/mob/living/carbon/human/npc/faction_pirate/silverscale + npc_name = "Silverscale Pirate" + crew_desc = "An aristocratic lizard pirate demanding tribute from lesser beings." + npc_look = /obj/effect/mob_spawn/corpse/human/pirate/faction/silverscale + npc_outfit_table = /datum/human_npc_outfit_table/pirate/silverscale + boarding_outfit_table = /datum/human_npc_outfit_table/pirate/silverscale/boarding + +/mob/living/carbon/human/npc/faction_pirate/silverscale/Initialize(mapload, datum/human_npc_order/order) + // The rank and file may be carrying a fish (as the basic duelists and marksmen do) + if(crew_role) + random_loot_2 = list(/obj/item/storage/medkit/regular, /obj/item/storage/toolbox/mechanical, random_fish_type()) + return ..() + +/mob/living/carbon/human/npc/faction_pirate/silverscale/melee + npc_name = "Silverscale Duelist" + crew_desc = "A noble lizard trained in the art of the blade." + crew_role = SHIP_CREW_ROLE_MELEE + npc_death_cash = 300 + +/mob/living/carbon/human/npc/faction_pirate/silverscale/ranged + npc_name = "Silverscale Marksman" + crew_desc = "A noble lizard with impeccable aim." + crew_role = SHIP_CREW_ROLE_GUNNER + npc_death_cash = 25 + +/mob/living/carbon/human/npc/faction_pirate/silverscale/captain + npc_name = "Silverscale Noble" + crew_desc = "A high-born lizard of impeccable breeding and ruthless ambition." + npc_rank = HUMAN_NPC_RANK_ELITE + random_loot = null + captain_ladder_melee = TRUE + npc_death_cash = 1000 + +/mob/living/carbon/human/npc/faction_pirate/silverscale/boss + npc_name = "Silverscale Highlord" + crew_desc = "The supreme ruler of the Silverscale noble house. A master duelist who has slain countless challengers." + npc_rank = HUMAN_NPC_RANK_BOSS + npc_always_site = HUMAN_NPC_SITE_BAD_AIR + stimulant_type = /obj/item/reagent_containers/hypospray/medipen/stimulants + random_loot = null + random_loot_2 = null + loot_pool = list(/obj/item/clothing/suit/hooded/cloak/drake, /obj/item/clothing/head/hooded/cloakhood/drake) + npc_death_cash = 3000 + +// ----- Skeleton (the Flying Dutchman) ----- + +/mob/living/carbon/human/npc/faction_pirate/skeleton + npc_name = "Skeleton Pirate" + crew_desc = "Yarr! An undead scourge of the space lanes." + npc_look = /obj/effect/mob_spawn/corpse/human/pirate/faction/skeleton + npc_outfit_table = /datum/human_npc_outfit_table/pirate/skeleton + boarding_outfit_table = /datum/human_npc_outfit_table/pirate/skeleton/boarding + npc_voice = /datum/human_npc_voice/faction_pirate/skeleton + // The dead don't give up + npc_surrender = null + crew_alert_lines = list( + "All hands! Boarders!", + "Fresh crew coming aboard!", + "They'll fit right in. Eventually.", + ) + crew_spot_lines = list( + "There ye are!", + "I see ye!", + "Over here, lads!", + ) + +/mob/living/carbon/human/npc/faction_pirate/skeleton/melee + npc_name = "Skeleton Swashbuckler" + crew_desc = "A skeletal swordsman that refuses to stay dead." + crew_role = SHIP_CREW_ROLE_MELEE + npc_death_cash = 300 + +/mob/living/carbon/human/npc/faction_pirate/skeleton/ranged + npc_name = "Skeleton Gunner" + crew_desc = "A skeletal marksman with hollow eyes." + crew_role = SHIP_CREW_ROLE_GUNNER + npc_death_cash = 25 + +/mob/living/carbon/human/npc/faction_pirate/skeleton/captain + npc_name = "Skeleton Captain" + crew_desc = "The terrifying undead commander of the Flying Dutchman." + npc_rank = HUMAN_NPC_RANK_ELITE + loot_pool = list(/obj/item/gun/energy/laser) + random_loot = null + npc_death_cash = 1000 + +/// Davy Jones drinks cursed grog from the flask in his pocket when he is hurt (his old regeneration, +/// defaults PI-5). +/mob/living/carbon/human/npc/faction_pirate/skeleton/boss + npc_name = "Davy Jones" + crew_desc = "Captain of the Flying Dutchman. His cursed compass always points to the greatest treasure... or the nearest victim." + npc_rank = HUMAN_NPC_RANK_BOSS + npc_always_site = HUMAN_NPC_SITE_BAD_AIR + stimulant_type = /obj/item/reagent_containers/hypospray/medipen/stimulants + random_loot = null + random_loot_2 = null + loot_pool = list(/obj/item/gun/ballistic/shotgun/hook) + npc_death_cash = 3000 + +// ----- Grey Tide (rogue assistants) ----- + +/mob/living/carbon/human/npc/faction_pirate/grey + npc_name = "Grey Tider" + crew_desc = "A former assistant turned space pirate. Robust." + npc_look = /obj/effect/mob_spawn/corpse/human/pirate/faction/grey + npc_outfit_table = /datum/human_npc_outfit_table/pirate/grey + boarding_outfit_table = /datum/human_npc_outfit_table/pirate/grey/boarding + npc_voice = /datum/human_npc_voice/faction_pirate/grey + npc_surrender = /datum/human_npc_surrender/faction_pirate/meek + crew_alert_lines = list( + "Someone's on the ship!", + "Who let them in?", + "They're after our stuff!", + ) + crew_spot_lines = list( + "Get 'em!", + "That one, there!", + "Over here!", + ) + +/mob/living/carbon/human/npc/faction_pirate/grey/melee + crew_desc = "Armed with a toolbox and bad intentions." + crew_role = SHIP_CREW_ROLE_MELEE + npc_death_cash = 300 + +/mob/living/carbon/human/npc/faction_pirate/grey/ranged + npc_name = "Grey Tider Gunner" + crew_desc = "An assistant with a gun. Uh oh." + crew_role = SHIP_CREW_ROLE_GUNNER + npc_death_cash = 25 + +/mob/living/carbon/human/npc/faction_pirate/grey/captain + npc_name = "Tidemaster" + crew_desc = "If he's on your shift, the Captain does not have his spare." + npc_rank = HUMAN_NPC_RANK_ELITE + loot_pool = list(/obj/item/storage/toolbox/syndicate) + random_loot = null + npc_death_cash = 1000 + +/mob/living/carbon/human/npc/faction_pirate/grey/boss + npc_name = "The Robust One" + crew_desc = "The ultimate assistant. The greyest tider to ever live. Their toolbox has seen things." + npc_rank = HUMAN_NPC_RANK_BOSS + npc_always_site = HUMAN_NPC_SITE_BAD_AIR + stimulant_type = /obj/item/reagent_containers/hypospray/medipen/stimulants + random_loot = null + random_loot_2 = null + loot_pool = list(/obj/item/stack/telecrystal/five) + rare_loot_pool = list(/obj/item/storage/toolbox/mechanical/old/clean) + npc_death_cash = 3000 + +/mob/living/carbon/human/npc/faction_pirate/grey/boss/Initialize(mapload, datum/human_npc_order/order) + . = ..() + AddComponent(/datum/component/hv_finisher_user, /datum/hv_finisher/robust_one) + +// ----- Lustrous (mutated ethereals) ----- + +// Real ethereals: they glow by their species, and a dead one's heart crystallises and revives it as a +// player's does, unless the crystal is broken (defaults PI-6). +/mob/living/carbon/human/npc/faction_pirate/lustrous + npc_name = "Lustrous Pirate" + crew_desc = "A mutated ethereal obsessed with bluespace crystals." + npc_look = /obj/effect/mob_spawn/corpse/human/pirate/faction/lustrous + npc_outfit_table = /datum/human_npc_outfit_table/pirate/lustrous + boarding_outfit_table = /datum/human_npc_outfit_table/pirate/lustrous/boarding + +/mob/living/carbon/human/npc/faction_pirate/lustrous/melee + npc_name = "Lustrous Scintillant" + crew_desc = "A crystalline being with a sharp blade." + crew_role = SHIP_CREW_ROLE_MELEE + npc_death_cash = 300 + +/mob/living/carbon/human/npc/faction_pirate/lustrous/ranged + npc_name = "Lustrous Coruscant" + crew_desc = "A crystalline being channeling energy through strange weapons." + crew_role = SHIP_CREW_ROLE_GUNNER + npc_death_cash = 25 + +/mob/living/carbon/human/npc/faction_pirate/lustrous/captain + npc_name = "Lustrous Radiant" + crew_desc = "A blindingly bright ethereal, the leader of their crystalline kind." + npc_rank = HUMAN_NPC_RANK_ELITE + random_loot = null + captain_ladder_melee = TRUE + npc_death_cash = 1000 + +/mob/living/carbon/human/npc/faction_pirate/lustrous/boss + npc_name = "The Radiant One" + crew_desc = "A blindingly luminous ethereal. The crystalline matrix of their body phases in and out of realspace." + npc_rank = HUMAN_NPC_RANK_BOSS + npc_always_site = HUMAN_NPC_SITE_BAD_AIR + stimulant_type = /obj/item/reagent_containers/hypospray/medipen/stimulants + random_loot = null + random_loot_2 = null + loot_pool = list(/obj/item/grenade/gas_crystal/nitrous_oxide_crystal) + rare_loot_pool = list(/obj/item/cain_and_abel) + npc_death_cash = 3000 + +// ----- Interdyne (ex-pharmacists) ----- + +/mob/living/carbon/human/npc/faction_pirate/interdyne + npc_name = "Interdyne Pirate" + crew_desc = "A former pharmaceutical employee turned bioterrorist." + npc_look = /obj/effect/mob_spawn/corpse/human/pirate/faction/interdyne + npc_outfit_table = /datum/human_npc_outfit_table/pirate/interdyne + boarding_outfit_table = /datum/human_npc_outfit_table/pirate/interdyne/boarding + +/mob/living/carbon/human/npc/faction_pirate/interdyne/melee + npc_name = "Interdyne Enforcer" + crew_desc = "Enforces pharmaceutical compliance with surgical precision." + crew_role = SHIP_CREW_ROLE_MELEE + npc_death_cash = 300 + +/mob/living/carbon/human/npc/faction_pirate/interdyne/ranged + npc_name = "Interdyne Pharmacist" + crew_desc = "Dispenses death instead of medicine." + crew_role = SHIP_CREW_ROLE_GUNNER + npc_death_cash = 25 + +/mob/living/carbon/human/npc/faction_pirate/interdyne/captain + npc_name = "Interdyne Director" + crew_desc = "The head of this rogue pharmaceutical operation." + npc_rank = HUMAN_NPC_RANK_ELITE + random_loot = null + captain_ladder_melee = TRUE + npc_death_cash = 1000 + +/mob/living/carbon/human/npc/faction_pirate/interdyne/boss + npc_name = "Director Prime" + crew_desc = "The head of all Interdyne black site operations. Their hypospray contains experimental compounds." + npc_rank = HUMAN_NPC_RANK_BOSS + npc_always_site = HUMAN_NPC_SITE_BAD_AIR + stimulant_type = /obj/item/reagent_containers/hypospray/medipen/stimulants + random_loot = null + random_loot_2 = null + loot_pool = list(/obj/item/reagent_containers/hypospray/combat, /obj/item/gun/syringe/syndicate, /obj/item/grenade/gluon) + npc_death_cash = 3000 + +// ----- IRS (tax collectors) ----- + +/mob/living/carbon/human/npc/faction_pirate/irs + npc_name = "IRS Agent" + crew_desc = "The only thing certain in life is death and taxes. They're here for both." + faction = list(FACTION_PIRATE, FACTION_IRS) + npc_look = /obj/effect/mob_spawn/corpse/human/pirate/faction/irs + npc_outfit_table = /datum/human_npc_outfit_table/pirate/irs + boarding_outfit_table = /datum/human_npc_outfit_table/pirate/irs/boarding + npc_voice = /datum/human_npc_voice/faction_pirate/irs + npc_surrender = /datum/human_npc_surrender/faction_pirate/meek + crew_alert_lines = list( + "Unscheduled visitors. Begin the audit.", + "Everyone aboard is now under review.", + "Intruders on deck. Find them.", + ) + crew_spot_lines = list( + "There's the taxpayer!", + "Stop right there.", + "You're overdue.", + ) + +/mob/living/carbon/human/npc/faction_pirate/irs/melee + npc_name = "IRS Enforcer" + crew_desc = "Collects taxes the hard way." + crew_role = SHIP_CREW_ROLE_MELEE + npc_death_cash = 300 + +/mob/living/carbon/human/npc/faction_pirate/irs/ranged + crew_desc = "Armed and ready to collect." + crew_role = SHIP_CREW_ROLE_GUNNER + npc_death_cash = 25 + +/mob/living/carbon/human/npc/faction_pirate/irs/captain + npc_name = "IRS Head Auditor" + crew_desc = "The head of tax enforcement. Nobody escapes their audits." + npc_rank = HUMAN_NPC_RANK_ELITE + loot_pool = list(/obj/item/gun/energy/laser) + random_loot = null + npc_death_cash = 1000 + +/mob/living/carbon/human/npc/faction_pirate/irs/boss + npc_name = "Chief Auditor" + crew_desc = "The supreme authority of the Space IRS. No one escapes their audits. NO ONE." + npc_rank = HUMAN_NPC_RANK_BOSS + npc_always_site = HUMAN_NPC_SITE_BAD_AIR + // Carried in the outfit: the chief has no bag to put one in + stimulant_type = null + random_loot = null + random_loot_2 = null + loot_pool = list(/obj/item/gun/energy/laser, /obj/item/storage/bag/money/dutchmen) + npc_death_cash = 3000 + +// ----- Medieval (space warmongers) ----- + +/mob/living/carbon/human/npc/faction_pirate/medieval + npc_name = "Medieval Pirate" + crew_desc = "A space-faring knight who somehow operates a starship." + npc_look = /obj/effect/mob_spawn/corpse/human/pirate/faction/medieval + npc_outfit_table = /datum/human_npc_outfit_table/pirate/medieval + boarding_outfit_table = /datum/human_npc_outfit_table/pirate/medieval/boarding + npc_voice = /datum/human_npc_voice/faction_pirate/medieval + npc_surrender = /datum/human_npc_surrender/faction_pirate/stubborn + crew_alert_lines = list( + "To arms! Intruders!", + "Who dares board us?", + "Defend the ship!", + ) + crew_spot_lines = list( + "Have at thee!", + "There, the coward!", + "Halt!", + ) + /// Hates guns and throws them hard (footsoldiers, the warlord and the Black Knight; not the crossbowmen) + var/refuses_guns = FALSE + +/mob/living/carbon/human/npc/faction_pirate/medieval/Initialize(mapload, datum/human_npc_order/order) + . = ..() + if(refuses_guns) + add_traits(list(TRAIT_NOGUNS, TRAIT_TOSS_GUN_HARD), INNATE_TRAIT) + +/mob/living/carbon/human/npc/faction_pirate/medieval/melee + npc_name = "Medieval Footsoldier" + crew_desc = "A knight who refuses to use guns. Honorable." + crew_role = SHIP_CREW_ROLE_MELEE + refuses_guns = TRUE + npc_death_cash = 300 + +/mob/living/carbon/human/npc/faction_pirate/medieval/ranged + npc_name = "Medieval Crossbowman" + crew_desc = "At least crossbows are period-appropriate. Sort of." + crew_role = SHIP_CREW_ROLE_GUNNER + npc_death_cash = 25 + +/// The warlord: plate armour and a stimulant where the basic mob had stun immunity (defaults PI-4). +/mob/living/carbon/human/npc/faction_pirate/medieval/captain + npc_name = "Medieval Warlord" + crew_desc = "A hulking brute of a knight. Massive, and very angry." + npc_rank = HUMAN_NPC_RANK_ELITE + refuses_guns = TRUE + stimulant_type = /obj/item/reagent_containers/hypospray/medipen/stimulants + loot_pool = list(/obj/item/fireaxe) + random_loot = null + npc_death_cash = 1000 + +/// The Black Knight: tg's hulk (stun and shove immune until he drops into crit) and gigantism (his size). +/mob/living/carbon/human/npc/faction_pirate/medieval/boss + npc_name = "The Black Knight" + crew_desc = "A massive armored warrior. 'Tis but a scratch!' No really, they refuse to die." + npc_rank = HUMAN_NPC_RANK_BOSS + npc_damage_taken = 0.5 + npc_always_site = HUMAN_NPC_SITE_BAD_AIR + refuses_guns = TRUE + random_loot = null + random_loot_2 = null + loot_pool = list(/obj/item/claymore/shortsword, /obj/item/shield/kite) + npc_death_cash = 3000 + +/mob/living/carbon/human/npc/faction_pirate/medieval/boss/Initialize(mapload, datum/human_npc_order/order) + . = ..() + dna.add_mutation(/datum/mutation/hulk, MUTATION_SOURCE_MUTATOR) + dna.add_mutation(/datum/mutation/gigantism, MUTATION_SOURCE_MUTATOR) + AddComponent(/datum/component/hv_finisher_user, /datum/hv_finisher/black_knight) + +// ===== Boss kit ===== + +/// Davy Jones's flask. Locked to him like the rest of his kit (D3). +/obj/item/reagent_containers/cup/glass/flask/davy_jones + name = "battered flask" + desc = "A dented pewter flask. Whatever is in it smells of the deep." + list_reagents = list(/datum/reagent/medicine/omnizine/cursed_grog = 40) + +/** + * Cursed grog: knits the flesh of the undead while it is in their blood, with a cold blue glow. To the + * living it is brine and bad rum, so blood drawn from Davy Jones heals nobody. Never synthesised, never + * overdosed. Like any reagent it can be purged, and the flask runs dry. + */ +/datum/reagent/medicine/omnizine/cursed_grog + name = "Cursed Grog" + description = "Sea water and something older. It keeps the dead from staying dead." + color = "#2a4a7a" + taste_description = "brine and old rum" + healing = 3 + overdose_threshold = 0 + chemical_flags = NONE + +/datum/reagent/medicine/omnizine/cursed_grog/on_mob_life(mob/living/carbon/affected_mob, seconds_per_tick, times_fired) + healing = (affected_mob.mob_biotypes & MOB_UNDEAD) ? initial(healing) : 0 + return ..() + +/datum/reagent/medicine/omnizine/cursed_grog/on_mob_metabolize(mob/living/affected_mob) + . = ..() + affected_mob.add_filter("cursed_grog", 2, outline_filter(1, "#4488FF")) + +/datum/reagent/medicine/omnizine/cursed_grog/on_mob_end_metabolize(mob/living/affected_mob) + . = ..() + affected_mob.remove_filter("cursed_grog") + +/// The Robust One's toolbox: the old blue toolbox, with the telecrystals inside that make it hit harder. +/obj/item/storage/toolbox/mechanical/old/clean/robust_one + attack_verb_continuous = list("ROBUSTS") + attack_verb_simple = list("ROBUST") + +/obj/item/storage/toolbox/mechanical/old/clean/robust_one/PopulateContents() + . = ..() + new /obj/item/stack/telecrystal(src, 6) + +/// Davy Jones's cutlass. +/obj/item/claymore/cutlass/davy_jones + attack_verb_continuous = list("curses", "slashes", "cuts") + attack_verb_simple = list("curse", "slash", "cut") + +/// The Black Knight's claymore. +/obj/item/claymore/black_knight + attack_verb_continuous = list("smites", "cleaves", "hews") + attack_verb_simple = list("smite", "cleave", "hew") + +/// The warlord's boarding axe. +/obj/item/fireaxe/boardingaxe/warlord + attack_verb_continuous = list("crushes", "cleaves", "hacks") + attack_verb_simple = list("crush", "cleave", "hack") + +/// An energy cutlass with a boss's own attack verbs. +/obj/item/melee/energy/sword/pirate/boss + /// Verbs while lit + var/list/boss_verbs_continuous = list("eviscerates") + var/list/boss_verbs_simple = list("eviscerate") + +/obj/item/melee/energy/sword/pirate/boss/make_transformable() + AddComponent( \ + /datum/component/transforming, \ + force_on = active_force, \ + throwforce_on = active_throwforce, \ + throw_speed_on = 4, \ + sharpness_on = active_sharpness, \ + hitsound_on = active_hitsound, \ + w_class_on = active_w_class, \ + attack_verb_continuous_on = boss_verbs_continuous, \ + attack_verb_simple_on = boss_verbs_simple, \ + ) + RegisterSignal(src, COMSIG_TRANSFORMING_ON_TRANSFORM, PROC_REF(on_transform)) + +/// The Radiant One's cutlass. +/obj/item/melee/energy/sword/pirate/boss/radiant + boss_verbs_continuous = list("phases through", "slashes") + boss_verbs_simple = list("phase through", "slash") + +// ===== Dressing by role, and for boarding ===== + +// A crewman of the rank and file wears its role's outfits from its faction's table +// (voidcrew/modules/human_npcs/human_npc_outfits_pirates.dm): a duelist the faction's blades, a marksman +// its guns in PR #500's gun weights. Captains and bosses wear their own. +/datum/human_npc_outfit_table/pirate/outfits_for(mob/living/carbon/human/npc/npc, zone) + var/mob/living/carbon/human/npc/faction_pirate/crewman = npc + if(istype(crewman) && crewman.npc_rank == HUMAN_NPC_RANK_REGULAR) + switch(crewman.crew_role) + if(SHIP_CREW_ROLE_MELEE) + if(length(melee) && !gunners_only) + return melee + if(SHIP_CREW_ROLE_GUNNER) + if(length(gunners)) + return gunners + return ..() + +// Boarders cross space and may land in a vented room, so they wear a sealed suit and carry air +// (always_site, human_npc_outfits.dm). Skeletons need neither and are left as they are. +/datum/human_npc_outfit_table/pirate/silverscale/boarding + always_site = HUMAN_NPC_SITE_VACUUM + +/datum/human_npc_outfit_table/pirate/skeleton/boarding + always_site = HUMAN_NPC_SITE_VACUUM + +/datum/human_npc_outfit_table/pirate/grey/boarding + always_site = HUMAN_NPC_SITE_VACUUM + +/datum/human_npc_outfit_table/pirate/lustrous/boarding + always_site = HUMAN_NPC_SITE_VACUUM + +/datum/human_npc_outfit_table/pirate/interdyne/boarding + always_site = HUMAN_NPC_SITE_VACUUM + +/datum/human_npc_outfit_table/pirate/irs/boarding + always_site = HUMAN_NPC_SITE_VACUUM + +/datum/human_npc_outfit_table/pirate/medieval/boarding + always_site = HUMAN_NPC_SITE_VACUUM diff --git a/voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_mobs.dm b/voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_mobs.dm index 4622793770b..081ecec1352 100644 --- a/voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_mobs.dm +++ b/voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_mobs.dm @@ -1,4 +1,5 @@ -// Faction-specific pirate NPC mobs for Voidcrew NPC ships +// Faction-specific pirate NPC basic mobs. NPC ship crews and their boarders are human NPCs now +// (faction_pirate_humans.dm); these stay for ruins, planets and missions until those move (phase C). // Each faction has melee, ranged, and captain variants // All are space-capable (no atmos damage, spacewalk trait) @@ -25,10 +26,6 @@ var/list/crew_alert_lines /// What it shouts when it spots someone. Null uses the generic lines. var/list/crew_spot_lines - /// Weights of the guns a gunner of this faction rolls when it joins a crew (pirate_guns.dm). Null: the default mix. - var/list/crew_gun_weights - /// Keeps its own ranged weapon instead of rolling a gun - var/crew_keeps_gun = FALSE /// Random combat loot - one item is picked at random and added to death drops. var/list/random_loot = list(\ /obj/item/knife/combat/survival,\ @@ -83,6 +80,10 @@ AddElement(/datum/element/death_drops, string_list(death_loot)) /mob/living/basic/trooper/pirate/faction/proc/roll_ladder_weapon(zone, roll = rand(1, 100)) + return pirate_roll_ladder_weapon(zone, roll) + +/// The weapon a faction pirate drops by the zone it fought in, basic or human (faction_pirate_humans.dm). +/proc/pirate_roll_ladder_weapon(zone, roll = rand(1, 100)) switch(zone) if(ZONE_YELLOW) return roll <= 5 ? /obj/item/gun/energy/laser : pick(npc_ladder_yellow_melee()) @@ -636,56 +637,3 @@ ADD_TRAIT(src, TRAIT_PUSHIMMUNE, INNATE_TRAIT) ADD_TRAIT(src, TRAIT_NOGUNS, INNATE_TRAIT) ADD_TRAIT(src, TRAIT_TOSS_GUN_HARD, INNATE_TRAIT) - -// ==================== CREW GUNS ==================== -// What each faction's gunners roll when they join a crew (pirate_guns.dm) - -/mob/living/basic/trooper/pirate/faction/silverscale - crew_gun_weights = list( - /datum/pirate_gun_loadout/energy_gun = 3, - /datum/pirate_gun_loadout/laser_rifle = 2, - /datum/pirate_gun_loadout/pistol = 3, - /datum/pirate_gun_loadout/shotgun = 1, - ) - -/mob/living/basic/trooper/pirate/faction/skeleton - crew_gun_weights = list( - /datum/pirate_gun_loadout/laser_rifle = 1, - /datum/pirate_gun_loadout/pistol = 2, - /datum/pirate_gun_loadout/smg = 2, - /datum/pirate_gun_loadout/shotgun = 3, - ) - -/mob/living/basic/trooper/pirate/faction/grey - crew_gun_weights = list( - /datum/pirate_gun_loadout/energy_gun = 3, - /datum/pirate_gun_loadout/laser_rifle = 3, - /datum/pirate_gun_loadout/smg = 1, - ) - -/mob/living/basic/trooper/pirate/faction/lustrous - crew_gun_weights = list( - /datum/pirate_gun_loadout/energy_gun = 3, - /datum/pirate_gun_loadout/laser_rifle = 3, - /datum/pirate_gun_loadout/pistol = 1, - ) - -/mob/living/basic/trooper/pirate/faction/interdyne - crew_gun_weights = list( - /datum/pirate_gun_loadout/energy_gun = 2, - /datum/pirate_gun_loadout/pistol = 2, - /datum/pirate_gun_loadout/smg = 3, - /datum/pirate_gun_loadout/shotgun = 1, - ) - -/mob/living/basic/trooper/pirate/faction/irs - crew_gun_weights = list( - /datum/pirate_gun_loadout/energy_gun = 1, - /datum/pirate_gun_loadout/pistol = 3, - /datum/pirate_gun_loadout/smg = 2, - /datum/pirate_gun_loadout/shotgun = 2, - ) - -// Crossbows suit them -/mob/living/basic/trooper/pirate/faction/medieval - crew_keeps_gun = TRUE diff --git a/voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_ships.dm b/voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_ships.dm index 8d743ce5b2f..1cffb46b6b3 100644 --- a/voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_ships.dm +++ b/voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_ships.dm @@ -1,5 +1,6 @@ // Faction-specific NPC pirate ship types -// Each faction has unique colors, crew types, and behaviors +// Each faction has unique colors, crew types, and behaviors. Crews, boarders and bosses are human NPCs +// (faction_pirate_humans.dm). // ==================== FACTION COLORS ==================== @@ -29,11 +30,11 @@ crew_min = 2 crew_max = 4 - captain_type = /mob/living/basic/trooper/pirate/faction/silverscale/captain + captain_type = /mob/living/carbon/human/npc/faction_pirate/silverscale/captain crew_types = list( - /mob/living/basic/trooper/pirate/faction/silverscale/melee, - /mob/living/basic/trooper/pirate/faction/silverscale/melee, - /mob/living/basic/trooper/pirate/faction/silverscale/ranged, + /mob/living/carbon/human/npc/faction_pirate/silverscale/melee, + /mob/living/carbon/human/npc/faction_pirate/silverscale/melee, + /mob/living/carbon/human/npc/faction_pirate/silverscale/ranged, ) // Boarding pods - aristocrats send their duelists @@ -52,7 +53,7 @@ pirate_faction = "silverscale" // Phased combat - aristocratic duelists - boss_type = /mob/living/basic/trooper/pirate/faction/boss/silverscale + boss_type = /mob/living/carbon/human/npc/faction_pirate/silverscale/boss broke_lines = list( "Destitute. How disappointing. My retainers will see what else your hold contains.", "You have nothing to offer but cargo, then. And perhaps your lives.", @@ -90,11 +91,11 @@ crew_min = 3 crew_max = 6 - captain_type = /mob/living/basic/trooper/pirate/faction/skeleton/captain + captain_type = /mob/living/carbon/human/npc/faction_pirate/skeleton/captain crew_types = list( - /mob/living/basic/trooper/pirate/faction/skeleton/melee, - /mob/living/basic/trooper/pirate/faction/skeleton/melee, - /mob/living/basic/trooper/pirate/faction/skeleton/ranged, + /mob/living/carbon/human/npc/faction_pirate/skeleton/melee, + /mob/living/carbon/human/npc/faction_pirate/skeleton/melee, + /mob/living/carbon/human/npc/faction_pirate/skeleton/ranged, ) // Boarding pods - undead are relentless boarders @@ -112,7 +113,7 @@ pirate_faction = "skeleton" // Phased combat - undead hordes - boss_type = /mob/living/basic/trooper/pirate/faction/boss/skeleton + boss_type = /mob/living/carbon/human/npc/faction_pirate/skeleton/boss broke_lines = list( "No coin on this wreck. No matter - we take flesh as readily as gold.", "Empty holds, empty pockets. We will settle for your crew.", @@ -150,11 +151,11 @@ crew_min = 3 crew_max = 5 - captain_type = /mob/living/basic/trooper/pirate/faction/grey/captain + captain_type = /mob/living/carbon/human/npc/faction_pirate/grey/captain crew_types = list( - /mob/living/basic/trooper/pirate/faction/grey/melee, - /mob/living/basic/trooper/pirate/faction/grey/melee, - /mob/living/basic/trooper/pirate/faction/grey/ranged, + /mob/living/carbon/human/npc/faction_pirate/grey/melee, + /mob/living/carbon/human/npc/faction_pirate/grey/melee, + /mob/living/carbon/human/npc/faction_pirate/grey/ranged, ) // Boarding pods - grey tiders love swarming @@ -172,7 +173,7 @@ hold_credits_max = 1600 // Phased combat - greytide swarm - boss_type = /mob/living/basic/trooper/pirate/faction/boss/grey + boss_type = /mob/living/carbon/human/npc/faction_pirate/grey/boss broke_lines = list( "lmao ur broke? w/e. boys go grab whatever isnt bolted down", "no creds? fine. WE TAKE THE TOOLBOXES", @@ -206,10 +207,10 @@ crew_min = 2 crew_max = 4 - captain_type = /mob/living/basic/trooper/pirate/faction/lustrous/captain + captain_type = /mob/living/carbon/human/npc/faction_pirate/lustrous/captain crew_types = list( - /mob/living/basic/trooper/pirate/faction/lustrous/melee, - /mob/living/basic/trooper/pirate/faction/lustrous/ranged, + /mob/living/carbon/human/npc/faction_pirate/lustrous/melee, + /mob/living/carbon/human/npc/faction_pirate/lustrous/ranged, ) // Boarding pods - ethereals prefer ranged combat, fewer boarders @@ -227,7 +228,7 @@ hold_credits_max = 3000 // Phased combat - crystalline beings - boss_type = /mob/living/basic/trooper/pirate/faction/boss/lustrous + boss_type = /mob/living/carbon/human/npc/faction_pirate/lustrous/boss broke_lines = list( "You carry no wealth. We will take what matter you do carry.", "Nothing of value in your accounts. We will harvest from your hold instead.", @@ -266,11 +267,11 @@ crew_min = 3 crew_max = 5 - captain_type = /mob/living/basic/trooper/pirate/faction/interdyne/captain + captain_type = /mob/living/carbon/human/npc/faction_pirate/interdyne/captain crew_types = list( - /mob/living/basic/trooper/pirate/faction/interdyne/melee, - /mob/living/basic/trooper/pirate/faction/interdyne/ranged, - /mob/living/basic/trooper/pirate/faction/interdyne/ranged, + /mob/living/carbon/human/npc/faction_pirate/interdyne/melee, + /mob/living/carbon/human/npc/faction_pirate/interdyne/ranged, + /mob/living/carbon/human/npc/faction_pirate/interdyne/ranged, ) // Boarding pods - interdyne sends surgical strike teams @@ -288,7 +289,7 @@ hold_credits_max = 3800 // Phased combat - surgical strike teams - boss_type = /mob/living/basic/trooper/pirate/faction/boss/interdyne + boss_type = /mob/living/carbon/human/npc/faction_pirate/interdyne/boss broke_lines = list( "Accounts empty. Switching to physical asset recovery. Deploying collection team.", "No liquid funds. Your cargo and your crew will serve as compensation.", @@ -331,11 +332,11 @@ crew_min = 3 crew_max = 5 - captain_type = /mob/living/basic/trooper/pirate/faction/irs/captain + captain_type = /mob/living/carbon/human/npc/faction_pirate/irs/captain crew_types = list( - /mob/living/basic/trooper/pirate/faction/irs/melee, - /mob/living/basic/trooper/pirate/faction/irs/ranged, - /mob/living/basic/trooper/pirate/faction/irs/ranged, + /mob/living/carbon/human/npc/faction_pirate/irs/melee, + /mob/living/carbon/human/npc/faction_pirate/irs/ranged, + /mob/living/carbon/human/npc/faction_pirate/irs/ranged, ) // Boarding pods - IRS sends auditors to seize assets @@ -354,7 +355,7 @@ hold_credits_max = 6000 // Phased combat - tax enforcement - boss_type = /mob/living/basic/trooper/pirate/faction/boss/irs + boss_type = /mob/living/carbon/human/npc/faction_pirate/irs/boss broke_lines = list( "Insufficient funds for settlement. Proceeding directly to asset seizure.", "You cannot pay. Then we collect in kind. Agents are boarding now.", @@ -396,11 +397,11 @@ crew_min = 3 crew_max = 6 - captain_type = /mob/living/basic/trooper/pirate/faction/medieval/captain + captain_type = /mob/living/carbon/human/npc/faction_pirate/medieval/captain crew_types = list( - /mob/living/basic/trooper/pirate/faction/medieval/melee, - /mob/living/basic/trooper/pirate/faction/medieval/melee, - /mob/living/basic/trooper/pirate/faction/medieval/ranged, + /mob/living/carbon/human/npc/faction_pirate/medieval/melee, + /mob/living/carbon/human/npc/faction_pirate/medieval/melee, + /mob/living/carbon/human/npc/faction_pirate/medieval/ranged, ) // Boarding pods - medieval warriors LOVE boarding actions @@ -418,7 +419,7 @@ hold_credits_max = 3200 // Phased combat - knights and men-at-arms - boss_type = /mob/living/basic/trooper/pirate/faction/boss/medieval + boss_type = /mob/living/carbon/human/npc/faction_pirate/medieval/boss broke_lines = list( "No coin in thy coffers? Then we shall take thy goods by force of arms!", "A pauper's ship! Very well - the spoils shall be whatever thou carriest!", diff --git a/voidcrew/modules/npc_ships/code/faction_pirates/nt_patrol.dm b/voidcrew/modules/npc_ships/code/faction_pirates/nt_patrol.dm index 20fe1ccaac3..0be6558a3d8 100644 --- a/voidcrew/modules/npc_ships/code/faction_pirates/nt_patrol.dm +++ b/voidcrew/modules/npc_ships/code/faction_pirates/nt_patrol.dm @@ -61,11 +61,11 @@ // Crew configuration - NT customs enforcement detail crew_min = 3 crew_max = 5 - captain_type = /mob/living/basic/trooper/nanotrasen/ranged/assault/customs + captain_type = /mob/living/carbon/human/npc/faction_pirate/nt_customs/sergeant crew_types = list( - /mob/living/basic/trooper/nanotrasen/customs, - /mob/living/basic/trooper/nanotrasen/ranged/smg/customs, - /mob/living/basic/trooper/nanotrasen/ranged/smg/customs, + /mob/living/carbon/human/npc/faction_pirate/nt_customs/officer, + /mob/living/carbon/human/npc/faction_pirate/nt_customs/inspector, + /mob/living/carbon/human/npc/faction_pirate/nt_customs/inspector, ) // Negotiation - the "fine". Dispatch overwrites both bounds with the exact @@ -88,8 +88,8 @@ boarding_pods_max = 2 boarding_pod_cooldown_time = 30 SECONDS boarding_pod_mob_types = list( - /mob/living/basic/trooper/nanotrasen/customs, - /mob/living/basic/trooper/nanotrasen/ranged/smg/customs, + /mob/living/carbon/human/npc/faction_pirate/nt_customs/officer, + /mob/living/carbon/human/npc/faction_pirate/nt_customs/inspector, ) // Phased combat - compliance action waves, then the Director @@ -99,7 +99,7 @@ list(3, 4), // Wave 2 list(3, 5), // Wave 3 ) - boss_type = /mob/living/basic/trooper/pirate/faction/boss/nt_patrol + boss_type = /mob/living/carbon/human/npc/faction_pirate/nt_customs/director wave_taunts = list( list( // Wave 1 -> 2 cooldown "Compliance teams are inbound. This is a billable action.", @@ -185,10 +185,11 @@ // faction_pirate_equipment.dm, but keyed to the NT crew's faction so they // don't gun down their own officers. // -// req_access is deliberately an access nobody aboard carries. The crew are -// basic mobs with no ID cards, so the swipe lock only ever gates boarders - -// and the inherited ACCESS_SYNDICATE gated it the wrong way round, since -// voidcrew's syndicate job outfits hand players that access at roundstart. +// req_access is CentCom access. The crew carry CentCom ID cards, but those are +// locked to their bodies (human NPC gear lock, voidcrew/modules/human_npcs/) and +// the crew never work a turret's panel, so the swipe lock only ever gates +// boarders - and the inherited ACCESS_SYNDICATE gated it the wrong way round, +// since voidcrew's syndicate job outfits hand players that access at roundstart. // The counterplay is the turretid console, which ship_nt_patrol.dmm maps // unlocked on purpose. @@ -204,100 +205,177 @@ faction = list(ROLE_DEATHSQUAD) req_access = list(ACCESS_CENT_GENERAL) -// ==================== CREW MOBS ==================== -// Space-capable customs variants of the upstream NT troopers -// (code/modules/mob/living/basic/trooper/nanotrasen.dm). Mirrors what -// /mob/living/basic/trooper/pirate/faction does for pirate crews: atmos -// immunity + TRAIT_SPACEWALK so ship interiors and boarding actions work. - -/// Customs guard - melee escort with a stun baton -/mob/living/basic/trooper/nanotrasen/customs - name = "\improper Nanotrasen Customs Officer" - desc = "A Nanotrasen customs officer, here to search your ship. The baton is standard issue." - maxHealth = 110 - health = 110 - melee_damage_lower = 12 - melee_damage_upper = 18 - attack_verb_continuous = "batons" - attack_verb_simple = "baton" - attack_sound = 'sound/items/weapons/genhit1.ogg' - unsuitable_atmos_damage = 0 - unsuitable_cold_damage = 0 - unsuitable_heat_damage = 0 - minimum_survivable_temperature = 0 - r_hand = /obj/item/melee/baton/security - -/mob/living/basic/trooper/nanotrasen/customs/Initialize(mapload) - . = ..() - ADD_TRAIT(src, TRAIT_SPACEWALK, INNATE_TRAIT) - -/// Customs inspector - SMG-armed ranged officer -/mob/living/basic/trooper/nanotrasen/ranged/smg/customs - name = "\improper Nanotrasen Customs Inspector" - desc = "A Nanotrasen customs inspector. Authorized to conduct searches, seizures, and suppressive fire." - unsuitable_atmos_damage = 0 - unsuitable_cold_damage = 0 - unsuitable_heat_damage = 0 - minimum_survivable_temperature = 0 - -/mob/living/basic/trooper/nanotrasen/ranged/smg/customs/Initialize(mapload) - . = ..() - ADD_TRAIT(src, TRAIT_SPACEWALK, INNATE_TRAIT) - -/// Customs sergeant - assault-rifle captain of the patrol (carries the ship key) -/mob/living/basic/trooper/nanotrasen/ranged/assault/customs - name = "\improper Nanotrasen Customs Sergeant" - desc = "The ranking customs officer aboard. Personally responsible for this quarter's seizure figures." - maxHealth = 120 - health = 120 - unsuitable_atmos_damage = 0 - unsuitable_cold_damage = 0 - unsuitable_heat_damage = 0 - minimum_survivable_temperature = 0 - -/mob/living/basic/trooper/nanotrasen/ranged/assault/customs/Initialize(mapload) - . = ..() - ADD_TRAIT(src, TRAIT_SPACEWALK, INNATE_TRAIT) - -// ==================== THE BOSS ==================== -// Subtypes /mob/living/basic/trooper/pirate/faction/boss because -// create_boss_boarding_pod() (boarding_pod.dm) writes boss.parent_ship and the -// boss death hook lives on that type - an upstream NT trooper would runtime. -// Flavor and loadout are pure Nanotrasen. - -/mob/living/basic/trooper/pirate/faction/boss/nt_patrol - name = "NT Compliance Director" - desc = "A senior Nanotrasen compliance executive in body armor, sent out when the paperwork stops working." - maxHealth = 350 - health = 350 - melee_damage_lower = 20 - melee_damage_upper = 25 - armour_penetration = 25 - attack_verb_continuous = "restructures" - attack_verb_simple = "restructure" - attack_sound = 'sound/items/weapons/genhit1.ogg' - attack_vis_effect = ATTACK_EFFECT_PUNCH +// ==================== THE CREW ==================== +// Customs officers, inspectors, their sergeant and the Compliance Director as human NPCs +// (voidcrew/modules/human_npcs/), crewing the corvette and boarding by pod the way the pirate factions do +// (faction_pirate_humans.dm, whose crew AI, boarding, captain's key and boss hooks they share). They look +// like tg's Nanotrasen troopers (the corpse spawners' species, hair and clothes) and hold the guns those +// troopers fired, by the zone ladder the basic customs mobs used (voidcrew/edits/mobs/weapon_drops.dm): +// inspectors and the sergeant carry an M1911 outside the red zone. Their CentCom ID cards are locked gear +// like the rest of their kit, so a dead officer's card opens nothing for anyone. Boarders wear a sealed suit +// and carry air. They drop nothing (a customs vessel is no prize); the Director drops his e-gun, his baton +// and 2,000 credits of collected fines, as the basic boss did. + +/// What customs says when things happen to its body (human_npc_barks.dm) +/datum/human_npc_voice/nt_customs + lines = list( + PIRATE_BARK_SPOT = list("Customs! Stay where you are!", "There. Detain them.", "Contact. Compliance action authorised."), + HUMAN_NPC_BARK_DOWNED = list("Officer down!", "I need a medic. Bill them for it."), + HUMAN_NPC_BARK_PLEAD = list("Assaulting an officer... is a crime...", "This is going on your file..."), + HUMAN_NPC_BARK_RECOVER = list("Back on duty.", "Where was I."), + HUMAN_NPC_BARK_CUFFED = list("You're cuffing a customs officer. That's on file.", "This is obstruction."), + HUMAN_NPC_BARK_SLIPPING = list("Almost..."), + HUMAN_NPC_BARK_PULLED_FREE = list("Hands off, citizen!"), + ) + emotes = list( + HUMAN_NPC_BARK_DOWNED = list("collapses."), + "stimulant" = list("jabs a needle into their neck."), + ) + chances = list(PIRATE_BARK_SPOT = 60) + +/mob/living/carbon/human/npc/faction_pirate/nt_customs + name = "customs officer" + npc_name = "Nanotrasen Customs Officer" + crew_desc = "A Nanotrasen customs officer, here to search your ship." + // The corvette's turrets and doors are keyed to it (above); never counted as a pirate faction = list(ROLE_DEATHSQUAD) - mob_spawner = /obj/effect/mob_spawn/corpse/human/nanotrasenelitesoldier - corpse = /obj/effect/mob_spawn/corpse/human/nanotrasenelitesoldier - r_hand = /obj/item/gun/energy/e_gun - loot_pool = list(/obj/item/gun/energy/e_gun, /obj/item/melee/baton/security/loaded) - plunder_credits = 2000 - ai_controller = /datum/ai_controller/basic_controller/trooper/ranged - var/projectiletype = /obj/projectile/beam/laser - var/projectilesound = 'sound/items/weapons/laser.ogg' - var/burst_shots = 3 - var/ranged_cooldown = 5 SECONDS - -/mob/living/basic/trooper/pirate/faction/boss/nt_patrol/Initialize(mapload) - . = ..() - AddComponent(\ - /datum/component/ranged_attacks,\ - projectile_type = projectiletype,\ - projectile_sound = projectilesound,\ - cooldown_time = ranged_cooldown,\ - burst_shots = burst_shots,\ + npc_look = /obj/effect/mob_spawn/corpse/human/nanotrasensoldier + npc_outfit_table = /datum/human_npc_outfit_table/pirate/nt_customs + boarding_outfit_table = /datum/human_npc_outfit_table/pirate/nt_customs/boarding + npc_voice = /datum/human_npc_voice/nt_customs + // Always aboard their corvette or with its boarders: the crew decides, as for pirates + npc_surrender = null + crew_alert_lines = list( + "Unauthorised boarders. Detain them.", + "Intruders on a customs vessel. Weapons free.", + "All officers, we have a breach.", ) + crew_spot_lines = list( + "Customs! Stay where you are!", + "There. Detain them.", + "Contact. Compliance action authorised.", + ) + // A customs vessel is no prize: the crew drop nothing + random_loot = null + random_loot_2 = null + +// Corporate staff, not natives of any planet +/mob/living/carbon/human/npc/faction_pirate/nt_customs/should_inherit_planetary_faction() + return FALSE + +// The corpse look's own CentCom ID (tg's trooper corpses) already names its rank; keep it and put the +// NPC's own name on it, so a masked officer isn't "Unknown". +/mob/living/carbon/human/npc/faction_pirate/nt_customs/crew_issue_id() + var/obj/item/card/id/card = wear_id + if(!istype(card)) + return ..() + card.registered_name = real_name + card.update_label() + +/// Customs guard: a stun baton and cuffs' worth of authority +/mob/living/carbon/human/npc/faction_pirate/nt_customs/officer + npc_name = "Nanotrasen Customs Officer" + crew_desc = "A Nanotrasen customs officer, here to search your ship. The baton is standard issue." + crew_role = SHIP_CREW_ROLE_MELEE + +/// Customs inspector: an M1911, or a WT-550 in the red zone +/mob/living/carbon/human/npc/faction_pirate/nt_customs/inspector + npc_name = "Nanotrasen Customs Inspector" + crew_desc = "A Nanotrasen customs inspector. Authorised to conduct searches, seizures, and suppressive fire." + crew_role = SHIP_CREW_ROLE_GUNNER + +/// Customs sergeant: the corvette's captain, who carries its key +/mob/living/carbon/human/npc/faction_pirate/nt_customs/sergeant + npc_name = "Nanotrasen Customs Sergeant" + crew_desc = "The ranking customs officer aboard. Personally responsible for this quarter's seizure figures." + npc_look = /obj/effect/mob_spawn/corpse/human/nanotrasenassaultsoldier + npc_rank = HUMAN_NPC_RANK_ELITE + +/// The Compliance Director: the boss the corvette sends last. Killing or taking him disables it. +/mob/living/carbon/human/npc/faction_pirate/nt_customs/director + npc_name = "NT Compliance Director" + crew_desc = "A senior Nanotrasen compliance executive in body armour, sent out when the paperwork stops working." + npc_look = /obj/effect/mob_spawn/corpse/human/nanotrasenelitesoldier + npc_rank = HUMAN_NPC_RANK_BOSS + npc_always_site = HUMAN_NPC_SITE_BAD_AIR + stimulant_type = /obj/item/reagent_containers/hypospray/medipen/stimulants + loot_pool = list(/obj/item/gun/energy/e_gun, /obj/item/melee/baton/security/loaded) + npc_death_cash = 2000 + +// ===== Outfits: tg's trooper corpse outfits, with the real weapons the basic mobs fired ===== + +/// Rank and file by role and zone; the sergeant and the Director wear their own. +/datum/human_npc_outfit_table/pirate/nt_customs + vacuum_layer = /datum/human_npc_layer/eva/nt_customs + melee = list(/datum/outfit/nanotrasensoldiercorpse/nt_customs_officer = 1) + gunners = list(/datum/outfit/nanotrasensoldiercorpse/nt_customs_inspector = 1) + elite = list(/datum/outfit/nanotrasenassaultsoldiercorpse/nt_customs_sergeant = 1) + boss = list(/datum/outfit/nt_customs_director = 1) + /// In the red zone the gunners and the sergeant carry the guns the basic mobs fired there + var/list/red_gunners = list(/datum/outfit/nanotrasensoldiercorpse/nt_customs_inspector/smg = 1) + var/list/red_elite = list(/datum/outfit/nanotrasenassaultsoldiercorpse/nt_customs_sergeant/rifle = 1) + +/datum/human_npc_outfit_table/pirate/nt_customs/outfits_for(mob/living/carbon/human/npc/npc, zone) + if(zone == ZONE_RED) + var/mob/living/carbon/human/npc/faction_pirate/crewman = npc + if(npc?.npc_rank == HUMAN_NPC_RANK_ELITE) + return red_elite + if(istype(crewman) && crewman.npc_rank == HUMAN_NPC_RANK_REGULAR && crewman.crew_role == SHIP_CREW_ROLE_GUNNER) + return red_gunners + return ..() + +// Boarders cross space: a sealed suit and air +/datum/human_npc_outfit_table/pirate/nt_customs/boarding + always_site = HUMAN_NPC_SITE_VACUUM + +/datum/human_npc_layer/eva/nt_customs + suit = /obj/item/clothing/suit/space/syndicate/black/blue + head = /obj/item/clothing/head/helmet/space/syndicate/black/blue + +/datum/outfit/nanotrasensoldiercorpse/nt_customs_officer + name = "Human NPC: NT Customs Officer" + r_hand = /obj/item/melee/baton/security/loaded + l_pocket = /obj/item/crowbar + +/datum/outfit/nanotrasensoldiercorpse/nt_customs_inspector + name = "Human NPC: NT Customs Inspector" + r_hand = /obj/item/gun/ballistic/automatic/pistol/m1911 + l_pocket = /obj/item/ammo_box/magazine/m45 + r_pocket = /obj/item/ammo_box/magazine/m45 + +/datum/outfit/nanotrasensoldiercorpse/nt_customs_inspector/smg + name = "Human NPC: NT Customs Inspector (WT-550)" + r_hand = /obj/item/gun/ballistic/automatic/wt550 + l_pocket = /obj/item/ammo_box/magazine/wt550m9 + r_pocket = /obj/item/ammo_box/magazine/wt550m9 + +/datum/outfit/nanotrasenassaultsoldiercorpse/nt_customs_sergeant + name = "Human NPC: NT Customs Sergeant" + r_hand = /obj/item/gun/ballistic/automatic/pistol/m1911 + l_pocket = /obj/item/ammo_box/magazine/m45 + r_pocket = /obj/item/ammo_box/magazine/m45 + +/datum/outfit/nanotrasenassaultsoldiercorpse/nt_customs_sergeant/rifle + name = "Human NPC: NT Customs Sergeant (rifle)" + r_hand = /obj/item/gun/ballistic/automatic/ar + l_pocket = /obj/item/ammo_box/magazine/m223 + r_pocket = /obj/item/ammo_box/magazine/m223 + +/// The Director: tg's elite trooper in body armour instead of the modsuit, a lethal e-gun and a baton +/datum/outfit/nt_customs_director + name = "Human NPC: NT Compliance Director" + uniform = /obj/item/clothing/under/rank/centcom/military + suit = /obj/item/clothing/suit/armor/bulletproof + shoes = /obj/item/clothing/shoes/combat + gloves = /obj/item/clothing/gloves/combat + mask = /obj/item/clothing/mask/gas/sechailer/swat + head = /obj/item/clothing/head/helmet/swat/nanotrasen + back = /obj/item/storage/backpack/security + belt = /obj/item/melee/baton/security/loaded + id = /obj/item/card/id/advanced/centcom + id_trim = /datum/id_trim/centcom/ert/security + r_hand = /obj/item/gun/energy/e_gun/lethal + l_pocket = /obj/item/knife/combat/survival // ==================== NEGOTIATION DIALOG ==================== diff --git a/voidcrew/modules/npc_ships/code/mob_patrol.dm b/voidcrew/modules/npc_ships/code/mob_patrol.dm index 6865b6ce6ad..058ed5851a3 100644 --- a/voidcrew/modules/npc_ships/code/mob_patrol.dm +++ b/voidcrew/modules/npc_ships/code/mob_patrol.dm @@ -1431,7 +1431,7 @@ PATROL_LOG("[pawn] not adjacent to assembly [assembly.name] (dist=[assembly_dist]), cannot attack") return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED - pawn.melee_attack(assembly) + patrol_melee_attack(controller, assembly) PATROL_LOG("[pawn] smashing door assembly [assembly.name]") return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED @@ -1464,7 +1464,7 @@ PATROL_LOG("[pawn] not adjacent to obstacle [obstacle.name], cannot attack") return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED - pawn.melee_attack(obstacle) + patrol_melee_attack(controller, obstacle) PATROL_LOG("[pawn] smashing blocking obstacle [obstacle.name]") return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED @@ -1504,7 +1504,7 @@ return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED // Keep running until adjacent // Adjacent - attack it - pawn.melee_attack(assembly) + patrol_melee_attack(controller, assembly) PATROL_LOG("[pawn] smashing patrol target assembly [assembly.name]") return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED @@ -1610,7 +1610,7 @@ // Always use melee attack for door breaking (like blobbernauts/standard troopers) // This is more reliable than ranged attacks and saves ammo for combat - pawn.melee_attack(door) + patrol_melee_attack(controller, door) PATROL_LOG("[pawn] smashing blocking door [door.name]") return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED @@ -1789,7 +1789,7 @@ // Always use melee attack for door breaking (like blobbernauts/standard troopers) // This is more reliable than ranged attacks and saves ammo for combat - pawn.melee_attack(door) + patrol_melee_attack(controller, door) PATROL_LOG("[pawn] smashing door [door.name]") return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED @@ -1931,7 +1931,7 @@ // If locked or welded, attack it to break it open if(closet.locked || closet.welded) - pawn.melee_attack(closet) + patrol_melee_attack(controller, closet) PATROL_LOG("[pawn] attacking locked/welded closet [closet.name]") return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED // Keep attacking until it opens @@ -1946,7 +1946,11 @@ // Scan for crew hiding inside - they'll be on/near the closet's turf now var/turf/closet_turf = get_turf(closet) if(closet_turf) + var/datum/targeting_strategy/targeting = GET_TARGETING_STRATEGY(controller.blackboard[BB_TARGETING_STRATEGY]) for(var/mob/living/carbon/hiding_crew in range(1, closet_turf)) + // Not the patroller itself, a person breaking out of an outpost prison, or anyone it won't fight + if(hiding_crew == pawn || (targeting && !targeting.can_attack(pawn, hiding_crew))) + continue if(hiding_crew.stat != DEAD) // Found a live crew member! Target them immediately controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hiding_crew) @@ -2136,3 +2140,14 @@ /datum/ai_planning_subtree/try_open_door_in_path, /datum/ai_planning_subtree/attack_patrol_door, ) + +/** + * One blow from a patroller at `target`: a basic mob's own melee attack, or, for a person on a patrol (a + * prisoner breaking out of an outpost prison is a real human body), a click with combat mode on through + * their own hands. + */ +/proc/patrol_melee_attack(datum/ai_controller/controller, atom/target) + var/mob/living/basic/basic_pawn = controller?.pawn + if(isbasicmob(basic_pawn)) + return basic_pawn.melee_attack(target) + return controller?.ai_interact(target = target, combat_mode = TRUE) diff --git a/voidcrew/modules/npc_ships/code/npc_ship.dm b/voidcrew/modules/npc_ships/code/npc_ship.dm index b639e0a06a5..0be9b40ff7c 100644 --- a/voidcrew/modules/npc_ships/code/npc_ship.dm +++ b/voidcrew/modules/npc_ships/code/npc_ship.dm @@ -147,6 +147,11 @@ /// treat an empty roster as a crew wipe unless this is set - otherwise a hull whose /// crew spawn silently failed would resolve at birth and churn the pool in a loop. var/crew_ever_spawned = FALSE + /// Human NPC crew still waiting in the spawn queue (spawn_human_npc()); the hull's roster isn't + /// complete, and can't be wiped, until they are built + var/list/datum/human_npc_order/crew_orders = list() + /// Set once the crew wipe has been handled, so a second path to it does nothing + var/crew_wipe_handled = FALSE // ========== MASS CACHING (Performance optimization) ========== // Instead of iterating all turfs every second, we cache mass and only @@ -239,8 +244,9 @@ if(abandonment_timer) deltimer(abandonment_timer) abandonment_timer = null - // Clear crew tracking + // Clear crew tracking; crew still in the spawn queue are never built tracked_crew.Cut() + QDEL_LIST(crew_orders) return ..() /** @@ -375,16 +381,13 @@ if(captain_type && length(valid_turfs)) var/turf/captain_loc = pick_n_take(valid_turfs) var/datum/npc_spawn_context/context = new(src, pool_zone_type, "boss") - var/mob/living/basic/captain = spawn_npc_in_zone(captain_type, captain_loc, context, FALSE) - // Give captain the ship key - stored in contents, drops on death - var/obj/item/ship_key/key = new(null, src) - key.forceMove(captain) - context.finalize() - // Track captain and register death signal - tracked_crew += captain - RegisterSignal(captain, COMSIG_LIVING_DEATH, PROC_REF(on_crew_death)) - // The captain holds the helm with one guard (pirate_crew.dm) - pirate_crew_enlist_defender(captain, src, PIRATE_ROLE_CAPTAIN) + if(ispath(captain_type, /mob/living/carbon/human/npc)) + // Human NPCs are built a body at a time (spawn_human_npc()); the captain joins when built + crew_orders += spawn_human_npc(captain_type, captain_loc, CALLBACK(src, PROC_REF(on_captain_built)), context = context) + else + var/mob/living/basic/captain = spawn_npc_in_zone(captain_type, captain_loc, context, FALSE) + context.finalize() + on_captain_built(captain) crew_count-- // Captain counts toward crew count // Spawn rest of crew from configured types @@ -392,15 +395,53 @@ var/turf/spawn_loc = pick_n_take(valid_turfs) var/mob_type = pick(crew_types) var/datum/npc_spawn_context/context = new(src, pool_zone_type, "ordinary") - var/mob/living/crewmember = spawn_npc_in_zone(mob_type, spawn_loc, context) - // Track crew and register death signal - tracked_crew += crewmember - RegisterSignal(crewmember, COMSIG_LIVING_DEATH, PROC_REF(on_crew_death)) - pirate_crew_enlist_defender(crewmember, src) + if(ispath(mob_type, /mob/living/carbon/human/npc)) + crew_orders += spawn_human_npc(mob_type, spawn_loc, CALLBACK(src, PROC_REF(on_crewman_built)), context = context) + else + on_crewman_built(spawn_npc_in_zone(mob_type, spawn_loc, context)) + +/// The captain is built: it carries the ship key and holds the helm with one guard (pirate_crew.dm). +/obj/structure/overmap/ship/npc/proc/on_captain_built(mob/living/captain) + if(QDELETED(captain)) + return + // The key is not gear: a human captain keeps it in a pocket, where a crew that cuffs or downs him can + // take it (the strip menu), and it drops when he dies (on_crew_death()) + var/obj/item/ship_key/key = new(null, src) + var/mob/living/carbon/human/npc/faction_pirate/human_captain = captain + if(!istype(human_captain) || !human_captain.crew_pocket(key)) + key.forceMove(captain) + track_crewman(captain, PIRATE_ROLE_CAPTAIN) +/// A crewman is built: tracked for the crew wipe and enlisted in the hull's crew. +/obj/structure/overmap/ship/npc/proc/on_crewman_built(mob/living/crewmember) + if(QDELETED(crewmember)) + return + track_crewman(crewmember, PIRATE_ROLE_HUNTER) + +/obj/structure/overmap/ship/npc/proc/track_crewman(mob/living/crewmember, role) + prune_crew_orders() + if(QDELETED(src)) + qdel(crewmember) + return + tracked_crew += crewmember + RegisterSignal(crewmember, COMSIG_LIVING_DEATH, PROC_REF(on_crew_death)) + // Out of the fight counts as gone for the crew wipe too (owner ruling OC-7): down or cuffed + if(ishumannpc(crewmember)) + RegisterSignals(crewmember, list(COMSIG_HUMAN_NPC_DOWNED, SIGNAL_ADDTRAIT(TRAIT_RESTRAINED)), PROC_REF(on_crew_out_of_fight)) + pirate_crew_enlist_defender(crewmember, src, role) // A roster exists; the pool may now treat this roster emptying as a crew wipe - if(length(tracked_crew)) - crew_ever_spawned = TRUE + crew_ever_spawned = TRUE + +/// Drops crew orders that have been built or cancelled. +/obj/structure/overmap/ship/npc/proc/prune_crew_orders() + for(var/datum/human_npc_order/order as anything in crew_orders.Copy()) + if(QDELETED(order) || order.done) + crew_orders -= order + +/// Whether crew are still waiting to be built. +/obj/structure/overmap/ship/npc/proc/crew_pending() + prune_crew_orders() + return length(crew_orders) > 0 /** * Signal handler for when any crew member dies. @@ -408,27 +449,45 @@ */ /obj/structure/overmap/ship/npc/proc/on_crew_death(mob/living/victim, gibbed) SIGNAL_HANDLER - UnregisterSignal(victim, COMSIG_LIVING_DEATH) + UnregisterSignal(victim, list(COMSIG_LIVING_DEATH, COMSIG_HUMAN_NPC_DOWNED, SIGNAL_ADDTRAIT(TRAIT_RESTRAINED))) - // Drop ship key if the victim has one (captain) + // Drop ship key if the victim has one (captain). A human captain's drops from his pocket with + // whatever else he carries that isn't gear (human_npc_gear.dm); this catches one held loose. var/turf/drop_loc = get_turf(victim) if(drop_loc) for(var/obj/item/ship_key/key in victim.contents) - key.forceMove(drop_loc) + if(!victim.get_slot_by_item(key)) + key.forceMove(drop_loc) // Remove from tracked crew list tracked_crew -= victim log_shuttle("NPC_SHIP: [name] crew member [victim] died ([length(tracked_crew)] tracked crew remain)") + check_crew_wipe() + +/// A human crewman went into crit or was cuffed: if nobody aboard is left fighting, the crew is wiped. +/obj/structure/overmap/ship/npc/proc/on_crew_out_of_fight(mob/living/source) + SIGNAL_HANDLER + check_crew_wipe() - // Check if all crew are dead - if(!length(tracked_crew)) - npc_metric_crew_wiped(src) - // The pool slot frees the instant the crew is wiped. The abandonment timer below - // is a separate concern - it holds the hull claimable for a while - and must not - // delay the replacement spawn. - if(!player_controlled) - notify_spawner_resolved("crew wiped") - start_abandonment_timer() +/** + * The crew is wiped once every tracked crewman is dead, or out of the fight (in crit or cuffed, owner + * ruling OC-7: a crew the players took down or captured is beaten, and a body frozen in crit on a hull + * nobody is near must not hold the pool slot). Crew still waiting to be built keep it from wiping. + */ +/obj/structure/overmap/ship/npc/proc/check_crew_wipe() + if(crew_wipe_handled || crew_pending()) + return + for(var/mob/living/crewmember as anything in tracked_crew) + if(!human_npc_out_of_fight(crewmember)) + return + crew_wipe_handled = TRUE + npc_metric_crew_wiped(src) + // The pool slot frees the instant the crew is wiped. The abandonment timer below + // is a separate concern - it holds the hull claimable for a while - and must not + // delay the replacement spawn. + if(!player_controlled) + notify_spawner_resolved("crew wiped") + start_abandonment_timer() /** * Starts a timer to abandon the ship after all crew die. @@ -522,21 +581,20 @@ return despawn_derelict() /** - * How many of this hull's own tracked crew are alive and actually aboard. + * How many of this hull's own tracked crew are still fighting and actually aboard. * * Derived from live state rather than roster bookkeeping on purpose: a missed death * signal, a hard-deleted mob, or a pirate spaced or dragged off the hull must all read - * as "not aboard", or the pool slot this crew holds never frees. The roster is 2-6 - * entries, so this is cheap enough for the reconcile's slow tick. + * as "not aboard", or the pool slot this crew holds never frees. A crewman in crit or + * cuffed is out of the fight and doesn't count either (owner ruling OC-7). The roster is + * 2-6 entries, so this is cheap enough for the reconcile's slow tick. */ /obj/structure/overmap/ship/npc/proc/count_live_crew_aboard() if(!shuttle?.shuttle_areas) return 0 var/count = 0 for(var/mob/living/crew as anything in tracked_crew) - if(QDELETED(crew)) - continue - if(crew.stat == DEAD) + if(human_npc_out_of_fight(crew)) continue var/area/crew_area = get_area(crew) if(!crew_area || !shuttle.shuttle_areas[crew_area]) @@ -544,25 +602,6 @@ count++ return count -/** - * Kills tracked crew that ended up floating in open space (hull breach blowout). - * The same cleanup boarding waves already get via check_boarders_in_space(); without it - * a spaced pirate drifts alive forever. Run from the pool reconcile. - */ -/obj/structure/overmap/ship/npc/proc/sweep_spaced_crew() - var/list/spaced = list() - for(var/mob/living/crew as anything in tracked_crew) - if(QDELETED(crew) || crew.stat == DEAD) - continue - var/turf/crew_turf = get_turf(crew) - if(!crew_turf) - continue - if(isspaceturf(crew_turf) || istype(get_area(crew_turf), /area/space)) - spaced += crew - // death() fires on_crew_death, which edits tracked_crew - never kill mid-iteration - for(var/mob/living/lost as anything in spaced) - lost.death() - /** * Signal handler for ship integrity changes. * Updates boarding state when ship is damaged enough. @@ -916,10 +955,10 @@ // Crew configuration crew_min = 3 crew_max = 6 - captain_type = /mob/living/basic/trooper/pirate/ranged/space + captain_type = /mob/living/carbon/human/npc/ruin/trooper/pirate/space/gunner crew_types = list( - /mob/living/basic/trooper/pirate/melee/space, - /mob/living/basic/trooper/pirate/ranged/space, + /mob/living/carbon/human/npc/ruin/trooper/pirate/space, + /mob/living/carbon/human/npc/ruin/trooper/pirate/space/gunner, ) // Faction diff --git a/voidcrew/modules/npc_ships/code/npc_ship_controller.dm b/voidcrew/modules/npc_ships/code/npc_ship_controller.dm index bb5a1744aab..f26d546ccf8 100644 --- a/voidcrew/modules/npc_ships/code/npc_ship_controller.dm +++ b/voidcrew/modules/npc_ships/code/npc_ship_controller.dm @@ -32,6 +32,10 @@ var/boarding_committed = 0 var/boarding_pending = 0 var/boarding_boss_sent = FALSE + /// Human boarders (and a human boss) of this encounter still waiting in the spawn queue + var/list/datum/human_npc_order/boarding_orders = list() + /// Of those, the ones the scripted wave sent: the wave isn't over while any of them is still coming + var/list/datum/human_npc_order/wave_orders = list() /datum/ai_controller/npc_ship/New(atom/new_pawn) // Initialize combat blackboard @@ -101,6 +105,7 @@ /// Override to avoid ai_movement access in parent Destroy /datum/ai_controller/npc_ship/Destroy(force) cleanup_boarding_signals() + cancel_boarding_orders() UnpossessPawn(FALSE) if(ai_status) GLOB.ai_controllers_by_status[ai_status] -= src @@ -439,6 +444,8 @@ // half-elapsed wipe timer over onto whoever we point at next. if(old_target != target) cleanup_boarding_signals() + // Boarders not yet built for the old target are never sent + cancel_boarding_orders() boarding_context = null boarding_budget = 0 boarding_committed = 0 @@ -835,27 +842,26 @@ GLOB.boarding_spawn_index = 0 GLOB.boarding_spawn_total = boarder_count - // Spawn the boarders via drop pods + // Spawn the boarders via drop pods. Human boarders are built through the spawn queue first, so they + // join the wave (track_wave_boarder()) as each one goes in its pod. var/list/wave_boarders = list() + blackboard[BB_NPC_BOARDING_WAVE_BOARDERS] = wave_boarders + wave_orders.Cut() + var/launched = 0 for(var/i in 1 to boarder_count) if(!length(valid_turfs)) break var/turf/spawn_loc = pick(valid_turfs) var/mob_type = pick(mob_types) - // Create boarding pod with the mob inside - returns the boarder for tracking - var/mob/living/boarder = create_boarding_pod(spawn_loc, target, ship, mob_type) - - if(boarder) - // Track this boarder and register death signal - wave_boarders += boarder - RegisterSignal(boarder, COMSIG_LIVING_DEATH, PROC_REF(on_boarder_death)) + var/sent = create_boarding_pod(spawn_loc, target, ship, mob_type, on_boarder = CALLBACK(src, PROC_REF(track_wave_boarder), wave_boarders)) + if(istype(sent, /datum/human_npc_order)) + wave_orders += sent + if(sent) + launched++ // Note: Patrol setup is handled by the boarding pod's open_pod() proc - log_shuttle("PATROL: Wave [wave_number] launched [length(wave_boarders)] boarders via drop pods") - - // Store the wave boarders for tracking - blackboard[BB_NPC_BOARDING_WAVE_BOARDERS] = wave_boarders + log_shuttle("PATROL: Wave [wave_number] launched [launched] boarders via drop pods") // Track wave start time and target position (for time limit and movement detection) set_blackboard_key(BB_NPC_BOARDING_WAVE_START_TIME, world.time) @@ -865,10 +871,43 @@ // Notify target ship target.ship_notify("Hostiles have boarded!", "SECURITY", SHIP_NOTIFY_DANGER, 'voidcrew/sound/warn3.ogg', 25) - npc_metric_boarding_wave(src, wave_number, length(wave_boarders)) + npc_metric_boarding_wave(src, wave_number, launched) return TRUE +/// A wave boarder is in its pod: it counts toward `wave` (the list it was sent with) until it is out of +/// the fight. Dead, in crit or cuffed is out (owner ruling OC-7). +/datum/ai_controller/npc_ship/proc/track_wave_boarder(list/wave, mob/living/boarder) + prune_boarding_orders() + if(QDELETED(boarder) || wave != blackboard[BB_NPC_BOARDING_WAVE_BOARDERS]) + return + wave += boarder + RegisterSignal(boarder, COMSIG_LIVING_DEATH, PROC_REF(on_boarder_death)) + if(ishumannpc(boarder)) + RegisterSignals(boarder, list(COMSIG_HUMAN_NPC_DOWNED, SIGNAL_ADDTRAIT(TRAIT_RESTRAINED)), PROC_REF(on_boarder_out_of_fight)) + +/// Remembers a human boarder still waiting to be built, so the encounter can call it off. +/datum/ai_controller/npc_ship/proc/track_boarding_order(datum/human_npc_order/order) + if(!QDELETED(order) && !order.done) + boarding_orders += order + +/// Drops orders that have been built or cancelled. +/datum/ai_controller/npc_ship/proc/prune_boarding_orders() + for(var/datum/human_npc_order/order as anything in boarding_orders.Copy()) + if(QDELETED(order) || order.done) + boarding_orders -= order + for(var/datum/human_npc_order/order as anything in wave_orders.Copy()) + if(QDELETED(order) || order.done) + wave_orders -= order + +/// Calls off every boarder of this encounter that hasn't been built yet. +/datum/ai_controller/npc_ship/proc/cancel_boarding_orders() + for(var/datum/human_npc_order/order as anything in boarding_orders) + if(!QDELETED(order)) + qdel(order) + boarding_orders.Cut() + wave_orders.Cut() + /** * Find valid turfs on the target ship for spawning boarders. */ @@ -904,7 +943,7 @@ */ /datum/ai_controller/npc_ship/proc/on_boarder_death(mob/living/victim, gibbed) SIGNAL_HANDLER - UnregisterSignal(victim, COMSIG_LIVING_DEATH) + UnregisterSignal(victim, list(COMSIG_LIVING_DEATH, COMSIG_HUMAN_NPC_DOWNED, SIGNAL_ADDTRAIT(TRAIT_RESTRAINED))) var/list/wave_boarders = blackboard[BB_NPC_BOARDING_WAVE_BOARDERS] if(wave_boarders) @@ -913,8 +952,14 @@ // Check if all boarders are dead INVOKE_ASYNC(src, PROC_REF(check_wave_complete)) +/// A human boarder went into crit or was cuffed: out of the fight, so the wave may be over. +/datum/ai_controller/npc_ship/proc/on_boarder_out_of_fight(mob/living/source) + SIGNAL_HANDLER + INVOKE_ASYNC(src, PROC_REF(check_wave_complete)) + /** - * Check if the current wave is complete (all boarders dead). + * Check if the current wave is complete: every boarder is out of the fight (dead, in crit or cuffed, + * owner ruling OC-7) and none is still waiting to be built. */ /datum/ai_controller/npc_ship/proc/check_wave_complete() // Guard against multiple calls - only process if we're in BOARDING state @@ -922,12 +967,16 @@ if(combat_state != NPC_COMBAT_BOARDING || !validate_boarding_target()) return + prune_boarding_orders() + if(length(wave_orders)) + return // Boarders still on their way + var/list/wave_boarders = blackboard[BB_NPC_BOARDING_WAVE_BOARDERS] - // Count living boarders + // Count boarders still fighting var/living_count = 0 for(var/mob/living/boarder as anything in wave_boarders) - if(!QDELETED(boarder) && boarder.stat != DEAD) + if(!human_npc_out_of_fight(boarder)) living_count++ if(living_count > 0) @@ -981,7 +1030,7 @@ // Notify about cooldown var/next_wave = completed_wave + 1 - target.ship_notify("Wave [completed_wave] repelled! Next wave in 30 seconds...", "COMBAT", SHIP_NOTIFY_NOTICE, 'voidcrew/sound/notify.ogg', 50) + target.ship_notify("Boarders repelled!", "COMBAT", SHIP_NOTIFY_NOTICE, 'voidcrew/sound/notify.ogg', 50) // Schedule next wave boarding_timers += addtimer(CALLBACK(src, PROC_REF(end_wave_cooldown), next_wave), NPC_BOARDING_WAVE_COOLDOWN, TIMER_STOPPABLE) @@ -1071,24 +1120,32 @@ if(!boss_type) return - // Create boss boarding pod - returns the boss for tracking - // Pod handles parent_ship, AI controller swap, and patrol assignment - var/mob/living/basic/trooper/pirate/faction/boss/boss = create_boss_boarding_pod(spawn_loc, target, ship, boss_type) - if(boss) - set_blackboard_key(BB_NPC_BOARDING_BOSS, boss) - RegisterSignal(boss, COMSIG_LIVING_DEATH, PROC_REF(on_boss_death)) - npc_metric_boss_deployed(src, boss) + // Create boss boarding pod. The pod gives the boss its parent_ship; track_boss() follows it from + // the moment it is in its pod (a human boss is built through the spawn queue first). + create_boss_boarding_pod(spawn_loc, target, ship, boss_type, CALLBACK(src, PROC_REF(track_boss))) // Announce boss arrival target.ship_notify("WARNING: Enemy Commander incoming via drop pod!", "SECURITY", SHIP_NOTIFY_DANGER, 'voidcrew/sound/warn3.ogg', 25) +/// The boss is in its pod: watched until it is out of the fight. +/datum/ai_controller/npc_ship/proc/track_boss(mob/living/boss) + prune_boarding_orders() + if(QDELETED(boss)) + return + set_blackboard_key(BB_NPC_BOARDING_BOSS, boss) + RegisterSignal(boss, COMSIG_LIVING_DEATH, PROC_REF(on_boss_death)) + // A human boss in crit or cuffed is beaten as surely as a dead one (owner ruling OC-7) + if(ishumannpc(boss)) + RegisterSignals(boss, list(COMSIG_HUMAN_NPC_DOWNED, SIGNAL_ADDTRAIT(TRAIT_RESTRAINED)), PROC_REF(on_boss_death)) + npc_metric_boss_deployed(src, boss) + /** - * Signal handler for when the boss is killed. + * Signal handler for when the boss is killed, or a human boss is downed or cuffed. * This disables the pirate ship and allows players to board it. */ /datum/ai_controller/npc_ship/proc/on_boss_death(mob/living/victim, gibbed) SIGNAL_HANDLER - UnregisterSignal(victim, COMSIG_LIVING_DEATH) + UnregisterSignal(victim, list(COMSIG_LIVING_DEATH, COMSIG_HUMAN_NPC_DOWNED, SIGNAL_ADDTRAIT(TRAIT_RESTRAINED))) INVOKE_ASYNC(src, PROC_REF(handle_boss_killed)) @@ -1333,6 +1390,8 @@ boarding_timers.Cut() boarding_committed -= boarding_pending boarding_pending = 0 + // Boarders still being built land as part of the raid, outside any wave + wave_orders.Cut() // Unregister from player crew deaths var/list/tracked_crew = blackboard[BB_NPC_BOARDING_PLAYER_CREW] @@ -1345,11 +1404,11 @@ var/list/wave_boarders = blackboard[BB_NPC_BOARDING_WAVE_BOARDERS] for(var/mob/living/boarder as anything in wave_boarders) if(!QDELETED(boarder)) - UnregisterSignal(boarder, COMSIG_LIVING_DEATH) + UnregisterSignal(boarder, list(COMSIG_LIVING_DEATH, COMSIG_HUMAN_NPC_DOWNED, SIGNAL_ADDTRAIT(TRAIT_RESTRAINED))) var/mob/living/boss = blackboard[BB_NPC_BOARDING_BOSS] if(!QDELETED(boss)) - UnregisterSignal(boss, COMSIG_LIVING_DEATH) + UnregisterSignal(boss, list(COMSIG_LIVING_DEATH, COMSIG_HUMAN_NPC_DOWNED, SIGNAL_ADDTRAIT(TRAIT_RESTRAINED))) // Clear boarding blackboard keys clear_blackboard_key(BB_NPC_BOARDING_WAVE) @@ -1397,13 +1456,14 @@ return npc_metric_wave_ended(src, current_wave, "timed_out") - // Clean up current wave boarders + // Clean up current wave boarders; any still on their way land as part of the raid, outside the wave var/list/wave_boarders = blackboard[BB_NPC_BOARDING_WAVE_BOARDERS] if(wave_boarders) for(var/mob/living/boarder as anything in wave_boarders) if(!QDELETED(boarder)) - UnregisterSignal(boarder, COMSIG_LIVING_DEATH) + UnregisterSignal(boarder, list(COMSIG_LIVING_DEATH, COMSIG_HUMAN_NPC_DOWNED, SIGNAL_ADDTRAIT(TRAIT_RESTRAINED))) clear_blackboard_key(BB_NPC_BOARDING_WAVE_BOARDERS) + wave_orders.Cut() if(is_red_zone_raid()) start_boss_cooldown() @@ -1411,8 +1471,9 @@ end_yellow_raid() /** - * Check if any boarders have fallen into space and clean them up. - * This prevents boarders from being "stuck" floating in space after being spaced. + * Boarders that have fallen into space are off the ship and out of this wave. Nothing kills them: space + * does that to an unsuited body, and a suited one drifts until its crew gives it up (pirate_crew.dm, + * check_adrift()). A wave whose last boarders were spaced is over. */ /datum/ai_controller/npc_ship/proc/check_boarders_in_space() var/list/wave_boarders = blackboard[BB_NPC_BOARDING_WAVE_BOARDERS] @@ -1421,21 +1482,17 @@ var/list/spaced_boarders = list() for(var/mob/living/boarder as anything in wave_boarders) - if(QDELETED(boarder)) + if(QDELETED(boarder) || boarder.stat == DEAD) continue - var/turf/boarder_turf = get_turf(boarder) - if(!boarder_turf) - continue - // Check if boarder is in space (not on a ship) - if(isspaceturf(boarder_turf) || istype(get_area(boarder_turf), /area/space)) + if(pirate_crew_member_adrift(boarder)) spaced_boarders += boarder - // Kill spaced boarders (they suffocate in space anyway) + if(!length(spaced_boarders)) + return for(var/mob/living/spaced as anything in spaced_boarders) - if(!QDELETED(spaced) && spaced.stat != DEAD) - spaced.death() - wave_boarders -= spaced - UnregisterSignal(spaced, COMSIG_LIVING_DEATH) + wave_boarders -= spaced + UnregisterSignal(spaced, list(COMSIG_LIVING_DEATH, COMSIG_HUMAN_NPC_DOWNED, SIGNAL_ADDTRAIT(TRAIT_RESTRAINED))) + check_wave_complete() /// Snapshot the target band and connected crew exactly once, including combat-only raids. /datum/ai_controller/npc_ship/proc/capture_boarding_encounter(obj/structure/overmap/ship/target) @@ -1451,6 +1508,7 @@ return reserved /// Timer callbacks must still belong to this encounter after docking or target changes. +/// Returns the boarder, or the order of a human one still being built. /datum/ai_controller/npc_ship/proc/deploy_combat_boarder(turf/spot, obj/structure/overmap/ship/target, mob_type, datum/npc_spawn_context/encounter) if(get_target() != target || boarding_context != encounter) return @@ -1464,10 +1522,6 @@ var/list/spots = get_target_spawn_turfs(target) if(!istype(ship) || !ship.boss_type || !length(spots)) return FALSE - var/mob/living/boss = create_boss_boarding_pod(pick(spots), target, ship, ship.boss_type) - if(!boss) + if(!create_boss_boarding_pod(pick(spots), target, ship, ship.boss_type, CALLBACK(src, PROC_REF(track_boss)))) return FALSE - set_blackboard_key(BB_NPC_BOARDING_BOSS, boss) - RegisterSignal(boss, COMSIG_LIVING_DEATH, PROC_REF(on_boss_death)) - npc_metric_boss_deployed(src, boss) return TRUE diff --git a/voidcrew/modules/npc_ships/code/pirate_crew.dm b/voidcrew/modules/npc_ships/code/pirate_crew.dm index 127b17cbc4b..37ce19f9618 100644 --- a/voidcrew/modules/npc_ships/code/pirate_crew.dm +++ b/voidcrew/modules/npc_ships/code/pirate_crew.dm @@ -8,8 +8,15 @@ * * Once alerted, a crew knows where every hostile on its battlefield is, refreshed every few * seconds, and sends its hunters after them. Players can dodge but can't hide. The captain - * and one guard hold the helm until most of the crew is dead. The per-mob behaviour lives in - * pirate_crew_ai.dm. + * and one guard hold the helm until most of the crew is out of the fight. The per-mob behaviour + * lives in pirate_crew_ai.dm, and for the human NPC crews every NPC ship now has, in + * pirate_crew_human.dm. + * + * A member counts as out of the fight once it is dead, in crit or cuffed (human_npc_out_of_fight(), + * owner ruling OC-7): it no longer hunts or holds the helm. A member adrift in space with no player + * near enough to see it is cleaned up after PIRATE_CREW_ADRIFT_TIME (check_adrift()): it can't get + * back aboard, and a body drifting alive forever would hold its crew open. That is bookkeeping, not a + * death: one drifting where a player can see it stays. */ /// Defending crews, by REF() of the NPC hull they crew @@ -38,9 +45,14 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( "Fine. I'll do it myself.", )) +/// Whether `recruit` is a body a pirate crew can take on: a basic mob, or a human NPC +/// (voidcrew/modules/human_npcs/). Human members still need their own ranged and breach behaviours. +/proc/pirate_crew_can_enlist(mob/living/recruit) + return isbasicmob(recruit) || ishumannpc(recruit) + /// Enlists `recruit` in the crew defending `hull`, making the crew if it has none yet /proc/pirate_crew_enlist_defender(mob/living/recruit, obj/structure/overmap/ship/hull, role = PIRATE_ROLE_HUNTER) - if(QDELETED(hull) || !isbasicmob(recruit) || QDELETED(recruit)) + if(QDELETED(hull) || !pirate_crew_can_enlist(recruit) || QDELETED(recruit)) return FALSE var/datum/pirate_crew/crew = pirate_crew_of(hull, FALSE) if(!crew) @@ -49,7 +61,7 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( /// Enlists `recruit` in the raid on `target`, making the raid if there is none yet /proc/pirate_crew_enlist_raider(mob/living/recruit, obj/structure/overmap/ship/target) - if(QDELETED(target) || !isbasicmob(recruit) || QDELETED(recruit)) + if(QDELETED(target) || !pirate_crew_can_enlist(recruit) || QDELETED(recruit)) return FALSE var/datum/pirate_crew/crew = pirate_crew_of(target, TRUE) if(!crew) @@ -64,8 +76,10 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( var/datum/pirate_crew/crew = registry[REF(ship)] return QDELETED(crew) ? null : crew -/// The controller a pirate gets when it joins a crew: ranged if it was a ranged trooper -/proc/pirate_crew_controller_type(mob/living/basic/recruit) +/// The controller a pirate gets when it joins a crew: the human one for a human NPC, else ranged if it was a ranged trooper +/proc/pirate_crew_controller_type(mob/living/recruit) + if(ishumannpc(recruit)) + return /datum/ai_controller/basic_controller/pirate_crew/human var/datum/ai_controller/current = recruit?.ai_controller if(istype(current, /datum/ai_controller/basic_controller/trooper/ranged) || istype(current, /datum/ai_controller/basic_controller/pirate_crew/ranged)) return /datum/ai_controller/basic_controller/pirate_crew/ranged @@ -73,15 +87,23 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( /// What `speaker` says for a PIRATE_BARK_* moment. Faction pirates may carry their own lines. /proc/pirate_crew_bark_lines(mob/living/speaker, kind) + var/list/alert_lines + var/list/spot_lines var/mob/living/basic/trooper/pirate/faction/faction_pirate = speaker + var/mob/living/carbon/human/npc/faction_pirate/crewman = speaker if(istype(faction_pirate)) - switch(kind) - if(PIRATE_BARK_ALERT) - if(length(faction_pirate.crew_alert_lines)) - return faction_pirate.crew_alert_lines - if(PIRATE_BARK_SPOT) - if(length(faction_pirate.crew_spot_lines)) - return faction_pirate.crew_spot_lines + alert_lines = faction_pirate.crew_alert_lines + spot_lines = faction_pirate.crew_spot_lines + else if(istype(crewman)) + alert_lines = crewman.crew_alert_lines + spot_lines = crewman.crew_spot_lines + switch(kind) + if(PIRATE_BARK_ALERT) + if(length(alert_lines)) + return alert_lines + if(PIRATE_BARK_SPOT) + if(length(spot_lines)) + return spot_lines switch(kind) if(PIRATE_BARK_ALERT) return GLOB.pirate_crew_alert_lines @@ -148,6 +170,8 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( var/battlefield_dirty = TRUE /// Whether the raiding crew has had its arrival line var/arrival_barked = FALSE + /// Members adrift in space, mob -> world.time they were first found adrift + var/list/adrift_since = list() COOLDOWN_DECLARE(intel_cooldown) COOLDOWN_DECLARE(battlefield_cooldown) COOLDOWN_DECLARE(spot_bark_cooldown) @@ -191,6 +215,7 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( controller.reset_ai_status() members.Cut() home_turfs.Cut() + adrift_since.Cut() for(var/mob/living/hostile in known_hostiles) UnregisterSignal(hostile, COMSIG_QDELETING) known_hostiles.Cut() @@ -207,7 +232,7 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( * role. A defending crew's first non-captain becomes the guard; a melee recruit takes the * job off a ranged guard while the crew is still calm. */ -/datum/pirate_crew/proc/enlist(mob/living/basic/recruit, role = PIRATE_ROLE_HUNTER) +/datum/pirate_crew/proc/enlist(mob/living/recruit, role = PIRATE_ROLE_HUNTER) if(QDELETED(recruit) || recruit.stat == DEAD) return FALSE if(raiding || isnull(role)) @@ -220,7 +245,6 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( home_turfs -= recruit return FALSE if(!already_member) - pirate_crew_arm(recruit) RegisterSignal(recruit, COMSIG_LIVING_DEATH, PROC_REF(on_member_lost)) RegisterSignal(recruit, COMSIG_QDELETING, PROC_REF(on_member_lost)) if(!raiding && role != PIRATE_ROLE_CAPTAIN) @@ -236,10 +260,15 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( return TRUE /// Puts `member` on a pirate crew controller wired to this crew. Returns the controller. -/datum/pirate_crew/proc/attach_controller(mob/living/basic/member, role) +/datum/pirate_crew/proc/attach_controller(mob/living/member, role) var/datum/ai_controller/basic_controller/pirate_crew/controller = swap_basic_ai_controller(member, pirate_crew_controller_type(member)) if(!istype(controller)) return null + // A human NPC's family decides who it keeps attacking (pirates: until hard crit); a fresh controller + // starts on its type's default + if(ishumannpc(member)) + var/mob/living/carbon/human/npc/human_member = member + controller.set_blackboard_key(BB_TARGET_MINIMUM_STAT, human_member.npc_target_stat) // A member handed over from another crew starts this crew's bookkeeping afresh if(controller.blackboard[BB_PIRATE_CREW] != src) controller.last_battlefield_turf = null @@ -277,8 +306,10 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( set_role(guard, PIRATE_ROLE_HUNTER) set_role(recruit, PIRATE_ROLE_GUARD) -/// Whether `member` fights at range +/// Whether `member` fights at range: a human carrying a gun it may use, or a basic mob on the ranged controller /proc/pirate_crew_is_ranged(mob/living/member) + if(ishuman(member)) + return pirate_crew_human_gunner(member) return istype(member?.ai_controller, /datum/ai_controller/basic_controller/pirate_crew/ranged) /datum/pirate_crew/proc/on_member_lost(mob/living/source) @@ -291,6 +322,7 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( UnregisterSignal(member, list(COMSIG_LIVING_DEATH, COMSIG_QDELETING)) members -= member home_turfs -= member + adrift_since -= member if(!length(members)) qdel(src) @@ -484,7 +516,8 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( /datum/pirate_crew/proc/assign_hunts() var/list/hunters = list() for(var/mob/living/member in members) - if(QDELETED(member) || member.stat == DEAD || !member.ai_controller) + // Down or cuffed: not hunting anyone + if(QDELETED(member) || human_npc_out_of_fight(member) || !member.ai_controller) continue if(holds_post(member)) member.ai_controller.clear_blackboard_key(BB_PIRATE_HUNT_TARGET) @@ -568,13 +601,13 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( controller.can_idle = TRUE controller.reset_ai_status() -/// The captain and the guard join the hunt once the rest of the crew is mostly dead +/// The captain and the guard join the hunt once the rest of the crew is mostly out of the fight /datum/pirate_crew/proc/check_promotion() if(promoted || raiding) return var/living = 0 for(var/mob/living/member in members) - if(members[member] != PIRATE_ROLE_CAPTAIN && member.stat != DEAD) + if(members[member] != PIRATE_ROLE_CAPTAIN && !human_npc_out_of_fight(member)) living++ if(living > min(starting_crew / 3, 1)) return @@ -584,13 +617,14 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( // ===== BARKS ===== +/// A crew shout from `speaker`. Ordinary speech (defaults PI-18): a gagged or muted pirate says nothing. /datum/pirate_crew/proc/bark(mob/living/speaker, kind) - if(QDELETED(speaker) || speaker.stat != CONSCIOUS) + if(QDELETED(speaker) || speaker.stat != CONSCIOUS || !speaker.can_speak()) return FALSE var/list/lines = pirate_crew_bark_lines(speaker, kind) if(!length(lines)) return FALSE - INVOKE_ASYNC(speaker, TYPE_PROC_REF(/atom/movable, say), message = pick(lines), forced = "pirate crew") + INVOKE_ASYNC(speaker, TYPE_PROC_REF(/atom/movable, say), message = pick(lines)) return TRUE /// `member` saw `target`: tell the crew, and maybe shout about it @@ -625,6 +659,9 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( if(battlefield_dirty || COOLDOWN_FINISHED(src, battlefield_cooldown)) refresh_battlefield() check_members() + if(QDELETED(src)) + return PROCESS_KILL + check_adrift() if(QDELETED(src)) return PROCESS_KILL if(!alerted) @@ -646,7 +683,8 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( */ /datum/pirate_crew/proc/check_members() var/list/stranded = list() - for(var/mob/living/basic/member in members) + // Every member, human NPCs included: a loop typed to basic mobs skipped them silently. + for(var/mob/living/member in members) if(QDELETED(member) || member.stat == DEAD || GET_CLIENT(member)) continue var/datum/ai_controller/controller = member.ai_controller @@ -660,13 +698,47 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( var/obj/structure/overmap/ship/other = pirate_crew_ship_at(where) if(other && other != home_ship) stranded[member] = other - for(var/mob/living/basic/member as anything in stranded) + for(var/mob/living/member as anything in stranded) var/obj/structure/overmap/ship/other = stranded[member] remove_member(member) pirate_crew_enlist_raider(member, other) if(QDELETED(src)) return +/** + * Cleans up members adrift in space that no player can see, once they have drifted for + * PIRATE_CREW_ADRIFT_TIME. Space kills a pirate without a suit on its own; a suited one would drift + * alive forever, off its battlefield, holding its crew and its hull's pool slot open. A human NPC goes + * the way one that walks out does (npc_vanish(): what it carries that isn't gear, a ship key, drops where + * it was). See the top of this file. + */ +/datum/pirate_crew/proc/check_adrift() + for(var/mob/living/member as anything in members.Copy()) + if(QDELETED(member) || member.stat == DEAD || GET_CLIENT(member) || !pirate_crew_member_adrift(member)) + adrift_since -= member + continue + if(isnull(adrift_since[member])) + adrift_since[member] = world.time + continue + if(world.time < adrift_since[member] + PIRATE_CREW_ADRIFT_TIME || human_npc_watched(member)) + continue + log_shuttle("PIRATE_CREW: [member] was lost adrift at [AREACOORD(member)]") + remove_member(member) + if(ishumannpc(member)) + var/mob/living/carbon/human/npc/lost = member + lost.npc_vanish() + else + qdel(member) + if(QDELETED(src)) + return + +/// Whether `member` is floating in space, off any ship's deck +/proc/pirate_crew_member_adrift(mob/living/member) + var/turf/where = get_turf(member) + if(isnull(where) || !isturf(member.loc)) + return FALSE + return isspaceturf(where) || istype(get_area(where), /area/space) + // ===== HOME SHIP SIGNALS ===== /datum/pirate_crew/proc/on_home_ship_deleted(datum/source) @@ -710,9 +782,12 @@ GLOBAL_LIST_INIT(pirate_crew_captain_lines, list( behavior_names += replacetext("[behavior.type]", "/datum/ai_behavior/", "") text += ": [controller.ai_status][controller.can_idle ? " (may idle)" : ""][controller.able_to_plan ? "" : " (planning blocked)"][controller.on_failed_planning_timeout ? " (planning timeout)" : ""]" text += ", doing [length(behavior_names) ? jointext(behavior_names, " + ") : "nothing"]" - var/datum/component/pirate_gun/gun = pirate_gun_of(member) - if(gun) - text += ", [gun.status_text()]" + if(ishuman(member)) + var/obj/item/gun/gun = human_npc_held_gun(member) + if(gun) + text += ", holding [gun][gun.can_shoot() ? "" : " (empty)"]" + if(human_npc_out_of_fight(member)) + text += " (out of the fight)" var/atom/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] text += ", target [target ? "[target]" : "none"]" var/mob/hunt = controller.blackboard[BB_PIRATE_HUNT_TARGET] diff --git a/voidcrew/modules/npc_ships/code/pirate_crew_ai.dm b/voidcrew/modules/npc_ships/code/pirate_crew_ai.dm index b2dbe66ce31..f0fb4024e87 100644 --- a/voidcrew/modules/npc_ships/code/pirate_crew_ai.dm +++ b/voidcrew/modules/npc_ships/code/pirate_crew_ai.dm @@ -4,6 +4,10 @@ * Fights whoever it can see, breaks through doors that won't open for it, holds the helm if it * is the captain or the guard, and otherwise walks to wherever the crew last knew a hostile to * be. Doors it may open are walked through, never hit. Allies in a corridor swap places. + * + * NPC ship crews and boarders are human NPCs and run the human controller (pirate_crew_human.dm), + * which fights and breaks doors with the body's own hands. The basic-mob controllers below are what + * a basic pirate gets if it is enlisted (an admin spawn, a basic boarding type). */ // ===== CONTROLLERS ===== @@ -67,8 +71,6 @@ * or away from the helm, since nothing would get to check. */ /datum/ai_planning_subtree/basic_ranged_attack_subtree/trooper/pirate_crew - // Stock gunfire, or a rolled pirate gun (pirate_guns.dm) - operational_datums = list(/datum/component/ranged_attacks, /datum/component/pirate_gun) ranged_attack_behavior = /datum/ai_behavior/basic_ranged_attack/trooper/pirate_crew /datum/ai_planning_subtree/basic_ranged_attack_subtree/trooper/pirate_crew/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) @@ -78,20 +80,12 @@ var/behavior = ranged_attack_behavior if(istype(pirate_controller) && pirate_controller.target_hold_ground) behavior = /datum/ai_behavior/basic_ranged_attack/trooper/pirate_crew/hold_ground - else - var/datum/component/pirate_gun/gun = pirate_gun_of(controller.pawn) - if(gun?.loadout.close_range) - behavior = /datum/ai_behavior/basic_ranged_attack/trooper/pirate_crew/close controller.queue_behavior(behavior, BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETING_STRATEGY, BB_BASIC_MOB_CURRENT_TARGET_HIDING_LOCATION) return SUBTREE_RETURN_FINISH_PLANNING /datum/ai_behavior/basic_ranged_attack/trooper/pirate_crew behavior_flags = AI_BEHAVIOR_REQUIRE_MOVEMENT | AI_BEHAVIOR_MOVE_AND_PERFORM | AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION -/// A shotgunner walks in close before it fires -/datum/ai_behavior/basic_ranged_attack/trooper/pirate_crew/close - required_distance = 3 - /// Returns fire at someone it may not go after (off the battlefield, or past the helm's leash) without taking a step towards them /datum/ai_behavior/basic_ranged_attack/trooper/pirate_crew/hold_ground required_distance = PIRATE_CREW_SIGHT_RANGE @@ -129,8 +123,7 @@ if(QDELETED(target)) return FALSE if(istype(src, /datum/ai_controller/basic_controller/pirate_crew/ranged)) - var/datum/component/pirate_gun/gun = pirate_gun_of(pawn) - return can_see(pawn, target, gun?.loadout.close_range || 5) + return can_see(pawn, target, 5) return get_dist(pawn, target) <= 1 // ----- Door bookkeeping ----- @@ -155,12 +148,16 @@ set_blackboard_key(BB_PIRATE_BREACH_STAND, stand || get_turf(pawn)) set_blackboard_key(BB_PIRATE_BREACH_TURF, get_turf(target)) set_blackboard_key(BB_PIRATE_BREACH_STARTED, world.time) + clear_blackboard_key(BB_PIRATE_BREACH_INTEGRITY) + clear_blackboard_key(BB_PIRATE_BREACH_PROGRESS_AT) /datum/ai_controller/basic_controller/pirate_crew/proc/clear_breach() clear_blackboard_key(BB_PIRATE_BREACH_TARGET) clear_blackboard_key(BB_PIRATE_BREACH_STAND) clear_blackboard_key(BB_PIRATE_BREACH_TURF) clear_blackboard_key(BB_PIRATE_BREACH_STARTED) + clear_blackboard_key(BB_PIRATE_BREACH_INTEGRITY) + clear_blackboard_key(BB_PIRATE_BREACH_PROGRESS_AT) // ----- Pawn signals ----- @@ -428,8 +425,15 @@ if(isliving(requester) && istype(requester.ai_controller, /datum/ai_controller/basic_controller/pirate_crew)) return TRUE -/// Whether breaking `door` would open the ship to space: an external airlock or blast door with nothing beyond it +/** + * Whether breaking `door` would open the ship to space: an external airlock or blast door with nothing + * beyond it, or a firelock holding back a room that has lost its air. + */ /proc/pirate_door_vents_space(obj/machinery/door/door, turf/from) + if(istype(door, /obj/machinery/door/firedoor)) + var/turf/firelock_turf = get_turf(door) + var/turf/beyond = (from && firelock_turf) ? get_turf_through_door(from, firelock_turf) : null + return beyond && !is_safe_turf(beyond, TRUE, FALSE) if(!istype(door, /obj/machinery/door/airlock/external) && !istype(door, /obj/machinery/door/poddoor)) return FALSE var/turf/door_turf = get_turf(door) @@ -582,7 +586,12 @@ return pirate_controller.target_hold_ground = (target_reach(pirate_controller, crew, found) == PIRATE_TARGET_HOLD) controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, found) - crew?.on_member_spotted(pawn, found) + if(crew) + crew.on_member_spotted(pawn, found) + else if(ishumannpc(pawn)) + // A faction pirate met in a ruin or a contract, with no crew to tell + var/mob/living/carbon/human/npc/loner = pawn + loner.npc_bark(PIRATE_BARK_SPOT) /datum/ai_planning_subtree/pirate_crew_find_target/proc/scan_for_target(datum/ai_controller/basic_controller/pirate_crew/controller, datum/pirate_crew/crew, datum/targeting_strategy/strategy, mob/living/basic/pawn, turf/pawn_turf) var/atom/best_player @@ -628,7 +637,7 @@ * battlefield or only just off it on solid ground, and within PIRATE_CREW_POST_LEASH of the helm * for the captain and the guard. Past that a gunner standing on the battlefield still shoots back * at a player from where it stands (PIRATE_TARGET_HOLD); anything else is let go (PIRATE_TARGET_OUT). - * Nobody follows a target into space, where the spaced-crew sweeps would kill them. + * Nobody follows a target into space: a crewman adrift is lost to the crew (pirate_crew.dm). */ /datum/ai_planning_subtree/pirate_crew_find_target/proc/target_reach(datum/ai_controller/basic_controller/pirate_crew/controller, datum/pirate_crew/crew, atom/target) if(!crew) @@ -638,7 +647,7 @@ return PIRATE_TARGET_OUT var/mob/living/pawn = controller.pawn var/fallback = PIRATE_TARGET_OUT - if(istype(controller, /datum/ai_controller/basic_controller/pirate_crew/ranged) && crew.turf_on_battlefield(get_turf(pawn)) && pirate_crew_player_target(target)) + if(pirate_crew_is_ranged(pawn) && crew.turf_on_battlefield(get_turf(pawn)) && pirate_crew_player_target(target)) fallback = PIRATE_TARGET_HOLD if(crew.holds_post(pawn)) var/turf/post = crew.post_for(pawn) @@ -740,8 +749,14 @@ if(!pirate_door_breachable(blocker, stand)) controller.skip_door(blocker) return FALSE + // Given up once a stretch goes by with the door taking no damage at all: a human shooting a door + // open takes longer than a basic mob smashing it, but gets somewhere. var/started = controller.blackboard[BB_PIRATE_BREACH_STARTED] || world.time - if(world.time > started + PIRATE_CREW_BREACH_GIVE_UP) + if(blocker.atom_integrity < (controller.blackboard[BB_PIRATE_BREACH_INTEGRITY] || INFINITY)) + controller.set_blackboard_key(BB_PIRATE_BREACH_INTEGRITY, blocker.atom_integrity) + controller.set_blackboard_key(BB_PIRATE_BREACH_PROGRESS_AT, world.time) + var/progress_at = max(started, controller.blackboard[BB_PIRATE_BREACH_PROGRESS_AT]) + if(world.time > progress_at + PIRATE_CREW_BREACH_GIVE_UP) log_shuttle("PIRATE_CREW: [pawn] gave up breaking [blocker] at [AREACOORD(blocker)]") controller.skip_door(blocker) return FALSE @@ -911,12 +926,28 @@ /datum/ai_behavior/pirate_crew_breach/perform(seconds_per_tick, datum/ai_controller/controller, target_key, stand_key) var/obj/blocker = controller.blackboard[target_key] - var/mob/living/basic/pawn = controller.pawn + var/mob/living/pawn = controller.pawn if(QDELETED(blocker) || !blocker.density) return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED if(istype(blocker, /obj/machinery/door) && pirate_can_open_door(pawn, blocker)) return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED - if(!isbasicmob(pawn) || !pawn.Adjacent(blocker)) + if(ishuman(pawn)) + // A person's hands: pry it, shoot it from a step back, or hit it (pirate_crew_human.dm) + var/turf/stand = controller.blackboard[stand_key] || get_turf(pawn) + var/turf/spot = pirate_crew_human_breach_spot(pawn, blocker, stand) + if(controller.current_movement_target != spot) + set_movement_target(controller, spot) + if(get_turf(pawn) != spot && !(spot == stand && pawn.Adjacent(blocker))) + return AI_BEHAVIOR_DELAY + if(!pirate_crew_human_breach(controller, pawn, blocker)) + // Nothing it carries can hurt this door: leave it to someone who can + var/datum/ai_controller/basic_controller/pirate_crew/pirate_controller = controller + pirate_controller.skip_door(blocker) + pirate_controller.clear_breach() + return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_DELAY + var/mob/living/basic/basic_pawn = pawn + if(!isbasicmob(basic_pawn) || !basic_pawn.Adjacent(blocker)) return AI_BEHAVIOR_DELAY - pawn.melee_attack(blocker) + basic_pawn.melee_attack(blocker) return AI_BEHAVIOR_DELAY diff --git a/voidcrew/modules/npc_ships/code/pirate_crew_combat_sense.dm b/voidcrew/modules/npc_ships/code/pirate_crew_combat_sense.dm new file mode 100644 index 00000000000..d3c42984a75 --- /dev/null +++ b/voidcrew/modules/npc_ships/code/pirate_crew_combat_sense.dm @@ -0,0 +1,47 @@ +/** + * Combat sense for faction pirates (voidcrew/modules/human_npcs/human_npc_combat_sense.dm): NPC ship crews, + * boarders, NT customs and the crews squatting in ruins, every faction and rank. + * + * What they carry is #509's and unchanged: the rank and file no stimulant; captains a combat stimpack and + * bosses a stimulant pen, which they inject as their fight starts (pirate_crew_human_self_care). So the + * stimulant half only ever fires for a pirate still holding an unused stimulant. Under stun fire: + * - a gunner runs for cover, but only on its crew's battlefield, a captain or helm guard only within + * PIRATE_CREW_POST_LEASH of its post, and a pirate with no crew only within PIRATE_CREWLESS_LEASH of + * where it was put; never onto open space; + * - a gunner told to hold its ground against someone off the battlefield (target_hold_ground) stays put + * and shoots back, as before; + * - a melee pirate, or a shotgunner (its gun handling's close_range), charges the shooter. + */ +/datum/npc_combat_sense/pirate_crew + +/mob/living/carbon/human/npc/faction_pirate + npc_combat_sense = /datum/npc_combat_sense/pirate_crew + +/datum/npc_combat_sense/pirate_crew/may_move(mob/living/carbon/human/npc, datum/ai_controller/controller) + var/datum/ai_controller/basic_controller/pirate_crew/pirate_controller = controller + return !(istype(pirate_controller) && pirate_controller.target_hold_ground) + +/datum/npc_combat_sense/pirate_crew/reach(mob/living/carbon/human/npc, datum/ai_controller/controller) + if(!pirate_crew_human_gunner(npc)) + return 1 + var/obj/item/gun/gun = human_npc_held_gun(npc) + if(gun) + var/datum/pirate_gun_handling/handling = pirate_gun_handling_for(gun) + if(handling?.close_range) + return handling.close_range + return controller.blackboard[BB_HUMAN_NPC_FIRE_RANGE] || 7 + +/datum/npc_combat_sense/pirate_crew/tile_ok(mob/living/carbon/human/npc, datum/ai_controller/controller, turf/tile) + if(!..() || pirate_turf_is_void(tile)) + return FALSE + var/datum/ai_controller/basic_controller/pirate_crew/pirate_controller = controller + var/datum/pirate_crew/crew = istype(pirate_controller) ? pirate_controller.get_crew() : null + if(crew) + if(!crew.turf_on_battlefield(tile)) + return FALSE + if(!crew.holds_post(npc)) + return TRUE + var/turf/post = crew.post_for(npc) + return isnull(post) || (post.z == tile.z && get_dist(post, tile) <= PIRATE_CREW_POST_LEASH) + var/turf/home = controller.blackboard[BB_PIRATE_CREWLESS_HOME] + return isnull(home) || home.z != tile.z || get_dist(home, tile) <= PIRATE_CREWLESS_LEASH diff --git a/voidcrew/modules/npc_ships/code/pirate_crew_human.dm b/voidcrew/modules/npc_ships/code/pirate_crew_human.dm new file mode 100644 index 00000000000..276364b569f --- /dev/null +++ b/voidcrew/modules/npc_ships/code/pirate_crew_human.dm @@ -0,0 +1,503 @@ +/** + * Pirate crew AI on human NPC bodies (human NPC migration, phase B). + * + * The crew AI itself is PR #500's (pirate_crew.dm, pirate_crew_ai.dm): the crew's intel, the captain and + * guard at the helm, the hunt, door breaking that never vents a ship, swapping places in corridors. This + * file gives it a human body's hands, through the human NPC base (voidcrew/modules/human_npcs/): + * - it runs in soft crit and while cuffed (human_npc_ai_able_to_run()), with the soft-crit branch first, + * so a downed pirate crawls, pleads and, if it is an elite or a boss, fires wild, and a cuffed one + * works at its cuffs; + * - gunners fire the real gun in their hands in volleys (pirate_guns.dm), reload from the magazines and + * shells they carry the way a player does, and fight with a knife or their fists when they run dry; + * - doors that won't open are pried with a crowbar or a fireaxe it carries (an unpowered airlock, a + * firelock), else shot, else hit with a blade heavy enough to dent them; + * - captains and bosses inject the stimulant they carry when their fight starts; a boss with a flask + * drinks from it when hurt; a boss gunner puts its gun to the head of a hunter who is down (the + * hyperviolence execution, with its wind-up the crew can interrupt), once a minute at most. + * Everything goes through ai_interact(), a player's click. + */ + +/datum/ai_controller/basic_controller/pirate_crew/human + blackboard = list( + BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/human_npc, + BB_TARGET_MINIMUM_STAT = HARD_CRIT, + BB_AGGRO_RANGE = PIRATE_CREW_SIGHT_RANGE, + BB_HUMAN_NPC_SHOT_DELAY = 3 SECONDS, + BB_HUMAN_NPC_FIRE_RANGE = 7, + BB_HUMAN_NPC_KEEP_AWAY = 2, + ) + // Holds still through its own do_afters: a cuff breakout, a gun to someone's head + ai_traits = PAUSE_DURING_DO_AFTER + planning_subtrees = list( + /datum/ai_planning_subtree/human_npc_soft_crit, + /datum/ai_planning_subtree/escape_captivity, + /datum/ai_planning_subtree/human_npc_surrender/crewless, + /datum/ai_planning_subtree/pirate_crew_find_target, + /datum/ai_planning_subtree/pirate_crew_human_self_care, + /datum/ai_planning_subtree/npc_combat_sense, + /datum/ai_planning_subtree/pirate_crew_doors, + /datum/ai_planning_subtree/human_npc_arm/pirate_crew, + /datum/ai_planning_subtree/pirate_crew_human_shoot, + /datum/ai_planning_subtree/human_npc_melee/pirate_crew, + /datum/ai_planning_subtree/pirate_crew_hold_post, + /datum/ai_planning_subtree/pirate_crew_hunt, + /datum/ai_planning_subtree/pirate_crew_leash, + /datum/ai_planning_subtree/pirate_crewless_home, + ) + +/datum/ai_controller/basic_controller/pirate_crew/human/TryPossessPawn(atom/new_pawn) + if(!ishuman(new_pawn)) + return AI_CONTROLLER_INCOMPATIBLE + return ..() + +// The human NPC base's run check: cuffs and soft crit don't stop it (human_npc_soft_crit.dm). +/datum/ai_controller/basic_controller/pirate_crew/human/get_able_to_run() + return human_npc_ai_able_to_run(src) + +/datum/ai_controller/basic_controller/pirate_crew/human/on_stat_changed(mob/living/source, new_stat) + . = ..() + human_npc_ai_stat_changed(src, new_stat) + +// A hit during an SMG's spin-up or a shotgun's aim spoils the volley. +/datum/ai_controller/basic_controller/pirate_crew/human/on_pawn_damaged(mob/living/source, damage_dealt) + . = ..() + if(damage_dealt <= 0 || blackboard[BB_PIRATE_WINDUP_UNTIL] <= world.time) + return + clear_blackboard_key(BB_PIRATE_WINDUP_UNTIL) + set_blackboard_key(BB_PIRATE_VOLLEY_LEFT, 0) + set_blackboard_key(BB_HUMAN_NPC_NEXT_SHOT, world.time + 1 SECONDS) + +/datum/ai_controller/basic_controller/pirate_crew/human/can_hit_now(atom/target) + if(QDELETED(target)) + return FALSE + var/mob/living/carbon/npc = pawn + var/obj/item/gun/gun = human_npc_loaded_gun(npc) + if(gun) + var/datum/pirate_gun_handling/handling = pirate_gun_handling_for(gun) + var/reach = handling.close_range || blackboard[BB_HUMAN_NPC_FIRE_RANGE] || 7 + return get_dist(npc, target) <= reach && can_see(npc, target, reach) + return npc.Adjacent(target) + +// ===== WITH NO CREW: ruins, planets, contracts ===== + +/// A pirate with no crew gives up by its family's rules (npc_surrender, human_npc_surrender.dm). One in a +/// crew fights on with it. +/datum/ai_planning_subtree/human_npc_surrender/crewless + +/datum/ai_planning_subtree/human_npc_surrender/crewless/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/datum/ai_controller/basic_controller/pirate_crew/pirate_controller = controller + if(istype(pirate_controller) && pirate_controller.get_crew()) + return + return ..() + +/// A pirate with no crew and nobody to fight walks back to where it was put once it has strayed more +/// than PIRATE_CREWLESS_LEASH tiles (a chase, a flight from its surrender). +/datum/ai_planning_subtree/pirate_crewless_home + +/datum/ai_planning_subtree/pirate_crewless_home/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/datum/ai_controller/basic_controller/pirate_crew/pirate_controller = controller + if(!istype(pirate_controller) || pirate_controller.get_crew() || controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + return + var/turf/home = controller.blackboard[BB_PIRATE_CREWLESS_HOME] + var/turf/here = get_turf(controller.pawn) + if(isnull(home) || isnull(here) || home.z != here.z) + return + if(get_dist(here, home) <= PIRATE_CREWLESS_LEASH) + return + controller.set_blackboard_key(BB_PIRATE_RETURN_TURF, home) + controller.queue_behavior(/datum/ai_behavior/pirate_crew_travel/leash, BB_PIRATE_RETURN_TURF) + return SUBTREE_RETURN_FINISH_PLANNING + +/// Whether a human crewman fights at range: it holds or carries a gun it can fire, and may use guns. +/proc/pirate_crew_human_gunner(mob/living/carbon/human/npc) + if(HAS_TRAIT(npc, TRAIT_NOGUNS)) + return FALSE + if(locate(/obj/item/gun) in npc.held_items) + return TRUE + return length(npc.get_all_contents_type(/obj/item/gun)) > 0 + +// ===== ARMING: the base's reload and draw, with the crew's reload shouts ===== + +/datum/ai_planning_subtree/human_npc_arm/pirate_crew + +/datum/ai_planning_subtree/human_npc_arm/pirate_crew/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/npc = controller.pawn + var/obj/item/gun/gun = human_npc_held_gun(npc) + var/was_dry = gun && !gun.can_shoot() + // A pump racked between shells is no reload worth shouting about + var/just_racking = istype(gun, /obj/item/gun/ballistic) && human_npc_gun_needs_rack(gun) + . = ..() + if(. != SUBTREE_RETURN_FINISH_PLANNING || !was_dry || just_racking || !prob(PIRATE_CREW_RELOAD_BARK_CHANCE)) + return + var/datum/pirate_gun_handling/handling = pirate_gun_handling_for(gun) + var/list/lines = human_npc_can_reload(npc, gun) ? handling.reload_lines : handling.dry_lines + if(length(lines) && human_npc_can_talk(npc)) + INVOKE_ASYNC(npc, TYPE_PROC_REF(/atom/movable, say), pick(lines)) + +// ===== SHOOTING ===== + +/** + * With a loaded gun in hand: fires its volleys at the target from up to the gun's range (a shotgunner + * walks in to three tiles first), stepping back from anyone too close, and closing in when it can't see + * them. A gunner told to hold its ground (target_reach()) shoots back from where it stands and never + * takes a step after them. A boss gunner whose target is down puts the gun to their head instead. + */ +/datum/ai_planning_subtree/pirate_crew_human_shoot + +/datum/ai_planning_subtree/pirate_crew_human_shoot/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/atom/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(QDELETED(target)) + return + var/mob/living/carbon/human/npc/npc = controller.pawn + if(HAS_TRAIT(npc, TRAIT_HANDS_BLOCKED) || LAZYLEN(npc.do_afters)) + return + var/obj/item/gun/gun = human_npc_loaded_gun(npc) + if(isnull(gun)) + return + var/datum/ai_controller/basic_controller/pirate_crew/pirate_controller = controller + var/hold = istype(pirate_controller) && pirate_controller.target_hold_ground + if(!hold && pirate_crew_human_wants_execution(controller, npc, target)) + if(npc.Adjacent(target)) + controller.queue_behavior(/datum/ai_behavior/pirate_crew_human_execute, BB_BASIC_MOB_CURRENT_TARGET) + else + controller.queue_behavior(/datum/ai_behavior/human_npc_close_in, BB_BASIC_MOB_CURRENT_TARGET, 1) + return SUBTREE_RETURN_FINISH_PLANNING + var/datum/pirate_gun_handling/handling = pirate_gun_handling_for(gun) + var/fire_range = hold ? PIRATE_CREW_SIGHT_RANGE : (handling.close_range || controller.blackboard[BB_HUMAN_NPC_FIRE_RANGE] || 7) + var/distance = get_dist(npc, target) + if(distance <= fire_range && can_see(npc, target, fire_range)) + var/keep_away = controller.blackboard[BB_HUMAN_NPC_KEEP_AWAY] + if(!hold && !handling.close_range && keep_away && distance < keep_away) + controller.queue_behavior(/datum/ai_behavior/step_away, BB_BASIC_MOB_CURRENT_TARGET) + controller.queue_behavior(/datum/ai_behavior/pirate_crew_human_shoot, BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETING_STRATEGY, BB_BASIC_MOB_CURRENT_TARGET_HIDING_LOCATION) + return SUBTREE_RETURN_FINISH_PLANNING + if(hold) + return + controller.queue_behavior(/datum/ai_behavior/human_npc_close_in, BB_BASIC_MOB_CURRENT_TARGET, fire_range) + return SUBTREE_RETURN_FINISH_PLANNING + +/** + * One pull of the trigger per step of a volley (pirate_guns.dm). A volley that needs a spin-up or a + * moment's aim waits for it first; a hit in that moment spoils it (the controller's on_pawn_damaged()). + * Doesn't hold up planning. + */ +/datum/ai_behavior/pirate_crew_human_shoot + action_cooldown = 0.1 SECONDS + behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/pirate_crew_human_shoot/perform(seconds_per_tick, datum/ai_controller/controller, target_key, targeting_strategy_key, hiding_location_key) + var/mob/living/carbon/npc = controller.pawn + var/atom/target = controller.blackboard[target_key] + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(controller.blackboard[targeting_strategy_key]) + if(QDELETED(target) || !strategy?.can_attack(npc, target)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + var/obj/item/gun/gun = human_npc_loaded_gun(npc) + if(isnull(gun)) + // Empty now: the next plan reloads or changes weapon + controller.set_blackboard_key(BB_PIRATE_VOLLEY_LEFT, 0) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + var/datum/pirate_gun_handling/handling = pirate_gun_handling_for(gun) + var/windup_until = controller.blackboard[BB_PIRATE_WINDUP_UNTIL] + if(windup_until) + if(world.time < windup_until) + return AI_BEHAVIOR_DELAY + controller.clear_blackboard_key(BB_PIRATE_WINDUP_UNTIL) + controller.set_blackboard_key(BB_PIRATE_VOLLEY_LEFT, handling.shots) + if(world.time < controller.blackboard[BB_HUMAN_NPC_NEXT_SHOT]) + return AI_BEHAVIOR_DELAY + if(controller.blackboard[BB_PIRATE_VOLLEY_LEFT] <= 0) + if(handling.windup) + npc.face_atom(target) + if(handling.windup_sound) + playsound(npc, handling.windup_sound, 50, TRUE) + controller.set_blackboard_key(BB_PIRATE_WINDUP_UNTIL, world.time + handling.windup) + return AI_BEHAVIOR_DELAY + controller.set_blackboard_key(BB_PIRATE_VOLLEY_LEFT, handling.shots) + var/atom/hiding_target = strategy.find_hidden_mobs(npc, target) + controller.set_blackboard_key(hiding_location_key, hiding_target) + var/atom/final_target = hiding_target || target + if(human_npc_ally_in_line(npc, final_target)) + human_npc_sidestep(npc, final_target) + return AI_BEHAVIOR_DELAY + if(!human_npc_ready_item(npc, gun)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + npc.zone_selected = pirate_crew_human_aim_zone(npc, final_target) + controller.ai_interact(target = final_target, combat_mode = TRUE) + var/volley_left = controller.blackboard[BB_PIRATE_VOLLEY_LEFT] - 1 + controller.set_blackboard_key(BB_PIRATE_VOLLEY_LEFT, volley_left) + controller.set_blackboard_key(BB_HUMAN_NPC_NEXT_SHOT, world.time + (volley_left > 0 ? handling.shot_gap : handling.volley_gap)) + return AI_BEHAVIOR_DELAY + +/// Where an ordinary shot is aimed. Never the head of someone helpless at point blank: that would be an +/// execution, which only a boss starts, and only on purpose (pirate_crew_human_execute). +/proc/pirate_crew_human_aim_zone(mob/living/shooter, atom/target) + var/zone = human_npc_pick_aim_zone() + if(zone == BODY_ZONE_HEAD && isliving(target) && shooter.Adjacent(target)) + var/mob/living/victim = target + if(victim.hv_can_be_executed()) + return BODY_ZONE_CHEST + return zone + +/// Whether a boss gunner should walk up to `target` and put its gun to their head: it is a boss (OC-9), +/// its execution isn't cooling down, and the target is someone it may execute. +/proc/pirate_crew_human_wants_execution(datum/ai_controller/controller, mob/living/carbon/human/npc/npc, atom/target) + if(!ishumannpc(npc) || npc.npc_rank < HUMAN_NPC_RANK_BOSS || !isliving(target)) + return FALSE + if(world.time < controller.blackboard[BB_PIRATE_NEXT_EXECUTION]) + return FALSE + var/mob/living/victim = target + if(victim.stat == DEAD || !victim.hv_can_be_executed()) + return FALSE + var/obj/item/gun/gun = human_npc_loaded_gun(npc) + return gun?.hv_execution_possible(npc, victim) || (gun && !npc.Adjacent(victim)) + +/** + * A boss puts the barrel of its gun to the head of someone down beside it: the hyperviolence execution + * (executions.dm), a click aimed at the head. Its 1.5 second wind-up is a do_after, so it runs apart + * from the AI's tick, and the crew can break it by moving either of them. + */ +/datum/ai_behavior/pirate_crew_human_execute + action_cooldown = 1 SECONDS + +/datum/ai_behavior/pirate_crew_human_execute/perform(seconds_per_tick, datum/ai_controller/controller, target_key) + var/mob/living/carbon/npc = controller.pawn + var/mob/living/victim = controller.blackboard[target_key] + var/obj/item/gun/gun = human_npc_loaded_gun(npc) + if(!isliving(victim) || isnull(gun) || !gun.hv_execution_possible(npc, victim) || !human_npc_ready_item(npc, gun)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + controller.set_blackboard_key(BB_PIRATE_NEXT_EXECUTION, world.time + PIRATE_CREW_EXECUTION_COOLDOWN) + npc.zone_selected = BODY_ZONE_HEAD + INVOKE_ASYNC(controller, TYPE_PROC_REF(/datum/ai_controller, ai_interact), victim, TRUE) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + +/// tg melee with what it holds, except against someone it was told to hold its ground against: a gunner +/// whose gun ran dry doesn't run off the battlefield or away from the helm after them. +/datum/ai_planning_subtree/human_npc_melee/pirate_crew + +/datum/ai_planning_subtree/human_npc_melee/pirate_crew/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/datum/ai_controller/basic_controller/pirate_crew/pirate_controller = controller + if(istype(pirate_controller) && pirate_controller.target_hold_ground) + return + return ..() + +// ===== STIMULANTS AND THE FLASK ===== + +/** + * Captains and bosses inject the stimulant they carry once their fight has started (they have someone + * to fight); a boss carrying a flask drinks from it when it is hurt. Real items used the way a player + * uses them: the medipen in hand, then used; the flask clicked on itself. + */ +/datum/ai_planning_subtree/pirate_crew_human_self_care + +/datum/ai_planning_subtree/pirate_crew_human_self_care/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/human/npc/npc = controller.pawn + if(!ishumannpc(npc) || npc.npc_rank < HUMAN_NPC_RANK_ELITE || npc.stat != CONSCIOUS) + return + if(HAS_TRAIT(npc, TRAIT_HANDS_BLOCKED) || LAZYLEN(npc.do_afters)) + return + if(!controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + return + var/obj/item/to_use = pirate_crew_human_stimulant(npc) + if(isnull(to_use) && npc.health < npc.maxHealth * PIRATE_CREW_DRINK_HEALTH_SHARE && world.time >= controller.blackboard[BB_PIRATE_NEXT_DRINK]) + to_use = pirate_crew_human_flask(npc) + if(isnull(to_use)) + return + controller.set_blackboard_key(BB_PIRATE_SELF_ITEM, to_use) + controller.queue_behavior(/datum/ai_behavior/pirate_crew_human_use_on_self, BB_PIRATE_SELF_ITEM) + return SUBTREE_RETURN_FINISH_PLANNING + +/// A stimulant medipen it carries and hasn't used, unless one is already in its blood. +/proc/pirate_crew_human_stimulant(mob/living/carbon/npc) + if(npc.reagents?.has_reagent(/datum/reagent/medicine/stimulants)) + return null + for(var/obj/item/reagent_containers/hypospray/medipen/pen in npc.get_all_contents_type(/obj/item/reagent_containers/hypospray/medipen)) + if(pen.used_up || !pen.reagents?.has_reagent(/datum/reagent/medicine/stimulants)) + continue + if(npc.is_holding(pen) || human_npc_can_draw(npc, pen)) + return pen + return null + +/// A flask with something left in it that it can take out. +/proc/pirate_crew_human_flask(mob/living/carbon/npc) + for(var/obj/item/reagent_containers/cup/glass/flask/flask in npc.get_all_contents_type(/obj/item/reagent_containers/cup/glass/flask)) + if(!flask.reagents?.total_volume) + continue + if(npc.is_holding(flask) || human_npc_can_draw(npc, flask)) + return flask + return null + +/** + * Takes the item in a free hand (letting go of a two-handed grip, or holstering a spent gun, if both are + * full), uses it on itself, puts a flask back and takes up its weapon again. + */ +/datum/ai_behavior/pirate_crew_human_use_on_self + action_cooldown = 0.8 SECONDS + behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/pirate_crew_human_use_on_self/perform(seconds_per_tick, datum/ai_controller/controller, item_key) + var/mob/living/carbon/human/npc/npc = controller.pawn + var/obj/item/thing = controller.blackboard[item_key] + if(QDELETED(thing) || human_npc_holding(thing) != npc || npc.stat != CONSCIOUS) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(!npc.is_holding(thing)) + if(!length(npc.get_empty_held_indexes()) && !pirate_crew_human_free_a_hand(npc)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(!human_npc_take_in_hand(npc, thing)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_DELAY + if(!human_npc_ready_item(npc, thing) || npc.next_move > world.time) + return AI_BEHAVIOR_DELAY + if(istype(thing, /obj/item/reagent_containers/hypospray/medipen)) + npc.npc_bark("stimulant", force = TRUE) + npc.execute_mode() + var/obj/item/reagent_containers/hypospray/medipen/pen = thing + if(pen.used_up && npc.is_holding(pen)) + npc.dropItemToGround(pen) + else + npc.npc_bark("drink", force = TRUE) + controller.ai_interact(target = npc, combat_mode = FALSE) + controller.set_blackboard_key(BB_PIRATE_NEXT_DRINK, world.time + PIRATE_CREW_DRINK_COOLDOWN) + if(npc.is_holding(thing)) + thing.equip_to_best_slot(npc) + for(var/obj/item/held in npc.held_items) + human_npc_ready_weapon(npc, held) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + +/datum/ai_behavior/pirate_crew_human_use_on_self/finish_action(datum/ai_controller/controller, succeeded, item_key) + . = ..() + controller.clear_blackboard_key(item_key) + if(!succeeded) + // Couldn't get at it; it won't keep trying every tick + controller.set_blackboard_key(BB_PIRATE_NEXT_DRINK, world.time + PIRATE_CREW_DRINK_COOLDOWN) + +/// Frees a hand: lets go of a two-handed grip, or holsters a gun that can't fire. Returns TRUE if a hand is free. +/proc/pirate_crew_human_free_a_hand(mob/living/carbon/npc) + for(var/obj/item/held in npc.held_items) + if(held.GetComponent(/datum/component/two_handed) && HAS_TRAIT(held, TRAIT_WIELDED)) + held.attack_self(npc) + break + if(length(npc.get_empty_held_indexes())) + return TRUE + var/obj/item/gun/spent = human_npc_held_gun(npc) + if(spent && !spent.can_shoot()) + spent.equip_to_best_slot(npc) + return length(npc.get_empty_held_indexes()) > 0 + +// ===== DOORS ===== + +/** + * A human crewman breaking through `blocker` (a door or the frame a broken door left), the ways a person + * can: prying an unpowered airlock or a firelock with a crowbar or fireaxe it carries, shooting the door + * from a step back, or hitting it with something heavy enough to dent it. Returns FALSE when it has no + * way to hurt this door, so the crew's breach gives up on it and another member can try. + */ +/proc/pirate_crew_human_breach(datum/ai_controller/controller, mob/living/carbon/human/npc, obj/blocker) + if(LAZYLEN(npc.do_afters) || HAS_TRAIT(npc, TRAIT_HANDS_BLOCKED) || npc.next_move > world.time) + return TRUE + // A pry bar on a door that will give: an airlock with no power that isn't bolted or welded, or a firelock + var/obj/item/pry_tool = pirate_crew_human_pry_tool(npc) + if(pry_tool && pirate_crew_human_can_pry(blocker)) + if(npc.Adjacent(blocker) && pirate_crew_human_ready_tool(npc, pry_tool)) + // A crowbar's right click forces a firelock fully open; its left click only holds it + var/list/modifiers = (istype(blocker, /obj/machinery/door/firedoor) && pry_tool.tool_behaviour == TOOL_CROWBAR) ? list(RIGHT_CLICK = TRUE) : null + controller.ai_interact(target = blocker, combat_mode = FALSE, modifiers = modifiers) + return TRUE + // A gun, from a step back so the shot isn't a bash (pirate_crew_human_breach_spot() puts it there) + var/obj/item/gun/gun = human_npc_loaded_gun(npc) + if(gun && !npc.Adjacent(blocker) && get_dist(npc, blocker) <= 3 && can_see(npc, blocker, 3)) + if(human_npc_ready_item(npc, gun)) + npc.face_atom(blocker) + controller.ai_interact(target = blocker, combat_mode = TRUE) + return TRUE + // A blade or a club that dents it + var/obj/item/weapon = pirate_crew_human_door_weapon(npc, blocker) + if(weapon) + if(npc.Adjacent(blocker) && human_npc_ready_item(npc, weapon)) + controller.ai_interact(target = blocker, combat_mode = TRUE) + return TRUE + return FALSE + +/** + * Where a crewman works on `blocker` from: the floor beside it (`stand`) to pry or hit it, or for a gunner + * with nothing to pry it, the floor a step further back, so the shot isn't a bash with the gun. + */ +/proc/pirate_crew_human_breach_spot(mob/living/carbon/human/npc, obj/blocker, turf/stand) + if(!isturf(stand)) + stand = get_turf(npc) + if(isnull(human_npc_loaded_gun(npc))) + return stand + if(pirate_crew_human_can_pry(blocker) && pirate_crew_human_pry_tool(npc)) + return stand + var/turf/back = get_step(stand, get_dir(blocker, stand)) + if(back && pirate_turf_standable(back) && can_see(back, blocker, 3)) + return back + return stand + +/// Whether a crowbar or a fireaxe in a person's hands would force `blocker`. +/proc/pirate_crew_human_can_pry(obj/blocker) + if(istype(blocker, /obj/machinery/door/firedoor)) + var/obj/machinery/door/firedoor/firelock = blocker + return firelock.density && !firelock.welded && !firelock.operating + if(!istype(blocker, /obj/machinery/door/airlock)) + return FALSE + var/obj/machinery/door/airlock/airlock = blocker + return airlock.density && !airlock.locked && !airlock.welded && !airlock.seal && !airlock.operating && !airlock.hasPower() + +/// A crowbar or a fireaxe it holds or can draw. +/proc/pirate_crew_human_pry_tool(mob/living/carbon/npc) + for(var/obj/item/thing as anything in npc.get_all_contents_type(/obj/item)) + if(!(thing.tool_behaviour == TOOL_CROWBAR || istype(thing, /obj/item/fireaxe))) + continue + if(npc.is_holding(thing) || human_npc_can_draw(npc, thing)) + return thing + return null + +/// Gets `tool` into the active hand and ready (a fireaxe wielded), putting away what's in the way. +/// Returns TRUE once it can be used. +/proc/pirate_crew_human_ready_tool(mob/living/carbon/npc, obj/item/tool) + if(!npc.is_holding(tool)) + if(!length(npc.get_empty_held_indexes()) && !pirate_crew_human_free_a_hand(npc)) + // Both hands still full: put the weaker of what it holds away + var/obj/item/stowed = npc.get_inactive_held_item() || npc.get_active_held_item() + if(isnull(stowed) || !stowed.equip_to_best_slot(npc)) + return FALSE + if(!human_npc_take_in_hand(npc, tool)) + return FALSE + if(istype(tool, /obj/item/fireaxe)) + human_npc_ready_weapon(npc, tool) + if(!HAS_TRAIT(tool, TRAIT_WIELDED)) + return FALSE + return human_npc_ready_item(npc, tool) + +/// A melee weapon it holds or can draw that hits `blocker` hard enough to hurt it (its damage +/// deflection), or null. +/proc/pirate_crew_human_door_weapon(mob/living/carbon/npc, obj/blocker) + var/obj/item/best + var/best_force = 0 + for(var/obj/item/thing as anything in npc.get_all_contents_type(/obj/item)) + if(!human_npc_is_melee_weapon(thing)) + continue + if(!npc.is_holding(thing) && !human_npc_can_draw(npc, thing)) + continue + var/blow = pirate_crew_human_door_blow(thing) + if(blow > best_force) + best = thing + best_force = blow + if(isnull(best) || best_force < blocker.damage_deflection) + return null + if(!npc.is_holding(best)) + if(!length(npc.get_empty_held_indexes()) || !human_npc_take_in_hand(npc, best)) + return null + human_npc_ready_weapon(npc, best) + return best + +/// What `weapon` hits a door for, as it would be swung: lit, wielded, and with its demolition modifier. +/proc/pirate_crew_human_door_blow(obj/item/weapon) + var/force = weapon.force + var/datum/component/transforming/transforming = weapon.GetComponent(/datum/component/transforming) + if(transforming && !HAS_TRAIT(weapon, TRAIT_TRANSFORM_ACTIVE)) + force = max(force, transforming.force_on) + var/datum/component/two_handed/two_handed = weapon.GetComponent(/datum/component/two_handed) + if(two_handed && !HAS_TRAIT(weapon, TRAIT_WIELDED)) + force = max(force, two_handed.force_wielded) + return force * weapon.demolition_mod diff --git a/voidcrew/modules/npc_ships/code/pirate_guns.dm b/voidcrew/modules/npc_ships/code/pirate_guns.dm index 9c98550f815..80ba300a4c7 100644 --- a/voidcrew/modules/npc_ships/code/pirate_guns.dm +++ b/voidcrew/modules/npc_ships/code/pirate_guns.dm @@ -1,359 +1,104 @@ /** - * Pirate crew guns. + * Pirate crew guns: how a human pirate handles the real gun in its hands. * - * A ranged pirate rolls a gun when it joins a crew (pirate_crew_arm()), weighted by its faction: an - * energy gun, a laser rifle, a pistol, an SMG or a shotgun. The gun shows in its hand and fires the - * real gun's rounds: a ballistic gun's are read off the item by bounty_real_weapon() (bounties - * module), with its magazine, pellets, spread and damage multiplier; an energy gun fires its - * casing's beam. Nothing is spawned for the fight and nothing drops. - * - * Each loadout has a magazine and a reload, and the SMG and shotgun wind up before they fire (a - * hit during the wind-up spoils it). The shotgun walks in close before it fires. Every loadout - * deals about what the old two-laser volley every 6 seconds did, so a crew hits as hard as before. + * PR #500 rolled a drawn gun for each basic-mob gunner and fired its rounds from the body. Human + * pirates (faction_pirate_humans.dm) hold the real thing, chosen by their faction's outfit table + * (voidcrew/modules/human_npcs/human_npc_outfits_pirates.dm, weighted as PR #500's crew_gun_weights), + * with real spare magazines or shells, and fire it through the real fire path. What is left of PR #500's + * loadouts is how each kind of gun is used: how many pulls of the trigger make a volley and how long the + * pirate waits between volleys (tuned, as before, to about the old two-laser volley every six seconds), + * the SMG's spin-up and the shotgun's moment of aim that a hit spoils, the shotgunner walking in close, + * and what it shouts when it reloads. The pump, the magazine change and their sounds are the gun's own. */ -/// One of each loadout, by type -GLOBAL_LIST_INIT(pirate_gun_loadouts, init_pirate_gun_loadouts()) +/// One of each handling, most specific gun type first +GLOBAL_LIST_INIT(pirate_gun_handlings, init_pirate_gun_handlings()) -/proc/init_pirate_gun_loadouts() +/proc/init_pirate_gun_handlings() . = list() - for(var/loadout_type in subtypesof(/datum/pirate_gun_loadout)) - .[loadout_type] = new loadout_type - -/// What a gunner rolls when its faction says nothing: an even mix of energy and ballistic -GLOBAL_LIST_INIT(pirate_gun_default_weights, list( - /datum/pirate_gun_loadout/energy_gun = 2, - /datum/pirate_gun_loadout/laser_rifle = 1, - /datum/pirate_gun_loadout/pistol = 2, - /datum/pirate_gun_loadout/smg = 2, - /datum/pirate_gun_loadout/shotgun = 2, -)) + // Most specific first: pistols are automatic guns too, and every gun type is a /obj/item/gun. + for(var/handling_type in list( + /datum/pirate_gun_handling/shotgun, + /datum/pirate_gun_handling/pistol, + /datum/pirate_gun_handling/smg, + /datum/pirate_gun_handling/ballistic, + /datum/pirate_gun_handling/crossbow, + /datum/pirate_gun_handling/energy, + /datum/pirate_gun_handling, + )) + . += new handling_type + +/// How a pirate uses `gun`: the first handling whose gun type it is. +/proc/pirate_gun_handling_for(obj/item/gun/gun) + for(var/datum/pirate_gun_handling/handling as anything in GLOB.pirate_gun_handlings) + if(istype(gun, handling.gun_type)) + return handling + return GLOB.pirate_gun_handlings[length(GLOB.pirate_gun_handlings)] /** - * A pirate gun: the item in the hand, its rounds, and how it is fired. Read-only, shared by every - * pirate carrying it; the ammunition and timers live on the pirate's /datum/component/pirate_gun. + * How a pirate fires one kind of gun. Read-only and shared; the timers live on the pirate's AI + * blackboard (BB_PIRATE_VOLLEY_LEFT, BB_PIRATE_WINDUP_UNTIL, BB_HUMAN_NPC_NEXT_SHOT). */ -/datum/pirate_gun_loadout - /// The gun in the hand - var/gun_type - /// For a ballistic gun, what it is loaded with (null: the magazine's own rounds) - var/ammo_type - /// For an energy gun, the casing it fires (its beam and its sound) - var/obj/item/ammo_casing/energy/energy_casing - /// For an energy gun, shots in a cell - var/energy_shots = 0 - /// Shots in one burst, and the time between them - var/burst = 1 - var/burst_delay = 0.2 SECONDS - /// From the start of one burst (or wind-up) to the next - var/cooldown = 6 SECONDS - var/reload_time = 2.5 SECONDS - /// The spin-up or pump before a burst, if any; a hit during it spoils the burst +/datum/pirate_gun_handling + /// The guns it covers + var/gun_type = /obj/item/gun + /// Pulls of the trigger in one volley, and the time between them + var/shots = 1 + var/shot_gap = 0.3 SECONDS + /// From the last pull of a volley to the first of the next + var/volley_gap = 3 SECONDS + /// The spin-up or aim before a volley, if any: a hit during it spoils the volley var/windup = 0 var/windup_sound - var/fire_sound - var/reload_sound = 'sound/items/weapons/gun/general/magazine_insert_full.ogg' /// Tiles: it walks in to this before it fires (0: the usual gunner range) var/close_range = 0 - /// What its carrier may shout on reloading + /// What it may shout as it changes magazines or loads shells var/list/reload_lines = list("Reloading!", "Changing mags!", "Cover me, I'm reloading!") - /// The real gun's numbers, for a ballistic gun (/datum/bounty_real_weapon) - var/datum/bounty_real_weapon/weapon - -/datum/pirate_gun_loadout/New() - . = ..() - if(ispath(gun_type, /obj/item/gun/ballistic)) - weapon = bounty_real_weapon(gun_type, ammo_type) - if(!fire_sound) - fire_sound = weapon.fire_sound - else if(energy_casing && !fire_sound) - fire_sound = initial(energy_casing.fire_sound) - -/// Rounds in a full magazine, or shots in a full cell -/datum/pirate_gun_loadout/proc/magazine_size() - if(weapon) - return max(1, weapon.magazine) - return max(1, energy_shots) - -/// Projectiles one round fires -/datum/pirate_gun_loadout/proc/pellets() - if(weapon) - return max(1, weapon.pellets) - return max(1, initial(energy_casing.pellets)) - -/// A new projectile of one round (one pellet of a shell) at `start`, carrying the real round's numbers -/datum/pirate_gun_loadout/proc/make_projectile(turf/start) - if(weapon) - if(!weapon.round_type) - return null - var/obj/projectile/bullet = new weapon.round_type(start) - weapon.load(bullet) - return bullet - var/projectile_type = initial(energy_casing.projectile_type) - return projectile_type ? new projectile_type(start) : null - -/// Degrees one projectile strays -/datum/pirate_gun_loadout/proc/shot_spread() - if(weapon) - return weapon.shot_spread() - var/variance = initial(energy_casing.variance) - return variance ? round((rand() - 0.5) * variance) : 0 - -/// Energy gun (lethal): two beams every six seconds, twelve shots to a cell -/datum/pirate_gun_loadout/energy_gun - gun_type = /obj/item/gun/energy/e_gun/lethal - energy_casing = /obj/item/ammo_casing/energy/laser - energy_shots = 12 - burst = 2 - cooldown = 6 SECONDS - reload_time = 3 SECONDS - reload_sound = 'sound/items/weapons/gun/general/magazine_insert_empty.ogg' - reload_lines = list("Swapping cells!", "Cell's dry!", "Cover me!") - -/// Laser rifle: as the energy gun, with a bigger cell -/datum/pirate_gun_loadout/laser_rifle - gun_type = /obj/item/gun/energy/laser - energy_casing = /obj/item/ammo_casing/energy/lasergun - energy_shots = 16 - burst = 2 - cooldown = 6 SECONDS - reload_time = 3 SECONDS - reload_sound = 'sound/items/weapons/gun/general/magazine_insert_empty.ogg' - reload_lines = list("Swapping cells!", "Cell's dry!", "Cover me!") - -/// Makarov: a quick pair of 9mm every seven seconds, a reload every six pairs -/datum/pirate_gun_loadout/pistol + /// What it may shout when the gun runs dry and can't be reloaded + var/list/dry_lines + +/// Energy guns: two beams every six seconds. A cell can't be changed by hand, so a dry one is put away. +/datum/pirate_gun_handling/energy + gun_type = /obj/item/gun/energy + shots = 2 + shot_gap = 0.2 SECONDS + volley_gap = 6 SECONDS + reload_lines = null + dry_lines = list("Cell's dry!", "Cover me!") + +/// The medieval crossbow: one bolt every six seconds. It draws itself again. +/datum/pirate_gun_handling/crossbow + gun_type = /obj/item/gun/energy/recharge + shots = 1 + volley_gap = 6 SECONDS + reload_lines = null + +/// Any other bullet gun: one shot every three seconds. +/datum/pirate_gun_handling/ballistic + gun_type = /obj/item/gun/ballistic + +/// Pistols: a quick pair every seven seconds. +/datum/pirate_gun_handling/pistol gun_type = /obj/item/gun/ballistic/automatic/pistol - burst = 2 - burst_delay = 0.3 SECONDS - cooldown = 7 SECONDS - reload_time = 2 SECONDS - reload_sound = 'sound/items/weapons/gun/pistol/mag_insert.ogg' - -/// Uzi: a five-round string after a short wind-up, every seven seconds -/datum/pirate_gun_loadout/smg - gun_type = /obj/item/gun/ballistic/automatic/mini_uzi - burst = 5 - burst_delay = 0.1 SECONDS - cooldown = 7 SECONDS - reload_time = 2.5 SECONDS + shots = 2 + shot_gap = 0.3 SECONDS + volley_gap = 7 SECONDS + +/// SMGs: spins up, then three bursts, every seven seconds. +/datum/pirate_gun_handling/smg + gun_type = /obj/item/gun/ballistic/automatic + shots = 3 + shot_gap = 0.3 SECONDS + volley_gap = 7 SECONDS windup = 0.4 SECONDS windup_sound = 'sound/items/weapons/gun/smg/smgrack.ogg' -/// Pump shotgun with buckshot: walks in close, pumps, and fires a shell every four seconds -/datum/pirate_gun_loadout/shotgun +/// Pump shotguns: walks in close, aims a moment and fires a shell every four seconds. The pump after +/// each shot is the gun's own (the AI racks it as a player does). +/datum/pirate_gun_handling/shotgun gun_type = /obj/item/gun/ballistic/shotgun - ammo_type = /obj/item/ammo_casing/shotgun/buckshot - burst = 1 - cooldown = 4 SECONDS - reload_time = 3 SECONDS + shots = 1 + volley_gap = 4 SECONDS windup = 0.4 SECONDS - windup_sound = 'sound/items/weapons/gun/shotgun/rack.ogg' - reload_sound = 'sound/items/weapons/gun/shotgun/insert_shell.ogg' close_range = 3 reload_lines = list("Reloading!", "Loading shells!", "Cover me!") - -// ===== ARMING ===== - -/// The loadout weights for `gunner`'s faction: type => weight, or null to keep its own gun -/proc/pirate_gun_weights_for(mob/living/basic/gunner) - var/mob/living/basic/trooper/pirate/faction/faction_pirate = gunner - if(istype(faction_pirate)) - if(faction_pirate.crew_keeps_gun) - return null - return faction_pirate.crew_gun_weights || GLOB.pirate_gun_default_weights - if(istype(gunner, /mob/living/basic/trooper/pirate)) - return GLOB.pirate_gun_default_weights - return null - -/** - * Hands `gunner` a rolled pirate gun in place of its stock ranged attack: the gun shows in its hand - * and fires real rounds. Only a gunner whose faction has loadouts, and only once. Returns the loadout. - */ -/proc/pirate_crew_arm(mob/living/basic/gunner, loadout_type) - if(QDELETED(gunner) || gunner.GetComponent(/datum/component/pirate_gun)) - return null - if(!gunner.GetComponent(/datum/component/ranged_attacks)) - return null - if(!loadout_type) - var/list/weights = pirate_gun_weights_for(gunner) - if(!length(weights)) - return null - loadout_type = pick_weight(weights) - var/datum/pirate_gun_loadout/loadout = GLOB.pirate_gun_loadouts[loadout_type] - if(!loadout) - return null - qdel(gunner.GetComponent(/datum/component/ranged_attacks)) - gunner.AddComponent(/datum/component/pirate_gun, loadout) - var/mob/living/basic/trooper/trooper = gunner - if(istype(trooper)) - trooper.r_hand = loadout.gun_type - if(trooper.use_dynamic_appearance) - apply_dynamic_human_appearance(trooper, mob_spawn_path = trooper.mob_spawner, r_hand = trooper.r_hand, l_hand = trooper.l_hand) - return loadout - -/// The pirate gun `gunner` carries, if any -/proc/pirate_gun_of(mob/living/gunner) - return gunner?.GetComponent(/datum/component/pirate_gun) - -// ===== THE GUN IN HAND ===== - -/** - * A pirate's gun in use: its ammunition and timers. The AI's ranged attack (RangedAttack()) asks it - * to fire; it fires a burst when it's ready, winds up first if it has to, and reloads when empty. - * Its timers check `serial`, so a spoiled or cancelled burst does nothing. - */ -/datum/component/pirate_gun - var/datum/pirate_gun_loadout/loadout - /// Rounds left in the magazine - var/ammo = 0 - /// world.time it may start the next burst or wind-up - var/next_fire_at = 0 - /// world.time the reload is done - var/reloading_until = 0 - /// Winding up now - var/winding = FALSE - /// Goes up with every burst, wind-up and fumble, so stale timers do nothing - var/serial = 0 - /// What it's aimed at - var/datum/weakref/aim_ref - -/datum/component/pirate_gun/Initialize(datum/pirate_gun_loadout/loadout) - if(!isbasicmob(parent) || !istype(loadout)) - return COMPONENT_INCOMPATIBLE - src.loadout = loadout - ammo = loadout.magazine_size() - -/datum/component/pirate_gun/Destroy(force) - serial++ - loadout = null - aim_ref = null - return ..() - -/datum/component/pirate_gun/RegisterWithParent() - . = ..() - ADD_TRAIT(parent, TRAIT_SUBTREE_REQUIRED_OPERATIONAL_DATUM, type) - RegisterSignal(parent, COMSIG_MOB_ATTACK_RANGED, PROC_REF(on_ranged_attack)) - RegisterSignal(parent, COMSIG_MOB_AFTER_APPLY_DAMAGE, PROC_REF(on_damaged)) - -/datum/component/pirate_gun/UnregisterFromParent() - . = ..() - UnregisterSignal(parent, list(COMSIG_MOB_ATTACK_RANGED, COMSIG_MOB_AFTER_APPLY_DAMAGE)) - REMOVE_TRAIT(parent, TRAIT_SUBTREE_REQUIRED_OPERATIONAL_DATUM, type) - -/datum/component/pirate_gun/proc/on_ranged_attack(mob/living/basic/source, atom/target, modifiers) - SIGNAL_HANDLER - try_fire(target) - -/// A hit during the wind-up spoils it: nothing fires, and the next try waits a moment -/datum/component/pirate_gun/proc/on_damaged(mob/living/source, damage_dealt) - SIGNAL_HANDLER - if(!winding || damage_dealt <= 0) - return - serial++ - winding = FALSE - next_fire_at = max(next_fire_at, world.time + 1 SECONDS) - -/datum/component/pirate_gun/proc/ready() - return !winding && world.time >= next_fire_at - -/datum/component/pirate_gun/proc/is_reloading() - return world.time < reloading_until - -/datum/component/pirate_gun/proc/can_fire(mob/living/owner) - return owner && owner.stat == CONSCIOUS && isturf(owner.loc) && !HAS_TRAIT(owner, TRAIT_INCAPACITATED) && !HAS_TRAIT(owner, TRAIT_HANDS_BLOCKED) - -/// Starts a burst at `target`, after the wind-up if it has one. TRUE if it started. -/datum/component/pirate_gun/proc/try_fire(atom/target) - var/mob/living/owner = parent - if(!can_fire(owner) || !ready() || QDELETED(target)) - return FALSE - if(loadout.close_range && get_dist(owner, target) > loadout.close_range) - return FALSE - aim_ref = WEAKREF(target) - serial++ - owner.face_atom(target) - if(loadout.windup) - winding = TRUE - next_fire_at = world.time + loadout.windup + loadout.cooldown - if(loadout.windup_sound) - playsound(owner, loadout.windup_sound, 50, TRUE) - addtimer(CALLBACK(src, PROC_REF(finish_windup), serial), loadout.windup, TIMER_DELETE_ME) - return TRUE - fire_burst() - return TRUE - -/datum/component/pirate_gun/proc/finish_windup(fire_serial) - if(fire_serial != serial || !winding) - return - winding = FALSE - if(can_fire(parent)) - fire_burst() - -/// A burst: as many shots as the magazine has left, then a reload if it's spent -/datum/component/pirate_gun/proc/fire_burst() - var/shots = clamp(loadout.burst, 1, ammo) - ammo -= shots - next_fire_at = max(next_fire_at, world.time + loadout.cooldown) - var/fire_serial = serial - shoot_once(fire_serial) - for(var/i in 2 to shots) - addtimer(CALLBACK(src, PROC_REF(shoot_once), fire_serial), (i - 1) * loadout.burst_delay, TIMER_DELETE_ME) - if(ammo <= 0) - start_reload((shots - 1) * loadout.burst_delay) - -/// One round of the burst under `fire_serial`: every pellet of it -/datum/component/pirate_gun/proc/shoot_once(fire_serial) - if(fire_serial != serial) - return null - var/mob/living/owner = parent - var/atom/target = aim_ref?.resolve() - if(!can_fire(owner) || QDELETED(target)) - return null - if(isliving(target)) - var/mob/living/living_target = target - if(living_target.stat == DEAD) - return null - owner.face_atom(target) - var/turf/start = get_turf(owner) - if(!start || start == get_turf(target)) - return null - var/obj/projectile/first - for(var/pellet in 1 to loadout.pellets()) - var/obj/projectile/shot = loadout.make_projectile(start) - if(!shot) - break - shot.firer = owner - shot.fired_from = owner - shot.ignored_factions = owner.faction?.Copy() - shot.aim_projectile(target, owner, null, loadout.shot_spread()) - if(QDELETED(shot)) - continue - shot.fire() - if(!first && !QDELETED(shot)) - first = shot - if(loadout.fire_sound) - playsound(owner, loadout.fire_sound, 60, TRUE) - SEND_SIGNAL(owner, COMSIG_BASICMOB_POST_ATTACK_RANGED, target, null) - return first - -/// A fresh magazine, ready `delay` + the reload time from now -/datum/component/pirate_gun/proc/start_reload(delay = 0) - ammo = loadout.magazine_size() - reloading_until = world.time + delay + loadout.reload_time - next_fire_at = max(next_fire_at, reloading_until) - addtimer(CALLBACK(src, PROC_REF(reload_effects)), delay, TIMER_DELETE_ME) - -/datum/component/pirate_gun/proc/reload_effects() - var/mob/living/owner = parent - if(QDELETED(owner) || owner.stat != CONSCIOUS) - return - if(loadout.reload_sound) - playsound(owner, loadout.reload_sound, 40, TRUE) - if(length(loadout.reload_lines) && prob(PIRATE_CREW_RELOAD_BARK_CHANCE)) - INVOKE_ASYNC(owner, TYPE_PROC_REF(/atom/movable, say), message = pick(loadout.reload_lines), forced = "pirate crew") - -/// For the admin status readout -/datum/component/pirate_gun/proc/status_text() - var/obj/item/gun_path = loadout.gun_type - return "[initial(gun_path.name)] [ammo]/[loadout.magazine_size()][is_reloading() ? " reloading" : ""][winding ? " winding up" : ""]" diff --git a/voidcrew/modules/npc_ships/code/spawner_subsystem.dm b/voidcrew/modules/npc_ships/code/spawner_subsystem.dm index 2391f08dc8b..f74882420fa 100644 --- a/voidcrew/modules/npc_ships/code/spawner_subsystem.dm +++ b/voidcrew/modules/npc_ships/code/spawner_subsystem.dm @@ -258,12 +258,18 @@ SUBSYSTEM_DEF(npc_ships) if(ship.spawner_resolved || ship.abandoned) continue if(!ship.crew_ever_spawned) + // Human crews are built a body at a time (spawn_human_npc()); still queued is not malformed + if(ship.crew_pending()) + continue if(!(REF(ship) in logged_malformed)) logged_malformed += REF(ship) log_world("SSnpc_ships: [ship.name] has no crew roster (spawn_crew failed?) - it holds its pool slot and will never auto-resolve") continue - // Put spaced survivors out of their misery before the census reads them - ship.sweep_spaced_crew() + // A crewman spaced off the hull no longer counts as aboard; the space kills him or it doesn't + // (no death is forced, defaults PI-3), and one adrift with nobody to see him is cleaned up by + // his crew (pirate_crew.dm). Crew still queued to be built keep the hull's slot. + if(ship.crew_pending()) + continue if(ship.count_live_crew_aboard() <= 0) ship.notify_spawner_resolved("crew wiped (reconcile)") continue diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index e54bb378b3d..8e83525fd59 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -96,6 +96,8 @@ #include "voidcrew_hull_containment.dm" #include "voidcrew_hull_survey.dm" #include "voidcrew_human_npcs.dm" +#include "voidcrew_human_npcs_nt_customs.dm" +#include "voidcrew_human_npcs_ruins.dm" #include "voidcrew_human_npcs_shared.dm" #include "voidcrew_hv_finishers.dm" #include "voidcrew_hyperviolence_blood.dm" @@ -197,6 +199,7 @@ #include "voidcrew_overmap_management_bans.dm" #include "voidcrew_pandora_links.dm" #include "voidcrew_pirate_crew_ai.dm" +#include "voidcrew_pirate_crew_human.dm" #include "voidcrew_planet_anomalies.dm" #include "voidcrew_planet_cleanup.dm" #include "voidcrew_planet_definitions.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_human_npcs.dm b/voidcrew/modules/unit_tests/voidcrew_human_npcs.dm index 3bd38e8919e..7916bed68e1 100644 --- a/voidcrew/modules/unit_tests/voidcrew_human_npcs.dm +++ b/voidcrew/modules/unit_tests/voidcrew_human_npcs.dm @@ -362,6 +362,8 @@ TEST_ASSERT(weathered, "Weather doesn't reach an awake human NPC") TEST_ASSERT(!human_npc_weathered(person), "human_npc_weathered() took in a person") + TEST_ASSERT(pirate_crew_can_enlist(npc), "A pirate crew can't take on a human NPC") + /// D3's exceptions: a ship key isn't gear and drops when the NPC dies; a grenade is a consumable the NPC /// can drop and throw, that no player can keep, and that goes when its NPC does. /datum/unit_test/voidcrew_human_npc_gear_exceptions diff --git a/voidcrew/modules/unit_tests/voidcrew_human_npcs_nt_customs.dm b/voidcrew/modules/unit_tests/voidcrew_human_npcs_nt_customs.dm new file mode 100644 index 00000000000..c06513479ba --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_human_npcs_nt_customs.dm @@ -0,0 +1,73 @@ +// NT customs as human NPCs (voidcrew/modules/npc_ships/code/faction_pirates/nt_patrol.dm, human NPC +// migration phase E1). Unit tests compile before voidcrew/_DEFINES, so values from there are written out: +// zones 1 green, 2 yellow, 3 red; ranks 0 regular, 1 elite, 2 boss. + +/** + * The corvette's crew, boarders and the Compliance Director are human NPCs on the pirate crew AI, dressed + * as tg's Nanotrasen troopers with the guns the basic mobs fired by zone, their CentCom ID cards locked to + * them, on the Deathsquad side and never counted as pirates; boarders are sealed and carry air; only the + * Director carries designed loot. + */ +/datum/unit_test/voidcrew_human_npc_nt_customs + +/datum/unit_test/voidcrew_human_npc_nt_customs/Run() + var/obj/structure/overmap/ship/npc/pirate/nt_patrol/patrol = allocate(/obj/structure/overmap/ship/npc/pirate/nt_patrol) + TEST_ASSERT(ispath(patrol.captain_type, /mob/living/carbon/human/npc/faction_pirate/nt_customs), "The patrol's captain isn't a human customs NPC") + TEST_ASSERT(ispath(patrol.boss_type, /mob/living/carbon/human/npc/faction_pirate/nt_customs/director), "The patrol's boss isn't the human Compliance Director") + for(var/crew_type in patrol.crew_types + patrol.boarding_pod_mob_types) + TEST_ASSERT(ispath(crew_type, /mob/living/carbon/human/npc/faction_pirate/nt_customs), "[crew_type] in the patrol's crew isn't a human customs NPC") + + for(var/zone in 1 to 3) + var/mob/living/carbon/human/npc/faction_pirate/nt_customs/officer/officer = human_npc_build_in_zone(/mob/living/carbon/human/npc/faction_pirate/nt_customs/officer, zone) + var/mob/living/carbon/human/npc/faction_pirate/nt_customs/inspector/inspector = human_npc_build_in_zone(/mob/living/carbon/human/npc/faction_pirate/nt_customs/inspector, zone) + var/mob/living/carbon/human/npc/faction_pirate/nt_customs/sergeant/sergeant = human_npc_build_in_zone(/mob/living/carbon/human/npc/faction_pirate/nt_customs/sergeant, zone) + TEST_ASSERT_NOTNULL(locate(/obj/item/melee/baton/security) in officer?.held_items, "A customs officer doesn't hold a stun baton in zone [zone]") + var/obj/item/gun/ballistic/inspector_gun = human_npc_held_gun(inspector) + var/obj/item/gun/ballistic/sergeant_gun = human_npc_held_gun(sergeant) + if(zone == 3) + TEST_ASSERT(istype(inspector_gun, /obj/item/gun/ballistic/automatic/wt550), "A red-zone customs inspector doesn't hold a WT-550") + TEST_ASSERT(istype(sergeant_gun, /obj/item/gun/ballistic/automatic/ar), "A red-zone customs sergeant doesn't hold a rifle") + else + TEST_ASSERT(istype(inspector_gun, /obj/item/gun/ballistic/automatic/pistol/m1911), "A zone [zone] customs inspector doesn't hold the ladder pistol") + TEST_ASSERT(istype(sergeant_gun, /obj/item/gun/ballistic/automatic/pistol/m1911), "A zone [zone] customs sergeant doesn't hold the ladder pistol") + TEST_ASSERT_NOTNULL(human_npc_find_ammo(inspector, inspector_gun), "A customs inspector carries no spare magazine in zone [zone]") + TEST_ASSERT_NOTNULL(human_npc_find_ammo(sergeant, sergeant_gun), "A customs sergeant carries no spare magazine in zone [zone]") + TEST_ASSERT_EQUAL(sergeant?.npc_rank, 1, "The customs sergeant isn't an elite") + for(var/mob/living/carbon/human/npc/faction_pirate/nt_customs/customs as anything in list(officer, inspector, sergeant)) + TEST_ASSERT_NOTNULL(customs, "A customs NPC wasn't built in zone [zone]") + if(isnull(customs)) + continue + TEST_ASSERT(ROLE_DEATHSQUAD in customs.faction, "[customs.type] isn't on the Deathsquad side its corvette is keyed to") + TEST_ASSERT(!(FACTION_PIRATE in customs.faction), "[customs.type] counts as a pirate") + TEST_ASSERT_EQUAL(customs.ai_controller?.type, /datum/ai_controller/basic_controller/pirate_crew/human, "[customs.type] isn't on the human crew AI") + var/obj/item/card/id/advanced/centcom/card = customs.wear_id + TEST_ASSERT(istype(card), "[customs.type] carries no CentCom ID card") + TEST_ASSERT(human_npc_gear_locked(card), "[customs.type]'s CentCom ID card isn't locked to it") + TEST_ASSERT(HAS_TRAIT(card, TRAIT_NO_STRIP), "[customs.type]'s CentCom ID card shows in the strip menu") + TEST_ASSERT_EQUAL(card?.registered_name, customs.real_name, "[customs.type]'s ID card doesn't carry its name") + TEST_ASSERT(human_npc_gear_locked(customs.w_uniform), "[customs.type]'s uniform isn't locked to it") + TEST_ASSERT(!length(customs.npc_roll_death_loot()), "[customs.type] rolls death loot; a customs vessel is no prize") + TEST_ASSERT_EQUAL(customs.npc_death_cash, 0, "[customs.type] carries cash") + TEST_ASSERT_EQUAL(customs.maxHealth, 100, "[customs.type]'s max health isn't a person's") + + // Boarders cross space: sealed, with air they can breathe. + var/datum/human_npc_order/order = new /datum/human_npc_order(/mob/living/carbon/human/npc/faction_pirate/nt_customs/officer, run_loc_floor_bottom_left) + order.outfit = boarding_outfit_for(/mob/living/carbon/human/npc/faction_pirate/nt_customs/officer) + order.zone = 2 + var/mob/living/carbon/human/npc/faction_pirate/nt_customs/officer/boarder = order.fulfil() + qdel(order) + allocated += boarder + TEST_ASSERT(boarder?.wear_suit && (boarder.wear_suit.clothing_flags & STOPSPRESSUREDAMAGE), "A customs boarder has no sealed suit") + TEST_ASSERT(boarder?.head && (boarder.head.clothing_flags & STOPSPRESSUREDAMAGE), "A customs boarder has no sealed helmet") + TEST_ASSERT(boarder?.can_breathe_internals() && length(boarder.get_all_contents_type(/obj/item/tank/internals)), "A customs boarder carries no air it can breathe") + + // The Director: a boss with his e-gun, his baton and the fines. + var/mob/living/carbon/human/npc/faction_pirate/nt_customs/director/director = human_npc_build_in_zone(/mob/living/carbon/human/npc/faction_pirate/nt_customs/director, 3) + TEST_ASSERT_EQUAL(director?.npc_rank, 2, "The Compliance Director isn't a boss") + TEST_ASSERT(istype(human_npc_held_gun(director), /obj/item/gun/energy/e_gun), "The Compliance Director doesn't hold an e-gun") + TEST_ASSERT(istype(director?.wear_suit, /obj/item/clothing/suit/armor), "The Compliance Director wears no body armour") + // Written inline: a list local here once tripped a DM compiler bug in the CI build (an "invalid variable" + // error reported in an unrelated upstream file). + TEST_ASSERT(/obj/item/gun/energy/e_gun in director?.npc_roll_death_loot(), "The Compliance Director lost his e-gun drop") + TEST_ASSERT(/obj/item/melee/baton/security/loaded in director?.npc_roll_death_loot(), "The Compliance Director lost his baton drop") + TEST_ASSERT_EQUAL(director?.npc_death_cash, 2000, "The Compliance Director's fines changed") diff --git a/voidcrew/modules/unit_tests/voidcrew_human_npcs_ruins.dm b/voidcrew/modules/unit_tests/voidcrew_human_npcs_ruins.dm new file mode 100644 index 00000000000..390f714e048 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_human_npcs_ruins.dm @@ -0,0 +1,271 @@ +// Ruin, planet and mission human NPCs, phase C (voidcrew/modules/human_npcs/ruins/). Unit tests compile +// before voidcrew/_DEFINES, so values from there are written out: zones 1 green, 2 yellow, 3 red; ranks +// 0 regular, 1 elite, 2 boss; the spot bark kind is "spot". + +/// The ruin families' own abstract types, which no spawner or list places. +/datum/unit_test/proc/ruin_npc_abstract_types() + return list( + /mob/living/carbon/human/npc/ruin, + /mob/living/carbon/human/npc/ruin/trooper, + ) + +/** + * Every ruin NPC type dresses in every zone, fights with something it holds (a green-zone wanderer with + * its fists), carries spare ammunition for a magazine gun, wears locked gear, and keeps its side. + */ +/datum/unit_test/voidcrew_ruin_npc_families + +/datum/unit_test/voidcrew_ruin_npc_families/Run() + var/list/abstract = ruin_npc_abstract_types() + for(var/npc_type in subtypesof(/mob/living/carbon/human/npc/ruin) - abstract) + var/mob/living/carbon/human/npc/ruin/prototype = npc_type + var/list/sides = initial(prototype.faction) + for(var/zone in 1 to 3) + var/mob/living/carbon/human/npc/ruin/npc = human_npc_build_in_zone(npc_type, zone) + TEST_ASSERT_NOTNULL(npc, "[npc_type] wasn't built in zone [zone]") + 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]") + 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) + TEST_ASSERT(gun || human_npc_held_melee_weapon(npc), "[npc_type] holds no weapon in zone [zone]") + if(istype(gun, /obj/item/gun/ballistic)) + TEST_ASSERT_NOTNULL(human_npc_find_ammo(npc, gun), "[npc_type] carries no spare ammunition for its [gun] in zone [zone]") + for(var/side in sides) + TEST_ASSERT(side in npc.faction, "[npc_type] lost its [side] faction") + TEST_ASSERT(npc.should_inherit_planetary_faction(), "[npc_type] doesn't join its planet's natives") + TEST_ASSERT_EQUAL(npc.maxHealth, 100, "[npc_type]'s max health isn't a person's") + qdel(npc) + +/// The trooper weapon ladder and the zone armour live in the outfit tables. +/datum/unit_test/voidcrew_ruin_npc_zone_ladder + +/datum/unit_test/voidcrew_ruin_npc_zone_ladder/Run() + // Syndicate SMG gunners carry a pistol outside the red zone, and the C-20r in it. + var/mob/living/carbon/human/npc/smg_green = human_npc_build_in_zone(/mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/smg, 1) + TEST_ASSERT_NOTNULL(locate(/obj/item/gun/ballistic/automatic/pistol) in smg_green?.held_items, "A green-zone Syndicate SMG gunner doesn't hold the ladder pistol") + TEST_ASSERT(!istype(smg_green?.wear_suit, /obj/item/clothing/suit/armor), "A green-zone Syndicate gunner wears armour") + var/mob/living/carbon/human/npc/smg_yellow = human_npc_build_in_zone(/mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/smg, 2) + TEST_ASSERT_NOTNULL(locate(/obj/item/gun/ballistic/automatic/pistol) in smg_yellow?.held_items, "A yellow-zone Syndicate SMG gunner doesn't hold the ladder pistol") + TEST_ASSERT(istype(smg_yellow?.wear_suit, /obj/item/clothing/suit/armor/vest), "A yellow-zone Syndicate gunner wears no vest") + var/mob/living/carbon/human/npc/smg_red = human_npc_build_in_zone(/mob/living/carbon/human/npc/ruin/trooper/syndicate/gunner/smg, 3) + TEST_ASSERT_NOTNULL(locate(/obj/item/gun/ballistic/automatic/c20r) in smg_red?.held_items, "A red-zone Syndicate SMG gunner holds no C-20r") + TEST_ASSERT(istype(smg_red?.head, /obj/item/clothing/head/helmet), "A red-zone Syndicate gunner wears no helmet") + TEST_ASSERT_NOTNULL(locate(/obj/item/reagent_containers/hypospray/medipen) in smg_red?.get_all_contents(), "A red-zone Syndicate gunner carries no medipen") + // The sword guard only has a knife in the green zone. + var/mob/living/carbon/human/npc/sword_green = human_npc_build_in_zone(/mob/living/carbon/human/npc/ruin/trooper/syndicate/sword, 1) + TEST_ASSERT_NULL(locate(/obj/item/melee/energy/sword) in sword_green?.held_items, "A green-zone Syndicate sword guard holds an energy sword") + var/mob/living/carbon/human/npc/sword_yellow = human_npc_build_in_zone(/mob/living/carbon/human/npc/ruin/trooper/syndicate/sword, 2) + TEST_ASSERT_NOTNULL(locate(/obj/item/melee/energy/sword) in sword_yellow?.held_items, "A yellow-zone Syndicate sword guard holds no energy sword") + // Stormtroopers are elites and still follow the ladder. + var/mob/living/carbon/human/npc/storm_green = human_npc_build_in_zone(/mob/living/carbon/human/npc/ruin/trooper/syndicate/stormtrooper, 1) + TEST_ASSERT_EQUAL(storm_green?.npc_rank, 1, "A stormtrooper isn't an elite") + TEST_ASSERT_NOTNULL(locate(/obj/item/gun/ballistic/automatic/pistol) in storm_green?.held_items, "A green-zone stormtrooper doesn't hold the ladder pistol") + var/mob/living/carbon/human/npc/storm_yellow = human_npc_build_in_zone(/mob/living/carbon/human/npc/ruin/trooper/syndicate/stormtrooper, 2) + TEST_ASSERT_NOTNULL(locate(/obj/item/gun/ballistic/automatic/c20r) in storm_yellow?.held_items, "A yellow-zone stormtrooper holds no C-20r") + // Space kit is sealed and carries its own air (opened when the air goes bad, human_npc.dm). + var/mob/living/carbon/human/npc/commando = human_npc_build_in_zone(/mob/living/carbon/human/npc/ruin/trooper/syndicate/commando/gunner, 1) + TEST_ASSERT(istype(commando?.wear_suit, /obj/item/clothing/suit/space/syndicate), "A Syndicate commando wears no space suit") + TEST_ASSERT(commando?.can_breathe_internals() && length(commando.get_all_contents_type(/obj/item/tank/internals)), "A Syndicate commando carries no air it can breathe") + +/// Faction pirates (shared with the NPC ship crews, voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_humans.dm) +/// drop what the basic mobs dropped: fixed pieces, a captain's zone blade, the ladder weapon, cash. +/datum/unit_test/voidcrew_ruin_npc_faction_pirate_loot + +/datum/unit_test/voidcrew_ruin_npc_faction_pirate_loot/Run() + var/mob/living/carbon/human/npc/faction_pirate/silverscale/captain/noble = human_npc_build_in_zone(/mob/living/carbon/human/npc/faction_pirate/silverscale/captain, 2) + TEST_ASSERT_EQUAL(noble?.npc_rank, 1, "A faction captain isn't an elite") + TEST_ASSERT(/obj/item/claymore/shortsword in noble?.npc_roll_death_loot(), "A yellow-zone Silverscale noble doesn't carry the zone's shortsword") + var/mob/living/carbon/human/npc/faction_pirate/skeleton/boss/davy = human_npc_build_in_zone(/mob/living/carbon/human/npc/faction_pirate/skeleton/boss, 3) + TEST_ASSERT_EQUAL(davy?.npc_rank, 2, "A faction leader isn't a boss") + var/list/davy_loot = davy?.npc_roll_death_loot() + TEST_ASSERT(/obj/item/gun/ballistic/shotgun/hook in davy_loot, "Davy Jones lost his hook shotgun") + TEST_ASSERT_EQUAL(length(davy_loot), 1, "Davy Jones rolls loot a boss doesn't") + var/mob/living/carbon/human/npc/faction_pirate/grey/melee/tider = human_npc_build_in_zone(/mob/living/carbon/human/npc/faction_pirate/grey/melee, 1) + TEST_ASSERT_EQUAL(length(tider?.npc_roll_death_loot()), 2, "A grey tider doesn't roll a ladder weapon and one odds-and-ends item") + // The designed drops and the cash land once, however often it dies. + var/turf/drop_turf = tider.drop_location() + var/list/before = drop_turf.contents.Copy() + tider.death() + var/obj/item/holochip/chip = locate() in (drop_turf.contents - before) + TEST_ASSERT_NOTNULL(chip, "A grey tider dropped no cash") + TEST_ASSERT_EQUAL(chip?.credits, 300, "A grey tider's cash changed") + var/list/after_first = drop_turf.contents.Copy() + tider.revive(ADMIN_HEAL_ALL) + tider.death() + TEST_ASSERT_NULL(locate(/obj/item/holochip) in (drop_turf.contents - after_first), "A revived grey tider paid its cash twice") + for(var/atom/movable/dropped in drop_turf.contents - before) + if(dropped != tider) + qdel(dropped) + +/// Mapped NPCs: a placed spawner queues its NPC with the map's name and side; the family's own spawner places nothing. +/obj/effect/spawner/human_npc/ruin/hermit/unit_test + npc_name = "Test Hermit" + npc_faction = list("saloon") + +/datum/unit_test/voidcrew_ruin_npc_spawners + +/datum/unit_test/voidcrew_ruin_npc_spawners/Run() + var/queued_before = length(SShuman_npcs.queue) + new /obj/effect/spawner/human_npc/ruin(run_loc_floor_bottom_left) + TEST_ASSERT_EQUAL(length(SShuman_npcs.queue), queued_before, "The ruin family's own spawner queued an NPC") + new /obj/effect/spawner/human_npc/ruin/hermit/unit_test(run_loc_floor_bottom_left) + TEST_ASSERT_EQUAL(length(SShuman_npcs.queue), queued_before + 1, "A placed hermit spawner queued nothing") + var/datum/human_npc_order/order = SShuman_npcs.queue[length(SShuman_npcs.queue)] + order.zone = 1 + var/mob/living/carbon/human/npc/ruin/hermit/hermit = order.fulfil() + qdel(order) + TEST_ASSERT_NOTNULL(hermit, "The placed hermit wasn't built") + if(isnull(hermit)) + return + allocated += hermit + TEST_ASSERT_EQUAL(hermit.real_name, "Test Hermit", "The map's name didn't reach the hermit") + TEST_ASSERT("saloon" in hermit.faction, "The map's faction didn't reach the hermit") + TEST_ASSERT(!("hermit" in hermit.faction), "The map's faction didn't replace the hermit's own") + // Lists that roll many mobs queue human types instead of building them. + var/datum/npc_spawn_context/context = new /datum/npc_spawn_context(run_loc_floor_bottom_left, 1) + var/datum/human_npc_order/queued = spawn_npc_in_zone_or_queue(/mob/living/carbon/human/npc/ruin/hermit, run_loc_floor_bottom_left, context) + TEST_ASSERT(istype(queued, /datum/human_npc_order), "A human NPC from a spawn list was built on the spot") + qdel(queued) + var/mob/living/basic/mouse/mouse = spawn_npc_in_zone_or_queue(/mob/living/basic/mouse, run_loc_floor_bottom_left, new /datum/npc_spawn_context(run_loc_floor_bottom_left, 1)) + allocated += mouse + TEST_ASSERT(istype(mouse, /mob/living/basic/mouse), "A basic mob from a spawn list wasn't built at once") + +/// Suppression counts human pirates, each body once, and never another side's NPCs. +/datum/mission_objective/kill_count/unit_test + +/datum/mission_objective/kill_count/unit_test/kill_zone_counts(turf/where) + return TRUE + +/datum/mission_objective/kill_count/unit_test/kill_attributable_to_crew(mob/living/victim, turf/where) + return TRUE + +/datum/unit_test/voidcrew_ruin_npc_suppression_counts + +/datum/unit_test/voidcrew_ruin_npc_suppression_counts/Run() + var/datum/mission_objective/kill_count/unit_test/counter = allocate(/datum/mission_objective/kill_count/unit_test) + counter.required_kills = 10 + var/mob/living/carbon/human/npc/pirate = human_npc_build_in_zone(/mob/living/carbon/human/npc/ruin/trooper/pirate, 2) + counter.on_any_death(null, pirate, FALSE) + TEST_ASSERT_EQUAL(counter.kill_count, 1, "A dead human pirate wasn't counted") + counter.on_any_death(null, pirate, FALSE) + TEST_ASSERT_EQUAL(counter.kill_count, 1, "A human pirate revived and killed again counted twice") + var/mob/living/carbon/human/npc/captain = human_npc_build_in_zone(/mob/living/carbon/human/npc/faction_pirate/grey/captain, 2) + counter.on_any_death(null, captain, FALSE) + TEST_ASSERT_EQUAL(counter.kill_count, 2, "A dead faction pirate captain wasn't counted") + var/mob/living/carbon/human/npc/boater = human_npc_build_in_zone(/mob/living/carbon/human/npc/ruin/trooper/pirate/beach, 2) + var/mob/living/carbon/human/npc/operative = human_npc_build_in_zone(/mob/living/carbon/human/npc/ruin/trooper/syndicate, 2) + counter.on_any_death(null, boater, FALSE) + counter.on_any_death(null, operative, FALSE) + TEST_ASSERT_EQUAL(counter.kill_count, 2, "Beach pirates or Syndicate operatives counted as pirates") + +/// Kill contracts queue a human target, track it once it is built, and pay its cash once per contract. +/datum/unit_test/voidcrew_ruin_npc_kill_contract + +/datum/unit_test/voidcrew_ruin_npc_kill_contract/Run() + var/turf/location = run_loc_floor_bottom_left + var/datum/mission/mission = allocate(/datum/mission/npc_zone_test) + mission.objective_name = "Test Captain" + var/datum/mission_target/npc_zone_test/site = allocate(/datum/mission_target/npc_zone_test, mission) + site.band = 2 + mission.target = site + var/datum/mission_objective/field/kill_named/hunt = allocate(/datum/mission_objective/field/kill_named) + hunt.mission = mission + hunt.active = TRUE + hunt.target_mob_type = /mob/living/carbon/human/npc/faction_pirate/grey/captain + hunt.spawn_field_objects(location) + TEST_ASSERT_NULL(hunt.target_mob, "A human target was built on the spot instead of queued") + TEST_ASSERT_NOTNULL(hunt.quarry_order, "A human target wasn't queued") + var/datum/human_npc_order/order = hunt.quarry_order + var/mob/living/carbon/human/npc/faction_pirate/quarry = order?.fulfil() + TEST_ASSERT_NOTNULL(quarry, "The queued target wasn't built") + if(isnull(quarry)) + return + allocated += quarry + TEST_ASSERT_EQUAL(hunt.target_mob, quarry, "The built target isn't tracked") + TEST_ASSERT_EQUAL(quarry.real_name, "Test Captain", "The target doesn't carry the contract's name") + TEST_ASSERT_EQUAL(quarry.npc_payout_mission?.resolve(), mission, "The target isn't tied to its contract's cash") + // A contract that has already paid its cash leaves the body without any. + mission.boss_cash_issued = TRUE + var/list/before = location.contents.Copy() + mission.forget_quest_atom(quarry) + hunt.deactivate() + quarry.death() + TEST_ASSERT_NULL(locate(/obj/item/holochip) in (location.contents - before), "A target paid cash its contract had already paid") + for(var/atom/movable/dropped in location.contents - before) + if(dropped != quarry) + qdel(dropped) + // A cancelled contract never builds a target still in the queue. + hunt.active = TRUE + hunt.spawn_field_objects(location) + var/datum/human_npc_order/cancelled = hunt.quarry_order + hunt.deactivate() + TEST_ASSERT(QDELETED(cancelled), "A deactivated contract left its target in the spawn queue") + +/// Poacher squads of human hermits are queued, counted from the start and named when built. +/datum/unit_test/voidcrew_ruin_npc_poacher_squad + +/datum/unit_test/voidcrew_ruin_npc_poacher_squad/Run() + var/turf/location = run_loc_floor_bottom_left + var/datum/mission/mission = allocate(/datum/mission/npc_zone_test) + mission.objective_name = "the Test Outfit" + var/datum/mission_target/npc_zone_test/site = allocate(/datum/mission_target/npc_zone_test, mission) + mission.target = site + var/datum/mission_objective/field/wipe_camp/camp = allocate(/datum/mission_objective/field/wipe_camp) + camp.mission = mission + camp.active = TRUE + camp.squad_types = list(/mob/living/carbon/human/npc/ruin/hermit/hunter, /mob/living/carbon/human/npc/ruin/hermit) + camp.squad_names = list("'Snares' Okafor", "'Tallow' Vance") + camp.spawn_field_objects(location) + TEST_ASSERT_EQUAL(camp.squad_size, 2, "The squad's head count didn't include the queued poachers") + TEST_ASSERT_EQUAL(length(camp.pending_poachers), 2, "The human poachers weren't queued") + for(var/datum/human_npc_order/order as anything in camp.pending_poachers.Copy()) + order.fulfil() + TEST_ASSERT_EQUAL(length(camp.squad), 2, "The built poachers didn't join the squad") + TEST_ASSERT_EQUAL(length(camp.pending_poachers), 0, "Built poachers are still pending") + var/list/names = list() + for(var/mob/living/carbon/human/npc/poacher in camp.squad) + names += poacher.real_name + allocated += poacher + TEST_ASSERT("'Snares' Okafor" in names, "The trailboss lost the contract's name") + mission.forget_quest_atom(mission.quest_atom) + camp.deactivate() + // The camp's dressing and its cache (with the evidence inside). + for(var/obj/thing in range(3, location)) + if(istype(thing, /obj/structure/bonfire) || istype(thing, /obj/structure/barricade) || istype(thing, /obj/structure/bed) || istype(thing, /obj/item/bedsheet) || istype(thing, /obj/structure/closet)) + qdel(thing) + +/// No Voidcrew ruin, shuttle or hull map places a trooper or hermit basic mob any more, and the derelict shuttles inside ruins load +/// their Voidcrew copies (the bounty lair's mafia is another phase's). +/datum/unit_test/voidcrew_ruin_npc_maps + +/datum/unit_test/voidcrew_ruin_npc_maps/Run() + var/list/maps = list() + for(var/root in list("_maps/voidcrew/RandomRuins/", "_maps/voidcrew/shuttles/", "_maps/voidcrew/ships/")) + ruin_npc_collect_maps(root, maps) + TEST_ASSERT(length(maps) > 100, "The Voidcrew map scan found only [length(maps)] maps") + for(var/map_path in maps) + if(findtext(map_path, "bounty_lair_mafia_club.dmm")) + continue + var/text = maps[map_path] + TEST_ASSERT(!findtext(text, "/mob/living/basic/trooper"), "[map_path] still places a trooper basic mob") + TEST_ASSERT(!findtext(text, "/mob/living/simple_animal/hostile/asteroid/hermit"), "[map_path] still places a hermit simple mob") + for(var/template_type in list( + /datum/map_template/shuttle/ruin/caravan_victim, + /datum/map_template/shuttle/ruin/pirate_cutter, + /datum/map_template/shuttle/ruin/syndicate_dropship, + /datum/map_template/shuttle/ruin/syndicate_fighter_shiv, + )) + var/datum/map_template/shuttle/template = new template_type() + TEST_ASSERT(findtext(template.mappath, "_maps/voidcrew/shuttles/") == 1, "[template_type] loads [template.mappath], not its Voidcrew copy") + TEST_ASSERT(fexists(template.mappath), "[template_type]'s map [template.mappath] is missing") + qdel(template) + +/datum/unit_test/voidcrew_ruin_npc_maps/proc/ruin_npc_collect_maps(root, list/out) + for(var/entry in flist(root)) + if(copytext(entry, -1) == "/") + ruin_npc_collect_maps("[root][entry]", out) + else if(copytext(entry, -4) == ".dmm") + out["[root][entry]"] = file2text("[root][entry]") diff --git a/voidcrew/modules/unit_tests/voidcrew_human_npcs_shared.dm b/voidcrew/modules/unit_tests/voidcrew_human_npcs_shared.dm index de6e5d5f785..1671452dd82 100644 --- a/voidcrew/modules/unit_tests/voidcrew_human_npcs_shared.dm +++ b/voidcrew/modules/unit_tests/voidcrew_human_npcs_shared.dm @@ -279,6 +279,31 @@ qdel(waiting) qdel(unresolved) + // Every pirate table, every outfit in it worn once. + var/list/outfits_seen = list() + for(var/table_type in subtypesof(/datum/human_npc_outfit_table/pirate)) + var/datum/human_npc_outfit_table/pirate/table = human_npc_singleton(table_type) + for(var/zone in 1 to 3) + TEST_ASSERT(length(table.outfits_for(null, zone)), "[table_type] dresses nobody in zone [zone]") + TEST_ASSERT(length(table.elite), "[table_type] has no captain") + TEST_ASSERT(length(table.boss), "[table_type] has no boss") + if(table.gunners_only) + for(var/outfit_type in table.green) + TEST_ASSERT(!(outfit_type in table.melee), "[table_type] hands out a melee outfit") + for(var/list/choices in list(table.green, table.elite, table.boss)) + for(var/outfit_type in choices) + outfits_seen |= outfit_type + for(var/outfit_type in outfits_seen) + TEST_ASSERT(ispath(outfit_type, /datum/outfit), "A pirate table lists [outfit_type], which is not an outfit") + var/datum/human_npc_order/dressed = spawn_human_npc(/mob/living/carbon/human/npc/sample, run_loc_floor_bottom_left, outfit = outfit_type, immediate = TRUE) + var/mob/living/carbon/human/npc/pirate = dressed.spawned_ref?.resolve() + TEST_ASSERT_NOTNULL(pirate, "[outfit_type] built nobody") + var/obj/item/gun/gun = human_npc_held_gun(pirate) + TEST_ASSERT(gun || human_npc_held_melee_weapon(pirate), "[outfit_type] holds no weapon") + if(istype(gun, /obj/item/gun/ballistic)) + TEST_ASSERT_NOTNULL(human_npc_find_ammo(pirate, gun), "[outfit_type] carries no spare ammunition for its [gun]") + qdel(pirate) + /// N7: where the air can't keep a person alive the NPC gets a sealed suit and a tank; in the cold it gets /// cold-weather wear; a species that needs neither is left alone. It minds its valve like a person: open /// while the air would hurt it, shut while the air is fine (so the tank doesn't run dry in a good room). diff --git a/voidcrew/modules/unit_tests/voidcrew_mission_console_rewards.dm b/voidcrew/modules/unit_tests/voidcrew_mission_console_rewards.dm index f0586b41d09..b2e2a530322 100644 --- a/voidcrew/modules/unit_tests/voidcrew_mission_console_rewards.dm +++ b/voidcrew/modules/unit_tests/voidcrew_mission_console_rewards.dm @@ -424,16 +424,17 @@ /datum/unit_test/voidcrew_m2_rewards/chips/Run() var/datum/mission/recovery/kill/kill_type = allocate(/datum/mission/recovery/kill/m2_rewards_test) TEST_ASSERT_EQUAL(kill_type.guarded_prize_family, "kill", "Kill fixture lost its production prize family") + // The targets are human NPC faction pirates (voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_humans.dm); their chip is npc_death_cash. var/easy_cash = 0 - for(var/mob/living/basic/trooper/pirate/faction/pirate_type as anything in kill_type.easy_targets) - easy_cash += initial(pirate_type.plunder_credits) + for(var/mob/living/carbon/human/npc/faction_pirate/pirate_type as anything in kill_type.easy_targets) + easy_cash += initial(pirate_type.npc_death_cash) TEST_ASSERT_EQUAL(easy_cash / length(kill_type.easy_targets), 300, "Wrong green kill-chip expectation") var/medium_cash = 0 - for(var/mob/living/basic/trooper/pirate/faction/pirate_type as anything in kill_type.medium_targets) - medium_cash += initial(pirate_type.plunder_credits) + for(var/mob/living/carbon/human/npc/faction_pirate/pirate_type as anything in kill_type.medium_targets) + medium_cash += initial(pirate_type.npc_death_cash) TEST_ASSERT_EQUAL(medium_cash / length(kill_type.medium_targets) + 300, 568.75, "Wrong yellow kill-chip expectation") - for(var/mob/living/basic/trooper/pirate/faction/pirate_type as anything in kill_type.hard_targets) - TEST_ASSERT_EQUAL(initial(pirate_type.plunder_credits) + 2 * 25, 3050, "Wrong red kill-chip expectation") + for(var/mob/living/carbon/human/npc/faction_pirate/pirate_type as anything in kill_type.hard_targets) + TEST_ASSERT_EQUAL(initial(pirate_type.npc_death_cash) + 2 * 25, 3050, "Wrong red kill-chip expectation") var/mob/living/basic/trooper/pirate/faction/medieval/captain/captain_type = /mob/living/basic/trooper/pirate/faction/medieval/captain TEST_ASSERT_EQUAL(initial(captain_type.plunder_credits), 1000, "Medieval captain kept its melee chip value") diff --git a/voidcrew/modules/unit_tests/voidcrew_missions.dm b/voidcrew/modules/unit_tests/voidcrew_missions.dm index 03090e20b56..8e3d7287f6b 100644 --- a/voidcrew/modules/unit_tests/voidcrew_missions.dm +++ b/voidcrew/modules/unit_tests/voidcrew_missions.dm @@ -608,7 +608,6 @@ /mob/living/basic/trooper/pirate/faction/boss/mission_rewind_test ai_controller = null basic_mob_flags = NONE - use_dynamic_appearance = FALSE corpse = null loot = null loot_pool = null diff --git a/voidcrew/modules/unit_tests/voidcrew_npc_zone_profiles.dm b/voidcrew/modules/unit_tests/voidcrew_npc_zone_profiles.dm index 05727a42eb3..742e3a0b459 100644 --- a/voidcrew/modules/unit_tests/voidcrew_npc_zone_profiles.dm +++ b/voidcrew/modules/unit_tests/voidcrew_npc_zone_profiles.dm @@ -780,7 +780,6 @@ /mob/living/basic/mining/wolf/random = /mob/living/basic/mining/wolf/alpha, /mob/living/basic/mining/wolf/wasteland/random = /mob/living/basic/mining/wolf/alpha/wasteland, /mob/living/simple_animal/hostile/asteroid/polarbear/random = /mob/living/simple_animal/hostile/asteroid/polarbear/warrior, - /mob/living/simple_animal/hostile/asteroid/hermit/survivor/random = /mob/living/simple_animal/hostile/asteroid/hermit/ranged, ) for(var/spawn_type in replacement_types) var/found_replacement = FALSE @@ -1316,8 +1315,6 @@ /mob/living/basic/trooper/nanotrasen/ranged/smg, /mob/living/basic/trooper/nanotrasen/ranged/assault, /mob/living/basic/trooper/nanotrasen/ranged/elite, - /mob/living/basic/trooper/nanotrasen/ranged/smg/customs, - /mob/living/basic/trooper/nanotrasen/ranged/assault/customs, /mob/living/basic/trooper/syndicate/ranged/smg, /mob/living/basic/trooper/syndicate/ranged/shotgun, /mob/living/basic/trooper/syndicate/ranged/smg/space/stormtrooper, @@ -1325,8 +1322,8 @@ for(var/mob_type in shooters) for(var/zone in 1 to 3) var/is_nt = ispath(mob_type, /mob/living/basic/trooper/nanotrasen) - var/is_customs = mob_type == /mob/living/basic/trooper/nanotrasen/ranged/smg/customs || mob_type == /mob/living/basic/trooper/nanotrasen/ranged/assault/customs - var/replaced = zone == 1 || (zone == 2 && (!is_nt || is_customs || mob_type == /mob/living/basic/trooper/nanotrasen/ranged/elite)) + // NT customs are human NPCs now; their ladder is tested in voidcrew_human_npcs_nt_customs.dm + var/replaced = zone == 1 || (zone == 2 && (!is_nt || mob_type == /mob/living/basic/trooper/nanotrasen/ranged/elite)) var/datum/npc_spawn_context/context = allocate(/datum/npc_spawn_context, src, zone) var/mob/living/basic/trooper/body = spawn_npc_in_zone(mob_type, run_loc_floor_bottom_left, context) var/datum/component/ranged_attacks/ranged = body.GetComponent(/datum/component/ranged_attacks) diff --git a/voidcrew/modules/unit_tests/voidcrew_pirate_crew_ai.dm b/voidcrew/modules/unit_tests/voidcrew_pirate_crew_ai.dm index 0a7fdb59221..6a401c2b29f 100644 --- a/voidcrew/modules/unit_tests/voidcrew_pirate_crew_ai.dm +++ b/voidcrew/modules/unit_tests/voidcrew_pirate_crew_ai.dm @@ -1,7 +1,9 @@ /** - * Pirate crew AI (voidcrew/modules/npc_ships/code/pirate_crew.dm and pirate_crew_ai.dm): which - * doors a pirate walks through, which it may break, the search for the door in the way, and how - * a hull's crew and a raid are put together. + * Pirate crew AI (voidcrew/modules/npc_ships/code/pirate_crew.dm, pirate_crew_ai.dm and + * pirate_crew_human.dm): which doors a pirate walks through, which it may break, the search for the + * door in the way, and how a hull's crew and a raid are put together. NPC ship crews are human NPCs + * (faction_pirate_humans.dm), so most of these use them; voidcrew_pirate_crew_human.dm tests what they + * do with their hands. * * Fork defines are included after the tests, so roles and blackboard keys appear as their * literal strings ("captain" is PIRATE_ROLE_CAPTAIN, "pirate_crew" is BB_PIRATE_CREW). Every @@ -30,13 +32,21 @@ changed_turfs |= where return where.ChangeTurf(new_type) +/// Builds a human NPC now at `where`, dressed in `outfit` if given (an outfit or an outfit table) +/datum/unit_test/voidcrew_pirate_crew/proc/build_npc(npc_type, turf/where, outfit) + var/datum/human_npc_order/order = spawn_human_npc(npc_type, where || run_loc_floor_bottom_left, outfit = outfit, immediate = TRUE) + var/mob/living/carbon/human/npc/npc = order?.spawned_ref?.resolve() + if(npc) + allocated += npc + return npc + // ===== WHICH DOORS OPEN ===== /// An unlocked airlock opens for a pirate; a bolted, welded, unpowered or access-locked one does not /datum/unit_test/voidcrew_pirate_crew/door_rules /datum/unit_test/voidcrew_pirate_crew/door_rules/Run() - var/mob/living/basic/trooper/pirate/melee/pirate = allocate(/mob/living/basic/trooper/pirate/melee, spot(0, 0)) + var/mob/living/carbon/human/npc/faction_pirate/grey/melee/pirate = build_npc(/mob/living/carbon/human/npc/faction_pirate/grey/melee, spot(0, 0)) var/obj/machinery/door/airlock/door = allocate(/obj/machinery/door/airlock, spot(2, 2)) TEST_ASSERT(door.density, "The test airlock spawned open") TEST_ASSERT(pirate_can_open_door(pirate, door), "A pirate can't open an unlocked, powered airlock") @@ -55,8 +65,9 @@ door.set_machine_stat(old_stat) TEST_ASSERT(pirate_can_open_door(pirate, door), "Restoring power didn't make the airlock openable again") + // The pirate's ID card carries its name and no access door.req_access = list(ACCESS_ENGINEERING) - TEST_ASSERT(!pirate_can_open_door(pirate, door), "A pirate with no ID can open an access-locked airlock") + TEST_ASSERT(!pirate_can_open_door(pirate, door), "A pirate's ID card opens an access-locked airlock") door.req_access = null /// Breaking an external airlock with space beyond it is off limits; an inner door or an indestructible one depends @@ -74,13 +85,19 @@ inner.open() TEST_ASSERT(!pirate_door_breachable(inner, spot(0, 2)), "A pirate may break an airlock that is already open") + // A firelock holding back a room that lost its air is never forced either + var/obj/machinery/door/firedoor/firelock = allocate(/obj/machinery/door/firedoor, spot(4, 3)) + TEST_ASSERT(pirate_door_vents_space(firelock, spot(4, 2)), "A pirate may force a firelock with vacuum behind it") + var/obj/machinery/door/firedoor/inner_firelock = allocate(/obj/machinery/door/firedoor, spot(1, 3)) + TEST_ASSERT(!pirate_door_vents_space(inner_firelock, spot(1, 2)), "A firelock with air on both sides counts as venting") + // ===== THE DOOR IN THE WAY ===== /// Two rooms joined only by a bolted airlock: the search finds that airlock and the floor to break it from /datum/unit_test/voidcrew_pirate_crew/breach_search /datum/unit_test/voidcrew_pirate_crew/breach_search/Run() - var/mob/living/basic/trooper/pirate/melee/pirate = allocate(/mob/living/basic/trooper/pirate/melee, spot(0, 2)) + var/mob/living/carbon/human/npc/faction_pirate/grey/melee/pirate = build_npc(/mob/living/carbon/human/npc/faction_pirate/grey/melee, spot(0, 2)) for(var/dy in list(0, 1, 3, 4)) change_turf(spot(2, dy), /turf/closed/wall) var/obj/machinery/door/airlock/instant/door = allocate(/obj/machinery/door/airlock/instant, spot(2, 2)) @@ -113,15 +130,18 @@ // ===== CREWS ===== -/// A hull's crew has one captain and one guard, a melee guard when there is one, and alerting it wakes everyone +/// A hull's crew has one captain and one guard, a melee guard when there is one, and alerting it wakes +/// everyone; the captain and guard join the hunt once the rest are out of the fight (dead, down or cuffed) /datum/unit_test/voidcrew_pirate_crew/defending_roles /datum/unit_test/voidcrew_pirate_crew/defending_roles/Run() var/obj/structure/overmap/ship/npc/pirate/hull = allocate(/obj/structure/overmap/ship/npc/pirate) - var/mob/living/basic/trooper/pirate/ranged/captain = allocate(/mob/living/basic/trooper/pirate/ranged, spot(0, 0)) - var/mob/living/basic/trooper/pirate/ranged/gunner = allocate(/mob/living/basic/trooper/pirate/ranged, spot(1, 0)) - var/mob/living/basic/trooper/pirate/melee/brawler = allocate(/mob/living/basic/trooper/pirate/melee, spot(2, 0)) - var/mob/living/basic/trooper/pirate/melee/deckhand = allocate(/mob/living/basic/trooper/pirate/melee, spot(3, 0)) + var/mob/living/carbon/human/npc/faction_pirate/silverscale/captain/captain = build_npc(/mob/living/carbon/human/npc/faction_pirate/silverscale/captain, spot(0, 0)) + var/mob/living/carbon/human/npc/faction_pirate/silverscale/ranged/gunner = build_npc(/mob/living/carbon/human/npc/faction_pirate/silverscale/ranged, spot(1, 0)) + var/mob/living/carbon/human/npc/faction_pirate/silverscale/melee/brawler = build_npc(/mob/living/carbon/human/npc/faction_pirate/silverscale/melee, spot(2, 0)) + var/mob/living/carbon/human/npc/faction_pirate/silverscale/melee/deckhand = build_npc(/mob/living/carbon/human/npc/faction_pirate/silverscale/melee, spot(3, 0)) + TEST_ASSERT(pirate_crew_is_ranged(gunner), "A marksman holding a gun doesn't count as a gunner") + TEST_ASSERT(!pirate_crew_is_ranged(brawler), "A duelist counts as a gunner") TEST_ASSERT(pirate_crew_enlist_defender(captain, hull, "captain"), "The captain could not join the hull's crew") // The gunner joins first and takes the guard post; the first melee recruit takes it off him @@ -142,6 +162,8 @@ if("guard") guards++ TEST_ASSERT_EQUAL(member.ai_controller?.blackboard["pirate_crew"], crew, "[member] doesn't know its crew") + TEST_ASSERT_EQUAL(member.ai_controller?.type, /datum/ai_controller/basic_controller/pirate_crew/human, "[member] isn't on the human pirate crew controller") + TEST_ASSERT_EQUAL(member.ai_controller?.blackboard[BB_TARGET_MINIMUM_STAT], HARD_CRIT, "[member] stops shooting people in crit") TEST_ASSERT_EQUAL(captains, 1, "The crew has [captains] captains") TEST_ASSERT_EQUAL(guards, 1, "The crew has [guards] guards") TEST_ASSERT_EQUAL(crew.members[captain], "captain", "The pirate enlisted as captain isn't the captain") @@ -159,32 +181,45 @@ for(var/mob/living/member in crew.members) TEST_ASSERT(!member.ai_controller.can_idle, "[member] can still idle on alert") + // The guard down and the deckhand cuffed: only the gunner is still fighting, so the captain joins in + brawler.adjustToxLoss(110) // down in soft crit; a silverscale doesn't breathe, so oxygen damage wouldn't touch it + var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs) + TEST_ASSERT(deckhand.equip_to_slot_if_possible(cuffs, ITEM_SLOT_HANDCUFFED), "Test fixture: the deckhand could not be cuffed") + crew.check_promotion() + TEST_ASSERT(crew.promoted, "The captain didn't join the hunt with only one of his crew still fighting") + TEST_ASSERT(!crew.holds_post(captain), "The captain still holds the post once his crew is beaten") + qdel(crew) TEST_ASSERT_NULL(pirate_crew_of(hull), "A deleted crew is still registered to its hull") TEST_ASSERT_NULL(captain.ai_controller.blackboard["pirate_crew"], "The captain still points at a deleted crew") -/// A boarder joins the raid on the ship it landed on, and a trooper gets the melee controller, a ranged trooper the ranged one +/// A boarder joins the raid on the ship it landed on; a human pirate gets the human controller, and a +/// basic trooper still gets the melee controller, a ranged trooper the ranged one /datum/unit_test/voidcrew_pirate_crew/raid_controllers /datum/unit_test/voidcrew_pirate_crew/raid_controllers/Run() var/obj/structure/overmap/ship/target = allocate(/obj/structure/overmap/ship) var/mob/living/basic/trooper/trooper = allocate(/mob/living/basic/trooper, spot(0, 0)) - var/mob/living/basic/trooper/pirate/ranged/gunner = allocate(/mob/living/basic/trooper/pirate/ranged, spot(1, 0)) + var/mob/living/basic/trooper/pirate/ranged/basic_gunner = allocate(/mob/living/basic/trooper/pirate/ranged, spot(1, 0)) + var/mob/living/carbon/human/npc/faction_pirate/irs/ranged/boarder = build_npc(/mob/living/carbon/human/npc/faction_pirate/irs/ranged, spot(2, 0)) TEST_ASSERT_EQUAL(pirate_crew_controller_type(trooper), /datum/ai_controller/basic_controller/pirate_crew, "A melee trooper is down for the wrong controller") - TEST_ASSERT_EQUAL(pirate_crew_controller_type(gunner), /datum/ai_controller/basic_controller/pirate_crew/ranged, "A ranged trooper is down for the wrong controller") + TEST_ASSERT_EQUAL(pirate_crew_controller_type(basic_gunner), /datum/ai_controller/basic_controller/pirate_crew/ranged, "A ranged trooper is down for the wrong controller") + TEST_ASSERT_EQUAL(pirate_crew_controller_type(boarder), /datum/ai_controller/basic_controller/pirate_crew/human, "A human pirate is down for the wrong controller") TEST_ASSERT(pirate_crew_enlist_raider(trooper, target), "A trooper could not join the raid") - TEST_ASSERT(pirate_crew_enlist_raider(gunner, target), "A gunner could not join the raid") + TEST_ASSERT(pirate_crew_enlist_raider(basic_gunner, target), "A basic gunner could not join the raid") + TEST_ASSERT(pirate_crew_enlist_raider(boarder, target), "A human boarder could not join the raid") TEST_ASSERT_EQUAL(trooper.ai_controller?.type, /datum/ai_controller/basic_controller/pirate_crew, "The trooper didn't get the pirate crew controller") - TEST_ASSERT_EQUAL(gunner.ai_controller?.type, /datum/ai_controller/basic_controller/pirate_crew/ranged, "The gunner didn't get the ranged pirate crew controller") + TEST_ASSERT_EQUAL(basic_gunner.ai_controller?.type, /datum/ai_controller/basic_controller/pirate_crew/ranged, "The basic gunner didn't get the ranged pirate crew controller") + TEST_ASSERT_EQUAL(boarder.ai_controller?.type, /datum/ai_controller/basic_controller/pirate_crew/human, "The human boarder lost its human controller") var/datum/pirate_crew/raid = pirate_crew_of(target, TRUE) TEST_ASSERT_NOTNULL(raid, "Enlisting made no raid on the ship") TEST_ASSERT_NULL(pirate_crew_of(target), "A raid registered itself as the ship's own crew") TEST_ASSERT(raid.raiding && raid.alerted, "A raid isn't on the attack from the start") - TEST_ASSERT_EQUAL(raid.members[trooper], "hunter", "A boarder isn't a hunter") - TEST_ASSERT(!raid.holds_post(trooper), "A boarder holds a post") - TEST_ASSERT(!trooper.ai_controller.can_idle && !gunner.ai_controller.can_idle, "Boarders can idle") + TEST_ASSERT_EQUAL(raid.members[boarder], "hunter", "A boarder isn't a hunter") + TEST_ASSERT(!raid.holds_post(boarder), "A boarder holds a post") + TEST_ASSERT(!trooper.ai_controller.can_idle && !boarder.ai_controller.can_idle, "Boarders can idle") qdel(raid) // ===== LOOKS ===== @@ -214,10 +249,10 @@ /datum/unit_test/voidcrew_pirate_crew/mineral_doors /datum/unit_test/voidcrew_pirate_crew/mineral_doors/Run() - var/mob/living/basic/trooper/pirate/melee/pirate = allocate(/mob/living/basic/trooper/pirate/melee, spot(0, 2)) + var/mob/living/carbon/human/npc/faction_pirate/grey/melee/pirate = build_npc(/mob/living/carbon/human/npc/faction_pirate/grey/melee, spot(0, 2)) var/mob/living/basic/trooper/pirate/melee/bystander = allocate(/mob/living/basic/trooper/pirate/melee, spot(4, 2)) var/obj/structure/overmap/ship/target = allocate(/obj/structure/overmap/ship) - TEST_ASSERT(pirate_crew_enlist_raider(pirate, target), "A trooper could not join the raid") + TEST_ASSERT(pirate_crew_enlist_raider(pirate, target), "A pirate could not join the raid") for(var/dy in list(0, 1, 3, 4)) change_turf(spot(2, dy), /turf/closed/wall) var/obj/structure/mineral_door/iron/slab = allocate(/obj/structure/mineral_door/iron, spot(2, 2)) @@ -237,66 +272,3 @@ TEST_ASSERT(!pirate_can_open_mineral_door(slab), "A pirate tries to open a loose iron door") TEST_ASSERT_NULL(pirate_crew_breach_search(pirate, spot(0, 2), spot(4, 2), areas), "The search found a way through a loose iron door") qdel(pirate_crew_of(target, TRUE)) - -// ===== GUNS ===== - -/// Every pirate gun fires a real round from a real magazine; a gunner joining a crew trades its stock shot for one, and a crossbowman keeps his -/datum/unit_test/voidcrew_pirate_crew/guns - -/datum/unit_test/voidcrew_pirate_crew/guns/Run() - for(var/loadout_type in subtypesof(/datum/pirate_gun_loadout)) - var/datum/pirate_gun_loadout/loadout = GLOB.pirate_gun_loadouts[loadout_type] - TEST_ASSERT_NOTNULL(loadout, "[loadout_type] has no shared copy") - TEST_ASSERT(loadout.magazine_size() > 1, "[loadout_type] holds [loadout.magazine_size()] rounds") - TEST_ASSERT(loadout.fire_sound, "[loadout_type] makes no sound") - var/obj/projectile/shot = loadout.make_projectile(spot(4, 4)) - TEST_ASSERT_NOTNULL(shot, "[loadout_type] fires nothing") - TEST_ASSERT(shot.damage > 0, "[loadout_type]'s round does no damage") - qdel(shot) - var/datum/pirate_gun_loadout/shotgun = GLOB.pirate_gun_loadouts[/datum/pirate_gun_loadout/shotgun] - TEST_ASSERT(shotgun.pellets() > 1, "The shotgun fires one pellet") - var/datum/pirate_gun_loadout/smg = GLOB.pirate_gun_loadouts[/datum/pirate_gun_loadout/smg] - TEST_ASSERT_EQUAL(smg.magazine_size(), 32, "The SMG's magazine isn't the Uzi's") - - var/obj/structure/overmap/ship/target = allocate(/obj/structure/overmap/ship) - var/mob/living/basic/trooper/pirate/faction/irs/ranged/gunner = allocate(/mob/living/basic/trooper/pirate/faction/irs/ranged, spot(0, 0)) - var/mob/living/basic/trooper/pirate/faction/medieval/ranged/archer = allocate(/mob/living/basic/trooper/pirate/faction/medieval/ranged, spot(0, 1)) - TEST_ASSERT(pirate_crew_enlist_raider(gunner, target), "A gunner could not join the raid") - TEST_ASSERT(pirate_crew_enlist_raider(archer, target), "A crossbowman could not join the raid") - var/datum/component/pirate_gun/gun = pirate_gun_of(gunner) - TEST_ASSERT_NOTNULL(gun, "A gunner joined a crew without rolling a gun") - TEST_ASSERT_NULL(gunner.GetComponent(/datum/component/ranged_attacks), "A gunner kept its stock shot as well as its gun") - TEST_ASSERT_EQUAL(gunner.r_hand, gun.loadout.gun_type, "A gunner holds a different gun from the one it fires") - TEST_ASSERT_NULL(pirate_gun_of(archer), "A crossbowman traded his crossbow for a gun") - TEST_ASSERT_NOTNULL(archer.GetComponent(/datum/component/ranged_attacks), "A crossbowman lost his crossbow") - - // A pistol fires its pair, and reloads when the magazine runs dry - var/mob/living/basic/trooper/pirate/ranged/pistoleer = allocate(/mob/living/basic/trooper/pirate/ranged, spot(0, 2)) - TEST_ASSERT_EQUAL(pirate_crew_arm(pistoleer, /datum/pirate_gun_loadout/pistol), GLOB.pirate_gun_loadouts[/datum/pirate_gun_loadout/pistol], "A gunner couldn't be handed a pistol") - var/datum/component/pirate_gun/pistol = pirate_gun_of(pistoleer) - var/mob/living/carbon/human/consistent/mark = allocate(/mob/living/carbon/human/consistent, spot(4, 2)) - var/full = pistol.ammo - TEST_ASSERT(pistol.try_fire(mark), "A loaded pistol wouldn't fire") - TEST_ASSERT_EQUAL(pistol.ammo, full - 2, "A pistol pair didn't use two rounds") - TEST_ASSERT(!pistol.try_fire(mark), "A pistol fired again before its cooldown") - pistol.next_fire_at = 0 - pistol.ammo = 1 - TEST_ASSERT(pistol.try_fire(mark), "A pistol with one round left wouldn't fire") - TEST_ASSERT(pistol.is_reloading(), "An empty pistol isn't reloading") - TEST_ASSERT_EQUAL(pistol.ammo, full, "A reload didn't fill the magazine") - - // A shotgunner holds fire until it's close, and a hit during the pump spoils the shot - var/mob/living/basic/trooper/pirate/ranged/shotgunner = allocate(/mob/living/basic/trooper/pirate/ranged, spot(0, 3)) - pirate_crew_arm(shotgunner, /datum/pirate_gun_loadout/shotgun) - var/datum/component/pirate_gun/pump = pirate_gun_of(shotgunner) - var/mob/living/carbon/human/consistent/far_mark = allocate(/mob/living/carbon/human/consistent, spot(4, 3)) - TEST_ASSERT(!pump.try_fire(far_mark), "A shotgun fired from four tiles out") - far_mark.forceMove(spot(2, 3)) - TEST_ASSERT(pump.try_fire(far_mark), "A shotgun wouldn't fire from two tiles") - TEST_ASSERT(pump.winding, "A shotgun fired without pumping") - var/shells = pump.ammo - shotgunner.apply_damage(5, BRUTE) - TEST_ASSERT(!pump.winding, "A hit during the pump didn't spoil it") - pump.finish_windup(pump.serial - 1) - TEST_ASSERT_EQUAL(pump.ammo, shells, "A spoiled pump still fired") - qdel(pirate_crew_of(target, TRUE)) diff --git a/voidcrew/modules/unit_tests/voidcrew_pirate_crew_human.dm b/voidcrew/modules/unit_tests/voidcrew_pirate_crew_human.dm new file mode 100644 index 00000000000..78e6062a824 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_pirate_crew_human.dm @@ -0,0 +1,487 @@ +/** + * Human NPC ship crews (voidcrew/modules/npc_ships/code/faction_pirates/faction_pirate_humans.dm and + * pirate_crew_human.dm, human NPC migration phase B): how they are dressed, armed and ranked, how they + * fire their real guns, how a hull's crew and a boarding wave count as beaten (dead, down or cuffed, + * owner ruling OC-7), what happens to one spaced (no forced death, PI-3), how boarders come by pod, and + * the bosses' real kit and finishers. + * + * Fork defines are included after the tests, so their values are written out: ranks + * HUMAN_NPC_RANK_ELITE 1 and _BOSS 2; blackboard keys by their strings; combat states "boarding", + * "boarding_cooldown"; HV_FINISHER_DAMAGED 3. Nothing waits on a timer or an AI walk. + */ + +/// The boarding test controller from voidcrew_npc_boarding_docking.dm, with the turfs its pods may use +/datum/unit_test/voidcrew_pirate_crew/human_crew + abstract_type = /datum/unit_test/voidcrew_pirate_crew/human_crew + +// ===== DRESS, RANK AND KIT ===== + +/// Every faction's crew is dressed for its role, ranked and armed; boarders wear a sealed suit and air, +/// crew aboard their own hull don't; medieval footsoldiers refuse guns and their crossbowmen don't. +/datum/unit_test/voidcrew_pirate_crew/human_crew/dress + +/datum/unit_test/voidcrew_pirate_crew/human_crew/dress/Run() + for(var/faction in list("silverscale", "skeleton", "grey", "lustrous", "interdyne", "irs", "medieval")) + var/melee_type = text2path("/mob/living/carbon/human/npc/faction_pirate/[faction]/melee") + var/ranged_type = text2path("/mob/living/carbon/human/npc/faction_pirate/[faction]/ranged") + var/captain_type = text2path("/mob/living/carbon/human/npc/faction_pirate/[faction]/captain") + var/mob/living/carbon/human/npc/faction_pirate/melee = build_npc(melee_type, spot(0, 0)) + var/mob/living/carbon/human/npc/faction_pirate/ranged = build_npc(ranged_type, spot(1, 0)) + var/mob/living/carbon/human/npc/faction_pirate/captain = build_npc(captain_type, spot(2, 0)) + TEST_ASSERT(human_npc_held_melee_weapon(melee) && !human_npc_held_gun(melee), "[melee_type] isn't holding a blade or a club") + TEST_ASSERT_NOTNULL(human_npc_held_gun(ranged), "[ranged_type] isn't holding a gun") + var/obj/item/gun/ballistic/bullet_gun = human_npc_held_gun(ranged) + if(istype(bullet_gun)) + TEST_ASSERT_NOTNULL(human_npc_find_ammo(ranged, bullet_gun), "[ranged_type] carries no spare ammunition") + TEST_ASSERT_EQUAL(captain.npc_rank, 1, "[captain_type] isn't an elite") + TEST_ASSERT_EQUAL(captain.npc_damage_taken, 0.8, "[captain_type] isn't as tough as a captain should be") + TEST_ASSERT_EQUAL(melee.npc_rank, 0, "[melee_type] isn't rank and file") + TEST_ASSERT_EQUAL(melee.ai_controller?.type, /datum/ai_controller/basic_controller/pirate_crew/human, "[melee_type] isn't on the human pirate crew controller") + TEST_ASSERT(melee.npc_death_cash > 0 && ranged.npc_death_cash > 0 && captain.npc_death_cash > melee.npc_death_cash, "[faction] crew lost their plunder") + // Their ID card names them, so a helmet doesn't make them "Unknown" + var/obj/item/card/id/card = melee.wear_id + TEST_ASSERT(istype(card) && card.registered_name == melee.real_name, "[melee_type] carries no ID card with its name") + TEST_ASSERT(human_npc_gear_locked(card), "[melee_type]'s ID card isn't locked to it") + // Aboard its own hull in good air: no space suit + TEST_ASSERT(!istype(melee.wear_suit, /obj/item/clothing/suit/space), "[melee_type] wears a space suit in good air") + // A boarder: sealed against vacuum's pressure and cold, and on its own air if it breathes. A skeleton + // needs neither; silverscale and lustrous shrug off the pressure and don't breathe, but feel the cold. + var/mob/living/carbon/human/npc/faction_pirate/boarder = build_npc(melee_type, spot(3, 0), boarding_outfit_for(melee_type)) + if(faction == "skeleton") + TEST_ASSERT(!istype(boarder.wear_suit, /obj/item/clothing/suit/space), "A skeleton boarder was given a space suit it doesn't need") + else + TEST_ASSERT(boarder.wear_suit && (boarder.wear_suit.clothing_flags & STOPSPRESSUREDAMAGE), "A [faction] boarder has no sealed suit") + TEST_ASSERT(boarder.head && (boarder.head.clothing_flags & STOPSPRESSUREDAMAGE), "A [faction] boarder has no sealed helmet") + if(!HAS_TRAIT(boarder, TRAIT_NOBREATH)) + TEST_ASSERT(boarder.can_breathe_internals() && length(boarder.get_all_contents_type(/obj/item/tank/internals)), "A [faction] boarder carries no air it can breathe") + if(faction == "medieval") + TEST_ASSERT(HAS_TRAIT(melee, TRAIT_NOGUNS), "A medieval footsoldier will use guns") + TEST_ASSERT(HAS_TRAIT(captain, TRAIT_NOGUNS), "The medieval warlord will use guns") + TEST_ASSERT(!HAS_TRAIT(ranged, TRAIT_NOGUNS), "A medieval crossbowman can't use his crossbow") + for(var/mob/living/carbon/human/npc/built as anything in list(melee, ranged, captain, boarder)) + qdel(built) + +/// The captain's key isn't gear: it is on him, not locked, and drops at his feet when he dies. Crew are +/// tracked by the hull as they are built. +/datum/unit_test/voidcrew_pirate_crew/human_crew/captain_key + +/datum/unit_test/voidcrew_pirate_crew/human_crew/captain_key/Run() + var/obj/structure/overmap/ship/npc/pirate/hull = allocate(/obj/structure/overmap/ship/npc/pirate) + var/mob/living/carbon/human/npc/faction_pirate/grey/captain/captain = build_npc(/mob/living/carbon/human/npc/faction_pirate/grey/captain, spot(1, 1)) + hull.on_captain_built(captain) + var/obj/item/ship_key/key = locate() in captain.get_all_contents() + TEST_ASSERT_NOTNULL(key, "The captain doesn't carry the ship key") + TEST_ASSERT(!human_npc_gear_locked(key) && !human_npc_gear_consumable(key), "The ship key was locked to the captain like his gear") + // In a pocket, where a crew that cuffs or downs him can take it through the strip menu + TEST_ASSERT(captain.get_slot_by_item(key) & ITEM_SLOT_POCKETS, "The captain doesn't keep the ship key in a pocket") + TEST_ASSERT(!HAS_TRAIT(key, TRAIT_NO_STRIP), "The ship key is hidden from the strip menu") + TEST_ASSERT(captain in hull.tracked_crew, "The hull doesn't track its captain") + TEST_ASSERT(hull.crew_ever_spawned, "The hull doesn't know it has a crew") + TEST_ASSERT_EQUAL(pirate_crew_of(hull)?.members[captain], "captain", "The captain isn't his crew's captain") + captain.death() + TEST_ASSERT_EQUAL(key.loc, get_turf(captain), "The ship key didn't drop at the dead captain's feet") + qdel(pirate_crew_of(hull)) + +// ===== OUT OF THE FIGHT (OC-7) ===== + +/// A hull's crew is wiped once every crewman is dead, down or cuffed; crew still being built hold it open. +/datum/unit_test/voidcrew_pirate_crew/human_crew/crew_wipe + +/datum/unit_test/voidcrew_pirate_crew/human_crew/crew_wipe/Run() + var/obj/structure/overmap/ship/npc/pirate/hull = allocate(/obj/structure/overmap/ship/npc/pirate) + var/mob/living/carbon/human/npc/faction_pirate/grey/melee/first = build_npc(/mob/living/carbon/human/npc/faction_pirate/grey/melee, spot(0, 1)) + var/mob/living/carbon/human/npc/faction_pirate/grey/ranged/second = build_npc(/mob/living/carbon/human/npc/faction_pirate/grey/ranged, spot(1, 1)) + hull.on_crewman_built(first) + hull.on_crewman_built(second) + // One more still waiting in the queue + var/datum/human_npc_order/pending = new /datum/human_npc_order(/mob/living/carbon/human/npc/faction_pirate/grey/melee, spot(2, 1)) + hull.crew_orders += pending + + var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs) + TEST_ASSERT(first.equip_to_slot_if_possible(cuffs, ITEM_SLOT_HANDCUFFED), "Test fixture: the crewman could not be cuffed") + TEST_ASSERT(!hull.crew_wipe_handled, "Cuffing one of two crewmen wiped the crew") + second.adjustToxLoss(110) // awake in soft crit; 50 oxygen damage would knock them out + TEST_ASSERT_EQUAL(second.stat, SOFT_CRIT, "Test fixture: the second crewman isn't in soft crit") + TEST_ASSERT(!hull.crew_wipe_handled, "The crew was wiped with another crewman still being built") + qdel(pending) + hull.check_crew_wipe() + TEST_ASSERT(hull.crew_wipe_handled, "A crew all down or cuffed wasn't wiped") + TEST_ASSERT_EQUAL(hull.count_live_crew_aboard(), 0, "Crew down or cuffed still count as aboard and fighting") + qdel(pirate_crew_of(hull)) + +/// A wave is over once every boarder is dead, down or cuffed, and none is still on its way. +/datum/unit_test/voidcrew_pirate_crew/human_crew/wave_out_of_fight + +/datum/unit_test/voidcrew_pirate_crew/human_crew/wave_out_of_fight/Run() + var/obj/structure/overmap/ship/npc/pirate/pirate = allocate(/obj/structure/overmap/ship/npc/pirate) + var/obj/structure/overmap/ship/target = allocate(/obj/structure/overmap/ship) + var/datum/ai_controller/npc_ship/boarding_docking_test/profile/controller = allocate(/datum/ai_controller/npc_ship/boarding_docking_test/profile, pirate) + controller.test_zone = allocate(/datum/overmap_zone, 3) + target.state = "flying" + pirate.state = "flying" + controller.set_target(target) + controller.set_combat_state("boarding") + var/list/wave = list() + controller.blackboard["npc_boarding_wave_boarders"] = wave + var/mob/living/carbon/human/npc/faction_pirate/irs/melee/boarder = build_npc(/mob/living/carbon/human/npc/faction_pirate/irs/melee, spot(1, 1)) + controller.track_wave_boarder(wave, boarder) + TEST_ASSERT(boarder in wave, "The boarder didn't join its wave") + + var/datum/human_npc_order/coming = new /datum/human_npc_order(/mob/living/carbon/human/npc/faction_pirate/irs/melee, spot(2, 1)) + controller.wave_orders += coming + var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs) + TEST_ASSERT(boarder.equip_to_slot_if_possible(cuffs, ITEM_SLOT_HANDCUFFED), "Test fixture: the boarder could not be cuffed") + TEST_ASSERT_EQUAL(controller.get_combat_state(), "boarding", "The wave ended with a boarder still on its way") + qdel(coming) + controller.check_wave_complete() + TEST_ASSERT_EQUAL(controller.get_combat_state(), "boarding_cooldown", "A wave whose last boarder was cuffed didn't end") + controller.clear_target() + +/// Spaced boarders are dropped from their wave but not killed; one adrift where no player can see it is +/// cleaned up by its crew after a while. +/datum/unit_test/voidcrew_pirate_crew/human_crew/spaced + +/datum/unit_test/voidcrew_pirate_crew/human_crew/spaced/Run() + change_turf(spot(4, 4), /turf/open/space) + var/obj/structure/overmap/ship/npc/pirate/pirate = allocate(/obj/structure/overmap/ship/npc/pirate) + var/obj/structure/overmap/ship/target = allocate(/obj/structure/overmap/ship) + var/datum/ai_controller/npc_ship/boarding_docking_test/profile/controller = allocate(/datum/ai_controller/npc_ship/boarding_docking_test/profile, pirate) + controller.test_zone = allocate(/datum/overmap_zone, 3) + target.state = "flying" + pirate.state = "flying" + controller.set_target(target) + controller.set_combat_state("boarding") + var/list/wave = list() + controller.blackboard["npc_boarding_wave_boarders"] = wave + var/mob/living/carbon/human/npc/faction_pirate/grey/melee/boarder = build_npc(/mob/living/carbon/human/npc/faction_pirate/grey/melee, spot(4, 4), /datum/human_npc_outfit_table/pirate/grey/boarding) + TEST_ASSERT(pirate_crew_enlist_raider(boarder, target), "The boarder could not join the raid") + controller.track_wave_boarder(wave, boarder) + TEST_ASSERT(pirate_crew_member_adrift(boarder), "A boarder floating in space isn't adrift") + controller.check_boarders_in_space() + TEST_ASSERT(!(boarder in wave), "A spaced boarder still counts toward its wave") + TEST_ASSERT(boarder.stat != DEAD, "A spaced boarder was killed") + + var/datum/pirate_crew/raid = pirate_crew_of(target, TRUE) + raid.check_adrift() + TEST_ASSERT(!QDELETED(boarder), "A boarder was cleaned up the moment it went adrift") + raid.adrift_since[boarder] = world.time - 3 MINUTES + raid.check_adrift() + TEST_ASSERT(QDELETED(boarder), "A boarder adrift for minutes with nobody to see it wasn't cleaned up") + controller.clear_target() + +/// Silverscale and lustrous pirates don't breathe and shrug off low pressure, but space is cold and only a +/// space suit keeps that out: their boarders come through tg's vacuum (pressure, cold) unhurt, where the same +/// pirate in its shipboard clothes freezes. +/datum/unit_test/voidcrew_pirate_crew/human_crew/vacuum_boarders + +/datum/unit_test/voidcrew_pirate_crew/human_crew/vacuum_boarders/Run() + var/turf/void = change_turf(spot(4, 4), /turf/open/space) + var/turf/void_too = change_turf(spot(4, 3), /turf/open/space) + for(var/faction in list("silverscale", "lustrous")) + var/melee_type = text2path("/mob/living/carbon/human/npc/faction_pirate/[faction]/melee") + var/mob/living/carbon/human/npc/faction_pirate/boarder = build_npc(melee_type, spot(0, 0), boarding_outfit_for(melee_type)) + var/mob/living/carbon/human/npc/faction_pirate/crewman = build_npc(melee_type, spot(1, 0)) + TEST_ASSERT(HAS_TRAIT(boarder, TRAIT_RESISTLOWPRESSURE) && HAS_TRAIT(boarder, TRAIT_NOBREATH) && !HAS_TRAIT(boarder, TRAIT_RESISTCOLD), "Test fixture: a [faction] pirate isn't pressure-proof and breathless but cold-blooded") + TEST_ASSERT(!istype(crewman.wear_suit, /obj/item/clothing/suit/space), "Test fixture: a [faction] crewman aboard wears a space suit") + boarder.forceMove(void) + crewman.forceMove(void_too) + // A minute of what Life() does with the air around them (the test level has no player, so they're dormant) + for(var/tick in 1 to 30) + for(var/mob/living/carbon/human/body as anything in list(boarder, crewman)) + body.dna.species.handle_environment(body, body.loc.return_air(), 2, tick) + body.dna.species.handle_body_temperature(body, 2, tick) + TEST_ASSERT(boarder.bodytemperature >= boarder.dna.species.bodytemp_cold_damage_limit, "A sealed [faction] boarder froze in vacuum ([boarder.bodytemperature] K)") + TEST_ASSERT(!(boarder.getBruteLoss() + boarder.getFireLoss() + boarder.getOxyLoss()), "A sealed [faction] boarder was hurt by a minute in vacuum") + TEST_ASSERT(crewman.bodytemperature < crewman.dna.species.bodytemp_cold_damage_limit, "Test fixture: a [faction] pirate in shipboard clothes didn't feel the cold of space ([crewman.bodytemperature] K)") + qdel(boarder) + qdel(crewman) + +/// The pod cap counts the raid's boarders aboard still fighting, human or not. +/datum/unit_test/voidcrew_pirate_crew/human_crew/pod_cap + +/datum/unit_test/voidcrew_pirate_crew/human_crew/pod_cap/Run() + var/obj/structure/overmap/ship/target = allocate(/obj/structure/overmap/ship) + var/obj/docking_port/mobile/voidcrew/port = allocate(/obj/docking_port/mobile/voidcrew, run_loc_floor_bottom_left) + port.shuttle_areas = list((get_area(spot(1, 1))) = TRUE) + target.shuttle = port + var/mob/living/carbon/human/npc/faction_pirate/irs/melee/boarder = build_npc(/mob/living/carbon/human/npc/faction_pirate/irs/melee, spot(1, 1)) + TEST_ASSERT(pirate_crew_enlist_raider(boarder, target), "The boarder could not join the raid") + var/datum/ai_behavior/npc_ship/fire_boarding_pods/pods = GET_AI_BEHAVIOR(/datum/ai_behavior/npc_ship/fire_boarding_pods) + var/counted = pods.count_hostile_mobs_on_ship(target) + boarder.adjustOxyLoss(110) + var/counted_down = pods.count_hostile_mobs_on_ship(target) + qdel(pirate_crew_of(target, TRUE)) + target.shuttle = null + port.shuttle_areas = list() + qdel(port, force = TRUE) + TEST_ASSERT_EQUAL(counted, 1, "The pod cap didn't count a human boarder aboard") + TEST_ASSERT_EQUAL(counted_down, 0, "The pod cap still counts a boarder in crit") + +// ===== BOARDING PODS ===== + +/// A human boarder is queued, built, put in its pod and sent, and its caller hears about it; a raid called +/// off before it is built never sends it. +/datum/unit_test/voidcrew_pirate_crew/human_crew/pods + +/datum/unit_test/voidcrew_pirate_crew/human_crew/pods/Run() + var/obj/structure/overmap/ship/npc/pirate/pirate = allocate(/obj/structure/overmap/ship/npc/pirate) + var/obj/structure/overmap/ship/target = allocate(/obj/structure/overmap/ship) + var/datum/ai_controller/npc_ship/boarding_docking_test/profile/controller = allocate(/datum/ai_controller/npc_ship/boarding_docking_test/profile, pirate) + controller.test_zone = allocate(/datum/overmap_zone, 3) + target.state = "flying" + pirate.state = "flying" + controller.set_target(target) + var/list/heard = list() + controller.blackboard["npc_boarding_wave_boarders"] = heard + var/sent = create_boarding_pod(spot(2, 2), target, pirate, /mob/living/carbon/human/npc/faction_pirate/lustrous/melee, on_boarder = CALLBACK(controller, TYPE_PROC_REF(/datum/ai_controller/npc_ship, track_wave_boarder), heard)) + TEST_ASSERT(istype(sent, /datum/human_npc_order), "A human boarder wasn't queued") + var/datum/human_npc_order/order = sent + TEST_ASSERT(order in controller.boarding_orders, "The encounter isn't tracking its queued boarder") + var/mob/living/carbon/human/npc/faction_pirate/boarder = order.fulfil() + TEST_ASSERT_NOTNULL(boarder, "The queued boarder wasn't built") + TEST_ASSERT(istype(boarder.loc, /obj/structure/closet/supplypod/boarding), "The boarder isn't in its pod") + TEST_ASSERT(boarder in heard, "The caller didn't hear about its boarder") + TEST_ASSERT(boarder.wear_suit && (boarder.wear_suit.clothing_flags & STOPSPRESSUREDAMAGE), "A boarder came without a sealed suit") + + var/datum/human_npc_order/second = create_boarding_pod(spot(3, 2), target, pirate, /mob/living/carbon/human/npc/faction_pirate/lustrous/melee) + TEST_ASSERT(istype(second), "The second boarder wasn't queued") + controller.cancel_boarding_orders() + TEST_ASSERT(QDELETED(second), "Calling the raid off left a boarder in the spawn queue") + + target.state = "idle" + for(var/obj/effect/pod_landingzone/boarding/landing in spot(2, 2)) + landing.cancel_if_target_docked() + controller.clear_target() + +// ===== GUNS ===== + +/// Each kind of gun is handled its own way; a gunner fires its real gun in volleys, and a hit during a +/// shotgun's aim spoils the shot. +/datum/unit_test/voidcrew_pirate_crew/human_crew/guns + +/datum/unit_test/voidcrew_pirate_crew/human_crew/guns/Run() + var/list/expected = list( + /obj/item/gun/ballistic/automatic/pistol = /datum/pirate_gun_handling/pistol, + /obj/item/gun/ballistic/automatic/mini_uzi = /datum/pirate_gun_handling/smg, + /obj/item/gun/ballistic/shotgun/lethal = /datum/pirate_gun_handling/shotgun, + /obj/item/gun/energy/e_gun/lethal = /datum/pirate_gun_handling/energy, + /obj/item/gun/energy/laser = /datum/pirate_gun_handling/energy, + /obj/item/gun/energy/recharge/ebow/large = /datum/pirate_gun_handling/crossbow, + ) + for(var/gun_type in expected) + var/obj/item/gun/gun = allocate(gun_type, spot(4, 4)) + var/datum/pirate_gun_handling/handling = pirate_gun_handling_for(gun) + TEST_ASSERT_EQUAL(handling.type, expected[gun_type], "[gun_type] is handled as [handling.type]") + TEST_ASSERT(handling.shots >= 1 && handling.volley_gap > 0, "[gun_type] never fires") + var/datum/pirate_gun_handling/shotgun_handling = pirate_gun_handling_for(allocate(/obj/item/gun/ballistic/shotgun/lethal, spot(4, 4))) + TEST_ASSERT_EQUAL(shotgun_handling.close_range, 3, "A shotgunner doesn't walk in close") + + // A pistol volley: two pulls, a short gap between them, then a long one + var/mob/living/carbon/human/npc/faction_pirate/gunner = build_npc(/mob/living/carbon/human/npc/faction_pirate/irs/ranged, spot(0, 0), /datum/outfit/piratecorpse/faction/irs/ranged/pistol) + var/mob/living/carbon/human/consistent/mark = allocate(/mob/living/carbon/human/consistent, spot(4, 0)) + var/obj/item/gun/ballistic/automatic/pistol/pistol = locate() in gunner.held_items + TEST_ASSERT_NOTNULL(pistol, "Test fixture: the gunner holds no pistol") + pistol.can_misfire = FALSE + var/datum/ai_controller/controller = gunner.ai_controller + controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, mark) + var/datum/ai_behavior/pirate_crew_human_shoot/shoot = GET_AI_BEHAVIOR(/datum/ai_behavior/pirate_crew_human_shoot) + var/rounds = pistol.get_ammo() + gunner.next_move = 0 + gunner.next_click = 0 + shoot.perform(1, controller, BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETING_STRATEGY, BB_BASIC_MOB_CURRENT_TARGET_HIDING_LOCATION) + TEST_ASSERT(pistol.get_ammo() < rounds, "The gunner's first pull didn't fire the pistol") + TEST_ASSERT_EQUAL(controller.blackboard["pirate_volley_left"], 1, "A pistol volley isn't two shots") + TEST_ASSERT(controller.blackboard["human_npc_next_shot"] <= world.time + 0.3 SECONDS, "The second shot of a pistol volley waits too long") + rounds = pistol.get_ammo() + shoot.perform(1, controller, BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETING_STRATEGY, BB_BASIC_MOB_CURRENT_TARGET_HIDING_LOCATION) + TEST_ASSERT_EQUAL(pistol.get_ammo(), rounds, "The gunner fired again before the gap between its shots") + + // A shotgun aims a moment first; a hit in that moment spoils it + var/mob/living/carbon/human/npc/faction_pirate/shotgunner = build_npc(/mob/living/carbon/human/npc/faction_pirate/irs/ranged, spot(0, 2), /datum/outfit/piratecorpse/faction/irs/ranged/shotgun) + var/datum/ai_controller/pump_controller = shotgunner.ai_controller + pump_controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, mark) + shotgunner.next_move = 0 + shotgunner.next_click = 0 + shoot.perform(1, pump_controller, BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETING_STRATEGY, BB_BASIC_MOB_CURRENT_TARGET_HIDING_LOCATION) + TEST_ASSERT(pump_controller.blackboard["pirate_windup_until"] > world.time, "A shotgun fired without aiming first") + shotgunner.apply_damage(5, BRUTE, BODY_ZONE_CHEST) + TEST_ASSERT(!pump_controller.blackboard["pirate_windup_until"], "A hit while aiming didn't spoil the shot") + +/// Only a boss puts its gun to the head of someone down beside it; anyone else never aims there at point blank. +/datum/unit_test/voidcrew_pirate_crew/human_crew/executions + +/datum/unit_test/voidcrew_pirate_crew/human_crew/executions/Run() + var/mob/living/carbon/human/npc/faction_pirate/chief = build_npc(/mob/living/carbon/human/npc/faction_pirate/irs/boss, spot(1, 1)) + var/mob/living/carbon/human/npc/faction_pirate/agent = build_npc(/mob/living/carbon/human/npc/faction_pirate/irs/ranged, spot(1, 3), /datum/outfit/piratecorpse/faction/irs/ranged/energy_gun) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(2, 2)) + victim.adjustToxLoss(110) // awake in soft crit; 50 oxygen damage would knock them out + TEST_ASSERT_EQUAL(victim.stat, SOFT_CRIT, "Test fixture: the victim isn't in soft crit") + TEST_ASSERT_EQUAL(chief.npc_rank, 2, "The Chief Auditor isn't a boss") + TEST_ASSERT(pirate_crew_human_wants_execution(chief.ai_controller, chief, victim), "A boss gunner doesn't go for a downed hunter's head") + TEST_ASSERT(!pirate_crew_human_wants_execution(agent.ai_controller, agent, victim), "An ordinary gunner tries to execute") + for(var/i in 1 to 30) + TEST_ASSERT(pirate_crew_human_aim_zone(agent, victim) != BODY_ZONE_HEAD, "An ordinary gunner aimed at the head of someone helpless beside it") + +// ===== CAPTAINS AND BOSSES ===== + +/// Captains and bosses carry a stimulant and inject it once they have someone to fight; Davy Jones drinks +/// from his flask when hurt. +/datum/unit_test/voidcrew_pirate_crew/human_crew/self_care + +/datum/unit_test/voidcrew_pirate_crew/human_crew/self_care/Run() + var/mob/living/carbon/human/npc/faction_pirate/noble = build_npc(/mob/living/carbon/human/npc/faction_pirate/silverscale/captain, spot(1, 1)) + var/mob/living/carbon/human/consistent/foe = allocate(/mob/living/carbon/human/consistent, spot(4, 4)) + TEST_ASSERT_NOTNULL(pirate_crew_human_stimulant(noble), "A captain carries no stimulant") + var/datum/ai_controller/controller = noble.ai_controller + var/datum/ai_planning_subtree/pirate_crew_human_self_care/care = new + TEST_ASSERT_NULL(care.SelectBehaviors(controller, 1), "A captain with nobody to fight injected its stimulant") + controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, foe) + TEST_ASSERT_EQUAL(care.SelectBehaviors(controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "A captain in a fight didn't reach for its stimulant") + var/datum/ai_behavior/pirate_crew_human_use_on_self/use = GET_AI_BEHAVIOR(/datum/ai_behavior/pirate_crew_human_use_on_self) + var/finished = FALSE + for(var/step in 1 to 6) + noble.next_move = 0 + noble.next_click = 0 + var/result = use.perform(1, controller, "pirate_self_item") + TEST_ASSERT(!(result & AI_BEHAVIOR_FAILED), "Using the stimulant failed at step [step]") + if(result & AI_BEHAVIOR_SUCCEEDED) + finished = TRUE + break + TEST_ASSERT(finished, "The captain never used its stimulant") + TEST_ASSERT(noble.reagents.has_reagent(/datum/reagent/medicine/stimulants), "The stimulant isn't in the captain's blood") + TEST_ASSERT(human_npc_held_melee_weapon(noble), "The captain didn't take up its sabre again") + + var/mob/living/carbon/human/npc/faction_pirate/davy = build_npc(/mob/living/carbon/human/npc/faction_pirate/skeleton/boss, spot(1, 3)) + var/obj/item/reagent_containers/cup/glass/flask/flask = pirate_crew_human_flask(davy) + TEST_ASSERT_NOTNULL(flask, "Davy Jones has no flask") + TEST_ASSERT(flask.reagents.has_reagent(/datum/reagent/medicine/omnizine/cursed_grog), "Davy Jones's flask has no grog in it") + TEST_ASSERT(human_npc_gear_locked(flask), "Davy Jones's flask isn't locked to him") + var/full = flask.reagents.total_volume + // Already stimmed, and hurt: he drinks + davy.reagents.add_reagent(/datum/reagent/medicine/stimulants, 5) + davy.adjustBruteLoss(80) + var/datum/ai_controller/davy_controller = davy.ai_controller + davy_controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, foe) + TEST_ASSERT_EQUAL(care.SelectBehaviors(davy_controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "A hurt Davy Jones doesn't reach for his flask") + TEST_ASSERT_EQUAL(davy_controller.blackboard["pirate_self_item"], flask, "Davy Jones reached for something other than his flask") + for(var/step in 1 to 6) + davy.next_move = 0 + davy.next_click = 0 + if(use.perform(1, davy_controller, "pirate_self_item") & AI_BEHAVIOR_SUCCEEDED) + break + TEST_ASSERT(flask.reagents.total_volume < full, "Davy Jones didn't drink from his flask") + +/// The bosses' real kit: rank and toughness, the Black Knight's hulk and size and his refusal of guns, the +/// finishers of the Black Knight and the Robust One, and a stimulant for the rest. +/datum/unit_test/voidcrew_pirate_crew/human_crew/bosses + +/datum/unit_test/voidcrew_pirate_crew/human_crew/bosses/Run() + for(var/faction in list("silverscale", "skeleton", "grey", "lustrous", "interdyne", "irs", "medieval")) + var/boss_type = text2path("/mob/living/carbon/human/npc/faction_pirate/[faction]/boss") + var/mob/living/carbon/human/npc/faction_pirate/boss = build_npc(boss_type, spot(2, 2)) + TEST_ASSERT_NOTNULL(boss, "[boss_type] wasn't built") + TEST_ASSERT_EQUAL(boss.npc_rank, 2, "[boss_type] isn't a boss") + TEST_ASSERT(boss.npc_damage_taken < 0.8, "[boss_type] is no tougher than a captain") + TEST_ASSERT(human_npc_held_melee_weapon(boss) || human_npc_held_gun(boss), "[boss_type] holds no weapon") + TEST_ASSERT(boss.maxHealth == 100, "[boss_type] was given a health pool") + TEST_ASSERT(!HAS_TRAIT_FROM(boss, TRAIT_STUNIMMUNE, INNATE_TRAIT), "[boss_type] is innately stun immune") + TEST_ASSERT(boss.npc_death_cash >= 3000, "[boss_type] lost its plunder") + if(faction == "medieval") + TEST_ASSERT(boss.dna.check_mutation(/datum/mutation/hulk), "The Black Knight isn't a hulk") + TEST_ASSERT(boss.dna.check_mutation(/datum/mutation/gigantism), "The Black Knight isn't huge") + TEST_ASSERT(HAS_TRAIT(boss, TRAIT_NOGUNS), "The Black Knight will use guns") + else + TEST_ASSERT_NOTNULL(pirate_crew_human_stimulant(boss), "[boss_type] carries no stimulant") + if(faction == "medieval" || faction == "grey") + TEST_ASSERT_NOTNULL(boss.GetComponent(/datum/component/hv_finisher_user), "[boss_type] has no finisher") + qdel(boss) + +/// HV-4 and HV-5: a human boss's finisher pins with a real aggressive grab and strikes with the real weapon +/// in its hand; it isn't rooted, takes no extra damage, and doesn't reel when made to let go. +/datum/unit_test/voidcrew_pirate_crew/human_crew/finisher + +/datum/unit_test/voidcrew_pirate_crew/human_crew/finisher/Run() + var/mob/living/carbon/human/npc/faction_pirate/robust = build_npc(/mob/living/carbon/human/npc/faction_pirate/grey/boss, spot(1, 1)) + var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent, spot(2, 1)) + victim.adjustToxLoss(110) // awake in soft crit; 50 oxygen damage would knock them out + TEST_ASSERT_EQUAL(victim.stat, SOFT_CRIT, "Test fixture: the victim isn't down") + // The toolbox blow below can roll a caved-in skull (/datum/hv_crit/skull), which kills them and ends the + // finisher before the boss is hurt. What that roll gives depends on the tests run before this one. + ADD_TRAIT(victim, TRAIT_HEAD_INJURY_BLOCKED, TRAIT_SOURCE_UNIT_TESTS) + var/datum/hv_finisher/robust_one/finisher = new(robust, victim) + TEST_ASSERT(finisher.real_hits, "A human boss's finisher isn't done with real hits") + TEST_ASSERT(finisher.start(), "The Robust One's finisher wouldn't start on someone down beside it") + var/datum/status_effect/hv_finishing/busy = robust.has_status_effect(/datum/status_effect/hv_finishing) + TEST_ASSERT_NOTNULL(busy, "The Robust One isn't busy with its finisher") + TEST_ASSERT_EQUAL(busy.vulnerability, 1, "A human boss takes extra damage while it finishes someone") + TEST_ASSERT(!HAS_TRAIT(robust, TRAIT_IMMOBILIZED), "A human boss is rooted while it finishes someone") + + TEST_ASSERT(finisher.take_grip(), "The Robust One couldn't get hold of the victim") + TEST_ASSERT_EQUAL(robust.pulling, victim, "The pin isn't a real grab") + TEST_ASSERT(robust.grab_state >= GRAB_AGGRESSIVE, "The pin isn't an aggressive grab") + // Only tg's own grab holds them: an aggressive grab (CHOKEHOLD_TRAIT) and being pulled in soft crit + // (PULLED_WHILE_SOFTCRIT_TRAIT). The finisher adds no hold of its own. + var/list/other_holds = GET_TRAIT_SOURCES(victim, TRAIT_IMMOBILIZED) - list(CHOKEHOLD_TRAIT, PULLED_WHILE_SOFTCRIT_TRAIT) + TEST_ASSERT(!length(other_holds), "The victim is held by something besides the grab ([english_list(other_holds)])") + + var/obj/item/bodypart/head/head = victim.get_bodypart(BODY_ZONE_HEAD) + var/head_before = head.get_damage() + TEST_ASSERT(finisher.real_blow(BODY_ZONE_HEAD), "The Robust One didn't swing its toolbox") + TEST_ASSERT(head.get_damage() > head_before, "The toolbox blow didn't hurt the victim's head") + + // A heavy hit makes it let go: the grab breaks, and it doesn't reel + robust.apply_damage(100, BRUTE, BODY_ZONE_CHEST) + TEST_ASSERT(!finisher.running, "A heavy hit didn't make the Robust One let go") + TEST_ASSERT_EQUAL(finisher.result, 3, "The finisher didn't end because the boss was hurt") + TEST_ASSERT(robust.pulling != victim, "The Robust One kept hold of the victim after letting go") + TEST_ASSERT(!robust.has_status_effect(/datum/status_effect/hv_finisher_reeling), "A human boss reeled after letting go") + qdel(finisher) + +/// AM-15: suppression sweeps count the human pirate crews. +/datum/unit_test/voidcrew_pirate_crew/human_crew/suppression_counts + +/datum/unit_test/voidcrew_pirate_crew/human_crew/suppression_counts/Run() + var/datum/mission_objective/kill_count/counter = allocate(/datum/mission_objective/kill_count) + var/mob/living/carbon/human/npc/crewman = human_npc_build_in_zone(/mob/living/carbon/human/npc/faction_pirate/grey/melee, 2) + TEST_ASSERT_NOTNULL(crewman, "Test fixture: the grey tider wasn't built") + TEST_ASSERT(counter.counts_victim(crewman), "A suppression sweep doesn't count the human pirate crews") + var/mob/living/basic/trooper/pirate/faction/basic_pirate = allocate(/mob/living/basic/trooper/pirate/faction/grey/melee) + TEST_ASSERT(counter.counts_victim(basic_pirate), "A suppression sweep stopped counting the basic faction pirates") + +// ===== WITH NO CREW ===== + +/** + * A pirate with no crew (a ruin's, a contract's) gives up by its family's rules and walks home when it has + * strayed with nothing to fight; one in a crew does neither. Blackboard keys by their strings. + */ +/datum/unit_test/voidcrew_pirate_crew/human_crew/crewless + +/datum/unit_test/voidcrew_pirate_crew/human_crew/crewless/Run() + var/mob/living/carbon/human/npc/faction_pirate/grey/melee/tider = build_npc(/mob/living/carbon/human/npc/faction_pirate/grey/melee, spot(0, 0)) + var/mob/living/carbon/human/npc/faction_pirate/skeleton/melee/skeleton = build_npc(/mob/living/carbon/human/npc/faction_pirate/skeleton/melee, spot(1, 0)) + var/mob/living/carbon/human/npc/faction_pirate/grey/boss/robust = build_npc(/mob/living/carbon/human/npc/faction_pirate/grey/boss, spot(2, 0)) + TEST_ASSERT(istype(tider.npc_surrender_rules(), /datum/human_npc_surrender/faction_pirate/meek), "A grey tider doesn't give up like a tider") + TEST_ASSERT_NULL(skeleton.npc_surrender_rules(), "A skeleton pirate can give up") + tider.apply_damage(70, BRUTE, BODY_ZONE_CHEST) + robust.apply_damage(70, BRUTE, BODY_ZONE_CHEST) + TEST_ASSERT(tider.npc_surrender_rules().hurt_enough(tider), "A badly hurt grey tider doesn't think about giving up") + TEST_ASSERT(!robust.npc_surrender_rules().hurt_enough(robust), "A pirate boss thinks about giving up") + TEST_ASSERT_EQUAL(tider.ai_controller.blackboard["pirate_crewless_home"], spot(0, 0), "A crewless pirate doesn't know where it was put") + + // Strayed with nobody to fight: it walks home. + var/turf/far_home = locate(tider.x + 12, tider.y, tider.z) + tider.ai_controller.set_blackboard_key("pirate_crewless_home", far_home) + var/datum/ai_planning_subtree/pirate_crewless_home/home_leash = GLOB.ai_subtrees[/datum/ai_planning_subtree/pirate_crewless_home] + TEST_ASSERT_EQUAL(home_leash.SelectBehaviors(tider.ai_controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "A crewless pirate twelve tiles from home doesn't walk back") + TEST_ASSERT_EQUAL(tider.ai_controller.blackboard["pirate_return_turf"], far_home, "A crewless pirate walks somewhere other than home") + tider.ai_controller.CancelActions() + tider.ai_controller.clear_blackboard_key("pirate_return_turf") + + // In a crew it does neither: its crew decides. + var/obj/structure/overmap/ship/npc/pirate/hull = allocate(/obj/structure/overmap/ship/npc/pirate) + hull.on_crewman_built(tider) + TEST_ASSERT_NULL(home_leash.SelectBehaviors(tider.ai_controller, 1), "A pirate in a crew walks to its own spawn point") + var/datum/ai_planning_subtree/human_npc_surrender/crewless/give_up = GLOB.ai_subtrees[/datum/ai_planning_subtree/human_npc_surrender/crewless] + tider.npc_next_surrender_roll = 0 + TEST_ASSERT_NULL(give_up.SelectBehaviors(tider.ai_controller, 1), "A pirate in a crew rolls to give up on its own") + qdel(pirate_crew_of(hull)) diff --git a/voidcrew/modules/unit_tests/voidcrew_planetary_factions.dm b/voidcrew/modules/unit_tests/voidcrew_planetary_factions.dm index a0a240408a5..e44eb64220b 100644 --- a/voidcrew/modules/unit_tests/voidcrew_planetary_factions.dm +++ b/voidcrew/modules/unit_tests/voidcrew_planetary_factions.dm @@ -288,9 +288,10 @@ distant_planet.enable_planetary_faction() // This represents a mob already initialized from a preloaded ruin before the planet's - // footprint was enabled. The mapped override replaces its normal type factions. - var/mob/living/simple_animal/hostile/asteroid/hermit/survivor/mapped_hermit = allocate( - /mob/living/simple_animal/hostile/asteroid/hermit/survivor, + // footprint was enabled. The mapped override replaces its normal type factions. Hermits are + // human NPCs (voidcrew/modules/human_npcs/ruins/), natives of their planet like the fauna. + var/mob/living/carbon/human/npc/ruin/hermit/mapped_hermit = allocate( + /mob/living/carbon/human/npc/ruin/hermit, run_loc_floor_bottom_left, ) mapped_hermit.faction = list("saloon", "[REF(mapped_hermit)]") diff --git a/voidcrew/modules/unit_tests/voidcrew_simple_mob_ai.dm b/voidcrew/modules/unit_tests/voidcrew_simple_mob_ai.dm index 52d776aa83c..a017e0fc6a9 100644 --- a/voidcrew/modules/unit_tests/voidcrew_simple_mob_ai.dm +++ b/voidcrew/modules/unit_tests/voidcrew_simple_mob_ai.dm @@ -5,13 +5,13 @@ * itself out of that list on its first tick. Upstream deleted the subsystem that walked * the idle list (tg #82469), which silently made AI_IDLE permanent - every mapped hermit * in the wasteland ruins loaded, idled, and then ignored players for the rest of the - * round. SSidlenpcpool + consider_wakeup() (voidcrew/controllers/subsystem/idle_npc_wakeup.dm) + * round. (Hermits are human NPCs now; the polar bear stands in as a mapped hostile.) SSidlenpcpool + consider_wakeup() (voidcrew/controllers/subsystem/idle_npc_wakeup.dm) * restore the wakeup; this guards it against being dropped in an upstream merge. */ /datum/unit_test/voidcrew_simple_mob_wakeup /datum/unit_test/voidcrew_simple_mob_wakeup/Run() - var/mob/living/simple_animal/hostile/asteroid/hermit/survivor/hermit = allocate(/mob/living/simple_animal/hostile/asteroid/hermit/survivor) + var/mob/living/simple_animal/hostile/asteroid/polarbear/hermit = allocate(/mob/living/simple_animal/hostile/asteroid/polarbear) var/turf/hermit_turf = get_turf(hermit) TEST_ASSERT(hermit_turf, "the test hermit was allocated without a turf") @@ -24,7 +24,7 @@ TEST_ASSERT_EQUAL(hermit.AIStatus, AI_IDLE, "an idle hostile woke up with nobody on its z-level") // Now put someone it wants to kill in front of it. Both mobs are allocated onto - // run_loc_floor_bottom_left, so this is well inside the hermit's vision_range of 2. + // run_loc_floor_bottom_left, so this is well inside the bear's vision_range of 2. var/mob/living/carbon/human/consistent/victim = allocate(/mob/living/carbon/human/consistent) SSmobs.clients_by_zlevel[hermit_turf.z] += victim hermit.consider_wakeup() diff --git a/voidcrew/objects/structures/spawner.dm b/voidcrew/objects/structures/spawner.dm index 603eb2311f4..52519a306d4 100644 --- a/voidcrew/objects/structures/spawner.dm +++ b/voidcrew/objects/structures/spawner.dm @@ -68,7 +68,10 @@ to_chat(user, "You start searching the [name] for anything useful...") if(do_after(user, 40, target = src)) if(prob(bite_chance)) - user.adjustBruteLoss(15) + // The hand that reached in takes the bite, through whatever glove covers it. + var/obj/item/clothing/gloves/worn_gloves = user.gloves + var/blocked = istype(worn_gloves) ? min(worn_gloves.get_armor_rating(MELEE), 100) : 0 + user.apply_damage(15, BRUTE, user.get_active_hand(), blocked, sharpness = SHARP_POINTY) playsound(user.loc, 'sound/items/weapons/bite.ogg', 50, TRUE, -1) to_chat(user, "OW! Something bit you!") else @@ -94,7 +97,7 @@ desc = "A musty, mold-covered barrel." icon = 'icons/obj/structures.dmi' icon_state = "barrel" - mob_types = list(/mob/living/basic/trooper/pirate/melee/beach, /mob/living/basic/trooper/pirate/ranged/beach) + mob_types = list(/mob/living/carbon/human/npc/ruin/trooper/pirate/beach, /mob/living/carbon/human/npc/ruin/trooper/pirate/beach/gunner) max_mobs = 2 max_integrity = 250 bite_chance = 0 From 79a97d2cb365459bc966c65cadfc87fddcfd9e4b Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:26:15 -0800 Subject: [PATCH 03/13] Bounty criminals, companions, the kingpin's crew and the mafia club are people Bounty targets are now human NPCs (/mob/living/carbon/human/npc): real human bodies with tg's own crit, wounds, cuffs, medicine and death. - Criminals of every tier, their companions, the mini-bosses, the kingpin with his goons, and Club Volga's staff and patrons. Fugitives blending in at trader outposts and the look-alike decoys around them are people too. - They are caught with tg's own crit, surrender and handcuffs; the bounty cuffs and the fake downed state are gone. - Criminals and companions dress from outfit tables and fight by style with real weapons. - The escaped convict on planets is a bounty criminal body. - The basic-mob bounty criminal, companion, boss and kingpin types are removed. - The bounty files are as they stood before the guard kit and chrome work; later pull requests finish them. --- .../SpaceRuins/bounty_lair_mafia_club.dmm | 4 +- tgstation.dme | 3 + voidcrew/_DEFINES/bounties.dm | 10 +- voidcrew/_DEFINES/bounty_ai.dm | 130 +- voidcrew/_DEFINES/bounty_bosses.dm | 172 +- voidcrew/_DEFINES/bounty_criminals.dm | 151 +- voidcrew/_DEFINES/bounty_kingpin.dm | 64 +- voidcrew/_DEFINES/bounty_lairs.dm | 77 +- voidcrew/_DEFINES/bounty_outpost.dm | 8 +- voidcrew/_HELPERS/hostile_creatures.dm | 7 +- voidcrew/modules/ambient_npcs/convict.dm | 605 +++++-- .../modules/bounties/bounty_activities.dm | 218 ++- voidcrew/modules/bounties/bounty_admin.dm | 149 +- voidcrew/modules/bounties/bounty_ai.dm | 588 +++--- voidcrew/modules/bounties/bounty_ai_human.dm | 210 +++ voidcrew/modules/bounties/bounty_ai_meek.dm | 495 +++--- voidcrew/modules/bounties/bounty_ai_normal.dm | 710 +------- voidcrew/modules/bounties/bounty_board.dm | 2 +- voidcrew/modules/bounties/bounty_boss.dm | 928 +++++----- voidcrew/modules/bounties/bounty_boss_kits.dm | 752 ++++---- .../modules/bounties/bounty_companions.dm | 394 ++-- voidcrew/modules/bounties/bounty_criminal.dm | 1047 +++-------- voidcrew/modules/bounties/bounty_identity.dm | 8 +- voidcrew/modules/bounties/bounty_kingpin.dm | 1386 +++++++++------ voidcrew/modules/bounties/bounty_lair.dm | 152 +- .../modules/bounties/bounty_lair_mafia.dm | 1579 +++++++++-------- .../modules/bounties/bounty_lair_types.dm | 24 +- voidcrew/modules/bounties/bounty_outfits.dm | 124 ++ voidcrew/modules/bounties/bounty_outpost.dm | 713 ++++---- voidcrew/modules/bounties/bounty_placement.dm | 43 +- voidcrew/modules/bounties/bounty_posting.dm | 39 +- .../modules/bounties/bounty_restraints.dm | 347 ++-- voidcrew/modules/bounties/bounty_styles.dm | 656 +++++++ voidcrew/modules/bounties/bounty_turn_in.dm | 81 +- voidcrew/modules/bounties/bounty_types.dm | 51 +- .../bounties/strings/bounty_lair_mafia.json | 15 + voidcrew/modules/missions/mission_pad.dm | 2 +- voidcrew/modules/npc_scaling/zone_profiles.dm | 4 +- .../unit_tests/voidcrew_ambient_strays.dm | 84 +- .../unit_tests/voidcrew_bounty_admin.dm | 148 +- .../modules/unit_tests/voidcrew_bounty_ai.dm | 600 ++++--- .../unit_tests/voidcrew_bounty_board.dm | 153 +- .../unit_tests/voidcrew_bounty_bosses.dm | 737 +++++--- .../unit_tests/voidcrew_bounty_criminal.dm | 997 ++++------- .../unit_tests/voidcrew_bounty_identity.dm | 8 +- .../unit_tests/voidcrew_bounty_kingpin.dm | 704 +++++--- .../unit_tests/voidcrew_bounty_lair_mafia.dm | 383 ++-- .../unit_tests/voidcrew_bounty_lair_maps.dm | 13 +- .../unit_tests/voidcrew_bounty_lairs.dm | 118 +- .../unit_tests/voidcrew_bounty_outpost.dm | 680 +++++-- .../unit_tests/voidcrew_bounty_seams.dm | 2 +- .../unit_tests/voidcrew_npc_zone_profiles.dm | 111 +- .../unit_tests/voidcrew_outpost_npc_looks.dm | 1 - .../voidcrew_outpost_prison_bounty.dm | 6 +- .../unit_tests/voidcrew_zone_identity.dm | 18 +- wiki/content/bounty-hunting.md | 101 +- 56 files changed, 9154 insertions(+), 7658 deletions(-) create mode 100644 voidcrew/modules/bounties/bounty_ai_human.dm create mode 100644 voidcrew/modules/bounties/bounty_outfits.dm create mode 100644 voidcrew/modules/bounties/bounty_styles.dm diff --git a/_maps/voidcrew/RandomRuins/SpaceRuins/bounty_lair_mafia_club.dmm b/_maps/voidcrew/RandomRuins/SpaceRuins/bounty_lair_mafia_club.dmm index ffeabbd76bb..67b2d679367 100644 --- a/_maps/voidcrew/RandomRuins/SpaceRuins/bounty_lair_mafia_club.dmm +++ b/_maps/voidcrew/RandomRuins/SpaceRuins/bounty_lair_mafia_club.dmm @@ -1749,7 +1749,7 @@ /area/ruin/space/has_grav/powered/mafia_club/back_office) "FW" = ( /obj/effect/landmark/bounty_lair_gatekeeper{ - gatekeeper_type = /mob/living/basic/trooper/russian/mafia/lieutenant + gatekeeper_type = /mob/living/carbon/human/npc/bounty_mafia/lieutenant }, /turf/open/floor/carpet/red, /area/ruin/space/has_grav/powered/mafia_club/back_office) @@ -2653,7 +2653,7 @@ /area/ruin/space/has_grav/powered/mafia_club/staff) "ZX" = ( /obj/effect/landmark/bounty_lair_gatekeeper{ - gatekeeper_type = /mob/living/basic/trooper/russian/mafia/lieutenant + gatekeeper_type = /mob/living/carbon/human/npc/bounty_mafia/lieutenant }, /turf/open/floor/iron/dark/textured, /area/ruin/space/has_grav/powered/mafia_club/back_office) diff --git a/tgstation.dme b/tgstation.dme index c15906369fe..2555f50033e 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7097,6 +7097,7 @@ #include "voidcrew\modules\bounties\bounty_activities.dm" #include "voidcrew\modules\bounties\bounty_admin.dm" #include "voidcrew\modules\bounties\bounty_ai.dm" +#include "voidcrew\modules\bounties\bounty_ai_human.dm" #include "voidcrew\modules\bounties\bounty_ai_meek.dm" #include "voidcrew\modules\bounties\bounty_ai_normal.dm" #include "voidcrew\modules\bounties\bounty_board.dm" @@ -7111,10 +7112,12 @@ #include "voidcrew\modules\bounties\bounty_lair_maps.dm" #include "voidcrew\modules\bounties\bounty_lair_types.dm" #include "voidcrew\modules\bounties\bounty_looks.dm" +#include "voidcrew\modules\bounties\bounty_outfits.dm" #include "voidcrew\modules\bounties\bounty_outpost.dm" #include "voidcrew\modules\bounties\bounty_placement.dm" #include "voidcrew\modules\bounties\bounty_posting.dm" #include "voidcrew\modules\bounties\bounty_restraints.dm" +#include "voidcrew\modules\bounties\bounty_styles.dm" #include "voidcrew\modules\bounties\bounty_turn_in.dm" #include "voidcrew\modules\bounties\bounty_types.dm" #include "voidcrew\modules\bounties\bounty_weapons.dm" diff --git a/voidcrew/_DEFINES/bounties.dm b/voidcrew/_DEFINES/bounties.dm index e4413b2c683..d6c49b1626f 100644 --- a/voidcrew/_DEFINES/bounties.dm +++ b/voidcrew/_DEFINES/bounties.dm @@ -70,10 +70,10 @@ // What capture_state() (P2) returns, listed in the order it checks them. The pad pays by these (P5). #define BOUNTY_STATE_DEAD "dead" -/// At or below the downed line, cuffed or not +/// In crit (tg's TRAIT_CRITICAL_CONDITION, soft or hard), cuffed or not #define BOUNTY_STATE_DOWNED "downed" #define BOUNTY_STATE_RESTRAINED "restrained" -/// Stamina crit, knocked down, paralysed, or surrendered (TRAIT_BOUNTY_SURRENDERED) +/// Stamina crit, knocked down, stunned, paralysed (tg's *surrender too), unconscious or asleep #define BOUNTY_STATE_STUNNED "stunned" /// Standing and free: the pad refuses it #define BOUNTY_STATE_FREE "free" @@ -117,14 +117,12 @@ /// Trait source for everything the bounty packages put on a mob #define BOUNTY_TRAIT "bounty" -/// A normal criminal has given up (P3): it can't attack, and capture_state() (P2) reads it as BOUNTY_STATE_STUNNED -#define TRAIT_BOUNTY_SURRENDERED "bounty_surrendered" // ===== SIGNALS ===== -/// Sent by P2 on a criminal when its health falls to the downed line: () +/// Sent by P2 on a criminal when it goes into tg's crit (soft or hard): () #define COMSIG_BOUNTY_CRIMINAL_DOWNED "bounty_criminal_downed" -/// Sent by P2 on a criminal when it gets back up after the recovery time: () +/// Sent by P2 on a criminal when it comes out of crit, or gets up from stamina crit: () #define COMSIG_BOUNTY_CRIMINAL_RECOVERED "bounty_criminal_recovered" /// Sent by P2 on a criminal when restraints go on: (mob/user) #define COMSIG_BOUNTY_CRIMINAL_RESTRAINED "bounty_criminal_restrained" diff --git a/voidcrew/_DEFINES/bounty_ai.dm b/voidcrew/_DEFINES/bounty_ai.dm index 9aa30f159d7..42fcfcbb112 100644 --- a/voidcrew/_DEFINES/bounty_ai.dm +++ b/voidcrew/_DEFINES/bounty_ai.dm @@ -1,24 +1,9 @@ // # Bounty hunting: criminal AI defines // // Owner: P3 AI (voidcrew/modules/bounties/bounty_ai.dm, bounty_ai_meek.dm, bounty_ai_normal.dm, -// bounty_activities.dm, bounty_companions.dm). Only P3 edits this file. The shared enums are in -// bounties.dm. The numbers come from balance/combat.md section 6 and spec section 12.3 (C4, C6, -// C7); the rest are the spec's section 3 values. - -// ===== TRAITS ===== - -// P2 declares these two in bounty_criminals.dm with the same values. The guarded copies here let this -// package build on its own; once both are merged, these can go. -#ifndef TRAIT_BOUNTY_SPRINTING -/// A meek criminal running flat out, not winded, cornered or aiming. P2's projectile dodge reads it. -#define TRAIT_BOUNTY_SPRINTING "bounty_sprinting" -#endif -#ifndef TRAIT_BOUNTY_HELD -/// Restrained or downed (P2): the AI plans nothing -#define TRAIT_BOUNTY_HELD "bounty_held" -#endif -/// Trait source for what the criminal AI puts on a mob (TRAIT_BOUNTY_SPRINTING) -#define BOUNTY_AI_TRAIT "bounty_ai" +// bounty_styles.dm, bounty_activities.dm, bounty_companions.dm). Only P3 edits this file. The shared +// enums are in bounties.dm. Criminals and companions are real human bodies (voidcrew/modules/human_npcs/): +// nothing here sets health, stamina or speed. A pace is only a walk or a run (ai_set_pace()). // ===== WHAT THEY ARE DOING ===== @@ -37,7 +22,7 @@ /// In a locker or a crate #define BOUNTY_HIDE_CONTAINER "container" -/// Passing as a potted plant +/// Holding up a potted plant (tg's own disguise: the plant's tactical component) #define BOUNTY_HIDE_PLANT "plant" /// Standing still on a dark tile #define BOUNTY_HIDE_DARK "dark" @@ -52,16 +37,18 @@ #define BB_BOUNTY_LEADER "bb_bounty_leader" /// Their fighting style's key (BOUNTY_STYLE_*) #define BB_BOUNTY_STYLE "bb_bounty_style" -/// The real item they fight with (a typepath: bounty_real_weapon()), or null for bare fists -#define BB_BOUNTY_WEAPON "bb_bounty_weapon" -/// Rounds left in the magazine -#define BB_BOUNTY_AMMO "bb_bounty_ammo" -/// world.time a reload ends -#define BB_BOUNTY_RELOAD_UNTIL "bb_bounty_reload_until" /// world.time the current wind-up ends #define BB_BOUNTY_WINDUP_UNTIL "bb_bounty_windup_until" -/// world.time of the last shot +/// world.time the current wind-up began +#define BB_BOUNTY_WINDUP_FROM "bb_bounty_windup_from" +/// Their stamina loss when the wind-up began: more by the end of it and they fumble +#define BB_BOUNTY_WINDUP_STAMINA "bb_bounty_windup_stamina" +/// world.time they last took a hit +#define BB_BOUNTY_HIT_AT "bb_bounty_hit_at" +/// world.time of the last shot or throw #define BB_BOUNTY_LAST_SHOT "bb_bounty_last_shot" +/// world.time they may next pull the trigger or throw +#define BB_BOUNTY_NEXT_SHOT "bb_bounty_next_shot" /// world.time a ranged fighter may next step back from someone too close #define BB_BOUNTY_BACKSTEP_AT "bb_bounty_backstep_at" @@ -76,8 +63,11 @@ // ===== SHARED ===== -/// Speed while going about their business, and while blended in (the fugitive and every decoy move alike) +/// The pace while going about their business, and while blended in (the fugitive and every decoy walk +/// alike). Anything quicker than this is a run (ai_set_pace()). #define BOUNTY_CALM_SPEED 2.5 +/// The pace of anyone running: running, as a person runs. There is no faster sprint. +#define BOUNTY_RUN_SPEED 1.5 /// How often they look around for hunters #define BOUNTY_NOTICE_INTERVAL (0.5 SECONDS) /// Held items at least this strong count as a weapon drawn @@ -96,29 +86,23 @@ #define BOUNTY_ACTIVITY_RANGE 8 /// How far exploring looks for things to look at #define BOUNTY_EXPLORE_RANGE 10 -/// Glasses a criminal leaves on tables at the bar before a finished glass just goes +/// Glasses a criminal leaves about at the bar (on a table or the floor) before a finished glass just goes #define BOUNTY_BAR_GLASSES_MAX 2 +/// Drunk this much (tg's drunkenness), they nurse their drink instead of drinking it +#define BOUNTY_BAR_SOBER_LIMIT 30 /// Spots an activity remembers as out of reach #define BOUNTY_FAILED_SPOTS_MAX 8 /// How long a trader outpost's public floor is reused between its patrons before it is worked out again #define BOUNTY_OUTPOST_FLOOR_CACHE (1 MINUTES) +/// A wind-up left this long past its end is stale: the next shot telegraphs again +#define BOUNTY_WINDUP_STALE (1 SECONDS) +/// After a fumble, this long before they try again +#define BOUNTY_FUMBLE_PAUSE (1 SECONDS) // ===== MEEK (combat.md 6.1, spec C6) ===== -/// Speed while sprinting: the tg trooper's, faster than a running person (1.5) -#define BOUNTY_MEEK_SPRINT_SPEED 1.1 -/// A lizard sprints a little faster (spec section 2) -#define BOUNTY_MEEK_LIZARD_SPRINT_BONUS 0.1 -/// Speed while winded: clearly slower than a runner -#define BOUNTY_MEEK_WINDED_SPEED 2.2 -/// How long they sprint before they are winded -#define BOUNTY_MEEK_SPRINT_TIME (8 SECONDS) -/// Resting still, the sprint comes back in this long -#define BOUNTY_MEEK_REST_TIME (8 SECONDS) -/// Sprint back per second spent hidden (full in about 5 s) -#define BOUNTY_MEEK_RECOVER_HIDDEN 1.5 -/// Sprint back per second spent unseen but not hidden -#define BOUNTY_MEEK_RECOVER_WALKING 0.3 +/// Stamina loss at which tg's own slowdown starts (human updatehealth(): 40): they are winded +#define BOUNTY_MEEK_WINDED_STAMINA 40 /// Someone armed, cuffs or a warrant in hand this close is noticed #define BOUNTY_MEEK_NOTICE_RANGE 6 /// Someone running straight at them this close is noticed @@ -149,7 +133,7 @@ #define BOUNTY_MEEK_CORNERED_TIME (0.8 SECONDS) /// The aim before the shots: the telegraph #define BOUNTY_MEEK_PISTOL_WINDUP (0.5 SECONDS) -/// Shots in the holdout's volley, a magazine at most +/// Trigger pulls in the holdout's volley, a magazine at most #define BOUNTY_MEEK_PISTOL_SHOTS 8 /// Between them #define BOUNTY_MEEK_PISTOL_GAP (0.2 SECONDS) @@ -169,9 +153,6 @@ // ===== NORMAL (combat.md 6.2, spec C7) ===== -/// Speed in a fight, by style -#define BOUNTY_NORMAL_SPEED_MELEE 1.25 -#define BOUNTY_NORMAL_SPEED_RANGED 1.4 /// Noticed at this range (someone armed, cuffs or a warrant in hand) #define BOUNTY_NORMAL_NOTICE_RANGE 6 /// Someone with a weapon drawn this close, while they are aware of them, starts the fight @@ -180,22 +161,21 @@ #define BOUNTY_NORMAL_AWARE_FORGET (15 SECONDS) /// Fighting, but nobody on the grudge list seen for this long: the fight is over #define BOUNTY_NORMAL_CALM_AFTER (30 SECONDS) -/// Share of max health at or below which they may give up +/// Surrender (defaults CR-10, /datum/human_npc_surrender/bounty): at or below this share of health, #define BOUNTY_SURRENDER_BELOW 0.4 -/// Percent chance on the hit that crosses the line +/// a percent chance on the first roll of a fight, #define BOUNTY_SURRENDER_CHANCE 60 -/// Less for each companion still standing +/// less this for each companion still standing, #define BOUNTY_SURRENDER_PER_COMPANION 20 -/// Percent chance on later hits +/// then this on later rolls, #define BOUNTY_SURRENDER_RETRY 25 -/// At most this often +/// at most this often, #define BOUNTY_SURRENDER_RETRY_GAP (5 SECONDS) -/// Hunters needed around them +/// with this many hunters around them, #define BOUNTY_SURRENDER_HUNTERS 2 -/// Within this range, in view +/// within this range, in view #define BOUNTY_SURRENDER_HUNTER_RANGE 7 -/// Below this share of health with no hunter near, they break off and retreat. The spec's 25% is the -/// downed line, so a standing criminal is never below it; the surrender line is used instead. +/// Below this share of health with no hunter near, they break off and retreat #define BOUNTY_NORMAL_RETREAT_BELOW 0.4 /// How far they try to get away when retreating #define BOUNTY_NORMAL_RETREAT_DISTANCE 10 @@ -204,58 +184,46 @@ #define BOUNTY_COMPANIONS_MIN 0 #define BOUNTY_COMPANIONS_MAX 2 -/// Health before the style's multiplier -#define BOUNTY_COMPANION_HEALTH 110 /// Below this share of health a companion may run (a BOUNTY_COMPANION_FLEE_CHANCE roll, once) #define BOUNTY_COMPANION_FLEE_BELOW 0.3 #define BOUNTY_COMPANION_FLEE_CHANCE 50 +/// Up from a stamina crit with hunters around: the chance a companion gives up rather than runs +#define BOUNTY_COMPANION_GIVE_UP_CHANCE 50 /// How far a companion keeps from its criminal while nothing is happening #define BOUNTY_COMPANION_FOLLOW 2 /// How often a companion calls the rest of the gang in (the trooper's 30 s) #define BOUNTY_REINFORCE_COOLDOWN (30 SECONDS) -// ===== STYLES (combat.md 6.2) ===== -// Every blow and shot is the real weapon's (bounty_weapons.dm): the item in their hand is each -// style's held_look, and a Wanted criminal carries its heavy_look where it has one. +// ===== STYLES (combat.md 6.2, bounty_styles.dm) ===== +// Every style is a real item the fighter carries and draws: blows and shots are the item's own, through +// the fighter's hands. These only set the timing: how often they pull the trigger or throw, the +// telegraph, and the distance they keep. -#define BOUNTY_BRAWLER_HEALTH 1.2 -#define BOUNTY_BRAWLER_STAMINA 0.8 -#define BOUNTY_BRAWLER_INTERVAL (1 SECONDS) -/// Chance a punch shoves the target back a tile and staggers them for a second +/// Chance a brawler's blow is a real shove instead of a punch #define BOUNTY_BRAWLER_SHOVE_CHANCE 20 -#define BOUNTY_BRAWLER_STAGGER (1 SECONDS) -#define BOUNTY_KNIFE_HEALTH 1 -#define BOUNTY_KNIFE_INTERVAL (0.8 SECONDS) - -#define BOUNTY_PISTOL_HEALTH 0.9 -#define BOUNTY_PISTOL_INTERVAL (0.25 SECONDS) +/// Between trigger pulls (each pull of the Stechkin is its own burst) +#define BOUNTY_PISTOL_INTERVAL (0.8 SECONDS) /// Keeps about this far away #define BOUNTY_PISTOL_RANGE 5 #define BOUNTY_PISTOL_MIN_RANGE 3 -/// The reload: the window to close in -#define BOUNTY_PISTOL_RELOAD (2 SECONDS) /// Raising the gun before the first shot of a string #define BOUNTY_PISTOL_WINDUP (0.2 SECONDS) /// Shots further apart than this start a new string #define BOUNTY_PISTOL_STRING_GAP (3 SECONDS) -#define BOUNTY_SHOTGUN_HEALTH 1 #define BOUNTY_SHOTGUN_INTERVAL (1.2 SECONDS) #define BOUNTY_SHOTGUN_RANGE 2 /// The pump before each blast #define BOUNTY_SHOTGUN_WINDUP (0.3 SECONDS) -/// Loading the tube again: the window to close in -#define BOUNTY_SHOTGUN_RELOAD (3 SECONDS) - -#define BOUNTY_CLUB_HEALTH 1.1 -#define BOUNTY_CLUB_INTERVAL (1.1 SECONDS) +/// Spare shells on the bandolier +#define BOUNTY_SHOTGUN_SHELLS 8 -#define BOUNTY_BOTTLE_HEALTH 0.9 #define BOUNTY_BOTTLE_INTERVAL (1.2 SECONDS) #define BOUNTY_BOTTLE_RANGE 4 #define BOUNTY_BOTTLE_MIN_RANGE 2 -/// Tiles a bottle flies -#define BOUNTY_BOTTLE_REACH 6 /// The throwing arc before each throw #define BOUNTY_BOTTLE_WINDUP (0.3 SECONDS) +/// Bottles in the bag, by tier: Petty, and above +#define BOUNTY_BOTTLES_PETTY 4 +#define BOUNTY_BOTTLES_WANTED 6 diff --git a/voidcrew/_DEFINES/bounty_bosses.dm b/voidcrew/_DEFINES/bounty_bosses.dm index 67ac1ea79c1..b647004b3fd 100644 --- a/voidcrew/_DEFINES/bounty_bosses.dm +++ b/voidcrew/_DEFINES/bounty_bosses.dm @@ -1,30 +1,32 @@ // # Bounty hunting: mini-boss defines // // Owner: P4 bosses (voidcrew/modules/bounties/bounty_boss.dm, bounty_boss_kits.dm). Only P4 edits -// this file. The shared enums are in bounties.dm. The numbers are the combat balance review's +// this file. The shared enums are in bounties.dm. The ability numbers are the combat balance review's // (balance/combat.md section 6.3, folded into spec.md 12.3 C8). A number marked (P4) is not in the -// review and was picked by P4. +// review and was picked by P4; one marked (phase D) came with the move to real human bodies and is a +// starting value for the balance pass (defaults 1.16). +// +// A boss is a real human (voidcrew/modules/human_npcs/): its health, stamina and stuns are tg's. There +// are no health tables, stamina pools or damage coefficients here, and there must never be. // ===== COMMON RULES ===== -/// Percent of max health at or below which a boss is tired: stamina works fully, it slows, its cooldowns stretch, and it can be stunned -#define BOUNTY_BOSS_TIRED_BELOW 40 -/// Stamina damage coefficient while fresh (the Heavy's is BOUNTY_HEAVY_STAMINA_FRESH). 0 after review H3: combat.md's 0.2 only slowed a fresh boss under steady disabler fire and pre-loaded its pool, so capture took one hit instead of five. -#define BOUNTY_BOSS_STAMINA_FRESH 0 -/// Stamina damage coefficient once tired -#define BOUNTY_BOSS_STAMINA_TIRED 1 -/// Stamina damage it takes to stamina-crit a tired boss (the Heavy's is BOUNTY_HEAVY_STAMINA), counted from zero when it tires. max_stamina stays P2's 100 because of the stamcrit removal quirk; the pool is folded into the coefficient instead. -#define BOUNTY_BOSS_STAMINA 150 +/// Brute and burn a boss takes, as a multiple of a person's, through its physiology (npc_damage_taken, defaults 1.5). Its armour does the rest. (phase D) +#define BOUNTY_BOSS_DAMAGE_TAKEN 0.6 +/// Its combat stimulant: one at the start of a fight, a second for its second wind (defaults 1.6, CR-4). Ephedrine: baton resistance, speed and quicker recovery from stuns, never immunity, so a crew can still stun and cuff a worn-out boss. (phase D) +#define BOUNTY_BOSS_STIMULANT /obj/item/reagent_containers/hypospray/medipen/stimpack +/// How many of BOUNTY_BOSS_STIMULANT it carries. (phase D) +#define BOUNTY_BOSS_STIMULANTS 2 +/// Worn out: stamina loss over this share of its max stamina... (phase D, CB-2) +#define BOUNTY_BOSS_WORN_OUT_STAMINA 0.5 +/// ...or health under this share of its max health. (phase D, CB-2) +#define BOUNTY_BOSS_WORN_OUT_HEALTH 0.4 +/// Worn out, it falls back from its target this long before its second wind. (phase D) +#define BOUNTY_BOSS_FALLBACK_TIME (8 SECONDS) /// Below this pressure (kPa) on either side, a wall, window or door is not interior (P4) #define BOUNTY_BOSS_INTERIOR_MIN_PRESSURE 20 /// More than this pressure difference (kPa) between its sides, and a wall, window or door is not interior (P4) #define BOUNTY_BOSS_INTERIOR_MAX_PRESSURE_GAP 50 -/// A dodge or miss message is shown at most this often (P4) -#define BOUNTY_BOSS_MESSAGE_COOLDOWN (1 SECONDS) -/// How much slower a tired boss moves -#define BOUNTY_BOSS_TIRED_SLOWDOWN 0.3 -/// Ability cooldowns are this much longer while tired (P4: the spec says "longer" and gives no number) -#define BOUNTY_BOSS_TIRED_COOLDOWN_MULT 1.5 /// Pause after one ability before the next may start, so telegraphs never overlap #define BOUNTY_BOSS_ABILITY_GAP_MIN (1 SECONDS) #define BOUNTY_BOSS_ABILITY_GAP_MAX (2 SECONDS) @@ -45,6 +47,19 @@ /// A hunter who hit the boss this recently is its first choice of target (P4) #define BOUNTY_BOSS_REVENGE_TIME (10 SECONDS) +// ===== THE POSSE (OC-8): ONE MORE COMPANION PER EXTRA HUNTER ===== + +/// Most companions a posse brings in for one boss (four or more hunters). (phase D) +#define BOUNTY_BOSS_REINFORCEMENTS_MAX 3 +/// Time between two companions coming in, and between tries to find a spot out of view. (phase D) +#define BOUNTY_BOSS_REINFORCE_DELAY (6 SECONDS) +/// A companion comes in at least this far from the boss... (phase D) +#define BOUNTY_BOSS_REINFORCE_MIN_DIST 5 +/// ...and no further than this. (phase D) +#define BOUNTY_BOSS_REINFORCE_MAX_DIST 14 +/// A spot any player within this many tiles can see is in view. (phase D) +#define BOUNTY_BOSS_REINFORCE_SIGHT 13 + // ===== SUMMONED THINGS: CAPS AND LIFETIMES (P4) ===== /// Fire pools (flamer floors and molotovs) burning at once, server-wide @@ -57,22 +72,11 @@ #define BOUNTY_BOSS_BARRICADES_PER_BOSS 2 /// How long a Heavy barricade stands before it folds away #define BOUNTY_BOSS_BARRICADE_LIFE (90 SECONDS) +/// Fire stacks (tg's) a boss's burning floor adds every second to anyone standing in it. (phase D, CB-8) +#define BOUNTY_BOSS_FIRE_TICK_STACKS 1 // ===== JUGGERNAUT ===== -/// Health for 1, 2, 3 and 4+ engaged hunters -#define BOUNTY_JUGGERNAUT_HEALTH_1 300 -#define BOUNTY_JUGGERNAUT_HEALTH_2 950 -#define BOUNTY_JUGGERNAUT_HEALTH_3 1600 -#define BOUNTY_JUGGERNAUT_HEALTH_4 2300 -#define BOUNTY_JUGGERNAUT_BRUTE_MOD 0.7 -#define BOUNTY_JUGGERNAUT_BURN_MOD 0.8 -#define BOUNTY_JUGGERNAUT_SPEED 1.9 -/// Its fists -#define BOUNTY_JUGGERNAUT_MELEE_MIN 20 -#define BOUNTY_JUGGERNAUT_MELEE_MAX 26 -#define BOUNTY_JUGGERNAUT_MELEE_AP 15 -#define BOUNTY_JUGGERNAUT_MELEE_COOLDOWN (1.1 SECONDS) /// Charge: a roar, a stamp and a cracked-floor line #define BOUNTY_JUGGERNAUT_CHARGE_WINDUP (0.8 SECONDS) #define BOUNTY_JUGGERNAUT_CHARGE_COOLDOWN (8 SECONDS) @@ -82,11 +86,15 @@ #define BOUNTY_JUGGERNAUT_CHARGE_STEP 1 #define BOUNTY_JUGGERNAUT_CHARGE_DAMAGE 25 #define BOUNTY_JUGGERNAUT_CHARGE_KNOCKDOWN (2 SECONDS) +/// Armour penetration of the charge +#define BOUNTY_JUGGERNAUT_CHARGE_AP 15 /// Percent chance that someone else in the way is caught too #define BOUNTY_JUGGERNAUT_CHARGE_BYSTANDER 25 -/// Charged into something it can't break: it stands reeling this long, taking more damage -#define BOUNTY_JUGGERNAUT_WALL_STAGGER (2 SECONDS) -#define BOUNTY_JUGGERNAUT_WALL_VULNERABLE 1.25 +/// Charged into something it can't break: brute to its head through its helmet, stamina, a moment's paralysis and a knockdown, as tg's tackle splat does (CB-6). (phase D) +#define BOUNTY_JUGGERNAUT_WALL_BRUTE 15 +#define BOUNTY_JUGGERNAUT_WALL_STAMINA 30 +#define BOUNTY_JUGGERNAUT_WALL_PARALYZE (1 SECONDS) +#define BOUNTY_JUGGERNAUT_WALL_KNOCKDOWN (3 SECONDS) /// Slam: both fists up, a red ring #define BOUNTY_JUGGERNAUT_SLAM_WINDUP (0.7 SECONDS) #define BOUNTY_JUGGERNAUT_SLAM_COOLDOWN (7 SECONDS) @@ -95,19 +103,8 @@ // ===== PYROMANIAC ===== -#define BOUNTY_PYROMANIAC_HEALTH_1 580 -#define BOUNTY_PYROMANIAC_HEALTH_2 1300 -#define BOUNTY_PYROMANIAC_HEALTH_3 1950 -#define BOUNTY_PYROMANIAC_HEALTH_4 2550 -/// Fireproof, not laser-proof: fire and heat can't hurt it, and lasers (BURN) hit it at this -#define BOUNTY_PYROMANIAC_BRUTE_MOD 0.9 -#define BOUNTY_PYROMANIAC_BURN_MOD 0.9 -#define BOUNTY_PYROMANIAC_SPEED 1.8 -/// Its torch: burn damage -#define BOUNTY_PYROMANIAC_MELEE_MIN 10 -#define BOUNTY_PYROMANIAC_MELEE_MAX 14 -#define BOUNTY_PYROMANIAC_MELEE_AP 15 -#define BOUNTY_PYROMANIAC_MELEE_COOLDOWN (1 SECONDS) +/// Its torch: lit, and it never goes out (a real tg torch, held from the start: it doesn't holster) +#define BOUNTY_PYROMANIAC_TORCH /obj/item/flashlight/flare/torch/everburning /// Flamer: a pilot light hiss, an orange cone #define BOUNTY_PYROMANIAC_FLAMER_WINDUP (0.5 SECONDS) #define BOUNTY_PYROMANIAC_FLAMER_COOLDOWN (5 SECONDS) @@ -115,6 +112,8 @@ /// Full width of the cone, in degrees #define BOUNTY_PYROMANIAC_FLAMER_ARC 90 #define BOUNTY_PYROMANIAC_FLAMER_DAMAGE 18 +/// Fire stacks (tg's) the jet puts on anyone in the cone. (phase D, CB-8) +#define BOUNTY_PYROMANIAC_FLAMER_STACKS 4 /// How long the floor the cone covered keeps burning #define BOUNTY_PYROMANIAC_FLAMER_FLOOR (4 SECONDS) /// Molotov: a lit rag, the throw, a ring where it lands @@ -122,23 +121,14 @@ #define BOUNTY_PYROMANIAC_MOLOTOV_COOLDOWN (7 SECONDS) #define BOUNTY_PYROMANIAC_MOLOTOV_RANGE 7 #define BOUNTY_PYROMANIAC_MOLOTOV_DAMAGE 10 +/// Fire stacks (tg's) the bursting bottle puts on anyone it splashes. (phase D, CB-8) +#define BOUNTY_PYROMANIAC_MOLOTOV_STACKS 3 #define BOUNTY_PYROMANIAC_MOLOTOV_POOL (8 SECONDS) -/// Set alight by a boss's fire: burn damage every second for this long, renewed while standing in the flames -#define BOUNTY_BOSS_BURNING_TIME (4 SECONDS) -#define BOUNTY_BOSS_BURNING_DAMAGE 3 // ===== DEMOLITIONIST ===== -#define BOUNTY_DEMOLITIONIST_HEALTH_1 870 -#define BOUNTY_DEMOLITIONIST_HEALTH_2 1750 -#define BOUNTY_DEMOLITIONIST_HEALTH_3 2300 -#define BOUNTY_DEMOLITIONIST_HEALTH_4 2850 -#define BOUNTY_DEMOLITIONIST_BRUTE_MOD 0.85 -#define BOUNTY_DEMOLITIONIST_BURN_MOD 0.85 -#define BOUNTY_DEMOLITIONIST_SPEED 1.7 -/// Its crowbar: the look in its hand and every number of its blows (bounty_real_weapon()) -#define BOUNTY_DEMOLITIONIST_CROWBAR /obj/item/crowbar/red -#define BOUNTY_DEMOLITIONIST_MELEE_COOLDOWN (1 SECONDS) +/// Its crowbar: carried in its bag until the fight starts +#define BOUNTY_DEMOLITIONIST_CROWBAR /obj/item/crowbar/large /// It keeps this far from its target unless someone is right on it #define BOUNTY_DEMOLITIONIST_KEEP_MIN 4 #define BOUNTY_DEMOLITIONIST_KEEP_MAX 6 @@ -148,9 +138,8 @@ #define BOUNTY_DEMOLITIONIST_GRENADE_COOLDOWN (4 SECONDS) #define BOUNTY_DEMOLITIONIST_GRENADE_RANGE 8 #define BOUNTY_DEMOLITIONIST_GRENADE_RADIUS 2 -/// Brute to anyone caught, against bomb armour +/// Damage to a mech's hull it catches, against bomb armour. People in the ring take tg's light explosion (CB-10). #define BOUNTY_DEMOLITIONIST_GRENADE_DAMAGE 35 -#define BOUNTY_DEMOLITIONIST_GRENADE_KNOCKDOWN (1 SECONDS) /// Damage to structures within BOUNTY_DEMOLITIONIST_GRENADE_OBJECT_RADIUS #define BOUNTY_DEMOLITIONIST_GRENADE_OBJECT_DAMAGE 60 #define BOUNTY_DEMOLITIONIST_GRENADE_OBJECT_RADIUS 1 @@ -160,79 +149,54 @@ #define BOUNTY_DEMOLITIONIST_BREACH_WINDUP (0.6 SECONDS) #define BOUNTY_DEMOLITIONIST_BREACH_FUSE (5 SECONDS) #define BOUNTY_DEMOLITIONIST_BREACH_COOLDOWN (18 SECONDS) +/// Damage to a mech's hull beside the charge. People beside it take tg's light explosion (CB-10). #define BOUNTY_DEMOLITIONIST_BREACH_DAMAGE 25 /// It breaches toward a target it can't see within this range #define BOUNTY_DEMOLITIONIST_BREACH_RANGE 8 // ===== GHOST ===== -#define BOUNTY_GHOST_HEALTH_1 250 -#define BOUNTY_GHOST_HEALTH_2 850 -#define BOUNTY_GHOST_HEALTH_3 1700 -#define BOUNTY_GHOST_HEALTH_4 2450 -#define BOUNTY_GHOST_BRUTE_MOD 1 -#define BOUNTY_GHOST_BURN_MOD 1 -#define BOUNTY_GHOST_SPEED 1.2 -/// Its blade: the look in its hand and every number of its blows (bounty_real_weapon()) +/// Its blade: a real combat knife, carried in a pocket until the fight starts, and every cut it lands is the knife's (CB-9) #define BOUNTY_GHOST_KNIFE /obj/item/knife/combat -#define BOUNTY_GHOST_MELEE_COOLDOWN (0.7 SECONDS) -/// Each cut bleeds this much brute a second for BOUNTY_GHOST_BLEED_TIME, up to BOUNTY_GHOST_BLEED_CAP a second -#define BOUNTY_GHOST_BLEED_PER_CUT 1 -#define BOUNTY_GHOST_BLEED_CAP 2 -#define BOUNTY_GHOST_BLEED_TIME (12 SECONDS) -/// Dash: a blur line to the target +/// Dash: a blur line to the target, the Cascade lattice firing as it goes (OC-6 ruling) #define BOUNTY_GHOST_DASH_WINDUP (0.3 SECONDS) #define BOUNTY_GHOST_DASH_COOLDOWN (5 SECONDS) #define BOUNTY_GHOST_DASH_RANGE 5 -/// The dash's cut, its biggest hit (P4: combat.md B4 asks for the dash to be the biggest hit), and its armour penetration -#define BOUNTY_GHOST_DASH_DAMAGE 20 -#define BOUNTY_GHOST_DASH_AP 10 -/// Cloak: a shimmer, then a faint distortion +/// Cloak: a shimmer, then a faint distortion. Only how it looks: nothing misses it for it (OC-6 ruling, CB-12) #define BOUNTY_GHOST_CLOAK_WINDUP (0.3 SECONDS) #define BOUNTY_GHOST_CLOAK_TIME (6 SECONDS) #define BOUNTY_GHOST_CLOAK_COOLDOWN (12 SECONDS) #define BOUNTY_GHOST_CLOAK_ALPHA 50 -/// Percent of hits that miss it while it is cloaked -#define BOUNTY_GHOST_CLOAK_MISS 50 -/// Percent of projectiles it dodges while moving -#define BOUNTY_GHOST_DODGE 30 -/// It counts as moving for this long after a step -#define BOUNTY_GHOST_MOVING_WINDOW (1 SECONDS) /// Hit and run: after this many cuts it breaks off for a while #define BOUNTY_GHOST_CUTS_BEFORE_BREAKOFF 2 #define BOUNTY_GHOST_BREAKOFF_TIME (4 SECONDS) // ===== HEAVY ===== -#define BOUNTY_HEAVY_HEALTH_1 340 -#define BOUNTY_HEAVY_HEALTH_2 970 -#define BOUNTY_HEAVY_HEALTH_3 1400 -#define BOUNTY_HEAVY_HEALTH_4 1850 -#define BOUNTY_HEAVY_BRUTE_MOD 0.55 -#define BOUNTY_HEAVY_BURN_MOD 0.65 -#define BOUNTY_HEAVY_SPEED 2.2 -/// 0 after review H3, as BOUNTY_BOSS_STAMINA_FRESH (combat.md had 0.15) -#define BOUNTY_HEAVY_STAMINA_FRESH 0 -#define BOUNTY_HEAVY_STAMINA 180 -/// Its belt-fed gun: the look in its hand, the rounds of its burst and the blow of its butt (bounty_real_weapon()) -#define BOUNTY_HEAVY_GUN /obj/item/gun/ballistic/automatic/l6_saw -#define BOUNTY_HEAVY_MELEE_COOLDOWN (1.1 SECONDS) +/// Its belt-fed gun: a real L6 held from the start (it has no sling, so it never holsters), with a real spare box (CB-13) +#define BOUNTY_HEAVY_GUN /obj/item/gun/ballistic/automatic/l6_saw/unrestricted +/// Its spare box magazine +#define BOUNTY_HEAVY_SPARE_AMMO /obj/item/ammo_box/magazine/m7mm /// Suppressive burst: a spin-up whirr, a laser sight and a red cone #define BOUNTY_HEAVY_BURST_WINDUP (0.7 SECONDS) #define BOUNTY_HEAVY_BURST_COOLDOWN (4 SECONDS) #define BOUNTY_HEAVY_BURST_RANGE 8 #define BOUNTY_HEAVY_BURST_SHOTS 10 -/// How long the burst takes to fire -#define BOUNTY_HEAVY_BURST_TIME (1.5 SECONDS) +/// How long the burst takes to fire. Each pull is a click, at least 2 deciseconds apart (a mob clicks once a decisecond at most). (phase D) +#define BOUNTY_HEAVY_BURST_TIME (2 SECONDS) /// Full width of the cone the rounds go into, in degrees #define BOUNTY_HEAVY_BURST_ARC 30 /// Extra width, in degrees, of the cone marked on the floor, so edge tiles a round can cross are marked too (P4) #define BOUNTY_HEAVY_BURST_MARK_MARGIN 10 -/// The rounds' damage to windows, grilles, tables and barricades it may break, as a share of their damage (none to anything else) -#define BOUNTY_HEAVY_BURST_DEMOLITION 0.25 -/// Barricade: tg's security barrier, dropped in front of it +/// A hit of at least this much damage while it aims makes it fumble the burst. (phase D, CB-13) +#define BOUNTY_HEAVY_FUMBLE_DAMAGE 8 +/// Barricade: a real barrier grenade, thrown in front of it (CB-26) #define BOUNTY_HEAVY_BARRICADE_WINDUP (0.6 SECONDS) #define BOUNTY_HEAVY_BARRICADE_COOLDOWN (20 SECONDS) +/// Barrier grenades it carries. (phase D) +#define BOUNTY_HEAVY_BARRIERS 2 +/// Its barrier grenades' fuse, set short. (phase D) +#define BOUNTY_HEAVY_BARRIER_FUSE (1 SECONDS) /// Percent of projectiles that pass its barricade (combat.md's number; tg's barrier lets 20 through) #define BOUNTY_HEAVY_BARRICADE_PASS 50 @@ -246,3 +210,7 @@ #define BB_BOUNTY_BOSS_PREY "BB_bounty_boss_prey" /// world.time it looks for prey again #define BB_BOUNTY_BOSS_HUNT_AT "BB_bounty_boss_hunt_at" +/// Who it falls back from while worn out +#define BB_BOUNTY_BOSS_FALL_BACK_FROM "BB_bounty_boss_fall_back_from" +/// world.time a Heavy's belt change in progress gives up +#define BB_BOUNTY_BOSS_RELOAD_UNTIL "BB_bounty_boss_reload_until" diff --git a/voidcrew/_DEFINES/bounty_criminals.dm b/voidcrew/_DEFINES/bounty_criminals.dm index e3e81d76cb4..696d2484b10 100644 --- a/voidcrew/_DEFINES/bounty_criminals.dm +++ b/voidcrew/_DEFINES/bounty_criminals.dm @@ -1,137 +1,22 @@ // # Bounty hunting: criminal body defines // -// Owner: P2 body (voidcrew/modules/bounties/bounty_criminal.dm, bounty_restraints.dm). Only P2 edits -// this file. The shared enums are in bounties.dm. The numbers are balance/combat.md section 6, as -// consolidated in spec.md section 12.3 (C1-C9). +// Owner: P2 body (voidcrew/modules/bounties/bounty_criminal.dm, bounty_restraints.dm, bounty_outfits.dm, +// bounty_ai_human.dm). Only P2 edits this file. The shared enums are in bounties.dm. +// +// A criminal is a real human NPC (human NPC migration, phase D): its health, stamina, crit, cuffs and +// breakout times are tg's, so there are no health pools, stamina pools, downed lines, recovery timers +// or slip times here, and there must never be. // // Unit tests compile before voidcrew/_DEFINES and cannot see these: a test uses the literal value, // with a comment naming the define. // ===== TRAITS ===== -/** - * On a criminal while it is restrained or downed: its AI must plan nothing. P3's controller can - * check it in its first subtree. P2 also adds TRAIT_AI_PAUSED under BOUNTY_BODY_HELD_TRAIT at the - * same time, which stops the controller outright. - */ -#define TRAIT_BOUNTY_HELD "bounty_held" -/// A meek criminal sprinting, and neither winded nor cornered: P3 adds and removes it (source BOUNTY_TRAIT). P2 dodges projectiles while it is on (BOUNTY_MEEK_DODGE). -#define TRAIT_BOUNTY_SPRINTING "bounty_sprinting" -/** - * A script is walking the criminal somewhere on purpose (a walk-out, a cutscene): the leash lets its - * steps through. Godmode counts the same, which covers P6's walk out to the hangar lift. - */ +/// A script is walking the criminal somewhere on purpose (a cutscene): the leash lets its steps through. Walking out (npc_walk_out()) counts the same. #define TRAIT_BOUNTY_SCRIPTED_MOVE "bounty_scripted_move" -/// Trait source for what the body always has (no teleports, no mob swaps) +/// Trait source for what the body always has (no teleports, no mob swaps). A convict a crew talks down loses them. #define BOUNTY_BODY_TRAIT "bounty_body" -/// Trait source for being downed: floored, incapacitated, immobilized -#define BOUNTY_BODY_DOWNED_TRAIT "bounty_body_downed" -/// Trait source for the restraints holding a criminal still -#define BOUNTY_BODY_CUFFS_TRAIT "bounty_body_cuffs" -/// Trait source for TRAIT_BOUNTY_HELD and TRAIT_AI_PAUSED while restrained or downed -#define BOUNTY_BODY_HELD_TRAIT "bounty_body_held" - -// ===== BODY ===== - -/// sentience_type of every criminal: no sentience potion, no ghost role -#define BOUNTY_CRIMINAL_NO_SENTIENCE 0 - -/// Health of a meek criminal, every tier -#define BOUNTY_MEEK_HEALTH 120 -/// Health of a normal criminal by tier, before the style's multiplier (C7) -#define BOUNTY_NORMAL_HEALTH_PETTY 140 -#define BOUNTY_NORMAL_HEALTH_WANTED 180 -#define BOUNTY_NORMAL_HEALTH_MOST 220 -/// P0's name for the normal criminal's health: the Wanted value -#define BOUNTY_NORMAL_HEALTH BOUNTY_NORMAL_HEALTH_WANTED - -/// Health multiplier by fighting style (combat.md 6.2) -#define BOUNTY_STYLE_HEALTH_BRAWLER 1.2 -#define BOUNTY_STYLE_HEALTH_KNIFE 1 -#define BOUNTY_STYLE_HEALTH_PISTOL 0.9 -#define BOUNTY_STYLE_HEALTH_SHOTGUN 1 -#define BOUNTY_STYLE_HEALTH_CLUB 1.1 -#define BOUNTY_STYLE_HEALTH_BOTTLE 0.9 -/// A brawler takes stamina damage x this -#define BOUNTY_STYLE_STAMINA_BRAWLER 0.8 - -/// Fire and heat (L3): a criminal on fire, or hotter than this, burns like a suited person, BOUNTY_CRIMINAL_BURN_DAMAGE a second. The mercy line and the automated floor still hold it. Mini-bosses keep P4's own fire rules. -#define BOUNTY_CRIMINAL_MAX_TEMP SPACE_SUIT_MAX_TEMP_PROTECT -#define BOUNTY_CRIMINAL_BURN_DAMAGE 3 - -/// An explosion counts as a player's when the explosive was last touched by one, or someone with a mind stands within this many tiles -#define BOUNTY_EXPLOSION_WITNESS_RANGE 7 - -/// Pace of a meek criminal: its sprint (P3 slows it while winded) -#define BOUNTY_BODY_MEEK_SPEED 1.1 -/// Pace of a normal criminal with a melee style, and with a ranged one (pistol, bottle) -#define BOUNTY_BODY_NORMAL_SPEED_MELEE 1.25 -#define BOUNTY_BODY_NORMAL_SPEED_RANGED 1.4 - -// ===== STAMINA ===== -// max_stamina stays at 100 on every criminal: basic mobs leave stamina crit by comparing raw stamina -// with a percentage (stamcrit.dm), which only agree at 100. A pool of any other size is the stamina -// damage coefficient: 100 / pool. - -#define BOUNTY_CRIMINAL_MAX_STAMINA 100 -/// Stamina crit at this much stamina: a hair under 100, so a pool that divides evenly (three 30-point disabler shots on a 90 pool) still crits through float rounding -#define BOUNTY_CRIMINAL_STAMCRIT_AT 99.9 -/// A meek criminal's stamina pool: three disabler shots or two batons (C5) -#define BOUNTY_MEEK_STAMINA 90 -/// A meek criminal's slowdown with no stamina left (tg's is 3): one hit must not end the chase (C5) -#define BOUNTY_MEEK_STAMINA_SLOWDOWN 0.5 -/// How long stamina crit lasts after the last stamina hit: meek (C5), and everyone else (tg's default, as simulated) -#define BOUNTY_MEEK_STAMCRIT_TIME (12 SECONDS) -#define BOUNTY_NORMAL_STAMCRIT_TIME (10 SECONDS) -/// P0's name for the stamina crit time -#define BOUNTY_STAMCRIT_TIME BOUNTY_NORMAL_STAMCRIT_TIME -/// P0's names for the stamina coefficients. The pool sets the real one (100 / pool); these stay 1. -#define BOUNTY_MEEK_STAMINA_COEFF 1 -#define BOUNTY_NORMAL_STAMINA_COEFF 1 - -/// Percent of projectiles a sprinting meek criminal ducks (C5) -#define BOUNTY_MEEK_DODGE 50 -/// No ducking within this long of being shot -#define BOUNTY_MEEK_DODGE_AFTER_HIT (1 SECONDS) - -// ===== DOWNED AND RECOVERY (C1, C3) ===== - -/// Percent of max health at or below which a criminal is downed -#define BOUNTY_DOWNED_BELOW 25 -/// P0's name for the downed line, as a fraction -#define BOUNTY_DOWNED_FRACTION (BOUNTY_DOWNED_BELOW / 100) -/// Percent of max health a downed criminal gets up with (more if it was healed while down) -#define BOUNTY_RECOVER_TO 35 -/// How long a downed, uncuffed criminal stays down, by archetype -#define BOUNTY_RECOVER_TIME_MEEK (60 SECONDS) -#define BOUNTY_RECOVER_TIME_NORMAL (75 SECONDS) -#define BOUNTY_RECOVER_TIME_BOSS (45 SECONDS) -/// The last stretch of the recovery, when it groans and tries to rise -#define BOUNTY_BODY_STIRRING_TELL (10 SECONDS) -/// A mini-boss that gets up shrugs off stamina for this long (C1); P4 shows it -#define BOUNTY_BODY_RALLY_TIME (20 SECONDS) - -// ===== AUTOMATED DAMAGE (AR-D3) ===== - -/// On its site, damage with nobody's mind behind it (turrets, traps, fire, fauna) stops at this percent of max health -#define BOUNTY_AUTOMATED_FLOOR 40 - -// ===== RESTRAINTS (C2) ===== - -/// Putting restraints on a downed, stunned or surrendered criminal -#define BOUNTY_CUFF_TIME (2 SECONDS) -/// Taking them off -#define BOUNTY_UNCUFF_TIME (2 SECONDS) -/// Cable restraints and zipties slip after this long; handcuffs never do -#define BOUNTY_CABLE_SLIP (3 MINUTES) -#define BOUNTY_ZIPTIE_SLIP (5 MINUTES) -/// Joke cuffs and zipties -#define BOUNTY_FAKE_CUFF_SLIP (5 SECONDS) -/// A mini-boss gets out of cable and zipties in this share of the time (combat.md 6.4) -#define BOUNTY_BOSS_SLIP_MULT 0.5 -/// The visible struggle starts this long before they slip -#define BOUNTY_SLIP_WARNING (20 SECONDS) // ===== LEASH AND TARGETS (AR-D1, AR-D2) ===== @@ -141,3 +26,23 @@ #define BOUNTY_BODY_FALLBACK_LEASH 40 /// Most mobs a criminal remembers as fair game; the oldest go first #define BOUNTY_GRUDGE_MAX 12 + +// ===== CUFFS, TOUGHNESS, SELF-TREATMENT ===== + +/// A criminal answers a reach for its wrists this long after tg's cuffing starts: a person's reaction, and inside tg's 4 second do_after, so stepping away breaks it +#define BOUNTY_CUFF_REACTION_DELAY (0.5 SECONDS) +/// Sent on a criminal when someone starts putting cuffs on it, before its own reaction: (mob/living/user). Return COMPONENT_BOUNTY_CUFF_HANDLED to take the reaction over. +#define COMSIG_BOUNTY_CUFF_REACHED "bounty_cuff_reached" + #define COMPONENT_BOUNTY_CUFF_HANDLED (1<<0) +/// A cuffed criminal that started working at its cuffs this recently and then lost them got itself out +#define BOUNTY_SELF_FREED_WINDOW (2 MINUTES) +/// Brute and burn a criminal takes, as a multiple of a person's (physiology, npc_damage_taken), by tier. Armour does the rest. +#define BOUNTY_TOUGHNESS_PETTY 1 +#define BOUNTY_TOUGHNESS_WANTED 0.9 +#define BOUNTY_TOUGHNESS_MOST_WANTED 0.8 +/// A bounty NPC treats itself when its health is at or below this share of its max, with nothing it can see attacking it +#define BOUNTY_TREAT_SELF_BELOW 0.7 +/// Between two goes at treating itself +#define BOUNTY_TREAT_SELF_COOLDOWN (20 SECONDS) +/// Blackboard key: the medical stack it is using on itself has been clicked on it once this go (bounty_ai_human.dm) +#define BB_BOUNTY_TREAT_APPLIED "bounty_treat_applied" diff --git a/voidcrew/_DEFINES/bounty_kingpin.dm b/voidcrew/_DEFINES/bounty_kingpin.dm index 5ebae7d5de0..07912939809 100644 --- a/voidcrew/_DEFINES/bounty_kingpin.dm +++ b/voidcrew/_DEFINES/bounty_kingpin.dm @@ -23,16 +23,11 @@ // ===== HIS BODY ===== -#define BOUNTY_KINGPIN_HEALTH 200 -/// Stamina damage that stamcrits him: 5 disabler hits in 10 seconds, or 3 baton hits -#define BOUNTY_KINGPIN_STAMINA 150 -/// Downed to up, uncuffed (the 10 s stirring tell is P2's, inside this) -#define BOUNTY_KINGPIN_RECOVERY (60 SECONDS) -/// After he gets up: stamina does nothing to him and he won't surrender (combat.md 5.6) -#define BOUNTY_KINGPIN_RALLY (20 SECONDS) -/// Below this percent of his health, with his crew down, he may surrender +/// Brute and burn he takes, as a multiple of a person's (the human NPC base's npc_damage_taken, boss rank). His armoured coat does the rest. +#define BOUNTY_KINGPIN_DAMAGE_TAKEN 0.6 +/// At or below this percent of his health, with his crew down and a hunter in sight, he may give up #define BOUNTY_KINGPIN_SURRENDER_BELOW 40 -/// Percent chance on the hit that crosses the line, and on each later hit +/// Percent chance on his first roll, and on each later one #define BOUNTY_KINGPIN_SURRENDER_FIRST 60 #define BOUNTY_KINGPIN_SURRENDER_LATER 25 /// At most one surrender roll per this @@ -40,13 +35,14 @@ // ===== HIS REVOLVER ===== -/// The revolver in his hand: its look, its rounds and its cylinder (bounty_real_weapon()) +/// The revolver he carries in his holster: a real .357, drawn when the guns come out #define BOUNTY_KINGPIN_REVOLVER /obj/item/gun/ballistic/revolver +/// His spare rounds: real .357 speedloaders, two in the holster and one in a pocket +#define BOUNTY_KINGPIN_SPEEDLOADER /obj/item/ammo_box/a357 /// The aim line before each shot; he never fires without it #define BOUNTY_KINGPIN_REVOLVER_AIM (0.5 SECONDS) /// From one aim to the next #define BOUNTY_KINGPIN_REVOLVER_COOLDOWN (1.2 SECONDS) -#define BOUNTY_KINGPIN_REVOLVER_RELOAD (3 SECONDS) // ===== THE SHOOTOUT ===== @@ -75,53 +71,47 @@ /// A fixed crew of six (kingpin.md 3.4), one per map post #define BOUNTY_KINGPIN_GOONS 6 -#define BOUNTY_GOON_HEALTH 150 -/// A goon's stamina pool, the way P2 sets a criminal's: max_stamina 100, with a coefficient of 100 / BOUNTY_GOON_HEALTH, so 5 disabler hits stamcrit him. tg's basic mobs compare raw points with this percentage when the crit ends, so it must be 100. -#define BOUNTY_GOON_MAX_STAMINA 100 -/// Percent of it that stamcrits him. Just under 100, for float rounding. -#define BOUNTY_GOON_STAMCRIT_AT 99.9 #define BOUNTY_GOON_WEAPON_PISTOL "pistol" #define BOUNTY_GOON_WEAPON_SMG "smg" #define BOUNTY_GOON_WEAPON_SHOTGUN "shotgun" -/// The guns in the goons' hands: their looks, their rounds and their magazines (bounty_real_weapon()) +/// The real guns the goons carry, and their real spares #define BOUNTY_GOON_PISTOL_GUN /obj/item/gun/ballistic/automatic/pistol/aps +#define BOUNTY_GOON_PISTOL_MAG /obj/item/ammo_box/magazine/m9mm_aps #define BOUNTY_GOON_SMG_GUN /obj/item/gun/ballistic/automatic/mini_uzi -#define BOUNTY_GOON_SHOTGUN_GUN /obj/item/gun/ballistic/shotgun/automatic/combat -/// What the shotguns are loaded with +#define BOUNTY_GOON_SMG_MAG /obj/item/ammo_box/magazine/uzim9mm +/// The combat shotgun, its tube loaded with buckshot (bounty_kingpin.dm) +#define BOUNTY_GOON_SHOTGUN_GUN /obj/item/gun/ballistic/shotgun/automatic/combat/bounty_kingpin +/// What the shotguns are loaded with, and the loose shells a shotgun goon carries in his bandolier #define BOUNTY_GOON_SHOTGUN_AMMO /obj/item/ammo_casing/shotgun/buckshot +#define BOUNTY_GOON_SHOTGUN_SHELLS 8 -#define BOUNTY_GOON_PISTOL_COOLDOWN (0.3 SECONDS) -#define BOUNTY_GOON_PISTOL_RELOAD (2 SECONDS) +/// Between two trigger pulls of a goon's pistol (each pull is the Stechkin's own three-round burst) +#define BOUNTY_GOON_PISTOL_COOLDOWN (1 SECONDS) -/// Shots in a burst, and the gap between them -#define BOUNTY_GOON_SMG_BURST 5 -#define BOUNTY_GOON_SMG_BURST_GAP (0.1 SECONDS) +/// Trigger pulls in a burst (each pull is the Uzi's own two-round burst), and the gap between them +#define BOUNTY_GOON_SMG_BURST 2 +#define BOUNTY_GOON_SMG_BURST_GAP (0.3 SECONDS) /// The spin-up: the gun comes up level, with a sound #define BOUNTY_GOON_SMG_WINDUP (0.3 SECONDS) #define BOUNTY_GOON_SMG_COOLDOWN (1 SECONDS) -#define BOUNTY_GOON_SMG_RELOAD (2.5 SECONDS) /// Tiles: he walks in to this before he fires #define BOUNTY_GOON_SHOTGUN_RANGE 2 /// The pump before each blast #define BOUNTY_GOON_SHOTGUN_WINDUP (0.3 SECONDS) #define BOUNTY_GOON_SHOTGUN_COOLDOWN (1.2 SECONDS) -#define BOUNTY_GOON_SHOTGUN_RELOAD (3 SECONDS) -/// Tiles from the sofa a goon ever walks +/// Tiles from the sofa a goon ever walks while his crew holds the lounge #define BOUNTY_GOON_LEASH 7 -/// Percent of the goons left who flee when he falls (downed, cuffed, surrendered or dead) +/// Percent of the goons left who run when he falls (in crit, cuffed, given up or dead) #define BOUNTY_GOON_FLEE_ON_BOSS 50 -/// A fleeing goon is gone after this -#define BOUNTY_GOON_FLEE_TIME (6 SECONDS) -/// A goon's body fades after this (the outpost never unloads) -#define BOUNTY_GOON_FADE (60 SECONDS) -/// How long a goon's body takes to fade, and a leaving goon to walk out -#define BOUNTY_GOON_FADE_OUT (2 SECONDS) -#define BOUNTY_GOON_LEAVE_TIME (5 SECONDS) -/// Between a goon's steps in a fight +/// The quickest a goon takes a step in a fight; his own body's slowdown (wounds, armour) can make it slower #define BOUNTY_GOON_STEP (0.35 SECONDS) +/// A reload by hand gives up after this: a tube is fed a shell at a time +#define BOUNTY_KINGPIN_RELOAD_GIVE_UP (15 SECONDS) +/// Blackboard key on him and his goons: their guns are out (the crew is drawing or fighting), so a spent gun is reloaded +#define BB_BOUNTY_KINGPIN_ARMED "bounty_kingpin_armed" // ===== TALKING ===== @@ -158,7 +148,7 @@ #define BOUNTY_KINGPIN_PAY_MAX 3500 /// Vouchers on a full-share turn-in; red adds BOUNTY_RED_VOUCHER_BONUS #define BOUNTY_KINGPIN_VOUCHERS 1 -/// Wanted dead or alive: restrained, stunned or downed is alive +/// Wanted dead or alive: alive pays in full however he is brought in (cuffed, stunned or in crit); dead pays 80% #define BOUNTY_KINGPIN_PAY_ALIVE 100 #define BOUNTY_KINGPIN_PAY_DEAD 80 /// He goes on the board no earlier than 45 minutes into the round, and only with 3+ active ships diff --git a/voidcrew/_DEFINES/bounty_lairs.dm b/voidcrew/_DEFINES/bounty_lairs.dm index 1044e6fdab2..c4776e75f22 100644 --- a/voidcrew/_DEFINES/bounty_lairs.dm +++ b/voidcrew/_DEFINES/bounty_lairs.dm @@ -58,9 +58,12 @@ /// A second pass that keeps the goons in their rooms, once every zone_mobs marker has had time to spawn (its resolver retries for up to a minute) #define BOUNTY_LAIR_GOON_LEASH_DELAY (65 SECONDS) -// ===== P12 ===== +/// ===== P12 ===== // The mafia club's people (bounty_lair_mafia.dm): balance/lairs.md sections 3-5 and 10, spec section 15. // Unit tests can't see these; they use the literal values with the define named in a comment. +// The goons, the lieutenants and the don are real human NPCs (voidcrew/modules/human_npcs/): their health is a +// person's, their toughness is what they wear and npc_damage_taken, and they fire the real guns in their hands. +// Only the don's mech is a mob of its own. /// The faction every club mob shares: goons, lieutenants, the mech and the don #define BOUNTY_MAFIA_FACTION "bounty_mafia" @@ -71,8 +74,10 @@ #define BOUNTY_MAFIA_BARK_COOLDOWN (12 SECONDS) /// Chance a second, per mob, that an idle goon says something while players are about #define BOUNTY_MAFIA_IDLE_BARK_CHANCE 1 +/// After someone starts cuffing a club member who can still move, how long before it steps away (tg's cuffing takes 4 seconds) +#define BOUNTY_MAFIA_CUFF_REACTION (0.6 SECONDS) -/// Sent on the mech as the don climbs out, before the mech's death: (mob/living/basic/bounty_lair_boss/mafia_don/don) +/// Sent on the mech as the don climbs out, before the mech's death: (mob/living/carbon/human/npc/bounty_mafia/don/don) #define COMSIG_BOUNTY_MAFIA_DON_EJECTED "bounty_mafia_don_ejected" /// Sent on the don when his trophy drops: (obj/item/bounty_proof/trophy/mafia_don/trophy) #define COMSIG_BOUNTY_MAFIA_TROPHY_DROPPED "bounty_mafia_trophy_dropped" @@ -81,30 +86,25 @@ #define BB_BOUNTY_MAFIA_MOVE_TO "BB_bounty_mafia_move_to" // ----- mobsters ----- -// Every blow and round is the real item's in their hand (bounty_real_weapon()): its look, damage and magazine. +// A volley is one aim (if the gun has one), then VOLLEY pulls of the trigger VOLLEY_GAP apart, then COOLDOWN before +// the next. The gun's own burst and fire rate apply to every pull: a Stechkin pull is its three-round burst. #define BOUNTY_MOBSTER_KNIFE /obj/item/knife/kitchen -#define BOUNTY_MOBSTER_KNIFE_HEALTH 120 -#define BOUNTY_MOBSTER_KNIFE_COOLDOWN (0.8 SECONDS) -#define BOUNTY_MOBSTER_KNIFE_SPEED 1.2 #define BOUNTY_MOBSTER_PISTOL_GUN /obj/item/gun/ballistic/automatic/pistol/aps -#define BOUNTY_MOBSTER_PISTOL_HEALTH 120 -/// A pistol fires this many shots each time it fires, this far apart; a goon only decides to shoot every half second -#define BOUNTY_MOBSTER_PISTOL_BURST 2 -#define BOUNTY_MOBSTER_PISTOL_BURST_GAP (0.25 SECONDS) -#define BOUNTY_MOBSTER_PISTOL_COOLDOWN (0.5 SECONDS) -#define BOUNTY_MOBSTER_PISTOL_RELOAD (2 SECONDS) -#define BOUNTY_MOBSTER_PISTOL_SPEED 1.4 +#define BOUNTY_MOBSTER_PISTOL_MAGAZINE /obj/item/ammo_box/magazine/m9mm_aps +#define BOUNTY_MOBSTER_PISTOL_VOLLEY 1 +#define BOUNTY_MOBSTER_PISTOL_VOLLEY_GAP (0.3 SECONDS) +#define BOUNTY_MOBSTER_PISTOL_COOLDOWN (0.8 SECONDS) #define BOUNTY_MOBSTER_SMG_GUN /obj/item/gun/ballistic/automatic/mini_uzi -#define BOUNTY_MOBSTER_SMG_HEALTH 150 -#define BOUNTY_MOBSTER_SMG_BURST 5 -#define BOUNTY_MOBSTER_SMG_BURST_GAP (0.1 SECONDS) +#define BOUNTY_MOBSTER_SMG_MAGAZINE /obj/item/ammo_box/magazine/uzim9mm +/// The SMG spins up before each volley ("aiming!"), and a hit then spoils it #define BOUNTY_MOBSTER_SMG_WINDUP (0.3 SECONDS) +/// Each pull is the Uzi's two-round burst +#define BOUNTY_MOBSTER_SMG_VOLLEY 3 +#define BOUNTY_MOBSTER_SMG_VOLLEY_GAP (0.3 SECONDS) #define BOUNTY_MOBSTER_SMG_COOLDOWN (1 SECONDS) -#define BOUNTY_MOBSTER_SMG_RELOAD (2.5 SECONDS) -#define BOUNTY_MOBSTER_SMG_SPEED 1.4 /// The shout before a room's first shot #define BOUNTY_MOBSTER_ALERT (0.5 SECONDS) @@ -125,25 +125,20 @@ // ----- lieutenants ----- +/// Both lieutenants take this much of any brute or burn, through their bodies (elite rank), on top of their armour +#define BOUNTY_LIEUTENANT_DAMAGE_TAKEN 0.8 + #define BOUNTY_LIEUTENANT_TOMMY_GUN /obj/item/gun/ballistic/automatic/tommygun -#define BOUNTY_LIEUTENANT_TOMMY_HEALTH 350 -#define BOUNTY_LIEUTENANT_TOMMY_BURST 6 -#define BOUNTY_LIEUTENANT_TOMMY_BURST_GAP (0.1 SECONDS) +#define BOUNTY_LIEUTENANT_TOMMY_MAGAZINE /obj/item/ammo_box/magazine/tommygunm45 #define BOUNTY_LIEUTENANT_TOMMY_WINDUP (0.3 SECONDS) +/// Each pull is one round of the Thompson +#define BOUNTY_LIEUTENANT_TOMMY_VOLLEY 6 +#define BOUNTY_LIEUTENANT_TOMMY_VOLLEY_GAP (0.1 SECONDS) #define BOUNTY_LIEUTENANT_TOMMY_COOLDOWN (1 SECONDS) -#define BOUNTY_LIEUTENANT_TOMMY_RELOAD (3 SECONDS) -#define BOUNTY_LIEUTENANT_TOMMY_SPEED 1.4 -/// Brute fights with his fists: a human's punch -#define BOUNTY_LIEUTENANT_BRUTE_HEALTH 400 -#define BOUNTY_LIEUTENANT_BRUTE_COOLDOWN (1 SECONDS) -/// Percent chance a blow knocks the hunter down +/// Brute fights with his fists: a person's punch. A landed punch knocks the hunter down this often (percent), for this long. #define BOUNTY_LIEUTENANT_BRUTE_KNOCKDOWN_CHANCE 25 #define BOUNTY_LIEUTENANT_BRUTE_KNOCKDOWN (1 SECONDS) -#define BOUNTY_LIEUTENANT_BRUTE_SPEED 1.2 - -/// Both lieutenants take this much of any brute or burn damage -#define BOUNTY_LIEUTENANT_DAMAGE_MOD 0.8 /// The lieutenants' names for the role var #define BOUNTY_LIEUTENANT_TOMMY "tommy" @@ -171,10 +166,11 @@ #define BOUNTY_MECH_STOMP_THROW 3 #define BOUNTY_MECH_STOMP_THROW_SPEED 2 -/// The lock-on: a marker under each hunter it can see, then one rocket per marker +/// The lock-on: a marker under each hunter it can see, then one rocket per marker. Each burst is tg's light blast +/// (ex_act(EXPLODE_LIGHT)) on everyone standing on its marker, and nothing else: no explosion(), no breach. #define BOUNTY_MECH_ROCKET_LOCK (0.8 SECONDS) +/// A rocket's damage to what it hits in flight in the arena (a table, a window, a door), before BOUNTY_MECH_ROCKET_DEMOLITION #define BOUNTY_MECH_ROCKET_DAMAGE 70 -#define BOUNTY_MECH_ROCKET_KNOCKDOWN (1 SECONDS) #define BOUNTY_MECH_ROCKET_COOLDOWN (9 SECONDS) /// Damage a rocket does to a table, window or door it hits in the arena, as a multiple of its damage #define BOUNTY_MECH_ROCKET_DEMOLITION 8 @@ -210,12 +206,15 @@ /// His name when his posting's record gives none: the name P10's card shows for Club Volga #define BOUNTY_DON_NAME "Arkady Sokolov" -/// His gold pistol: its look, its rounds and its magazine (bounty_real_weapon()); he fires strings of BOUNTY_MOBSTER_PISTOL_BURST as a goon does +/// The don takes this much of any brute or burn, through his body (boss rank) +#define BOUNTY_DON_DAMAGE_TAKEN 0.6 +/// His gold pistol, and the magazines he carries for it #define BOUNTY_DON_GUN /obj/item/gun/ballistic/automatic/pistol/deagle/gold -#define BOUNTY_DON_HEALTH 250 -#define BOUNTY_DON_COOLDOWN (0.5 SECONDS) -#define BOUNTY_DON_RELOAD (2 SECONDS) -/// He raises the pistol this long before each string of shots +#define BOUNTY_DON_MAGAZINE /obj/item/ammo_box/magazine/m50 +/// He raises the pistol this long before the first volley of each magazine #define BOUNTY_DON_RAISE (0.2 SECONDS) -#define BOUNTY_DON_SPEED 1.4 +#define BOUNTY_DON_VOLLEY 2 +#define BOUNTY_DON_VOLLEY_GAP (0.25 SECONDS) +#define BOUNTY_DON_COOLDOWN (0.5 SECONDS) +/// Climbing out of the wreck, he takes this long to get his bearings before he acts #define BOUNTY_DON_EJECT_STAGGER (2 SECONDS) diff --git a/voidcrew/_DEFINES/bounty_outpost.dm b/voidcrew/_DEFINES/bounty_outpost.dm index 97017714e57..faa545816d5 100644 --- a/voidcrew/_DEFINES/bounty_outpost.dm +++ b/voidcrew/_DEFINES/bounty_outpost.dm @@ -17,12 +17,8 @@ #define BOUNTY_DECOY_FLEE_DISTANCE 5 /// How long a decoy keeps backing off #define BOUNTY_DECOY_FLEE_TIME (4 SECONDS) -/// Move delay of someone walking out to the hangar: a walk, not a run -#define BOUNTY_OUTPOST_EXIT_DELAY 4 -/// Anyone still walking out after this fades where they are -#define BOUNTY_OUTPOST_EXIT_TIMEOUT (45 SECONDS) -/// How long the fade out takes -#define BOUNTY_OUTPOST_FADE_TIME (1 SECONDS) +// Walking out to the hangar lift is the human NPC base's npc_walk_out() (human_npc_states.dm): a walk +// at the body's own pace, with no timeout and no fade. They leave on the lift or out of sight. /// Trait source for everything P6 puts on a mob #define BOUNTY_OUTPOST_TRAIT "bounty_outpost" diff --git a/voidcrew/_HELPERS/hostile_creatures.dm b/voidcrew/_HELPERS/hostile_creatures.dm index 22dc386a234..30e616a1de2 100644 --- a/voidcrew/_HELPERS/hostile_creatures.dm +++ b/voidcrew/_HELPERS/hostile_creatures.dm @@ -73,9 +73,10 @@ GLOBAL_LIST_INIT(turret_retaliating_subtrees, typecacheof(list( // headslug, whose stock AI already reads as hostile. Their custom AI does not. if(istype(creature, /mob/living/basic/outpost_experiment)) return is_outpost_experiment_turret_target(creature) - // Bounty criminals, decoys and companions (voidcrew/modules/bounties/bounty_criminal.dm): trader-outpost - // turrets leave them to the hunters, and no turret shoots a criminal already down, stunned or cuffed. - if(istype(creature, /mob/living/basic/bounty_criminal) || istype(creature, /mob/living/basic/bounty_companion)) + // Bounty criminals, decoys and companions (voidcrew/modules/bounties/bounty_criminal.dm), real human bodies: + // trader-outpost turrets leave them to the hunters, and no turret shoots a criminal already in crit, + // stunned or cuffed (tg's states). + if(istype(creature, /mob/living/carbon/human/npc/bounty_criminal) || istype(creature, /mob/living/carbon/human/npc/bounty_companion)) if(bounty_turret_ignores(creature, istype(get_area(creature), /area/voidcrew/trader_outpost))) return FALSE // Bees from an outpost's own apiary never sting anyone (outpost_apiary.dm), but their diff --git a/voidcrew/modules/ambient_npcs/convict.dm b/voidcrew/modules/ambient_npcs/convict.dm index 79bf0667f63..f7e8296213c 100644 --- a/voidcrew/modules/ambient_npcs/convict.dm +++ b/voidcrew/modules/ambient_npcs/convict.dm @@ -7,24 +7,35 @@ * inside the existing two-offer limit, paid by the existing capture rules; recruiting them * withdraws it unpaid. * - * The convict (spec 5.4) is the bounty module's meek criminal in prison orange, with its own AI: - * camping at a small fire on a planet, or looking round a space ruin; sprinting and hiding from - * anyone who comes at them armed; a holdout when cornered. This file only calls the bounty - * module's procs; it edits nothing there. - * - Sighted: the first time someone of a ship crew comes into view, they put their hands up - * ("Don't shoot!") and a private petty bounty on them is posted to that crew's ship, if the board - * would offer that ship another private bounty now (under BOUNTY_PRIVATE_MAX, and not in the gap - * after its last one ended). Only ever one bounty per convict. The crew cuff them and use - * their pad, and the bounty pays by the usual rules. + * The convict (spec 5.4) is the bounty module's meek criminal, a real human body + * (voidcrew/modules/human_npcs/), in prison orange, with the meek AI: camping at a small fire on a + * planet, or looking round a space ruin; running and hiding from anyone who comes at them armed; a + * holdout pistol when cornered. This file only calls the bounty module's procs; it edits nothing there. + * - Sighted: the first time someone of a ship crew comes into view, they give up the way a person + * does (npc_surrender(): the weapon put away, "Don't shoot!", tg's *surrender, a real 20 second + * Paralyze), and a private petty bounty on them is posted to that crew's ship, if the board would + * offer that ship another private bounty now (under BOUNTY_PRIVATE_MAX, and not in the gap after its + * last one ended). Only ever one bounty per convict. The crew cuff them and use their pad, and the + * bounty pays on their condition there by the usual rules. * - Talked down: an empty hand from a crew member while they are calm, and they ask to come along. - * "Come with us" turns them into a stray following that crew (recruit.dm), wearing the same face, - * and withdraws their bounty unpaid. A convict who is fleeing, hiding, down or cuffed won't talk. + * "Come with us" and the SAME body goes with that crew (defaults 1.9, AM-6): its bounty is withdrawn + * unpaid, it is taken off the board for good (no posting, no leash, no teleport block, no sweep + * protection, off the convict count), and its AI and faction change: a small follower AI of its own + * (below) walks after whoever asked, keeps out of fights, and stays aboard once it has stepped onto + * their ship. Wounds, blood and everything else about the body carry on. A convict who is fleeing, + * hiding, down, stunned or cuffed won't talk. * - Left alone: when a bounty on a free convict ends unclaimed, they stay where they are, off the * board for good. * Where they turn up: a planet site (/datum/ambient_site_kind/convict, yellow and red space) or, * rolled once per space ruin per round by SSambient_strays (stranded_lifeboat.dm), a loaded ruin * a crew has docked at. At most one per AMBIENT_CONVICT_SHIPS_PER active crews, and never more than * AMBIENT_CONVICTS_MAX alive. + * + * A talked-down convict is still a /bounty_criminal type: a mob can't change type and stay the same + * body. What reads the posting (the pad, the board, proof of death, pay) leaves it alone, since it has + * none. What reads the type alone still counts it as a bounty body: other criminals never pick it as a + * target, and the core's transporter, bag-fold and contract-pad checks still refuse it while it is alive + * (see the PHASE D CORE REQUEST below). Turrets leave it be: its follower AI has no target finding. */ /// How far a convict sees a crew member coming @@ -37,8 +48,33 @@ #define CONVICT_TALK_COOLDOWN (4 SECONDS) /// The reason a convict's bounty closes when a crew takes them in #define CONVICT_CLOSE_RECRUITED "recruited" - -/// Weakrefs to every escaped convict's body (weakrefs: the bounty body's own Destroy() is not overridden here) +/// Beyond this many tiles (or off the level, or dead) a follower's leader is out of reach +#define CONVICT_FOLLOW_RANGE 12 +/// A leader out of reach this long is lost: the follower waits where it is +#define CONVICT_LOST_TIME (60 SECONDS) +/// Further than this behind its leader, a follower runs to catch up +#define CONVICT_RUN_DISTANCE 4 +/// How long a follower keeps clear of someone who hit it +#define CONVICT_SHY_TIME (10 SECONDS) +/// How close a fight has to be for a follower to back off from it +#define CONVICT_FIGHT_RANGE 5 +/// Between a follower's idle lines aboard, while somebody is near +#define CONVICT_IDLE_LINE_LOW (90 SECONDS) +#define CONVICT_IDLE_LINE_HIGH (180 SECONDS) +/// Contexts a talked-down convict says from the strays file's deckhand section first +#define CONVICT_DECKHAND_CONTEXTS list("talk", "idle", "follow", "wait") + +/// Blackboard: who a talked-down convict follows (null: it stays where it is) +#define BB_CONVICT_LEADER "convict_leader" +/// Blackboard: world.time its leader went out of reach, or null +#define BB_CONVICT_LOST_SINCE "convict_lost_since" +/// Blackboard: whoever last hit it, and the world.time it stops keeping clear of them +#define BB_CONVICT_HIT_BY "convict_hit_by" +#define BB_CONVICT_HIT_UNTIL "convict_hit_until" +/// Blackboard: what it is backing away from now (run_away_from_target clears it) +#define BB_CONVICT_AVOID "convict_avoid" + +/// Weakrefs to every escaped convict's body still on the board (weakrefs: the bounty body's own Destroy() is not overridden here) GLOBAL_LIST_EMPTY(ambient_convicts) // ========================================================================= @@ -62,7 +98,7 @@ GLOBAL_LIST_EMPTY(ambient_convicts) /proc/ambient_live_convicts() . = 0 for(var/datum/weakref/ref as anything in GLOB.ambient_convicts.Copy()) - var/mob/living/basic/bounty_criminal/meek/convict/convict = ref?.resolve() + var/mob/living/carbon/human/npc/bounty_criminal/meek/convict/convict = ref?.resolve() if(QDELETED(convict)) GLOB.ambient_convicts -= ref continue @@ -78,7 +114,8 @@ GLOBAL_LIST_EMPTY(ambient_convicts) /** * A new convict at `where`, on site `site` (the overmap planet or ruin, or null), for a * `placement_kind` (BOUNTY_PLACEMENT_PLANET or _RUIN) site: `record`'s person, or someone new. They - * camp on a planet and look round a ruin. Returns the convict, or null. + * camp on a planet and look round a ruin. One body, wanted back at once, so it is built now rather + * than queued, in its record's face and name. Returns the convict, or null. */ /proc/ambient_spawn_convict(turf/where, obj/structure/overmap/site, placement_kind = BOUNTY_PLACEMENT_PLANET, datum/bounty_record/record) where = get_turf(where) @@ -87,7 +124,11 @@ GLOBAL_LIST_EMPTY(ambient_convicts) record ||= generate_bounty_record(BOUNTY_TIER_PETTY, BOUNTY_ARCHETYPE_MEEK, placement_kind) if(!record) return null - var/mob/living/basic/bounty_criminal/meek/convict/convict = new(where) + var/datum/human_npc_order/order = spawn_human_npc(/mob/living/carbon/human/npc/bounty_criminal/meek/convict, where, look = record, name = record.name, immediate = TRUE) + var/mob/living/carbon/human/npc/bounty_criminal/meek/convict/convict = order?.spawned_ref?.resolve() + qdel(order) + if(QDELETED(convict)) + return null convict.body_setup(record, null) if(site) convict.body_set_site(site) @@ -167,7 +208,7 @@ GLOBAL_LIST_EMPTY(ambient_convicts) if(site.data["taken"] || site.state == AMBIENT_SITE_SPENT) return FALSE var/datum/weakref/convict_ref = site.data["convict"] - var/mob/living/basic/bounty_criminal/meek/convict/convict = convict_ref?.resolve() + var/mob/living/carbon/human/npc/bounty_criminal/meek/convict/convict = convict_ref?.resolve() if(!QDELETED(convict)) return FALSE if(!has_room()) @@ -190,7 +231,24 @@ GLOBAL_LIST_EMPTY(ambient_convicts) // THE CONVICT // ========================================================================= -/mob/living/basic/bounty_criminal/meek/convict +/** + * Prison orange and the escapee's shiv, with the meek criminal's kit (bounty_styles.dm's holdout): the + * little Makarov in a pocket, its spare magazine and the stimpack they bolt on in a fanny pack. They run + * and hide, and only shoot when cornered. Their own name stays on them: no prisoner number. + */ +/datum/outfit/prisoner/bounty_convict + name = "Escaped convict" + l_pocket = /obj/item/gun/ballistic/automatic/pistol + belt = /obj/item/storage/belt/fannypack + belt_contents = list( + /obj/item/ammo_box/magazine/m9mm = 1, + /obj/item/reagent_containers/hypospray/medipen/stimpack = 1, + ) + +/datum/outfit/prisoner/bounty_convict/post_equip(mob/living/carbon/human/prisoner, visuals_only = FALSE) + return + +/mob/living/carbon/human/npc/bounty_criminal/meek/convict name = "escaped convict" desc = "Someone in prison orange, a long way from any prison." /// Weakref to the planet site (/datum/ambient_place/site) that keeps them, if any @@ -205,16 +263,25 @@ GLOBAL_LIST_EMPTY(ambient_convicts) var/convict_next_line = 0 /// REF of a player -> world.time they may talk to them again var/list/convict_talk_cooldowns - -/mob/living/basic/bounty_criminal/meek/convict/Initialize(mapload) + /// Talked down: off the board, going with a crew (the same body, a follower AI) + var/convict_recruited = FALSE + /// Weakref to the ship whose crew took them in + var/datum/weakref/convict_ship_ref + /// They have stepped aboard that ship, and stay aboard from now on + var/convict_aboard = FALSE + /// world.time of their next idle line aboard + var/convict_next_idle_line = 0 + +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/Initialize(mapload, datum/human_npc_order/order) . = ..() GLOB.ambient_convicts += WEAKREF(src) -// Prison orange, wherever they are -/mob/living/basic/bounty_criminal/meek/convict/bounty_outfit() - return /datum/outfit/prisoner +// Prison orange, wherever they are (the human NPC base adds a sealed suit and air, a mask or warm +// clothes on top where the spot needs them) +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/bounty_build_outfit(zone) + return /datum/outfit/prisoner/bounty_convict -/mob/living/basic/bounty_criminal/meek/convict/death(gibbed) +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/death(gibbed) var/was_alive = stat != DEAD . = ..() if(!was_alive) @@ -224,7 +291,7 @@ GLOBAL_LIST_EMPTY(ambient_convicts) site.npc_died(src) /// Their planet site knows they are gone for good (a bounty took them over, or a crew took them in) -/mob/living/basic/bounty_criminal/meek/convict/proc/convict_mark_site_taken() +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_mark_site_taken() var/datum/ambient_place/site/site = convict_site_ref?.resolve() if(!site || QDELETED(site)) return @@ -233,38 +300,63 @@ GLOBAL_LIST_EMPTY(ambient_convicts) // ----- their own lines ----- +/** + * Their lines for `context` from the strays file: the convict section, and once a crew has taken them + * in the deckhand section too (first for its everyday contexts, CONVICT_DECKHAND_CONTEXTS). + */ +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_lines(context) + var/list/sections = list("convict") + if(convict_recruited) + if(context in CONVICT_DECKHAND_CONTEXTS) + sections.Insert(1, "deckhand") + else + sections += "deckhand" + for(var/section in sections) + var/list/lines = ambient_dialogue_lines(AMBIENT_STRINGS_STRAYS, section, context) + if(length(lines)) + return lines + return list() + /// Says a line for `context` from the strays file, now and then; `force` skips the wait. TRUE if they spoke. -/mob/living/basic/bounty_criminal/meek/convict/proc/convict_say(context, force = FALSE) +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_say(context, force = FALSE) if(stat != CONSCIOUS || (!force && world.time < convict_next_line)) return FALSE - var/list/lines = ambient_dialogue_lines(AMBIENT_STRINGS_STRAYS, "convict", context) + var/list/lines = convict_lines(context) if(!length(lines)) return FALSE convict_next_line = world.time + CONVICT_LINE_COOLDOWN INVOKE_ASYNC(src, TYPE_PROC_REF(/atom/movable, say), pick(lines)) return TRUE -// Their own words where the strays file has them (at the camp, cornered, cuffed), the bounty module's otherwise -/mob/living/basic/bounty_criminal/meek/convict/bounty_say(context, list/values, force = FALSE) - if(!length(ambient_dialogue_lines(AMBIENT_STRINGS_STRAYS, "convict", context))) - return ..() +// Their own words where the strays file has them (seen and giving up, at the camp, cornered, cuffed), +// the bounty module's otherwise +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/bounty_say(context, list/values, force = FALSE) + // The human NPC base's surrender bark: theirs is "Don't shoot! I'm not armed." + if(context == HUMAN_NPC_BARK_SURRENDER) + context = "sighted" + if(!length(convict_lines(context))) + return ..(context, values, force) return convict_say(context, force) // ----- being seen ----- -// Each look round for hunters is also a look for crews they have not seen yet -/mob/living/basic/bounty_criminal/meek/convict/ai_look_around() - convict_look_for_crews() +// Each look round for hunters is also a look for crews they have not seen yet. Giving up to one, they +// notice nobody else this look: they are lying there with their hands on their head. +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/ai_look_around() + if(convict_recruited) + return null + if(convict_look_for_crews() || npc_surrendering) + return null return ..() -/// The first time someone of a ship crew comes into view: hands up, and maybe their bounty -/mob/living/basic/bounty_criminal/meek/convict/proc/convict_look_for_crews() - if(world.time < convict_next_look || hidden || !ai_can_act()) - return +/// The first time someone of a ship crew comes into view: they give up, and maybe their bounty. TRUE if they saw a new crew. +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_look_for_crews() + if(convict_recruited || world.time < convict_next_look || hidden || !ai_can_act()) + return FALSE convict_next_look = world.time + CONVICT_LOOK_INTERVAL var/turf/here = get_turf(src) if(!here) - return + return FALSE for(var/mob/living/person in SSspatial_grid.orthogonal_range_search(here, SPATIAL_GRID_CONTENTS_TYPE_CLIENTS, CONVICT_SIGHT_RANGE)) if(!bounty_ai_is_hunter(person)) continue @@ -276,16 +368,21 @@ GLOBAL_LIST_EMPTY(ambient_convicts) continue LAZYADD(convict_seen_by, key) INVOKE_ASYNC(src, PROC_REF(convict_sighted), person, ship) - return + return TRUE + return FALSE -/// `person` of `ship` saw them -/mob/living/basic/bounty_criminal/meek/convict/proc/convict_sighted(mob/living/person, obj/structure/overmap/ship/ship) - if(QDELETED(src) || stat != CONSCIOUS) +/** + * `person` of `ship` saw them. They give up the way a person does (npc_surrender(): whatever weapon is + * in their hands goes in a pocket, "Don't shoot!", tg's *surrender, a real 20 second Paralyze, the cuff + * window), and that crew may get a private bounty on them. If nobody cuffs them before they get up, the + * meek AI carries on: calm, they can be talked to; at someone armed, they run. + */ +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_sighted(mob/living/person, obj/structure/overmap/ship/ship) + if(QDELETED(src) || stat != CONSCIOUS || convict_recruited) return if(!QDELETED(person)) face_atom(person) - manual_emote("puts [p_their()] hands up.") - convict_say("sighted", force = TRUE) + npc_surrender() convict_post_bounty(ship) /** @@ -293,8 +390,8 @@ GLOBAL_LIST_EMPTY(ambient_convicts) * private offer. board_post() rolls a record of its own, so the posting takes theirs instead, and * the card shows who the crew actually saw. Returns the posting, or null. */ -/mob/living/basic/bounty_criminal/meek/convict/proc/convict_post_bounty(obj/structure/overmap/ship/ship) - if(convict_posted || QDELETED(ship) || !record || posting() || stat == DEAD) +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_post_bounty(obj/structure/overmap/ship/ship) + if(convict_posted || convict_recruited || QDELETED(ship) || !record || posting() || stat == DEAD) return null // Inside the board's own rules for private offers: at most BOUNTY_PRIVATE_MAX open, and none during the gap after one ends if(SScriminal_bounties.board_private_count(ship) >= BOUNTY_PRIVATE_MAX || world.time < SScriminal_bounties.board_private_next[WEAKREF(ship)]) @@ -329,15 +426,15 @@ GLOBAL_LIST_EMPTY(ambient_convicts) /** * Their bounty closed. Claimed, the pad has them. Anything else while they are free on their own - * ground (not dead, down, cuffed or aboard a ship): they stay where they are, off the board. + * ground (not dead, in crit, cuffed or aboard a ship): they stay where they are, off the board. */ -/mob/living/basic/bounty_criminal/meek/convict/proc/convict_on_posting_closed(datum/source, reason, obj/structure/overmap/ship/winner) +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_on_posting_closed(datum/source, reason, obj/structure/overmap/ship/winner) SIGNAL_HANDLER UnregisterSignal(source, COMSIG_BOUNTY_POSTING_CLOSED) var/datum/criminal_bounty/posting = source if(reason == BOUNTY_CLOSE_CLAIMED || QDELETED(src) || posting.criminal() != src) return - if(stat == DEAD || downed || is_restrained() || get_ship_from_atom(src)) + if(stat == DEAD || is_downed() || is_restrained() || get_ship_from_atom(src)) return posting.board_detach_criminal() posting_ref = null @@ -345,20 +442,28 @@ GLOBAL_LIST_EMPTY(ambient_convicts) // ----- being talked down ----- -/// Whether they would talk: awake, calm, on their feet, not hidden or cuffed -/mob/living/basic/bounty_criminal/meek/convict/proc/convict_can_talk() - if(stat != CONSCIOUS || hidden || downed || is_restrained() || HAS_TRAIT(src, TRAIT_BOUNTY_REMOVED)) +/// Whether they would talk: awake, calm, on their feet, not hidden, stunned or cuffed, and not taken in already +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_can_talk() + if(convict_recruited || stat != CONSCIOUS || hidden || is_downed() || is_restrained() || HAS_TRAIT(src, TRAIT_BOUNTY_REMOVED)) return FALSE return ai_can_act() && ai_mode == BOUNTY_AI_CALM -/mob/living/basic/bounty_criminal/meek/convict/attack_hand(mob/living/carbon/human/user, list/modifiers) - if(istype(user) && !user.combat_mode && !LAZYACCESS(modifiers, RIGHT_CLICK) && convict_can_talk()) - INVOKE_ASYNC(src, PROC_REF(convict_talk), user) - return TRUE +// An empty hand: the plea while they are wild, follow or stay once a crew has them. Anything else (they +// are down, asleep or on fire) is tg's own help: CPR, shaking them awake, patting them out. +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/attack_hand(mob/living/carbon/human/user, list/modifiers) + if(istype(user) && !user.combat_mode && !LAZYACCESS(modifiers, RIGHT_CLICK)) + if(convict_recruited) + var/obj/structure/overmap/ship/ship = convict_ship() + if(ship && convict_follower_can_talk() && ambient_crew_ship(user) == ship) + INVOKE_ASYNC(src, PROC_REF(convict_crew_menu), user) + return TRUE + else if(convict_can_talk()) + INVOKE_ASYNC(src, PROC_REF(convict_talk), user) + return TRUE return ..() /// A word with `user`, and to a crew member with room aboard, the plea. Sleeps. -/mob/living/basic/bounty_criminal/meek/convict/proc/convict_talk(mob/living/user) +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_talk(mob/living/user) var/key = REF(user) if(LAZYACCESS(convict_talk_cooldowns, key) > world.time) return @@ -384,68 +489,370 @@ GLOBAL_LIST_EMPTY(ambient_convicts) convict_say("refused", force = TRUE) /** - * They go with `leader` to `ship`: a stray with the same name and face takes their place, following - * `leader` (recruit.dm), and their bounty is withdrawn unpaid. Returns the stray, or null. + * They go with `leader` to `ship`, in the same body (defaults 1.9): their bounty is withdrawn unpaid, + * they come off the board for good, their side changes to the people's (FACTION_NEUTRAL, as a player's) + * and their AI to the follower's, set on `leader`. The ship counts them as one of the strays it took this + * round (recruit.dm's limits). Returns them, or null if they can't go now. */ -/mob/living/basic/bounty_criminal/meek/convict/proc/convict_join(mob/living/leader, obj/structure/overmap/ship/ship) - var/turf/here = get_turf(src) - if(!here || QDELETED(ship) || QDELETED(leader)) +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_join(mob/living/leader, obj/structure/overmap/ship/ship) + if(convict_recruited || stat == DEAD || !isturf(loc) || QDELETED(ship) || QDELETED(leader)) return null - var/mob/living/basic/ambient_npc/stray/convict/stray = new(here, list("name" = real_name, "gender" = gender), record) - stray.setDir(dir) - // Their face, carried over at once; build_look() puts the same one back on from the record - stray.icon = icon - stray.icon_state = icon_state - stray.appearance_flags |= KEEP_TOGETHER - stray.copy_overlays(src, cut_old = TRUE) + // Off its posting first, so closing it takes nobody away var/datum/criminal_bounty/posting = posting() if(posting) UnregisterSignal(posting, COMSIG_BOUNTY_POSTING_CLOSED) posting.board_detach_criminal() + posting_ref = null convict_mark_site_taken() + convict_site_ref = null ai_put_out_camp() - // Gone on purpose: no proof of death, nothing to turn in - body_mark_removed() - ADD_TRAIT(src, TRAIT_BOUNTY_REMOVED, BOUNTY_PAD_TRAIT) + ai_end_activity() + // Withdrawn unpaid: the crew who saw them are told, as for any offer that ends posting?.close(CONVICT_CLOSE_RECRUITED) - ambient_offer_recruit(stray) - stray.accept_offer(leader, ship) + convict_leave_board() + convict_recruited = TRUE + convict_ship_ref = WEAKREF(ship) + var/datum/ambient_place/ship/deck = ambient_ship_place(ship) + if(deck) + deck.taken++ + faction = list(FACTION_NEUTRAL) + new /datum/ai_controller/basic_controller/convict_follower(src) + convict_follow(leader) + convict_say("accepted", force = TRUE) log_game("AMBIENT: the escaped convict [real_name] went with the [ship.name], talked down by [key_name(leader)]") - qdel(src) - return stray + return src + +/** + * Takes the bounty body's rules off them, for a convict who is no criminal any more: the sweep + * protection, the teleport and mob-swap block, the body's signal hooks (teleport, polymorph and + * type-change refusals, grudges), any container's teleport block, the leash and the grudge list. Off the + * convict count. Its corpse is an ordinary human NPC's from now on: the corpse sweep may clear it. + */ +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_leave_board() + REMOVE_TRAIT(src, TRAIT_MISSION_FIELD_MOB, BOUNTY_TRAIT) + remove_traits(list(TRAIT_NO_TELEPORT, TRAIT_NOMOBSWAP), BOUNTY_BODY_TRAIT) + qdel(GetComponent(/datum/component/bounty_body)) + body_set_holder(null) + body_set_site(null) + grudge.Cut() + ai_set_mode(BOUNTY_AI_CALM) + GLOB.ambient_convicts -= WEAKREF(src) + npc_corpse_lifetime = HUMAN_NPC_CORPSE_LIFETIME + +// Taken in, nothing they sit in is held back from a teleport any more +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/body_set_holder(atom/movable/holder) + return ..(convict_recruited ? null : holder) + +// Taken in, they let their own crew cuff them +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/body_on_cuff_attempt(mob/living/user) + if(convict_recruited) + return + return ..() // ========================================================================= -// THE CONVICT WHO JOINED A CREW +// THE CONVICT WHO WENT WITH A CREW // ========================================================================= -/// A convict who went with a crew: the same face, a stray now (recruit.dm) -/mob/living/basic/ambient_npc/stray/convict - name = "escaped convict" - desc = "Someone in prison orange who has decided not to go back." - outfit = /datum/outfit/prisoner - dialogue_section = "convict" - random_name = FALSE - /// Who they are (/datum/bounty_record): their face comes from it - var/datum/bounty_record/bounty_record - -/mob/living/basic/ambient_npc/stray/convict/Initialize(mapload, list/identity, datum/bounty_record/from_record) - bounty_record = from_record - return ..(mapload, identity) - -/mob/living/basic/ambient_npc/stray/convict/Destroy() - bounty_record = null - return ..() +/// The ship whose crew took them in, if it is still there +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_ship() + var/obj/structure/overmap/ship/ship = convict_ship_ref?.resolve() + return QDELETED(ship) ? null : ship + +/// That ship's deckhand place (recruit.dm), if any +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_deck() + var/obj/structure/overmap/ship/ship = convict_ship() + return ship ? ambient_ship_place(ship, create = FALSE) : null + +/// Whether `spot` is aboard the ship that took them in +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_on_ship(turf/spot) + var/datum/ambient_place/ship/deck = convict_deck() + return !!deck?.aboard(get_turf(spot)) + +/// Who they follow, or null while they stay where they are +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_leader() + var/mob/living/leader = ai_controller?.blackboard[BB_CONVICT_LEADER] + return QDELETED(leader) ? null : leader + +/// They follow `leader` from now on. TRUE if they will. +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_follow(mob/living/leader) + if(!isliving(leader) || QDELETED(leader) || !istype(ai_controller, /datum/ai_controller/basic_controller/convict_follower)) + return FALSE + ai_controller.set_blackboard_key(BB_CONVICT_LEADER, leader) + ai_controller.clear_blackboard_key(BB_CONVICT_LOST_SINCE) + return TRUE + +/// They stay where they are +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_stay() + ai_controller?.clear_blackboard_key(BB_CONVICT_LEADER) + ai_controller?.clear_blackboard_key(BB_CONVICT_LOST_SINCE) + +/// Their leader has been out of reach too long: they wait where they are for someone of the crew +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_lose_leader() + convict_stay() + convict_say("lost", force = TRUE) -/mob/living/basic/ambient_npc/stray/convict/build_look() - if(QDELETED(src)) +/// Whether `leader` can still be followed: alive, on this level, near enough +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_leader_in_reach(mob/living/leader) + var/turf/there = get_turf(leader) + return !QDELETED(leader) && leader.stat != DEAD && there && isturf(loc) && there.z == z && get_dist(src, there) <= CONVICT_FOLLOW_RANGE + +/// Whether they would answer a crew member: awake and on their feet +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_follower_can_talk() + return stat == CONSCIOUS && !body_is_stunned() + +/// Follow or stay, for `user` of their ship. Sleeps. +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_crew_menu(mob/living/user) + var/key = REF(user) + if(LAZYACCESS(convict_talk_cooldowns, key) > world.time) return - if(bounty_record) - apply_bounty_look(src, bounty_record, /datum/outfit/prisoner) + LAZYSET(convict_talk_cooldowns, key, world.time + CONVICT_TALK_COOLDOWN) + if(!buckled) + face_atom(user) + convict_say("talk", force = TRUE) + var/list/choices = list() + if(convict_leader() == user) + choices["Stay here"] = image(icon = 'icons/hud/radial.dmi', icon_state = "guard") + else + choices["Follow me"] = image(icon = 'icons/hud/radial.dmi', icon_state = "move") + var/choice = show_radial_menu(user, src, choices, require_near = TRUE, tooltips = TRUE, autopick_single_option = FALSE) + if(QDELETED(src) || QDELETED(user) || !convict_follower_can_talk() || ambient_crew_ship(user) != convict_ship()) + return + switch(choice) + if("Follow me") + if(convict_follow(user)) + convict_say("follow", force = TRUE) + if("Stay here") + convict_stay() + convict_say("wait", force = TRUE) + +/// The first time they stand aboard their crew's ship: the line, and they live aboard from now on. TRUE if they just stepped aboard. +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_board_if_aboard() + if(!convict_recruited || convict_aboard || !convict_on_ship(get_turf(src))) + return FALSE + convict_aboard = TRUE + convict_next_idle_line = world.time + rand(CONVICT_IDLE_LINE_LOW, CONVICT_IDLE_LINE_HIGH) + convict_say("aboard", force = TRUE) + var/obj/structure/overmap/ship/ship = convict_ship() + log_game("AMBIENT: the escaped convict [real_name] came aboard the [ship?.name || "ship"]") + return TRUE + +/// Aboard, now and then a word while somebody is near +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_idle_chatter() + if(!convict_aboard || world.time < convict_next_idle_line) + return + convict_next_idle_line = world.time + rand(CONVICT_IDLE_LINE_LOW, CONVICT_IDLE_LINE_HIGH) + var/turf/here = get_turf(src) + if(here && ambient_any_player_near(here, 5)) + convict_say("idle") + +/// Hit by someone of the crew they follow: they stop following and say so +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_hit_by(mob/living/attacker) + if(QDELETED(src) || stat != CONSCIOUS || !isliving(attacker)) return + var/obj/structure/overmap/ship/ship = convict_ship() + if(!ship || ambient_crew_ship(attacker) != ship || !convict_leader()) + return + convict_stay() + convict_say("attacked", force = TRUE) + +/// Where they may take a step of their own: never into lava, a chasm or the like; aboard, never off the ship; never out into no air without a sealed suit, unless they are out in it already +/mob/living/carbon/human/npc/bounty_criminal/meek/convict/proc/convict_may_step(turf/next) + next = get_turf(next) + if(!next) + return TRUE + if(!next.can_cross_safely(src)) + return FALSE + var/turf/here = get_turf(src) + if(convict_aboard && convict_on_ship(here) && !convict_on_ship(next)) + return FALSE + if(!is_atmos_sealed() && convict_airless(next) && !convict_airless(here)) + return FALSE + return TRUE + +/// Whether `spot` has too little air to stand in unsuited (read only: never materialises a planet turf's air) +/proc/convict_airless(turf/spot) + if(!isopenturf(spot)) + return FALSE + var/datum/gas_mixture/air = spot.return_air_readonly() + return isnull(air) || air.return_pressure() < HAZARD_LOW_PRESSURE + +// ========================================================================= +// THE FOLLOWER'S AI +// ========================================================================= + +/** + * A talked-down convict's AI: a human pawn (human_npc_ai_able_to_run(), so it stops while stunned, + * knocked down or out, and in soft crit only crawls, pleads and uses a medipen). It never picks a fight: + * no target finding at all, so turrets read it as harmless. It backs off from whoever hit it and from + * anything fighting it or its leader, and otherwise walks after its leader (running to catch up), by a + * pathfinder that keeps out of hazards and airless ground and, once it is aboard, on the ship. + */ +/datum/ai_controller/basic_controller/convict_follower + ai_movement = /datum/ai_movement/jps/convict_follower + planning_subtrees = list( + /datum/ai_planning_subtree/human_npc_soft_crit, + /datum/ai_planning_subtree/convict_keep_clear, + /datum/ai_planning_subtree/convict_follow, + ) + +/datum/ai_controller/basic_controller/convict_follower/TryPossessPawn(atom/new_pawn) + if(!istype(new_pawn, /mob/living/carbon/human/npc/bounty_criminal/meek/convict)) + return AI_CONTROLLER_INCOMPATIBLE + new_pawn.AddElement(/datum/element/relay_attackers) + RegisterSignal(new_pawn, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_pawn_attacked)) + return ..() + +/datum/ai_controller/basic_controller/convict_follower/UnpossessPawn(destroy) + if(pawn) + UnregisterSignal(pawn, COMSIG_ATOM_WAS_ATTACKED) return ..() +/datum/ai_controller/basic_controller/convict_follower/get_able_to_run() + return human_npc_ai_able_to_run(src) + +/datum/ai_controller/basic_controller/convict_follower/on_stat_changed(mob/living/source, new_stat) + . = ..() + human_npc_ai_stat_changed(src, new_stat) + +/// Someone hit it: it keeps clear of them for a while, and if it was its own crew, it stops following +/datum/ai_controller/basic_controller/convict_follower/proc/on_pawn_attacked(mob/living/source, atom/attacker, attack_flags) + SIGNAL_HANDLER + if(source == attacker || !isliving(attacker) || !(attack_flags & (ATTACKER_DAMAGING_ATTACK | ATTACKER_STAMINA_ATTACK | ATTACKER_SHOVING))) + return + set_blackboard_key(BB_CONVICT_HIT_BY, attacker) + set_blackboard_key(BB_CONVICT_HIT_UNTIL, world.time + CONVICT_SHY_TIME) + INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living/carbon/human/npc/bounty_criminal/meek/convict, convict_hit_by), attacker) + +/// Backs off from a fight near it: whoever hit it lately, or anything set on it or its leader +/datum/ai_planning_subtree/convict_keep_clear + +/datum/ai_planning_subtree/convict_keep_clear/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/human/npc/bounty_criminal/meek/convict/convict = controller.pawn + if(!istype(convict) || convict.stat != CONSCIOUS) + return + var/mob/living/threat = convict_nearest_fight(controller) + if(isnull(threat)) + return + controller.set_blackboard_key(BB_CONVICT_AVOID, threat) + controller.queue_behavior(/datum/ai_behavior/run_away_from_target, BB_CONVICT_AVOID) + return SUBTREE_RETURN_FINISH_PLANNING + +/// The fight `controller`'s pawn should keep clear of, or null +/proc/convict_nearest_fight(datum/ai_controller/controller) + var/mob/living/pawn = controller.pawn + var/mob/living/hitter = controller.blackboard[BB_CONVICT_HIT_BY] + if(isliving(hitter) && !QDELETED(hitter) && hitter.stat == CONSCIOUS && world.time < controller.blackboard[BB_CONVICT_HIT_UNTIL] && can_see(pawn, hitter, CONVICT_FIGHT_RANGE)) + return hitter + var/mob/living/leader = controller.blackboard[BB_CONVICT_LEADER] + var/mob/living/closest + var/closest_distance = INFINITY + for(var/mob/living/other in oview(CONVICT_FIGHT_RANGE, pawn)) + var/datum/ai_controller/their_ai = other.ai_controller + if(other.stat != CONSCIOUS || other.client || !istype(their_ai)) + continue + var/atom/their_target = their_ai.blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(isnull(their_target) || (their_target != pawn && their_target != leader)) + continue + var/distance = get_dist(pawn, other) + if(distance < closest_distance) + closest = other + closest_distance = distance + return closest + +/// Walks after its leader, says its line on stepping aboard, and loses a leader out of reach too long +/datum/ai_planning_subtree/convict_follow + +/datum/ai_planning_subtree/convict_follow/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/human/npc/bounty_criminal/meek/convict/convict = controller.pawn + if(!istype(convict) || convict.stat != CONSCIOUS) + return + convict.convict_board_if_aboard() + var/mob/living/leader = controller.blackboard[BB_CONVICT_LEADER] + if(isnull(leader)) + convict.convict_idle_chatter() + return + if(!convict.convict_leader_in_reach(leader)) + var/lost_since = controller.blackboard[BB_CONVICT_LOST_SINCE] + if(!lost_since) + controller.set_blackboard_key(BB_CONVICT_LOST_SINCE, world.time) + else if(world.time - lost_since >= CONVICT_LOST_TIME) + convict.convict_lose_leader() + return + controller.clear_blackboard_key(BB_CONVICT_LOST_SINCE) + var/distance = get_dist(convict, leader) + var/run = distance > CONVICT_RUN_DISTANCE + if((convict.move_intent == MOVE_INTENT_RUN) != run) + convict.toggle_move_intent() + if(distance <= 2) + if(!convict.buckled) + convict.face_atom(leader) + convict.convict_idle_chatter() + return + // Aboard, it stays aboard: it waits for a leader who has gone off the ship + if(convict.convict_aboard && !convict.convict_on_ship(get_turf(leader))) + return + controller.queue_behavior(/datum/ai_behavior/convict_follow, BB_CONVICT_LEADER) + return SUBTREE_RETURN_FINISH_PLANNING + +/// Walks to its leader's side, following them as they move +/datum/ai_behavior/convict_follow + required_distance = 1 + 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/convict_follow/setup(datum/ai_controller/controller, leader_key) + . = ..() + var/atom/leader = controller.blackboard[leader_key] + if(QDELETED(leader)) + return FALSE + set_movement_target(controller, leader) + +/datum/ai_behavior/convict_follow/perform(seconds_per_tick, datum/ai_controller/controller, leader_key) + var/mob/living/leader = controller.blackboard[leader_key] + if(QDELETED(leader) || leader.stat == DEAD) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(get_dist(controller.pawn, leader) <= 1) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + return AI_BEHAVIOR_DELAY + +/// Smart pathing that keeps a follower out of hazards and airless ground, and aboard once it lives there +/datum/ai_movement/jps/convict_follower + +/datum/ai_movement/jps/convict_follower/allowed_to_move(datum/move_loop/has_target/jps/source) + . = ..() + if(!.) + return + var/list/path = source.movement_path + if(!length(path)) + return + var/mob/living/carbon/human/npc/bounty_criminal/meek/convict/convict = source.moving + if(istype(convict) && !convict.convict_may_step(path[1])) + return FALSE + +/* + * PHASE D CORE REQUEST: bounty_blocks_transport(), bounty_holds_living_criminal() and + * bounty_blocks_bag_fold() (bounty_turn_in.dm) and bounty_is_gang_body() (bounty_criminal.dm) go by type + * alone, so a talked-down convict (still a /bounty_criminal type, posting_ref null, convict_recruited TRUE) + * can't ride a transporter beam, be sent on a contract pad or be folded into a bluespace body bag while it + * lives, and other criminals never take it for a target. A shared "is this body wanted on anything" check + * (a posting, or not a recruited convict) in those procs would fix it; this file can't reach them. + */ + #undef CONVICT_SIGHT_RANGE #undef CONVICT_LOOK_INTERVAL #undef CONVICT_LINE_COOLDOWN #undef CONVICT_TALK_COOLDOWN #undef CONVICT_CLOSE_RECRUITED +#undef CONVICT_FOLLOW_RANGE +#undef CONVICT_LOST_TIME +#undef CONVICT_RUN_DISTANCE +#undef CONVICT_SHY_TIME +#undef CONVICT_FIGHT_RANGE +#undef CONVICT_IDLE_LINE_LOW +#undef CONVICT_IDLE_LINE_HIGH +#undef CONVICT_DECKHAND_CONTEXTS +#undef BB_CONVICT_LEADER +#undef BB_CONVICT_LOST_SINCE +#undef BB_CONVICT_HIT_BY +#undef BB_CONVICT_HIT_UNTIL +#undef BB_CONVICT_AVOID diff --git a/voidcrew/modules/bounties/bounty_activities.dm b/voidcrew/modules/bounties/bounty_activities.dm index 894fd6f1026..cda2ba521bc 100644 --- a/voidcrew/modules/bounties/bounty_activities.dm +++ b/voidcrew/modules/bounties/bounty_activities.dm @@ -4,13 +4,14 @@ * Owner: P3 AI. Do not edit this file outside P3. * * What it owns: the idle activities (spec section 3), each with real objects: - * - bar: a stool or chair beside a table or counter, a drink in hand, sipped now and then; + * - bar: a stool or chair beside a table or counter (sat on: a real buckle), a real glass in hand, + * drunk from now and then (a real gulp: the drink goes into them, and they stop once they are tipsy); * - chat: turns at talking with a companion (or whoever is at hand); * - trade: at a trader's counter or a vending machine, haggling out loud; * - explore: three to five things on the site to walk up to and look over; * - loot: lockers and crates (zone loot first) opened, gone through and shut again; * - camp: a small camp made once (a fire, or a fixed lamp where a fire won't burn; a mattress; a - * crate), sat at, with errands; + * crate), sat at on the ground (tg's resting), with errands; * - blend: the routine a trader-outpost fugitive and every one of its decoys share (AR-C6/C7): the * same steps, weights, speed and lines, so nothing in how they act gives the fugitive away. * An activity scans for what it uses once, when it starts (or a blend step starts), never per tick. @@ -18,14 +19,14 @@ * they could not walk to is not picked again while the activity lasts, and at a trader outpost the * blend routine only picks spots on the public floor (L5). * It runs while they are calm; a flight or a fight puts it away, and it is set up again after. - * The decoy's AI (/mob/living/basic/bounty_criminal/decoy: blend, and getting out of the way when + * The decoy's AI (/mob/living/carbon/human/npc/bounty_criminal/decoy: blend, and getting out of the way when * hit) is here too; what a decoy does when accused is P6's. * * The shared vars are declared in bounty_types.dm and nowhere else; a var only P3 uses has an * `ai_` prefix. */ -/mob/living/basic/bounty_criminal +/mob/living/carbon/human/npc/bounty_criminal /// What they are doing now (/datum/bounty_activity), if anything var/datum/bounty_activity/ai_activity /// The kind start_activity() set (BOUNTY_ACTIVITY_*), kept so they go back to it once calm @@ -34,17 +35,17 @@ var/datum/weakref/ai_activity_anchor /// world.time before which an activity that could not be set up is not tried again var/ai_activity_retry_at = 0 - /// The drink in their hand, held in their contents + /// The glass in their hand at the bar var/obj/item/reagent_containers/cup/glass/drinkingglass/ai_drink /// Weakref to the seat they sat down on, so only that one is ever left var/datum/weakref/ai_seat_ref - /// Sitting on the floor + /// Sitting on the floor: lying down by their own choice (tg's resting), which they get up from themselves var/ai_crouching = FALSE /// Weakrefs to the camp they made: the fire or lamp, the mattress, the crate var/list/ai_camp /// The mattress and crate were made; only the fire is ever made again var/ai_camp_made = FALSE - /// Glasses left on tables at the bar; past BOUNTY_BAR_GLASSES_MAX the glass just goes (M4) + /// Glasses left on tables at the bar; past BOUNTY_BAR_GLASSES_MAX a finished glass just goes (M4) var/ai_glasses_left = 0 /// Spots they could not walk to (turf = TRUE), not picked again until the activity changes (L5) var/list/ai_failed_spots @@ -57,7 +58,7 @@ * null to find one nearby. BOUNTY_ACTIVITY_BLEND also makes them a blended patron. Returns the * activity, or null if nothing could be set up (they stand around and try again later). */ -/mob/living/basic/bounty_criminal/proc/start_activity(kind, atom/anchor) +/mob/living/carbon/human/npc/bounty_criminal/proc/start_activity(kind, atom/anchor) ai_suspend_activity() ai_activity_kind = kind ai_activity_anchor = anchor ? WEAKREF(anchor) : null @@ -73,7 +74,7 @@ return ai_resume_activity() /// Their activity, set up again if it was put away. Falls back to standing around when it can't be set up. -/mob/living/basic/bounty_criminal/proc/ai_resume_activity() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_resume_activity() if(ai_activity) return ai_activity if(!ai_activity_kind || world.time < ai_activity_retry_at) @@ -92,7 +93,7 @@ return activity /// The activity datum for `kind` -/mob/living/basic/bounty_criminal/proc/ai_activity_type(kind) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_activity_type(kind) switch(kind) if(BOUNTY_ACTIVITY_BAR) return /datum/bounty_activity/bar @@ -111,13 +112,13 @@ return /datum/bounty_activity/loiter /// A meek criminal never loots: it looks around instead -/mob/living/basic/bounty_criminal/meek/ai_activity_type(kind) +/mob/living/carbon/human/npc/bounty_criminal/meek/ai_activity_type(kind) if(kind == BOUNTY_ACTIVITY_LOOT) return /datum/bounty_activity/explore return ..() /// Puts their activity away (drink down, up from the seat), keeping its kind to go back to -/mob/living/basic/bounty_criminal/proc/ai_suspend_activity() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_suspend_activity() if(!ai_activity) return var/datum/bounty_activity/old = ai_activity @@ -126,13 +127,13 @@ qdel(old) /// Stops their activity for good -/mob/living/basic/bounty_criminal/proc/ai_end_activity() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_end_activity() ai_activity_kind = null ai_activity_anchor = null ai_suspend_activity() /// One step of their activity, where they stand: arriving the first time, then its business. Returns BOUNTY_STEP_*. -/mob/living/basic/bounty_criminal/proc/ai_activity_step(seconds) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_activity_step(seconds) if(!ai_activity) return BOUNTY_STEP_DONE if(!ai_activity.arrived) @@ -142,8 +143,8 @@ // ===== BLENDING IN ===== -/// A patron now: moves like every other, can't be pulled, and shots aimed at someone else pass through them -/mob/living/basic/bounty_criminal/proc/ai_start_blend() +/// A patron now: walks like every other patron, and does what every other patron does (the blend routine) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_start_blend() blended = TRUE ai_set_pace(BOUNTY_CALM_SPEED) @@ -152,7 +153,7 @@ * (the component's stop_blending(): pulls, containers and the turrets' faction back to normal), so * `blended` and the act never disagree (C1). */ -/mob/living/basic/bounty_criminal/proc/ai_end_blend() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_end_blend() var/datum/component/bounty_outpost_blend/act = GetComponent(/datum/component/bounty_outpost_blend) act?.stop_blending() blended = FALSE @@ -161,8 +162,8 @@ // ===== SEATS, DRINKS, SPOTS ===== -/// Sits on `seat` from its tile -/mob/living/basic/bounty_criminal/proc/ai_sit_on(obj/structure/chair/seat) +/// Sits on `seat` from its tile: buckled to it, as anyone sitting down is +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_sit_on(obj/structure/chair/seat) if(QDELETED(seat)) return FALSE if(buckled == seat) @@ -175,68 +176,98 @@ ai_seat_ref = WEAKREF(seat) return TRUE -/// Sits down on the floor -/mob/living/basic/bounty_criminal/proc/ai_crouch() - if(ai_crouching || buckled) +/// Sits down on the floor: tg's resting, as a player lies down +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_crouch() + if(ai_crouching || buckled || resting) return ai_crouching = TRUE - add_offsets(BOUNTY_AI_TRAIT, y_add = -4) + set_resting(TRUE, silent = TRUE) -/// Up from their seat or the floor. Only a seat they sat on themselves: never out of a bed or a chair someone put them in. -/mob/living/basic/bounty_criminal/proc/ai_stand_up() +/// Up from their seat or the floor. Only a seat they sat on themselves, and only the floor they lay down on themselves: never out of a bed or a chair someone put them in. +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_stand_up() if(ai_crouching) ai_crouching = FALSE - remove_offsets(BOUNTY_AI_TRAIT) + if(resting) + set_resting(FALSE, silent = TRUE) var/obj/structure/chair/seat = ai_seat_ref?.resolve() ai_seat_ref = null if(seat && buckled == seat) seat.unbuckle_mob(src, force = TRUE) -/// A drink in hand, poured for the occasion -/mob/living/basic/bounty_criminal/proc/ai_take_drink() - if(!QDELETED(ai_drink)) +/// A glass of something in hand, poured for them at the bar: a real drinking glass in a free hand. Null with no hand free. +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_take_drink() + if(!QDELETED(ai_drink) && is_holding(ai_drink)) return ai_drink - var/obj/item/reagent_containers/cup/glass/drinkingglass/glass = new(src) - glass.reagents.add_reagent(pick(/datum/reagent/consumable/ethanol/beer, /datum/reagent/consumable/ethanol/whiskey, /datum/reagent/consumable/ethanol/rum), 25) - ai_drink = glass - ai_hand = bounty_ai_update_held(src, ai_hand, glass) - return glass + ai_drink = bounty_ai_pour_drink(src) + return ai_drink -/// A sip; an empty glass gets filled again after a while -/mob/living/basic/bounty_criminal/proc/ai_sip() - if(QDELETED(ai_drink)) - return FALSE - if(!ai_drink.reagents.total_volume) - ai_drink.reagents.add_reagent(/datum/reagent/consumable/ethanol/beer, 25) - visible_message(span_notice("[src] gets another drink."), vision_distance = 5) - else - ai_drink.reagents.remove_all(5) - visible_message(span_notice("[src] takes a sip from [p_their()] glass."), vision_distance = 5) - playsound(src, 'sound/items/drink.ogg', 20, TRUE, -4) - ai_hand = bounty_ai_update_held(src, ai_hand, ai_drink) - return TRUE +/// A gulp from their glass, a real one (the drink goes into them); an empty glass gets filled again after a while. Tipsy, they only nurse it. +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_sip() + return bounty_ai_sip(src, ai_drink) /** * Sets the drink down on `table` if it is right there (on their side of any glass), up to * BOUNTY_BAR_GLASSES_MAX glasses (M4); otherwise, or with no table, it goes. */ -/mob/living/basic/bounty_criminal/proc/ai_put_drink_down(obj/structure/table/table) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_put_drink_down(obj/structure/table/table) var/obj/item/glass = ai_drink ai_drink = null - ai_hand = bounty_ai_update_held(src, ai_hand, null) if(QDELETED(glass)) return - if(stat == CONSCIOUS && ai_glasses_left < BOUNTY_BAR_GLASSES_MAX && !QDELETED(table) && isturf(table.loc) && isturf(loc) && Adjacent(table)) + if(stat == CONSCIOUS && ai_glasses_left < BOUNTY_BAR_GLASSES_MAX && bounty_ai_set_glass_down(src, glass, table)) ai_glasses_left++ - glass.forceMove(table.loc) - glass.pixel_x = rand(-6, 6) - glass.pixel_y = rand(0, 6) - visible_message(span_notice("[src] puts [glass] down on [table]."), vision_distance = 5) return qdel(glass) +/// The drinks a bar patron is poured. The first glass is any of these; another is a beer. +GLOBAL_LIST_INIT(bounty_bar_drinks, list( + /datum/reagent/consumable/ethanol/beer, + /datum/reagent/consumable/ethanol/whiskey, + /datum/reagent/consumable/ethanol/rum, +)) + +/// A fresh glass of something poured into a free hand of `drinker` (a criminal or a companion). Returns it, or null with no hand free. +/proc/bounty_ai_pour_drink(mob/living/carbon/human/drinker) + if(QDELETED(drinker) || !length(drinker.get_empty_held_indexes())) + return null + var/obj/item/reagent_containers/cup/glass/drinkingglass/glass = new(drinker.drop_location()) + glass.reagents.add_reagent(pick(GLOB.bounty_bar_drinks), 25) + if(!drinker.put_in_hands(glass)) + qdel(glass) + return null + return glass + +/** + * A gulp from `glass`: the glass's own drink proc on `drinker` themselves, as a player drinking does, so + * the drink goes into them (and its alcohol is theirs to deal with). Tipsy (BOUNTY_BAR_SOBER_LIMIT), + * they only nurse it. An empty glass gets another beer. + */ +/proc/bounty_ai_sip(mob/living/carbon/human/drinker, obj/item/reagent_containers/cup/glass/glass) + if(QDELETED(glass) || !drinker.is_holding(glass) || drinker.stat != CONSCIOUS) + return FALSE + if(!glass.reagents.total_volume) + glass.reagents.add_reagent(/datum/reagent/consumable/ethanol/beer, 25) + drinker.visible_message(span_notice("[drinker] gets another drink."), vision_distance = 5) + return TRUE + if(drinker.get_drunk_amount() >= BOUNTY_BAR_SOBER_LIMIT) + return FALSE + drinker.visible_message(span_notice("[drinker] takes a sip from [drinker.p_their()] glass."), vision_distance = 5) + glass.attack(drinker, drinker) + return TRUE + +/// Sets `glass` down on `table` from right beside it (on their side of any window), as anyone puts a glass down. Returns TRUE if it is on the table. +/proc/bounty_ai_set_glass_down(mob/living/carbon/human/drinker, obj/item/glass, obj/structure/table/table) + if(QDELETED(table) || !isturf(table.loc) || !isturf(drinker.loc) || !drinker.Adjacent(table) || !drinker.is_holding(glass)) + return FALSE + if(!drinker.transferItemToLoc(glass, table.loc)) + return FALSE + glass.pixel_x = rand(-6, 6) + glass.pixel_y = rand(0, 6) + drinker.visible_message(span_notice("[drinker] puts [glass] down on [table]."), vision_distance = 5) + return TRUE + /// A floor tile they can stand on: not space, lava or a chasm, free, on their site -/mob/living/basic/bounty_criminal/proc/ai_standable(turf/tile) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_standable(turf/tile) if(!isopenturf(tile) || isspaceturf(tile) || isgroundlessturf(tile) || islava(tile) || ischasm(tile)) return FALSE if(tile != loc && tile.is_blocked_turf(source_atom = src)) @@ -244,13 +275,13 @@ return leash_ok(tile) /// Whether an activity may send them to `tile`: not a spot they failed to reach, and on the floor it is kept to (L5) -/mob/living/basic/bounty_criminal/proc/ai_spot_allowed(turf/tile) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_spot_allowed(turf/tile) if(LAZYACCESS(ai_failed_spots, tile)) return FALSE return !ai_allowed_floor || ai_allowed_floor[tile] /// Remembers `tile` as somewhere they could not walk to, for as long as the activity lasts (a few at most) -/mob/living/basic/bounty_criminal/proc/ai_spot_failed(turf/tile) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_spot_failed(turf/tile) if(!isturf(tile)) return LAZYSET(ai_failed_spots, tile, TRUE) @@ -262,7 +293,7 @@ * Right beside it (distance 1), nothing may stand between the tile and the thing (Adjacent(): no * wall, glass or rail), since they will use it from there. */ -/mob/living/basic/bounty_criminal/proc/ai_free_tile_beside(atom/thing, distance = 1) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_free_tile_beside(atom/thing, distance = 1) var/turf/center = get_turf(thing) if(!center) return null @@ -280,7 +311,7 @@ return best /// A random free tile within `radius` of `center`, in the same area, or null -/mob/living/basic/bounty_criminal/proc/ai_random_tile_near(turf/center, radius) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_random_tile_near(turf/center, radius) if(!center) return null var/area/here = get_area(src) @@ -291,7 +322,7 @@ return null /// A table beside `thing`, or null -/mob/living/basic/bounty_criminal/proc/ai_table_beside(atom/thing) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_table_beside(atom/thing) var/turf/center = get_turf(thing) if(!center) return null @@ -305,7 +336,7 @@ * Whether they could sit on `seat`: loose on the floor, nobody on it, on their site. Stools (bar * stools too) have can_buckle off for people; they are sat on with a forced buckle all the same. */ -/mob/living/basic/bounty_criminal/proc/ai_seat_usable(obj/structure/chair/seat) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_seat_usable(obj/structure/chair/seat) if(QDELETED(seat) || !isturf(seat.loc) || istype(seat, /obj/structure/chair/e_chair)) return FALSE if(seat.has_buckled_mobs() && !(src in seat.buckled_mobs)) @@ -316,7 +347,7 @@ return leash_ok(seat.loc) && (seat.loc == loc || ai_spot_allowed(seat.loc)) /// The nearest seat within `range` of `near` they could sit on, beside a table if `needs_table` -/mob/living/basic/bounty_criminal/proc/ai_find_seat(atom/near, range = BOUNTY_ACTIVITY_RANGE, needs_table = TRUE) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_find_seat(atom/near, range = BOUNTY_ACTIVITY_RANGE, needs_table = TRUE) var/turf/center = get_turf(near) || get_turf(src) if(!center) return null @@ -332,7 +363,7 @@ return best /// The nearest table within `range` of `near` with room to stand at, or null -/mob/living/basic/bounty_criminal/proc/ai_find_table(atom/near, range = BOUNTY_ACTIVITY_RANGE) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_find_table(atom/near, range = BOUNTY_ACTIVITY_RANGE) var/turf/center = get_turf(near) || get_turf(src) if(!center) return null @@ -348,7 +379,7 @@ return best /// The nearest trader or vending machine within `range`: somewhere to look at goods and haggle -/mob/living/basic/bounty_criminal/proc/ai_find_stall(range = BOUNTY_ACTIVITY_RANGE) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_find_stall(range = BOUNTY_ACTIVITY_RANGE) var/turf/center = get_turf(src) if(!center) return null @@ -370,22 +401,22 @@ * Someone to talk to within `range`: their own companions first; otherwise someone at hand who is * awake and not played (a patron, an outpost regular, another blended patron, one of their own faction). */ -/mob/living/basic/bounty_criminal/proc/ai_find_chat_partner(range = BOUNTY_ACTIVITY_RANGE, patrons_only = FALSE) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_find_chat_partner(range = BOUNTY_ACTIVITY_RANGE, patrons_only = FALSE) var/turf/here = get_turf(src) if(!here) return null if(!patrons_only) - for(var/mob/living/basic/bounty_companion/buddy as anything in ai_companions()) + for(var/mob/living/carbon/human/npc/bounty_companion/buddy as anything in ai_companions()) if(buddy.stat == CONSCIOUS && get_dist(src, buddy) <= range) return buddy var/list/options = list() - for(var/mob/living/basic/other in range(range, here)) - if(other == src || other.stat != CONSCIOUS || other.client) + for(var/mob/living/other in range(range, here)) + if(other == src || other.stat != CONSCIOUS || other.client || other.mind) continue if(istype(other, /mob/living/basic/ambient_npc)) options += other - else if(istype(other, /mob/living/basic/bounty_criminal)) - var/mob/living/basic/bounty_criminal/patron = other + else if(istype(other, /mob/living/carbon/human/npc/bounty_criminal)) + var/mob/living/carbon/human/npc/bounty_criminal/patron = other if(patron.blended || !patrons_only) options += other else if(!patrons_only && (other.mob_biotypes & MOB_HUMANOID) && faction_check_atom(other)) @@ -412,7 +443,7 @@ return is_type_in_typecache(thing, interesting) && isturf(thing.loc) && !thing.invisibility /// Three to five things to look at around `anchor`, spread out, or spots on open ground when there is little; as weakrefs -/mob/living/basic/bounty_criminal/proc/ai_find_points_of_interest(atom/anchor) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_find_points_of_interest(atom/anchor) var/turf/center = get_turf(anchor) || get_turf(src) . = list() if(!center) @@ -444,7 +475,7 @@ . += WEAKREF(point) /// Whether they could go through `box`: loose, not locked or welded, not outpost property, not a body bag, on their site -/mob/living/basic/bounty_criminal/proc/ai_can_rummage(obj/structure/closet/box) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_can_rummage(obj/structure/closet/box) if(QDELETED(box) || !isturf(box.loc) || box.locked || box.welded) return FALSE if(istype(box, /obj/structure/closet/body_bag) || box.wall_mounted || (box.resistance_flags & INDESTRUCTIBLE)) @@ -452,7 +483,7 @@ return leash_ok(box.loc) /// Up to four containers to go through around `anchor`, zone loot caches first; as weakrefs -/mob/living/basic/bounty_criminal/proc/ai_find_containers(atom/anchor) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_find_containers(atom/anchor) var/turf/center = get_turf(anchor) || get_turf(src) . = list() if(!center) @@ -475,7 +506,7 @@ break /// Shuts `box` after going through it, from right beside it, unless someone is standing in it -/mob/living/basic/bounty_criminal/proc/ai_close_container(obj/structure/closet/box) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_close_container(obj/structure/closet/box) if(QDELETED(box) || !box.opened || !isturf(loc) || !Adjacent(box)) return if(locate(/mob/living) in box.loc) @@ -489,7 +520,7 @@ * again, and one that is gone is replaced. The fire is solid, so no walk, flight or fight takes * anyone through the flames (L4). Returns the fire or lamp, or null. */ -/mob/living/basic/bounty_criminal/proc/ai_make_camp(turf/center) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_make_camp(turf/center) var/atom/fire = ai_camp_fire() if(fire) var/obj/structure/bonfire/bonfire = fire @@ -528,7 +559,7 @@ return fire /// Their camp's fire or lamp, if it is still there where they put it (one carried off is gone, L4) -/mob/living/basic/bounty_criminal/proc/ai_camp_fire() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_camp_fire() var/atom/movable/fire = ai_camp_piece(/obj/structure/bonfire) || ai_camp_piece(/obj/structure/bounty_camp_lamp) return (fire && isturf(fire.loc)) ? fire : null @@ -550,13 +581,13 @@ light_color = "#ffcc66" /// They are gone: the camp stays as it is, but the fire burns down -/mob/living/basic/bounty_criminal/proc/ai_put_out_camp() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_put_out_camp() var/obj/structure/bonfire/bonfire = ai_camp_piece(/obj/structure/bonfire) if(bonfire?.burning) bonfire.extinguish() /// A piece of their camp of `piece_type`, if it is still there -/mob/living/basic/bounty_criminal/proc/ai_camp_piece(piece_type) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_camp_piece(piece_type) for(var/datum/weakref/ref as anything in ai_camp) var/atom/piece = ref?.resolve() if(!QDELETED(piece) && istype(piece, piece_type)) @@ -564,7 +595,7 @@ return null /// The patron they are talking to answers them, a moment after they spoke -/mob/living/basic/bounty_criminal/proc/ai_get_reply(datum/weakref/partner_ref) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_get_reply(datum/weakref/partner_ref) var/mob/living/partner = partner_ref?.resolve() if(partner && stat == CONSCIOUS && get_dist(src, partner) <= 2) bounty_ai_reply(partner, src) @@ -573,10 +604,10 @@ /proc/bounty_ai_reply(mob/living/partner, mob/living/speaker) if(QDELETED(partner) || partner.stat != CONSCIOUS) return - if(istype(partner, /mob/living/basic/bounty_companion)) + if(istype(partner, /mob/living/carbon/human/npc/bounty_companion)) partner.face_atom(speaker) INVOKE_ASYNC(partner, TYPE_PROC_REF(/mob/living, bounty_say), "companion_reply") - else if(istype(partner, /mob/living/basic/bounty_criminal)) + else if(istype(partner, /mob/living/carbon/human/npc/bounty_criminal)) partner.face_atom(speaker) INVOKE_ASYNC(partner, TYPE_PROC_REF(/mob/living, bounty_say), "idle_chat") @@ -586,7 +617,7 @@ /datum/ai_planning_subtree/bounty_activity /datum/ai_planning_subtree/bounty_activity/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn if(!istype(criminal) || criminal.ai_mode != BOUNTY_AI_CALM || criminal.hidden || !criminal.ai_can_act()) return var/datum/bounty_activity/activity = criminal.ai_activity || criminal.ai_resume_activity() @@ -606,11 +637,11 @@ behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION /datum/ai_behavior/bounty_activity/setup(datum/ai_controller/controller) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn return istype(criminal) && !!criminal.ai_activity /datum/ai_behavior/bounty_activity/perform(seconds_per_tick, datum/ai_controller/controller) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn var/datum/bounty_activity/activity = criminal.ai_activity if(!activity || criminal.ai_mode != BOUNTY_AI_CALM) return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED @@ -635,7 +666,7 @@ /datum/bounty_activity /// Short text for the admin panel var/name = "standing around" - var/mob/living/basic/bounty_criminal/doer + var/mob/living/carbon/human/npc/bounty_criminal/doer var/datum/weakref/anchor_ref /// Where they are headed, or null where they are var/turf/spot @@ -646,7 +677,7 @@ /// world.time of the next line var/next_line = 0 -/datum/bounty_activity/New(mob/living/basic/bounty_criminal/new_doer, atom/anchor) +/datum/bounty_activity/New(mob/living/carbon/human/npc/bounty_criminal/new_doer, atom/anchor) . = ..() doer = new_doer anchor_ref = anchor ? WEAKREF(anchor) : null @@ -1276,7 +1307,7 @@ if(prob(step_kind == "chat" ? 70 : 30)) doer.ai_bark("idle_chat") if(step_kind == "chat" && isliving(target)) - addtimer(CALLBACK(doer, TYPE_PROC_REF(/mob/living/basic/bounty_criminal, ai_get_reply), WEAKREF(target)), rand(3, 6) SECONDS, TIMER_DELETE_ME) + addtimer(CALLBACK(doer, TYPE_PROC_REF(/mob/living/carbon/human/npc/bounty_criminal, ai_get_reply), WEAKREF(target)), rand(3, 6) SECONDS, TIMER_DELETE_ME) return BOUNTY_STEP_CONTINUE /// Ends the step: the glass goes with them (never left on the bar, M4), up from the seat @@ -1298,7 +1329,7 @@ * as turf = TRUE), shared for BOUNTY_OUTPOST_FLOOR_CACHE between everyone there; null anywhere else, * or when the outpost has none (a broken load). */ -/proc/bounty_ai_outpost_floor(mob/living/basic/bounty_criminal/patron) +/proc/bounty_ai_outpost_floor(mob/living/carbon/human/npc/bounty_criminal/patron) var/datum/component/bounty_outpost_blend/act = patron?.GetComponent(/datum/component/bounty_outpost_blend) var/obj/structure/overmap/trader_outpost/outpost = act?.outpost_ref?.resolve() if(!istype(outpost)) @@ -1336,22 +1367,25 @@ * this controller is only the default for a decoy made some other way. Every criminal tree carries * bounty_flee_and_calm, so a decoy that runs on any of them runs and then calms down (M3). */ -/mob/living/basic/bounty_criminal/decoy +/mob/living/carbon/human/npc/bounty_criminal/decoy ai_controller = /datum/ai_controller/basic_controller/bounty/criminal/decoy /datum/ai_controller/basic_controller/bounty/criminal/decoy planning_subtrees = list( + /datum/ai_planning_subtree/human_npc_soft_crit, + /datum/ai_planning_subtree/bounty_escape_captivity, + /datum/ai_planning_subtree/human_npc_walk_out, /datum/ai_planning_subtree/bounty_gate, /datum/ai_planning_subtree/bounty_flee_and_calm, /datum/ai_planning_subtree/bounty_activity, ) /// Always a patron -/mob/living/basic/bounty_criminal/decoy/ai_expose() +/mob/living/carbon/human/npc/bounty_criminal/decoy/ai_expose() return /// Made to react (P6, or a decoy no longer blending in): they back away, then go back to their evening -/mob/living/basic/bounty_criminal/decoy/ai_react(mob/living/threat, bark) +/mob/living/carbon/human/npc/bounty_criminal/decoy/ai_react(mob/living/threat, bark) ai_flee_from(threat) /** @@ -1363,7 +1397,7 @@ /datum/ai_planning_subtree/bounty_flee_and_calm /datum/ai_planning_subtree/bounty_flee_and_calm/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn if(!istype(criminal) || criminal.ai_mode != BOUNTY_AI_FLEEING) return var/seen = criminal.ai_sees_threat(BOUNTY_FLEE_DISTANCE) diff --git a/voidcrew/modules/bounties/bounty_admin.dm b/voidcrew/modules/bounties/bounty_admin.dm index 721a17dfc7e..3ba9fa629c4 100644 --- a/voidcrew/modules/bounties/bounty_admin.dm +++ b/voidcrew/modules/bounties/bounty_admin.dm @@ -12,8 +12,7 @@ * * It changes other packages' state only through their procs: * - P1: generate_bounty_record(), make_decoy_record(); - * - P2: spawn_bounty_criminal(), body_apply_cuffs(), body_remove_cuffs(), body_downed_line(), - * body_stand_up(), capture_state(); + * - P2: spawn_bounty_criminal(), capture_state(); * - P3: start_activity(); * - P5: post_criminal_bounty(), close(), relist(), hunt() (forced), print_warrant(), * SScriminal_bounties.board_fast_forward() and @@ -21,8 +20,10 @@ * - P6: the decoy's outpost_become() and the outpost's display name, description and outfit; * - P7: bounty_pool_add(), bounty_pool_remove(), bounty_pool_clear(), the prison's * bounty_admit_record(). - * The one direct write is a criminal's worst_state back to free (force_free()): no package has a - * proc that makes a worst state better, and the admin's "Free" exists to try a full-pay turn-in again. + * A criminal is a real human body (voidcrew/modules/human_npcs/), so the forced capture states are + * tg's own, put on through tg's procs (CR-21): real brute on the chest to just past its crit line, a + * real Paralyze, real handcuffs in the cuff slot, death(), and for "Free" tg's revive(HEAL_ALL) with the + * cuffs taken off and every stun ended. No stand-in states; the pad reads them as it reads anyone's. * * Everything goes through /datum/bounty_admin_panel. The menu procs (menu_*) ask the questions; the * action procs (admin_*) take plain arguments, check the admin again, act and log, so a unit test can @@ -43,6 +44,10 @@ #define BOUNTY_ADMIN_TICK_SECONDS 10 /// How long a forced stun lasts #define BOUNTY_ADMIN_STUN_TIME (30 SECONDS) +/// Most hits "force downed" lands to get a tough body past its crit line (its toughness cuts each one) +#define BOUNTY_ADMIN_DOWN_HITS 20 +/// The brute of "force downed"'s first hit, which learns how much of a hit the body takes before the rest are sized +#define BOUNTY_ADMIN_DOWN_PROBE 10 /// Most questions one opening of the panel asks before it closes itself: a guard, never reached by hand #define BOUNTY_ADMIN_MAX_STEPS 200 /// Who the pool's test records say brought them in @@ -205,7 +210,7 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a var/share_choice = ask_list(user, "The decoy shares how much of their look?", "Spawn a decoy", shares) if(!share_choice || !authorized(user)) return - var/mob/living/basic/bounty_criminal/wanted = wanted_ref.resolve() + var/mob/living/carbon/human/npc/bounty_criminal/wanted = wanted_ref.resolve() if(QDELETED(wanted)) refuse(user, "That criminal is gone.") return @@ -353,12 +358,12 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a "Stunned" = BOUNTY_STATE_STUNNED, "Restrained (cuffs on)" = BOUNTY_STATE_RESTRAINED, "Dead" = BOUNTY_STATE_DEAD, - "Free (up, healed, uncuffed, worst state cleared)" = BOUNTY_STATE_FREE, + "Free (alive, healed, uncuffed)" = BOUNTY_STATE_FREE, ) var/state_choice = ask_list(user, "Which state?", "Force a capture state", states) if(!state_choice || !authorized(user)) return - var/mob/living/basic/bounty_criminal/criminal = criminal_ref.resolve() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = criminal_ref.resolve() if(QDELETED(criminal)) refuse(user, "That criminal is gone.") return @@ -454,7 +459,7 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a /// The live criminal the admin picks (never a decoy), or null /datum/bounty_admin_panel/proc/pick_criminal(mob/user, message) var/list/choices = list() - for(var/mob/living/basic/bounty_criminal/criminal as anything in live_criminals()) + for(var/mob/living/carbon/human/npc/bounty_criminal/criminal as anything in live_criminals()) choices[unique_label(choices, criminal_label(criminal))] = WEAKREF(criminal) if(!length(choices)) return refuse(user, "No bounty criminals are about. Spawn one first.") @@ -462,7 +467,7 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a if(!choice || !authorized(user)) return null var/datum/weakref/criminal_ref = choices[choice] - var/mob/living/basic/bounty_criminal/criminal = criminal_ref?.resolve() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = criminal_ref?.resolve() if(QDELETED(criminal)) return refuse(user, "That criminal is gone.") return criminal @@ -500,10 +505,10 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a /// Every live bounty criminal in the world, decoys only if asked for /datum/bounty_admin_panel/proc/live_criminals(include_decoys = FALSE) var/list/found = list() - for(var/mob/living/basic/bounty_criminal/criminal in GLOB.mob_living_list) + for(var/mob/living/carbon/human/npc/bounty_criminal/criminal in GLOB.mob_living_list) if(QDELETED(criminal)) continue - if(!include_decoys && istype(criminal, /mob/living/basic/bounty_criminal/decoy)) + if(!include_decoys && istype(criminal, /mob/living/carbon/human/npc/bounty_criminal/decoy)) continue found += criminal return found @@ -682,7 +687,7 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a // ===== DESCRIPTIONS ===== -/datum/bounty_admin_panel/proc/criminal_name(mob/living/basic/bounty_criminal/criminal) +/datum/bounty_admin_panel/proc/criminal_name(mob/living/carbon/human/npc/bounty_criminal/criminal) if(!criminal) return "nobody" return criminal.record?.name || criminal.real_name || criminal.name @@ -694,7 +699,7 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a var/variant = record.kit || record.style return "[bounty_tier_name(record.tier)] [record.archetype || "criminal"][variant ? " ([variant])" : ""]" -/datum/bounty_admin_panel/proc/criminal_label(mob/living/basic/bounty_criminal/criminal) +/datum/bounty_admin_panel/proc/criminal_label(mob/living/carbon/human/npc/bounty_criminal/criminal) var/area/place = get_area(criminal) return "[criminal_name(criminal)]: [record_kind(criminal.record)], [criminal.capture_state()], in [place?.name || "nowhere"]" @@ -739,7 +744,7 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a var/datum/bounty_record/record = posting.record var/obj/structure/overmap/site = posting.site() var/obj/structure/overmap/ship/private_ship = posting.offered_to() - var/mob/living/basic/bounty_criminal/criminal = posting.criminal() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = posting.criminal() var/location = criminal ? "[ADMIN_VERBOSEJMP(criminal)], [criminal.capture_state()]" : absent_reason(posting) return list( "tier" = bounty_tier_name(record?.tier), @@ -829,7 +834,7 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a record.kit = null if(variant) record.style = variant - var/mob/living/basic/bounty_criminal/criminal = spawn_bounty_criminal(record, where, null) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = spawn_bounty_criminal(record, where, null) if(QDELETED(criminal)) return refuse(user, "The criminal did not spawn.") if(activity) @@ -845,11 +850,11 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a * the alert and it walks out when the posting ends; anywhere else it stands alone, with the black * market's look. A decoy is never linked to a posting through posting_ref (P6). Returns the decoy. */ -/datum/bounty_admin_panel/proc/admin_spawn_decoy(mob/user, mob/living/basic/bounty_criminal/wanted, shared = 1) +/datum/bounty_admin_panel/proc/admin_spawn_decoy(mob/user, mob/living/carbon/human/npc/bounty_criminal/wanted, shared = 1) error = null if(!authorized(user)) return null - if(QDELETED(wanted) || istype(wanted, /mob/living/basic/bounty_criminal/decoy)) + if(QDELETED(wanted) || istype(wanted, /mob/living/carbon/human/npc/bounty_criminal/decoy)) return refuse(user, "Pick a wanted criminal, not a decoy.") if(!wanted.record) return refuse(user, "[criminal_name(wanted)] has no record to copy.") @@ -868,8 +873,12 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a var/datum/criminal_bounty/posting = wanted.posting() if(posting && (posting.placement_kind != BOUNTY_PLACEMENT_TRADER_OUTPOST || posting.outpost_site?.resolve() != outpost)) posting = null - var/datum/npc_spawn_context/context = wanted.bounty_profile_context() - var/mob/living/basic/bounty_criminal/decoy/decoy = spawn_npc_in_zone(/mob/living/basic/bounty_criminal/decoy, decoy_spot(center), context, FALSE) + // One body, wanted back at once: built now rather than queued, in the decoy record's face + var/datum/human_npc_order/order = spawn_human_npc(/mob/living/carbon/human/npc/bounty_criminal/decoy, decoy_spot(center), look = decoy_record, immediate = TRUE) + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = order?.spawned_ref?.resolve() + qdel(order) + if(QDELETED(decoy)) + return refuse(user, "The decoy did not spawn.") decoy.outpost_become(wanted, decoy_record, posting, outpost, bounty_outpost_display_name(outpost), bounty_outpost_display_desc(outpost), bounty_outpost_outfit(outpost)) if(posting) posting.decoys += WEAKREF(decoy) @@ -1012,7 +1021,7 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a return "not spawned yet" /// Moves the admin to `criminal`. Returns TRUE if they moved. -/datum/bounty_admin_panel/proc/admin_jump(mob/user, mob/living/basic/bounty_criminal/criminal, datum/criminal_bounty/posting) +/datum/bounty_admin_panel/proc/admin_jump(mob/user, mob/living/carbon/human/npc/bounty_criminal/criminal, datum/criminal_bounty/posting) error = null if(!authorized(user)) return FALSE @@ -1024,7 +1033,7 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a return TRUE /// Brings `criminal` to the admin's tile, out of any locker or crate. Returns TRUE if they came. -/datum/bounty_admin_panel/proc/admin_bring(mob/user, mob/living/basic/bounty_criminal/criminal, datum/criminal_bounty/posting) +/datum/bounty_admin_panel/proc/admin_bring(mob/user, mob/living/carbon/human/npc/bounty_criminal/criminal, datum/criminal_bounty/posting) error = null if(!authorized(user)) return FALSE @@ -1043,11 +1052,12 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a // ===== CAPTURE STATES ===== /** - * Puts `criminal` in capture state `state` (BOUNTY_STATE_*) through P2's own procs: damage to its - * downed line, a stun, real handcuffs put on by nobody (so nobody lands on its grudge list), death, - * or taking all of that off again. Returns TRUE if capture_state() now reads `state`. + * Puts `criminal` in capture state `state` (BOUNTY_STATE_*) the way tg does it to anyone (CR-21): real + * brute to just past its crit line, a real Paralyze, real handcuffs put on by nobody (so nobody lands on + * its grudge list), death(), or for free a revive with all of that taken off again. Returns TRUE if it + * was done; what capture_state() reads then is reported to the admin. */ -/datum/bounty_admin_panel/proc/admin_force_state(mob/user, mob/living/basic/bounty_criminal/criminal, state) +/datum/bounty_admin_panel/proc/admin_force_state(mob/user, mob/living/carbon/human/npc/bounty_criminal/criminal, state) error = null if(!authorized(user)) return FALSE @@ -1070,7 +1080,7 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a if(!done) return FALSE var/now = criminal.capture_state() - log_action(user, "force [criminal_name(criminal)] to [state] (capture state now [now], worst [criminal.worst_state])") + log_action(user, "force [criminal_name(criminal)] to [state] (capture state now [now])") if(now != state) // Stunned or cuffed while down still reads as downed, as the pad would pay it tell(user, span_notice("[criminal_name(criminal)] is [state], but reads as [now]: [now] comes first.")) @@ -1078,21 +1088,42 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a tell(user, span_notice("[criminal_name(criminal)] is now [now].")) return TRUE -/// Damage straight to P2's downed line, past the mercy rule and armour; P2 downs it from there -/datum/bounty_admin_panel/proc/force_downed(mob/user, mob/living/basic/bounty_criminal/criminal) +/** + * Real brute on its chest until it is just in crit: health a point under its crit line (tg's + * crit_threshold, HEALTH_THRESHOLD_CRIT; the hard-crit line for a body that has no soft crit). No + * armour roll and no wound. How much of a hit it takes (its toughness, a species' weak or tough + * limbs) is learned from a small first hit, and each hit after is sized by what the last one took + * off, so a body that takes more than a person's doesn't overshoot into hard crit. + */ +/datum/bounty_admin_panel/proc/force_downed(mob/user, mob/living/carbon/human/npc/bounty_criminal/criminal) if(criminal.stat == DEAD) return refuse(user, "[criminal_name(criminal)] is dead.") if(criminal.is_downed()) return refuse(user, "[criminal_name(criminal)] is already down.") - var/excess = criminal.health - criminal.body_downed_line() - if(excess > 0) - criminal.adjust_health(excess, TRUE, TRUE) + var/line = (HAS_TRAIT(criminal, TRAIT_NOSOFTCRIT) ? criminal.hardcrit_threshold : criminal.crit_threshold) - 1 + var/taken = 1 + for(var/hit in 1 to BOUNTY_ADMIN_DOWN_HITS) + if(criminal.is_downed() || criminal.stat == DEAD) + break + var/excess = criminal.health - line + if(excess <= 0) + break + var/amount = excess / taken + if(hit == 1) + amount = min(amount, BOUNTY_ADMIN_DOWN_PROBE) + var/before = criminal.health + if(!criminal.apply_damage(amount, BRUTE, BODY_ZONE_CHEST, wound_bonus = CANT_WOUND)) + break + var/dropped = before - criminal.health + if(dropped <= 0) + break + taken = dropped / amount if(!criminal.is_downed()) - return refuse(user, "[criminal_name(criminal)] did not go down ([criminal.health] health, line [criminal.body_downed_line()]).") + return refuse(user, "[criminal_name(criminal)] did not go down ([criminal.health] health).") return TRUE -/// A long paralysis, past stun immunity -/datum/bounty_admin_panel/proc/force_stunned(mob/user, mob/living/basic/bounty_criminal/criminal) +/// A long tg paralysis, past stun immunity +/datum/bounty_admin_panel/proc/force_stunned(mob/user, mob/living/carbon/human/npc/bounty_criminal/criminal) if(criminal.stat == DEAD) return refuse(user, "[criminal_name(criminal)] is dead.") criminal.Paralyze(BOUNTY_ADMIN_STUN_TIME, TRUE) @@ -1100,20 +1131,27 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a return refuse(user, "[criminal_name(criminal)] shrugged the stun off.") return TRUE -/// A new pair of real handcuffs, put on at once through P2's body_apply_cuffs() by nobody: held still, its AI paused, and no one on its grudge list -/datum/bounty_admin_panel/proc/force_restrained(mob/user, mob/living/basic/bounty_criminal/criminal) +/** + * A new pair of real handcuffs in its cuff slot, put on the way tg's apply_cuffs() does it, by nobody: + * no cuffing do_after for it to answer, and no one on its grudge list. It can work at them as at + * anyone's. + */ +/datum/bounty_admin_panel/proc/force_restrained(mob/user, mob/living/carbon/human/npc/bounty_criminal/criminal) if(criminal.stat == DEAD) - return refuse(user, "[criminal_name(criminal)] is dead: the cuffs would only fall off.") + return refuse(user, "[criminal_name(criminal)] is dead.") if(criminal.is_restrained()) - return refuse(user, "[criminal_name(criminal)] is already cuffed.") + return refuse(user, "[criminal_name(criminal)] is already restrained.") + if(!criminal.canBeHandcuffed()) + return refuse(user, "[criminal_name(criminal)] has no wrists to cuff.") var/obj/item/restraints/handcuffs/cuffs = new(criminal.drop_location()) - if(!criminal.body_apply_cuffs(cuffs, null)) + criminal.equip_to_slot(cuffs, ITEM_SLOT_HANDCUFFED) + if(criminal.handcuffed != cuffs) if(!QDELETED(cuffs) && cuffs.loc != criminal) qdel(cuffs) return refuse(user, "The cuffs did not go on [criminal_name(criminal)].") return TRUE -/datum/bounty_admin_panel/proc/force_dead(mob/user, mob/living/basic/bounty_criminal/criminal) +/datum/bounty_admin_panel/proc/force_dead(mob/user, mob/living/carbon/human/npc/bounty_criminal/criminal) if(criminal.stat == DEAD) return refuse(user, "[criminal_name(criminal)] is already dead.") criminal.death() @@ -1122,27 +1160,20 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a return TRUE /** - * Takes every capture state off: the cuffs come off through P2's body_remove_cuffs() (they drop at - * its feet), the surrender ends, stuns end, all damage heals, a downed one gets back up through P2's - * body_stand_up() (a mini-boss rallies, as it would), and the worst state goes back to free, so a - * full-pay turn-in can be tried again. The dead stay dead: a criminal can't be revived. + * Takes every capture state off, through tg (CR-21): revive(HEAL_ALL) heals every hurt (damage, wounds, + * organs, blood, stamina, stuns) and brings a dead one back if its body can live; the cuffs come off + * through tg's uncuff() (they drop at its feet), and any stun left ends, a surrender with it. So a + * full-pay turn-in can be tried again, or a dead criminal brought back for another go. */ -/datum/bounty_admin_panel/proc/force_free(mob/user, mob/living/basic/bounty_criminal/criminal) +/datum/bounty_admin_panel/proc/force_free(mob/user, mob/living/carbon/human/npc/bounty_criminal/criminal) + criminal.revive(HEAL_ALL) if(criminal.stat == DEAD) - return refuse(user, "[criminal_name(criminal)] is dead, and the dead stay dead.") - criminal.body_remove_cuffs(null) - REMOVE_TRAIT(criminal, TRAIT_BOUNTY_SURRENDERED, BOUNTY_TRAIT) - criminal.SetParalyzed(0, TRUE) - criminal.SetKnockdown(0, TRUE) - criminal.SetStun(0, TRUE) - criminal.SetImmobilized(0, TRUE) + return refuse(user, "[criminal_name(criminal)] could not be brought back.") + if(criminal.handcuffed || criminal.legcuffed) + criminal.uncuff() + criminal.SetAllImmobility(0) + criminal.SetSleeping(0) criminal.remove_status_effect(/datum/status_effect/incapacitating/stamcrit) - criminal.fully_heal(HEAL_DAMAGE) - if(criminal.is_downed()) - criminal.body_cancel_recovery() - criminal.body_stand_up() - // No proc makes a worst state better: this is the panel's one direct write (see the file's header) - criminal.worst_state = BOUNTY_STATE_FREE if(criminal.capture_state() != BOUNTY_STATE_FREE) return refuse(user, "[criminal_name(criminal)] still reads as [criminal.capture_state()].") return TRUE @@ -1335,6 +1366,8 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a #undef BOUNTY_ADMIN_MAX_TICKS #undef BOUNTY_ADMIN_TICK_SECONDS #undef BOUNTY_ADMIN_STUN_TIME +#undef BOUNTY_ADMIN_DOWN_HITS +#undef BOUNTY_ADMIN_DOWN_PROBE #undef BOUNTY_ADMIN_MAX_STEPS #undef BOUNTY_ADMIN_TEST_CAPTOR #undef BOUNTY_ADMIN_RELIST_REASON diff --git a/voidcrew/modules/bounties/bounty_ai.dm b/voidcrew/modules/bounties/bounty_ai.dm index 7efeb9db2b1..41ee248a3b8 100644 --- a/voidcrew/modules/bounties/bounty_ai.dm +++ b/voidcrew/modules/bounties/bounty_ai.dm @@ -1,22 +1,30 @@ /** * # Bounty hunting: criminal AI, shared parts * - * Owner: P3 AI. Owns this file, bounty_ai_meek.dm, bounty_ai_normal.dm, bounty_activities.dm, - * bounty_companions.dm, voidcrew/_DEFINES/bounty_ai.dm and the tests in + * Owner: P3 AI. Owns this file, bounty_ai_meek.dm, bounty_ai_normal.dm, bounty_styles.dm, + * bounty_activities.dm, bounty_companions.dm, voidcrew/_DEFINES/bounty_ai.dm and the tests in * voidcrew/modules/unit_tests/voidcrew_bounty_ai.dm. Do not edit this file outside P3. * - * What it owns: the criminal AI's own system (decision 11: never the prison AI). This file holds - * what meek, normal, decoys and companions share: - * - the controller base, which hooks the mob's signals from the controller (a separate datum, so - * nothing here collides with the body's own registrations in bounty_criminal.dm); - * - who they may fight (/datum/targeting_strategy/basic/bounty: the body's may_attack(), never - * their own gang, never a downed hunter), and movement that stays on their site (leash_ok()); - * - the planning gate: nothing is planned while dead, downed, restrained or surrendered, and a - * hidden criminal only keeps still; - * - noticing hunters (a spatial grid lookup of player mobs, once a second, never view()); - * - being attacked, confronted, downed, getting up, cuffed and uncuffed; - * - what they hold in their hand and over their head (drawn in vis_contents, so a look rebuilt - * over their overlays never wipes it), and their pace. + * Criminals and their companions are real human bodies (voidcrew/modules/human_npcs/, phase D of the + * human NPC migration). Their crit, stamina, stuns, cuffs, wounds and death are tg's; this AI only + * chooses what the body does, and the body does it the way a player would: it walks or runs, draws + * a weapon it carries, clicks with it (controller.ai_interact()), throws, shoves, sits on a chair, + * lies down, climbs into a locker, injects a pen it carries. + * + * This file holds what meek, normal, decoys and companions share: + * - the controller base (/datum/ai_controller/basic_controller/bounty), which runs on a human pawn + * (contract 2.4: the human NPC run check, soft crit, the core's bounty_escape_captivity) and hooks + * the pawn's attack signals from the controller (a separate datum, so nothing here collides with the + * body's own registrations in bounty_criminal.dm); + * - who they may fight (/datum/targeting_strategy/basic/bounty: the body's may_attack(), never their + * own gang, never someone who is down), and movement that stays on their site + * (/datum/ai_movement/jps/bounty: the body's own leash rule, body_move_allowed()). There is no body + * Move() override: the leash is the AI's, so anyone can still drag, carry or shove them anywhere; + * - the planning gate: nothing is planned while they are dead, in crit, restrained, stunned or giving + * up, and a hidden criminal only keeps still; + * - noticing hunters (a spatial grid lookup of player mobs, twice a second, never view()); + * - being attacked, confronted, downed, getting up, cuffed and uncuffed, giving up; + * - their pace: a walk or a run (ai_set_pace()), as a person moves. * P4 overrides on_confronted() for bosses in its own files, on the /boss subtype. * * The shared vars are declared in bounty_types.dm and nowhere else; a var only P3 uses has an @@ -25,7 +33,7 @@ // ===== STATE ON THE CRIMINAL ===== -/mob/living/basic/bounty_criminal +/mob/living/carbon/human/npc/bounty_criminal ai_controller = /datum/ai_controller/basic_controller/bounty/criminal /// BOUNTY_AI_CALM, _AWARE, _FLEEING, _FIGHTING or _RETREATING var/ai_mode = BOUNTY_AI_CALM @@ -37,12 +45,8 @@ var/ai_next_notice = 0 /// How far off each person was at the last look around, by REF(), to spot someone running at them var/list/ai_seen_distances - /// The speed they move at now; see ai_set_pace() + /// The pace they asked for last (ai_set_pace()): calm or slower is a walk, anything quicker a run var/ai_pace - /// What they hold in their hand, drawn in their vis_contents - var/obj/effect/abstract/bounty_held/ai_hand - /// What shows over their head (hands up), drawn in their vis_contents - var/obj/effect/abstract/bounty_held/ai_over_head /// A walk that keeps failing: how many times, so they give up on it var/ai_travel_failures = 0 @@ -50,10 +54,10 @@ /// The criminal a mob fights for: the criminal itself, or a companion's criminal. Null for anyone else. /proc/bounty_ai_side_of(atom/movable/thing) - if(istype(thing, /mob/living/basic/bounty_criminal)) + if(istype(thing, /mob/living/carbon/human/npc/bounty_criminal)) return thing - if(istype(thing, /mob/living/basic/bounty_companion)) - var/mob/living/basic/bounty_companion/companion = thing + if(istype(thing, /mob/living/carbon/human/npc/bounty_companion)) + var/mob/living/carbon/human/npc/bounty_companion/companion = thing return companion.ai_leader() return null @@ -61,7 +65,7 @@ /proc/bounty_ai_same_gang(atom/movable/first, atom/movable/second) if(first == second) return TRUE - var/mob/living/basic/bounty_criminal/side = bounty_ai_side_of(first) + var/mob/living/carbon/human/npc/bounty_criminal/side = bounty_ai_side_of(first) return !isnull(side) && side == bounty_ai_side_of(second) /// Whether `person` counts as a hunter: someone played, awake, and not a criminal or one of their friends @@ -70,7 +74,7 @@ return FALSE if(!person.mind && !person.client) return FALSE - if(istype(person, /mob/living/basic/bounty_criminal) || istype(person, /mob/living/basic/bounty_companion)) + if(istype(person, /mob/living/carbon/human/npc/bounty_criminal) || istype(person, /mob/living/carbon/human/npc/bounty_companion)) return FALSE return TRUE @@ -83,10 +87,10 @@ /proc/bounty_ai_may_hit(atom/movable/fighter, atom/target) if(QDELETED(target) || bounty_ai_same_gang(fighter, target)) return FALSE - if(istype(fighter, /mob/living/basic/bounty_criminal)) - var/mob/living/basic/bounty_criminal/criminal = fighter + if(istype(fighter, /mob/living/carbon/human/npc/bounty_criminal)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = fighter return criminal.may_attack(target) - var/mob/living/basic/bounty_criminal/leader = bounty_ai_side_of(fighter) + var/mob/living/carbon/human/npc/bounty_criminal/leader = bounty_ai_side_of(fighter) return !leader || leader.may_attack_scope(target) /// Tiles between `first` and `second` by the turfs they stand on, so a pilot counts as where their mech is (H4); INFINITY across z-levels @@ -150,65 +154,10 @@ continue .++ -// ===== HELD THINGS ===== - -/** - * Something drawn in a mob's hand or over its head. It lives in the mob's vis_contents rather than - * its overlays: the look builder replaces the overlays wholesale, and would wipe it. - */ -/obj/effect/abstract/bounty_held - name = "" - mouse_opacity = MOUSE_OPACITY_TRANSPARENT - appearance_flags = KEEP_APART | RESET_COLOR | RESET_TRANSFORM | PIXEL_SCALE - vis_flags = VIS_INHERIT_PLANE - layer = ABOVE_MOB_LAYER - /// Over the head rather than in the hand - var/over_head = FALSE - /// Drawn with the item's own in-hand sprite, which turns with the holder, rather than its item icon - var/inhand = FALSE - -/** - * Draws `look` in `owner`'s hand (or over their head), reusing `holder`: `look` is an atom, whose - * appearance is copied, or an atom typepath, whose icon is used. An item with an in-hand sprite is - * drawn with that instead, the way a player holds it, so it points the way they face. A null `look` - * takes it away. Returns the holder to keep, or null. - */ -/proc/bounty_ai_update_held(mob/living/owner, obj/effect/abstract/bounty_held/holder, look, over_head = FALSE) - if(isnull(look) || QDELETED(owner)) - if(holder) - owner?.vis_contents -= holder - qdel(holder) - return null - if(!holder) - holder = new(null) - owner.vis_contents += holder - var/list/inhand_look = over_head ? null : npc_inhand_look(look) - if(inhand_look) - holder.appearance = mutable_appearance(inhand_look[1], inhand_look[2]) - else if(ispath(look, /atom)) - var/atom/look_type = look - holder.appearance = mutable_appearance(initial(look_type.icon), initial(look_type.icon_state)) - else if(isatom(look)) - var/atom/look_atom = look - holder.appearance = look_atom.appearance - holder.name = "" - holder.over_head = over_head - holder.inhand = !!inhand_look - holder.mouse_opacity = MOUSE_OPACITY_TRANSPARENT - holder.appearance_flags = KEEP_APART | RESET_COLOR | RESET_TRANSFORM | PIXEL_SCALE - holder.vis_flags = VIS_INHERIT_PLANE - holder.layer = ABOVE_MOB_LAYER - holder.alpha = 255 - holder.dir = SOUTH - holder.pixel_x = 0 - holder.pixel_y = 0 - bounty_ai_place_held(owner, holder) - return holder - /** * The right-hand sprite of `look` (an item or item typepath) as list(file, state), or null when it - * has none: what a player holding it shows. Drawn on an NPC's body it turns with them, as a player's - * does. Used by bounty NPCs and the prison's prisoners and guards. + * has none: what a player holding it shows. The prison's prisoners and guards draw it on their bodies + * (outpost_prison_prisoner.dm); bounty NPCs now hold the real item. */ /proc/npc_inhand_look(look) var/hand_file @@ -225,45 +174,54 @@ return null return list(hand_file, state) -/// Puts a held thing in the hand on the side they face (`facing`, or the way they face now), or over their head -/proc/bounty_ai_place_held(mob/living/owner, obj/effect/abstract/bounty_held/holder, facing) - if(!holder || !owner) - return - // An in-hand sprite is drawn for a whole body: full size, no offset, facing their way - if(holder.inhand) - holder.transform = matrix() - holder.pixel_w = 0 - holder.pixel_z = 0 - holder.dir = facing || owner.dir - return - holder.transform = matrix().Scale(0.6) - if(holder.over_head) - holder.pixel_w = 0 - holder.pixel_z = 22 +/** + * Sets the pace of `body` (a criminal or a companion): calm or slower walks, anything quicker runs, + * through tg's own move intent. A person can't go faster than a run. + */ +/proc/bounty_ai_set_pace(mob/living/carbon/human/body, new_speed) + if(QDELETED(body)) return - var/facing_dir = facing || owner.dir - // The same hand whichever way they face: to the right facing south or east, the left facing north or west - holder.pixel_w = ((facing_dir & WEST) || facing_dir == NORTH) ? -7 : 7 - holder.pixel_z = -4 - -/// What a fighter holds, by whichever of the two types it is -/proc/bounty_ai_hold(mob/living/basic/fighter, look) - if(istype(fighter, /mob/living/basic/bounty_criminal)) - var/mob/living/basic/bounty_criminal/criminal = fighter - criminal.ai_hand = bounty_ai_update_held(criminal, criminal.ai_hand, look) - else if(istype(fighter, /mob/living/basic/bounty_companion)) - var/mob/living/basic/bounty_companion/companion = fighter - companion.ai_hand = bounty_ai_update_held(companion, companion.ai_hand, look) + var/want_run = !isnull(new_speed) && new_speed < BOUNTY_CALM_SPEED + if(want_run != (body.move_intent == MOVE_INTENT_RUN)) + body.toggle_move_intent() + +/** + * A step `mover` (a criminal or a companion) takes by hand, outside the AI's pathing: never off its + * side's leash (the criminal's own body_move_allowed(); a companion its criminal's leash_ok()), into + * lava or a chasm. Returns TRUE if it moved. Every direct step in the bounty AI goes through here. + */ +/proc/bounty_ai_step(mob/living/mover, turf/destination) + if(QDELETED(mover) || !isturf(mover.loc) || !isturf(destination) || get_dist(mover, destination) != 1) + return FALSE + if(islava(destination) || ischasm(destination) || destination.is_blocked_turf(source_atom = mover)) + return FALSE + if(!bounty_ai_step_allowed(mover, destination)) + return FALSE + var/turf/was = mover.loc + mover.Move(destination, get_dir(mover, destination)) + return mover.loc != was + +/// Whether `mover`'s own step onto `destination` keeps to its leash (see bounty_ai_step()) +/proc/bounty_ai_step_allowed(mob/living/mover, turf/destination) + if(istype(mover, /mob/living/carbon/human/npc/bounty_criminal)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = mover + return criminal.body_move_allowed(destination) + var/mob/living/carbon/human/npc/bounty_criminal/leader = bounty_ai_side_of(mover) + if(!leader || leader.leash_ok(destination)) + return TRUE + // Already off its criminal's ground (dragged, carried, woken elsewhere): it may walk about, but never onto danger + return !leader.leash_ok(get_turf(mover)) && destination.can_cross_safely(mover) // ===== THE CRIMINAL'S SIDE OF IT ===== /** - * `user` confronted them: showed the warrant, or accused them. A meek criminal bolts, a normal one - * fights; a boss starts its fight (P4 overrides this on /boss); P6 decides what a decoy does. This - * and P6's exposure (which ends its act, then calls this) are the only ways out of blending in: - * anything else that happens to a blended patron shows nothing (C1). + * `user` confronted them: showed the warrant, accused them, reached for their wrists (the core's cuff + * reaction calls this). A meek criminal bolts, a normal one fights; a boss starts its fight (P4 + * overrides this on /boss); P6 decides what a decoy does. This and P6's exposure (which ends its act, + * then calls this) are the only ways out of blending in: anything else that happens to a blended + * patron shows nothing (C1). */ -/mob/living/basic/bounty_criminal/proc/on_confronted(mob/user) +/mob/living/carbon/human/npc/bounty_criminal/proc/on_confronted(mob/user) if(stat != CONSCIOUS || !isliving(user) || QDELETED(user)) return ai_add_grudge(user) @@ -278,58 +236,58 @@ * What they do about `threat`: a meek criminal runs, a normal one fights, a decoy gets out of the * way. `bark` is the dialogue context to use instead of the usual one, or null. */ -/mob/living/basic/bounty_criminal/proc/ai_react(mob/living/threat, bark) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_react(mob/living/threat, bark) return /// Something about `hunter` made them look twice (armed, cuffs, a warrant, running at them) -/mob/living/basic/bounty_criminal/proc/ai_notice(mob/living/hunter) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_notice(mob/living/hunter) return /// How far they notice hunters -/mob/living/basic/bounty_criminal/proc/ai_notice_range() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_notice_range() return BOUNTY_NORMAL_NOTICE_RANGE /// Their fighting style's key, BOUNTY_STYLE_*, or null for a mob that never fights -/mob/living/basic/bounty_criminal/proc/ai_wanted_style() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_wanted_style() return null /// Whether they carry their style's heavier weapon: every tier above Petty. A 9mm is a 9mm; the tier only picks the gun. -/mob/living/basic/bounty_criminal/proc/ai_heavy_weapon() - return record?.tier != BOUNTY_TIER_PETTY +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_heavy_weapon() + return !isnull(record?.tier) && record.tier != BOUNTY_TIER_PETTY -/// Puts their style on them, once the record says which it is. Cheap when nothing changed. -/mob/living/basic/bounty_criminal/proc/ai_update_style() +/// Puts their style on their AI, once the record says which it is. Cheap when nothing changed. The weapon itself is what they carry (bounty_build_outfit()). +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_update_style() var/key = ai_wanted_style() if(!key || QDELETED(ai_controller) || ai_controller.blackboard[BB_BOUNTY_STYLE] == key) return - bounty_ai_apply_style(src, key, ai_heavy_weapon()) + bounty_ai_apply_style(src, key) /** - * Whether they can do anything at all: alive, on their feet, free and not giving up. Knocked down, - * stunned or in stamina crit (P2's body_is_stunned()) is the cuff window: no blows, no shots, no - * climbing into hiding (H2). + * Whether they can do anything at all: alive, out of crit, on their feet, free and not giving up. + * Knocked down, stunned, in stamina crit or lying there with their hands on their head (tg's + * *surrender) is the cuff window: no blows, no shots, no climbing into hiding (H2). All read from tg. */ -/mob/living/basic/bounty_criminal/proc/ai_can_act() - if(stat != CONSCIOUS || HAS_TRAIT(src, TRAIT_BOUNTY_HELD) || HAS_TRAIT(src, TRAIT_FLOORED) || is_downed() || is_restrained()) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_can_act() + if(stat != CONSCIOUS || npc_surrendering || HAS_TRAIT(src, TRAIT_FLOORED) || is_downed() || is_restrained()) return FALSE return !body_is_stunned() /// Says a line for `context`, never from inside a signal handler's stack. `force` skips the cooldown, for a moment that must be heard. -/mob/living/basic/bounty_criminal/proc/ai_bark(context, force = FALSE) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_bark(context, force = FALSE) INVOKE_ASYNC(src, TYPE_PROC_REF(/mob/living, bounty_say), context, null, force) /// Puts `who` on the list of people they may fight, by P2's rules (the cap, never another criminal or a companion) -/mob/living/basic/bounty_criminal/proc/ai_add_grudge(mob/living/who) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_add_grudge(mob/living/who) if(!isliving(who) || bounty_ai_same_gang(src, who)) return body_add_grudge(who) /// Whether `who` is on their grudge list -/mob/living/basic/bounty_criminal/proc/ai_has_grudge(mob/living/who) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_has_grudge(mob/living/who) return body_has_grudge(who) /// The nearest person on their grudge list they can see (a pilot through their mech), or null -/mob/living/basic/bounty_criminal/proc/ai_nearest_grudge(range = BOUNTY_FIGHT_VISION) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_nearest_grudge(range = BOUNTY_FIGHT_VISION) var/mob/living/best var/best_distance = INFINITY for(var/datum/weakref/ref as anything in grudge) @@ -345,16 +303,16 @@ return best /// Who they are wary of, running from or fighting, if they still exist -/mob/living/basic/bounty_criminal/proc/ai_threat() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_threat() var/mob/living/threat = ai_threat_ref?.resolve() return QDELETED(threat) ? null : threat -/mob/living/basic/bounty_criminal/proc/ai_set_threat(mob/living/threat) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_set_threat(mob/living/threat) ai_threat_ref = threat ? WEAKREF(threat) : null ai_threat_seen_at = world.time /// Whether they can see their threat now (a pilot through their mech); seeing it restarts the clock on losing it -/mob/living/basic/bounty_criminal/proc/ai_sees_threat(range = BOUNTY_FIGHT_VISION) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_sees_threat(range = BOUNTY_FIGHT_VISION) var/mob/living/threat = ai_threat() var/turf/threat_turf = get_turf(threat) if(!threat || threat_turf?.z != z || !bounty_ai_can_see(src, threat, range)) @@ -362,21 +320,20 @@ ai_threat_seen_at = world.time return TRUE -/mob/living/basic/bounty_criminal/proc/ai_set_mode(new_mode) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_set_mode(new_mode) ai_mode = new_mode -/// Moves at `new_speed` from now on. Compared with the speed they have, not a cache: the body sets speed too (L3). -/mob/living/basic/bounty_criminal/proc/ai_set_pace(new_speed) +/// Walks (calm, BOUNTY_CALM_SPEED or slower) or runs (anything quicker) from now on: tg's move intent, nothing faster. +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_set_pace(new_speed) ai_pace = new_speed - if(speed != new_speed) - set_varspeed(new_speed) + bounty_ai_set_pace(src, new_speed) /** * Takes them out of blending in: P6's act ends with it, and they never go back to the routine (a * P6 exposure has already cleared `blended` by the time on_confronted() runs). Not for decoys, who * are always patrons (bounty_activities.dm). */ -/mob/living/basic/bounty_criminal/proc/ai_expose() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_expose() ai_end_blend() /** @@ -385,7 +342,7 @@ * pathfinder's own step check), and never leaves their site. Built once per flight, never per tick * (H1). get_path_to() can't be used here: it sleeps, and planning must not. */ -/mob/living/basic/bounty_criminal/proc/ai_reachable_turfs(radius) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_reachable_turfs(radius) . = list() var/turf/start = get_turf(src) if(!start) @@ -407,10 +364,10 @@ queue += next /// Gets out of the way of `threat` without looking for somewhere to hide (a decoy that stopped blending in) -/mob/living/basic/bounty_criminal/proc/ai_flee_from(mob/living/threat) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_flee_from(mob/living/threat) if(!isliving(threat) || !ai_flee_event(threat, null, seek_hiding = FALSE, quiet = TRUE)) return FALSE - ai_set_pace(BOUNTY_NORMAL_SPEED_MELEE) + ai_set_pace(BOUNTY_RUN_SPEED) return TRUE /** @@ -420,7 +377,7 @@ * blended in (a fugitive at a trader outpost only reacts to a warrant or a blow), fleeing or * fighting. Returns the nearest one found, or null. */ -/mob/living/basic/bounty_criminal/proc/ai_look_around() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_look_around() if(blended || ai_mode == BOUNTY_AI_FLEEING || ai_mode == BOUNTY_AI_FIGHTING) return null if(world.time < ai_next_notice) @@ -459,7 +416,7 @@ * - Friendly fire from their own side of the site with nobody playing it (the pirates they are * aboard with, the site's fauna) is let go (M1). */ -/mob/living/basic/bounty_criminal/proc/ai_attacked_by(mob/living/attacker) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_attacked_by(mob/living/attacker) if(stat == DEAD || blended || !isliving(attacker) || bounty_ai_same_gang(src, attacker)) return if(bounty_ai_friendly_fire(src, attacker)) @@ -476,88 +433,95 @@ ai_react(attacker, null) /// Attacked while already running or fighting -/mob/living/basic/bounty_criminal/proc/ai_attacked_again(mob/living/attacker) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_attacked_again(mob/living/attacker) return /// Someone touched them without attacking: a hider is found by it -/mob/living/basic/bounty_criminal/proc/ai_touched_by(mob/living/toucher) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_touched_by(mob/living/toucher) if(hidden && ai_hide_mode != BOUNTY_HIDE_CONTAINER) ai_reveal(toucher, "touched") /// Someone walked into them: a hider is found by it -/mob/living/basic/bounty_criminal/proc/ai_bumped_by(mob/living/bumper) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_bumped_by(mob/living/bumper) if(hidden && ai_hide_mode != BOUNTY_HIDE_CONTAINER && bounty_ai_is_hunter(bumper)) ai_reveal(bumper, "bumped") -/// They are about to take damage. Inside a signal handler: must not sleep. -/mob/living/basic/bounty_criminal/proc/ai_took_damage(damage, damagetype) +/// They took a hit of `damage` `damagetype`. Inside a signal handler: must not sleep. +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_took_damage(damage, damagetype) return -/// Down at the downed line (P2's COMSIG_BOUNTY_CRIMINAL_DOWNED): they drop everything, a shot or a wind-up included. The body says the line (body_go_down()). -/mob/living/basic/bounty_criminal/proc/ai_on_downed() +/// Into crit (the core's COMSIG_BOUNTY_CRIMINAL_DOWNED): whatever they were doing stops, a shot or a wind-up included. The body says the line. +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_on_downed() ai_let_go() if(!QDELETED(ai_controller)) ai_controller.CancelActions() ai_companions_lose_heart() /** - * Back up after the recovery time (P2's COMSIG_BOUNTY_CRIMINAL_RECOVERED): they run or fight again. + * Out of crit or back up from stamina crit (COMSIG_BOUNTY_CRIMINAL_RECOVERED): they run or fight again. * Blended in, they only go back to the blend routine, like any patron (M2). */ -/mob/living/basic/bounty_criminal/proc/ai_on_recovered() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_on_recovered() if(blended || !ai_can_act()) return ai_react(ai_threat() || ai_nearest_grudge(), "recover") -/// Cuffed (P2's COMSIG_BOUNTY_CRIMINAL_RESTRAINED). The body says the line (body_apply_cuffs()). -/mob/living/basic/bounty_criminal/proc/ai_on_restrained(mob/living/user) +/// Cuffed (COMSIG_BOUNTY_CRIMINAL_RESTRAINED). The body says the line. +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_on_restrained(mob/living/user) ai_let_go() if(!QDELETED(ai_controller)) ai_controller.CancelActions() ai_add_grudge(user) ai_companions_lose_heart() -/// Cuffs off (P2's COMSIG_BOUNTY_CRIMINAL_UNRESTRAINED): if they slipped them, they make a break for it -/mob/living/basic/bounty_criminal/proc/ai_on_unrestrained(mob/living/user) +/// Cuffs off (COMSIG_BOUNTY_CRIMINAL_UNRESTRAINED): if they got out of them themselves, they make a break for it +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_on_unrestrained(mob/living/user) if(user) return - REMOVE_TRAIT(src, TRAIT_BOUNTY_SURRENDERED, BOUNTY_TRAIT) - ai_over_head = bounty_ai_update_held(src, ai_over_head, null) if(!blended && ai_can_act()) ai_react(ai_nearest_grudge(), null) +/// They gave up (tg's *surrender, run by the human NPC base): hands on their head, the fight dropped, their friends lose heart +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_on_surrendered() + visible_message(span_notice("[src] raises [p_their()] hands and gives up.")) + ai_stop_aiming() + ai_suspend_activity() + if(!QDELETED(ai_controller)) + ai_controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + ai_controller.clear_blackboard_key(BB_BOUNTY_DESTINATION) + ai_controller.ai_movement?.stop_moving_towards(ai_controller) + ai_companions_lose_heart() + /// Dead: they let go of everything, and a disguise comes off, so the body looks like them -/mob/living/basic/bounty_criminal/proc/ai_on_death() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_on_death() ai_let_go() - ai_over_head = bounty_ai_update_held(src, ai_over_head, null) /** * Drops everything they are doing: out of hiding (looks restored), no aim, the activity put away - * (drink down, standing up), nothing in their hand, not sprinting. Safe to call at any time, + * (drink down, up from a seat or the floor). What they hold stays in their hands: their gear is locked + * to them (D3), and a person who is down or cuffed can't holster anything. Safe to call at any time, * including while they are being deleted. */ -/mob/living/basic/bounty_criminal/proc/ai_let_go() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_let_go() if(hidden) ai_unhide() ai_stop_aiming() ai_suspend_activity() // Off the floor from a retreat's rest too, not only an activity's (L9) ai_stand_up() - ai_hand = bounty_ai_update_held(src, ai_hand, null) - REMOVE_TRAIT(src, TRAIT_BOUNTY_SPRINTING, BOUNTY_AI_TRAIT) if(!QDELETED(ai_controller)) ai_controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) ai_controller.clear_blackboard_key(BB_BASIC_MOB_FLEE_TARGET) ai_controller.clear_blackboard_key(BB_BOUNTY_HIDE_SPOT) ai_controller.clear_blackboard_key(BB_BOUNTY_DESTINATION) -/// Nothing is after them any more: back to what they were doing, at an easy pace -/mob/living/basic/bounty_criminal/proc/ai_calm_down() +/// Nothing is after them any more: weapon away, back to what they were doing, at a walk +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_calm_down() ai_set_mode(BOUNTY_AI_CALM) ai_set_threat(null) ai_stop_aiming() - REMOVE_TRAIT(src, TRAIT_BOUNTY_SPRINTING, BOUNTY_AI_TRAIT) - ai_hand = bounty_ai_update_held(src, ai_hand, null) + if(ai_can_act() && !HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)) + bounty_ai_holster(src) ai_set_pace(BOUNTY_CALM_SPEED) if(!QDELETED(ai_controller)) ai_controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) @@ -566,7 +530,7 @@ ai_controller.clear_blackboard_key(BB_BOUNTY_DESTINATION) /// A walk the AI set up failed; after a few, they give up on it -/mob/living/basic/bounty_criminal/proc/ai_travel_failed() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_travel_failed() if(++ai_travel_failures < BOUNTY_TRAVEL_GIVE_UP) return ai_travel_failures = 0 @@ -579,39 +543,44 @@ ai_activity?.spot_unreachable() /// Their companions, as mobs that still exist -/mob/living/basic/bounty_criminal/proc/ai_companions() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_companions() . = list() for(var/datum/weakref/ref as anything in companions) - var/mob/living/basic/bounty_companion/buddy = ref?.resolve() + var/mob/living/carbon/human/npc/bounty_companion/buddy = ref?.resolve() if(!QDELETED(buddy)) . += buddy /// Tells every companion to go for `target`: the trooper reinforcement pattern, without a view() scan -/mob/living/basic/bounty_criminal/proc/ai_rally_companions(mob/living/target) - for(var/mob/living/basic/bounty_companion/buddy as anything in ai_companions()) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_rally_companions(mob/living/target) + for(var/mob/living/carbon/human/npc/bounty_companion/buddy as anything in ai_companions()) buddy.ai_join_fight(target) /// Their criminal is down, cuffed or gave up: each companion may run for it -/mob/living/basic/bounty_criminal/proc/ai_companions_lose_heart() - for(var/mob/living/basic/bounty_companion/buddy as anything in ai_companions()) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_companions_lose_heart() + for(var/mob/living/carbon/human/npc/bounty_companion/buddy as anything in ai_companions()) buddy.ai_lose_heart() /// Whether they may fire at `target` now. A meek criminal only fires its cornered volley. -/mob/living/basic/bounty_criminal/proc/ai_may_shoot(atom/target) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_may_shoot(atom/target) return TRUE // ===== TARGETING AND MOVEMENT ===== /** * Who a criminal or a companion may fight: tg's rules (in sight, not in godmode), plus - * bounty_ai_may_hit() (the body's rules on who is fair game, never their own gang), and never a - * downed hunter (BB_TARGET_MINIMUM_STAT is CONSCIOUS, spec C4). A pilot is fought through their - * mech (H4): tg's own mech branch tests the pilot with no sight range and never passes, so a mech - * is judged here, as P4 does for bosses. + * bounty_ai_may_hit() (the body's rules on who is fair game, never their own gang), and never someone + * who is down (BB_TARGET_MINIMUM_STAT is CONSCIOUS: the human NPC base's HUMAN_NPC_SPARES_DOWNED, spec + * C4). A check made without a range uses the sight range (BB_AGGRO_RANGE), as the human NPC base's + * targeting does, and never picks someone in another packed encounter. This is the only gate on whom + * a blow or a shot is aimed at: the body then clicks the target like a player. A pilot is fought + * through their mech (H4): tg's own mech branch tests the pilot with no sight range and never + * passes, so a mech is judged here, as P4 does for bosses. */ /datum/targeting_strategy/basic/bounty /datum/targeting_strategy/basic/bounty/can_attack(mob/living/living_mob, atom/the_target, vision_range) + if(isnull(vision_range)) + vision_range = living_mob.ai_controller?.blackboard[BB_AGGRO_RANGE] || BOUNTY_FIGHT_VISION if(ismecha(the_target)) return mech_attackable(living_mob, the_target, vision_range) . = ..() @@ -620,6 +589,8 @@ var/mob/living/person = the_target if(isliving(person) && ismecha(person.loc)) return FALSE + if(map_region_excludes_turf(map_region_for_turf(get_turf(living_mob)), get_turf(the_target))) + return FALSE return bounty_ai_may_hit(living_mob, the_target) /// A mech in sight with someone awake aboard who is fair game @@ -634,9 +605,11 @@ return FALSE /** - * Smart pathing that stays on their site (AR-E1): a step off the leash (P2's leash_ok(): the site's - * bounds, never a ship, hangar or player outpost) is refused. Paths are bounded by - * AI_MAX_PATH_LENGTH like any jps mover. + * Smart pathing that stays on their site (AR-E1, CR-19): a step the body's leash refuses is never + * taken (body_move_allowed(): onto the site always, off it never, and an off-site body only back + * toward it and never into a hazard or another ship). This is the leash; the body has no Move() + * override, so drags, carries and shoves are tg's. Paths are bounded by AI_MAX_PATH_LENGTH like any + * jps mover. */ /datum/ai_movement/jps/bounty @@ -647,8 +620,8 @@ var/list/path = source.movement_path if(!length(path)) return - var/mob/living/basic/bounty_criminal/leash_holder = bounty_ai_side_of(source.moving) - if(leash_holder && !leash_holder.leash_ok(path[1])) + var/mob/living/mover = source.moving + if(isliving(mover) && !bounty_ai_step_allowed(mover, path[1])) return FALSE /// Now and then a step in some direction, while nothing else is planned: never off the leash, never while hiding, cuffed or down @@ -658,39 +631,36 @@ /datum/idle_behavior/bounty_wander/perform_idle_behavior(seconds_per_tick, datum/ai_controller/controller) . = ..() - var/mob/living/basic/wanderer = controller.pawn - if(!istype(wanderer) || !isturf(wanderer.loc) || wanderer.buckled || wanderer.pulledby || LAZYLEN(wanderer.do_afters)) + var/mob/living/carbon/human/wanderer = controller.pawn + if(!istype(wanderer) || wanderer.stat != CONSCIOUS || !isturf(wanderer.loc) || wanderer.buckled || wanderer.pulledby || wanderer.resting || LAZYLEN(wanderer.do_afters)) return if(!(wanderer.mobility_flags & MOBILITY_MOVE) || !SPT_PROB(walk_chance, seconds_per_tick)) return - if(istype(wanderer, /mob/living/basic/bounty_criminal)) - var/mob/living/basic/bounty_criminal/criminal = wanderer + if(istype(wanderer, /mob/living/carbon/human/npc/bounty_criminal)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = wanderer if(criminal.hidden || !criminal.ai_can_act() || criminal.ai_activity) return - else if(istype(wanderer, /mob/living/basic/bounty_companion)) - var/mob/living/basic/bounty_companion/companion = wanderer - if(companion.ai_gave_up) + else if(istype(wanderer, /mob/living/carbon/human/npc/bounty_companion)) + var/mob/living/carbon/human/npc/bounty_companion/companion = wanderer + if(!companion.ai_can_fight()) return - var/mob/living/basic/bounty_criminal/side = bounty_ai_side_of(wanderer) - var/move_dir = pick(GLOB.alldirs) - var/turf/destination = get_step(wanderer, move_dir) + var/turf/destination = get_step(wanderer, pick(GLOB.alldirs)) if(!destination?.can_cross_safely(wanderer)) return - if(side && !side.leash_ok(destination)) - return - wanderer.Move(destination, move_dir) + bounty_ai_step(wanderer, destination) // ===== PLANNING ===== /** - * First in every criminal's tree. Nothing is planned while they are dead, downed, restrained or - * surrendered; a hidden criminal only keeps still (and checks whether it has been found); one - * shut in something they can't get out of waits. + * First of a criminal's own subtrees, after the human NPC base's soft crit and the core's + * bounty_escape_captivity. Nothing is planned while they can't act (in crit, cuffed, stunned, giving + * up); a hidden criminal only keeps still (and checks whether it has been found); one shut in + * something they can't get out of waits. */ /datum/ai_planning_subtree/bounty_gate /datum/ai_planning_subtree/bounty_gate/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn if(!istype(criminal)) return if(!criminal.ai_can_act()) @@ -706,7 +676,7 @@ /datum/ai_planning_subtree/bounty_notice /datum/ai_planning_subtree/bounty_notice/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn var/mob/living/hunter = criminal.ai_look_around() if(hunter) criminal.ai_notice(hunter) @@ -716,11 +686,11 @@ action_cooldown = 1 SECONDS /datum/ai_behavior/bounty_stay_hidden/setup(datum/ai_controller/controller) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn return istype(criminal) && criminal.hidden /datum/ai_behavior/bounty_stay_hidden/perform(seconds_per_tick, datum/ai_controller/controller) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn if(!criminal.hidden) return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED criminal.ai_hidden_tick() @@ -732,9 +702,9 @@ behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION /datum/ai_behavior/bounty_watch/perform(seconds_per_tick, datum/ai_controller/controller) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn var/mob/living/threat = istype(criminal) ? criminal.ai_threat() : null - if(threat && bounty_ai_dist(criminal, threat) <= BOUNTY_FIGHT_VISION) + if(threat && bounty_ai_dist(criminal, threat) <= BOUNTY_FIGHT_VISION && !criminal.buckled) criminal.face_atom(bounty_ai_target_for(threat)) return AI_BEHAVIOR_DELAY @@ -760,7 +730,7 @@ var/atom/target = controller.blackboard[target_key] var/stuck = !succeeded && controller.consecutive_pathing_attempts > 0 && target && controller.current_movement_target == target . = ..() - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn if(!istype(criminal)) return if(succeeded) @@ -775,74 +745,69 @@ // ===== CONTROLLERS ===== /** - * What every bounty fighter's controller shares, criminals and companions alike: who they may - * fight, smart pathing on the leash, and the signal hooks for styles and for being attacked. The - * hooks are registered by the controller, never by the mob on itself, so they never collide with - * the body's own registrations (a second RegisterSignal from the same datum replaces the first). - * - * Attacks are read from the attack signals themselves (items, hands, mobs, shots that landed, - * thrown things) rather than relay_attackers, whose projectile hook fires even for a shot that - * passes through a blended patron. + * What every bounty fighter's controller shares, criminals and companions alike, on a human pawn + * (contract 2.4): the human NPC base's run check (cuffs and soft crit don't switch the AI off, so it can + * work at its cuffs and crawl), who they may fight, smart pathing on the leash, and the signal hooks for + * being attacked. The hooks are registered by the controller, never by the mob on itself, so they + * never collide with the body's own registrations (a second RegisterSignal from the same datum + * replaces the first). * * Who they fight comes from their grudge list and retaliation only, filtered by the body's * may_attack() and their own gang, so faction is ignored in targeting: a criminal shares * FACTION_NEUTRAL with players until the placement sets otherwise, and would never hit back. + * + * Every planning list starts with the human NPC base's soft-crit subtree, then the core's + * bounty_escape_captivity (it works at its cuffs and breaks grabs, but never climbs out of a locker it + * hid in or off a chair it sat on). */ /datum/ai_controller/basic_controller/bounty blackboard = list( BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/bounty, - BB_TARGET_MINIMUM_STAT = CONSCIOUS, + BB_TARGET_MINIMUM_STAT = HUMAN_NPC_SPARES_DOWNED, + BB_AGGRO_RANGE = BOUNTY_FIGHT_VISION, BB_BASIC_MOB_FLEE_DISTANCE = BOUNTY_FLEE_DISTANCE, BB_ALWAYS_IGNORE_FACTION = TRUE, ) ai_movement = /datum/ai_movement/jps/bounty idle_behavior = /datum/idle_behavior/bounty_wander - /// Whether the mob carries a ranged_attacks component, for a ranged style or the holdout. A tree with a ranged subtree needs it at init. - var/armed = TRUE /datum/ai_controller/basic_controller/bounty/TryPossessPawn(atom/new_pawn) - if(!isbasicmob(new_pawn)) + if(!ishumannpc(new_pawn)) return AI_CONTROLLER_INCOMPATIBLE - var/mob/living/basic/fighter = new_pawn - if(armed) - fighter.AddComponent(/datum/component/ranged_attacks, projectile_type = /obj/projectile/bullet/bounty) - RegisterSignal(fighter, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(on_pre_melee)) - RegisterSignal(fighter, COMSIG_HOSTILE_POST_ATTACKINGTARGET, PROC_REF(on_post_melee)) - RegisterSignal(fighter, COMSIG_BASICMOB_PRE_ATTACK_RANGED, PROC_REF(on_pre_ranged)) - RegisterSignal(fighter, COMSIG_BASICMOB_POST_ATTACK_RANGED, PROC_REF(on_post_ranged)) - RegisterSignal(fighter, COMSIG_PROJECTILE_FIRER_BEFORE_FIRE, PROC_REF(on_fire)) - RegisterSignal(fighter, COMSIG_ATOM_DIR_CHANGE, PROC_REF(on_turned)) + var/mob/living/carbon/human/npc/fighter = new_pawn RegisterSignal(fighter, COMSIG_ATOM_AFTER_ATTACKEDBY, PROC_REF(on_attacked_by_item)) RegisterSignal(fighter, COMSIG_ATOM_ATTACK_HAND, PROC_REF(on_touched)) - // A basic mob's blow reaches attack_animal() too, so this one signal covers both kinds of mob - RegisterSignal(fighter, COMSIG_ATOM_ATTACK_ANIMAL, PROC_REF(on_attacked_by_mob)) + RegisterSignals(fighter, list(COMSIG_ATOM_ATTACK_ANIMAL, COMSIG_ATOM_ATTACK_BASIC_MOB), PROC_REF(on_attacked_by_mob)) RegisterSignal(fighter, COMSIG_ATOM_ATTACK_MECH, PROC_REF(on_attacked_by_mech)) RegisterSignal(fighter, COMSIG_ATOM_BULLET_ACT, PROC_REF(on_shot)) RegisterSignal(fighter, COMSIG_ATOM_HITBY, PROC_REF(on_hit_by_thrown)) - RegisterSignal(fighter, COMSIG_MOB_APPLY_DAMAGE, PROC_REF(on_damage)) + RegisterSignal(fighter, COMSIG_MOB_AFTER_APPLY_DAMAGE, PROC_REF(on_damage)) RegisterSignal(fighter, SIGNAL_ADDTRAIT(TRAIT_FLOORED), PROC_REF(on_floored)) return ..() /datum/ai_controller/basic_controller/bounty/UnpossessPawn(destroy) if(pawn) UnregisterSignal(pawn, list( - COMSIG_HOSTILE_PRE_ATTACKINGTARGET, - COMSIG_HOSTILE_POST_ATTACKINGTARGET, - COMSIG_BASICMOB_PRE_ATTACK_RANGED, - COMSIG_BASICMOB_POST_ATTACK_RANGED, - COMSIG_PROJECTILE_FIRER_BEFORE_FIRE, - COMSIG_ATOM_DIR_CHANGE, COMSIG_ATOM_AFTER_ATTACKEDBY, COMSIG_ATOM_ATTACK_HAND, COMSIG_ATOM_ATTACK_ANIMAL, + COMSIG_ATOM_ATTACK_BASIC_MOB, COMSIG_ATOM_ATTACK_MECH, COMSIG_ATOM_BULLET_ACT, COMSIG_ATOM_HITBY, - COMSIG_MOB_APPLY_DAMAGE, + COMSIG_MOB_AFTER_APPLY_DAMAGE, SIGNAL_ADDTRAIT(TRAIT_FLOORED), )) return ..() +// The basic controller's own check, except that cuffs and soft crit don't stop us (human NPC base, contract 2.4) +/datum/ai_controller/basic_controller/bounty/get_able_to_run() + return human_npc_ai_able_to_run(src) + +/datum/ai_controller/basic_controller/bounty/on_stat_changed(mob/living/source, new_stat) + . = ..() + human_npc_ai_stat_changed(src, new_stat) + /// Whether the pawn may land a blow or a shot on `target` (a companion fights on when its criminal is down, H3) /datum/ai_controller/basic_controller/bounty/proc/may_strike(atom/target) return bounty_ai_may_hit(pawn, target) @@ -859,50 +824,10 @@ /datum/ai_controller/basic_controller/bounty/proc/pawn_touched(mob/living/toucher) return -/// The pawn is about to take `damage` of `damagetype`. Called inside the signal handler: must not sleep. +/// The pawn just took `damage` of `damagetype` (its health already shows it). Inside the signal handler: must not sleep. /datum/ai_controller/basic_controller/bounty/proc/pawn_damaged(damage, damagetype) return -/// Moves what the pawn holds to the hand on the side it is turning to (`facing`) -/datum/ai_controller/basic_controller/bounty/proc/place_held(facing) - return - -/datum/ai_controller/basic_controller/bounty/proc/on_pre_melee(mob/living/basic/source, atom/target, proximity, list/modifiers) - SIGNAL_HANDLER - if(!may_strike(target)) - return COMPONENT_HOSTILE_NO_ATTACK - // Each swing picks one of the weapon's own verbs, as a player's does - bounty_ai_real_weapon(source)?.pick_verb(source) - return NONE - -/datum/ai_controller/basic_controller/bounty/proc/on_post_melee(mob/living/basic/source, atom/target, result) - SIGNAL_HANDLER - if(!result || !isliving(target)) - return - var/datum/bounty_style/style = bounty_ai_style(source) - if(style) - INVOKE_ASYNC(style, TYPE_PROC_REF(/datum/bounty_style, on_melee_hit), source, target) - -/datum/ai_controller/basic_controller/bounty/proc/on_pre_ranged(mob/living/basic/source, atom/target, list/modifiers) - SIGNAL_HANDLER - return may_shoot(target) ? NONE : COMPONENT_CANCEL_RANGED_ATTACK - -/datum/ai_controller/basic_controller/bounty/proc/on_post_ranged(mob/living/basic/source, atom/target, list/modifiers) - SIGNAL_HANDLER - var/datum/bounty_style/style = bounty_ai_style(source) - style?.after_shot(source) - -/datum/ai_controller/basic_controller/bounty/proc/on_fire(mob/living/basic/source, obj/projectile/shot, atom/fired_from, atom/original) - SIGNAL_HANDLER - var/datum/bounty_style/style = bounty_ai_style(source) - style?.prepare_projectile(source, shot) - -/// Sent before the turn lands, so the new direction is passed on rather than read off the mob -/datum/ai_controller/basic_controller/bounty/proc/on_turned(atom/source, old_dir, new_dir) - SIGNAL_HANDLER - if(old_dir != new_dir) - place_held(new_dir) - /datum/ai_controller/basic_controller/bounty/proc/on_attacked_by_item(atom/source, obj/item/weapon, mob/living/attacker, list/modifiers) SIGNAL_HANDLER if(weapon?.force && isliving(attacker)) @@ -919,12 +844,8 @@ /datum/ai_controller/basic_controller/bounty/proc/on_attacked_by_mob(atom/source, mob/living/attacker) SIGNAL_HANDLER - if(!isliving(attacker)) + if(!isliving(attacker) || attacker.melee_damage_upper <= 0) return - if(isbasicmob(attacker)) - var/mob/living/basic/basic_attacker = attacker - if(basic_attacker.melee_damage_upper <= 0) - return INVOKE_ASYNC(src, PROC_REF(pawn_attacked), attacker) /// A mech's blow is its pilot's (H4) @@ -934,7 +855,7 @@ if(attacker) INVOKE_ASYNC(src, PROC_REF(pawn_attacked), attacker) -/// Only a shot that actually hit: one that passed through a blended patron never gets here. A mech's gunfire is its pilot's (H4). +/// A shot that hit them. A mech's gunfire is its pilot's (H4). /datum/ai_controller/basic_controller/bounty/proc/on_shot(atom/source, obj/projectile/shot, def_zone, piercing_hit, blocked) SIGNAL_HANDLER if(!shot.is_hostile_projectile()) @@ -961,8 +882,12 @@ if(isliving(thrower)) INVOKE_ASYNC(src, PROC_REF(pawn_attacked), thrower) +/// Any damage landed: the hit is noted (a wind-up it lands in is fumbled, bounty_styles.dm) /datum/ai_controller/basic_controller/bounty/proc/on_damage(atom/source, damage, damagetype, def_zone, blocked, wound_bonus, exposed_wound_bonus, sharpness, attack_direction, attacking_item) SIGNAL_HANDLER + if(damage <= 0) + return + set_blackboard_key(BB_BOUNTY_HIT_AT, world.time) pawn_damaged(damage, damagetype) /** @@ -971,23 +896,25 @@ * bounty_activities.dm). can_idle stays TRUE, as for every basic mob. */ /datum/ai_controller/basic_controller/bounty/criminal - armed = FALSE planning_subtrees = list( + /datum/ai_planning_subtree/human_npc_soft_crit, + /datum/ai_planning_subtree/bounty_escape_captivity, + /datum/ai_planning_subtree/human_npc_walk_out, /datum/ai_planning_subtree/bounty_gate, /datum/ai_planning_subtree/bounty_activity, ) /datum/ai_controller/basic_controller/bounty/criminal/TryPossessPawn(atom/new_pawn) - if(!istype(new_pawn, /mob/living/basic/bounty_criminal)) + if(!istype(new_pawn, /mob/living/carbon/human/npc/bounty_criminal)) return AI_CONTROLLER_INCOMPATIBLE - var/mob/living/basic/bounty_criminal/criminal = new_pawn - RegisterSignal(criminal, COMSIG_PROJECTILE_PREHIT, PROC_REF(on_prehit)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = new_pawn RegisterSignal(criminal, COMSIG_ATOM_CAN_BE_PULLED, PROC_REF(on_pull_check)) RegisterSignal(criminal, COMSIG_ATOM_BUMPED, PROC_REF(on_bumped)) RegisterSignal(criminal, COMSIG_BOUNTY_CRIMINAL_DOWNED, PROC_REF(on_downed)) RegisterSignal(criminal, COMSIG_BOUNTY_CRIMINAL_RECOVERED, PROC_REF(on_recovered)) RegisterSignal(criminal, COMSIG_BOUNTY_CRIMINAL_RESTRAINED, PROC_REF(on_restrained)) RegisterSignal(criminal, COMSIG_BOUNTY_CRIMINAL_UNRESTRAINED, PROC_REF(on_unrestrained)) + RegisterSignal(criminal, COMSIG_HUMAN_NPC_SURRENDERED, PROC_REF(on_surrendered)) criminal.ai_set_pace(BOUNTY_CALM_SPEED) // Spec section 3: they don't fight the hostiles native to their site. The placement adds the // site's own factions (pirates) on top. @@ -998,100 +925,85 @@ return ..() /datum/ai_controller/basic_controller/bounty/criminal/UnpossessPawn(destroy) - var/mob/living/basic/bounty_criminal/criminal = pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = pawn if(istype(criminal)) UnregisterSignal(criminal, list( - COMSIG_PROJECTILE_PREHIT, COMSIG_ATOM_CAN_BE_PULLED, COMSIG_ATOM_BUMPED, COMSIG_BOUNTY_CRIMINAL_DOWNED, COMSIG_BOUNTY_CRIMINAL_RECOVERED, COMSIG_BOUNTY_CRIMINAL_RESTRAINED, COMSIG_BOUNTY_CRIMINAL_UNRESTRAINED, + COMSIG_HUMAN_NPC_SURRENDERED, )) - // Anything they hold goes, and a disguise comes off: this runs before the mob's contents are deleted. + // A disguise comes off, a hiding place is left: this runs before the mob's contents are deleted. criminal.ai_let_go() - criminal.ai_over_head = bounty_ai_update_held(criminal, criminal.ai_over_head, null) // Their camp stays as it is, but the fire burns down criminal.ai_put_out_camp() return ..() /datum/ai_controller/basic_controller/bounty/criminal/on_stat_changed(mob/living/source, new_stat) . = ..() - var/mob/living/basic/bounty_criminal/criminal = pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = pawn if(istype(criminal) && criminal.stat == DEAD) criminal.ai_on_death() /// No blow from someone giving up, cuffed, down, hidden or passing as a patron /datum/ai_controller/basic_controller/bounty/criminal/may_strike(atom/target) - var/mob/living/basic/bounty_criminal/criminal = pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = pawn if(!istype(criminal) || !criminal.ai_can_act() || criminal.hidden || criminal.blended) return FALSE return ..() /datum/ai_controller/basic_controller/bounty/criminal/may_shoot(atom/target) - var/mob/living/basic/bounty_criminal/criminal = pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = pawn if(!istype(criminal) || !criminal.ai_may_shoot(target)) return FALSE return ..() /datum/ai_controller/basic_controller/bounty/criminal/pawn_attacked(mob/living/attacker) - var/mob/living/basic/bounty_criminal/criminal = pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = pawn if(istype(criminal)) criminal.ai_attacked_by(attacker) /datum/ai_controller/basic_controller/bounty/criminal/pawn_touched(mob/living/toucher) - var/mob/living/basic/bounty_criminal/criminal = pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = pawn if(istype(criminal)) criminal.ai_touched_by(toucher) /datum/ai_controller/basic_controller/bounty/criminal/pawn_damaged(damage, damagetype) - var/mob/living/basic/bounty_criminal/criminal = pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = pawn if(istype(criminal)) criminal.ai_took_damage(damage, damagetype) -/datum/ai_controller/basic_controller/bounty/criminal/place_held(facing) - var/mob/living/basic/bounty_criminal/criminal = pawn - if(istype(criminal)) - bounty_ai_place_held(criminal, criminal.ai_hand, facing) - -/// A shot passes through a blended patron (the fugitive or a decoy) it was not aimed at (AR-C7) -/datum/ai_controller/basic_controller/bounty/criminal/proc/on_prehit(mob/living/basic/bounty_criminal/source, obj/projectile/shot) +/// Pulling at a hider finds them (CR-8: the pull itself is tg's and goes ahead) +/datum/ai_controller/basic_controller/bounty/criminal/proc/on_pull_check(mob/living/carbon/human/npc/bounty_criminal/source, mob/living/user) SIGNAL_HANDLER - if(source.blended && shot.original != source) - return PROJECTILE_INTERRUPT_HIT_PHASE + if(source.hidden && isliving(user)) + INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living/carbon/human/npc/bounty_criminal, ai_reveal), user, "pulled") return NONE -/** - * Pulling at a hider finds them (P2 sends the signal before its own refusal, L1). Who may pull a - * blended patron is P2's rule (body_can_be_dragged(): a downed one can be dragged, AR-C7) and P6's - * act, never decided here. - */ -/datum/ai_controller/basic_controller/bounty/criminal/proc/on_pull_check(mob/living/basic/bounty_criminal/source, mob/living/user) +/datum/ai_controller/basic_controller/bounty/criminal/proc/on_bumped(mob/living/carbon/human/npc/bounty_criminal/source, atom/movable/bumper) SIGNAL_HANDLER - if(source.hidden) - if(isliving(user)) - INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living/basic/bounty_criminal, ai_reveal), user, "pulled") - return COMSIG_ATOM_CANT_PULL - return NONE + if(source.hidden && isliving(bumper)) + INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living/carbon/human/npc/bounty_criminal, ai_bumped_by), bumper) -/datum/ai_controller/basic_controller/bounty/criminal/proc/on_bumped(mob/living/basic/bounty_criminal/source, atom/movable/bumper) +/datum/ai_controller/basic_controller/bounty/criminal/proc/on_downed(mob/living/carbon/human/npc/bounty_criminal/source) SIGNAL_HANDLER - if(source.hidden && isliving(bumper)) - INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living/basic/bounty_criminal, ai_bumped_by), bumper) + INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living/carbon/human/npc/bounty_criminal, ai_on_downed)) -/datum/ai_controller/basic_controller/bounty/criminal/proc/on_downed(mob/living/basic/bounty_criminal/source) +/datum/ai_controller/basic_controller/bounty/criminal/proc/on_recovered(mob/living/carbon/human/npc/bounty_criminal/source) SIGNAL_HANDLER - INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living/basic/bounty_criminal, ai_on_downed)) + INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living/carbon/human/npc/bounty_criminal, ai_on_recovered)) -/datum/ai_controller/basic_controller/bounty/criminal/proc/on_recovered(mob/living/basic/bounty_criminal/source) +/datum/ai_controller/basic_controller/bounty/criminal/proc/on_restrained(mob/living/carbon/human/npc/bounty_criminal/source, mob/living/user) SIGNAL_HANDLER - INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living/basic/bounty_criminal, ai_on_recovered)) + INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living/carbon/human/npc/bounty_criminal, ai_on_restrained), user) -/datum/ai_controller/basic_controller/bounty/criminal/proc/on_restrained(mob/living/basic/bounty_criminal/source, mob/living/user) +/datum/ai_controller/basic_controller/bounty/criminal/proc/on_unrestrained(mob/living/carbon/human/npc/bounty_criminal/source, mob/living/user) SIGNAL_HANDLER - INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living/basic/bounty_criminal, ai_on_restrained), user) + INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living/carbon/human/npc/bounty_criminal, ai_on_unrestrained), user) -/datum/ai_controller/basic_controller/bounty/criminal/proc/on_unrestrained(mob/living/basic/bounty_criminal/source, mob/living/user) +/datum/ai_controller/basic_controller/bounty/criminal/proc/on_surrendered(mob/living/carbon/human/npc/bounty_criminal/source) SIGNAL_HANDLER - INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living/basic/bounty_criminal, ai_on_unrestrained), user) + INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living/carbon/human/npc/bounty_criminal, ai_on_surrendered)) diff --git a/voidcrew/modules/bounties/bounty_ai_human.dm b/voidcrew/modules/bounties/bounty_ai_human.dm new file mode 100644 index 00000000000..ba71cdb90f2 --- /dev/null +++ b/voidcrew/modules/bounties/bounty_ai_human.dm @@ -0,0 +1,210 @@ +/** + * # Bounty hunting: AI pieces for human bodies + * + * Owner: P2 body. Shared by every bounty AI controller (criminals, companions, decoys, mini-bosses, + * the kingpin's crew, the mafia club), whose pawns are real humans (voidcrew/modules/human_npcs/). + * + * - Breaking free (bounty_escape_captivity): tg's escape_captivity, without the cases that would undo + * what a criminal chose to do: it never resists out of a chair it sat down on or a locker it hid in. + * It works at its cuffs (tg's breakout times), breaks grabs by anyone it may fight, and squirms off a + * carrier's shoulders, the way a player does. + * - Self-treatment (N6, bounty_treat_self): hurt, with nothing it can see attacking it, it uses what it + * carries on itself the way a player does: a medipen through the human NPC base's + * human_npc_treat_self ("use in hand"), a bruise pack, ointment, suture or mesh clicked on itself on its + * worst limb (tg's own self-treatment delay). No heal comes from anywhere else. + * - Injectors (bounty_ai_use_injector()): a boss's stimulant at the start of a fight, a meek criminal's + * stimpack as it bolts: a real pen, used on itself. + */ + +// ===== BREAKING FREE ===== + +/datum/ai_planning_subtree/bounty_escape_captivity + /// Blackboard key of the targeting strategy that says whose grab it fights + var/targeting_strategy_key = BB_TARGETING_STRATEGY + +/datum/ai_planning_subtree/bounty_escape_captivity/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/pawn = controller.pawn + if(!iscarbon(pawn) || pawn.stat != CONSCIOUS) + return + if(HAS_TRAIT(pawn, TRAIT_RESTRAINED)) + controller.queue_behavior(/datum/ai_behavior/resist) + return SUBTREE_RETURN_FINISH_PLANNING + var/mob/living/carbon/human/npc/bounty_criminal/criminal = istype(pawn, /mob/living/carbon/human/npc/bounty_criminal) ? pawn : null + // Shut in something it didn't choose to hide in: it gets out the way a person does. + if(!isturf(pawn.loc) && !ismob(pawn.loc) && !criminal?.hidden) + controller.queue_behavior(/datum/ai_behavior/resist) + return SUBTREE_RETURN_FINISH_PLANNING + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(controller.blackboard[targeting_strategy_key]) + var/mob/living/puller = pawn.pulledby + if(puller && puller.grab_state > GRAB_PASSIVE && bounty_ai_fights_holder(pawn, puller, strategy)) + controller.queue_behavior(/datum/ai_behavior/resist) + return SUBTREE_RETURN_FINISH_PLANNING + // Over someone's shoulders, or on a buckle it didn't sit down on, it gets off. + if(ismob(pawn.buckled)) + if(bounty_ai_fights_holder(pawn, pawn.buckled, strategy)) + controller.queue_behavior(/datum/ai_behavior/resist) + return SUBTREE_RETURN_FINISH_PLANNING + else if(pawn.buckled?.buckle_requires_restraints) + controller.queue_behavior(/datum/ai_behavior/resist) + return SUBTREE_RETURN_FINISH_PLANNING + +/// Whether `pawn` fights its way out of `holder`'s hold: someone it may fight, or any player while it is wanted +/proc/bounty_ai_fights_holder(mob/living/pawn, mob/living/holder, datum/targeting_strategy/strategy) + if(!isliving(holder) || holder == pawn || pawn.faction_check_atom(holder)) + return FALSE + if(strategy?.can_attack(pawn, holder)) + return TRUE + return !isnull(holder.mind) || !isnull(holder.client) + +// ===== SELF-TREATMENT (N6) ===== + +/** + * Hurt and unthreatened, it treats itself with what it carries. Put it after the fight subtrees: it + * only plans when nothing before it did, and never with a living hostile in sight that has hurt it. + */ +/datum/ai_planning_subtree/bounty_treat_self + +/datum/ai_planning_subtree/bounty_treat_self/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/pawn = controller.pawn + if(!iscarbon(pawn) || pawn.stat != CONSCIOUS || HAS_TRAIT(pawn, TRAIT_HANDS_BLOCKED) || LAZYLEN(pawn.do_afters)) + return + if(world.time < controller.blackboard[BB_HUMAN_NPC_NEXT_TREAT]) + return + if(pawn.health > pawn.maxHealth * BOUNTY_TREAT_SELF_BELOW) + return + if(controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + return + if(bounty_ai_queue_treat_self(controller)) + return SUBTREE_RETURN_FINISH_PLANNING + +/** + * Queues the best treatment `controller`'s pawn carries for itself: a medipen with something in it, else + * a medical stack that suits its worst hurt. Returns TRUE if it queued one. For a retreat that wants to + * patch up where it sits. + */ +/proc/bounty_ai_queue_treat_self(datum/ai_controller/controller) + var/mob/living/carbon/pawn = controller.pawn + if(!iscarbon(pawn) || world.time < controller.blackboard[BB_HUMAN_NPC_NEXT_TREAT]) + return FALSE + var/obj/item/reagent_containers/hypospray/medipen/pen = bounty_ai_find_medipen(pawn) + if(pen) + controller.set_blackboard_key(BB_HUMAN_NPC_TREAT_ITEM, pen) + controller.queue_behavior(/datum/ai_behavior/human_npc_treat_self, BB_HUMAN_NPC_TREAT_ITEM) + return TRUE + var/obj/item/stack/medical/stack = bounty_ai_find_medical_stack(pawn) + if(stack) + controller.set_blackboard_key(BB_HUMAN_NPC_TREAT_ITEM, stack) + controller.queue_behavior(/datum/ai_behavior/bounty_apply_medical, BB_HUMAN_NPC_TREAT_ITEM) + return TRUE + // Nothing to use: it doesn't look again for a while. + controller.set_blackboard_key(BB_HUMAN_NPC_NEXT_TREAT, world.time + BOUNTY_TREAT_SELF_COOLDOWN) + return FALSE + +/// A medipen it carries with something healing in it (not a stimulant: those are for a fight), that it can reach +/proc/bounty_ai_find_medipen(mob/living/carbon/pawn) + for(var/obj/item/reagent_containers/hypospray/medipen/pen in pawn.get_all_contents_type(/obj/item/reagent_containers/hypospray/medipen)) + if(pen.used_up || !pen.reagents?.total_volume || bounty_ai_is_stimulant(pen)) + continue + if(pawn.is_holding(pen) || human_npc_can_draw(pawn, pen)) + return pen + return null + +/// Whether `pen` is a stimulant (a fight drug), not a treatment +/proc/bounty_ai_is_stimulant(obj/item/reagent_containers/hypospray/medipen/pen) + return istype(pen, /obj/item/reagent_containers/hypospray/medipen/stimpack) || istype(pen, /obj/item/reagent_containers/hypospray/medipen/stimulants) || istype(pen, /obj/item/reagent_containers/hypospray/medipen/methamphetamine) + +/// A medical stack it carries and can reach that treats the kind of hurt it has most of +/proc/bounty_ai_find_medical_stack(mob/living/carbon/pawn) + var/burnt = pawn.getFireLoss() > pawn.getBruteLoss() + var/obj/item/stack/medical/fallback + for(var/obj/item/stack/medical/stack in pawn.get_all_contents_type(/obj/item/stack/medical)) + if(stack.amount <= 0 || !(pawn.is_holding(stack) || human_npc_can_draw(pawn, stack))) + continue + if((burnt && stack.heal_burn > 0) || (!burnt && stack.heal_brute > 0)) + return stack + fallback ||= stack + return fallback + +/// The limb of `pawn` with the most brute and burn on it, or the chest +/proc/bounty_ai_worst_limb(mob/living/carbon/pawn) + var/obj/item/bodypart/worst + var/worst_damage = 0 + for(var/obj/item/bodypart/limb as anything in pawn.bodyparts) + var/damage = limb.brute_dam + limb.burn_dam + if(damage > worst_damage) + worst = limb + worst_damage = damage + return worst?.body_zone || BODY_ZONE_CHEST + +/** + * Applies a medical stack to itself the way a player does: takes it in hand (holstering its gun if both + * hands are full), aims at its worst limb and clicks itself with it. tg's own self-treatment do_after + * runs; the AI waits through it. + */ +/datum/ai_behavior/bounty_apply_medical + action_cooldown = 1 SECONDS + behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/bounty_apply_medical/perform(seconds_per_tick, datum/ai_controller/controller, item_key) + var/mob/living/carbon/pawn = controller.pawn + var/obj/item/stack/medical/stack = controller.blackboard[item_key] + if(!istype(stack) || QDELETED(stack) || human_npc_holding(stack) != pawn || pawn.stat != CONSCIOUS) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(LAZYLEN(pawn.do_afters)) + return AI_BEHAVIOR_DELAY + if(pawn.health > pawn.maxHealth * BOUNTY_TREAT_SELF_BELOW && !pawn.is_holding(stack)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + if(!pawn.is_holding(stack)) + if(!length(pawn.get_empty_held_indexes())) + var/obj/item/gun/gun = human_npc_held_gun(pawn) + var/obj/item/stowed = gun || human_npc_held_melee_weapon(pawn) + if(isnull(stowed) || !stowed.equip_to_best_slot(pawn)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_DELAY + if(!human_npc_take_in_hand(pawn, stack)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_DELAY + // One application per go; it puts the rest away after. + if(controller.blackboard[BB_BOUNTY_TREAT_APPLIED]) + if(!stack.equip_to_best_slot(pawn)) + pawn.dropItemToGround(stack) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + if(!human_npc_ready_item(pawn, stack) || pawn.next_move > world.time) + return AI_BEHAVIOR_DELAY + pawn.zone_selected = bounty_ai_worst_limb(pawn) + controller.set_blackboard_key(BB_BOUNTY_TREAT_APPLIED, TRUE) + controller.ai_interact(target = pawn, combat_mode = FALSE) + return AI_BEHAVIOR_DELAY + +/datum/ai_behavior/bounty_apply_medical/finish_action(datum/ai_controller/controller, succeeded, item_key) + . = ..() + controller.clear_blackboard_key(item_key) + controller.clear_blackboard_key(BB_BOUNTY_TREAT_APPLIED) + controller.set_blackboard_key(BB_HUMAN_NPC_NEXT_TREAT, world.time + BOUNTY_TREAT_SELF_COOLDOWN) + +// ===== INJECTORS ===== + +/** + * Has `controller`'s pawn inject `pen` (a medipen or autoinjector it carries) into itself, with a + * visible emote first: a boss's combat stimulant, a meek criminal's stimpack as it bolts. A real pen and + * a real dose; what it does is the reagent's. Returns TRUE if the injection is queued. + */ +/proc/bounty_ai_use_injector(datum/ai_controller/controller, obj/item/reagent_containers/hypospray/medipen/pen) + var/mob/living/carbon/pawn = controller?.pawn + if(!iscarbon(pawn) || !istype(pen) || QDELETED(pen) || pen.used_up || !pen.reagents?.total_volume) + return FALSE + if(human_npc_holding(pen) != pawn || !(pawn.is_holding(pen) || human_npc_can_draw(pawn, pen))) + return FALSE + pawn.visible_message(span_warning("[pawn] pulls out [pen].")) + controller.set_blackboard_key(BB_HUMAN_NPC_TREAT_ITEM, pen) + controller.queue_behavior(/datum/ai_behavior/human_npc_treat_self, BB_HUMAN_NPC_TREAT_ITEM) + return TRUE + +/// The first unused pen of `pen_type` that `pawn` carries and can reach, or null +/proc/bounty_ai_find_injector(mob/living/carbon/pawn, pen_type = /obj/item/reagent_containers/hypospray/medipen) + for(var/obj/item/reagent_containers/hypospray/medipen/pen in pawn.get_all_contents_type(pen_type)) + if(pen.used_up || !pen.reagents?.total_volume) + continue + if(pawn.is_holding(pen) || human_npc_can_draw(pawn, pen)) + return pen + return null diff --git a/voidcrew/modules/bounties/bounty_ai_meek.dm b/voidcrew/modules/bounties/bounty_ai_meek.dm index b27ae351772..798ace46139 100644 --- a/voidcrew/modules/bounties/bounty_ai_meek.dm +++ b/voidcrew/modules/bounties/bounty_ai_meek.dm @@ -3,26 +3,32 @@ * * Owner: P3 AI. Do not edit this file outside P3. * - * What it owns: the meek archetype (spec section 3, C6): - * - sprinting faster than a runner, getting winded, and getting the sprint back by resting or - * hiding (TRAIT_BOUNTY_SPRINTING while running flat out, for the body's dodge); + * What it owns: the meek archetype (spec section 3, C6, defaults CR-14): + * - running at a person's run, nothing faster. When they bolt they jab the stimpack they carry (a real + * pen, ephedrine and coffee) if they still have it; worn out (tg's own stamina slowdown) they say so. + * Their dodge is a real Slipwire implant (npc_cyberware), the shared dodge arbiter's, which an EMP + * stops; it burns out when they die; * - noticing hunters, and choosing the best hiding place ONCE per flight within - * BOUNTY_MEEK_HIDE_RADIUS, on their site: a locker or crate (in, and shut), a potted plant (they - * take it and pass as it), a dark tile (they stand still, faded); - * - being found (the container opened; bumped, touched, pulled, hit or examined up close; a light - * coming near), which shoves the finder back a tile and sends them running again; + * BOUNTY_MEEK_HIDE_RADIUS, on their site: a locker or crate (in, and shut: a real move into it), a + * potted plant (picked up and held in both hands: tg's own disguise, the plant's tactical + * component, which makes whoever holds it look and read like the plant), a dark tile (they stand + * still, faded); + * - being found (the container opened; bumped, touched, pulled, hit or examined up close; the plant + * knocked out of their hands; a light coming near), which shoves the finder (a real shove) and sends + * them running again; * - a restless tell while hidden a long time, so a search can end; - * - cornered: a shout, a short aim with the holdout (the telegraph), a quick volley, then - * running again. A stamina hit during the aim makes them fumble it; each shot checks they can - * still shoot. - * It never loots and never attacks first. + * - cornered: a shout, the holdout out of their pocket and aimed (the telegraph), then a quick volley + * of real trigger pulls, then the gun goes back in the pocket and they run again. A hit during the + * aim makes them fumble it; each pull checks they can still shoot. + * It never loots and never attacks first. It wears plain clothes for its zone, its tier's armour, the + * holdout and its spare magazine, and the stimpack. * * The shared vars (`hidden` and the rest) are declared in bounty_types.dm and nowhere else; a var * only P3 uses has an `ai_` prefix. The hiding procs sit on the base type so the shared hooks * (attacked, touched, pulled, dead, deleted) can undo them for anyone. */ -/mob/living/basic/bounty_criminal +/mob/living/carbon/human/npc/bounty_criminal /// How they are hidden while `hidden`: BOUNTY_HIDE_CONTAINER, _PLANT or _DARK var/ai_hide_mode /// Weakref to what they hide in or as: the closet, the plant or the turf @@ -37,14 +43,12 @@ var/ai_next_restless = 0 /// world.time they next check whether it is quiet enough to come out var/ai_next_quiet_check = 0 - /// Their own look, kept while they pass as a plant or stand faded in the dark - var/list/ai_disguise_saved - /// Deciseconds of sprint left - var/ai_sprint_left = BOUNTY_MEEK_SPRINT_TIME - /// Out of breath: slow until the sprint is all back + /// Their alpha before they stood faded in the dark + var/ai_saved_alpha + /// Out of breath (tg's stamina slowdown), and said so var/ai_winded = FALSE - /// world.time the sprint was last worked out - var/ai_sprint_checked_at = 0 + /// A fresh flight: they jab their stimpack, if they still have one + var/ai_bolting = FALSE /// world.time this cornering began, or 0 var/ai_cornered_since = 0 /// world.time running away last failed, or 0 @@ -53,29 +57,33 @@ var/ai_holdout_ready_at = 0 /// Aiming the holdout: world.time the shots go off, or 0 var/ai_aim_until = 0 + /// world.time the aim began + var/ai_aim_from = 0 /// Their stamina loss when the aim began: any more at the shot and they fumble it var/ai_aim_stamina = 0 /// Weakref to who they aim at var/datum/weakref/ai_aim_ref - /// Shots of the volley still to fire, and when the next goes + /// Trigger pulls of the volley still to come, and when the next goes var/ai_volley_left = 0 var/ai_next_volley_shot = 0 /// Weakref to who the volley is at var/datum/weakref/ai_volley_ref - /// Set only while a volley shot is being fired, so no other shot gets out - var/ai_firing = FALSE #ifdef UNIT_TESTS /// Unit tests only: turfs that read as dark. The test room is fullbright, so nothing is dark there otherwise. GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) #endif -/mob/living/basic/bounty_criminal/meek +/mob/living/carbon/human/npc/bounty_criminal/meek ai_controller = /datum/ai_controller/basic_controller/bounty/criminal/meek + // OC-6 ruling: their dodge is real chrome, the shared arbiter's (voidcrew/modules/cyberware/ware_pro_combat.dm) + npc_cyberware = list(/obj/item/organ/cyberimp/cyberware/slipwire) /datum/ai_controller/basic_controller/bounty/criminal/meek - armed = TRUE planning_subtrees = list( + /datum/ai_planning_subtree/human_npc_soft_crit, + /datum/ai_planning_subtree/bounty_escape_captivity, + /datum/ai_planning_subtree/human_npc_walk_out, /datum/ai_planning_subtree/bounty_gate, /datum/ai_planning_subtree/bounty_meek_volley, /datum/ai_planning_subtree/bounty_notice, @@ -85,27 +93,31 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) /datum/ai_planning_subtree/bounty_activity, ) -/mob/living/basic/bounty_criminal/meek/ai_notice_range() +/mob/living/carbon/human/npc/bounty_criminal/meek/ai_notice_range() return BOUNTY_MEEK_NOTICE_RANGE -/mob/living/basic/bounty_criminal/meek/ai_wanted_style() +/mob/living/carbon/human/npc/bounty_criminal/meek/ai_wanted_style() return BOUNTY_STYLE_HOLDOUT /// The holdout is the same little gun whatever the tier -/mob/living/basic/bounty_criminal/meek/ai_heavy_weapon() +/mob/living/carbon/human/npc/bounty_criminal/meek/ai_heavy_weapon() return FALSE -/mob/living/basic/bounty_criminal/meek/ai_sprints() +/// Plain clothes for their zone, their tier's armour, the holdout and its spare, and the stimpack they bolt on +/mob/living/carbon/human/npc/bounty_criminal/meek/bounty_build_outfit(zone) + return bounty_fighter_outfit(BOUNTY_ARCHETYPE_MEEK, zone, record?.tier, BOUNTY_STYLE_HOLDOUT, FALSE, /obj/item/reagent_containers/hypospray/medipen/stimpack) + +/mob/living/carbon/human/npc/bounty_criminal/meek/ai_sprints() return TRUE -/mob/living/basic/bounty_criminal/meek/ai_notice(mob/living/hunter) +/mob/living/carbon/human/npc/bounty_criminal/meek/ai_notice(mob/living/hunter) ai_flee_event(hunter, "noticed") -/mob/living/basic/bounty_criminal/meek/ai_react(mob/living/threat, bark) +/mob/living/carbon/human/npc/bounty_criminal/meek/ai_react(mob/living/threat, bark) ai_flee_event(threat, bark) /// Hit while running: they run from whoever is closer -/mob/living/basic/bounty_criminal/meek/ai_attacked_again(mob/living/attacker) +/mob/living/carbon/human/npc/bounty_criminal/meek/ai_attacked_again(mob/living/attacker) var/mob/living/threat = ai_threat() if(!threat || bounty_ai_dist(src, attacker) < bounty_ai_dist(src, threat)) ai_set_threat(attacker) @@ -113,16 +125,16 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) ai_bark("hurt") /// Anything that hurts a hider finds them -/mob/living/basic/bounty_criminal/meek/ai_took_damage(damage, damagetype) +/mob/living/carbon/human/npc/bounty_criminal/meek/ai_took_damage(damage, damagetype) if(hidden && damage > 0) INVOKE_ASYNC(src, PROC_REF(ai_reveal), null, "hurt") /// Only the cornered volley gets a shot out: they never attack first -/mob/living/basic/bounty_criminal/meek/ai_may_shoot(atom/target) - return ai_firing +/mob/living/carbon/human/npc/bounty_criminal/meek/ai_may_shoot(atom/target) + return ai_aim_until || ai_volley_left -/// Passing as a plant, they look and read like the plant; up close, looking at them gives them away -/mob/living/basic/bounty_criminal/meek/examine(mob/user) +/// Behind the plant, they read as the plant; up close, looking at them gives them away +/mob/living/carbon/human/npc/bounty_criminal/meek/examine(mob/user) if(!hidden || ai_hide_mode == BOUNTY_HIDE_CONTAINER) return ..() if(user && get_dist(user, src) <= 1 && bounty_ai_is_hunter(user)) @@ -135,8 +147,8 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) // ===== RUNNING ===== -/// Whether they sprint and tire (only the meek) -/mob/living/basic/bounty_criminal/proc/ai_sprints() +/// Whether they run and hide (only the meek) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_sprints() return FALSE /** @@ -144,7 +156,7 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) * the best hiding place in reach, once for this whole flight. `bark` is the line to shout, or * null for the usual one on a fresh flight (none if `quiet`). */ -/mob/living/basic/bounty_criminal/proc/ai_flee_event(mob/living/threat, bark, seek_hiding = TRUE, quiet = FALSE) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_flee_event(mob/living/threat, bark, seek_hiding = TRUE, quiet = FALSE) if(!ai_can_act() || hidden) return FALSE var/fresh = ai_mode != BOUNTY_AI_FLEEING @@ -173,70 +185,43 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) else if(fresh && !quiet) ai_bark("flee") if(ai_sprints()) - ai_update_sprint() + ai_set_pace(BOUNTY_RUN_SPEED) + if(fresh && seek_hiding) + ai_bolting = TRUE return TRUE -/// Their sprint speed: a lizard's is a little quicker -/mob/living/basic/bounty_criminal/proc/ai_sprint_speed() - if(ispath(record?.species, /datum/species/lizard)) - return BOUNTY_MEEK_SPRINT_SPEED - BOUNTY_MEEK_LIZARD_SPRINT_BONUS - return BOUNTY_MEEK_SPRINT_SPEED - -/** - * Works out their sprint since the last time: running in sight of the hunter uses it up, and then - * they are winded (slow) until it is all back. It comes back fastest hidden, slowly while out of - * sight but still on the run, and at a rest in BOUNTY_MEEK_REST_TIME. Sets their pace and - * TRAIT_BOUNTY_SPRINTING while running flat out (never winded, cornered or shooting). - */ -/mob/living/basic/bounty_criminal/proc/ai_update_sprint() - var/now = world.time - var/elapsed = ai_sprint_checked_at ? min(now - ai_sprint_checked_at, 5 SECONDS) : 0 - ai_sprint_checked_at = now - var/running = ai_mode == BOUNTY_AI_FLEEING && !hidden && !ai_aim_until && !ai_volley_left && !ai_cornered_since && (now - ai_threat_seen_at) <= 1 SECONDS - if(running) - if(!ai_winded) - ai_sprint_left -= elapsed - else if(hidden) - ai_sprint_left += elapsed * BOUNTY_MEEK_RECOVER_HIDDEN - else if(ai_mode == BOUNTY_AI_FLEEING) - ai_sprint_left += elapsed * BOUNTY_MEEK_RECOVER_WALKING - else - ai_sprint_left += elapsed * (BOUNTY_MEEK_SPRINT_TIME / BOUNTY_MEEK_REST_TIME) - ai_sprint_left = clamp(ai_sprint_left, 0, BOUNTY_MEEK_SPRINT_TIME) - if(!ai_winded && ai_sprint_left <= 0) - ai_winded = TRUE +/// Out of breath: tg's own stamina slowdown has them. They say so once, and again only after getting their breath back. +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_check_winded() + var/winded = getStaminaLoss() >= BOUNTY_MEEK_WINDED_STAMINA + if(winded == ai_winded) + return + ai_winded = winded + if(winded && stat == CONSCIOUS) visible_message(span_notice("[src] is out of breath.")) ai_bark("winded") - else if(ai_winded && ai_sprint_left >= BOUNTY_MEEK_SPRINT_TIME) - ai_winded = FALSE - if(running && !ai_winded) - ADD_TRAIT(src, TRAIT_BOUNTY_SPRINTING, BOUNTY_AI_TRAIT) - else - REMOVE_TRAIT(src, TRAIT_BOUNTY_SPRINTING, BOUNTY_AI_TRAIT) - if(ai_mode == BOUNTY_AI_FLEEING) - ai_set_pace(ai_winded ? BOUNTY_MEEK_WINDED_SPEED : ai_sprint_speed()) /** - * The run: to the hiding place chosen for this flight if there is one and it is still good, else - * away from the hunter while they can see them, else still and catching their breath. Cornered, - * the holdout comes out. Out of sight long enough, they calm down. + * The run: their stimpack first on a fresh flight, then to the hiding place chosen for this flight if + * there is one and it is still good, else away from the hunter while they can see them, else still and + * catching their breath. Cornered, the holdout comes out. Out of sight long enough, they calm down. */ /datum/ai_planning_subtree/bounty_meek_flee /datum/ai_planning_subtree/bounty_meek_flee/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn - // A decoy given this tree (P6 gives decoys their fugitive's controller) never sprints, hides or - // draws: bounty_flee_and_calm, next in the tree, runs it (L6). + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn + // A decoy given this tree (P6 gives decoys their fugitive's controller) never hides or draws: + // bounty_flee_and_calm, next in the tree, runs it (L6). if(!criminal.ai_sprints()) return var/seen = criminal.ai_mode == BOUNTY_AI_FLEEING && criminal.ai_sees_threat(BOUNTY_MEEK_HIDE_RADIUS) - criminal.ai_update_sprint() + criminal.ai_check_winded() if(criminal.ai_mode != BOUNTY_AI_FLEEING) return var/mob/living/threat = criminal.ai_threat() if(!threat || world.time - criminal.ai_threat_seen_at > BOUNTY_MEEK_CALM_AFTER) criminal.ai_calm_down() return + criminal.ai_plan_stimpack(controller) if(seen && criminal.ai_check_cornered(threat)) controller.queue_behavior(/datum/ai_behavior/bounty_holdout_volley) return SUBTREE_RETURN_FINISH_PLANNING @@ -263,6 +248,21 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) controller.queue_behavior(/datum/ai_behavior/bounty_watch) return SUBTREE_RETURN_FINISH_PLANNING +/** + * Bolting: the stimpack they carry, jabbed in as they run (the core's bounty_ai_use_injector(), the human + * NPC base's "use in hand"), once per pen. Kept in the plan until the pen is spent. + */ +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_plan_stimpack(datum/ai_controller/controller) + var/obj/item/reagent_containers/hypospray/medipen/pen = controller.blackboard[BB_HUMAN_NPC_TREAT_ITEM] + if(istype(pen, /obj/item/reagent_containers/hypospray/medipen/stimpack) && !pen.used_up) + controller.queue_behavior(/datum/ai_behavior/human_npc_treat_self, BB_HUMAN_NPC_TREAT_ITEM) + return TRUE + if(!ai_bolting) + return FALSE + ai_bolting = FALSE + pen = bounty_ai_find_injector(src, /obj/item/reagent_containers/hypospray/medipen/stimpack) + return pen && bounty_ai_use_injector(controller, pen) + /** * tg's run away, staying on the site: a leg never goes off the leash, into lava or into a chasm * (D-A9). When no leg works, the criminal is cornered (ai_run_failed_at). @@ -273,21 +273,21 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) /datum/ai_behavior/run_away_from_target/bounty/setup(datum/ai_controller/controller, target_key, hiding_location_key) . = ..() if(!.) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn if(istype(criminal)) criminal.ai_run_failed_at = world.time /datum/ai_behavior/run_away_from_target/bounty/perform(seconds_per_tick, datum/ai_controller/controller, target_key, hiding_location_key) . = ..() if(. & AI_BEHAVIOR_FAILED) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn if(istype(criminal)) criminal.ai_run_failed_at = world.time /datum/ai_behavior/run_away_from_target/bounty/get_furthest_turf(atom/source, angle, atom/target) var/turf/return_turf var/list/airlocks = SSmachines.get_machines_by_type_and_subtypes(/obj/machinery/door/airlock) - var/mob/living/basic/bounty_criminal/leash_holder = bounty_ai_side_of(source) + var/mob/living/carbon/human/npc/bounty_criminal/leash_holder = bounty_ai_side_of(source) for(var/i in 1 to run_distance) var/turf/test_destination = get_ranged_target_turf_direct(source, target, range = i, offset = angle) if(test_destination.is_blocked_turf(source_atom = source, ignore_atoms = airlocks)) @@ -308,7 +308,7 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) // ===== CORNERED ===== /// How many ways out lead away from `threat`: free, on the leash, and further from them -/mob/living/basic/bounty_criminal/proc/ai_ways_out(mob/living/threat) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_ways_out(mob/living/threat) . = 0 var/turf/here = get_turf(src) if(!here || !threat) @@ -323,10 +323,9 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) /** * Whether they are cornered by `threat`, and have been for BOUNTY_MEEK_CORNERED_TIME: the hunter * close, with running away failing or fewer than two ways out. Once it has lasted, and the holdout - * is ready, the aim starts. Returns TRUE when it did. Being held no longer counts: a free criminal - * pulls away from any hand (P2), so a grab only happens while it is stunned and can't act (H2). + * is ready, the aim starts. Returns TRUE when it did. */ -/mob/living/basic/bounty_criminal/proc/ai_check_cornered(mob/living/threat) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_check_cornered(mob/living/threat) if(!ai_sprints() || world.time < ai_holdout_ready_at || !threat || !ai_can_act()) ai_cornered_since = 0 return FALSE @@ -347,73 +346,100 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) return FALSE return ai_start_aim(threat) -/// The aim: the holdout in hand, a mark where it points, a shout. The shots start BOUNTY_MEEK_PISTOL_WINDUP later. Never from the floor (H2). -/mob/living/basic/bounty_criminal/proc/ai_start_aim(mob/living/target) - if(!ai_sprints() || ai_aim_until || ai_volley_left || !ai_can_act() || !isturf(loc) || !isliving(target)) +/// The holdout they carry (in hand, a pocket or the fanny pack), or null +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_holdout() + var/datum/bounty_style/style = GLOB.bounty_styles[BOUNTY_STYLE_HOLDOUT] + for(var/obj/item/gun/ballistic/gun as anything in get_all_contents_type(style.weapon_type)) + if(is_holding(gun) || human_npc_can_draw(src, gun)) + return gun + return null + +/** + * The aim: the holdout out of their pocket and into their hand, a mark where it points, a shout. The + * shots start BOUNTY_MEEK_PISTOL_WINDUP later. Never from the floor (H2), never with an empty gun. + */ +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_start_aim(mob/living/target) + if(!ai_sprints() || ai_aim_until || ai_volley_left || !ai_can_act() || !isturf(loc) || !isliving(target) || HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)) return FALSE ai_update_style() + var/obj/item/gun/ballistic/gun = ai_holdout() + if(!gun || !(gun.can_shoot() || human_npc_gun_needs_rack(gun))) + return FALSE + if(!is_holding(gun)) + if(!length(get_empty_held_indexes())) + bounty_ai_free_other_hand(src, null) + if(!human_npc_take_in_hand(src, gun)) + return FALSE + if(human_npc_gun_needs_rack(gun)) + human_npc_ready_item(src, gun) + gun.attack_self(src) ai_aim_ref = WEAKREF(target) ai_aim_until = world.time + BOUNTY_MEEK_PISTOL_WINDUP - ai_aim_stamina = staminaloss + ai_aim_from = world.time + ai_aim_stamina = getStaminaLoss() ai_cornered_since = 0 - REMOVE_TRAIT(src, TRAIT_BOUNTY_SPRINTING, BOUNTY_AI_TRAIT) face_atom(bounty_ai_target_for(target)) - ai_hand = bounty_ai_update_held(src, ai_hand, bounty_ai_held_look(src) || /obj/item/gun/ballistic/automatic/pistol) new /obj/effect/temp_visual/telegraphing/bounty_aim(get_turf(target)) - visible_message(span_danger("[src] pulls out a small pistol and aims it at [target]!")) + visible_message(span_danger("[src] pulls out [gun] and aims it at [target]!")) to_chat(target, span_userdanger("[src] is aiming a pistol at you!")) playsound(src, 'sound/items/weapons/gun/pistol/rack_small.ogg', 50, TRUE) - // Forced: the draw is a one-second warning, and a meek criminal has just said "cornered" or "hurt" + // Forced: the draw is a half-second warning, and a meek criminal has just said "cornered" or "hurt" ai_bark("draw_gun", TRUE) return TRUE /** - * The aim is up: the volley starts, BOUNTY_MEEK_PISTOL_SHOTS shots (never more than the holdout's - * magazine) BOUNTY_MEEK_PISTOL_GAP apart, the first one now. A stamina hit or a stun during the aim - * makes them fumble it instead. Returns TRUE if the first shot went. + * The aim is up: the volley starts, BOUNTY_MEEK_PISTOL_SHOTS trigger pulls (never more than the gun + * holds) BOUNTY_MEEK_PISTOL_GAP apart, the first one now. A hit, more stamina loss or a stun during the + * aim makes them fumble it instead. Returns TRUE if the first shot went. */ -/mob/living/basic/bounty_criminal/proc/ai_fire_holdout() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_fire_holdout() var/mob/living/target = ai_aim_ref?.resolve() - var/stunned = !ai_can_act() || staminaloss > ai_aim_stamina + 1 || HAS_TRAIT(src, TRAIT_INCAPACITATED) + var/hit_at = ai_controller?.blackboard[BB_BOUNTY_HIT_AT] + var/spoiled = !ai_can_act() || getStaminaLoss() > ai_aim_stamina + 1 || HAS_TRAIT(src, TRAIT_INCAPACITATED) || (hit_at && hit_at >= ai_aim_from) ai_aim_until = 0 ai_aim_ref = null ai_holdout_ready_at = world.time + BOUNTY_MEEK_PISTOL_COOLDOWN ai_run_failed_at = 0 - if(stunned) + if(spoiled) ai_fumble() return FALSE if(!ai_volley_target_ok(target)) ai_put_gun_away() return FALSE - var/datum/bounty_real_weapon/holdout = bounty_ai_real_weapon(src) - ai_volley_left = holdout?.magazine ? min(BOUNTY_MEEK_PISTOL_SHOTS, holdout.magazine) : BOUNTY_MEEK_PISTOL_SHOTS + var/obj/item/gun/ballistic/gun = ai_holdout() + var/rounds = istype(gun) ? gun.get_ammo(TRUE) : 0 + ai_volley_left = clamp(rounds, 0, BOUNTY_MEEK_PISTOL_SHOTS) ai_volley_ref = WEAKREF(target) return ai_volley_shot() /// Whether the volley may go on at `target`: awake (downed hunters are left alone, C4), close and in sight -/mob/living/basic/bounty_criminal/proc/ai_volley_target_ok(mob/living/target) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_volley_target_ok(mob/living/target) return !QDELETED(target) && target.stat == CONSCIOUS && bounty_ai_can_see(src, target, BOUNTY_MEEK_PISTOL_RANGE) /** - * One shot of the volley, if they can still shoot (on their feet, not hidden) and the target is - * still there. Returns TRUE if a shot left the gun; a shot the gun refused ends the volley. + * One trigger pull of the volley, the player's way (a click with the gun in hand), if they can still + * shoot (on their feet, not hidden, the gun in hand and loaded) and the target is still there and + * nobody they may not hit stands in the way. Returns TRUE if a round left the gun; a pull that didn't + * fire ends the volley. */ -/mob/living/basic/bounty_criminal/proc/ai_volley_shot() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_volley_shot() var/mob/living/target = ai_volley_ref?.resolve() - if(!ai_volley_left || !ai_can_act() || hidden || !isturf(loc) || !ai_volley_target_ok(target)) + if(!ai_volley_left || !ai_can_act() || hidden || !isturf(loc) || !ai_volley_target_ok(target) || QDELETED(ai_controller)) ai_end_volley() return FALSE - var/datum/component/ranged_attacks/gun = GetComponent(/datum/component/ranged_attacks) - if(!gun) + var/obj/item/gun/ballistic/gun = ai_holdout() + if(!istype(gun) || !is_holding(gun) || !gun.can_shoot() || HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)) ai_end_volley() return FALSE - face_atom(bounty_ai_target_for(target)) - var/cooldown_before = gun.fire_cooldown - ai_firing = TRUE - RangedAttack(bounty_ai_target_for(target)) - ai_firing = FALSE - // The gun starts its cooldown only when it fires: a refused shot leaves it as it was - if(gun.fire_cooldown == cooldown_before || gun.fire_cooldown <= world.time) + var/atom/aim_at = bounty_ai_target_for(target) + face_atom(aim_at) + if(bounty_ai_line_blocked(src, aim_at) || !human_npc_ready_item(src, gun)) + ai_end_volley() + return FALSE + var/rounds_before = gun.get_ammo(TRUE) + zone_selected = human_npc_pick_aim_zone() + ai_controller.ai_interact(target = aim_at, combat_mode = TRUE) + if(QDELETED(gun) || gun.get_ammo(TRUE) >= rounds_before) ai_end_volley() return FALSE ai_volley_left-- @@ -422,38 +448,41 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) ai_end_volley() return TRUE -/// The volley is over (or cut short): the gun goes away a moment later -/mob/living/basic/bounty_criminal/proc/ai_end_volley() +/// The volley is over (or cut short): the gun goes back in the pocket a moment later +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_end_volley() ai_volley_left = 0 ai_volley_ref = null addtimer(CALLBACK(src, PROC_REF(ai_put_gun_away)), 0.5 SECONDS, TIMER_DELETE_ME) -/// A stamina hit or a stun during the aim: the volley never happens and they run -/mob/living/basic/bounty_criminal/proc/ai_fumble() +/// A hit, more stamina loss or a stun during the aim: the volley never happens and they run +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_fumble() ai_aim_until = 0 ai_aim_ref = null ai_volley_left = 0 ai_volley_ref = null ai_holdout_ready_at = max(ai_holdout_ready_at, world.time + BOUNTY_MEEK_PISTOL_COOLDOWN) - ai_hand = bounty_ai_update_held(src, ai_hand, null) - if(stat != DEAD) - visible_message(span_notice("[src] fumbles the pistol!")) + if(stat == DEAD) + return + visible_message(span_notice("[src] fumbles the pistol!")) + ai_put_gun_away() -/// Puts the holdout away after the volley -/mob/living/basic/bounty_criminal/proc/ai_put_gun_away() - if(ai_aim_until || ai_volley_left || ai_mode == BOUNTY_AI_FIGHTING) +/// Puts the holdout back in a pocket after the volley, when they can +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_put_gun_away() + if(ai_aim_until || ai_volley_left || ai_mode == BOUNTY_AI_FIGHTING || HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)) return - ai_hand = bounty_ai_update_held(src, ai_hand, null) + var/obj/item/gun/gun = ai_holdout() + if(gun && is_holding(gun)) + gun.equip_to_best_slot(src) /// Drops the aim and the volley without a word: they calmed down, hid, were cuffed, died -/mob/living/basic/bounty_criminal/proc/ai_stop_aiming() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_stop_aiming() if(!ai_aim_until && !ai_volley_left) return ai_aim_until = 0 ai_aim_ref = null ai_volley_left = 0 ai_volley_ref = null - ai_hand = bounty_ai_update_held(src, ai_hand, null) + ai_put_gun_away() /// The mark where a cornered criminal aims, for the length of the aim /obj/effect/temp_visual/telegraphing/bounty_aim @@ -461,25 +490,24 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) /// The volley: first in a meek criminal's tree while an aim or a volley is on /datum/ai_planning_subtree/bounty_meek_volley - operational_datums = list(/datum/component/ranged_attacks) /datum/ai_planning_subtree/bounty_meek_volley/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn if(!criminal.ai_aim_until && !criminal.ai_volley_left) return controller.queue_behavior(/datum/ai_behavior/bounty_holdout_volley) return SUBTREE_RETURN_FINISH_PLANNING -/// Holds the aim, then fires the volley shot by shot. Cancelled (a stun stops the AI), the aim is fumbled or the volley cut short. +/// Holds the aim, then fires the volley pull by pull. Cancelled (a stun stops the AI), the aim is fumbled or the volley cut short. /datum/ai_behavior/bounty_holdout_volley - action_cooldown = 0.2 SECONDS + action_cooldown = 0.1 SECONDS /datum/ai_behavior/bounty_holdout_volley/setup(datum/ai_controller/controller) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn return istype(criminal) && (criminal.ai_aim_until || criminal.ai_volley_left) /datum/ai_behavior/bounty_holdout_volley/perform(seconds_per_tick, datum/ai_controller/controller) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn if(criminal.ai_aim_until) if(world.time < criminal.ai_aim_until) var/mob/living/target = criminal.ai_aim_ref?.resolve() @@ -499,7 +527,7 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) . = ..() if(succeeded) return - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn if(!istype(criminal)) return if(criminal.ai_aim_until) @@ -517,7 +545,7 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) * them and out of the hunter's sight is better. Never where they were just found, never off their * site. Null if nothing will do. */ -/mob/living/basic/bounty_criminal/proc/ai_pick_hide_spot(mob/living/threat) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_pick_hide_spot(mob/living/threat) var/turf/center = get_turf(src) if(!center) return null @@ -553,7 +581,7 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) best = thing best_score = score best_stand = stand - var/dark_bonus = BOUNTY_HIDE_SCORE_DARK + (ispath(record?.species, /datum/species/moth) ? BOUNTY_HIDE_SCORE_MOTH_DARK : 0) + var/dark_bonus = BOUNTY_HIDE_SCORE_DARK + (ismoth(src) ? BOUNTY_HIDE_SCORE_MOTH_DARK : 0) for(var/turf/tile as anything in ai_dark_candidates(reachable)) if(tile == last) continue @@ -569,7 +597,7 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) return best /// How good `spot` is to hide from `threat`, or null if it is no good at all -/mob/living/basic/bounty_criminal/proc/ai_score_hide_spot(atom/spot, mob/living/threat) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_score_hide_spot(atom/spot, mob/living/threat) var/turf/spot_turf = get_turf(spot) if(!spot_turf || spot_turf.z != z) return null @@ -587,7 +615,7 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) . += BOUNTY_HIDE_SCORE_UNSEEN /// Up to `samples` dark tiles they could stand in, sampled once from `reachable` (turf = TRUE, the floor they can walk to) -/mob/living/basic/bounty_criminal/proc/ai_dark_candidates(list/reachable, samples = BOUNTY_MEEK_DARK_SAMPLES) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_dark_candidates(list/reachable, samples = BOUNTY_MEEK_DARK_SAMPLES) . = list() var/list/pool = list() for(var/turf/tile as anything in reachable) @@ -602,7 +630,7 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) * Whether `tile` is dark enough to hide in. A turf with no lighting object (planet ground, lit by * its area's ambient light) reads its area's base light instead, which tg's lumcount skips (L2). */ -/mob/living/basic/bounty_criminal/proc/ai_tile_is_dark(turf/tile) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_tile_is_dark(turf/tile) if(!isturf(tile)) return FALSE #ifdef UNIT_TESTS @@ -614,7 +642,7 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) return (tile_area.base_lighting_alpha / 255) + tile.dynamic_lumcount < BOUNTY_MEEK_DARK_LUMCOUNT return tile.get_lumcount() < BOUNTY_MEEK_DARK_LUMCOUNT -/mob/living/basic/bounty_criminal/proc/ai_hide_spot_usable(atom/spot) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_hide_spot_usable(atom/spot) if(QDELETED(spot)) return FALSE if(istype(spot, /obj/structure/closet)) @@ -629,7 +657,7 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) * A locker or crate they fit in: on the floor, unlocked, not welded, not full, not outpost property, * not a body bag, and nobody standing in it (shutting it would take them along). */ -/mob/living/basic/bounty_criminal/proc/ai_container_usable(obj/structure/closet/container) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_container_usable(obj/structure/closet/container) if(QDELETED(container) || !isturf(container.loc) || container.locked || container.welded) return FALSE if(istype(container, /obj/structure/closet/body_bag) || container.wall_mounted || (container.resistance_flags & INDESTRUCTIBLE)) @@ -647,7 +675,7 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) return leash_ok(get_turf(container)) /// A potted plant on the floor, loose, with nobody standing on it -/mob/living/basic/bounty_criminal/proc/ai_plant_usable(obj/item/kirbyplants/plant) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_plant_usable(obj/item/kirbyplants/plant) if(QDELETED(plant) || !isturf(plant.loc) || plant.anchored) return FALSE var/turf/plant_turf = plant.loc @@ -659,15 +687,15 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) return leash_ok(plant_turf) /// A dark floor tile they can stand on: not space, lava or a chasm, free, on their site -/mob/living/basic/bounty_criminal/proc/ai_dark_usable(turf/tile) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_dark_usable(turf/tile) if(!isopenturf(tile) || isspaceturf(tile) || isgroundlessturf(tile) || islava(tile) || ischasm(tile)) return FALSE if(tile != loc && tile.is_blocked_turf(source_atom = src)) return FALSE return leash_ok(tile) && ai_tile_is_dark(tile) -/// Whether they can hide in or as `spot` from where they stand: on the dark tile, or right beside the closet or plant with nothing between (H1) -/mob/living/basic/bounty_criminal/proc/ai_at_hide_spot(atom/spot) +/// Whether they can hide in or as `spot` from where they stand: on the dark tile or the plant's, or right beside the closet or plant with nothing between (H1) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_at_hide_spot(atom/spot) if(!isturf(loc)) return FALSE if(isturf(spot)) @@ -677,7 +705,7 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) return Adjacent(spot) /// Where they walk to to hide at `spot`: beside a closet on their side of it (the tile picked with it), onto a plant or a dark tile. Null if there is nowhere. -/mob/living/basic/bounty_criminal/proc/ai_hide_approach(atom/spot) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_hide_approach(atom/spot) if(istype(spot, /obj/structure/closet)) if(ai_hide_stand && (ai_hide_stand == loc || ai_standable(ai_hide_stand)) && ai_hide_stand.Adjacent(spot)) return ai_hide_stand @@ -688,7 +716,7 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) * The tile to stand on to climb into `container`: beside it, free, with no wall, window or rail * between (so Adjacent() holds from it), and in `reachable` when that is given. Nearest to them. */ -/mob/living/basic/bounty_criminal/proc/ai_container_approach(obj/structure/closet/container, list/reachable) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_container_approach(obj/structure/closet/container, list/reachable) var/turf/container_turf = get_turf(container) if(!container_turf) return null @@ -710,7 +738,7 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) action_cooldown = 0.5 SECONDS /datum/ai_behavior/bounty_hide/perform(seconds_per_tick, datum/ai_controller/controller, spot_key) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn var/atom/spot = controller.blackboard[spot_key] if(QDELETED(spot) || !criminal.ai_hide_in(spot)) controller.clear_blackboard_key(spot_key) @@ -718,17 +746,15 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED /** - * Hides in or as `spot`, from beside it: a closet (in, and shut), a potted plant (theirs now, and - * so is its look) or a dark turf (still and faded). Returns TRUE if they are hidden. + * Hides in or as `spot`, from beside it: a closet (in, and shut), a potted plant (picked up and held + * up in front of them) or a dark turf (still and faded). Returns TRUE if they are hidden. */ -/mob/living/basic/bounty_criminal/proc/ai_hide_in(atom/spot) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_hide_in(atom/spot) // Never from the floor: a knockdown is a cuff window (H2) if(hidden || !ai_can_act() || QDELETED(spot) || !isturf(loc)) return FALSE ai_suspend_activity() ai_stop_aiming() - ai_hand = bounty_ai_update_held(src, ai_hand, null) - ai_over_head = bounty_ai_update_held(src, ai_over_head, null) var/done = FALSE if(istype(spot, /obj/structure/closet)) done = ai_hide_in_container(spot) @@ -743,7 +769,6 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) ai_next_restless = world.time + BOUNTY_MEEK_RESTLESS_AFTER ai_next_quiet_check = world.time + BOUNTY_MEEK_COME_OUT_AFTER ai_cornered_since = 0 - REMOVE_TRAIT(src, TRAIT_BOUNTY_SPRINTING, BOUNTY_AI_TRAIT) if(!QDELETED(ai_controller)) ai_controller.clear_blackboard_key(BB_BOUNTY_HIDE_SPOT) ai_controller.clear_blackboard_key(BB_BOUNTY_DESTINATION) @@ -752,11 +777,12 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) return TRUE /** - * In a locker or a crate: opens it if shut, gets in, and shuts it from inside. A crate won't take - * a standing person the ordinary way, so it is straight insertion for both, then close(). Only - * from right beside it, with no wall or window between (H1). + * In a locker or a crate: opens it if shut, gets in (a real move into it), and pulls it shut from + * inside. A crate won't take a standing person the ordinary way, so it is straight in for both, then + * close(). Only from right beside it, with no wall or window between (H1). Getting out is the + * container opening, as anyone gets out. */ -/mob/living/basic/bounty_criminal/proc/ai_hide_in_container(obj/structure/closet/container) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_hide_in_container(obj/structure/closet/container) if(!ai_container_usable(container) || !Adjacent(container)) return FALSE ai_stand_up() @@ -777,10 +803,12 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) return TRUE /** - * As a potted plant: they step onto its tile (a real step, from right beside it: H1), take it, keep - * their own look aside, and wear the plant's: name, description, icon, overlays and layer. + * Behind a potted plant: they step onto its tile (a real step, from right beside it: H1), put away what + * is in their hands, and pick it up in both hands. The plant's own tactical component (tg's disguise: + * whoever holds it up looks like the plant to everyone and goes by its name) does the rest; nothing of + * their own look is touched. The plant knocked out of their hands, or put down, gives them away. */ -/mob/living/basic/bounty_criminal/proc/ai_hide_as_plant(obj/item/kirbyplants/plant) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_hide_as_plant(obj/item/kirbyplants/plant) if(!ai_plant_usable(plant)) return FALSE var/turf/plant_turf = plant.loc @@ -788,42 +816,28 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) if(!Adjacent(plant)) return FALSE ai_stand_up() - Move(plant_turf, get_dir(src, plant_turf)) - if(loc != plant_turf) + if(!bounty_ai_step(src, plant_turf) || loc != plant_turf) return FALSE ai_stand_up() - ai_disguise_saved = list( - "plant_turf" = plant_turf, - "name" = name, - "desc" = desc, - "icon" = icon, - "icon_state" = icon_state, - "overlays" = overlays.Copy(), - "underlays" = underlays.Copy(), - "layer" = layer, - "alpha" = alpha, - ) - plant.forceMove(src) - if(plant.loc != src) - ai_disguise_saved = null - return FALSE - name = plant.name - desc = plant.desc - icon = plant.icon - icon_state = plant.icon_state - overlays = plant.overlays.Copy() - underlays = null - layer = plant.layer + bounty_ai_holster(src) + if(length(get_empty_held_indexes()) < 2) + bounty_ai_free_other_hand(src, null) + if(length(get_empty_held_indexes()) < 2 || !put_in_hands(plant)) + return FALSE + if(!is_holding(plant)) + return FALSE + RegisterSignal(plant, COMSIG_ITEM_DROPPED, PROC_REF(ai_on_plant_dropped)) + RegisterSignal(plant, COMSIG_QDELETING, PROC_REF(ai_on_plant_dropped)) ai_hide_mode = BOUNTY_HIDE_PLANT ai_hide_ref = WEAKREF(plant) return TRUE /// In the dark: on the tile, still, faded -/mob/living/basic/bounty_criminal/proc/ai_hide_in_dark(turf/tile) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_hide_in_dark(turf/tile) if(loc != tile || !ai_dark_usable(tile)) return FALSE ai_stand_up() - ai_disguise_saved = list("alpha" = alpha) + ai_saved_alpha = alpha alpha = BOUNTY_MEEK_DARK_ALPHA setDir(pick(GLOB.cardinals)) ai_hide_mode = BOUNTY_HIDE_DARK @@ -831,11 +845,10 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) return TRUE /** - * Stops hiding: out of the closet if it opens, the plant put back where it stood and their own look - * back, the fade gone. Welded or locked in, they stay in (and hidden, so opening it later finds - * them) and it returns FALSE. + * Stops hiding: out of the closet if it opens, the plant put down at their feet, the fade gone. Welded + * or locked in, they stay in (and hidden, so opening it later finds them) and it returns FALSE. */ -/mob/living/basic/bounty_criminal/proc/ai_unhide() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_unhide() var/atom/spot = ai_hide_ref?.resolve() switch(ai_hide_mode) if(BOUNTY_HIDE_CONTAINER) @@ -850,54 +863,40 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) RegisterSignal(container, COMSIG_QDELETING, PROC_REF(ai_on_container_gone)) return FALSE if(BOUNTY_HIDE_PLANT) - // Back where it stood (L8): the outpost's decor stays where the outpost put it - var/turf/plant_turf = ai_disguise_saved?["plant_turf"] - ai_restore_look() var/obj/item/kirbyplants/plant = spot - if(istype(plant) && plant.loc == src) - var/atom/put_down = isturf(plant_turf) ? plant_turf : drop_location() - if(put_down) - plant.forceMove(put_down) - else - qdel(plant) + if(istype(plant)) + UnregisterSignal(plant, list(COMSIG_ITEM_DROPPED, COMSIG_QDELETING)) + if(is_holding(plant)) + dropItemToGround(plant) if(BOUNTY_HIDE_DARK) - ai_restore_look() + if(!isnull(ai_saved_alpha)) + alpha = ai_saved_alpha + ai_saved_alpha = null hidden = FALSE ai_hide_mode = null ai_hide_ref = null - ai_sprint_checked_at = world.time return TRUE -/// Their own look back after passing as a plant or standing faded -/mob/living/basic/bounty_criminal/proc/ai_restore_look() - var/list/saved = ai_disguise_saved - ai_disguise_saved = null - if(!saved) - return - if("icon" in saved) - name = saved["name"] - desc = saved["desc"] - icon = saved["icon"] - icon_state = saved["icon_state"] - overlays = saved["overlays"] - underlays = saved["underlays"] - layer = saved["layer"] - alpha = saved["alpha"] - -/mob/living/basic/bounty_criminal/proc/ai_on_container_opened(obj/structure/closet/source, mob/living/user, force) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_on_container_opened(obj/structure/closet/source, mob/living/user, force) SIGNAL_HANDLER INVOKE_ASYNC(src, PROC_REF(ai_reveal), isliving(user) ? user : null, "opened") -/mob/living/basic/bounty_criminal/proc/ai_on_container_gone(obj/structure/closet/source) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_on_container_gone(obj/structure/closet/source) SIGNAL_HANDLER INVOKE_ASYNC(src, PROC_REF(ai_reveal), null, "opened") +/// The plant left their hands (knocked away, shoved out of them, broken): they are found +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_on_plant_dropped(obj/item/kirbyplants/source) + SIGNAL_HANDLER + UnregisterSignal(source, list(COMSIG_ITEM_DROPPED, COMSIG_QDELETING)) + INVOKE_ASYNC(src, PROC_REF(ai_reveal), null, "dropped") + /** - * Found: out of hiding, a word, the finder shoved back a tile if they are right there (M4), and - * off again, to a new hiding place. `finder` may be null (a light came, the closet broke). Welded - * or locked in, they can't get out and stay hidden. Returns TRUE if they came out. + * Found: out of hiding, a word, the finder shoved if they are right there (M4, a real shove), and off + * again, to a new hiding place. `finder` may be null (a light came, the closet broke). Welded or locked + * in, they can't get out and stay hidden. Returns TRUE if they came out. */ -/mob/living/basic/bounty_criminal/proc/ai_reveal(mob/living/finder, reason) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_reveal(mob/living/finder, reason) if(!hidden) return FALSE var/mode = ai_hide_mode @@ -925,30 +924,22 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) ai_flee_event(isliving(finder) ? finder : ai_threat(), "found") return TRUE -/// Shoves `finder` back a tile, without a stun, to get a head start; never onto lava, into a chasm or out into space (M5) -/mob/living/basic/bounty_criminal/proc/ai_shove_away(mob/living/finder) - bounty_ai_shove_back(src, finder) - visible_message(span_warning("[src] shoves [finder] back and bolts!")) - playsound(finder, 'sound/items/weapons/shove.ogg', 50, TRUE) - -/// Pushes `victim` a tile away from `shover`, if the tile behind them is safe to stand on (M5). Returns TRUE if they moved. -/proc/bounty_ai_shove_back(atom/shover, mob/living/victim) - var/shove_dir = get_dir(shover, victim) - var/turf/behind = shove_dir && get_step(victim, shove_dir) - if(!behind || behind.is_blocked_turf(source_atom = victim)) +/// Shoves `finder`, a real shove with an empty hand (tg's own, which may knock them into a wall), to get a head start +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_shove_away(mob/living/finder) + if(QDELETED(ai_controller) || !ai_can_act() || !human_npc_ready_empty_hand(src)) return FALSE - if(isspaceturf(behind) || isopenspaceturf(behind) || isgroundlessturf(behind) || islava(behind) || ischasm(behind) || !behind.can_cross_safely(victim)) - return FALSE - return victim.Move(behind, shove_dir) + face_atom(finder) + return ai_controller.ai_interact(target = finder, combat_mode = TRUE, modifiers = list(RIGHT_CLICK = TRUE)) /** * About once a second while hidden: whether they have been found out (let out of the closet, a - * light on them), the restless tell, and coming out when it has been quiet for long enough. + * light on them, the plant gone from their hands), the restless tell, and coming out when it has been + * quiet for long enough. */ -/mob/living/basic/bounty_criminal/proc/ai_hidden_tick() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_hidden_tick() if(!hidden) return - ai_update_sprint() + ai_check_winded() var/atom/spot = ai_hide_ref?.resolve() switch(ai_hide_mode) if(BOUNTY_HIDE_CONTAINER) @@ -956,6 +947,10 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) if(!istype(container) || loc != container || container.opened) ai_reveal(null, "opened") return + if(BOUNTY_HIDE_PLANT) + if(!spot || !is_holding(spot)) + ai_reveal(null, "dropped") + return if(BOUNTY_HIDE_DARK) if(!ai_tile_is_dark(get_turf(src))) ai_reveal(null, "light") @@ -972,7 +967,7 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) * The restless tell (M2): after a while hidden, a noise and a shake of the hiding place every * BOUNTY_MEEK_RESTLESS_GAP, heard within BOUNTY_MEEK_RESTLESS_RANGE, and now and then a mutter. */ -/mob/living/basic/bounty_criminal/proc/ai_restless_tell() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_restless_tell() var/atom/shaken = src var/message switch(ai_hide_mode) @@ -990,7 +985,7 @@ GLOBAL_LIST_EMPTY(bounty_ai_test_dark_turfs) ai_bark("hide") /// Quiet for long enough: they come out and carry on with what they were doing -/mob/living/basic/bounty_criminal/proc/ai_come_out() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_come_out() var/mode = ai_hide_mode var/atom/spot = ai_hide_ref?.resolve() if(!ai_unhide() || !isturf(loc)) diff --git a/voidcrew/modules/bounties/bounty_ai_normal.dm b/voidcrew/modules/bounties/bounty_ai_normal.dm index 70aa025207e..6630df3e905 100644 --- a/voidcrew/modules/bounties/bounty_ai_normal.dm +++ b/voidcrew/modules/bounties/bounty_ai_normal.dm @@ -7,49 +7,55 @@ * - noticing someone armed (aware: up from what they were doing, watching them), and fighting when * attacked, confronted, or when someone with a weapon drawn comes within * BOUNTY_NORMAL_THREAT_RANGE while they are aware; - * - fighting by style, with its companions called in; - * - surrendering (TRAIT_BOUNTY_SURRENDERED, source BOUNTY_TRAIT, which P2's capture_state() reads): - * rolled on the hit that crosses BOUNTY_SURRENDER_BELOW and on later hits, with two hunters near; - * - breaking off and retreating when badly hurt with nobody near. They never regenerate. - * It also owns the fighting styles every bounty fighter uses (criminals, companions, the meek's - * holdout): /datum/bounty_style and their projectiles. Every blow and shot is the real weapon's - * (bounty_weapons.dm). + * - fighting by style with the real weapon they carry (bounty_styles.dm), their companions called in; + * - giving up (CR-10): an AI choice followed by tg's *surrender, through the human NPC base + * (/datum/human_npc_surrender/bounty below: hurt, with hunters around them, less likely for each + * companion still standing). tg's 20 second paralysis is the cuff window; nobody cuffs them in it and + * they decide again: give up again, run, or fight on; + * - breaking off and retreating when badly hurt with nobody near: they sit down there and patch + * themselves up with what they carry (N6), and nothing else heals them; + * - what they wear: plain clothes for their zone, their tier's armour, their style's weapon and spares, + * and a bruise pack. * * The shared vars are declared in bounty_types.dm and nowhere else; a var only P3 uses has an * `ai_` prefix. */ -/mob/living/basic/bounty_criminal - /// Whether the roll on the hit that crosses the surrender line has been made - var/ai_surrender_rolled = FALSE - /// world.time the next surrender roll on a later hit may be made - var/ai_next_surrender_roll = 0 - -/mob/living/basic/bounty_criminal/normal +/mob/living/carbon/human/npc/bounty_criminal/normal ai_controller = /datum/ai_controller/basic_controller/bounty/criminal/normal + npc_surrender = /datum/human_npc_surrender/bounty /datum/ai_controller/basic_controller/bounty/criminal/normal - armed = TRUE planning_subtrees = list( + /datum/ai_planning_subtree/human_npc_soft_crit, + /datum/ai_planning_subtree/bounty_escape_captivity, + /datum/ai_planning_subtree/human_npc_walk_out, + /datum/ai_planning_subtree/human_npc_surrender, /datum/ai_planning_subtree/bounty_gate, /datum/ai_planning_subtree/bounty_notice, /datum/ai_planning_subtree/bounty_fight_target, - /datum/ai_planning_subtree/basic_ranged_attack_subtree/bounty, - /datum/ai_planning_subtree/basic_melee_attack_subtree/bounty, + /datum/ai_planning_subtree/bounty_arm, + /datum/ai_planning_subtree/bounty_ranged, + /datum/ai_planning_subtree/bounty_melee, /datum/ai_planning_subtree/bounty_retreat, + /datum/ai_planning_subtree/bounty_treat_self, /datum/ai_planning_subtree/bounty_aware, // For a decoy on this tree (P6 gives decoys their fugitive's controller): run, then calm down (M3) /datum/ai_planning_subtree/bounty_flee_and_calm, /datum/ai_planning_subtree/bounty_activity, ) -/mob/living/basic/bounty_criminal/normal/ai_wanted_style() +/mob/living/carbon/human/npc/bounty_criminal/normal/ai_wanted_style() var/key = record?.style if(key && key != BOUNTY_STYLE_HOLDOUT && GLOB.bounty_styles[key]) return key return BOUNTY_STYLE_BRAWLER -/mob/living/basic/bounty_criminal/normal/ai_notice(mob/living/hunter) +/// Plain clothes for their zone, their tier's armour, their style's weapon and spares, and a bruise pack +/mob/living/carbon/human/npc/bounty_criminal/normal/bounty_build_outfit(zone) + return bounty_fighter_outfit(BOUNTY_ARCHETYPE_NORMAL, zone, record?.tier, ai_wanted_style(), ai_heavy_weapon(), /obj/item/stack/medical/bruise_pack) + +/mob/living/carbon/human/npc/bounty_criminal/normal/ai_notice(mob/living/hunter) var/mob/living/watched = ai_threat() if(ai_mode == BOUNTY_AI_CALM || ai_mode == BOUNTY_AI_RETREATING) ai_become_aware(hunter) @@ -58,7 +64,7 @@ if(ai_mode == BOUNTY_AI_AWARE && bounty_ai_dist(src, hunter) <= BOUNTY_NORMAL_THREAT_RANGE && bounty_ai_is_armed(hunter, weapons_only = TRUE)) ai_start_fight(hunter) -/mob/living/basic/bounty_criminal/normal/ai_react(mob/living/threat, bark) +/mob/living/carbon/human/npc/bounty_criminal/normal/ai_react(mob/living/threat, bark) if(!ai_can_act()) return threat = threat || ai_nearest_grudge() @@ -69,7 +75,7 @@ ai_start_fight(threat, bark) /// Hit in a fight by someone new: they turn on whoever is closer (a pilot through their mech, H4) -/mob/living/basic/bounty_criminal/normal/ai_attacked_again(mob/living/attacker) +/mob/living/carbon/human/npc/bounty_criminal/normal/ai_attacked_again(mob/living/attacker) if(ai_mode == BOUNTY_AI_FIGHTING) ai_rally_companions(attacker) var/mob/living/threat = ai_threat() @@ -81,13 +87,10 @@ return ai_start_fight(attacker) -/mob/living/basic/bounty_criminal/normal/ai_took_damage(damage, damagetype) - ai_check_surrender(damage, damagetype) - // ===== AWARE ===== /// Someone armed caught their eye: they stop what they are doing and keep an eye on them -/mob/living/basic/bounty_criminal/proc/ai_become_aware(mob/living/hunter) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_become_aware(mob/living/hunter) if(!ai_can_act()) return ai_suspend_activity() @@ -101,7 +104,7 @@ /datum/ai_planning_subtree/bounty_aware /datum/ai_planning_subtree/bounty_aware/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn if(criminal.ai_mode != BOUNTY_AI_AWARE) return criminal.ai_sees_threat(BOUNTY_FIGHT_VISION) @@ -113,8 +116,12 @@ // ===== FIGHTING ===== -/// Starts (or keeps) fighting `target`: up, weapon out, companions called in, a line for it. A pilot is fought through their mech (H4). -/mob/living/basic/bounty_criminal/proc/ai_start_fight(mob/living/target, bark) +/** + * Starts (or keeps) fighting `target`: up, at a run, companions called in, a line for it. The weapon + * comes out of its holster, pocket or bag through the arm subtree (bounty_styles.dm). A pilot is fought + * through their mech (H4). + */ +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_start_fight(mob/living/target, bark) if(!ai_can_act() || !isliving(target) || QDELETED(ai_controller)) return FALSE ai_update_style() @@ -124,9 +131,7 @@ ai_set_mode(BOUNTY_AI_FIGHTING) ai_set_threat(target) ai_add_grudge(target) - var/datum/bounty_style/style = bounty_ai_style(src) - ai_set_pace(style?.speed || BOUNTY_NORMAL_SPEED_MELEE) - ai_hand = bounty_ai_update_held(src, ai_hand, bounty_ai_held_look(src)) + ai_set_pace(BOUNTY_RUN_SPEED) if(fresh) ai_bark(bark || "fight_start") ai_rally_companions(target) @@ -137,7 +142,7 @@ * The nearest valid target on their grudge list, keeping the current one while it is still good. * Someone in a mech is fought through the mech (H4): tg's melee can't reach a pilot inside. */ -/mob/living/basic/bounty_criminal/proc/ai_pick_fight_target() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_pick_fight_target() if(QDELETED(ai_controller)) return null var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(ai_controller.blackboard[BB_TARGETING_STRATEGY]) @@ -160,7 +165,7 @@ return best /// The fight is over: nobody on their grudge list seen for a while -/mob/living/basic/bounty_criminal/proc/ai_fight_over() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_fight_over() if(ai_should_retreat()) ai_start_retreat(ai_threat()) return @@ -173,7 +178,7 @@ /datum/ai_planning_subtree/bounty_fight_target /datum/ai_planning_subtree/bounty_fight_target/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn if(criminal.ai_mode != BOUNTY_AI_FIGHTING) return var/atom/target = criminal.ai_pick_fight_target() @@ -190,201 +195,78 @@ controller.queue_behavior(/datum/ai_behavior/bounty_watch) return SUBTREE_RETURN_FINISH_PLANNING -/// Whether a pawn is in a fight it can take part in: a criminal fighting, or a companion that has not broken -/proc/bounty_ai_fighting(mob/living/basic/fighter) - if(istype(fighter, /mob/living/basic/bounty_criminal)) - var/mob/living/basic/bounty_criminal/criminal = fighter - return criminal.ai_mode == BOUNTY_AI_FIGHTING && criminal.ai_can_act() - if(istype(fighter, /mob/living/basic/bounty_companion)) - var/mob/living/basic/bounty_companion/companion = fighter - return companion.ai_can_fight() - return FALSE - -/// tg's melee subtree, for melee styles only, and only in a fight -/datum/ai_planning_subtree/basic_melee_attack_subtree/bounty - -/datum/ai_planning_subtree/basic_melee_attack_subtree/bounty/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/datum/bounty_style/style = GLOB.bounty_styles[controller.blackboard[BB_BOUNTY_STYLE]] - if(!style || style.ranged || !bounty_ai_fighting(controller.pawn)) - return - return ..() - -/// tg's ranged subtree, for ranged styles only, and only in a fight: each style keeps its own distance -/datum/ai_planning_subtree/basic_ranged_attack_subtree/bounty - ranged_attack_behavior = /datum/ai_behavior/basic_ranged_attack/bounty - -/datum/ai_planning_subtree/basic_ranged_attack_subtree/bounty/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/datum/bounty_style/style = GLOB.bounty_styles[controller.blackboard[BB_BOUNTY_STYLE]] - if(!style?.ranged || !bounty_ai_fighting(controller.pawn)) - return - if(!controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) - return - controller.queue_behavior(style.ranged_behavior, BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETING_STRATEGY, BB_BASIC_MOB_CURRENT_TARGET_HIDING_LOCATION) - return SUBTREE_RETURN_FINISH_PLANNING +// ===== SURRENDER (CR-10) ===== /** - * tg's ranged attack, with the style doing the shooting: its wind-up telegraph, its magazine and - * reload, through the mob's ranged_attacks component. The pistol keeps BOUNTY_PISTOL_RANGE off and - * backs off a step when someone gets inside its style's min_range. Planning carries on meanwhile, - * so a new target, a retreat or a call for help is picked up mid-fight. + * When a normal criminal or a companion gives up (defaults CR-10, 1.3): at or below 40% of its health, + * with two hunters within seven tiles that it can see; 60% on its first roll of a fight, less 20 for + * each companion still standing with it, then 25% every 5 seconds. Through the human NPC base's + * human_npc_surrender subtree, which stows the weapon, says the line and runs tg's *surrender. */ -/datum/ai_behavior/basic_ranged_attack/bounty - // Often enough that the pistol fires at its own pace, and its wind-up is never stretched; each tick walks the line of fire (L10) - action_cooldown = 0.1 SECONDS - behavior_flags = AI_BEHAVIOR_REQUIRE_MOVEMENT | AI_BEHAVIOR_MOVE_AND_PERFORM | AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION - required_distance = BOUNTY_PISTOL_RANGE - chase_range = BOUNTY_FIGHT_VISION - avoid_friendly_fire = TRUE - -/datum/ai_behavior/basic_ranged_attack/bounty/perform(seconds_per_tick, datum/ai_controller/controller, target_key, targeting_strategy_key, hiding_location_key) - var/mob/living/basic/fighter = controller.pawn - var/atom/target = controller.blackboard[target_key] - var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(controller.blackboard[targeting_strategy_key]) - if(!strategy.can_attack(fighter, target, chase_range)) - return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED - var/datum/bounty_style/style = bounty_ai_style(fighter) - if(!style?.ranged) - return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED - if(!can_see(fighter, target, required_distance)) - return AI_BEHAVIOR_INSTANT - if(style.min_range && get_dist(fighter, target) < style.min_range && !controller.blackboard[BB_BOUNTY_WINDUP_UNTIL]) - back_off(controller, fighter, target) - if(avoid_friendly_fire && check_friendly_in_path(fighter, target, strategy)) - adjust_position(fighter, target) - return AI_BEHAVIOR_DELAY - return style.ranged_tick(fighter, target) - -/// tg's sidestep out of a friend's line of fire, never off the leash, into lava or into a chasm (L11) -/datum/ai_behavior/basic_ranged_attack/bounty/adjust_position(mob/living/living_pawn, atom/target) - var/turf/our_turf = get_turf(living_pawn) - if(!our_turf) +/datum/human_npc_surrender/bounty + chance = BOUNTY_SURRENDER_CHANCE + retry_chance = BOUNTY_SURRENDER_RETRY + ally_penalty = BOUNTY_SURRENDER_PER_COMPANION + health_share = BOUNTY_SURRENDER_BELOW + hostiles_needed = BOUNTY_SURRENDER_HUNTERS + range = BOUNTY_SURRENDER_HUNTER_RANGE + retry_delay = BOUNTY_SURRENDER_RETRY_GAP + +/// The hunters near it that can see it: a spatial grid lookup of player mobs, as the criminal AI looks around +/datum/human_npc_surrender/bounty/hostiles_near(mob/living/carbon/human/npc/npc) + . = list() + var/turf/here = get_turf(npc) + if(!here) return - var/mob/living/basic/bounty_criminal/leash_holder = bounty_ai_side_of(living_pawn) - var/list/possible_turfs = list() - for(var/direction in GLOB.alldirs) - var/turf/target_turf = get_step(our_turf, direction) - if(isnull(target_turf) || target_turf.is_blocked_turf() || get_dist(target_turf, target) > get_dist(living_pawn, target)) - continue - if(islava(target_turf) || ischasm(target_turf) || !target_turf.can_cross_safely(living_pawn)) + for(var/mob/living/person in SSspatial_grid.orthogonal_range_search(here, SPATIAL_GRID_CONTENTS_TYPE_CLIENTS, range)) + if(!bounty_ai_is_hunter(person) || get_dist(here, person) > range || !can_see(person, here, range)) continue - if(leash_holder && !leash_holder.leash_ok(target_turf)) - continue - possible_turfs += target_turf - if(!length(possible_turfs)) - return - var/turf/picked_turf = get_closest_atom(/turf, possible_turfs, target) - living_pawn.Move(picked_turf, get_dir(living_pawn, picked_turf)) + . += person -/// A wind-up cut short never carries over: the next shot telegraphs again -/datum/ai_behavior/basic_ranged_attack/bounty/finish_action(datum/ai_controller/controller, succeeded, target_key, targeting_strategy_key, hiding_location_key) - . = ..() - controller.clear_blackboard_key(BB_BOUNTY_WINDUP_UNTIL) - -/// A step back from `target`, now and then, never off the leash -/datum/ai_behavior/basic_ranged_attack/bounty/proc/back_off(datum/ai_controller/controller, mob/living/basic/fighter, atom/target) - if(world.time < controller.blackboard[BB_BOUNTY_BACKSTEP_AT] || !isturf(fighter.loc)) - return - controller.set_blackboard_key(BB_BOUNTY_BACKSTEP_AT, world.time + BOUNTY_BACKSTEP_GAP) - var/away_dir = get_dir(target, fighter) - var/turf/away = get_step(fighter, away_dir) - if(!away_dir || !away || away.is_blocked_turf(source_atom = fighter) || islava(away) || ischasm(away)) - return - var/mob/living/basic/bounty_criminal/leash_holder = bounty_ai_side_of(fighter) - if(leash_holder && !leash_holder.leash_ok(away)) +/// The companions still standing with it (a companion counts its criminal's other companions) +/datum/human_npc_surrender/bounty/allies_near(mob/living/carbon/human/npc/npc) + . = list() + var/mob/living/carbon/human/npc/bounty_criminal/side = bounty_ai_side_of(npc) + if(!side) return - fighter.Move(away, away_dir) - fighter.face_atom(target) - -/// The shotgun closes in to BOUNTY_SHOTGUN_RANGE -/datum/ai_behavior/basic_ranged_attack/bounty/close - required_distance = BOUNTY_SHOTGUN_RANGE - -/// The bottle thrower stays BOUNTY_BOTTLE_RANGE off -/datum/ai_behavior/basic_ranged_attack/bounty/throw - required_distance = BOUNTY_BOTTLE_RANGE - -// ===== SURRENDER ===== - -/** - * Rolls to give up as a hit is about to land (combat.md N2): BOUNTY_SURRENDER_CHANCE on the hit that - * crosses BOUNTY_SURRENDER_BELOW, less BOUNTY_SURRENDER_PER_COMPANION for each companion still up, - * then BOUNTY_SURRENDER_RETRY on later hits at most every BOUNTY_SURRENDER_RETRY_GAP. Only with - * BOUNTY_SURRENDER_HUNTERS hunters near. Rolled before the damage lands, so the body's mercy rule - * can see TRAIT_BOUNTY_SURRENDERED on that same hit. Must not sleep: it runs in a signal handler. - */ -/mob/living/basic/bounty_criminal/proc/ai_check_surrender(damage, damagetype) - if(damage <= 0 || blended || !(damagetype in list(BRUTE, BURN)) || !ai_can_act()) + for(var/mob/living/carbon/human/npc/bounty_companion/buddy as anything in side.ai_companions()) + if(buddy != npc && buddy.ai_can_fight() && buddy.body_position == STANDING_UP) + . += buddy + +/// Not while blended in at a trader outpost (nothing gives the fugitive away but P6's rules, C1) +/datum/human_npc_surrender/bounty/should_consider(mob/living/carbon/human/npc/npc, list/hostiles, list/allies) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = npc + if(istype(criminal) && criminal.blended) return FALSE - var/line = maxHealth * BOUNTY_SURRENDER_BELOW - var/coeff = damage_coeff?[damagetype] - var/after = health - damage * (isnull(coeff) ? 1 : coeff) - var/chance - if(health > line && after <= line && !ai_surrender_rolled) - ai_surrender_rolled = TRUE - chance = ai_surrender_chance() - else if(health <= line && world.time >= ai_next_surrender_roll) - chance = BOUNTY_SURRENDER_RETRY - else - return FALSE - ai_next_surrender_roll = world.time + BOUNTY_SURRENDER_RETRY_GAP - if(bounty_ai_hunters_near(src, BOUNTY_SURRENDER_HUNTER_RANGE) < BOUNTY_SURRENDER_HUNTERS || !prob(chance)) - return FALSE - ai_surrender() - return TRUE + return ..() -/// The chance on the crossing hit: less for each companion still standing with them -/mob/living/basic/bounty_criminal/proc/ai_surrender_chance() - var/standing = 0 - for(var/mob/living/basic/bounty_companion/buddy as anything in ai_companions()) - if(buddy.ai_can_fight()) - standing++ - return max(0, BOUNTY_SURRENDER_CHANCE - standing * BOUNTY_SURRENDER_PER_COMPANION) +/// The chance on the first roll of a fight: less for each companion still standing with them +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_surrender_chance() + var/datum/human_npc_surrender/rules = npc_surrender_rules() || human_npc_singleton(/datum/human_npc_surrender/bounty) + return rules.odds(src, list(src), rules.allies_near(src), TRUE) /** - * They give up: hands up (an overhead mark), no more attacks, cuffable in 2 s, and a full share at - * the pad until cuffed (P2's capture_state() reads the trait as STUNNED). Hitting them afterwards - * does not undo it. Their companions may lose heart. + * Gives up now: the human NPC base's npc_surrender() (the weapon stowed, the line, tg's *surrender). + * Returns TRUE if they are lying there with their hands on their head. Its AI side + * (ai_on_surrendered()) runs from the base's COMSIG_HUMAN_NPC_SURRENDERED. */ -/mob/living/basic/bounty_criminal/proc/ai_surrender() - if(HAS_TRAIT(src, TRAIT_BOUNTY_SURRENDERED) || stat == DEAD) - return - ADD_TRAIT(src, TRAIT_BOUNTY_SURRENDERED, BOUNTY_TRAIT) - body_note_state() - ai_stop_aiming() - ai_suspend_activity() - ai_set_mode(BOUNTY_AI_CALM) - ai_hand = bounty_ai_update_held(src, ai_hand, null) - ai_over_head = bounty_ai_update_held(src, ai_over_head, /obj/effect/abstract/bounty_surrender_mark, over_head = TRUE) - REMOVE_TRAIT(src, TRAIT_BOUNTY_SPRINTING, BOUNTY_AI_TRAIT) - if(!QDELETED(ai_controller)) - ai_controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) - ai_controller.clear_blackboard_key(BB_BOUNTY_DESTINATION) - ai_controller.ai_movement?.stop_moving_towards(ai_controller) - ai_controller.CancelActions() - visible_message(span_notice("[src] raises [p_their()] hands and gives up.")) - // Forced: it usually comes right after a "hurt" line, inside that line's cooldown (BUG-1) - ai_bark("surrender", TRUE) - ai_companions_lose_heart() - -/// Only its look is used: the hands-up mark over a surrendered criminal's head -/obj/effect/abstract/bounty_surrender_mark - icon = 'icons/hud/screen_alert.dmi' - icon_state = "surrender" +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_surrender() + return npc_surrender() // ===== RETREAT ===== /// Badly hurt with no hunter near: they break off rather than wait to be found -/mob/living/basic/bounty_criminal/proc/ai_should_retreat() +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_should_retreat() if(!ai_can_act() || health > maxHealth * BOUNTY_NORMAL_RETREAT_BELOW) return FALSE return !bounty_ai_hunters_near(src, BOUNTY_SURRENDER_HUNTER_RANGE) /** * Gets away from `from` (or where they stand) to somewhere about BOUNTY_NORMAL_RETREAT_DISTANCE - * off on their site, picked from a handful of random tiles once, and sits it out there. They do not - * heal; a hunter coming close starts the fight again. + * off on their site, picked from a handful of random tiles once, and sits it out there, patching + * themselves up with what they carry. A hunter coming close starts the fight again. */ -/mob/living/basic/bounty_criminal/proc/ai_start_retreat(mob/living/from) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_start_retreat(mob/living/from) if(!ai_can_act() || QDELETED(ai_controller)) return FALSE var/turf/here = get_turf(src) @@ -401,8 +283,8 @@ best_distance = distance ai_suspend_activity() ai_set_mode(BOUNTY_AI_RETREATING) - ai_hand = bounty_ai_update_held(src, ai_hand, null) - ai_set_pace(BOUNTY_NORMAL_SPEED_RANGED) + bounty_ai_holster(src) + ai_set_pace(BOUNTY_RUN_SPEED) ai_controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) if(best) ai_controller.set_blackboard_key(BB_BOUNTY_DESTINATION, best) @@ -411,11 +293,11 @@ ai_bark("hurt") return TRUE -/// Walks to where they retreat to, then sits down there, winded and hurt +/// Walks to where they retreat to, then sits down on the floor there and treats themselves (N6) /datum/ai_planning_subtree/bounty_retreat /datum/ai_planning_subtree/bounty_retreat/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/bounty_criminal/criminal = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/criminal = controller.pawn if(criminal.ai_mode != BOUNTY_AI_RETREATING) return var/turf/destination = controller.blackboard[BB_BOUNTY_DESTINATION] @@ -427,411 +309,7 @@ criminal.ai_set_pace(BOUNTY_CALM_SPEED) criminal.ai_crouch() criminal.visible_message(span_notice("[criminal] sits down heavily, catching [criminal.p_their()] breath.")) + if(criminal.health < criminal.maxHealth && bounty_ai_queue_treat_self(controller)) + return SUBTREE_RETURN_FINISH_PLANNING controller.queue_behavior(/datum/ai_behavior/bounty_watch) return SUBTREE_RETURN_FINISH_PLANNING - -// ===== STYLES ===== - -/// Every fighting style by key (BOUNTY_STYLE_*), one datum each -GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) - -/proc/init_bounty_styles() - var/list/styles = list() - for(var/datum/bounty_style/style_type as anything in subtypesof(/datum/bounty_style)) - var/datum/bounty_style/style = new style_type - if(style.key) - styles[style.key] = style - return styles - -/// A fighter's style: from its controller's blackboard -/proc/bounty_ai_style(mob/living/basic/fighter) - var/datum/ai_controller/controller = fighter?.ai_controller - if(QDELETED(controller)) - return null - return GLOB.bounty_styles[controller.blackboard[BB_BOUNTY_STYLE]] - -/// The item a fighter fights with and shows in their hand (a typepath), or null for bare fists -/proc/bounty_ai_held_look(mob/living/basic/fighter) - var/datum/ai_controller/controller = fighter?.ai_controller - if(QDELETED(controller)) - return null - return controller.blackboard[BB_BOUNTY_WEAPON] - -/// The real weapon a fighter fights with: the item in their hand, loaded as their style loads it. Null with no style. -/proc/bounty_ai_real_weapon(mob/living/basic/fighter) - var/datum/bounty_style/style = bounty_ai_style(fighter) - if(!style) - return null - return bounty_real_weapon(bounty_ai_held_look(fighter), style.ammo_type) - -// A style's health multiplier is P2's bounty_style_health_mult() (bounty_criminal.dm), from the combat.md defines. - -/// Stamina damage multiplier of a style (the brawler shrugs off some): P2 folds it into damage_coeff[STAMINA] -/proc/bounty_style_stamina_mult(style_key) - var/datum/bounty_style/style = GLOB.bounty_styles[style_key] - return style ? style.stamina_mult : 1 - -/** - * Puts style `key` on `fighter`: its weapon (the style's heavy_look if `heavy` and it has one), a - * full magazine, and the blow and the gun that weapon gives. - */ -/proc/bounty_ai_apply_style(mob/living/basic/fighter, key, heavy = FALSE) - var/datum/bounty_style/style = GLOB.bounty_styles[key] - var/datum/ai_controller/controller = fighter?.ai_controller - if(!style || QDELETED(controller)) - return FALSE - var/weapon_type = (heavy && style.heavy_look) || style.held_look - var/datum/bounty_real_weapon/weapon = bounty_real_weapon(weapon_type, style.ammo_type) - controller.set_blackboard_key(BB_BOUNTY_STYLE, key) - if(weapon_type) - controller.set_blackboard_key(BB_BOUNTY_WEAPON, weapon_type) - else - controller.clear_blackboard_key(BB_BOUNTY_WEAPON) - controller.set_blackboard_key(BB_BOUNTY_AMMO, weapon.magazine) - controller.clear_blackboard_key(BB_BOUNTY_RELOAD_UNTIL) - controller.clear_blackboard_key(BB_BOUNTY_WINDUP_UNTIL) - style.apply(fighter, weapon) - return TRUE - -/** - * How someone fights (combat.md 6.2). Criminals, companions and the meek's holdout share these. - * Every blow and shot is the real weapon's (bounty_weapons.dm): the item the style puts in their - * hand gives its damage, wounds, armour penetration, rounds and magazine, so a 9mm is a 9mm - * whoever fires it. The style only sets the timing: how fast they swing or fire, the telegraph, the - * reload and the distance they keep. Melee styles hit through the mob's own melee attack; ranged - * ones shoot through its ranged_attacks component. Nothing is spawned for the fight, and nothing - * drops. - */ -/datum/bounty_style - /// BOUNTY_STYLE_* - var/key - /// Fights at range - var/ranged = FALSE - /// Health multiplier (P2 applies it to a criminal; companions apply it themselves) - var/health_mult = 1 - /// Stamina damage multiplier (P2 applies it to a criminal) - var/stamina_mult = 1 - /// Between attacks - var/interval = 1.4 SECONDS - /// Speed in a fight - var/speed = BOUNTY_NORMAL_SPEED_MELEE - /// The real item they fight with, shown in their hand (a typepath; null for bare fists) - var/held_look - /// The heavier real item a Wanted criminal carries instead, if the style has one - var/heavy_look - /// What a gun is loaded with instead of what it comes with (a shotgun's buckshot) - var/ammo_type - /// Ranged: the NPCs' own projectile a round flies as, and the sound of a throw (a gun sounds like itself) - var/projectile_type - var/projectile_sound - /// The ranged behavior that keeps this style's distance - var/ranged_behavior = /datum/ai_behavior/basic_ranged_attack/bounty - /// Anyone closer than this and they step back (0: never) - var/min_range = 0 - /// The telegraph before a shot or throw, and what it says and sounds like - var/windup = 0 - var/windup_message - var/windup_sound - /// How long a reload takes once the magazine is spent, and what it sounds like - var/reload_time = 0 - var/reload_sound - -/// Sets `weapon`'s blow and gun on `fighter`, at this style's pace -/datum/bounty_style/proc/apply(mob/living/basic/fighter, datum/bounty_real_weapon/weapon) - fighter.melee_attack_cooldown = interval - weapon.apply_melee(fighter) - var/datum/component/ranged_attacks/gun = fighter.GetComponent(/datum/component/ranged_attacks) - if(!gun || !projectile_type) - return - gun.casing_type = null - gun.projectile_type = projectile_type - gun.projectile_sound = weapon.fire_sound || projectile_sound - gun.cooldown_time = interval - gun.burst_shots = null - gun.burst_intervals = 0 - -/// Anything extra a melee hit does -/datum/bounty_style/proc/on_melee_hit(mob/living/basic/fighter, mob/living/target) - return - -/// Whether this shot needs the telegraph first -/datum/bounty_style/proc/needs_windup(datum/ai_controller/controller) - return windup > 0 - -/// The telegraph: what they say, show and sound like before the shot -/datum/bounty_style/proc/telegraph(mob/living/basic/fighter, atom/target) - fighter.face_atom(target) - var/look = bounty_ai_held_look(fighter) - if(look) - bounty_ai_hold(fighter, look) - if(windup_message) - fighter.visible_message(span_warning(replacetext(windup_message, "%USER", "[fighter]"))) - if(windup_sound) - playsound(fighter, windup_sound, 50, TRUE) - -/** - * One tick of a ranged fight: reloading, winding up, or firing through the ranged_attacks - * component when it is ready. Returns the AI behavior flags. - */ -/datum/bounty_style/proc/ranged_tick(mob/living/basic/fighter, atom/target) - var/datum/ai_controller/controller = fighter.ai_controller - var/datum/bounty_real_weapon/weapon = bounty_ai_real_weapon(fighter) - var/magazine = weapon?.magazine - var/now = world.time - var/reload_until = controller.blackboard[BB_BOUNTY_RELOAD_UNTIL] - if(reload_until) - if(now < reload_until) - return AI_BEHAVIOR_DELAY - controller.clear_blackboard_key(BB_BOUNTY_RELOAD_UNTIL) - controller.set_blackboard_key(BB_BOUNTY_AMMO, magazine) - if(magazine && controller.blackboard[BB_BOUNTY_AMMO] <= 0) - controller.set_blackboard_key(BB_BOUNTY_RELOAD_UNTIL, now + reload_time) - fighter.visible_message(span_notice("[fighter] reloads.")) - if(reload_sound) - playsound(fighter, reload_sound, 50, TRUE) - return AI_BEHAVIOR_DELAY - var/datum/component/ranged_attacks/gun = fighter.GetComponent(/datum/component/ranged_attacks) - if(!gun) - return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED - var/windup_until = controller.blackboard[BB_BOUNTY_WINDUP_UNTIL] - if(windup_until && now > windup_until + 1 SECONDS) - // A wind-up left over from an interrupted fight: it has to be done again - controller.clear_blackboard_key(BB_BOUNTY_WINDUP_UNTIL) - windup_until = null - if(!windup_until) - if(gun.fire_cooldown > now + windup) - return AI_BEHAVIOR_DELAY - if(needs_windup(controller)) - controller.set_blackboard_key(BB_BOUNTY_WINDUP_UNTIL, now + windup) - telegraph(fighter, target) - return AI_BEHAVIOR_DELAY - else if(now < windup_until) - fighter.face_atom(target) - return AI_BEHAVIOR_DELAY - controller.clear_blackboard_key(BB_BOUNTY_WINDUP_UNTIL) - fighter.RangedAttack(target) - return AI_BEHAVIOR_DELAY - -/// After each shot: the magazine and the clock for the next string -/datum/bounty_style/proc/after_shot(mob/living/basic/fighter) - var/datum/ai_controller/controller = fighter.ai_controller - if(QDELETED(controller)) - return - controller.set_blackboard_key(BB_BOUNTY_LAST_SHOT, world.time) - var/datum/bounty_real_weapon/weapon = bounty_ai_real_weapon(fighter) - if(weapon?.magazine) - controller.set_blackboard_key(BB_BOUNTY_AMMO, max(0, controller.blackboard[BB_BOUNTY_AMMO] - 1)) - -/** - * Loads a shot as it leaves the gun: the real round's numbers and its spread, and the rest of a - * shell's pellets fired alongside it (one shell, one shot from the magazine). A thrown bottle - * takes the bottle's throw. Called inside the projectile's fire(): must not sleep. - */ -/datum/bounty_style/proc/prepare_projectile(mob/living/basic/fighter, obj/projectile/shot) - var/datum/bounty_real_weapon/weapon = bounty_ai_real_weapon(fighter) - if(!weapon) - return - if(istype(shot, /obj/projectile/bounty_bottle)) - weapon.load_thrown(shot) - return - var/obj/projectile/bullet/bounty/bullet = shot - if(!istype(bullet) || bullet.round_loaded) - return - bullet.round_loaded = TRUE - if(!weapon.load(bullet)) - return - bullet.set_angle(bullet.angle + weapon.shot_spread()) - for(var/pellet in 2 to weapon.pellets) - INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(bounty_ai_fire_pellet), fighter, weapon, bullet.type, bullet.original) - -/// Another pellet of the shell `fighter` just fired at `target`, with its own spread -/proc/bounty_ai_fire_pellet(mob/living/basic/fighter, datum/bounty_real_weapon/weapon, shot_type, atom/target) - var/turf/start = get_turf(fighter) - if(!start || QDELETED(fighter) || QDELETED(target)) - return null - var/obj/projectile/bullet/bounty/pellet = new shot_type(start) - pellet.round_loaded = TRUE - weapon.load(pellet) - pellet.firer = fighter - pellet.fired_from = fighter - pellet.aim_projectile(target, fighter, null, weapon.shot_spread()) - if(QDELETED(pellet)) - return null - pellet.fire() - return pellet - -/// Bare fists: a human's punch -/datum/bounty_style/brawler - key = BOUNTY_STYLE_BRAWLER - health_mult = BOUNTY_BRAWLER_HEALTH - stamina_mult = BOUNTY_BRAWLER_STAMINA - interval = BOUNTY_BRAWLER_INTERVAL - -/// Now and then a punch shoves them back a tile (never onto lava, into a chasm or out into space, M5) and staggers them; no stun -/datum/bounty_style/brawler/on_melee_hit(mob/living/basic/fighter, mob/living/target) - if(target.stat != CONSCIOUS || !prob(BOUNTY_BRAWLER_SHOVE_CHANCE)) - return - bounty_ai_shove_back(fighter, target) - target.apply_status_effect(/datum/status_effect/staggered, BOUNTY_BRAWLER_STAGGER) - fighter.visible_message(span_warning("[fighter] shoves [target] back!")) - playsound(target, 'sound/items/weapons/shove.ogg', 50, TRUE) - -/// The blade's own cuts bleed, as a real one's do -/datum/bounty_style/knife - key = BOUNTY_STYLE_KNIFE - health_mult = BOUNTY_KNIFE_HEALTH - interval = BOUNTY_KNIFE_INTERVAL - held_look = /obj/item/knife/kitchen - heavy_look = /obj/item/knife/combat - -/datum/bounty_style/club - key = BOUNTY_STYLE_CLUB - health_mult = BOUNTY_CLUB_HEALTH - interval = BOUNTY_CLUB_INTERVAL - held_look = /obj/item/melee/baseball_bat - heavy_look = /obj/item/melee/baseball_bat/ablative - -/// A bat knocks them back a tile or two, gently, as tg's bat does; never onto lava, into a chasm or out into space -/datum/bounty_style/club/on_melee_hit(mob/living/basic/fighter, mob/living/target) - if(QDELETED(target) || target.stat == DEAD) - return - bounty_throw_back(fighter, target, rand(1, 2), prob(60) ? 1 : 4, gentle = TRUE) - -/datum/bounty_style/pistol - key = BOUNTY_STYLE_PISTOL - ranged = TRUE - health_mult = BOUNTY_PISTOL_HEALTH - interval = BOUNTY_PISTOL_INTERVAL - speed = BOUNTY_NORMAL_SPEED_RANGED - held_look = /obj/item/gun/ballistic/automatic/pistol/aps - projectile_type = /obj/projectile/bullet/bounty - windup = BOUNTY_PISTOL_WINDUP - windup_message = "%USER raises a pistol." - windup_sound = 'sound/items/weapons/gun/pistol/rack_small.ogg' - min_range = BOUNTY_PISTOL_MIN_RANGE - reload_time = BOUNTY_PISTOL_RELOAD - reload_sound = 'sound/items/weapons/gun/pistol/mag_insert.ogg' - -/// Only the first shot of a string needs the gun raised -/datum/bounty_style/pistol/needs_windup(datum/ai_controller/controller) - var/last_shot = controller.blackboard[BB_BOUNTY_LAST_SHOT] - return !last_shot || world.time - last_shot > BOUNTY_PISTOL_STRING_GAP - -/// A reload starts a new string -/datum/bounty_style/pistol/ranged_tick(mob/living/basic/fighter, atom/target) - var/datum/ai_controller/controller = fighter.ai_controller - if(controller.blackboard[BB_BOUNTY_RELOAD_UNTIL] && world.time >= controller.blackboard[BB_BOUNTY_RELOAD_UNTIL]) - controller.clear_blackboard_key(BB_BOUNTY_LAST_SHOT) - return ..() - -/// Buckshot: every pellet of a shell, one shell a shot -/datum/bounty_style/shotgun - key = BOUNTY_STYLE_SHOTGUN - ranged = TRUE - health_mult = BOUNTY_SHOTGUN_HEALTH - interval = BOUNTY_SHOTGUN_INTERVAL - speed = BOUNTY_NORMAL_SPEED_RANGED - held_look = /obj/item/gun/ballistic/shotgun - heavy_look = /obj/item/gun/ballistic/shotgun/automatic/combat - ammo_type = /obj/item/ammo_casing/shotgun/buckshot - projectile_type = /obj/projectile/bullet/bounty - ranged_behavior = /datum/ai_behavior/basic_ranged_attack/bounty/close - windup = BOUNTY_SHOTGUN_WINDUP - windup_message = "%USER pumps the shotgun." - windup_sound = 'sound/items/weapons/gun/shotgun/rack.ogg' - reload_time = BOUNTY_SHOTGUN_RELOAD - reload_sound = 'sound/items/weapons/gun/shotgun/insert_shell.ogg' - -/// A beer bottle, thrown: it hits with the bottle's throwforce, and breaks -/datum/bounty_style/bottle - key = BOUNTY_STYLE_BOTTLE - ranged = TRUE - health_mult = BOUNTY_BOTTLE_HEALTH - interval = BOUNTY_BOTTLE_INTERVAL - speed = BOUNTY_NORMAL_SPEED_RANGED - held_look = /obj/item/reagent_containers/cup/glass/bottle/beer - projectile_type = /obj/projectile/bounty_bottle - projectile_sound = 'sound/items/weapons/punchmiss.ogg' - ranged_behavior = /datum/ai_behavior/basic_ranged_attack/bounty/throw - min_range = BOUNTY_BOTTLE_MIN_RANGE - windup = BOUNTY_BOTTLE_WINDUP - windup_message = "%USER winds up to throw a bottle." - -/** - * The meek's little gun: a quick volley when cornered, once per cornering. The volley is fired - * one shot at a time by the meek AI (bounty_ai_meek.dm), each shot checking they can still shoot, - * so the gun here only has to be ready again between shots. - */ -/datum/bounty_style/holdout - key = BOUNTY_STYLE_HOLDOUT - ranged = TRUE - interval = BOUNTY_MEEK_PISTOL_GAP * 0.8 - speed = BOUNTY_MEEK_SPRINT_SPEED - held_look = /obj/item/gun/ballistic/automatic/pistol - projectile_type = /obj/projectile/bullet/bounty/holdout - -// ===== WHAT THEY FIRE ===== - -/** - * A criminal's bullet or pellet: the real round's numbers are put on it as it is fired - * (/datum/bounty_style/proc/prepare_projectile()), embedding and all. It never hits the shooter's - * own gang, and off their site or at a trader outpost it passes anyone the body's rules leave alone - * (AR-C8, AR-D1; bounty_ai_may_hit(), so a companion's shots don't depend on its criminal being up, - * H3): only a direct target is hit regardless. - */ -/obj/projectile/bullet/bounty - name = "bullet" - /// The round's numbers are on it already: a pellet fired alongside a shell's first - var/round_loaded = FALSE - -/obj/projectile/bullet/bounty/can_hit_target(atom/target, direct_target = FALSE, ignore_loc = FALSE, cross_failed = FALSE) - . = ..() - if(!. || direct_target || !isliving(target) || !firer) - return - if(!bounty_ai_may_hit(firer, target)) - return FALSE - -/// The meek's holdout fires these -/obj/projectile/bullet/bounty/holdout - name = "small bullet" - -/** - * A thrown bottle: it flies slower than a bullet, hits with the bottle's throw, and smashes where it - * lands, leaving broken glass on the floor (a decal, never a weapon). - */ -/obj/projectile/bounty_bottle - name = "bottle" - icon = 'icons/obj/drinks/bottles.dmi' - icon_state = "beer" - damage_type = BRUTE - armor_flag = MELEE - speed = 0.6 - range = BOUNTY_BOTTLE_REACH - hitsound = 'sound/effects/glass/glassbr1.ogg' - hitsound_wall = 'sound/effects/glass/glassbr2.ogg' - /// Smashed already, so it leaves glass once - var/smashed = FALSE - -/obj/projectile/bounty_bottle/can_hit_target(atom/target, direct_target = FALSE, ignore_loc = FALSE, cross_failed = FALSE) - . = ..() - if(!. || direct_target || !isliving(target) || !firer) - return - if(!bounty_ai_may_hit(firer, target)) - return FALSE - -/obj/projectile/bounty_bottle/on_hit(atom/target, blocked = 0, pierce_hit) - . = ..() - smash(get_turf(target)) - -/obj/projectile/bounty_bottle/on_range() - smash(get_turf(src)) - return ..() - -/// Broken glass where it landed -/obj/projectile/bounty_bottle/proc/smash(turf/where) - if(smashed || !where) - return - smashed = TRUE - if(!isgroundlessturf(where) && !isspaceturf(where)) - new /obj/effect/decal/cleanable/glass(where) - playsound(where, 'sound/effects/glass/glassbr3.ogg', 50, TRUE) diff --git a/voidcrew/modules/bounties/bounty_board.dm b/voidcrew/modules/bounties/bounty_board.dm index 7f17d045fe0..28617021795 100644 --- a/voidcrew/modules/bounties/bounty_board.dm +++ b/voidcrew/modules/bounties/bounty_board.dm @@ -186,7 +186,7 @@ SUBSYSTEM_DEF(criminal_bounties) /datum/controller/subsystem/criminal_bounties/proc/board_live_criminals() var/count = 0 for(var/datum/criminal_bounty/posting as anything in GLOB.criminal_bounties) - var/mob/living/basic/bounty_criminal/criminal = posting.criminal() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = posting.criminal() if(criminal && criminal.stat != DEAD) count++ return count diff --git a/voidcrew/modules/bounties/bounty_boss.dm b/voidcrew/modules/bounties/bounty_boss.dm index 94d389fabdf..8c4b1680f80 100644 --- a/voidcrew/modules/bounties/bounty_boss.dm +++ b/voidcrew/modules/bounties/bounty_boss.dm @@ -5,32 +5,42 @@ * the tests in voidcrew/modules/unit_tests/voidcrew_bounty_bosses.dm. Do not edit this file * outside P4. * - * What it owns: /mob/living/basic/bounty_criminal/boss (its body, built-in values and AI tree), the - * bounty ability base with its wind-up, telegraph and stale-serial guard (a port of the prison - * horror's pattern, not a reuse of its type), health that grows with the posse, tiredness below - * BOUNTY_BOSS_TIRED_BELOW percent, the limits on what it may break, and on_confronted() for bosses - * (spec section 5, 12.3 C8). + * What it owns: /mob/living/carbon/human/npc/bounty_criminal/boss (its body's built-in values, its gear + * and its AI), the bounty ability base with its wind-up, telegraph and stale-serial guard (a port of + * the prison horror's pattern), the posse and its reinforcements, the limits on what it may break, its + * scripted fire and blasts, and on_confronted() for bosses (spec section 5, 12.3 C8). * - * The shared vars are declared in bounty_types.dm and nowhere else; a var only P4 uses goes here - * with a `boss_` prefix, or on the /boss subtypes. + * A boss is a real human (the human NPC base, voidcrew/modules/human_npcs/; owner decision D5). Its + * crit, stamina, stamcrit, stuns, cuffs, wounds, bleeding and death are tg's, exactly as a player's: + * - Toughness is real armour from its kit (locked to its body, D3) and npc_damage_taken + * (BOUNTY_BOSS_DAMAGE_TAKEN), fixed whatever the posse (defaults 1.5, OC-8). Never health. + * - Resistance to stuns is its armour and a real stimulant pen it carries and injects, with a visible + * emote, when its fight starts (defaults 1.6). A second pen is its second wind. + * - "Worn out" is its AI reading real state (stamina loss over half its pool, or health under 40%): it + * says so, falls back, and then takes its second pen if it has one (CB-2, CR-4). + * - It fights with what it holds (real knives, a real torch, a real gun, its fists) through its hands, + * the way a player does (controller.ai_interact()). + * - It never surrenders. Bosses execute nobody this phase (the core's hv_can_execute(), OC-9). * * How a fight goes: * - A boss waits (its activity, if P3 gives it one) until it spots a hunter, is attacked or is * confronted. Then it turns hostile: every player within BOUNTY_BOSS_POSSE_RANGE who can see it - * joins its posse, and its health is set from the kit's table for that many hunters. Anyone who - * hurts it later joins too, raising its health again (never lowering it). - * - Its AI: nothing while busy or disabled; a target; an ability, never the same one twice in a - * row; the kit's way of closing in or keeping away; its melee attack; and with nobody in sight, - * the hunt for the nearest hunter still on its site. It calms down after BOUNTY_BOSS_CALM_TIME - * with nobody around. + * joins its posse. Each hunter in the posse beyond the first brings one more companion in from out of + * their view, one at a time (OC-8, CB-1), up to BOUNTY_BOSS_REINFORCEMENTS_MAX. + * - Its AI: soft crit and breaking free first (the human NPC base's and the core's); nothing while + * busy or disabled; worn out, it falls back; its stimulant; a target; its kit's gear; an ability, + * never the same one twice in a row; the kit's way of closing in or keeping away; its melee; patching + * itself up with nobody about; and with nobody in sight, the hunt for the nearest hunter still on its + * site. It calms down after BOUNTY_BOSS_CALM_TIME with nobody around. * - Every ability winds up first, where everyone can see and hear it (telegraph()), and does its - * harm only when the wind-up is over (effect()). Downed, restrained, stunned or dead in between, - * and nothing happens. - * - Below BOUNTY_BOSS_TIRED_BELOW percent health it tires: slower, longer cooldowns, and stamina - * weapons work fully, so it can be stunned and cuffed. That is the capture window. + * harm only when the wind-up is over (effect()). Downed, restrained, stunned, knocked down or dead + * in between (tg's states, CB-24), and nothing happens. + * - Who it chooses to go after is never someone already down (npc_target_stat, its targeting). What + * its fire and blasts catch is whoever stands there, down or not (CB-11, defaults 1.11). * - What it breaks is scripted, never a real explosion or atmos fire: tables, chairs, windows and * grilles, and at most BOUNTY_BOSS_WALL_BUDGET walls or doors a fight, only indoors on its own - * site, never anything with space, the outdoors or another place on its far side. + * site, never anything with space, the outdoors or another place on its far side. People its fire + * reaches burn with tg's fire stacks; people its blasts reach take tg's light explosion. */ /// Trait source for standing still while busy with an ability @@ -47,41 +57,47 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) /proc/bounty_boss_is_hunter(mob/living/candidate) if(!isliving(candidate) || QDELETED(candidate) || candidate.stat == DEAD) return FALSE - if(istype(candidate, /mob/living/basic/bounty_criminal) || istype(candidate, /mob/living/basic/bounty_companion)) + if(bounty_is_gang_body(candidate)) return FALSE return !isnull(candidate.mind) || !isnull(candidate.client) +/** + * Whether a boss's fire or blast catches `thing`, whatever state it is in (CB-11): a person who isn't + * on the boss's side (`side`, its factions), or a mech with one in it. Never a criminal or a companion, + * never anyone in godmode. Where it reaches is the caller's business (boss_reach_ok()). + */ +/proc/bounty_boss_effect_victim(atom/thing, list/side) + if(QDELETED(thing)) + return FALSE + if(ismecha(thing)) + var/obj/vehicle/sealed/mecha/mech = thing + for(var/mob/living/pilot in mech.occupants) + if(bounty_boss_effect_person(pilot, side)) + return TRUE + return FALSE + var/mob/living/person = thing + // A pilot is reached through the mech's hull. + return isliving(person) && !ismecha(person.loc) && bounty_boss_effect_person(person, side) + +/// Whether `person` is someone a boss's fire and blasts catch: anyone not on its side, down, dead or standing +/proc/bounty_boss_effect_person(mob/living/person, list/side) + if(!isliving(person) || QDELETED(person) || HAS_TRAIT(person, TRAIT_GODMODE) || bounty_is_gang_body(person)) + return FALSE + return !length(side) || !faction_check(side, person.faction) + // ===== THE BOSS ===== -/mob/living/basic/bounty_criminal/boss +/mob/living/carbon/human/npc/bounty_criminal/boss name = "wanted criminal" desc = "Someone with a big price on their head, and the gear to keep it." - maxHealth = BOUNTY_JUGGERNAUT_HEALTH_1 - health = BOUNTY_JUGGERNAUT_HEALTH_1 - // Fresh, it shrugs off stuns and knockdowns; boss_update_tired() adds them back once it tires. - status_flags = CANPUSH - move_resist = MOVE_FORCE_STRONG - mob_size = MOB_SIZE_HUMAN - combat_mode = TRUE - // The placement adds the site's own factions (spec section 3), so the site's hostiles leave it be. - faction = list(FACTION_HOSTILE) - environment_smash = ENVIRONMENT_SMASH_NONE - // max_stamina and the stamina crit threshold are P2's (100 and 99.9). Stamina never slows a boss: - // the tired slowdown is the only one the spec asks for, so steady disabler fire can't pin it (H3). - max_stamina_slowdown = 0 - damage_coeff = list(BRUTE = 1, BURN = 1, TOX = 1, STAMINA = BOUNTY_BOSS_STAMINA_FRESH * 100 / BOUNTY_BOSS_STAMINA, OXY = 1) - melee_damage_lower = 10 - melee_damage_upper = 14 - melee_attack_cooldown = 1.5 SECONDS - attack_verb_continuous = "hits" - attack_verb_simple = "hit" - attack_sound = 'sound/items/weapons/punch4.ogg' - attack_vis_effect = ATTACK_EFFECT_PUNCH ai_controller = /datum/ai_controller/basic_controller/bounty_boss + // Aimed crits like a player's (D4); executions stay off for every bounty NPC (the core's hv_can_execute()). + npc_rank = HUMAN_NPC_RANK_BOSS + // Fixed toughness, whatever its tier or posse (defaults 1.5, OC-8). Its armour does the rest. + npc_damage_taken = BOUNTY_BOSS_DAMAGE_TAKEN + body_tier_toughness = FALSE /// BOUNTY_KIT_*: which kit it is, and the prefix of its dialogue contexts var/boss_kit - /// The real item in its hand it strikes with (bounty_real_weapon()): its blows are that item's. Null keeps the kit's own blow. - var/boss_weapon /// The ability types it is given var/list/boss_ability_types = list() /// Its abilities (/datum/action/cooldown/mob_cooldown/bounty_boss), granted at Initialize @@ -92,26 +108,23 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) var/boss_strict_rotation = BOUNTY_BOSS_STRICT_ROTATION /// world.time the next ability may start var/boss_next_ability_at = 0 - /// What keeps it still with its AI quiet ("windup", "charge", "dash", "burst", "stagger"), or null + /// What keeps it still with its AI quiet ("windup", "charge", "dash", "burst"), or null var/boss_busy /// Goes up each time it becomes busy, so a stale timer knows to do nothing var/boss_busy_serial = 0 var/boss_busy_timer /// The ability winding up now, whose telegraph goes if it is interrupted var/datum/weakref/boss_winding_ref - /// Stamina damage it takes to crit it once tired, and its coefficient while fresh - var/boss_stamina_pool = BOUNTY_BOSS_STAMINA - var/boss_stamina_fresh = BOUNTY_BOSS_STAMINA_FRESH - /// At or below BOUNTY_BOSS_TIRED_BELOW percent health - var/boss_tired = FALSE - /// Its speed while fresh, and its brute and burn coefficients (a stagger's weakness puts them back) - var/boss_base_speed - var/boss_brute_coeff = 1 - var/boss_burn_coeff = 1 /// Turned hostile: it spotted a hunter, or someone attacked or confronted it var/boss_hostile = FALSE - /// REF() of each hunter in its posse -> TRUE; its health follows how many + /// REF() of each hunter in its posse -> TRUE var/list/boss_engaged = list() + /// Companions its posse has brought in (OC-8), and how many more are owed and not yet called + var/boss_reinforcements_sent = 0 + var/boss_reinforcements_owed = 0 + var/boss_reinforce_timer + /// Weakrefs to the companions that came in for it + var/list/boss_reinforcement_refs /// Walls and doors it may still break this fight var/boss_walls_left = BOUNTY_BOSS_WALL_BUDGET /// Whoever hurt it last (a person, or the mech they are in), and when @@ -119,54 +132,56 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) var/boss_last_attacked_at = 0 /// world.time it calms down if it still finds no hunter on its site var/boss_calm_at = 0 - -/mob/living/basic/bounty_criminal/boss/Initialize(mapload) + /// Worn out (boss_is_worn_out(), read by its AI): said so, and falls back until boss_fallback_until + var/boss_worn_out = FALSE + var/boss_fallback_until = 0 + /// Stimulant pens it has used: the first when its fight starts, the second for its second wind + var/boss_stimulants_used = 0 + /// Its fall back is over and it is still worn out: its next plan takes the second pen + var/boss_second_wind_due = FALSE + +/mob/living/carbon/human/npc/bounty_criminal/boss/Initialize(mapload, datum/human_npc_order/order) . = ..() - if(boss_weapon) - bounty_real_weapon(boss_weapon).apply_melee(src) - damage_coeff = damage_coeff.Copy() - boss_brute_coeff = damage_coeff[BRUTE] - boss_burn_coeff = damage_coeff[BURN] - boss_base_speed = speed for(var/ability_type in boss_ability_types) var/datum/action/cooldown/mob_cooldown/bounty_boss/ability = new ability_type(src) ability.Grant(src) boss_abilities += ability - AddElement(/datum/element/relay_attackers) AddComponent(/datum/component/bounty_boss_signals) - boss_update_tired(silent = TRUE, force = TRUE) - // Dressed by the spawner when it has a record; an admin spawn with none gets the kit's look. - addtimer(CALLBACK(src, PROC_REF(boss_dress_fallback)), 1, TIMER_DELETE_ME) -/mob/living/basic/bounty_criminal/boss/Destroy() +/mob/living/carbon/human/npc/bounty_criminal/boss/Destroy() boss_interrupt() QDEL_LIST(boss_abilities) deltimer(boss_busy_timer) boss_busy_timer = null + deltimer(boss_reinforce_timer) + boss_reinforce_timer = null + boss_reinforcement_refs = null boss_winding_ref = null boss_last_attacker = null return ..() -/mob/living/basic/bounty_criminal/boss/death(gibbed) +/mob/living/carbon/human/npc/bounty_criminal/boss/death(gibbed) boss_interrupt() - . = ..() - boss_update_hold() + deltimer(boss_reinforce_timer) + boss_reinforce_timer = null + boss_reinforcements_owed = 0 + return ..() -/mob/living/basic/bounty_criminal/boss/examine(mob/user) +/mob/living/carbon/human/npc/bounty_criminal/boss/examine(mob/user) . = ..() - if(stat == DEAD) + if(stat == DEAD || hidden) return var/gear = boss_gear_text() if(gear) . += span_warning(gear) - if(boss_tired) + if(boss_worn_out) . += span_notice("[p_They()] look[p_s()] worn out.") /** * `user` confronted them: showed the warrant, or accused them. A boss doesn't run or argue. It * starts its fight, with `user` first on its list. */ -/mob/living/basic/bounty_criminal/boss/on_confronted(mob/user) +/mob/living/carbon/human/npc/bounty_criminal/boss/on_confronted(mob/user) if(stat != CONSCIOUS || !isliving(user)) return body_add_grudge(user) @@ -175,135 +190,94 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) if(boss_valid_target(target)) ai_controller?.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, target) -/** - * Its blows land on a mech's hull in full (H2): tg's mech defence scales a mob's blow by how much it - * smashes, and a boss smashes nothing, so every blow would do nothing. - */ -/mob/living/basic/bounty_criminal/boss/melee_attack(atom/target, list/modifiers, ignore_cooldown = FALSE) - // Each swing picks one of the weapon's own verbs, as a player's does - if(boss_weapon) - bounty_real_weapon(boss_weapon).pick_verb(src) - if(!ismecha(target)) - return ..() - if(!early_melee_attack(target, modifiers, ignore_cooldown)) - return FALSE - do_attack_animation(target, attack_vis_effect) - if(attack_sound) - playsound(target, attack_sound, 50, TRUE) - target.visible_message(span_danger("[src] [attack_verb_continuous] [target]!")) - boss_hit(target, rand(melee_damage_lower, melee_damage_upper), melee_damage_type, MELEE, 0, armour_penetration, TRUE) - SEND_SIGNAL(src, COMSIG_HOSTILE_POST_ATTACKINGTARGET, target, TRUE) - if(!ignore_cooldown) - changeNext_move(melee_attack_cooldown) - return TRUE - // ----- its kit ----- -/// Health for 1, 2, 3 and 4+ engaged hunters. Each kit has its own. -/mob/living/basic/bounty_criminal/boss/proc/boss_health_table() - return list(initial(maxHealth)) - -/// The outfit its look is built in: each kit has one, so the five read differently at a glance. P2's look uses it. -/mob/living/basic/bounty_criminal/boss/boss_kit_outfit() - return /datum/outfit/bounty_boss +// What each kit wears and carries (bounty_boss_kits.dm): real armour, its weapon carried or held, spare +// ammunition, its stimulants and something to patch itself up with. The base adds vacuum and cold layers. +/mob/living/carbon/human/npc/bounty_criminal/boss/bounty_build_outfit(zone) + return boss_supplies(bounty_outfit_instance(/datum/outfit/bounty_boss)) -/// With no record to dress it from (an admin spawn), the kit's look on a stock face -/mob/living/basic/bounty_criminal/boss/proc/boss_dress_fallback() - if(QDELETED(src) || record) - return - apply_dynamic_human_appearance(src, boss_kit_outfit(), /datum/species/human) +/** + * Packs what every boss carries into `outfit`, an instance: BOUNTY_BOSS_STIMULANTS combat stimulants + * and a bruise pack, in a bag on its back (one is added if it wears none). Returns the outfit. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_supplies(datum/outfit/outfit) + if(!istype(outfit)) + return outfit + outfit.back ||= /obj/item/storage/backpack + LAZYINITLIST(outfit.backpack_contents) + outfit.backpack_contents[BOUNTY_BOSS_STIMULANT] = (outfit.backpack_contents[BOUNTY_BOSS_STIMULANT] || 0) + BOUNTY_BOSS_STIMULANTS + outfit.backpack_contents[/obj/item/stack/medical/bruise_pack] = (outfit.backpack_contents[/obj/item/stack/medical/bruise_pack] || 0) + 1 + return outfit /// A line on examine about its gear, if the kit has one -/mob/living/basic/bounty_criminal/boss/proc/boss_gear_text() +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_gear_text() return null /** * Says a line for "_", or for "_" if there is none for it. Async, so a * signal handler can call it. */ -/mob/living/basic/bounty_criminal/boss/proc/boss_bark(suffix, fallback) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_bark(suffix, fallback) if(!boss_kit || stat != CONSCIOUS) return INVOKE_ASYNC(src, PROC_REF(boss_bark_now), suffix, fallback) -/mob/living/basic/bounty_criminal/boss/proc/boss_bark_now(suffix, fallback) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_bark_now(suffix, fallback) if(QDELETED(src) || stat != CONSCIOUS) return FALSE if(bounty_say("[boss_kit]_[suffix]")) return TRUE return fallback ? bounty_say("[boss_kit]_[fallback]") : FALSE -// ----- state ----- +// ----- state, all tg's ----- -/// Downed: P2's state, read from the shared var too so a test can set it -/mob/living/basic/bounty_criminal/boss/proc/boss_is_downed() - return downed || is_downed() - -/// Restrained: P2's state, read from the shared var too so a test can set it -/mob/living/basic/bounty_criminal/boss/proc/boss_is_restrained() - return !isnull(restraints) || is_restrained() - -/// Whether it can act at all: alive and awake, not downed, restrained, given up, stunned or knocked down -/mob/living/basic/bounty_criminal/boss/proc/boss_can_act() +/// Whether it can act at all: alive and awake, not in crit, restrained, stunned, knocked down or in stamina crit +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_can_act() if(QDELETED(src) || stat != CONSCIOUS || !isturf(loc)) return FALSE - if(boss_is_downed() || boss_is_restrained() || HAS_TRAIT(src, TRAIT_BOUNTY_SURRENDERED)) + if(is_downed() || is_restrained() || npc_surrendering) return FALSE return !HAS_TRAIT(src, TRAIT_INCAPACITATED) && !HAS_TRAIT(src, TRAIT_FLOORED) -/// Whether it may start an ability now: able, not busy, and past the gap since the last one -/mob/living/basic/bounty_criminal/boss/proc/boss_can_use_ability() - return boss_can_act() && !boss_busy && world.time >= boss_next_ability_at - -/// Its cooldowns stretch once it tires -/mob/living/basic/bounty_criminal/boss/proc/boss_cooldown_mult() - return boss_tired ? BOUNTY_BOSS_TIRED_COOLDOWN_MULT : 1 - -/// Pulled by anyone once it is dead, downed or cuffed; hard to shift otherwise -/mob/living/basic/bounty_criminal/boss/proc/boss_update_hold() - move_resist = (stat == DEAD || boss_is_downed() || boss_is_restrained()) ? MOVE_RESIST_DEFAULT : initial(move_resist) +/// Whether it may start an ability now: able, not busy, not falling back, and past the gap since the last one +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_can_use_ability() + return boss_can_act() && !boss_busy && world.time >= boss_next_ability_at && world.time >= boss_fallback_until /** - * Tired at or below BOUNTY_BOSS_TIRED_BELOW percent health: stamina weapons work fully, stuns and - * knockdowns land, it moves slower and its cooldowns stretch. Healed back above the line, it is - * fresh again. Returns TRUE if that changed. P2's rally calls it with `force` when the rally ends. - * - * On tiring, its stamina loss starts again from zero, so the capture takes its whole pool - * (BOUNTY_BOSS_STAMINA: five disabler hits) whatever was thrown at it while it was fresh (H3). + * Worn out, read from its body (CB-2): stamina loss over BOUNTY_BOSS_WORN_OUT_STAMINA of its pool, or + * health under BOUNTY_BOSS_WORN_OUT_HEALTH of its max. tg's own slowdown from both does the rest. */ -/mob/living/basic/bounty_criminal/boss/boss_update_tired(silent = FALSE, force = FALSE) - var/now_tired = stat != DEAD && maxHealth > 0 && health <= maxHealth * BOUNTY_BOSS_TIRED_BELOW / 100 - if(now_tired == boss_tired && !force) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_is_worn_out() + if(stat == DEAD) return FALSE - var/was_tired = boss_tired - boss_tired = now_tired - damage_coeff[STAMINA] = boss_stamina_coefficient() - if(boss_tired && !was_tired && staminaloss > 0) - adjustStaminaLoss(-staminaloss, forced = TRUE) - status_flags &= ~(CANSTUN | CANKNOCKDOWN) - if(boss_tired) - status_flags |= CANSTUN | CANKNOCKDOWN - set_varspeed(boss_base_speed + (boss_tired ? BOUNTY_BOSS_TIRED_SLOWDOWN : 0)) - if(boss_tired && !silent) - visible_message(span_warning("[src] is breathing hard and slowing down. [p_They()] look[p_s()] worn out.")) - // The stun window is open: the balloon says so where the fight is, not only in chat (P4 polish) - body_alert_hunters("worn out") - boss_bark("exhausted") - return TRUE + return getStaminaLoss() > max_stamina * BOUNTY_BOSS_WORN_OUT_STAMINA || health < maxHealth * BOUNTY_BOSS_WORN_OUT_HEALTH -/// Stamina damage coefficient now: the fresh or tired one, folded against its pool, as max_stamina stays 100 -/mob/living/basic/bounty_criminal/boss/proc/boss_stamina_coefficient() - var/coefficient = boss_tired ? BOUNTY_BOSS_STAMINA_TIRED : boss_stamina_fresh - return coefficient * max_stamina / max(boss_stamina_pool, 1) +/// It has just worn out: it says so where the fight is, drops what it was winding up and falls back for a while +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_wear_out() + boss_worn_out = TRUE + boss_second_wind_due = FALSE + boss_fallback_until = world.time + BOUNTY_BOSS_FALLBACK_TIME + boss_interrupt() + visible_message(span_warning("[src] is breathing hard and slowing down. [p_They()] look[p_s()] worn out.")) + body_alert_hunters("worn out") + boss_bark("exhausted") + +/// Whether its next plan should take a stimulant: the first when its fight starts, the second for its second wind +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_wants_stimulant() + if(!boss_hostile || boss_stimulants_used >= BOUNTY_BOSS_STIMULANTS) + return FALSE + return !boss_stimulants_used || boss_second_wind_due // ----- busy ----- /** - * Busy with `state`, its AI quiet. `immobile` keeps it standing still (a wind-up, a stagger); a - * charge or dash moves it itself. With a `duration` it ends on its own. Returns the serial a timer - * checks against, so a stale one does nothing. + * Busy with `state`, its AI quiet. `immobile` keeps it standing still (a wind-up, a burst); a charge or + * dash moves it itself. A wind-up is a telegraph: tg's stuns, knockdowns, stamcrit, crit and cuffs + * interrupt it (the bounty_boss_signals component, and boss_can_act() when it ends; CB-24). With a + * `duration` it ends on its own. Returns the serial a timer checks against, so a stale one does nothing. */ -/mob/living/basic/bounty_criminal/boss/proc/boss_set_busy(state, duration, immobile = TRUE) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_set_busy(state, duration, immobile = TRUE) boss_busy = state boss_busy_serial++ deltimer(boss_busy_timer) @@ -318,7 +292,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) return boss_busy_serial /// Free again, unless `serial` is stale -/mob/living/basic/bounty_criminal/boss/proc/boss_clear_busy(serial) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_clear_busy(serial) if(serial && serial != boss_busy_serial) return FALSE boss_busy = null @@ -328,11 +302,11 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) return TRUE /// Whether it is still busy with `state` under `serial`: what a charge or burst checks before each step -/mob/living/basic/bounty_criminal/boss/proc/boss_still(state, serial) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_still(state, serial) return !QDELETED(src) && boss_busy == state && boss_busy_serial == serial && boss_can_act() /// Knocked out of whatever it was doing: a wind-up's telegraph goes, and nothing lands -/mob/living/basic/bounty_criminal/boss/proc/boss_interrupt() +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_interrupt() var/datum/action/cooldown/mob_cooldown/bounty_boss/winding = boss_winding_ref?.resolve() boss_winding_ref = null winding?.cancel_windup() @@ -341,23 +315,14 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) boss_on_interrupted() /// A kit's own clean-up when it is interrupted, downed or killed -/mob/living/basic/bounty_criminal/boss/proc/boss_on_interrupted() +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_on_interrupted() return -/// Reeling for `duration` (charged into a wall): still, quiet, and taking `vulnerable` times the damage. Not a stun, so it can't be cuffed for it. -/mob/living/basic/bounty_criminal/boss/proc/boss_stagger(duration, vulnerable = 1) - if(stat != CONSCIOUS) - return - boss_set_busy("stagger", duration) - Shake(2, 1, duration) - if(vulnerable != 1) - damage_coeff[BRUTE] = boss_brute_coeff * vulnerable - damage_coeff[BURN] = boss_burn_coeff * vulnerable - addtimer(CALLBACK(src, PROC_REF(boss_end_vulnerable)), duration, TIMER_UNIQUE | TIMER_OVERRIDE | TIMER_DELETE_ME) - -/mob/living/basic/bounty_criminal/boss/proc/boss_end_vulnerable() - damage_coeff[BRUTE] = boss_brute_coeff - damage_coeff[BURN] = boss_burn_coeff +/// The ability winding up now, if any +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_winding() + if(boss_busy != "windup") + return null + return boss_winding_ref?.resolve() // ----- abilities ----- @@ -366,7 +331,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) * while another is ready. With BOUNTY_BOSS_STRICT_ROTATION (boss_strict_rotation) the last one is * never picked again straight away, even when it is the only one ready. */ -/mob/living/basic/bounty_criminal/boss/proc/boss_choose_ability(atom/target) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_choose_ability(atom/target) if(QDELETED(target) || !boss_can_use_ability()) return null var/list/options = list() @@ -383,7 +348,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) return boss_strict_rotation ? null : last_one /// Starts `ability`'s wind-up. Returns the serial its timer checks, or 0 if it can't start now. -/mob/living/basic/bounty_criminal/boss/proc/boss_begin_ability(datum/action/cooldown/mob_cooldown/bounty_boss/ability) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_begin_ability(datum/action/cooldown/mob_cooldown/bounty_boss/ability) if(!boss_can_use_ability()) return 0 boss_last_ability = ability.type @@ -392,7 +357,11 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) return boss_set_busy("windup", ability.windup + 1 SECONDS) /// The kit's way of fighting after abilities: keep range, break off. Returns TRUE if it queued something. -/mob/living/basic/bounty_criminal/boss/proc/boss_engage_plan(datum/ai_controller/controller, atom/target) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_engage_plan(datum/ai_controller/controller, atom/target) + return FALSE + +/// The kit's own gear to see to before it fights on (a Heavy's belt change). Returns TRUE if it queued something. +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_gear_plan(datum/ai_controller/controller) return FALSE // ----- the posse and turning hostile ----- @@ -402,7 +371,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) * count (boss_counts_for_posse()). The first time, everyone who counts within * BOUNTY_BOSS_POSSE_RANGE and can see it joins too, mech pilots included, and it says its intro line. */ -/mob/living/basic/bounty_criminal/boss/proc/boss_turn_hostile(mob/living/instigator) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_turn_hostile(mob/living/instigator) if(stat == DEAD) return FALSE boss_calm_at = world.time + BOUNTY_BOSS_CALM_TIME @@ -418,12 +387,11 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) for(var/obj/vehicle/sealed/mecha/mech in view(BOUNTY_BOSS_POSSE_RANGE, src)) for(var/mob/living/pilot in mech.occupants) boss_engage(pilot, announce = FALSE) - boss_apply_posse_health(announce = FALSE) boss_bark("intro") return TRUE -/// With no hunter left on its site, it stops hunting and waits again. Its posse and health stay. -/mob/living/basic/bounty_criminal/boss/proc/boss_calm_down() +/// With no hunter left on its site, it stops hunting and waits again. Its posse stays. +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_calm_down() boss_hostile = FALSE ai_controller?.clear_blackboard_key(BB_BOUNTY_BOSS_PREY) @@ -432,7 +400,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) * confronted or cuffed it), or one whose ship is hunting its bounty. Being seen or targeted alone * doesn't count. */ -/mob/living/basic/bounty_criminal/boss/proc/boss_counts_for_posse(mob/living/hunter) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_counts_for_posse(mob/living/hunter) if(!bounty_boss_is_hunter(hunter)) return FALSE if(body_has_grudge(hunter)) @@ -445,55 +413,109 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) return TRUE return FALSE -/// Adds `hunter` to its posse if they count, raising its health for the bigger posse. Returns TRUE if they are new. -/mob/living/basic/bounty_criminal/boss/proc/boss_engage(mob/living/hunter, announce = TRUE) +/** + * Adds `hunter` to its posse if they count. Each hunter beyond the first owes it one more companion + * (OC-8); with `announce`, it sizes the bigger posse up out loud. Returns TRUE if they are new. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_engage(mob/living/hunter, announce = TRUE) if(stat == DEAD || !boss_counts_for_posse(hunter)) return FALSE var/key = REF(hunter) if(boss_engaged[key]) return FALSE boss_engaged[key] = TRUE - boss_apply_posse_health(announce) - return TRUE - -/** - * Max health for the posse it has: the kit's table entry for that many hunters (never more than the - * 4+ entry), raised and never lowered (M4). - * - Fresh, current health rises by the same step (spec: "raised, current health too"). - * - Tired, it keeps the same share of its health, so a newcomer never heals it out of its capture - * window. - * - Downed or cuffed, the raise waits; it is applied when it gets up (on_freed), keeping its share. - * Returns TRUE if max health rose. - */ -/mob/living/basic/bounty_criminal/boss/proc/boss_apply_posse_health(announce = TRUE) - if(stat == DEAD || boss_is_downed() || boss_is_restrained()) - return FALSE - var/list/table = boss_health_table() var/count = length(boss_engaged) - if(!length(table) || !count) - return FALSE - var/wanted = table[clamp(count, 1, length(table))] - var/raw_health = wanted - wanted *= npc_zone_health_factor - if(wanted <= maxHealth) - return FALSE - npc_zone_original_max_health = raw_health - var/share = maxHealth > 0 ? health / maxHealth : 1 - setMaxHealth(wanted) - if(boss_tired) - // Basic mobs keep all their damage as bruteloss. Not rounded, so it never lands over the tired line. - bruteloss = wanted * (1 - share) - updatehealth() - boss_update_tired(silent = TRUE) + boss_owe_reinforcements(count) if(announce && count > 1) visible_message(span_warning("[src] looks over the [count] of you and squares up.")) boss_bark("posse", "intro") return TRUE +/// A posse of `count` hunters owes one companion for each beyond the first, up to BOUNTY_BOSS_REINFORCEMENTS_MAX, called one at a time +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_owe_reinforcements(count) + var/wanted = clamp(count - 1, 0, BOUNTY_BOSS_REINFORCEMENTS_MAX) + var/more = wanted - boss_reinforcements_sent - boss_reinforcements_owed + if(more <= 0) + return + boss_reinforcements_owed += more + boss_schedule_reinforcement() + +/// The next companion comes after BOUNTY_BOSS_REINFORCE_DELAY, never two at once +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_schedule_reinforcement() + if(boss_reinforce_timer || boss_reinforcements_owed <= 0 || stat == DEAD) + return + boss_reinforce_timer = addtimer(CALLBACK(src, PROC_REF(boss_reinforce_tick)), BOUNTY_BOSS_REINFORCE_DELAY, TIMER_STOPPABLE | TIMER_DELETE_ME) + +/// Calls the next companion owed, from somewhere no player can see; tries again later if there is nowhere yet +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_reinforce_tick() + boss_reinforce_timer = null + if(QDELETED(src) || stat == DEAD || !boss_hostile || boss_reinforcements_owed <= 0) + return + var/turf/spot = boss_reinforcement_spot() + if(spot) + boss_send_reinforcement(spot) + boss_schedule_reinforcement() + +/** + * Calls one companion owed in at `where` (the criminal-AI package's bounty_spawn_companion(): a queued, + * throttled human NPC joined to it). Returns what that returns. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_send_reinforcement(turf/where) + if(boss_reinforcements_owed <= 0 || !isturf(where)) + return null + boss_reinforcements_owed-- + boss_reinforcements_sent++ + return bounty_spawn_companion(src, where, CALLBACK(src, PROC_REF(boss_reinforcement_arrived))) + +/// A companion it called is here: it goes after whoever the boss is fighting +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_reinforcement_arrived(mob/living/carbon/human/npc/companion) + if(QDELETED(src) || !ismob(companion) || QDELETED(companion)) + return + LAZYADD(boss_reinforcement_refs, WEAKREF(companion)) + var/atom/target = ai_controller?.blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(!QDELETED(target)) + companion.ai_controller?.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, target) + +/** + * A spot for a companion to come in at: open ground on its site, BOUNTY_BOSS_REINFORCE_MIN_DIST to + * _MAX_DIST tiles off, where no player within BOUNTY_BOSS_REINFORCE_SIGHT can see. Null if there is none. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_reinforcement_spot() + var/turf/here = get_turf(src) + if(!here) + return null + var/list/watchers = list() + if(here.z <= length(SSmobs.clients_by_zlevel)) + for(var/mob/living/person as anything in SSmobs.clients_by_zlevel[here.z]) + if(person.stat != DEAD && get_dist(person, here) <= BOUNTY_BOSS_REINFORCE_MAX_DIST + BOUNTY_BOSS_REINFORCE_SIGHT) + watchers += person + var/list/candidates = list() + for(var/turf/open/spot in RANGE_TURFS(BOUNTY_BOSS_REINFORCE_MAX_DIST, here)) + if(get_dist(spot, here) < BOUNTY_BOSS_REINFORCE_MIN_DIST) + continue + if(isspaceturf(spot) || isgroundlessturf(spot) || islava(spot) || ischasm(spot) || spot.is_blocked_turf()) + continue + if(!leash_ok(spot) || !boss_reach_ok(spot)) + continue + candidates += spot + shuffle_inplace(candidates) + var/tries = 0 + for(var/turf/spot as anything in candidates) + if(++tries > 40) + break + var/seen = FALSE + for(var/mob/living/watcher as anything in watchers) + if(get_dist(watcher, spot) <= BOUNTY_BOSS_REINFORCE_SIGHT && can_see(watcher, spot, BOUNTY_BOSS_REINFORCE_SIGHT)) + seen = TRUE + break + if(!seen) + return spot + return null + // ----- targets ----- /// The people behind `thing`: the person, or everyone in the mech -/mob/living/basic/bounty_criminal/boss/proc/boss_people_in(atom/thing) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_people_in(atom/thing) . = list() if(isliving(thing)) . += thing @@ -503,60 +525,65 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) . += pilot /// What to go after for `who`: the mech they sit in, or them -/mob/living/basic/bounty_criminal/boss/proc/boss_target_for(atom/who) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_target_for(atom/who) var/mob/living/person = who if(isliving(person) && ismecha(person.loc)) return person.loc return who -/// Whether it goes after `target`: a hunter, or a mech with a hunter in it, that it may hurt -/mob/living/basic/bounty_criminal/boss/proc/boss_valid_target(atom/target) - return boss_can_hurt(target) - /** - * Whether it and its abilities may hurt `victim` (C4, H2, M2, L1): - * - an awake hunter not on its side, or a mech with one in it (a pilot is hurt through the mech); - * - standing on its site, and never in a ship, a hangar or an outpost; - * - someone it may attack from where it is (P2's may_attack()). - * Never a criminal, one of their friends, fauna or anyone else on the site. + * Whether it chooses to go after `target` (C4, H2, M2, L1): an awake hunter not on its side, or a mech + * with one in it (a pilot is hurt through the mech); standing on its site, never in a ship, a hangar or + * an outpost; someone it may attack from where it is (P2's may_attack()). This is its choice of target + * only: what its fire and blasts catch is boss_effect_hits() (CB-11). */ -/mob/living/basic/bounty_criminal/boss/proc/boss_can_hurt(atom/victim) - if(QDELETED(victim) || victim == src) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_valid_target(atom/target) + if(QDELETED(target) || target == src) return FALSE - if(!boss_reach_ok(get_turf(victim))) + if(!boss_reach_ok(get_turf(target))) return FALSE - if(ismecha(victim)) - var/obj/vehicle/sealed/mecha/mech = victim + if(ismecha(target)) + var/obj/vehicle/sealed/mecha/mech = target return boss_hunter_aboard(mech) && may_attack(mech) - var/mob/living/person = victim + var/mob/living/person = target if(!isliving(person) || ismecha(person.loc) || !boss_hunter_awake(person)) return FALSE return may_attack(person) -/// An awake hunter not on its side -/mob/living/basic/bounty_criminal/boss/proc/boss_hunter_awake(mob/living/person) +/// An awake hunter not on its side: who it picks to fight. Never used for what its fire and blasts catch. +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_hunter_awake(mob/living/person) return bounty_boss_is_hunter(person) && person.stat == CONSCIOUS && !HAS_TRAIT(person, TRAIT_GODMODE) && !faction_check_atom(person) /// Whether an awake hunter not on its side sits in `mech` -/mob/living/basic/bounty_criminal/boss/proc/boss_hunter_aboard(obj/vehicle/sealed/mecha/mech) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_hunter_aboard(obj/vehicle/sealed/mecha/mech) for(var/mob/living/pilot in mech.occupants) if(boss_hunter_awake(pilot)) return TRUE return FALSE -/// Everyone on `turfs` its abilities may hurt: hunters, and mechs with hunters in them -/mob/living/basic/bounty_criminal/boss/proc/boss_victims_on(list/turfs) +/** + * Whether its fire, blasts, charge or slam catch `victim` where it stands: anywhere its abilities may + * reach (boss_reach_ok()), anyone not on its side, in whatever state (CB-11: down, cuffed or standing). + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_effect_hits(atom/victim) + if(QDELETED(victim) || victim == src) + return FALSE + return boss_reach_ok(get_turf(victim)) && bounty_boss_effect_victim(victim, faction) + +/// Everyone on `turfs` its abilities catch: people not on its side, in any state, and mechs with one in them +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_victims_on(list/turfs) . = list() for(var/turf/spot as anything in turfs) for(var/atom/movable/thing as anything in spot) - if((isliving(thing) || ismecha(thing)) && boss_can_hurt(thing)) + if((isliving(thing) || ismecha(thing)) && boss_effect_hits(thing)) . += thing /** - * One hit from an ability on `victim`: `damage` of `damage_type` against `armour_flag` armour, and - * a knockdown. A mech takes it on its hull (H2). + * One scripted hit from an ability (a charge or a slam) on `victim`: `damage` of `damage_type` against + * `armour_flag` armour on the chest, and a knockdown, both through tg (CB-25). A mech takes it on its + * hull (H2). `already_scaled` is for the zone-damage helper, which leaves human bosses at a person's. */ -/mob/living/basic/bounty_criminal/boss/proc/boss_hit(atom/victim, damage, damage_type = BRUTE, armour_flag = MELEE, knockdown = 0, armour_penetration = 0, already_scaled = FALSE) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_hit(atom/victim, damage, damage_type = BRUTE, armour_flag = MELEE, knockdown = 0, armour_penetration = 0, already_scaled = FALSE) damage = npc_zone_damage(damage, src, already_scaled) if(ismecha(victim)) var/obj/vehicle/sealed/mecha/mech = victim @@ -572,7 +599,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) return TRUE /// Whoever hurt it within BOUNTY_BOSS_REVENGE_TIME (their mech, if they were in one), if it may still go after them -/mob/living/basic/bounty_criminal/boss/proc/boss_revenge_target() +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_revenge_target() if(world.time > boss_last_attacked_at + BOUNTY_BOSS_REVENGE_TIME) return null var/atom/attacker = boss_target_for(boss_last_attacker?.resolve()) @@ -582,7 +609,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) * `attacker` went for it: a person, or a mech and everyone in it (H2). The hunters behind it go on * its grudge list and into its posse, it turns hostile, and it remembers whom to turn on. */ -/mob/living/basic/bounty_criminal/boss/proc/boss_note_attacker(atom/attacker) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_note_attacker(atom/attacker) if(stat == DEAD || QDELETED(attacker) || attacker == src) return FALSE var/list/hunters = list() @@ -599,7 +626,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) return TRUE /// The nearest hunter (or their mech) still on its site within BOUNTY_BOSS_HUNT_RANGE, for the hunt. Only players with a client count, from SSmobs' list for its level. -/mob/living/basic/bounty_criminal/boss/proc/boss_nearest_hunter() +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_nearest_hunter() var/turf/here = get_turf(src) if(!here || here.z > length(SSmobs.clients_by_zlevel)) return null @@ -621,7 +648,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) // ----- where it may reach, and what it may break ----- /// Whether an ability's effect may reach `spot` (M2): on its site, and never in a ship (other than the one it is wanted aboard), a hangar or an outpost -/mob/living/basic/bounty_criminal/boss/proc/boss_reach_ok(turf/spot) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_reach_ok(turf/spot) spot = get_turf(spot) return !isnull(spot) && body_on_site(spot) && !body_forbidden_turf(spot) @@ -630,24 +657,24 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) * P2's environment_damage_allowed(): its own site, never a trader outpost, and never within * BOUNTY_ENV_SAFE_RANGE tiles of a player ship, a hangar, a player outpost or a planet's dock strip. */ -/mob/living/basic/bounty_criminal/boss/proc/boss_environment_allowed(turf/spot) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_environment_allowed(turf/spot) spot = get_turf(spot) if(!spot || spot.z != z) return FALSE return environment_damage_allowed(spot) /// Whether a thrown or fired ability may be aimed at `spot` (M2): somewhere it could walk itself, and allowed for environment damage -/mob/living/basic/bounty_criminal/boss/proc/boss_landing_ok(turf/spot) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_landing_ok(turf/spot) spot = get_turf(spot) return !isnull(spot) && leash_ok(spot) && boss_environment_allowed(spot) /// The air pressure on `spot`, in kPa -/mob/living/basic/bounty_criminal/boss/proc/boss_turf_pressure(turf/spot) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_turf_pressure(turf/spot) var/datum/gas_mixture/air = spot?.return_air() return air ? air.return_pressure() : 0 /// Whether `spot` holds an airlock with space, another ship or somewhere off its site on one side: an outer airlock -/mob/living/basic/bounty_criminal/boss/proc/boss_outer_airlock_turf(turf/spot) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_outer_airlock_turf(turf/spot) if(!(locate(/obj/machinery/door/airlock) in spot)) return FALSE for(var/direction in GLOB.cardinals) @@ -661,7 +688,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) * another ship, a hangar or an outpost, with air in it. A ship's tile counts only if nothing around * it is space, off its site, another ship, or an outer airlock. */ -/mob/living/basic/bounty_criminal/boss/proc/boss_indoor_turf(turf/spot) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_indoor_turf(turf/spot) if(!spot || isspaceturf(spot) || isgroundlessturf(spot) || islava(spot) || ischasm(spot)) return FALSE var/area/spot_area = get_area(spot) @@ -682,7 +709,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) * than BOUNTY_BOSS_INTERIOR_MAX_PRESSURE_GAP between their pressures (L2). Never a hull, never an * outside wall, never a window onto space, the outdoors, a vacuum or another ship. */ -/mob/living/basic/bounty_criminal/boss/proc/boss_interior_spot(turf/spot) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_interior_spot(turf/spot) if(!spot) return FALSE var/list/open_sides = list() @@ -712,15 +739,16 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) /** * Whether its abilities may damage `thing`: allowed there (boss_environment_allowed(), and P2's - * may_attack(), which refuses structures off its site), indoors on both sides, and a kind it breaks - * (tables, chairs, windows, grilles, barricades; plain walls and doors only while its - * BOUNTY_BOSS_WALL_BUDGET lasts). Never anything indestructible or outpost property. + * may_attack_scope(), which refuses structures off its site), indoors on both sides, and a kind it + * breaks (tables, chairs, windows, grilles, barricades; plain walls and doors only while its + * BOUNTY_BOSS_WALL_BUDGET lasts). Never anything indestructible or outpost property. It is about the + * place and the thing, not about the boss's own state: a grenade already thrown still lands. */ -/mob/living/basic/bounty_criminal/boss/proc/boss_may_break(atom/thing) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_may_break(atom/thing) if(QDELETED(thing)) return FALSE var/turf/spot = get_turf(thing) - if(!boss_environment_allowed(spot) || !may_attack(thing) || !boss_interior_spot(spot)) + if(!boss_environment_allowed(spot) || !may_attack_scope(thing) || !boss_interior_spot(spot)) return FALSE if(isturf(thing)) if(!iswallturf(thing) || istype(thing, /turf/closed/wall/r_wall) || isindestructiblewall(thing)) @@ -741,7 +769,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) * with its frame, so the way through really opens; either spends the fight's wall budget, as does a * door that damage alone destroys. Returns TRUE if it did damage. */ -/mob/living/basic/bounty_criminal/boss/proc/boss_damage_structure(atom/thing, damage, list/tally, damage_flag = MELEE) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_damage_structure(atom/thing, damage, list/tally, damage_flag = MELEE) if(length(tally) && tally[1] <= 0) return FALSE if(!boss_may_break(thing)) @@ -772,156 +800,112 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) boss_walls_left-- return TRUE -/// With its boss gone, whom its leftover fire or blast may still hurt: awake hunters, and mechs with one in them -/proc/bounty_boss_orphan_victim(atom/thing) - if(ismecha(thing)) - var/obj/vehicle/sealed/mecha/mech = thing - for(var/mob/living/pilot in mech.occupants) - if(bounty_boss_is_hunter(pilot) && pilot.stat == CONSCIOUS) - return TRUE - return FALSE - var/mob/living/person = thing - return isliving(person) && !ismecha(person.loc) && person.stat == CONSCIOUS && bounty_boss_is_hunter(person) - // ===== SIGNALS ===== /** * The boss's signal hooks, on a component of their own so they never replace a handler P2 or P3 - * registers on the same mob for the same signal. Each one hands over to a boss proc. + * registers on the same mob for the same signal. Each one hands over to a boss proc. Being disabled is + * read from tg's own state changes: crit, cuffs, stamcrit, stuns and knockdowns (CB-24). */ /datum/component/bounty_boss_signals /datum/component/bounty_boss_signals/Initialize() - if(!istype(parent, /mob/living/basic/bounty_criminal/boss)) + if(!istype(parent, /mob/living/carbon/human/npc/bounty_criminal/boss)) return COMPONENT_INCOMPATIBLE /datum/component/bounty_boss_signals/RegisterWithParent() - RegisterSignal(parent, COMSIG_LIVING_HEALTH_UPDATE, PROC_REF(on_health)) RegisterSignal(parent, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_attacked)) RegisterSignal(parent, COMSIG_AI_BLACKBOARD_KEY_SET(BB_BASIC_MOB_CURRENT_TARGET), PROC_REF(on_target)) RegisterSignals(parent, list( - COMSIG_BOUNTY_CRIMINAL_DOWNED, - COMSIG_BOUNTY_CRIMINAL_RESTRAINED, - COMSIG_LIVING_ENTER_STAMCRIT, + SIGNAL_ADDTRAIT(TRAIT_CRITICAL_CONDITION), + SIGNAL_ADDTRAIT(TRAIT_RESTRAINED), SIGNAL_ADDTRAIT(TRAIT_INCAPACITATED), SIGNAL_ADDTRAIT(TRAIT_FLOORED), - SIGNAL_ADDTRAIT(TRAIT_BOUNTY_SURRENDERED), + COMSIG_LIVING_ENTER_STAMCRIT, ), PROC_REF(on_disabled)) - RegisterSignals(parent, list(COMSIG_BOUNTY_CRIMINAL_RECOVERED, COMSIG_BOUNTY_CRIMINAL_UNRESTRAINED), PROC_REF(on_freed)) RegisterSignal(parent, COMSIG_PROJECTILE_PREHIT, PROC_REF(on_prehit)) - RegisterSignal(parent, COMSIG_LIVING_CHECK_BLOCK, PROC_REF(on_check_block)) RegisterSignal(parent, COMSIG_MOB_AFTER_APPLY_DAMAGE, PROC_REF(on_damaged)) RegisterSignal(parent, COMSIG_ATOM_ATTACKBY, PROC_REF(on_attackby)) RegisterSignal(parent, COMSIG_MOB_FLASHED, PROC_REF(on_flashed)) - RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved)) + RegisterSignal(parent, COMSIG_MOB_ITEM_ATTACK, PROC_REF(on_item_attack)) /datum/component/bounty_boss_signals/UnregisterFromParent() UnregisterSignal(parent, list( - COMSIG_LIVING_HEALTH_UPDATE, COMSIG_ATOM_WAS_ATTACKED, COMSIG_AI_BLACKBOARD_KEY_SET(BB_BASIC_MOB_CURRENT_TARGET), - COMSIG_BOUNTY_CRIMINAL_DOWNED, - COMSIG_BOUNTY_CRIMINAL_RESTRAINED, - COMSIG_LIVING_ENTER_STAMCRIT, + SIGNAL_ADDTRAIT(TRAIT_CRITICAL_CONDITION), + SIGNAL_ADDTRAIT(TRAIT_RESTRAINED), SIGNAL_ADDTRAIT(TRAIT_INCAPACITATED), SIGNAL_ADDTRAIT(TRAIT_FLOORED), - SIGNAL_ADDTRAIT(TRAIT_BOUNTY_SURRENDERED), - COMSIG_BOUNTY_CRIMINAL_RECOVERED, - COMSIG_BOUNTY_CRIMINAL_UNRESTRAINED, + COMSIG_LIVING_ENTER_STAMCRIT, COMSIG_PROJECTILE_PREHIT, - COMSIG_LIVING_CHECK_BLOCK, COMSIG_MOB_AFTER_APPLY_DAMAGE, COMSIG_ATOM_ATTACKBY, COMSIG_MOB_FLASHED, - COMSIG_MOVABLE_MOVED, + COMSIG_MOB_ITEM_ATTACK, )) -/datum/component/bounty_boss_signals/proc/on_health(mob/living/basic/bounty_criminal/boss/source) - SIGNAL_HANDLER - source.boss_update_tired() - // A person or a mech (relay_attackers reports mech melee with the mech as the attacker). -/datum/component/bounty_boss_signals/proc/on_attacked(mob/living/basic/bounty_criminal/boss/source, atom/attacker, attack_flags) +/datum/component/bounty_boss_signals/proc/on_attacked(mob/living/carbon/human/npc/bounty_criminal/boss/source, atom/attacker, attack_flags) SIGNAL_HANDLER if(!(attack_flags & (ATTACKER_DAMAGING_ATTACK | ATTACKER_STAMINA_ATTACK))) return source.boss_note_attacker(attacker) -/datum/component/bounty_boss_signals/proc/on_target(mob/living/basic/bounty_criminal/boss/source) +/datum/component/bounty_boss_signals/proc/on_target(mob/living/carbon/human/npc/bounty_criminal/boss/source) SIGNAL_HANDLER var/atom/target = source.ai_controller?.blackboard[BB_BASIC_MOB_CURRENT_TARGET] for(var/mob/living/person as anything in source.boss_people_in(target)) if(bounty_boss_is_hunter(person)) source.boss_turn_hostile(person) -/datum/component/bounty_boss_signals/proc/on_disabled(mob/living/basic/bounty_criminal/boss/source) +/datum/component/bounty_boss_signals/proc/on_disabled(mob/living/carbon/human/npc/bounty_criminal/boss/source) SIGNAL_HANDLER source.boss_interrupt() - source.boss_update_hold() - -/datum/component/bounty_boss_signals/proc/on_freed(mob/living/basic/bounty_criminal/boss/source) - SIGNAL_HANDLER - source.boss_update_hold() - // Not forced: P2's rally may have just set the stamina coefficient for itself. - source.boss_update_tired(silent = TRUE) - // Hunters who joined while it was down or cuffed count now, keeping its share of health (M4). - source.boss_apply_posse_health(announce = FALSE) -/datum/component/bounty_boss_signals/proc/on_prehit(mob/living/basic/bounty_criminal/boss/source, obj/projectile/shot) +/datum/component/bounty_boss_signals/proc/on_prehit(mob/living/carbon/human/npc/bounty_criminal/boss/source, obj/projectile/shot) SIGNAL_HANDLER // relay_attackers drops shots whose firer isn't a mob, so a mech's gunfire is noted here (H2). if(ismecha(shot.firer) && shot.is_hostile_projectile()) source.boss_note_attacker(shot.firer) - return source.boss_projectile_prehit(shot) - -/datum/component/bounty_boss_signals/proc/on_check_block(mob/living/basic/bounty_criminal/boss/source, atom/hit_by, damage, attack_text, attack_type, armour_penetration, damage_type) - SIGNAL_HANDLER - return source.boss_check_block(hit_by, attack_text, attack_type) + return NONE -/datum/component/bounty_boss_signals/proc/on_damaged(mob/living/basic/bounty_criminal/boss/source, damage, damagetype) +/datum/component/bounty_boss_signals/proc/on_damaged(mob/living/carbon/human/npc/bounty_criminal/boss/source, damage, damagetype) SIGNAL_HANDLER if(damage > 0) source.boss_took_damage(damage, damagetype) -/datum/component/bounty_boss_signals/proc/on_attackby(mob/living/basic/bounty_criminal/boss/source, obj/item/attacking_item, mob/living/user) +/datum/component/bounty_boss_signals/proc/on_attackby(mob/living/carbon/human/npc/bounty_criminal/boss/source, obj/item/attacking_item, mob/living/user) SIGNAL_HANDLER var/obj/item/assembly/flash/flash = attacking_item if(istype(flash) && !flash.burnt_out && isliving(user)) source.boss_flashed(user) return NONE -/datum/component/bounty_boss_signals/proc/on_flashed(mob/living/basic/bounty_criminal/boss/source) +/datum/component/bounty_boss_signals/proc/on_flashed(mob/living/carbon/human/npc/bounty_criminal/boss/source) SIGNAL_HANDLER source.boss_flashed() -/datum/component/bounty_boss_signals/proc/on_moved(mob/living/basic/bounty_criminal/boss/source) +/datum/component/bounty_boss_signals/proc/on_item_attack(mob/living/carbon/human/npc/bounty_criminal/boss/source, mob/living/target, mob/living/user) SIGNAL_HANDLER - source.boss_moved() - -// Kit hooks for those signals. None of them may sleep. - -/// A projectile is about to hit it: return PROJECTILE_INTERRUPT_HIT_PHASE to dodge it -/mob/living/basic/bounty_criminal/boss/proc/boss_projectile_prehit(obj/projectile/shot) - SHOULD_NOT_SLEEP(TRUE) + if(user == source && isliving(target) && target != source) + source.boss_landed_blow(target, source.get_active_held_item()) return NONE -/// A blow or a thrown thing is about to land: return SUCCESSFUL_BLOCK to make it miss -/mob/living/basic/bounty_criminal/boss/proc/boss_check_block(atom/hit_by, attack_text, attack_type) - SHOULD_NOT_SLEEP(TRUE) - return NONE +// Kit hooks for those signals. None of them may sleep. /// Damage landed on it -/mob/living/basic/bounty_criminal/boss/proc/boss_took_damage(damage, damagetype) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_took_damage(damage, damagetype) SHOULD_NOT_SLEEP(TRUE) return /// Flashed, by a handheld flash (`user`) or a flash going off near it -/mob/living/basic/bounty_criminal/boss/proc/boss_flashed(mob/living/user) +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_flashed(mob/living/user) SHOULD_NOT_SLEEP(TRUE) return -/// It took a step -/mob/living/basic/bounty_criminal/boss/proc/boss_moved() +/// It swung `weapon` at `victim` with its own hand +/mob/living/carbon/human/npc/bounty_criminal/boss/proc/boss_landed_blow(mob/living/victim, obj/item/weapon) SHOULD_NOT_SLEEP(TRUE) return @@ -967,7 +951,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) . = ..() if(!.) return FALSE - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner return istype(boss) && boss.boss_can_use_ability() /// Whether it is worth using on `target` now: in range, in sight, and so on @@ -980,17 +964,17 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) /// Whether a thrown or fired ability may be aimed at where `target` stands (M2) /datum/action/cooldown/mob_cooldown/bounty_boss/proc/landing_ok(atom/target) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner return istype(boss) && boss.boss_landing_ok(get_turf(target)) /datum/action/cooldown/mob_cooldown/bounty_boss/Activate(atom/target) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner if(!istype(boss) || QDELETED(target)) return FALSE var/serial = boss.boss_begin_ability(src) if(!serial) return FALSE - StartCooldown(cooldown_time * boss.boss_cooldown_mult()) + StartCooldown(cooldown_time) pending_serial = serial pending_target = WEAKREF(target) // Marks left lingering from the last use look after themselves. @@ -1012,7 +996,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) pending_serial = 0 pending_target = null clear_telegraphs() - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner if(!istype(boss) || boss.boss_busy != "windup" || boss.boss_busy_serial != serial || !boss.boss_can_act()) return FALSE boss.boss_winding_ref = null @@ -1066,7 +1050,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) /// Damages `thing` as part of this use, within its cap and the fight's wall budget /datum/action/cooldown/mob_cooldown/bounty_boss/proc/break_thing(atom/thing, damage, damage_flag = MELEE) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner if(!istype(boss)) return FALSE if(!structure_tally) @@ -1147,10 +1131,13 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) /** * A patch of a boss's fire: flames on `turfs` for `lifetime`, only where its boss's abilities may - * reach (never off its site or in a ship, hangar or outpost, M2). A hunter it may hurt who stands in - * them is set alight (/datum/status_effect/bounty_boss_burning) every second; a mech with a hunter - * in it takes the burn on its hull. Effect-only fire: no gas, no hotspots, nothing flammable set - * burning, no fire alarms. Capped at BOUNTY_BOSS_FIRE_POOL_CAP server-wide. + * reach (never off its site or in a ship, hangar or outpost, M2). The patch itself is scripted: it + * makes no gas and no hotspot and lights nothing, so it never spreads or sets off fire alarms (site + * safety). Whoever it catches burns for real (CB-8): `landing_damage` burn against fire armour where it + * first lands, then tg's own fire stacks and ignite_mob() (`new_landing_stacks` on landing, + * BOUNTY_BOSS_FIRE_TICK_STACKS every second they stand in it), whatever state they are in. From then on + * it is tg's fire on them: firesuits, stop-drop-and-roll, extinguishers, showers and wet clothes all + * work. A mech with someone in it takes the burn on its hull. Capped at BOUNTY_BOSS_FIRE_POOL_CAP. */ /obj/effect/bounty_boss_fire_pool name = "fire" @@ -1162,16 +1149,23 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) light_color = LIGHT_COLOR_FIRE /// The tiles burning var/list/turfs - /// The boss whose fire it is, for who it may hurt + /// The boss whose fire it is, for who it catches var/datum/weakref/boss_ref + /// Its boss's factions when it was lit: its fire never catches its own side, even with the boss gone + var/list/side_factions + /// Its boss's zone damage factor when it was lit (1 for a human boss) var/damage_factor = 1 + /// Fire stacks it puts on whoever it catches where it first lands + var/landing_stacks = BOUNTY_BOSS_FIRE_TICK_STACKS -/obj/effect/bounty_boss_fire_pool/Initialize(mapload, list/fire_turfs, lifetime, mob/living/basic/bounty_criminal/boss/boss, landing_damage = 0) +/obj/effect/bounty_boss_fire_pool/Initialize(mapload, list/fire_turfs, lifetime, mob/living/carbon/human/npc/bounty_criminal/boss/boss, landing_damage = 0, new_landing_stacks) . = ..() if(length(GLOB.bounty_boss_fire_pools) >= BOUNTY_BOSS_FIRE_POOL_CAP) return INITIALIZE_HINT_QDEL GLOB.bounty_boss_fire_pools += src lifetime = lifetime || 4 SECONDS + if(!isnull(new_landing_stacks)) + landing_stacks = new_landing_stacks turfs = list() for(var/turf/spot as anything in fire_turfs) if(isturf(spot) && !isclosedturf(spot) && (!boss || boss.boss_reach_ok(spot))) @@ -1179,6 +1173,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) if(!length(turfs)) return INITIALIZE_HINT_QDEL boss_ref = boss ? WEAKREF(boss) : null + side_factions = boss ? boss.faction.Copy() : null damage_factor = boss ? boss.get_npc_zone_damage_factor() : 1 // Invisible, but the light comes from here: sit it where the fire is. var/turf/middle = turfs[round((length(turfs) + 1) / 2)] @@ -1186,7 +1181,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) forceMove(middle) for(var/turf/spot as anything in turfs) new /obj/effect/temp_visual/bounty_boss_flames(spot, lifetime) - scorch(landing_damage) + scorch(landing_damage, landing_stacks) addtimer(CALLBACK(src, PROC_REF(scorch)), 1 SECONDS, TIMER_LOOP | TIMER_DELETE_ME) addtimer(CALLBACK(src, PROC_REF(burn_out)), lifetime, TIMER_DELETE_ME) @@ -1194,111 +1189,96 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) GLOB.bounty_boss_fire_pools -= src turfs = null boss_ref = null + side_factions = null return ..() -/// Whether it may burn `victim`: its boss's rules, or with the boss gone, awake hunters and their mechs +/// Whether it catches `victim`: its boss's rules, or with the boss gone, anyone not on the boss's side. Never by the victim's state (CB-11). /obj/effect/bounty_boss_fire_pool/proc/may_burn(atom/victim) - var/mob/living/basic/bounty_criminal/boss/boss = boss_ref?.resolve() + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = boss_ref?.resolve() if(!QDELETED(boss)) - return boss.boss_can_hurt(victim) - return bounty_boss_orphan_victim(victim) + return boss.boss_effect_hits(victim) + return bounty_boss_effect_victim(victim, side_factions) -/// Sets alight everyone it may burn in the flames, with `damage` burn first if given; mechs take the burn on the hull -/obj/effect/bounty_boss_fire_pool/proc/scorch(damage = 0) +/** + * Catches everyone in the flames: `damage` burn against fire armour if given (the jet or the bottle + * landing), then `stacks` of tg's fire stacks and ignite_mob(). Mechs take the burn on the hull. + */ +/obj/effect/bounty_boss_fire_pool/proc/scorch(damage = 0, stacks = BOUNTY_BOSS_FIRE_TICK_STACKS) for(var/turf/spot as anything in turfs) for(var/atom/movable/thing as anything in spot) if(!(isliving(thing) || ismecha(thing)) || !may_burn(thing)) continue if(ismecha(thing)) var/obj/vehicle/sealed/mecha/mech = thing - mech.take_damage(npc_zone_damage(max(damage, BOUNTY_BOSS_BURNING_DAMAGE), damage_factor), BURN, FIRE, FALSE) + mech.take_damage(npc_zone_damage(max(damage, 3), damage_factor), BURN, FIRE, FALSE) continue var/mob/living/victim = thing if(damage > 0) victim.apply_damage(npc_zone_damage(damage, damage_factor), BURN, blocked = victim.run_armor_check(null, FIRE, silent = TRUE), spread_damage = TRUE) to_chat(victim, span_userdanger("You're caught in the flames!")) - victim.apply_status_effect(/datum/status_effect/bounty_boss_burning, damage_factor) + if(stacks > 0) + victim.adjust_fire_stacks(stacks) + victim.ignite_mob() /obj/effect/bounty_boss_fire_pool/proc/burn_out() qdel(src) -/** - * Set alight by a boss's fire: BOUNTY_BOSS_BURNING_DAMAGE burn a second, against fire armour, for - * BOUNTY_BOSS_BURNING_TIME, renewed while standing in the flames. It goes out once they are down - * (C4, M3). Scripted: it never lights the air or anything else. - */ -/datum/status_effect/bounty_boss_burning - id = "bounty_boss_burning" - duration = BOUNTY_BOSS_BURNING_TIME - tick_interval = 1 SECONDS - status_type = STATUS_EFFECT_REFRESH - alert_type = null - /// The flames on them - var/mutable_appearance/flames - var/damage_factor = 1 - -/datum/status_effect/bounty_boss_burning/on_creation(mob/living/new_owner, factor = 1) - damage_factor = factor - return ..() - -/datum/status_effect/bounty_boss_burning/refresh(mob/living/new_owner, factor = 1) - damage_factor = factor - return ..() - -/datum/status_effect/bounty_boss_burning/on_apply() - if(owner.stat != CONSCIOUS || HAS_TRAIT(owner, TRAIT_NOFIRE)) - return FALSE - flames = mutable_appearance('icons/mob/effects/onfire.dmi', ishuman(owner) ? "human_small_fire" : "generic_fire", -HIGHEST_LAYER, appearance_flags = RESET_COLOR | KEEP_APART) - owner.add_overlay(flames) - return TRUE - -/datum/status_effect/bounty_boss_burning/tick(seconds_between_ticks) - if(owner.stat != CONSCIOUS) - qdel(src) - return - owner.apply_damage(npc_zone_damage(BOUNTY_BOSS_BURNING_DAMAGE, damage_factor), BURN, blocked = owner.run_armor_check(null, FIRE, silent = TRUE), spread_damage = TRUE) - -/datum/status_effect/bounty_boss_burning/on_remove() - if(flames) - owner.cut_overlay(flames) - flames = null - // ===== THE MIND ===== /** - * Its planning: nothing while it is busy or can't act; its target; an ability; the kit's way of - * closing in or keeping away; its melee attack; and with nobody in sight, the hunt for the nearest - * hunter still on its site. - * - * TODO(P3 integration): if start_activity() needs a planning subtree to run, add it to the end of - * this list, so a boss waiting for hunters does its activity. + * Its planning, on a real human body (contract 2.4): soft crit and breaking free first; nothing while + * it is busy or can't act; worn out, it falls back; its stimulant; its target; its kit's gear; drawing + * its weapon once its fight has started; an ability; the kit's way of closing in or keeping away; its + * melee with what it holds; patching itself up with nobody about; and with nobody in sight, the hunt + * for the nearest hunter still on its site. Bosses never surrender. */ /datum/ai_controller/basic_controller/bounty_boss blackboard = list( - BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/bounty_boss, - BB_TARGET_MINIMUM_STAT = CONSCIOUS, + BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/human_npc/bounty_boss, + BB_TARGET_MINIMUM_STAT = HUMAN_NPC_SPARES_DOWNED, BB_AGGRO_RANGE = BOUNTY_BOSS_POSSE_RANGE, ) - ai_movement = /datum/ai_movement/jps + ai_movement = /datum/ai_movement/jps/bounty idle_behavior = null planning_subtrees = list( + /datum/ai_planning_subtree/human_npc_soft_crit, + /datum/ai_planning_subtree/bounty_escape_captivity, /datum/ai_planning_subtree/bounty_boss_busy, + /datum/ai_planning_subtree/bounty_boss_worn_out, + /datum/ai_planning_subtree/bounty_boss_stimulant, /datum/ai_planning_subtree/bounty_boss_target, /datum/ai_planning_subtree/simple_find_target, + /datum/ai_planning_subtree/bounty_boss_gear, + /datum/ai_planning_subtree/human_npc_arm/bounty_boss, /datum/ai_planning_subtree/bounty_boss_abilities, /datum/ai_planning_subtree/bounty_boss_engage, - /datum/ai_planning_subtree/basic_melee_attack_subtree, + /datum/ai_planning_subtree/human_npc_melee, + /datum/ai_planning_subtree/bounty_treat_self, /datum/ai_planning_subtree/bounty_boss_hunt, ) +/datum/ai_controller/basic_controller/bounty_boss/TryPossessPawn(atom/new_pawn) + if(!ishumannpc(new_pawn)) + return AI_CONTROLLER_INCOMPATIBLE + return ..() + +// Cuffs and soft crit don't stop it (the human NPC base's run check), so it can work at its cuffs and crawl. +/datum/ai_controller/basic_controller/bounty_boss/get_able_to_run() + return human_npc_ai_able_to_run(src) + +/datum/ai_controller/basic_controller/bounty_boss/on_stat_changed(mob/living/source, new_stat) + . = ..() + human_npc_ai_stat_changed(src, new_stat) + /** - * Hunters it may hurt, and mechs with one in them (H2); never anyone already down (C4). tg's own mech - * branch would test the pilot, whom it only hurts through the mech, so a mech is judged here. + * Hunters it may go after, and mechs with one in them (H2); never anyone already down (C4, + * npc_target_stat). tg's own mech branch would test the pilot, whom it only hurts through the mech, so + * a mech is judged here. */ -/datum/targeting_strategy/basic/bounty_boss +/datum/targeting_strategy/basic/human_npc/bounty_boss -/datum/targeting_strategy/basic/bounty_boss/can_attack(mob/living/living_mob, atom/the_target, vision_range) - var/mob/living/basic/bounty_criminal/boss/boss = living_mob +/datum/targeting_strategy/basic/human_npc/bounty_boss/can_attack(mob/living/living_mob, atom/the_target, vision_range) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = living_mob if(!istype(boss) || !boss.boss_valid_target(the_target)) return FALSE if(ismecha(the_target)) @@ -1306,19 +1286,81 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) return isturf(boss.loc) && the_target.z == boss.z && get_dist(boss, the_target) <= range && can_see(boss, the_target, range) return ..() -/// Nothing at all while it winds up, charges or reels, or while it can't act +/// Nothing at all while it winds up, charges or bursts, or while it can't act (tg's states) /datum/ai_planning_subtree/bounty_boss_busy /datum/ai_planning_subtree/bounty_boss_busy/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/bounty_criminal/boss/boss = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = controller.pawn if(!istype(boss) || boss.boss_busy || !boss.boss_can_act()) return SUBTREE_RETURN_FINISH_PLANNING +/** + * Worn out (boss_is_worn_out(), its body's real state): the first time, it says so and shows it to + * the hunters (boss_wear_out()); then it falls back from whoever it was fighting for + * BOUNTY_BOSS_FALLBACK_TIME, and after that its second wind is due (bounty_boss_stimulant). Back above + * the line (healed, or its stamina back), it is fresh again. + */ +/datum/ai_planning_subtree/bounty_boss_worn_out + +/datum/ai_planning_subtree/bounty_boss_worn_out/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = controller.pawn + if(!istype(boss) || !boss.boss_hostile) + return + if(!boss.boss_is_worn_out()) + boss.boss_worn_out = FALSE + boss.boss_fallback_until = 0 + return + if(!boss.boss_worn_out) + boss.boss_wear_out() + if(world.time >= boss.boss_fallback_until) + if(boss.boss_fallback_until && boss.boss_stimulants_used < BOUNTY_BOSS_STIMULANTS) + boss.boss_second_wind_due = TRUE + boss.boss_fallback_until = 0 + return + var/atom/threat = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] || boss.boss_revenge_target() + if(QDELETED(threat)) + return + controller.set_blackboard_key(BB_BOUNTY_BOSS_FALL_BACK_FROM, threat) + controller.queue_behavior(/datum/ai_behavior/run_away_from_target, BB_BOUNTY_BOSS_FALL_BACK_FROM) + return SUBTREE_RETURN_FINISH_PLANNING + +/** + * Its combat stimulant (defaults 1.6, CR-4): the first pen as its fight starts, the second for its + * second wind once a fall back is over, each a real pen it carries, used on itself the player's way + * through the core's bounty_ai_use_injector() (a visible emote first). The second comes with its + * "recover" line ("Round two."). While a pen is going in, it keeps at it. + */ +/datum/ai_planning_subtree/bounty_boss_stimulant + +/datum/ai_planning_subtree/bounty_boss_stimulant/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = controller.pawn + if(!istype(boss) || !boss.boss_hostile) + return + var/obj/item/reagent_containers/hypospray/medipen/using = controller.blackboard[BB_HUMAN_NPC_TREAT_ITEM] + if(istype(using) && !QDELETED(using) && !using.used_up && bounty_ai_is_stimulant(using)) + controller.queue_behavior(/datum/ai_behavior/human_npc_treat_self, BB_HUMAN_NPC_TREAT_ITEM) + return SUBTREE_RETURN_FINISH_PLANNING + if(!boss.boss_wants_stimulant()) + return + var/obj/item/reagent_containers/hypospray/medipen/pen = bounty_ai_find_injector(boss, BOUNTY_BOSS_STIMULANT) + if(isnull(pen)) + // Nothing left to take: it fights on as it is. + boss.boss_stimulants_used = BOUNTY_BOSS_STIMULANTS + boss.boss_second_wind_due = FALSE + return + if(!bounty_ai_use_injector(controller, pen)) + return + boss.boss_stimulants_used++ + if(boss.boss_second_wind_due) + boss.boss_second_wind_due = FALSE + INVOKE_ASYNC(boss, TYPE_PROC_REF(/mob/living, bounty_say), "recover", null, TRUE) + return SUBTREE_RETURN_FINISH_PLANNING + /// Drops a target it may no longer go after, and turns on whoever hurt it last when it has none /datum/ai_planning_subtree/bounty_boss_target /datum/ai_planning_subtree/bounty_boss_target/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/bounty_criminal/boss/boss = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = controller.pawn var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(controller.blackboard[BB_TARGETING_STRATEGY]) var/atom/current = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] if(current && !strategy?.can_attack(boss, current, BOUNTY_BOSS_POSSE_RANGE)) @@ -1330,11 +1372,30 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) if(avenge && strategy?.can_attack(boss, avenge, BOUNTY_BOSS_POSSE_RANGE)) controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, avenge) +/// The kit's own gear, once its fight is on: a Heavy changing the belt in its gun +/datum/ai_planning_subtree/bounty_boss_gear + +/datum/ai_planning_subtree/bounty_boss_gear/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = controller.pawn + if(!istype(boss) || !boss.boss_hostile) + return + if(boss.boss_gear_plan(controller)) + return SUBTREE_RETURN_FINISH_PLANNING + +/// The human NPC base's arming (reload or draw what it carries), only once its fight has started: until then its weapon stays where it carries it +/datum/ai_planning_subtree/human_npc_arm/bounty_boss + +/datum/ai_planning_subtree/human_npc_arm/bounty_boss/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = controller.pawn + if(!istype(boss) || !boss.boss_hostile) + return + return ..() + /// One ability, if one is ready, worth it, and not the one it used last /datum/ai_planning_subtree/bounty_boss_abilities /datum/ai_planning_subtree/bounty_boss_abilities/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/bounty_criminal/boss/boss = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = controller.pawn var/atom/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] if(QDELETED(target)) return @@ -1349,7 +1410,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) /datum/ai_behavior/bounty_boss_ability /datum/ai_behavior/bounty_boss_ability/perform(seconds_per_tick, datum/ai_controller/controller, ability_key, target_key) - var/mob/living/basic/bounty_criminal/boss/boss = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = controller.pawn var/datum/action/cooldown/mob_cooldown/bounty_boss/ability = controller.blackboard[ability_key] var/atom/target = controller.blackboard[target_key] if(QDELETED(ability) || QDELETED(target)) @@ -1366,13 +1427,34 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) /datum/ai_planning_subtree/bounty_boss_engage /datum/ai_planning_subtree/bounty_boss_engage/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/bounty_criminal/boss/boss = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = controller.pawn var/atom/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] if(QDELETED(target)) return if(boss.boss_engage_plan(controller, target)) return SUBTREE_RETURN_FINISH_PLANNING +/** + * One real step away from `target_key`'s target, onto ground its leash allows (P2's + * body_step_away_from()): tg's step_away walks on a movement that knows nothing of the leash. + */ +/datum/ai_behavior/bounty_boss_back_off + action_cooldown = 0.3 SECONDS + behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +// No quicker than its body walks: armour, wounds and stamina slow it as they slow anyone. +/datum/ai_behavior/bounty_boss_back_off/get_cooldown(datum/ai_controller/cooldown_for) + var/mob/living/pawn = cooldown_for?.pawn + return max(action_cooldown, pawn?.cached_multiplicative_slowdown || 0) + +/datum/ai_behavior/bounty_boss_back_off/perform(seconds_per_tick, datum/ai_controller/controller, target_key) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = controller.pawn + var/atom/target = controller.blackboard[target_key] + if(!istype(boss) || QDELETED(target) || !boss.boss_can_act()) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + boss.face_atom(target) + return boss.body_step_away_from(target) ? (AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED) : (AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED) + /** * Nobody in sight while hostile: it goes after the nearest hunter still on its site, looking again * every BOUNTY_BOSS_HUNT_INTERVAL. With nobody on the site for BOUNTY_BOSS_CALM_TIME it calms down. @@ -1380,7 +1462,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) /datum/ai_planning_subtree/bounty_boss_hunt /datum/ai_planning_subtree/bounty_boss_hunt/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/bounty_criminal/boss/boss = controller.pawn + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = controller.pawn if(!boss.boss_hostile || controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) return var/atom/prey = controller.blackboard[BB_BOUNTY_BOSS_PREY] @@ -1401,7 +1483,7 @@ GLOBAL_LIST_EMPTY(bounty_boss_barricades) // ===== LOOKS ===== -/// A mini-boss's look before its kit's: plain dark clothes +/// A mini-boss's clothes before its kit's: plain dark clothes /datum/outfit/bounty_boss name = "Bounty mini-boss" uniform = /obj/item/clothing/under/color/black diff --git a/voidcrew/modules/bounties/bounty_boss_kits.dm b/voidcrew/modules/bounties/bounty_boss_kits.dm index 22bfcd86bb2..471bf1922e7 100644 --- a/voidcrew/modules/bounties/bounty_boss_kits.dm +++ b/voidcrew/modules/bounties/bounty_boss_kits.dm @@ -4,22 +4,28 @@ * Owner: P4 bosses. Do not edit this file outside P4. * * What it owns: the Juggernaut, Pyromaniac, Demolitionist, Ghost and Heavy - * (/mob/living/basic/bounty_criminal/boss/, BOUNTY_KIT_*): their health, armour, weapon and - * two abilities each (spec section 5, 12.3 C8). No kit drops real loot: the guns, grenades and - * flamers are scripted, and the gear exists only in the look. + * (/mob/living/carbon/human/npc/bounty_criminal/boss/, BOUNTY_KIT_*): what each wears and carries, + * and its two abilities (spec section 5, 12.3 C8). Every kit is a real human in real gear, locked to its + * body (D3): its armour protects by tg's rules and its weapon is a real item it fights with. Its + * stimulants and bruise pack are packed by boss_supplies(). Nothing it carries is ever loot. * - * - Juggernaut: riot plates. Charges in a line, smashing tables, chairs and plain windows and - * tearing through an interior wall; bounces off anything else and reels. Slams the floor around - * it when someone is close. - * - Pyromaniac: a fire suit and a flamer. Sweeps a cone of fire, and throws molotovs that leave a - * burning patch. Fire can't hurt it; lasers can. - * - Demolitionist: a bandolier of grenades. Keeps its distance and lobs grenades with a visible - * fuse, and blows a hole through an interior wall or door to get at someone behind cover. - * - Ghost: a dark cloak and a knife. Dashes in along a line, cuts that bleed, cloaks into a faint - * shimmer that a flash or a hit breaks, dodges shots while moving, and backs off after a couple of + * - Juggernaut: riot armour and a body grown huge (tg's gigantism gene). Charges in a line, smashing + * tables, chairs and plain windows and tearing through an interior wall; running into anything else + * hurts it and knocks it down, as running into a wall does anyone (CB-6). Slams the floor around it + * when someone is close. Fights with its fists. + * - Pyromaniac: a real firefighter suit and helmet (tg's thermal protection, CB-7) and a lit torch. + * Sweeps a cone of fire and throws molotovs that leave a burning patch; whoever it catches burns with + * tg's fire stacks (CB-8). + * - Demolitionist: a hard hat, a hi-vis vest, a bandolier and a crowbar in its bag. Keeps its distance + * and lobs grenades with a visible fuse, and blows a hole through an interior wall or door to get at + * someone behind cover. Whoever a blast catches takes tg's light explosion (CB-10). + * - Ghost: a dark hood, a real combat knife and real chrome (Slipwire, Cascade; the OC-6 ruling). + * Dashes in along a line with its Cascade lattice firing and stabs at the end of it (CB-9); fades + * into a shimmer that is only a look, broken by a hit or a flash (CB-12); backs off after a couple of * cuts. - * - Heavy: heavy armour and a belt-fed gun. A laser sight and a spin-up, then a burst into a cone; - * drops a folding barrier for cover. Slow. + * - Heavy: SWAT armour and a real L6 with a spare box. A laser sight and a spin-up, then a burst of + * real rounds into a cone (a hit while it aims spoils the shot); throws real barrier grenades for + * cover (CB-26); changes its own belts. Slow. * * The shared vars are declared in bounty_types.dm and nowhere else; a var only P4 uses goes here * with a `boss_` prefix, or on the /boss subtypes. @@ -27,39 +33,24 @@ // ===== JUGGERNAUT ===== -/mob/living/basic/bounty_criminal/boss/juggernaut +/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut name = "armoured criminal" desc = "A huge criminal in riot plates, built like a door." - maxHealth = BOUNTY_JUGGERNAUT_HEALTH_1 - health = BOUNTY_JUGGERNAUT_HEALTH_1 - mob_size = MOB_SIZE_LARGE - speed = BOUNTY_JUGGERNAUT_SPEED - damage_coeff = list(BRUTE = BOUNTY_JUGGERNAUT_BRUTE_MOD, BURN = BOUNTY_JUGGERNAUT_BURN_MOD, TOX = 1, STAMINA = BOUNTY_BOSS_STAMINA_FRESH * 100 / BOUNTY_BOSS_STAMINA, OXY = 1) - melee_damage_lower = BOUNTY_JUGGERNAUT_MELEE_MIN - melee_damage_upper = BOUNTY_JUGGERNAUT_MELEE_MAX - armour_penetration = BOUNTY_JUGGERNAUT_MELEE_AP - melee_attack_cooldown = BOUNTY_JUGGERNAUT_MELEE_COOLDOWN - attack_verb_continuous = "pounds" - attack_verb_simple = "pound" - attack_sound = 'sound/effects/hit_punch.ogg' - attack_vis_effect = ATTACK_EFFECT_SMASH boss_kit = BOUNTY_KIT_JUGGERNAUT boss_ability_types = list( /datum/action/cooldown/mob_cooldown/bounty_boss/charge, /datum/action/cooldown/mob_cooldown/bounty_boss/slam, ) -/mob/living/basic/bounty_criminal/boss/juggernaut/Initialize(mapload) +/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/Initialize(mapload, datum/human_npc_order/order) . = ..() - update_transform(1.15) + // Its size is a real gene (CB-21, PI-21): mutadone shrinks it back like anyone else. + dna?.add_mutation(/datum/mutation/gigantism, MUTATION_SOURCE_ACTIVATED) -/mob/living/basic/bounty_criminal/boss/juggernaut/boss_health_table() - return list(BOUNTY_JUGGERNAUT_HEALTH_1, BOUNTY_JUGGERNAUT_HEALTH_2, BOUNTY_JUGGERNAUT_HEALTH_3, BOUNTY_JUGGERNAUT_HEALTH_4) +/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/bounty_build_outfit(zone) + return boss_supplies(bounty_outfit_instance(/datum/outfit/bounty_boss/juggernaut)) -/mob/living/basic/bounty_criminal/boss/juggernaut/boss_kit_outfit() - return /datum/outfit/bounty_boss/juggernaut - -/mob/living/basic/bounty_criminal/boss/juggernaut/boss_gear_text() +/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss_gear_text() return "Riot plates cover [p_them()] from neck to boots." /datum/outfit/bounty_boss/juggernaut @@ -71,11 +62,11 @@ shoes = /obj/item/clothing/shoes/jackboots /** - * Charge: a roar, a stamp and a line on the floor, then a run down that line. The first hunter in + * Charge: a roar, a stamp and a line on the floor, then a run down that line. The first person in * the way is slammed and knocked down (anyone else in the way only BOUNTY_JUGGERNAUT_CHARGE_BYSTANDER * percent of the time). Tables, chairs, plain windows and grilles on the line are smashed. With * nobody caught, it tears through an interior wall at the end of the line if its budget allows; - * anything else stops it dead, reeling and open to damage. + * anything else stops it dead, hurt and on the floor (bounce()). */ /datum/action/cooldown/mob_cooldown/bounty_boss/charge name = "Charge" @@ -131,7 +122,7 @@ mark_turfs(path, "#c8a060") /datum/action/cooldown/mob_cooldown/bounty_boss/charge/effect(atom/target) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner if(!istype(boss) || !length(path)) path = null return @@ -145,7 +136,7 @@ /// One tile of the charge /datum/action/cooldown/mob_cooldown/bounty_boss/charge/proc/charge_step(serial) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner if(!istype(boss) || !boss.boss_still("charge", serial)) end_charge(serial) return @@ -158,9 +149,9 @@ if(!boss.leash_ok(next) || isspaceturf(next) || isgroundlessturf(next) || islava(next) || ischasm(next)) end_charge(serial) return - // Someone in the way: a hunter, or a mech with one in it, is slammed rather than bounced off (H2). + // Someone in the way: a person, or a mech with one in it, is slammed rather than bounced off (H2). for(var/atom/movable/thing as anything in next) - if(!thing.density || !(isliving(thing) || ismecha(thing)) || !boss.boss_can_hurt(thing)) + if(!thing.density || !(isliving(thing) || ismecha(thing)) || !boss.boss_effect_hits(thing)) continue if(thing == charge_target?.resolve() || prob(BOUNTY_JUGGERNAUT_CHARGE_BYSTANDER)) slam_into(thing) @@ -217,8 +208,8 @@ playsound(spot, is_window ? 'sound/effects/glass/glassbr1.ogg' : 'sound/effects/woodhit.ogg', 70, TRUE) return QDELETED(thing) || !thing.density -/// Steps onto `next`; a plain directional window on its own tile facing that way is smashed first. Returns TRUE if it moved. -/datum/action/cooldown/mob_cooldown/bounty_boss/charge/proc/try_step(mob/living/basic/bounty_criminal/boss/boss, turf/next) +/// Steps onto `next` (its leash checked by charge_step()); a plain directional window on its own tile facing that way is smashed first. Returns TRUE if it moved. +/datum/action/cooldown/mob_cooldown/bounty_boss/charge/proc/try_step(mob/living/carbon/human/npc/bounty_criminal/boss/boss, turf/next) var/direction = get_dir(boss, next) if(boss.Move(next, direction)) return TRUE @@ -233,34 +224,43 @@ return FALSE return boss.Move(next, direction) -/// Slams into `victim`, a hunter or a mech: brute through armour, and a hunter is knocked down +/// Slams into `victim`, a person or a mech: brute through armour, and a person is knocked down (CB-25) /datum/action/cooldown/mob_cooldown/bounty_boss/charge/proc/slam_into(atom/victim) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner victim.visible_message(span_danger("[boss] slams into [victim]!"), span_userdanger("[boss] slams into you!")) playsound(victim, 'sound/effects/meteorimpact.ogg', 70, TRUE) - boss.boss_hit(victim, BOUNTY_JUGGERNAUT_CHARGE_DAMAGE, BRUTE, MELEE, BOUNTY_JUGGERNAUT_CHARGE_KNOCKDOWN, BOUNTY_JUGGERNAUT_MELEE_AP) + boss.boss_hit(victim, BOUNTY_JUGGERNAUT_CHARGE_DAMAGE, BRUTE, MELEE, BOUNTY_JUGGERNAUT_CHARGE_KNOCKDOWN, BOUNTY_JUGGERNAUT_CHARGE_AP) -/// Ran into something it can't break: stopped dead, reeling +/** + * Ran into something it can't break: stopped dead, and it hurts, the way running into a wall at full + * tilt hurts anyone (tg's tackle splat, CB-6): brute to its head through its helmet, a blow to its + * stamina, a moment's paralysis and a knockdown, all tg's. No damage multiplier: on the floor it is + * simply easier to hit, and to cuff. + */ /datum/action/cooldown/mob_cooldown/bounty_boss/charge/proc/bounce(atom/obstacle, serial) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner end_charge(serial) if(!istype(boss) || boss.stat != CONSCIOUS) return boss.visible_message(span_danger("[boss] slams into [obstacle] and reels!")) playsound(boss, 'sound/effects/bang.ogg', 80, TRUE) - boss.boss_stagger(BOUNTY_JUGGERNAUT_WALL_STAGGER, BOUNTY_JUGGERNAUT_WALL_VULNERABLE) + boss.Shake(2, 1, BOUNTY_JUGGERNAUT_WALL_KNOCKDOWN) + boss.apply_damage(BOUNTY_JUGGERNAUT_WALL_BRUTE, BRUTE, BODY_ZONE_HEAD, boss.run_armor_check(BODY_ZONE_HEAD, MELEE, silent = TRUE)) + boss.apply_damage(BOUNTY_JUGGERNAUT_WALL_STAMINA, STAMINA) + boss.Paralyze(BOUNTY_JUGGERNAUT_WALL_PARALYZE) + boss.Knockdown(BOUNTY_JUGGERNAUT_WALL_KNOCKDOWN) /datum/action/cooldown/mob_cooldown/bounty_boss/charge/proc/end_charge(serial) path = null charge_target = null - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner if(istype(boss) && boss.boss_busy == "charge" && boss.boss_busy_serial == serial) boss.boss_clear_busy(serial) /** - * Slam: both fists up and a red ring on the floor around it, then down. Every hunter it may hurt in - * the ring takes brute through armour and is knocked down; a mech takes it on its hull. Only when - * someone is next to it. + * Slam: both fists up and a red ring on the floor around it, then down. Everyone it catches in the + * ring, standing or not, takes brute through armour and is knocked down; a mech takes it on its hull. + * Only when someone is next to it. */ /datum/action/cooldown/mob_cooldown/bounty_boss/slam name = "Ground Slam" @@ -282,7 +282,7 @@ animate(transform = rest, time = 0.2 SECONDS) /datum/action/cooldown/mob_cooldown/bounty_boss/slam/effect(atom/target) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner boss.visible_message(span_danger("[boss] brings both fists down on the floor!")) playsound(boss, 'sound/effects/meteorimpact.ogg', 80, TRUE) for(var/atom/victim as anything in boss.boss_victims_on(RANGE_TURFS(1, boss))) @@ -292,43 +292,23 @@ // ===== PYROMANIAC ===== -/mob/living/basic/bounty_criminal/boss/pyromaniac +/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac name = "scorched criminal" - desc = "A criminal in a blackened fire suit, with a fuel tank on their back and a lit torch in hand." - maxHealth = BOUNTY_PYROMANIAC_HEALTH_1 - health = BOUNTY_PYROMANIAC_HEALTH_1 - speed = BOUNTY_PYROMANIAC_SPEED - damage_coeff = list(BRUTE = BOUNTY_PYROMANIAC_BRUTE_MOD, BURN = BOUNTY_PYROMANIAC_BURN_MOD, TOX = 1, STAMINA = BOUNTY_BOSS_STAMINA_FRESH * 100 / BOUNTY_BOSS_STAMINA, OXY = 1) - melee_damage_lower = BOUNTY_PYROMANIAC_MELEE_MIN - melee_damage_upper = BOUNTY_PYROMANIAC_MELEE_MAX - armour_penetration = BOUNTY_PYROMANIAC_MELEE_AP - melee_damage_type = BURN - melee_attack_cooldown = BOUNTY_PYROMANIAC_MELEE_COOLDOWN - attack_verb_continuous = "burns" - attack_verb_simple = "burn" - attack_sound = 'sound/items/weapons/sear.ogg' - attack_vis_effect = ATTACK_EFFECT_SMASH - // Fireproof, not laser-proof: no heat damage and no fire stacks, but BURN still lands. - unsuitable_heat_damage = 0 + desc = "A criminal in a blackened fire suit, with a lit torch in hand." boss_kit = BOUNTY_KIT_PYROMANIAC boss_ability_types = list( /datum/action/cooldown/mob_cooldown/bounty_boss/flamer, /datum/action/cooldown/mob_cooldown/bounty_boss/molotov, ) -/mob/living/basic/bounty_criminal/boss/pyromaniac/Initialize(mapload) - . = ..() - add_traits(list(TRAIT_NOFIRE, TRAIT_RESISTHEAT), BOUNTY_TRAIT) - -/mob/living/basic/bounty_criminal/boss/pyromaniac/boss_health_table() - return list(BOUNTY_PYROMANIAC_HEALTH_1, BOUNTY_PYROMANIAC_HEALTH_2, BOUNTY_PYROMANIAC_HEALTH_3, BOUNTY_PYROMANIAC_HEALTH_4) - -/mob/living/basic/bounty_criminal/boss/pyromaniac/boss_kit_outfit() - return /datum/outfit/bounty_boss/pyromaniac +/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/bounty_build_outfit(zone) + return boss_supplies(bounty_outfit_instance(/datum/outfit/bounty_boss/pyromaniac)) -/mob/living/basic/bounty_criminal/boss/pyromaniac/boss_gear_text() +/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/boss_gear_text() return "[p_Their()] fire suit is scorched black." +// The firefighter suit and helmet are what keep its own fire off it (tg's thermal protection, CB-7). The torch +// doesn't holster, so it is in hand from the start. /datum/outfit/bounty_boss/pyromaniac name = "Bounty mini-boss: Pyromaniac" uniform = /obj/item/clothing/under/color/black @@ -336,12 +316,12 @@ head = /obj/item/clothing/head/utility/hardhat/red gloves = /obj/item/clothing/gloves/color/black shoes = /obj/item/clothing/shoes/workboots - r_hand = /obj/item/flamethrower + r_hand = BOUNTY_PYROMANIAC_TORCH /** * Flamer: the pilot light hisses and an orange cone shows on the floor, then a jet of fire sweeps - * it. Everyone it may hurt in the cone takes BOUNTY_PYROMANIAC_FLAMER_DAMAGE burn and is set - * alight; the floor burns on for BOUNTY_PYROMANIAC_FLAMER_FLOOR. + * it. Everyone it catches in the cone takes BOUNTY_PYROMANIAC_FLAMER_DAMAGE burn and catches fire + * (tg's fire stacks); the floor burns on for BOUNTY_PYROMANIAC_FLAMER_FLOOR. */ /datum/action/cooldown/mob_cooldown/bounty_boss/flamer name = "Flamer" @@ -359,7 +339,7 @@ return aimable(target) && get_dist(owner, target) <= BOUNTY_PYROMANIAC_FLAMER_RANGE && can_see(owner, target, BOUNTY_PYROMANIAC_FLAMER_RANGE) && landing_ok(target) /datum/action/cooldown/mob_cooldown/bounty_boss/flamer/telegraph(atom/target) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner cone = list() // Only where its fire may reach: never off its site or into a ship (M2). for(var/turf/spot as anything in cone_turfs(target, BOUNTY_PYROMANIAC_FLAMER_RANGE, BOUNTY_PYROMANIAC_FLAMER_ARC)) @@ -376,12 +356,12 @@ return owner.visible_message(span_danger("[owner] sweeps a jet of fire across the floor!")) playsound(owner, 'sound/items/weapons/fwoosh.ogg', 80, TRUE) - new /obj/effect/bounty_boss_fire_pool(get_turf(owner), fire_turfs, BOUNTY_PYROMANIAC_FLAMER_FLOOR, owner, BOUNTY_PYROMANIAC_FLAMER_DAMAGE) + new /obj/effect/bounty_boss_fire_pool(get_turf(owner), fire_turfs, BOUNTY_PYROMANIAC_FLAMER_FLOOR, owner, BOUNTY_PYROMANIAC_FLAMER_DAMAGE, BOUNTY_PYROMANIAC_FLAMER_STACKS) /** * Molotov: it lights the rag on a bottle and a ring shows where it will land, then it throws. The * bottle breaks into a 3x3 patch of fire (not through walls) for BOUNTY_PYROMANIAC_MOLOTOV_POOL: - * BOUNTY_PYROMANIAC_MOLOTOV_DAMAGE burn to anyone it may hurt there, and set alight. + * BOUNTY_PYROMANIAC_MOLOTOV_DAMAGE burn to anyone it catches there, and they catch fire. */ /datum/action/cooldown/mob_cooldown/bounty_boss/molotov name = "Molotov" @@ -411,7 +391,7 @@ /// The 3x3 around `center` that a bottle bursting there reaches: open floor, not through walls, and only where its fire may reach (M2) /datum/action/cooldown/mob_cooldown/bounty_boss/molotov/proc/splash_turfs(turf/center) . = list() - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner if(!center || !istype(boss)) return for(var/turf/spot as anything in RANGE_TURFS(1, center)) @@ -433,7 +413,7 @@ if(QDELETED(owner)) return playsound(spot, 'sound/effects/glass/glassbr3.ogg', 70, TRUE) - new /obj/effect/bounty_boss_fire_pool(spot, splash_turfs(spot), BOUNTY_PYROMANIAC_MOLOTOV_POOL, owner, BOUNTY_PYROMANIAC_MOLOTOV_DAMAGE) + new /obj/effect/bounty_boss_fire_pool(spot, splash_turfs(spot), BOUNTY_PYROMANIAC_MOLOTOV_POOL, owner, BOUNTY_PYROMANIAC_MOLOTOV_DAMAGE, BOUNTY_PYROMANIAC_MOLOTOV_STACKS) /// Something thrown, flying from where it starts to `destination` /obj/effect/temp_visual/bounty_boss_thrown @@ -454,29 +434,19 @@ // ===== DEMOLITIONIST ===== -/mob/living/basic/bounty_criminal/boss/demolitionist +/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist name = "criminal in a hard hat" - desc = "A criminal in a hard hat and a hi-vis vest, with a bandolier of grenades across their chest." - maxHealth = BOUNTY_DEMOLITIONIST_HEALTH_1 - health = BOUNTY_DEMOLITIONIST_HEALTH_1 - speed = BOUNTY_DEMOLITIONIST_SPEED - damage_coeff = list(BRUTE = BOUNTY_DEMOLITIONIST_BRUTE_MOD, BURN = BOUNTY_DEMOLITIONIST_BURN_MOD, TOX = 1, STAMINA = BOUNTY_BOSS_STAMINA_FRESH * 100 / BOUNTY_BOSS_STAMINA, OXY = 1) - melee_attack_cooldown = BOUNTY_DEMOLITIONIST_MELEE_COOLDOWN - attack_vis_effect = ATTACK_EFFECT_SMASH + desc = "A criminal in a hard hat and a hi-vis vest, with a bandolier across their chest." boss_kit = BOUNTY_KIT_DEMOLITIONIST - boss_weapon = BOUNTY_DEMOLITIONIST_CROWBAR boss_ability_types = list( /datum/action/cooldown/mob_cooldown/bounty_boss/grenade, /datum/action/cooldown/mob_cooldown/bounty_boss/breach, ) -/mob/living/basic/bounty_criminal/boss/demolitionist/boss_health_table() - return list(BOUNTY_DEMOLITIONIST_HEALTH_1, BOUNTY_DEMOLITIONIST_HEALTH_2, BOUNTY_DEMOLITIONIST_HEALTH_3, BOUNTY_DEMOLITIONIST_HEALTH_4) +/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist/bounty_build_outfit(zone) + return boss_supplies(bounty_outfit_instance(/datum/outfit/bounty_boss/demolitionist)) -/mob/living/basic/bounty_criminal/boss/demolitionist/boss_kit_outfit() - return /datum/outfit/bounty_boss/demolitionist - -/mob/living/basic/bounty_criminal/boss/demolitionist/boss_gear_text() +/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist/boss_gear_text() return "A bandolier of grenades is slung across [p_their()] chest." /** @@ -485,14 +455,14 @@ * ready for this target (out of its sight with no breach possible, or the strict rotation ruling * out the grenade), rather than standing idle. */ -/mob/living/basic/bounty_criminal/boss/demolitionist/boss_engage_plan(datum/ai_controller/controller, atom/target) +/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist/boss_engage_plan(datum/ai_controller/controller, atom/target) if(!isliving(target) && !ismecha(target)) return FALSE var/distance = get_dist(src, target) if(distance <= 1 || !boss_has_next_throw(target)) return FALSE if(distance < BOUNTY_DEMOLITIONIST_KEEP_MIN) - controller.queue_behavior(/datum/ai_behavior/step_away, BB_BASIC_MOB_CURRENT_TARGET) + controller.queue_behavior(/datum/ai_behavior/bounty_boss_back_off, BB_BASIC_MOB_CURRENT_TARGET) return TRUE if(distance > BOUNTY_DEMOLITIONIST_KEEP_MAX) controller.queue_behavior(/datum/ai_behavior/pursue_to_range, BB_BASIC_MOB_CURRENT_TARGET, BOUNTY_DEMOLITIONIST_KEEP_MAX) @@ -504,7 +474,7 @@ * Whether the rotation leaves it an ability it could use on `target` from its band. Cooldowns are * ignored on purpose, so it holds its range between grenades instead of stepping in and out. */ -/mob/living/basic/bounty_criminal/boss/demolitionist/proc/boss_has_next_throw(atom/target) +/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist/proc/boss_has_next_throw(atom/target) for(var/datum/action/cooldown/mob_cooldown/bounty_boss/ability as anything in boss_abilities) if(QDELETED(ability) || (boss_strict_rotation && ability.type == boss_last_ability)) continue @@ -517,6 +487,7 @@ return TRUE return FALSE +// Its crowbar rides in its bag until the fight starts; welding goggles keep a flash out of its eyes (tg's flash protection). /datum/outfit/bounty_boss/demolitionist name = "Bounty mini-boss: Demolitionist" uniform = /obj/item/clothing/under/misc/overalls @@ -526,7 +497,8 @@ glasses = /obj/item/clothing/glasses/welding gloves = /obj/item/clothing/gloves/color/black shoes = /obj/item/clothing/shoes/workboots - r_hand = BOUNTY_DEMOLITIONIST_CROWBAR + back = /obj/item/storage/backpack/industrial + backpack_contents = list(BOUNTY_DEMOLITIONIST_CROWBAR = 1) /** * Grenade: it pulls the pin and a mark shows where it is aiming, then it throws. The grenade lands @@ -567,7 +539,7 @@ throw_grenade(spot) if(!prob(BOUNTY_DEMOLITIONIST_SECOND_GRENADE)) return - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner var/list/near = list() for(var/turf/other as anything in RANGE_TURFS(2, spot)) if(other != spot && !isclosedturf(other) && boss.boss_reach_ok(other) && bounty_boss_clear_line(get_turf(owner), other)) @@ -577,7 +549,7 @@ /// Throws one grenade at `spot`: it flies, lands and starts its fuse /datum/action/cooldown/mob_cooldown/bounty_boss/grenade/proc/throw_grenade(turf/spot) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner // The second grenade comes half a second later: not if it was downed, cuffed or stunned meanwhile. if(!istype(boss) || !boss.boss_can_act() || !spot) return @@ -610,7 +582,7 @@ return ..() /datum/action/cooldown/mob_cooldown/bounty_boss/breach/worth_using(atom/target) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner if(!aimable(target) || !istype(boss) || boss.boss_walls_left <= 0) return FALSE if(get_dist(boss, target) > BOUNTY_DEMOLITIONIST_BREACH_RANGE) @@ -622,7 +594,7 @@ /// The interior wall or door beside it that leads toward `target`, if it may break one /datum/action/cooldown/mob_cooldown/bounty_boss/breach/proc/breach_spot(atom/target) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner var/toward = get_dir(boss, target) for(var/direction in list(toward, turn(toward, 45), turn(toward, -45))) var/turf/spot = get_step(boss, direction) @@ -645,7 +617,7 @@ mark_turfs(list(get_turf(spot)), COLOR_RED) /datum/action/cooldown/mob_cooldown/bounty_boss/breach/effect(atom/target) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner var/atom/spot = breach_ref?.resolve() breach_ref = null if(!istype(boss) || QDELETED(spot) || !boss.boss_may_break(spot)) @@ -654,11 +626,13 @@ boss.visible_message(span_danger("The charge on [spot] starts beeping!")) /** - * A boss's grenade or breaching charge: a fuse with a blinking red ring and beeping, then a - * scripted blast. No explosion(), no fire: brute against bomb armour and a knockdown to everyone - * the boss may hurt within `radius` (not through walls), and damage to structures within - * `object_radius` through the boss's rules (boss_damage_structure()). Capped at - * BOUNTY_BOSS_EXPLOSIVE_CAP server-wide. With its boss gone, it still goes off but breaks nothing. + * A boss's grenade or breaching charge: a fuse with a blinking red ring and beeping, then a blast. + * The object is scripted so nothing breaches a hull: no explosion() and no fire, and structures within + * `object_radius` take damage only through the boss's rules (boss_damage_structure()). Whoever the blast + * catches within `radius` (not through walls), standing or down, takes tg's own light explosion + * (ex_act(EXPLODE_LIGHT), CB-10): bomb armour, knockdown, ears, wounds and limbs are all tg's. A mech + * with someone in it takes `damage` on its hull. Capped at BOUNTY_BOSS_EXPLOSIVE_CAP server-wide. With + * its boss gone, it still goes off but breaks nothing. */ /obj/effect/bounty_boss_explosive name = "grenade" @@ -669,12 +643,17 @@ layer = ABOVE_OBJ_LAYER /// The boss who threw it var/datum/weakref/boss_ref + /// Its boss's factions when it was thrown: its blast never catches its own side, even with the boss gone + var/list/side_factions var/fuse = BOUNTY_DEMOLITIONIST_GRENADE_FUSE - /// Who it catches, and how hard + /// Who it catches var/radius = BOUNTY_DEMOLITIONIST_GRENADE_RADIUS + /// What it does to a mech's hull var/damage = BOUNTY_DEMOLITIONIST_GRENADE_DAMAGE + /// Its boss's zone damage factor when it was thrown (1 for a human boss) var/damage_factor = 1 - var/knockdown = BOUNTY_DEMOLITIONIST_GRENADE_KNOCKDOWN + /// Unused by the field kit (people get tg's own knockdown from the explosion); the prison's rigged charge sets it + var/knockdown = 0 /// What it breaks, and how hard var/object_radius = BOUNTY_DEMOLITIONIST_GRENADE_OBJECT_RADIUS var/object_damage = BOUNTY_DEMOLITIONIST_GRENADE_OBJECT_DAMAGE @@ -683,12 +662,13 @@ /// Its ring var/obj/effect/temp_visual/bounty_boss_mark/ring -/obj/effect/bounty_boss_explosive/Initialize(mapload, mob/living/basic/bounty_criminal/boss/boss) +/obj/effect/bounty_boss_explosive/Initialize(mapload, mob/living/carbon/human/npc/bounty_criminal/boss/boss) . = ..() if(length(GLOB.bounty_boss_explosives) >= BOUNTY_BOSS_EXPLOSIVE_CAP) return INITIALIZE_HINT_QDEL GLOB.bounty_boss_explosives += src boss_ref = boss ? WEAKREF(boss) : null + side_factions = boss ? boss.faction.Copy() : null damage_factor = boss ? boss.get_npc_zone_damage_factor() : 1 structure_tally = list(BOUNTY_BOSS_ABILITY_STRUCTURE_CAP) ring = new(get_turf(src), fuse, COLOR_RED, "target_circle") @@ -701,6 +681,7 @@ /obj/effect/bounty_boss_explosive/Destroy() GLOB.bounty_boss_explosives -= src boss_ref = null + side_factions = null structure_tally = null if(!QDELETED(ring)) qdel(ring) @@ -710,18 +691,18 @@ /obj/effect/bounty_boss_explosive/proc/beep() playsound(src, 'sound/machines/beep/beep.ogg', 30, TRUE) -/// Whether the blast may hurt `victim`: its boss's rules, or with the boss gone, awake hunters and their mechs -/obj/effect/bounty_boss_explosive/proc/may_hit(atom/victim, mob/living/basic/bounty_criminal/boss/boss) +/// Whether the blast catches `victim`: its boss's rules, or with the boss gone, anyone not on the boss's side. Never by the victim's state (CB-11). +/obj/effect/bounty_boss_explosive/proc/may_hit(atom/victim, mob/living/carbon/human/npc/bounty_criminal/boss/boss) if(!QDELETED(boss)) - return boss.boss_can_hurt(victim) - return bounty_boss_orphan_victim(victim) + return boss.boss_effect_hits(victim) + return bounty_boss_effect_victim(victim, side_factions) /obj/effect/bounty_boss_explosive/proc/detonate() var/turf/here = get_turf(src) if(!here) qdel(src) return - var/mob/living/basic/bounty_criminal/boss/boss = boss_ref?.resolve() + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = boss_ref?.resolve() if(QDELETED(boss)) boss = null blast_structures(boss, here) @@ -730,19 +711,21 @@ for(var/atom/movable/victim in range(radius, here)) if(!(isliving(victim) || ismecha(victim)) || !may_hit(victim, boss) || !bounty_boss_clear_line(here, get_turf(victim))) continue - if(boss) - boss.boss_hit(victim, npc_zone_damage(damage, damage_factor), BRUTE, BOMB, knockdown, already_scaled = TRUE) - else if(ismecha(victim)) - victim.take_damage(npc_zone_damage(damage, damage_factor), BRUTE, BOMB, FALSE) - else - var/mob/living/person = victim - person.apply_damage(npc_zone_damage(damage, damage_factor), BRUTE, BODY_ZONE_CHEST, person.run_armor_check(BODY_ZONE_CHEST, BOMB, silent = TRUE)) - if(knockdown) - person.Knockdown(knockdown) + blast(victim) qdel(src) +/// Catches `victim` in the blast: a mech on its hull, a person by tg's light explosion +/obj/effect/bounty_boss_explosive/proc/blast(atom/movable/victim) + if(ismecha(victim)) + var/obj/vehicle/sealed/mecha/mech = victim + mech.take_damage(npc_zone_damage(damage, damage_factor), BRUTE, BOMB, FALSE, get_dir(mech, src)) + return + var/mob/living/person = victim + EX_ACT(person, EXPLODE_LIGHT) + shake_camera(person, 3, 2) + /// Structures in reach take the blast, through the boss's rules -/obj/effect/bounty_boss_explosive/proc/blast_structures(mob/living/basic/bounty_criminal/boss/boss, turf/here) +/obj/effect/bounty_boss_explosive/proc/blast_structures(mob/living/carbon/human/npc/bounty_criminal/boss/boss, turf/here) if(!boss || object_damage <= 0) return for(var/obj/thing in range(object_radius, here)) @@ -758,13 +741,12 @@ fuse = BOUNTY_DEMOLITIONIST_BREACH_FUSE radius = 1 damage = BOUNTY_DEMOLITIONIST_BREACH_DAMAGE - knockdown = 0 object_radius = 0 object_damage = 0 /// The wall or door it is on var/datum/weakref/breach_ref -/obj/effect/bounty_boss_explosive/breach/Initialize(mapload, mob/living/basic/bounty_criminal/boss/boss, atom/breach_target) +/obj/effect/bounty_boss_explosive/breach/Initialize(mapload, mob/living/carbon/human/npc/bounty_criminal/boss/boss, atom/breach_target) . = ..() breach_ref = breach_target ? WEAKREF(breach_target) : null @@ -775,7 +757,7 @@ /obj/effect/bounty_boss_explosive/breach/beep() playsound(src, 'sound/machines/beep/beep.ogg', 60, TRUE) -/obj/effect/bounty_boss_explosive/breach/blast_structures(mob/living/basic/bounty_criminal/boss/boss, turf/here) +/obj/effect/bounty_boss_explosive/breach/blast_structures(mob/living/carbon/human/npc/bounty_criminal/boss/boss, turf/here) var/atom/target = breach_ref?.resolve() if(!boss || QDELETED(target)) return @@ -783,46 +765,39 @@ // ===== GHOST ===== -/mob/living/basic/bounty_criminal/boss/ghost +/mob/living/carbon/human/npc/bounty_criminal/boss/ghost name = "hooded criminal" - desc = "A lean criminal in a dark hooded cloak, holding a long knife low." - maxHealth = BOUNTY_GHOST_HEALTH_1 - health = BOUNTY_GHOST_HEALTH_1 - speed = BOUNTY_GHOST_SPEED - damage_coeff = list(BRUTE = BOUNTY_GHOST_BRUTE_MOD, BURN = BOUNTY_GHOST_BURN_MOD, TOX = 1, STAMINA = BOUNTY_BOSS_STAMINA_FRESH * 100 / BOUNTY_BOSS_STAMINA, OXY = 1) - melee_attack_cooldown = BOUNTY_GHOST_MELEE_COOLDOWN - attack_vis_effect = ATTACK_EFFECT_SLASH + desc = "A lean criminal in a dark hooded cloak, a knife at the ready." boss_kit = BOUNTY_KIT_GHOST - boss_weapon = BOUNTY_GHOST_KNIFE + // Its quickness is real chrome (the OC-6 ruling): a Slipwire shunt and a Cascade lattice. An EMP or a + // brownout takes it away as it would from a player, and it burns out when the Ghost dies. + npc_cyberware = list( + /obj/item/organ/cyberimp/cyberware/slipwire, + /obj/item/organ/cyberimp/cyberware/cascade, + ) boss_ability_types = list( /datum/action/cooldown/mob_cooldown/bounty_boss/dash, /datum/action/cooldown/mob_cooldown/bounty_boss/cloak, ) - /// Cloaked: faint, and hard to hit, until a flash, a hit or the time runs out + /// Shimmering: only a look (alpha and blur), until a flash, a hit or the time runs out var/boss_cloaked = FALSE var/boss_cloak_timer - /// world.time of its last step, for dodging while moving - var/boss_last_moved = 0 /// Cuts since it last broke off, and when it may close in again var/boss_cuts = 0 var/boss_breakoff_until = 0 - /// Its dodge and miss messages show at most every BOUNTY_BOSS_MESSAGE_COOLDOWN (L5) - COOLDOWN_DECLARE(boss_message_cooldown) -/mob/living/basic/bounty_criminal/boss/ghost/Destroy() +/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/Destroy() deltimer(boss_cloak_timer) boss_cloak_timer = null return ..() -/mob/living/basic/bounty_criminal/boss/ghost/boss_health_table() - return list(BOUNTY_GHOST_HEALTH_1, BOUNTY_GHOST_HEALTH_2, BOUNTY_GHOST_HEALTH_3, BOUNTY_GHOST_HEALTH_4) - -/mob/living/basic/bounty_criminal/boss/ghost/boss_kit_outfit() - return /datum/outfit/bounty_boss/ghost +/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/bounty_build_outfit(zone) + return boss_supplies(bounty_outfit_instance(/datum/outfit/bounty_boss/ghost)) -/mob/living/basic/bounty_criminal/boss/ghost/boss_gear_text() +/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/boss_gear_text() return "[p_They()] move[p_s()] quick and light, and the knife is never still." +// The hood goes up as the outfit is put on (tg's hooded suits do that). The knife rides in a pocket until the fight starts. /datum/outfit/bounty_boss/ghost name = "Bounty mini-boss: Ghost" uniform = /obj/item/clothing/under/color/black @@ -830,81 +805,66 @@ mask = /obj/item/clothing/mask/bandana/black gloves = /obj/item/clothing/gloves/color/black shoes = /obj/item/clothing/shoes/sneakers/black - r_hand = BOUNTY_GHOST_KNIFE + l_pocket = BOUNTY_GHOST_KNIFE -/// Its cuts bleed, and after a couple of them it breaks off for a while -/mob/living/basic/bounty_criminal/boss/ghost/melee_attack(atom/target, list/modifiers, ignore_cooldown = FALSE) - . = ..() - if(!. || !isliving(target)) - return - boss_cut(target) +/// The knife it holds, if it has one in hand +/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/proc/boss_knife() + for(var/obj/item/knife/blade in held_items) + return blade + return null + +/** + * Stabs `victim` with the knife it holds, as a player would: the knife in its active hand, a body + * zone picked, and a click through controller.ai_interact(). Damage, armour, wounds and bleeding are + * the knife's and tg's (CB-9). Returns TRUE if it swung. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/proc/boss_knife_attack(atom/victim) + var/obj/item/knife/blade = boss_knife() + if(isnull(blade) || isnull(ai_controller) || next_move > world.time || !human_npc_ready_item(src, blade)) + return FALSE + victim.visible_message(span_danger("[src] darts in and slashes [victim]!"), span_userdanger("[src] darts in and slashes you!")) + playsound(victim, 'sound/items/weapons/bladeslice.ogg', 70, TRUE) + zone_selected = human_npc_pick_aim_zone() + return ai_controller.ai_interact(target = victim, combat_mode = TRUE) -/// A cut on `victim`: it bleeds, and the hit-and-run count goes up -/mob/living/basic/bounty_criminal/boss/ghost/proc/boss_cut(mob/living/victim) - if(QDELETED(victim) || victim.stat == DEAD) +// Every knife blow it lands counts toward its hit and run: after a couple, it breaks off for a while. +/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/boss_landed_blow(mob/living/victim, obj/item/weapon) + if(!istype(weapon, /obj/item/knife)) return - victim.apply_status_effect(/datum/status_effect/bounty_boss_bleed, get_npc_zone_damage_factor()) boss_cuts++ if(boss_cuts >= BOUNTY_GHOST_CUTS_BEFORE_BREAKOFF) boss_cuts = 0 boss_breakoff_until = world.time + BOUNTY_GHOST_BREAKOFF_TIME /// Breaking off: it backs away from its target for a while -/mob/living/basic/bounty_criminal/boss/ghost/boss_engage_plan(datum/ai_controller/controller, atom/target) +/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/boss_engage_plan(datum/ai_controller/controller, atom/target) if(world.time >= boss_breakoff_until || !(isliving(target) || ismecha(target)) || get_dist(src, target) > 4) return FALSE - controller.queue_behavior(/datum/ai_behavior/step_away, BB_BASIC_MOB_CURRENT_TARGET) + controller.queue_behavior(/datum/ai_behavior/bounty_boss_back_off, BB_BASIC_MOB_CURRENT_TARGET) return TRUE -/mob/living/basic/bounty_criminal/boss/ghost/boss_moved() - boss_last_moved = world.time - -/// Whether it is on the move, for dodging -/mob/living/basic/bounty_criminal/boss/ghost/proc/boss_moving() - return world.time <= boss_last_moved + BOUNTY_GHOST_MOVING_WINDOW && boss_can_act() - -/// It dodges some shots while moving, and cloaked, half of them miss -/mob/living/basic/bounty_criminal/boss/ghost/boss_projectile_prehit(obj/projectile/shot) - if(shot.firer == src || stat != CONSCIOUS) - return NONE - var/hit_chance = 100 - if(boss_moving()) - hit_chance *= (100 - BOUNTY_GHOST_DODGE) / 100 - if(boss_cloaked) - hit_chance *= (100 - BOUNTY_GHOST_CLOAK_MISS) / 100 - if(prob(hit_chance)) - return NONE - boss_miss_message(span_warning("[src] slips aside from [shot]!")) - return PROJECTILE_INTERRUPT_HIT_PHASE - -/// A dodge or miss message, at most every BOUNTY_BOSS_MESSAGE_COOLDOWN so automatic fire doesn't flood chat (L5) -/mob/living/basic/bounty_criminal/boss/ghost/proc/boss_miss_message(message) - if(!COOLDOWN_FINISHED(src, boss_message_cooldown)) - return - COOLDOWN_START(src, boss_message_cooldown, BOUNTY_BOSS_MESSAGE_COOLDOWN) - visible_message(message) - -/// Cloaked, half the blows find nothing -/mob/living/basic/bounty_criminal/boss/ghost/boss_check_block(atom/hit_by, attack_text, attack_type) - if(!boss_cloaked || stat != CONSCIOUS || !prob(BOUNTY_GHOST_CLOAK_MISS)) - return NONE - boss_miss_message(span_warning("[attack_text] swings through the shimmer where [src] was!")) - return SUCCESSFUL_BLOCK +/// Fires its Cascade lattice (the chrome's own action), if it is ready. Returns TRUE if it fired. +/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/proc/boss_surge() + for(var/obj/item/organ/cyberimp/cyberware/cascade/lattice in organs) + for(var/datum/action/cooldown/cyberware/cascade_surge/surge in lattice.actions) + if(surge.IsAvailable()) + return surge.Trigger() + return FALSE -/mob/living/basic/bounty_criminal/boss/ghost/boss_took_damage(damage, damagetype) +/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/boss_took_damage(damage, damagetype) if(boss_cloaked) boss_uncloak("A hit breaks the shimmer around [src].") -/mob/living/basic/bounty_criminal/boss/ghost/boss_flashed(mob/living/user) +/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/boss_flashed(mob/living/user) if(boss_cloaked) boss_uncloak("The flash burns away the shimmer around [src]!") -/mob/living/basic/bounty_criminal/boss/ghost/boss_on_interrupted() +/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/boss_on_interrupted() if(boss_cloaked) boss_uncloak() -/// Fades to a faint shimmer for BOUNTY_GHOST_CLOAK_TIME -/mob/living/basic/bounty_criminal/boss/ghost/proc/boss_cloak() +/// Fades to a faint shimmer for BOUNTY_GHOST_CLOAK_TIME: a look only, nothing misses it for it (CB-12) +/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/proc/boss_cloak() if(stat != CONSCIOUS) return FALSE boss_cloaked = TRUE @@ -914,8 +874,8 @@ boss_cloak_timer = addtimer(CALLBACK(src, PROC_REF(boss_uncloak), "The shimmer around [src] fades."), BOUNTY_GHOST_CLOAK_TIME, TIMER_STOPPABLE | TIMER_DELETE_ME) return TRUE -/// Plain to see again, with `message` if something broke the cloak -/mob/living/basic/bounty_criminal/boss/ghost/proc/boss_uncloak(message) +/// Plain to see again, with `message` if something broke the shimmer +/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/proc/boss_uncloak(message) if(!boss_cloaked) return FALSE boss_cloaked = FALSE @@ -928,8 +888,8 @@ return TRUE /** - * Dash: it crouches and a blurred line shows on the floor to its target, then it darts down it, - * leaving after-images, and cuts at the end: BOUNTY_GHOST_DASH_DAMAGE and a bleed. + * Dash: it crouches and a blurred line shows on the floor to its target, then it darts down it with + * its Cascade lattice firing, leaving after-images, and stabs at the end with the knife it holds. */ /datum/action/cooldown/mob_cooldown/bounty_boss/dash name = "Dash" @@ -949,7 +909,8 @@ return ..() /datum/action/cooldown/mob_cooldown/bounty_boss/dash/worth_using(atom/target) - if(!aimable(target)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/boss = owner + if(!aimable(target) || !istype(boss) || isnull(boss.boss_knife())) return FALSE var/distance = get_dist(owner, target) return distance >= 2 && distance <= BOUNTY_GHOST_DASH_RANGE + 1 && bounty_boss_clear_line(get_turf(owner), get_turf(target)) @@ -970,11 +931,13 @@ mark_turfs(path, "#9a9ab8") /datum/action/cooldown/mob_cooldown/bounty_boss/dash/effect(atom/target) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/boss = owner if(!istype(boss)) return dash_target = aimable(target) ? WEAKREF(target) : null step_index = 0 + // The lattice fires as it goes (the OC-6 ruling): real chrome, with its own crash after. + boss.boss_surge() if(!length(path)) cut_at_end(target) return @@ -983,7 +946,7 @@ dash_step(serial) /datum/action/cooldown/mob_cooldown/bounty_boss/dash/proc/dash_step(serial) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner if(!istype(boss) || !boss.boss_still("dash", serial)) end_dash(serial, FALSE) return @@ -1003,7 +966,7 @@ addtimer(CALLBACK(src, PROC_REF(dash_step), serial), 1, TIMER_DELETE_ME) /datum/action/cooldown/mob_cooldown/bounty_boss/dash/proc/end_dash(serial, cut) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner path = null var/atom/victim = dash_target?.resolve() dash_target = null @@ -1012,30 +975,25 @@ if(cut) cut_at_end(victim) -/// The cut at the end of the dash, if its target (a hunter, or a mech) is within reach +/** + * The cut at the end of the dash: a real knife attack on whoever it dashed at, if they are within + * reach, standing or not (CB-11). Returns TRUE if it swung. + */ /datum/action/cooldown/mob_cooldown/bounty_boss/dash/proc/cut_at_end(atom/victim) - var/mob/living/basic/bounty_criminal/boss/ghost/boss = owner - if(!istype(boss) || !boss.boss_can_act() || !aimable(victim) || !boss.Adjacent(victim) || !boss.boss_can_hurt(victim)) - return - boss.do_attack_animation(victim, ATTACK_EFFECT_SLASH) - playsound(victim, 'sound/items/weapons/bladeslice.ogg', 70, TRUE) - victim.visible_message(span_danger("[boss] darts in and slashes [victim]!"), span_userdanger("[boss] darts in and slashes you!")) - if(ismecha(victim)) - boss.boss_hit(victim, BOUNTY_GHOST_DASH_DAMAGE, BRUTE, MELEE, 0, BOUNTY_GHOST_DASH_AP) - return - var/mob/living/person = victim - person.apply_damage(npc_zone_damage(BOUNTY_GHOST_DASH_DAMAGE, boss), BRUTE, BODY_ZONE_CHEST, person.run_armor_check(BODY_ZONE_CHEST, MELEE, armour_penetration = BOUNTY_GHOST_DASH_AP, silent = TRUE), sharpness = SHARP_EDGED) - boss.boss_cut(person) + var/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/boss = owner + if(!istype(boss) || !boss.boss_can_act() || !aimable(victim) || !boss.Adjacent(victim) || !boss.boss_effect_hits(victim)) + return FALSE + return boss.boss_knife_attack(victim) -/// Cloak: the air around it shimmers, then it fades to a faint distortion that half of all hits miss +/// Cloak: the air around it shimmers, then it fades to a faint distortion. A look only (CB-12). /datum/action/cooldown/mob_cooldown/bounty_boss/cloak name = "Cloak" - desc = "Fade into a shimmer that is hard to hit." + desc = "Fade into a shimmer." cooldown_time = BOUNTY_GHOST_CLOAK_COOLDOWN windup = BOUNTY_GHOST_CLOAK_WINDUP /datum/action/cooldown/mob_cooldown/bounty_boss/cloak/worth_using(atom/target) - var/mob/living/basic/bounty_criminal/boss/ghost/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/boss = owner return aimable(target) && istype(boss) && !boss.boss_cloaked /datum/action/cooldown/mob_cooldown/bounty_boss/cloak/telegraph(atom/target) @@ -1045,75 +1003,29 @@ animate(alpha = 255, time = windup / 2) /datum/action/cooldown/mob_cooldown/bounty_boss/cloak/effect(atom/target) - var/mob/living/basic/bounty_criminal/boss/ghost/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/boss = owner if(istype(boss) && boss.boss_cloak()) boss.visible_message(span_warning("[boss] fades into a faint shimmer!")) -/** - * The Ghost's cuts: BOUNTY_GHOST_BLEED_PER_CUT brute a second for each cut, up to - * BOUNTY_GHOST_BLEED_CAP, for BOUNTY_GHOST_BLEED_TIME after the last one, with the blood to show it. - * It stops once they are down (C4, M3). - */ -/datum/status_effect/bounty_boss_bleed - id = "bounty_boss_bleed" - duration = BOUNTY_GHOST_BLEED_TIME - tick_interval = 1 SECONDS - status_type = STATUS_EFFECT_REFRESH - alert_type = null - /// Cuts bleeding - var/cuts = 1 - var/damage_factor = 1 - -/datum/status_effect/bounty_boss_bleed/on_creation(mob/living/new_owner, factor = 1) - damage_factor = factor - return ..() - -/datum/status_effect/bounty_boss_bleed/on_apply() - return owner.stat == CONSCIOUS - -/datum/status_effect/bounty_boss_bleed/refresh(mob/living/new_owner, factor = 1) - damage_factor = factor - . = ..() - cuts++ - -/datum/status_effect/bounty_boss_bleed/tick(seconds_between_ticks) - if(owner.stat != CONSCIOUS) - qdel(src) - return - var/rate = min(cuts * BOUNTY_GHOST_BLEED_PER_CUT, BOUNTY_GHOST_BLEED_CAP) - owner.apply_damage(npc_zone_damage(rate, damage_factor), BRUTE, spread_damage = TRUE) - owner.bleed(rate) - // ===== HEAVY ===== -/mob/living/basic/bounty_criminal/boss/heavy +/mob/living/carbon/human/npc/bounty_criminal/boss/heavy name = "heavily armed criminal" desc = "A big criminal in heavy armour, carrying a belt-fed gun." - maxHealth = BOUNTY_HEAVY_HEALTH_1 - health = BOUNTY_HEAVY_HEALTH_1 - mob_size = MOB_SIZE_LARGE - speed = BOUNTY_HEAVY_SPEED - damage_coeff = list(BRUTE = BOUNTY_HEAVY_BRUTE_MOD, BURN = BOUNTY_HEAVY_BURN_MOD, TOX = 1, STAMINA = BOUNTY_HEAVY_STAMINA_FRESH * 100 / BOUNTY_HEAVY_STAMINA, OXY = 1) - melee_attack_cooldown = BOUNTY_HEAVY_MELEE_COOLDOWN - attack_vis_effect = ATTACK_EFFECT_SMASH boss_kit = BOUNTY_KIT_HEAVY - boss_weapon = BOUNTY_HEAVY_GUN - boss_stamina_pool = BOUNTY_HEAVY_STAMINA - boss_stamina_fresh = BOUNTY_HEAVY_STAMINA_FRESH boss_ability_types = list( /datum/action/cooldown/mob_cooldown/bounty_boss/burst, /datum/action/cooldown/mob_cooldown/bounty_boss/barricade, ) -/mob/living/basic/bounty_criminal/boss/heavy/boss_health_table() - return list(BOUNTY_HEAVY_HEALTH_1, BOUNTY_HEAVY_HEALTH_2, BOUNTY_HEAVY_HEALTH_3, BOUNTY_HEAVY_HEALTH_4) - -/mob/living/basic/bounty_criminal/boss/heavy/boss_kit_outfit() - return /datum/outfit/bounty_boss/heavy +/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/bounty_build_outfit(zone) + return boss_supplies(bounty_outfit_instance(/datum/outfit/bounty_boss/heavy)) -/mob/living/basic/bounty_criminal/boss/heavy/boss_gear_text() +/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/boss_gear_text() return "[p_They()] [p_are()] in heavy armour." +// The L6 has no sling and won't holster, so it is in hand from the start, its other hand free to fire it. +// A spare box rides in the bag; a barrier grenade in each pocket. /datum/outfit/bounty_boss/heavy name = "Bounty mini-boss: Heavy" uniform = /obj/item/clothing/under/syndicate/combat @@ -1122,14 +1034,128 @@ gloves = /obj/item/clothing/gloves/combat shoes = /obj/item/clothing/shoes/jackboots r_hand = BOUNTY_HEAVY_GUN + l_pocket = /obj/item/grenade/barrier/bounty_boss + r_pocket = /obj/item/grenade/barrier/bounty_boss + back = /obj/item/storage/backpack + backpack_contents = list(BOUNTY_HEAVY_SPARE_AMMO = 1) + +/// The belt-fed gun it holds, if it holds one +/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/proc/boss_gun() + for(var/obj/item/gun/ballistic/automatic/l6_saw/gun in held_items) + return gun + return null + +/** + * Whether `gun` is the only thing in its hands. tg fires a heavy gun only with the other hand empty, + * whichever hand is active now: the gun may sit in either, and is made the active one to fire. + */ +/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/proc/boss_hands_free_for(obj/item/gun/gun) + for(var/obj/item/held in held_items) + if(held != gun) + return FALSE + return !isnull(gun) && is_holding(gun) + +/// A barrier grenade it carries, not yet thrown +/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/proc/boss_barrier() + for(var/obj/item/grenade/barrier/bounty_boss/barrier in get_all_contents_type(/obj/item/grenade/barrier/bounty_boss)) + if(!barrier.active && (is_holding(barrier) || human_npc_can_draw(src, barrier))) + return barrier + return null + +// Its gun's belt runs out: it changes it the way a player does (bounty_heavy_reload), if it has a spare. +/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/boss_gear_plan(datum/ai_controller/controller) + if(world.time < controller.blackboard[BB_HUMAN_NPC_ARMING_RETRY_AT] || HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)) + return FALSE + var/obj/item/gun/ballistic/automatic/l6_saw/gun = boss_gun() + if(isnull(gun) || (gun.can_shoot() && !gun.cover_open)) + return FALSE + if(!gun.cover_open && isnull(human_npc_find_ammo(src, gun))) + return FALSE + controller.queue_behavior(/datum/ai_behavior/bounty_heavy_reload) + return TRUE + +// A hit while it aims spoils the burst (CB-13). +/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/boss_took_damage(damage, damagetype) + var/datum/action/cooldown/mob_cooldown/bounty_boss/burst/aiming = boss_winding() + if(!istype(aiming) || damage < BOUNTY_HEAVY_FUMBLE_DAMAGE) + return + visible_message(span_warning("[src] fumbles the shot.")) + boss_interrupt() + +/** + * Changes the belt in its L6 the way a player does, one step per action: open the feed cover, pull + * the empty box with its free hand and let it fall, take the spare from its bag, click the gun with it, + * close the cover. tg's own sounds and procs throughout. Gives up after a while and fights on. + */ +/datum/ai_behavior/bounty_heavy_reload + action_cooldown = 0.8 SECONDS + +/datum/ai_behavior/bounty_heavy_reload/setup(datum/ai_controller/controller) + . = ..() + var/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/heavy = controller.pawn + var/obj/item/gun/ballistic/automatic/l6_saw/gun = istype(heavy) ? heavy.boss_gun() : null + if(isnull(gun)) + return FALSE + controller.set_blackboard_key(BB_BOUNTY_BOSS_RELOAD_UNTIL, world.time + 12 SECONDS) + if(!gun.cover_open) + heavy.visible_message(span_notice("[heavy] flips open the feed cover on [gun].")) + +/datum/ai_behavior/bounty_heavy_reload/perform(seconds_per_tick, datum/ai_controller/controller) + var/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/heavy = controller.pawn + var/obj/item/gun/ballistic/automatic/l6_saw/gun = istype(heavy) ? heavy.boss_gun() : null + if(isnull(gun) || world.time >= controller.blackboard[BB_BOUNTY_BOSS_RELOAD_UNTIL] || HAS_TRAIT(heavy, TRAIT_HANDS_BLOCKED)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(heavy.next_move > world.time) + return AI_BEHAVIOR_DELAY + var/obj/item/spent = human_npc_spent_ammo_in_hand(heavy, gun) + if(spent) + heavy.dropItemToGround(spent, force = TRUE) + return AI_BEHAVIOR_DELAY + if(gun.magazine && gun.can_shoot()) + if(gun.cover_open) + gun.click_alt(heavy) + return AI_BEHAVIOR_DELAY + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + if(!gun.cover_open) + gun.click_alt(heavy) + return AI_BEHAVIOR_DELAY + if(gun.magazine) + // The empty box comes out into its free hand. + if(!human_npc_ready_empty_hand(heavy)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + controller.ai_interact(target = gun, combat_mode = FALSE) + return AI_BEHAVIOR_DELAY + var/obj/item/ammo = human_npc_find_ammo(heavy, gun) + if(isnull(ammo)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(!heavy.is_holding(ammo)) + if(!human_npc_take_in_hand(heavy, ammo)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_DELAY + if(!human_npc_ready_item(heavy, ammo)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + controller.ai_interact(target = gun, combat_mode = FALSE) + return AI_BEHAVIOR_DELAY + +/datum/ai_behavior/bounty_heavy_reload/finish_action(datum/ai_controller/controller, succeeded) + . = ..() + controller.clear_blackboard_key(BB_BOUNTY_BOSS_RELOAD_UNTIL) + if(succeeded) + return + // A change that got nowhere: the cover goes back down and it fights on with what it has for a while. + controller.set_blackboard_key(BB_HUMAN_NPC_ARMING_RETRY_AT, world.time + 10 SECONDS) + var/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/heavy = controller.pawn + var/obj/item/gun/ballistic/automatic/l6_saw/gun = istype(heavy) ? heavy.boss_gun() : null + if(gun?.cover_open) + gun.click_alt(heavy) /** * Suppressive burst: the gun spins up with a whirr, a red laser sight settles on the target's tile - * and a red cone shows on the floor, staying there until the last round (L3). Then - * BOUNTY_HEAVY_BURST_SHOTS rounds go into that cone over BOUNTY_HEAVY_BURST_TIME, where it aimed, not - * where the target went, and no further than the cone is marked. The rounds damage only windows, - * grilles, tables and barricades the boss may break (interior, on its site), at - * BOUNTY_HEAVY_BURST_DEMOLITION of their damage (M5). + * and a red cone shows on the floor, staying there until the last round (L3). Then it pulls the + * trigger of the real gun it holds BOUNTY_HEAVY_BURST_SHOTS times over BOUNTY_HEAVY_BURST_TIME, at the + * far edge of the cone where it aimed, not where the target went (CB-13). Real rounds from its real + * belt: when the belt runs dry the burst stops and it changes belts. It holds its fire for a round + * with one of its own side in the way. A hit while it aims spoils the burst (boss_took_damage()). */ /datum/action/cooldown/mob_cooldown/bounty_boss/burst name = "Suppressive Burst" @@ -1148,7 +1174,12 @@ return ..() /datum/action/cooldown/mob_cooldown/bounty_boss/burst/worth_using(atom/target) - if(!aimable(target)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/boss = owner + if(!aimable(target) || !istype(boss)) + return FALSE + var/obj/item/gun/gun = boss.boss_gun() + // Its gun loaded, its other hand free to fire it. + if(isnull(gun) || !gun.can_shoot() || !boss.boss_hands_free_for(gun)) return FALSE var/distance = get_dist(owner, target) return distance >= 2 && distance <= BOUNTY_HEAVY_BURST_RANGE && can_see(owner, target, BOUNTY_HEAVY_BURST_RANGE) && landing_ok(target) @@ -1166,7 +1197,7 @@ mark_turfs(cone_turfs(target, BOUNTY_HEAVY_BURST_RANGE, BOUNTY_HEAVY_BURST_ARC + BOUNTY_HEAVY_BURST_MARK_MARGIN), "#ff2020", linger = BOUNTY_HEAVY_BURST_TIME) /datum/action/cooldown/mob_cooldown/bounty_boss/burst/effect(atom/target) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner if(!istype(boss) || !aim_turf) return shots_left = BOUNTY_HEAVY_BURST_SHOTS @@ -1174,65 +1205,54 @@ var/serial = boss.boss_set_busy("burst", effect_time + 1 SECONDS) fire_round(serial) -/// One round of the burst, and the next after it +/// Where one round goes: a tile at the cone's far edge, somewhere within its arc +/datum/action/cooldown/mob_cooldown/bounty_boss/burst/proc/round_spot() + var/turf/origin = get_turf(owner) + if(!origin) + return null + var/angle = aim_angle + rand(-BOUNTY_HEAVY_BURST_ARC / 2, BOUNTY_HEAVY_BURST_ARC / 2) + return locate( + clamp(origin.x + round(BOUNTY_HEAVY_BURST_RANGE * sin(angle)), 1, world.maxx), + clamp(origin.y + round(BOUNTY_HEAVY_BURST_RANGE * cos(angle)), 1, world.maxy), + origin.z, + ) + +/// One pull of the trigger, and the next after it /datum/action/cooldown/mob_cooldown/bounty_boss/burst/proc/fire_round(serial) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/boss = owner if(!istype(boss) || !boss.boss_still("burst", serial) || shots_left <= 0 || !aim_turf) end_burst(serial) return + var/obj/item/gun/gun = boss.boss_gun() + if(isnull(gun) || !gun.can_shoot()) + // Out of belt: it changes it on its next plan. + end_burst(serial) + return shots_left-- - var/turf/origin = get_turf(boss) - var/obj/projectile/bullet/bounty_boss_heavy/bullet = new(origin) - // Its gun's own rounds, no further than the marked cone - bounty_real_weapon(BOUNTY_HEAVY_GUN).load(bullet) - bullet.range = BOUNTY_HEAVY_BURST_RANGE - bullet.maximum_range = BOUNTY_HEAVY_BURST_RANGE - bullet.firer = boss - bullet.fired_from = boss - bullet.ignored_factions = boss.faction.Copy() - bullet.aim_projectile(aim_turf, boss) - if(!QDELETED(bullet)) - bullet.fire(aim_angle + rand(-BOUNTY_HEAVY_BURST_ARC / 2, BOUNTY_HEAVY_BURST_ARC / 2)) - playsound(boss, 'sound/items/weapons/gun/l6/shot.ogg', 60, TRUE) + var/turf/spot = round_spot() + if(spot && !human_npc_ally_in_line(boss, spot) && boss.boss_hands_free_for(gun) && human_npc_ready_item(boss, gun)) + boss.ai_controller?.ai_interact(target = spot, combat_mode = TRUE) if(shots_left <= 0) end_burst(serial) return - addtimer(CALLBACK(src, PROC_REF(fire_round), serial), max(1, round(BOUNTY_HEAVY_BURST_TIME / BOUNTY_HEAVY_BURST_SHOTS)), TIMER_DELETE_ME) + addtimer(CALLBACK(src, PROC_REF(fire_round), serial), max(2, round(BOUNTY_HEAVY_BURST_TIME / BOUNTY_HEAVY_BURST_SHOTS)), TIMER_DELETE_ME) /datum/action/cooldown/mob_cooldown/bounty_boss/burst/proc/end_burst(serial) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner shots_left = 0 aim_turf = null if(istype(boss) && boss.boss_busy == "burst" && boss.boss_busy_serial == serial) boss.boss_clear_busy(serial) /** - * The Heavy's rounds: its belt-fed gun's own (BOUNTY_HEAVY_GUN, loaded as they are fired), no - * further than the marked cone, and hard on structures only where the boss may break them - */ -/obj/projectile/bullet/bounty_boss_heavy - name = "heavy round" - range = BOUNTY_HEAVY_BURST_RANGE - demolition_mod = 0 - -// Judged at what it hits, not where it was fired from (M5): never a window onto space, never off the site. -// A mech is a target, not a structure: it takes the round in full. -/obj/projectile/bullet/bounty_boss_heavy/get_demolition_modifier(obj/target) - if(ismecha(target)) - return 1 - var/mob/living/basic/bounty_criminal/boss/boss = firer - if(!istype(boss) || QDELETED(boss) || !istype(target) || istype(target, /obj/machinery/door)) - return 0 - return boss.boss_may_break(target) ? BOUNTY_HEAVY_BURST_DEMOLITION : 0 - -/** - * Barricade: it unslings a folding barrier and drops it on the tile in front of it, toward its - * target: tg's security barrier (/obj/structure/barricade/security/bounty_boss). It keeps - * BOUNTY_BOSS_BARRICADES_PER_BOSS standing; each folds away after BOUNTY_BOSS_BARRICADE_LIFE. + * Barricade: it unslings a folded barrier, arms a real barrier grenade it carries and tosses it onto + * the tile in front of it, toward its target (CB-26). The grenade opens into the Heavy's folding barrier + * (/obj/structure/barricade/security/bounty_boss). It keeps BOUNTY_BOSS_BARRICADES_PER_BOSS standing; + * each folds away after BOUNTY_BOSS_BARRICADE_LIFE. Two grenades, two barriers: then it has none left. */ /datum/action/cooldown/mob_cooldown/bounty_boss/barricade name = "Deploy Barricade" - desc = "Drop a folding barrier in front of you." + desc = "Toss a barrier grenade in front of you." cooldown_time = BOUNTY_HEAVY_BARRICADE_COOLDOWN windup = BOUNTY_HEAVY_BARRICADE_WINDUP /// Where it will stand, from the telegraph @@ -1246,14 +1266,17 @@ return ..() /datum/action/cooldown/mob_cooldown/bounty_boss/barricade/worth_using(atom/target) - if(!aimable(target) || length(GLOB.bounty_boss_barricades) >= BOUNTY_BOSS_BARRICADE_CAP) + var/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/boss = owner + if(!aimable(target) || !istype(boss) || length(GLOB.bounty_boss_barricades) >= BOUNTY_BOSS_BARRICADE_CAP) + return FALSE + if(isnull(boss.boss_barrier()) || !length(boss.get_empty_held_indexes())) return FALSE var/distance = get_dist(owner, target) return distance >= 3 && distance <= 9 && !isnull(find_spot(target)) /// The open tile in front of it toward `target`, on its site, with no barrier on it /datum/action/cooldown/mob_cooldown/bounty_boss/barricade/proc/find_spot(atom/target) - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = owner if(!istype(boss)) return null var/turf/spot = get_step(boss, get_dir(boss, target)) @@ -1273,16 +1296,26 @@ /datum/action/cooldown/mob_cooldown/bounty_boss/barricade/effect(atom/target) var/turf/spot = barricade_spot barricade_spot = null - var/mob/living/basic/bounty_criminal/boss/boss = owner + var/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/boss = owner if(!istype(boss) || !spot || spot.is_blocked_turf() || (locate(/obj/structure/barricade) in spot) || !boss.boss_environment_allowed(spot)) return if(length(GLOB.bounty_boss_barricades) >= BOUNTY_BOSS_BARRICADE_CAP) return - var/obj/structure/barricade/security/bounty_boss/barrier = new(spot) + var/obj/item/grenade/barrier/bounty_boss/grenade = boss.boss_barrier() + if(isnull(grenade) || !human_npc_take_in_hand(boss, grenade) || !human_npc_ready_item(boss, grenade)) + return + grenade.ability_ref = WEAKREF(src) + // The player's way: pull the pin in hand, then throw it. + grenade.attack_self(boss) + boss.throw_mode_on(THROW_MODE_TOGGLE) + if(!boss.throw_item(spot)) + boss.throw_mode_off(THROW_MODE_TOGGLE) + boss.dropItemToGround(grenade) + +/// One of its barriers went up: it keeps count of it +/datum/action/cooldown/mob_cooldown/bounty_boss/barricade/proc/note_barrier(obj/structure/barricade/security/bounty_boss/barrier) if(QDELETED(barrier)) return - boss.visible_message(span_warning("[boss] slams a barrier down in front of [boss.p_them()].")) - playsound(spot, 'sound/effects/bang.ogg', 50, TRUE) barriers += WEAKREF(barrier) prune_barriers() @@ -1297,6 +1330,39 @@ var/obj/structure/barricade/security/bounty_boss/barrier = oldest.resolve() barrier?.fold_away() +/** + * The Heavy's barrier grenades: tg's barrier grenade on a short fuse, that opens into its folding + * barrier instead of a standing one. Issued as a consumable (it may leave the Heavy's body, thrown, but + * in anyone else's hands it is gone). + */ +/obj/item/grenade/barrier/bounty_boss + det_time = BOUNTY_HEAVY_BARRIER_FUSE + /// The Heavy's barricade ability that threw it, to count the barrier it makes + var/datum/weakref/ability_ref + +/obj/item/grenade/barrier/bounty_boss/Destroy() + ability_ref = null + return ..() + +// tg's barrier grenade, but what it makes is the folding barrier (and only ever the one). +/obj/item/grenade/barrier/bounty_boss/detonate(mob/living/lanced_by) + if(dud_flags) + active = FALSE + update_appearance() + return FALSE + dud_flags |= GRENADE_USED + SEND_SIGNAL(src, COMSIG_GRENADE_DETONATE, lanced_by) + var/turf/spot = get_turf(src) + if(spot && !(locate(/obj/structure/barricade) in spot)) + var/obj/structure/barricade/security/bounty_boss/barrier = new(spot) + if(!QDELETED(barrier)) + spot.visible_message(span_warning("[src] snaps open into a barrier.")) + playsound(spot, 'sound/effects/bang.ogg', 50, TRUE) + var/datum/action/cooldown/mob_cooldown/bounty_boss/barricade/ability = ability_ref?.resolve() + ability?.note_barrier(barrier) + qdel(src) + return TRUE + /// The Heavy's folding barrier: tg's security barrier that folds itself away after BOUNTY_BOSS_BARRICADE_LIFE. Drops nothing. /obj/structure/barricade/security/bounty_boss name = "folding barrier" diff --git a/voidcrew/modules/bounties/bounty_companions.dm b/voidcrew/modules/bounties/bounty_companions.dm index 909d993cbd6..3637824a3cd 100644 --- a/voidcrew/modules/bounties/bounty_companions.dm +++ b/voidcrew/modules/bounties/bounty_companions.dm @@ -3,66 +3,49 @@ * * Owner: P3 AI. Do not edit this file outside P3. * - * What it owns: /mob/living/basic/bounty_companion (its body, its built-in values and its AI) and - * spawn_companions(). Companions (0-2, spec C7) keep a criminal company: they sit at the bar with - * them, take turns in their talk, sit round their camp, and fight beside them with a style of their - * own (BOUNTY_COMPANION_HEALTH x the style's health; its weapon hits as the real one does). The - * AI is the trooper's peaceful pattern: retaliation, then calling the rest of the gang in, then the - * attack, then going to whoever called. A badly hurt companion may run; when their criminal goes - * down, is cuffed or gives up, each may run; a stamina-crit companion gives up for good. + * What it owns: /mob/living/carbon/human/npc/bounty_companion (its built-in values, its outfit and its + * AI), bounty_spawn_companion() and spawn_companions(). Companions (0-2, spec C7) keep a criminal + * company: they sit at the bar with them (a real chair and a real glass), take turns in their talk, sit + * round their camp, and fight beside them with a style of their own: a real weapon they carry and draw + * (bounty_styles.dm). They are real human bodies (CR-11): a person's health and stamina, toughness 1, + * no multipliers. The AI is the trooper's peaceful pattern: retaliation, then calling the rest of the + * gang in, then the attack, then going to whoever called. Badly hurt, a companion may run; when their + * criminal goes down, is cuffed or gives up, each may run; up from a real stamina crit with hunters + * around, it gives up (tg's *surrender) or runs. It gives up the way its criminal does + * (/datum/human_npc_surrender/bounty). * - * They are not bounties, pay nothing, drop nothing and carry no real weapon (what is in their hand - * is only a picture, though its blows and shots are the real item's). P5 deletes them when the posting closes; deleting one at any time - * is safe. + * They are not bounties, pay nothing and drop nothing (their kit is locked to them, D3). P5 deletes + * them when the posting closes; deleting one at any time is safe. * * The shared vars are declared in bounty_types.dm and nowhere else (leader_ref); the rest here * have an `ai_` prefix. */ -/mob/living/basic/bounty_companion +/mob/living/carbon/human/npc/bounty_companion name = "associate" - desc = "Someone keeping bad company." - icon = 'icons/mob/simple/simple_human.dmi' - unique_name = FALSE - maxHealth = BOUNTY_COMPANION_HEALTH - health = BOUNTY_COMPANION_HEALTH - speed = BOUNTY_CALM_SPEED - mob_biotypes = MOB_ORGANIC | MOB_HUMANOID - sentience_type = SENTIENCE_HUMANOID - status_flags = CANPUSH | CANSTUN | CANKNOCKDOWN - basic_mob_flags = NONE - // Stamina crit compares raw loss with a percentage when it ends; a pool of 100 keeps the two the same. - max_stamina = 100 - max_stamina_slowdown = 1 - // Dressed for the site, as their criminal is: no dying of the air or the cold on the way. - unsuitable_atmos_damage = 0 - unsuitable_cold_damage = 0 - unsuitable_heat_damage = 0 - blood_volume = BLOOD_VOLUME_NORMAL - mobility_flags = MOBILITY_FLAGS_REST_CAPABLE_DEFAULT - rotate_on_lying = TRUE - death_message = "seizes up and falls limp, their eyes dead and lifeless..." - response_help_continuous = "pats" - response_help_simple = "pat" faction = list(FACTION_HOSTILE) ai_controller = /datum/ai_controller/basic_controller/bounty/companion - /// What they hold, drawn in their vis_contents - var/obj/effect/abstract/bounty_held/ai_hand - /// Hands up, over their head, once they give up - var/obj/effect/abstract/bounty_held/ai_over_head - /// Put their hands up (stamina crit): out of it for good - var/ai_gave_up = FALSE + npc_outfit_table = /datum/human_npc_outfit_table/bounty + npc_surrender = /datum/human_npc_surrender/bounty + // They stop once their target is down, as their criminal does (spec C4) + npc_target_stat = HUMAN_NPC_SPARES_DOWNED + // A person's toughness: no multipliers (CR-11) + npc_damage_taken = 1 + /// Their fighting style (BOUNTY_STYLE_*), picked when they are dressed + var/ai_style /// Ran off: out of it for good var/ai_fled = FALSE /// The one roll to run when badly hurt has been made var/ai_flee_rolled = FALSE - /// In the fight now (weapon out, fighting pace) + /// In the fight now (weapon out, at a run) var/ai_in_fight = FALSE - /// Their drink at the bar, in their contents + /// Went into a real stamina crit, and hasn't decided yet what to do about it + var/ai_stamcritted = FALSE + /// Their glass at the bar var/obj/item/reagent_containers/cup/glass/drinkingglass/ai_drink /// Weakref to the seat they sat on var/datum/weakref/ai_seat_ref - /// Sitting on the floor + /// Sitting on the floor (tg's resting, of their own choosing) var/ai_crouching = FALSE /// Where they mean to be while nothing is happening, and when that is next thought about var/turf/ai_idle_spot @@ -70,112 +53,107 @@ /// world.time of their next word in the conversation var/ai_next_reply = 0 -/mob/living/basic/bounty_companion/Destroy() +/mob/living/carbon/human/npc/bounty_companion/Destroy() ai_let_go() - ai_over_head = bounty_ai_update_held(src, ai_over_head, null) ai_idle_spot = null leader_ref = null return ..() -/mob/living/basic/bounty_companion/death(gibbed) +/mob/living/carbon/human/npc/bounty_companion/death(gibbed) ai_let_go() - ai_over_head = bounty_ai_update_held(src, ai_over_head, null) return ..() -/// Their criminal, if still around -/mob/living/basic/bounty_companion/proc/ai_leader() - var/mob/living/basic/bounty_criminal/leader = leader_ref?.resolve() - return QDELETED(leader) ? null : leader - -/// Whether they can still fight: awake, on their feet (a knockdown is a cuff window, H2), not run off, not given up -/mob/living/basic/bounty_companion/proc/ai_can_fight() - return stat == CONSCIOUS && !ai_gave_up && !ai_fled && !HAS_TRAIT(src, TRAIT_INCAPACITATED) && !HAS_TRAIT(src, TRAIT_FLOORED) - /** - * Joins `leader`: their faction, a style of their own, a look for the site, and a name. Called by - * spawn_companions(). + * What they wear: plain clothes for the zone they are made in, their style's weapon (never a Wanted + * criminal's heavier one) and its spares, and a bruise pack. The style is picked here, as they are + * dressed, so the weapon they carry is the one they fight with. */ -/mob/living/basic/bounty_companion/proc/ai_join(mob/living/basic/bounty_criminal/leader) - leader_ref = WEAKREF(leader) - faction = leader.faction.Copy() - gender = pick(MALE, FEMALE) - name = generate_random_name_species_based(gender, TRUE, /datum/species/human) - real_name = name - ai_controller?.set_blackboard_key(BB_BOUNTY_LEADER, leader) - ai_take_style(pick_weight(list( +/mob/living/carbon/human/npc/bounty_companion/bounty_build_outfit(zone) + ai_style ||= pick_weight(list( BOUNTY_STYLE_BRAWLER = 3, BOUNTY_STYLE_KNIFE = 2, BOUNTY_STYLE_CLUB = 2, BOUNTY_STYLE_PISTOL = 1, BOUNTY_STYLE_BOTTLE = 1, BOUNTY_STYLE_SHOTGUN = 1, - ))) - INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(set_outpost_npc_look), src, bounty_companion_outfit(leader), gender, random_outpost_npc_look_number()) + )) + return bounty_fighter_outfit(BOUNTY_ARCHETYPE_NORMAL, zone, BOUNTY_TIER_PETTY, ai_style, FALSE, /obj/item/stack/medical/bruise_pack) + +/// Their criminal, if still around +/mob/living/carbon/human/npc/bounty_companion/proc/ai_leader() + var/mob/living/carbon/human/npc/bounty_criminal/leader = leader_ref?.resolve() + return QDELETED(leader) ? null : leader + +/** + * Whether they can still fight: awake, out of crit, on their feet (a knockdown is a cuff window, H2), + * free, not giving up and not run off. All read from tg. + */ +/mob/living/carbon/human/npc/bounty_companion/proc/ai_can_fight() + if(stat != CONSCIOUS || ai_fled || npc_surrendering || HAS_TRAIT(src, TRAIT_CRITICAL_CONDITION) || HAS_TRAIT(src, TRAIT_RESTRAINED)) + return FALSE + return !HAS_TRAIT(src, TRAIT_INCAPACITATED) && !HAS_TRAIT(src, TRAIT_FLOORED) -/// Takes style `key`: health BOUNTY_COMPANION_HEALTH x the style's, and the style's own weapon (never a Wanted criminal's heavier one) -/mob/living/basic/bounty_companion/proc/ai_take_style(key) - var/datum/bounty_style/style = GLOB.bounty_styles[key] - if(!style) +/** + * Joins `leader`: their faction, the style they were dressed for, and a place on the criminal's and + * the posting's list of companions (whoever spawned them). Called by bounty_spawn_companion(). + */ +/mob/living/carbon/human/npc/bounty_companion/proc/ai_join(mob/living/carbon/human/npc/bounty_criminal/leader) + if(QDELETED(leader)) return FALSE - maxHealth = round(BOUNTY_COMPANION_HEALTH * style.health_mult) - health = maxHealth - damage_coeff = damage_coeff.Copy() - damage_coeff[STAMINA] = style.stamina_mult - return bounty_ai_apply_style(src, key) - -/// What a companion of `leader` wears, by where the criminal is -/proc/bounty_companion_outfit(mob/living/basic/bounty_criminal/leader) - var/datum/criminal_bounty/posting = leader?.posting() - switch(posting?.placement_kind) - if(BOUNTY_PLACEMENT_NPC_SHIP) - return /datum/outfit/outpost_off_duty_pirate - if(BOUNTY_PLACEMENT_TRADER_OUTPOST) - return /datum/outfit/job/assistant/greytide - return pick(/datum/outfit/hermit/survivor, /datum/outfit/hermit/survivor/hunter) + leader_ref = WEAKREF(leader) + faction = leader.faction.Copy() + ai_controller?.set_blackboard_key(BB_BOUNTY_LEADER, leader) + bounty_ai_apply_style(src, ai_style || BOUNTY_STYLE_BRAWLER) + var/datum/weakref/our_ref = WEAKREF(src) + leader.companions |= our_ref + var/datum/criminal_bounty/posting = leader.posting() + if(posting) + posting.companions |= our_ref + bounty_ai_set_pace(src, BOUNTY_CALM_SPEED) + return TRUE /// Called in by their criminal: `target` is theirs to fight too -/mob/living/basic/bounty_companion/proc/ai_join_fight(mob/living/target) +/mob/living/carbon/human/npc/bounty_companion/proc/ai_join_fight(mob/living/target) if(!ai_can_fight() || !isliving(target) || QDELETED(ai_controller) || bounty_ai_same_gang(src, target)) return ai_mark_enemy(target) - var/mob/living/basic/bounty_criminal/leader = ai_leader() + var/mob/living/carbon/human/npc/bounty_criminal/leader = ai_leader() if(leader && get_dist(src, leader) > 4) ai_controller.set_blackboard_key(BB_BASIC_MOB_REINFORCEMENT_TARGET, leader) ai_enter_fight() -/// Weapon out, up from their seat, fighting pace -/mob/living/basic/bounty_companion/proc/ai_enter_fight() +/// Up from their seat, drink down, at a run. The weapon comes out through the arm subtree (bounty_styles.dm). +/mob/living/carbon/human/npc/bounty_companion/proc/ai_enter_fight() if(ai_in_fight) return ai_in_fight = TRUE ai_put_drink_away() ai_stand_up() - var/datum/bounty_style/style = bounty_ai_style(src) - set_varspeed(style?.speed || BOUNTY_NORMAL_SPEED_MELEE) - ai_hand = bounty_ai_update_held(src, ai_hand, bounty_ai_held_look(src)) + bounty_ai_set_pace(src, BOUNTY_RUN_SPEED) -/// The fight is over for them: weapon away, easy pace -/mob/living/basic/bounty_companion/proc/ai_leave_fight() +/// The fight is over for them: weapon away, at a walk +/mob/living/carbon/human/npc/bounty_companion/proc/ai_leave_fight() if(!ai_in_fight) return ai_in_fight = FALSE - set_varspeed(BOUNTY_CALM_SPEED) - ai_hand = bounty_ai_update_held(src, ai_hand, null) + bounty_ai_set_pace(src, BOUNTY_CALM_SPEED) + bounty_ai_holster(src) /// Their criminal is down, cuffed or gave up: half the time they run for it -/mob/living/basic/bounty_companion/proc/ai_lose_heart() +/mob/living/carbon/human/npc/bounty_companion/proc/ai_lose_heart() if(!ai_can_fight() || !prob(50)) return var/mob/living/threat = ai_controller?.blackboard[BB_BASIC_MOB_CURRENT_TARGET] ai_run_off(isliving(threat) ? threat : null) /// Runs off, out of the fight for good -/mob/living/basic/bounty_companion/proc/ai_run_off(mob/living/threat) +/mob/living/carbon/human/npc/bounty_companion/proc/ai_run_off(mob/living/threat) if(ai_fled || stat != CONSCIOUS) return ai_fled = TRUE ai_let_go() - set_varspeed(BOUNTY_NORMAL_SPEED_MELEE) + bounty_ai_holster(src) + bounty_ai_set_pace(src, BOUNTY_RUN_SPEED) visible_message(span_notice("[src] backs off and runs for it.")) if(QDELETED(ai_controller)) return @@ -186,25 +164,36 @@ ai_controller.set_blackboard_key(BB_BASIC_MOB_FLEE_TARGET, bounty_ai_target_for(threat)) ai_controller.CancelActions() -/// Stamina crit: hands up, done with it -/mob/living/basic/bounty_companion/proc/ai_give_up() - if(ai_gave_up || stat == DEAD) - return - ai_gave_up = TRUE - ai_let_go() - ai_over_head = bounty_ai_update_held(src, ai_over_head, /obj/effect/abstract/bounty_surrender_mark, over_head = TRUE) +/// They gave up (tg's *surrender, through the human NPC base): the fight dropped +/mob/living/carbon/human/npc/bounty_companion/proc/ai_on_surrendered() visible_message(span_notice("[src] puts [p_their()] hands up.")) + ai_let_go() if(QDELETED(ai_controller)) return ai_controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) ai_controller.clear_blackboard_key(BB_BASIC_MOB_RETALIATE_LIST) - ai_controller.CancelActions() + +/** + * Up from a real stamina crit (CR-11): with hunters around, they give up (tg's *surrender) or run; + * with nobody about, they get back to it. + */ +/mob/living/carbon/human/npc/bounty_companion/proc/ai_after_stamcrit() + ai_stamcritted = FALSE + if(!ai_can_fight()) + return + var/datum/human_npc_surrender/rules = npc_surrender_rules() + var/list/hostiles = rules?.hostiles_near(src) + if(!length(hostiles)) + return + if(prob(BOUNTY_COMPANION_GIVE_UP_CHANCE) && npc_surrender()) + return + ai_run_off(get_closest_atom(/mob/living, hostiles, src)) /** * `enemy` is someone to fight: onto their retaliation list, and the mech they sit in with them (H4: * the targeting takes the mech while they are in it, and them once they climb out). */ -/mob/living/basic/bounty_companion/proc/ai_mark_enemy(mob/living/enemy) +/mob/living/carbon/human/npc/bounty_companion/proc/ai_mark_enemy(mob/living/enemy) if(QDELETED(ai_controller) || !isliving(enemy)) return ai_controller.insert_blackboard_key_lazylist(BB_BASIC_MOB_RETALIATE_LIST, enemy) @@ -218,8 +207,8 @@ * blow from their own side of the site with nobody playing it is let go (M1). Knocked down, they * still remember who did it, and fight once up. */ -/mob/living/basic/bounty_companion/proc/ai_attacked_by(mob/living/attacker) - if(stat == DEAD || ai_gave_up || ai_fled || !isliving(attacker) || bounty_ai_same_gang(src, attacker)) +/mob/living/carbon/human/npc/bounty_companion/proc/ai_attacked_by(mob/living/attacker) + if(stat == DEAD || ai_fled || !isliving(attacker) || bounty_ai_same_gang(src, attacker)) return if(bounty_ai_friendly_fire(src, attacker)) return @@ -228,24 +217,24 @@ ai_enter_fight() ai_leader()?.ai_ally_attacked(attacker) -/// About to take damage: badly hurt, they may run (one roll) -/mob/living/basic/bounty_companion/proc/ai_took_damage(damage, damagetype) +/// They took a hit: badly hurt (a person's health, read after the hit), they may run (one roll) +/mob/living/carbon/human/npc/bounty_companion/proc/ai_took_damage(damage, damagetype) if(ai_flee_rolled || damage <= 0 || !ai_can_fight() || !(damagetype in list(BRUTE, BURN))) return - if(health - damage > maxHealth * BOUNTY_COMPANION_FLEE_BELOW) + if(health > maxHealth * BOUNTY_COMPANION_FLEE_BELOW) return ai_flee_rolled = TRUE if(prob(BOUNTY_COMPANION_FLEE_CHANCE)) var/mob/living/threat = ai_controller?.blackboard[BB_BASIC_MOB_CURRENT_TARGET] INVOKE_ASYNC(src, PROC_REF(ai_run_off), isliving(threat) ? threat : null) -/// Everything down: drink, seat, weapon -/mob/living/basic/bounty_companion/proc/ai_let_go() +/// Everything down: drink, seat or the floor. What they hold stays held (D3). +/mob/living/carbon/human/npc/bounty_companion/proc/ai_let_go() ai_put_drink_away() ai_stand_up() - ai_hand = bounty_ai_update_held(src, ai_hand, null) -/mob/living/basic/bounty_companion/proc/ai_sit_on(obj/structure/chair/seat) +/// Sits on `seat` from its tile: buckled to it, as anyone sitting down is +/mob/living/carbon/human/npc/bounty_companion/proc/ai_sit_on(obj/structure/chair/seat) if(QDELETED(seat) || loc != seat.loc || (seat.has_buckled_mobs() && buckled != seat)) return FALSE if(buckled == seat) @@ -256,40 +245,49 @@ ai_seat_ref = WEAKREF(seat) return TRUE -/mob/living/basic/bounty_companion/proc/ai_crouch() - if(ai_crouching || buckled) +/// Sits down on the ground: tg's resting +/mob/living/carbon/human/npc/bounty_companion/proc/ai_crouch() + if(ai_crouching || buckled || resting) return ai_crouching = TRUE - add_offsets(BOUNTY_AI_TRAIT, y_add = -4) + set_resting(TRUE, silent = TRUE) -/// Up from a seat they sat on themselves, or the floor -/mob/living/basic/bounty_companion/proc/ai_stand_up() +/// Up from a seat they sat on themselves, or the floor they lay down on themselves +/mob/living/carbon/human/npc/bounty_companion/proc/ai_stand_up() if(ai_crouching) ai_crouching = FALSE - remove_offsets(BOUNTY_AI_TRAIT) + if(resting) + set_resting(FALSE, silent = TRUE) var/obj/structure/chair/seat = ai_seat_ref?.resolve() ai_seat_ref = null if(seat && buckled == seat) seat.unbuckle_mob(src, force = TRUE) -/mob/living/basic/bounty_companion/proc/ai_take_drink() - if(!QDELETED(ai_drink)) +/// A glass of something poured into a free hand +/mob/living/carbon/human/npc/bounty_companion/proc/ai_take_drink() + if(!QDELETED(ai_drink) && is_holding(ai_drink)) + return ai_drink + ai_drink = bounty_ai_pour_drink(src) + return ai_drink + +/// The glass goes: on the table beside them if there is one, else it is gone (M4, L7) +/mob/living/carbon/human/npc/bounty_companion/proc/ai_put_drink_away() + if(QDELETED(ai_drink)) + ai_drink = null return - ai_drink = new(src) - ai_drink.reagents.add_reagent(/datum/reagent/consumable/ethanol/beer, 25) - ai_hand = bounty_ai_update_held(src, ai_hand, ai_drink) - -/mob/living/basic/bounty_companion/proc/ai_put_drink_away() - if(ai_drink) - QDEL_NULL(ai_drink) - ai_hand = bounty_ai_update_held(src, ai_hand, null) + var/obj/item/glass = ai_drink + ai_drink = null + var/obj/structure/table/table = locate() in range(1, src) + if(stat == CONSCIOUS && bounty_ai_set_glass_down(src, glass, table)) + return + qdel(glass) /** * Where they mean to be while nothing is happening, thought about every few seconds rather than * every plan: beside their criminal when they talk, on a seat near them at the bar, beside the fire * at the camp, otherwise within BOUNTY_COMPANION_FOLLOW of them. Null means right where they are. */ -/mob/living/basic/bounty_companion/proc/ai_pick_idle_spot(mob/living/basic/bounty_criminal/leader) +/mob/living/carbon/human/npc/bounty_companion/proc/ai_pick_idle_spot(mob/living/carbon/human/npc/bounty_criminal/leader) var/datum/bounty_activity/activity = leader.ai_activity if(istype(activity, /datum/bounty_activity/chat)) var/datum/bounty_activity/chat/talk = activity @@ -312,9 +310,9 @@ return ai_free_tile_near(leader, BOUNTY_COMPANION_FOLLOW) /// The nearest free tile within `distance` of `thing` (not its own), on their criminal's site -/mob/living/basic/bounty_companion/proc/ai_free_tile_near(atom/thing, distance) +/mob/living/carbon/human/npc/bounty_companion/proc/ai_free_tile_near(atom/thing, distance) var/turf/center = get_turf(thing) - var/mob/living/basic/bounty_criminal/leader = ai_leader() + var/mob/living/carbon/human/npc/bounty_criminal/leader = ai_leader() if(!center) return null var/turf/best @@ -334,18 +332,22 @@ /** * Hanging out with their criminal, about once a second: sat down where there is a seat (with a - * drink at the bar), sat by the fire at the camp, facing them, and now and then a word back. + * drink at the bar, which they really drink now and then), sat by the fire at the camp, facing them, + * and now and then a word back. */ -/mob/living/basic/bounty_companion/proc/ai_hang_out() - var/mob/living/basic/bounty_criminal/leader = ai_leader() +/mob/living/carbon/human/npc/bounty_companion/proc/ai_hang_out() + var/mob/living/carbon/human/npc/bounty_criminal/leader = ai_leader() if(!leader) return var/obj/structure/chair/seat = locate() in loc if(seat && istype(leader.buckled, /obj/structure/chair) && ai_sit_on(seat)) - ai_take_drink() + if(QDELETED(ai_drink)) + ai_take_drink() + else if(prob(5)) + bounty_ai_sip(src, ai_drink) else if(istype(leader.ai_activity, /datum/bounty_activity/camp)) ai_crouch() - if(!buckled && get_dist(src, leader) <= 3) + if(!buckled && !resting && get_dist(src, leader) <= 3) face_atom(leader) if(world.time < ai_next_reply || leader.ai_mode != BOUNTY_AI_CALM || get_dist(src, leader) > 3) return @@ -353,14 +355,39 @@ if(prob(50) && !istype(leader.ai_activity, /datum/bounty_activity/chat)) INVOKE_ASYNC(src, TYPE_PROC_REF(/mob/living, bounty_say), "companion_reply") +// ===== SPAWNING ===== + +/** + * Queues one companion for `leader` at `where` (the human NPC spawn queue: never a room of humans in + * one tick), who joins them as it is made: their faction, their side, their posting's list. Then + * `on_spawned` is called with it. If the criminal is gone by then, the companion is not kept. + * `immediate` builds it now (tests, admin tools). Returns the spawn order (qdel() cancels it). + */ +/proc/bounty_spawn_companion(mob/living/carbon/human/npc/bounty_criminal/leader, turf/where, datum/callback/on_spawned, immediate = FALSE) + where = get_turf(where) + if(QDELETED(leader) || !where) + return null + return spawn_human_npc(/mob/living/carbon/human/npc/bounty_companion, where, CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(bounty_companion_spawned), WEAKREF(leader), on_spawned), immediate = immediate) + +/// A queued companion is made: it joins its criminal, or goes if its criminal is gone +/proc/bounty_companion_spawned(datum/weakref/leader_ref, datum/callback/on_spawned, mob/living/carbon/human/npc/bounty_companion/companion) + var/mob/living/carbon/human/npc/bounty_criminal/leader = leader_ref?.resolve() + if(QDELETED(companion)) + return + if(QDELETED(leader) || !companion.ai_join(leader)) + qdel(companion) + return + on_spawned?.Invoke(companion) + // ===== THE CRIMINAL'S SIDE ===== /** * Spawns `count` companions (clamped to BOUNTY_COMPANIONS_MIN-BOUNTY_COMPANIONS_MAX) on free tiles - * beside them, remembered in their own `companions`. Returns the companions spawned: the caller - * (P5) puts them on the posting, and keeps to the global cap on live companions. + * beside them, through the human NPC spawn queue (bounty_spawn_companion()). Each joins them, and their + * posting, as it is made. Returns the companions already made: only with `immediate` (tests, admin + * tools), otherwise an empty list. */ -/mob/living/basic/bounty_criminal/proc/spawn_companions(count) +/mob/living/carbon/human/npc/bounty_criminal/proc/spawn_companions(count, immediate = FALSE) . = list() count = clamp(count, BOUNTY_COMPANIONS_MIN, BOUNTY_COMPANIONS_MAX) var/turf/home = get_turf(src) @@ -377,16 +404,16 @@ for(var/i in 1 to count) if(!length(spots)) break - var/mob/living/basic/bounty_companion/buddy = new(pick_n_take(spots)) - buddy.ai_join(src) - companions |= WEAKREF(buddy) - . += buddy + var/datum/human_npc_order/order = bounty_spawn_companion(src, pick_n_take(spots), null, immediate) + var/mob/living/carbon/human/npc/bounty_companion/buddy = order?.spawned_ref?.resolve() + if(!QDELETED(buddy)) + . += buddy /** * One of their companions was attacked by `attacker`: it goes on their grudge list, and the gang * turns on them. Never while blended in (C1), and never over friendly fire (M1). */ -/mob/living/basic/bounty_criminal/proc/ai_ally_attacked(mob/living/attacker) +/mob/living/carbon/human/npc/bounty_criminal/proc/ai_ally_attacked(mob/living/attacker) if(blended || !isliving(attacker) || bounty_ai_same_gang(src, attacker) || bounty_ai_friendly_fire(src, attacker)) return ai_add_grudge(attacker) @@ -397,18 +424,25 @@ // ===== AI ===== /** - * A companion's controller: the trooper's peaceful pattern (retaliate, call the others in, - * attack by style, go to whoever called), then hanging out with their criminal. + * A companion's controller: the trooper's peaceful pattern (retaliate, call the others in, attack by + * style with the real weapon, go to whoever called), patching themselves up when it is quiet (N6), then + * hanging out with their criminal. It gives up as its criminal does (human_npc_surrender). */ /datum/ai_controller/basic_controller/bounty/companion planning_subtrees = list( + /datum/ai_planning_subtree/human_npc_soft_crit, + /datum/ai_planning_subtree/bounty_escape_captivity, + /datum/ai_planning_subtree/human_npc_walk_out, + /datum/ai_planning_subtree/human_npc_surrender, /datum/ai_planning_subtree/bounty_companion_gate, /datum/ai_planning_subtree/flee_target/bounty, /datum/ai_planning_subtree/target_retaliate/bounty, /datum/ai_planning_subtree/call_reinforcements/bounty, - /datum/ai_planning_subtree/basic_ranged_attack_subtree/bounty, - /datum/ai_planning_subtree/basic_melee_attack_subtree/bounty, + /datum/ai_planning_subtree/bounty_arm, + /datum/ai_planning_subtree/bounty_ranged, + /datum/ai_planning_subtree/bounty_melee, /datum/ai_planning_subtree/travel_to_point/and_clear_target/reinforce/bounty, + /datum/ai_planning_subtree/bounty_treat_self, /datum/ai_planning_subtree/bounty_companion_idle, ) @@ -418,53 +452,61 @@ * takes a pilot's mech on with them (H4). */ /datum/ai_controller/basic_controller/bounty/companion/TryPossessPawn(atom/new_pawn) - if(!istype(new_pawn, /mob/living/basic/bounty_companion)) + if(!istype(new_pawn, /mob/living/carbon/human/npc/bounty_companion)) return AI_CONTROLLER_INCOMPATIBLE - var/mob/living/basic/bounty_companion/companion = new_pawn + var/mob/living/carbon/human/npc/bounty_companion/companion = new_pawn RegisterSignal(companion, COMSIG_LIVING_ENTER_STAMCRIT, PROC_REF(on_stamcrit)) + RegisterSignal(companion, COMSIG_HUMAN_NPC_RECOVERED, PROC_REF(on_recovered)) + RegisterSignal(companion, COMSIG_HUMAN_NPC_SURRENDERED, PROC_REF(on_surrendered)) return ..() /datum/ai_controller/basic_controller/bounty/companion/UnpossessPawn(destroy) if(pawn) - UnregisterSignal(pawn, COMSIG_LIVING_ENTER_STAMCRIT) + UnregisterSignal(pawn, list(COMSIG_LIVING_ENTER_STAMCRIT, COMSIG_HUMAN_NPC_RECOVERED, COMSIG_HUMAN_NPC_SURRENDERED)) return ..() /datum/ai_controller/basic_controller/bounty/companion/may_shoot(atom/target) - var/mob/living/basic/bounty_companion/companion = pawn + var/mob/living/carbon/human/npc/bounty_companion/companion = pawn return istype(companion) && companion.ai_can_fight() && ..() /datum/ai_controller/basic_controller/bounty/companion/may_strike(atom/target) - var/mob/living/basic/bounty_companion/companion = pawn + var/mob/living/carbon/human/npc/bounty_companion/companion = pawn return istype(companion) && companion.ai_can_fight() && ..() /datum/ai_controller/basic_controller/bounty/companion/pawn_attacked(mob/living/attacker) - var/mob/living/basic/bounty_companion/companion = pawn + var/mob/living/carbon/human/npc/bounty_companion/companion = pawn if(istype(companion)) companion.ai_attacked_by(attacker) /datum/ai_controller/basic_controller/bounty/companion/pawn_damaged(damage, damagetype) - var/mob/living/basic/bounty_companion/companion = pawn + var/mob/living/carbon/human/npc/bounty_companion/companion = pawn if(istype(companion)) companion.ai_took_damage(damage, damagetype) -/datum/ai_controller/basic_controller/bounty/companion/place_held(facing) - var/mob/living/basic/bounty_companion/companion = pawn - if(istype(companion)) - bounty_ai_place_held(companion, companion.ai_hand, facing) +/datum/ai_controller/basic_controller/bounty/companion/proc/on_stamcrit(mob/living/carbon/human/npc/bounty_companion/source) + SIGNAL_HANDLER + source.ai_stamcritted = TRUE + +/// Back up: from a real stamina crit, they decide whether to give up or run +/datum/ai_controller/basic_controller/bounty/companion/proc/on_recovered(mob/living/carbon/human/npc/bounty_companion/source) + SIGNAL_HANDLER + if(source.ai_stamcritted && source.stat == CONSCIOUS) + INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living/carbon/human/npc/bounty_companion, ai_after_stamcrit)) -/datum/ai_controller/basic_controller/bounty/companion/proc/on_stamcrit(mob/living/basic/bounty_companion/source) +/datum/ai_controller/basic_controller/bounty/companion/proc/on_surrendered(mob/living/carbon/human/npc/bounty_companion/source) SIGNAL_HANDLER - INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living/basic/bounty_companion, ai_give_up)) + INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living/carbon/human/npc/bounty_companion, ai_on_surrendered)) /** - * First in a companion's tree: nothing while given up or down; one that ran off only runs, and - * once clear of whoever it ran from, stays out of it. + * A companion's own subtrees start here, after soft crit, breaking free and giving up: nothing while + * it can't act (in crit, cuffed, stunned, giving up); one that ran off only runs, and once clear of + * whoever it ran from, stays out of it. */ /datum/ai_planning_subtree/bounty_companion_gate /datum/ai_planning_subtree/bounty_companion_gate/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/bounty_companion/companion = controller.pawn - if(!istype(companion) || companion.stat != CONSCIOUS || companion.ai_gave_up) + var/mob/living/carbon/human/npc/bounty_companion/companion = controller.pawn + if(!istype(companion) || companion.stat != CONSCIOUS || companion.npc_surrendering || HAS_TRAIT(companion, TRAIT_RESTRAINED)) return SUBTREE_RETURN_FINISH_PLANNING // Knocked down or stunned: nothing at all until they are up (H2) if(HAS_TRAIT(companion, TRAIT_FLOORED) || HAS_TRAIT(companion, TRAIT_INCAPACITATED)) @@ -497,7 +539,7 @@ /datum/ai_behavior/call_reinforcements/bounty/perform(seconds_per_tick, datum/ai_controller/controller) var/mob/living/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] - var/mob/living/basic/bounty_criminal/leader = bounty_ai_side_of(controller.pawn) + var/mob/living/carbon/human/npc/bounty_criminal/leader = bounty_ai_side_of(controller.pawn) if(leader && isliving(target)) leader.ai_ally_attacked(target) controller.set_blackboard_key(BB_BASIC_MOB_REINFORCEMENTS_COOLDOWN, world.time + BOUNTY_REINFORCE_COOLDOWN) @@ -514,10 +556,10 @@ /datum/ai_planning_subtree/bounty_companion_idle /datum/ai_planning_subtree/bounty_companion_idle/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/bounty_companion/companion = controller.pawn + var/mob/living/carbon/human/npc/bounty_companion/companion = controller.pawn if(!companion.ai_can_fight()) return - var/mob/living/basic/bounty_criminal/leader = companion.ai_leader() + var/mob/living/carbon/human/npc/bounty_criminal/leader = companion.ai_leader() if(companion.ai_in_fight && !controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET) && leader?.ai_mode != BOUNTY_AI_FIGHTING) companion.ai_leave_fight() if(!leader) @@ -541,7 +583,7 @@ behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION /datum/ai_behavior/bounty_companion_hang_out/perform(seconds_per_tick, datum/ai_controller/controller) - var/mob/living/basic/bounty_companion/companion = controller.pawn + var/mob/living/carbon/human/npc/bounty_companion/companion = controller.pawn if(!istype(companion) || !companion.ai_can_fight()) return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED companion.ai_hang_out() diff --git a/voidcrew/modules/bounties/bounty_criminal.dm b/voidcrew/modules/bounties/bounty_criminal.dm index e8f95e0702f..0ed97caf93f 100644 --- a/voidcrew/modules/bounties/bounty_criminal.dm +++ b/voidcrew/modules/bounties/bounty_criminal.dm @@ -5,97 +5,48 @@ * bounty exemption line in voidcrew/_HELPERS/hostile_creatures.dm and the tests in * voidcrew/modules/unit_tests/voidcrew_bounty_criminal.dm. Do not edit this file outside P2. * - * What it owns: the criminal mob's body (health, stamina, status flags and the built-in values of - * /mob/living/basic/bounty_criminal, /meek and /normal), the downed state and its mercy rule and - * recovery, capture_state(), refusing teleports and polymorph, the planet-sweep protection, - * spawn_bounty_criminal(), the leash and who it may attack (spec sections 4 and 12). + * A criminal is a real human (/mob/living/carbon/human/npc, voidcrew/modules/human_npcs/), so its body + * is a player's: tg's soft and hard crit, stamina and stamcrit, stuns, wounds, bleeding, cuffs, grabs, + * fireman carries, fire, cold, suffocation, death and revival (owner decision D5, no stand-ins). What + * this file adds on top is the bounty's own rules: + * - Who it is (record, posting) and its look: its record's face (the human NPC base applies it), in the + * outfit its archetype and tier give it (bounty_outfits.dm). Toughness is the armour it wears and + * npc_damage_taken by tier (body_toughness()), never health. + * - capture_state(), read from tg at the moment it is asked: dead; in crit (soft or hard, even + * cuffed); restrained (tg's TRAIT_RESTRAINED: handcuffs, cable, zipties, a straitjacket); stunned + * (stamcrit, knockdown, stun, paralysis including tg's *surrender, unconscious, asleep); free. The pad + * pays on the state at the press (owner ruling 2026-11-08: no worst-state ratchet). + * - What it says: npc_bark() speaks through bounty_say() and strings/bounty_criminals.json, so the human + * NPC base's reactions (crit, getting up, cuffs, working the cuffs, breaking a grab, giving up) use the + * criminal lines. + * - Its site and leash (AR-D2, H1, M3): the site's rectangle, or the pirate ship it is wanted aboard, + * less every ship, hangar, player outpost and dock strip inside it. Its AI's movement keeps to it + * (/datum/ai_movement/jps/bounty); anyone can drag, carry or shove it anywhere. Off its site, and + * anywhere at a trader outpost, it fights only those on its grudge list and never structures. + * - No teleports (the pad deletes it), and a container it is in can't be teleported either; no fultons, + * no polymorph, no type change (M2). Turrets read its tg state (bounty_turret_ignores()). + * - Its body is the proof (AR-A5): a corpse is turned in for the dead share; a body destroyed with its + * posting open (gibbed, dusted, lost in a chasm or lava) leaves an evidence tag through P5's + * bounty_drop_proof(), unless it was removed on purpose (TRAIT_BOUNTY_REMOVED, or body_mark_removed()). + * A live body deleted never does. It can be revived like anyone; it pays by its condition when it + * reaches the pad. + * Cuffs and the reaction to a reach for its wrists are in bounty_restraints.dm. * - * The body, in short: - * - Health: meek BOUNTY_MEEK_HEALTH; normal by tier times its style; mini-bosses per kit (P4). - * - Stamina: max_stamina is always 100 (tg's basic mobs leave stamina crit by comparing raw points - * with a percentage), so a pool of another size is the stamina damage coefficient, 100 / pool. - * - Downed at BOUNTY_DOWNED_BELOW percent: floored, harmless and draggable. A hit on one still on its - * feet stops just under the line (the mercy rule), so killing it is always a choice; a hit on one - * that is down can kill. It gets up after its recovery time, groaning for the last - * BOUNTY_BODY_STIRRING_TELL, at BOUNTY_RECOVER_TO percent. Cuffed, it stays down; healing does not - * stand it up; a stamina hit starts the clock again (C1). A mini-boss that gets up rallies for - * BOUNTY_BODY_RALLY_TIME: stamina does nothing to it. - * - On its site, damage with nobody's mind behind it (turrets, traps, fire, fauna) stops at - * BOUNTY_AUTOMATED_FLOOR percent. /datum/component/bounty_body keeps the ledger (AR-D3): a hit is a - * player's when someone with a mind made it, fired it (a mech's or vehicle's shot counts its pilot), - * last touched the explosive, or stands near an explosion. - * - Fire and heat burn it like a suited person (L3), within the mercy line and the floor. - * - worst_state only ever gets worse (spec 12.1); P5 pays on it, and carries it to a respawned copy - * with body_restore_worst_state(). - * - On the floor and draggable (down, stunned, cuffed or dead), it can be fireman carried like a - * person. It squirms off the carrier's shoulders once it can't be dragged any more. - * - Dead, the body stays and can't be revived (AR-A5). A dead body destroyed with its posting open - * (gibbed, dusted, lost in a chasm) asks P5's bounty_drop_proof() for proof of death, unless it was - * removed on purpose (P5's TRAIT_BOUNTY_REMOVED, or body_mark_removed()). A live one deleted never - * does. P5 decides where the proof goes. - * - Its site: the site's rectangle (or the pirate ship it is wanted aboard), less every ship, hangar, - * player outpost and planet dock strip inside it (H1). Leashed to it (AR-D2): its own feet never - * take it off, nor onto a trader outpost's lift alcove, lava, a chasm or space. Once off (woken - * aboard a ship, dragged away), it may walk about where it is and back, but never on into another - * ship or hangar or into a player outpost (M3). Anyone can still drag it anywhere, and a scripted - * walk (TRAIT_BOUNTY_SCRIPTED_MOVE, or godmode) goes where it is sent. Off its site, and anywhere at - * a trader outpost, it fights only those on its grudge list and never structures (AR-D1, AR-C8). - * - No teleports (the pad deletes it), and a container it is in can't be teleported either; no - * fultons, no polymorph, no type change, no sentience (M2). Turrets at trader outposts leave it - * alone, and no turret shoots one that is down, stunned or restrained (bounty_turret_ignores()). - * Restraints are in bounty_restraints.dm. - * - * The shared vars are declared in bounty_types.dm and nowhere else; a var only P2 uses goes here - * with a `body_` prefix. + * What differs from a player's body is only the human NPC base's documented list (dormancy off-z, no + * mood or hunger, locked gear). The shared vars are declared in bounty_types.dm and nowhere else; a var + * only P2 uses goes here with a `body_` prefix. */ // ===== BUILT-IN VALUES ===== -/mob/living/basic/bounty_criminal +/mob/living/carbon/human/npc/bounty_criminal name = "criminal" - desc = "Someone with a price on their head." - icon = 'icons/mob/simple/simple_human.dmi' - unique_name = FALSE - maxHealth = BOUNTY_NORMAL_HEALTH_WANTED - health = BOUNTY_NORMAL_HEALTH_WANTED - speed = BOUNTY_BODY_NORMAL_SPEED_MELEE - mob_biotypes = MOB_ORGANIC | MOB_HUMANOID - mob_size = MOB_SIZE_HUMAN - sentience_type = BOUNTY_CRIMINAL_NO_SENTIENCE - density = TRUE - // Too heavy to shove about while free and on its feet; see body_update_drag(). - move_resist = MOVE_FORCE_VERY_STRONG - // No DEL_ON_DEATH: the body is the proof (AR-A5). - basic_mob_flags = NONE - // Batons knock them down, as they do people. - status_flags = CANPUSH | CANSTUN | CANKNOCKDOWN - max_stamina = BOUNTY_CRIMINAL_MAX_STAMINA - stamina_crit_threshold = BOUNTY_CRIMINAL_STAMCRIT_AT - stamina_regen_time = BOUNTY_NORMAL_STAMCRIT_TIME - // Downed, stunned or dead, they lie on the floor like a person. - mobility_flags = MOBILITY_FLAGS_REST_CAPABLE_DEFAULT - rotate_on_lying = TRUE - blood_volume = BLOOD_VOLUME_NORMAL - // Dressed for out there: vacuum and cold don't hurt them (D-A9). Weapons, lava, chasms and fire do; - // fire and heat through Life(), not tg's element, so the mercy line holds. - unsuitable_atmos_damage = 0 - unsuitable_cold_damage = 0 - unsuitable_heat_damage = 0 - // tg's human deathgasp - death_message = "seizes up and falls limp, their eyes dead and lifeless..." - response_help_continuous = "taps" - response_help_simple = "tap" - /// Runs while it is down: the stirring tell, then getting up - var/body_recovery_timer - /// Down, and groaning as it tries to get up - var/body_stirring = FALSE - /// Its recovery came due while it was cuffed: it gets up once the cuffs are off - var/body_recovery_due = FALSE - /// world.time until which a mini-boss that just got up shrugs off stamina, and the timer that ends it - var/body_rally_until = 0 - var/body_rally_timer - /// world.time a projectile last got through to it, for the meek's dodge - var/body_last_shot_at = -1 + faction = list(FACTION_HOSTILE) + // Criminals stop once their target is down (spec C4, defaults 1.13). Their area effects still hit whoever stands there. + npc_target_stat = HUMAN_NPC_SPARES_DOWNED + // The body is the proof: its posting decides when it goes (bounty_posting.dm), never the corpse sweep. + npc_corpse_lifetime = 0 + npc_outfit_table = /datum/human_npc_outfit_table/bounty /// Removed on purpose (beamed out by the pad, cleaned up by its posting, its site unloading): being deleted is not a death, so it leaves no proof var/body_removed = FALSE /// Its proof of death is down already @@ -104,59 +55,39 @@ var/datum/weakref/body_site_ref /// The top row of its planet's dock strip, or null var/body_dock_top_y - /// Someone is putting restraints on it or taking them off (bounty_restraints.dm) - var/body_cuff_work = FALSE - /// The timers for its restraints slipping: the visible struggle, then the slip (bounty_restraints.dm) - var/body_slip_warn_timer - var/body_slip_timer /// Weakref to the container holding it (a locker, a crate, a body bag), kept from being teleported while it is inside var/datum/weakref/body_holder_ref /// The last balloon floated over it for hunters (body_alert_hunters()): "worn out" var/body_last_alert + /// Its toughness comes from its record's tier (body_toughness()). A subtype with a fixed toughness of its own (a mini-boss, the kingpin) turns this off. + var/body_tier_toughness = TRUE -/mob/living/basic/bounty_criminal/meek - maxHealth = BOUNTY_MEEK_HEALTH - health = BOUNTY_MEEK_HEALTH - speed = BOUNTY_BODY_MEEK_SPEED - max_stamina_slowdown = BOUNTY_MEEK_STAMINA_SLOWDOWN - stamina_regen_time = BOUNTY_MEEK_STAMCRIT_TIME - -/mob/living/basic/bounty_criminal/Initialize(mapload) +/mob/living/carbon/human/npc/bounty_criminal/Initialize(mapload, datum/human_npc_order/order) + // Who it is must be known before the base dresses it: the outfit table reads the record (bounty_outfits.dm). + if(istype(order?.look, /datum/bounty_record)) + record = order.look . = ..() - // Its own copy: the stamina pool here, and a mini-boss's armour (P4), change it per mob. - damage_coeff = damage_coeff.Copy() - body_update_stamina_coeff() - // TRAIT_CAN_MOUNT_HUMANS: someone can carry it over their shoulders (body_can_be_carried()) - add_traits(list(TRAIT_NO_TELEPORT, TRAIT_NOMOBSWAP, TRAIT_CAN_MOUNT_HUMANS), BOUNTY_BODY_TRAIT) + add_traits(list(TRAIT_NO_TELEPORT, TRAIT_NOMOBSWAP), BOUNTY_BODY_TRAIT) AddComponent(/datum/component/bounty_body) - AddElement(/datum/element/footstep, footstep_type = FOOTSTEP_MOB_SHOE) + body_hook_cuffs() + body_toughness() -/mob/living/basic/bounty_criminal/Destroy() +/mob/living/carbon/human/npc/bounty_criminal/Destroy() if(body_leaves_proof()) body_drop_proof() - deltimer(body_recovery_timer) - body_recovery_timer = null - body_remove_cuffs() body_set_holder(null) grudge?.Cut() body_site_ref = null return ..() -// Fire and heat burn it like a suited person (L3). Not forced, so the mercy line and the automated floor hold. Mini-bosses keep P4's own fire rules. -/mob/living/basic/bounty_criminal/Life(seconds_per_tick = SSMOBS_DT, times_fired) - . = ..() - if(stat == DEAD || istype(src, /mob/living/basic/bounty_criminal/boss)) - return - if(on_fire || bodytemperature > BOUNTY_CRIMINAL_MAX_TEMP) - adjustFireLoss(BOUNTY_CRIMINAL_BURN_DAMAGE * seconds_per_tick) - // ===== SPAWNING ===== /** * Spawns the criminal for `record` at `where`, wanted on `posting` (or on nothing, for an admin - * spawn): the subtype for its archetype and kit, with the body for its tier and style, leashed to the - * posting's site, protected from the planet sweep and dressed in its look. Returns the mob. Decoys - * are made by P6 directly. + * spawn): a real human of the subtype for its archetype and kit, built now (one body, so it doesn't + * wait in the human NPC queue), in its record's face and name, dressed for its archetype, tier and + * site, leashed to the posting's site and protected from the planet sweep. Returns the mob. Decoys are + * made by P6 directly. */ /proc/spawn_bounty_criminal(datum/bounty_record/record, turf/where, datum/criminal_bounty/posting) where = get_turf(where) @@ -165,9 +96,12 @@ var/criminal_type = bounty_criminal_type(record, posting) var/atom/site = posting?.site_ref?.resolve() var/datum/npc_spawn_context/context = new(site || where, null, "ordinary", source_turf = site ? get_turf(site) : where) - var/mob/living/basic/bounty_criminal/criminal = spawn_npc_in_zone(criminal_type, where, context, FALSE) + var/datum/human_npc_order/order = spawn_human_npc(criminal_type, where, look = record, name = record?.name, context = context, immediate = TRUE) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = order?.spawned_ref?.resolve() + qdel(order) + if(QDELETED(criminal)) + return null criminal.body_setup(record, posting) - context.finalize() return criminal /// The criminal type for `record` wanted on `posting`: meek, normal, or the mini-boss of its kit. A mini-boss never goes to a trader outpost; a normal criminal stands in (D-A8). @@ -177,138 +111,81 @@ archetype = BOUNTY_ARCHETYPE_NORMAL switch(archetype) if(BOUNTY_ARCHETYPE_MEEK) - return /mob/living/basic/bounty_criminal/meek + return /mob/living/carbon/human/npc/bounty_criminal/meek if(BOUNTY_ARCHETYPE_BOSS) switch(record.kit) if(BOUNTY_KIT_JUGGERNAUT) - return /mob/living/basic/bounty_criminal/boss/juggernaut + return /mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut if(BOUNTY_KIT_PYROMANIAC) - return /mob/living/basic/bounty_criminal/boss/pyromaniac + return /mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac if(BOUNTY_KIT_DEMOLITIONIST) - return /mob/living/basic/bounty_criminal/boss/demolitionist + return /mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist if(BOUNTY_KIT_GHOST) - return /mob/living/basic/bounty_criminal/boss/ghost + return /mob/living/carbon/human/npc/bounty_criminal/boss/ghost if(BOUNTY_KIT_HEAVY) - return /mob/living/basic/bounty_criminal/boss/heavy + return /mob/living/carbon/human/npc/bounty_criminal/boss/heavy return pick( - /mob/living/basic/bounty_criminal/boss/juggernaut, - /mob/living/basic/bounty_criminal/boss/pyromaniac, - /mob/living/basic/bounty_criminal/boss/demolitionist, - /mob/living/basic/bounty_criminal/boss/ghost, - /mob/living/basic/bounty_criminal/boss/heavy, + /mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, + /mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac, + /mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist, + /mob/living/carbon/human/npc/bounty_criminal/boss/ghost, + /mob/living/carbon/human/npc/bounty_criminal/boss/heavy, ) - return /mob/living/basic/bounty_criminal/normal + return /mob/living/carbon/human/npc/bounty_criminal/normal /** - * Makes it the person in `new_record`, wanted on `new_posting` (either may be null): name, the body - * for its tier and style, the leash to the posting's site, the planet-sweep protection, and its look, - * put on in the background. spawn_bounty_criminal() calls it once, right after making the mob. + * Makes it the person in `new_record`, wanted on `new_posting` (either may be null): name, toughness + * for its tier, the leash to the posting's site and the planet-sweep protection. spawn_bounty_criminal() + * calls it once, right after making the mob; its face and clothes are already on (the human NPC base + * dresses it from the record as it is made). */ -/mob/living/basic/bounty_criminal/proc/body_setup(datum/bounty_record/new_record, datum/criminal_bounty/new_posting) +/mob/living/carbon/human/npc/bounty_criminal/proc/body_setup(datum/bounty_record/new_record, datum/criminal_bounty/new_posting) record = new_record posting_ref = new_posting ? WEAKREF(new_posting) : null - if(record?.name) - name = record.name - real_name = record.name - if(record?.gender == MALE || record?.gender == FEMALE) - gender = record.gender - var/tier_health = body_tier_health() - if(tier_health) - maxHealth = tier_health - updatehealth() - if(istype(src, /mob/living/basic/bounty_criminal/normal)) - var/ranged = record?.style == BOUNTY_STYLE_PISTOL || record?.style == BOUNTY_STYLE_BOTTLE - set_varspeed(ranged ? BOUNTY_BODY_NORMAL_SPEED_RANGED : BOUNTY_BODY_NORMAL_SPEED_MELEE) - body_update_stamina_coeff() + if(record?.name && real_name != record.name) + fully_replace_character_name(real_name, record.name) + body_toughness() body_set_site(new_posting?.site_ref?.resolve()) if(new_posting) // The planet's fauna sweep leaves it be while it is wanted (missions/objectives/combat.dm). P5 takes it off when the posting ends. ADD_TRAIT(src, TRAIT_MISSION_FIELD_MOB, BOUNTY_TRAIT) - INVOKE_ASYNC(src, PROC_REF(body_dress)) -/// A normal criminal's health: its tier's, times its style's. Null for anyone else, who keeps their built-in health. -/mob/living/basic/bounty_criminal/proc/body_tier_health() - if(!istype(src, /mob/living/basic/bounty_criminal/normal)) - return null - var/base = BOUNTY_NORMAL_HEALTH_WANTED +/** + * How much brute and burn it takes, as a multiple of a person's, through its physiology (the human + * NPC base's npc_damage_taken): by its record's tier, meek criminals at a person's. A subtype with a + * fixed value of its own sets body_tier_toughness = FALSE. Its armour does the rest. + */ +/mob/living/carbon/human/npc/bounty_criminal/proc/body_toughness() + if(!body_tier_toughness) + return + var/wanted = BOUNTY_TOUGHNESS_PETTY switch(record?.tier) - if(BOUNTY_TIER_PETTY) - base = BOUNTY_NORMAL_HEALTH_PETTY + if(BOUNTY_TIER_WANTED) + wanted = BOUNTY_TOUGHNESS_WANTED if(BOUNTY_TIER_MOST_WANTED) - base = BOUNTY_NORMAL_HEALTH_MOST - return round(base * bounty_style_health_mult(record?.style), 1) - -/// How much tougher or frailer than its tier a fighting style makes a normal criminal -/proc/bounty_style_health_mult(style) - switch(style) - if(BOUNTY_STYLE_BRAWLER) - return BOUNTY_STYLE_HEALTH_BRAWLER - if(BOUNTY_STYLE_KNIFE) - return BOUNTY_STYLE_HEALTH_KNIFE - if(BOUNTY_STYLE_PISTOL) - return BOUNTY_STYLE_HEALTH_PISTOL - if(BOUNTY_STYLE_SHOTGUN) - return BOUNTY_STYLE_HEALTH_SHOTGUN - if(BOUNTY_STYLE_CLUB) - return BOUNTY_STYLE_HEALTH_CLUB - if(BOUNTY_STYLE_BOTTLE) - return BOUNTY_STYLE_HEALTH_BOTTLE - return 1 - -/// How much stamina damage stamina-crits it: a meek criminal's pool, or anyone else's health -/mob/living/basic/bounty_criminal/proc/body_stamina_pool() - if(istype(src, /mob/living/basic/bounty_criminal/meek)) - return BOUNTY_MEEK_STAMINA - return maxHealth - -/// Sets its stamina damage coefficient from its pool (max_stamina / pool), times its style's. A mini-boss's is P4's. -/mob/living/basic/bounty_criminal/proc/body_update_stamina_coeff() - if(istype(src, /mob/living/basic/bounty_criminal/boss)) - return - var/pool = body_stamina_pool() - if(pool <= 0) - return - var/style_mult = record?.style == BOUNTY_STYLE_BRAWLER ? BOUNTY_STYLE_STAMINA_BRAWLER : 1 - damage_coeff[STAMINA] = style_mult * max_stamina / pool + wanted = BOUNTY_TOUGHNESS_MOST_WANTED + if(istype(src, /mob/living/carbon/human/npc/bounty_criminal/meek)) + wanted = BOUNTY_TOUGHNESS_PETTY + if(wanted != npc_damage_taken) + set_npc_toughness(wanted) /** - * Gives it the same body as `other`: health, pace and stamina. For a trader-outpost decoy (P6), which - * must be as tough and as quick as the fugitive it stands in for (AR-C6). + * Gives it the same toughness and pace as `other`: a trader-outpost decoy (P6) must be as hard to put + * down and as quick as the fugitive it stands in for (AR-C6). Its armour comes from its own clothes. + * The fugitive's chrome is part of its pace (a meek criminal's Slipwire), so the same pieces go into + * this body too, real chrome that an EMP stops and that burns out when it dies. */ -/mob/living/basic/bounty_criminal/proc/body_match(mob/living/basic/bounty_criminal/other) +/mob/living/carbon/human/npc/bounty_criminal/proc/body_match(mob/living/carbon/human/npc/bounty_criminal/other) if(QDELETED(other) || other == src) return - // Copy raw stats before finalizing the inherited profile, never its scaled pool. - var/datum/npc_spawn_context/context = npc_spawn_context - if(!context || context.source_id != other.npc_spawn_context?.source_id) - context = other.bounty_profile_context() - if(npc_zone_applied) - UnregisterSignal(src, COMSIG_PROJECTILE_FIRER_BEFORE_FIRE) - melee_damage_lower = npc_zone_original_melee_lower - melee_damage_upper = npc_zone_original_melee_upper - npc_zone_applied = FALSE - npc_zone_health_factor = 1 - npc_zone_damage_factor = 1 - npc_spawn_context = context - maxHealth = other.npc_zone_applied ? other.npc_zone_original_max_health : other.maxHealth - var/health_share = other.maxHealth > 0 ? other.health / other.maxHealth : 1 - setBruteLoss(maxHealth * (1 - health_share)) - updatehealth() - context.bodies |= WEAKREF(src) - context.finalize() - set_varspeed(other.speed) - damage_coeff[STAMINA] = other.damage_coeff[STAMINA] - stamina_regen_time = other.stamina_regen_time - if(max_stamina_slowdown != other.max_stamina_slowdown) - // The same arguments make_stamina_slowable() added it with, or the element is not found. - RemoveElement(/datum/element/basic_stamina_slowdown, minium_stamina_threshold = max_stamina / 3, maximum_stamina = max_stamina, maximum_slowdown = max_stamina_slowdown) - max_stamina_slowdown = other.max_stamina_slowdown - make_stamina_slowable() - -/// Decoys use the source's selected role before construction, including named boss bodies. -/mob/living/basic/bounty_criminal/proc/bounty_profile_context() - var/role = npc_zone_role || (npc_zone_boss_type(type) ? "boss" : npc_spawn_context?.role || "ordinary") - return new /datum/npc_spawn_context(src, null, role) + if(npc_damage_taken != other.npc_damage_taken) + set_npc_toughness(other.npc_damage_taken) + if(move_intent != other.move_intent) + toggle_move_intent() + for(var/obj/item/organ/ware as anything in other.organs) + if(!ware.GetComponent(/datum/component/cyberware) || (locate(ware.type) in organs)) + continue + npc_install_cyberware(ware.type) // ===== THE SITE ===== @@ -317,7 +194,7 @@ * site's rectangle, or for a pirate ship the hull itself. A site with no rectangle to read gets a box * around where it stands. With no site at all (an admin spawn) it has no leash. */ -/mob/living/basic/bounty_criminal/proc/body_set_site(atom/site) +/mob/living/carbon/human/npc/bounty_criminal/proc/body_set_site(atom/site) body_site_ref = site ? WEAKREF(site) : null site_bounds = bounty_site_bounds(site) body_dock_top_y = bounty_site_dock_top(site) @@ -356,17 +233,17 @@ return planet.get_dock_strip_top_y(level) /// The overmap object of its site: the one it was spawned for, else its posting's -/mob/living/basic/bounty_criminal/proc/body_site() +/mob/living/carbon/human/npc/bounty_criminal/proc/body_site() var/obj/structure/overmap/site = body_site_ref?.resolve() || posting()?.site_ref?.resolve() return (istype(site) && !QDELETED(site)) ? site : null /// The pirate ship that is its site, if it is wanted aboard one -/mob/living/basic/bounty_criminal/proc/body_site_ship() +/mob/living/carbon/human/npc/bounty_criminal/proc/body_site_ship() var/obj/structure/overmap/ship/site_ship = body_site() return istype(site_ship) ? site_ship : null /// Whether it has a site to be leashed to -/mob/living/basic/bounty_criminal/proc/body_has_site() +/mob/living/carbon/human/npc/bounty_criminal/proc/body_has_site() return !!site_bounds || !!body_site_ship() /** @@ -374,7 +251,7 @@ * on), and not part of a ship, a hangar, a player outpost or a planet's dock strip that happens to lie * inside that rectangle (H1). With no site, anywhere but those is. */ -/mob/living/basic/bounty_criminal/proc/body_on_site(turf/place) +/mob/living/carbon/human/npc/bounty_criminal/proc/body_on_site(turf/place) place = get_turf(place) if(!place || body_forbidden_turf(place)) return FALSE @@ -386,14 +263,14 @@ return TRUE /// Whether `place` is never its ground: a ship (other than the pirate ship it is wanted aboard), a hangar, a player outpost, or its planet's dock strip -/mob/living/basic/bounty_criminal/proc/body_forbidden_turf(turf/place) +/mob/living/carbon/human/npc/bounty_criminal/proc/body_forbidden_turf(turf/place) return !!body_hold(place) || body_on_dock_strip(place) /** * The ship, hangar or player outpost `place` is part of, or null: the pirate ship it is wanted aboard * is its site, not a hold. A ship is known by its docking port, so every room aboard is one hold. */ -/mob/living/basic/bounty_criminal/proc/body_hold(turf/place) +/mob/living/carbon/human/npc/bounty_criminal/proc/body_hold(turf/place) var/area/place_area = get_area(place) if(istype(place_area, /area/shuttle)) var/obj/structure/overmap/ship/site_ship = body_site_ship() @@ -406,22 +283,22 @@ return null /// Whether `place` is on its planet's dock strip, where ships land (L1) -/mob/living/basic/bounty_criminal/proc/body_on_dock_strip(turf/place) +/mob/living/carbon/human/npc/bounty_criminal/proc/body_on_dock_strip(turf/place) if(isnull(body_dock_top_y) || !place) return FALSE return (!site_bounds || place.z == site_bounds[5]) && place.y <= body_dock_top_y /// Whether it is at a trader outpost, wanted there or standing in one: there it fights only its grudge list (AR-C8) -/mob/living/basic/bounty_criminal/proc/body_at_trader_outpost() +/mob/living/carbon/human/npc/bounty_criminal/proc/body_at_trader_outpost() return posting()?.placement_kind == BOUNTY_PLACEMENT_TRADER_OUTPOST || istype(get_area(src), /area/voidcrew/trader_outpost) /** * Whether it may go onto `destination` by itself (AR-D2, AR-E1, L1): on its site (so never a ship, a * hangar, a player outpost or a dock strip), never a lift alcove that would carry it off, and never - * lava, a chasm or open space. P3 checks hiding spots and flight paths with it; its own steps are held - * to it too (Move()). + * lava, a chasm or open space. P3 checks hiding spots and flight paths with it, and its AI's movement + * holds its own steps to it (body_move_allowed()). */ -/mob/living/basic/bounty_criminal/proc/leash_ok(turf/destination) +/mob/living/carbon/human/npc/bounty_criminal/proc/leash_ok(turf/destination) destination = get_turf(destination) if(!destination || !body_on_site(destination)) return FALSE @@ -430,23 +307,19 @@ return FALSE return destination.can_cross_safely(src) -// Its own steps stay on the leash (M3). Dragged, carried along, thrown or walked by a script, it goes where it is taken. -/mob/living/basic/bounty_criminal/Move(atom/newloc, direct, glide_size_override) - if(!body_move_allowed(newloc)) - return FALSE - return ..() - -/// Whether a script is walking it on purpose: TRAIT_BOUNTY_SCRIPTED_MOVE, or godmode (P6's walk out to the lift) -/mob/living/basic/bounty_criminal/proc/body_scripted() - return HAS_TRAIT(src, TRAIT_BOUNTY_SCRIPTED_MOVE) || HAS_TRAIT(src, TRAIT_GODMODE) +/// Whether a script is walking it on purpose (TRAIT_BOUNTY_SCRIPTED_MOVE), or it is walking out (the human NPC base's npc_walk_out()) +/mob/living/carbon/human/npc/bounty_criminal/proc/body_scripted() + return HAS_TRAIT(src, TRAIT_BOUNTY_SCRIPTED_MOVE) || !isnull(npc_exit) /** - * Whether a step of its own onto `newloc` is allowed. Onto its leash, always. Off it from on it, - * never. Already off it (woken aboard a ship, dragged off its site, carried somewhere), it may walk - * about and back toward its site, but never into a hazard and never on into a ship, hangar or player - * outpost other than the one it is already in (M3). + * Whether a step of its own onto `newloc` is allowed: the leash its AI's movement keeps to + * (/datum/ai_movement/jps/bounty, and any step the AI takes by hand). Onto its leash, always. Off it + * from on it, never. Already off it (woken aboard a ship, dragged off its site, carried somewhere), it + * may walk about and back toward its site, but never into a hazard and never on into a ship, hangar or + * player outpost other than the one it is already in (M3). Its body is never held back: anyone can drag, + * carry, throw or shove it anywhere. */ -/mob/living/basic/bounty_criminal/proc/body_move_allowed(atom/newloc) +/mob/living/carbon/human/npc/bounty_criminal/proc/body_move_allowed(atom/newloc) if(!isturf(newloc) || !isturf(loc) || pulledby || buckled || throwing || stat == DEAD || body_scripted()) return TRUE var/turf/destination = newloc @@ -463,7 +336,7 @@ * BOUNTY_ENV_SAFE_RANGE tiles of a ship (other than the pirate ship it is aboard), a hangar, a player * outpost or a planet's dock strip. */ -/mob/living/basic/bounty_criminal/proc/environment_damage_allowed(turf/target_turf) +/mob/living/carbon/human/npc/bounty_criminal/proc/environment_damage_allowed(turf/target_turf) target_turf = get_turf(target_turf) if(!target_turf || !body_on_site(target_turf) || body_at_trader_outpost()) return FALSE @@ -482,15 +355,16 @@ // ===== WHO IT FIGHTS ===== /** - * Whether it may attack `target` (AR-D1, AR-C8, C4). Never while down, restrained or surrendered, - * never someone who is down, and never its own side. Off its site, and anywhere at a trader outpost, - * only those on its grudge list, and no structures. On its site it may break structures that are on - * its site and not part of a ship, a hangar or an outpost. Its melee and ranged attacks are held to it. + * Whether it may attack `target` (AR-D1, AR-C8, C4). Never while it can't fight (dead, in crit, + * restrained, lying there with its hands on its head after giving up), and never someone who is down, + * or its own side. Off its site, and anywhere at a trader outpost, only those on its grudge list, and no + * structures. On its site it may break structures that are on its site and not part of a ship, a hangar + * or an outpost. Its AI's targeting is held to it. */ -/mob/living/basic/bounty_criminal/proc/may_attack(atom/target) +/mob/living/carbon/human/npc/bounty_criminal/proc/may_attack(atom/target) if(QDELETED(target) || target == src) return FALSE - if(stat != CONSCIOUS || downed || is_restrained() || HAS_TRAIT(src, TRAIT_BOUNTY_SURRENDERED)) + if(stat != CONSCIOUS || is_downed() || is_restrained() || npc_surrendering) return FALSE return may_attack_scope(target) @@ -500,7 +374,7 @@ * grudge list off its site and at a trader outpost, structures only on its own ground. Its * companions go by this alone, so they fight on when it is down, cuffed, dead or has given up. */ -/mob/living/basic/bounty_criminal/proc/may_attack_scope(atom/target) +/mob/living/carbon/human/npc/bounty_criminal/proc/may_attack_scope(atom/target) if(QDELETED(target) || target == src) return FALSE // A ship, hangar, outpost or dock strip inside the site's rectangle is not its site (H1) @@ -520,15 +394,19 @@ var/turf/target_turf = get_turf(target) return body_on_site(target_turf) && !body_forbidden_turf(target_turf) for(var/mob/living/person as anything in people) - if(person.stat != CONSCIOUS || istype(person, /mob/living/basic/bounty_criminal) || istype(person, /mob/living/basic/bounty_companion)) + if(person.stat != CONSCIOUS || bounty_is_gang_body(person)) continue if(!limited || body_has_grudge(person)) return TRUE return FALSE +/// Whether `thing` is a bounty criminal or a companion: never on anyone's grudge list, never counted as a player +/proc/bounty_is_gang_body(atom/thing) + return istype(thing, /mob/living/carbon/human/npc/bounty_criminal) || istype(thing, /mob/living/carbon/human/npc/bounty_companion) + /// Remembers `who` as someone it may fight anywhere: they attacked it, confronted it or cuffed it. P3 calls it when someone confronts it. -/mob/living/basic/bounty_criminal/proc/body_add_grudge(mob/living/who) - if(!isliving(who) || who == src || istype(who, /mob/living/basic/bounty_criminal) || istype(who, /mob/living/basic/bounty_companion)) +/mob/living/carbon/human/npc/bounty_criminal/proc/body_add_grudge(mob/living/who) + if(!isliving(who) || who == src || bounty_is_gang_body(who)) return var/datum/weakref/who_ref = WEAKREF(who) if(who_ref in grudge) @@ -538,26 +416,25 @@ grudge.Cut(1, 2) /// Whether `who` is on its grudge list -/mob/living/basic/bounty_criminal/proc/body_has_grudge(mob/living/who) +/mob/living/carbon/human/npc/bounty_criminal/proc/body_has_grudge(mob/living/who) return !isnull(who?.weak_reference) && (who.weak_reference in grudge) -// Its own fists follow may_attack(). -/mob/living/basic/bounty_criminal/early_melee_attack(atom/target, list/modifiers, ignore_cooldown = FALSE) - if(!may_attack(target)) - return FALSE - return ..() +// Bounty NPCs never land a gun execution this phase: a boss's deliberate, telegraphed execution (OC-9) +// isn't built yet, and an accidental point-blank head shot must not stand in for it. Aimed crits still +// follow npc_rank (D4). +/mob/living/carbon/human/npc/bounty_criminal/hv_can_execute() + return !!client // ===== CAPTURE STATE ===== /** - * What the pad pays on (BOUNTY_STATE_*), checked in order (AR-A3): dead; downed (even if cuffed or - * healed); restrained with its own restraints; stunned (stamina crit, knocked down, stunned, - * paralysed, unconscious, or surrendered); free. + * What the pad pays on (BOUNTY_STATE_*), read from tg in this order (AR-A3): dead; in crit, soft or hard, + * even if cuffed; restrained; stunned; free. The pad reads it once, at the press. */ -/mob/living/basic/bounty_criminal/proc/capture_state() +/mob/living/carbon/human/npc/bounty_criminal/proc/capture_state() if(stat == DEAD) return BOUNTY_STATE_DEAD - if(downed) + if(is_downed()) return BOUNTY_STATE_DOWNED if(is_restrained()) return BOUNTY_STATE_RESTRAINED @@ -565,17 +442,20 @@ return BOUNTY_STATE_STUNNED return BOUNTY_STATE_FREE -/// Whether it is down and alive: floored and harmless until it recovers -/mob/living/basic/bounty_criminal/proc/is_downed() - return downed && stat != DEAD +/// Whether it is alive and in crit (tg's TRAIT_CRITICAL_CONDITION: soft or hard crit) +/mob/living/carbon/human/npc/bounty_criminal/proc/is_downed() + return stat != DEAD && HAS_TRAIT(src, TRAIT_CRITICAL_CONDITION) -/// Whether its own restraints are on it -/mob/living/basic/bounty_criminal/proc/is_restrained() - return !QDELETED(restraints) && restraints.loc == src +/// Whether it is restrained: tg's handcuffs, cable or zipties, or a straitjacket +/mob/living/carbon/human/npc/bounty_criminal/proc/is_restrained() + return HAS_TRAIT(src, TRAIT_RESTRAINED) -/// Whether it is stunned: stamina crit, knocked down, stunned, paralysed, out cold, or surrendered (TRAIT_BOUNTY_SURRENDERED) -/mob/living/basic/bounty_criminal/proc/body_is_stunned() - if(HAS_TRAIT(src, TRAIT_BOUNTY_SURRENDERED) || has_status_effect(/datum/status_effect/incapacitating/stamcrit)) +/** + * Whether it is stunned: stamina crit, knocked down, stunned, paralysed (tg's *surrender is a 20 second + * paralysis), unconscious or asleep (a sedative dart counts). + */ +/mob/living/carbon/human/npc/bounty_criminal/proc/body_is_stunned() + if(stat == UNCONSCIOUS || has_status_effect(/datum/status_effect/incapacitating/stamcrit)) return TRUE return IsKnockdown() || IsStun() || IsParalyzed() || IsUnconscious() || IsSleeping() @@ -590,192 +470,49 @@ return 3 return 4 -/// Records its capture state in worst_state if it is as bad or worse: once downed or dead, it never gets better (spec 12.1) -/mob/living/basic/bounty_criminal/proc/body_note_state() - var/state = capture_state() - if(state != BOUNTY_STATE_FREE) - posting()?.board_note_work_zone(src) - if(bounty_state_rank(state) <= bounty_state_rank(worst_state)) - worst_state = state - /** - * Carries a worst state over from an earlier copy of this criminal (M4): P5 respawns the same record - * when its site loads again, and pay must not forget that it was downed or killed before. Only ever - * makes worst_state worse. Returns the worst state now. + * Something about its state may have changed (stat, crit, cuffs, a stun): the first catch or death + * binds the zone the bounty's reputation counts in. Nothing else is remembered; the pad reads the + * body when it is pressed. */ -/mob/living/basic/bounty_criminal/proc/body_restore_worst_state(state) - if(state && bounty_state_rank(state) < bounty_state_rank(worst_state)) - worst_state = state - return worst_state - -/// Something about its state changed: worst_state, and whether it can be dragged or carried -/mob/living/basic/bounty_criminal/proc/body_state_changed() - body_note_state() - body_update_drag() - body_update_carry() - -/mob/living/basic/bounty_criminal/set_stat(new_stat) - . = ..() - body_state_changed() - -/mob/living/basic/bounty_criminal/on_floored_trait_gain(datum/source) - . = ..() - body_state_changed() - -/mob/living/basic/bounty_criminal/on_floored_trait_loss(datum/source) - . = ..() - body_state_changed() - -/mob/living/basic/bounty_criminal/on_incapacitated_trait_gain(datum/source) - . = ..() - body_state_changed() - -/mob/living/basic/bounty_criminal/on_incapacitated_trait_loss(datum/source) - . = ..() - body_state_changed() - -// ===== DRAGGING ===== +/mob/living/carbon/human/npc/bounty_criminal/proc/body_state_changed() + if(capture_state() != BOUNTY_STATE_FREE) + posting()?.board_note_work_zone(src) -/** - * Whether it can be dragged: dead, downed, restrained or stunned. Blending in at a trader outpost it - * shakes off any hand until it is down or cuffed (AR-C7), the same for the fugitive and its decoys. - * Free and on its feet it pulls away. - */ -/mob/living/basic/bounty_criminal/proc/body_can_be_dragged() - if(stat == DEAD || downed || is_restrained()) - return TRUE - if(blended) - return FALSE - return body_is_stunned() +// ===== WHAT IT SAYS ===== -/// Too heavy to shove while free; ordinary once it can be dragged. Anyone dragging it loses their grip when it can't be. -/mob/living/basic/bounty_criminal/proc/body_update_drag() - var/draggable = body_can_be_dragged() - move_resist = draggable ? MOVE_RESIST_DEFAULT : MOVE_FORCE_VERY_STRONG - if(draggable || !pulledby) - return - visible_message(span_warning("[src] pulls free of [pulledby].")) - pulledby.stop_pulling() - -/mob/living/basic/bounty_criminal/can_be_pulled(user, force) - if(!body_can_be_dragged()) - // P3 REVIEW ROUND (L1): the pull attempt is still announced before it is refused, so P3 hears - // it (pulling at a hider finds it) and P6's blend hooks see it. A hider shows no balloon: it - // is being found instead. - SEND_SIGNAL(src, COMSIG_ATOM_CAN_BE_PULLED, user) - if(ismob(user) && !hidden) - balloon_alert(user, "[p_they()] pull[p_s()] away!") +// The human NPC base's reactions (human_npc_barks.dm) speak the criminal's own lines (strings/bounty_criminals.json). +/mob/living/carbon/human/npc/bounty_criminal/npc_bark(kind, force = FALSE) + if(QDELETED(src) || !istext(kind)) return FALSE - body_update_drag() - return ..() - -// ===== CARRYING ===== - -/// Whether someone can lift it over their shoulders (a fireman carry): on the floor, and in a state to be dragged -/mob/living/basic/bounty_criminal/proc/body_can_be_carried() - return body_position == LYING_DOWN && body_can_be_dragged() - -/// Carried, and no longer in a state to be dragged (it came round, or got up): it gets off whoever is carrying it -/mob/living/basic/bounty_criminal/proc/body_update_carry() - if(!ishuman(buckled) || body_can_be_dragged()) - return - var/mob/living/carrier = buckled - carrier.unbuckle_mob(src, force = TRUE) - visible_message(span_warning("[src] squirms off [carrier]'s shoulders.")) - -/** - * Turns `body` flat when it lies down out of a chair or off someone's shoulders (set_lying_down()). - * tg turns only carbons there (/mob/living/carbon/on_lying_down()); any other mob gets its angle from - * on_floored_start(), which is skipped while a chair holds it up. Without this, a criminal or a goon - * unbuckled while down or dead lies down but still looks like it is standing. - */ -/proc/bounty_body_lie_flat(mob/living/body, new_lying_angle) - if(!body.rotate_on_lying || body.body_position != LYING_DOWN || body.lying_angle) - return - if(body.buckled && body.buckled.buckle_lying == 0) - return - body.set_lying_angle(new_lying_angle || pick(LYING_ANGLE_EAST, LYING_ANGLE_WEST)) + // Crawling in soft crit it pleads with its downed lines. + if(kind == HUMAN_NPC_BARK_PLEAD) + kind = HUMAN_NPC_BARK_DOWNED + // The capture's moments are always heard, past the line cooldown (BUG-1): the cuffs go on moments after a fall. + if(kind == HUMAN_NPC_BARK_CUFFED) + force = TRUE + npc_last_bark = kind + INVOKE_ASYNC(src, TYPE_PROC_REF(/mob/living, bounty_say), kind, null, force) + return TRUE -/mob/living/basic/bounty_criminal/set_lying_down(new_lying_angle) +/mob/living/carbon/human/npc/bounty_criminal/npc_on_downed() + visible_message(span_danger("[src] collapses.")) . = ..() - bounty_body_lie_flat(src, new_lying_angle) - -// A criminal lying on the floor can be carried like a person, as long as it can be dragged -/mob/living/carbon/human/can_be_firemanned(mob/living/carbon/target) - if(istype(target, /mob/living/basic/bounty_criminal)) - var/mob/living/basic/bounty_criminal/criminal = target - return criminal.body_can_be_carried() - return ..() - -// ===== DOWNED, MERCY AND RECOVERY ===== - -/// Its health at the downed line -/mob/living/basic/bounty_criminal/proc/body_downed_line() - return maxHealth * BOUNTY_DOWNED_BELOW / 100 - -// Every kind of damage a basic mob takes comes through here: the mercy rule and the automated floor hold it back. -/mob/living/basic/bounty_criminal/adjust_health(amount, updating_health = TRUE, forced = FALSE) - if(amount > 0 && !forced && stat != DEAD) - amount = body_allowed_damage(amount) - return ..(amount, updating_health, forced) - -/** - * How much of `amount` damage gets through. On its feet (stamina crit counts), a hit stops at 1 under - * the downed line: the rest is dropped. On its site, damage with no mind behind it stops at - * BOUNTY_AUTOMATED_FLOOR percent. Down, its own side's blows miss it entirely. Anything else gets through. - */ -/mob/living/basic/bounty_criminal/proc/body_allowed_damage(amount) - var/datum/component/bounty_body/ledger = GetComponent(/datum/component/bounty_body) - var/player_hit = ledger?.player_hit_now() - if(downed && !player_hit && ledger?.own_side_hit_now()) - return 0 - var/floor = downed ? 0 : body_downed_line() - 1 - if(!player_hit && body_has_site() && body_on_site(get_turf(src))) - floor = max(floor, maxHealth * BOUNTY_AUTOMATED_FLOOR / 100) - var/health_left = maxHealth - bruteloss - if(health_left - amount >= floor) - return amount - return max(0, health_left - floor) - -// An explosion names no attacker; the ledger works out whose it was before the blast lands (M1). -/mob/living/basic/bounty_criminal/ex_act(severity, target, origin) - var/datum/component/bounty_body/ledger = GetComponent(/datum/component/bounty_body) - ledger?.note_explosion(origin) - return ..() + body_state_changed() + SEND_SIGNAL(src, COMSIG_BOUNTY_CRIMINAL_DOWNED) -/mob/living/basic/bounty_criminal/updatehealth() +/mob/living/carbon/human/npc/bounty_criminal/npc_on_recovered() + if(stat == CONSCIOUS && !is_restrained()) + visible_message(span_warning("[src] gets back up.")) . = ..() - body_check_downed() - -/// Downs it once its health reaches the downed line -/mob/living/basic/bounty_criminal/proc/body_check_downed() - if(downed || stat == DEAD || QDELETED(src) || health > body_downed_line()) - return - body_go_down() - -/// Down: floored, harmless, draggable, its AI paused, and its recovery clock running. The line is forced: it is the moment the fight ends (BUG-1). -/mob/living/basic/bounty_criminal/proc/body_go_down() - downed = TRUE - body_recovery_due = FALSE - body_rally_until = 0 - deltimer(body_rally_timer) - body_rally_timer = null - add_traits(list(TRAIT_FLOORED, TRAIT_INCAPACITATED, TRAIT_IMMOBILIZED), BOUNTY_BODY_DOWNED_TRAIT) - body_update_held() - ai_controller?.CancelActions() - if(pulling) - stop_pulling() - body_start_recovery() body_state_changed() - visible_message(span_danger("[src] collapses.")) - SEND_SIGNAL(src, COMSIG_BOUNTY_CRIMINAL_DOWNED) - INVOKE_ASYNC(src, TYPE_PROC_REF(/mob/living, bounty_say), "downed", null, TRUE) + SEND_SIGNAL(src, COMSIG_BOUNTY_CRIMINAL_RECOVERED) /** * Floats `text` over it for every hunter who can see it (bounty_ai_is_hunter()), and nobody else. * Kept in body_last_alert. Returns how many hunters saw it. */ -/mob/living/basic/bounty_criminal/proc/body_alert_hunters(text) +/mob/living/carbon/human/npc/bounty_criminal/proc/body_alert_hunters(text) . = 0 body_last_alert = text for(var/mob/living/viewer in get_hearers_in_view(DEFAULT_MESSAGE_RANGE, src, RECURSIVE_CONTENTS_CLIENT_MOBS)) @@ -784,130 +521,19 @@ balloon_alert(viewer, text) .++ -/// Restrained or down, its AI plans nothing: TRAIT_BOUNTY_HELD for P3's controller, and TRAIT_AI_PAUSED -/mob/living/basic/bounty_criminal/proc/body_update_held() - if(downed || is_restrained()) - add_traits(list(TRAIT_BOUNTY_HELD, TRAIT_AI_PAUSED), BOUNTY_BODY_HELD_TRAIT) - else - remove_traits(list(TRAIT_BOUNTY_HELD, TRAIT_AI_PAUSED), BOUNTY_BODY_HELD_TRAIT) - -/// How long it stays down: meek, normal or mini-boss -/mob/living/basic/bounty_criminal/proc/body_recovery_time() - if(istype(src, /mob/living/basic/bounty_criminal/boss)) - return BOUNTY_RECOVER_TIME_BOSS - if(istype(src, /mob/living/basic/bounty_criminal/meek)) - return BOUNTY_RECOVER_TIME_MEEK - return BOUNTY_RECOVER_TIME_NORMAL - -/// (Re)starts its recovery clock from the top: on going down, and on every stamina hit while down, cuffed or not (L4) -/mob/living/basic/bounty_criminal/proc/body_start_recovery() - deltimer(body_recovery_timer) - body_stirring = FALSE - body_recovery_due = FALSE - body_recovery_timer = addtimer(CALLBACK(src, PROC_REF(body_stir)), max(0, body_recovery_time() - BOUNTY_BODY_STIRRING_TELL), TIMER_STOPPABLE | TIMER_DELETE_ME) - -/// Stops its recovery clock -/mob/living/basic/bounty_criminal/proc/body_cancel_recovery() - deltimer(body_recovery_timer) - body_recovery_timer = null - body_stirring = FALSE - -/// The tell before it gets up: it groans and tries to rise, and is up BOUNTY_BODY_STIRRING_TELL later. Cuffed, it waits for the cuffs to come off. -/mob/living/basic/bounty_criminal/proc/body_stir() - body_recovery_timer = null - if(!downed || stat == DEAD || QDELETED(src)) - return - if(is_restrained()) - body_recovery_due = TRUE - return - body_stirring = TRUE - visible_message(span_warning("[src] groans and tries to get up.")) - Shake(1, 0, 0.5 SECONDS) - body_recovery_timer = addtimer(CALLBACK(src, PROC_REF(body_stand_up)), BOUNTY_BODY_STIRRING_TELL, TIMER_STOPPABLE | TIMER_DELETE_ME) - -/** - * Up again at BOUNTY_RECOVER_TO percent of its health, or more if it was healed while down. A - * mini-boss rallies. Cuffed, it stays down until the cuffs come off (C1). Returns TRUE if it got up. - */ -/mob/living/basic/bounty_criminal/proc/body_stand_up() - body_recovery_timer = null - body_stirring = FALSE - if(!downed || stat == DEAD || QDELETED(src)) - return FALSE - if(is_restrained()) - body_recovery_due = TRUE - return FALSE - var/stand_health = maxHealth * BOUNTY_RECOVER_TO / 100 - var/health_now = maxHealth - bruteloss - if(health_now < stand_health) - adjust_health(health_now - stand_health, forced = TRUE) - downed = FALSE - body_recovery_due = FALSE - remove_traits(list(TRAIT_FLOORED, TRAIT_INCAPACITATED, TRAIT_IMMOBILIZED), BOUNTY_BODY_DOWNED_TRAIT) - body_update_held() - var/rally = body_rally_time() - if(rally > 0) - body_rally_until = world.time + rally - deltimer(body_rally_timer) - body_rally_timer = addtimer(CALLBACK(src, PROC_REF(body_end_rally)), rally, TIMER_STOPPABLE | TIMER_DELETE_ME) - body_state_changed() - visible_message(span_warning("[src] gets back up.")) - SEND_SIGNAL(src, COMSIG_BOUNTY_CRIMINAL_RECOVERED) - INVOKE_ASYNC(src, TYPE_PROC_REF(/mob/living, bounty_say), "recover") - return TRUE - -/// How long it rallies after getting up: a mini-boss only (C1). P4 may override it per kit. -/mob/living/basic/bounty_criminal/proc/body_rally_time() - return istype(src, /mob/living/basic/bounty_criminal/boss) ? BOUNTY_BODY_RALLY_TIME : 0 - -/// Whether it is rallying after getting up: stamina does nothing, and it won't surrender (P3) -/mob/living/basic/bounty_criminal/proc/body_is_rallying() - return world.time < body_rally_until +// ===== DEATH AND PROOF ===== -/// The rally is over: stamina works on it again, as far as its tiredness lets it (P4's boss_update_tired()) -/mob/living/basic/bounty_criminal/proc/body_end_rally() - body_rally_timer = null - body_rally_until = 0 - if(QDELETED(src) || stat == DEAD) - return - boss_update_tired(force = TRUE) - -/** - * A mini-boss re-reads how tired it is: its stamina coefficient and stun flags (P4). Nothing for - * anyone else. P4 overrides it on /boss; the override must not repeat the `proc/` keyword. - */ -/mob/living/basic/bounty_criminal/proc/boss_update_tired(silent = FALSE, force = FALSE) - return - -// A stamina hit while it is down starts its recovery over; rallying, it shrugs stamina off. -/mob/living/basic/bounty_criminal/adjustStaminaLoss(amount, updating_stamina = TRUE, forced = FALSE, required_biotype) - if(amount > 0 && !forced && stat != DEAD) - if(body_is_rallying()) - return 0 - if(downed) - body_start_recovery() - return ..() - -// ===== DEATH ===== - -// The body stays as proof; the cuffs come off it. -/mob/living/basic/bounty_criminal/death(gibbed) - body_cancel_recovery() +// The body stays as proof. Fallen into a chasm, it is in the chasm's depths for good: P5 puts the proof on +// safe ground beside the chasm (get_turf() here is the chasm itself). +/mob/living/carbon/human/npc/bounty_criminal/death(gibbed) . = ..() - if(QDELETED(src)) + if(QDELETED(src) || stat != DEAD) return - body_remove_cuffs() body_state_changed() - // Fallen into a chasm: the body is in the chasm's depths for good. P5 puts the proof on safe ground - // beside the chasm (get_turf() here is the chasm itself). if(istype(loc, /obj/effect/abstract/chasm_storage) && body_leaves_proof()) body_drop_proof() -// Nothing brings it back: dead is the dead share (AR-A5). -/mob/living/basic/bounty_criminal/can_be_revived() - return FALSE - -/mob/living/basic/bounty_criminal/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE) +/mob/living/carbon/human/npc/bounty_criminal/Moved(atom/old_loc, movement_dir, forced, list/old_locs, momentum_change = TRUE) . = ..() body_set_holder(isturf(loc) ? null : loc) // A body dragged into a chasm is gone for good too; P5 puts the proof beside it. @@ -917,9 +543,11 @@ /** * Keeps whatever holds it (`holder`, the outermost thing it is inside, or null on a turf) from being * teleported while it is inside (M2): a ship's transporter can't beam up a locker, crate or body bag - * with a criminal in it, any more than the criminal itself. Moves the block when it changes hands. + * with a criminal in it, any more than the criminal itself, and a person carrying a folded body bag + * with one inside can't teleport with it. Moves the block when it changes hands. (Carried over the + * shoulders it isn't inside anyone: it stands on the carrier's tile.) */ -/mob/living/basic/bounty_criminal/proc/body_set_holder(atom/movable/holder) +/mob/living/carbon/human/npc/bounty_criminal/proc/body_set_holder(atom/movable/holder) while(ismovable(holder?.loc)) holder = holder.loc var/atom/movable/old_holder = body_holder_ref?.resolve() @@ -938,7 +566,7 @@ * no proof. P5 marks removals with TRAIT_BOUNTY_REMOVED instead (the pad, closing, relisting, a site * unloading); this is for anything else that takes a criminal away on purpose. */ -/mob/living/basic/bounty_criminal/proc/body_mark_removed() +/mob/living/carbon/human/npc/bounty_criminal/proc/body_mark_removed() body_removed = TRUE /** @@ -946,171 +574,53 @@ * first; a live one deleted is never a death, M5), not removed on purpose, and its posting still open. * P5's bounty_drop_proof() makes the final call (a site unloading, a relist) and places the proof. */ -/mob/living/basic/bounty_criminal/proc/body_leaves_proof() +/mob/living/carbon/human/npc/bounty_criminal/proc/body_leaves_proof() if(stat != DEAD || body_removed || body_proof_dropped || HAS_TRAIT(src, TRAIT_BOUNTY_REMOVED)) return FALSE var/datum/criminal_bounty/wanted_on = posting() return wanted_on?.status == BOUNTY_POSTING_OPEN /// Leaves proof of death through P5's bounty_drop_proof(), once -/mob/living/basic/bounty_criminal/proc/body_drop_proof() +/mob/living/carbon/human/npc/bounty_criminal/proc/body_drop_proof() body_proof_dropped = TRUE bounty_drop_proof(src) -// ===== LOOKS ===== - -/// Puts its look on: its record's face in the outfit for its archetype and zone. Sleeps. -/mob/living/basic/bounty_criminal/proc/body_dress() - var/outfit = bounty_outfit() - if(record) - apply_bounty_look(src, record, outfit) - else - set_outpost_npc_look(src, outfit, gender, 1) - if(QDELETED(src)) - return - update_appearance(UPDATE_OVERLAYS) - -/// The outfit it wears: a mini-boss its kit's (boss_kit_outfit(), P4), anyone else plain clothes for their archetype and the zone of their site -/mob/living/basic/bounty_criminal/proc/bounty_outfit() - if(istype(src, /mob/living/basic/bounty_criminal/boss)) - return boss_kit_outfit() || boss_outfit() - var/meek = istype(src, /mob/living/basic/bounty_criminal/meek) - switch(body_zone()) - if(ZONE_RED) - return meek ? /datum/outfit/bounty_criminal/drifter : /datum/outfit/bounty_criminal/tough - if(ZONE_YELLOW) - return meek ? /datum/outfit/bounty_criminal/spacer : /datum/outfit/bounty_criminal/hauler - return meek ? /datum/outfit/bounty_criminal : /datum/outfit/bounty_criminal/local - -/// A mini-boss's kit outfit, or null. P4 overrides it on /boss; the override must not repeat the `proc/` keyword. -/mob/living/basic/bounty_criminal/proc/boss_kit_outfit() - return null - -/// What a mini-boss wears when its kit has no outfit: plain rough clothes -/mob/living/basic/bounty_criminal/proc/boss_outfit() - return /datum/outfit/bounty_criminal/tough - -/// ZONE_GREEN, ZONE_YELLOW or ZONE_RED for where its site is (or where it stands), green if unknown -/mob/living/basic/bounty_criminal/proc/body_zone() - var/atom/site = body_site_ref?.resolve() - var/zone = site ? SSovermap_zones?.get_zone_type(get_turf(site)) : SSovermap_zones?.get_zone_type_anywhere(get_turf(src)) - return zone || ZONE_GREEN - -/mob/living/basic/bounty_criminal/update_overlays() - . = ..() - if(is_restrained() && !hidden) - // tg's own cuff overlay, as people wear it - . += mutable_appearance('icons/mob/simple/mob.dmi', "handcuff1") - -/// Plain clothes for a meek criminal in green space -/datum/outfit/bounty_criminal - name = "Bounty criminal: civilian" - uniform = /obj/item/clothing/under/pants/jeans - suit = /obj/item/clothing/suit/toggle/jacket/sweater - shoes = /obj/item/clothing/shoes/sneakers/brown - -/// A meek criminal in yellow space -/datum/outfit/bounty_criminal/spacer - name = "Bounty criminal: spacer" - uniform = /obj/item/clothing/under/color/grey - suit = /obj/item/clothing/suit/jacket/bomber - shoes = /obj/item/clothing/shoes/workboots - head = /obj/item/clothing/head/beanie - -/// A meek criminal in red space -/datum/outfit/bounty_criminal/drifter - name = "Bounty criminal: drifter" - uniform = /obj/item/clothing/under/color/black - suit = /obj/item/clothing/suit/jacket/leather - shoes = /obj/item/clothing/shoes/jackboots - head = /obj/item/clothing/head/soft/grey - -/// A normal criminal in green space -/datum/outfit/bounty_criminal/local - name = "Bounty criminal: local" - uniform = /obj/item/clothing/under/costume/buttondown/slacks - suit = /obj/item/clothing/suit/jacket/letterman - shoes = /obj/item/clothing/shoes/sneakers/black - -/// A normal criminal in yellow space -/datum/outfit/bounty_criminal/hauler - name = "Bounty criminal: hauler" - uniform = /obj/item/clothing/under/pants/jeans - suit = /obj/item/clothing/suit/jacket/miljacket - gloves = /obj/item/clothing/gloves/fingerless - shoes = /obj/item/clothing/shoes/workboots - -/// A normal criminal in red space, and the fallback for a mini-boss -/datum/outfit/bounty_criminal/tough - name = "Bounty criminal: tough" - uniform = /obj/item/clothing/under/color/black - suit = /obj/item/clothing/suit/jacket/leather/biker - gloves = /obj/item/clothing/gloves/fingerless - shoes = /obj/item/clothing/shoes/jackboots - // ===== EXAMINE ===== /** - * How hurt it looks, its distinguishing features, and whether it is restrained, down or has given up. - * Blending in, the fugitive and its decoys show one layout: how hurt, then the features. Hidden (a - * disguise, a locker), it adds nothing. + * Its distinguishing features, and whether it has given up. How hurt it is, whether it is restrained + * and whether it is down are tg's own human examine. Hidden (a disguise, a locker), it adds nothing. */ -/mob/living/basic/bounty_criminal/examine(mob/user) +/mob/living/carbon/human/npc/bounty_criminal/examine(mob/user) . = ..() if(hidden) return - if(stat != DEAD) - . += body_health_line() for(var/line in record?.feature_lines()) . += span_notice(line) - if(blended || stat == DEAD) + if(blended || stat != CONSCIOUS) return - if(is_restrained()) - . += span_warning("[p_They()] [p_are()] restrained with [restraints].") - if(downed) - if(body_stirring) - . += span_warning("[p_They()] [p_are()] trying to get up.") - else - . += span_notice("[p_They()] [p_are()] down.") - else if(HAS_TRAIT(src, TRAIT_BOUNTY_SURRENDERED)) + if(npc_surrendering && IsParalyzed()) . += span_notice("[p_They()] [p_have()] given up.") -/// One line on how hurt it looks -/mob/living/basic/bounty_criminal/proc/body_health_line() - var/fraction = maxHealth > 0 ? health / maxHealth : 0 - if(fraction >= 0.9) - return span_notice("[p_They()] look[p_s()] unhurt.") - if(fraction >= 0.6) - return span_warning("[p_They()] [p_have()] a few cuts and bruises.") - if(fraction > BOUNTY_DOWNED_BELOW / 100) - return span_warning("[p_They()] [p_are()] badly hurt.") - return span_danger("[p_They()] [p_are()] barely conscious.") - -// ===== THE LEDGER AND THE BODY'S SIGNALS ===== +// ===== THE BODY'S SIGNALS ===== /** - * Who has been hurting a criminal, and the rest of the body's signal hooks, kept on a component so the - * AI packages can register the same signals on the mob without clashing. The ledger (in the style of - * experiment_damage_ledger) tells a hit with someone's mind behind it from one without, so turrets, - * traps, fire and fauna can't finish off a criminal on its site (AR-D3), and puts attackers on its - * grudge list. Damage and the attack report arrive in the same tick: a projectile's pre-hit and an item - * attack's attackby come before the damage, so the tick's attacker is known when the damage lands. - * It also refuses teleports, polymorph and type changes, lets a sprinting meek criminal duck shots, - * holds ranged attacks to may_attack(), and stops a free criminal being dragged onto things. + * The body's own signal hooks, kept on a component so the AI packages can register the same signals on + * the mob without clashing: + * - who has been attacking it (tg's relay_attackers, an item's attackby, a projectile's firer, a mech's + * or a vehicle's pilot) goes on its grudge list; + * - teleports, polymorph and type changes are refused; + * - any change of tg state that capture_state() reads tells the body (body_state_changed()). */ /datum/component/bounty_body dupe_mode = COMPONENT_DUPE_UNIQUE - /// world.time someone with a mind behind them last attacked it - var/player_hit_at = -1 - /// world.time another criminal or a companion last attacked it - var/own_side_hit_at = -1 /datum/component/bounty_body/Initialize() - if(!istype(parent, /mob/living/basic/bounty_criminal)) + if(!istype(parent, /mob/living/carbon/human/npc/bounty_criminal)) return COMPONENT_INCOMPATIBLE /datum/component/bounty_body/RegisterWithParent() - var/mob/living/basic/bounty_criminal/criminal = parent + var/mob/living/carbon/human/npc/bounty_criminal/criminal = parent criminal.AddElement(/datum/element/relay_attackers) RegisterSignal(criminal, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_attacked)) RegisterSignal(criminal, COMSIG_ATOM_ATTACKBY, PROC_REF(on_attackby)) @@ -1118,9 +628,15 @@ RegisterSignal(criminal, COMSIG_MOVABLE_TELEPORTING, PROC_REF(refuse_teleport)) RegisterSignal(criminal, COMSIG_LIVING_PRE_WABBAJACKED, PROC_REF(refuse_polymorph)) RegisterSignal(criminal, COMSIG_PRE_MOB_CHANGED_TYPE, PROC_REF(refuse_type_change)) - RegisterSignal(criminal, COMSIG_BASICMOB_PRE_ATTACK_RANGED, PROC_REF(on_pre_ranged_attack)) - RegisterSignal(criminal, COMSIG_MOUSEDROP_ONTO, PROC_REF(on_mousedrop)) - RegisterSignals(criminal, list(SIGNAL_ADDTRAIT(TRAIT_BOUNTY_SURRENDERED), SIGNAL_REMOVETRAIT(TRAIT_BOUNTY_SURRENDERED)), PROC_REF(on_state_signal)) + RegisterSignal(criminal, COMSIG_MOB_STATCHANGE, PROC_REF(on_state_signal)) + RegisterSignals(criminal, list( + SIGNAL_ADDTRAIT(TRAIT_CRITICAL_CONDITION), + SIGNAL_REMOVETRAIT(TRAIT_CRITICAL_CONDITION), + SIGNAL_ADDTRAIT(TRAIT_FLOORED), + SIGNAL_REMOVETRAIT(TRAIT_FLOORED), + SIGNAL_ADDTRAIT(TRAIT_INCAPACITATED), + SIGNAL_REMOVETRAIT(TRAIT_INCAPACITATED), + ), PROC_REF(on_state_signal)) // A stun's traits land before the stun is on its list, so the trait handlers alone would miss it. RegisterSignals(criminal, list(COMSIG_LIVING_STATUS_APPLIED, COMSIG_LIVING_STATUS_REMOVED), PROC_REF(on_state_signal)) @@ -1132,29 +648,20 @@ COMSIG_MOVABLE_TELEPORTING, COMSIG_LIVING_PRE_WABBAJACKED, COMSIG_PRE_MOB_CHANGED_TYPE, - COMSIG_BASICMOB_PRE_ATTACK_RANGED, - COMSIG_MOUSEDROP_ONTO, - SIGNAL_ADDTRAIT(TRAIT_BOUNTY_SURRENDERED), - SIGNAL_REMOVETRAIT(TRAIT_BOUNTY_SURRENDERED), + COMSIG_MOB_STATCHANGE, + SIGNAL_ADDTRAIT(TRAIT_CRITICAL_CONDITION), + SIGNAL_REMOVETRAIT(TRAIT_CRITICAL_CONDITION), + SIGNAL_ADDTRAIT(TRAIT_FLOORED), + SIGNAL_REMOVETRAIT(TRAIT_FLOORED), + SIGNAL_ADDTRAIT(TRAIT_INCAPACITATED), + SIGNAL_REMOVETRAIT(TRAIT_INCAPACITATED), COMSIG_LIVING_STATUS_APPLIED, COMSIG_LIVING_STATUS_REMOVED, )) -/// Whether someone with a mind behind them attacked it this tick -/datum/component/bounty_body/proc/player_hit_now() - return player_hit_at == world.time - -/// Whether its own side (another criminal, a companion) attacked it this tick -/datum/component/bounty_body/proc/own_side_hit_now() - return own_side_hit_at == world.time - -/// `attacker` went for it: noted for the ledger, and they go on its grudge list +/// `attacker` went for it: they go on its grudge list (a vehicle's pilots for a vehicle) /datum/component/bounty_body/proc/note_attacker(atom/attacker) - var/mob/living/basic/bounty_criminal/criminal = parent - if(bounty_player_behind(attacker)) - player_hit_at = world.time - if(istype(attacker, /mob/living/basic/bounty_criminal) || istype(attacker, /mob/living/basic/bounty_companion)) - own_side_hit_at = world.time + var/mob/living/carbon/human/npc/bounty_criminal/criminal = parent if(istype(attacker, /obj/vehicle/sealed)) var/obj/vehicle/sealed/vehicle = attacker for(var/mob/living/pilot in vehicle.occupants) @@ -1162,60 +669,35 @@ else if(isliving(attacker)) criminal.body_add_grudge(attacker) -/** - * An explosion is about to hit it (M1). ex_act() carries no attacker, so the blast counts as a - * player's when the explosive was last handled by one (`origin`'s last fingerprints: a grenade - * someone threw or set), or when someone with a mind stands within BOUNTY_EXPLOSION_WITNESS_RANGE - * tiles. Anything else is automated, like fire. - */ -/datum/component/bounty_body/proc/note_explosion(atom/origin) - var/mob/living/basic/bounty_criminal/criminal = parent - if(isatom(origin) && origin.fingerprintslast) - player_hit_at = world.time - return - var/turf/here = get_turf(criminal) - if(!here) - return - for(var/mob/living/person in range(BOUNTY_EXPLOSION_WITNESS_RANGE, here)) - if(bounty_player_behind(person)) - player_hit_at = world.time - return - /datum/component/bounty_body/proc/on_attacked(datum/source, atom/attacker, attack_flags) SIGNAL_HANDLER if(!(attack_flags & (ATTACKER_DAMAGING_ATTACK | ATTACKER_STAMINA_ATTACK | ATTACKER_SHOVING))) return note_attacker(attacker) -// Before an item's damage lands (relay_attackers only reports it after), so the ledger knows whose it is. /datum/component/bounty_body/proc/on_attackby(datum/source, obj/item/attacking_item, mob/living/user, list/modifiers, list/attack_modifiers) SIGNAL_HANDLER if(attacking_item?.force > 0 || user?.combat_mode) note_attacker(user) -/// Whose shot it is, even a mech's or a vehicle's (relay_attackers only reports mobs, M1); and a sprinting meek criminal ducks some shots (C5), though one that gets through spoils the next second's dodging +/// Whose shot it is, even a mech's or a vehicle's (relay_attackers only reports mobs, M1) /datum/component/bounty_body/proc/on_projectile_prehit(datum/source, obj/projectile/shot) SIGNAL_HANDLER - var/mob/living/basic/bounty_criminal/criminal = parent if(shot?.firer && shot.is_hostile_projectile()) note_attacker(shot.firer) - if(prob(criminal.body_dodge_chance())) - criminal.visible_message(span_warning("[criminal] ducks out of the way of [shot]!")) - return PROJECTILE_INTERRUPT_HIT_PHASE - criminal.body_last_shot_at = world.time return NONE /// The pad deletes a criminal; nothing teleports one (D-A10) /datum/component/bounty_body/proc/refuse_teleport(datum/source, atom/destination, channel) SIGNAL_HANDLER - var/mob/living/basic/bounty_criminal/criminal = parent + var/mob/living/carbon/human/npc/bounty_criminal/criminal = parent if(isturf(criminal.loc)) criminal.visible_message(span_notice("[criminal] flickers for a moment, but stays where [criminal.p_they()] [criminal.p_are()].")) return TRUE /datum/component/bounty_body/proc/refuse_polymorph(datum/source, what_to_randomize) SIGNAL_HANDLER - var/mob/living/basic/bounty_criminal/criminal = parent + var/mob/living/carbon/human/npc/bounty_criminal/criminal = parent criminal.visible_message(span_notice("[criminal] shimmers for a moment, then looks the same as before.")) return STOP_WABBAJACK @@ -1223,51 +705,30 @@ SIGNAL_HANDLER return COMPONENT_BLOCK_MOB_CHANGE -/datum/component/bounty_body/proc/on_pre_ranged_attack(datum/source, atom/target, modifiers) - SIGNAL_HANDLER - var/mob/living/basic/bounty_criminal/criminal = parent - if(!criminal.may_attack(target)) - return COMPONENT_CANCEL_RANGED_ATTACK - -/datum/component/bounty_body/proc/on_mousedrop(datum/source, atom/over, mob/user) - SIGNAL_HANDLER - var/mob/living/basic/bounty_criminal/criminal = parent - if(!criminal.body_can_be_dragged()) - return COMPONENT_CANCEL_MOUSEDROP_ONTO - -/// It surrendered or stopped, or a stun, knockdown or stamina crit came or went: its capture state may have changed +/// Its stat, crit, a stun, a knockdown or stamina crit came or went: its capture state may have changed /datum/component/bounty_body/proc/on_state_signal(datum/source) SIGNAL_HANDLER - var/mob/living/basic/bounty_criminal/criminal = parent - criminal.body_state_changed() - -/// The chance, in percent, that it ducks a shot now: a meek criminal sprinting freely (TRAIT_BOUNTY_SPRINTING, from P3), not shot in the last second -/mob/living/basic/bounty_criminal/proc/body_dodge_chance() - if(!istype(src, /mob/living/basic/bounty_criminal/meek) || !HAS_TRAIT(src, TRAIT_BOUNTY_SPRINTING)) - return 0 - if(stat != CONSCIOUS || downed || is_restrained() || !isturf(loc) || pulledby || buckled) - return 0 - if(HAS_TRAIT(src, TRAIT_INCAPACITATED) || HAS_TRAIT(src, TRAIT_IMMOBILIZED) || HAS_TRAIT(src, TRAIT_FLOORED)) - return 0 - if(world.time - body_last_shot_at < BOUNTY_MEEK_DODGE_AFTER_HIT) - return 0 - return BOUNTY_MEEK_DODGE + var/mob/living/carbon/human/npc/bounty_criminal/criminal = parent + if(!QDELING(criminal)) + criminal.body_state_changed() + +// ===== TURRETS AND PLAYERS ===== /** - * Whether a turret leaves `creature` alone for being part of a bounty (L2; hostile_creatures.dm). + * Whether a turret leaves `creature` alone for being part of a bounty (L2, AM-11; hostile_creatures.dm). * `at_trader_outpost`: it stands in a trader outpost's concourse. There, criminals, decoys and - * companions are left to the hunters (spec 4). Anywhere else a criminal is left alone only once it is - * down, stunned, restrained or dead, so a crew's own turrets don't finish off their catch; a free one, - * and any companion, is judged like any other creature. + * companions are left to the hunters (spec 4), unless an exposed fugitive hurt a bystander (P6's + * outpost_turret_target()). Anywhere else a criminal is left alone once it is in crit, stunned, + * restrained or dead (tg's states), so a crew's own turrets don't finish off their catch; a free one, and + * any companion, is judged like any other creature. */ /proc/bounty_turret_ignores(mob/living/creature, at_trader_outpost) - var/mob/living/basic/bounty_criminal/criminal = creature + var/mob/living/carbon/human/npc/bounty_criminal/criminal = creature if(istype(criminal)) - // At a trader outpost, turrets leave it alone unless an exposed fugitive hurt someone outside its grudge list (AR-C8, P6's outpost_turret_target()). if(at_trader_outpost) return !criminal.outpost_turret_target() return criminal.capture_state() != BOUNTY_STATE_FREE - return at_trader_outpost && istype(creature, /mob/living/basic/bounty_companion) + return at_trader_outpost && istype(creature, /mob/living/carbon/human/npc/bounty_companion) /// Whether someone with a mind is behind `attacker`: a person, a borg, or the pilot of a mech or other vehicle. Criminals and their companions never count. /proc/bounty_player_behind(atom/attacker) @@ -1278,6 +739,6 @@ return TRUE return FALSE var/mob/living/person = attacker - if(!istype(person) || istype(person, /mob/living/basic/bounty_criminal) || istype(person, /mob/living/basic/bounty_companion)) + if(!istype(person) || bounty_is_gang_body(person)) return FALSE return !isnull(person.mind) || !isnull(person.ckey) diff --git a/voidcrew/modules/bounties/bounty_identity.dm b/voidcrew/modules/bounties/bounty_identity.dm index 43e82826b77..66cce89380d 100644 --- a/voidcrew/modules/bounties/bounty_identity.dm +++ b/voidcrew/modules/bounties/bounty_identity.dm @@ -710,22 +710,22 @@ GLOBAL_LIST_INIT(bounty_species_weights, list( /mob/living/proc/identity_line_values() return null -/mob/living/basic/bounty_criminal/identity_voice() +/mob/living/carbon/human/npc/bounty_criminal/identity_voice() // Blended in at a trader outpost, the fugitive talks exactly like its decoys (AR-C6). if(blended) return null return record?.archetype -/mob/living/basic/bounty_criminal/identity_line_values() +/mob/living/carbon/human/npc/bounty_criminal/identity_line_values() // A Most Wanted crime is no line to toss off ("All this over the Corvina Station massacre?"). if(!record?.crime || record.tier == BOUNTY_TIER_MOST_WANTED) return null return list("{crime}" = record.crime) /// A decoy is an innocent patron: always the shared, neutral lines, whether or not it is blended in -/mob/living/basic/bounty_criminal/decoy/identity_voice() +/mob/living/carbon/human/npc/bounty_criminal/decoy/identity_voice() return null /// A decoy has no crime to own up to -/mob/living/basic/bounty_criminal/decoy/identity_line_values() +/mob/living/carbon/human/npc/bounty_criminal/decoy/identity_line_values() return null diff --git a/voidcrew/modules/bounties/bounty_kingpin.dm b/voidcrew/modules/bounties/bounty_kingpin.dm index 29ab4fe6b61..d0ff11992c1 100644 --- a/voidcrew/modules/bounties/bounty_kingpin.dm +++ b/voidcrew/modules/bounties/bounty_kingpin.dm @@ -21,32 +21,37 @@ * ckey), and anyone aboard for themselves, can never hunt him or turn him in, and his goons treat * them as guests. One run at a time (the job's mission_limit, counting the one he holds). He won't * hire drifters or crews who fought his people. - * - His posting (/datum/criminal_bounty/kingpin): P5's posting with his own shares (alive 100%, - * downed counts as alive, dead 80%), his own card lines and a clock that pauses during a shootout. + * - His posting (/datum/criminal_bounty/kingpin): P5's posting with his own shares (alive 100% + * however he is brought in, dead 80%), his own card lines and a clock that pauses during a shootout. * It goes up only on the clock (no earlier than 45 minutes in with 3+ active ships, the next 60-90 * minutes after the last resolves) or from the admin panel; a shootout never puts him on the * board. It adopts him wherever he is, alive (never a second body), so a crew that grabbed him * early can turn him in once he is posted; with his crew at ease every empty goon post gets a new - * goon. Killed before any posting, he is gone with nothing to claim, and his body fades. Closed - * unclaimed (run out, withdrawn), it leaves him in the lounge, alive, uncuffed and in business, - * when he is alive within his goons' leash of the sofa; otherwise he is removed as any criminal is, - * and gone. + * goon. Killed before any posting, he is gone with nothing to claim: his body is an ordinary corpse + * that the human NPC corpse sweep takes in time. Closed unclaimed (run out, withdrawn), it leaves + * him in the lounge, alive, uncuffed and in business, when he is alive within his goons' leash of + * the sofa; otherwise he is removed as any criminal is, and gone. * - Talking: a radial on him. "We're here for you" and "Walk away" only show once that crew's * ship has taken his open posting from the board; the first gets his confront line and starts the - * shootout. Any attack on him or a goon starts it too. A warrant shown to him, or a reach for his - * wrists, only gets the confront line. + * shootout. Any attack on him or a goon starts it too. A warrant shown to him only gets the + * confront line; a reach for his wrists while he can still move gets the line and a shove. * - The shootout (/datum/bounty_kingpin_crew): a 0.6 s telegraph where nobody fires ("the goons - * reach for their guns"), then first shots spread over half a second, at most two goons on one - * hunter in cover. He never leaves the sofa and fires a revolver after a visible 0.5 s aim. Goons - * stay within 7 tiles of the sofa, never shoot anyone who is down, and half of those left flee once - * he falls. The barkeep shouts, the turret ignores both sides, and hunters - * fighting his crew take no outpost property strikes (one marked hook in outpost.dm). His crew - * lives as long as he does. - * - His body is P2's (/mob/living/basic/bounty_criminal), with or without a posting: downed at 25%, - * up again after 60 s unless cuffed, and P2's capture rules and P5's pad apply. He surrenders only - * once his crew is down. - * - Goons (/mob/living/basic/bounty_kingpin_goon) are not bounties: 150 health, no loot, no real - * guns, and their bodies fade after 60 s. + * reach for their guns", and they really draw them), then first shots spread over half a second, + * at most two goons on one hunter in cover. Every shot is a real trigger pull of the real gun in a + * hand, through that body's AI controller (ai_interact(), a player's click), and every reload is + * the player's reload from the spares they carry. Nobody in his crew fires through someone they + * aren't fighting: a bystander, a guest or one of their own in the line holds the shot. He never + * leaves the sofa and fires his revolver after a visible 0.5 s aim that a hit spoils. Goons stay + * within 7 tiles of the sofa, never shoot anyone who is down, and half of those left walk out once + * he falls. The barkeep shouts, the turret ignores both sides, and hunters fighting his crew take + * no outpost property strikes (one marked hook in outpost.dm). His crew lives as long as he does. + * - His body is P2's (/mob/living/carbon/human/npc/bounty_criminal), a real human with or without a + * posting: tg's crit, stamina, cuffs and death, P2's capture rules and P5's pad. A boss (aimed crits), + * tougher by physiology (BOUNTY_KINGPIN_DAMAGE_TAKEN) and an armoured coat. He gives up (tg's + * *surrender) only once his crew is down and he is badly hurt. + * - Goons (/mob/living/carbon/human/npc/bounty_kingpin_goon) are not bounties: real humans in armour + * vests with real pistols, SMGs and shotguns and real spare magazines and shells. Their gear is + * locked to them (D3), so nothing they carry is loot; their bodies go with the human NPC corpse sweep. * * A var this file adds to a shared type carries a `kingpin_` prefix. */ @@ -182,65 +187,92 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) // LOOKS // ========================================================================= -/// The kingpin: a charcoal suit, a red tie, a fedora and a cigar +/** + * The kingpin: a charcoal suit under an armoured trenchcoat, a red tie, a fedora and a cigar. His .357 + * and two speedloaders ride in the shoulder holster under the coat, a third speedloader and an + * epinephrine pen in his pockets. Locked to him (D3): none of it is loot. + */ /datum/outfit/bounty_kingpin name = "Bounty kingpin" uniform = /obj/item/clothing/under/suit/charcoal - suit = /obj/item/clothing/suit/toggle/lawyer/black + suit = /obj/item/clothing/suit/armor/hos/trenchcoat neck = /obj/item/clothing/neck/tie/red/tied gloves = /obj/item/clothing/gloves/color/black shoes = /obj/item/clothing/shoes/laceup head = /obj/item/clothing/head/fedora mask = /obj/item/cigarette/cigar/havana - -/// The kingpin in a shootout: the same, with his revolver out (worn look only; he carries no real gun) -/datum/outfit/bounty_kingpin/armed - name = "Bounty kingpin: armed" - r_hand = BOUNTY_KINGPIN_REVOLVER - -/// A goon at ease: black suit, black tie, sunglasses + belt = /obj/item/storage/belt/holster/detective + belt_contents = list( + BOUNTY_KINGPIN_REVOLVER = 1, + BOUNTY_KINGPIN_SPEEDLOADER = 2, + ) + l_pocket = BOUNTY_KINGPIN_SPEEDLOADER + r_pocket = /obj/item/reagent_containers/hypospray/medipen + +/// A goon: black suit and tie under an armour vest, sunglasses. The subtypes carry the gun and its spares. /datum/outfit/bounty_kingpin_goon name = "Kingpin goon" uniform = /obj/item/clothing/under/suit/black - suit = /obj/item/clothing/suit/toggle/lawyer/black + suit = /obj/item/clothing/suit/armor/vest neck = /obj/item/clothing/neck/tie/black/tied glasses = /obj/item/clothing/glasses/sunglasses gloves = /obj/item/clothing/gloves/color/black shoes = /obj/item/clothing/shoes/laceup -/// Goons with their guns out (worn looks only; goons carry no real guns and drop none) +/// A Stechkin in the holster under the vest, with two spare magazines beside it /datum/outfit/bounty_kingpin_goon/pistol name = "Kingpin goon: pistol" - r_hand = BOUNTY_GOON_PISTOL_GUN + belt = /obj/item/storage/belt/holster/detective + belt_contents = list( + BOUNTY_GOON_PISTOL_GUN = 1, + BOUNTY_GOON_PISTOL_MAG = 2, + ) +/// An Uzi on the vest, a spare magazine in each pocket /datum/outfit/bounty_kingpin_goon/smg name = "Kingpin goon: SMG" - r_hand = BOUNTY_GOON_SMG_GUN + suit_store = BOUNTY_GOON_SMG_GUN + l_pocket = BOUNTY_GOON_SMG_MAG + r_pocket = BOUNTY_GOON_SMG_MAG +/// A combat shotgun on the back, a bandolier of buckshot /datum/outfit/bounty_kingpin_goon/shotgun name = "Kingpin goon: shotgun" - r_hand = BOUNTY_GOON_SHOTGUN_GUN + back = BOUNTY_GOON_SHOTGUN_GUN + belt = /obj/item/storage/belt/bandolier + belt_contents = list(BOUNTY_GOON_SHOTGUN_AMMO = BOUNTY_GOON_SHOTGUN_SHELLS) + +/// The goons' combat shotgun: tg's, with its tube loaded with buckshot instead of rubber +/obj/item/gun/ballistic/shotgun/automatic/combat/bounty_kingpin + spawn_magazine_type = /obj/item/ammo_box/magazine/internal/shot/com/bounty_kingpin + +/obj/item/ammo_box/magazine/internal/shot/com/bounty_kingpin + ammo_type = BOUNTY_GOON_SHOTGUN_AMMO // ========================================================================= // THE KINGPIN // ========================================================================= /** - * The kingpin: P2's criminal body with his own numbers. He sits on the sofa and never leaves it, - * talks across the table, and in a shootout fires a revolver after a visible aim. His crew - * (kingpin_crew) runs the goons, the room and his business. He may be on a posting or on none. + * The kingpin: P2's criminal body, a real human. He sits on the sofa and never leaves it, talks across + * the table, and in a shootout draws his real revolver and fires it after a visible aim. His crew + * (kingpin_crew) runs the goons, the room, his shots and his business; his own AI controller only + * does what his body does by itself (soft crit, breaking free, giving up, reloading, his medipen). He + * may be on a posting or on none. */ -/mob/living/basic/bounty_criminal/kingpin +/mob/living/carbon/human/npc/bounty_criminal/kingpin name = "kingpin" desc = "Sharp suit, cold eyes. He runs this lounge, and his people are never far away." - maxHealth = BOUNTY_KINGPIN_HEALTH - health = BOUNTY_KINGPIN_HEALTH - // His crew drives him; no criminal AI (P3) is ever put on him. - ai_controller = null + ai_controller = /datum/ai_controller/basic_controller/human_npc/bounty_kingpin + npc_rank = HUMAN_NPC_RANK_BOSS + npc_damage_taken = BOUNTY_KINGPIN_DAMAGE_TAKEN + // A boss's toughness is his own, not his record's tier (bounty_criminal.dm body_toughness()) + body_tier_toughness = FALSE + npc_surrender = /datum/human_npc_surrender/bounty_kingpin + // Killed before any posting he is an ordinary corpse; on an open posting the sweep leaves him for the pad (npc_corpse_expired()) + npc_corpse_lifetime = HUMAN_NPC_CORPSE_LIFETIME /// His goons, the shootout, the room and the job he holds (/datum/bounty_kingpin_crew). He deletes it. var/datum/bounty_kingpin_crew/kingpin_crew - /// Rounds left in his revolver (a full cylinder at Initialize) - var/kingpin_rounds = 0 /// world.time he may start his next aim var/kingpin_next_aim_at = 0 /// The timer that fires the aimed shot, while he aims @@ -251,65 +283,51 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) var/datum/weakref/kingpin_aim_target /// Weakref of anyone who hit him -> how many times: he shoots whoever hurt him most var/list/kingpin_hits = list() - /// world.time of his next surrender roll - var/kingpin_next_surrender_roll = 0 - /// The timer fading his body out, when no posting holds it (kingpin_start_fade()) - var/kingpin_fade_timer /// Between two of his lines COOLDOWN_DECLARE(kingpin_say_cooldown) -/mob/living/basic/bounty_criminal/kingpin/Initialize(mapload) - . = ..() - kingpin_rounds = bounty_kingpin_revolver().magazine - -/mob/living/basic/bounty_criminal/kingpin/Destroy() +/mob/living/carbon/human/npc/bounty_criminal/kingpin/Destroy() kingpin_cancel_aim() - deltimer(kingpin_fade_timer) - kingpin_fade_timer = null QDEL_NULL(kingpin_crew) kingpin_hits.Cut() - // Deleted for any reason (the pad, a posting's cleanup, an admin): he is gone for the round + // Deleted for any reason (the pad, a posting's cleanup, the corpse sweep, an admin): he is gone for the round SSbounty_kingpin.kingpin_removed(src) return ..() -// Dead is gone for the round. On the board, his body is there to bring in; killed off it, there is nothing to claim and it fades. -/mob/living/basic/bounty_criminal/kingpin/death(gibbed) +// Dead is gone for the round. On the board, his body is there to bring in; killed off it, there is nothing to claim. +/mob/living/carbon/human/npc/bounty_criminal/kingpin/death(gibbed) . = ..() SSbounty_kingpin.kingpin_died(src) if(QDELETED(src)) return + kingpin_cancel_aim() // A chair holds a body upright: he slumps off his sofa if(istype(buckled, /obj/structure/chair)) buckled.unbuckle_mob(src, force = TRUE) - if(!kingpin_posting()) - kingpin_start_fade() - -// His numbers on P2's body -/mob/living/basic/bounty_criminal/kingpin/body_recovery_time() - return BOUNTY_KINGPIN_RECOVERY - -/mob/living/basic/bounty_criminal/kingpin/body_rally_time() - return BOUNTY_KINGPIN_RALLY -/mob/living/basic/bounty_criminal/kingpin/body_stamina_pool() - return BOUNTY_KINGPIN_STAMINA +// The corpse sweep never takes the body an open posting pays for; with no posting he is an ordinary corpse +/mob/living/carbon/human/npc/bounty_criminal/kingpin/npc_corpse_expired() + if(kingpin_posting()?.is_open()) + return FALSE + return ..() -/mob/living/basic/bounty_criminal/kingpin/bounty_outfit() - return kingpin_crew?.crew_armed ? /datum/outfit/bounty_kingpin/armed : /datum/outfit/bounty_kingpin +// He dresses as himself, whatever the zone: the outfit table asks (bounty_outfits.dm) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/bounty_build_outfit(zone) + return /datum/outfit/bounty_kingpin // He is always at the sofa; nothing else sets what he is doing. -/mob/living/basic/bounty_criminal/kingpin/start_activity(kind, atom/anchor) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/start_activity(kind, atom/anchor) return -// Shown a warrant, or someone reached for his wrists: his confront line, and nothing more (P6, P2) -/mob/living/basic/bounty_criminal/kingpin/on_confronted(mob/user) +// Shown a warrant: his confront line, and nothing more (P6, P2) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/on_confronted(mob/user) INVOKE_ASYNC(src, PROC_REF(kingpin_confronted), user) -/mob/living/basic/bounty_criminal/kingpin/identity_voice() +/mob/living/carbon/human/npc/bounty_criminal/kingpin/identity_voice() return BOUNTY_ARCHETYPE_KINGPIN /// His lines come from his own dialogue file first; anything it has no lines for goes to P1's -/mob/living/basic/bounty_criminal/kingpin/bounty_say(context, list/values, force = FALSE) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/bounty_say(context, list/values, force = FALSE) if(QDELETED(src) || stat == DEAD || !istext(context)) return FALSE if(!length(bounty_kingpin_lines("kingpin", context))) @@ -326,28 +344,46 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) say(line, forced = "bounty kingpin") return TRUE -/mob/living/basic/bounty_criminal/kingpin/examine(mob/user) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/examine(mob/user) . = ..() if(kingpin_can_talk()) . += span_notice("[p_They()] look[p_s()] ready to talk business.") -// Every hit that gets through: with his crew down, he may give up -/mob/living/basic/bounty_criminal/kingpin/adjust_health(amount, updating_health = TRUE, forced = FALSE) - var/health_before = health - . = ..() - if(amount > 0 && !forced) - kingpin_consider_surrender(health_before) - // Hurt while his crew is at ease, by anything at all: they find out who - kingpin_crew?.member_hurt(src) +/** + * Someone reaches for his wrists. A man on his sofa doesn't step away: while he can still move he + * shoves them off a moment later (a real shove, which breaks their cuffing) and says his confront line. + * Paralysed after giving up, stamcritted, knocked down or in crit, he can't, and the cuffs go on. + */ +/mob/living/carbon/human/npc/bounty_criminal/kingpin/body_on_cuff_attempt(mob/living/user) + if(!kingpin_able()) + return + body_add_grudge(user) + addtimer(CALLBACK(src, PROC_REF(kingpin_answer_cuffs), WEAKREF(user)), BOUNTY_CUFF_REACTION_DELAY, TIMER_DELETE_ME) + +/// A moment after the reach: his line, and a shove for whoever is at his wrists, if he still can +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_answer_cuffs(datum/weakref/user_ref) + var/mob/living/user = user_ref?.resolve() + if(QDELETED(src) || QDELETED(user) || !kingpin_able() || !Adjacent(user)) + return + INVOKE_ASYNC(src, PROC_REF(kingpin_confronted), user) + bounty_kingpin_shove(src, user) + +// He gives up the way a person does (the human NPC base): his aim drops, his hands go up, then tg's *surrender +/mob/living/carbon/human/npc/bounty_criminal/kingpin/npc_surrender() + if(stat != CONSCIOUS || HAS_TRAIT(src, TRAIT_RESTRAINED) || npc_surrendering) + return FALSE + kingpin_cancel_aim() + visible_message(span_notice("[src] puts [p_their()] hands up."), vision_distance = BOUNTY_KINGPIN_SIGHT) + return ..() // An open hand in reach of him starts the talk -/mob/living/basic/bounty_criminal/kingpin/attack_hand(mob/living/carbon/human/user, list/modifiers) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/attack_hand(mob/living/carbon/human/user, list/modifiers) if(istype(user) && !user.combat_mode && !LAZYACCESS(modifiers, RIGHT_CLICK) && !is_restrained() && kingpin_can_talk()) INVOKE_ASYNC(src, PROC_REF(kingpin_open_talk), user) return TRUE return ..() -/mob/living/basic/bounty_criminal/kingpin/ranged_attack_hand(mob/living/user, list/modifiers) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/ranged_attack_hand(mob/living/user, list/modifiers) if(!kingpin_in_talk_range(user)) return FALSE if(!kingpin_can_talk()) @@ -357,72 +393,54 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) return TRUE /// His posting, if he is on one (/datum/criminal_bounty/kingpin): none while he just sits in his lounge -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_posting() +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_posting() RETURN_TYPE(/datum/criminal_bounty/kingpin) var/datum/criminal_bounty/kingpin/posting = posting() return istype(posting) ? posting : null /// Whether he is in his lounge: on a turf (not in a locker or a bag) within his goons' leash of his seat -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_on_leash() +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_on_leash() var/turf/seat = kingpin_crew?.crew_seat var/turf/here = get_turf(src) if(!seat || !here || !isturf(loc)) return FALSE return here.z == seat.z && get_dist(here, seat) <= BOUNTY_GOON_LEASH -/// A posting let go of him in his lounge: his people see to him. The cuffs come off (onto the floor) and he stops giving up; a downed one gets up in his own time. -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_back_to_business() - if(is_restrained()) - body_remove_cuffs() - REMOVE_TRAIT(src, TRAIT_BOUNTY_SURRENDERED, BOUNTY_TRAIT) - -/// His body, with no posting to bring it in for, fades after BOUNTY_GOON_FADE as a goon's does (once) -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_start_fade() - if(kingpin_fade_timer || stat != DEAD || QDELETED(src)) - return - kingpin_fade_timer = addtimer(CALLBACK(src, PROC_REF(kingpin_fade_out)), BOUNTY_GOON_FADE, TIMER_STOPPABLE | TIMER_DELETE_ME) - -/// The body fades away, unless a posting holds it for the pad. Taken away, not destroyed: no proof of death. -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_fade_out() - kingpin_fade_timer = null - if(QDELETED(src) || kingpin_posting()) - return - ADD_TRAIT(src, TRAIT_BOUNTY_REMOVED, BOUNTY_KINGPIN_TRAIT) - pulledby?.stop_pulling() - animate(src, alpha = 0, time = BOUNTY_GOON_FADE_OUT) - QDEL_IN(src, BOUNTY_GOON_FADE_OUT) +/// A posting let go of him in his lounge: his people see to him. The cuffs come off (onto the floor); anything else he is in, crit included, he gets over in his own time. +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_back_to_business() + if(handcuffed || legcuffed) + uncuff() /** * Takes him back to his sofa when he's been moved off it and is free again: a step at a time within - * his crew's leash, a walk from further off, and put straight back from another level or too far to - * walk, when nobody is watching him (L5). + * his crew's leash, a real walk from further off, and put straight back from another level or too + * far to walk only when no player is near enough to see it (human_npc_watched(), CB-19, L5). */ -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_go_home() +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_go_home() var/turf/seat = kingpin_crew?.crew_seat var/turf/here = get_turf(src) if(!seat || !here || here == seat || buckled || !kingpin_able() || !isturf(loc) || pulledby) return FALSE if(here.z == seat.z && get_dist(here, seat) <= BOUNTY_GOON_LEASH) var/turf/next = get_step_to(src, seat) - if(next) + if(next && body_move_allowed(next)) Move(next, get_dir(src, next)) return TRUE if(here.z == seat.z && get_dist(here, seat) <= BOUNTY_KINGPIN_WALK_HOME_MAX) if(world.time >= kingpin_crew.crew_next_home_walk) kingpin_crew.crew_next_home_walk = world.time + BOUNTY_KINGPIN_WALK_HOME_GAP - GLOB.move_manager.jps_move(src, seat, delay = 3, timeout = BOUNTY_KINGPIN_WALK_HOME_GAP, repath_delay = 2 SECONDS, max_path_length = BOUNTY_KINGPIN_WALK_HOME_MAX * 2, simulated_only = TRUE, priority = MOVEMENT_ABOVE_SPACE_PRIORITY) + GLOB.move_manager.jps_move(src, seat, delay = max(3, cached_multiplicative_slowdown), timeout = BOUNTY_KINGPIN_WALK_HOME_GAP, repath_delay = 2 SECONDS, max_path_length = BOUNTY_KINGPIN_WALK_HOME_MAX * 2, simulated_only = TRUE, priority = MOVEMENT_ABOVE_SPACE_PRIORITY) return TRUE - for(var/mob/living/watcher in viewers(world.view, src)) - if(watcher.client && watcher != src) - return FALSE + if(human_npc_watched(src)) + return FALSE forceMove(seat) return kingpin_sit() /// Sits him on the sofa at his seat, facing the way it faces. TRUE if he is sitting there now. -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_sit() +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_sit() if(buckled) return istype(buckled, /obj/structure/chair) - if(stat != CONSCIOUS || downed || is_restrained() || body_is_stunned()) + if(stat != CONSCIOUS || is_downed() || is_restrained() || body_is_stunned()) return FALSE var/turf/seat = kingpin_crew?.crew_seat || get_turf(src) if(get_turf(src) != seat) @@ -438,30 +456,30 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) // ===== TALKING ===== /// Whether he'll talk now: awake, free, on his feet, and no shootout on -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_can_talk() - if(stat != CONSCIOUS || downed || is_restrained() || body_is_stunned()) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_can_talk() + if(stat != CONSCIOUS || is_downed() || is_restrained() || body_is_stunned() || npc_surrendering) return FALSE return kingpin_crew?.crew_state == BOUNTY_KINGPIN_CALM /// Whether `user` is close enough to talk to him: across the table, in sight, awake -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_in_talk_range(mob/living/user) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_in_talk_range(mob/living/user) if(!isliving(user) || QDELETED(user) || user.stat != CONSCIOUS || user.z != z) return FALSE return get_dist(src, user) <= BOUNTY_KINGPIN_TALK_RANGE && can_see(user, src, BOUNTY_KINGPIN_TALK_RANGE) /// The radial's validity check -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_talk_check(mob/living/user) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_talk_check(mob/living/user) return kingpin_can_talk() && kingpin_in_talk_range(user) /// Whether `user`'s crew has a live reason to confront him: his posting is up and open, and their ship took it from the board -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_confrontable(mob/living/user) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_confrontable(mob/living/user) var/datum/criminal_bounty/kingpin/posting = kingpin_posting() if(!posting?.is_open()) return FALSE return posting.is_hunting(get_crew_ship(user)) /// The talk radial for `user`. "We're here for you" and "Walk away" only while their crew is hunting him; "I'll take it" only while he has offered their crew his job. Sleeps. -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_open_talk(mob/living/user) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_open_talk(mob/living/user) if(!kingpin_talk_check(user)) return var/list/options = list() @@ -487,7 +505,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) * starts, his job is offered or taken, or nothing happens. Returns TRUE if he listened. Making a job * can sleep. */ -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_talk(mob/living/user, option) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_talk(mob/living/user, option) if(!kingpin_can_talk() || QDELETED(user)) return FALSE bounty_kingpin_hunter_says(user, option) @@ -508,7 +526,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) return TRUE /// Shown a warrant or reached for: his confront line, and no fight -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_confronted(mob/living/user) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_confronted(mob/living/user) if(!kingpin_can_talk() || QDELETED(user)) return bounty_say("confront", force = TRUE) @@ -516,7 +534,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) // ===== HIS BUSINESS ===== /// The name he goes by on his jobs: his alias, else his name ("The Accountant") -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_job_name() +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_job_name() return capitalize(record?.alias || record?.name || name) /** @@ -525,7 +543,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) * fought his people, someone is already running his job, or he has none to give. May make his job, * which can sleep. */ -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_work_refusal(mob/living/user) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_work_refusal(mob/living/user) var/datum/bounty_kingpin_crew/crew = kingpin_crew if(!crew) return "no_work" @@ -546,7 +564,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) return null /// "Got any work?": he offers `user`'s crew the job he holds, for BOUNTY_KINGPIN_OFFER_TIME, or says why not. Returns TRUE if he offered it. Sleeps. -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_offer_work(mob/living/user) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_offer_work(mob/living/user) var/refusal = kingpin_work_refusal(user) var/datum/bounty_kingpin_crew/crew = kingpin_crew if(QDELETED(src) || !crew) @@ -566,7 +584,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) * (SSbounty_kingpin.kingpin_bind()): none of them can hunt him or turn him in. He makes another job * if the round's limit allows. Returns the job, or null. Sleeps. */ -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_take_job(mob/living/user) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_take_job(mob/living/user) var/datum/bounty_kingpin_crew/crew = kingpin_crew var/obj/structure/overmap/ship/ship = get_crew_ship(user) var/datum/mission/job = crew?.job() @@ -605,29 +623,32 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) // ===== HIS REVOLVER ===== -/// His revolver: the one in his hand, whose rounds and cylinder are his (bounty_real_weapon()) -/proc/bounty_kingpin_revolver() - return bounty_real_weapon(BOUNTY_KINGPIN_REVOLVER) - -/// Whether he can shoot now: awake, not down, not cuffed, not stunned, not given up -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_able() - if(stat != CONSCIOUS || downed || is_restrained() || body_is_stunned()) +/// Whether he can shoot now: awake, not in crit, not cuffed, not stunned, not lying there having given up, hands free +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_able() + if(stat != CONSCIOUS || is_downed() || is_restrained() || body_is_stunned() || npc_surrendering) return FALSE - return !HAS_TRAIT(src, TRAIT_INCAPACITATED) + return !HAS_TRAIT(src, TRAIT_INCAPACITATED) && !HAS_TRAIT(src, TRAIT_HANDS_BLOCKED) -/// He thumbs the hammer back and aims at `target`: a visible line for BOUNTY_KINGPIN_REVOLVER_AIM, then the shot -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_start_aim(mob/living/target) +/// He thumbs the hammer back and aims at `target`: a visible line for BOUNTY_KINGPIN_REVOLVER_AIM, then the shot. Needs a loaded gun in his hand. +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_start_aim(mob/living/target) kingpin_cancel_aim() + if(!human_npc_loaded_gun(src)) + return FALSE kingpin_next_aim_at = world.time + BOUNTY_KINGPIN_REVOLVER_COOLDOWN kingpin_aim_target = WEAKREF(target) var/atom/aim_at = kingpin_crew?.shot_target(target) || target + face_atom(aim_at) kingpin_aim_beam = Beam(aim_at, icon_state = "infrared", time = BOUNTY_KINGPIN_REVOLVER_AIM, beam_color = COLOR_RED) visible_message(span_danger("[src] thumbs the hammer back and aims at [target]!"), vision_distance = BOUNTY_KINGPIN_SIGHT) playsound(src, 'sound/items/weapons/gun/general/ballistic_click.ogg', 60, TRUE) kingpin_aim_timer = addtimer(CALLBACK(src, PROC_REF(kingpin_fire)), BOUNTY_KINGPIN_REVOLVER_AIM, TIMER_STOPPABLE | TIMER_DELETE_ME) + return TRUE -/// The aim is done: he fires if he still can and still sees them. A stun in the meantime spoils it. -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_fire() +/** + * The aim is done: he pulls the trigger of the revolver in his hand, if he still can, still sees them + * and nobody he isn't fighting stands in the line. A stun in the meantime spoils it. + */ +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_fire() kingpin_aim_timer = null var/mob/living/target = kingpin_aim_target?.resolve() kingpin_aim_target = null @@ -641,32 +662,45 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) return FALSE if(!crew.valid_target(target) || !bounty_kingpin_clear_shot(src, target)) return FALSE - kingpin_rounds-- - bounty_kingpin_shoot(src, crew.shot_target(target), bounty_kingpin_revolver(), crew) + var/atom/aim_at = crew.shot_target(target) + if(crew.line_blocked(src, aim_at)) + return FALSE + var/obj/item/gun/gun = human_npc_loaded_gun(src) + if(!gun) + return FALSE + return crew.pull_trigger(src, gun, aim_at) + +/// A hit while he aims: the shot is spoiled +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_fumble() + if(!kingpin_aim_timer) + return FALSE + kingpin_cancel_aim() + if(stat == CONSCIOUS) + visible_message(span_notice("[src] fumbles the shot."), vision_distance = COMBAT_MESSAGE_RANGE) return TRUE /// Drops his aim, if he has one -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_cancel_aim() +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_cancel_aim() if(kingpin_aim_timer) deltimer(kingpin_aim_timer) kingpin_aim_timer = null kingpin_aim_target = null QDEL_NULL(kingpin_aim_beam) -/// He reloads: BOUNTY_KINGPIN_REVOLVER_RELOAD with nothing fired, a window for the hunters -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_reload() - kingpin_rounds = bounty_kingpin_revolver().magazine - kingpin_next_aim_at = world.time + BOUNTY_KINGPIN_REVOLVER_RELOAD +/// His reload starts (his AI's reload, the player's way: a speedloader into the cylinder): his line, and the room hears him ask for cover +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_reload_tell() + kingpin_cancel_aim() visible_message(span_notice("[src] breaks open [p_their()] revolver and reloads."), vision_distance = COMBAT_MESSAGE_RANGE) - playsound(src, 'sound/items/weapons/gun/revolver/load_bullet.ogg', 50, TRUE) INVOKE_ASYNC(src, TYPE_PROC_REF(/mob/living, bounty_say), "reload") -/// He picks who to shoot among `visible`: whoever hit him most, else the nearest -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_choose_target(list/visible) +/// He picks who to shoot among `visible`: whoever hit him most, else the nearest, among those he has a clear line to +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_choose_target(list/visible) var/mob/living/best var/best_hits = -1 var/best_dist = INFINITY for(var/mob/living/candidate as anything in visible) + if(kingpin_crew?.line_blocked(src, kingpin_crew.shot_target(candidate))) + continue var/hits = kingpin_hits[candidate.weak_reference] || 0 var/dist = get_dist(src, candidate) if(hits > best_hits || (hits == best_hits && dist < best_dist)) @@ -676,48 +710,51 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) return best /// Someone hit him: they count toward who he shoots first -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_note_hit(mob/living/attacker) +/mob/living/carbon/human/npc/bounty_criminal/kingpin/proc/kingpin_note_hit(mob/living/attacker) if(!isliving(attacker)) return var/datum/weakref/ref = WEAKREF(attacker) kingpin_hits[ref] = (kingpin_hits[ref] || 0) + 1 -// ===== GIVING UP ===== +// ===== GIVING UP (CB-14) ===== /** - * After a hit that got through: with his crew down and his health at or below - * BOUNTY_KINGPIN_SURRENDER_BELOW percent, he may give up. BOUNTY_KINGPIN_SURRENDER_FIRST on the hit - * that crosses the line, BOUNTY_KINGPIN_SURRENDER_LATER on later hits, one roll per - * BOUNTY_KINGPIN_SURRENDER_GAP. Never while rallying. Doesn't sleep. + * His surrender rules for the human NPC base's surrender subtree: only once his crew is down (no goon + * still in the fight) and he is at or below BOUNTY_KINGPIN_SURRENDER_BELOW percent of his health, with + * a hunter in sight. BOUNTY_KINGPIN_SURRENDER_FIRST on his first roll, BOUNTY_KINGPIN_SURRENDER_LATER + * after, one roll per BOUNTY_KINGPIN_SURRENDER_GAP. He holsters the revolver, says his line, puts his + * hands up and runs tg's *surrender; then tg's cuffs. He never runs from the sofa. */ -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_consider_surrender(health_before) - if(stat != CONSCIOUS || downed || is_restrained() || HAS_TRAIT(src, TRAIT_BOUNTY_SURRENDERED) || body_is_rallying()) - return FALSE - if(!kingpin_crew?.crew_down()) - return FALSE - var/line = maxHealth * BOUNTY_KINGPIN_SURRENDER_BELOW / 100 - if(health > line) - return FALSE - var/chance = BOUNTY_KINGPIN_SURRENDER_FIRST - if(health_before <= line) - if(world.time < kingpin_next_surrender_roll) - return FALSE - chance = BOUNTY_KINGPIN_SURRENDER_LATER - kingpin_next_surrender_roll = world.time + BOUNTY_KINGPIN_SURRENDER_GAP - if(!prob(chance)) +/datum/human_npc_surrender/bounty_kingpin + chance = BOUNTY_KINGPIN_SURRENDER_FIRST + retry_chance = BOUNTY_KINGPIN_SURRENDER_LATER + ally_penalty = 0 + health_share = BOUNTY_KINGPIN_SURRENDER_BELOW / 100 + hostiles_needed = 1 + range = BOUNTY_KINGPIN_SIGHT + retry_delay = BOUNTY_KINGPIN_SURRENDER_GAP + flees = FALSE + +/datum/human_npc_surrender/bounty_kingpin/hurt_enough(mob/living/carbon/human/npc/npc) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = npc + if(!istype(kingpin) || !kingpin.kingpin_crew?.crew_down()) return FALSE - kingpin_surrender() - return TRUE + return ..() -/// He gives up: P2 reads it as stunned, so he can be cuffed, and he fires no more -/mob/living/basic/bounty_criminal/kingpin/proc/kingpin_surrender() - if(HAS_TRAIT(src, TRAIT_BOUNTY_SURRENDERED)) +// Who he gives up to: the hunters his crew is fighting that he can see +/datum/human_npc_surrender/bounty_kingpin/hostiles_near(mob/living/carbon/human/npc/npc) + . = list() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = npc + var/datum/bounty_kingpin_crew/crew = istype(kingpin) ? kingpin.kingpin_crew : null + if(!crew) return - kingpin_cancel_aim() - ADD_TRAIT(src, TRAIT_BOUNTY_SURRENDERED, BOUNTY_TRAIT) - body_note_state() - visible_message(span_notice("[src] puts [p_their()] hands up."), vision_distance = BOUNTY_KINGPIN_SIGHT) - INVOKE_ASYNC(src, TYPE_PROC_REF(/mob/living, bounty_say), "surrender", null, TRUE) + for(var/mob/living/hunter as anything in crew.live_hunters()) + if(can_see(npc, hunter, range)) + . += hunter + +// His crew is down by the time he thinks about it: nobody's left to count +/datum/human_npc_surrender/bounty_kingpin/allies_near(mob/living/carbon/human/npc/npc) + return list() // ========================================================================= // THE GOONS @@ -726,42 +763,23 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) /** * # Kingpin goon * - * One of the kingpin's crew: not a bounty, pays nothing, carries nothing. Before a shootout they - * idle at their posts (smoke, drink, murmur, watch the room); in one, their crew - * (/datum/bounty_kingpin_crew) moves them and fires their simulated guns. Turrets leave them alone - * (FACTION_TURRET). Their bodies fade after BOUNTY_GOON_FADE. + * One of the kingpin's crew: not a bounty, pays nothing. A real human in a suit and an armour vest, + * with a real gun and its spares carried on the body (the subtype picks which: three pistols, two + * shotguns and an SMG in the lounge). Their gear is locked to them (D3), so none of it is loot. Before + * a shootout they idle at their posts (smoke, drink, murmur, watch the room); in one, their crew + * (/datum/bounty_kingpin_crew) picks their targets, moves them, and pulls the triggers of the guns + * in their hands through their AI controllers; their own AI reloads, breaks free, crawls in crit and + * walks out. Turrets leave them alone (FACTION_TURRET). Their bodies go with the human NPC corpse sweep. */ -/mob/living/basic/bounty_kingpin_goon +/mob/living/carbon/human/npc/bounty_kingpin_goon name = "goon" - desc = "One of the kingpin's people. Good suit, bad attitude." - icon = 'icons/mob/simple/simple_human.dmi' - unique_name = FALSE - maxHealth = BOUNTY_GOON_HEALTH - health = BOUNTY_GOON_HEALTH - speed = 1 - mob_biotypes = MOB_ORGANIC | MOB_HUMANOID - mob_size = MOB_SIZE_HUMAN - sentience_type = SENTIENCE_BOSS + npc_name = "goon" faction = list(FACTION_BOUNTY_KINGPIN, FACTION_TURRET) - density = TRUE - move_resist = MOVE_FORCE_VERY_STRONG - // The body stays until it fades; nothing drops - basic_mob_flags = NONE - status_flags = CANPUSH | CANSTUN | CANKNOCKDOWN - // P2's pattern: a pool of 100 and a coefficient, or the stamcrit ends the moment it starts (M1) - max_stamina = BOUNTY_GOON_MAX_STAMINA - stamina_crit_threshold = BOUNTY_GOON_STAMCRIT_AT - mobility_flags = MOBILITY_FLAGS_REST_CAPABLE_DEFAULT - rotate_on_lying = TRUE - blood_volume = BLOOD_VOLUME_NORMAL - unsuitable_atmos_damage = 0 - unsuitable_cold_damage = 0 - unsuitable_heat_damage = 0 - death_message = "seizes up and falls limp, their eyes dead and lifeless..." - response_help_continuous = "taps" - response_help_simple = "tap" - ai_controller = null - /// BOUNTY_GOON_WEAPON_* + ai_controller = /datum/ai_controller/basic_controller/human_npc/bounty_kingpin_goon + npc_outfit_table = /datum/human_npc_outfit_table/bounty + // Like the criminals, his people never shoot someone who is down (defaults 1.13) + npc_target_stat = HUMAN_NPC_SPARES_DOWNED + /// BOUNTY_GOON_WEAPON_*: what they carry var/goon_weapon = BOUNTY_GOON_WEAPON_PISTOL /// Where they stand, or sit, when there is no fight var/turf/goon_post @@ -771,9 +789,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) var/datum/weakref/goon_crew_ref /// Weakref to who they are shooting at var/datum/weakref/goon_target_ref - /// Rounds (or shells) left before a reload - var/goon_rounds = 0 - /// world.time they may fire next + /// world.time they may pull the trigger next var/goon_next_fire_at = 0 /// world.time a fumble ends var/goon_fumbled_until = 0 @@ -781,70 +797,56 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) var/goon_windup_timer /// world.time of their next step var/goon_next_move_at = 0 - /// Running away: he fell and they don't want to die for him + /// Running away: he fell and they don't want to die for him (they walk out, npc_walk_out()) var/goon_fleeing = FALSE - /// Walking out: their crew is gone - var/goon_leaving = FALSE - /// Their gun is out (their worn look) - var/goon_armed = FALSE - /// Which of the look pool's faces they have - var/goon_look_number = 1 - /// The timer fading their body out - var/goon_fade_timer /// Weakref to the chair at their post, if they sit var/datum/weakref/goon_chair_ref -/mob/living/basic/bounty_kingpin_goon/Initialize(mapload) +/mob/living/carbon/human/npc/bounty_kingpin_goon/pistol + +/mob/living/carbon/human/npc/bounty_kingpin_goon/smg + goon_weapon = BOUNTY_GOON_WEAPON_SMG + +/mob/living/carbon/human/npc/bounty_kingpin_goon/shotgun + goon_weapon = BOUNTY_GOON_WEAPON_SHOTGUN + +/// The goon type that carries `weapon` (BOUNTY_GOON_WEAPON_*) +/proc/bounty_kingpin_goon_type(weapon) + switch(weapon) + if(BOUNTY_GOON_WEAPON_SMG) + return /mob/living/carbon/human/npc/bounty_kingpin_goon/smg + if(BOUNTY_GOON_WEAPON_SHOTGUN) + return /mob/living/carbon/human/npc/bounty_kingpin_goon/shotgun + return /mob/living/carbon/human/npc/bounty_kingpin_goon/pistol + +/mob/living/carbon/human/npc/bounty_kingpin_goon/Initialize(mapload, datum/human_npc_order/order) . = ..() - // Their own copy: 5 disabler hits (30 each) fill the pool of BOUNTY_GOON_MAX_STAMINA - damage_coeff = damage_coeff.Copy() - damage_coeff[STAMINA] = BOUNTY_GOON_MAX_STAMINA / BOUNTY_GOON_HEALTH - gender = prob(75) ? MALE : FEMALE - goon_look_number = random_outpost_npc_look_number() add_traits(list(TRAIT_NO_TELEPORT, TRAIT_NOMOBSWAP), BOUNTY_KINGPIN_TRAIT) - AddElement(/datum/element/relay_attackers) - AddElement(/datum/element/footstep, footstep_type = FOOTSTEP_MOB_SHOE) - INVOKE_ASYNC(src, PROC_REF(goon_dress)) -/mob/living/basic/bounty_kingpin_goon/Destroy() +/mob/living/carbon/human/npc/bounty_kingpin_goon/Destroy() goon_cancel_windup() - deltimer(goon_fade_timer) - goon_fade_timer = null goon_post = null goon_crew_ref = null goon_target_ref = null goon_chair_ref = null return ..() +// The outfit table asks what they wear: the suit and vest, and the gun of their post with its spares +/mob/living/carbon/human/npc/bounty_kingpin_goon/bounty_build_outfit(zone) + switch(goon_weapon) + if(BOUNTY_GOON_WEAPON_SMG) + return /datum/outfit/bounty_kingpin_goon/smg + if(BOUNTY_GOON_WEAPON_SHOTGUN) + return /datum/outfit/bounty_kingpin_goon/shotgun + return /datum/outfit/bounty_kingpin_goon/pistol + /// Their crew, if it still exists -/mob/living/basic/bounty_kingpin_goon/proc/goon_crew() +/mob/living/carbon/human/npc/bounty_kingpin_goon/proc/goon_crew() var/datum/bounty_kingpin_crew/crew = goon_crew_ref?.resolve() return QDELETED(crew) ? null : crew -/// Puts their look on: at ease, or with their gun out. Sleeps. -/mob/living/basic/bounty_kingpin_goon/proc/goon_dress() - var/outfit = /datum/outfit/bounty_kingpin_goon - if(goon_armed) - switch(goon_weapon) - if(BOUNTY_GOON_WEAPON_SMG) - outfit = /datum/outfit/bounty_kingpin_goon/smg - if(BOUNTY_GOON_WEAPON_SHOTGUN) - outfit = /datum/outfit/bounty_kingpin_goon/shotgun - else - outfit = /datum/outfit/bounty_kingpin_goon/pistol - set_outpost_npc_look(src, outfit, gender, goon_look_number) - if(!QDELETED(src)) - update_appearance(UPDATE_OVERLAYS) - -/// Their gun comes out, or goes away -/mob/living/basic/bounty_kingpin_goon/proc/goon_arm(armed) - if(goon_armed == armed) - return - goon_armed = armed - INVOKE_ASYNC(src, PROC_REF(goon_dress)) - /// Says a line from the goons' dialogue, out loud or under their breath -/mob/living/basic/bounty_kingpin_goon/proc/goon_say(context, whisper = FALSE) +/mob/living/carbon/human/npc/bounty_kingpin_goon/proc/goon_say(context, whisper = FALSE) if(stat != CONSCIOUS) return FALSE var/line = bounty_kingpin_line("goon", context) @@ -856,110 +858,230 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) say(line, forced = "bounty kingpin goon") return TRUE -/// Whether they can fight now: awake, on their feet, not stunned, not leaving -/mob/living/basic/bounty_kingpin_goon/proc/goon_able() - if(stat != CONSCIOUS || goon_fleeing || goon_leaving) +/// Whether they can fight now: awake, on their feet, hands free, not cuffed, not running, not leaving +/mob/living/carbon/human/npc/bounty_kingpin_goon/proc/goon_able() + if(stat != CONSCIOUS || goon_fleeing || !isnull(npc_exit)) + return FALSE + if(HAS_TRAIT(src, TRAIT_RESTRAINED) || HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)) return FALSE return !HAS_TRAIT(src, TRAIT_INCAPACITATED) && !HAS_TRAIT(src, TRAIT_FLOORED) /// Drops a burst or a blast that was winding up -/mob/living/basic/bounty_kingpin_goon/proc/goon_cancel_windup() +/mob/living/carbon/human/npc/bounty_kingpin_goon/proc/goon_cancel_windup() if(goon_windup_timer) deltimer(goon_windup_timer) goon_windup_timer = null -/// A goon's gun by BOUNTY_GOON_WEAPON_*: the one in his hand, loaded as it is (bounty_real_weapon()) -/proc/bounty_kingpin_goon_gun(weapon) - switch(weapon) - if(BOUNTY_GOON_WEAPON_SMG) - return bounty_real_weapon(BOUNTY_GOON_SMG_GUN) - if(BOUNTY_GOON_WEAPON_SHOTGUN) - return bounty_real_weapon(BOUNTY_GOON_SHOTGUN_GUN, BOUNTY_GOON_SHOTGUN_AMMO) - return bounty_real_weapon(BOUNTY_GOON_PISTOL_GUN) - -/// A full magazine (or tube) for their gun -/proc/bounty_kingpin_goon_mag(weapon) - var/datum/bounty_real_weapon/gun = bounty_kingpin_goon_gun(weapon) - return gun.magazine - -/// How long their gun takes to reload -/proc/bounty_kingpin_goon_reload(weapon) - switch(weapon) - if(BOUNTY_GOON_WEAPON_SMG) - return BOUNTY_GOON_SMG_RELOAD - if(BOUNTY_GOON_WEAPON_SHOTGUN) - return BOUNTY_GOON_SHOTGUN_RELOAD - return BOUNTY_GOON_PISTOL_RELOAD +/mob/living/carbon/human/npc/bounty_kingpin_goon/examine(mob/user) + . = ..() + if(stat == DEAD || human_npc_held_gun(src)) + return + . += span_notice("[p_They()] keep[p_s()] a hand near [p_their()] jacket.") -/mob/living/basic/bounty_kingpin_goon/examine(mob/user) +// Killed in a chair, they slump out of it +/mob/living/carbon/human/npc/bounty_kingpin_goon/death(gibbed) + goon_cancel_windup() . = ..() - if(stat == DEAD) + if(QDELETED(src) || stat != DEAD) return - if(goon_armed) - . += span_warning("[p_They()] [p_have()] a gun out.") - else - . += span_notice("[p_They()] keep[p_s()] a hand near [p_their()] jacket.") + if(istype(buckled, /obj/structure/chair)) + buckled.unbuckle_mob(src, force = TRUE) -// Hurt while their crew is at ease, by anything at all: the crew finds out who (H1) -/mob/living/basic/bounty_kingpin_goon/adjust_health(amount, updating_health = TRUE, forced = FALSE) +/** + * They broke someone's hold on them by resisting (the human NPC base's reactions): the grab answer + * (CB-22). A word, the grabber told, and a real shove if they're still in reach and have a hand free. + */ +/mob/living/carbon/human/npc/bounty_kingpin_goon/npc_check_pulled_free(atom/movable/holder, within = 0) + var/mob/living/grabber = npc_resisted_hold?.resolve() + var/freed = npc_resisted_at && world.time <= npc_resisted_at + within && (!holder || grabber == holder) . = ..() - if(amount > 0 && !forced) - goon_crew()?.member_hurt(src) + if(!freed || !isliving(grabber) || QDELETED(grabber) || stat != CONSCIOUS) + return + INVOKE_ASYNC(src, PROC_REF(goon_shove_off), grabber) + +/// "Hands off.", and a shove for `grabber`. Sleeps. +/mob/living/carbon/human/npc/bounty_kingpin_goon/proc/goon_shove_off(mob/living/grabber) + if(QDELETED(src) || QDELETED(grabber) || stat != CONSCIOUS) + return + balloon_alert(grabber, "[p_they()] shove[p_s()] you off!") + goon_say("shoved") + bounty_kingpin_shove(src, grabber) -// Alive, they don't get dragged off anywhere; a body can be. -/mob/living/basic/bounty_kingpin_goon/can_be_pulled(user, force) - if(stat != DEAD) - if(ismob(user)) - balloon_alert(user, "[p_they()] shove[p_s()] you off!") +/** + * `shover` gives `target` a real shove: an empty hand, a right click on them, tg's shove (a step back, + * or a stagger against something solid). Nothing if they're out of reach or both hands are full. + * Returns TRUE if it was tried. + */ +/proc/bounty_kingpin_shove(mob/living/carbon/human/shover, mob/living/target) + if(QDELETED(shover) || QDELETED(target) || !shover.Adjacent(target) || !shover.ai_controller) return FALSE - return ..() + if(HAS_TRAIT(shover, TRAIT_HANDS_BLOCKED) || HAS_TRAIT(shover, TRAIT_INCAPACITATED)) + return FALSE + if(!human_npc_ready_empty_hand(shover)) + return FALSE + INVOKE_ASYNC(shover.ai_controller, TYPE_PROC_REF(/datum/ai_controller, ai_interact), target, TRUE, list(RIGHT_CLICK = TRUE)) + return TRUE -// Out of a chair while down or dead, they lie flat as the criminals do -/mob/living/basic/bounty_kingpin_goon/set_lying_down(new_lying_angle) - . = ..() - bounty_body_lie_flat(src, new_lying_angle) +// ===== THEIR HANDS AND THEIR GUNS ===== -// A goon's body stays for BOUNTY_GOON_FADE, then fades. Nothing drops. -/mob/living/basic/bounty_kingpin_goon/death(gibbed) - goon_cancel_windup() - . = ..() - if(QDELETED(src)) - return - // A chair holds a body upright: they slump out of it - if(istype(buckled, /obj/structure/chair)) - buckled.unbuckle_mob(src, force = TRUE) - // A body can be dragged about - move_resist = MOVE_RESIST_DEFAULT - deltimer(goon_fade_timer) - goon_fade_timer = addtimer(CALLBACK(src, PROC_REF(goon_fade_out)), BOUNTY_GOON_FADE, TIMER_STOPPABLE | TIMER_DELETE_ME) - -/// Their body fades away -/mob/living/basic/bounty_kingpin_goon/proc/goon_fade_out() - goon_fade_timer = null - if(QDELETED(src)) +/// A gun `npc` carries on its body and can draw in a moment (holster, belt, suit storage, back, a pocket): a loaded one first +/proc/bounty_kingpin_carried_gun(mob/living/carbon/npc) + var/obj/item/gun/found + for(var/obj/item/gun/gun in npc.get_all_contents_type(/obj/item/gun)) + if(npc.is_holding(gun) || !human_npc_can_draw(npc, gun)) + continue + if(gun.can_shoot()) + return gun + found ||= gun + return found + +/// `npc` draws its gun into a free hand, as a person does, and readies it. Returns the gun in its hand, or null. +/proc/bounty_kingpin_draw_gun(mob/living/carbon/npc) + var/obj/item/gun/gun = human_npc_held_gun(npc) + if(gun) + return gun + if(HAS_TRAIT(npc, TRAIT_HANDS_BLOCKED) || HAS_TRAIT(npc, TRAIT_INCAPACITATED)) + return null + gun = bounty_kingpin_carried_gun(npc) + if(!gun || !human_npc_take_in_hand(npc, gun)) + return null + human_npc_ready_weapon(npc, gun) + human_npc_ready_item(npc, gun) + return gun + +/// `npc` puts the guns in its hands away on its body (D3: never on the floor) +/proc/bounty_kingpin_holster_guns(mob/living/carbon/npc) + for(var/obj/item/gun/gun in npc.held_items) + gun.equip_to_best_slot(npc) + +/// Tells `member`'s AI whether its crew's guns are out, so a spent one gets reloaded (and a holstered one drawn again) +/proc/bounty_kingpin_set_armed(mob/living/member, armed) + var/datum/ai_controller/controller = member?.ai_controller + if(!controller) return - pulledby?.stop_pulling() - animate(src, alpha = 0, time = BOUNTY_GOON_FADE_OUT) - addtimer(CALLBACK(src, PROC_REF(goon_gone)), BOUNTY_GOON_FADE_OUT, TIMER_DELETE_ME) + if(armed) + controller.set_blackboard_key(BB_BOUNTY_KINGPIN_ARMED, TRUE) + else + controller.clear_blackboard_key(BB_BOUNTY_KINGPIN_ARMED) + controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) -/mob/living/basic/bounty_kingpin_goon/proc/goon_gone() - qdel(src) +// ========================================================================= +// THEIR AI +// ========================================================================= /** - * They leave: their crew is gone (the posting closed), or they ran. They walk toward `exit` and fade - * out after `time`. Nobody can hurt them on the way out. A body is left to fade on its own. + * The kingpin's own AI: what his body does by itself. His crew aims and fires for him. First the human + * NPC base's soft crit and breaking free (never out of his sofa: P2's bounty_escape_captivity leaves + * a chair he sat in alone), then giving up (his surrender rules), keeping his revolver loaded while the + * guns are out, and his medipen when he is hurt and nobody is on him. He doesn't wander. */ -/mob/living/basic/bounty_kingpin_goon/proc/goon_leave(turf/exit, time = BOUNTY_GOON_LEAVE_TIME) - if(goon_leaving || stat == DEAD || QDELETED(src)) +/datum/ai_controller/basic_controller/human_npc/bounty_kingpin + idle_behavior = null + planning_subtrees = list( + /datum/ai_planning_subtree/human_npc_soft_crit, + /datum/ai_planning_subtree/bounty_escape_captivity, + /datum/ai_planning_subtree/human_npc_surrender, + /datum/ai_planning_subtree/bounty_kingpin_crew_arms, + /datum/ai_planning_subtree/bounty_treat_self, + ) + +/** + * A goon's own AI: soft crit, breaking free of cuffs, carriers and hard grabs (P2's), the grab answer + * for anyone else holding them (CB-22), walking out when they leave, and keeping their gun loaded while + * the guns are out. Their crew does the rest. They don't wander. + */ +/datum/ai_controller/basic_controller/human_npc/bounty_kingpin_goon + idle_behavior = null + planning_subtrees = list( + /datum/ai_planning_subtree/human_npc_soft_crit, + /datum/ai_planning_subtree/bounty_escape_captivity, + /datum/ai_planning_subtree/bounty_kingpin_goon_grabbed, + /datum/ai_planning_subtree/human_npc_walk_out, + /datum/ai_planning_subtree/bounty_kingpin_crew_arms, + ) + +/// Held by anyone outside the crew, even a gentle pull: they resist, and break free with a word and a shove (npc_check_pulled_free()) +/datum/ai_planning_subtree/bounty_kingpin_goon_grabbed + +/datum/ai_planning_subtree/bounty_kingpin_goon_grabbed/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = controller.pawn + if(!istype(goon) || goon.stat != CONSCIOUS || HAS_TRAIT(goon, TRAIT_RESTRAINED)) return - goon_leaving = TRUE - goon_cancel_windup() - goon_target_ref = null - ADD_TRAIT(src, TRAIT_GODMODE, BOUNTY_KINGPIN_TRAIT) - buckled?.unbuckle_mob(src, force = TRUE) - if(exit && isturf(loc)) - GLOB.move_manager.jps_move(src, exit, delay = BOUNTY_GOON_STEP, timeout = time, repath_delay = 2 SECONDS, max_path_length = 60, simulated_only = TRUE, priority = MOVEMENT_ABOVE_SPACE_PRIORITY) - addtimer(CALLBACK(src, PROC_REF(goon_fade_out)), time, TIMER_DELETE_ME) + var/mob/living/grabber = goon.pulledby + if(!isliving(grabber) || goon.goon_crew()?.is_member(grabber)) + return + controller.queue_behavior(/datum/ai_behavior/resist) + return SUBTREE_RETURN_FINISH_PLANNING + +/** + * While the crew's guns are out (BB_BOUNTY_KINGPIN_ARMED): a spent gun in hand is reloaded the player's + * way from the spares carried, and an empty hand draws the gun again (after giving up, say). Nothing + * while at ease: the guns stay holstered. + */ +/datum/ai_planning_subtree/bounty_kingpin_crew_arms + +/datum/ai_planning_subtree/bounty_kingpin_crew_arms/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/pawn = controller.pawn + if(pawn.stat != CONSCIOUS || HAS_TRAIT(pawn, TRAIT_HANDS_BLOCKED) || LAZYLEN(pawn.do_afters)) + return + if(!controller.blackboard[BB_BOUNTY_KINGPIN_ARMED] || world.time < controller.blackboard[BB_HUMAN_NPC_ARMING_RETRY_AT]) + return + if(ishumannpc(pawn)) + var/mob/living/carbon/human/npc/npc = pawn + if(npc.npc_surrendering) + return + var/obj/item/gun/gun = human_npc_held_gun(pawn) + if(gun?.can_shoot()) + return + if(gun) + if(!human_npc_can_reload(pawn, gun)) + return + controller.queue_behavior(/datum/ai_behavior/human_npc_reload/bounty_kingpin_crew) + return SUBTREE_RETURN_FINISH_PLANNING + var/obj/item/gun/carried = bounty_kingpin_carried_gun(pawn) + if(!carried) + return + controller.set_blackboard_key(BB_HUMAN_NPC_DRAW_ITEM, carried) + controller.queue_behavior(/datum/ai_behavior/human_npc_draw, BB_HUMAN_NPC_DRAW_ITEM) + return SUBTREE_RETURN_FINISH_PLANNING + +/** + * The human NPC base's reload (a spare from a pocket, belt or bag into the free hand, the gun clicked + * with it, racked, the empty dropped), with the crew's own line as it starts. A tube or cylinder is + * fed what it takes before it is racked, as a person feeds shells one by one. + */ +/datum/ai_behavior/human_npc_reload/bounty_kingpin_crew + give_up_after = BOUNTY_KINGPIN_RELOAD_GIVE_UP + +// Its own start instead of the base's: the same checks and give-up time, with the kingpin's or the goon's line +/datum/ai_behavior/human_npc_reload/bounty_kingpin_crew/setup(datum/ai_controller/controller) + var/mob/living/carbon/npc = controller.pawn + var/obj/item/gun/ballistic/gun = human_npc_held_gun(npc) + if(!istype(gun)) + return FALSE + controller.set_blackboard_key(BB_HUMAN_NPC_RELOAD_UNTIL, world.time + give_up_after) + if(istype(npc, /mob/living/carbon/human/npc/bounty_criminal/kingpin)) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = npc + kingpin.kingpin_reload_tell() + else + npc.visible_message(span_notice("[npc] reloads."), vision_distance = COMBAT_MESSAGE_RANGE) + return TRUE + +/datum/ai_behavior/human_npc_reload/bounty_kingpin_crew/perform(seconds_per_tick, datum/ai_controller/controller) + var/mob/living/carbon/npc = controller.pawn + var/obj/item/gun/ballistic/gun = human_npc_held_gun(npc) + // Shell by shell into a tube with room left, while there's time to rack it after + if(istype(gun) && gun.internal_magazine && gun.magazine && world.time < controller.blackboard[BB_HUMAN_NPC_RELOAD_UNTIL] - 3 SECONDS) + if(!human_npc_spent_ammo_in_hand(npc, gun) && human_npc_live_rounds(gun.magazine) < gun.magazine.max_ammo) + var/obj/item/ammo = human_npc_find_ammo(npc, gun) + if(ammo) + if(!npc.is_holding(ammo)) + if(human_npc_take_in_hand(npc, ammo)) + return AI_BEHAVIOR_DELAY + else if(human_npc_ready_item(npc, ammo)) + controller.ai_interact(target = gun, combat_mode = FALSE) + return AI_BEHAVIOR_DELAY + return ..() // ========================================================================= // HIS CREW: THE ROOM AND THE SHOOTOUT @@ -972,7 +1094,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) * shootout, and the job he holds for a crew. Owned by the kingpin and deleted with * him: it lives as long as he does, posting or none. Holds its mobs by weakref. Processes on * SSfastprocess: at ease it keeps the room lively and watches for known hunters; in a shootout it - * moves the goons and fires their guns and his. + * picks targets, moves the goons and pulls the triggers of the real guns in their hands, and his. */ /datum/bounty_kingpin_crew /// Weakref to the kingpin @@ -981,6 +1103,10 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) var/turf/crew_seat /// The goon posts he sat down with, list(list(turf, BOUNTY_GOON_WEAPON_*), ...): an empty one is filled again when he goes on the board var/list/crew_posts = list() + /// Goons on their way to a post (human NPCs are built a body at a time): post turf -> /datum/human_npc_order + var/list/crew_pending = list() + /// Build new goons at once instead of queueing them (the unit tests) + var/crew_immediate = FALSE /// The job he holds for a crew (a BOUNTY_KINGPIN_JOB mission, not yet taken), or null var/datum/mission/crew_job /// Weakref of a ship he offered crew_job to -> world.time the offer lapses @@ -991,7 +1117,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) var/crew_facing = NORTH /// Where bystanders and leaving goons go: the lounge's refuge mark, out of the room and away from the lift var/turf/crew_refuge - /// Weakrefs to the goons (/mob/living/basic/bounty_kingpin_goon) + /// Weakrefs to the goons (/mob/living/carbon/human/npc/bounty_kingpin_goon) var/list/crew_goons = list() /// Weakrefs to everyone the crew is fighting: whoever confronted him, attacked any of them, or came with them var/list/crew_hunters = list() @@ -1032,20 +1158,20 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) var/crew_next_calm_at = 0 var/crew_next_home_walk = 0 var/crew_next_table_warning = 0 - /// Shots the crew has fired (the unit tests read it) + /// Trigger pulls the crew has made (the unit tests read it) var/crew_shots = 0 -/datum/bounty_kingpin_crew/New(mob/living/basic/bounty_criminal/kingpin/kingpin, turf/seat) +/datum/bounty_kingpin_crew/New(mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin, turf/seat, immediate = FALSE) . = ..() kingpin_ref = WEAKREF(kingpin) crew_seat = seat || get_turf(kingpin) + crew_immediate = immediate var/obj/structure/chair/sofa = locate(/obj/structure/chair) in crew_seat if(sofa) crew_facing = sofa.dir GLOB.bounty_kingpin_crews += src - RegisterSignal(kingpin, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_member_attacked)) - RegisterSignal(kingpin, COMSIG_PROJECTILE_PREHIT, PROC_REF(on_member_shot)) - RegisterSignals(kingpin, list(COMSIG_BOUNTY_CRIMINAL_DOWNED, COMSIG_LIVING_DEATH, SIGNAL_ADDTRAIT(TRAIT_BOUNTY_SURRENDERED)), PROC_REF(on_boss_fell)) + watch_member(kingpin) + RegisterSignals(kingpin, list(COMSIG_BOUNTY_CRIMINAL_DOWNED, COMSIG_LIVING_DEATH, COMSIG_HUMAN_NPC_SURRENDERED), PROC_REF(on_boss_fell)) RegisterSignal(kingpin, COMSIG_BOUNTY_CRIMINAL_RESTRAINED, PROC_REF(on_boss_restrained)) crew_next_idle_at = world.time + rand(BOUNTY_GOON_IDLE_MIN, BOUNTY_GOON_IDLE_MAX) crew_next_boss_idle_at = world.time + rand(BOUNTY_KINGPIN_IDLE_MIN, BOUNTY_KINGPIN_IDLE_MAX) @@ -1054,14 +1180,22 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) /datum/bounty_kingpin_crew/Destroy() STOP_PROCESSING(SSfastprocess, src) GLOB.bounty_kingpin_crews -= src + // Goons still on their way never arrive + for(var/post in crew_pending) + qdel(crew_pending[post]) + crew_pending.Cut() // The job he held goes with him drop_job() restore_room(TRUE) - // Whoever is still standing leaves; bodies fade on their own - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in goons()) + // Whoever is still alive walks out, for real, as soon as they can; bodies are the corpse sweep's + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in goons()) goon.goon_crew_ref = null - if(goon.stat != DEAD) - goon.goon_leave(exit_turf(goon)) + goon.goon_cancel_windup() + if(goon.stat == DEAD) + continue + bounty_kingpin_set_armed(goon, FALSE) + bounty_kingpin_holster_guns(goon) + goon_walk_out(goon) crew_goons.Cut() crew_hunters.Cut() crew_hostile_ships.Cut() @@ -1080,29 +1214,43 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) crew_barkeep_ref = null return ..() +/// Listens to `member` (him or a goon) for attacks, shots from things that aren't people, and any damage at all +/datum/bounty_kingpin_crew/proc/watch_member(mob/living/member) + RegisterSignal(member, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_member_attacked)) + RegisterSignal(member, COMSIG_PROJECTILE_PREHIT, PROC_REF(on_member_shot)) + RegisterSignal(member, COMSIG_MOB_AFTER_APPLY_DAMAGE, PROC_REF(on_member_damaged)) + RegisterSignals(member, list(COMSIG_LIVING_ADJUST_BRUTE_DAMAGE, COMSIG_LIVING_ADJUST_BURN_DAMAGE), PROC_REF(on_member_adjusted)) + // ===== WHO IS WHO ===== /// The kingpin, if he still exists /datum/bounty_kingpin_crew/proc/kingpin() - RETURN_TYPE(/mob/living/basic/bounty_criminal/kingpin) - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_ref?.resolve() + RETURN_TYPE(/mob/living/carbon/human/npc/bounty_criminal/kingpin) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_ref?.resolve() return QDELETED(kingpin) ? null : kingpin /// The goons that still exist, dead or alive /datum/bounty_kingpin_crew/proc/goons() . = list() for(var/datum/weakref/ref as anything in crew_goons.Copy()) - var/mob/living/basic/bounty_kingpin_goon/goon = ref?.resolve() + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = ref?.resolve() if(QDELETED(goon)) crew_goons -= ref continue . += goon -/// The goons still in the fight: alive, not running, not leaving +/// The goons still in the fight: not dead, in crit or cuffed (human_npc_out_of_fight()), not running, not leaving /datum/bounty_kingpin_crew/proc/standing_goons() . = list() - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in goons()) - if(goon.stat != DEAD && !goon.goon_fleeing && !goon.goon_leaving) + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in goons()) + if(!goon.goon_fleeing && isnull(goon.npc_exit) && !human_npc_out_of_fight(goon)) + . += goon + +/// The goons still at their posts, whatever state they are in: alive, not running, not leaving +/datum/bounty_kingpin_crew/proc/present_goons() + . = list() + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in goons()) + if(goon.stat != DEAD && !goon.goon_fleeing && isnull(goon.npc_exit)) . += goon /// His crew is down: no goon still in the fight @@ -1115,7 +1263,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) return FALSE if(thing == kingpin()) return TRUE - var/mob/living/basic/bounty_kingpin_goon/goon = thing + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = thing return istype(goon) && goon.goon_crew_ref?.resolve() == src /// Whether the crew is fighting `who` @@ -1135,7 +1283,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) /datum/bounty_kingpin_crew/proc/add_hunter(mob/living/who) if(!isliving(who) || QDELETED(who) || is_member(who)) return FALSE - if(istype(who, /mob/living/basic/bounty_criminal) || istype(who, /mob/living/basic/bounty_companion)) + if(istype(who, /mob/living/carbon/human/npc/bounty_criminal) || istype(who, /mob/living/carbon/human/npc/bounty_companion)) return FALSE var/datum/weakref/ref = WEAKREF(who) if(ref in crew_hunters) @@ -1233,18 +1381,44 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) // ===== THE GOONS ===== -/// A goon with `weapon` at `post`, sitting if there is a chair there, facing the talk spot -/datum/bounty_kingpin_crew/proc/spawn_goon(turf/post, weapon = BOUNTY_GOON_WEAPON_PISTOL) +/** + * A goon with `weapon` (BOUNTY_GOON_WEAPON_*) for `post`, sitting if there is a chair there, facing + * the talk spot. A real human, so it goes through the human NPC spawn queue: `immediate` builds it now + * and returns it, else it is queued (one post at a time) and joins the crew when it is built, and this + * returns null. + */ +/datum/bounty_kingpin_crew/proc/spawn_goon(turf/post, weapon = BOUNTY_GOON_WEAPON_PISTOL, immediate = TRUE) if(!post) return null - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_ref?.resolve() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_ref?.resolve() var/datum/npc_spawn_context/context = new(kingpin || post, null, "ordinary", source_turf = post) - var/mob/living/basic/bounty_kingpin_goon/goon = spawn_npc_in_zone(/mob/living/basic/bounty_kingpin_goon, post, context, FALSE) + var/goon_type = bounty_kingpin_goon_type(weapon) + if(!immediate) + if(crew_pending[post]) + return null + crew_pending[post] = spawn_human_npc(goon_type, post, CALLBACK(src, PROC_REF(goon_arrived), post, weapon), context = context) + return null + var/datum/human_npc_order/order = spawn_human_npc(goon_type, post, context = context, immediate = TRUE) + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = order?.spawned_ref?.resolve() + qdel(order) + if(QDELETED(goon)) + return null + goon_joined(goon, post, weapon) + return goon + +/// A queued goon for `post` has been built: he takes his post +/datum/bounty_kingpin_crew/proc/goon_arrived(turf/post, weapon, mob/living/carbon/human/npc/bounty_kingpin_goon/goon) + crew_pending -= post + if(QDELETED(goon)) + return + goon_joined(goon, post, weapon) + +/// `goon` takes `post` with `weapon`: in its chair, or facing the talk spot, one of the crew. A fight on already: he draws. +/datum/bounty_kingpin_crew/proc/goon_joined(mob/living/carbon/human/npc/bounty_kingpin_goon/goon, turf/post, weapon) goon.goon_weapon = weapon goon.goon_post = post - goon.goon_rounds = bounty_kingpin_goon_mag(weapon) if(crew_seat && get_dist(post, crew_seat) <= 3) - goon.name = "bodyguard" + goon.fully_replace_character_name(goon.real_name, "bodyguard") var/obj/structure/chair/chair = locate(/obj/structure/chair) in post if(chair && !chair.has_buckled_mobs() && chair.buckle_mob(goon, force = TRUE)) goon.goon_chair_ref = WEAKREF(chair) @@ -1258,15 +1432,14 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) goon.goon_post_dir = facing || SOUTH goon.setDir(goon.goon_post_dir) add_goon(goon) - context.finalize() - return goon + if(is_fighting()) + goon_draw(goon) /// Makes `goon` one of the crew -/datum/bounty_kingpin_crew/proc/add_goon(mob/living/basic/bounty_kingpin_goon/goon) +/datum/bounty_kingpin_crew/proc/add_goon(mob/living/carbon/human/npc/bounty_kingpin_goon/goon) goon.goon_crew_ref = WEAKREF(src) crew_goons |= WEAKREF(goon) - RegisterSignal(goon, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_member_attacked)) - RegisterSignal(goon, COMSIG_PROJECTILE_PREHIT, PROC_REF(on_member_shot)) + watch_member(goon) /// Where hunters stand to talk to him: two tiles out from the sofa, across the table /datum/bounty_kingpin_crew/proc/talk_spot() @@ -1275,12 +1448,23 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) var/turf/front = get_step(crew_seat, crew_facing) return front ? (get_step(front, crew_facing) || front) : crew_seat +/// `goon` walks out of the lounge for real (the human NPC base's npc_walk_out()): gone at the exit, or once nobody can see him +/datum/bounty_kingpin_crew/proc/goon_walk_out(mob/living/carbon/human/npc/bounty_kingpin_goon/goon, turf/exit) + exit ||= exit_turf(goon) + if(!exit || goon.stat == DEAD) + return FALSE + goon.goon_cancel_windup() + goon.goon_target_ref = null + if(istype(goon.buckled, /obj/structure/chair)) + goon.buckled.unbuckle_mob(goon) + return goon.npc_walk_out(exit) + // ===== THE ROOM ===== /** * Finds the room around the sofa: the coffee table in front of it and the tables at the goons' posts * (breakable while he is here, and put back if missing), the barkeep who can see the - * sofa, and the refuge. + * sofa, and the refuge. Reads the posts, not the goons: they may still be on their way. */ /datum/bounty_kingpin_crew/proc/find_room() if(!crew_seat) @@ -1293,9 +1477,10 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) if(spot) coffee_spots += spot var/list/table_spots = coffee_spots.Copy() - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in goons()) + for(var/list/post as anything in crew_posts) + var/turf/post_turf = post[1] for(var/direction in GLOB.cardinals) - var/turf/spot = get_step(goon.goon_post, direction) + var/turf/spot = get_step(post_turf, direction) if(spot && !(spot in table_spots)) table_spots += spot for(var/turf/spot as anything in table_spots) @@ -1377,11 +1562,14 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) else make_table_breakable(table) -/// Somewhere out of the lounge for `mover` to walk to: the refuge mark, never the hangar lift (M5) +/// Somewhere out of the lounge for `mover` to walk to: the refuge mark, never the hangar lift (M5). With no refuge (a test room): straight on out from the sofa past them. /datum/bounty_kingpin_crew/proc/exit_turf(atom/mover) if(crew_refuge) return crew_refuge - return null + var/turf/here = get_turf(mover) + if(!crew_seat || !here || here == crew_seat || here.z != crew_seat.z) + return null + return get_ranged_target_turf_direct(crew_seat, here, BOUNTY_KINGPIN_SIGHT + BOUNTY_GOON_LEASH) // ===== HIS BUSINESS ===== @@ -1426,7 +1614,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) qdel(job) crew_job_retry_at = world.time + BOUNTY_KINGPIN_JOB_RETRY return null - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin() if(kingpin) job.author = kingpin.kingpin_job_name() job.update_text() @@ -1494,20 +1682,21 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) /** * He goes on the board with his crew at ease: every post he sat down with whose goon is dead or gone - * (fled, walked out) gets a new goon. Nothing mid-fight. Returns the goons it placed. + * (fled, walked out) gets a new goon, through the human NPC spawn queue (at once in the tests). + * Nothing mid-fight. Returns the goons it placed at once. */ /datum/bounty_kingpin_crew/proc/restaff() . = list() if(crew_state != BOUNTY_KINGPIN_CALM) return var/list/manned = list() - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in standing_goons()) + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in present_goons()) manned |= goon.goon_post for(var/list/post as anything in crew_posts) var/turf/spot = post[1] - if(!spot || (spot in manned)) + if(!spot || (spot in manned) || crew_pending[spot]) continue - var/mob/living/basic/bounty_kingpin_goon/goon = spawn_goon(spot, post[2]) + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = spawn_goon(spot, post[2], crew_immediate) if(goon) manned |= spot . += goon @@ -1521,9 +1710,9 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) if(!length(people)) return if(!(attack_flags & (ATTACKER_DAMAGING_ATTACK | ATTACKER_STAMINA_ATTACK))) - if((attack_flags & ATTACKER_SHOVING) && istype(source, /mob/living/basic/bounty_kingpin_goon)) - var/mob/living/basic/bounty_kingpin_goon/goon = source - INVOKE_ASYNC(goon, TYPE_PROC_REF(/mob/living/basic/bounty_kingpin_goon, goon_say), "shoved") + if((attack_flags & ATTACKER_SHOVING) && istype(source, /mob/living/carbon/human/npc/bounty_kingpin_goon)) + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = source + INVOKE_ASYNC(goon, TYPE_PROC_REF(/mob/living/carbon/human/npc/bounty_kingpin_goon, goon_say), "shoved") return member_attacked(source, people) @@ -1540,6 +1729,18 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) if(length(people)) member_attacked(source, people) +/// Him or a goon took brute or burn through tg's apply_damage (a hit to a limb, a bullet, a blade) +/datum/bounty_kingpin_crew/proc/on_member_damaged(mob/living/source, damage, damagetype, def_zone, blocked) + SIGNAL_HANDLER + if(damage > 0 && (damagetype == BRUTE || damagetype == BURN)) + member_hurt(source) + +/// Him or a goon took brute or burn straight to the body (fire, a blast, a chemical) +/datum/bounty_kingpin_crew/proc/on_member_adjusted(mob/living/source, damagetype, amount, forced) + SIGNAL_HANDLER + if(amount > 0 && !forced) + member_hurt(source) + /// A hunter fired: at his crew, it's part of the fight (their stray shots take no outpost strike) /datum/bounty_kingpin_crew/proc/on_hunter_fired(mob/living/source, obj/projectile/shot, atom/fired_from, atom/original) SIGNAL_HANDLER @@ -1556,11 +1757,11 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) /** * `member` (him or a goon) was attacked by `people`: they are hunters now, a goon drawing or - * winding up fumbles, and if all was calm the shootout starts. Someone the crew won't fight (another - * criminal) sets nothing off (L6). Doesn't sleep. + * winding up fumbles, his aim is spoiled, and if all was calm the shootout starts. Someone the crew + * won't fight (another criminal) sets nothing off (L6). Doesn't sleep. */ /datum/bounty_kingpin_crew/proc/member_attacked(atom/member, list/people) - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin() var/mob/living/first for(var/mob/living/person as anything in people) if(QDELETED(person) || is_member(person)) @@ -1573,8 +1774,11 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) kingpin.kingpin_note_hit(person) if(!first) return - if(istype(member, /mob/living/basic/bounty_kingpin_goon)) + if(istype(member, /mob/living/carbon/human/npc/bounty_kingpin_goon)) goon_hit(member) + else if(member == kingpin) + // A hit while he aims: "[src] fumbles the shot." + kingpin.kingpin_fumble() if(crew_state == BOUNTY_KINGPIN_CALM) start_shootout(first, FALSE) @@ -1596,7 +1800,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) for(var/mob/living/person in range(BOUNTY_GOON_LEASH, member)) if(person.stat != CONSCIOUS || !(person.mind || person.client) || is_member(person)) continue - if(istype(person, /mob/living/basic/bounty_criminal) || istype(person, /mob/living/basic/bounty_companion)) + if(istype(person, /mob/living/carbon/human/npc/bounty_criminal) || istype(person, /mob/living/carbon/human/npc/bounty_companion)) continue if(SSbounty_kingpin.kingpin_mind_bound(person.mind) && !is_hunter(person)) continue @@ -1607,7 +1811,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) if(suspect) member_attacked(member, list(suspect)) -/// He fell (downed, gave up, died): his aim drops, and half the goons left run (once a fight) +/// He fell (in crit, gave up, died): his aim drops, and half the goons left run (once a fight) /datum/bounty_kingpin_crew/proc/on_boss_fell(datum/source) SIGNAL_HANDLER kingpin()?.kingpin_cancel_aim() @@ -1630,7 +1834,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) var/list/standing = sortTim(standing_goons(), GLOBAL_PROC_REF(cmp_bounty_kingpin_goon_health)) var/fleeing = floor(length(standing) * BOUNTY_GOON_FLEE_ON_BOSS / 100) for(var/i in 1 to fleeing) - var/mob/living/basic/bounty_kingpin_goon/goon = standing[i] + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = standing[i] goon_flee(goon) . += goon @@ -1638,27 +1842,32 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) /proc/cmp_bounty_kingpin_goon_health(mob/living/first, mob/living/second) return first.health - second.health -/// `goon` runs for it: away from the nearest hunter, and gone after BOUNTY_GOON_FLEE_TIME -/datum/bounty_kingpin_crew/proc/goon_flee(mob/living/basic/bounty_kingpin_goon/goon) +/** + * `goon` runs for it (CB-16): his gun goes away, his line, and he walks out for real (npc_walk_out()), + * to the refuge, else away from the nearest hunter. Shots still land on the way; he is gone only on + * the exit tile or once nobody can see him. + */ +/datum/bounty_kingpin_crew/proc/goon_flee(mob/living/carbon/human/npc/bounty_kingpin_goon/goon) if(goon.goon_fleeing || goon.stat == DEAD) return goon.goon_fleeing = TRUE goon.goon_cancel_windup() goon.goon_target_ref = null - INVOKE_ASYNC(goon, TYPE_PROC_REF(/mob/living/basic/bounty_kingpin_goon, goon_say), "flee") - var/mob/living/nearest - for(var/mob/living/hunter as anything in live_hunters()) - if(!nearest || get_dist(goon, hunter) < get_dist(goon, nearest)) - nearest = hunter - if(nearest && isturf(goon.loc)) - GLOB.move_manager.move_away(goon, nearest, BOUNTY_KINGPIN_SIGHT + BOUNTY_GOON_LEASH, BOUNTY_GOON_STEP, BOUNTY_GOON_FLEE_TIME, priority = MOVEMENT_ABOVE_SPACE_PRIORITY) - else - goon.goon_leave(exit_turf(goon), BOUNTY_GOON_FLEE_TIME) - return - addtimer(CALLBACK(goon, TYPE_PROC_REF(/mob/living/basic/bounty_kingpin_goon, goon_leave), null, 1), BOUNTY_GOON_FLEE_TIME, TIMER_DELETE_ME) + bounty_kingpin_set_armed(goon, FALSE) + bounty_kingpin_holster_guns(goon) + INVOKE_ASYNC(goon, TYPE_PROC_REF(/mob/living/carbon/human/npc/bounty_kingpin_goon, goon_say), "flee") + var/turf/exit = crew_refuge + if(!exit) + var/mob/living/nearest + for(var/mob/living/hunter as anything in live_hunters()) + if(!nearest || get_dist(goon, hunter) < get_dist(goon, nearest)) + nearest = hunter + if(nearest && get_turf(nearest) != get_turf(goon)) + exit = get_ranged_target_turf_direct(goon, nearest, BOUNTY_KINGPIN_SIGHT + BOUNTY_GOON_LEASH, 180) + goon_walk_out(goon, exit) /// A goon was hit: drawing, he fumbles his first shot; winding up, he loses the burst or the blast -/datum/bounty_kingpin_crew/proc/goon_hit(mob/living/basic/bounty_kingpin_goon/goon) +/datum/bounty_kingpin_crew/proc/goon_hit(mob/living/carbon/human/npc/bounty_kingpin_goon/goon) if(goon.stat != CONSCIOUS) return if(crew_state == BOUNTY_KINGPIN_DRAWING) @@ -1675,7 +1884,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) /datum/bounty_kingpin_crew/proc/can_fight() if(kingpin()?.kingpin_able()) return TRUE - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in standing_goons()) + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in standing_goons()) if(goon.stat == CONSCIOUS) return TRUE return FALSE @@ -1683,10 +1892,10 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) /** * The shootout starts, set off by `instigator` ("We're here for you" when `confronted`, else an * attack): the telegraph. For BOUNTY_KINGPIN_TELEGRAPH nobody in the crew fires: the goons reach - * for their guns, the table goons flip their tables, he kicks the coffee table over and the - * barkeep shouts. The instigator and their shipmates nearby are hunters now. It - * puts nobody on the board. Nothing starts when the crew won't fight the instigator (L6) or nobody - * can shoot. Doesn't sleep. Returns TRUE if it started. + * for their guns (and draw them), the table goons flip their tables, he draws his and kicks the + * coffee table over and the barkeep shouts. The instigator and their shipmates nearby are hunters + * now. It puts nobody on the board. Nothing starts when the crew won't fight the instigator (L6) or + * nobody can shoot. Doesn't sleep. Returns TRUE if it started. */ /datum/bounty_kingpin_crew/proc/start_shootout(mob/living/instigator, confronted = FALSE) add_hunter(instigator) @@ -1698,38 +1907,41 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) crew_last_contact_at = world.time crew_lead = null crew_boss_fell = FALSE - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin() if(kingpin?.stat == CONSCIOUS) kingpin.kingpin_cancel_aim() INVOKE_ASYNC(kingpin, TYPE_PROC_REF(/mob/living, bounty_say), confronted ? "confront" : "attacked", null, TRUE) crew_seat?.visible_message(span_userdanger("The goons reach for their guns!"), vision_distance = BOUNTY_KINGPIN_SIGHT) crew_armed = TRUE if(kingpin) - INVOKE_ASYNC(kingpin, TYPE_PROC_REF(/mob/living/basic/bounty_criminal, body_dress)) kingpin.kingpin_next_aim_at = crew_draw_ends_at - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in standing_goons()) + bounty_kingpin_set_armed(kingpin, TRUE) + if(kingpin.kingpin_able()) + bounty_kingpin_draw_gun(kingpin) + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in standing_goons()) goon_draw(goon) kick_table() clear_room() log_game("BOUNTY: [key_name(instigator)] started a shootout with [kingpin || "the kingpin's crew"] at [AREACOORD(crew_seat)] ([confronted ? "a confrontation" : "an attack"])") return TRUE -/// `goon` reaches for his gun: the telegraph box, the sound, out of his chair, his table over -/datum/bounty_kingpin_crew/proc/goon_draw(mob/living/basic/bounty_kingpin_goon/goon) - goon.goon_arm(TRUE) +/// `goon` reaches for his gun: the telegraph box, the sound, out of his chair, the real gun into his hand, his table over +/datum/bounty_kingpin_crew/proc/goon_draw(mob/living/carbon/human/npc/bounty_kingpin_goon/goon) goon.goon_cancel_windup() goon.goon_target_ref = null - goon.goon_rounds = bounty_kingpin_goon_mag(goon.goon_weapon) goon.goon_next_fire_at = crew_draw_ends_at + bounty_kingpin_set_armed(goon, TRUE) var/turf/spot = get_turf(goon) if(spot) new /obj/effect/temp_visual/telegraphing/bounty_kingpin(spot) playsound(goon, 'sound/items/weapons/gun/pistol/rack.ogg', 50, TRUE) if(goon.buckled) goon.buckled.unbuckle_mob(goon, force = TRUE) + if(goon.goon_able()) + bounty_kingpin_draw_gun(goon) goon_flip_table(goon) if(prob(40)) - INVOKE_ASYNC(goon, TYPE_PROC_REF(/mob/living/basic/bounty_kingpin_goon, goon_say), "draw") + INVOKE_ASYNC(goon, TYPE_PROC_REF(/mob/living/carbon/human/npc/bounty_kingpin_goon, goon_say), "draw") /// Flips `table` toward `direction`: a table someone else knocked over the wrong way is set up first (H2) /datum/bounty_kingpin_crew/proc/flip_our_way(obj/structure/table/table, direction) @@ -1745,7 +1957,9 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) return TRUE /// A goon at a table kicks it over for cover, away from himself. Never the coffee table: that's his. -/datum/bounty_kingpin_crew/proc/goon_flip_table(mob/living/basic/bounty_kingpin_goon/goon) +/datum/bounty_kingpin_crew/proc/goon_flip_table(mob/living/carbon/human/npc/bounty_kingpin_goon/goon) + if(!goon.goon_able()) + return null for(var/direction in GLOB.cardinals) var/turf/spot = get_step(goon, direction) var/obj/structure/table/table = locate(/obj/structure/table) in spot @@ -1759,7 +1973,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) /// He kicks the coffee table over, toward the hunters: his shots go over it, theirs hit it /datum/bounty_kingpin_crew/proc/kick_table() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin() if(!kingpin?.kingpin_able()) return FALSE var/kicked = FALSE @@ -1795,7 +2009,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) var/list/goons = shuffle(standing_goons()) var/count = length(goons) for(var/i in 1 to count) - var/mob/living/basic/bounty_kingpin_goon/goon = goons[i] + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = goons[i] var/offset = count > 1 ? round(BOUNTY_KINGPIN_FIRST_SHOT_SPREAD * (i - 1) / (count - 1), 1) : 0 goon.goon_next_fire_at = max(crew_draw_ends_at + offset, goon.goon_fumbled_until) goon.goon_target_ref = null @@ -1806,26 +2020,28 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) crew_lead = null crew_armed = FALSE crew_engaged.Cut() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin() if(kingpin) kingpin.kingpin_cancel_aim() - INVOKE_ASYNC(kingpin, TYPE_PROC_REF(/mob/living/basic/bounty_criminal, body_dress)) + bounty_kingpin_set_armed(kingpin, FALSE) + bounty_kingpin_holster_guns(kingpin) if(kingpin.kingpin_able()) INVOKE_ASYNC(kingpin, TYPE_PROC_REF(/mob/living, bounty_say), "stand_down", null, TRUE) - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in standing_goons()) + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in present_goons()) goon.goon_cancel_windup() goon.goon_target_ref = null - goon.goon_arm(FALSE) + bounty_kingpin_set_armed(goon, FALSE) + bounty_kingpin_holster_guns(goon) restore_room() log_game("BOUNTY: [kingpin || "the kingpin's crew"] stood down at [AREACOORD(crew_seat)]") /** * With him gone (padded or deleted) or carried off his leash, there is nobody left to guard: the - * goons still standing walk out. Cuffed or dead on his sofa, they stay with him (M2). Returns TRUE if - * they left. + * goons still standing walk out, for real. Cuffed, in crit or dead on his sofa, they stay with him + * (M2). Returns TRUE if they left. */ /datum/bounty_kingpin_crew/proc/dismiss_if_boss_gone() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin() if(kingpin) var/turf/here = get_turf(kingpin) var/on_leash = here && crew_seat && here.z == crew_seat.z && get_dist(here, crew_seat) <= BOUNTY_GOON_LEASH @@ -1834,25 +2050,24 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) var/list/leaving = standing_goons() if(!length(leaving)) return FALSE - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in leaving) - goon.goon_leave(exit_turf(goon)) - return TRUE + . = FALSE + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in leaving) + bounty_kingpin_set_armed(goon, FALSE) + bounty_kingpin_holster_guns(goon) + if(goon_walk_out(goon)) + . = TRUE // ===== THE TICK ===== /datum/bounty_kingpin_crew/process(seconds_per_tick) - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin() if(!kingpin) return PROCESS_KILL - if(!kingpin.kingpin_posting()) - // With no posting to answer for him (L10): nowhere at all (nullspace) is gone for good - if(!get_turf(kingpin)) - log_game("BOUNTY: [kingpin] was cleared away from nowhere") - qdel(kingpin) - return PROCESS_KILL - // A body nobody can bring in (killed off the board, or its proof went up at a chasm's edge) fades - if(kingpin.stat == DEAD) - kingpin.kingpin_start_fade() + // With no posting to answer for him (L10): nowhere at all (nullspace) is gone for good + if(!kingpin.kingpin_posting() && !get_turf(kingpin)) + log_game("BOUNTY: [kingpin] was cleared away from nowhere") + qdel(kingpin) + return PROCESS_KILL // The pad is taking him, or a posting is clearing him away if(HAS_TRAIT(kingpin, TRAIT_BOUNTY_REMOVED)) return @@ -1871,10 +2086,10 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) /datum/bounty_kingpin_crew/proc/fight_tick() var/list/hunters = live_hunters() var/contact = FALSE - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in standing_goons()) + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in standing_goons()) if(goon_tick(goon, hunters)) contact = TRUE - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin() if(kingpin && boss_tick(kingpin, hunters)) contact = TRUE if(contact) @@ -1896,7 +2111,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) crew_lead_at = world.time /// One goon's turn: pick a target, close in or shoot, or go looking. Returns TRUE if he sees a hunter. -/datum/bounty_kingpin_crew/proc/goon_tick(mob/living/basic/bounty_kingpin_goon/goon, list/hunters) +/datum/bounty_kingpin_crew/proc/goon_tick(mob/living/carbon/human/npc/bounty_kingpin_goon/goon, list/hunters) if(goon.stat != CONSCIOUS) goon.goon_cancel_windup() return FALSE @@ -1921,10 +2136,10 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) return length(visible) > 0 /// Whether `goon` is one of the BOUNTY_KINGPIN_MAX_ON_ONE goons nearest the lead, the ones who go looking -/datum/bounty_kingpin_crew/proc/goon_is_seeker(mob/living/basic/bounty_kingpin_goon/goon) +/datum/bounty_kingpin_crew/proc/goon_is_seeker(mob/living/carbon/human/npc/bounty_kingpin_goon/goon) var/my_dist = get_dist(goon, crew_lead) var/closer = 0 - for(var/mob/living/basic/bounty_kingpin_goon/other as anything in standing_goons()) + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/other as anything in standing_goons()) if(other == goon || !other.goon_able()) continue if(get_dist(other, crew_lead) < my_dist) @@ -1936,7 +2151,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) * opening volley, and whenever a hunter is in cover, at most BOUNTY_KINGPIN_MAX_ON_ONE goons draw * on one hunter. */ -/datum/bounty_kingpin_crew/proc/goon_choose_target(mob/living/basic/bounty_kingpin_goon/goon, list/visible) +/datum/bounty_kingpin_crew/proc/goon_choose_target(mob/living/carbon/human/npc/bounty_kingpin_goon/goon, list/visible) if(!length(visible)) return null var/opening = world.time < crew_draw_ends_at + BOUNTY_KINGPIN_FIRST_SHOT_SPREAD @@ -1955,22 +2170,25 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) return best /// Whether enough other goons are drawing on `hunter` already that `goon` should pick someone else -/datum/bounty_kingpin_crew/proc/target_full(mob/living/hunter, mob/living/basic/bounty_kingpin_goon/goon, opening) +/datum/bounty_kingpin_crew/proc/target_full(mob/living/hunter, mob/living/carbon/human/npc/bounty_kingpin_goon/goon, opening) if(!opening && !in_cover(hunter)) return FALSE return goons_on(hunter, goon) >= BOUNTY_KINGPIN_MAX_ON_ONE /// How many goons other than `except` are drawing on `hunter` -/datum/bounty_kingpin_crew/proc/goons_on(mob/living/hunter, mob/living/basic/bounty_kingpin_goon/except) +/datum/bounty_kingpin_crew/proc/goons_on(mob/living/hunter, mob/living/carbon/human/npc/bounty_kingpin_goon/except) var/count = 0 - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in standing_goons()) + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in standing_goons()) if(goon != except && goon.goon_target_ref?.resolve() == hunter) count++ return count -/// One step for `goon` toward `destination`, never past his leash from the sofa. Returns TRUE if he moved. -/datum/bounty_kingpin_crew/proc/goon_step_toward(mob/living/basic/bounty_kingpin_goon/goon, turf/destination) - if(!destination || !crew_seat || world.time < goon.goon_next_move_at || goon.buckled || !isturf(goon.loc)) +/** + * One real step for `goon` toward `destination`, never past his leash from the sofa, and never faster + * than his body walks (wounds, armour and stamina slow him as they slow anyone). Returns TRUE if he moved. + */ +/datum/bounty_kingpin_crew/proc/goon_step_toward(mob/living/carbon/human/npc/bounty_kingpin_goon/goon, turf/destination) + if(!destination || !crew_seat || world.time < goon.goon_next_move_at || goon.buckled || !isturf(goon.loc) || goon.pulledby) return FALSE if(get_turf(goon) == destination) return FALSE @@ -1979,24 +2197,42 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) return FALSE if(next.z != crew_seat.z || get_dist(next, crew_seat) > BOUNTY_GOON_LEASH) return FALSE - goon.goon_next_move_at = world.time + BOUNTY_GOON_STEP + goon.goon_next_move_at = world.time + max(BOUNTY_GOON_STEP, goon.cached_multiplicative_slowdown) return goon.Move(next, get_dir(goon, next)) +/// A sidestep for a clear line on `target`: an open tile next to `goon`, no further from them, from which nobody he isn't fighting is in the way +/datum/bounty_kingpin_crew/proc/goon_sidestep(mob/living/carbon/human/npc/bounty_kingpin_goon/goon, atom/target) + var/turf/here = get_turf(goon) + var/turf/there = get_turf(target) + if(!here || !there) + return FALSE + var/list/spots = list() + for(var/direction in GLOB.alldirs) + var/turf/spot = get_step(here, direction) + if(!spot || spot == there || spot.is_blocked_turf(exclude_mobs = FALSE) || get_dist(spot, there) > get_dist(here, there)) + continue + if(line_blocked(spot, target)) + continue + spots += spot + if(!length(spots)) + return FALSE + return goon_step_toward(goon, pick(spots)) + /** - * `goon` tries to shoot `target`. Nobody fires while the crew is drawing. A pistol fires at once; an - * SMG spins up (BOUNTY_GOON_SMG_WINDUP) and a shotgun pumps (BOUNTY_GOON_SHOTGUN_WINDUP) first, and - * a hit in the meantime spoils it. An empty gun reloads. Returns TRUE if a shot or a wind-up started. + * `goon` tries to shoot `target`. Nobody fires while the crew is drawing, and only with a loaded gun + * in hand: a spent one is his AI's to reload. A pistol fires at once; an SMG spins up + * (BOUNTY_GOON_SMG_WINDUP) and a shotgun pumps (BOUNTY_GOON_SHOTGUN_WINDUP) first, and a hit in the + * meantime spoils it. Returns TRUE if a shot or a wind-up started. */ -/datum/bounty_kingpin_crew/proc/goon_try_attack(mob/living/basic/bounty_kingpin_goon/goon, mob/living/target) +/datum/bounty_kingpin_crew/proc/goon_try_attack(mob/living/carbon/human/npc/bounty_kingpin_goon/goon, mob/living/target) if(crew_state != BOUNTY_KINGPIN_FIGHTING || !goon.goon_able() || !valid_target(target)) return FALSE if(goon.goon_windup_timer || world.time < goon.goon_next_fire_at || world.time < goon.goon_fumbled_until) return FALSE - if(goon.goon_rounds <= 0) - goon.goon_rounds = bounty_kingpin_goon_mag(goon.goon_weapon) - goon.goon_next_fire_at = world.time + bounty_kingpin_goon_reload(goon.goon_weapon) - goon.visible_message(span_notice("[goon] reloads."), vision_distance = COMBAT_MESSAGE_RANGE) - playsound(goon, 'sound/items/weapons/gun/general/magazine_insert_full.ogg', 40, TRUE) + if(!human_npc_loaded_gun(goon)) + return FALSE + if(line_blocked(goon, shot_target(target))) + goon_sidestep(goon, target) return FALSE switch(goon.goon_weapon) if(BOUNTY_GOON_WEAPON_SMG) @@ -2016,7 +2252,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) /// The wind-up is done: the SMG's burst or the shotgun's blast, if he still can and still sees them /datum/bounty_kingpin_crew/proc/goon_finish_windup(datum/weakref/goon_ref, datum/weakref/target_ref) - var/mob/living/basic/bounty_kingpin_goon/goon = goon_ref?.resolve() + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = goon_ref?.resolve() if(QDELETED(goon)) return goon.goon_windup_timer = null @@ -2027,27 +2263,70 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) if(get_dist(goon, target) <= BOUNTY_GOON_SHOTGUN_RANGE) goon_fire(goon, target) return - goon_fire(goon, target) - for(var/shot in 2 to BOUNTY_GOON_SMG_BURST) - addtimer(CALLBACK(src, PROC_REF(goon_burst_shot), goon_ref, target_ref), (shot - 1) * BOUNTY_GOON_SMG_BURST_GAP, TIMER_DELETE_ME) + if(!goon_fire(goon, target)) + return + for(var/pull in 2 to BOUNTY_GOON_SMG_BURST) + addtimer(CALLBACK(src, PROC_REF(goon_burst_shot), goon_ref, target_ref), (pull - 1) * BOUNTY_GOON_SMG_BURST_GAP, TIMER_DELETE_ME) -/// The rest of an SMG burst, one shot at a time +/// The rest of an SMG burst, a trigger pull at a time /datum/bounty_kingpin_crew/proc/goon_burst_shot(datum/weakref/goon_ref, datum/weakref/target_ref) - var/mob/living/basic/bounty_kingpin_goon/goon = goon_ref?.resolve() + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = goon_ref?.resolve() var/mob/living/target = target_ref?.resolve() if(QDELETED(goon) || crew_state != BOUNTY_KINGPIN_FIGHTING || !goon.goon_able() || !valid_target(target) || !bounty_kingpin_clear_shot(goon, target)) return goon_fire(goon, target) -/// One round from `goon`'s gun at `target` (at the mech they drive, if they drive one), if one is left: every pellet of a shell -/datum/bounty_kingpin_crew/proc/goon_fire(mob/living/basic/bounty_kingpin_goon/goon, mob/living/target) - if(goon.goon_rounds <= 0) - return null - goon.goon_rounds-- - return bounty_kingpin_shoot(goon, shot_target(target), bounty_kingpin_goon_gun(goon.goon_weapon), src) +/** + * One pull of the trigger of the loaded gun in `goon`'s hand at `target` (at the mech they drive, if + * they drive one), unless someone he isn't fighting is in the line: then he steps aside instead. + * Returns TRUE if he pulled it. + */ +/datum/bounty_kingpin_crew/proc/goon_fire(mob/living/carbon/human/npc/bounty_kingpin_goon/goon, mob/living/target) + var/obj/item/gun/gun = human_npc_loaded_gun(goon) + if(!gun || QDELETED(target)) + return FALSE + var/atom/aim_at = shot_target(target) + if(line_blocked(goon, aim_at)) + goon_sidestep(goon, target) + return FALSE + return pull_trigger(goon, gun, aim_at) + +/** + * `shooter` pulls the trigger of `gun` (in their hand) at `aim_at`, the way a player does: the gun made + * the active hand, a body zone picked, and a click through the body's AI controller (ai_interact()), so + * the gun's own fire path runs (fire delay, burst, recoil, spread, casing, sound, wounds). No projectile + * is ever made here. Returns TRUE if the click was made. + */ +/datum/bounty_kingpin_crew/proc/pull_trigger(mob/living/carbon/human/shooter, obj/item/gun/gun, atom/aim_at) + var/datum/ai_controller/controller = shooter?.ai_controller + if(!controller || QDELETED(aim_at) || !human_npc_ready_item(shooter, gun)) + return FALSE + shooter.zone_selected = human_npc_pick_aim_zone() + INVOKE_ASYNC(controller, TYPE_PROC_REF(/datum/ai_controller, ai_interact), aim_at, TRUE) + crew_shots++ + return TRUE + +/** + * Whether someone the crew isn't fighting stands between `from` and `target`: a bystander, a guest, + * another criminal, or one of the crew itself. A shot from them would hit that person, so it isn't + * taken (CB-11, CB-13: no round passes through anyone). Shots go over anyone lying down. + */ +/datum/bounty_kingpin_crew/proc/line_blocked(atom/from, atom/target) + var/turf/start = get_turf(from) + var/turf/end = get_turf(target) + if(!start || !end || start == end) + return FALSE + for(var/turf/line_turf as anything in get_line(start, end)) + if(line_turf == start || line_turf == end) + continue + for(var/mob/living/other in line_turf) + if(other.stat == DEAD || other.body_position == LYING_DOWN || is_hunter(other)) + continue + return TRUE + return FALSE -/// The kingpin's turn: aim at whoever hurt him most, or reload. Never while drawing. Returns TRUE if he sees a hunter. -/datum/bounty_kingpin_crew/proc/boss_tick(mob/living/basic/bounty_criminal/kingpin/kingpin, list/hunters) +/// The kingpin's turn: aim at whoever hurt him most. Never while drawing; a spent revolver is his AI's to reload. Returns TRUE if he sees a hunter. +/datum/bounty_kingpin_crew/proc/boss_tick(mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin, list/hunters) if(kingpin.stat != CONSCIOUS) kingpin.kingpin_cancel_aim() return FALSE @@ -2057,8 +2336,8 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) return length(visible) > 0 if(crew_state != BOUNTY_KINGPIN_FIGHTING || kingpin.kingpin_aim_timer || world.time < kingpin.kingpin_next_aim_at) return length(visible) > 0 - if(kingpin.kingpin_rounds <= 0) - kingpin.kingpin_reload() + if(!human_npc_loaded_gun(kingpin)) + // Holstered (he gave up and thought better of it): his AI draws it again while the guns are out return length(visible) > 0 var/mob/living/target = kingpin.kingpin_choose_target(visible) if(target) @@ -2078,10 +2357,10 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) return if(watch_for_trouble()) return - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin() if(kingpin && !kingpin.buckled && kingpin.kingpin_able() && !kingpin.kingpin_sit()) kingpin.kingpin_go_home() - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in standing_goons()) + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in standing_goons()) goon_calm_tick(goon) right_the_tables() prune_job_offers() @@ -2099,7 +2378,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) * started. */ /datum/bounty_kingpin_crew/proc/watch_for_trouble() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin() var/mob/living/puller = kingpin?.pulledby if(isliving(puller) && !is_member(puller)) member_attacked(kingpin, list(puller)) @@ -2132,8 +2411,8 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) var/obj/structure/table/table = ref?.resolve() if(QDELETED(table) || !table.is_flipped) continue - var/mob/living/basic/bounty_kingpin_goon/nearest - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in goons) + var/mob/living/carbon/human/npc/bounty_kingpin_goon/nearest + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in goons) if(goon.goon_able() && (!nearest || get_dist(goon, table) < get_dist(nearest, table))) nearest = goon if(!nearest) @@ -2141,13 +2420,13 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) table.unflip_table() nearest.visible_message(span_notice("[nearest] sets [table] back on its legs."), vision_distance = COMBAT_MESSAGE_RANGE) righted = TRUE - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin() if(righted && world.time >= crew_next_table_warning && kingpin?.kingpin_can_talk()) crew_next_table_warning = world.time + BOUNTY_KINGPIN_TABLE_WARN_GAP INVOKE_ASYNC(kingpin, TYPE_PROC_REF(/mob/living, bounty_say), "furniture", null, TRUE) /// A goon at ease: back to his post and into his chair, and watching whoever is closest -/datum/bounty_kingpin_crew/proc/goon_calm_tick(mob/living/basic/bounty_kingpin_goon/goon) +/datum/bounty_kingpin_crew/proc/goon_calm_tick(mob/living/carbon/human/npc/bounty_kingpin_goon/goon) if(!goon.goon_able()) return if(goon.goon_post && get_turf(goon) != goon.goon_post) @@ -2173,7 +2452,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) /// Someone came up to the table: a goon warns him, he says hello. Each visitor once per BOUNTY_KINGPIN_GREET_GAP. /datum/bounty_kingpin_crew/proc/greet_visitors() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin() if(!kingpin?.kingpin_can_talk() || !crew_seat) return for(var/mob/living/carbon/human/visitor in range(3, crew_seat)) @@ -2186,8 +2465,8 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) crew_greeted[ref] = world.time var/list/goons = standing_goons() if(length(goons)) - var/mob/living/basic/bounty_kingpin_goon/goon = pick(goons) - INVOKE_ASYNC(goon, TYPE_PROC_REF(/mob/living/basic/bounty_kingpin_goon, goon_say), "company") + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = pick(goons) + INVOKE_ASYNC(goon, TYPE_PROC_REF(/mob/living/carbon/human/npc/bounty_kingpin_goon, goon_say), "company") var/context = "greet" if(is_hunter(visitor)) context = "greet_hostile" @@ -2199,14 +2478,14 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) /// One goon does something: a quiet word, a smoke, a drink, the cards /datum/bounty_kingpin_crew/proc/goon_idle() var/list/at_ease = list() - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in standing_goons()) + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in standing_goons()) if(goon.goon_able()) at_ease += goon if(!length(at_ease)) return - var/mob/living/basic/bounty_kingpin_goon/goon = pick(at_ease) + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = pick(at_ease) if(prob(40)) - INVOKE_ASYNC(goon, TYPE_PROC_REF(/mob/living/basic/bounty_kingpin_goon, goon_say), "idle", TRUE) + INVOKE_ASYNC(goon, TYPE_PROC_REF(/mob/living/carbon/human/npc/bounty_kingpin_goon, goon_say), "idle", TRUE) return var/context = "actions" var/turf/spot = get_turf(goon) @@ -2225,7 +2504,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) /// He says something to nobody in particular, or puffs his cigar /datum/bounty_kingpin_crew/proc/boss_idle() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin() if(!kingpin?.kingpin_can_talk()) return if(prob(50)) @@ -2247,58 +2526,11 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) duration = BOUNTY_KINGPIN_TELEGRAPH /** - * # A shot from the kingpin's crew - * - * The real round of the gun that fires it (bounty_kingpin_shoot()). It passes through anyone the - * crew isn't fighting (bystanders, the crew itself, those who work for him): only a hunter it - * reaches can be hit. - */ -/obj/projectile/bullet/bounty_kingpin - name = "bullet" - /// Weakref to the crew whose shot it is (/datum/bounty_kingpin_crew) - var/datum/weakref/kingpin_crew_ref - -/obj/projectile/bullet/bounty_kingpin/can_hit_target(atom/target, direct_target = FALSE, ignore_loc = FALSE, cross_failed = FALSE) - if(isliving(target) && !direct_target) - var/datum/bounty_kingpin_crew/crew = kingpin_crew_ref?.resolve() - if(!crew?.is_hunter(target)) - return FALSE - return ..() - -/** - * `shooter` fires one round of `weapon` (a /datum/bounty_real_weapon) at `target` for `crew`: every - * pellet of a shell, each with the real round's numbers and spread. Returns the first projectile. - */ -/proc/bounty_kingpin_shoot(mob/living/shooter, atom/target, datum/bounty_real_weapon/weapon, datum/bounty_kingpin_crew/crew) - var/turf/start = get_turf(shooter) - if(!start || !target || !weapon) - return null - var/obj/projectile/bullet/bounty_kingpin/first - for(var/pellet in 1 to weapon.pellets) - var/obj/projectile/bullet/bounty_kingpin/bullet = new(start) - weapon.load(bullet) - bullet.kingpin_crew_ref = crew ? WEAKREF(crew) : null - bullet.starting = start - bullet.firer = shooter - bullet.fired_from = shooter - bullet.yo = target.y - start.y - bullet.xo = target.x - start.x - bullet.original = target - bullet.aim_projectile(target, shooter, null, weapon.shot_spread()) - if(QDELETED(bullet)) - continue - first ||= bullet - INVOKE_ASYNC(bullet, TYPE_PROC_REF(/obj/projectile, fire)) - if(weapon.fire_sound) - playsound(shooter, weapon.fire_sound, 60, TRUE) - if(crew) - crew.crew_shots++ - return first - -/** - * Whether a shot from `from` would reach `target`: in range, on the same level, and nothing in the - * way that stops a bullet (walls, windows, closed doors, machines; tables only when flipped toward - * the shot). People in the way don't count: the crew's shots pass through anyone but a hunter. + * Whether `from` has a line of sight and fire on `target` for the crew's choice of who to shoot: in + * range, on the same level, and nothing in the way that stops a bullet (walls, windows, closed doors, + * machines; tables only when flipped toward the shot, as tg's flipped tables let shots from behind + * through). People in the way are the trigger's business (line_blocked()): a goon doesn't fire + * through anyone he isn't fighting. */ /proc/bounty_kingpin_clear_shot(atom/from, atom/target, range = BOUNTY_KINGPIN_SIGHT) var/turf/start = get_turf(from) @@ -2340,7 +2572,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) /** * # The kingpin's posting * - * P5's posting with his rules: "wanted dead or alive" (alive 100% however he got there, dead 80%), + * P5's posting with his rules: "wanted dead or alive" (alive 100% however he is brought in, dead 80%), * a clock that stops during a shootout, no relisting (he is only ever on his sofa), and no place * under the board's live-criminal cap. It never spawns him: it adopts the seated kingpin wherever he * is (bounty_kingpin_post()). Nobody who works for him (SSbounty_kingpin's bindings) can hunt him or @@ -2351,11 +2583,11 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) /// Every crew has been told he is wanted: once, when it went up (L7) var/kingpin_announced = FALSE -// Wanted dead or alive: restrained, stunned or downed is alive and pays in full; dead pays 80% -/datum/criminal_bounty/kingpin/board_share_for(state, worst_state) +// Wanted dead or alive (CB-28), on his condition at the pad: alive pays in full, cuffed, stunned or in crit alike; dead pays 80%. Free is refused. +/datum/criminal_bounty/kingpin/board_share_for(state) if(!bounty_state_share(state)) return 0 - if(state == BOUNTY_STATE_DEAD || worst_state == BOUNTY_STATE_DEAD) + if(state == BOUNTY_STATE_DEAD) return BOUNTY_KINGPIN_PAY_DEAD return BOUNTY_KINGPIN_PAY_ALIVE @@ -2369,7 +2601,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) // The clock stops while his crew is fighting; a hunt doesn't stop it /datum/criminal_bounty/kingpin/board_clock_held(now = world.time) - var/mob/living/basic/bounty_criminal/kingpin/kingpin = criminal() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = criminal() if(!kingpin) return !board_proof() && !board_relisting return istype(kingpin) && !!kingpin.kingpin_crew?.is_fighting() @@ -2427,7 +2659,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) if(reason == BOUNTY_CLOSE_CLAIMED) SSbounty_kingpin.kingpin_set_gone("claimed") else - var/mob/living/basic/bounty_criminal/kingpin/kingpin = criminal() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = criminal() if(kingpin_stays(kingpin)) kingpin_let_go(kingpin) . = ..() @@ -2435,13 +2667,13 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) SSbounty_kingpin.kingpin_resolved() /// Whether `kingpin` stays when it closes unclaimed: alive, with his crew, in his lounge (within his goons' leash of the sofa) -/datum/criminal_bounty/kingpin/proc/kingpin_stays(mob/living/basic/bounty_criminal/kingpin/kingpin) +/datum/criminal_bounty/kingpin/proc/kingpin_stays(mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin) if(!istype(kingpin) || QDELETED(kingpin) || kingpin.stat == DEAD || !kingpin.kingpin_crew || HAS_TRAIT(kingpin, TRAIT_BOUNTY_REMOVED)) return FALSE return kingpin.kingpin_on_leash() /// Lets go of `kingpin`, who stays in his lounge: no longer its criminal, on no posting, and back to business -/datum/criminal_bounty/kingpin/proc/kingpin_let_go(mob/living/basic/bounty_criminal/kingpin/kingpin) +/datum/criminal_bounty/kingpin/proc/kingpin_let_go(mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin) board_detach_criminal() kingpin.posting_ref = null REMOVE_TRAIT(kingpin, TRAIT_MISSION_FIELD_MOB, BOUNTY_TRAIT) @@ -2468,24 +2700,30 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) /** * The kingpin in `record`'s face at `seat` (on its sofa), on no posting, with a goon at each of * `posts` (list(list(turf, BOUNTY_GOON_WEAPON_*), ...)), and his crew knowing the room. Leashed to - * the trader outpost the seat is in, if it is in one. Returns him. + * the trader outpost the seat is in, if it is in one. He is built at once (one body); his goons come + * through the human NPC spawn queue a body at a time, unless `immediate_goons` (the unit tests). + * Returns him. */ -/proc/bounty_kingpin_setup(turf/seat, list/posts, datum/bounty_record/record) +/proc/bounty_kingpin_setup(turf/seat, list/posts, datum/bounty_record/record, immediate_goons = FALSE) if(!seat) return null var/datum/npc_spawn_context/context = new(seat, null, "boss") - var/mob/living/basic/bounty_criminal/kingpin/kingpin = spawn_npc_in_zone(/mob/living/basic/bounty_criminal/kingpin, seat, context, FALSE) - kingpin.kingpin_crew = new /datum/bounty_kingpin_crew(kingpin, seat) + var/datum/human_npc_order/order = spawn_human_npc(/mob/living/carbon/human/npc/bounty_criminal/kingpin, seat, look = record, name = record?.name, context = context, immediate = TRUE) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = order?.spawned_ref?.resolve() + qdel(order) + if(QDELETED(kingpin)) + return null + kingpin.kingpin_crew = new /datum/bounty_kingpin_crew(kingpin, seat, immediate_goons) kingpin.body_setup(record, null) var/obj/structure/overmap/trader_outpost/outpost = get_trader_outpost_for_turf(seat) if(outpost) kingpin.body_set_site(outpost) kingpin.kingpin_sit() - context.finalize() for(var/list/post as anything in posts) kingpin.kingpin_crew.crew_posts += list(post.Copy()) - kingpin.kingpin_crew.spawn_goon(post[1], post[2]) kingpin.kingpin_crew.find_room() + for(var/list/post as anything in posts) + kingpin.kingpin_crew.spawn_goon(post[1], post[2], immediate_goons) return kingpin /// A new record for a kingpin: Most Wanted, his own archetype, a boss's alias and crime, a base value from his band @@ -2542,7 +2780,7 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) * SSbounty_kingpin.kingpin_post() is the way in (the clock and the admin panel). Doesn't sleep. * Returns the posting, or null. */ -/proc/bounty_kingpin_post(mob/living/basic/bounty_criminal/kingpin/kingpin) +/proc/bounty_kingpin_post(mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin) if(!istype(kingpin) || QDELETED(kingpin) || HAS_TRAIT(kingpin, TRAIT_BOUNTY_REMOVED) || kingpin.kingpin_posting() || bounty_kingpin_open_posting()) return null var/obj/structure/overmap/trader_outpost/outpost = kingpin.kingpin_crew?.crew_outpost() @@ -2605,7 +2843,7 @@ SUBSYSTEM_DEF(bounty_kingpin) /// Whether it seats and posts him on its own. Off in tests, which seat and post their own. var/kingpin_auto_post = TRUE #endif - /// Weakref to the round's kingpin (/mob/living/basic/bounty_criminal/kingpin), once seated + /// Weakref to the round's kingpin (/mob/living/carbon/human/npc/bounty_criminal/kingpin), once seated var/datum/weakref/kingpin_ref /// He died, was deleted or was claimed at a pad: nobody seats or posts him again this round var/kingpin_gone = FALSE @@ -2631,12 +2869,12 @@ SUBSYSTEM_DEF(bounty_kingpin) /// This round's kingpin, if he is seated and his mob still exists (dead or alive) /datum/controller/subsystem/bounty_kingpin/proc/kingpin() - RETURN_TYPE(/mob/living/basic/bounty_criminal/kingpin) - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_ref?.resolve() + RETURN_TYPE(/mob/living/carbon/human/npc/bounty_criminal/kingpin) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_ref?.resolve() return QDELETED(kingpin) ? null : kingpin /// Makes `kingpin` this round's kingpin -/datum/controller/subsystem/bounty_kingpin/proc/kingpin_track(mob/living/basic/bounty_criminal/kingpin/kingpin) +/datum/controller/subsystem/bounty_kingpin/proc/kingpin_track(mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin) kingpin_ref = (istype(kingpin) && !QDELETED(kingpin)) ? WEAKREF(kingpin) : null /// Seats him at the black market once it has loaded, unless he sits there already or is gone for the round. Returns him, or null. @@ -2656,7 +2894,7 @@ SUBSYSTEM_DEF(bounty_kingpin) /datum/controller/subsystem/bounty_kingpin/proc/kingpin_seat(obj/structure/overmap/trader_outpost/outpost) if(kingpin_gone) return null - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin() if(kingpin) return kingpin for(var/datum/bounty_kingpin_crew/crew as anything in GLOB.bounty_kingpin_crews) @@ -2711,7 +2949,7 @@ SUBSYSTEM_DEF(bounty_kingpin) /datum/controller/subsystem/bounty_kingpin/proc/kingpin_post() if(kingpin_gone) return null - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin() if(!kingpin || kingpin.stat == DEAD) return null var/datum/criminal_bounty/kingpin/posting = bounty_kingpin_post(kingpin) @@ -2720,11 +2958,11 @@ SUBSYSTEM_DEF(bounty_kingpin) return posting /// `kingpin` died: he is gone for the round. A posting already up holds his body for the dead share; none goes up for it. -/datum/controller/subsystem/bounty_kingpin/proc/kingpin_died(mob/living/basic/bounty_criminal/kingpin/kingpin) +/datum/controller/subsystem/bounty_kingpin/proc/kingpin_died(mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin) kingpin_set_gone(kingpin?.kingpin_posting() ? "died on the board" : "died off the board, nothing to claim") /// `kingpin`'s mob is being deleted: he is gone for the round -/datum/controller/subsystem/bounty_kingpin/proc/kingpin_removed(mob/living/basic/bounty_criminal/kingpin/kingpin) +/datum/controller/subsystem/bounty_kingpin/proc/kingpin_removed(mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin) if(kingpin_ref && kingpin_ref == kingpin?.weak_reference) kingpin_ref = null kingpin_set_gone("deleted") @@ -2942,5 +3180,5 @@ SUBSYSTEM_DEF(bounty_kingpin) return "post the kingpin bounty on [posting.record?.name || "nobody"] at [posting.board_site_name || "the black market"]" /// His lounge faction stays neutral; his explicit boss encounter is still profiled. -/mob/living/basic/bounty_criminal/kingpin/is_npc_zone_exempt() +/mob/living/carbon/human/npc/bounty_criminal/kingpin/is_npc_zone_exempt() return npc_zone_exempt || npc_spawn_context?.exempt || client || mind diff --git a/voidcrew/modules/bounties/bounty_lair.dm b/voidcrew/modules/bounties/bounty_lair.dm index d8173490d96..0cb5f3338b1 100644 --- a/voidcrew/modules/bounties/bounty_lair.dm +++ b/voidcrew/modules/bounties/bounty_lair.dm @@ -22,9 +22,10 @@ * rooms a crew clears stay cleared: the zone_mobs markers delete themselves after spawning and are never stamped * again. On its first load it indexes its own footprint once: it spawns the boss and the gatekeepers on their * landmarks, finds its gate poddoors (id BOUNTY_LAIR_GATE_ID), and keeps the boss, the gatekeepers and the goons to - * the rooms they started in. When the last gatekeeper dies, the gate opens. When the last boss dies (the mech, then - * the don who climbs out of it), the trophy drops where he fell, unless the boss's own death dropped it through - * bounty_lair_drop_trophy(). + * the rooms they started in. Gatekeepers that are human NPCs are queued (spawn_human_npc(), a body or two a tick); + * until each order has built its body, it counts as a gatekeeper standing, so the gate never opens on an empty back + * office. When the last gatekeeper dies, the gate opens. When the last boss dies (the mech, then the don who climbs + * out of it), the trophy drops where he fell, unless the boss's own death dropped it through bounty_lair_drop_trophy(). * * ## The lair clock (SSbounty_lairs) * @@ -88,8 +89,8 @@ close(BOUNTY_CLOSE_LAIR_GONE) return FALSE -/// Dead, and only dead: the trophy pays in full, anything else pays nothing -/datum/criminal_bounty/kill_only/board_share_for(state, worst_state) +/// Dead, and only dead: the trophy pays in full, anything else pays nothing (a boss brought in cuffed pays nothing: his trophy pays) +/datum/criminal_bounty/kill_only/board_share_for(state) return state == BOUNTY_STATE_DEAD ? 100 : 0 /// The pad takes its trophy only: the one it dropped, or any trophy bound to it, lying on the pad's own tile @@ -274,12 +275,33 @@ return FALSE return TRUE +/// Whether `candidate` is a lair boss: a /mob/living/basic/bounty_lair_boss (the don's mech), or the don on foot (a person) +/proc/bounty_is_lair_boss(mob/living/candidate) + return istype(candidate, /mob/living/basic/bounty_lair_boss) || istype(candidate, /mob/living/carbon/human/npc/bounty_mafia/don) + +/// The weakref to the posting a lair boss is wanted on, or null (not a lair boss, or an admin spawn) +/proc/bounty_lair_boss_posting_ref(mob/living/boss) + if(istype(boss, /mob/living/basic/bounty_lair_boss)) + var/mob/living/basic/bounty_lair_boss/machine = boss + return machine.posting_ref + if(istype(boss, /mob/living/carbon/human/npc/bounty_mafia/don)) + var/mob/living/carbon/human/npc/bounty_mafia/don/person = boss + return person.posting_ref + return null + +/// Makes `boss` wanted on the posting `posting_ref` points at. Does nothing to a mob that isn't a lair boss. +/proc/bounty_lair_set_boss_posting(mob/living/boss, datum/weakref/posting_ref) + if(istype(boss, /mob/living/basic/bounty_lair_boss)) + var/mob/living/basic/bounty_lair_boss/machine = boss + machine.posting_ref = posting_ref + else if(istype(boss, /mob/living/carbon/human/npc/bounty_mafia/don)) + var/mob/living/carbon/human/npc/bounty_mafia/don/person = boss + person.posting_ref = posting_ref + /// The open kill-only bounty a lair boss is wanted on (its posting_ref), or null /proc/bounty_kill_posting_of(mob/living/boss) - if(!istype(boss, /mob/living/basic/bounty_lair_boss)) - return null - var/mob/living/basic/bounty_lair_boss/lair_boss = boss - var/datum/criminal_bounty/kill_only/posting = lair_boss.posting_ref?.resolve() + var/datum/weakref/posting_ref = bounty_lair_boss_posting_ref(boss) + var/datum/criminal_bounty/kill_only/posting = posting_ref?.resolve() if(!istype(posting) || !posting.is_open()) return null return posting @@ -329,6 +351,11 @@ var/list/lair_gate_doors = list() /// Weakrefs to its living gatekeepers; the gate opens when the last one is gone var/list/lair_gatekeepers = list() + /// Gatekeepers still in the human NPC spawn queue: a key per order -> the order (/datum/human_npc_order). Each counts + /// as a gatekeeper standing until it has built its body (or failed to). + var/list/lair_pending_gatekeepers = list() + /// Makes the keys of lair_pending_gatekeepers + var/lair_spawn_serial = 0 /// Weakrefs to the bosses it is waiting on (the mech, then the don who climbs out of it) var/list/lair_bosses = list() /// The gate is open: it stays open, and the gatekeepers never come back @@ -357,6 +384,7 @@ /obj/structure/overmap/space_ruin/bounty_lair/Destroy() lair_unhook_mobs() + lair_cancel_pending_gatekeepers() lair_clear_timers() if(lair_release_timer) deltimer(lair_release_timer) @@ -550,9 +578,15 @@ log_mapping("BOUNTY LAIR: [name] has a boss landmark with no mob type at [AREACOORD(home)]") continue var/datum/npc_spawn_context/context = new(src, null, "boss") - var/mob/living/boss = spawn_npc_in_zone(boss_type, home, context, FALSE) + var/mob/living/boss + if(ispath(boss_type, /mob/living/carbon/human/npc)) + // One body, wanted before the fight can start: built now + var/datum/human_npc_order/order = spawn_human_npc(boss_type, home, context = context, immediate = TRUE) + boss = order?.spawned_ref?.resolve() + else + boss = spawn_npc_in_zone(boss_type, home, context, FALSE) + context.finalize() lair_adopt_boss(boss) - context.finalize() for(var/obj/effect/landmark/bounty_lair_gatekeeper/mark as anything in keeper_marks) if(QDELETED(mark)) @@ -566,17 +600,24 @@ log_mapping("BOUNTY LAIR: [name] has a gatekeeper landmark with no mob type at [AREACOORD(home)]") continue var/datum/npc_spawn_context/context = new(src, null, "boss") + if(ispath(keeper_type, /mob/living/carbon/human/npc)) + // People are queued, never a room of them in one tick: it holds the gate from now, and is watched once built + lair_spawn_serial++ + var/key = "[lair_spawn_serial]" + var/datum/human_npc_order/order = spawn_human_npc(keeper_type, home, CALLBACK(src, PROC_REF(lair_on_gatekeeper_built), key), context = context) + lair_pending_gatekeepers[key] = order + continue var/mob/living/keeper = spawn_npc_in_zone(keeper_type, home, context, FALSE) lair_add_gatekeeper(keeper) context.finalize() lair_leash_goons() - lair_goon_timer = addtimer(CALLBACK(src, PROC_REF(lair_leash_goons)), BOUNTY_LAIR_GOON_LEASH_DELAY, TIMER_STOPPABLE) + lair_goon_timer = addtimer(CALLBACK(src, PROC_REF(lair_settle)), BOUNTY_LAIR_GOON_LEASH_DELAY, TIMER_STOPPABLE) // Nobody left to hold the gate (none mapped, or it was opened before a reload): it stands open - if(lair_gate_open || !length(lair_gatekeepers)) + if(lair_gate_open || (!length(lair_gatekeepers) && !lair_pending_gatekeeper_count())) lair_open_gate(silent = TRUE) lair_link_done = TRUE - log_game("BOUNTY: [name] linked its interior: [length(lair_bosses)] boss(es), [length(lair_gatekeepers)] gatekeeper(s), [length(lair_gate_doors)] gate door(s)") + log_game("BOUNTY: [name] linked its interior: [length(lair_bosses)] boss(es), [length(lair_gatekeepers)] gatekeeper(s) and [lair_pending_gatekeeper_count()] on their way, [length(lair_gate_doors)] gate door(s)") /** * The interior is being given back while the bounty is open (nothing does this while it is mission-locked, so this is @@ -585,6 +626,7 @@ /obj/structure/overmap/space_ruin/bounty_lair/proc/lair_on_unloading(datum/source) SIGNAL_HANDLER lair_unhook_mobs() + lair_cancel_pending_gatekeepers() lair_clear_timers() lair_gate_doors = list() lair_last_death_spot = null @@ -599,9 +641,7 @@ /obj/structure/overmap/space_ruin/bounty_lair/proc/lair_adopt_boss(mob/living/boss) if(QDELETED(boss)) return FALSE - if(istype(boss, /mob/living/basic/bounty_lair_boss)) - var/mob/living/basic/bounty_lair_boss/lair_boss = boss - lair_boss.posting_ref = posting_ref + bounty_lair_set_boss_posting(boss, posting_ref) lair_bosses |= WEAKREF(boss) lair_watch(boss, PROC_REF(lair_on_boss_gone)) lair_leash(boss) @@ -637,7 +677,7 @@ if(!posting || lair_boss_killed) return var/standing = FALSE - for(var/mob/living/basic/bounty_lair_boss/boss as anything in lair_bosses_inside()) + for(var/mob/living/boss as anything in lair_bosses_inside()) if(boss.stat == DEAD) continue if(!boss.weak_reference || !(boss.weak_reference in lair_bosses)) @@ -673,13 +713,13 @@ log_game("BOUNTY: [name]'s boss is dead but there was no safe floor for its trophy; closing its bounty") posting.close(BOUNTY_CLOSE_LAIR_GONE) -/// Every lair boss standing in its footprint +/// Every lair boss standing in its footprint (bounty_is_lair_boss()) /obj/structure/overmap/space_ruin/bounty_lair/proc/lair_bosses_inside() . = list() if(!footprint) return - for(var/mob/living/basic/bounty_lair_boss/boss in GLOB.mob_living_list) - if(!QDELETED(boss) && footprint.contains_turf(get_turf(boss))) + for(var/mob/living/boss as anything in GLOB.mob_living_list) + if(!QDELETED(boss) && bounty_is_lair_boss(boss) && footprint.contains_turf(get_turf(boss))) . += boss /// A trophy already bound to `posting` near where the boss fell (a boss's death that made its own) @@ -699,8 +739,8 @@ if(QDELETED(keeper)) return FALSE lair_gatekeepers |= WEAKREF(keeper) - // Troopers delete themselves on death and leave a corpse spawner: either signal counts, whichever comes first. - // An admin deleting one counts as gone too: a gate that never opens is worse. + // A person dies in place (COMSIG_LIVING_DEATH); a mob deleted on death, or by an admin, counts as gone too, whichever + // signal comes first: a gate that never opens is worse. lair_watch(keeper, PROC_REF(lair_on_gatekeeper_gone)) lair_leash(keeper) return TRUE @@ -713,7 +753,7 @@ lair_gatekeepers -= source.weak_reference lair_check_gate() -/// Opens the gate if no gatekeeper is left standing. Returns TRUE if it opened now. +/// Opens the gate if no gatekeeper is left standing, and none is still on its way. Returns TRUE if it opened now. /obj/structure/overmap/space_ruin/bounty_lair/proc/lair_check_gate() if(lair_gate_open) return FALSE @@ -723,9 +763,48 @@ lair_gatekeepers -= ref continue return FALSE + if(lair_pending_gatekeeper_count()) + return FALSE lair_open_gate() return TRUE +/** + * How many queued gatekeepers are still to be built. An order that was cancelled, or built nothing, is dropped here; + * one that built its body has already moved to lair_gatekeepers (lair_on_gatekeeper_built()). + */ +/obj/structure/overmap/space_ruin/bounty_lair/proc/lair_pending_gatekeeper_count() + . = 0 + for(var/key in lair_pending_gatekeepers.Copy()) + var/datum/human_npc_order/order = lair_pending_gatekeepers[key] + if(QDELETED(order) || order.done) + lair_pending_gatekeepers -= key + continue + .++ + +/// A queued gatekeeper (`key`) was built: it holds the gate from now, kept to its room, unless the gate opened meanwhile +/obj/structure/overmap/space_ruin/bounty_lair/proc/lair_on_gatekeeper_built(key, mob/living/keeper) + if(QDELETED(src)) + return + var/known = !isnull(lair_pending_gatekeepers[key]) + lair_pending_gatekeepers -= key + if(QDELETED(keeper)) + lair_check_gate() + return + lair_leash(keeper) + if(!known || lair_gate_open || !lair_posting()) + return + lair_add_gatekeeper(keeper) + +/// Calls off every gatekeeper still in the spawn queue (the interior is going, or the lair is) +/obj/structure/overmap/space_ruin/bounty_lair/proc/lair_cancel_pending_gatekeepers() + var/list/orders = list() + for(var/key in lair_pending_gatekeepers) + orders += lair_pending_gatekeepers[key] + lair_pending_gatekeepers = list() + for(var/datum/human_npc_order/order as anything in orders) + if(!QDELETED(order) && !order.done) + qdel(order) + /// Opens its gate poddoors, the ones in its own footprint only, and tells everyone inside unless `silent` /obj/structure/overmap/space_ruin/bounty_lair/proc/lair_open_gate(silent = FALSE) lair_gate_open = TRUE @@ -757,9 +836,15 @@ lair_mob.AddElement(/datum/element/bounty_lair_room_leash, home.type) return TRUE +/// Once every marker has spawned (the zone resolver retries for up to a minute, then the people are queued): the late goons +/// are kept to their rooms, and a gatekeeper order that never built a body stops holding the gate +/obj/structure/overmap/space_ruin/bounty_lair/proc/lair_settle() + lair_goon_timer = null + lair_leash_goons() + lair_check_gate() + /// Keeps every living goon of its kind in the room it stands in. Runs at the link, and again once every marker has spawned. /obj/structure/overmap/space_ruin/bounty_lair/proc/lair_leash_goons() - lair_goon_timer = null var/goon_type = lair_kind?.goon_type if(!goon_type || !footprint || !loaded) return 0 @@ -774,13 +859,16 @@ /** * Keeps a lair mob in the room (area) it started in: it won't step out of it on its own, so it fights from the * doorway and a fight never drags the next room in (balance/lairs.md 9.2). Moves it doesn't make itself are never - * stopped (pulled, thrown, or dead), and once it is out of its room it walks freely, so it can never be stuck. + * stopped (pulled, carried or wheeled on what it is buckled to, thrown, shoved, or dead), and once it is out of its + * room it walks freely, so it can never be stuck. */ /datum/element/bounty_lair_room_leash element_flags = ELEMENT_BESPOKE argument_hash_start_idx = 2 /// The area type it is kept to. A type, not the area: a lair's areas are per-load instances, and no ref is held. var/home_area_type + /// REF() of each mob shoved -> the world.time of the shove: the push of a shove is someone else's move + var/list/shoved_at = list() /datum/element/bounty_lair_room_leash/Attach(datum/target, home_area_type) . = ..() @@ -788,14 +876,20 @@ return ELEMENT_INCOMPATIBLE src.home_area_type = home_area_type RegisterSignal(target, COMSIG_MOVABLE_PRE_MOVE, PROC_REF(on_pre_move), override = TRUE) + RegisterSignal(target, COMSIG_LIVING_DISARM_HIT, PROC_REF(on_shoved), override = TRUE) /datum/element/bounty_lair_room_leash/Detach(datum/source) - UnregisterSignal(source, COMSIG_MOVABLE_PRE_MOVE) + UnregisterSignal(source, list(COMSIG_MOVABLE_PRE_MOVE, COMSIG_LIVING_DISARM_HIT)) + shoved_at -= REF(source) return ..() +/datum/element/bounty_lair_room_leash/proc/on_shoved(mob/living/source, mob/living/attacker, zone, obj/item/weapon) + SIGNAL_HANDLER + shoved_at[REF(source)] = world.time + /datum/element/bounty_lair_room_leash/proc/on_pre_move(mob/living/source, atom/new_location) SIGNAL_HANDLER - if(source.stat == DEAD || source.pulledby || source.throwing) + if(source.stat == DEAD || source.pulledby || source.buckled || source.throwing || shoved_at[REF(source)] == world.time) return NONE var/area/here = get_area(source) if(here?.type != home_area_type) @@ -916,7 +1010,7 @@ trophy_type = /obj/item/bounty_proof/trophy/mafia_don mugshot_icon = 'icons/mob/rideables/mecha.dmi' mugshot_state = "mauler" - goon_type = /mob/living/basic/trooper/russian/mafia + goon_type = /mob/living/carbon/human/npc/bounty_mafia gate_message = "The garage door grinds open." /** diff --git a/voidcrew/modules/bounties/bounty_lair_mafia.dm b/voidcrew/modules/bounties/bounty_lair_mafia.dm index 796e4eb45f9..822e2d3d63c 100644 --- a/voidcrew/modules/bounties/bounty_lair_mafia.dm +++ b/voidcrew/modules/bounties/bounty_lair_mafia.dm @@ -8,42 +8,54 @@ * declared in bounty_lair_types.dm; this file sets their values and behaviour. Its numbers are in the P12 * section of voidcrew/_DEFINES/bounty_lairs.dm, its lines in strings/bounty_lair_mafia.json. * + * The goons, the lieutenants and the don are real human NPCs (voidcrew/modules/human_npcs/, phase D of the human NPC + * migration): a person's body, crit, wounds, cuffs and death, dressed in their Club Volga clothes, holding real guns + * with real spare magazines, reloading them by hand. Their kit is locked to them (owner decision D3), so a corpse + * leaves no gun. Only the don's mech is a mob of its own: it is a machine (owner call OC-5). + * * How the club fights: - * - **Goons** (/mob/living/basic/trooper/russian/mafia: knife, /pistol, /smg) keep to the room (area) they - * spawned in: they never walk out of it, and come to its door to get a line. A room is alerted by what its - * own goons see or what hits them: the one who spots a hunter shouts, the room's first shots follow a + * - **Goons** (/mob/living/carbon/human/npc/bounty_mafia: a kitchen knife, /pistol a Stechkin, /smg an Uzi) keep to + * the room (area) they spawned in: they never walk out of it, and come to its door to get a line. A room is alerted + * by what its own goons see or what hits them: the one who spots a hunter shouts, the room's first shots follow a * second later and spread over another second, and gunmen kick a wood table over for cover. At most * BOUNTY_MOBSTER_MAX_ON_ONE goons of a room go after one hunter standing in a doorway, however many are shot at. - * Grabbed, a goon breaks free and fights its grabber; dragged or thrown out of its room it still fights, and - * only walks back once there's nobody to fight. Nobody in the club targets a hunter who is down. Polymorph and - * type changes are refused. They leave a corpse in club clothes and never a gun. - * - **Lieutenants** (/lieutenant, /lieutenant/tommy, /lieutenant/brute) are tougher goons that hold the - * arena gate. The base type takes whichever role its room doesn't have yet, so two plain gatekeeper - * landmarks give one of each. They die like any trooper: COMSIG_LIVING_DEATH, then deletion. - * - **The mech** (/mob/living/basic/bounty_lair_boss/mafia_mech) is a mob that looks like a Mauler, not a tg - * mecha and not /mob/living/basic/boss. Its health follows the hunters engaged (P4's posse rule), counting - * exosuit pilots and harmless shots such as ion bolts. Anyone who hurts it is fair game at any range: it closes - * in as far as its arena lets it and answers from there, so it can't be sniped from past its sight. Every - * ability winds up where everyone can see it: the rocket volley puts a marker under each hunter it sees, - * then fires one non-breaching rocket per marker; the LMG shows a red cone out to its target that stays until - * the burst ends. An EMP stalls it (the ability it cut off is ready again as the stall ends) rather than - * killing it. With nobody left to fight for BOUNTY_MECH_RESET_AFTER it resets. It never leaves its arena. - * - **The don** (/mob/living/basic/bounty_lair_boss/mafia_don) climbs out when the mech breaks, next to a - * burnt-out wreck he uses for cover, holding the mech's grudges. He can't be cuffed and fights to the death; - * his death drops the gold signet ring (/obj/item/bounty_proof/trophy/mafia_don) with the posting on it, which - * P10 pays on. + * Grabbed, a goon resists the tg way and fights its grabber; dragged, carried, shoved or thrown out of its room it + * still fights, and only walks back once there's nobody to fight. Someone starting to cuff a goon who can still + * move sees it step away. Nobody in the club picks a hunter who is down as a target (only the choice: a round in + * flight hits whoever is in the way). Polymorph and type changes are refused. + * - **Lieutenants** (/lieutenant, /lieutenant/tommy, /lieutenant/brute) are elite goons in real armour that hold the + * arena gate. The base type takes whichever role its room doesn't have yet, so two plain gatekeeper landmarks give + * one of each. They die in place like anyone: P10 opens the gate on COMSIG_LIVING_DEATH. Tommy fires a Thompson; + * Brute punches, and a landed punch now and then knocks the hunter down (a tg Knockdown). + * - **The mech** (/mob/living/basic/bounty_lair_boss/mafia_mech) is a mob that looks like a Mauler, not a tg mecha + * and not /mob/living/basic/boss. Its health follows the hunters engaged (P4's posse rule), counting exosuit pilots + * and harmless shots such as ion bolts. Anyone who hurts it is fair game at any range: it closes in as far as its + * arena lets it and answers from there, so it can't be sniped from past its sight. Every ability winds up where + * everyone can see it: the rocket volley puts a marker under each hunter it sees, then fires one rocket per marker, + * whose burst is tg's light blast on everyone standing there, whatever their state, and never explosion(); the LMG + * shows a red cone out to its target that stays until the burst ends, and its rounds hit whoever is in the way. An + * EMP stalls it (the ability it cut off is ready again as the stall ends) rather than killing it. With nobody left + * to fight for BOUNTY_MECH_RESET_AFTER it repairs itself. It never leaves its arena. + * - **The don** (/mob/living/carbon/human/npc/bounty_mafia/don) climbs out when the mech breaks, next to a burnt-out + * wreck he uses for cover while he reloads, holding the mech's grudges. He never gives up: someone starting to cuff + * him while he can still move hears about it and sees him step away; cuffed, he works at the cuffs. A cuffed don + * still pays nothing: the lair is kill-only, and only his ring pays. His death drops the gold signet ring + * (/obj/item/bounty_proof/trophy/mafia_don) with the posting on it, once, which P10 pays on. + * + * For P10: a gatekeeper's death is COMSIG_LIVING_DEATH (watch COMSIG_QDELETING too, for an admin delete). The mech + * hands its posting_ref to the don and sends COMSIG_BOUNTY_MAFIA_DON_EJECTED with him before its own death; the don's + * death drops the ring through P10's bounty_lair_drop_trophy() and sends COMSIG_BOUNTY_MAFIA_TROPHY_DROPPED with it. + * Everyone keeps to their room by bounty_mafia_leash_allows(), the same rule as P10's + * /datum/element/bounty_lair_room_leash, which a lair also puts on its mobs. * - * For P10: a gatekeeper's death is COMSIG_LIVING_DEATH (the lieutenant is deleted right after, so watch - * COMSIG_QDELETING too for an admin delete). The mech hands its posting_ref to the don and sends - * COMSIG_BOUNTY_MAFIA_DON_EJECTED with him before its own death; the don's death drops the ring through P10's - * bounty_lair_drop_trophy() and sends COMSIG_BOUNTY_MAFIA_TROPHY_DROPPED with it. Everyone keeps to their room by - * bounty_mafia_leash_allows(), the same rule as P10's /datum/element/bounty_lair_room_leash. + * The club is built a body at a time (spawn_human_npc(), queued): its markers queue their goons, the lair queues the + * lieutenants, and only the don, one body the fight needs at once, is built on the spot. * * Nothing here scans turfs on a tick: targets come from SSmobs' list of players on the level, and every * telegraph and timer is tracked and cleaned up. */ -/// Trait source for a club mob standing still while it winds up, fires or reels +/// Trait source for the mech standing still while it winds up, fires or reels #define BOUNTY_MAFIA_BUSY_TRAIT "bounty_mafia_busy" // ===== SHARED ===== @@ -59,7 +71,10 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) return FALSE return !isnull(candidate.mind) || !isnull(candidate.client) -/// Whether a club mob may shoot or hit `target` now: a hunter on their feet, never anyone already down (spec 12.3 C4) +/** + * Whether a club mob may pick `target` to go after: a hunter on their feet, never anyone already down (spec 12.3 C4). + * Only the choice of target: what is fired hits whoever it hits (defaults 1.11, CB-11). + */ /proc/bounty_mafia_may_hurt(mob/living/target) if(!bounty_mafia_is_hunter(target) || target.stat != CONSCIOUS) return FALSE @@ -89,9 +104,15 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) var/list/lines = GLOB.string_cache?[BOUNTY_MAFIA_STRINGS_FILE]?[context] return length(lines) ? pick(lines) : null -/// `speaker` says a line for `context`, off the caller's stack (safe from signal handlers). TRUE if there was one. +/** + * `speaker` says a line for `context`, off the caller's stack (safe from signal handlers). TRUE if there was one. + * A person speaks on their feet or whispers in soft crit (tg's say() does the whisper), never deeper down. + */ /proc/bounty_mafia_say(mob/living/speaker, context) - if(QDELETED(speaker) || speaker.stat != CONSCIOUS) + if(QDELETED(speaker)) + return FALSE + var/can_talk = ishuman(speaker) ? human_npc_can_talk(speaker) : (speaker.stat == CONSCIOUS) + if(!can_talk) return FALSE var/line = bounty_mafia_line(context) if(!line) @@ -99,46 +120,15 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) INVOKE_ASYNC(speaker, TYPE_PROC_REF(/atom/movable, say), line) return TRUE -/** - * Fires one round of `weapon` (a /datum/bounty_real_weapon) from `shooter` at `target` (a mob or a turf) as - * `projectile_type`: every pellet of a shell, each with the real round's numbers and spread, plus `spread` degrees - * more (full width) if given, and no farther than `max_range` tiles if given. The club's own faction is never hit by - * it. Returns the first projectile still flying, or null. - */ -/proc/bounty_mafia_shoot(mob/living/shooter, projectile_type, atom/target, datum/bounty_real_weapon/weapon, spread = 0, max_range) - var/turf/start = get_turf(shooter) - var/turf/aim = get_turf(target) - if(!start || !aim || start == aim || !weapon) - return null - var/obj/projectile/first - for(var/pellet in 1 to weapon.pellets) - var/obj/projectile/bullet = new projectile_type(start) - weapon.load(bullet) - if(max_range) - bullet.range = max_range - bullet.maximum_range = max_range - bullet.firer = shooter - bullet.fired_from = shooter - bullet.ignored_factions = shooter.faction?.Copy() - bullet.spread = spread - bullet.aim_projectile(target, shooter, null, weapon.shot_spread()) - if(QDELETED(bullet)) - continue - bullet.fire() - if(!first && !QDELETED(bullet)) - first = bullet - if(weapon.fire_sound) - playsound(shooter, weapon.fire_sound, 60, TRUE) - return first - /** * Whether `mover`, kept to the room (area) `home`, may step onto `new_loc` on its own: anywhere in its room, never * out of it, so it fights from its doorway and a fight never drags the next room in (lairs.md 9.2). The same rule as * P10's /datum/element/bounty_lair_room_leash, which a lair also puts on its mobs at load, so the two always agree: - * moves it doesn't make itself (pulled, thrown, dead) are never stopped, and once out of its room it walks freely. + * moves it doesn't make itself (pulled, carried or wheeled on what it is buckled to, thrown, `shoved`, dead) are never + * stopped, and once out of its room it walks freely. */ -/proc/bounty_mafia_leash_allows(mob/living/mover, area/home, atom/new_loc) - if(!home || !new_loc || mover.stat == DEAD || mover.pulledby || mover.throwing) +/proc/bounty_mafia_leash_allows(mob/living/mover, area/home, atom/new_loc, shoved = FALSE) + if(!home || !new_loc || mover.stat == DEAD || mover.pulledby || mover.buckled || mover.throwing || shoved) return TRUE if(get_area(mover) != home) return TRUE @@ -172,14 +162,14 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) if(!at) return null var/static/list/crews = list( - "foyer" = list(/mob/living/basic/trooper/russian/mafia = 2, /mob/living/basic/trooper/russian/mafia/pistol = 1), - "cloakroom" = list(/mob/living/basic/trooper/russian/mafia/pistol = 1, /mob/living/basic/trooper/russian/mafia = 1, /mob/living/basic/trooper/russian/mafia/smg = 1), - "casino" = list(/mob/living/basic/trooper/russian/mafia/pistol = 2, /mob/living/basic/trooper/russian/mafia = 2, /mob/living/basic/trooper/russian/mafia/smg = 1), - "bar" = list(/mob/living/basic/trooper/russian/mafia/pistol = 2, /mob/living/basic/trooper/russian/mafia/smg = 1, /mob/living/basic/trooper/russian/mafia = 1), - "kitchen" = list(/mob/living/basic/trooper/russian/mafia = 2, /mob/living/basic/trooper/russian/mafia/pistol = 1), - "vip" = list(/mob/living/basic/trooper/russian/mafia/smg = 1, /mob/living/basic/trooper/russian/mafia/pistol = 2, /mob/living/basic/trooper/russian/mafia = 1), - "counting" = list(/mob/living/basic/trooper/russian/mafia/pistol = 1, /mob/living/basic/trooper/russian/mafia = 1, /mob/living/basic/trooper/russian/mafia/smg = 1), - "back_office" = list(/mob/living/basic/trooper/russian/mafia/pistol = 1), + "foyer" = list(/mob/living/carbon/human/npc/bounty_mafia = 2, /mob/living/carbon/human/npc/bounty_mafia/pistol = 1), + "cloakroom" = list(/mob/living/carbon/human/npc/bounty_mafia/pistol = 1, /mob/living/carbon/human/npc/bounty_mafia = 1, /mob/living/carbon/human/npc/bounty_mafia/smg = 1), + "casino" = list(/mob/living/carbon/human/npc/bounty_mafia/pistol = 2, /mob/living/carbon/human/npc/bounty_mafia = 2, /mob/living/carbon/human/npc/bounty_mafia/smg = 1), + "bar" = list(/mob/living/carbon/human/npc/bounty_mafia/pistol = 2, /mob/living/carbon/human/npc/bounty_mafia/smg = 1, /mob/living/carbon/human/npc/bounty_mafia = 1), + "kitchen" = list(/mob/living/carbon/human/npc/bounty_mafia = 2, /mob/living/carbon/human/npc/bounty_mafia/pistol = 1), + "vip" = list(/mob/living/carbon/human/npc/bounty_mafia/smg = 1, /mob/living/carbon/human/npc/bounty_mafia/pistol = 2, /mob/living/carbon/human/npc/bounty_mafia = 1), + "counting" = list(/mob/living/carbon/human/npc/bounty_mafia/pistol = 1, /mob/living/carbon/human/npc/bounty_mafia = 1, /mob/living/carbon/human/npc/bounty_mafia/smg = 1), + "back_office" = list(/mob/living/carbon/human/npc/bounty_mafia/pistol = 1), ) return crews[copytext(type_text, at + length(marker))] @@ -213,7 +203,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) var/room_key /// Its area var/datum/weakref/area_ref - /// Weakrefs to its goons (/mob/living/basic/trooper/russian/mafia) + /// Weakrefs to its goons (/mob/living/carbon/human/npc/bounty_mafia) var/list/members = list() /// Someone has seen or been hit by a hunter: the shout has gone up var/alerted = FALSE @@ -271,26 +261,26 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) break return room_exits -/datum/bounty_mafia_room/proc/join(mob/living/basic/trooper/russian/mafia/goon) +/datum/bounty_mafia_room/proc/join(mob/living/carbon/human/npc/bounty_mafia/goon) members |= WEAKREF(goon) -/datum/bounty_mafia_room/proc/leave(mob/living/basic/trooper/russian/mafia/goon) +/datum/bounty_mafia_room/proc/leave(mob/living/carbon/human/npc/bounty_mafia/goon) members -= WEAKREF(goon) if(!length(members)) qdel(src) -/// Its goons still standing +/// Its goons still alive /datum/bounty_mafia_room/proc/goons() . = list() for(var/datum/weakref/ref as anything in members) - var/mob/living/basic/trooper/russian/mafia/goon = ref.resolve() + var/mob/living/carbon/human/npc/bounty_mafia/goon = ref.resolve() if(!QDELETED(goon) && goon.stat != DEAD) . += goon /// How many of its goons, besides `except`, are going after `hunter` /datum/bounty_mafia_room/proc/attackers_on(mob/living/hunter, mob/living/except) . = 0 - for(var/mob/living/basic/trooper/russian/mafia/goon as anything in goons()) + for(var/mob/living/carbon/human/npc/bounty_mafia/goon as anything in goons()) if(goon != except && goon.ai_controller?.blackboard[BB_BASIC_MOB_CURRENT_TARGET] == hunter) .++ @@ -304,221 +294,28 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) * BOUNTY_MOBSTER_ALERT, the others spread over the next BOUNTY_MOBSTER_FIRST_SHOT_SPREAD. Returns TRUE if this * alerted it. */ -/datum/bounty_mafia_room/proc/raise_alarm(mob/living/basic/trooper/russian/mafia/spotter, mob/living/hunter) +/datum/bounty_mafia_room/proc/raise_alarm(mob/living/carbon/human/npc/bounty_mafia/spotter, mob/living/hunter) if(hunter) hunter_ref = WEAKREF(hunter) if(alerted) return FALSE alerted = TRUE - for(var/mob/living/basic/trooper/russian/mafia/goon as anything in goons()) + for(var/mob/living/carbon/human/npc/bounty_mafia/goon as anything in goons()) goon.mafia_on_alarm(spotter, goon == spotter ? 0 : rand(0, BOUNTY_MOBSTER_FIRST_SHOT_SPREAD), hunter) return TRUE -// ===== GUNS ===== - -/** - * A club mob's gun, simulated: no item, nothing to drop, but every round is the real gun's - * (`gun_type`, bounty_real_weapon()): its damage, wounds, armour penetration, spread and magazine. - * try_fire() spins it up first if it has a wind-up, then fires a burst of real projectiles, and - * reloads when the magazine is spent. A hit during the wind-up can spoil it (fumble()). Its timers - * check `serial`, so a cancelled shot does nothing. - */ -/datum/bounty_mafia_gun - /// What it's called in messages - var/gun_name = "pistol" - /// The real gun: the one in its owner's hand - var/gun_type = BOUNTY_MOBSTER_PISTOL_GUN - var/projectile_type = /obj/projectile/bullet/bounty_mafia - /// Shots in one burst, and the time between them. A pistol fires a quick string of shots each time. - var/burst = BOUNTY_MOBSTER_PISTOL_BURST - var/burst_delay = BOUNTY_MOBSTER_PISTOL_BURST_GAP - /// From the start of one burst (or wind-up) to the next - var/cooldown = BOUNTY_MOBSTER_PISTOL_COOLDOWN - var/reload_time = BOUNTY_MOBSTER_PISTOL_RELOAD - /// The spin-up before a burst, if any - var/windup = 0 - /// The wind-up comes once per magazine (the don raises his pistol before each string), not before every burst - var/windup_once_per_magazine = FALSE - var/windup_sound - var/reload_sound = 'sound/items/weapons/gun/pistol/mag_insert.ogg' - /// Dialogue context its owner may say on reloading, and the chance they do - var/reload_context = "goon_reload" - var/reload_bark_chance = 35 - /// A hit during the wind-up spoils it - var/fumbles = FALSE - /// The real gun's numbers (/datum/bounty_real_weapon) - var/datum/bounty_real_weapon/weapon - /// Rounds in a full magazine: the real gun's - var/magazine = 0 - /// Rounds left in the magazine - var/ammo - /// world.time it may start the next burst or wind-up - var/next_fire_at = 0 - /// world.time the reload is done - var/reloading_until = 0 - /// Spinning up now - var/winding = FALSE - /// Raised this magazine (windup_once_per_magazine) - var/raised = FALSE - /// Goes up with every burst or wind-up, and on a fumble, so stale timers do nothing - var/serial = 0 - /// Its owner (/mob/living) - var/datum/weakref/owner_ref - /// What it's aimed at - var/datum/weakref/aim_ref - -/datum/bounty_mafia_gun/New(mob/living/owner) - . = ..() - owner_ref = WEAKREF(owner) - weapon = bounty_real_weapon(gun_type) - magazine = max(1, weapon.magazine) - ammo = magazine - -/datum/bounty_mafia_gun/Destroy() - serial++ - owner_ref = null - aim_ref = null - weapon = null - return ..() - -/datum/bounty_mafia_gun/proc/owner() - var/mob/living/owner = owner_ref?.resolve() - return QDELETED(owner) ? null : owner - -/// Ready to start a burst or a wind-up -/datum/bounty_mafia_gun/proc/ready() - return !winding && world.time >= next_fire_at - -/datum/bounty_mafia_gun/proc/is_reloading() - return world.time < reloading_until - -/datum/bounty_mafia_gun/proc/owner_can_fire(mob/living/owner) - return owner && owner.stat == CONSCIOUS && isturf(owner.loc) && !HAS_TRAIT(owner, TRAIT_INCAPACITATED) - -/// Starts a burst at `target`, after the wind-up if it has one. Returns TRUE if it started. -/datum/bounty_mafia_gun/proc/try_fire(atom/target) - var/mob/living/owner = owner() - if(!owner_can_fire(owner) || !ready() || QDELETED(target)) - return FALSE - aim_ref = WEAKREF(target) - serial++ - owner.face_atom(target) - if(windup && !(windup_once_per_magazine && raised)) - winding = TRUE - next_fire_at = world.time + windup + cooldown - if(windup_sound) - playsound(owner, windup_sound, 50, TRUE) - owner.balloon_alert_to_viewers("aiming!") - addtimer(CALLBACK(src, PROC_REF(finish_windup), serial), windup, TIMER_DELETE_ME) - return TRUE - fire_burst() - return TRUE - -/// The wind-up under `fire_serial` is over: the burst goes, unless it was spoiled. Returns TRUE if it fired. -/datum/bounty_mafia_gun/proc/finish_windup(fire_serial) - if(fire_serial != serial || !winding) - return FALSE - winding = FALSE - raised = TRUE - if(!owner_can_fire(owner())) - return FALSE - fire_burst() - return TRUE - -/// A burst: as many of its shots as the magazine has rounds left, then a reload if it's spent -/datum/bounty_mafia_gun/proc/fire_burst() - var/shots = clamp(burst, 1, ammo) - ammo -= shots - next_fire_at = max(next_fire_at, world.time + cooldown) - var/fire_serial = serial - shoot_once(fire_serial) - for(var/i in 2 to shots) - addtimer(CALLBACK(src, PROC_REF(shoot_once), fire_serial), (i - 1) * burst_delay, TIMER_DELETE_ME) - if(ammo <= 0) - start_reload((shots - 1) * burst_delay) - -/// One shot of the burst under `fire_serial`. Never at someone who went down meanwhile. -/datum/bounty_mafia_gun/proc/shoot_once(fire_serial) - if(fire_serial != serial) - return null - var/mob/living/owner = owner() - var/atom/target = aim_ref?.resolve() - if(!owner_can_fire(owner) || QDELETED(target)) - return null - if(isliving(target) && !bounty_mafia_may_hurt(target)) - return null - owner.face_atom(target) - return bounty_mafia_shoot(owner, projectile_type, target, weapon) - -/// A fresh magazine, ready `delay` + reload_time from now -/datum/bounty_mafia_gun/proc/start_reload(delay = 0) - ammo = magazine - raised = FALSE - reloading_until = world.time + delay + reload_time - next_fire_at = max(next_fire_at, reloading_until) - var/mob/living/owner = owner() - if(!owner) - return - if(reload_sound) - playsound(owner, reload_sound, 40, TRUE) - if(reload_context && prob(reload_bark_chance)) - bounty_mafia_say(owner, reload_context) - -/// The wind-up is spoiled: nothing fires, and the next try waits `delay` -/datum/bounty_mafia_gun/proc/fumble(delay) - serial++ - winding = FALSE - next_fire_at = max(next_fire_at, world.time + delay) - -/datum/bounty_mafia_gun/smg - gun_name = "SMG" - gun_type = BOUNTY_MOBSTER_SMG_GUN - burst = BOUNTY_MOBSTER_SMG_BURST - burst_delay = BOUNTY_MOBSTER_SMG_BURST_GAP - cooldown = BOUNTY_MOBSTER_SMG_COOLDOWN - reload_time = BOUNTY_MOBSTER_SMG_RELOAD - windup = BOUNTY_MOBSTER_SMG_WINDUP - windup_sound = 'sound/items/weapons/gun/smg/smgrack.ogg' - reload_sound = 'sound/items/weapons/gun/general/magazine_insert_full.ogg' - fumbles = TRUE - -/datum/bounty_mafia_gun/tommy - gun_name = "Tommy gun" - gun_type = BOUNTY_LIEUTENANT_TOMMY_GUN - burst = BOUNTY_LIEUTENANT_TOMMY_BURST - burst_delay = BOUNTY_LIEUTENANT_TOMMY_BURST_GAP - cooldown = BOUNTY_LIEUTENANT_TOMMY_COOLDOWN - reload_time = BOUNTY_LIEUTENANT_TOMMY_RELOAD - windup = BOUNTY_LIEUTENANT_TOMMY_WINDUP - windup_sound = 'sound/items/weapons/gun/smg/smgrack.ogg' - reload_sound = 'sound/items/weapons/gun/general/magazine_insert_full.ogg' - -/datum/bounty_mafia_gun/don - gun_name = "gold pistol" - gun_type = BOUNTY_DON_GUN - cooldown = BOUNTY_DON_COOLDOWN - reload_time = BOUNTY_DON_RELOAD - windup = BOUNTY_DON_RAISE - windup_once_per_magazine = TRUE - windup_sound = 'sound/items/weapons/gun/pistol/rack_small.ogg' - reload_context = "don_reload" - reload_bark_chance = 50 - -// ===== PROJECTILES ===== - -/// A club bullet: the real round of the gun that fires it (bounty_mafia_shoot()) -/obj/projectile/bullet/bounty_mafia - name = "bullet" +// ===== THE MECH'S ROUNDS ===== +// The club's people fire the real guns in their hands; only the machine fires rounds of its own. /// The mech's machine gun: its real exosuit gun's rounds (BOUNTY_MECH_LMG_GUN), which barely scratch furniture -/obj/projectile/bullet/bounty_mafia/lmg +/obj/projectile/bullet/bounty_mafia_lmg name = "machine gun round" demolition_mod = BOUNTY_MECH_LMG_DEMOLITION /** * The mech's rocket: the cyberware buster's pattern, never tg's rocket and never explosion(). It flies through - * people to the marker it was fired at, and there does BOUNTY_MECH_ROCKET_DAMAGE brute and a knockdown to each - * hunter still standing on it, once a volley each. A player's exosuit in its way takes + * people to the marker it was fired at, and there it bursts: tg's light blast (ex_act(EXPLODE_LIGHT)) on everyone + * standing on it, whatever their state, once a volley each. A player's exosuit in its way takes * BOUNTY_MECH_ROCKET_EXOSUIT_DAMAGE, never the anti-structure multiplier. It bursts harmlessly on a wall, a pillar * or anything else in its way; it breaks tables, windows and doors only inside the club's garage. */ @@ -535,7 +332,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) projectile_phasing = PASSMOB /// The marker it flies to var/turf/rocket_target - /// REF() of each hunter this volley has hit -> TRUE, shared by the volley's rockets + /// REF() of each mob this volley has hit -> TRUE, shared by the volley's rockets var/list/rocket_volley /// The arena (/area), the only place it breaks things var/datum/weakref/rocket_area_ref @@ -590,7 +387,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) return FALSE return get_area(spot) == arena -/// The bang, and nothing else: the fake explosion and its sound +/// The look and sound of the burst, and nothing else /obj/projectile/bullet/bounty_mafia_rocket/proc/rocket_burst(turf/spot) if(rocket_done || !spot) return FALSE @@ -599,53 +396,46 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) playsound(spot, 'sound/effects/explosion/explosion1.ogg', 60, TRUE) return TRUE -/// It reached its marker on `spot`: the bang, and the hit on each hunter standing there not yet hit this volley. Returns who it hit. +/** + * It reached its marker on `spot`: the burst, and tg's light blast on each mob standing there that this volley hasn't + * caught yet, whatever its state (CB-10: the blast is ex_act's, which spreads the damage, wounds, deafens and knocks + * down by the victim's bomb armour; no explosion(), so nothing is breached). Returns who it caught. + */ /obj/projectile/bullet/bounty_mafia_rocket/proc/rocket_detonate(turf/spot) . = list() if(rocket_done || !spot) return rocket_burst(spot) for(var/mob/living/victim in spot) - if(!bounty_mafia_may_hurt(victim)) + if(victim == firer) continue var/key = REF(victim) if(rocket_volley?[key]) continue if(rocket_volley) rocket_volley[key] = TRUE - var/blocked = victim.run_armor_check(BODY_ZONE_CHEST, BULLET, silent = TRUE) - victim.apply_damage(npc_zone_damage(damage, npc_zone_damage_factor, npc_zone_damage_scaled), BRUTE, BODY_ZONE_CHEST, blocked) - victim.Knockdown(BOUNTY_MECH_ROCKET_KNOCKDOWN) + victim.ex_act(EXPLODE_LIGHT, null, src) to_chat(victim, span_userdanger("A rocket bursts right at your feet!")) . += victim if(!QDELETED(src)) qdel(src) -// ===== GOONS ===== +// ===== THE CLUB'S PEOPLE ===== /** - * A club mobster. The base is the knife man; /pistol and /smg carry guns. Every blow and round is the real - * item's in its hand (`r_hand`, bounty_real_weapon()), at the club's own pace (lairs.md 3.1). + * A club mobster, a person. The base is the knife man; /pistol and /smg carry guns, /lieutenant holds the gate and + * /don runs the family. Each holds its real weapon from the start (they are on the clock in a mob club), with its + * spare magazines in its pockets, and fights with it through its hands (the AI's clicks). */ -/mob/living/basic/trooper/russian/mafia - name = "mobster" - desc = "A heavy in a tracksuit, working for the family that runs this club. He has a knife out." - maxHealth = BOUNTY_MOBSTER_KNIFE_HEALTH - health = BOUNTY_MOBSTER_KNIFE_HEALTH - speed = BOUNTY_MOBSTER_KNIFE_SPEED - melee_attack_cooldown = BOUNTY_MOBSTER_KNIFE_COOLDOWN +/mob/living/carbon/human/npc/bounty_mafia + npc_name = "mobster" + npc_look = /obj/effect/mob_spawn/corpse/human/bounty_mafia + npc_outfit = /datum/outfit/bounty_mafia_goon/armed + npc_target_stat = HUMAN_NPC_SPARES_DOWNED faction = list(FACTION_RUSSIAN, BOUNTY_MAFIA_FACTION) - sentience_type = SENTIENCE_BOSS - // They talk to the hunters, so they speak Common - initial_language_holder = /datum/language_holder/atom_basic - mob_spawner = /obj/effect/mob_spawn/corpse/human/bounty_mafia - corpse = /obj/effect/mob_spawn/corpse/human/bounty_mafia - r_hand = BOUNTY_MOBSTER_KNIFE - loot = null ai_controller = /datum/ai_controller/basic_controller/bounty_mafia - /// The gun it fights with (a /datum/bounty_mafia_gun type), or null for a knife - var/mafia_gun_type - var/datum/bounty_mafia_gun/mafia_gun + /// A line on examine: who they are, never how to fight them + var/mafia_examine_line = "He works for the family that runs this club." /// Its room: the area it spawned in, which it never walks out of var/datum/weakref/mafia_home_ref /// Where it spawned, to walk back to if it's ever pushed out of its room @@ -658,46 +448,95 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) var/mafia_next_bark_at = 0 /// Prefix of its dialogue contexts; lines it has none of come from "goon" var/mafia_voice = "goon" + /// It chats about the club while nobody is fighting (the don doesn't) + var/mafia_idle_chatter = TRUE + /// Percent chance it says something when it's hurt + var/mafia_hurt_bark_chance = 20 /// world.time it first found itself out of its room with nobody to fight, or 0 var/mafia_away_since = 0 /// It has kicked a table over for cover this fight var/mafia_took_cover = FALSE - -/mob/living/basic/trooper/russian/mafia/Initialize(mapload) + /// world.time someone last shoved it: that tick's push is someone else's move, which its room never holds back + var/mafia_shoved_at = -1 + + // ----- how it fires its gun (a volley: the aim, then the pulls, then a pause) ----- + /// The aim before a volley ("aiming!"), or 0 for none + var/mafia_windup = 0 + /// The aim comes once per magazine (the don raises his pistol before the first string), not before every volley + var/mafia_windup_once = FALSE + var/mafia_windup_sound + /// A hit during the aim spoils it + var/mafia_fumbles = FALSE + /// Pulls of the trigger in a volley, and the time between them + var/mafia_volley = BOUNTY_MOBSTER_PISTOL_VOLLEY + var/mafia_volley_gap = BOUNTY_MOBSTER_PISTOL_VOLLEY_GAP + /// From the end of one volley to the start of the next + var/mafia_cooldown = BOUNTY_MOBSTER_PISTOL_COOLDOWN + /// What it says as it reloads ("[voice]_[context]"), how often, and the sound of its hand going for a magazine + var/mafia_reload_context = "reload" + var/mafia_reload_chance = 35 + var/mafia_reload_sound = 'sound/items/weapons/gun/pistol/mag_insert.ogg' + /// world.time the aim under way is done, or 0 + var/mafia_aim_until = 0 + /// A hit spoiled the aim under way + var/mafia_aim_spoiled = FALSE + /// Raised this magazine (mafia_windup_once) + var/mafia_raised = FALSE + /// Pulls left in the volley under way + var/mafia_volley_left = 0 + /// world.time of its next pull in the volley, and of its next volley + var/mafia_next_pull_at = 0 + var/mafia_next_volley_at = 0 + +/mob/living/carbon/human/npc/bounty_mafia/Initialize(mapload, datum/human_npc_order/order) . = ..() - // Its blows are the real item's in its hand (bare fists without one) - bounty_real_weapon(r_hand).apply_melee(src) - if(mafia_gun_type) - mafia_gun = new mafia_gun_type(src) - mafia_home_turf = get_turf(src) - var/area/home = get_area(src) - if(home) - mafia_home_ref = WEAKREF(home) - mafia_room_key = REF(home) - var/datum/bounty_mafia_room/room = bounty_mafia_room_for(home) - room.join(src) + mafia_settle_home() AddElement(/datum/element/relay_attackers) - RegisterSignal(src, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(mafia_on_attacked)) - RegisterSignal(src, COMSIG_ATOM_BULLET_ACT, PROC_REF(mafia_on_bullet_act)) - RegisterSignal(src, COMSIG_MOVABLE_PRE_MOVE, PROC_REF(mafia_on_pre_move)) - RegisterSignal(src, COMSIG_MOB_AFTER_APPLY_DAMAGE, PROC_REF(mafia_on_damaged)) - // A polymorph or a type change deletes it without a death: a free kill, and for a lieutenant a free gate - RegisterSignal(src, COMSIG_LIVING_PRE_WABBAJACKED, PROC_REF(mafia_refuse_polymorph)) - RegisterSignal(src, COMSIG_PRE_MOB_CHANGED_TYPE, PROC_REF(mafia_refuse_type_change)) + AddElement(/datum/element/bounty_mafia_body) -/mob/living/basic/trooper/russian/mafia/Destroy() +/mob/living/carbon/human/npc/bounty_mafia/Destroy() var/datum/bounty_mafia_room/room = mafia_room() room?.leave(src) - QDEL_NULL(mafia_gun) mafia_home_ref = null mafia_home_turf = null - // The shout's "!" (do_alert_animation) forgets itself on a timer that dies with us: let it go now, or it hard-deletes - update_on_z = null + // The shout's "!" (do_alert_animation) forgets itself on a timer that dies with us: let it go now + for(var/atom/movable/flick_visual/visual in update_on_z) + LAZYREMOVE(update_on_z, visual) return ..() -/mob/living/basic/trooper/russian/mafia/Life(seconds_per_tick = SSMOBS_DT, times_fired) +/// Takes the room it stands in as its home: its leash, its shout and its doorway cap +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_settle_home() + mafia_home_turf = get_turf(src) + var/area/home = get_area(src) + if(!home) + return + mafia_home_ref = WEAKREF(home) + mafia_room_key = REF(home) + bounty_mafia_room_for(home).join(src) + +// Club Volga's men: the face and hair of their look, always a man's build +/mob/living/carbon/human/npc/bounty_mafia/npc_apply_spawner_look(obj/effect/mob_spawn/spawner) + . = ..() + if(gender == MALE) + return + gender = MALE + physique = MALE + update_body(is_creating = TRUE) + +/mob/living/carbon/human/npc/bounty_mafia/examine(mob/user) + . = ..() + if(mafia_examine_line && stat != DEAD) + . += span_notice(mafia_examine_line) + +// OC-9: no deliberate executions are built this phase, so the club never executes anyone by accident +/mob/living/carbon/human/npc/bounty_mafia/hv_can_execute() + return !isnull(client) + +/mob/living/carbon/human/npc/bounty_mafia/Life(seconds_per_tick = SSMOBS_DT, times_fired) . = ..() - if(stat != CONSCIOUS || world.time < mafia_next_bark_at || !SPT_PROB(BOUNTY_MAFIA_IDLE_BARK_CHANCE, seconds_per_tick)) + if(!mafia_idle_chatter || stat != CONSCIOUS || npc_dormant()) + return + if(world.time < mafia_next_bark_at || !SPT_PROB(BOUNTY_MAFIA_IDLE_BARK_CHANCE, seconds_per_tick)) return var/datum/bounty_mafia_room/room = mafia_room() if(room?.alerted || !mafia_player_nearby()) @@ -705,7 +544,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) mafia_bark("idle") /// Whether a player is close enough to hear it chat -/mob/living/basic/trooper/russian/mafia/proc/mafia_player_nearby() +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_player_nearby() var/turf/here = get_turf(src) if(!here || here.z > length(SSmobs.clients_by_zlevel)) return FALSE @@ -715,28 +554,112 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) return FALSE /// Its room (/datum/bounty_mafia_room), or null -/mob/living/basic/trooper/russian/mafia/proc/mafia_room() +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_room() return mafia_room_key ? GLOB.bounty_mafia_rooms[mafia_room_key] : null /// Says a line for "_" (or the plain goon one) unless it spoke recently or `force`. TRUE if it spoke. -/mob/living/basic/trooper/russian/mafia/proc/mafia_bark(context, force = FALSE) - if(stat != CONSCIOUS || (!force && world.time < mafia_next_bark_at)) +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_bark(context, force = FALSE) + if(!human_npc_can_talk(src) || (!force && world.time < mafia_next_bark_at)) return FALSE if(!bounty_mafia_say(src, "[mafia_voice]_[context]") && (mafia_voice == "goon" || !bounty_mafia_say(src, "goon_[context]"))) return FALSE mafia_next_bark_at = world.time + BOUNTY_MAFIA_BARK_COOLDOWN return TRUE -/mob/living/basic/trooper/russian/mafia/proc/mafia_refuse_polymorph(datum/source, what_to_randomize) - SIGNAL_HANDLER - return STOP_WABBAJACK +/** + * The base reactions (human_npc_barks.dm) speak the club's lines: going down is a hurt line, breaking a grab is + * "Hands off." Everything else they react to (cuffs on and off, working at them, death) is left to tg's messages. + */ +/mob/living/carbon/human/npc/bounty_mafia/npc_bark(kind, force = FALSE) + switch(kind) + if(HUMAN_NPC_BARK_DOWNED) + return mafia_bark("hurt", force = TRUE) + if(HUMAN_NPC_BARK_PULLED_FREE) + return mafia_bark("shoved", force = TRUE) + return FALSE -/mob/living/basic/trooper/russian/mafia/proc/mafia_refuse_type_change(datum/source) - SIGNAL_HANDLER - return COMPONENT_BLOCK_MOB_CHANGE +// It broke a hunter's grab by resisting: the hunter feels it shove them off +/mob/living/carbon/human/npc/bounty_mafia/npc_check_pulled_free(atom/movable/holder, within = 0) + var/broke_free = npc_resisted_at && world.time <= npc_resisted_at + within + var/mob/living/resisted = npc_resisted_hold?.resolve() + . = ..() + if(!broke_free || !isliving(resisted) || (holder && resisted != holder)) + return + balloon_alert(resisted, "[p_they()] shove[p_s()] you off!") + +// ----- what happens to it (/datum/element/bounty_mafia_body relays these) ----- + +/** + * `attacker` (a player, or an exosuit's pilots) went for it: its room is alerted, and it turns on them if it has no + * one else, and only while the doorway cap has room (so shooting a goon held back never pulls it in). + */ +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_answer_attack(atom/attacker) + if(stat == DEAD || !attacker) + return + for(var/mob/living/hunter as anything in bounty_mafia_attackers(attacker)) + mafia_raise_alarm(hunter) + if(ai_controller && !ai_controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET) && mafia_target_ok(hunter) && mafia_room_has_space(hunter)) + ai_controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) + +/** + * A hunter has hold of it (a grab, a carry, the cuffs coming out): that's an attack. The room is alerted and the + * hunter is its target, doorway cap or not. Its AI resists the hold the tg way (escape_captivity). TRUE if it answered. + */ +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_answer_grab(mob/living/grabber) + if(stat == DEAD || !bounty_mafia_is_hunter(grabber) || faction_check_atom(grabber)) + return FALSE + mafia_raise_alarm(grabber) + if(ai_controller && ai_controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] != grabber && mafia_target_ok(grabber)) + ai_controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, grabber) + return TRUE + +/// Whether it can still answer cuffs on its own feet: up, awake, free, and nobody holding it +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_can_answer_cuffs() + if(stat != CONSCIOUS || !isturf(loc) || buckled || pulledby || body_position != STANDING_UP) + return FALSE + return !HAS_TRAIT(src, TRAIT_INCAPACITATED) && !HAS_TRAIT(src, TRAIT_FLOORED) && !HAS_TRAIT(src, TRAIT_IMMOBILIZED) && !HAS_TRAIT(src, TRAIT_RESTRAINED) + +/** + * tg's attempt_to_cuff() has begun on it (COMSIG_CARBON_CUFF_ATTEMPTED, defaults 1.4, CB-15). The cuffer is its target, + * and if it can still move it says so and, a moment into the cuffer's four seconds, steps away: a real step, which + * breaks their do_after. Down, paralysed or held, it can't, and the cuffs go on. Never COMSIG_CARBON_CUFF_PREVENT. + */ +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_on_cuff_attempt(mob/living/user) + if(stat == DEAD || !isliving(user)) + return + mafia_answer_grab(user) + if(!mafia_can_answer_cuffs()) + return + mafia_bark("cuffed", force = TRUE) + addtimer(CALLBACK(src, PROC_REF(mafia_dodge_cuffs), WEAKREF(user)), BOUNTY_MAFIA_CUFF_REACTION, TIMER_DELETE_ME) + +/// One step away from `user_ref`'s cuffer, if it still can. TRUE if it stepped. +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_dodge_cuffs(datum/weakref/user_ref) + var/mob/living/user = user_ref?.resolve() + if(QDELETED(user) || !mafia_can_answer_cuffs() || !Adjacent(user)) + return FALSE + var/turf/here = get_turf(src) + var/away = get_dir(user, src) || pick(GLOB.cardinals) + for(var/direction in list(away, turn(away, 45), turn(away, -45), turn(away, 90), turn(away, -90))) + var/turf/spot = get_step(here, direction) + if(!spot || spot.is_blocked_turf()) + continue + // A real step: its room's leash and everything else on a move apply + if(Move(spot, direction) && get_turf(src) == spot) + return TRUE + return FALSE + +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_on_damaged(damage, damagetype) + if(damage <= 0 || stat != CONSCIOUS) + return + if(mafia_fumbles && mafia_aim_until && !mafia_aim_spoiled) + mafia_aim_spoiled = TRUE + visible_message(span_notice("[src] flinches and loses [p_their()] aim.")) + if(prob(mafia_hurt_bark_chance)) + mafia_bark("hurt") /// Its room was alerted by `spotter` over `hunter`; it may attack `delay` after the shout, and a gunman takes cover -/mob/living/basic/trooper/russian/mafia/proc/mafia_on_alarm(mob/living/basic/trooper/russian/mafia/spotter, delay = 0, mob/living/hunter) +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_on_alarm(mob/living/carbon/human/npc/bounty_mafia/spotter, delay = 0, mob/living/hunter) mafia_ready_at = world.time + BOUNTY_MOBSTER_ALERT + delay if(spotter == src) do_alert_animation() @@ -748,8 +671,8 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) * A gunman kicks over a wood table beside it, on its side toward `hunter`, once a fight (lairs.md 3.1). The table's * top faces the hunter, so their shots hit it and the gunman's pass over it. Returns the table, or null. */ -/mob/living/basic/trooper/russian/mafia/proc/mafia_take_cover(mob/living/hunter) - if(mafia_took_cover || !mafia_gun || stat != CONSCIOUS || QDELETED(hunter)) +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_take_cover(mob/living/hunter) + if(mafia_took_cover || !human_npc_held_gun(src) || !mafia_can_act() || QDELETED(hunter)) return null var/turf/here = get_turf(src) var/toward = here ? get_dir(here, hunter) : NONE @@ -777,7 +700,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) return cover /// Raises its room's alarm over `hunter`, or just its own with no room. TRUE if this raised it. -/mob/living/basic/trooper/russian/mafia/proc/mafia_raise_alarm(mob/living/hunter) +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_raise_alarm(mob/living/hunter) var/datum/bounty_mafia_room/room = mafia_room() if(room?.raise_alarm(src, hunter)) return TRUE @@ -787,34 +710,28 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) mafia_on_alarm(room ? null : src, room ? rand(0, BOUNTY_MOBSTER_FIRST_SHOT_SPREAD) : 0) return TRUE -/// Whether it can do anything at all -/mob/living/basic/trooper/russian/mafia/proc/mafia_can_act() +/// Whether it can do anything at all on its feet +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_can_act() return !QDELETED(src) && stat == CONSCIOUS && isturf(loc) && !HAS_TRAIT(src, TRAIT_INCAPACITATED) // ----- its room ----- /// Whether it stands in its own room -/mob/living/basic/trooper/russian/mafia/proc/mafia_at_home() +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_at_home() var/area/home = mafia_home_ref?.resolve() return !home || get_area(src) == home /// Whether it may step onto `spot` on its own: anywhere in its room, never out of it (bounty_mafia_leash_allows()) -/mob/living/basic/trooper/russian/mafia/proc/mafia_leash_allows(turf/spot) - return bounty_mafia_leash_allows(src, mafia_home_ref?.resolve(), spot) - -/mob/living/basic/trooper/russian/mafia/proc/mafia_on_pre_move(datum/source, atom/new_loc) - SIGNAL_HANDLER - if(!mafia_leash_allows(get_turf(new_loc))) - return COMPONENT_MOVABLE_BLOCK_PRE_MOVE - return NONE +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_leash_allows(turf/spot) + return bounty_mafia_leash_allows(src, mafia_home_ref?.resolve(), spot, mafia_shoved_at == world.time) /// Whether its next step toward `target` stays in its room -/mob/living/basic/trooper/russian/mafia/proc/mafia_step_ok(atom/target) +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_step_ok(atom/target) var/turf/next = get_step_towards(src, target) return next && mafia_leash_allows(next) /// Its room's door tile nearest `target`: where it goes to get a line on someone outside, when a straight step won't do -/mob/living/basic/trooper/russian/mafia/proc/mafia_exit_toward(atom/target) +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_exit_toward(atom/target) var/datum/bounty_mafia_room/room = mafia_room() if(!room || !target) return null @@ -831,7 +748,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) * Out of its room with nobody to fight: it walks back. If it hasn't made it in BOUNTY_MOBSTER_ROOM_GIVE_UP (another * leash keeps it where it is), the room it stands in becomes its room. Returns the turf it walks to, or null. */ -/mob/living/basic/trooper/russian/mafia/proc/mafia_head_home() +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_head_home() if(mafia_at_home()) mafia_away_since = 0 return null @@ -843,7 +760,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) return mafia_home_turf /// `new_home` is its room from now on: its leash, its shout and its doorway cap -/mob/living/basic/trooper/russian/mafia/proc/mafia_adopt_room(area/new_home) +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_adopt_room(area/new_home) if(!new_home) return var/datum/bounty_mafia_room/old_room = mafia_room() @@ -857,14 +774,14 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) // ----- targets ----- /// Whether it may go after `target`: a hunter on their feet, on its level and near -/mob/living/basic/trooper/russian/mafia/proc/mafia_target_ok(mob/living/target) +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_target_ok(mob/living/target) if(!bounty_mafia_may_hurt(target) || faction_check_atom(target)) return FALSE var/turf/spot = get_turf(target) return spot && spot.z == z && get_dist(src, spot) <= BOUNTY_MOBSTER_CHASE /// Whether `hunter` is in a doorway as its room sees it: outside the room, or on a door tile -/mob/living/basic/trooper/russian/mafia/proc/mafia_in_doorway(mob/living/hunter) +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_in_doorway(mob/living/hunter) var/turf/spot = get_turf(hunter) if(!spot) return FALSE @@ -874,7 +791,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) return !isnull(locate(/obj/machinery/door) in spot) /// Whether it may take `hunter` on: fewer than BOUNTY_MOBSTER_MAX_ON_ONE of its room already on a hunter in a doorway -/mob/living/basic/trooper/russian/mafia/proc/mafia_room_has_space(mob/living/hunter) +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_room_has_space(mob/living/hunter) if(!mafia_in_doorway(hunter)) return TRUE var/datum/bounty_mafia_room/room = mafia_room() @@ -885,7 +802,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) * room's alarm), else the one its alerted room knows about, to get a line on from inside the room. Only * players on its level with a client are looked at, from SSmobs' list. */ -/mob/living/basic/trooper/russian/mafia/proc/mafia_find_target() +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_find_target() var/datum/ai_controller/controller = ai_controller if(!controller) return null @@ -921,130 +838,113 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, best) return best -/** - * A hunter is pulling or grabbing it: that's an attack. The room is alerted and the grabber is its target, doorway cap - * or not. Returns TRUE while it is held, so it resists before anything else. - */ -/mob/living/basic/trooper/russian/mafia/proc/mafia_answer_grab() - var/mob/living/grabber = pulledby - if(!bounty_mafia_is_hunter(grabber) || faction_check_atom(grabber)) - return FALSE - mafia_raise_alarm(grabber) - if(ai_controller && ai_controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] != grabber && mafia_target_ok(grabber)) - ai_controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, grabber) - return TRUE - /// Whether it's past the shout and may attack -/mob/living/basic/trooper/russian/mafia/proc/mafia_is_ready() +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_is_ready() var/datum/bounty_mafia_room/room = mafia_room() if(room && !room.alerted) return FALSE return mafia_ready_at && world.time >= mafia_ready_at -/// One attack on `target`: a burst if it has a gun and a line, a stab if it's next to them. TRUE if it attacked. -/mob/living/basic/trooper/russian/mafia/proc/mafia_attack(mob/living/target) - if(!mafia_can_act() || !mafia_is_ready() || !mafia_target_ok(target)) +// ----- fighting, through its hands ----- + +/** + * Queues its next move against `target` on `controller`: a reload from its pockets when its gun is dry, a volley + * when it has a loaded gun and a line, its knife or fists when it's next to them. TRUE if it queued one (or is + * between volleys, standing its ground); FALSE if it has to move to get at them. + */ +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_plan_attack(datum/ai_controller/controller, mob/living/target) + if(HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)) return FALSE - face_atom(target) - if(mafia_gun) - if(!can_see(src, target, BOUNTY_MOBSTER_SIGHT)) + var/obj/item/gun/gun = human_npc_held_gun(src) + if(gun && !gun.can_shoot() && !LAZYLEN(do_afters) && world.time >= controller.blackboard[BB_HUMAN_NPC_ARMING_RETRY_AT] && human_npc_can_reload(src, gun)) + controller.queue_behavior(/datum/ai_behavior/human_npc_reload/bounty_mafia) + return TRUE + if(human_npc_loaded_gun(src)) + if(!can_see(src, target, mafia_sight())) return FALSE - return mafia_gun.try_fire(target) - if(!Adjacent(target) || world.time < next_move) + controller.queue_behavior(/datum/ai_behavior/bounty_mafia_fire, BB_BASIC_MOB_CURRENT_TARGET) + return TRUE + if(!Adjacent(target)) return FALSE - return melee_attack(target) - -// ----- what happens to it ----- - -/mob/living/basic/trooper/russian/mafia/proc/mafia_on_attacked(datum/source, atom/attacker, attack_flags) - SIGNAL_HANDLER - if(!(attack_flags & (ATTACKER_DAMAGING_ATTACK | ATTACKER_STAMINA_ATTACK))) - return - mafia_answer_attack(attacker) - -// Every shot that hits it, the ones relay_attackers skips too: an exosuit's guns fire as the suit -/mob/living/basic/trooper/russian/mafia/proc/mafia_on_bullet_act(datum/source, obj/projectile/shot, def_zone, piercing_hit, blocked) - SIGNAL_HANDLER - mafia_answer_attack(shot?.firer) + controller.queue_behavior(mafia_melee_behavior(), BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETING_STRATEGY, BB_BASIC_MOB_CURRENT_TARGET_HIDING_LOCATION) + return TRUE -/** - * `attacker` (a player, or an exosuit's pilots) went for it: its room is alerted, and it turns on them if it has no - * one else, and only while the doorway cap has room (so shooting a goon held back never pulls it in). - */ -/mob/living/basic/trooper/russian/mafia/proc/mafia_answer_attack(atom/attacker) - if(stat == DEAD || !attacker) - return - for(var/mob/living/hunter as anything in bounty_mafia_attackers(attacker)) - mafia_raise_alarm(hunter) - if(ai_controller && !ai_controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET) && mafia_target_ok(hunter) && mafia_room_has_space(hunter)) - ai_controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) +/// How far it sees and shoots +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_sight() + return BOUNTY_MOBSTER_SIGHT -/mob/living/basic/trooper/russian/mafia/proc/mafia_on_damaged(datum/source, damage, damagetype) - SIGNAL_HANDLER - if(damage <= 0 || stat != CONSCIOUS) - return - if(mafia_gun?.fumbles && mafia_gun.winding) - mafia_gun.fumble(BOUNTY_MOBSTER_FUMBLE) - visible_message(span_notice("[src] flinches and loses [p_their()] aim.")) - if(prob(20)) - mafia_bark("hurt") +/// The behaviour it hits with up close: tg's melee, with the best thing it holds or its fist +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_melee_behavior() + return /datum/ai_behavior/basic_melee_attack/human_npc -/// A gunman with a pistol -/mob/living/basic/trooper/russian/mafia/pistol - name = "mobster gunman" - desc = "A heavy in a balaclava and a leather jacket, working for the family that runs this club. He has a pistol." - maxHealth = BOUNTY_MOBSTER_PISTOL_HEALTH - health = BOUNTY_MOBSTER_PISTOL_HEALTH - speed = BOUNTY_MOBSTER_PISTOL_SPEED - mob_spawner = /obj/effect/mob_spawn/corpse/human/bounty_mafia/pistol - corpse = /obj/effect/mob_spawn/corpse/human/bounty_mafia/pistol - r_hand = BOUNTY_MOBSTER_PISTOL_GUN - attack_vis_effect = ATTACK_EFFECT_PUNCH - mafia_gun_type = /datum/bounty_mafia_gun - -/// An enforcer with an SMG that spins up before each burst -/mob/living/basic/trooper/russian/mafia/smg - name = "mobster enforcer" - desc = "A heavy in a balaclava and a leather jacket, working for the family that runs this club. He has an SMG." - maxHealth = BOUNTY_MOBSTER_SMG_HEALTH - health = BOUNTY_MOBSTER_SMG_HEALTH - speed = BOUNTY_MOBSTER_SMG_SPEED - mob_spawner = /obj/effect/mob_spawn/corpse/human/bounty_mafia/smg - corpse = /obj/effect/mob_spawn/corpse/human/bounty_mafia/smg - r_hand = BOUNTY_MOBSTER_SMG_GUN - attack_vis_effect = ATTACK_EFFECT_PUNCH - mafia_gun_type = /datum/bounty_mafia_gun/smg +/// It starts aiming at `target`: the "aiming!" telegraph, its gun's sound, and nothing fires until mafia_aim_until +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_start_aim(atom/target) + mafia_aim_until = world.time + mafia_windup + mafia_aim_spoiled = FALSE + face_atom(target) + if(mafia_windup_sound) + playsound(src, mafia_windup_sound, 50, TRUE) + balloon_alert_to_viewers("aiming!") + +/// It reaches for a fresh magazine (its AI's reload, human_npc_reload): the sound, maybe a line, and the next magazine needs raising again +/mob/living/carbon/human/npc/bounty_mafia/proc/mafia_on_reload() + mafia_raised = FALSE + if(mafia_reload_sound) + playsound(src, mafia_reload_sound, 40, TRUE) + if(mafia_reload_context && prob(mafia_reload_chance)) + mafia_bark(mafia_reload_context) + +/// A gunman with a Stechkin +/mob/living/carbon/human/npc/bounty_mafia/pistol + npc_name = "mobster gunman" + npc_look = /obj/effect/mob_spawn/corpse/human/bounty_mafia/pistol + npc_outfit = /datum/outfit/bounty_mafia_goon/pistol/armed + +/// An enforcer with an Uzi that spins up before each volley +/mob/living/carbon/human/npc/bounty_mafia/smg + npc_name = "mobster enforcer" + npc_look = /obj/effect/mob_spawn/corpse/human/bounty_mafia/smg + npc_outfit = /datum/outfit/bounty_mafia_goon/smg/armed + mafia_windup = BOUNTY_MOBSTER_SMG_WINDUP + mafia_windup_sound = 'sound/items/weapons/gun/smg/smgrack.ogg' + mafia_fumbles = TRUE + mafia_volley = BOUNTY_MOBSTER_SMG_VOLLEY + mafia_volley_gap = BOUNTY_MOBSTER_SMG_VOLLEY_GAP + mafia_cooldown = BOUNTY_MOBSTER_SMG_COOLDOWN + mafia_reload_sound = 'sound/items/weapons/gun/general/magazine_insert_full.ogg' // ===== LIEUTENANTS ===== /** - * The two who hold the arena gate: "Tommy" with a Tommy gun and "Brute" with his fists. Both take - * BOUNTY_LIEUTENANT_DAMAGE_MOD of any brute or burn. The base type takes the role its room doesn't have yet, - * so the first is Tommy and the second Brute; /tommy and /brute fix it. P10 opens the gate on their deaths - * (COMSIG_LIVING_DEATH; they are deleted right after, as troopers are). + * The two who hold the arena gate: "Tommy" with a Thompson and "Brute" with his fists. Elites (aimed crits, fire + * from the floor), in real armour, and they take BOUNTY_LIEUTENANT_DAMAGE_TAKEN of any brute or burn through their + * bodies. The base type takes the role its room doesn't have yet, so the first is Tommy and the second Brute; + * /tommy and /brute fix it. P10 opens the gate on their deaths (COMSIG_LIVING_DEATH). */ -/mob/living/basic/trooper/russian/mafia/lieutenant - name = "lieutenant" - desc = "One of the don's lieutenants." - maxHealth = BOUNTY_LIEUTENANT_TOMMY_HEALTH - health = BOUNTY_LIEUTENANT_TOMMY_HEALTH +/mob/living/carbon/human/npc/bounty_mafia/lieutenant + npc_name = "lieutenant" + npc_rank = HUMAN_NPC_RANK_ELITE + npc_damage_taken = BOUNTY_LIEUTENANT_DAMAGE_TAKEN + mafia_examine_line = "One of the don's lieutenants." /// BOUNTY_LIEUTENANT_TOMMY or BOUNTY_LIEUTENANT_BRUTE; null picks one at Initialize var/mafia_lieutenant_role + /// Percent chance a punch of Brute's that lands knocks them down + var/mafia_punch_knockdown_chance = BOUNTY_LIEUTENANT_BRUTE_KNOCKDOWN_CHANCE -/mob/living/basic/trooper/russian/mafia/lieutenant/Initialize(mapload) +/mob/living/carbon/human/npc/bounty_mafia/lieutenant/Initialize(mapload, datum/human_npc_order/order) if(!mafia_lieutenant_role) mafia_lieutenant_role = mafia_pick_lieutenant_role() mafia_apply_lieutenant_role() return ..() /// The role its room doesn't have yet: Tommy first, then Brute -/mob/living/basic/trooper/russian/mafia/lieutenant/proc/mafia_pick_lieutenant_role() +/mob/living/carbon/human/npc/bounty_mafia/lieutenant/proc/mafia_pick_lieutenant_role() var/area/home = get_area(loc) var/datum/bounty_mafia_room/room = home ? GLOB.bounty_mafia_rooms[REF(home)] : null var/has_tommy = FALSE var/has_brute = FALSE if(room) - for(var/mob/living/basic/trooper/russian/mafia/lieutenant/other in room.goons()) + for(var/mob/living/carbon/human/npc/bounty_mafia/lieutenant/other in room.goons()) if(other.mafia_lieutenant_role == BOUNTY_LIEUTENANT_TOMMY) has_tommy = TRUE else if(other.mafia_lieutenant_role == BOUNTY_LIEUTENANT_BRUTE) @@ -1057,94 +957,187 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) return pick(BOUNTY_LIEUTENANT_TOMMY, BOUNTY_LIEUTENANT_BRUTE) return BOUNTY_LIEUTENANT_TOMMY -/// Its role's body, gun and look. Before the parent Initialize, which dresses it and makes its AI. -/mob/living/basic/trooper/russian/mafia/lieutenant/proc/mafia_apply_lieutenant_role() - damage_coeff = list(BRUTE = BOUNTY_LIEUTENANT_DAMAGE_MOD, BURN = BOUNTY_LIEUTENANT_DAMAGE_MOD, TOX = 1, STAMINA = 1, OXY = 1) +/// Its role's look, clothes, gun and voice. Before the parent Initialize, which dresses it and makes its AI. +/mob/living/carbon/human/npc/bounty_mafia/lieutenant/proc/mafia_apply_lieutenant_role() if(mafia_lieutenant_role == BOUNTY_LIEUTENANT_BRUTE) - name = "Brute" - desc = "A mountain of a man in a tracksuit and a bear-pelt hat, knuckles taped for work. The family's muscle." - maxHealth = BOUNTY_LIEUTENANT_BRUTE_HEALTH - health = BOUNTY_LIEUTENANT_BRUTE_HEALTH - speed = BOUNTY_LIEUTENANT_BRUTE_SPEED - melee_attack_cooldown = BOUNTY_LIEUTENANT_BRUTE_COOLDOWN - attack_vis_effect = ATTACK_EFFECT_PUNCH - mafia_gun_type = null - mob_spawner = /obj/effect/mob_spawn/corpse/human/bounty_mafia/brute - corpse = /obj/effect/mob_spawn/corpse/human/bounty_mafia/brute - r_hand = null + npc_name = "Brute" + npc_look = /obj/effect/mob_spawn/corpse/human/bounty_mafia/brute + npc_outfit = /datum/outfit/bounty_mafia_brute/armed + mafia_examine_line = "One of the don's lieutenants: the family's muscle, knuckles taped for work." mafia_voice = "brute" return mafia_lieutenant_role = BOUNTY_LIEUTENANT_TOMMY - name = "Tommy" - desc = "A lieutenant in a long coat and a fedora, with a drum-fed Tommy gun. He runs the back office." - maxHealth = BOUNTY_LIEUTENANT_TOMMY_HEALTH - health = BOUNTY_LIEUTENANT_TOMMY_HEALTH - speed = BOUNTY_LIEUTENANT_TOMMY_SPEED - attack_vis_effect = ATTACK_EFFECT_PUNCH - mafia_gun_type = /datum/bounty_mafia_gun/tommy - mob_spawner = /obj/effect/mob_spawn/corpse/human/bounty_mafia/tommy - corpse = /obj/effect/mob_spawn/corpse/human/bounty_mafia/tommy - r_hand = BOUNTY_LIEUTENANT_TOMMY_GUN + npc_name = "Tommy" + npc_look = /obj/effect/mob_spawn/corpse/human/bounty_mafia/tommy + npc_outfit = /datum/outfit/bounty_mafia_tommy/armed + mafia_examine_line = "One of the don's lieutenants. He runs the back office." mafia_voice = "tommy" + mafia_windup = BOUNTY_LIEUTENANT_TOMMY_WINDUP + mafia_windup_sound = 'sound/items/weapons/gun/smg/smgrack.ogg' + mafia_volley = BOUNTY_LIEUTENANT_TOMMY_VOLLEY + mafia_volley_gap = BOUNTY_LIEUTENANT_TOMMY_VOLLEY_GAP + mafia_cooldown = BOUNTY_LIEUTENANT_TOMMY_COOLDOWN + mafia_reload_sound = 'sound/items/weapons/gun/general/magazine_insert_full.ogg' + +/mob/living/carbon/human/npc/bounty_mafia/lieutenant/mafia_melee_behavior() + if(mafia_lieutenant_role == BOUNTY_LIEUTENANT_BRUTE) + return /datum/ai_behavior/basic_melee_attack/human_npc/bounty_mafia_brute + return ..() -// Brute's blows knock people down now and then -/mob/living/basic/trooper/russian/mafia/lieutenant/melee_attack(atom/target, list/modifiers, ignore_cooldown = FALSE) - . = ..() - if(!. || mafia_lieutenant_role != BOUNTY_LIEUTENANT_BRUTE || !isliving(target)) +/** + * Brute's punch landed on `victim` (COMSIG_HUMAN_GOT_PUNCHED, which his melee listens to on its target for the length + * of the blow): now and then it knocks them off their feet. A designed weapon effect, through tg's Knockdown. + */ +/mob/living/carbon/human/npc/bounty_mafia/lieutenant/proc/mafia_on_punch_landed(mob/living/carbon/human/victim, mob/living/attacker, damage, attack_type, obj/item/bodypart/affecting, final_armor_block, kicking, limb_sharpness) + SIGNAL_HANDLER + if(attacker != src || mafia_lieutenant_role != BOUNTY_LIEUTENANT_BRUTE || QDELETED(victim) || victim.stat == DEAD) return - if(!prob(BOUNTY_LIEUTENANT_BRUTE_KNOCKDOWN_CHANCE)) + if(!prob(mafia_punch_knockdown_chance)) return - var/mob/living/victim = target victim.Knockdown(BOUNTY_LIEUTENANT_BRUTE_KNOCKDOWN) victim.visible_message(span_danger("[src]'s punch knocks [victim] off [victim.p_their()] feet!"), span_userdanger("[src]'s punch knocks you off your feet!")) -/mob/living/basic/trooper/russian/mafia/lieutenant/tommy - name = "Tommy" +/mob/living/carbon/human/npc/bounty_mafia/lieutenant/tommy + npc_name = "Tommy" mafia_lieutenant_role = BOUNTY_LIEUTENANT_TOMMY -/mob/living/basic/trooper/russian/mafia/lieutenant/brute - name = "Brute" - maxHealth = BOUNTY_LIEUTENANT_BRUTE_HEALTH - health = BOUNTY_LIEUTENANT_BRUTE_HEALTH +/mob/living/carbon/human/npc/bounty_mafia/lieutenant/brute + npc_name = "Brute" mafia_lieutenant_role = BOUNTY_LIEUTENANT_BRUTE +/** + * Listens to a club member's body for it: hits, shots, steps, damage, grabs, cuffs, shoves, and the polymorph and + * type changes it refuses. An element, so nothing else registering the same signals on the mob replaces these. + */ +/datum/element/bounty_mafia_body + element_flags = ELEMENT_DETACH_ON_HOST_DESTROY + +/datum/element/bounty_mafia_body/Attach(datum/target) + . = ..() + if(!istype(target, /mob/living/carbon/human/npc/bounty_mafia)) + return ELEMENT_INCOMPATIBLE + RegisterSignal(target, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_attacked)) + RegisterSignal(target, COMSIG_ATOM_BULLET_ACT, PROC_REF(on_bullet_act)) + RegisterSignal(target, COMSIG_MOVABLE_PRE_MOVE, PROC_REF(on_pre_move)) + RegisterSignal(target, COMSIG_MOB_AFTER_APPLY_DAMAGE, PROC_REF(on_damaged)) + RegisterSignal(target, COMSIG_LIVING_GET_PULLED, PROC_REF(on_grabbed)) + RegisterSignal(target, COMSIG_CARBON_CUFF_ATTEMPTED, PROC_REF(on_cuff_attempt)) + RegisterSignal(target, COMSIG_LIVING_DISARM_HIT, PROC_REF(on_shoved)) + // A polymorph or a type change deletes it without a death: a free kill, and for a lieutenant a free gate + RegisterSignal(target, COMSIG_LIVING_PRE_WABBAJACKED, PROC_REF(refuse_polymorph)) + RegisterSignal(target, COMSIG_PRE_MOB_CHANGED_TYPE, PROC_REF(refuse_type_change)) + +/datum/element/bounty_mafia_body/Detach(datum/source) + UnregisterSignal(source, list( + COMSIG_ATOM_WAS_ATTACKED, + COMSIG_ATOM_BULLET_ACT, + COMSIG_MOVABLE_PRE_MOVE, + COMSIG_MOB_AFTER_APPLY_DAMAGE, + COMSIG_LIVING_GET_PULLED, + COMSIG_CARBON_CUFF_ATTEMPTED, + COMSIG_LIVING_DISARM_HIT, + COMSIG_LIVING_PRE_WABBAJACKED, + COMSIG_PRE_MOB_CHANGED_TYPE, + )) + return ..() + +/datum/element/bounty_mafia_body/proc/on_attacked(mob/living/carbon/human/npc/bounty_mafia/source, atom/attacker, attack_flags) + SIGNAL_HANDLER + if(attack_flags & (ATTACKER_DAMAGING_ATTACK | ATTACKER_STAMINA_ATTACK)) + source.mafia_answer_attack(attacker) + +// Every shot that hits it, the ones relay_attackers skips too: an exosuit's guns fire as the suit +/datum/element/bounty_mafia_body/proc/on_bullet_act(mob/living/carbon/human/npc/bounty_mafia/source, obj/projectile/shot, def_zone, piercing_hit, blocked) + SIGNAL_HANDLER + source.mafia_answer_attack(shot?.firer) + +/datum/element/bounty_mafia_body/proc/on_pre_move(mob/living/carbon/human/npc/bounty_mafia/source, atom/new_loc) + SIGNAL_HANDLER + if(!source.mafia_leash_allows(get_turf(new_loc))) + return COMPONENT_MOVABLE_BLOCK_PRE_MOVE + return NONE + +/datum/element/bounty_mafia_body/proc/on_damaged(mob/living/carbon/human/npc/bounty_mafia/source, damage, damagetype) + SIGNAL_HANDLER + source.mafia_on_damaged(damage, damagetype) + +/datum/element/bounty_mafia_body/proc/on_grabbed(mob/living/carbon/human/npc/bounty_mafia/source, mob/living/puller) + SIGNAL_HANDLER + source.mafia_answer_grab(puller) + +/datum/element/bounty_mafia_body/proc/on_cuff_attempt(mob/living/carbon/human/npc/bounty_mafia/source, mob/living/user) + SIGNAL_HANDLER + source.mafia_on_cuff_attempt(user) + return NONE + +/datum/element/bounty_mafia_body/proc/on_shoved(mob/living/carbon/human/npc/bounty_mafia/source, mob/living/attacker, zone, obj/item/weapon) + SIGNAL_HANDLER + source.mafia_shoved_at = world.time + +/datum/element/bounty_mafia_body/proc/refuse_polymorph(datum/source, what_to_randomize) + SIGNAL_HANDLER + return STOP_WABBAJACK + +/datum/element/bounty_mafia_body/proc/refuse_type_change(datum/source) + SIGNAL_HANDLER + return COMPONENT_BLOCK_MOB_CHANGE + // ===== THE ROOM SPAWNER ===== /** * The club's goons. On P11's map every room has one of these; its room (the marker's area) fixes the crew - * (bounty_mafia_room_crew()). Each marker rolls 1-2 from its room's weighted roster. Goons - * only spawn on tiles of the marker's own room. + * (bounty_mafia_room_crew()). Each marker rolls 1-2 from its room's weighted roster, anywhere else 1-2 from its zone + * table. Goons only spawn on tiles of the marker's own room. They are people, so they are queued + * (spawn_human_npc()): a club of two dozen is built a body at a time, never in one tick. */ /obj/effect/zone_mobs/mafia name = "zone mob spawner (mafia)" scatter_radius = 3 mobs_green = list( - /mob/living/basic/trooper/russian/mafia = 4, - /mob/living/basic/trooper/russian/mafia/pistol = 3, - /mob/living/basic/trooper/russian/mafia/smg = 1, + /mob/living/carbon/human/npc/bounty_mafia = 4, + /mob/living/carbon/human/npc/bounty_mafia/pistol = 3, + /mob/living/carbon/human/npc/bounty_mafia/smg = 1, ) mobs_yellow = list( - /mob/living/basic/trooper/russian/mafia = 3, - /mob/living/basic/trooper/russian/mafia/pistol = 4, - /mob/living/basic/trooper/russian/mafia/smg = 2, + /mob/living/carbon/human/npc/bounty_mafia = 3, + /mob/living/carbon/human/npc/bounty_mafia/pistol = 4, + /mob/living/carbon/human/npc/bounty_mafia/smg = 2, ) mobs_red = list( - /mob/living/basic/trooper/russian/mafia = 2, - /mob/living/basic/trooper/russian/mafia/pistol = 4, - /mob/living/basic/trooper/russian/mafia/smg = 3, + /mob/living/carbon/human/npc/bounty_mafia = 2, + /mob/living/carbon/human/npc/bounty_mafia/pistol = 4, + /mob/living/carbon/human/npc/bounty_mafia/smg = 3, ) +/// Queues its goons. Returns their orders (/datum/human_npc_order). /obj/effect/zone_mobs/mafia/do_spawn(zone_type) + . = list() var/area/room = get_area(src) var/list/crew = room ? bounty_mafia_room_crew(room.type) : null - if(!crew) - return ..() + var/amount + if(crew) + amount = rand(1, 2) + else + var/list/count_range = count_green + crew = mobs_green + switch(zone_type) + if(ZONE_YELLOW) + crew = mobs_yellow || crew + count_range = count_yellow + if(ZONE_RED) + crew = mobs_red || mobs_yellow || crew + count_range = count_red + amount = rand(count_range[1], count_range[2]) + if(!length(crew) || amount < 1) + return var/list/open_turfs = get_scatter_turfs() - for(var/i in 1 to rand(1, 2)) + for(var/i in 1 to amount) var/mob_path = pick_weight(crew) + if(!ispath(mob_path, /mob/living/carbon/human/npc)) + continue var/turf/spot = length(open_turfs) ? pick_n_take(open_turfs) : get_turf(src) var/datum/npc_spawn_context/context = new(src, zone_type, "ordinary") - spawn_npc_in_zone(mob_path, spot, context) + . += spawn_human_npc(mob_path, spot, context = context) /obj/effect/zone_mobs/mafia/get_scatter_turfs() var/area/room = get_area(src) @@ -1153,9 +1146,10 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) if(get_area(spot) == room) . += spot -// ===== LOOKS AND CORPSES ===== -// The goons wear what the corpse leaves behind: club clothes, and never a gun (the gun in the living mob's -// hand is only a picture). +// ===== CLOTHES AND LOOKS ===== +// The club's clothes, as their corpses used to wear them; the /armed outfits are what the living wear: the same +// clothes, their real gun or knife in hand and spare magazines in their pockets, and the lieutenants' real armour. +// All of it is locked to them (D3): none of it is loot. /// A Ratnik tracksuit and an ushanka: the doormen and knife men /datum/outfit/bounty_mafia_goon @@ -1165,12 +1159,22 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) gloves = /obj/item/clothing/gloves/color/black shoes = /obj/item/clothing/shoes/sneakers/black +/datum/outfit/bounty_mafia_goon/armed + name = "Club Volga mobster (armed)" + r_hand = BOUNTY_MOBSTER_KNIFE + /// The gunmen hide their faces under the ushanka and keep a leather jacket over the tracksuit /datum/outfit/bounty_mafia_goon/pistol name = "Club Volga gunman" suit = /obj/item/clothing/suit/jacket/leather mask = /obj/item/clothing/mask/russian_balaclava +/datum/outfit/bounty_mafia_goon/pistol/armed + name = "Club Volga gunman (armed)" + r_hand = BOUNTY_MOBSTER_PISTOL_GUN + l_pocket = BOUNTY_MOBSTER_PISTOL_MAGAZINE + r_pocket = BOUNTY_MOBSTER_PISTOL_MAGAZINE + /// The enforcers: a military tracksuit, a black balaclava, heavy boots /datum/outfit/bounty_mafia_goon/smg name = "Club Volga enforcer" @@ -1180,6 +1184,12 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) suit = /obj/item/clothing/suit/jacket/leather shoes = /obj/item/clothing/shoes/russian +/datum/outfit/bounty_mafia_goon/smg/armed + name = "Club Volga enforcer (armed)" + r_hand = BOUNTY_MOBSTER_SMG_GUN + l_pocket = BOUNTY_MOBSTER_SMG_MAGAZINE + r_pocket = BOUNTY_MOBSTER_SMG_MAGAZINE + /// Tommy dresses like the old films: a black suit, a long coat, a fedora /datum/outfit/bounty_mafia_tommy name = "Club Volga lieutenant (Tommy)" @@ -1189,6 +1199,14 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) gloves = /obj/item/clothing/gloves/color/black shoes = /obj/item/clothing/shoes/laceup +/// His long coat is a lined noir trenchcoat (real armour), the Thompson in his hands and two drums in his pockets +/datum/outfit/bounty_mafia_tommy/armed + name = "Club Volga lieutenant (Tommy, armed)" + suit = /obj/item/clothing/suit/toggle/jacket/det_trench/noir + r_hand = BOUNTY_LIEUTENANT_TOMMY_GUN + l_pocket = BOUNTY_LIEUTENANT_TOMMY_MAGAZINE + r_pocket = BOUNTY_LIEUTENANT_TOMMY_MAGAZINE + /// Brute: a tracksuit, a bear-pelt hat and taped knuckles /datum/outfit/bounty_mafia_brute name = "Club Volga lieutenant (Brute)" @@ -1197,6 +1215,11 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) gloves = /obj/item/clothing/gloves/color/black shoes = /obj/item/clothing/shoes/russian +/// And a bulletproof vest over the tracksuit (real armour) +/datum/outfit/bounty_mafia_brute/armed + name = "Club Volga lieutenant (Brute, armed)" + suit = /obj/item/clothing/suit/armor/vest/russian + /// The don: a black suit, a fur coat, a gold chain and dark glasses /datum/outfit/bounty_mafia_don name = "Club Volga don" @@ -1207,6 +1230,13 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) gloves = /obj/item/clothing/gloves/color/black shoes = /obj/item/clothing/shoes/laceup +/datum/outfit/bounty_mafia_don/armed + name = "Club Volga don (armed)" + r_hand = BOUNTY_DON_GUN + l_pocket = BOUNTY_DON_MAGAZINE + r_pocket = BOUNTY_DON_MAGAZINE + +// The club's looks: hair and faces for the people (npc_look), and the plain clothes outfits above /obj/effect/mob_spawn/corpse/human/bounty_mafia name = "Club Volga mobster" outfit = /datum/outfit/bounty_mafia_goon @@ -1295,7 +1325,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) /// What its volley fires: never tg's rocket (explosion()), always this var/mech_rocket_type = /obj/projectile/bullet/bounty_mafia_rocket /// What its machine gun fires - var/mech_lmg_type = /obj/projectile/bullet/bounty_mafia/lmg + var/mech_lmg_type = /obj/projectile/bullet/bounty_mafia_lmg /// What keeps it still with its AI quiet ("rockets", "lmg_windup", "lmg_fire", "stall"), or null var/mech_busy /// Goes up each time it becomes busy, so a stale timer does nothing @@ -1399,7 +1429,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) return COMPONENT_MOVABLE_BLOCK_PRE_MOVE return NONE -/// Dragged or thrown out of its arena somehow: it's put back where it started +/// Dragged or thrown out of its arena somehow: the machine is put back where it started (OC-5) /mob/living/basic/bounty_lair_boss/mafia_mech/proc/mech_check_home() var/area/arena = mech_home_ref?.resolve() if(!arena || !mech_home_turf || get_area(src) == arena) @@ -1575,7 +1605,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) /** * After BOUNTY_MECH_RESET_AFTER with nobody in its arena, in sight or shooting at it, a fight it was in resets: * full health, the one-hunter table and an empty posse, so a second crew never finishes a wounded mech (lairs.md - * 9.5). Its Life() calls this. TRUE if it reset. + * 9.5). A machine with repair arms (OC-5, CB-18). Its Life() calls this. TRUE if it reset. */ /mob/living/basic/bounty_lair_boss/mafia_mech/proc/mech_check_reset() if(stat == DEAD) @@ -1695,9 +1725,10 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) return FALSE /** - * The rocket volley's lock-on: a red marker under each of `targets` (by default each hunter it can see), a - * rising tone, and BOUNTY_MECH_ROCKET_LOCK later one rocket per marker (mech_fire_rockets()). Nothing is hurt - * before then. Returns the serial the launch checks, or 0 if it didn't start. + * The rocket volley's lock-on: a red marker under each of `targets` (by default each hunter it can see; it never + * picks one who is down), a rising tone, and BOUNTY_MECH_ROCKET_LOCK later one rocket per marker + * (mech_fire_rockets()). Nothing is hurt before then, and the burst then catches whoever stands on the marker. + * Returns the serial the launch checks, or 0 if it didn't start. */ /mob/living/basic/bounty_lair_boss/mafia_mech/proc/mech_start_rockets(list/targets) if(!mech_can_start_ability()) @@ -1754,7 +1785,6 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) rocket.rocket_area_ref = mech_home_ref rocket.firer = src rocket.fired_from = src - rocket.ignored_factions = faction.Copy() rocket.range = get_dist(start, spot) + 3 rocket.maximum_range = rocket.range rocket.aim_projectile(spot, src) @@ -1805,7 +1835,38 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) /mob/living/basic/bounty_lair_boss/mafia_mech/proc/mech_lmg_round(serial) if(!mech_still("lmg_fire", serial) || !mech_lmg_aim) return null - return bounty_mafia_shoot(src, mech_lmg_type, mech_lmg_aim, bounty_real_weapon(BOUNTY_MECH_LMG_GUN), BOUNTY_MECH_LMG_ARC, mech_lmg_range + 1) + return mech_shoot_round(mech_lmg_aim, bounty_real_weapon(BOUNTY_MECH_LMG_GUN), BOUNTY_MECH_LMG_ARC, mech_lmg_range + 1) + +/** + * The machine fires one round of `weapon` (a /datum/bounty_real_weapon, its exosuit gun) at `target` (a turf): + * every pellet with the real round's numbers and spread, `spread` degrees more (full width), no farther than + * `max_range` tiles. A real round from a machine: it hits whoever is in its way, the club's own people included. + * Returns the first projectile still flying, or null. + */ +/mob/living/basic/bounty_lair_boss/mafia_mech/proc/mech_shoot_round(atom/target, datum/bounty_real_weapon/weapon, spread = 0, max_range) + var/turf/start = get_turf(src) + var/turf/aim = get_turf(target) + if(!start || !aim || start == aim || !weapon) + return null + var/obj/projectile/first + for(var/pellet in 1 to weapon.pellets) + var/obj/projectile/bullet = new mech_lmg_type(start) + weapon.load(bullet) + if(max_range) + bullet.range = max_range + bullet.maximum_range = max_range + bullet.firer = src + bullet.fired_from = src + bullet.spread = spread + bullet.aim_projectile(target, src, null, weapon.shot_spread()) + if(QDELETED(bullet)) + continue + bullet.fire() + if(!first && !QDELETED(bullet)) + first = bullet + if(weapon.fire_sound) + playsound(src, weapon.fire_sound, 60, TRUE) + return first /** * A stomp on someone right next to it, which throws them (their exosuit and all) BOUNTY_MECH_STOMP_THROW tiles @@ -1862,7 +1923,8 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) /** * The mech breaks: a burnt-out wreck where it stood (decoration and cover, nothing to salvage) and the don - * climbing out beside it, on the side away from the hunters, with the mech's posting. Returns the don. + * climbing out beside it, on the side away from the hunters, with the mech's posting. He is one body the fight + * needs at once, so he is built now (spawn_human_npc(immediate = TRUE)). Returns the don. */ /mob/living/basic/bounty_lair_boss/mafia_mech/proc/mech_eject() if(mech_ejected) @@ -1877,22 +1939,21 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) var/obj/structure/bounty_mafia_wreck/wreck = new(spot) wreck.setDir(dir) var/turf/exit = mech_exit_turf(spot) + var/datum/criminal_bounty/posting = posting_ref?.resolve() var/datum/npc_spawn_context/context = new(src, null, "boss") - var/mob/living/basic/bounty_lair_boss/mafia_don/don = spawn_npc_in_zone(/mob/living/basic/bounty_lair_boss/mafia_don, exit || spot, context, FALSE) + var/datum/human_npc_order/order = spawn_human_npc(/mob/living/carbon/human/npc/bounty_mafia/don, exit || spot, name = posting?.record?.name, context = context, immediate = TRUE) + var/mob/living/carbon/human/npc/bounty_mafia/don/don = order?.spawned_ref?.resolve() + if(QDELETED(don)) + return null don.posting_ref = posting_ref don.don_wreck_ref = WEAKREF(wreck) // Whoever broke his machine, he knows don.don_grudge = mech_grudge.Copy() if(mech_home_ref) - don.don_home_ref = mech_home_ref - don.don_home_turf = mech_home_turf - var/datum/criminal_bounty/posting = posting_ref?.resolve() - if(posting?.record?.name) - don.name = posting.record.name - don.real_name = posting.record.name + don.mafia_home_ref = mech_home_ref + don.mafia_home_turf = mech_home_turf SEND_SIGNAL(src, COMSIG_BOUNTY_MAFIA_DON_EJECTED, don) don.don_on_eject() - context.finalize() return don /// The open tile beside `wreck_spot`, in its arena, farthest from the hunters @@ -1933,155 +1994,77 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) // ===== THE DON ===== /** - * The don on foot (phase two), out of his wreck. A pistol, the wreck for cover while he reloads, and no - * surrender: cuffs are refused and he fights until he dies. His death drops the gold signet ring with his - * posting on it and leaves a corpse in his clothes. + * The don on foot (phase two), out of his wreck: a person, the boss of the club. His gold Desert Eagle and two + * spare magazines, the wreck for cover while he reloads, and no surrender: he fights until he dies, and resists + * cuffs the tg way. Dragged out of his garage he can be taken anywhere; on his feet with nobody to fight he walks + * back. His death drops the gold signet ring with his posting on it, once, and leaves his body in his clothes. */ -/mob/living/basic/bounty_lair_boss/mafia_don - name = BOUNTY_DON_NAME - desc = "The don himself, head of the family that runs this club: a fur coat, a gold chain, and a gold pistol in his hand. He looks furious." - icon = 'icons/mob/simple/simple_human.dmi' - gender = MALE - // Nobody drags the don out of his garage - move_resist = MOVE_FORCE_STRONG - mob_biotypes = MOB_ORGANIC|MOB_HUMANOID - maxHealth = BOUNTY_DON_HEALTH - health = BOUNTY_DON_HEALTH - speed = BOUNTY_DON_SPEED - melee_attack_cooldown = 1.2 SECONDS - attack_vis_effect = ATTACK_EFFECT_PUNCH - combat_mode = TRUE - faction = list(FACTION_RUSSIAN, BOUNTY_MAFIA_FACTION) - sentience_type = SENTIENCE_BOSS - basic_mob_flags = DEL_ON_DEATH - initial_language_holder = /datum/language_holder/atom_basic - unsuitable_atmos_damage = 7.5 - unsuitable_cold_damage = 7.5 - unsuitable_heat_damage = 7.5 - ai_controller = /datum/ai_controller/basic_controller/bounty_mafia_don - /// His gold pistol (/datum/bounty_mafia_gun/don) - var/datum/bounty_mafia_gun/don/don_gun - /// His arena, which he never leaves, and where he's put back if dragged out - var/datum/weakref/don_home_ref - var/turf/don_home_turf +/mob/living/carbon/human/npc/bounty_mafia/don + npc_name = BOUNTY_DON_NAME + npc_look = /obj/effect/mob_spawn/corpse/human/bounty_mafia/don + npc_outfit = /datum/outfit/bounty_mafia_don/armed + npc_rank = HUMAN_NPC_RANK_BOSS + npc_damage_taken = BOUNTY_DON_DAMAGE_TAKEN + ai_controller = /datum/ai_controller/basic_controller/bounty_mafia/don + mafia_examine_line = "The don himself, head of the family that runs this club. He looks furious." + mafia_voice = "don" + mafia_idle_chatter = FALSE + mafia_hurt_bark_chance = 15 + mafia_windup = BOUNTY_DON_RAISE + mafia_windup_once = TRUE + mafia_windup_sound = 'sound/items/weapons/gun/pistol/rack_small.ogg' + mafia_volley = BOUNTY_DON_VOLLEY + mafia_volley_gap = BOUNTY_DON_VOLLEY_GAP + mafia_cooldown = BOUNTY_DON_COOLDOWN + mafia_reload_chance = 50 /// The wreck he hides behind (/obj/structure/bounty_mafia_wreck) var/datum/weakref/don_wreck_ref - /// What keeps him still with his AI quiet ("stagger"), or null - var/don_busy - var/don_busy_serial = 0 - var/don_busy_timer - /// The ring has dropped - var/don_trophy_dropped = FALSE - /// world.time he may say another line - var/don_next_bark_at = 0 /// Weakrefs to the hunters who have hurt him or his mech: fair game at any range, seen or not var/list/don_grudge = list() + /// world.time he has his bearings after climbing out of the wreck + var/don_dazed_until = 0 + /// The ring has dropped + var/don_trophy_dropped = FALSE -/mob/living/basic/bounty_lair_boss/mafia_don/Initialize(mapload) - . = ..() - don_gun = new(src) - // Up close he pistol-whips with it, as hard as the real thing - bounty_real_weapon(BOUNTY_DON_GUN).apply_melee(src) - apply_dynamic_human_appearance(src, mob_spawn_path = /obj/effect/mob_spawn/corpse/human/bounty_mafia/don, r_hand = BOUNTY_DON_GUN) - AddElement(/datum/element/death_drops, string_list(list(/obj/effect/mob_spawn/corpse/human/bounty_mafia/don))) - AddElement(/datum/element/footstep, footstep_type = FOOTSTEP_MOB_SHOE) - AddElement(/datum/element/relay_attackers) - RegisterSignal(src, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(don_on_attacked)) - RegisterSignal(src, COMSIG_ATOM_BULLET_ACT, PROC_REF(don_on_bullet_act)) - RegisterSignal(src, COMSIG_MOVABLE_PRE_MOVE, PROC_REF(don_on_pre_move)) - RegisterSignal(src, COMSIG_MOB_AFTER_APPLY_DAMAGE, PROC_REF(don_on_damaged)) - RegisterSignal(src, COMSIG_LIVING_PRE_WABBAJACKED, PROC_REF(don_refuse_polymorph)) - RegisterSignal(src, COMSIG_PRE_MOB_CHANGED_TYPE, PROC_REF(don_refuse_type_change)) - ban_from_containment() - don_home_turf = get_turf(src) - var/area/home = get_area(src) - if(home) - don_home_ref = WEAKREF(home) - -/mob/living/basic/bounty_lair_boss/mafia_don/Destroy() - QDEL_NULL(don_gun) - deltimer(don_busy_timer) - don_busy_timer = null - don_home_ref = null - don_home_turf = null +/mob/living/carbon/human/npc/bounty_mafia/don/Destroy() don_wreck_ref = null don_grudge = null return ..() -/mob/living/basic/bounty_lair_boss/mafia_don/Life(seconds_per_tick = SSMOBS_DT, times_fired) - . = ..() - if(stat == DEAD) - return - var/area/arena = don_home_ref?.resolve() - if(arena && don_home_turf && get_area(src) != arena) - forceMove(don_home_turf) - -/mob/living/basic/bounty_lair_boss/mafia_don/death(gibbed) - if(stat != DEAD) - don_clear_busy() - don_drop_trophy() - return ..() +// His garage is his arena: no room, no shout, no doorway cap +/mob/living/carbon/human/npc/bounty_mafia/don/mafia_settle_home() + mafia_home_turf = get_turf(src) + var/area/home = get_area(src) + if(home) + mafia_home_ref = WEAKREF(home) -// He won't be taken alive (kill-only, spec 14.1) -/mob/living/basic/bounty_lair_boss/mafia_don/item_interaction(mob/living/user, obj/item/tool, list/modifiers) - if(istype(tool, /obj/item/restraints)) - if(stat != DEAD) - balloon_alert(user, "he won't be taken alive!") - return ITEM_INTERACT_BLOCKING - return ..() +/mob/living/carbon/human/npc/bounty_mafia/don/mafia_is_ready() + return TRUE -/mob/living/basic/bounty_lair_boss/mafia_don/proc/don_refuse_polymorph(datum/source, what_to_randomize) - SIGNAL_HANDLER - return STOP_WABBAJACK +/mob/living/carbon/human/npc/bounty_mafia/don/mafia_raise_alarm(mob/living/hunter) + return FALSE -/mob/living/basic/bounty_lair_boss/mafia_don/proc/don_refuse_type_change(datum/source) - SIGNAL_HANDLER - return COMPONENT_BLOCK_MOB_CHANGE +/mob/living/carbon/human/npc/bounty_mafia/don/mafia_sight() + return BOUNTY_MECH_SIGHT -/// Says a line for "don_" unless he spoke recently or `force` -/mob/living/basic/bounty_lair_boss/mafia_don/proc/don_bark(context, force = FALSE) - if(stat != CONSCIOUS || (!force && world.time < don_next_bark_at)) - return FALSE - if(!bounty_mafia_say(src, "don_[context]")) - return FALSE - don_next_bark_at = world.time + BOUNTY_MAFIA_BARK_COOLDOWN - return TRUE +/mob/living/carbon/human/npc/bounty_mafia/don/death(gibbed) + var/was_alive = stat != DEAD + . = ..() + if(was_alive && stat == DEAD) + don_drop_trophy() -/// Climbing out of the wreck: dazed for BOUNTY_DON_EJECT_STAGGER, and a word about his machine -/mob/living/basic/bounty_lair_boss/mafia_don/proc/don_on_eject() - don_set_busy("stagger", BOUNTY_DON_EJECT_STAGGER) +/// Climbing out of the wreck: he takes BOUNTY_DON_EJECT_STAGGER to get his bearings, and has a word about his machine +/mob/living/carbon/human/npc/bounty_mafia/don/proc/don_on_eject() + don_dazed_until = world.time + BOUNTY_DON_EJECT_STAGGER Shake(2, 1, BOUNTY_DON_EJECT_STAGGER) visible_message(span_danger("The canopy blows off the wreck and [src] climbs out, coughing!")) - don_bark("eject", force = TRUE) - -/mob/living/basic/bounty_lair_boss/mafia_don/proc/don_set_busy(state, duration) - don_busy = state - don_busy_serial++ - deltimer(don_busy_timer) - don_busy_timer = null - ADD_TRAIT(src, TRAIT_IMMOBILIZED, BOUNTY_MAFIA_BUSY_TRAIT) - ai_controller?.CancelActions() - if(duration) - don_busy_timer = addtimer(CALLBACK(src, PROC_REF(don_clear_busy), don_busy_serial), duration, TIMER_STOPPABLE | TIMER_DELETE_ME) - return don_busy_serial - -/mob/living/basic/bounty_lair_boss/mafia_don/proc/don_clear_busy(serial) - if(serial && serial != don_busy_serial) - return FALSE - don_busy = null - deltimer(don_busy_timer) - don_busy_timer = null - REMOVE_TRAIT(src, TRAIT_IMMOBILIZED, BOUNTY_MAFIA_BUSY_TRAIT) - return TRUE - -/mob/living/basic/bounty_lair_boss/mafia_don/proc/don_can_act() - return !QDELETED(src) && stat == CONSCIOUS && isturf(loc) && !HAS_TRAIT(src, TRAIT_INCAPACITATED) + mafia_bark("eject", force = TRUE) /** - * The trophy: the gold signet ring, where he fell, with his posting and its record on it. Once only. - * Returns the ring, or null. + * The trophy: the gold signet ring, where he fell, with his posting and its record on it. Once only, however often + * he dies. A designed death drop: it is not his gear. Returns the ring, or null. */ -/mob/living/basic/bounty_lair_boss/mafia_don/proc/don_drop_trophy() +/mob/living/carbon/human/npc/bounty_mafia/don/proc/don_drop_trophy() if(don_trophy_dropped) return null var/turf/spot = get_turf(src) @@ -2102,39 +2085,23 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) SEND_SIGNAL(src, COMSIG_BOUNTY_MAFIA_TROPHY_DROPPED, ring) return ring -/mob/living/basic/bounty_lair_boss/mafia_don/proc/don_on_pre_move(datum/source, atom/new_loc) - SIGNAL_HANDLER - if(!bounty_mafia_leash_allows(src, don_home_ref?.resolve(), new_loc)) - return COMPONENT_MOVABLE_BLOCK_PRE_MOVE - return NONE - -/mob/living/basic/bounty_lair_boss/mafia_don/proc/don_on_attacked(datum/source, atom/attacker, attack_flags) - SIGNAL_HANDLER - if(!(attack_flags & (ATTACKER_DAMAGING_ATTACK | ATTACKER_STAMINA_ATTACK))) - return - don_answer_attack(attacker) - -// Every shot that hits him, the ones relay_attackers skips too (an exosuit's guns fire as the suit) -/mob/living/basic/bounty_lair_boss/mafia_don/proc/don_on_bullet_act(datum/source, obj/projectile/shot, def_zone, piercing_hit, blocked) - SIGNAL_HANDLER - don_answer_attack(shot?.firer) - -/// `attacker` (a player, or an exosuit's pilots) went for him, from any range: a grudge, and his target if he has none -/mob/living/basic/bounty_lair_boss/mafia_don/proc/don_answer_attack(atom/attacker) +// He holds a grudge against whoever hurts him, from any range, and takes them on if he has nobody else +/mob/living/carbon/human/npc/bounty_mafia/don/mafia_answer_attack(atom/attacker) if(stat == DEAD || !attacker) return for(var/mob/living/hunter as anything in bounty_mafia_attackers(attacker)) don_grudge |= WEAKREF(hunter) - if(ai_controller && !ai_controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET) && don_target_ok(hunter)) + if(ai_controller && !ai_controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET) && mafia_target_ok(hunter)) ai_controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) -/mob/living/basic/bounty_lair_boss/mafia_don/proc/don_on_damaged(datum/source, damage, damagetype) - SIGNAL_HANDLER - if(damage > 0 && stat == CONSCIOUS && prob(15)) - don_bark("hurt") +/mob/living/carbon/human/npc/bounty_mafia/don/mafia_answer_grab(mob/living/grabber) + if(stat == DEAD || !bounty_mafia_is_hunter(grabber) || faction_check_atom(grabber)) + return FALSE + don_grudge |= WEAKREF(grabber) + return ..() /// Whether he may go after `target`: a hunter on their feet in his arena, in his sight, or who has hurt him or his mech (any range up to BOUNTY_MECH_GRUDGE_RANGE) -/mob/living/basic/bounty_lair_boss/mafia_don/proc/don_target_ok(mob/living/target) +/mob/living/carbon/human/npc/bounty_mafia/don/mafia_target_ok(mob/living/target) if(!bounty_mafia_may_hurt(target) || faction_check_atom(target)) return FALSE var/turf/spot = get_turf(target) @@ -2145,16 +2112,16 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) return TRUE if(distance > BOUNTY_MECH_SIGHT) return FALSE - var/area/arena = don_home_ref?.resolve() + var/area/arena = mafia_home_ref?.resolve() return (arena && get_area(spot) == arena) || can_see(src, target, BOUNTY_MECH_SIGHT) -/// His target: the one he has while they're fair game, else the nearest he can see, else the nearest in his arena -/mob/living/basic/bounty_lair_boss/mafia_don/proc/don_find_target() +/// His target: the one he has while they're fair game, else the nearest he can see, else the nearest in his arena or holding his grudge +/mob/living/carbon/human/npc/bounty_mafia/don/mafia_find_target() var/datum/ai_controller/controller = ai_controller if(!controller) return null var/mob/living/current = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] - if(don_target_ok(current)) + if(mafia_target_ok(current)) return current current = null var/turf/here = get_turf(src) @@ -2167,7 +2134,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) if(grudged) candidates |= grudged for(var/mob/living/person in candidates) - if(!don_target_ok(person)) + if(!mafia_target_ok(person)) continue var/seen = can_see(src, person, BOUNTY_MECH_SIGHT) var/distance = get_dist(src, person) @@ -2182,7 +2149,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) return current /// The tile behind his wreck from `threat`, if it's open and in his arena -/mob/living/basic/bounty_lair_boss/mafia_don/proc/don_cover_turf(atom/threat) +/mob/living/carbon/human/npc/bounty_mafia/don/proc/don_cover_turf(atom/threat) var/obj/structure/bounty_mafia_wreck/wreck = don_wreck_ref?.resolve() if(QDELETED(wreck) || !threat) return null @@ -2190,7 +2157,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) var/away = get_dir(threat, wreck_spot) if(!wreck_spot || !away) return null - var/area/arena = don_home_ref?.resolve() + var/area/arena = mafia_home_ref?.resolve() for(var/direction in list(away, turn(away, 45), turn(away, -45))) var/turf/spot = get_step(wreck_spot, direction) if(!spot || isclosedturf(spot) || spot.is_blocked_turf(exclude_mobs = TRUE)) @@ -2200,16 +2167,11 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) return spot return null -/// One attack on `target`: a shot if he has a line, the pistol butt if he's next to them. TRUE if he attacked. -/mob/living/basic/bounty_lair_boss/mafia_don/proc/don_attack(mob/living/target) - if(!don_can_act() || don_busy || !don_target_ok(target)) - return FALSE - face_atom(target) - if(don_gun.ready() && can_see(src, target, BOUNTY_MECH_SIGHT) && don_gun.try_fire(target)) - return TRUE - if(Adjacent(target) && world.time >= next_move && !don_gun.winding) - return melee_attack(target) - return FALSE +/// Out of his garage on his own feet with nobody to fight: he walks back to where he climbed out. Returns that turf, or null. +/mob/living/carbon/human/npc/bounty_mafia/don/proc/don_head_home() + if(mafia_at_home() || !mafia_home_turf) + return null + return mafia_home_turf // ===== THE TROPHY ===== @@ -2245,30 +2207,164 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) . = ..() controller.clear_blackboard_key(target_key) +/** + * A club gunman's volley at its target, through its hands: the aim first if its gun has one (mafia_start_aim(), + * "aiming!"), then mafia_volley pulls of the trigger (controller.ai_interact(), the gun's own fire path, burst and + * fire rate) mafia_volley_gap apart, then mafia_cooldown before the next. A hit during the aim spoils it for a gun + * that fumbles. It checks its line of fire before each pull and steps aside rather than shoot through a friend. + */ +/datum/ai_behavior/bounty_mafia_fire + action_cooldown = 0.1 SECONDS + behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/bounty_mafia_fire/setup(datum/ai_controller/controller, target_key) + . = ..() + var/mob/living/carbon/human/npc/bounty_mafia/shooter = controller.pawn + var/atom/target = controller.blackboard[target_key] + if(!istype(shooter) || QDELETED(target) || isnull(human_npc_loaded_gun(shooter))) + return FALSE + if(world.time < shooter.mafia_next_volley_at) + return FALSE + shooter.mafia_aim_until = 0 + shooter.mafia_aim_spoiled = FALSE + shooter.mafia_volley_left = 0 + shooter.mafia_next_pull_at = 0 + if(shooter.mafia_windup && !(shooter.mafia_windup_once && shooter.mafia_raised)) + shooter.mafia_start_aim(target) + else + shooter.mafia_volley_left = shooter.mafia_volley + return TRUE + +/datum/ai_behavior/bounty_mafia_fire/perform(seconds_per_tick, datum/ai_controller/controller, target_key) + var/mob/living/carbon/human/npc/bounty_mafia/shooter = controller.pawn + var/atom/target = controller.blackboard[target_key] + if(QDELETED(target) || !shooter.mafia_can_act() || HAS_TRAIT(shooter, TRAIT_HANDS_BLOCKED)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + shooter.face_atom(target) + if(shooter.mafia_aim_until) + if(shooter.mafia_aim_spoiled) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(world.time < shooter.mafia_aim_until) + return AI_BEHAVIOR_DELAY + shooter.mafia_aim_until = 0 + shooter.mafia_raised = TRUE + shooter.mafia_volley_left = shooter.mafia_volley + var/obj/item/gun/gun = human_npc_loaded_gun(shooter) + if(isnull(gun) || shooter.mafia_volley_left <= 0) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + if(world.time < shooter.mafia_next_pull_at) + return AI_BEHAVIOR_DELAY + if(human_npc_ally_in_line(shooter, target)) + human_npc_sidestep(shooter, target) + return AI_BEHAVIOR_DELAY + if(!human_npc_ready_item(shooter, gun)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + shooter.zone_selected = human_npc_pick_aim_zone() + controller.ai_interact(target = target, combat_mode = TRUE) + shooter.mafia_volley_left-- + shooter.mafia_next_pull_at = world.time + shooter.mafia_volley_gap + if(shooter.mafia_volley_left <= 0) + return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED + return AI_BEHAVIOR_DELAY + +/datum/ai_behavior/bounty_mafia_fire/finish_action(datum/ai_controller/controller, succeeded, target_key) + . = ..() + var/mob/living/carbon/human/npc/bounty_mafia/shooter = controller.pawn + if(!istype(shooter)) + return + var/pause = shooter.mafia_aim_spoiled ? BOUNTY_MOBSTER_FUMBLE : shooter.mafia_cooldown + shooter.mafia_next_volley_at = max(shooter.mafia_next_volley_at, world.time + pause) + shooter.mafia_aim_until = 0 + shooter.mafia_aim_spoiled = FALSE + shooter.mafia_volley_left = 0 + +/// The player's reload (human_npc_reload), with the club's sound and lines as the hand goes for the magazine +/datum/ai_behavior/human_npc_reload/bounty_mafia + +/datum/ai_behavior/human_npc_reload/bounty_mafia/setup(datum/ai_controller/controller) + . = ..() + if(!.) + return + var/mob/living/carbon/human/npc/bounty_mafia/member = controller.pawn + if(istype(member)) + member.mafia_on_reload() + +/// Brute's fists: tg's melee, listening for his punch landing on the target for the length of the blow +/datum/ai_behavior/basic_melee_attack/human_npc/bounty_mafia_brute + +/datum/ai_behavior/basic_melee_attack/human_npc/bounty_mafia_brute/perform(seconds_per_tick, datum/ai_controller/controller, target_key, targeting_strategy_key, hiding_location_key) + var/mob/living/carbon/human/npc/bounty_mafia/lieutenant/brute = controller.pawn + var/mob/living/carbon/human/victim = controller.blackboard[target_key] + if(!istype(brute) || !ishuman(victim) || QDELETED(victim)) + return ..() + brute.RegisterSignal(victim, COMSIG_HUMAN_GOT_PUNCHED, TYPE_PROC_REF(/mob/living/carbon/human/npc/bounty_mafia/lieutenant, mafia_on_punch_landed), override = TRUE) + . = ..() + brute.UnregisterSignal(victim, COMSIG_HUMAN_GOT_PUNCHED) + +/** + * The bounty AI's breaking free (bounty_escape_captivity: cuffs, a locker, a hard grab, a carry), and any hold a + * hunter has on a club member, a passive grab included: grabbed, a goon breaks free. It resists the tg way (resist()). + */ +/datum/ai_planning_subtree/bounty_escape_captivity/bounty_mafia + +/datum/ai_planning_subtree/bounty_escape_captivity/bounty_mafia/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + . = ..() + if(. == SUBTREE_RETURN_FINISH_PLANNING) + return + var/mob/living/carbon/human/npc/bounty_mafia/member = controller.pawn + if(!istype(member) || member.stat != CONSCIOUS) + return + var/mob/living/holder = member.pulledby || (ismob(member.buckled) ? member.buckled : null) + if(!holder || !member.mafia_answer_grab(holder)) + return + controller.queue_behavior(/datum/ai_behavior/resist) + return SUBTREE_RETURN_FINISH_PLANNING + // ----- goons ----- +/** + * The club's people on human bodies: soft crit first (crawl, plead, a boss fires wild from the floor), then breaking + * free of whatever holds them, then the family's own mind. + */ /datum/ai_controller/basic_controller/bounty_mafia - blackboard = list() + blackboard = list( + BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/human_npc, + BB_TARGET_MINIMUM_STAT = HUMAN_NPC_SPARES_DOWNED, + BB_AGGRO_RANGE = BOUNTY_MOBSTER_SIGHT, + BB_HUMAN_NPC_SHOT_DELAY = BOUNTY_MOBSTER_PISTOL_COOLDOWN, + BB_HUMAN_NPC_FIRE_RANGE = BOUNTY_MOBSTER_SIGHT, + ) ai_movement = /datum/ai_movement/basic_avoidance idle_behavior = null planning_subtrees = list( + /datum/ai_planning_subtree/human_npc_soft_crit, + /datum/ai_planning_subtree/bounty_escape_captivity/bounty_mafia, /datum/ai_planning_subtree/bounty_mafia_goon, ) +/datum/ai_controller/basic_controller/bounty_mafia/TryPossessPawn(atom/new_pawn) + if(!ishumannpc(new_pawn)) + return AI_CONTROLLER_INCOMPATIBLE + return ..() + +// Cuffs and soft crit don't stop a person's AI (human_npc_soft_crit.dm) +/datum/ai_controller/basic_controller/bounty_mafia/get_able_to_run() + return human_npc_ai_able_to_run(src) + +/datum/ai_controller/basic_controller/bounty_mafia/on_stat_changed(mob/living/source, new_stat) + . = ..() + human_npc_ai_stat_changed(src, new_stat) + /** - * A goon's whole mind: back into its room if it's out; its target; nothing until its room's shout is over; - * then shoot with a line (or stab when next to them), else close in as far as its room lets it. + * A goon's whole mind: its target; nothing until its room's shout is over; then reload, shoot with a line (or stab + * or punch when next to them), else close in as far as its room lets it; with nobody to fight, back into its room. */ /datum/ai_planning_subtree/bounty_mafia_goon /datum/ai_planning_subtree/bounty_mafia_goon/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/trooper/russian/mafia/goon = controller.pawn + var/mob/living/carbon/human/npc/bounty_mafia/goon = controller.pawn if(!istype(goon) || goon.stat != CONSCIOUS) return SUBTREE_RETURN_FINISH_PLANNING - // Grabbed by a hunter: that's a fight. He's the target, and it breaks free first. - if(goon.mafia_answer_grab()) - controller.queue_behavior(/datum/ai_behavior/resist) - return SUBTREE_RETURN_FINISH_PLANNING if(!goon.mafia_can_act()) return SUBTREE_RETURN_FINISH_PLANNING var/at_home = goon.mafia_at_home() @@ -2278,10 +2374,8 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) goon.face_atom(target) return SUBTREE_RETURN_FINISH_PLANNING if(target) - var/has_line = goon.mafia_gun ? can_see(goon, target, BOUNTY_MOBSTER_SIGHT) : goon.Adjacent(target) - if(has_line) + if(goon.mafia_plan_attack(controller, target)) goon.mafia_away_since = 0 - controller.queue_behavior(/datum/ai_behavior/bounty_mafia_goon_attack, BB_BASIC_MOB_CURRENT_TARGET) return SUBTREE_RETURN_FINISH_PLANNING if(at_home) if(goon.mafia_step_ok(target)) @@ -2293,22 +2387,13 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) controller.set_blackboard_key(BB_BOUNTY_MAFIA_MOVE_TO, exit) controller.queue_behavior(/datum/ai_behavior/bounty_mafia_approach/onto, BB_BOUNTY_MAFIA_MOVE_TO) return SUBTREE_RETURN_FINISH_PLANNING + // Nobody it can get at from here: out of its room, it walks back var/turf/home = goon.mafia_head_home() if(home) controller.set_blackboard_key(BB_BOUNTY_MAFIA_MOVE_TO, home) controller.queue_behavior(/datum/ai_behavior/bounty_mafia_approach/onto, BB_BOUNTY_MAFIA_MOVE_TO) return SUBTREE_RETURN_FINISH_PLANNING -/datum/ai_behavior/bounty_mafia_goon_attack - -/datum/ai_behavior/bounty_mafia_goon_attack/perform(seconds_per_tick, datum/ai_controller/controller, target_key) - var/mob/living/basic/trooper/russian/mafia/goon = controller.pawn - var/mob/living/target = controller.blackboard[target_key] - if(!istype(goon) || QDELETED(target)) - return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED - goon.mafia_attack(target) - return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED - // ----- the mech ----- /datum/ai_controller/basic_controller/bounty_mafia_mech @@ -2358,44 +2443,50 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) // ----- the don ----- -/datum/ai_controller/basic_controller/bounty_mafia_don - blackboard = list() - ai_movement = /datum/ai_movement/basic_avoidance - idle_behavior = null +/datum/ai_controller/basic_controller/bounty_mafia/don + blackboard = list( + BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/human_npc, + BB_TARGET_MINIMUM_STAT = HUMAN_NPC_SPARES_DOWNED, + BB_AGGRO_RANGE = BOUNTY_MECH_SIGHT, + BB_HUMAN_NPC_SHOT_DELAY = BOUNTY_DON_COOLDOWN, + BB_HUMAN_NPC_FIRE_RANGE = BOUNTY_MECH_SIGHT, + ) planning_subtrees = list( + /datum/ai_planning_subtree/human_npc_soft_crit, + /datum/ai_planning_subtree/bounty_escape_captivity/bounty_mafia, /datum/ai_planning_subtree/bounty_mafia_don, ) -/// The don's mind: nothing while he reels; his target; behind the wreck while he reloads; shoot with a line; else closer +/** + * The don's mind: nothing while he gets his bearings; his target; behind the wreck to reload; shoot with a line, or + * his fists up close; else closer. With nobody to fight, back into his garage if he was taken out of it. + */ /datum/ai_planning_subtree/bounty_mafia_don /datum/ai_planning_subtree/bounty_mafia_don/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/bounty_lair_boss/mafia_don/don = controller.pawn - if(!istype(don) || don.don_busy || !don.don_can_act()) + var/mob/living/carbon/human/npc/bounty_mafia/don/don = controller.pawn + if(!istype(don) || don.stat != CONSCIOUS) + return SUBTREE_RETURN_FINISH_PLANNING + if(world.time < don.don_dazed_until || !don.mafia_can_act()) return SUBTREE_RETURN_FINISH_PLANNING - var/mob/living/target = don.don_find_target() + var/mob/living/target = don.mafia_find_target() if(!target) + var/turf/home = don.don_head_home() + if(home) + controller.set_blackboard_key(BB_BOUNTY_MAFIA_MOVE_TO, home) + controller.queue_behavior(/datum/ai_behavior/bounty_mafia_approach/onto, BB_BOUNTY_MAFIA_MOVE_TO) return SUBTREE_RETURN_FINISH_PLANNING - if(don.don_gun.is_reloading()) + var/obj/item/gun/gun = human_npc_held_gun(don) + if(gun && !gun.can_shoot() && !LAZYLEN(don.do_afters) && world.time >= controller.blackboard[BB_HUMAN_NPC_ARMING_RETRY_AT] && human_npc_can_reload(don, gun)) + // Behind the wreck first, then the fresh magazine var/turf/cover = don.don_cover_turf(target) if(cover && get_turf(don) != cover) controller.set_blackboard_key(BB_BOUNTY_MAFIA_MOVE_TO, cover) controller.queue_behavior(/datum/ai_behavior/bounty_mafia_approach/onto, BB_BOUNTY_MAFIA_MOVE_TO) return SUBTREE_RETURN_FINISH_PLANNING - if(don.Adjacent(target) || can_see(don, target, BOUNTY_MECH_SIGHT)) - controller.queue_behavior(/datum/ai_behavior/bounty_mafia_don_attack, BB_BASIC_MOB_CURRENT_TARGET) - else - controller.queue_behavior(/datum/ai_behavior/bounty_mafia_approach, BB_BASIC_MOB_CURRENT_TARGET) + if(don.mafia_plan_attack(controller, target)) + return SUBTREE_RETURN_FINISH_PLANNING + controller.queue_behavior(/datum/ai_behavior/bounty_mafia_approach, BB_BASIC_MOB_CURRENT_TARGET) return SUBTREE_RETURN_FINISH_PLANNING -/datum/ai_behavior/bounty_mafia_don_attack - -/datum/ai_behavior/bounty_mafia_don_attack/perform(seconds_per_tick, datum/ai_controller/controller, target_key) - var/mob/living/basic/bounty_lair_boss/mafia_don/don = controller.pawn - var/mob/living/target = controller.blackboard[target_key] - if(!istype(don) || QDELETED(target)) - return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED - don.don_attack(target) - return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED - #undef BOUNTY_MAFIA_BUSY_TRAIT diff --git a/voidcrew/modules/bounties/bounty_lair_types.dm b/voidcrew/modules/bounties/bounty_lair_types.dm index 3abadc197f3..f4406c2c0b5 100644 --- a/voidcrew/modules/bounties/bounty_lair_types.dm +++ b/voidcrew/modules/bounties/bounty_lair_types.dm @@ -19,30 +19,32 @@ /// Where a lair's boss appears when the interior loads. Placed on the map (P11); P10 spawns boss_type there. /obj/effect/landmark/bounty_lair_boss - /// The boss to spawn here (a /mob/living/basic/bounty_lair_boss path), set on the map + /// The boss to spawn here, set on the map: a /mob/living/basic/bounty_lair_boss path, or a human NPC boss (built at once, it is one body) var/boss_type /// A lair's gatekeeper spot. P10 spawns gatekeeper_type here at load; when every gatekeeper in the lair is dead, P10 opens the lair's gate poddoors (mapped with id "bounty_lair_gate"). /obj/effect/landmark/bounty_lair_gatekeeper - /// The mob to spawn here as a gatekeeper, set on the map (the mafia lieutenant for the club) + /// The mob to spawn here as a gatekeeper, set on the map (the mafia lieutenant for the club). A human NPC is queued (spawn_human_npc()). var/gatekeeper_type -/// The base of lair bosses: never under /mob/living/basic/boss (megafauna are banned from ruins and outposts). P12 sets the mafia ones. +/// The base of lair bosses that aren't people: never under /mob/living/basic/boss (megafauna are banned from ruins and outposts). P12 sets the mafia one. /mob/living/basic/bounty_lair_boss /// Weakref to the posting (/datum/criminal_bounty), or null for an admin spawn var/datum/weakref/posting_ref -/// The don in his mech (phase one). P12. +/// The don in his mech (phase one): a machine, so it stays a mob of its own (owner call OC-5). P12. /mob/living/basic/bounty_lair_boss/mafia_mech -/// The don on foot after the mech breaks (phase two). His death drops the trophy. P12. -/mob/living/basic/bounty_lair_boss/mafia_don -/// Mafia goons for the club. P12 sets them (lootless, club outfits); P11 places their markers. -/mob/living/basic/trooper/russian/mafia -/mob/living/basic/trooper/russian/mafia/pistol -/mob/living/basic/trooper/russian/mafia/smg +/// The club's people: real human NPCs. The base is the knife man; P12 sets them (club outfits, real guns); P11 places their markers. +/mob/living/carbon/human/npc/bounty_mafia +/mob/living/carbon/human/npc/bounty_mafia/pistol +/mob/living/carbon/human/npc/bounty_mafia/smg /// Tougher; their deaths open the arena (P10's gate rule). P12. -/mob/living/basic/trooper/russian/mafia/lieutenant +/mob/living/carbon/human/npc/bounty_mafia/lieutenant +/// The don on foot after the mech breaks (phase two), a person. His death drops the trophy. P12. +/mob/living/carbon/human/npc/bounty_mafia/don + /// Weakref to the posting (/datum/criminal_bounty) he is wanted on, or null for an admin spawn + var/datum/weakref/posting_ref /// Room spawner for the club's goons. P12 sets its tables; P11 places it on the map (the loot test requires every zone_mobs subtype to appear in a ruin map). /obj/effect/zone_mobs/mafia diff --git a/voidcrew/modules/bounties/bounty_outfits.dm b/voidcrew/modules/bounties/bounty_outfits.dm new file mode 100644 index 00000000000..cb8ff1c6da0 --- /dev/null +++ b/voidcrew/modules/bounties/bounty_outfits.dm @@ -0,0 +1,124 @@ +/** + * # Bounty hunting: what criminals and their people wear + * + * Owner: P2 body (the table, the base clothes and the tier armour). The families dress themselves by + * overriding bounty_build_outfit(): P3 meek and normal criminals and companions, P4 the mini-boss kits, + * P6 decoys, P9 the kingpin and his goons, P12 the mafia club. + * + * Toughness comes from what they wear (defaults 1.5, CR-12): petty criminals in plain clothes, Wanted in + * an armour vest, Most Wanted in a vest and a helmet, mini-bosses in their kit's armour. It is real + * armour on real slots, locked to the body (D3), so it protects by tg's armour rules and never drops. + * Their weapons are carried, not held, until the fight starts, with real spare ammunition; their + * self-treatment items are real (N6). The human NPC base adds a sealed suit and air in vacuum, a mask in + * bad air and warm clothes in the cold, on top of whatever is picked here (human_npc_outfits.dm). + */ + +/** + * The outfit table of every bounty human: it asks the NPC being dressed (bounty_build_outfit()), so + * the choice can read its record, its tier, its style and its kit. Set as npc_outfit_table. + */ +/datum/human_npc_outfit_table/bounty + vacuum_layer = /datum/human_npc_layer/eva + +/datum/human_npc_outfit_table/bounty/pick_outfit(mob/living/carbon/human/npc/npc, zone) + if(!ishumannpc(npc)) + return null + return npc.bounty_build_outfit(zone || ZONE_GREEN) + +/** + * What a bounty human wears in `zone` (ZONE_*): a /datum/outfit typepath, or an instance made for it + * (bounty_outfit_instance()). Null leaves it in whatever its look brings. Every bounty family overrides it. + */ +/mob/living/carbon/human/npc/proc/bounty_build_outfit(zone) + return null + +/// A fresh outfit of `base_type`, to add weapons, armour and kit to before it is worn +/proc/bounty_outfit_instance(base_type) + if(!ispath(base_type, /datum/outfit)) + return null + return new base_type() + +/** + * Puts the armour of `tier` (BOUNTY_TIER_*) on `outfit`, an instance: Wanted an armour vest, Most Wanted + * a vest and a helmet, Petty none. Anything the old suit carried in its storage moves to the backpack. + */ +/proc/bounty_add_tier_armour(datum/outfit/outfit, tier) + if(!istype(outfit) || tier == BOUNTY_TIER_PETTY || isnull(tier)) + return outfit + if(outfit.suit_store) + if(outfit.back) + LAZYADDASSOC(outfit.backpack_contents, outfit.suit_store, 1) + outfit.suit_store = null + outfit.suit = /obj/item/clothing/suit/armor/vest + if(tier == BOUNTY_TIER_MOST_WANTED) + outfit.head = /obj/item/clothing/head/helmet + return outfit + +/// The plain clothes a criminal of `archetype` (BOUNTY_ARCHETYPE_*) wears in `zone` +/proc/bounty_plain_clothes(archetype, zone) + var/meek = archetype == BOUNTY_ARCHETYPE_MEEK + switch(zone) + if(ZONE_RED) + return meek ? /datum/outfit/bounty_criminal/drifter : /datum/outfit/bounty_criminal/tough + if(ZONE_YELLOW) + return meek ? /datum/outfit/bounty_criminal/spacer : /datum/outfit/bounty_criminal/hauler + return meek ? /datum/outfit/bounty_criminal : /datum/outfit/bounty_criminal/local + +// A criminal with no family of its own to dress it: plain clothes for its archetype and zone, and its tier's armour. +/mob/living/carbon/human/npc/bounty_criminal/bounty_build_outfit(zone) + var/datum/outfit/outfit = bounty_outfit_instance(bounty_plain_clothes(record?.archetype, zone)) + return bounty_add_tier_armour(outfit, record?.tier) + +/// ZONE_GREEN, ZONE_YELLOW or ZONE_RED for where its site is (or where it stands), green if unknown +/mob/living/carbon/human/npc/bounty_criminal/proc/body_zone() + var/atom/site = body_site_ref?.resolve() + var/zone = site ? SSovermap_zones?.get_zone_type(get_turf(site)) : SSovermap_zones?.get_zone_type_anywhere(get_turf(src)) + return zone || ZONE_GREEN + +// ===== PLAIN CLOTHES ===== + +/// Plain clothes for a meek criminal in green space +/datum/outfit/bounty_criminal + name = "Bounty criminal: civilian" + uniform = /obj/item/clothing/under/pants/jeans + suit = /obj/item/clothing/suit/toggle/jacket/sweater + shoes = /obj/item/clothing/shoes/sneakers/brown + +/// A meek criminal in yellow space +/datum/outfit/bounty_criminal/spacer + name = "Bounty criminal: spacer" + uniform = /obj/item/clothing/under/color/grey + suit = /obj/item/clothing/suit/jacket/bomber + shoes = /obj/item/clothing/shoes/workboots + head = /obj/item/clothing/head/beanie + +/// A meek criminal in red space +/datum/outfit/bounty_criminal/drifter + name = "Bounty criminal: drifter" + uniform = /obj/item/clothing/under/color/black + suit = /obj/item/clothing/suit/jacket/leather + shoes = /obj/item/clothing/shoes/jackboots + head = /obj/item/clothing/head/soft/grey + +/// A normal criminal in green space +/datum/outfit/bounty_criminal/local + name = "Bounty criminal: local" + uniform = /obj/item/clothing/under/costume/buttondown/slacks + suit = /obj/item/clothing/suit/jacket/letterman + shoes = /obj/item/clothing/shoes/sneakers/black + +/// A normal criminal in yellow space. Overalls, not bare jeans: a Wanted criminal's vest goes over a shirt. +/datum/outfit/bounty_criminal/hauler + name = "Bounty criminal: hauler" + uniform = /obj/item/clothing/under/misc/overalls + suit = /obj/item/clothing/suit/jacket/miljacket + gloves = /obj/item/clothing/gloves/fingerless + shoes = /obj/item/clothing/shoes/workboots + +/// A normal criminal in red space, and the fallback for a mini-boss +/datum/outfit/bounty_criminal/tough + name = "Bounty criminal: tough" + uniform = /obj/item/clothing/under/color/black + suit = /obj/item/clothing/suit/jacket/leather/biker + gloves = /obj/item/clothing/gloves/fingerless + shoes = /obj/item/clothing/shoes/jackboots diff --git a/voidcrew/modules/bounties/bounty_outpost.dm b/voidcrew/modules/bounties/bounty_outpost.dm index a60b8834fbf..3dbff01d01f 100644 --- a/voidcrew/modules/bounties/bounty_outpost.dm +++ b/voidcrew/modules/bounties/bounty_outpost.dm @@ -7,23 +7,29 @@ * tgui/packages/tgui/interfaces/WantedBoard.tsx and the tests in * voidcrew/modules/unit_tests/voidcrew_bounty_outpost.dm. Do not edit this file outside P6. * - * What it owns: identifying the fugitive (decision 16, spec section 7, abuse review section C): + * What it owns: identifying the fugitive (decision 16, spec section 7, abuse review section C). + * The fugitive and its decoys are real humans (/mob/living/carbon/human/npc, voidcrew/modules/human_npcs/): * - Blending in. The fugitive and BOUNTY_DECOY_COUNT decoys wear the zone's patron clothes and go * by the same generic name ("patron", "dockhand", "spacer"); the alias is never shown. While - * they blend in nobody can pull them, turrets leave them alone and stray shots pass through them - * (/datum/component/bounty_outpost_blend). - * - Decoys (/mob/living/basic/bounty_criminal/decoy): look-alikes with the same body and routine - * as the fugitive. Showing one the warrant, or hitting one on purpose, raises the posting's - * alert; a hit is also an outpost strike for the hitter. + * they blend in the turrets leave them alone and a hit on one is judged by who it was meant for + * (/datum/component/bounty_outpost_blend). They are people like any other: they can be grabbed, + * shot, knocked down and cuffed the way anyone can, and what they do about it is their AI's. + * - Decoys (/mob/living/carbon/human/npc/bounty_criminal/decoy): look-alikes with the fugitive's + * face (a record that shares one or two of its features), the zone's clothes, its bag and belt + * (outpost_match_kit(), emptied), and its toughness and pace (body_match()). Showing one the + * warrant, hitting one on purpose or reaching for its wrists raises the posting's alert; a hit is + * also an outpost strike for the hitter. * - Traders' clues: any trader, the barkeep included, gives a ship hunting a fugitive there one * true clue, a different one per trader. * - The warrant (/obj/item/paper/bounty_warrant): shown to the fugitive it exposes them (P3's * on_confronted()); shown to anyone else they protest. A ship can show one every * BOUNTY_WARRANT_COOLDOWN. - * - The alert: at BOUNTY_OUTPOST_ALERT_SLIP the fugitive slips away and the bounty relists (P5's - * relist()). - * - The walk out: when the posting closes or the fugitive slips away, the decoys and an uncaught - * fugitive walk to the hangar lift and fade out (/datum/component/bounty_outpost_exit). + * - The alert: at BOUNTY_OUTPOST_ALERT_SLIP the decoys leave and the fugitive walks out to the + * hangar lift; the bounty relists at another trader outpost once it has gone (P5's relist()). A + * fugitive caught on the way is still the posting's. + * - The walk out: when the posting closes, the decoys and an uncaught fugitive walk to the hangar + * lift through the human NPC base's npc_walk_out(). They can be shot, downed and cuffed on the way + * and are deleted only on the lift or out of every player's sight (bounty_outpost_walk_out()). * - The wanted board (/obj/structure/bounty_wanted_board): a locked board on each concourse * listing the public bounties. * @@ -127,24 +133,28 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( var/list/outpost_clues_told = list() /// How many of the fugitive's features each decoy was made to share, in spawn order var/list/outpost_decoy_shares = list() + /// The decoys' human NPC orders (/datum/human_npc_order), kept so the ones not built yet can be cancelled + var/list/outpost_decoy_orders = list() /** * Sets a trader-outpost bounty up to blend in, once P5 has spawned the criminal at the outpost * (site_ref and criminal_ref set): * - the record gets its old look, so the listing's mugshot shows how they used to look (AR-C1); * - the fugitive wears the zone's clothes and the zone's generic name, and blends in; - * - BOUNTY_DECOY_COUNT decoys spawn out of sight, each sharing one or two of its features; + * - BOUNTY_DECOY_COUNT decoys spawn out of sight, each sharing one or two of its features. They are + * human NPCs, so they wait their turn in the spawn queue and join `decoys` as they are built; with + * `immediate` they are built now (tests, and callers that need them at once); * - the alert and the traders' clues start over. * * Refuses (FALSE) a mini-boss (AR-C9), an outpost that already has BOUNTY_MAX_FUGITIVES_PER_OUTPOST, * and a posting whose site is not a loaded trader outpost. Returns TRUE when set up. */ -/datum/criminal_bounty/proc/setup_outpost_blend() +/datum/criminal_bounty/proc/setup_outpost_blend(immediate = FALSE) var/obj/structure/overmap/trader_outpost/outpost = site_ref?.resolve() - var/mob/living/basic/bounty_criminal/fugitive = criminal() + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = criminal() if(!istype(outpost) || !outpost.template_bottom_left || !outpost.outpost_template || !fugitive || !record) return FALSE - if(istype(fugitive, /mob/living/basic/bounty_criminal/boss) || record.archetype == BOUNTY_ARCHETYPE_BOSS) + if(istype(fugitive, /mob/living/carbon/human/npc/bounty_criminal/boss) || record.archetype == BOUNTY_ARCHETYPE_BOSS) log_game("BOUNTY: a mini-boss ([record.name]) was refused at [outpost]. Mini-bosses never go to trader outposts.") return FALSE if(!bounty_outpost_has_room(outpost, src)) @@ -189,6 +199,7 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( if(!fugitive.site_bounds) fugitive.site_bounds = bounty_outpost_bounds(outpost) + // Dressed in the zone's clothes by the component, which also gives it the generic name fugitive.AddComponent(/datum/component/bounty_outpost_blend, src, FALSE, display_name, display_desc, outfit) // Everyone blending in has the same even chance of heading for a bar stool, the fugitive included var/list/free_stools = bounty_outpost_free_stools(public_floor) @@ -196,7 +207,7 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( var/feature_count = length(record.features) for(var/turf/spot as anything in spots) - if(length(decoys) >= BOUNTY_DECOY_COUNT) + if(length(outpost_decoy_orders) >= BOUNTY_DECOY_COUNT) break // One or two of its features each, and never all of them (make_decoy_record() holds to that too) var/shared = rand(1, 2) @@ -207,16 +218,19 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( // If a line ever names a crime, it names the same one for everybody if(decoy_record) decoy_record.crime = record.crime - var/datum/npc_spawn_context/context = fugitive.bounty_profile_context() - var/mob/living/basic/bounty_criminal/decoy/decoy = spawn_npc_in_zone(/mob/living/basic/bounty_criminal/decoy, spot, context, FALSE) var/atom/anchor = (length(free_stools) && prob(50)) ? pick_n_take(free_stools) : null - decoy.outpost_become(fugitive, decoy_record, src, outpost, display_name, display_desc, outfit, anchor) - decoys += WEAKREF(decoy) + var/datum/human_npc_order/order = bounty_outpost_spawn_decoy(fugitive, decoy_record, spot, src, outpost, display_name, display_desc, outfit, anchor, CALLBACK(src, PROC_REF(outpost_decoy_built)), immediate) + outpost_decoy_orders += order RegisterSignal(src, COMSIG_BOUNTY_POSTING_CLOSED, PROC_REF(outpost_on_closed), override = TRUE) - log_game("BOUNTY: [record.name] is blending in at [outpost] as a [display_name], with [length(decoys)] decoys.") + log_game("BOUNTY: [record.name] is blending in at [outpost] as a [display_name], with [length(outpost_decoy_orders)] decoys on the way.") return TRUE +/// One of this posting's decoys has been built and made a look-alike: it is the posting's from now on +/datum/criminal_bounty/proc/outpost_decoy_built(mob/living/carbon/human/npc/bounty_criminal/decoy/decoy) + if(!QDELETED(decoy)) + decoys += WEAKREF(decoy) + /** * Raises the fugitive's alert for `reason` (BOUNTY_ALERT_*): a wrong warrant, or a hit on a decoy, * whoever did it. At BOUNTY_OUTPOST_ALERT_SLIP a fugitive still blending in slips away: it walks @@ -233,32 +247,58 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( return TRUE /** - * The fugitive has noticed too much fuss: while it is still blending in and free, it and its - * decoys leave, and the bounty relists. An exposed fugitive is already running or fighting and - * stays. Returns TRUE if it slipped away. + * The fugitive has noticed too much fuss: while it is still blending in and free, the decoys leave + * and it walks out to the hangar lift for real (bounty_outpost_walk_out()). The bounty relists at + * another trader outpost once it has gone (outpost_fugitive_left()); until then it is still this + * posting's, so a fugitive downed or cuffed on the way is as good a catch as any. An exposed + * fugitive is already running or fighting and stays. Returns TRUE if it set off. */ /datum/criminal_bounty/proc/outpost_slip_away() - var/mob/living/basic/bounty_criminal/fugitive = criminal() + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = criminal() if(!fugitive || !fugitive.blended || fugitive.capture_state() != BOUNTY_STATE_FREE) return FALSE + var/datum/component/bounty_outpost_blend/blend = fugitive.GetComponent(/datum/component/bounty_outpost_blend) + if(blend?.leaving) + return FALSE var/obj/structure/overmap/trader_outpost/outpost = outpost_site?.resolve() || site_ref?.resolve() var/where = outpost ? format_text(outpost.name) : "the outpost" - log_game("BOUNTY: [record?.name] slipped away from [where].") - // Detached first (outpost_release_site()), so relist() never deletes them mid-walk. P5 shows the - // reason as "WANTED: ." - outpost_release_site() - relist("slipped away from [where]") - return TRUE + log_game("BOUNTY: [record?.name] is slipping away from [where].") + outpost_dismiss_decoys() + // P5 shows the reason as "WANTED: ." + return bounty_outpost_walk_out(fugitive, outpost, CALLBACK(src, PROC_REF(outpost_fugitive_left), "slipped away from [where]")) -/// The decoys at the current site leave and fade out, and the posting forgets them -/datum/criminal_bounty/proc/outpost_dismiss_decoys(list/floor) - var/obj/structure/overmap/trader_outpost/outpost = outpost_site?.resolve() - if(length(decoys) && outpost && isnull(floor)) - floor = bounty_outpost_public_floor(outpost) +/** + * The slipping fugitive reached the lift (or went where no player could see): the bounty relists. + * Its body goes with it, so the posting lets go of it first and its going is not read as a loss. + * Nothing happens if it stopped being the posting's meanwhile (the posting closed or relisted). + */ +/datum/criminal_bounty/proc/outpost_fugitive_left(reason, mob/living/carbon/human/npc/bounty_criminal/leaver) + if(!is_open() || board_relisting || QDELETED(leaver) || criminal() != leaver) + return + board_detach_criminal() + leaver.posting_ref = null + log_game("BOUNTY: [record?.name] slipped away.") + relist(reason) + +/** + * The decoys not built yet are cancelled and the built ones set walking out, and the posting forgets + * them all. The walk itself starts asynchronously: closing a posting must not wait on anyone's AI. + */ +/datum/criminal_bounty/proc/outpost_dismiss_decoys() + var/list/leaving = outpost_forget_decoys() + if(length(leaving)) + INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(bounty_outpost_walk_out_all), leaving, outpost_site?.resolve()) + +/// Cancels the decoys still waiting to be built and lets go of the built ones. Returns the built ones, living or dead. +/datum/criminal_bounty/proc/outpost_forget_decoys() + for(var/datum/human_npc_order/order as anything in outpost_decoy_orders) + qdel(order) + outpost_decoy_orders.Cut() + . = list() for(var/datum/weakref/decoy_ref as anything in decoys) - var/mob/living/basic/bounty_criminal/decoy = decoy_ref?.resolve() + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = decoy_ref?.resolve() if(!QDELETED(decoy)) - bounty_outpost_walk_out(decoy, outpost, floor) + . += decoy decoys.Cut() /** @@ -270,15 +310,15 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( */ /datum/criminal_bounty/proc/outpost_release_site() var/obj/structure/overmap/trader_outpost/outpost = outpost_site?.resolve() - var/list/floor = outpost ? bounty_outpost_public_floor(outpost) : null - outpost_dismiss_decoys(floor) - var/mob/living/basic/bounty_criminal/fugitive = criminal() - if(!fugitive || !outpost || get_trader_outpost_for_turf(get_turf(fugitive)) != outpost) - return - // P5's own detach, so its deletion watch comes off too and the fade isn't read as a loss - board_detach_criminal() - fugitive.posting_ref = null - bounty_outpost_walk_out(fugitive, outpost, floor) + var/list/leaving = outpost_forget_decoys() + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = criminal() + if(fugitive && outpost && get_trader_outpost_for_turf(get_turf(fugitive)) == outpost) + // P5's own detach, so its deletion watch comes off too and the walk isn't read as a loss + board_detach_criminal() + fugitive.posting_ref = null + leaving += fugitive + if(length(leaving)) + INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(bounty_outpost_walk_out_all), leaving, outpost) /// The posting closed (P5's close()): the decoys and an uncaught fugitive walk out /datum/criminal_bounty/proc/outpost_on_closed(datum/source, reason, obj/structure/overmap/ship/winner) @@ -444,7 +484,7 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( * `user` showed this posting's warrant to its fugitive: it stops blending in, remembers who, and * reacts as its kind does (P3's on_confronted(): a meek one bolts, a normal one fights). */ -/datum/criminal_bounty/proc/outpost_confront(mob/living/basic/bounty_criminal/fugitive, mob/living/user) +/datum/criminal_bounty/proc/outpost_confront(mob/living/carbon/human/npc/bounty_criminal/fugitive, mob/living/user) fugitive.body_add_grudge(user) var/datum/component/bounty_outpost_blend/blend = fugitive.GetComponent(/datum/component/bounty_outpost_blend) blend?.stop_blending() @@ -460,7 +500,7 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( * The room notices an exposed fugitive: the nearest trader who can see them, within * BOUNTY_OUTPOST_REACT_RANGE, calls out. Returns the trader, or null. */ -/datum/criminal_bounty/proc/outpost_trader_reacts(mob/living/basic/bounty_criminal/fugitive) +/datum/criminal_bounty/proc/outpost_trader_reacts(mob/living/carbon/human/npc/bounty_criminal/fugitive) var/mob/living/basic/outpost_trader/nearest var/nearest_distance = INFINITY for(var/mob/living/basic/outpost_trader/trader in view(BOUNTY_OUTPOST_REACT_RANGE, fugitive)) @@ -478,7 +518,7 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( * `user` showed this posting's warrant to the wrong person, `target`: they protest and show their * papers. At this posting's trader outpost, it raises the alert. */ -/datum/criminal_bounty/proc/outpost_wrong_accusation(mob/living/basic/bounty_criminal/target, mob/living/user) +/datum/criminal_bounty/proc/outpost_wrong_accusation(mob/living/carbon/human/npc/bounty_criminal/target, mob/living/user) target.outpost_protest(user) to_chat(user, span_notice("Their papers are in order. Not who you're after.")) var/obj/structure/overmap/trader_outpost/outpost = outpost_site?.resolve() @@ -492,7 +532,7 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( * Someone showed them a warrant that isn't theirs: they protest, and show a docking pass that * checks out. Nothing else happens to them. */ -/mob/living/basic/bounty_criminal/proc/outpost_protest(mob/user) +/mob/living/carbon/human/npc/bounty_criminal/proc/outpost_protest(mob/user) if(stat != CONSCIOUS) return // Forced: a protest always comes out, whatever was said a moment ago (P1's third argument) @@ -505,99 +545,110 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( // DECOYS // ========================================================================= -// Built-in values, P6's. Everything that could tell a decoy from its fugitive is copied from the -// fugitive when the decoy is made (outpost_match_body()), whatever the fugitive's kind. -/mob/living/basic/bounty_criminal/decoy +// Built-in values, P6's. A decoy is a person like the fugitive: the same species, build and face but +// for the features it was made not to share, the zone's clothes, the fugitive's bag and belt +// (outpost_match_kit()), and its toughness and pace (body_match()). It carries no weapon and never fights. +/mob/living/carbon/human/npc/bounty_criminal/decoy name = "patron" desc = "Another customer passing through." - maxHealth = BOUNTY_MEEK_HEALTH - health = BOUNTY_MEEK_HEALTH + /// Its fixed toughness is its fugitive's (body_match()), never its own record's tier + body_tier_toughness = FALSE + /// Nobody's posting cleans a dead decoy up: the corpse sweep does + npc_corpse_lifetime = HUMAN_NPC_CORPSE_LIFETIME /// Barks when hit are rate-limited on their own, beside bounty_say()'s cooldown COOLDOWN_DECLARE(outpost_bark_cooldown) - /// How long its fugitive stays down (P2's body_recovery_time()), so they get up together; null before it is made one - var/outpost_recovery_time - /// Its fugitive's stamina pool (P2's body_stamina_pool()); null before it is made one - var/outpost_stamina_pool /** - * Makes this decoy a look-alike of `fugitive` wanted on `posting` at `outpost`: `decoy_record`'s - * face in the zone's `outfit`, the fugitive's body and routine, the zone's generic name, doing - * what the fugitive does (at `anchor`, a bar stool, or nothing). The decoy is NOT linked to the - * posting through posting_ref: it is not the criminal, and nothing the pad, the proof of death or - * the board does may treat it as one. The admin panel's decoys should come through here too. + * A decoy made any other way than bounty_outpost_spawn_decoy() still dresses as a customer of the zone + * it was made in, never as a criminal: no gun, no armour. + */ +/mob/living/carbon/human/npc/bounty_criminal/decoy/bounty_build_outfit(zone) + switch(zone) + if(ZONE_YELLOW) + return /datum/outfit/bounty_outpost_dockhand + if(ZONE_RED) + return /datum/outfit/bounty_outpost_spacer + return /datum/outfit/bounty_outpost_patron + +/** + * Builds a decoy for `fugitive` at `spot`: a human NPC with `decoy_record`'s face in the zone's + * `outfit` and generic name, in its fugitive's faction, in the spawn queue (SShuman_npcs) unless + * `immediate`. Once built it is made a look-alike (outpost_become()) and `on_built` is called with it. + * Returns the order; qdel() it to cancel a decoy not built yet. A decoy built for a posting that has + * closed, moved on or lost its fugitive in the meantime is deleted unseen. + */ +/proc/bounty_outpost_spawn_decoy(mob/living/carbon/human/npc/bounty_criminal/fugitive, datum/bounty_record/decoy_record, turf/spot, datum/criminal_bounty/posting, obj/structure/overmap/trader_outpost/outpost, display_name, display_desc, outfit, atom/anchor, datum/callback/on_built, immediate = FALSE) + var/datum/npc_spawn_context/context = new(outpost || spot, null, "ordinary", source_turf = get_turf(outpost || spot)) + var/datum/callback/finish = CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(bounty_outpost_finish_decoy), WEAKREF(fugitive), decoy_record, posting ? WEAKREF(posting) : null, outpost ? WEAKREF(outpost) : null, display_name, display_desc, outfit, anchor ? WEAKREF(anchor) : null, on_built) + return spawn_human_npc(/mob/living/carbon/human/npc/bounty_criminal/decoy, spot, finish, look = decoy_record, outfit = outfit, name = display_name, faction = fugitive?.faction, context = context, immediate = immediate) + +/// A decoy has just been built (bounty_outpost_spawn_decoy()): checks it is still wanted, then makes it a look-alike +/proc/bounty_outpost_finish_decoy(datum/weakref/fugitive_ref, datum/bounty_record/decoy_record, datum/weakref/posting_ref, datum/weakref/outpost_ref, display_name, display_desc, outfit, datum/weakref/anchor_ref, datum/callback/on_built, mob/living/carbon/human/npc/bounty_criminal/decoy/decoy) + if(QDELETED(decoy)) + return + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = fugitive_ref?.resolve() + var/datum/criminal_bounty/posting = posting_ref?.resolve() + var/obj/structure/overmap/trader_outpost/outpost = outpost_ref?.resolve() + if(QDELETED(fugitive) || (posting_ref && (QDELETED(posting) || !posting.is_open() || posting.outpost_site?.resolve() != outpost))) + qdel(decoy) + return + decoy.outpost_become(fugitive, decoy_record, posting, outpost, display_name, display_desc, outfit, anchor_ref?.resolve()) + on_built?.Invoke(decoy) + +/** + * Makes this decoy, already built in the zone's clothes with its record's face, a look-alike of + * `fugitive` wanted on `posting` at `outpost`: the fugitive's toughness and pace (body_match()), the + * zone's generic name and description, blending in like the fugitive and doing what it does (at + * `anchor`, a bar stool, or nothing). The decoy is NOT linked to the posting through posting_ref: it + * is not the criminal, and nothing the pad, the proof of death or the board does may treat it as + * one. `outfit` is the zone's clothes: a decoy built another way has its own put right. */ -/mob/living/basic/bounty_criminal/decoy/proc/outpost_become(mob/living/basic/bounty_criminal/fugitive, datum/bounty_record/decoy_record, datum/criminal_bounty/posting, obj/structure/overmap/trader_outpost/outpost, display_name, display_desc, outfit, atom/anchor) +/mob/living/carbon/human/npc/bounty_criminal/decoy/proc/outpost_become(mob/living/carbon/human/npc/bounty_criminal/fugitive, datum/bounty_record/decoy_record, datum/criminal_bounty/posting, obj/structure/overmap/trader_outpost/outpost, display_name, display_desc, outfit, atom/anchor) record = decoy_record - if(decoy_record?.gender) - gender = decoy_record.gender - site_bounds = bounty_outpost_bounds(outpost) - outpost_match_body(fugitive) - // The same routine as the fugitive's (AR-C6): the same AI controller type, so start_activity() - // sets the same blend-in routine on both. - var/datum/ai_controller/fugitive_controller = fugitive.ai_controller - if(istype(fugitive_controller)) - var/datum/ai_controller/current = ai_controller - if(!istype(current) || current.type != fugitive_controller.type) - if(istype(current)) - QDEL_NULL(ai_controller) - var/controller_type = fugitive_controller.type - new controller_type(src) + body_set_site(outpost) + // The concourse itself, whatever the site gave it + var/list/bounds = bounty_outpost_bounds(outpost) + if(bounds) + site_bounds = bounds + body_match(fugitive) + outpost_match_kit(fugitive) AddComponent(/datum/component/bounty_outpost_blend, posting, TRUE, display_name, display_desc, outfit) start_activity(BOUNTY_ACTIVITY_BLEND, anchor) /** - * Copies everything about `fugitive`'s body that a player could compare (AR-C6): P2's body_match() - * (health, pace, stamina and how it slows), how long it stays down, its size, how it breathes and - * talks, and how it reacts to a touch. + * Wears the same bag and belt as `fugitive` (a meek criminal's fanny pack, a holster, a satchel), which + * show at a glance and which the patron clothes leave on the fugitive. Each is a new one of its type, + * emptied: a decoy carries no weapon, so a gun slung on the fugitive's back has no match here. Locked + * to its body like the rest of its kit (D3). */ -/mob/living/basic/bounty_criminal/decoy/proc/outpost_match_body(mob/living/basic/bounty_criminal/fugitive) - outpost_recovery_time = fugitive.body_recovery_time() - outpost_stamina_pool = fugitive.body_stamina_pool() - body_match(fugitive) - damage_coeff = fugitive.damage_coeff.Copy() - max_stamina = fugitive.max_stamina - stamina_crit_threshold = fugitive.stamina_crit_threshold - stamina_recovery = fugitive.stamina_recovery - status_flags = fugitive.status_flags - mob_size = fugitive.mob_size - faction = LAZYCOPY(fugitive.faction) - habitable_atmos = fugitive.habitable_atmos?.Copy() - unsuitable_atmos_damage = fugitive.unsuitable_atmos_damage - minimum_survivable_temperature = fugitive.minimum_survivable_temperature - maximum_survivable_temperature = fugitive.maximum_survivable_temperature - unsuitable_cold_damage = fugitive.unsuitable_cold_damage - unsuitable_heat_damage = fugitive.unsuitable_heat_damage - speak_emote = fugitive.speak_emote?.Copy() - verb_say = fugitive.verb_say - verb_ask = fugitive.verb_ask - verb_exclaim = fugitive.verb_exclaim - verb_yell = fugitive.verb_yell - verb_whisper = fugitive.verb_whisper - bubble_icon = fugitive.bubble_icon - response_help_continuous = fugitive.response_help_continuous - response_help_simple = fugitive.response_help_simple - response_disarm_continuous = fugitive.response_disarm_continuous - response_disarm_simple = fugitive.response_disarm_simple - response_harm_continuous = fugitive.response_harm_continuous - response_harm_simple = fugitive.response_harm_simple - attacked_sound = fugitive.attacked_sound - -// Down as long as its fugitive would be (M2): a meek fugitive can't give itself away by getting up first. -/mob/living/basic/bounty_criminal/decoy/body_recovery_time() - return isnull(outpost_recovery_time) ? ..() : outpost_recovery_time - -/mob/living/basic/bounty_criminal/decoy/body_stamina_pool() - return isnull(outpost_stamina_pool) ? ..() : outpost_stamina_pool +/mob/living/carbon/human/npc/bounty_criminal/decoy/proc/outpost_match_kit(mob/living/carbon/human/npc/bounty_criminal/fugitive) + if(QDELETED(fugitive)) + return + for(var/slot in list(ITEM_SLOT_BACK, ITEM_SLOT_BELT)) + var/obj/item/theirs = fugitive.get_item_by_slot(slot) + var/obj/item/mine = get_item_by_slot(slot) + if(mine?.type == theirs?.type) + continue + if(mine) + temporarilyRemoveItemFromInventory(mine, force = TRUE) + qdel(mine) + if(!istype(theirs, /obj/item/storage)) + continue + var/obj/item/storage/copy = new theirs.type(src) + for(var/atom/movable/inside as anything in copy.contents) + qdel(inside) + if(equip_to_slot_or_del(copy, slot, initial = TRUE)) + npc_lock_item(copy) /// A decoy never fights anyone (P2's gate on attacks) -/mob/living/basic/bounty_criminal/decoy/may_attack(atom/target) +/mob/living/carbon/human/npc/bounty_criminal/decoy/may_attack(atom/target) return FALSE /** - * Confronting a decoy, whoever does it (a wrong warrant, cuffs reached for, any other package): a - * wrong accusation, with its cost. It protests, and at its outpost the posting's alert rises (C1). + * Confronting a decoy, whoever does it (a wrong warrant, any other package): a wrong accusation, + * with its cost. It protests, and at its outpost the posting's alert rises (C1). */ -/mob/living/basic/bounty_criminal/decoy/on_confronted(mob/user) +/mob/living/carbon/human/npc/bounty_criminal/decoy/on_confronted(mob/user) var/datum/component/bounty_outpost_blend/blend = GetComponent(/datum/component/bounty_outpost_blend) var/datum/criminal_bounty/posting = blend?.posting_ref?.resolve() if(blend?.leaving || QDELETED(posting) || !isliving(user) || !user.mind) @@ -605,15 +656,16 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( return posting.outpost_wrong_accusation(src, user) -/// Someone hit it on purpose: a bark, then it backs off from them for a few seconds -/mob/living/basic/bounty_criminal/decoy/proc/outpost_react_to_hit(mob/living/attacker) +/// Someone hit it on purpose: a bark, then it backs off from them for a few seconds (not while it is walking out) +/mob/living/carbon/human/npc/bounty_criminal/decoy/proc/outpost_react_to_hit(mob/living/attacker) if(stat != CONSCIOUS || is_downed() || is_restrained()) return if(COOLDOWN_FINISHED(src, outpost_bark_cooldown)) COOLDOWN_START(src, outpost_bark_cooldown, 8 SECONDS) if(!bounty_say("hurt")) say(pick(GLOB.bounty_decoy_hurt_lines), forced = "bounty decoy") - if(QDELETED(attacker) || !isturf(loc) || HAS_TRAIT(src, TRAIT_IMMOBILIZED)) + var/datum/component/bounty_outpost_blend/blend = GetComponent(/datum/component/bounty_outpost_blend) + if(blend?.leaving || QDELETED(attacker) || !isturf(loc) || HAS_TRAIT(src, TRAIT_IMMOBILIZED)) return GLOB.move_manager.move_away(src, attacker, BOUNTY_DECOY_FLEE_DISTANCE, max(cached_multiplicative_slowdown, 1), BOUNTY_DECOY_FLEE_TIME, priority = MOVEMENT_ABOVE_SPACE_PRIORITY) @@ -626,15 +678,19 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( * * On the fugitive and on each decoy, so the two behave the same way (AR-C6, C7, C8): * - the zone's generic name and description (set once, and kept); - * - nobody can pull, drag, shove or stuff them anywhere; + * - the fugitive wears the zone's clothes (redress()); a decoy is built in them; * - the outpost's turrets leave them alone; - * - a shot not aimed at them passes through them; + * - they never step onto the hangar lift by themselves; * - a deliberate hit by a person counts: on a decoy it raises the alert and is an outpost strike, - * on the fugitive it ends the act. + * on the fugitive it ends the act. So does a reach for their wrists with cuffs. + * + * Nothing else is special about them: a hand on them, a shot, a shove or a thrown bottle goes through + * tg like it would for anyone, and they answer it the way their AI does. A shot hits whoever it hits; + * only one aimed at them counts as a deliberate hit. * * The fugitive stops blending in when exposed (the warrant, or a hit); a decoy never does. The - * component stays on an exposed fugitive for the rest of its time at the outpost: its own shots - * there pass through anyone not on its grudge list (AR-C8). + * component stays on an exposed fugitive for the rest of its time at the outpost: if it hurts a + * bystander there, the turrets are let loose on it (AR-C8). */ /datum/component/bounty_outpost_blend /// The posting they are part of, as a weakref (/datum/criminal_bounty) @@ -645,7 +701,7 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( var/decoy = FALSE /// Still blending in var/blending = TRUE - /// Walking out to the hangar (/datum/component/bounty_outpost_exit): hits and warrants no longer count + /// Walking out to the hangar (bounty_outpost_walk_out()): hits and warrants no longer count var/leaving = FALSE /// The zone's clothes they wear while blending in var/outfit @@ -657,21 +713,21 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( COOLDOWN_DECLARE(hit_grace) /datum/component/bounty_outpost_blend/Initialize(datum/criminal_bounty/posting, decoy = FALSE, display_name, display_desc, outfit) - if(!istype(parent, /mob/living/basic/bounty_criminal)) + if(!istype(parent, /mob/living/carbon/human/npc/bounty_criminal)) return COMPONENT_INCOMPATIBLE posting_ref = posting ? WEAKREF(posting) : null var/atom/outpost = posting?.outpost_site?.resolve() || posting?.site_ref?.resolve() outpost_ref = outpost ? WEAKREF(outpost) : null src.decoy = decoy src.outfit = outfit - var/mob/living/basic/bounty_criminal/owner = parent + var/mob/living/carbon/human/npc/bounty_criminal/owner = parent owner.blended = TRUE if(display_name) owner.name = display_name owner.real_name = display_name + owner.dna?.real_name = display_name if(display_desc) owner.desc = display_desc - owner.move_resist = MOVE_FORCE_VERY_STRONG ADD_TRAIT(owner, TRAIT_NO_CONTAINMENT, BOUNTY_OUTPOST_TRAIT) ADD_TRAIT(owner, TRAIT_NO_STORAGE_INSERT, BOUNTY_OUTPOST_TRAIT) // Belt and braces beside P2's turret rule for criminals: turrets skip faction-mates before @@ -681,23 +737,18 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( new_faction += FACTION_TURRET owner.faction = new_faction added_turret_faction = TRUE + // A decoy was built in the zone's clothes already, which changes nothing; the fugitive was dressed as the criminal it is if(outfit) redress() - // P2 dresses a new criminal in its own clothes in the background; whichever look lands - // last would stick, so the zone's is put back on after it (from the cache: cheap). - addtimer(CALLBACK(src, PROC_REF(redress)), 3 SECONDS, TIMER_DELETE_ME) - addtimer(CALLBACK(src, PROC_REF(redress)), 10 SECONDS, TIMER_DELETE_ME) /datum/component/bounty_outpost_blend/Destroy(force) stop_blending() return ..() /datum/component/bounty_outpost_blend/RegisterWithParent() - RegisterSignal(parent, COMSIG_ATOM_CAN_BE_PULLED, PROC_REF(on_pull_attempt)) - RegisterSignal(parent, COMSIG_MOUSEDROP_ONTO, PROC_REF(on_dragged)) RegisterSignal(parent, COMSIG_MOVABLE_PRE_MOVE, PROC_REF(on_pre_move)) RegisterSignal(parent, COMSIG_PROJECTILE_PREHIT, PROC_REF(on_projectile_prehit)) - RegisterSignal(parent, COMSIG_ATOM_ITEM_INTERACTION, PROC_REF(on_item_interaction)) + RegisterSignal(parent, COMSIG_BOUNTY_CUFF_REACHED, PROC_REF(on_cuff_reached)) RegisterSignal(parent, COMSIG_ATOM_AFTER_ATTACKEDBY, PROC_REF(on_item_attack)) RegisterSignal(parent, COMSIG_ATOM_ATTACK_HAND, PROC_REF(on_hand_attack)) RegisterSignal(parent, COMSIG_ATOM_ATTACK_HAND_SECONDARY, PROC_REF(on_shoved)) @@ -707,15 +758,13 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( RegisterSignal(parent, COMSIG_ATOM_PREHITBY, PROC_REF(on_thrown_hit)) RegisterSignals(parent, list(COMSIG_ATOM_ATTACK_BASIC_MOB, COMSIG_ATOM_ATTACK_ANIMAL), PROC_REF(on_creature_attack)) RegisterSignal(parent, COMSIG_PROJECTILE_FIRER_BEFORE_FIRE, PROC_REF(on_firing)) - RegisterSignal(parent, COMSIG_HOSTILE_POST_ATTACKINGTARGET, PROC_REF(on_melee_attack)) + RegisterSignals(parent, list(COMSIG_MOB_ITEM_ATTACK, COMSIG_LIVING_UNARMED_ATTACK), PROC_REF(on_own_melee_attack)) /datum/component/bounty_outpost_blend/UnregisterFromParent() UnregisterSignal(parent, list( - COMSIG_ATOM_CAN_BE_PULLED, - COMSIG_MOUSEDROP_ONTO, COMSIG_MOVABLE_PRE_MOVE, COMSIG_PROJECTILE_PREHIT, - COMSIG_ATOM_ITEM_INTERACTION, + COMSIG_BOUNTY_CUFF_REACHED, COMSIG_ATOM_AFTER_ATTACKEDBY, COMSIG_ATOM_ATTACK_HAND, COMSIG_ATOM_ATTACK_HAND_SECONDARY, @@ -726,27 +775,87 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( COMSIG_ATOM_ATTACK_BASIC_MOB, COMSIG_ATOM_ATTACK_ANIMAL, COMSIG_PROJECTILE_FIRER_BEFORE_FIRE, - COMSIG_HOSTILE_POST_ATTACKINGTARGET, + COMSIG_MOB_ITEM_ATTACK, + COMSIG_LIVING_UNARMED_ATTACK, )) -/// Puts the zone's clothes back on, while still blending in and not hiding (a meek one's disguise stays) +/** + * Changes the fugitive into the zone's clothes while it blends in. It was dressed as the criminal it + * is; decoys are built in the zone's, so the two must end up looking the same. See + * outpost_wear_patron_clothes(). + */ /datum/component/bounty_outpost_blend/proc/redress() - var/mob/living/basic/bounty_criminal/owner = parent - if(!blending || leaving || !outfit || !owner.record || owner.hidden) + var/mob/living/carbon/human/npc/bounty_criminal/owner = parent + if(!blending || leaving || !outfit || QDELETED(owner)) return - INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(apply_bounty_look), owner, owner.record, outfit) + owner.outpost_wear_patron_clothes(outfit) + +/** + * Changes into `outfit_type`'s clothes: the uniform, the coat, the gloves and the shoes it names, and + * nothing on the head or the face (the zone's patrons wear no hats: hair is a clue). What it wore + * there is taken away and deleted. Everything else it carries stays where it is, pockets and belt + * included. The new clothes are locked to the body like the rest of its kit (D3). + * What its species can't live without stays on (a plasmaman's envirosuit, helmet and gloves, its + * species' outfit_important_for_life): its decoys, of its species, are dressed over the same. + */ +/mob/living/carbon/human/npc/bounty_criminal/proc/outpost_wear_patron_clothes(outfit_type) + var/datum/outfit/patron = new outfit_type() + var/list/swaps = list( + list(w_uniform, patron.uniform, ITEM_SLOT_ICLOTHING), + list(wear_suit, patron.suit, ITEM_SLOT_OCLOTHING), + list(gloves, patron.gloves, ITEM_SLOT_GLOVES), + list(shoes, patron.shoes, ITEM_SLOT_FEET), + list(head, patron.head, ITEM_SLOT_HEAD), + list(wear_mask, patron.mask, ITEM_SLOT_MASK), + ) + qdel(patron) + var/datum/outfit/life = dna?.species?.outfit_important_for_life + for(var/list/swap as anything in swaps) + var/obj/item/worn = swap[1] + var/new_type = swap[2] + if(worn && ispath(new_type) && worn.type == new_type) + continue + if(bounty_outpost_kept_for_life(worn, life, swap[3])) + continue + if(worn) + // idrop off: the pockets, belt and suit storage are meant to stay when the clothes over them are swapped + temporarilyRemoveItemFromInventory(worn, force = TRUE, idrop = FALSE) + qdel(worn) + if(!ispath(new_type)) + continue + var/obj/item/clothes = new new_type(src) + equip_to_slot_or_del(clothes, swap[3], initial = TRUE) + npc_lock_item(clothes) -/// Ends the act: pullable (by P2's rules) and containable again, and no longer in the turrets' faction. The name stays. +/// Whether `worn`, in `slot`, is what `life` (a species' outfit_important_for_life) puts there: kept on when blending in +/proc/bounty_outpost_kept_for_life(obj/item/worn, datum/outfit/life, slot) + if(isnull(worn) || !ispath(life, /datum/outfit)) + return FALSE + var/life_type + switch(slot) + if(ITEM_SLOT_ICLOTHING) + life_type = initial(life.uniform) + if(ITEM_SLOT_OCLOTHING) + life_type = initial(life.suit) + if(ITEM_SLOT_GLOVES) + life_type = initial(life.gloves) + if(ITEM_SLOT_FEET) + life_type = initial(life.shoes) + if(ITEM_SLOT_HEAD) + life_type = initial(life.head) + if(ITEM_SLOT_MASK) + life_type = initial(life.mask) + return ispath(life_type) && istype(worn, life_type) + +/// Ends the act: containable again, and no longer in the turrets' faction. The name stays. /datum/component/bounty_outpost_blend/proc/stop_blending() if(!blending) return blending = FALSE - var/mob/living/basic/bounty_criminal/owner = parent + var/mob/living/carbon/human/npc/bounty_criminal/owner = parent if(QDELETED(owner)) return owner.blended = FALSE - if(!leaving) - owner.body_update_drag() REMOVE_TRAIT(owner, TRAIT_NO_CONTAINMENT, BOUNTY_OUTPOST_TRAIT) REMOVE_TRAIT(owner, TRAIT_NO_STORAGE_INSERT, BOUNTY_OUTPOST_TRAIT) if(added_turret_faction) @@ -755,29 +864,6 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( owner.faction = new_faction added_turret_faction = FALSE -/** - * Nobody pulls someone blending in, or walking out. By P2's rule, though, anyone down, cuffed or dead - * can be dragged: a fugitive (or a decoy, the same, AR-C6) downed or cuffed while still blending in, - * by a blast say, is dragged like any other catch. - */ -/datum/component/bounty_outpost_blend/proc/on_pull_attempt(datum/source, mob/living/puller) - SIGNAL_HANDLER - if(leaving) - return COMSIG_ATOM_CANT_PULL - if(!blending) - return NONE - var/mob/living/basic/bounty_criminal/owner = parent - if(owner.stat == DEAD || owner.downed || owner.is_restrained()) - return NONE - return COMSIG_ATOM_CANT_PULL - -/// Drag-drops (onto a bed, into a crate or disposals) never check move_resist, so they are refused here -/datum/component/bounty_outpost_blend/proc/on_dragged(datum/source, atom/over, mob/user) - SIGNAL_HANDLER - if(blending || leaving) - return COMPONENT_CANCEL_MOUSEDROP_ONTO - return NONE - /** * They never step onto the hangar lift by themselves: the lift carries everyone standing on it, and * a patron riding it down would leave the outpost. Dragged or thrown, they go where they are taken @@ -794,37 +880,39 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( return NONE /** - * A shot not aimed at someone blending in passes through them (AR-C7): nobody can use a decoy as a - * shield, or shoot "past" one to make a rival hit it. A shot aimed at them is a deliberate hit. + * A shot hits whoever it hits. One aimed at someone blending in is a deliberate hit by whoever fired + * it; a stray one that lands on them is not (nobody is framed with it). */ /datum/component/bounty_outpost_blend/proc/on_projectile_prehit(datum/source, obj/projectile/projectile) SIGNAL_HANDLER - if(leaving) - return PROJECTILE_INTERRUPT_HIT_PHASE - if(!blending) - return NONE - if(projectile.original != parent) - return PROJECTILE_INTERRUPT_HIT_PHASE - if(projectile.is_hostile_projectile() && isliving(projectile.firer)) + if(projectile.original == parent && projectile.is_hostile_projectile() && isliving(projectile.firer)) deliberate_hit(projectile.firer) return NONE /** - * Restraints reached for (C1): exactly the cost of a punch, on anyone blending in. A decoy's wrists - * are an outpost strike and the alert; the fugitive's end its act. Standing and free, they pull - * away, so P2's own refusal (and the confrontation it starts) never runs as a free test. Down or - * stunned, the cuffs go on as P2 puts them on anyone. + * Someone is putting restraints on them (COMSIG_BOUNTY_CUFF_REACHED, from the criminal body before its + * own reaction), exactly the cost of a punch (C1): + * - A decoy's wrists are an outpost strike and the alert, and it backs away (which breaks the cuffer's + * try). Handled here, so it isn't also taken for a wrong warrant. + * - The fugitive's end its act. The body's own reaction then steps it away and runs or fights, as for + * anyone who is reached for while free. + * Down, stunned or held, they can't do anything about it: the cuffs go on. Nobody without a mind + * counts. Walking out, the fugitive just takes it like any other free criminal; a decoy's wrists are + * still the hitter's strike (handle_hit()). */ -/datum/component/bounty_outpost_blend/proc/on_item_interaction(datum/source, mob/living/user, obj/item/tool, list/modifiers) +/datum/component/bounty_outpost_blend/proc/on_cuff_reached(datum/source, mob/living/user) SIGNAL_HANDLER - if(!blending || leaving || !istype(tool, /obj/item/restraints/handcuffs)) + if(!isliving(user) || !user.mind) return NONE - var/mob/living/basic/bounty_criminal/owner = parent - deliberate_hit(user) - if(owner.capture_state() != BOUNTY_STATE_FREE) + var/mob/living/carbon/human/npc/bounty_criminal/owner = parent + if(decoy) + deliberate_hit(user) + return owner.body_can_answer_cuffs() ? COMPONENT_BOUNTY_CUFF_HANDLED : NONE + if(!blending || leaving) return NONE - owner.balloon_alert(user, "[owner.p_they()] pull[owner.p_s()] away!") - return ITEM_INTERACT_BLOCKING + owner.body_add_grudge(user) + stop_blending() + return NONE /datum/component/bounty_outpost_blend/proc/on_item_attack(datum/source, obj/item/weapon, mob/living/attacker, list/modifiers, list/attack_modifiers) SIGNAL_HANDLER @@ -873,22 +961,24 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( /// Someone hit them on purpose. Only a person counts: stray shots, stray throws, explosions and NPCs never do. /datum/component/bounty_outpost_blend/proc/deliberate_hit(mob/living/attacker) - if(leaving || !istype(attacker) || !attacker.mind || attacker == parent) + if(!istype(attacker) || !attacker.mind || attacker == parent) return INVOKE_ASYNC(src, PROC_REF(handle_hit), attacker) /** * A person hit them on purpose. - * - The fugitive: the act is over (it remembers who, and reacts as its kind does). + * - The fugitive: the act is over (it remembers who, and reacts as its kind does). Walking out, it + * just takes the blow. * - A decoy (AR-C5): one outpost strike for the hitter, as for hitting a trader, and the bounty's - * alert rises once per scuffle, whoever swung. The decoy barks and backs off. + * alert rises once per scuffle, whoever swung. The decoy barks and backs off. Walking out, the + * alert has gone up already, so only the strike and the bark are left. */ /datum/component/bounty_outpost_blend/proc/handle_hit(mob/living/attacker) - var/mob/living/basic/bounty_criminal/owner = parent - if(QDELETED(owner) || QDELETED(attacker) || leaving) + var/mob/living/carbon/human/npc/bounty_criminal/owner = parent + if(QDELETED(owner) || QDELETED(attacker)) return if(!decoy) - if(!blending) + if(!blending || leaving) return owner.body_add_grudge(attacker) stop_blending() @@ -896,33 +986,33 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( return var/obj/structure/overmap/trader_outpost/outpost = get_trader_outpost_for_turf(get_turf(owner)) outpost?.register_aggression(attacker) - if(COOLDOWN_FINISHED(src, hit_grace)) + if(!leaving && COOLDOWN_FINISHED(src, hit_grace)) COOLDOWN_START(src, hit_grace, BOUNTY_OUTPOST_HIT_GRACE) var/datum/criminal_bounty/posting = posting_ref?.resolve() if(posting && !QDELETED(posting)) log_game("BOUNTY: [key_name(attacker)] hit a decoy of [posting.record?.name] at [AREACOORD(owner)].") posting.raise_alert(BOUNTY_ALERT_DECOY_HIT) // The alert may have sent everyone out already - var/mob/living/basic/bounty_criminal/decoy/decoy_mob = owner - if(!leaving && istype(decoy_mob)) + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy_mob = owner + if(istype(decoy_mob)) decoy_mob.outpost_react_to_hit(attacker) -/// Its own fists landed on `target` -/datum/component/bounty_outpost_blend/proc/on_melee_attack(datum/source, atom/target, result) +/// Its own fists, or what it swung, landed on `target` +/datum/component/bounty_outpost_blend/proc/on_own_melee_attack(datum/source, atom/target) SIGNAL_HANDLER note_victim(target) /** * The fugitive hurt `victim`. At a trader outpost, anyone not on its grudge list is a bystander, and * hurting one ends the turrets' leave to let the hunters handle it (AR-C8). P2's may_attack() and - * the grudge-only shots below keep that from happening; a thrown attack that gets round them should - * call this too. + * its AI's line-of-fire check keep that from happening on purpose; a bullet that hits one anyway + * lands here too (on_firing()). */ /datum/component/bounty_outpost_blend/proc/note_victim(atom/victim) if(decoy || !isliving(victim) || victim == parent) return - var/mob/living/basic/bounty_criminal/owner = parent - if(owner.body_has_grudge(victim) || istype(victim, /mob/living/basic/bounty_criminal) || istype(victim, /mob/living/basic/bounty_companion)) + var/mob/living/carbon/human/npc/bounty_criminal/owner = parent + if(owner.body_has_grudge(victim) || istype(victim, /mob/living/carbon/human/npc/bounty_criminal) || istype(victim, /mob/living/carbon/human/npc/bounty_companion)) return if(!is_trader_outpost_protected(owner)) return @@ -933,48 +1023,60 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( /** * Whether a trader outpost's turrets may fire on them (AR-C8): only a fugitive, exposed, that has * hurt someone who never crossed it. Blending in, or fighting only those who came for it, never. - * P2's line in is_hostile_creature() asks this for bounty criminals. + * Nor one the hunters already have: dead, in crit, cuffed or stunned (tg's own states). P2's line in + * is_hostile_creature() asks this for bounty criminals. */ -/mob/living/basic/bounty_criminal/proc/outpost_turret_target() +/mob/living/carbon/human/npc/bounty_criminal/proc/outpost_turret_target() + if(capture_state() != BOUNTY_STATE_FREE) + return FALSE var/datum/component/bounty_outpost_blend/blend = GetComponent(/datum/component/bounty_outpost_blend) return !!blend && !blend.blending && !blend.leaving && blend.hurt_bystander -/// The fugitive fired: at a trader outpost its shot passes through anyone not on its grudge list (AR-C8) +/// The fugitive fired: a shot of its that hits someone at a trader outpost is judged by who it hit (note_victim()) /datum/component/bounty_outpost_blend/proc/on_firing(datum/source, obj/projectile/projectile, atom/fired_from, atom/original) SIGNAL_HANDLER if(decoy || !is_trader_outpost_protected(parent)) return - RegisterSignal(projectile, COMSIG_PROJECTILE_SELF_PREHIT, PROC_REF(on_own_projectile_prehit)) + RegisterSignal(projectile, COMSIG_PROJECTILE_SELF_ON_HIT, PROC_REF(on_own_projectile_hit)) -/datum/component/bounty_outpost_blend/proc/on_own_projectile_prehit(obj/projectile/source, atom/target) +/datum/component/bounty_outpost_blend/proc/on_own_projectile_hit(obj/projectile/source, atom/movable/firer, atom/target, angle, hit_limb, blocked, pierce_hit) SIGNAL_HANDLER - if(!isliving(target) || target == parent) - return NONE - var/mob/living/basic/bounty_criminal/owner = parent - if(owner.body_has_grudge(target)) - return NONE - return PROJECTILE_INTERRUPT_HIT_PHASE + note_victim(target) // ========================================================================= // WALKING OUT // ========================================================================= +/// Sends each of `walkers` (human NPCs) out to `outpost`'s hangar lift: bounty_outpost_walk_out() +/proc/bounty_outpost_walk_out_all(list/walkers, obj/structure/overmap/trader_outpost/outpost) + for(var/mob/living/carbon/human/npc/walker as anything in walkers) + bounty_outpost_walk_out(walker, outpost) + /** - * `walker` leaves `outpost`: walks to the nearest hangar lift and fades out, or fades where they - * are if they can't walk there. `floor` is the outpost's public floor if the caller has it (one - * flood for everyone leaving at once); the lift is only walked to from a tile on it, so an - * unreachable lift is never pathed to. + * `walker` is done at `outpost`: it walks to the nearest hangar lift the way a person would + * (npc_walk_out(), human_npc_states.dm). It can be shot, downed, cuffed or grabbed on the way and then + * stays where it is; it is deleted only when it stands on the lift, or when no player can see it and + * it is on its feet and free. `on_left` is called with it just before that. A lift behind a counter it + * can't get round just means it goes when nobody is looking. Someone who is dead stays for the + * corpse sweep; someone sitting at a table or hiding gets up first. Returns TRUE if it set off. */ -/proc/bounty_outpost_walk_out(mob/living/walker, obj/structure/overmap/trader_outpost/outpost, list/floor) - if(QDELETED(walker) || walker.GetComponent(/datum/component/bounty_outpost_exit)) - return - var/turf/exit_turf = bounty_outpost_exit_turf(walker, outpost) - if(exit_turf) - if(isnull(floor)) - floor = bounty_outpost_public_floor(outpost) - if(!isturf(walker.loc) || !(walker.loc in floor) || !(exit_turf in floor)) - exit_turf = null - walker.AddComponent(/datum/component/bounty_outpost_exit, exit_turf) +/proc/bounty_outpost_walk_out(mob/living/carbon/human/npc/walker, obj/structure/overmap/trader_outpost/outpost, datum/callback/on_left) + if(QDELETED(walker) || walker.stat == DEAD || !isnull(walker.npc_exit)) + return FALSE + var/datum/component/bounty_outpost_blend/blend = walker.GetComponent(/datum/component/bounty_outpost_blend) + blend?.leaving = TRUE + var/mob/living/carbon/human/npc/bounty_criminal/criminal = walker + if(istype(criminal)) + // Out of the closet or from behind the plant, and up from its seat, its drink put down + if(criminal.hidden) + criminal.ai_unhide() + criminal.ai_end_activity() + criminal.ai_stand_up() + else if(walker.buckled && !ismob(walker.buckled) && !human_npc_out_of_fight(walker)) + walker.buckled.unbuckle_mob(walker, force = TRUE) + // The lift if there is one on its level; else where it stands, which it leaves once nobody can see it + var/turf/exit_turf = bounty_outpost_exit_turf(walker, outpost) || get_turf(walker) + return walker.npc_walk_out(exit_turf, on_left) /// The hangar lift alcove tile nearest `from`, on its level, or null /proc/bounty_outpost_exit_turf(atom/from, obj/structure/overmap/trader_outpost/outpost) @@ -992,114 +1094,6 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( nearest_distance = distance return nearest -/** - * # Walking out - * - * Someone P6 put at an outpost is done there: their AI stops, nobody can hurt or pull them, and - * they walk to the hangar lift and fade out. Anyone who can't walk (down, cuffed, hidden, dead), - * can't reach the lift, is taken off their feet on the way, or is still walking after - * BOUNTY_OUTPOST_EXIT_TIMEOUT fades where they are. The walk's move loop never outlives them. - */ -/datum/component/bounty_outpost_exit - /// The hangar lift tile they are walking to, or null - var/turf/destination - /// The walk to the lift, while it runs - var/datum/move_loop/walk_loop - /// Fading out now - var/fading = FALSE - -/datum/component/bounty_outpost_exit/Initialize(turf/destination) - if(!isliving(parent)) - return COMPONENT_INCOMPATIBLE - src.destination = destination - var/mob/living/walker = parent - var/datum/component/bounty_outpost_blend/blend = walker.GetComponent(/datum/component/bounty_outpost_blend) - if(blend) - blend.leaving = TRUE - ADD_TRAIT(walker, TRAIT_AI_PAUSED, BOUNTY_OUTPOST_TRAIT) - ADD_TRAIT(walker, TRAIT_GODMODE, BOUNTY_OUTPOST_TRAIT) - walker.move_resist = MOVE_FORCE_VERY_STRONG - walker.pulledby?.stop_pulling() - walker.stop_pulling() - addtimer(CALLBACK(src, PROC_REF(fade_out)), BOUNTY_OUTPOST_EXIT_TIMEOUT, TIMER_DELETE_ME) - if(!destination || !can_walk() || destination.z != walker.z) - fade_out() - return - RegisterSignal(walker, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved)) - walk_loop = GLOB.move_manager.jps_move(walker, destination, delay = BOUNTY_OUTPOST_EXIT_DELAY, timeout = BOUNTY_OUTPOST_EXIT_TIMEOUT, repath_delay = 2 SECONDS, max_path_length = 150, simulated_only = TRUE, priority = MOVEMENT_ABOVE_SPACE_PRIORITY) - if(!walk_loop) - fade_out() - return - RegisterSignal(walk_loop, COMSIG_MOVELOOP_PREPROCESS_CHECK, PROC_REF(before_step)) - RegisterSignals(walk_loop, list(COMSIG_MOVELOOP_STOP, COMSIG_QDELETING), PROC_REF(on_walk_ended)) - -/datum/component/bounty_outpost_exit/Destroy(force) - end_walk() - destination = null - return ..() - -/// Whether they can walk out on their own feet -/datum/component/bounty_outpost_exit/proc/can_walk() - var/mob/living/walker = parent - if(QDELETED(walker) || walker.stat != CONSCIOUS || !isturf(walker.loc) || walker.buckled) - return FALSE - if(HAS_TRAIT(walker, TRAIT_IMMOBILIZED) || HAS_TRAIT(walker, TRAIT_FLOORED) || HAS_TRAIT(walker, TRAIT_RESTRAINED)) - return FALSE - if(istype(walker, /mob/living/basic/bounty_criminal)) - var/mob/living/basic/bounty_criminal/criminal = walker - if(criminal.hidden || criminal.is_downed() || criminal.is_restrained()) - return FALSE - return TRUE - -/// Before each step: someone off their feet or off the floor (stuffed somewhere, carried off) stops walking and fades, so the pathfinder is never asked to start from nowhere -/datum/component/bounty_outpost_exit/proc/before_step(datum/move_loop/source) - SIGNAL_HANDLER - if(can_walk()) - return NONE - addtimer(CALLBACK(src, PROC_REF(fade_out)), 0, TIMER_DELETE_ME) - return MOVELOOP_SKIP_STEP - -/// The walk stopped (timed out, or ended): whoever hasn't reached the lift fades where they are -/datum/component/bounty_outpost_exit/proc/on_walk_ended(datum/move_loop/source) - SIGNAL_HANDLER - UnregisterSignal(source, list(COMSIG_MOVELOOP_PREPROCESS_CHECK, COMSIG_MOVELOOP_STOP, COMSIG_QDELETING)) - if(walk_loop == source) - walk_loop = null - if(!fading) - addtimer(CALLBACK(src, PROC_REF(fade_out)), 0, TIMER_DELETE_ME) - -/// Stops the walk, if it is still going -/datum/component/bounty_outpost_exit/proc/end_walk() - if(!walk_loop) - return - var/datum/move_loop/ending = walk_loop - walk_loop = null - UnregisterSignal(ending, list(COMSIG_MOVELOOP_PREPROCESS_CHECK, COMSIG_MOVELOOP_STOP, COMSIG_QDELETING)) - if(!QDELETED(ending)) - qdel(ending) - -/datum/component/bounty_outpost_exit/proc/on_moved(datum/source, atom/old_loc, dir, forced, list/old_locs) - SIGNAL_HANDLER - // Faded after the step, never inside the move loop's own step - if(destination && get_dist(parent, destination) <= 1) - addtimer(CALLBACK(src, PROC_REF(fade_out)), 0, TIMER_DELETE_ME) - -/datum/component/bounty_outpost_exit/proc/fade_out() - if(fading) - return - fading = TRUE - end_walk() - var/mob/living/walker = parent - if(QDELETED(walker)) - return - UnregisterSignal(walker, COMSIG_MOVABLE_MOVED) - GLOB.move_manager.stop_looping(walker) - animate(walker, alpha = 0, time = BOUNTY_OUTPOST_FADE_TIME) - addtimer(CALLBACK(src, PROC_REF(vanish)), BOUNTY_OUTPOST_FADE_TIME, TIMER_DELETE_ME) - -/datum/component/bounty_outpost_exit/proc/vanish() - qdel(parent) - // ========================================================================= // ASKING TRADERS // ========================================================================= @@ -1132,7 +1126,7 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( if(!posting) return FALSE var/words - var/mob/living/basic/bounty_criminal/fugitive = posting.criminal() + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = posting.criminal() if(!fugitive || get_trader_outpost_for_turf(get_turf(fugitive)) != trader.outpost) words = "They're not here any more." // slipped away, or someone already dragged them off else @@ -1204,21 +1198,21 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( var/obj/structure/overmap/trader_outpost/outpost = outpost_site?.resolve() switch(kind[1]) if(BOUNTY_CLUE_SEEN) - var/mob/living/basic/bounty_criminal/fugitive = criminal() + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = criminal() return fugitive ? bounty_outpost_where(fugitive, outpost) : null if(BOUNTY_CLUE_RULED_OUT) var/index = kind[2] if(index < 1 || index > length(decoys)) return null var/datum/weakref/decoy_ref = decoys[index] - var/mob/living/basic/bounty_criminal/decoy = decoy_ref?.resolve() + var/mob/living/carbon/human/npc/bounty_criminal/decoy = decoy_ref?.resolve() if(QDELETED(decoy) || decoy.stat == DEAD) return null var/where = bounty_outpost_where(decoy, outpost) if(!where) return null // Only if the place picks out one person: never a hint that could fit the fugitive - for(var/mob/living/basic/bounty_criminal/other as anything in outpost_candidates()) + for(var/mob/living/carbon/human/npc/bounty_criminal/other as anything in outpost_candidates()) if(other != decoy && bounty_outpost_where(other, outpost) == where) return null return where @@ -1251,11 +1245,11 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( /// The fugitive and its decoys, whoever of them still exists /datum/criminal_bounty/proc/outpost_candidates() . = list() - var/mob/living/basic/bounty_criminal/fugitive = criminal() + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = criminal() if(fugitive) . += fugitive for(var/datum/weakref/decoy_ref as anything in decoys) - var/mob/living/basic/bounty_criminal/decoy = decoy_ref?.resolve() + var/mob/living/carbon/human/npc/bounty_criminal/decoy = decoy_ref?.resolve() if(!QDELETED(decoy)) . += decoy @@ -1408,15 +1402,6 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( show_warrant(interacting_with, user) return ITEM_INTERACT_SUCCESS -/// Its bounty closed: it burns away, wherever it is. Whoever carries it is told; on the floor, the room sees it. -/obj/item/paper/bounty_warrant/proc/burn_up() - var/mob/living/holder = get(src, /mob/living) - if(holder) - to_chat(holder, span_notice("[src] curls up and burns away.")) - else if(isturf(loc)) - visible_message(span_notice("[src] curls up and burns away."), vision_distance = COMBAT_MESSAGE_RANGE) - qdel(src) - /** * `user` holds the warrant up to `target`. * - The fugitive it is for: exposed (outpost_confront()). @@ -1429,7 +1414,7 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( if(QDELETED(posting) || posting.status != BOUNTY_POSTING_OPEN) to_chat(user, span_warning("This warrant is out of date.")) return - if(!istype(target, /mob/living/basic/bounty_criminal)) + if(!istype(target, /mob/living/carbon/human/npc/bounty_criminal)) user.visible_message(span_notice("[user] holds up a warrant for [target] to see."), span_notice("You hold up the warrant for [target] to see."), vision_distance = COMBAT_MESSAGE_RANGE) if(target.client) to_chat(target, span_notice("[user] shows you a bounty warrant. It isn't for you.")) @@ -1443,7 +1428,7 @@ GLOBAL_LIST_INIT(bounty_outpost_trader_react_lines, list( return posting.outpost_start_warrant_cooldown(user) user.visible_message(span_notice("[user] holds up a warrant for [target] to see."), span_notice("You hold up the warrant for [target] to see."), vision_distance = COMBAT_MESSAGE_RANGE) - var/mob/living/basic/bounty_criminal/criminal = target + var/mob/living/carbon/human/npc/bounty_criminal/criminal = target if(criminal == posting.criminal()) posting.outpost_confront(criminal, user) else diff --git a/voidcrew/modules/bounties/bounty_placement.dm b/voidcrew/modules/bounties/bounty_placement.dm index f150143c2ce..2ee253fc2cf 100644 --- a/voidcrew/modules/bounties/bounty_placement.dm +++ b/voidcrew/modules/bounties/bounty_placement.dm @@ -277,7 +277,7 @@ SIGNAL_HANDLER if(!is_open() || board_relisting) return - var/mob/living/basic/bounty_criminal/criminal = criminal() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = criminal() // A criminal carried off the site (aboard a ship) is not the site's to take if(criminal && !board_site_contains(source, get_turf(criminal))) return @@ -285,11 +285,11 @@ /** * The site's interior went away with the criminal in it (spec 6: unload): the criminal, its - * companions and the marker go, the posting stays open, and the same record comes back at full - * health on the next load. Cuffs don't survive, but the worst state it reached does (12.1): it - * never pays more than it did before, and a dead one comes back as proof of death. + * companions and the marker go, the posting stays open, and the same record comes back unhurt on the + * next load, out of any cuffs. Pay is by its condition on the pad, so a living one owes nothing to how + * it was before; one that died comes back as proof of death. */ -/datum/criminal_bounty/proc/board_site_took_criminal(mob/living/basic/bounty_criminal/criminal) +/datum/criminal_bounty/proc/board_site_took_criminal(mob/living/carbon/human/npc/bounty_criminal/criminal) board_note_worst(criminal) board_detach_criminal() var/list/extras = list() @@ -307,13 +307,10 @@ board_wait_for_load(site()) log_game("BOUNTY: the [board_log_name()] waits for its site to load again") -/// Remembers the worst state `criminal` reached, for whatever body of it comes next (12.1) -/datum/criminal_bounty/proc/board_note_worst(mob/living/basic/bounty_criminal/criminal) - if(!criminal) - return - var/state = criminal.stat == DEAD ? BOUNTY_STATE_DEAD : criminal.worst_state - if(bounty_state_rank(state) < bounty_state_rank(board_worst_state)) - board_worst_state = state +/// Remembers whether `criminal` was dead when its site took it: the next body of it is then its proof of death +/datum/criminal_bounty/proc/board_note_worst(mob/living/carbon/human/npc/bounty_criminal/criminal) + if(criminal?.stat == DEAD) + board_worst_state = BOUNTY_STATE_DEAD /// The site is gone (a ruin respawning elsewhere, a pirate ship destroyed or despawned) /datum/criminal_bounty/proc/board_on_site_deleted(datum/source) @@ -409,7 +406,7 @@ return null if(board_worst_state == BOUNTY_STATE_DEAD) return board_place_proof(spot) - var/mob/living/basic/bounty_criminal/criminal = spawn_bounty_criminal(record, spot, src) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = spawn_bounty_criminal(record, spot, src) board_spawning = FALSE if(QDELETED(criminal)) return null @@ -441,7 +438,7 @@ * the blend at a trader outpost: P6's setup_outpost_blend()). Also used by tests and the admin panel * to adopt a criminal spawned by hand. */ -/datum/criminal_bounty/proc/board_adopt_criminal(mob/living/basic/bounty_criminal/criminal, obj/structure/overmap/where, activity, atom/anchor) +/datum/criminal_bounty/proc/board_adopt_criminal(mob/living/carbon/human/npc/bounty_criminal/criminal, obj/structure/overmap/where, activity, atom/anchor) if(QDELETED(criminal)) return FALSE board_detach_criminal() @@ -451,8 +448,6 @@ criminal.record = record RegisterSignal(criminal, COMSIG_QDELETING, PROC_REF(board_on_criminal_deleted)) board_spawn_failures = 0 - // Whatever an earlier body of theirs went through still counts (12.1). Only ever made worse. - criminal.body_restore_worst_state(board_worst_state) if(where) criminal.site_bounds = board_site_bounds(where) board_add_site_factions(criminal, where) @@ -480,7 +475,7 @@ /// Stops tracking the criminal without touching it /datum/criminal_bounty/proc/board_detach_criminal() - var/mob/living/basic/bounty_criminal/criminal = criminal() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = criminal() if(criminal) UnregisterSignal(criminal, COMSIG_QDELETING) criminal_ref = null @@ -497,7 +492,7 @@ return BOUNTY_ACTIVITY_EXPLORE /// Companions for a normal criminal: 0 to BOUNTY_MAX_COMPANIONS in every zone (12.3 C9: the zone scales pay, never the fight), within the server's cap -/datum/criminal_bounty/proc/board_spawn_companions(mob/living/basic/bounty_criminal/criminal) +/datum/criminal_bounty/proc/board_spawn_companions(mob/living/carbon/human/npc/bounty_criminal/criminal) var/count = rand(0, BOUNTY_MAX_COMPANIONS) // The crew aboard a pirate ship are company enough if(placement_kind == BOUNTY_PLACEMENT_NPC_SHIP) @@ -505,17 +500,15 @@ count = min(count, BOUNTY_MAX_LIVE_COMPANIONS - SScriminal_bounties.board_live_companions()) if(count <= 0) return list() - var/list/spawned = criminal.spawn_companions(count) - for(var/mob/living/companion in spawned) - companions |= WEAKREF(companion) - return spawned + // Built through the human NPC queue: each companion joins the posting's list as it joins its criminal (bounty_companions.dm). + criminal.spawn_companions(count) /** * Makes the criminal a friend of the site's own, so it doesn't fight the hostiles native to where * it hides (spec 3): the crew's factions aboard a pirate ship, the planet's and ruins' hostiles. * The neutral faction every player has is never added. */ -/datum/criminal_bounty/proc/board_add_site_factions(mob/living/basic/bounty_criminal/criminal, obj/structure/overmap/where) +/datum/criminal_bounty/proc/board_add_site_factions(mob/living/carbon/human/npc/bounty_criminal/criminal, obj/structure/overmap/where) var/list/added = list(FACTION_HOSTILE) if(istype(where, /obj/structure/overmap/ship/npc)) var/obj/structure/overmap/ship/npc/npc_ship = where @@ -562,7 +555,7 @@ * let go and the bounty lists at a new site. Returns TRUE if it acted. */ /datum/criminal_bounty/proc/board_check_unreachable() - var/mob/living/basic/bounty_criminal/criminal = criminal() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = criminal() if(!criminal) return FALSE var/in_chasm = istype(criminal.loc, /obj/effect/abstract/chasm_storage) @@ -850,7 +843,7 @@ if(placement_kind == BOUNTY_PLACEMENT_TRADER_OUTPOST) board_drop_marker() return FALSE - var/mob/living/basic/bounty_criminal/criminal = criminal() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = criminal() if(!criminal) return FALSE if(!force && world.time < board_next_sighting) diff --git a/voidcrew/modules/bounties/bounty_posting.dm b/voidcrew/modules/bounties/bounty_posting.dm index 68f9bbe68a7..3fe62e1ed42 100644 --- a/voidcrew/modules/bounties/bounty_posting.dm +++ b/voidcrew/modules/bounties/bounty_posting.dm @@ -45,7 +45,7 @@ var/datum/weakref/board_proof_ref /// Weakrefs to GPS units (/datum/component/gps/item) its sighting beacon was uploaded to -> weakref of the ship that linked them var/list/board_gps_units = list() - /// The worst capture state (BOUNTY_STATE_*) any body of its criminal reached. A criminal that comes back when its site loads again starts from here: once downed, never full pay; once dead, only proof (12.1). + /// BOUNTY_STATE_DEAD once a body of its criminal was dead when its site unloaded: the next load places its proof of death, never a living body again. Otherwise BOUNTY_STATE_FREE. var/board_worst_state = BOUNTY_STATE_FREE /// The sighting beacon's tag on those units var/board_gps_tag @@ -53,8 +53,6 @@ var/board_next_sighting = 0 /// "[REF(ship)]" -> warrants that ship printed for it (AR-G2) var/list/board_warrants = list() - /// Weakrefs to every warrant printed for it, burned when it closes - var/list/board_printed_warrants = list() /// Timer deciding, a moment after its criminal was deleted, whether anything is left to turn in var/board_lost_timer @@ -284,7 +282,6 @@ claimants.Cut() board_hunt_started.Cut() board_clear_gps() - board_burn_warrants() // Listeners get the criminal and decoys first: P6 detaches the ones at a trader outpost and walks them out SEND_SIGNAL(src, COMSIG_BOUNTY_POSTING_CLOSED, reason, winner) @@ -351,7 +348,7 @@ * so this never touches one being beamed out. */ /datum/criminal_bounty/proc/board_remove_mobs(reason, relisting = FALSE) - var/mob/living/basic/bounty_criminal/criminal = criminal() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = criminal() board_detach_criminal() var/list/extras = list() for(var/datum/weakref/ref as anything in companions + decoys) @@ -385,6 +382,12 @@ var/turf/spot = get_turf(leaving) if(spot && leaving.stat != DEAD) new /obj/effect/temp_visual/transporter_flash/departure(spot) + // Its locked kit goes with it (D3); whatever on it isn't its own (papers, a key, a crew's cuffs) stays behind. + if(ishumannpc(leaving) && spot) + var/mob/living/carbon/human/npc/body = leaving + body.npc_drop_not_gear() + for(var/obj/item/restraints/worn in list(body.handcuffed, body.legcuffed)) + body.transferItemToLoc(worn, spot, force = TRUE) qdel(leaving) // ===== RELISTING ===== @@ -486,19 +489,12 @@ return 0 /** - * Percent paid for a criminal in `state` at the pad that has at some point been as bad as - * `worst_state` (12.1: once downed, at most the downed share; once dead, the dead share). 0 for a - * free criminal, which the pad refuses. + * Percent paid for a criminal in `state` at the pad: its condition there, nothing it went through on the + * way (owner ruling 2026-11-08). 0 for a free criminal, which the pad refuses. The kingpin and kill-only + * postings override it. */ -/datum/criminal_bounty/proc/board_share_for(state, worst_state) - var/share = bounty_state_share(state) - if(!share) - return 0 - if(worst_state && worst_state != BOUNTY_STATE_FREE) - var/worst_share = bounty_state_share(worst_state) - if(worst_share) - share = min(share, worst_share) - return share +/datum/criminal_bounty/proc/board_share_for(state) + return bounty_state_share(state) /** * What a turn-in at `share` percent pays: list(credits, vouchers). Vouchers come only with the @@ -626,17 +622,8 @@ warrant.name = "warrant ([record?.name || "unknown"])" warrant.add_raw_text(board_warrant_text(), advanced_html = TRUE) warrant.update_appearance() - board_printed_warrants += WEAKREF(warrant) return warrant -/// Burns every warrant printed for it that is still around: a closed bounty's warrant is only litter -/datum/criminal_bounty/proc/board_burn_warrants() - for(var/datum/weakref/warrant_ref as anything in board_printed_warrants) - var/obj/item/paper/bounty_warrant/warrant = warrant_ref?.resolve() - if(!QDELETED(warrant)) - warrant.burn_up() - board_printed_warrants.Cut() - /// The reward as a poster says it: "1000 cr and 1 trade voucher" /datum/criminal_bounty/proc/board_reward_text() return "[value] cr[board_vouchers ? " and [board_vouchers] trade voucher[board_vouchers > 1 ? "s" : ""]" : ""]" diff --git a/voidcrew/modules/bounties/bounty_restraints.dm b/voidcrew/modules/bounties/bounty_restraints.dm index 736afda066f..a1eabc81d22 100644 --- a/voidcrew/modules/bounties/bounty_restraints.dm +++ b/voidcrew/modules/bounties/bounty_restraints.dm @@ -1,268 +1,137 @@ /** - * # Bounty hunting: restraints on a criminal + * # Bounty hunting: cuffs on a criminal * * Owner: P2 body. Do not edit this file outside P2. * - * What it owns: cuffing bounty criminals, a port of the prisoner's cuff pattern - * (outpost_prison_capture.dm) as procs on the criminal (spec sections 4 and 12.3, C1 and C2): - * - Any tg handcuffs, cable restraints or zipties, used on it by anyone with hands. Only on a criminal - * that is downed, stunned or has surrendered, over BOUNTY_CUFF_TIME. On one standing free the cuffs - * are refused, and the try alerts it (P3's on_confronted()). - * - Restrained, it is held still, throws no punches and fires no shots (may_attack()), plans nothing - * (TRAIT_BOUNTY_HELD and TRAIT_AI_PAUSED), and can be dragged. A downed one stays down until the - * cuffs come off. - * - Anyone takes them off with an empty hand over BOUNTY_UNCUFF_TIME: handcuffs to their hand, cable - * and zipties cut away. - * - Cable restraints slip after BOUNTY_CABLE_SLIP and zipties after BOUNTY_ZIPTIE_SLIP (a mini-boss in - * half the time, and it snaps them), with a visible struggle for the last BOUNTY_SLIP_WARNING. - * Handcuffs never slip. - * - The cuffs show as tg's handcuff overlay, stay in its contents, and drop when it dies or is deleted. - * Cuffing a criminal gives no claim on it: whoever gets it onto their own pad is paid (decision 18). + * A criminal is cuffed the way a person is: tg's attempt_to_cuff() (4 seconds, anyone with hands, any + * tg handcuffs, cable restraints or zipties), worn in tg's handcuff slot, and taken off the way anyone's + * are. A cuffed criminal can walk, as players can; it works at its cuffs through tg's resist (its AI's + * escape captivity): a minute for handcuffs, 45 s for zipties, 30 s for cable, and dragging it breaks the + * try (defaults 1.4). Its AI plans nothing else while cuffed. * - * The shared vars (`restraints` and the rest) are declared in bounty_types.dm and nowhere else; a - * var only P2 uses goes here, or in bounty_criminal.dm, with a `body_` prefix. + * What this file adds: + * - The reaction to a reach for its wrists (defaults 1.4, CR-7): while it can still move on its own it + * steps away a moment after the cuffing starts, which breaks the cuffer's do_after, and then runs or + * fights (on_confronted()). Paralysed after giving up, stamcritted, knocked down or in crit, it can't, + * and the cuffs go on. A subtype changes it in body_on_cuff_attempt(); the trader-outpost blend takes + * it over through COMSIG_BOUNTY_CUFF_REACHED. + * - COMSIG_BOUNTY_CRIMINAL_RESTRAINED and _UNRESTRAINED for the AI packages, from tg's TRAIT_RESTRAINED. + * - Fultons never go on (M2, owner question 10): the pad is the only way off its site bar the carry. + * Cuffing gives no claim on it: whoever gets it onto their own pad is paid (decision 18). */ -// ===== CUFFING ===== +/mob/living/carbon/human/npc/bounty_criminal + /// Weakref to whoever last reached for its wrists, and when + var/datum/weakref/body_cuffer_ref + var/body_cuffed_at = 0 + /// world.time it last started working at its cuffs (tg's cuff_resist()) + var/body_working_cuffs_at = 0 + +/// Hooks tg's cuffing on it. Called once from Initialize(). Cuffs going on and off come through tg's +/// own TRAIT_RESTRAINED handlers below: a second registration of that signal on itself would replace +/// tg's, and its hands would stay free in cuffs. +/mob/living/carbon/human/npc/bounty_criminal/proc/body_hook_cuffs() + RegisterSignal(src, COMSIG_CARBON_CUFF_ATTEMPTED, PROC_REF(body_on_cuff_signal)) + RegisterSignal(src, COMSIG_MOB_REMOVING_CUFFS, PROC_REF(body_on_working_cuffs)) + +// tg's own TRAIT_RESTRAINED handlers (code/modules/mob/living/init_signals.dm) block its hands. Registering +// the trait's signals again on itself would replace them, so the body hears the cuffs through them. +/mob/living/carbon/human/npc/bounty_criminal/on_restrained_trait_gain(datum/source) + . = ..() + body_on_restrained(source) + +/mob/living/carbon/human/npc/bounty_criminal/on_restrained_trait_loss(datum/source) + . = ..() + body_on_unrestrained(source) -// Restraints go on from the item interaction, ahead of anything else that item might do to it. A -// fulton never goes on: the pad is the only way off its site bar the carry (M2, owner question 10). -/mob/living/basic/bounty_criminal/item_interaction(mob/living/user, obj/item/tool, list/modifiers) - if(istype(tool, /obj/item/restraints/handcuffs)) - return body_on_cuffs_used(user, tool) +// A fulton never goes on a criminal (M2). +/mob/living/carbon/human/npc/bounty_criminal/item_interaction(mob/living/user, obj/item/tool, list/modifiers) if(istype(tool, /obj/item/extraction_pack)) balloon_alert(user, "won't hold [p_them()]!") return ITEM_INTERACT_BLOCKING return ..() -/// Why `user` can't put `cuffs` on it now, as a balloon alert, or null if they can -/mob/living/basic/bounty_criminal/proc/body_cuff_refusal(mob/living/user, obj/item/restraints/handcuffs/cuffs) - if(stat == DEAD) - return "can't cuff [p_them()]" - if(is_restrained()) - return "already cuffed" - if(istype(cuffs, /obj/item/restraints/handcuffs/cable/zipties/used) || istype(cuffs, /obj/item/restraints/handcuffs/cable/zipties/fake/used)) - return "used up" - if(user && !iscyborg(user) && user.usable_hands <= 0) - return "no hands free" - // Standing and free, it fights or runs; it has to be put down, stunned or talked into giving up first (C2). - if(capture_state() == BOUNTY_STATE_FREE) - return "[p_they()] pull[p_s()] away!" - return null +// ===== A REACH FOR ITS WRISTS ===== -/// Restraints used on it: refused with a balloon alert (and a free one is alerted), or put on in the background -/mob/living/basic/bounty_criminal/proc/body_on_cuffs_used(mob/living/user, obj/item/restraints/handcuffs/cuffs) - var/refusal = body_cuff_work ? "already busy" : body_cuff_refusal(user, cuffs) - if(refusal) - balloon_alert(user, refusal) - // Reaching for its wrists is a confrontation: a meek one bolts, a normal one fights (P3). Blending - // in, P6's blend component answers for it, the same for the fugitive and its decoys. - if(!body_cuff_work && !blended && capture_state() == BOUNTY_STATE_FREE) - body_add_grudge(user) - INVOKE_ASYNC(src, PROC_REF(on_confronted), user) - return ITEM_INTERACT_BLOCKING - INVOKE_ASYNC(src, PROC_REF(body_cuff_by), user, cuffs) - return ITEM_INTERACT_SUCCESS +/// tg's attempt_to_cuff() is about to start on it. Never refuses the cuffs: the body answers the way a person would. +/mob/living/carbon/human/npc/bounty_criminal/proc/body_on_cuff_signal(datum/source, mob/living/user) + SIGNAL_HANDLER + if(!isliving(user) || user == src || stat == DEAD) + return NONE + body_cuffer_ref = WEAKREF(user) + body_cuffed_at = world.time + if(SEND_SIGNAL(src, COMSIG_BOUNTY_CUFF_REACHED, user) & COMPONENT_BOUNTY_CUFF_HANDLED) + return NONE + body_on_cuff_attempt(user) + return NONE /** - * `user` puts `cuffs` on it over BOUNTY_CUFF_TIME, with tg's cuff sounds. Fails if it gets up or - * breaks free meanwhile, or moves away. Returns TRUE if it is restrained. Sleeps. + * `user` started cuffing it. While it can still move on its own it puts them on its grudge list and, + * a moment into their cuffing, steps away from them (breaking the try) and runs or fights. Override + * for a body that answers differently (a man on his sofa, a don who won't be taken alive). Inside the + * cuff signal's stack: must not sleep. */ -/mob/living/basic/bounty_criminal/proc/body_cuff_by(mob/living/user, obj/item/restraints/handcuffs/cuffs) - if(body_cuff_work || body_cuff_refusal(user, cuffs)) - return FALSE - body_cuff_work = TRUE - user.visible_message(span_danger("[user] is trying to put [cuffs] on [src]!"), span_danger("You try to put [cuffs] on [src].")) - playsound(src, cuffs.cuffsound, 30, TRUE, -2) - var/done = do_after(user, BOUNTY_CUFF_TIME, target = src, timed_action_flags = IGNORE_SLOWDOWNS) - body_cuff_work = FALSE - if(QDELETED(src)) - return FALSE - // A borg's cuffs are part of its module: it puts on a new pair of the same kind, as tg's cuffs do for borgs. - var/dispense = iscyborg(user) - if(!done || QDELETED(cuffs) || (cuffs.loc != user && !dispense) || body_cuff_refusal(user, cuffs)) - balloon_alert(user, "failed to cuff!") +/mob/living/carbon/human/npc/bounty_criminal/proc/body_on_cuff_attempt(mob/living/user) + if(!body_can_answer_cuffs()) + return + body_add_grudge(user) + addtimer(CALLBACK(src, PROC_REF(body_answer_cuffs), WEAKREF(user)), BOUNTY_CUFF_REACTION_DELAY, TIMER_DELETE_ME) + +/// Whether it can do anything about a reach for its wrists: awake, on its feet and free to move, not already cuffed, not held or hidden +/mob/living/carbon/human/npc/bounty_criminal/proc/body_can_answer_cuffs() + if(stat != CONSCIOUS || is_restrained() || buckled || hidden || !isturf(loc)) return FALSE - var/success_sound = cuffs.cuffsuccesssound - if(!body_apply_cuffs(cuffs, user, dispense)) - balloon_alert(user, "failed to cuff!") + if(HAS_TRAIT(src, TRAIT_INCAPACITATED) || HAS_TRAIT(src, TRAIT_IMMOBILIZED) || HAS_TRAIT(src, TRAIT_FLOORED)) return FALSE - playsound(src, success_sound, 30, TRUE, -2) - user.visible_message(span_notice("[user] restrains [src] with [restraints]."), span_notice("You restrain [src] with [restraints].")) - log_combat(user, src, "restrained") - return TRUE + return !(pulledby && pulledby.grab_state >= GRAB_AGGRESSIVE) -/// What `cuffs` turn into once worn: zipties their used pair, fake zipties their fake used pair (tg gives both the real one), anything else stays itself (null) -/proc/bounty_worn_cuffs_type(obj/item/restraints/handcuffs/cuffs) - if(istype(cuffs, /obj/item/restraints/handcuffs/cable/zipties/fake) && !istype(cuffs, /obj/item/restraints/handcuffs/cable/zipties/fake/used)) - return /obj/item/restraints/handcuffs/cable/zipties/fake/used - return cuffs?.trashtype +/// A moment after the reach: a step away from `user_ref`'s owner, then its fight or flight (on_confronted()). +/mob/living/carbon/human/npc/bounty_criminal/proc/body_answer_cuffs(datum/weakref/user_ref) + var/mob/living/user = user_ref?.resolve() + if(QDELETED(src) || QDELETED(user) || !body_can_answer_cuffs()) + return + body_step_away_from(user) + on_confronted(user) -/** - * Puts `cuffs` on it at once; zipties become their used pair, as on people. `user`, if any, gives - * them up from their hands, unless `dispense` (a borg), which puts on a new pair of the same kind - * instead. Returns TRUE if it is restrained. - */ -/mob/living/basic/bounty_criminal/proc/body_apply_cuffs(obj/item/restraints/handcuffs/cuffs, mob/living/user, dispense = FALSE) - if(is_restrained() || QDELETED(cuffs) || stat == DEAD) +/// One real step directly or diagonally away from `threat`, onto ground its leash allows. Returns TRUE if it moved. +/mob/living/carbon/human/npc/bounty_criminal/proc/body_step_away_from(atom/threat) + var/turf/here = get_turf(src) + if(!here || !threat) return FALSE - var/obj/item/restraints/handcuffs/worn = cuffs - var/used_path = bounty_worn_cuffs_type(cuffs) - if(dispense) - var/dispensed_path = used_path || cuffs.type - worn = new dispensed_path(src) - else - if(user && !user.temporarilyRemoveItemFromInventory(cuffs)) - return FALSE - if(used_path) - worn = new used_path(src) - qdel(cuffs) - else - cuffs.forceMove(src) - if(QDELETED(worn) || worn.loc != src) - return FALSE - restraints = worn - ADD_TRAIT(src, TRAIT_IMMOBILIZED, BOUNTY_BODY_CUFFS_TRAIT) - if(pulling) - stop_pulling() - ai_controller?.CancelActions() - body_update_held() + var/away = get_dir(threat, src) || pick(GLOB.alldirs) + for(var/direction in list(away, turn(away, 45), turn(away, -45), turn(away, 90), turn(away, -90))) + var/turf/step_turf = get_step(here, direction) + if(!step_turf || step_turf.is_blocked_turf(exclude_mobs = FALSE) || !body_move_allowed(step_turf)) + continue + if(Move(step_turf, direction)) + return TRUE + return FALSE + +// ===== CUFFS ON AND OFF ===== + +/mob/living/carbon/human/npc/bounty_criminal/proc/body_on_working_cuffs(datum/source, obj/item/cuffs) + SIGNAL_HANDLER + body_working_cuffs_at = world.time + +/// Cuffed: the AI packages hear who did it (whoever last reached for its wrists, if it was lately) +/mob/living/carbon/human/npc/bounty_criminal/proc/body_on_restrained(datum/source) + SIGNAL_HANDLER + if(stat == DEAD || QDELING(src)) + return + var/mob/living/user = body_cuffer_ref?.resolve() + if(world.time > body_cuffed_at + 30 SECONDS) + user = null if(user) body_add_grudge(user) - body_start_slip() - update_appearance(UPDATE_OVERLAYS) body_state_changed() SEND_SIGNAL(src, COMSIG_BOUNTY_CRIMINAL_RESTRAINED, user) - // Forced: the cuffs go on 2 s after a downing or a stun, well inside the cooldown of what they said then (BUG-1). - if(stat == CONSCIOUS) - INVOKE_ASYNC(src, TYPE_PROC_REF(/mob/living, bounty_say), "cuffed", null, TRUE) - return TRUE -// ===== UNCUFFING ===== - -// An empty, open hand on a restrained criminal starts taking the restraints off. -/mob/living/basic/bounty_criminal/attack_hand(mob/living/carbon/human/user, list/modifiers) - if(is_restrained() && stat != DEAD && !user.combat_mode && !LAZYACCESS(modifiers, RIGHT_CLICK)) - INVOKE_ASYNC(src, PROC_REF(body_uncuff_by), user) - return TRUE - return ..() - -/// `user` takes its restraints off over BOUNTY_UNCUFF_TIME. Returns TRUE if they came off. Sleeps. -/mob/living/basic/bounty_criminal/proc/body_uncuff_by(mob/living/user) - if(!is_restrained() || body_cuff_work) - return FALSE - body_cuff_work = TRUE - user.visible_message(span_notice("[user] starts taking [restraints] off [src]."), span_notice("You start taking [restraints] off [src].")) - var/done = do_after(user, BOUNTY_UNCUFF_TIME, target = src) - body_cuff_work = FALSE - if(!done || QDELETED(src) || !is_restrained()) - return FALSE - var/cut = istype(restraints, /obj/item/restraints/handcuffs/cable) - user.visible_message(span_notice("[user] [cut ? "cuts" : "takes"] [restraints] off [src]."), span_notice("You [cut ? "cut" : "take"] [restraints] off [src].")) - body_remove_cuffs(user) - return TRUE - -/** - * Takes its restraints off. With `user`, handcuffs go to their hands (or the floor) and cable and - * zipties are cut away; without, the restraints drop where it is. Returns the restraints still about, - * or null. - */ -/mob/living/basic/bounty_criminal/proc/body_remove_cuffs(mob/living/user) - var/obj/item/restraints/handcuffs/worn = restraints - if(!worn) - return null - // Cleared first, so Exited() leaves the rest to this proc. - restraints = null - var/atom/drop_spot = drop_location() - if(QDELETED(worn)) - worn = null - else if((user && istype(worn, /obj/item/restraints/handcuffs/cable)) || !drop_spot) - qdel(worn) - worn = null - else - worn.forceMove(drop_spot) - if(user) - user.put_in_hands(worn) - body_uncuffed(user) - return worn - -/// Its restraints are off, however they came off: it can move and act again, and a downed one whose recovery came due starts getting up -/mob/living/basic/bounty_criminal/proc/body_uncuffed(mob/living/user) - REMOVE_TRAIT(src, TRAIT_IMMOBILIZED, BOUNTY_BODY_CUFFS_TRAIT) - body_stop_slip() - if(QDELETED(src)) +/// Out of its cuffs: the AI packages hear whether it got itself out (null) or someone took them off (src: who isn't known) +/mob/living/carbon/human/npc/bounty_criminal/proc/body_on_unrestrained(datum/source) + SIGNAL_HANDLER + if(stat == DEAD || QDELING(src)) return - body_update_held() - update_appearance(UPDATE_OVERLAYS) + var/self_freed = body_working_cuffs_at && world.time <= body_working_cuffs_at + BOUNTY_SELF_FREED_WINDOW + body_working_cuffs_at = 0 body_state_changed() - SEND_SIGNAL(src, COMSIG_BOUNTY_CRIMINAL_UNRESTRAINED, user) - if(downed && body_recovery_due && stat != DEAD) - body_recovery_due = FALSE - deltimer(body_recovery_timer) - body_stir() - -/mob/living/basic/bounty_criminal/Exited(atom/movable/gone, direction) - . = ..() - if(gone == restraints) - // Taken or destroyed some other way than body_remove_cuffs() - restraints = null - body_uncuffed(null) - -// ===== SLIPPING ===== - -/// How long its restraints hold before it slips them: cable, zipties or joke cuffs; a mini-boss in half the time; 0 for handcuffs, which never slip -/mob/living/basic/bounty_criminal/proc/body_slip_time() - if(!is_restrained()) - return 0 - var/time - if(istype(restraints, /obj/item/restraints/handcuffs/fake) || istype(restraints, /obj/item/restraints/handcuffs/cable/zipties/fake)) - time = BOUNTY_FAKE_CUFF_SLIP - else if(istype(restraints, /obj/item/restraints/handcuffs/cable/zipties)) - time = BOUNTY_ZIPTIE_SLIP - else if(istype(restraints, /obj/item/restraints/handcuffs/cable)) - time = BOUNTY_CABLE_SLIP - else - return 0 - if(istype(src, /mob/living/basic/bounty_criminal/boss)) - time *= BOUNTY_BOSS_SLIP_MULT - return time - -/// Starts the clock on its restraints slipping, if they ever do -/mob/living/basic/bounty_criminal/proc/body_start_slip() - body_stop_slip() - var/time = body_slip_time() - if(time <= 0) - return - body_slip_warn_timer = addtimer(CALLBACK(src, PROC_REF(body_slip_warning)), max(0, time - BOUNTY_SLIP_WARNING), TIMER_STOPPABLE | TIMER_DELETE_ME) - body_slip_timer = addtimer(CALLBACK(src, PROC_REF(body_slip_cuffs)), time, TIMER_STOPPABLE | TIMER_DELETE_ME) - -/// Stops the slipping clock -/mob/living/basic/bounty_criminal/proc/body_stop_slip() - deltimer(body_slip_warn_timer) - deltimer(body_slip_timer) - body_slip_warn_timer = null - body_slip_timer = null - -/// The visible struggle before it slips its restraints -/mob/living/basic/bounty_criminal/proc/body_slip_warning() - body_slip_warn_timer = null - if(!is_restrained() || stat == DEAD) - return - if(istype(src, /mob/living/basic/bounty_criminal/boss)) - visible_message(span_warning("[src] strains against [restraints].")) - else - visible_message(span_warning("[src] is working at [restraints].")) - INVOKE_ASYNC(src, TYPE_PROC_REF(/mob/living, bounty_say), "slipping_cuffs") - -/// Out of its restraints: a mini-boss snaps them, anyone else slips them and they drop. Returns TRUE if they came off. -/mob/living/basic/bounty_criminal/proc/body_slip_cuffs() - body_slip_timer = null - if(!is_restrained() || stat == DEAD) - return FALSE - var/snapped = istype(src, /mob/living/basic/bounty_criminal/boss) - var/message = snapped ? "[src] snaps [restraints]!" : "[src] slips out of [restraints]!" - visible_message(span_danger(message)) - var/obj/item/restraints/handcuffs/worn = body_remove_cuffs() - if(snapped && worn) - qdel(worn) - return TRUE + SEND_SIGNAL(src, COMSIG_BOUNTY_CRIMINAL_UNRESTRAINED, self_freed ? null : src) diff --git a/voidcrew/modules/bounties/bounty_styles.dm b/voidcrew/modules/bounties/bounty_styles.dm new file mode 100644 index 00000000000..d590d9812d0 --- /dev/null +++ b/voidcrew/modules/bounties/bounty_styles.dm @@ -0,0 +1,656 @@ +/** + * # Bounty hunting: fighting styles, with real weapons + * + * Owner: P3 AI. Do not edit this file outside P3. + * + * How a criminal or a companion fights (combat.md 6.2, defaults CR-13). Every style is a real item the + * fighter carries, puts in its hand when the fight starts, and uses the way a player does, through + * controller.ai_interact() (a click): + * - brawler: fists, and now and then a real shove (a right click); + * - knife: a knife from a pocket (Wanted and above: a combat knife). Its cuts and bleeding are the + * knife's own; + * - club: a baseball bat in hand (Wanted and above: the metal bat). It knocks people back as tg's bat does; + * - pistol: a Stechkin from a shoulder holster, a spare magazine in a pocket, reloaded the player's way; + * - shotgun: a pump shotgun on the back with buckshot (Wanted and above: a semi-automatic combat + * shotgun), shells on a bandolier, loaded into the tube shell by shell; + * - bottle: beer bottles from a satchel, thrown one at a time with a real throw (tg's bottle smashes on + * whoever it hits); out of bottles, they fight with their fists; + * - holdout: a meek criminal's little Makarov, a pocket gun, and a spare magazine in a fanny pack (the + * cornered volley in bounty_ai_meek.dm). + * Nothing is spawned for the fight, no projectile comes from the body, and nothing passes through + * anyone: before a shot or a throw the fighter checks its line and steps aside for anyone it may not + * hit (bounty_ai_line_blocked()). The style sets only the timing: how often they pull the trigger or + * throw, the telegraph before it (a hit during it fumbles the attack), the reload, and the distance they + * keep. Gear is locked to the body (D3): it never drops and is never loot; bottles are consumables, so a + * thrown one leaves the hand and breaks. + */ + +/// Every fighting style by key (BOUNTY_STYLE_*), one datum each +GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) + +/proc/init_bounty_styles() + var/list/styles = list() + for(var/datum/bounty_style/style_type as anything in subtypesof(/datum/bounty_style)) + var/datum/bounty_style/style = new style_type + if(style.key) + styles[style.key] = style + return styles + +/// A fighter's style: from its controller's blackboard +/proc/bounty_ai_style(mob/living/fighter) + var/datum/ai_controller/controller = fighter?.ai_controller + if(QDELETED(controller)) + return null + return GLOB.bounty_styles[controller.blackboard[BB_BOUNTY_STYLE]] + +/// Puts style `key` on `fighter`'s AI. Its weapon is whatever it was dressed with (bounty_build_outfit()). +/proc/bounty_ai_apply_style(mob/living/fighter, key) + var/datum/bounty_style/style = GLOB.bounty_styles[key] + var/datum/ai_controller/controller = fighter?.ai_controller + if(!style || QDELETED(controller)) + return FALSE + controller.set_blackboard_key(BB_BOUNTY_STYLE, key) + bounty_ai_clear_windup(controller) + return TRUE + +/// Whether a pawn is in a fight it can take part in: a criminal fighting, or a companion that has not broken +/proc/bounty_ai_fighting(mob/living/fighter) + if(istype(fighter, /mob/living/carbon/human/npc/bounty_criminal)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = fighter + return criminal.ai_mode == BOUNTY_AI_FIGHTING && criminal.ai_can_act() + if(istype(fighter, /mob/living/carbon/human/npc/bounty_companion)) + var/mob/living/carbon/human/npc/bounty_companion/companion = fighter + return companion.ai_can_fight() + return FALSE + +/// Puts the weapons in `body`'s hands away on its body (the human NPC base's npc_stow_weapons()): a holster, a pocket, a back. What has nowhere to go stays in hand. +/proc/bounty_ai_holster(mob/living/carbon/human/npc/body) + if(!ishumannpc(body) || HAS_TRAIT(body, TRAIT_HANDS_BLOCKED)) + return + body.npc_stow_weapons() + +/// The first `item_type` that `body` carries and can take in hand in a moment (held, worn, in a bag or pouch it wears), or null +/proc/bounty_ai_carried(mob/living/carbon/body, item_type) + if(!ispath(item_type)) + return null + for(var/obj/item/thing as anything in body.get_all_contents_type(item_type)) + if(body.is_holding(thing) || human_npc_can_draw(body, thing)) + return thing + return null + +/// Whether `gun` fires on the next pull, or would after the pump its style's telegraph works (`pumps`) +/proc/bounty_ai_gun_ready(obj/item/gun/gun, pumps = FALSE) + if(!istype(gun)) + return FALSE + if(gun.can_shoot()) + return TRUE + var/obj/item/gun/ballistic/ballistic = gun + return pumps && istype(ballistic) && human_npc_gun_needs_rack(ballistic) + +/// Empties the hand that isn't holding `keep`, for a gun that needs both: puts what's there away, and lets go of a spent shell or a spent magazine +/proc/bounty_ai_free_other_hand(mob/living/carbon/body, obj/item/keep) + for(var/obj/item/held in body.held_items) + if(held == keep) + continue + if((isammocasing(held) || istype(held, /obj/item/ammo_box)) && !human_npc_live_rounds(held)) + body.dropItemToGround(held) + continue + if(!held.equip_to_best_slot(body)) + body.dropItemToGround(held) + return length(body.get_empty_held_indexes()) > 0 + +/** + * Whether someone `shooter` may not hit stands in its line of fire to `target`: one of its own gang, its + * own side of the site (the crew it is aboard with), or a bystander it has no quarrel with. Shots and + * throws pass over anyone lying down. This is the whole of friendly fire: nothing it fires passes + * through anyone. + */ +/proc/bounty_ai_line_blocked(mob/living/shooter, atom/target) + var/turf/start = get_turf(shooter) + var/turf/end = get_turf(target) + if(!start || !end) + return FALSE + for(var/turf/line_turf as anything in get_line(start, end)) + if(line_turf == start || line_turf == end) + continue + for(var/mob/living/other in line_turf) + if(other == shooter || other.stat == DEAD || other.body_position == LYING_DOWN) + continue + if(shooter.faction_check_atom(other) || !bounty_ai_may_hit(shooter, other)) + return TRUE + return FALSE + +/// One step sideways for a clear line to `target`, no further from them, on the leash +/proc/bounty_ai_sidestep(mob/living/fighter, atom/target) + var/turf/here = get_turf(fighter) + if(!here || !isturf(fighter.loc)) + return FALSE + var/list/options = list() + for(var/direction in GLOB.alldirs) + var/turf/next = get_step(here, direction) + if(!next || get_dist(next, target) > get_dist(here, target) || !next.can_cross_safely(fighter)) + continue + options += next + shuffle_inplace(options) + for(var/turf/next as anything in options) + if(bounty_ai_step(fighter, next)) + return TRUE + return FALSE + +/// A step straight back from `target`, now and then, on the leash +/proc/bounty_ai_back_off(datum/ai_controller/controller, mob/living/fighter, atom/target) + if(world.time < controller.blackboard[BB_BOUNTY_BACKSTEP_AT] || !isturf(fighter.loc)) + return FALSE + controller.set_blackboard_key(BB_BOUNTY_BACKSTEP_AT, world.time + BOUNTY_BACKSTEP_GAP) + var/away_dir = get_dir(target, fighter) + var/turf/away = away_dir && get_step(fighter, away_dir) + if(!away || !bounty_ai_step(fighter, away)) + return FALSE + fighter.face_atom(target) + return TRUE + +/// Forgets a wind-up in progress +/proc/bounty_ai_clear_windup(datum/ai_controller/controller) + controller.clear_blackboard_key(BB_BOUNTY_WINDUP_UNTIL) + controller.clear_blackboard_key(BB_BOUNTY_WINDUP_FROM) + controller.clear_blackboard_key(BB_BOUNTY_WINDUP_STAMINA) + +// ===== THE STYLES ===== + +/** + * How someone fights. Criminals, companions and the meek's holdout share these. The style puts a real + * weapon (and its spares) on the outfit they are dressed in, and sets how they use it; what the weapon + * does is the weapon's. + */ +/datum/bounty_style + /// BOUNTY_STYLE_* + var/key + /// Fights at range: a gun, or something thrown + var/ranged = FALSE + /// What they carry, by tier: Petty, and Wanted or above (null for bare fists) + var/weapon + var/heavy_weapon + /// What counts as their style's weapon when they look for it on themselves + var/weapon_type + /// The behaviour that keeps this style's distance while it shoots or throws + var/ranged_behavior = /datum/ai_behavior/bounty_shoot + /// Anyone closer than this and they step back (0: never) + var/min_range = 0 + /// Between trigger pulls or throws + var/interval = 1 SECONDS + /// The telegraph before a shot or a throw, and what it says and sounds like + var/windup = 0 + var/windup_message + var/windup_sound + /// The telegraph works a pump: a spent shell in the chamber doesn't need a reload + var/pumps = FALSE + /// Chance a blow is a shove instead + var/shove_chance = 0 + +/** + * Puts this style's weapon and spares on `outfit` (an instance), the heavier weapon if `heavy`. The + * weapon is carried (a holster, a pocket, the back, a bag) unless it has nowhere to go on a body. + */ +/datum/bounty_style/proc/equip(datum/outfit/outfit, heavy = FALSE) + return + +/// The weapon this style carries at `heavy` +/datum/bounty_style/proc/weapon_for(heavy) + return (heavy && heavy_weapon) || weapon + +/// The ranged weapon in `fighter`'s hand that is ready to use, or null: a loaded (or pumpable) gun, a bottle +/datum/bounty_style/proc/ready_in_hand(mob/living/carbon/fighter) + if(!ranged) + return null + for(var/obj/item/gun/gun in fighter.held_items) + if(bounty_ai_gun_ready(gun, pumps)) + return gun + return null + +/// A ranged weapon of this style `fighter` carries that is worth drawing (one that fires, or that it can load), or null +/datum/bounty_style/proc/carried_ranged(mob/living/carbon/fighter) + if(!ranged || !weapon_type) + return null + for(var/obj/item/gun/gun in fighter.get_all_contents_type(weapon_type)) + if(fighter.is_holding(gun) || !human_npc_can_draw(fighter, gun)) + continue + if(bounty_ai_gun_ready(gun, pumps) || human_npc_can_reload(fighter, gun)) + return gun + return null + +/// Whether this shot needs the telegraph first +/datum/bounty_style/proc/needs_windup(datum/ai_controller/controller) + return windup > 0 + +/// The telegraph: what they say, show and sound like before the shot +/datum/bounty_style/proc/telegraph(mob/living/carbon/fighter, atom/target, obj/item/weapon) + fighter.face_atom(target) + if(windup_message) + fighter.visible_message(span_warning(replacetext(windup_message, "%USER", "[fighter]"))) + if(windup_sound) + playsound(fighter, windup_sound, 50, TRUE) + +/** + * One step of a telegraphed attack. Returns TRUE when the attack goes now. Otherwise it is winding + * up (the telegraph is shown at the start), or the wind-up just ended in a fumble: any hit taken during + * it (damage, or more stamina loss) spoils the attack, and they try again a moment later. + */ +/datum/bounty_style/proc/windup_step(mob/living/carbon/fighter, datum/ai_controller/controller, atom/target, obj/item/weapon) + var/now = world.time + var/until = controller.blackboard[BB_BOUNTY_WINDUP_UNTIL] + if(until && now > until + BOUNTY_WINDUP_STALE) + // Left over from an interrupted fight: it has to be done again + bounty_ai_clear_windup(controller) + until = null + if(!until) + if(!needs_windup(controller)) + return TRUE + controller.set_blackboard_key(BB_BOUNTY_WINDUP_UNTIL, now + windup) + controller.set_blackboard_key(BB_BOUNTY_WINDUP_FROM, now) + controller.set_blackboard_key(BB_BOUNTY_WINDUP_STAMINA, fighter.getStaminaLoss()) + telegraph(fighter, target, weapon) + return FALSE + if(now < until) + fighter.face_atom(target) + return FALSE + var/hit_at = controller.blackboard[BB_BOUNTY_HIT_AT] + var/fumbled = (hit_at && hit_at >= controller.blackboard[BB_BOUNTY_WINDUP_FROM]) || fighter.getStaminaLoss() > controller.blackboard[BB_BOUNTY_WINDUP_STAMINA] + 1 + bounty_ai_clear_windup(controller) + if(fumbled) + fighter.visible_message(span_notice("[fighter] fumbles [weapon]!")) + controller.set_blackboard_key(BB_BOUNTY_NEXT_SHOT, now + BOUNTY_FUMBLE_PAUSE) + return FALSE + return TRUE + +/** + * The attack itself, with `weapon` in hand: a trigger pull at `target`, the player's way. Returns TRUE + * if it went. + */ +/datum/bounty_style/proc/attack(mob/living/carbon/fighter, datum/ai_controller/controller, atom/target, obj/item/weapon) + var/obj/item/gun/gun = weapon + if(!istype(gun)) + return FALSE + if(gun.weapon_weight == WEAPON_HEAVY) + bounty_ai_free_other_hand(fighter, gun) + if(!human_npc_ready_item(fighter, gun)) + return FALSE + fighter.zone_selected = human_npc_pick_aim_zone() + return controller.ai_interact(target = target, combat_mode = TRUE) + +/// Bare fists: a person's punch, and now and then a shove +/datum/bounty_style/brawler + key = BOUNTY_STYLE_BRAWLER + shove_chance = BOUNTY_BRAWLER_SHOVE_CHANCE + +/// A knife in a pocket. Its cuts bleed, as a real one's do. +/datum/bounty_style/knife + key = BOUNTY_STYLE_KNIFE + weapon = /obj/item/knife + heavy_weapon = /obj/item/knife/combat + weapon_type = /obj/item/knife + +/datum/bounty_style/knife/equip(datum/outfit/outfit, heavy = FALSE) + bounty_outfit_carry(outfit, weapon_for(heavy)) + +/// A baseball bat. A bat has no slot to go in on a body, so it is in hand from the start. +/datum/bounty_style/club + key = BOUNTY_STYLE_CLUB + weapon = /obj/item/melee/baseball_bat + heavy_weapon = /obj/item/melee/baseball_bat/ablative + weapon_type = /obj/item/melee/baseball_bat + +/datum/bounty_style/club/equip(datum/outfit/outfit, heavy = FALSE) + outfit.r_hand = weapon_for(heavy) + +/// A Stechkin in a shoulder holster, a spare magazine in a pocket +/datum/bounty_style/pistol + key = BOUNTY_STYLE_PISTOL + ranged = TRUE + weapon = /obj/item/gun/ballistic/automatic/pistol/aps + weapon_type = /obj/item/gun/ballistic/automatic/pistol/aps + interval = BOUNTY_PISTOL_INTERVAL + min_range = BOUNTY_PISTOL_MIN_RANGE + windup = BOUNTY_PISTOL_WINDUP + windup_message = "%USER raises a pistol." + windup_sound = 'sound/items/weapons/gun/pistol/rack_small.ogg' + +/datum/bounty_style/pistol/equip(datum/outfit/outfit, heavy = FALSE) + var/obj/item/gun/ballistic/gun_type = weapon_for(heavy) + outfit.belt = /obj/item/storage/belt/holster + outfit.belt_contents = null + LAZYADDASSOC(outfit.belt_contents, gun_type, 1) + bounty_outfit_carry(outfit, initial(gun_type.accepted_magazine_type)) + +/// Only the first shot of a string needs the gun raised +/datum/bounty_style/pistol/needs_windup(datum/ai_controller/controller) + var/last_shot = controller.blackboard[BB_BOUNTY_LAST_SHOT] + return !last_shot || world.time - last_shot > BOUNTY_PISTOL_STRING_GAP + +/// Buckshot: a pump shotgun on the back, shells on a bandolier. The pump is the telegraph before each blast. +/datum/bounty_style/shotgun + key = BOUNTY_STYLE_SHOTGUN + ranged = TRUE + weapon = /obj/item/gun/ballistic/shotgun/lethal + heavy_weapon = /obj/item/gun/ballistic/shotgun/automatic/combat/bounty + weapon_type = /obj/item/gun/ballistic/shotgun + ranged_behavior = /datum/ai_behavior/bounty_shoot/close + interval = BOUNTY_SHOTGUN_INTERVAL + windup = BOUNTY_SHOTGUN_WINDUP + windup_message = "%USER pumps the shotgun." + windup_sound = 'sound/items/weapons/gun/shotgun/rack.ogg' + pumps = TRUE + +/datum/bounty_style/shotgun/equip(datum/outfit/outfit, heavy = FALSE) + outfit.back = weapon_for(heavy) + outfit.belt = /obj/item/storage/belt/bandolier + outfit.belt_contents = null + LAZYADDASSOC(outfit.belt_contents, /obj/item/ammo_casing/shotgun/buckshot, BOUNTY_SHOTGUN_SHELLS) + +/// The pump is real: a spent shell in the chamber is worked out by hand, which makes the rack's own sound +/datum/bounty_style/shotgun/telegraph(mob/living/carbon/fighter, atom/target, obj/item/weapon) + fighter.face_atom(target) + if(windup_message) + fighter.visible_message(span_warning(replacetext(windup_message, "%USER", "[fighter]"))) + var/obj/item/gun/ballistic/gun = weapon + if(istype(gun) && human_npc_gun_needs_rack(gun) && human_npc_ready_item(fighter, gun)) + gun.attack_self(fighter) + else if(windup_sound) + playsound(fighter, windup_sound, 50, TRUE) + +/// Beer bottles from a satchel, thrown one at a time +/datum/bounty_style/bottle + key = BOUNTY_STYLE_BOTTLE + ranged = TRUE + weapon = /obj/item/reagent_containers/cup/glass/bottle/beer + weapon_type = /obj/item/reagent_containers/cup/glass/bottle + ranged_behavior = /datum/ai_behavior/bounty_shoot/throw + interval = BOUNTY_BOTTLE_INTERVAL + min_range = BOUNTY_BOTTLE_MIN_RANGE + windup = BOUNTY_BOTTLE_WINDUP + windup_message = "%USER winds up to throw a bottle." + +/datum/bounty_style/bottle/equip(datum/outfit/outfit, heavy = FALSE) + if(!outfit.back) + outfit.back = /obj/item/storage/backpack/satchel + LAZYADDASSOC(outfit.backpack_contents, weapon, heavy ? BOUNTY_BOTTLES_WANTED : BOUNTY_BOTTLES_PETTY) + +/datum/bounty_style/bottle/ready_in_hand(mob/living/carbon/fighter) + for(var/obj/item/reagent_containers/cup/glass/bottle/bottle in fighter.held_items) + if(bottle.isGlass) + return bottle + return null + +/datum/bounty_style/bottle/carried_ranged(mob/living/carbon/fighter) + for(var/obj/item/reagent_containers/cup/glass/bottle/bottle in fighter.get_all_contents_type(weapon_type)) + if(bottle.isGlass && !fighter.is_holding(bottle) && human_npc_can_draw(fighter, bottle)) + return bottle + return null + +/// A real throw: the bottle leaves the hand and flies, as a player's does. tg's bottle breaks on whoever it hits. +/datum/bounty_style/bottle/attack(mob/living/carbon/fighter, datum/ai_controller/controller, atom/target, obj/item/weapon) + if(!human_npc_ready_item(fighter, weapon)) + return FALSE + fighter.zone_selected = human_npc_pick_aim_zone() + fighter.throw_mode_on(THROW_MODE_TOGGLE) + controller.ai_interact(target = target, combat_mode = TRUE) + // A click that didn't go through leaves throw mode on: the next click must not be a throw + if(fighter.throw_mode) + fighter.throw_mode_off(THROW_MODE_TOGGLE) + return FALSE + return !fighter.is_holding(weapon) + +/** + * The meek's little gun: a Makarov in a pocket and a spare magazine in a fanny pack. The volley is fired + * one trigger pull at a time by the meek AI (bounty_ai_meek.dm). + */ +/datum/bounty_style/holdout + key = BOUNTY_STYLE_HOLDOUT + ranged = TRUE + weapon = /obj/item/gun/ballistic/automatic/pistol + weapon_type = /obj/item/gun/ballistic/automatic/pistol + interval = BOUNTY_MEEK_PISTOL_GAP + +/datum/bounty_style/holdout/equip(datum/outfit/outfit, heavy = FALSE) + var/obj/item/gun/ballistic/gun_type = weapon + bounty_outfit_carry(outfit, gun_type) + outfit.belt = /obj/item/storage/belt/fannypack + outfit.belt_contents = null + LAZYADDASSOC(outfit.belt_contents, initial(gun_type.accepted_magazine_type), 1) + +/** + * Puts `item_type` somewhere `outfit` carries it: a free pocket, else the belt's pouch, else the bag. + * Returns TRUE if it found a place. + */ +/proc/bounty_outfit_carry(datum/outfit/outfit, item_type) + if(!istype(outfit) || !ispath(item_type)) + return FALSE + if(!outfit.r_pocket) + outfit.r_pocket = item_type + return TRUE + if(!outfit.l_pocket) + outfit.l_pocket = item_type + return TRUE + if(outfit.belt && ispath(outfit.belt, /obj/item/storage)) + LAZYADDASSOC(outfit.belt_contents, item_type, 1) + return TRUE + if(outfit.back && ispath(outfit.back, /obj/item/storage)) + LAZYADDASSOC(outfit.backpack_contents, item_type, 1) + return TRUE + return FALSE + +/** + * The outfit a bounty fighter wears: plain clothes for `archetype` in `zone`, its tier's armour, its + * style's weapon and spares, and `treatment` (a bruise pack, a stimpack) in a pocket. + */ +/proc/bounty_fighter_outfit(archetype, zone, tier, style_key, heavy = FALSE, treatment) + var/datum/outfit/outfit = bounty_outfit_instance(bounty_plain_clothes(archetype, zone)) + if(!outfit) + return null + bounty_add_tier_armour(outfit, tier) + var/datum/bounty_style/style = GLOB.bounty_styles[style_key] + style?.equip(outfit, heavy) + if(treatment) + bounty_outfit_carry(outfit, treatment) + return outfit + +/// A Wanted criminal's combat shotgun, loaded with buckshot (tg's comes with rubber shot) +/obj/item/gun/ballistic/shotgun/automatic/combat/bounty + accepted_magazine_type = /obj/item/ammo_box/magazine/internal/shot/com/bounty + +/obj/item/ammo_box/magazine/internal/shot/com/bounty + ammo_type = /obj/item/ammo_casing/shotgun/buckshot + +// ===== ARMING ===== + +/** + * In a fight with a target: keeps their style's weapon in hand. Draws it when the fight starts (a + * holster, a pocket, the back, a bag), reloads a gun the player's way when it runs dry (the human NPC + * base's reload; a shotgun shell by shell), or draws something else, or nothing and uses fists. + */ +/datum/ai_planning_subtree/bounty_arm + +/datum/ai_planning_subtree/bounty_arm/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/human/npc/fighter = controller.pawn + if(!ishumannpc(fighter) || !bounty_ai_fighting(fighter) || !controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + return + if(HAS_TRAIT(fighter, TRAIT_HANDS_BLOCKED) || LAZYLEN(fighter.do_afters) || world.time < controller.blackboard[BB_HUMAN_NPC_ARMING_RETRY_AT]) + return + var/datum/bounty_style/style = bounty_ai_style(fighter) + if(!style) + return + var/obj/item/to_draw + if(style.ranged) + if(style.ready_in_hand(fighter)) + return + var/obj/item/gun/ballistic/gun = human_npc_held_gun(fighter) + if(istype(gun) && human_npc_can_reload(fighter, gun)) + controller.queue_behavior(gun.internal_magazine ? /datum/ai_behavior/human_npc_reload/bounty_tube : /datum/ai_behavior/human_npc_reload) + return SUBTREE_RETURN_FINISH_PLANNING + to_draw = style.carried_ranged(fighter) + else if(style.weapon_type) + if(human_npc_held_melee_weapon(fighter)) + return + to_draw = bounty_ai_carried(fighter, style.weapon_type) + if(fighter.is_holding(to_draw)) + return + else + return + if(!to_draw && !human_npc_held_melee_weapon(fighter)) + to_draw = human_npc_backup_weapon(fighter) + if(!to_draw) + return + controller.set_blackboard_key(BB_HUMAN_NPC_DRAW_ITEM, to_draw) + controller.queue_behavior(/datum/ai_behavior/human_npc_draw, BB_HUMAN_NPC_DRAW_ITEM) + return SUBTREE_RETURN_FINISH_PLANNING + +/** + * The human NPC base's reload, for a gun loaded through its tube (a shotgun): every shell it can fit, + * one at a time, then the pump. + */ +/datum/ai_behavior/human_npc_reload/bounty_tube + give_up_after = 15 SECONDS + +/datum/ai_behavior/human_npc_reload/bounty_tube/perform(seconds_per_tick, datum/ai_controller/controller) + var/mob/living/carbon/npc = controller.pawn + var/obj/item/gun/ballistic/gun = human_npc_held_gun(npc) + if(!istype(gun) || !gun.internal_magazine || world.time >= controller.blackboard[BB_HUMAN_NPC_RELOAD_UNTIL]) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + var/obj/item/spent = human_npc_spent_ammo_in_hand(npc, gun) + if(spent) + npc.dropItemToGround(spent, force = TRUE) + return AI_BEHAVIOR_DELAY + var/obj/item/ammo_box/magazine/tube = gun.magazine + if(tube && tube.ammo_count(FALSE) < tube.max_ammo) + var/obj/item/ammo = human_npc_find_ammo(npc, gun) + if(ammo) + if(!npc.is_holding(ammo)) + if(!human_npc_take_in_hand(npc, ammo)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + return AI_BEHAVIOR_DELAY + if(!human_npc_ready_item(npc, ammo)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + controller.ai_interact(target = gun, combat_mode = FALSE) + return AI_BEHAVIOR_DELAY + if(human_npc_gun_needs_rack(gun)) + if(!human_npc_ready_item(npc, gun)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + controller.ai_interact(target = gun, combat_mode = FALSE) + return AI_BEHAVIOR_DELAY + if(gun.can_shoot()) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + +// ===== SHOOTING AND THROWING ===== + +/// In a fight with a ranged style and its weapon ready in hand: shoots or throws, at the style's distance +/datum/ai_planning_subtree/bounty_ranged + +/datum/ai_planning_subtree/bounty_ranged/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/fighter = controller.pawn + if(!bounty_ai_fighting(fighter) || !controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + return + var/datum/bounty_style/style = bounty_ai_style(fighter) + if(!style?.ranged || HAS_TRAIT(fighter, TRAIT_HANDS_BLOCKED) || !style.ready_in_hand(fighter)) + return + controller.queue_behavior(style.ranged_behavior, BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETING_STRATEGY) + return SUBTREE_RETURN_FINISH_PLANNING + +/** + * Shoots (or throws) at the target from the style's distance: closes in while it can't see them, steps + * back from anyone inside the style's min_range, steps aside for anyone it may not hit in its line, + * telegraphs, then pulls the trigger (or throws) once per the style's interval. Planning carries on + * meanwhile, so a new target, a retreat or a call for help is picked up mid-fight. + */ +/datum/ai_behavior/bounty_shoot + // Often enough that a style fires at its own pace and its wind-up is never stretched + action_cooldown = 0.1 SECONDS + behavior_flags = AI_BEHAVIOR_REQUIRE_MOVEMENT | AI_BEHAVIOR_MOVE_AND_PERFORM | AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + required_distance = BOUNTY_PISTOL_RANGE + +/datum/ai_behavior/bounty_shoot/setup(datum/ai_controller/controller, target_key, targeting_strategy_key) + . = ..() + var/atom/target = controller.blackboard[target_key] + if(QDELETED(target)) + return FALSE + set_movement_target(controller, target) + +/datum/ai_behavior/bounty_shoot/perform(seconds_per_tick, datum/ai_controller/controller, target_key, targeting_strategy_key) + var/mob/living/carbon/fighter = controller.pawn + var/atom/target = controller.blackboard[target_key] + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(controller.blackboard[targeting_strategy_key]) + if(QDELETED(target) || !strategy?.can_attack(fighter, target, BOUNTY_FIGHT_VISION)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + var/datum/ai_controller/basic_controller/bounty/brain = controller + if(istype(brain) && !brain.may_shoot(target)) + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + var/datum/bounty_style/style = bounty_ai_style(fighter) + var/obj/item/weapon = style?.ready_in_hand(fighter) + if(!weapon || HAS_TRAIT(fighter, TRAIT_HANDS_BLOCKED)) + // Dry or empty-handed: the arm subtree reloads or draws, or they fight with their fists + return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + if(!can_see(fighter, target, required_distance)) + return AI_BEHAVIOR_INSTANT + var/winding = !!controller.blackboard[BB_BOUNTY_WINDUP_UNTIL] + if(style.min_range && get_dist(fighter, target) < style.min_range && !winding) + bounty_ai_back_off(controller, fighter, target) + if(bounty_ai_line_blocked(fighter, target)) + bounty_ai_sidestep(fighter, target) + return AI_BEHAVIOR_DELAY + if(!winding && world.time < controller.blackboard[BB_BOUNTY_NEXT_SHOT]) + return AI_BEHAVIOR_DELAY + if(!style.windup_step(fighter, controller, target, weapon)) + return AI_BEHAVIOR_DELAY + if(style.attack(fighter, controller, target, weapon)) + controller.set_blackboard_key(BB_BOUNTY_LAST_SHOT, world.time) + controller.set_blackboard_key(BB_BOUNTY_NEXT_SHOT, world.time + style.interval) + return AI_BEHAVIOR_DELAY + +/// A wind-up cut short never carries over: the next shot telegraphs again +/datum/ai_behavior/bounty_shoot/finish_action(datum/ai_controller/controller, succeeded, target_key, targeting_strategy_key) + . = ..() + bounty_ai_clear_windup(controller) + +/// The shotgun closes in to BOUNTY_SHOTGUN_RANGE +/datum/ai_behavior/bounty_shoot/close + required_distance = BOUNTY_SHOTGUN_RANGE + +/// The bottle thrower stays BOUNTY_BOTTLE_RANGE off +/datum/ai_behavior/bounty_shoot/throw + required_distance = BOUNTY_BOTTLE_RANGE + +// ===== MELEE ===== + +/** + * In a fight with a target and no ranged weapon ready: walks up and hits with the best melee weapon in + * hand, or a fist (the human NPC base's melee). A brawler now and then shoves instead. + */ +/datum/ai_planning_subtree/bounty_melee + +/datum/ai_planning_subtree/bounty_melee/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/carbon/fighter = controller.pawn + if(!bounty_ai_fighting(fighter) || !controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + return + var/datum/bounty_style/style = bounty_ai_style(fighter) + if(style?.ranged && style.ready_in_hand(fighter)) + return + controller.queue_behavior(/datum/ai_behavior/basic_melee_attack/human_npc/bounty, BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETING_STRATEGY, BB_BASIC_MOB_CURRENT_TARGET_HIDING_LOCATION) + return SUBTREE_RETURN_FINISH_PLANNING + +/// The human NPC base's melee (tg's, through a click), with the brawler's shove: a real right click with an empty hand +/datum/ai_behavior/basic_melee_attack/human_npc/bounty + +/datum/ai_behavior/basic_melee_attack/human_npc/bounty/perform(seconds_per_tick, datum/ai_controller/controller, target_key, targeting_strategy_key, hiding_location_key) + var/mob/living/carbon/fighter = controller.pawn + var/mob/living/target = controller.blackboard[target_key] + var/datum/bounty_style/style = bounty_ai_style(fighter) + if(!style?.shove_chance || !isliving(target) || !fighter.CanReach(target) || world.time < fighter.next_move) + return ..() + var/attack_at = controller.blackboard[BB_BASIC_MOB_MELEE_COOLDOWN_TIMER] + if(isnull(attack_at) || attack_at > world.time || !prob(style.shove_chance)) + return ..() + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(controller.blackboard[targeting_strategy_key]) + if(!strategy?.can_attack(fighter, target) || !human_npc_ready_empty_hand(fighter)) + return ..() + fighter.zone_selected = BODY_ZONE_CHEST + controller.ai_interact(target = target, combat_mode = TRUE, modifiers = list(RIGHT_CLICK = TRUE)) + return AI_BEHAVIOR_DELAY diff --git a/voidcrew/modules/bounties/bounty_turn_in.dm b/voidcrew/modules/bounties/bounty_turn_in.dm index 463539bf9a0..422892a428f 100644 --- a/voidcrew/modules/bounties/bounty_turn_in.dm +++ b/voidcrew/modules/bounties/bounty_turn_in.dm @@ -36,7 +36,7 @@ // ===== TURNING IN ===== /// Bind field work before the criminal or its proof can be carried to another band. -/datum/criminal_bounty/proc/board_note_work_zone(mob/living/basic/bounty_criminal/target) +/datum/criminal_bounty/proc/board_note_work_zone(mob/living/carbon/human/npc/bounty_criminal/target) if(!is_open() || !record || record.board_work_zone || target != criminal() || record.status != BOUNTY_RECORD_WANTED) return var/band = get_zone_type_for_player_turf(get_turf(target)) @@ -112,7 +112,7 @@ /datum/criminal_bounty/proc/board_target_on_pad(obj/machinery/mission_pad/pad) if(!pad || !isturf(pad.loc)) return null - var/mob/living/basic/bounty_criminal/criminal = criminal() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = criminal() if(criminal && criminal.loc == pad.loc) return criminal var/obj/item/bounty_proof/proof = board_proof() @@ -129,13 +129,13 @@ /datum/criminal_bounty/proc/board_target_refusal(obj/machinery/mission_pad/pad, list/found) var/atom/movable/target = board_target_on_pad(pad) if(!target) - var/mob/living/basic/bounty_criminal/criminal = criminal() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = criminal() if(criminal && get_turf(criminal) == get_turf(pad)) return "they're inside [criminal.loc]" return "nothing on the pad for this bounty" var/state = BOUNTY_STATE_DEAD - if(istype(target, /mob/living/basic/bounty_criminal)) - var/mob/living/basic/bounty_criminal/criminal = target + if(istype(target, /mob/living/carbon/human/npc/bounty_criminal)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = target if(criminal.client || criminal.mind) return "the pad won't take them" state = criminal.capture_state() @@ -147,9 +147,11 @@ /** * Pays `ship` for `target` (this bounty's criminal or its proof) in `state` at `pad`, and ends the - * bounty for everyone. No yield from start to end. The share is the worse of `state` and the worst - * state the criminal ever reached (12.1); a live catch gets its hurt, its captor and its preferred - * prison and goes to the prisoner pool. Returns list(credits, vouchers), or why not. + * bounty for everyone. No yield from start to end, and it pays once: the posting is closed before + * anything else can press. The share is the criminal's condition on the pad, read at the press (owner + * ruling 2026-11-08: dead 25%, in crit 60%, cuffed or stunned 100%; what it went through on the way + * doesn't count). A live catch gets its hurt, its captor and its preferred prison and goes to the + * prisoner pool. Returns list(credits, vouchers), or why not. */ /datum/criminal_bounty/proc/board_claim(obj/structure/overmap/ship/ship, obj/machinery/mission_pad/pad, atom/movable/target, state, mob/user) // Everything after this line runs once: a second press, or a second ship, finds it closed @@ -157,13 +159,13 @@ return "that bounty is closed" if(QDELETED(target) || QDELETED(ship)) return "nothing on the pad for this bounty" - var/mob/living/basic/bounty_criminal/criminal = istype(target, /mob/living/basic/bounty_criminal) ? target : null + var/mob/living/carbon/human/npc/bounty_criminal/criminal = istype(target, /mob/living/carbon/human/npc/bounty_criminal) ? target : null var/obj/item/bounty_proof/proof = istype(target, /obj/item/bounty_proof) ? target : null if(!criminal && !proof) return "nothing on the pad for this bounty" if(proof) state = BOUNTY_STATE_DEAD - var/share = board_share_for(state, criminal ? criminal.worst_state : BOUNTY_STATE_DEAD) + var/share = board_share_for(state) if(!share) return "they're standing free" var/list/pay = board_payout(share) @@ -266,8 +268,8 @@ var/state = null if(target) state = "proof" - if(istype(target, /mob/living/basic/bounty_criminal)) - var/mob/living/basic/bounty_criminal/criminal = target + if(istype(target, /mob/living/carbon/human/npc/bounty_criminal)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = target state = criminal.capture_state() var/refusal if(private_to && offered_to() != ship) @@ -316,8 +318,8 @@ /// What the pad says about `arrived` on it, or null if it says nothing (not a bounty target, or not this ship's to turn in) /obj/machinery/mission_pad/proc/bounty_pad_line(atom/movable/arrived) var/datum/criminal_bounty/posting - if(istype(arrived, /mob/living/basic/bounty_criminal)) - var/mob/living/basic/bounty_criminal/criminal = arrived + if(istype(arrived, /mob/living/carbon/human/npc/bounty_criminal)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = arrived posting = criminal.posting() else if(istype(arrived, /obj/item/bounty_proof)) var/obj/item/bounty_proof/proof = arrived @@ -343,18 +345,19 @@ // ===== THE BEAM ===== /** - * The pad takes them: held still, harmless and untouchable, and fading out in the prisoner's - * beam (outpost_prison_prisoner.dm beam_out()), then deleted. Never a teleport (AR-A1). Nothing - * they leave behind counts as proof of death. + * The pad takes them: held still and harmless, fading out in the prisoner's beam + * (outpost_prison_prisoner.dm beam_out()), then deleted. Never a teleport (AR-A1). The pay was settled + * before the beam starts, so nothing that happens to them during it changes it; there is no godmode + * (defaults 1.8, CR-18). Their locked kit goes with them (D3); anything on them that isn't kit (papers, + * a key, the crew's own cuffs) is left on the pad. Nothing they leave behind counts as proof of death. */ -/mob/living/basic/bounty_criminal/proc/board_beam_out() +/mob/living/carbon/human/npc/bounty_criminal/proc/board_beam_out() // Their last words as the pad takes them (P1's beamed_out lines), said before the beam holds them still if(stat == CONSCIOUS) INVOKE_ASYNC(src, TYPE_PROC_REF(/mob/living, bounty_say), "beamed_out", null, TRUE) ADD_TRAIT(src, TRAIT_BOUNTY_REMOVED, BOUNTY_PAD_TRAIT) ADD_TRAIT(src, TRAIT_IMMOBILIZED, BOUNTY_PAD_TRAIT) ADD_TRAIT(src, TRAIT_INCAPACITATED, BOUNTY_PAD_TRAIT) - ADD_TRAIT(src, TRAIT_GODMODE, BOUNTY_PAD_TRAIT) REMOVE_TRAIT(src, TRAIT_MISSION_FIELD_MOB, BOUNTY_TRAIT) ai_controller?.set_ai_status(AI_STATUS_OFF) pulledby?.stop_pulling() @@ -368,8 +371,13 @@ transporter_dematerialise(src, BOUNTY_BEAM_TIME) addtimer(CALLBACK(src, PROC_REF(board_finish_beam_out)), BOUNTY_BEAM_TIME, TIMER_DELETE_ME) -/mob/living/basic/bounty_criminal/proc/board_finish_beam_out() +/mob/living/carbon/human/npc/bounty_criminal/proc/board_finish_beam_out() var/turf/spot = get_turf(src) + npc_drop_not_gear() + // The crew's restraints stay with the crew: they are theirs, not the criminal's. + if(spot) + for(var/obj/item/restraints/worn in list(handcuffed, legcuffed)) + transferItemToLoc(worn, spot, force = TRUE) if(spot) new /obj/effect/temp_visual/transporter_flash/departure(spot) transporter_sparks(spot) @@ -445,13 +453,13 @@ * the criminal away (TRAIT_BOUNTY_REMOVED), when its bounty is closed or relisting, or when the * criminal went with its site's interior (it comes back at the next load). One proof per bounty. */ -/proc/bounty_drop_proof(mob/living/basic/bounty_criminal/criminal) +/proc/bounty_drop_proof(mob/living/carbon/human/npc/bounty_criminal/criminal) if(!criminal || HAS_TRAIT(criminal, TRAIT_BOUNTY_REMOVED)) return null var/datum/criminal_bounty/posting = criminal.posting_ref?.resolve() if(!posting || !posting.is_open() || posting.board_relisting) return null - var/mob/living/basic/bounty_criminal/current = posting.criminal() + var/mob/living/carbon/human/npc/bounty_criminal/current = posting.criminal() if(current && current != criminal) return null var/turf/spot = get_turf(criminal) @@ -526,13 +534,15 @@ /** * Called from the bluespace body bag's attempt_fold(): TRUE stops `folder` folding `bag`, because - * a living bounty criminal is inside (AR-E7). Tells `folder` why. + * a bounty criminal inside is alive and struggling (AR-E7, PL-20). One in crit or dead is a body, and + * folds like anyone's; the bag still never rides a transporter beam with a live one in it + * (bounty_blocks_transport()). Tells `folder` why. */ /proc/bounty_blocks_bag_fold(obj/structure/closet/body_bag/bag, mob/living/folder) if(!bag) return FALSE - for(var/mob/living/basic/bounty_criminal/criminal in bag.get_all_contents()) - if(criminal.stat == DEAD) + for(var/mob/living/carbon/human/npc/bounty_criminal/criminal in bag.get_all_contents()) + if(!bounty_body_bound(criminal) || criminal.is_downed()) continue if(folder) to_chat(folder, span_warning("[bag] won't fold with someone alive and struggling inside.")) @@ -555,12 +565,22 @@ if(QDELETED(thing)) return FALSE for(var/mob/living/passenger in thing.get_all_contents()) - if(passenger == thing || passenger.stat == DEAD) - continue - if(istype(passenger, /mob/living/basic/bounty_criminal) || istype(passenger, /mob/living/basic/bounty_companion)) + if(passenger != thing && bounty_body_bound(passenger)) return TRUE return FALSE +/** + * Whether `body` is a living bounty person the pad is the only way out for: a criminal still held to its + * site (its body's TRAIT_NO_TELEPORT; a convict a crew talked down loses it and is free to go), or a + * companion. Dead bodies are proof, and travel like any body. + */ +/proc/bounty_body_bound(mob/living/body) + if(!isliving(body) || QDELETED(body) || body.stat == DEAD) + return FALSE + if(istype(body, /mob/living/carbon/human/npc/bounty_criminal)) + return HAS_TRAIT_FROM(body, TRAIT_NO_TELEPORT, BOUNTY_BODY_TRAIT) + return istype(body, /mob/living/carbon/human/npc/bounty_companion) + /** * Called from the transporter pad's gather_payload(): TRUE keeps `thing` off the beam. A criminal * refuses teleports itself (P2); this stops a locker, a crate or a bag with a living one inside @@ -570,7 +590,6 @@ /proc/bounty_blocks_transport(atom/movable/thing) if(QDELETED(thing)) return FALSE - if(istype(thing, /mob/living/basic/bounty_criminal) || istype(thing, /mob/living/basic/bounty_companion)) - var/mob/living/rider = thing - return rider.stat != DEAD + if(ismob(thing)) + return bounty_body_bound(thing) return bounty_holds_living_criminal(thing) diff --git a/voidcrew/modules/bounties/bounty_types.dm b/voidcrew/modules/bounties/bounty_types.dm index 6af790269ea..12943ae57fd 100644 --- a/voidcrew/modules/bounties/bounty_types.dm +++ b/voidcrew/modules/bounties/bounty_types.dm @@ -140,7 +140,7 @@ GLOBAL_LIST_EMPTY(bounty_prisoner_pool) var/placement_kind /// Weakref to where the criminal is: the overmap object of the planet, ruin, pirate ship or trader outpost var/datum/weakref/site_ref - /// Weakref to the criminal's mob while its site is loaded (/mob/living/basic/bounty_criminal) + /// Weakref to the criminal's mob while its site is loaded (/mob/living/carbon/human/npc/bounty_criminal) var/datum/weakref/criminal_ref /// Weakref to the ship a private offer is for; null for a public bounty var/datum/weakref/private_to @@ -152,9 +152,9 @@ GLOBAL_LIST_EMPTY(bounty_prisoner_pool) var/value = 0 /// world.time it comes off the board var/expires_at = 0 - /// Weakrefs to its decoys at a trader outpost (/mob/living/basic/bounty_criminal/decoy) + /// Weakrefs to its decoys at a trader outpost (/mob/living/carbon/human/npc/bounty_criminal/decoy) var/list/decoys = list() - /// Weakrefs to the criminal's companions (/mob/living/basic/bounty_companion) + /// Weakrefs to the criminal's companions (/mob/living/carbon/human/npc/bounty_companion) var/list/companions = list() /// The sighting marker hunters' GPS units point to var/obj/effect/bounty_sighting/marker @@ -167,29 +167,26 @@ GLOBAL_LIST_EMPTY(bounty_prisoner_pool) /// The criminal's mob, if its site is loaded and it still exists /datum/criminal_bounty/proc/criminal() - var/mob/living/basic/bounty_criminal/criminal = criminal_ref?.resolve() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = criminal_ref?.resolve() return QDELETED(criminal) ? null : criminal // ===== THE CRIMINALS ===== /** - * A wanted criminal, while its site is loaded. Its own mob family: not an outpost prisoner (a - * caught criminal becomes a new prisoner, rebuilt from the record) and never under - * /mob/living/basic/boss (megafauna are banned from outposts). No AI controller until P3 gives it - * one. Built-in values are set by P2 in bounty_criminal.dm. + * A wanted criminal, while its site is loaded: a real human body (/mob/living/carbon/human/npc, the + * human NPC base) driven by the bounty AI. Its crit, stamina, cuffs, wounds, death and revival are + * tg's, as for a player; only its AI and the bounty rules on top are its own. Not an outpost + * prisoner: a caught criminal becomes a new prisoner, rebuilt from the record. Built-in values are + * set by P2 in bounty_criminal.dm. */ -/mob/living/basic/bounty_criminal +/mob/living/carbon/human/npc/bounty_criminal /// Who they are (/datum/bounty_record) var/datum/bounty_record/record /// Weakref to the posting they are wanted on (/datum/criminal_bounty); null for an admin spawn with none var/datum/weakref/posting_ref - /// At or below the downed line: floored, harmless and draggable until they recover (P2) - var/downed = FALSE /// Hidden in a locker, a crate, as a potted plant or in the dark (P3) var/hidden = FALSE - /// The restraints on them, held in their contents (P2), or null - var/obj/item/restraints/handcuffs/restraints - /// Weakrefs to their companions (/mob/living/basic/bounty_companion) + /// Weakrefs to their companions (/mob/living/carbon/human/npc/bounty_companion) var/list/companions = list() /// Blending in at a trader outpost: the fugitive and its decoys idle, talk and move the same way (P6, P3) var/blended = FALSE @@ -197,42 +194,40 @@ GLOBAL_LIST_EMPTY(bounty_prisoner_pool) var/list/grudge = list() /// Their leash, list(min_x, min_y, max_x, max_y, z), or null for none (P2's leash_ok()) var/list/site_bounds - /// The worst capture state they have reached (BOUNTY_STATE_*): once downed or dead, the pay share never rises again. P2 writes it, P5 pays on it. - var/worst_state = BOUNTY_STATE_FREE /// The posting they are wanted on, if it still exists -/mob/living/basic/bounty_criminal/proc/posting() +/mob/living/carbon/human/npc/bounty_criminal/proc/posting() var/datum/criminal_bounty/posting = posting_ref?.resolve() return QDELETED(posting) ? null : posting /// A meek criminal: runs, hides, blends in. P2 sets its body, P3 its AI. -/mob/living/basic/bounty_criminal/meek +/mob/living/carbon/human/npc/bounty_criminal/meek /// A normal criminal: found doing something, fights back. P2 sets its body, P3 its AI. -/mob/living/basic/bounty_criminal/normal +/mob/living/carbon/human/npc/bounty_criminal/normal /// A mini-boss: the base of the five kits. P4 sets its body and AI in bounty_boss.dm. -/mob/living/basic/bounty_criminal/boss +/mob/living/carbon/human/npc/bounty_criminal/boss -/mob/living/basic/bounty_criminal/boss/juggernaut -/mob/living/basic/bounty_criminal/boss/pyromaniac -/mob/living/basic/bounty_criminal/boss/demolitionist -/mob/living/basic/bounty_criminal/boss/ghost -/mob/living/basic/bounty_criminal/boss/heavy +/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut +/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac +/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist +/mob/living/carbon/human/npc/bounty_criminal/boss/ghost +/mob/living/carbon/human/npc/bounty_criminal/boss/heavy /** * A patron at a trader outpost who shares some of the fugitive's features. Same body, same * blended-in mode and same examine layout as the fugitive, so nothing about it gives the fugitive * away; only what a warrant does to it differs. P6 owns its behaviour (bounty_outpost.dm). */ -/mob/living/basic/bounty_criminal/decoy +/mob/living/carbon/human/npc/bounty_criminal/decoy /** * Someone with a normal criminal: fights beside them, is not a bounty and pays nothing. P3 owns it * (bounty_companions.dm) and sets its built-in values. */ -/mob/living/basic/bounty_companion - /// Weakref to the criminal they are with (/mob/living/basic/bounty_criminal) +/mob/living/carbon/human/npc/bounty_companion + /// Weakref to the criminal they are with (/mob/living/carbon/human/npc/bounty_criminal) var/datum/weakref/leader_ref // ===== OBJECTS ===== diff --git a/voidcrew/modules/bounties/strings/bounty_lair_mafia.json b/voidcrew/modules/bounties/strings/bounty_lair_mafia.json index 1c4af5a59e4..d0966d79c2a 100644 --- a/voidcrew/modules/bounties/strings/bounty_lair_mafia.json +++ b/voidcrew/modules/bounties/strings/bounty_lair_mafia.json @@ -33,6 +33,16 @@ "I'm bleeding here!", "Somebody shoot them!" ], + "goon_shoved": [ + "Hands off.", + "Back up, pal.", + "Don't touch me." + ], + "goon_cuffed": [ + "Get off me!", + "Not a chance.", + "You're not putting those on me." + ], "tommy_alert": [ "Nobody goes through this door. Boss's orders.", "You picked the wrong club, friend.", @@ -83,5 +93,10 @@ "You'll pay for that.", "My family will find you.", "Not like this. Not in my own club." + ], + "don_cuffed": [ + "Nobody takes me alive.", + "You'll have to kill me first.", + "Cuffs? On me?" ] } diff --git a/voidcrew/modules/missions/mission_pad.dm b/voidcrew/modules/missions/mission_pad.dm index 3c59618a55b..f52ef602e19 100644 --- a/voidcrew/modules/missions/mission_pad.dm +++ b/voidcrew/modules/missions/mission_pad.dm @@ -181,7 +181,7 @@ if(arrived.loc != loc) return // A wanted criminal or its proof of death: the pad says what Turn In would pay (voidcrew/modules/bounties/bounty_turn_in.dm) - if(istype(arrived, /mob/living/basic/bounty_criminal) || istype(arrived, /obj/item/bounty_proof)) + if(istype(arrived, /mob/living/carbon/human/npc/bounty_criminal) || istype(arrived, /obj/item/bounty_proof)) INVOKE_ASYNC(src, PROC_REF(bounty_pad_announce), arrived) if(!isitem(arrived)) return diff --git a/voidcrew/modules/npc_scaling/zone_profiles.dm b/voidcrew/modules/npc_scaling/zone_profiles.dm index 59385ef4d83..4ad76e95be6 100644 --- a/voidcrew/modules/npc_scaling/zone_profiles.dm +++ b/voidcrew/modules/npc_scaling/zone_profiles.dm @@ -101,8 +101,8 @@ /mob/living/simple_animal/hostile/asteroid/elite, /mob/living/basic/boss, /mob/living/basic/trooper/pirate/faction/boss, - /mob/living/basic/bounty_criminal/boss, - /mob/living/basic/bounty_criminal/kingpin, + /mob/living/carbon/human/npc/bounty_criminal/boss, + /mob/living/carbon/human/npc/bounty_criminal/kingpin, /mob/living/basic/bounty_lair_boss, /mob/living/basic/lich, /mob/living/basic/hoarfrost_matriarch, diff --git a/voidcrew/modules/unit_tests/voidcrew_ambient_strays.dm b/voidcrew/modules/unit_tests/voidcrew_ambient_strays.dm index 48dbd3d1c30..9511e78dc9d 100644 --- a/voidcrew/modules/unit_tests/voidcrew_ambient_strays.dm +++ b/voidcrew/modules/unit_tests/voidcrew_ambient_strays.dm @@ -271,7 +271,13 @@ // THE ESCAPED CONVICT // ========================================================================= -/// The cap follows the crews; a convict is a meek petty criminal in orange; seen, they get one private offer on their own record, within the two-offer limit; talked down, the offer is withdrawn unpaid and a stray with their name follows the crew; an offer that ends leaves a free convict where they are +/** + * The cap follows the crews; a convict is a meek petty criminal in prison orange with the meek's holdout + * kit; seen, they give up the tg way (weapon away, *surrender's real Paralyze) and get one private offer on + * their own record, within the two-offer limit; talked down, the SAME body goes with the crew (follower AI, + * the people's side, off the board for good) and the offer is withdrawn unpaid; aboard they stay aboard; an + * offer that ends leaves a free convict where they are + */ /datum/unit_test/voidcrew_ambient_strays_convict /datum/unit_test/voidcrew_ambient_strays_convict/Run() @@ -285,23 +291,43 @@ var/list/room = ambient_test_room_bounds() var/turf/corner = run_loc_floor_bottom_left var/obj/structure/overmap/space_ruin/ruin = allocate(/obj/structure/overmap/space_ruin) - var/mob/living/basic/bounty_criminal/meek/convict/convict = ambient_spawn_convict(corner, ruin, "ruin") // BOUNTY_PLACEMENT_RUIN + var/mob/living/carbon/human/npc/bounty_criminal/meek/convict/convict = ambient_spawn_convict(corner, ruin, "ruin") // BOUNTY_PLACEMENT_RUIN TEST_ASSERT_NOTNULL(convict, "No convict was made") allocated += convict convict.ai_controller?.set_ai_status(AI_STATUS_OFF) TEST_ASSERT(WEAKREF(convict) in GLOB.ambient_convicts, "A convict is not on the list") TEST_ASSERT_EQUAL(convict.record?.tier, 1, "A convict is not a petty criminal") // BOUNTY_TIER_PETTY TEST_ASSERT_EQUAL(convict.record?.archetype, "meek", "A convict is not meek") // BOUNTY_ARCHETYPE_MEEK - TEST_ASSERT_EQUAL(convict.bounty_outfit(), /datum/outfit/prisoner, "A convict is not in prison orange") + + // Prison orange, under their own name, with the meek's holdout carried, not held + TEST_ASSERT(ispath(convict.bounty_build_outfit(1), /datum/outfit/prisoner), "A convict is not dressed as an escapee") // ZONE_GREEN + TEST_ASSERT(istype(convict.w_uniform, /obj/item/clothing/under/rank/prisoner), "A convict is not in prison orange") + TEST_ASSERT(istype(convict.shoes, /obj/item/clothing/shoes/sneakers/orange), "A convict is not in orange shoes") + TEST_ASSERT_EQUAL(convict.real_name, convict.record?.name, "A convict goes by a prisoner number, not their own name") + var/obj/item/gun/ballistic/automatic/pistol/holdout = locate() in convict.get_all_contents() + TEST_ASSERT_NOTNULL(holdout, "A convict carries no holdout") + TEST_ASSERT(!convict.is_holding(holdout), "A convict walks about with the holdout in hand") + TEST_ASSERT_NOTNULL(locate(/obj/item/ammo_box/magazine/m9mm) in convict.get_all_contents(), "A convict carries no spare magazine") + TEST_ASSERT_NULL(convict.posting(), "A convict nobody has seen is wanted") TEST_ASSERT(convict.convict_can_talk(), "A calm convict won't talk") convict.hidden = TRUE TEST_ASSERT(!convict.convict_can_talk(), "A hidden convict talks") convict.hidden = FALSE - // Seen: one private petty offer, to that crew, on the convict's own record + // Seen: they give up the way a person does, and one private petty offer goes to that crew, on the convict's own record var/obj/structure/overmap/ship/ship = strays_test_ship(room) - var/datum/criminal_bounty/posting = convict.convict_post_bounty(ship) + var/mob/living/carbon/human/consistent/spotter = allocate(__IMPLIED_TYPE__, run_loc_floor_top_right) + TEST_ASSERT(human_npc_take_in_hand(convict, holdout), "Test fixture: the convict could not draw the holdout") + convict.convict_sighted(spotter, ship) + TEST_ASSERT(convict.IsParalyzed(), "A sighted convict did not give up with tg's *surrender") + TEST_ASSERT(convict.npc_surrendering, "A sighted convict is not lying there with their hands on their head") + TEST_ASSERT_EQUAL(convict.npc_last_bark, "surrender", "A sighted convict gave no line as they gave up") // HUMAN_NPC_BARK_SURRENDER + TEST_ASSERT_EQUAL(convict.capture_state(), "stunned", "A convict who gave up reads as [convict.capture_state()]") // BOUNTY_STATE_STUNNED + TEST_ASSERT(!convict.is_holding(holdout), "A convict who gave up kept the holdout in hand") + TEST_ASSERT_EQUAL(human_npc_holding(holdout), convict, "A convict's holdout left their body when they gave up") + TEST_ASSERT(!convict.convict_can_talk(), "A convict lying there with their hands on their head talks") + var/datum/criminal_bounty/posting = convict.posting() TEST_ASSERT_NOTNULL(posting, "Seeing a convict posted no bounty") TEST_ASSERT_EQUAL(posting?.record, convict.record, "The bounty shows someone other than the convict") TEST_ASSERT_EQUAL(posting?.offered_to(), ship, "The bounty was not offered to the crew who saw the convict") @@ -315,25 +341,51 @@ var/obj/structure/overmap/ship/busy = strays_test_ship(room) SScriminal_bounties.board_post(1, null, ruin, busy, TRUE) // BOUNTY_TIER_PETTY SScriminal_bounties.board_post(1, null, ruin, busy, TRUE) - var/mob/living/basic/bounty_criminal/meek/convict/other = ambient_spawn_convict(run_loc_floor_top_right, ruin, "ruin") + var/mob/living/carbon/human/npc/bounty_criminal/meek/convict/other = ambient_spawn_convict(run_loc_floor_top_right, ruin, "ruin") allocated += other other.ai_controller?.set_ai_status(AI_STATUS_OFF) TEST_ASSERT_NULL(other.convict_post_bounty(busy), "A convict's bounty went past the two private offers") // BOUNTY_PRIVATE_MAX - // Talked down: the bounty is withdrawn unpaid, and a stray with their name follows the crew + // Talked down once they are up again: the same body goes with the crew, and the bounty is withdrawn unpaid + convict.SetParalyzed(0) var/mob/living/carbon/human/consistent/leader = allocate(__IMPLIED_TYPE__, locate(corner.x + 1, corner.y, corner.z)) var/convict_name = convict.real_name var/datum/bounty_record/convict_record = convict.record - var/mob/living/basic/ambient_npc/stray/convict/stray = convict.convict_join(leader, ship) - TEST_ASSERT_NOTNULL(stray, "A talked-down convict did not join the crew") - allocated += stray - TEST_ASSERT(QDELETED(convict), "The convict's body stayed after they joined a crew") + var/datum/ambient_place/ship/deck = GLOB.ambient_ship_places[REF(ship)] + var/taken_before = deck?.taken + TEST_ASSERT_EQUAL(convict.convict_join(leader, ship), convict, "A talked-down convict did not go with the crew in their own body") + convict.ai_controller?.set_ai_status(AI_STATUS_OFF) + TEST_ASSERT(!QDELETED(convict), "The convict's body was replaced when they joined a crew") + TEST_ASSERT(convict.convict_recruited, "The talked-down convict is not with the crew") TEST_ASSERT(!(posting in GLOB.criminal_bounties), "Recruiting the convict left their bounty open") + TEST_ASSERT_NULL(convict.posting(), "A recruited convict is still wanted on a posting") TEST_ASSERT_EQUAL(convict_record.status, "closed", "The recruited convict's record is still wanted") // BOUNTY_RECORD_CLOSED - TEST_ASSERT_EQUAL(stray?.real_name, convict_name, "The convict came back as someone else") - TEST_ASSERT_EQUAL(stray?.bounty_record, convict_record, "The recruited convict lost their face") - TEST_ASSERT(stray?.is_following(), "The recruited convict is not following the crew") - TEST_ASSERT_NULL(locate(/obj/item/bounty_proof) in get_turf(stray), "Recruiting the convict left proof of death") + TEST_ASSERT_EQUAL(convict.real_name, convict_name, "The recruited convict is someone else now") + TEST_ASSERT_EQUAL(convict.record, convict_record, "The recruited convict lost who they are") + TEST_ASSERT(istype(convict.ai_controller, /datum/ai_controller/basic_controller/convict_follower), "The recruited convict kept the criminal's AI") + TEST_ASSERT_EQUAL(convict.convict_leader(), leader, "The recruited convict is not following the crew member who asked") + TEST_ASSERT((FACTION_NEUTRAL in convict.faction) && !(FACTION_HOSTILE in convict.faction), "The recruited convict is still on the hostiles' side") + TEST_ASSERT(!(WEAKREF(convict) in GLOB.ambient_convicts), "A recruited convict still counts as a convict on the loose") + TEST_ASSERT(!HAS_TRAIT(convict, TRAIT_NO_TELEPORT), "A recruited convict still can't be teleported") + TEST_ASSERT_NULL(convict.GetComponent(/datum/component/bounty_body), "A recruited convict still has the bounty body's hooks") + TEST_ASSERT(!HAS_TRAIT(convict, "mission_field_mob"), "A recruited convict is still kept from the sweep") // TRAIT_MISSION_FIELD_MOB + TEST_ASSERT(!is_hostile_creature(convict), "A hull turret would take the recruited convict for a threat") + TEST_ASSERT_EQUAL(deck?.taken, taken_before + 1, "The ship did not count the convict it took in") + TEST_ASSERT_NULL(locate(/obj/item/bounty_proof) in get_turf(convict), "Recruiting the convict left proof of death") + TEST_ASSERT(!convict.convict_can_talk(), "A recruited convict pleads to be taken in again") + + // Aboard (the test room counts as the ship): they step aboard once, and from then on stay aboard + TEST_ASSERT(convict.convict_board_if_aboard(), "The recruited convict did not step aboard") + TEST_ASSERT(convict.convict_aboard, "The recruited convict does not live aboard") + TEST_ASSERT(!convict.convict_board_if_aboard(), "The recruited convict stepped aboard twice") + TEST_ASSERT(convict.convict_may_step(locate(corner.x + 1, corner.y + 1, corner.z)), "Aboard, the recruited convict won't walk about the ship") + TEST_ASSERT(!convict.convict_may_step(locate(corner.x - 1, corner.y, corner.z)), "Aboard, the recruited convict would walk off the ship") + + // Told to stay, they stay; asked again, they follow + convict.convict_stay() + TEST_ASSERT_NULL(convict.convict_leader(), "Told to stay, the recruited convict still follows someone") + TEST_ASSERT(convict.convict_follow(leader), "The recruited convict would not follow again") + TEST_ASSERT_EQUAL(convict.convict_leader(), leader, "Asked again, the recruited convict follows someone else") // The crew's last offer just ended: none during the board's gap after it TEST_ASSERT_NULL(other.convict_post_bounty(ship), "A convict was offered during the gap after the crew's last private offer ended") // BOUNTY_PRIVATE_GAP @@ -374,7 +426,7 @@ record.sites += site TEST_ASSERT(kind.realize(site), "A hideout brought no convict out") var/datum/weakref/convict_ref = site.data["convict"] - var/mob/living/basic/bounty_criminal/meek/convict/convict = convict_ref?.resolve() + var/mob/living/carbon/human/npc/bounty_criminal/meek/convict/convict = convict_ref?.resolve() TEST_ASSERT(istype(convict), "A hideout's convict is not a convict") allocated += convict convict.ai_controller?.set_ai_status(AI_STATUS_OFF) diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_admin.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_admin.dm index 7188777d9db..5e7b5dad5fb 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_admin.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_admin.dm @@ -6,8 +6,9 @@ * * The panel runs without an admin client: /datum/bounty_admin_panel/unit_test answers its prompts * from a list and notes what it logged and said. The tests call the action procs straight, and the - * menu once each through its prompts. They run against the real packages: capture states are read - * back through P2's capture_state(), the pool through P7's procs, the clock through P5's. + * menu once each through its prompts. They run against the real packages: criminals are real human + * bodies, so a forced state is checked on tg's own state (crit, Paralyze, the cuff slot, death) and read + * back through P2's capture_state(); the pool through P7's procs, the clock through P5's. * * Every test that touches a global list (the postings, the pool) sets it aside first and puts it back * after, from a Run() that calls a separate checks proc, so a failed check can't skip the restore. @@ -81,7 +82,7 @@ /// A criminal spawned by the panel, deleted with the test /datum/unit_test/voidcrew_bounty_admin/proc/spawn_criminal(datum/bounty_admin_panel/unit_test/panel, mob/operator, tier, archetype, variant, turf/spot) - var/mob/living/basic/bounty_criminal/criminal = panel.admin_spawn_criminal(operator, tier, archetype, variant, null, spot) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = panel.admin_spawn_criminal(operator, tier, archetype, variant, null, spot) if(criminal) allocated += criminal return criminal @@ -107,19 +108,19 @@ // Every archetype and kit: list(archetype, kit or style, the subtype P2 picks) var/list/cases = list( - list("meek", null, /mob/living/basic/bounty_criminal/meek), // BOUNTY_ARCHETYPE_MEEK - list("normal", "knife", /mob/living/basic/bounty_criminal/normal), // BOUNTY_ARCHETYPE_NORMAL, BOUNTY_STYLE_KNIFE - list("boss", "juggernaut", /mob/living/basic/bounty_criminal/boss/juggernaut), // BOUNTY_ARCHETYPE_BOSS, BOUNTY_KIT_* - list("boss", "pyromaniac", /mob/living/basic/bounty_criminal/boss/pyromaniac), - list("boss", "demolitionist", /mob/living/basic/bounty_criminal/boss/demolitionist), - list("boss", "ghost", /mob/living/basic/bounty_criminal/boss/ghost), - list("boss", "heavy", /mob/living/basic/bounty_criminal/boss/heavy), + list("meek", null, /mob/living/carbon/human/npc/bounty_criminal/meek), // BOUNTY_ARCHETYPE_MEEK + list("normal", "knife", /mob/living/carbon/human/npc/bounty_criminal/normal), // BOUNTY_ARCHETYPE_NORMAL, BOUNTY_STYLE_KNIFE + list("boss", "juggernaut", /mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut), // BOUNTY_ARCHETYPE_BOSS, BOUNTY_KIT_* + list("boss", "pyromaniac", /mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac), + list("boss", "demolitionist", /mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist), + list("boss", "ghost", /mob/living/carbon/human/npc/bounty_criminal/boss/ghost), + list("boss", "heavy", /mob/living/carbon/human/npc/bounty_criminal/boss/heavy), ) for(var/list/spawn_case as anything in cases) var/archetype = spawn_case[1] var/variant = spawn_case[2] var/expected = spawn_case[3] - var/mob/living/basic/bounty_criminal/criminal = spawn_criminal(panel, operator, 2, archetype, variant, spot) // BOUNTY_TIER_WANTED + var/mob/living/carbon/human/npc/bounty_criminal/criminal = spawn_criminal(panel, operator, 2, archetype, variant, spot) // BOUNTY_TIER_WANTED TEST_ASSERT_NOTNULL(criminal, "No [archetype] [variant] criminal spawned: [panel.error]") TEST_ASSERT_EQUAL(criminal.type, expected, "The [archetype] [variant] criminal is a [criminal.type]") TEST_ASSERT_EQUAL(get_turf(criminal), spot, "The [archetype] [variant] criminal spawned away from the spot") @@ -138,7 +139,7 @@ TEST_ASSERT_EQUAL(length(panel.operations), length(cases), "The panel logged [length(panel.operations)] spawns for [length(cases)]") // A random kit is still a kit. - var/mob/living/basic/bounty_criminal/random_boss = spawn_criminal(panel, operator, 3, "boss", null, spot) // BOUNTY_TIER_MOST_WANTED + var/mob/living/carbon/human/npc/bounty_criminal/random_boss = spawn_criminal(panel, operator, 3, "boss", null, spot) // BOUNTY_TIER_MOST_WANTED TEST_ASSERT((random_boss?.record?.kit in list("juggernaut", "pyromaniac", "demolitionist", "ghost", "heavy")), "A boss with a random kit has the kit [random_boss?.record?.kit]") // Bad requests are refused, with a reason and no log line. @@ -155,8 +156,8 @@ panel.answers = list("Spawn a criminal at my feet", "Normal", "Petty", "Shotgun", "Camping") panel.run_menu(operator) TEST_ASSERT_EQUAL(length(panel.missed), 0, "The spawn menu did not offer: [jointext(panel.missed, "; ")]") - var/mob/living/basic/bounty_criminal/from_menu - for(var/mob/living/basic/bounty_criminal/found in get_turf(operator)) + var/mob/living/carbon/human/npc/bounty_criminal/from_menu + for(var/mob/living/carbon/human/npc/bounty_criminal/found in get_turf(operator)) from_menu = found TEST_ASSERT_NOTNULL(from_menu, "The spawn menu put nobody at the admin's feet") allocated += from_menu @@ -164,16 +165,16 @@ TEST_ASSERT_EQUAL(from_menu.record?.tier, 1, "The spawn menu's criminal is not petty") // BOUNTY_TIER_PETTY // A decoy, through P6's builder: its own record, beside the criminal, blending in, on no posting. - var/mob/living/basic/bounty_criminal/wanted = spawn_criminal(panel, operator, 1, "meek", null, spot) - var/mob/living/basic/bounty_criminal/decoy/decoy = panel.admin_spawn_decoy(operator, wanted, 2) + var/mob/living/carbon/human/npc/bounty_criminal/wanted = spawn_criminal(panel, operator, 1, "meek", null, spot) + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = panel.admin_spawn_decoy(operator, wanted, 2) TEST_ASSERT_NOTNULL(decoy, "No decoy spawned: [panel.error]") allocated += decoy - TEST_ASSERT(istype(decoy, /mob/living/basic/bounty_criminal/decoy), "The decoy is a [decoy.type]") + TEST_ASSERT(istype(decoy, /mob/living/carbon/human/npc/bounty_criminal/decoy), "The decoy is a [decoy.type]") TEST_ASSERT(decoy.record && decoy.record != wanted.record, "The decoy has no record of its own") TEST_ASSERT(get_dist(decoy, wanted) <= 1, "The decoy spawned [get_dist(decoy, wanted)] tiles from its criminal") TEST_ASSERT_NULL(decoy.posting_ref, "The decoy is linked to a posting through posting_ref") TEST_ASSERT(decoy.blended, "The decoy is not blending in: it skipped P6's builder") - TEST_ASSERT_EQUAL(decoy.maxHealth, wanted.maxHealth, "The decoy's health does not match its criminal's") + TEST_ASSERT_EQUAL(decoy.npc_damage_taken, wanted.npc_damage_taken, "The decoy's toughness does not match its criminal's") TEST_ASSERT_NULL(panel.admin_spawn_decoy(operator, decoy, 1), "A decoy of a decoy was spawned") TEST_ASSERT(!(decoy in panel.live_criminals()), "Decoys are offered as wanted criminals") TEST_ASSERT(decoy in panel.live_criminals(include_decoys = TRUE), "Decoys are missing when asked for") @@ -181,21 +182,26 @@ // ===== CAPTURE STATES ===== /** - * Each forced state reads back through P2's capture_state(), each on a fresh criminal; restraints go on - * through P2's own proc with nobody on the grudge list; and "Free" takes off everything P2 puts on, - * including cuffs a player put on a downed criminal. + * Each forced state is tg's own, read back through P2's capture_state(), each on a fresh criminal: + * downed is real brute on the chest to just past the crit line (soft crit, not hard, and no wound), a + * tough Most Wanted body included; stunned is a real Paralyze; restrained is real handcuffs in tg's cuff + * slot with nobody on the grudge list; dead is death(). "Free" takes all of it off through tg + * (revive(HEAL_ALL), uncuff(), the stuns ended): a real *surrender, a hunter's cuffs on a body in crit, + * and death itself. */ /datum/unit_test/voidcrew_bounty_admin/force_state -/datum/unit_test/voidcrew_bounty_admin/force_state/proc/fresh(datum/bounty_admin_panel/unit_test/panel, mob/operator) - return spawn_criminal(panel, operator, 1, "normal", "brawler", run_loc_floor_bottom_left) // BOUNTY_TIER_PETTY +/datum/unit_test/voidcrew_bounty_admin/force_state/proc/fresh(datum/bounty_admin_panel/unit_test/panel, mob/operator, tier = 1) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = spawn_criminal(panel, operator, tier, "normal", "brawler", run_loc_floor_bottom_left) // BOUNTY_TIER_PETTY + criminal?.ai_controller?.set_ai_status(AI_STATUS_OFF) + return criminal /datum/unit_test/voidcrew_bounty_admin/force_state/Run() var/mob/living/carbon/human/operator = make_operator(run_loc_floor_top_right) var/datum/bounty_admin_panel/unit_test/panel = allocate(__IMPLIED_TYPE__, operator) // Only an admin, and only known states; refusals log nothing. - var/mob/living/basic/bounty_criminal/criminal = fresh(panel, operator) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = fresh(panel, operator) TEST_ASSERT_NOTNULL(criminal, "No criminal spawned: [panel.error]") var/logged = length(panel.operations) panel.allow_actions = FALSE @@ -205,77 +211,93 @@ TEST_ASSERT(!panel.admin_force_state(operator, criminal, "fine") && panel.error, "An unknown state was accepted") TEST_ASSERT_EQUAL(length(panel.operations), logged, "A refused forced state was logged") - // Downed: down, alive, at or under P2's line. + // Downed: tg's crit, just past the line, from real brute on the chest. criminal = fresh(panel, operator) TEST_ASSERT(panel.admin_force_state(operator, criminal, "downed"), "Forcing downed was refused: [panel.error]") // BOUNTY_STATE_DOWNED TEST_ASSERT_EQUAL(criminal.capture_state(), "downed", "A forced downed criminal reads as [criminal.capture_state()]") - TEST_ASSERT(criminal.is_downed(), "A forced downed criminal is not down") - TEST_ASSERT(criminal.health <= criminal.body_downed_line(), "Forcing downed left them at [criminal.health] health, over the line") - TEST_ASSERT_EQUAL(criminal.worst_state, "downed", "A forced downed criminal's worst state is [criminal.worst_state]") + TEST_ASSERT(HAS_TRAIT(criminal, TRAIT_CRITICAL_CONDITION), "A forced downed criminal is not in tg's crit") + TEST_ASSERT_EQUAL(criminal.stat, SOFT_CRIT, "Forcing downed left them at stat [criminal.stat] ([criminal.health] health, [criminal.dna.species.type]), not just into soft crit") + TEST_ASSERT(criminal.health <= HEALTH_THRESHOLD_CRIT && criminal.health > HEALTH_THRESHOLD_FULLCRIT, "Forcing downed left them at [criminal.health] health, not just past the crit line") + var/obj/item/bodypart/chest = criminal.get_bodypart(BODY_ZONE_CHEST) + TEST_ASSERT(chest?.brute_dam > 0, "Forcing downed put no brute on their chest") + TEST_ASSERT_EQUAL(LAZYLEN(criminal.all_wounds), 0, "Forcing downed wounded them") TEST_ASSERT(!panel.admin_force_state(operator, criminal, "downed"), "A downed criminal was downed again") - - // Stunned: paralysed. + // A tougher body (Most Wanted takes less of each hit) still goes down, no further than a person would. + var/mob/living/carbon/human/npc/bounty_criminal/tough = fresh(panel, operator, 3) // BOUNTY_TIER_MOST_WANTED + TEST_ASSERT(tough.npc_damage_taken < 1, "Test fixture: a Most Wanted criminal takes a person's damage") + TEST_ASSERT(panel.admin_force_state(operator, tough, "downed"), "Forcing a Most Wanted criminal downed was refused: [panel.error]") + TEST_ASSERT_EQUAL(tough.stat, SOFT_CRIT, "A forced downed Most Wanted criminal is at stat [tough.stat]") + // A body that takes more of each hit than a person (a plasmaman's frail bones) stops in soft crit too. + var/datum/bounty_record/frail_record = generate_bounty_record(1, "normal", "planet", /datum/species/plasmaman) // BOUNTY_TIER_PETTY, BOUNTY_ARCHETYPE_NORMAL, BOUNTY_PLACEMENT_PLANET + var/mob/living/carbon/human/npc/bounty_criminal/frail = spawn_bounty_criminal(frail_record, run_loc_floor_bottom_left, null) + TEST_ASSERT_NOTNULL(frail, "Test fixture: no plasmaman criminal spawned") + allocated += frail + frail.ai_controller?.set_ai_status(AI_STATUS_OFF) + TEST_ASSERT(panel.admin_force_state(operator, frail, "downed"), "Forcing a plasmaman criminal downed was refused: [panel.error]") + TEST_ASSERT_EQUAL(frail.stat, SOFT_CRIT, "A forced downed plasmaman criminal is at stat [frail.stat] ([frail.health] health)") + + // Stunned: a real paralysis. criminal = fresh(panel, operator) TEST_ASSERT(panel.admin_force_state(operator, criminal, "stunned"), "Forcing a stun was refused: [panel.error]") // BOUNTY_STATE_STUNNED TEST_ASSERT_EQUAL(criminal.capture_state(), "stunned", "A forced stunned criminal reads as [criminal.capture_state()]") TEST_ASSERT(criminal.IsParalyzed(), "A forced stunned criminal is not paralysed") - // Restrained: P2's cuffs and everything that comes with them, and nobody on the grudge list. + // Restrained: real handcuffs in tg's cuff slot, put on by nobody. criminal = fresh(panel, operator) TEST_ASSERT(panel.admin_force_state(operator, criminal, "restrained"), "Forcing restraints was refused: [panel.error]") // BOUNTY_STATE_RESTRAINED TEST_ASSERT_EQUAL(criminal.capture_state(), "restrained", "A forced restrained criminal reads as [criminal.capture_state()]") - TEST_ASSERT(criminal.is_restrained(), "A forced restrained criminal has no restraints on") - TEST_ASSERT(istype(criminal.restraints, /obj/item/restraints/handcuffs), "Forcing restraints put no handcuffs on them") - TEST_ASSERT(HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_body_cuffs"), "The forced cuffs don't hold them still") // BOUNTY_BODY_CUFFS_TRAIT - TEST_ASSERT(HAS_TRAIT_FROM(criminal, TRAIT_AI_PAUSED, "bounty_body_held"), "The forced cuffs don't pause their AI") // BOUNTY_BODY_HELD_TRAIT + TEST_ASSERT(istype(criminal.handcuffed, /obj/item/restraints/handcuffs), "Forcing restraints put no handcuffs in their cuff slot") + TEST_ASSERT(HAS_TRAIT(criminal, TRAIT_RESTRAINED), "The forced cuffs don't restrain them") TEST_ASSERT_EQUAL(length(criminal.grudge), 0, "Forcing restraints put someone on their grudge list") TEST_ASSERT(!panel.admin_force_state(operator, criminal, "restrained") && panel.error, "Cuffing a cuffed criminal was accepted") - // Free takes them off through P2: the cuffs drop at their feet and the hold is gone. - var/obj/item/restraints/handcuffs/forced_cuffs = criminal.restraints + // Free takes them off the tg way: the cuffs drop at their feet. + var/obj/item/restraints/handcuffs/forced_cuffs = criminal.handcuffed TEST_ASSERT(panel.admin_force_state(operator, criminal, "free"), "Freeing a cuffed criminal was refused: [panel.error]") // BOUNTY_STATE_FREE TEST_ASSERT_EQUAL(criminal.capture_state(), "free", "A freed criminal reads as [criminal.capture_state()]") - TEST_ASSERT(!HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, "bounty_body_cuffs"), "Freeing left them held still by the cuffs") - TEST_ASSERT(!HAS_TRAIT_FROM(criminal, TRAIT_AI_PAUSED, "bounty_body_held"), "Freeing left their AI paused") + TEST_ASSERT_NULL(criminal.handcuffed, "Freeing left the cuffs on") + TEST_ASSERT(!HAS_TRAIT(criminal, TRAIT_RESTRAINED), "Freeing left them restrained") TEST_ASSERT_EQUAL(forced_cuffs.loc, get_turf(criminal), "Freeing did not drop the cuffs at their feet") allocated += forced_cuffs - // Surrendered reads as stunned, and free ends it. + // A real *surrender reads as stunned, and free ends it. criminal = fresh(panel, operator) - ADD_TRAIT(criminal, "bounty_surrendered", "bounty") // TRAIT_BOUNTY_SURRENDERED, BOUNTY_TRAIT - TEST_ASSERT_EQUAL(criminal.capture_state(), "stunned", "A surrendered criminal reads as [criminal.capture_state()]") - TEST_ASSERT(panel.admin_force_state(operator, criminal, "free"), "Freeing a surrendered criminal was refused: [panel.error]") - TEST_ASSERT(!HAS_TRAIT(criminal, "bounty_surrendered"), "Freeing left the surrender on") - TEST_ASSERT_EQUAL(criminal.capture_state(), "free", "A freed surrendered criminal reads as [criminal.capture_state()]") - - // A player cuffs a downed criminal through P2; the admin frees it: up, healed, uncuffed, nothing of P2's left on it. + TEST_ASSERT(criminal.npc_surrender(), "Test fixture: the criminal would not give up") + TEST_ASSERT_EQUAL(criminal.capture_state(), "stunned", "A criminal who gave up reads as [criminal.capture_state()]") + TEST_ASSERT(panel.admin_force_state(operator, criminal, "free"), "Freeing a criminal who gave up was refused: [panel.error]") + TEST_ASSERT(!criminal.IsParalyzed(), "Freeing left them paralysed") + TEST_ASSERT(!criminal.npc_surrendering, "Freeing left the surrender on") + TEST_ASSERT_EQUAL(criminal.capture_state(), "free", "A freed criminal who gave up reads as [criminal.capture_state()]") + + // A hunter cuffs a criminal in crit (tg's apply_cuffs, without the do_after); the admin frees it: up, healed, uncuffed. criminal = fresh(panel, operator) TEST_ASSERT(panel.admin_force_state(operator, criminal, "downed"), "Forcing downed was refused: [panel.error]") var/mob/living/carbon/human/hunter = make_operator(run_loc_floor_bottom_left) var/obj/item/restraints/handcuffs/player_cuffs = allocate(/obj/item/restraints/handcuffs, run_loc_floor_bottom_left) hunter.put_in_hands(player_cuffs) - TEST_ASSERT(criminal.body_apply_cuffs(player_cuffs, hunter), "The hunter's cuffs did not go on the downed criminal") - TEST_ASSERT_EQUAL(criminal.capture_state(), "downed", "A cuffed downed criminal reads as [criminal.capture_state()]") - TEST_ASSERT(panel.admin_force_state(operator, criminal, "free"), "Freeing a cuffed downed criminal was refused: [panel.error]") + player_cuffs.apply_cuffs(criminal, hunter) + TEST_ASSERT_EQUAL(criminal.handcuffed, player_cuffs, "The hunter's cuffs did not go on the criminal in crit") + TEST_ASSERT_EQUAL(criminal.capture_state(), "downed", "A cuffed criminal in crit reads as [criminal.capture_state()]") + TEST_ASSERT(panel.admin_force_state(operator, criminal, "free"), "Freeing a cuffed criminal in crit was refused: [panel.error]") TEST_ASSERT_EQUAL(criminal.capture_state(), "free", "The freed criminal reads as [criminal.capture_state()]") - TEST_ASSERT(!criminal.is_downed(), "Freeing left them down") + TEST_ASSERT_EQUAL(criminal.stat, CONSCIOUS, "Freeing left them at stat [criminal.stat]") + TEST_ASSERT(!HAS_TRAIT(criminal, TRAIT_CRITICAL_CONDITION), "Freeing left them in crit") TEST_ASSERT(!criminal.is_restrained(), "Freeing left the hunter's cuffs on") + TEST_ASSERT_EQUAL(player_cuffs.loc, get_turf(criminal), "Freeing did not drop the hunter's cuffs at their feet") TEST_ASSERT_EQUAL(criminal.health, criminal.maxHealth, "Freeing left them hurt") - TEST_ASSERT_EQUAL(criminal.worst_state, "free", "Freeing left the worst state at [criminal.worst_state]") - for(var/source in list("bounty_body_cuffs", "bounty_body_downed")) // BOUNTY_BODY_CUFFS_TRAIT, BOUNTY_BODY_DOWNED_TRAIT - TEST_ASSERT(!HAS_TRAIT_FROM(criminal, TRAIT_IMMOBILIZED, source), "Freeing left them held still ([source])") - TEST_ASSERT(!HAS_TRAIT_FROM(criminal, TRAIT_FLOORED, "bounty_body_downed"), "Freeing left them on the floor") - TEST_ASSERT(!HAS_TRAIT_FROM(criminal, TRAIT_AI_PAUSED, "bounty_body_held"), "Freeing left their AI paused") - TEST_ASSERT(!HAS_TRAIT_FROM(criminal, "bounty_held", "bounty_body_held"), "Freeing left them held") // TRAIT_BOUNTY_HELD - - // Dead: dead, and the pad would read it so. The dead stay dead and take no other state. + chest = criminal.get_bodypart(BODY_ZONE_CHEST) + TEST_ASSERT_EQUAL(chest?.brute_dam, 0, "Freeing left brute on their chest") + + // Dead: dead, and the pad would read it so. No other state goes on a corpse; free brings them back. criminal = fresh(panel, operator) TEST_ASSERT(panel.admin_force_state(operator, criminal, "dead"), "Forcing death was refused: [panel.error]") TEST_ASSERT_EQUAL(criminal.stat, DEAD, "Forcing death left them alive") TEST_ASSERT_EQUAL(criminal.capture_state(), "dead", "A dead criminal reads as [criminal.capture_state()]") - TEST_ASSERT(!panel.admin_force_state(operator, criminal, "free"), "A dead criminal was freed") - TEST_ASSERT_EQUAL(criminal.stat, DEAD, "Freeing a dead criminal revived them") TEST_ASSERT(!panel.admin_force_state(operator, criminal, "downed"), "A dead criminal was downed") TEST_ASSERT(!panel.admin_force_state(operator, criminal, "restrained"), "A dead criminal was cuffed") + TEST_ASSERT(!panel.admin_force_state(operator, criminal, "stunned"), "A dead criminal was stunned") + TEST_ASSERT(panel.admin_force_state(operator, criminal, "free"), "Freeing a dead criminal was refused: [panel.error]") + TEST_ASSERT(criminal.stat != DEAD, "Freeing a dead criminal did not revive them") + TEST_ASSERT_EQUAL(criminal.capture_state(), "free", "A revived criminal reads as [criminal.capture_state()]") // Through the menu: pick the criminal, then the state. criminal = fresh(panel, operator) @@ -382,7 +404,7 @@ posting.value = 1234 posting.expires_at = world.time + 20 MINUTES GLOB.criminal_bounties += posting - var/mob/living/basic/bounty_criminal/criminal = spawn_bounty_criminal(record, run_loc_floor_bottom_left, posting) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = spawn_bounty_criminal(record, run_loc_floor_bottom_left, posting) if(criminal) allocated += criminal posting.criminal_ref = WEAKREF(criminal) @@ -392,7 +414,7 @@ GLOB.criminal_bounties.Cut() GLOB.criminal_bounties += postings_before -/datum/unit_test/voidcrew_bounty_admin/postings/proc/run_checks(datum/bounty_admin_panel/unit_test/panel, mob/operator, datum/criminal_bounty/posting, mob/living/basic/bounty_criminal/criminal) +/datum/unit_test/voidcrew_bounty_admin/postings/proc/run_checks(datum/bounty_admin_panel/unit_test/panel, mob/operator, datum/criminal_bounty/posting, mob/living/carbon/human/npc/bounty_criminal/criminal) TEST_ASSERT_NOTNULL(criminal, "No criminal spawned for the posting") // The row: every field, a jump link to the criminal, the time left. diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_ai.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_ai.dm index a19b953039a..4a794551936 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_ai.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_ai.dm @@ -1,5 +1,8 @@ /** - * Bounty hunting: P3 AI's tests, for voidcrew/modules/bounties/bounty_ai*.dm, bounty_activities.dm and bounty_companions.dm. + * Bounty hunting: P3 AI's tests, for voidcrew/modules/bounties/bounty_ai*.dm, bounty_styles.dm, + * bounty_activities.dm and bounty_companions.dm. Criminals and companions are real human bodies (phase D + * of the human NPC migration): these tests check that they draw, fire, throw and shove with the real + * items they carry, hide by real moves, sit and drink for real, and give up through tg's *surrender. * The blend test uses P6's blend component and the companion tests P2's may_attack_scope(), as * production does. * @@ -15,11 +18,36 @@ /datum/unit_test/voidcrew_bounty_ai/proc/tile(dx, dy) return locate(run_loc_floor_bottom_left.x + dx, run_loc_floor_bottom_left.y + dy, run_loc_floor_bottom_left.z) -/// Hiding in a locker and in a crate; opening either finds them, and they bolt +/** + * A criminal of `criminal_type` at `where`, made the way production makes one (the human NPC spawn + * order, with its record as its look), so it is dressed by its record: `style` (BOUNTY_STYLE_*) and + * `tier` (BOUNTY_TIER_*, 1 Petty). + */ +/datum/unit_test/voidcrew_bounty_ai/proc/make_criminal(criminal_type, turf/where, style, tier = 1) + var/archetype = ispath(criminal_type, /mob/living/carbon/human/npc/bounty_criminal/meek) ? "meek" : "normal" // BOUNTY_ARCHETYPE_* + var/datum/bounty_record/record = generate_bounty_record(tier, archetype, "planet", /datum/species/human) // BOUNTY_PLACEMENT_PLANET + record.tier = tier + if(style) + record.style = style + var/datum/human_npc_order/order = spawn_human_npc(criminal_type, where, look = record, immediate = TRUE) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = order?.spawned_ref?.resolve() + qdel(order) + TEST_ASSERT_NOTNULL(criminal, "Test fixture: no [criminal_type] was made") + allocated += criminal + criminal.ai_update_style() + return criminal + +/// The first `item_type` `body` carries anywhere on it, held or not +/datum/unit_test/voidcrew_bounty_ai/proc/carried(mob/living/carbon/body, item_type) + for(var/obj/item/thing as anything in body.get_all_contents_type(item_type)) + return thing + return null + +/// Hiding in a locker and in a crate (a real move in, and out when it opens); opening either finds them, and they bolt /datum/unit_test/voidcrew_bounty_ai/containers /datum/unit_test/voidcrew_bounty_ai/containers/Run() - var/mob/living/basic/bounty_criminal/meek/criminal = allocate(/mob/living/basic/bounty_criminal/meek, tile(1, 1)) + var/mob/living/carbon/human/npc/bounty_criminal/meek/criminal = allocate(/mob/living/carbon/human/npc/bounty_criminal/meek, tile(1, 1)) var/obj/structure/closet/locker = allocate(/obj/structure/closet, tile(2, 1)) TEST_ASSERT(criminal.ai_hide_in(locker), "The meek criminal would not hide in the locker beside them") TEST_ASSERT(criminal.hidden, "Hiding in a locker did not set hidden") @@ -31,9 +59,11 @@ TEST_ASSERT(!criminal.hidden, "Opening the locker did not find them") TEST_ASSERT(isturf(criminal.loc), "Found, they are still in the locker") TEST_ASSERT_EQUAL(criminal.ai_mode, "fleeing", "Found, they did not bolt") // BOUNTY_AI_FLEEING + TEST_ASSERT_EQUAL(criminal.move_intent, MOVE_INTENT_RUN, "Found, they bolted at a walk") TEST_ASSERT_EQUAL(criminal.ai_last_hide_ref?.resolve(), locker, "They would hide in the same locker again") criminal.ai_calm_down() + TEST_ASSERT_EQUAL(criminal.move_intent, MOVE_INTENT_WALK, "Calm again, they still run") criminal.forceMove(tile(1, 1)) var/obj/structure/closet/crate/crate = allocate(/obj/structure/closet/crate, tile(1, 2)) TEST_ASSERT(criminal.ai_hide_in(crate), "The meek criminal would not hide in the crate beside them") @@ -49,43 +79,41 @@ locker.welded = TRUE TEST_ASSERT(!criminal.ai_container_usable(locker), "A welded locker counts as a hiding place") -/// Passing as a potted plant, and their own look back after +/// Behind a potted plant: tg's own disguise (the plant held up in both hands), and their own name back when it is put down /datum/unit_test/voidcrew_bounty_ai/plant /datum/unit_test/voidcrew_bounty_ai/plant/Run() - var/mob/living/basic/bounty_criminal/meek/criminal = allocate(/mob/living/basic/bounty_criminal/meek, tile(1, 1)) + var/mob/living/carbon/human/npc/bounty_criminal/meek/criminal = allocate(/mob/living/carbon/human/npc/bounty_criminal/meek, tile(1, 1)) var/obj/item/kirbyplants/plant = allocate(/obj/item/kirbyplants, tile(2, 1)) - var/old_name = criminal.name - var/old_desc = criminal.desc - var/old_icon = criminal.icon - var/old_state = criminal.icon_state - var/old_layer = criminal.layer + var/old_name = criminal.get_visible_name() - TEST_ASSERT(criminal.ai_hide_in(plant), "The meek criminal would not pass as the plant beside them") + TEST_ASSERT(criminal.ai_hide_in(plant), "The meek criminal would not hide behind the plant beside them") TEST_ASSERT_EQUAL(criminal.loc, tile(2, 1), "They did not step onto the plant's tile") - TEST_ASSERT_EQUAL(plant.loc, criminal, "They did not take the plant") - TEST_ASSERT_EQUAL(criminal.name, plant.name, "They do not go by the plant's name") - TEST_ASSERT_EQUAL(criminal.desc, plant.desc, "They do not read as the plant") - TEST_ASSERT_EQUAL(criminal.icon, plant.icon, "They do not look like the plant") - TEST_ASSERT_EQUAL(criminal.icon_state, plant.icon_state, "They do not look like the plant") + TEST_ASSERT(criminal.is_holding(plant), "They are not holding the plant up") + TEST_ASSERT_EQUAL(criminal.get_visible_name(), plant.name, "Behind the plant, they don't go by the plant's name") + TEST_ASSERT_EQUAL(criminal.ai_hide_mode, "plant", "The wrong hiding mode") // BOUNTY_HIDE_PLANT // Someone touching the plant finds them var/mob/living/carbon/human/consistent/finder = allocate(/mob/living/carbon/human/consistent, tile(3, 1)) criminal.ai_touched_by(finder) TEST_ASSERT(!criminal.hidden, "Touching the plant did not find them") - TEST_ASSERT_EQUAL(criminal.name, old_name, "Their name did not come back") - TEST_ASSERT_EQUAL(criminal.desc, old_desc, "Their description did not come back") - TEST_ASSERT_EQUAL(criminal.icon, old_icon, "Their look did not come back") - TEST_ASSERT_EQUAL(criminal.icon_state, old_state, "Their look did not come back") - TEST_ASSERT_EQUAL(criminal.layer, old_layer, "Their layer did not come back") - TEST_ASSERT_EQUAL(plant.loc, tile(2, 1), "The plant was not put back") + TEST_ASSERT(!criminal.is_holding(plant), "Found, they still hold the plant") + TEST_ASSERT(isturf(plant.loc), "Found, the plant was not put down") + TEST_ASSERT_EQUAL(criminal.get_visible_name(), old_name, "Their own name did not come back") TEST_ASSERT(criminal.ai_has_grudge(finder), "The finder is not on their grudge list") + // Knocked out of their hands, the plant gives them away + criminal.ai_calm_down() + criminal.forceMove(get_turf(plant)) + TEST_ASSERT(criminal.ai_hide_in(plant), "They would not hide behind the plant a second time") + criminal.dropItemToGround(plant) + TEST_ASSERT(!criminal.hidden, "The plant left their hands, but they still count as hidden") + /// Picking a dark tile, standing in it faded, and a light finding them /datum/unit_test/voidcrew_bounty_ai/dark /datum/unit_test/voidcrew_bounty_ai/dark/Run() - var/mob/living/basic/bounty_criminal/meek/criminal = allocate(/mob/living/basic/bounty_criminal/meek, tile(2, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/meek/criminal = allocate(/mob/living/carbon/human/npc/bounty_criminal/meek, tile(2, 2)) var/turf/dark = tile(3, 3) // The test room is fullbright: mark one tile dark GLOB.bounty_ai_test_dark_turfs += dark @@ -109,19 +137,30 @@ /datum/unit_test/voidcrew_bounty_ai/hide_choice /datum/unit_test/voidcrew_bounty_ai/hide_choice/Run() - var/mob/living/basic/bounty_criminal/meek/criminal = allocate(/mob/living/basic/bounty_criminal/meek, tile(2, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/meek/criminal = allocate(/mob/living/carbon/human/npc/bounty_criminal/meek, tile(2, 2)) var/mob/living/carbon/human/consistent/hunter = allocate(/mob/living/carbon/human/consistent, tile(0, 2)) var/obj/structure/closet/near_hunter = allocate(/obj/structure/closet, tile(1, 3)) var/obj/structure/closet/far_side = allocate(/obj/structure/closet, tile(4, 2)) TEST_ASSERT_EQUAL(criminal.ai_pick_hide_spot(hunter), far_side, "They picked the locker by the hunter over the one away from them") TEST_ASSERT(near_hunter, "The test's locker was not made") -/// Cornered: the aim (hand, mark, message), and a stamina hit during it makes them fumble +/** + * Meek kit and cornering: they carry a real Makarov, a spare magazine and a stimpack, and a Slipwire + * implant; cornered, they shout, take the holdout out of their pocket and aim (the telegraph); a hit + * during the aim makes them fumble it; a clean aim fires real rounds, one trigger pull at a time. + */ /datum/unit_test/voidcrew_bounty_ai/cornered /datum/unit_test/voidcrew_bounty_ai/cornered/Run() - var/mob/living/basic/bounty_criminal/meek/criminal = allocate(/mob/living/basic/bounty_criminal/meek, tile(0, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/meek/criminal = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/meek, tile(0, 0)) var/mob/living/carbon/human/consistent/hunter = allocate(/mob/living/carbon/human/consistent, tile(1, 1)) + var/obj/item/gun/ballistic/automatic/pistol/holdout = criminal.ai_holdout() + TEST_ASSERT_NOTNULL(holdout, "The meek criminal carries no holdout pistol") + TEST_ASSERT(!criminal.is_holding(holdout), "The holdout is out before anything happened") + TEST_ASSERT(human_npc_gear_locked(holdout), "The holdout isn't locked to the body") + TEST_ASSERT_NOTNULL(carried(criminal, /obj/item/ammo_box/magazine/m9mm), "The meek criminal carries no spare magazine") + TEST_ASSERT_NOTNULL(carried(criminal, /obj/item/reagent_containers/hypospray/medipen/stimpack), "The meek criminal carries no stimpack") + TEST_ASSERT_NOTNULL(criminal.get_organ_by_type(/obj/item/organ/cyberimp/cyberware/slipwire), "The meek criminal has no Slipwire implant to dodge with") TEST_ASSERT(criminal.ai_ways_out(hunter) < 2, "In the corner with the hunter on them, they have [criminal.ai_ways_out(hunter)] ways out") // The first moment cornered: a warning, and no gun yet @@ -131,44 +170,57 @@ TEST_ASSERT(voice.last_line in lines["cornered"]["any"], "Cornered, they warned nobody ([voice.last_line || "nothing said"])") // The draw is said even inside the cooldown of that warning (BUG-2: draw_gun was never said) voice.last_line = null - criminal.ai_update_style() TEST_ASSERT(criminal.ai_start_aim(hunter), "Cornered, they did not aim") TEST_ASSERT(voice.last_line in lines["draw_gun"]["any"], "Drawing the holdout, they said [voice.last_line || "nothing"]") TEST_ASSERT(criminal.ai_aim_until > world.time, "The aim has no wind-up") - TEST_ASSERT_NOTNULL(criminal.ai_hand, "No gun in their hand while aiming") + TEST_ASSERT(criminal.is_holding(holdout), "The holdout is not in their hand while aiming") TEST_ASSERT(locate(/obj/effect/temp_visual/telegraphing/bounty_aim) in get_turf(hunter), "No aim mark on the hunter") - TEST_ASSERT(!HAS_TRAIT(criminal, "bounty_sprinting"), "Aiming, they still count as sprinting") // TRAIT_BOUNTY_SPRINTING + // A stamina hit during the aim: fumbled, and the gun goes back in the pocket criminal.adjustStaminaLoss(20) criminal.ai_aim_until = world.time TEST_ASSERT(!criminal.ai_fire_holdout(), "A stamina hit during the aim did not make them fumble") TEST_ASSERT(!criminal.ai_aim_until, "Still aiming after the fumble") - TEST_ASSERT_NULL(criminal.ai_hand, "The gun is still in their hand after the fumble") + TEST_ASSERT(!criminal.is_holding(holdout), "The gun is still in their hand after the fumble") TEST_ASSERT(criminal.ai_holdout_ready_at > world.time, "No cooldown after the fumble") - // Ready again, a clean aim fires + // Ready again, a clean aim fires: a real round leaves the real gun criminal.setStaminaLoss(0) criminal.ai_holdout_ready_at = 0 + criminal.next_click = 0 TEST_ASSERT(criminal.ai_start_aim(hunter), "They would not aim a second time") criminal.ai_aim_until = world.time + var/rounds = holdout.get_ammo(TRUE) + TEST_ASSERT(rounds >= 2, "Test fixture: the holdout holds [rounds] rounds") TEST_ASSERT(criminal.ai_fire_holdout(), "A clean aim did not fire") - TEST_ASSERT_EQUAL(criminal.ai_volley_left, 7, "After the first shot, seven of the volley should be left") // BOUNTY_MEEK_PISTOL_SHOTS - 1 - var/datum/component/ranged_attacks/gun = criminal.GetComponent(/datum/component/ranged_attacks) - TEST_ASSERT_NOTNULL(gun, "The meek criminal has no ranged_attacks component") - TEST_ASSERT_EQUAL(gun.projectile_type, /obj/projectile/bullet/bounty/holdout, "The holdout fires the wrong thing") - TEST_ASSERT(gun.cooldown_time < 5, "The holdout's gun is not ready between the volley's shots") // BOUNTY_MEEK_PISTOL_GAP - - // Cuffed or down mid-volley, the rest of it never comes - ADD_TRAIT(criminal, "bounty_held", "test") // TRAIT_BOUNTY_HELD - TEST_ASSERT(!criminal.ai_volley_shot(), "A held criminal fired the rest of the volley") + TEST_ASSERT_EQUAL(holdout.get_ammo(TRUE), rounds - 1, "The first pull of the volley did not fire a round from the gun") + TEST_ASSERT_EQUAL(criminal.ai_volley_left, min(8, rounds) - 1, "After the first pull, the rest of the volley should be left") // BOUNTY_MEEK_PISTOL_SHOTS + + // Cuffed mid-volley, the rest of it never comes + board_test_cuff(criminal) + TEST_ASSERT(criminal.is_restrained(), "Test fixture: the cuffs did not go on") + TEST_ASSERT(!criminal.ai_volley_shot(), "A cuffed criminal fired the rest of the volley") TEST_ASSERT(!criminal.ai_volley_left, "The volley was not cut short") - REMOVE_TRAIT(criminal, "bounty_held", "test") -/// A normal criminal notices someone armed, fights when they close in, and surrenders +/// A meek criminal winded by real stamina loss says so, once +/datum/unit_test/voidcrew_bounty_ai/winded + +/datum/unit_test/voidcrew_bounty_ai/winded/Run() + var/mob/living/carbon/human/npc/bounty_criminal/meek/criminal = allocate(/mob/living/carbon/human/npc/bounty_criminal/meek, tile(2, 2)) + criminal.ai_check_winded() + TEST_ASSERT(!criminal.ai_winded, "Fresh, they count as winded") + criminal.adjustStaminaLoss(50) + criminal.ai_check_winded() + TEST_ASSERT(criminal.ai_winded, "Worn out by real stamina loss, they are not winded") + criminal.setStaminaLoss(0) + criminal.ai_check_winded() + TEST_ASSERT(!criminal.ai_winded, "Rested, they are still winded") + +/// A normal criminal notices someone armed, fights when they close in, and gives up through tg's *surrender /datum/unit_test/voidcrew_bounty_ai/normal /datum/unit_test/voidcrew_bounty_ai/normal/Run() - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(/mob/living/basic/bounty_criminal/normal, tile(1, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(1, 2), "brawler") // BOUNTY_STYLE_BRAWLER var/mob/living/carbon/human/consistent/hunter = allocate(/mob/living/carbon/human/consistent, tile(3, 2)) var/obj/item/knife/kitchen/knife = allocate(/obj/item/knife/kitchen) hunter.put_in_hands(knife) @@ -181,162 +233,207 @@ criminal.ai_notice(hunter) TEST_ASSERT_EQUAL(criminal.ai_mode, "fighting", "Someone armed two tiles off did not start the fight") // BOUNTY_AI_FIGHTING TEST_ASSERT(criminal.ai_has_grudge(hunter), "The armed hunter is not on their grudge list") - TEST_ASSERT_EQUAL(criminal.ai_controller.blackboard["bb_bounty_style"], "brawler", "With no record, they did not fight as a brawler") // BB_BOUNTY_STYLE, BOUNTY_STYLE_BRAWLER + TEST_ASSERT_EQUAL(criminal.ai_controller.blackboard["bb_bounty_style"], "brawler", "They did not fight as a brawler") // BB_BOUNTY_STYLE, BOUNTY_STYLE_BRAWLER TEST_ASSERT_EQUAL(criminal.ai_controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET], hunter, "They are not targeting the hunter") TEST_ASSERT_EQUAL(criminal.ai_pick_fight_target(), hunter, "In the fight, they do not pick the hunter from their grudge list") + TEST_ASSERT_EQUAL(criminal.move_intent, MOVE_INTENT_RUN, "In a fight, they walk") // One companion standing: less chance to give up - var/list/buddies = criminal.spawn_companions(1) + var/list/buddies = criminal.spawn_companions(1, TRUE) + TEST_ASSERT_EQUAL(length(buddies), 1, "Test fixture: no companion was made") TEST_ASSERT_EQUAL(criminal.ai_surrender_chance(), 40, "One standing companion should take the chance from 60 to 40") // BOUNTY_SURRENDER_CHANCE - BOUNTY_SURRENDER_PER_COMPANION QDEL_LIST(buddies) TEST_ASSERT_EQUAL(criminal.ai_surrender_chance(), 60, "With no companion the chance should be 60") // BOUNTY_SURRENDER_CHANCE - // Giving up is said even right after another line, inside the cooldown (BUG-1) + // Giving up: tg's *surrender (a real paralysis, the cuff window), said even right after another line (BUG-1) var/datum/component/bounty_identity_voice/voice = criminal.LoadComponent(/datum/component/bounty_identity_voice) COOLDOWN_START(voice, line_cooldown, 8 SECONDS) // BOUNTY_SAY_COOLDOWN voice.last_line = null - criminal.ai_surrender() + TEST_ASSERT(criminal.ai_surrender(), "The criminal would not give up") TEST_ASSERT(voice.last_line in bounty_identity_strings("lines")["surrender"]["any"], "Giving up, they said [voice.last_line || "nothing"]") - TEST_ASSERT(HAS_TRAIT(criminal, "bounty_surrendered"), "Surrendering did not set the trait") // TRAIT_BOUNTY_SURRENDERED + TEST_ASSERT(criminal.npc_surrendering && criminal.IsParalyzed(), "Giving up is not tg's *surrender") + TEST_ASSERT_EQUAL(criminal.capture_state(), "stunned", "A criminal lying there with its hands on its head is not stunned") // BOUNTY_STATE_STUNNED TEST_ASSERT(!criminal.ai_can_act(), "A surrendered criminal can still act") - TEST_ASSERT_NOTNULL(criminal.ai_over_head, "No hands-up mark over a surrendered criminal") TEST_ASSERT_NULL(criminal.ai_controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET], "A surrendered criminal kept a target") var/datum/ai_controller/basic_controller/bounty/brain = criminal.ai_controller TEST_ASSERT(!brain.may_shoot(hunter), "A surrendered criminal may still shoot") TEST_ASSERT(!brain.may_strike(hunter), "A surrendered criminal may still hit") - // Hitting them afterwards does not undo it - criminal.ai_attacked_by(hunter) - TEST_ASSERT(HAS_TRAIT(criminal, "bounty_surrendered"), "A hit undid the surrender") // TRAIT_BOUNTY_SURRENDERED + TEST_ASSERT(locate(/datum/ai_planning_subtree/human_npc_surrender) in brain.planning_subtrees, "The normal criminal's tree never gives up") + var/datum/human_npc_surrender/rules = criminal.npc_surrender_rules() + TEST_ASSERT(istype(rules, /datum/human_npc_surrender/bounty), "The normal criminal gives up by the wrong rules") -/// Styles: each carries a real weapon; the pistol reloads through the Stechkin's magazine, the club is a bat, fists are a punch +/** + * Every style is a real item they carry, not hold, until the fight: the pistol in a holster with a spare + * magazine, the shotgun on the back with shells on a bandolier, the knife in a pocket, bottles in a bag, + * the bat in hand (it has nowhere else to go), fists for a brawler. A bruise pack for treating themselves. + * The tier picks the weapon (a combat knife, a combat shotgun) and the armour; it never scales them. + */ /datum/unit_test/voidcrew_bounty_ai/styles /datum/unit_test/voidcrew_bounty_ai/styles/Run() - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(/mob/living/basic/bounty_criminal/normal, tile(1, 1)) - TEST_ASSERT(bounty_ai_apply_style(criminal, "pistol"), "The pistol style would not apply") // BOUNTY_STYLE_PISTOL - var/datum/component/ranged_attacks/gun = criminal.GetComponent(/datum/component/ranged_attacks) - TEST_ASSERT_EQUAL(gun.projectile_type, /obj/projectile/bullet/bounty, "The pistol fires the wrong thing") - TEST_ASSERT_EQUAL(criminal.ai_controller.blackboard["bb_bounty_weapon"], /obj/item/gun/ballistic/automatic/pistol/aps, "The pistol style isn't the Stechkin") // BB_BOUNTY_WEAPON - var/obj/item/ammo_box/magazine/m9mm_aps/magazine = /obj/item/ammo_box/magazine/m9mm_aps - var/rounds = initial(magazine.max_ammo) - TEST_ASSERT_EQUAL(criminal.ai_controller.blackboard["bb_bounty_ammo"], rounds, "The pistol's magazine isn't a full Stechkin magazine") // BB_BOUNTY_AMMO - var/datum/bounty_style/pistol = bounty_ai_style(criminal) - for(var/shot in 1 to rounds) - pistol.after_shot(criminal) - TEST_ASSERT_EQUAL(criminal.ai_controller.blackboard["bb_bounty_ammo"], 0, "A magazine's worth of shots did not empty the magazine") // BB_BOUNTY_AMMO - TEST_ASSERT(bounty_style_health_mult("brawler") > 1, "The brawler is not sturdier") // BOUNTY_STYLE_BRAWLER - - // The club is a baseball bat; a Wanted criminal's is the metal one. The tier picks the bat, never scales it. - var/obj/item/melee/baseball_bat/bat = /obj/item/melee/baseball_bat - var/obj/item/melee/baseball_bat/ablative/metal_bat = /obj/item/melee/baseball_bat/ablative - TEST_ASSERT(bounty_ai_apply_style(criminal, "club"), "The club style would not apply") // BOUNTY_STYLE_CLUB - TEST_ASSERT_EQUAL(criminal.melee_damage_upper, initial(bat.force), "The club doesn't hit like a baseball bat") - TEST_ASSERT_EQUAL(criminal.wound_bonus, initial(bat.wound_bonus), "The club doesn't wound like a baseball bat") - TEST_ASSERT(bounty_ai_apply_style(criminal, "club", TRUE), "The heavy club style would not apply") - TEST_ASSERT_EQUAL(criminal.melee_damage_upper, initial(metal_bat.force), "A Wanted criminal's club doesn't hit like a metal bat") - - // Bare fists are a human's punch - var/obj/item/bodypart/arm/right/arm = /obj/item/bodypart/arm/right - TEST_ASSERT(bounty_ai_apply_style(criminal, "brawler"), "The brawler style would not apply") // BOUNTY_STYLE_BRAWLER - TEST_ASSERT_EQUAL(criminal.melee_damage_lower, initial(arm.unarmed_damage_low), "A brawler's weakest punch isn't a human's") - TEST_ASSERT_EQUAL(criminal.melee_damage_upper, initial(arm.unarmed_damage_high), "A brawler's hardest punch isn't a human's") - TEST_ASSERT_NULL(criminal.ai_controller.blackboard["bb_bounty_weapon"], "A brawler has something in their hand") // BB_BOUNTY_WEAPON - -/// Their weapons are the real thing: a pistol's shot is a 9mm round, a shotgun fires a whole shell of buckshot, a knife cuts like a knife + var/mob/living/carbon/human/npc/bounty_criminal/normal/pistol = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(0, 0), "pistol") // BOUNTY_STYLE_PISTOL + var/obj/item/gun/ballistic/automatic/pistol/aps/stechkin = carried(pistol, /obj/item/gun/ballistic/automatic/pistol/aps) + TEST_ASSERT_NOTNULL(stechkin, "The pistol criminal carries no Stechkin") + TEST_ASSERT(!pistol.is_holding(stechkin), "The Stechkin is in hand before the fight") + TEST_ASSERT(istype(stechkin.loc, /obj/item/storage/belt/holster), "The Stechkin isn't in a holster") + TEST_ASSERT_NOTNULL(carried(pistol, /obj/item/ammo_box/magazine/m9mm_aps), "The pistol criminal carries no spare magazine") + TEST_ASSERT_NOTNULL(carried(pistol, /obj/item/stack/medical/bruise_pack), "The criminal carries nothing to treat themselves with") + var/datum/bounty_style/pistol_style = bounty_ai_style(pistol) + TEST_ASSERT_EQUAL(pistol_style?.carried_ranged(pistol), stechkin, "The pistol style would not draw the holstered Stechkin") + TEST_ASSERT(human_npc_take_in_hand(pistol, stechkin), "The Stechkin can't be drawn") + TEST_ASSERT_EQUAL(pistol_style.ready_in_hand(pistol), stechkin, "The drawn Stechkin isn't ready to fire") + + var/mob/living/carbon/human/npc/bounty_criminal/normal/shotgunner = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(1, 0), "shotgun") // BOUNTY_STYLE_SHOTGUN + TEST_ASSERT(istype(shotgunner.back, /obj/item/gun/ballistic/shotgun/lethal), "A petty shotgun criminal has no pump shotgun on the back") + TEST_ASSERT(istype(shotgunner.belt, /obj/item/storage/belt/bandolier), "The shotgun criminal has no bandolier") + var/shells = length(shotgunner.belt.get_all_contents_type(/obj/item/ammo_casing/shotgun/buckshot)) + TEST_ASSERT_EQUAL(shells, 8, "The bandolier holds [shells] buckshot shells") // BOUNTY_SHOTGUN_SHELLS + + var/mob/living/carbon/human/npc/bounty_criminal/normal/heavy = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(2, 0), "shotgun", 2) // BOUNTY_STYLE_SHOTGUN, BOUNTY_TIER_WANTED + var/obj/item/gun/ballistic/shotgun/automatic/combat/combat = heavy.back + TEST_ASSERT(istype(combat), "A Wanted shotgun criminal has no combat shotgun") + TEST_ASSERT(istype(combat.chambered, /obj/item/ammo_casing/shotgun/buckshot), "The Wanted criminal's combat shotgun isn't loaded with buckshot") + TEST_ASSERT(istype(heavy.wear_suit, /obj/item/clothing/suit/armor/vest), "A Wanted criminal wears no armour vest") + + var/mob/living/carbon/human/npc/bounty_criminal/normal/knifer = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(3, 0), "knife") // BOUNTY_STYLE_KNIFE + var/obj/item/knife/blade = carried(knifer, /obj/item/knife) + TEST_ASSERT_NOTNULL(blade, "The knife criminal carries no knife") + TEST_ASSERT(!knifer.is_holding(blade), "The knife is out before the fight") + var/mob/living/carbon/human/npc/bounty_criminal/normal/wanted_knifer = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(4, 0), "knife", 2) // BOUNTY_STYLE_KNIFE, BOUNTY_TIER_WANTED + TEST_ASSERT_NOTNULL(carried(wanted_knifer, /obj/item/knife/combat), "A Wanted knife criminal carries no combat knife") + + var/mob/living/carbon/human/npc/bounty_criminal/normal/clubber = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(0, 1), "club") // BOUNTY_STYLE_CLUB + var/obj/item/melee/baseball_bat/bat = carried(clubber, /obj/item/melee/baseball_bat) + TEST_ASSERT(bat && clubber.is_holding(bat), "The club criminal holds no baseball bat") + + var/mob/living/carbon/human/npc/bounty_criminal/normal/thrower = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(1, 1), "bottle") // BOUNTY_STYLE_BOTTLE + var/list/bottles = thrower.get_all_contents_type(/obj/item/reagent_containers/cup/glass/bottle/beer) + TEST_ASSERT_EQUAL(length(bottles), 4, "A petty bottle thrower carries [length(bottles)] bottles") // BOUNTY_BOTTLES_PETTY + var/obj/item/reagent_containers/cup/glass/bottle/beer/bottle = bottles[1] + TEST_ASSERT(human_npc_gear_consumable(bottle), "The bottles aren't consumables that may leave the body") + + var/mob/living/carbon/human/npc/bounty_criminal/normal/brawler = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(2, 1), "brawler") // BOUNTY_STYLE_BRAWLER + TEST_ASSERT_NULL(carried(brawler, /obj/item/gun), "A brawler carries a gun") + TEST_ASSERT_NULL(carried(brawler, /obj/item/knife), "A brawler carries a knife") + TEST_ASSERT_EQUAL(brawler.npc_damage_taken, 1, "A petty criminal takes other than a person's damage") // BOUNTY_TOUGHNESS_PETTY + +/** + * Real weapons used for real: the shotgun's pump is its telegraph, a hit during it fumbles the blast, a + * clean blast fires the chambered shell; a bottle leaves the hand in a real throw; a knife cuts; a + * brawler's shove is a real shove; nobody fires through their own gang. + */ /datum/unit_test/voidcrew_bounty_ai/real_weapons - /// How many projectiles the criminal fired (counted, never kept: they fly off and are deleted) - var/shots_fired = 0 - /// The last hit the hunter took: damage, sharpness, wound bonus, exposed wound bonus + /// The last hit the hunter took: damage, sharpness var/list/last_hit + /// How many times the hunter was shoved + var/shoves = 0 -/datum/unit_test/voidcrew_bounty_ai/real_weapons/proc/on_fired(datum/source, obj/projectile/shot, atom/fired_from, atom/original) +/datum/unit_test/voidcrew_bounty_ai/real_weapons/proc/on_hit(datum/source, damage, damagetype, def_zone, blocked, wound_bonus, exposed_wound_bonus, sharpness, attack_direction, attacking_item) SIGNAL_HANDLER - shots_fired++ + last_hit = list(damage, sharpness) -/datum/unit_test/voidcrew_bounty_ai/real_weapons/proc/on_hit(datum/source, damage, damagetype, def_zone, blocked, wound_bonus, exposed_wound_bonus, sharpness, attack_direction, attacking_item) +/datum/unit_test/voidcrew_bounty_ai/real_weapons/proc/on_shoved(datum/source, mob/living/shover, zone, obj/item/weapon) SIGNAL_HANDLER - last_hit = list(damage, sharpness, wound_bonus, exposed_wound_bonus) + shoves++ /datum/unit_test/voidcrew_bounty_ai/real_weapons/Run() - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(/mob/living/basic/bounty_criminal/normal, tile(1, 2)) - var/mob/living/carbon/human/consistent/hunter = allocate(/mob/living/carbon/human/consistent, tile(2, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(1, 2), "shotgun") // BOUNTY_STYLE_SHOTGUN + var/mob/living/carbon/human/consistent/hunter = allocate(/mob/living/carbon/human/consistent, tile(3, 2)) criminal.ai_add_grudge(hunter) - RegisterSignal(criminal, COMSIG_PROJECTILE_FIRER_BEFORE_FIRE, PROC_REF(on_fired)) - RegisterSignal(hunter, COMSIG_MOB_APPLY_DAMAGE, PROC_REF(on_hit)) + var/datum/ai_controller/controller = criminal.ai_controller + var/datum/bounty_style/style = bounty_ai_style(criminal) + var/obj/item/gun/ballistic/shotgun/gun = criminal.back + TEST_ASSERT(istype(gun), "Test fixture: no shotgun on their back") + TEST_ASSERT(human_npc_take_in_hand(criminal, gun), "The shotgun can't be drawn off their back") + TEST_ASSERT_EQUAL(style.ready_in_hand(criminal), gun, "The drawn shotgun isn't ready") + TEST_ASSERT_NOTNULL(gun.chambered?.loaded_projectile, "Test fixture: the shotgun has no shell chambered") + + // The pump is the telegraph: no blast on the first step + TEST_ASSERT(!style.windup_step(criminal, controller, hunter, gun), "The shotgun fired with no pump first") + TEST_ASSERT(controller.blackboard["bb_bounty_windup_until"], "No wind-up began") // BB_BOUNTY_WINDUP_UNTIL + // A hit during it: fumbled + controller.set_blackboard_key("bb_bounty_hit_at", world.time) // BB_BOUNTY_HIT_AT + controller.set_blackboard_key("bb_bounty_windup_until", world.time) // BB_BOUNTY_WINDUP_UNTIL + TEST_ASSERT(!style.windup_step(criminal, controller, hunter, gun), "A hit during the pump did not spoil the blast") + TEST_ASSERT(controller.blackboard["bb_bounty_next_shot"] > world.time, "A fumble did not hold the next blast back") // BB_BOUNTY_NEXT_SHOT + // Clean: the chambered shell is fired, the player's way + controller.clear_blackboard_key("bb_bounty_hit_at") // BB_BOUNTY_HIT_AT + TEST_ASSERT(!style.windup_step(criminal, controller, hunter, gun), "The shotgun fired with no pump first") + controller.set_blackboard_key("bb_bounty_windup_until", world.time) // BB_BOUNTY_WINDUP_UNTIL + TEST_ASSERT(style.windup_step(criminal, controller, hunter, gun), "A clean pump did not let the blast go") + criminal.next_click = 0 + TEST_ASSERT(style.attack(criminal, controller, hunter, gun), "The blast didn't go") + TEST_ASSERT_NULL(gun.chambered?.loaded_projectile, "The blast did not fire the chambered shell") + TEST_ASSERT(bounty_ai_gun_ready(gun, TRUE), "A pump shotgun with shells in its tube isn't ready for the next pump") + + // Nobody fires through their own gang + var/list/buddies = criminal.spawn_companions(1, TRUE) + var/mob/living/carbon/human/npc/bounty_companion/buddy = buddies[1] + buddy.forceMove(tile(2, 2)) + TEST_ASSERT(bounty_ai_line_blocked(criminal, hunter), "A companion in the line of fire doesn't block the shot") + buddy.forceMove(tile(0, 4)) + TEST_ASSERT(!bounty_ai_line_blocked(criminal, hunter), "A clear line of fire counts as blocked") + QDEL_LIST(buddies) - // The pistol: the Stechkin's 9mm round, wounds and embedding and all - var/obj/projectile/bullet/c9mm/nine = /obj/projectile/bullet/c9mm - TEST_ASSERT(bounty_ai_apply_style(criminal, "pistol"), "The pistol style would not apply") // BOUNTY_STYLE_PISTOL - var/obj/projectile/bullet/bounty/bullet = fire_at(criminal, hunter) - TEST_ASSERT_EQUAL(shots_fired, 1, "A pistol shot fired [shots_fired] projectiles") - TEST_ASSERT_EQUAL(bullet.damage, initial(nine.damage), "A pistol shot doesn't do a 9mm round's damage") - TEST_ASSERT_EQUAL(bullet.wound_bonus, initial(nine.wound_bonus), "A pistol shot doesn't wound like a 9mm round") - TEST_ASSERT_EQUAL(bullet.armour_penetration, initial(nine.armour_penetration), "A pistol shot doesn't pierce armour like a 9mm round") - TEST_ASSERT_EQUAL(bullet.sharpness, initial(nine.sharpness), "A pistol shot isn't as sharp as a 9mm round") - TEST_ASSERT_EQUAL(bullet.embed_type, initial(nine.embed_type), "A pistol shot doesn't embed like a 9mm round") - TEST_ASSERT_NOTNULL(bullet.get_embed(), "A pistol shot can't embed") - TEST_ASSERT_NOTNULL(bullet.shrapnel_type, "A pistol shot leaves nothing to embed") - - // The shotgun: every pellet of a buckshot shell, one shell from the tube - var/obj/item/ammo_casing/shotgun/buckshot/shell = /obj/item/ammo_casing/shotgun/buckshot - var/obj/projectile/bullet/pellet/shotgun_buckshot/pellet = /obj/projectile/bullet/pellet/shotgun_buckshot - TEST_ASSERT(bounty_ai_apply_style(criminal, "shotgun"), "The shotgun style would not apply") // BOUNTY_STYLE_SHOTGUN - shots_fired = 0 - var/obj/projectile/bullet/bounty/first_pellet = fire_at(criminal, hunter) - TEST_ASSERT_EQUAL(shots_fired, initial(shell.pellets), "A shotgun blast wasn't a whole shell of buckshot") - TEST_ASSERT_EQUAL(first_pellet.damage, initial(pellet.damage), "A pellet doesn't do buckshot's damage") - TEST_ASSERT_EQUAL(first_pellet.sharpness, initial(pellet.sharpness), "A pellet isn't as sharp as buckshot") - var/datum/bounty_style/shotgun = bounty_ai_style(criminal) - shotgun.after_shot(criminal) - var/obj/item/ammo_box/magazine/internal/shot/tube = /obj/item/ammo_box/magazine/internal/shot - TEST_ASSERT_EQUAL(criminal.ai_controller.blackboard["bb_bounty_ammo"], initial(tube.max_ammo) - 1, "A blast took more than one shell") // BB_BOUNTY_AMMO - // A Wanted criminal's combat shotgun hits harder, as the real one does - var/obj/item/gun/ballistic/shotgun/automatic/combat/combat = /obj/item/gun/ballistic/shotgun/automatic/combat - var/datum/bounty_real_weapon/heavy = bounty_real_weapon(/obj/item/gun/ballistic/shotgun/automatic/combat, /obj/item/ammo_casing/shotgun/buckshot) - TEST_ASSERT_EQUAL(heavy.round_damage, initial(pellet.damage) * initial(combat.projectile_damage_multiplier), "The combat shotgun's pellets don't take its damage multiplier") - - // The knife: a kitchen knife's force, edge and wounds, through the mob's own blow - var/obj/item/knife/kitchen/knife = /obj/item/knife/kitchen - TEST_ASSERT(bounty_ai_apply_style(criminal, "knife"), "The knife style would not apply") // BOUNTY_STYLE_KNIFE + // A bottle, thrown for real: it leaves the hand + var/mob/living/carbon/human/npc/bounty_criminal/normal/thrower = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(1, 4), "bottle") // BOUNTY_STYLE_BOTTLE + var/datum/bounty_style/bottle_style = bounty_ai_style(thrower) + var/obj/item/reagent_containers/cup/glass/bottle/bottle = bottle_style.carried_ranged(thrower) + TEST_ASSERT_NOTNULL(bottle, "The bottle thrower has no bottle to draw") + TEST_ASSERT(human_npc_take_in_hand(thrower, bottle), "A bottle can't be drawn from the bag") + TEST_ASSERT(bottle_style.attack(thrower, thrower.ai_controller, hunter, bottle), "The bottle wasn't thrown") + TEST_ASSERT(!thrower.is_holding(bottle), "The thrown bottle is still in their hand") + TEST_ASSERT(!thrower.throw_mode, "Throw mode was left on after the throw") + + // A knife cuts, through the body's own blow + RegisterSignal(hunter, COMSIG_MOB_APPLY_DAMAGE, PROC_REF(on_hit)) + var/mob/living/carbon/human/npc/bounty_criminal/normal/knifer = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(4, 2), "knife") // BOUNTY_STYLE_KNIFE + knifer.ai_add_grudge(hunter) + var/obj/item/knife/blade = carried(knifer, /obj/item/knife) + TEST_ASSERT(human_npc_take_in_hand(knifer, blade) && human_npc_ready_item(knifer, blade), "The knife can't be drawn") last_hit = null - TEST_ASSERT(criminal.melee_attack(hunter, ignore_cooldown = TRUE), "The knife didn't land") - TEST_ASSERT_NOTNULL(last_hit, "The knife hit did no damage") - TEST_ASSERT_EQUAL(last_hit[1], initial(knife.force), "A knife hit doesn't do the kitchen knife's force") - TEST_ASSERT_EQUAL(last_hit[2], SHARP_EDGED, "A knife hit isn't edged") - TEST_ASSERT_EQUAL(last_hit[3], initial(knife.wound_bonus), "A knife hit doesn't wound like the kitchen knife") - TEST_ASSERT_EQUAL(last_hit[4], initial(knife.exposed_wound_bonus), "A knife hit doesn't wound bare skin like the kitchen knife") - -/// Loads a shot from `criminal` at `target` as it leaves the gun, as the ranged_attacks component's shot does, and returns it -/datum/unit_test/voidcrew_bounty_ai/real_weapons/proc/fire_at(mob/living/basic/bounty_criminal/criminal, mob/living/target) - var/datum/bounty_style/style = bounty_ai_style(criminal) - var/obj/projectile/bullet/bounty/shot = allocate(style.projectile_type, get_turf(criminal)) - shot.firer = criminal - shot.fired_from = criminal - shot.original = target - SEND_SIGNAL(criminal, COMSIG_PROJECTILE_FIRER_BEFORE_FIRE, shot, criminal, target) - return shot - -/// Every activity kind starts with its anchor in place + knifer.next_click = 0 + knifer.ai_controller.ai_interact(target = hunter, combat_mode = TRUE) + TEST_ASSERT_NOTNULL(last_hit, "The knife did no damage") + TEST_ASSERT_EQUAL(last_hit[2], SHARP_EDGED, "A knife's cut isn't edged") + + // A brawler's shove is a right click with an empty hand + RegisterSignal(hunter, COMSIG_LIVING_DISARM_HIT, PROC_REF(on_shoved)) + var/mob/living/carbon/human/npc/bounty_criminal/normal/brawler = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(4, 3), "brawler") // BOUNTY_STYLE_BRAWLER + brawler.forceMove(get_step(hunter, NORTH)) + TEST_ASSERT(human_npc_ready_empty_hand(brawler), "Test fixture: the brawler has no free hand") + brawler.next_click = 0 + brawler.next_move = 0 + brawler.ai_controller.ai_interact(target = hunter, combat_mode = TRUE, modifiers = list("right" = TRUE)) // RIGHT_CLICK + TEST_ASSERT_EQUAL(shoves, 1, "The brawler's shove didn't shove") + +/// Every activity kind starts with its anchor in place; the bar is a real seat and a real glass, really drunk from /datum/unit_test/voidcrew_bounty_ai/activities /datum/unit_test/voidcrew_bounty_ai/activities/Run() - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(/mob/living/basic/bounty_criminal/normal, tile(1, 1)) + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(1, 1), "brawler") // BOUNTY_STYLE_BRAWLER var/obj/structure/chair/stool/stool = allocate(/obj/structure/chair/stool, tile(2, 2)) var/obj/structure/table/table = allocate(/obj/structure/table, tile(3, 2)) - // bar: the stool, sitting, a drink; put away, the drink goes on the table + // bar: the stool, sitting (a buckle), a glass in hand, a real sip; put away, the glass goes on the table var/datum/bounty_activity/activity = criminal.start_activity("bar", stool) // BOUNTY_ACTIVITY_BAR TEST_ASSERT(istype(activity, /datum/bounty_activity/bar), "The bar activity did not start") TEST_ASSERT_EQUAL(activity.spot, get_turf(stool), "The bar activity is not headed for the stool") criminal.forceMove(get_turf(stool)) criminal.ai_activity_step(1) TEST_ASSERT_EQUAL(criminal.buckled, stool, "At the bar, they did not sit on the stool") - TEST_ASSERT_NOTNULL(criminal.ai_drink, "At the bar, they have no drink") - TEST_ASSERT_NOTNULL(criminal.ai_hand, "At the bar, the drink is not in their hand") - var/obj/item/glass = criminal.ai_drink + var/obj/item/reagent_containers/cup/glass/drinkingglass/glass = criminal.ai_drink + TEST_ASSERT_NOTNULL(glass, "At the bar, they have no drink") + TEST_ASSERT(criminal.is_holding(glass), "At the bar, the glass is not in their hand") + var/before = glass.reagents.total_volume + TEST_ASSERT(criminal.ai_sip(), "They would not drink") + TEST_ASSERT(glass.reagents.total_volume < before, "A sip left the glass as full as it was") + // A drink goes into the stomach first, as anyone's does, and into the blood as it digests + var/obj/item/organ/stomach/belly = criminal.get_organ_slot(ORGAN_SLOT_STOMACH) + TEST_ASSERT((belly?.reagents?.total_volume || 0) + criminal.reagents.total_volume > 0, "A sip put nothing in them") criminal.ai_suspend_activity() TEST_ASSERT_NULL(criminal.buckled, "Done at the bar, they are still sitting") - TEST_ASSERT_EQUAL(glass.loc, get_turf(table), "Done at the bar, the drink was not put down on the table") + TEST_ASSERT_EQUAL(glass.loc, get_turf(table), "Done at the bar, the glass was not put down on the table") TEST_ASSERT_EQUAL(criminal.ai_activity_kind, "bar", "Putting the activity away forgot what it was") // BOUNTY_ACTIVITY_BAR qdel(glass) criminal.forceMove(tile(1, 1)) @@ -362,7 +459,7 @@ TEST_ASSERT(length(exploring.points) >= 1, "Exploring, they found nothing to look at") // chat: with a companion - var/list/buddies = criminal.spawn_companions(1) + var/list/buddies = criminal.spawn_companions(1, TRUE) activity = criminal.start_activity("chat", buddies[1]) // BOUNTY_ACTIVITY_CHAT TEST_ASSERT(istype(activity, /datum/bounty_activity/chat), "The chat activity did not start") var/datum/bounty_activity/chat/talking = activity @@ -370,7 +467,7 @@ criminal.ai_end_activity() QDEL_LIST(buddies) - // camp: a fire (or a fixed lamp), a mattress and a crate around the spot + // camp: a fire (or a fixed lamp), a mattress and a crate around the spot; sat at on the ground (tg's resting) activity = criminal.start_activity("camp", tile(2, 3)) // BOUNTY_ACTIVITY_CAMP TEST_ASSERT(istype(activity, /datum/bounty_activity/camp), "The camp activity did not start") var/atom/movable/fire = criminal.ai_camp_fire() @@ -378,42 +475,74 @@ TEST_ASSERT(fire.density || fire.anchored, "The camp's fire can be walked through, or its lamp carried off") var/list/camp = criminal.ai_camp.Copy() TEST_ASSERT_EQUAL(criminal.ai_make_camp(tile(2, 3)), fire, "A second camp was made") + criminal.ai_crouch() + TEST_ASSERT(criminal.resting, "Sitting down at the camp isn't tg's resting") + criminal.ai_stand_up() + TEST_ASSERT(!criminal.resting, "Getting up from the camp left them resting") criminal.ai_end_activity() for(var/datum/weakref/ref as anything in camp) qdel(ref.resolve()) - // blend: a patron now + // blend: a patron now, at a walk activity = criminal.start_activity("blend", stool) // BOUNTY_ACTIVITY_BLEND TEST_ASSERT(istype(activity, /datum/bounty_activity/blend), "The blend activity did not start") TEST_ASSERT(criminal.blended, "Blending in did not make them a patron") + TEST_ASSERT_EQUAL(criminal.move_intent, MOVE_INTENT_WALK, "Blended in, they don't walk") criminal.start_activity(null) TEST_ASSERT(!criminal.blended, "Stopping the blend left them a patron") -/// Companions spawn beside their criminal, fight in their style, and delete cleanly in any order +/** + * Companions are made through the human NPC spawn queue (or at once for a test), join their criminal, + * fight in their style with the real weapon they carry, give up through tg's *surrender, and delete + * cleanly in any order. + */ /datum/unit_test/voidcrew_bounty_ai/companions /datum/unit_test/voidcrew_bounty_ai/companions/Run() - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(/mob/living/basic/bounty_criminal/normal, tile(2, 2)) - var/list/buddies = criminal.spawn_companions(5) + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(2, 2), "brawler") // BOUNTY_STYLE_BRAWLER + // Queued, a companion is not there yet + var/datum/human_npc_order/order = bounty_spawn_companion(criminal, tile(1, 1)) + TEST_ASSERT_NOTNULL(order, "No companion was queued") + TEST_ASSERT_NULL(order.spawned_ref?.resolve(), "A queued companion was made at once") + qdel(order) + + var/list/buddies = criminal.spawn_companions(5, TRUE) TEST_ASSERT_EQUAL(length(buddies), 2, "Asked for five, [length(buddies)] companions came; the most is two") // BOUNTY_COMPANIONS_MAX TEST_ASSERT_EQUAL(length(criminal.ai_companions()), 2, "The criminal does not know its companions") - for(var/mob/living/basic/bounty_companion/buddy as anything in buddies) + for(var/mob/living/carbon/human/npc/bounty_companion/buddy as anything in buddies) TEST_ASSERT_EQUAL(buddy.ai_leader(), criminal, "A companion does not know its criminal") TEST_ASSERT(get_dist(buddy, criminal) <= 2, "A companion spawned too far off") TEST_ASSERT_NOTNULL(buddy.ai_controller.blackboard["bb_bounty_style"], "A companion has no style") // BB_BOUNTY_STYLE + TEST_ASSERT_EQUAL(buddy.ai_controller.blackboard["bb_bounty_style"], buddy.ai_style, "A companion fights in another style than it was dressed for") // BB_BOUNTY_STYLE TEST_ASSERT(bounty_ai_same_gang(buddy, criminal), "A companion is not on its criminal's side") TEST_ASSERT(!length(buddy.faction - criminal.faction) && !length(criminal.faction - buddy.faction), "A companion does not share its criminal's faction") + TEST_ASSERT_EQUAL(buddy.npc_damage_taken, 1, "A companion takes other than a person's damage") + var/datum/bounty_style/style = GLOB.bounty_styles[buddy.ai_style] + if(style.weapon_type) + TEST_ASSERT_NOTNULL(bounty_ai_carried(buddy, style.weapon_type), "A [buddy.ai_style] companion doesn't carry its weapon") // Called into a fight var/mob/living/carbon/human/consistent/hunter = allocate(/mob/living/carbon/human/consistent, tile(4, 4)) criminal.ai_rally_companions(hunter) - var/mob/living/basic/bounty_companion/first = buddies[1] + var/mob/living/carbon/human/npc/bounty_companion/first = buddies[1] TEST_ASSERT(hunter in first.ai_controller.blackboard[BB_BASIC_MOB_RETALIATE_LIST], "Rallied, a companion did not take the hunter on") + TEST_ASSERT_EQUAL(first.move_intent, MOVE_INTENT_RUN, "In the fight, a companion walks") + + // A companion gives up the way its criminal does: tg's *surrender + var/mob/living/carbon/human/npc/bounty_companion/second = buddies[2] + TEST_ASSERT(istype(second.npc_surrender_rules(), /datum/human_npc_surrender/bounty), "A companion gives up by the wrong rules") + TEST_ASSERT(second.npc_surrender(), "A companion would not give up") + TEST_ASSERT(second.IsParalyzed() && !second.ai_can_fight(), "A companion that gave up can still fight") + + // Up from a real stamina crit with nobody about, it carries on + first.adjustStaminaLoss(200) + TEST_ASSERT(first.ai_stamcritted, "A real stamina crit went unnoticed") + first.setStaminaLoss(0) + TEST_ASSERT(!first.ai_stamcritted, "Up from stamina crit, the companion never decided what to do") // Deleting one, then the criminal, then the last qdel(first) TEST_ASSERT_EQUAL(length(criminal.ai_companions()), 1, "A deleted companion is still counted") - var/mob/living/basic/bounty_companion/second = buddies[2] qdel(criminal) TEST_ASSERT_NULL(second.ai_leader(), "A companion still has a deleted criminal") second.ai_join_fight(hunter) @@ -421,15 +550,14 @@ /** * The blend routine, with the fugitive and a decoy made as P6 makes them: the decoy runs the - * fugitive's own controller, and both carry P6's act. They share a routine and a pace, can't be - * pulled, and let shots aimed at someone else through. Nothing but P6's rules exposes the fugitive - * (C1), and once exposed, `blended` and P6's act agree. + * fugitive's own controller, and both carry P6's act. They share a routine and a pace. Confronted, the + * fugitive stops blending in, and `blended` and P6's act agree. */ /datum/unit_test/voidcrew_bounty_ai/blend /datum/unit_test/voidcrew_bounty_ai/blend/Run() - var/mob/living/basic/bounty_criminal/meek/fugitive = allocate(/mob/living/basic/bounty_criminal/meek, tile(1, 1)) - var/mob/living/basic/bounty_criminal/decoy/decoy = allocate(/mob/living/basic/bounty_criminal/decoy, tile(3, 1)) + var/mob/living/carbon/human/npc/bounty_criminal/meek/fugitive = allocate(/mob/living/carbon/human/npc/bounty_criminal/meek, tile(1, 1)) + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = allocate(/mob/living/carbon/human/npc/bounty_criminal/decoy, tile(3, 1)) var/mob/living/carbon/human/consistent/hunter = allocate(/mob/living/carbon/human/consistent, tile(2, 3)) hunter.mind_initialize() QDEL_NULL(decoy.ai_controller) @@ -438,57 +566,29 @@ TEST_ASSERT_EQUAL(decoy.ai_controller?.type, controller_type, "The decoy does not run its fugitive's controller") fugitive.AddComponent(/datum/component/bounty_outpost_blend, null, FALSE) decoy.AddComponent(/datum/component/bounty_outpost_blend, null, TRUE) - var/datum/component/bounty_outpost_blend/act = fugitive.GetComponent(/datum/component/bounty_outpost_blend) fugitive.start_activity("blend") // BOUNTY_ACTIVITY_BLEND decoy.start_activity("blend") // BOUNTY_ACTIVITY_BLEND TEST_ASSERT(fugitive.blended && decoy.blended, "Blending in did not make both patrons") TEST_ASSERT_EQUAL(fugitive.ai_activity?.type, decoy.ai_activity?.type, "The fugitive and the decoy do not share one routine") - TEST_ASSERT_EQUAL(fugitive.speed, decoy.speed, "The fugitive and the decoy move at different speeds") - TEST_ASSERT_EQUAL(fugitive.speed, 2.5, "Blended in, they do not move at the calm pace") // BOUNTY_CALM_SPEED + TEST_ASSERT_EQUAL(fugitive.move_intent, decoy.move_intent, "The fugitive and the decoy move at different paces") + TEST_ASSERT_EQUAL(fugitive.move_intent, MOVE_INTENT_WALK, "Blended in, they do not walk") - TEST_ASSERT(!fugitive.can_be_pulled(hunter, MOVE_FORCE_EXTREMELY_STRONG), "A blended fugitive can be pulled") - TEST_ASSERT(!decoy.can_be_pulled(hunter, MOVE_FORCE_EXTREMELY_STRONG), "A decoy can be pulled") - - var/obj/projectile/bullet/shot = allocate(/obj/projectile/bullet, tile(2, 2)) - shot.original = hunter - TEST_ASSERT(SEND_SIGNAL(decoy, COMSIG_PROJECTILE_PREHIT, shot) & PROJECTILE_INTERRUPT_HIT_PHASE, "A shot aimed at someone else hit the decoy") - TEST_ASSERT(SEND_SIGNAL(fugitive, COMSIG_PROJECTILE_PREHIT, shot) & PROJECTILE_INTERRUPT_HIT_PHASE, "A shot aimed at someone else hit the blended fugitive") - QDEL_NULL(shot) - - // Nothing P6 does not count gives the fugitive away: a stray throw, a creature, getting up, cuffs slipping + // Nothing P6 does not count gives the fugitive away: a stray blow, a creature, getting up, cuffs slipping var/datum/ai_controller/basic_controller/bounty/fugitive_brain = fugitive.ai_controller var/datum/ai_controller/basic_controller/bounty/decoy_brain = decoy.ai_controller var/mob/living/carbon/human/consistent/thrower = allocate(/mob/living/carbon/human/consistent, tile(4, 4)) fugitive_brain.pawn_attacked(thrower) - var/mob/living/basic/carp/creature = allocate(/mob/living/basic/carp, tile(0, 2)) - SEND_SIGNAL(fugitive, COMSIG_ATOM_ATTACK_ANIMAL, creature) fugitive.ai_add_grudge(hunter) fugitive.ai_on_recovered() fugitive.ai_on_unrestrained(null) - TEST_ASSERT(fugitive.blended && act.blending, "Something P6 does not count as a hit exposed the fugitive") + TEST_ASSERT(fugitive.blended, "Something P6 does not count as a hit exposed the fugitive") TEST_ASSERT_EQUAL(fugitive.ai_mode, "calm", "The blended fugitive reacted on its own") // BOUNTY_AI_CALM TEST_ASSERT(istype(fugitive.ai_activity, /datum/bounty_activity/blend), "The blended fugitive stopped blending in") decoy_brain.pawn_attacked(thrower) TEST_ASSERT_EQUAL(decoy.ai_mode, "calm", "A blended decoy reacted to a blow on its own") // BOUNTY_AI_CALM - // Walking out, not even a blow from a person gives it away - act.leaving = TRUE - hunter.set_combat_mode(TRUE) - SEND_SIGNAL(fugitive, COMSIG_ATOM_ATTACK_HAND, hunter, null) - fugitive_brain.pawn_attacked(hunter) - TEST_ASSERT(fugitive.blended, "A blow while walking out exposed the fugitive") - TEST_ASSERT_EQUAL(fugitive.ai_mode, "calm", "Walking out, the fugitive reacted to a blow") // BOUNTY_AI_CALM - act.leaving = FALSE - - // A hit P6 counts exposes it, and its act and `blended` end together - act.handle_hit(hunter) - TEST_ASSERT(!fugitive.blended, "A hit P6 counts did not expose the fugitive") - TEST_ASSERT(!act.blending, "Exposed, the fugitive is still blending in by P6's act") - TEST_ASSERT_EQUAL(fugitive.ai_mode, "fleeing", "The exposed meek fugitive did not bolt") // BOUNTY_AI_FLEEING - TEST_ASSERT(fugitive.ai_activity_kind != "blend", "The exposed fugitive would go back to blending in") // BOUNTY_ACTIVITY_BLEND - // Confronted directly (any package's on_confronted()), P6's act ends too - var/mob/living/basic/bounty_criminal/normal/other = allocate(/mob/living/basic/bounty_criminal/normal, tile(0, 4)) + var/mob/living/carbon/human/npc/bounty_criminal/normal/other = allocate(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(0, 4)) other.AddComponent(/datum/component/bounty_outpost_blend, null, FALSE) other.start_activity("blend") // BOUNTY_ACTIVITY_BLEND var/datum/component/bounty_outpost_blend/other_act = other.GetComponent(/datum/component/bounty_outpost_blend) @@ -509,27 +609,39 @@ TEST_ASSERT_EQUAL(decoy.ai_mode, "calm", "Out of sight long enough, the decoy did not calm down") // BOUNTY_AI_CALM TEST_ASSERT(istype(decoy.ai_resume_activity(), /datum/bounty_activity/blend), "Calm again, the decoy did not go back to blending in") -/// A normal fugitive's decoy runs the normal tree, which can run it off and calm it down (M3) -/datum/unit_test/voidcrew_bounty_ai/normal_decoy - -/datum/unit_test/voidcrew_bounty_ai/normal_decoy/Run() - var/mob/living/basic/bounty_criminal/normal/fugitive = allocate(/mob/living/basic/bounty_criminal/normal, tile(1, 1)) - var/mob/living/basic/bounty_criminal/decoy/decoy = allocate(/mob/living/basic/bounty_criminal/decoy, tile(3, 1)) - QDEL_NULL(decoy.ai_controller) - var/controller_type = fugitive.ai_controller.type - new controller_type(decoy) - var/datum/ai_controller/basic_controller/bounty/brain = decoy.ai_controller - TEST_ASSERT(locate(/datum/ai_planning_subtree/bounty_flee_and_calm) in brain.planning_subtrees, "The normal tree cannot run a fleeing decoy") +/// Every bounty tree runs on a human: soft crit first, then breaking free and walking out, before anything of its own (contract 2.4) +/datum/unit_test/voidcrew_bounty_ai/trees + +/datum/unit_test/voidcrew_bounty_ai/trees/Run() + var/list/pawn_types = list( + /mob/living/carbon/human/npc/bounty_criminal = /datum/ai_controller/basic_controller/bounty/criminal, + /mob/living/carbon/human/npc/bounty_criminal/meek = /datum/ai_controller/basic_controller/bounty/criminal/meek, + /mob/living/carbon/human/npc/bounty_criminal/normal = /datum/ai_controller/basic_controller/bounty/criminal/normal, + /mob/living/carbon/human/npc/bounty_criminal/decoy = /datum/ai_controller/basic_controller/bounty/criminal/decoy, + /mob/living/carbon/human/npc/bounty_companion = /datum/ai_controller/basic_controller/bounty/companion, + ) + var/spot = 0 + for(var/pawn_type in pawn_types) + var/mob/living/carbon/human/npc/pawn = allocate(pawn_type, tile(spot++, 2)) + var/datum/ai_controller/brain = pawn.ai_controller + TEST_ASSERT(istype(brain, pawn_types[pawn_type]), "[pawn_type]'s AI didn't take its human body") + TEST_ASSERT_EQUAL(brain.blackboard[BB_TARGET_MINIMUM_STAT], CONSCIOUS, "[pawn_type] fights people who are down") + TEST_ASSERT(length(brain.planning_subtrees) >= 3, "[pawn_type] has no planning list") + var/datum/first = brain.planning_subtrees[1] + var/datum/second = brain.planning_subtrees[2] + var/datum/third = brain.planning_subtrees[3] + TEST_ASSERT_EQUAL(first.type, /datum/ai_planning_subtree/human_npc_soft_crit, "[pawn_type] doesn't plan soft crit first") + TEST_ASSERT_EQUAL(second.type, /datum/ai_planning_subtree/bounty_escape_captivity, "[pawn_type] doesn't break free second") + TEST_ASSERT_EQUAL(third.type, /datum/ai_planning_subtree/human_npc_walk_out, "[pawn_type] doesn't walk out third") /// Knocked down is the cuff window (H2): no blows, no shots, no aim, no climbing into hiding /datum/unit_test/voidcrew_bounty_ai/knockdown /datum/unit_test/voidcrew_bounty_ai/knockdown/Run() - var/mob/living/basic/bounty_criminal/meek/meek = allocate(/mob/living/basic/bounty_criminal/meek, tile(0, 0)) - var/mob/living/basic/bounty_criminal/normal/normal = allocate(/mob/living/basic/bounty_criminal/normal, tile(3, 3)) + var/mob/living/carbon/human/npc/bounty_criminal/meek/meek = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/meek, tile(0, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/normal/normal = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(3, 3), "brawler") // BOUNTY_STYLE_BRAWLER var/mob/living/carbon/human/consistent/hunter = allocate(/mob/living/carbon/human/consistent, tile(1, 1)) var/obj/structure/closet/locker = allocate(/obj/structure/closet, tile(1, 0)) - meek.ai_update_style() normal.ai_add_grudge(hunter) var/datum/ai_controller/basic_controller/bounty/meek_brain = meek.ai_controller var/datum/ai_controller/basic_controller/bounty/normal_brain = normal.ai_controller @@ -552,8 +664,8 @@ TEST_ASSERT(meek_brain, "The meek criminal has no AI") // A companion on the floor can't fight either - var/list/buddies = normal.spawn_companions(1) - var/mob/living/basic/bounty_companion/buddy = buddies[1] + var/list/buddies = normal.spawn_companions(1, TRUE) + var/mob/living/carbon/human/npc/bounty_companion/buddy = buddies[1] var/datum/ai_controller/basic_controller/bounty/buddy_brain = buddy.ai_controller buddy.Knockdown(5 SECONDS) TEST_ASSERT(!buddy.ai_can_fight(), "A knocked-down companion can still fight") @@ -567,25 +679,26 @@ TEST_ASSERT(buddy.ai_can_fight(), "Up again, the companion still can't fight") QDEL_LIST(buddies) -/// A companion fights on when its criminal is down, cuffed, surrendered or gone (H3) +/// A companion fights on when its criminal is down, cuffed, gave up or is gone (H3) /datum/unit_test/voidcrew_bounty_ai/companion_fights_on /datum/unit_test/voidcrew_bounty_ai/companion_fights_on/Run() - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(/mob/living/basic/bounty_criminal/normal, tile(2, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(2, 2), "brawler") // BOUNTY_STYLE_BRAWLER var/mob/living/carbon/human/consistent/hunter = allocate(/mob/living/carbon/human/consistent, tile(4, 4)) - var/list/buddies = criminal.spawn_companions(1) - var/mob/living/basic/bounty_companion/buddy = buddies[1] + var/list/buddies = criminal.spawn_companions(1, TRUE) + var/mob/living/carbon/human/npc/bounty_companion/buddy = buddies[1] var/datum/ai_controller/basic_controller/bounty/buddy_brain = buddy.ai_controller var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(buddy_brain.blackboard[BB_TARGETING_STRATEGY]) criminal.ai_add_grudge(hunter) - ADD_TRAIT(criminal, "bounty_surrendered", "test") // TRAIT_BOUNTY_SURRENDERED - TEST_ASSERT(!criminal.may_attack(hunter), "A surrendered criminal may still attack") - TEST_ASSERT(criminal.may_attack_scope(hunter), "Surrendering took the hunter out of the criminal's scope") - TEST_ASSERT(buddy_brain.may_strike(hunter), "With its criminal surrendered, the companion may not hit the hunter") - TEST_ASSERT(strategy.can_attack(buddy, hunter, 9), "With its criminal surrendered, the companion will not target the hunter") // BOUNTY_FIGHT_VISION - TEST_ASSERT(bounty_ai_may_hit(buddy, hunter), "With its criminal surrendered, the companion's shots pass the hunter") - REMOVE_TRAIT(criminal, "bounty_surrendered", "test") // TRAIT_BOUNTY_SURRENDERED + // Its criminal lying there giving up (the human NPC base's state; the roll to run is left out of this test) + criminal.npc_surrendering = TRUE + TEST_ASSERT(!criminal.may_attack(hunter), "A surrendering criminal may still attack") + TEST_ASSERT(criminal.may_attack_scope(hunter), "Giving up took the hunter out of the criminal's scope") + TEST_ASSERT(buddy_brain.may_strike(hunter), "With its criminal giving up, the companion may not hit the hunter") + TEST_ASSERT(strategy.can_attack(buddy, hunter, 9), "With its criminal giving up, the companion will not target the hunter") // BOUNTY_FIGHT_VISION + TEST_ASSERT(bounty_ai_may_hit(buddy, hunter), "With its criminal giving up, the companion may not hit the hunter") + criminal.npc_surrendering = FALSE // Hit by the hunter, it takes them on itself: no tg element needed buddy_brain.pawn_attacked(hunter) @@ -600,9 +713,9 @@ /datum/unit_test/voidcrew_bounty_ai/friendly_fire /datum/unit_test/voidcrew_bounty_ai/friendly_fire/Run() - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(/mob/living/basic/bounty_criminal/normal, tile(2, 2)) - var/list/buddies = criminal.spawn_companions(1) - var/mob/living/basic/bounty_companion/buddy = buddies[1] + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(2, 2), "brawler") // BOUNTY_STYLE_BRAWLER + var/list/buddies = criminal.spawn_companions(1, TRUE) + var/mob/living/carbon/human/npc/bounty_companion/buddy = buddies[1] var/mob/living/basic/carp/crewmate = allocate(/mob/living/basic/carp, tile(4, 4)) crewmate.faction = criminal.faction.Copy() var/datum/ai_controller/basic_controller/bounty/brain = criminal.ai_controller @@ -613,13 +726,18 @@ TEST_ASSERT_EQUAL(criminal.ai_mode, "calm", "A stray blow from its own side started a fight") // BOUNTY_AI_CALM var/list/retaliate = buddy_brain.blackboard[BB_BASIC_MOB_RETALIATE_LIST] TEST_ASSERT(!LAZYLEN(retaliate) || !(crewmate in retaliate), "A stray blow from its own side turned the companion on a crewmate") + // Their own side in the line of fire stops a shot + crewmate.forceMove(tile(3, 2)) + var/mob/living/carbon/human/consistent/hunter = allocate(/mob/living/carbon/human/consistent, tile(4, 2)) + criminal.ai_add_grudge(hunter) + TEST_ASSERT(bounty_ai_line_blocked(criminal, hunter), "A crewmate in the line of fire doesn't block the shot") QDEL_LIST(buddies) /// Someone in a mech is seen, fought and run from like anyone else (H4) /datum/unit_test/voidcrew_bounty_ai/mech_hunter /datum/unit_test/voidcrew_bounty_ai/mech_hunter/Run() - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(/mob/living/basic/bounty_criminal/normal, tile(1, 1)) + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(1, 1), "brawler") // BOUNTY_STYLE_BRAWLER var/mob/living/carbon/human/consistent/pilot = allocate(/mob/living/carbon/human/consistent, tile(3, 3)) var/obj/vehicle/sealed/mecha/ripley/mech = allocate(/obj/vehicle/sealed/mecha/ripley, tile(3, 3)) mech.mob_enter(pilot, silent = TRUE) @@ -639,7 +757,7 @@ TEST_ASSERT_EQUAL(criminal.ai_pick_fight_target(), mech, "In the fight, the criminal does not pick the mech") // The mech's gunfire is the pilot's: a meek one runs from it - var/mob/living/basic/bounty_criminal/meek/meek = allocate(/mob/living/basic/bounty_criminal/meek, tile(0, 4)) + var/mob/living/carbon/human/npc/bounty_criminal/meek/meek = allocate(/mob/living/carbon/human/npc/bounty_criminal/meek, tile(0, 4)) var/obj/projectile/bullet/shot = allocate(/obj/projectile/bullet, tile(0, 3)) shot.firer = mech SEND_SIGNAL(meek, COMSIG_ATOM_BULLET_ACT, shot, BODY_ZONE_CHEST, FALSE, 0) @@ -656,7 +774,7 @@ var/obj/item/kirbyplants/plant = allocate(/obj/item/kirbyplants, tile(4, 4)) allocate(/obj/structure/window/fulltile, tile(3, 4)) allocate(/obj/structure/window/fulltile, tile(4, 3)) - var/mob/living/basic/bounty_criminal/meek/criminal = allocate(/mob/living/basic/bounty_criminal/meek, tile(3, 3)) + var/mob/living/carbon/human/npc/bounty_criminal/meek/criminal = allocate(/mob/living/carbon/human/npc/bounty_criminal/meek, tile(3, 3)) TEST_ASSERT(!criminal.Adjacent(plant), "The test's panes do not wall the plant off") TEST_ASSERT(!criminal.ai_at_hide_spot(plant), "A walled-off plant counts as right beside them") TEST_ASSERT(!criminal.ai_hide_in(plant), "They got onto the plant through the glass") @@ -679,3 +797,19 @@ TEST_ASSERT_EQUAL(criminal.ai_pick_hide_spot(null), locker, "They did not pick the locker they can walk round to") var/turf/stand = criminal.ai_hide_approach(locker) TEST_ASSERT(stand && stand != tile(0, 0) && stand.Adjacent(locker), "The locker is to be climbed into through the window") + +/// The leash (CR-19): the AI's own steps never leave their site; there is no Move() override on the body +/datum/unit_test/voidcrew_bounty_ai/leash + +/datum/unit_test/voidcrew_bounty_ai/leash/Run() + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = allocate(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(1, 1)) + var/turf/home = tile(1, 1) + criminal.site_bounds = list(home.x - 1, home.y - 1, home.x + 1, home.y + 1, home.z) + TEST_ASSERT(bounty_ai_step(criminal, tile(2, 1)), "A step inside their site was refused") + TEST_ASSERT_EQUAL(criminal.loc, tile(2, 1), "The step inside their site didn't move them") + TEST_ASSERT(!bounty_ai_step(criminal, tile(3, 1)), "A step off their site was taken") + TEST_ASSERT_EQUAL(criminal.loc, tile(2, 1), "A refused step moved them anyway") + // Their body is anyone's to move: only their own steps are held to the leash + criminal.Move(tile(3, 1), EAST) + TEST_ASSERT_EQUAL(criminal.loc, tile(3, 1), "Their body can't be moved off their site (a Move() override)") + criminal.site_bounds = null diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_board.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_board.dm index fddd969960c..7e83faaaf40 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_board.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_board.dm @@ -48,13 +48,19 @@ /// The posting's criminal, spawned at `spot` and adopted by hand, its AI off so it stays where a test puts it /datum/unit_test/proc/board_test_criminal(datum/criminal_bounty/posting, turf/spot) - var/mob/living/basic/bounty_criminal/criminal = spawn_bounty_criminal(posting.record, spot, posting) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = spawn_bounty_criminal(posting.record, spot, posting) if(!criminal) return null posting.board_adopt_criminal(criminal, null, "explore", null) // BOUNTY_ACTIVITY_EXPLORE criminal.ai_controller?.set_ai_status(AI_STATUS_OFF) return criminal +/// Puts real tg handcuffs on `target`, as a person would (tg's apply_cuffs() without the do_after). Returns the cuffs it wears. +/datum/unit_test/proc/board_test_cuff(mob/living/carbon/target) + var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs) + cuffs.apply_cuffs(target, allocate(/mob/living/carbon/human/consistent), dispense = TRUE) + return target.handcuffed + /// A bare ship record with an account holding `balance` /datum/unit_test/proc/board_test_ship(balance = 0) var/obj/structure/overmap/ship/ship = allocate(/obj/structure/overmap/ship) @@ -348,7 +354,7 @@ var/turf/aside = locate(pad_turf.x + 2, pad_turf.y, pad_turf.z) var/obj/machinery/mission_pad/pad = allocate(/obj/machinery/mission_pad, pad_turf) var/datum/criminal_bounty/posting = board_test_posting() - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, aside) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, aside) TEST_ASSERT_NOTNULL(criminal, "No criminal was spawned") var/list/found = list() @@ -366,7 +372,7 @@ // Another bounty's criminal is the wrong mob var/datum/criminal_bounty/other_posting = board_test_posting() - var/mob/living/basic/bounty_criminal/wrong = board_test_criminal(other_posting, aside) + var/mob/living/carbon/human/npc/bounty_criminal/wrong = board_test_criminal(other_posting, aside) wrong.forceMove(pad_turf) TEST_ASSERT(istext(posting.board_target_refusal(pad, found)), "The pad took another bounty's criminal for this one") TEST_ASSERT(!QDELETED(wrong), "The wrong criminal was deleted") @@ -405,38 +411,36 @@ // ===== PAY ===== -/// Pay by the worst state reached: 100 / 100 / 60 / 25%, vouchers only on a full share (12.1) +/// Pay by the criminal's condition on the pad: 100 / 100 / 60 / 25%, vouchers only on a full share (owner ruling 2026-11-08) /datum/unit_test/voidcrew_bounty_board/pay /datum/unit_test/voidcrew_bounty_board/pay/Run() var/turf/pad_turf = run_loc_floor_bottom_left var/obj/machinery/mission_pad/pad = allocate(/obj/machinery/mission_pad, pad_turf) var/obj/structure/overmap/ship/ship = board_test_ship() - // state, worst state, credits, vouchers: a value of 1000 and 1 voucher (VOUCHER_CREDIT_VALUE 1200) + // state at the pad, credits, vouchers: a value of 1000 and 1 voucher (VOUCHER_CREDIT_VALUE 1200) var/list/cases = list( - list("restrained", "free", 1000, 1), - list("stunned", "stunned", 1000, 1), - list("downed", "downed", 1320, 0), - list("dead", "dead", 550, 0), - list("restrained", "downed", 1320, 0), - list("stunned", "dead", 550, 0), + list("restrained", 1000, 1), + list("stunned", 1000, 1), + list("downed", 1320, 0), + list("dead", 550, 0), ) for(var/list/pay_case as anything in cases) var/datum/criminal_bounty/posting = board_test_posting() var/datum/bounty_record/record = posting.record - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, pad_turf) - criminal.worst_state = pay_case[2] + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, pad_turf) var/balance_before = ship.ship_account.account_balance var/vouchers_before = board_test_vouchers(pad_turf) var/list/paid = posting.board_claim(ship, pad, criminal, pay_case[1]) - TEST_ASSERT(islist(paid), "A [pay_case[1]] criminal (worst [pay_case[2]]) was refused: [paid]") - TEST_ASSERT_EQUAL(paid[1], pay_case[3], "A [pay_case[1]] criminal (worst [pay_case[2]]) paid the wrong credits") - TEST_ASSERT_EQUAL(paid[2], pay_case[4], "A [pay_case[1]] criminal (worst [pay_case[2]]) paid the wrong vouchers") - TEST_ASSERT_EQUAL(ship.ship_account.account_balance - balance_before, pay_case[3], "The ship's account didn't get the credits") - TEST_ASSERT_EQUAL(board_test_vouchers(pad_turf) - vouchers_before, pay_case[4], "The pad didn't get the vouchers") + TEST_ASSERT(islist(paid), "A [pay_case[1]] criminal was refused: [paid]") + TEST_ASSERT_EQUAL(paid[1], pay_case[2], "A [pay_case[1]] criminal paid the wrong credits") + TEST_ASSERT_EQUAL(paid[2], pay_case[3], "A [pay_case[1]] criminal paid the wrong vouchers") + TEST_ASSERT_EQUAL(ship.ship_account.account_balance - balance_before, pay_case[2], "The ship's account didn't get the credits") + TEST_ASSERT_EQUAL(board_test_vouchers(pad_turf) - vouchers_before, pay_case[3], "The pad didn't get the vouchers") TEST_ASSERT(QDELETED(posting), "A claimed bounty stayed up") TEST_ASSERT(HAS_TRAIT(criminal, "bounty_removed"), "The claimed criminal isn't marked taken") // TRAIT_BOUNTY_REMOVED - TEST_ASSERT(HAS_TRAIT(criminal, TRAIT_GODMODE), "The criminal isn't held still for the beam") + TEST_ASSERT(HAS_TRAIT(criminal, TRAIT_IMMOBILIZED), "The criminal isn't held still for the beam") + TEST_ASSERT(!HAS_TRAIT(criminal, TRAIT_GODMODE), "The beam put the criminal in godmode") TEST_ASSERT_NULL(bounty_drop_proof(criminal), "A criminal the pad took left proof of death") TEST_ASSERT_EQUAL(record.captor_name, ship.name, "The record doesn't name its captor") if(pay_case[1] == "dead") @@ -448,7 +452,7 @@ // A second press finds it closed: one payment, one record (AR-A7) var/datum/criminal_bounty/posting = board_test_posting() - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, pad_turf) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, pad_turf) var/balance_before = ship.ship_account.account_balance TEST_ASSERT(islist(posting.board_claim(ship, pad, criminal, "restrained")), "The first press was refused") TEST_ASSERT(istext(posting.board_claim(ship, pad, criminal, "restrained")), "A second press paid again") @@ -462,7 +466,7 @@ // A free criminal pays nothing var/datum/criminal_bounty/free_posting = board_test_posting() - var/mob/living/basic/bounty_criminal/free_criminal = board_test_criminal(free_posting, pad_turf) + var/mob/living/carbon/human/npc/bounty_criminal/free_criminal = board_test_criminal(free_posting, pad_turf) TEST_ASSERT(istext(free_posting.board_claim(ship, pad, free_criminal, "free")), "A free criminal was paid for") TEST_ASSERT(free_posting.is_open(), "Refusing a free criminal closed the bounty") @@ -500,7 +504,7 @@ var/obj/machinery/mission_pad/pad = allocate(/obj/machinery/mission_pad, pad_turf) var/datum/criminal_bounty/posting = board_test_posting() var/datum/bounty_record/record = posting.record - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, pad_turf) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, pad_turf) criminal.adjustBruteLoss(round(criminal.maxHealth * 0.1)) var/hurt = clamp(1 - criminal.health / criminal.maxHealth, 0, 1) TEST_ASSERT(islist(posting.board_claim(ship, pad, criminal, "restrained")), "The live catch was refused") @@ -517,7 +521,7 @@ ship.board_test_heard.Cut() var/datum/criminal_bounty/refused_posting = board_test_posting() var/datum/bounty_record/refused_record = refused_posting.record - var/mob/living/basic/bounty_criminal/refused_criminal = board_test_criminal(refused_posting, pad_turf) + var/mob/living/carbon/human/npc/bounty_criminal/refused_criminal = board_test_criminal(refused_posting, pad_turf) TEST_ASSERT(islist(refused_posting.board_claim(ship, pad, refused_criminal, "restrained")), "The second live catch was refused") TEST_ASSERT(!ship.board_test_heard("headed for your prison at"), "The notice promised a prison that takes no bounty transfers") TEST_ASSERT(!ship.board_test_heard("transfer pool"), "The notice explains the prisoner transfers") @@ -542,7 +546,7 @@ var/obj/machinery/mission_pad/pad = allocate(/obj/machinery/mission_pad, pad_turf) var/obj/structure/overmap/ship/ship = board_test_ship() var/datum/criminal_bounty/posting = board_test_posting() - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, aside) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, aside) // Taken away on purpose (the pad, the board): no proof, even with the bounty still open (L9) ADD_TRAIT(criminal, "bounty_removed", "bounty_pad") // TRAIT_BOUNTY_REMOVED, BOUNTY_PAD_TRAIT @@ -591,7 +595,7 @@ TEST_ASSERT_EQUAL(posting.hunt(ship), TRUE, "The ship could not hunt the bounty") TEST_ASSERT_NOTNULL(ship.get_waypoint("wanted_[REF(posting)]"), "Hunting didn't chart the site on the helm") var/turf/aside = locate(run_loc_floor_bottom_left.x + 2, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z) - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, aside) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, aside) var/expires_before = posting.expires_at // Deleted, the body leaves proof (P2 asks for it); gone too, nothing is left qdel(criminal) @@ -636,11 +640,11 @@ var/turf/spot = locate(run_loc_floor_bottom_left.x + 2, run_loc_floor_bottom_left.y + 2, run_loc_floor_bottom_left.z) var/datum/criminal_bounty/posting = board_test_posting() TEST_ASSERT_EQUAL(posting.hunt(ship), TRUE, "The ship could not hunt the bounty") - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, spot) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, spot) ADD_TRAIT(criminal, "mission_field_mob", "bounty") // TRAIT_MISSION_FIELD_MOB, BOUNTY_TRAIT - var/mob/living/basic/bounty_companion/companion = new(spot) + var/mob/living/carbon/human/npc/bounty_companion/companion = new(spot) posting.companions |= WEAKREF(companion) - var/mob/living/basic/bounty_criminal/decoy/decoy = new(spot) + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = new(spot) posting.decoys |= WEAKREF(decoy) TEST_ASSERT(posting.board_move_sighting(TRUE), "The sighting marker wasn't placed") var/obj/effect/bounty_sighting/marker = posting.marker @@ -697,7 +701,7 @@ /datum/unit_test/voidcrew_bounty_board/direct_delete/Run() var/datum/criminal_bounty/posting = board_test_posting() - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, run_loc_floor_bottom_left) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, run_loc_floor_bottom_left) qdel(posting) TEST_ASSERT(QDELETED(posting), "The posting wasn't deleted") TEST_ASSERT_EQUAL(posting.status, "closed", "Deleting an open posting didn't close it") // BOUNTY_POSTING_CLOSED @@ -721,7 +725,7 @@ bag.close() TEST_ASSERT(bag.attempt_fold(folder), "An empty bag won't fold") var/datum/criminal_bounty/posting = board_test_posting() - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, spot) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, spot) criminal.forceMove(bag) TEST_ASSERT(!bag.attempt_fold(folder), "A bag folded with a living criminal inside") TEST_ASSERT(bounty_blocks_bag_fold(bag, null), "The guard doesn't see a living criminal in the bag") @@ -737,11 +741,11 @@ var/obj/item/mmi/posibrain/brain = allocate(/obj/item/mmi/posibrain, spot) TEST_ASSERT_NULL(bounty_offer_refusal(list(brain)), "An offer refused a positronic brain") var/datum/criminal_bounty/other_posting = board_test_posting() - var/mob/living/basic/bounty_criminal/bagged = board_test_criminal(other_posting, spot) + var/mob/living/carbon/human/npc/bounty_criminal/bagged = board_test_criminal(other_posting, spot) bagged.forceMove(folded) TEST_ASSERT(istext(bounty_offer_refusal(list(brain, folded))), "An offer sent a living criminal inside an item") bagged.forceMove(spot) - var/mob/living/basic/bounty_companion/companion = allocate(/mob/living/basic/bounty_companion, spot) + var/mob/living/carbon/human/npc/bounty_companion/companion = allocate(/mob/living/carbon/human/npc/bounty_companion, spot) companion.forceMove(folded) TEST_ASSERT(istext(bounty_offer_refusal(list(folded))), "An offer sent a living companion inside an item") companion.forceMove(spot) @@ -834,7 +838,7 @@ pad.set_anchored(TRUE) var/datum/criminal_bounty/posting = board_test_posting() - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, deck) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, deck) criminal.death() criminal.forceMove(deck) var/balance_before = ship.ship_account.account_balance @@ -847,9 +851,8 @@ // A live one, cuffed with its own restraints: full pay and the voucher, and the record goes on to the prisons var/datum/criminal_bounty/live_posting = board_test_posting() var/datum/bounty_record/live_record = live_posting.record - var/mob/living/basic/bounty_criminal/cuffed = board_test_criminal(live_posting, deck) - var/obj/item/restraints/handcuffs/cuffs = new(deck) - TEST_ASSERT(cuffed.body_apply_cuffs(cuffs, null), "The criminal could not be cuffed") + var/mob/living/carbon/human/npc/bounty_criminal/cuffed = board_test_criminal(live_posting, deck) + TEST_ASSERT_NOTNULL(board_test_cuff(cuffed), "The criminal could not be cuffed") cuffed.forceMove(deck) TEST_ASSERT_EQUAL(cuffed.capture_state(), "restrained", "A cuffed criminal doesn't read restrained") // BOUNTY_STATE_RESTRAINED balance_before = ship.ship_account.account_balance @@ -865,26 +868,27 @@ // ===== SITES UNLOADING ===== -/// The worst state a criminal reached outlives its site unloading: it never pays more on the next body, and a dead one comes back as proof (12.1, M2) +/// A criminal's site unloading: a living one comes back on the next load and pays by its condition then; a dead one comes back as proof (M2) /datum/unit_test/voidcrew_bounty_board/worst_state /datum/unit_test/voidcrew_bounty_board/worst_state/Run() var/turf/spot = locate(run_loc_floor_bottom_left.x + 2, run_loc_floor_bottom_left.y + 2, run_loc_floor_bottom_left.z) var/datum/criminal_bounty/posting = board_test_posting() - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, spot) - criminal.worst_state = "downed" // BOUNTY_STATE_DOWNED + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, spot) + bounty_test_hurt_to(criminal, -10) + TEST_ASSERT(criminal.is_downed(), "The criminal didn't go into crit") posting.board_site_took_criminal(criminal) TEST_ASSERT(QDELETED(criminal), "The unloading site didn't take the criminal") TEST_ASSERT(posting.is_open() && !posting.board_relisting, "The bounty didn't stay up for the next load") - TEST_ASSERT_EQUAL(posting.board_worst_state, "downed", "The bounty forgot its criminal was downed") + TEST_ASSERT_EQUAL(posting.board_worst_state, "free", "A criminal alive when its site unloaded counts as dead") // BOUNTY_STATE_FREE TEST_ASSERT_NULL(posting.board_proof(), "A criminal taken by its site left proof of death") - // The next load: the same record, still paying no more than the downed share - var/mob/living/basic/bounty_criminal/again = posting.board_place_at(spot, "explore", null, null) // BOUNTY_ACTIVITY_EXPLORE + // The next load: the same record, paid by its condition on the pad (no ratchet) + var/mob/living/carbon/human/npc/bounty_criminal/again = posting.board_place_at(spot, "explore", null, null) // BOUNTY_ACTIVITY_EXPLORE TEST_ASSERT(istype(again), "The criminal didn't come back") TEST_ASSERT_EQUAL(again.record, posting.record, "Someone else came back") - TEST_ASSERT_EQUAL(again.worst_state, "downed", "The criminal came back with a clean slate") - TEST_ASSERT_EQUAL(posting.board_share_for("restrained", again.worst_state), 60, "A criminal downed before the unload pays in full") // BOUNTY_SHARE_DOWNED + TEST_ASSERT(!again.is_downed(), "The criminal came back still in crit") + TEST_ASSERT_EQUAL(posting.board_share_for("restrained"), 100, "A cuffed criminal doesn't pay the full share") // BOUNTY_SHARE_RESTRAINED // Dead when its site unloaded: it comes back as its proof of death, never alive again.death() @@ -922,7 +926,7 @@ var/datum/criminal_bounty/posting = board_test_posting() var/turf/brink = locate(pit.x - 1, pit.y, pit.z) - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, brink) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, brink) criminal.forceMove(pit) sleep(3 SECONDS) TEST_ASSERT(QDELETED(criminal) || istype(criminal.loc, /obj/effect/abstract/chasm_storage), "The criminal didn't fall into the chasm") @@ -952,7 +956,7 @@ /datum/unit_test/voidcrew_bounty_board/unreachable/Run() var/datum/criminal_bounty/posting = board_test_posting() - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, run_loc_floor_bottom_left) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, run_loc_floor_bottom_left) TEST_ASSERT(!posting.board_check_unreachable(), "A criminal standing on the floor counts as unreachable") criminal.moveToNullspace() TEST_ASSERT(posting.board_check_unreachable(), "A criminal in nullspace still holds the bounty") @@ -1067,22 +1071,6 @@ TEST_ASSERT(!findtext(text, features[length(features)]), "The warrant lists every feature") qdel(warrant) -/// A closed bounty's warrants burn away, on the floor or in a hand; a relist keeps them -/datum/unit_test/voidcrew_bounty_board/warrant_burns - -/datum/unit_test/voidcrew_bounty_board/warrant_burns/Run() - var/datum/criminal_bounty/posting = board_test_posting() - var/mob/living/carbon/human/consistent/hunter = allocate(/mob/living/carbon/human/consistent) - var/obj/item/paper/bounty_warrant/on_floor = posting.print_warrant(run_loc_floor_bottom_left) - var/obj/item/paper/bounty_warrant/in_hand = posting.print_warrant(run_loc_floor_bottom_left) - hunter.put_in_hands(in_hand) - TEST_ASSERT(hunter.is_holding(in_hand), "The hunter isn't holding the warrant") - posting.relist("slipped away") - TEST_ASSERT(!QDELETED(on_floor) && !QDELETED(in_hand), "A relist burned the warrants") - posting.close("admin") // BOUNTY_CLOSE_ADMIN - TEST_ASSERT(QDELETED(on_floor), "A closed bounty's warrant on the floor is still there") - TEST_ASSERT(QDELETED(in_hand), "A closed bounty's warrant in a hand is still there") - // ===== THE POLISH ROUND ===== /// The card and the warrant read like a poster: the terms, the old photo, one reward and no rules, and a ruin's real name (BUG-9) @@ -1177,7 +1165,7 @@ var/obj/machinery/mission_pad/pad = allocate(/obj/machinery/mission_pad, pad_turf) var/datum/criminal_bounty/posting = board_test_posting(3) TEST_ASSERT_EQUAL(posting.hunt(hunter), TRUE, "The hunter could not hunt the bounty") - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, pad_turf) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, pad_turf) var/wanted_name = posting.record.name listener.board_test_heard.Cut() hunter.board_test_heard.Cut() @@ -1199,7 +1187,7 @@ var/obj/structure/overmap/ship/ship = board_test_ship() var/datum/criminal_bounty/posting = board_test_posting() var/wanted_name = posting.record.name - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, pad_turf) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, pad_turf) TEST_ASSERT(islist(posting.board_claim(ship, pad, criminal, "restrained")), "The clean catch was refused") var/obj/item/paper/bounty_captured/poster = locate() in pad_turf TEST_ASSERT_NOTNULL(poster, "A clean Wanted catch left no poster") @@ -1213,10 +1201,9 @@ qdel(poster) var/datum/criminal_bounty/downed_posting = board_test_posting() - var/mob/living/basic/bounty_criminal/downed_criminal = board_test_criminal(downed_posting, pad_turf) - downed_criminal.worst_state = "downed" // BOUNTY_STATE_DOWNED - TEST_ASSERT(islist(downed_posting.board_claim(ship, pad, downed_criminal, "restrained")), "The downed catch was refused") - TEST_ASSERT_NULL(locate(/obj/item/paper/bounty_captured) in pad_turf, "A catch downed earlier left a poster") + var/mob/living/carbon/human/npc/bounty_criminal/downed_criminal = board_test_criminal(downed_posting, pad_turf) + TEST_ASSERT(islist(downed_posting.board_claim(ship, pad, downed_criminal, "downed")), "The downed catch was refused") + TEST_ASSERT_NULL(locate(/obj/item/paper/bounty_captured) in pad_turf, "A catch in crit left a poster") for(var/datum/bounty_record/pooled as anything in GLOB.bounty_prisoner_pool.Copy()) bounty_pool_remove(pooled) @@ -1230,7 +1217,7 @@ var/obj/machinery/mission_pad/pad = allocate(/obj/machinery/mission_pad, pad_turf) var/datum/criminal_bounty/posting = board_test_posting() var/wanted_name = posting.record.name - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, aside) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, aside) // Nothing there: the card says so var/list/preview = posting.board_pad_preview(ship, pad) @@ -1246,11 +1233,9 @@ var/line = pad.bounty_pad_line(criminal) TEST_ASSERT_EQUAL(line, "On the pad: [wanted_name], standing free.", "The pad's line for a free criminal") - // Cuffed, but downed earlier: the pad names the state and why Turn In won't work (the bare pad isn't aboard), never the pay - var/obj/item/restraints/handcuffs/cuffs = new(pad_turf) - TEST_ASSERT(criminal.body_apply_cuffs(cuffs, null), "The criminal could not be cuffed") + // Cuffed: the pad names the state and why Turn In won't work (the bare pad isn't aboard), never the pay + TEST_ASSERT_NOTNULL(board_test_cuff(criminal), "The criminal could not be cuffed") criminal.forceMove(pad_turf) - criminal.worst_state = "downed" // BOUNTY_STATE_DOWNED preview = posting.board_pad_preview(ship, pad) TEST_ASSERT_EQUAL(preview[3], "the pad must be aboard your ship", "The card doesn't say the pad isn't aboard") line = pad.bounty_pad_line(criminal) @@ -1259,9 +1244,17 @@ TEST_ASSERT(!findtext(line, "1320") && !findtextEx(line, " cr") && !findtextEx(line, "pays"), "The pad says what the catch pays: [line]") var/list/entry = posting.board_ui_entry(ship, pad) TEST_ASSERT_EQUAL(entry["turn_in_refusal"], "the pad must be aboard your ship", "The card entry doesn't carry the refusal") - // The pay itself is unchanged: downed earlier, the downed share (60% of 1000 + 1200) - var/list/downed_pay = posting.board_payout(posting.board_share_for(criminal.capture_state(), criminal.worst_state)) - TEST_ASSERT_EQUAL(downed_pay[1], 1320, "A catch downed earlier doesn't pay the downed share") + // The pay is the condition on the pad: cuffed, the full share; in crit, the downed share (60% of 1000 + 1200) + var/list/cuffed_pay = posting.board_payout(posting.board_share_for(criminal.capture_state())) + TEST_ASSERT_EQUAL(cuffed_pay[1], 1000, "A cuffed catch doesn't pay the full share") + TEST_ASSERT_EQUAL(cuffed_pay[2], 1, "A cuffed catch doesn't pay its voucher") + bounty_test_hurt_to(criminal, -10) + TEST_ASSERT_EQUAL(criminal.capture_state(), "downed", "A cuffed criminal in crit doesn't read downed") + var/list/downed_pay = posting.board_payout(posting.board_share_for(criminal.capture_state())) + TEST_ASSERT_EQUAL(downed_pay[1], 1320, "A catch in crit doesn't pay the downed share") + // Patched up out of crit and still cuffed: the full share again (owner ruling 2026-11-08) + criminal.adjustBruteLoss(-110) + TEST_ASSERT_EQUAL(posting.board_share_for(criminal.capture_state()), 100, "A criminal patched up after a fall doesn't pay in full") // Once per few seconds, however often they're dragged on and off (dragging them on above already spoke) COOLDOWN_RESET(pad, bounty_announce_cooldown) @@ -1270,9 +1263,9 @@ // Another crew's offer, or a decoy: nothing var/datum/criminal_bounty/offer = board_test_posting(1, board_test_ship()) - var/mob/living/basic/bounty_criminal/offered = board_test_criminal(offer, pad_turf) + var/mob/living/carbon/human/npc/bounty_criminal/offered = board_test_criminal(offer, pad_turf) TEST_ASSERT_NULL(pad.bounty_pad_line(offered), "The pad spoke about another crew's offer") - var/mob/living/basic/bounty_criminal/decoy/decoy = allocate(/mob/living/basic/bounty_criminal/decoy, pad_turf) + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = allocate(/mob/living/carbon/human/npc/bounty_criminal/decoy, pad_turf) TEST_ASSERT_NULL(pad.bounty_pad_line(decoy), "The pad spoke about a decoy") // Its proof of death: the pad names it, and it pays the dead share (25% of 1000 + 1200) @@ -1284,7 +1277,7 @@ TEST_ASSERT(findtext(line, "Evidence tag for [wanted_name]"), "The pad's line for the proof: [line]") preview = posting.board_pad_preview(ship, pad) TEST_ASSERT_EQUAL(preview[2], "proof", "The card doesn't see the proof on the pad") - var/list/dead_pay = posting.board_payout(posting.board_share_for("dead", "dead")) // BOUNTY_STATE_DEAD + var/list/dead_pay = posting.board_payout(posting.board_share_for("dead")) // BOUNTY_STATE_DEAD TEST_ASSERT_EQUAL(dead_pay[1], 550, "The proof doesn't pay the dead share") // The body the proof stands for is no longer the bounty's, so closing it won't take the body away qdel(criminal) @@ -1297,7 +1290,7 @@ var/turf/spot = locate(run_loc_floor_bottom_left.x + 2, run_loc_floor_bottom_left.y + 2, run_loc_floor_bottom_left.z) var/datum/criminal_bounty/posting = board_test_posting() TEST_ASSERT_EQUAL(posting.hunt(ship), TRUE, "The ship could not hunt the bounty") - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, spot) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, spot) TEST_ASSERT_NOTNULL(criminal, "No criminal to track") var/mob/living/carbon/human/consistent/holder = allocate(/mob/living/carbon/human/consistent, run_loc_floor_bottom_left) var/obj/item/gps/gps = allocate(/obj/item/gps, run_loc_floor_bottom_left) diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_bosses.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_bosses.dm index d8c7284bb9a..3c40f30f99a 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_bosses.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_bosses.dm @@ -4,6 +4,11 @@ * Owner: P4 bosses. Do not edit this file outside that package. Fork defines are included after the * tests, so a test uses the literal value with a comment naming the define. Every test calls the * boss's procs directly with the mob already in place; none waits on a timer or an AI walk. + * + * The bosses are real humans (phase D of the human NPC migration): these tests check that they wear + * and carry real gear, that their fire, blasts and knife reach people through tg's own paths whatever + * state those people are in, that their wind-ups stop for tg's states, and that their AI reads real + * state (worn out, the stimulant, the posse's reinforcements). */ /// Shared helpers; not a test itself @@ -49,6 +54,11 @@ hunter.mind_initialize() return hunter +/// Puts `person` into crit with real damage on the chest (soft crit, health -20) +/datum/unit_test/voidcrew_bounty_boss/proc/put_in_crit(mob/living/person) + bounty_test_hurt_to(person, -20) + return person.stat != CONSCIOUS && person.stat != DEAD + /// A Ripley at `where` with `pilot` in it /datum/unit_test/voidcrew_bounty_boss/proc/mech_with(turf/where, mob/living/pilot) var/obj/vehicle/sealed/mecha/ripley/mech = allocate(/obj/vehicle/sealed/mecha/ripley, where) @@ -57,20 +67,25 @@ return mech /// `hunter` hits `boss`, as far as its posse is concerned: onto its grudge list, then into the posse -/datum/unit_test/voidcrew_bounty_boss/proc/posse_member(mob/living/basic/bounty_criminal/boss/boss, mob/living/hunter) +/datum/unit_test/voidcrew_bounty_boss/proc/posse_member(mob/living/carbon/human/npc/bounty_criminal/boss/boss, mob/living/hunter) boss.body_add_grudge(hunter) return boss.boss_engage(hunter) /// The ability of `ability_type` that `boss` has -/datum/unit_test/voidcrew_bounty_boss/proc/ability_of(mob/living/basic/bounty_criminal/boss/boss, ability_type) +/datum/unit_test/voidcrew_bounty_boss/proc/ability_of(mob/living/carbon/human/npc/bounty_criminal/boss/boss, ability_type) return locate(ability_type) in boss.boss_abilities /// Ready for another ability straight away: no gap, no cooldowns -/datum/unit_test/voidcrew_bounty_boss/proc/ready(mob/living/basic/bounty_criminal/boss/boss) +/datum/unit_test/voidcrew_bounty_boss/proc/ready(mob/living/carbon/human/npc/bounty_criminal/boss/boss) boss.boss_next_ability_at = 0 for(var/datum/action/cooldown/ability as anything in boss.boss_abilities) ability.next_use_time = 0 +/// Ready to click again: no click or attack cooldown left +/datum/unit_test/voidcrew_bounty_boss/proc/ready_hands(mob/living/carbon/human/npc/bounty_criminal/boss/boss) + boss.next_move = 0 + boss.next_click = 0 + /// Telegraph marks on the tiles around `center` /datum/unit_test/voidcrew_bounty_boss/proc/marks_near(atom/center, radius = 1) . = 0 @@ -85,50 +100,97 @@ return TRUE return FALSE -// ===== EACH KIT SPAWNS AND GOES CLEANLY ===== +/// How many of `item_type` `holder` carries anywhere on it +/datum/unit_test/voidcrew_bounty_boss/proc/carried(mob/living/holder, item_type) + return length(holder.get_all_contents_type(item_type)) + +// ===== EACH KIT IS A REAL HUMAN IN REAL GEAR, AND GOES CLEANLY ===== /datum/unit_test/voidcrew_bounty_boss/kits /datum/unit_test/voidcrew_bounty_boss/kits/Run() var/list/kits = list( - /mob/living/basic/bounty_criminal/boss/juggernaut = "juggernaut", // BOUNTY_KIT_JUGGERNAUT - /mob/living/basic/bounty_criminal/boss/pyromaniac = "pyromaniac", // BOUNTY_KIT_PYROMANIAC - /mob/living/basic/bounty_criminal/boss/demolitionist = "demolitionist", // BOUNTY_KIT_DEMOLITIONIST - /mob/living/basic/bounty_criminal/boss/ghost = "ghost", // BOUNTY_KIT_GHOST - /mob/living/basic/bounty_criminal/boss/heavy = "heavy", // BOUNTY_KIT_HEAVY + /mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut = "juggernaut", // BOUNTY_KIT_JUGGERNAUT + /mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac = "pyromaniac", // BOUNTY_KIT_PYROMANIAC + /mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist = "demolitionist", // BOUNTY_KIT_DEMOLITIONIST + /mob/living/carbon/human/npc/bounty_criminal/boss/ghost = "ghost", // BOUNTY_KIT_GHOST + /mob/living/carbon/human/npc/bounty_criminal/boss/heavy = "heavy", // BOUNTY_KIT_HEAVY ) for(var/kit_type in kits) - TEST_ASSERT(!ispath(kit_type, /mob/living/basic/boss), "[kit_type] is a megafauna boss, which outposts ban") - var/mob/living/basic/bounty_criminal/boss/boss = allocate(kit_type) + var/mob/living/carbon/human/npc/bounty_criminal/boss/boss = allocate(kit_type) + TEST_ASSERT(ishuman(boss), "[kit_type] isn't a real human") TEST_ASSERT_EQUAL(boss.boss_kit, kits[kit_type], "[kit_type] has the wrong kit") TEST_ASSERT_EQUAL(length(boss.boss_abilities), 2, "[kit_type] doesn't have its two abilities") TEST_ASSERT(istype(boss.ai_controller, /datum/ai_controller/basic_controller/bounty_boss), "[kit_type] doesn't have the boss AI") - var/list/table = boss.boss_health_table() - TEST_ASSERT_EQUAL(length(table), 4, "[kit_type] has no health for 1, 2, 3 and 4+ hunters") - TEST_ASSERT_EQUAL(boss.maxHealth, table[1], "[kit_type] doesn't start at its one-hunter health") - for(var/i in 2 to 4) - TEST_ASSERT(table[i] > table[i - 1], "[kit_type]'s health doesn't grow with the posse") - TEST_ASSERT(!(boss.status_flags & CANSTUN), "A fresh [kit_type] can be stunned") - TEST_ASSERT(boss.mob_size <= MOB_SIZE_LARGE, "[kit_type] is bigger than large") - TEST_ASSERT(ispath(boss.boss_kit_outfit(), /datum/outfit/bounty_boss), "[kit_type] has no boss outfit") - TEST_ASSERT(boss.boss_kit_outfit() != /datum/outfit/bounty_boss, "[kit_type] wears the plain boss outfit") + TEST_ASSERT_EQUAL(boss.npc_rank, 2, "[kit_type] isn't ranked a boss") // HUMAN_NPC_RANK_BOSS + // Toughness is armour and physiology, never health (defaults 1.5). + TEST_ASSERT_EQUAL(boss.maxHealth, 100, "[kit_type] has a health pool of [boss.maxHealth]") // MAX_LIVING_HEALTH + TEST_ASSERT(abs(boss.physiology.brute_mod - 0.6) < 0.01, "[kit_type] takes [boss.physiology.brute_mod] brute, not 0.6") // BOUNTY_BOSS_DAMAGE_TAKEN + TEST_ASSERT(abs(boss.physiology.burn_mod - 0.6) < 0.01, "[kit_type] takes [boss.physiology.burn_mod] burn, not 0.6") + TEST_ASSERT(boss.status_flags & CANSTUN, "[kit_type] can't be stunned") + TEST_ASSERT(boss.status_flags & CANKNOCKDOWN, "[kit_type] can't be knocked down") + // Its stimulants and a bruise pack, carried for real. + TEST_ASSERT_EQUAL(carried(boss, /obj/item/reagent_containers/hypospray/medipen/stimpack), 2, "[kit_type] doesn't carry its two stimulants") // BOUNTY_BOSS_STIMULANTS + TEST_ASSERT(carried(boss, /obj/item/stack/medical/bruise_pack) >= 1, "[kit_type] carries nothing to patch itself up with") + TEST_ASSERT(boss.boss_gear_text(), "[kit_type] has no gear line on examine") var/list/abilities = boss.boss_abilities.Copy() qdel(boss) TEST_ASSERT(QDELETED(boss), "[kit_type] didn't delete") for(var/datum/ability as anything in abilities) TEST_ASSERT(QDELETED(ability), "[kit_type]'s [ability.type] outlived it") - // Fireproof, not laser-proof. - var/mob/living/basic/bounty_criminal/boss/pyromaniac/pyro = allocate(/mob/living/basic/bounty_criminal/boss/pyromaniac) - TEST_ASSERT(HAS_TRAIT(pyro, TRAIT_NOFIRE), "The Pyromaniac can be set alight") - TEST_ASSERT(pyro.damage_coeff[BURN] >= 0.9, "The Pyromaniac shrugs off lasers") // BOUNTY_PYROMANIAC_BURN_MOD - -// ===== WIND-UP BEFORE DAMAGE; RESTRAINED OR DOWNED, NOTHING ===== + // The Juggernaut: riot armour, and a real gene for its size (CB-5, CB-21). + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/jugg = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut) + TEST_ASSERT(istype(jugg.wear_suit, /obj/item/clothing/suit/armor/riot), "The Juggernaut isn't wearing riot armour") + TEST_ASSERT(istype(jugg.head, /obj/item/clothing/head/helmet/toggleable/riot), "The Juggernaut isn't wearing a riot helmet") + TEST_ASSERT(HAS_TRAIT(jugg, TRAIT_GIANT), "The Juggernaut isn't a giant") + TEST_ASSERT_NOTNULL(jugg.dna.get_mutation(/datum/mutation/gigantism), "The Juggernaut's size isn't the gigantism gene") + + // The Pyromaniac: its fire suit and helmet keep fire off it, not a trait (CB-7). Its torch is a real one, lit. + var/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/pyro = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac) + TEST_ASSERT(!HAS_TRAIT(pyro, TRAIT_NOFIRE), "The Pyromaniac is fireproof by a trait") + TEST_ASSERT(!HAS_TRAIT(pyro, TRAIT_RESISTHEAT), "The Pyromaniac is heat-proof by a trait") + TEST_ASSERT(istype(pyro.wear_suit, /obj/item/clothing/suit/utility/fire/firefighter), "The Pyromaniac isn't wearing a firefighter suit") + TEST_ASSERT(istype(pyro.head, /obj/item/clothing/head/utility/hardhat/red), "The Pyromaniac isn't wearing a firefighter helmet") + TEST_ASSERT(pyro.get_thermal_protection() >= FIRE_SUIT_MAX_TEMP_PROTECT, "The Pyromaniac's gear doesn't keep the fire off it") + var/obj/item/flashlight/flare/torch/torch = locate() in pyro.held_items + TEST_ASSERT_NOTNULL(torch, "The Pyromaniac holds no torch") + TEST_ASSERT(torch.light_on && torch.damtype == BURN, "The Pyromaniac's torch isn't lit") + + // The Demolitionist: a hard hat, and its crowbar in its bag until the fight starts. + var/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist/demo = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist) + TEST_ASSERT(istype(demo.head, /obj/item/clothing/head/utility/hardhat), "The Demolitionist isn't wearing a hard hat") + TEST_ASSERT(istype(demo.belt, /obj/item/storage/belt/bandolier), "The Demolitionist has no bandolier") + var/obj/item/crowbar/large/crowbar = locate() in demo.get_all_contents_type(/obj/item/crowbar/large) + TEST_ASSERT_NOTNULL(crowbar, "The Demolitionist carries no crowbar") + TEST_ASSERT(!demo.is_holding(crowbar), "The Demolitionist has its crowbar out before any fight") + + // The Ghost: its hood up, its knife in a pocket, and real chrome for its quickness (OC-6 ruling). + var/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/ghost = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/ghost) + TEST_ASSERT(istype(ghost.head, /obj/item/clothing/head/hooded/chaplain_hood), "The Ghost's hood isn't up") + var/obj/item/knife/combat/knife = locate() in ghost.get_all_contents_type(/obj/item/knife/combat) + TEST_ASSERT_NOTNULL(knife, "The Ghost carries no combat knife") + TEST_ASSERT(!ghost.is_holding(knife), "The Ghost has its knife out before any fight") + TEST_ASSERT_NOTNULL(locate(/obj/item/organ/cyberimp/cyberware/slipwire) in ghost.organs, "The Ghost has no Slipwire") + TEST_ASSERT_NOTNULL(locate(/obj/item/organ/cyberimp/cyberware/cascade) in ghost.organs, "The Ghost has no Cascade lattice") + + // The Heavy: SWAT armour, a real L6 with a belt in it, a spare box and two barrier grenades (CB-13, CB-26). + var/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/heavy = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/heavy) + TEST_ASSERT(istype(heavy.wear_suit, /obj/item/clothing/suit/armor/swat), "The Heavy isn't wearing SWAT armour") + TEST_ASSERT(istype(heavy.head, /obj/item/clothing/head/helmet/swat), "The Heavy isn't wearing a SWAT helmet") + var/obj/item/gun/ballistic/automatic/l6_saw/gun = heavy.boss_gun() + TEST_ASSERT_NOTNULL(gun, "The Heavy holds no belt-fed gun") + TEST_ASSERT(gun.can_shoot(), "The Heavy's gun isn't loaded") + TEST_ASSERT(heavy.boss_hands_free_for(gun), "The Heavy's other hand isn't free to fire") + TEST_ASSERT_EQUAL(carried(heavy, /obj/item/ammo_box/magazine/m7mm), 2, "The Heavy has no spare box beside the one in its gun") + TEST_ASSERT_EQUAL(carried(heavy, /obj/item/grenade/barrier/bounty_boss), 2, "The Heavy doesn't carry its two barrier grenades") // BOUNTY_HEAVY_BARRIERS + +// ===== WIND-UP BEFORE DAMAGE; TG'S STATES STOP IT (CB-24) ===== /datum/unit_test/voidcrew_bounty_boss/windup /datum/unit_test/voidcrew_bounty_boss/windup/Run() - var/mob/living/basic/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/basic/bounty_criminal/boss/juggernaut, spot(0, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(0, 0)) var/mob/living/carbon/human/consistent/victim = hunter_at(spot(1, 0)) var/datum/action/cooldown/mob_cooldown/bounty_boss/slam/slam = ability_of(boss, /datum/action/cooldown/mob_cooldown/bounty_boss/slam) TEST_ASSERT_NOTNULL(slam, "The Juggernaut has no slam") @@ -147,106 +209,54 @@ var/mob/living/carbon/human/consistent/second = hunter_at(spot(0, 1)) - // Restrained: it can't start one. + // Restrained (tg's TRAIT_RESTRAINED): it can't start one. ready(boss) - boss.restraints = new /obj/item/restraints/handcuffs(boss) + ADD_TRAIT(boss, TRAIT_RESTRAINED, "bounty_boss_test") TEST_ASSERT(!boss.boss_can_act(), "A cuffed boss can act") TEST_ASSERT(!slam.IsAvailable(), "A cuffed boss's ability is available") TEST_ASSERT(!slam.Trigger(target = second), "A cuffed boss started an ability") TEST_ASSERT_NULL(boss.boss_busy, "A cuffed boss began a wind-up") - qdel(boss.restraints) - boss.restraints = null + REMOVE_TRAIT(boss, TRAIT_RESTRAINED, "bounty_boss_test") - // Downed: it can't start one. - boss.downed = TRUE - TEST_ASSERT(!slam.IsAvailable(), "A downed boss's ability is available") - TEST_ASSERT(!slam.Trigger(target = second), "A downed boss started an ability") - boss.downed = FALSE + // Knocked down (tg's Knockdown): it can't start one either. + boss.Knockdown(5 SECONDS) + TEST_ASSERT(!slam.IsAvailable(), "A knocked-down boss's ability is available") + boss.SetKnockdown(0) // Cuffed during the wind-up: the telegraph goes and nothing lands. ready(boss) TEST_ASSERT(slam.Trigger(target = second), "The slam didn't start again") var/serial = slam.pending_serial - SEND_SIGNAL(boss, "bounty_criminal_restrained", null) // COMSIG_BOUNTY_CRIMINAL_RESTRAINED + ADD_TRAIT(boss, TRAIT_RESTRAINED, "bounty_boss_test") TEST_ASSERT(!length(slam.telegraphs), "The telegraph stayed after the boss was cuffed") TEST_ASSERT_NULL(boss.boss_busy, "The boss kept winding up after it was cuffed") TEST_ASSERT(!slam.finish_windup(serial), "A cancelled wind-up still landed") TEST_ASSERT_EQUAL(second.getBruteLoss(), 0, "A cancelled slam hurt someone") + REMOVE_TRAIT(boss, TRAIT_RESTRAINED, "bounty_boss_test") - // Downed during the wind-up, with no signal: the check when it ends still stops it. + // Stunned during the wind-up (tg's Stun): the same. ready(boss) TEST_ASSERT(slam.Trigger(target = second), "The slam didn't start a third time") - boss.downed = TRUE - TEST_ASSERT(!slam.finish_windup(slam.pending_serial), "A downed boss's wind-up landed") - TEST_ASSERT_EQUAL(second.getBruteLoss(), 0, "A downed boss's slam hurt someone") - boss.downed = FALSE - -// ===== TIRED BELOW 40%; STAMINA ONLY THEN (H3) ===== - -/datum/unit_test/voidcrew_bounty_boss/tired - -/datum/unit_test/voidcrew_bounty_boss/tired/Run() - var/mob/living/basic/bounty_criminal/boss/heavy/heavy = allocate(/mob/living/basic/bounty_criminal/boss/heavy, spot(0, 0)) - TEST_ASSERT(!heavy.boss_tired, "A fresh boss is tired") - TEST_ASSERT(!(heavy.status_flags & (CANSTUN | CANKNOCKDOWN)), "A fresh boss can be stunned or knocked down") - TEST_ASSERT_EQUAL(heavy.damage_coeff[STAMINA], 0, "A fresh boss takes stamina damage") // BOUNTY_HEAVY_STAMINA_FRESH - TEST_ASSERT_NULL(heavy.body_last_alert, "A fresh boss showed [heavy.body_last_alert]") - var/fresh_speed = heavy.speed - - // Down to 38%, under BOUNTY_BOSS_TIRED_BELOW (40) - heavy.adjustBruteLoss(heavy.maxHealth * 0.62, forced = TRUE) - TEST_ASSERT(heavy.boss_tired, "A boss at [heavy.health]/[heavy.maxHealth] isn't tired") - // The stun window opening shows over it, not only in chat (P4 polish) - TEST_ASSERT_EQUAL(heavy.body_last_alert, "worn out", "Tiring showed [heavy.body_last_alert || "nothing"] over the boss") - TEST_ASSERT(heavy.status_flags & CANSTUN, "A tired boss can't be stunned") - TEST_ASSERT(heavy.status_flags & CANKNOCKDOWN, "A tired boss can't be knocked down") - // BOUNTY_BOSS_STAMINA_TIRED 1 against BOUNTY_HEAVY_STAMINA 180, as max_stamina is 100 - TEST_ASSERT(abs(heavy.damage_coeff[STAMINA] - 100 / 180) < 0.001, "A tired Heavy's stamina coefficient is [heavy.damage_coeff[STAMINA]]") - TEST_ASSERT(abs(heavy.speed - (fresh_speed + 0.3)) < 0.001, "A tired boss isn't slower") // BOUNTY_BOSS_TIRED_SLOWDOWN - TEST_ASSERT_EQUAL(heavy.boss_cooldown_mult(), 1.5, "A tired boss's cooldowns don't stretch") // BOUNTY_BOSS_TIRED_COOLDOWN_MULT - heavy.adjustStaminaLoss(200) - TEST_ASSERT(heavy.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "Stamina weapons don't put a tired boss down") - TEST_ASSERT(!heavy.boss_can_act(), "A stamina-crit boss can still act") - - // Healed back over the line, it is fresh again. - var/mob/living/basic/bounty_criminal/boss/juggernaut/healed = allocate(/mob/living/basic/bounty_criminal/boss/juggernaut, spot(4, 0)) - healed.adjustBruteLoss(healed.maxHealth * 0.7, forced = TRUE) - TEST_ASSERT(healed.boss_tired, "The boss didn't tire") - healed.adjustBruteLoss(-healed.maxHealth, forced = TRUE) - TEST_ASSERT(!healed.boss_tired, "A healed boss is still tired") - TEST_ASSERT(!(healed.status_flags & CANSTUN), "A healed boss can still be stunned") - -/// Steady disabler fire on a fresh boss neither slows it nor builds up; once tired, it takes the whole pool (review H3) -/datum/unit_test/voidcrew_bounty_boss/stamina + serial = slam.pending_serial + boss.Stun(5 SECONDS) + TEST_ASSERT_NULL(boss.boss_busy, "The boss kept winding up after it was stunned") + TEST_ASSERT(!slam.finish_windup(serial), "A stunned boss's wind-up landed") + boss.SetStun(0) -/datum/unit_test/voidcrew_bounty_boss/stamina/Run() - var/mob/living/basic/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/basic/bounty_criminal/boss/juggernaut, spot(0, 0)) - var/fresh_speed = boss.speed - for(var/i in 1 to 25) - boss.adjustStaminaLoss(30) // a disabler shot - TEST_ASSERT_EQUAL(boss.staminaloss, 0, "Disabler fire built up on a fresh boss") - TEST_ASSERT_EQUAL(boss.speed, fresh_speed, "Disabler fire slowed a fresh boss") - TEST_ASSERT(!boss.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "Disabler fire put a fresh boss down") - - // Whatever it had built up is wiped when it tires. - boss.adjustStaminaLoss(80, forced = TRUE) - boss.adjustBruteLoss(boss.maxHealth * 0.65, forced = TRUE) - TEST_ASSERT(boss.boss_tired, "The boss didn't tire") - TEST_ASSERT_EQUAL(boss.staminaloss, 0, "The boss tired with stamina already built up") - - // Tired: four disabler shots don't do it (BOUNTY_BOSS_STAMINA 150), the fifth does. - for(var/i in 1 to 4) - boss.adjustStaminaLoss(30) - TEST_ASSERT(!boss.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "Four disabler shots put a tired boss down") - boss.adjustStaminaLoss(30) - TEST_ASSERT(boss.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "Five disabler shots didn't put a tired boss down") + // Into crit during the wind-up, by real damage: the same. + ready(boss) + TEST_ASSERT(slam.Trigger(target = second), "The slam didn't start a fourth time") + serial = slam.pending_serial + TEST_ASSERT(put_in_crit(boss), "Test fixture: the boss isn't in crit") + TEST_ASSERT(!slam.finish_windup(serial), "A downed boss's wind-up landed") + TEST_ASSERT_EQUAL(second.getBruteLoss(), 0, "A downed boss's slam hurt someone") // ===== WHAT IT MAY BREAK, AND HOW (H1, M1, L2) ===== /datum/unit_test/voidcrew_bounty_boss/structures /datum/unit_test/voidcrew_bounty_boss/structures/Run() - var/mob/living/basic/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/basic/bounty_criminal/boss/juggernaut, spot(0, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(0, 0)) var/turf/middle = spot(2, 2) change_turf(middle, /turf/closed/wall) TEST_ASSERT(boss.boss_may_break(middle), "The boss may not break a plain interior wall") @@ -326,13 +336,14 @@ /datum/unit_test/voidcrew_bounty_boss/near_ships /datum/unit_test/voidcrew_bounty_boss/near_ships/Run() - var/mob/living/basic/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/basic/bounty_criminal/boss/juggernaut, spot(0, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(0, 0)) var/turf/middle = spot(2, 2) change_turf(middle, /turf/closed/wall) var/mob/living/carbon/human/consistent/hunter = hunter_at(spot(4, 4)) TEST_ASSERT(boss.boss_may_break(middle), "The boss may not break an interior wall before any ship is near") TEST_ASSERT(boss.boss_landing_ok(get_turf(hunter)), "The boss may not aim at a hunter before any ship is near") - TEST_ASSERT(boss.boss_can_hurt(hunter), "The boss may not hurt a hunter before any ship is near") + TEST_ASSERT(boss.boss_valid_target(hunter), "The boss won't go after a hunter before any ship is near") + TEST_ASSERT(boss.boss_effect_hits(hunter), "The boss's fire and blasts don't reach a hunter before any ship is near") // A ship's tile in the room, within BOUNTY_ENV_SAFE_RANGE (7) of everything here. var/turf/ship_floor = make_ship_tile(spot(4, 0)) @@ -343,7 +354,8 @@ // Standing inside the ship, a hunter is out of its reach altogether. hunter.forceMove(ship_floor) - TEST_ASSERT(!boss.boss_can_hurt(hunter), "The boss may hurt a hunter inside their ship") + TEST_ASSERT(!boss.boss_valid_target(hunter), "The boss goes after a hunter inside their ship") + TEST_ASSERT(!boss.boss_effect_hits(hunter), "The boss's fire and blasts reach inside a ship") TEST_ASSERT(!boss.boss_reach_ok(ship_floor), "The boss's fire and blasts may reach inside a ship") // ===== NEVER THE SAME ABILITY TWICE IN A ROW WHILE ANOTHER IS READY ===== @@ -352,7 +364,7 @@ /datum/unit_test/voidcrew_bounty_boss/rotation/Run() // Two abilities both worth using: they alternate. - var/mob/living/basic/bounty_criminal/boss/pyromaniac/pyro = allocate(/mob/living/basic/bounty_criminal/boss/pyromaniac, spot(0, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/pyro = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac, spot(0, 0)) var/mob/living/carbon/human/consistent/near = hunter_at(spot(2, 0)) var/last_type for(var/i in 1 to 20) @@ -385,7 +397,7 @@ TEST_ASSERT(other && other.type == molotov.type, "The flamer repeated while the molotov was off cooldown") // Only one ability worth using: it repeats; strictly, nothing (the hoarfrost rotation). - var/mob/living/basic/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/basic/bounty_criminal/boss/juggernaut, spot(0, 3)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(0, 3)) var/mob/living/carbon/human/consistent/far = hunter_at(spot(3, 3)) var/datum/action/cooldown/mob_cooldown/bounty_boss/first = boss.boss_choose_ability(far) TEST_ASSERT(istype(first, /datum/action/cooldown/mob_cooldown/bounty_boss/charge), "The Juggernaut didn't choose to charge someone three tiles off") @@ -394,73 +406,49 @@ boss.boss_strict_rotation = TRUE TEST_ASSERT_NULL(boss.boss_choose_ability(far), "The strict rotation chose the same ability twice in a row") -// ===== SUMMONED THINGS CLEAN UP; CAPS HOLD ===== - -/datum/unit_test/voidcrew_bounty_boss/cleanup - -/datum/unit_test/voidcrew_bounty_boss/cleanup/Run() - // Telegraphs go with a cancelled wind-up. - var/mob/living/basic/bounty_criminal/boss/juggernaut/jugg = allocate(/mob/living/basic/bounty_criminal/boss/juggernaut, spot(2, 2)) - var/mob/living/carbon/human/consistent/beside = hunter_at(spot(3, 2)) - var/datum/action/cooldown/mob_cooldown/bounty_boss/slam/slam = ability_of(jugg, /datum/action/cooldown/mob_cooldown/bounty_boss/slam) - TEST_ASSERT(slam.Trigger(target = beside), "The slam didn't start") - TEST_ASSERT(marks_near(jugg), "The slam left no marks") - jugg.boss_interrupt() - TEST_ASSERT_EQUAL(marks_near(jugg), 0, "The slam's marks outlived the interrupted wind-up") - qdel(jugg) - qdel(beside) - - // Barricades: one from the ability, folding away on its own; a global cap. - TEST_ASSERT_EQUAL(length(GLOB.bounty_boss_barricades), 0, "Barricades were standing before the test") - var/mob/living/basic/bounty_criminal/boss/heavy/heavy = allocate(/mob/living/basic/bounty_criminal/boss/heavy, spot(0, 0)) - var/mob/living/carbon/human/consistent/target = hunter_at(spot(4, 0)) - var/datum/action/cooldown/mob_cooldown/bounty_boss/barricade/barricade = ability_of(heavy, /datum/action/cooldown/mob_cooldown/bounty_boss/barricade) - TEST_ASSERT(barricade.worth_using(target), "The Heavy won't put up a barricade") - TEST_ASSERT(barricade.Trigger(target = target), "The barricade didn't start") - TEST_ASSERT(barricade.finish_windup(barricade.pending_serial), "The barricade didn't go up") - var/obj/structure/barricade/security/bounty_boss/barrier = locate() in spot(1, 0) - TEST_ASSERT_NOTNULL(barrier, "No barricade in front of the Heavy") - TEST_ASSERT(barrier in GLOB.bounty_boss_barricades, "The barricade isn't counted") - barrier.fold_away() - TEST_ASSERT(QDELETED(barrier), "The barricade didn't fold away") - TEST_ASSERT_EQUAL(length(GLOB.bounty_boss_barricades), 0, "A folded barricade is still counted") - - var/list/made = list() - for(var/i in 1 to 9) - made += new /obj/structure/barricade/security/bounty_boss(spot(i % 5, 4)) - TEST_ASSERT_EQUAL(length(GLOB.bounty_boss_barricades), 8, "The barricade cap didn't hold") // BOUNTY_BOSS_BARRICADE_CAP - for(var/obj/structure/barricade/security/bounty_boss/extra as anything in made) - if(!QDELETED(extra)) - qdel(extra) - TEST_ASSERT_EQUAL(length(GLOB.bounty_boss_barricades), 0, "Deleted barricades are still counted") +// ===== FIRE IS TG'S FIRE, ON ANYONE IT CATCHES (CB-8, CB-11) ===== - // Barricades a boss keeps: a new one folds up its oldest. - var/list/mine = list() - for(var/i in 1 to 3) - var/obj/structure/barricade/security/bounty_boss/one = new(spot(i, 3)) - mine += one - barricade.barriers += WEAKREF(one) - barricade.prune_barriers() - TEST_ASSERT(QDELETED(mine[1]), "The Heavy's oldest barricade stayed past its limit") // BOUNTY_BOSS_BARRICADES_PER_BOSS - TEST_ASSERT_EQUAL(length(barricade.barriers), 2, "The Heavy keeps the wrong number of barricades") - for(var/obj/structure/barricade/security/bounty_boss/kept as anything in mine) - if(!QDELETED(kept)) - qdel(kept) +/datum/unit_test/voidcrew_bounty_boss/fire - // Fire: it burns who it may, never the boss, and goes out. - var/mob/living/basic/bounty_criminal/boss/pyromaniac/pyro = allocate(/mob/living/basic/bounty_criminal/boss/pyromaniac, spot(0, 2)) +/datum/unit_test/voidcrew_bounty_boss/fire/Run() + var/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/pyro = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac, spot(0, 2)) var/mob/living/carbon/human/consistent/walker = hunter_at(spot(2, 2)) - var/obj/effect/bounty_boss_fire_pool/pool = new(spot(2, 2), list(spot(0, 2), spot(2, 2)), 4 SECONDS, pyro, 10) + var/mob/living/carbon/human/consistent/downed = hunter_at(spot(3, 2)) + TEST_ASSERT(put_in_crit(downed), "Test fixture: the second hunter isn't in crit") + + var/obj/effect/bounty_boss_fire_pool/pool = new(spot(2, 2), list(spot(0, 2), spot(2, 2), spot(3, 2)), 4 SECONDS, pyro, 10, 4) TEST_ASSERT(!QDELETED(pool), "The fire went out at once") TEST_ASSERT(pool in GLOB.bounty_boss_fire_pools, "The fire isn't counted") - TEST_ASSERT(walker.getFireLoss() > 0, "The fire didn't burn someone standing in it") - TEST_ASSERT(walker.has_status_effect(/datum/status_effect/bounty_boss_burning), "The fire didn't set someone alight") + TEST_ASSERT(walker.getFireLoss() > 0, "The fire's landing didn't burn someone standing in it") + TEST_ASSERT(walker.fire_stacks > 0, "The fire put no fire stacks on someone standing in it") + TEST_ASSERT(walker.on_fire, "The fire didn't set someone standing in it alight") + TEST_ASSERT(downed.fire_stacks > 0, "The fire put no fire stacks on someone in crit") + TEST_ASSERT(downed.on_fire, "The fire didn't set someone in crit alight") TEST_ASSERT_EQUAL(pyro.getFireLoss(), 0, "The Pyromaniac's own fire burned it") + TEST_ASSERT(!pyro.on_fire, "The Pyromaniac's own fire set it alight") + + // Every second in the flames adds to the fire, standing or not. + var/stacks_before = downed.fire_stacks + pool.scorch() + TEST_ASSERT(downed.fire_stacks > stacks_before, "Lying in the flames added no fire stacks") + + // Once lit, it is tg's fire: putting it out is tg's too. + walker.extinguish_mob() + TEST_ASSERT(!walker.on_fire, "A boss's fire couldn't be put out the tg way") + downed.extinguish_mob() + pool.burn_out() TEST_ASSERT(QDELETED(pool), "The fire didn't go out") TEST_ASSERT(!(pool in GLOB.bounty_boss_fire_pools), "A fire that went out is still counted") - walker.remove_status_effect(/datum/status_effect/bounty_boss_burning) - TEST_ASSERT(!walker.has_status_effect(/datum/status_effect/bounty_boss_burning), "The burning didn't end") + + // With its boss gone, it still burns anyone not on the boss's side. + var/obj/effect/bounty_boss_fire_pool/orphan = new(spot(2, 2), list(spot(2, 2)), 4 SECONDS, pyro) + qdel(pyro) + walker.set_fire_stacks(0) + orphan.scorch() + TEST_ASSERT(walker.on_fire, "A fire whose boss is gone didn't burn anyone") + walker.extinguish_mob() + qdel(orphan) // The fire cap. var/list/pools = list() @@ -471,23 +459,47 @@ if(!QDELETED(extra_pool)) qdel(extra_pool) TEST_ASSERT_EQUAL(length(GLOB.bounty_boss_fire_pools), 0, "Deleted fire pools are still counted") + walker.extinguish_mob() + downed.extinguish_mob() + +// ===== BLASTS ARE TG'S LIGHT EXPLOSION, ON ANYONE THEY CATCH (CB-10, CB-11) ===== + +/datum/unit_test/voidcrew_bounty_boss/blasts + /// Severity of the last explosion that reached the watched victim + var/blast_severity = 0 + +/datum/unit_test/voidcrew_bounty_boss/blasts/proc/on_ex_act(datum/source, severity, target, origin) + SIGNAL_HANDLER + blast_severity = severity - // A grenade: nothing until its fuse runs out, never its thrower, then gone. - var/mob/living/basic/bounty_criminal/boss/demolitionist/demo = allocate(/mob/living/basic/bounty_criminal/boss/demolitionist, spot(2, 4)) +/datum/unit_test/voidcrew_bounty_boss/blasts/Run() + var/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist/demo = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist, spot(2, 4)) var/mob/living/carbon/human/consistent/caught = hunter_at(spot(4, 4)) + TEST_ASSERT(put_in_crit(caught), "Test fixture: the hunter isn't in crit") + RegisterSignal(caught, COMSIG_ATOM_EX_ACT, PROC_REF(on_ex_act)) var/obj/effect/bounty_boss_explosive/grenade = new(spot(3, 4), demo) TEST_ASSERT(grenade in GLOB.bounty_boss_explosives, "The grenade isn't counted") - TEST_ASSERT_EQUAL(caught.getBruteLoss(), 0, "The grenade hurt someone before its fuse ran out") + var/before = caught.getBruteLoss() + TEST_ASSERT_EQUAL(blast_severity, 0, "The grenade went off before its fuse ran out") grenade.detonate() - TEST_ASSERT(caught.getBruteLoss() > 0, "The grenade didn't hurt someone next to it") + TEST_ASSERT_EQUAL(blast_severity, EXPLODE_LIGHT, "The grenade's blast didn't reach someone in crit as tg's light explosion") + TEST_ASSERT(caught.getBruteLoss() > before, "The grenade's blast didn't hurt someone in crit next to it") TEST_ASSERT_EQUAL(demo.getBruteLoss(), 0, "The grenade hurt the Demolitionist who threw it") TEST_ASSERT(QDELETED(grenade), "The grenade is still there after going off") TEST_ASSERT_EQUAL(length(GLOB.bounty_boss_explosives), 0, "A spent grenade is still counted") + UnregisterSignal(caught, COMSIG_ATOM_EX_ACT) + + // A blast never goes through a wall. + var/mob/living/carbon/human/consistent/behind = hunter_at(spot(0, 0)) + change_turf(spot(1, 0), /turf/closed/wall/r_wall) + var/obj/effect/bounty_boss_explosive/walled = new(spot(2, 0), demo) + walled.detonate() + TEST_ASSERT_EQUAL(behind.getBruteLoss(), 0, "A blast reached through a wall") // The explosive cap. var/list/bombs = list() for(var/i in 1 to 17) - bombs += new /obj/effect/bounty_boss_explosive(spot(i % 5, 0)) + bombs += new /obj/effect/bounty_boss_explosive(spot(i % 5, 1)) TEST_ASSERT_EQUAL(length(GLOB.bounty_boss_explosives), 16, "The explosive cap didn't hold") // BOUNTY_BOSS_EXPLOSIVE_CAP for(var/obj/effect/bounty_boss_explosive/extra_bomb as anything in bombs) if(!QDELETED(extra_bomb)) @@ -503,108 +515,193 @@ TEST_ASSERT(!blocked(spot(2, 3)), "The breached airlock left something in the way") TEST_ASSERT_EQUAL(demo.boss_walls_left, 1, "Breaching the airlock didn't spend the budget") -// ===== DOWNED HUNTERS ARE LEFT ALONE (C4, M3) ===== +// ===== ITS CHOICE OF TARGET SPARES THE DOWNED; ITS EFFECTS DON'T (CB-11) ===== /datum/unit_test/voidcrew_bounty_boss/downed_hunters /datum/unit_test/voidcrew_bounty_boss/downed_hunters/Run() - var/mob/living/basic/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/basic/bounty_criminal/boss/juggernaut, spot(0, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(0, 0)) var/mob/living/carbon/human/consistent/victim = hunter_at(spot(1, 0)) - victim.apply_status_effect(/datum/status_effect/bounty_boss_burning) - victim.apply_status_effect(/datum/status_effect/bounty_boss_bleed) - TEST_ASSERT(victim.has_status_effect(/datum/status_effect/bounty_boss_burning), "The hunter didn't catch fire") - TEST_ASSERT(victim.has_status_effect(/datum/status_effect/bounty_boss_bleed), "The hunter didn't bleed") - victim.adjustBruteLoss(120) - TEST_ASSERT(victim.stat != CONSCIOUS && victim.stat != DEAD, "The hunter isn't down") - TEST_ASSERT(!boss.boss_can_hurt(victim), "The boss may hurt a downed hunter") - TEST_ASSERT(!(victim in boss.boss_victims_on(list(get_turf(victim)))), "Area abilities catch a downed hunter") - var/datum/status_effect/burning = victim.has_status_effect(/datum/status_effect/bounty_boss_burning) - burning?.tick(1) - var/datum/status_effect/bleeding = victim.has_status_effect(/datum/status_effect/bounty_boss_bleed) - bleeding?.tick(1) - TEST_ASSERT(!victim.has_status_effect(/datum/status_effect/bounty_boss_burning), "A downed hunter keeps burning") - TEST_ASSERT(!victim.has_status_effect(/datum/status_effect/bounty_boss_bleed), "A downed hunter keeps bleeding from the cuts") - TEST_ASSERT(!victim.apply_status_effect(/datum/status_effect/bounty_boss_burning), "A downed hunter can be set alight") - -// ===== HEALTH GROWS WITH THE POSSE (M4) ===== + TEST_ASSERT(boss.boss_valid_target(victim), "The boss won't go after a hunter on their feet") + TEST_ASSERT(put_in_crit(victim), "Test fixture: the hunter isn't down") + TEST_ASSERT(!boss.boss_valid_target(victim), "The boss chooses to go after a downed hunter") + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(/datum/targeting_strategy/basic/human_npc/bounty_boss) + TEST_ASSERT(!strategy.can_attack(boss, victim, 9), "The boss's targeting picks a downed hunter") + // What its abilities catch is whoever is there. + TEST_ASSERT(boss.boss_effect_hits(victim), "The boss's fire and blasts skip a downed hunter") + TEST_ASSERT(victim in boss.boss_victims_on(list(get_turf(victim))), "Area abilities skip a downed hunter") + var/datum/action/cooldown/mob_cooldown/bounty_boss/slam/slam = ability_of(boss, /datum/action/cooldown/mob_cooldown/bounty_boss/slam) + var/mob/living/carbon/human/consistent/standing = hunter_at(spot(0, 1)) + var/before = victim.getBruteLoss() + TEST_ASSERT(slam.Trigger(target = standing), "The slam didn't start") + TEST_ASSERT(slam.finish_windup(slam.pending_serial), "The slam didn't land") + TEST_ASSERT(victim.getBruteLoss() > before, "The slam passed over a downed hunter beside the boss") + // Never its own side. + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/friend = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(1, 1)) + TEST_ASSERT(!boss.boss_effect_hits(friend), "The boss's fire and blasts catch another criminal") + +// ===== THE POSSE: ONE MORE COMPANION PER EXTRA HUNTER (OC-8, CB-1) ===== /datum/unit_test/voidcrew_bounty_boss/posse /datum/unit_test/voidcrew_bounty_boss/posse/Run() - var/mob/living/basic/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/basic/bounty_criminal/boss/juggernaut, spot(0, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(0, 0)) var/mob/living/carbon/human/consistent/first = hunter_at(spot(4, 4)) var/mob/living/carbon/human/consistent/second = hunter_at(spot(3, 4)) var/mob/living/carbon/human/consistent/third = hunter_at(spot(2, 4)) var/mob/living/carbon/human/consistent/fourth = hunter_at(spot(1, 4)) var/mob/living/carbon/human/consistent/fifth = hunter_at(spot(0, 4)) - // BOUNTY_JUGGERNAUT_HEALTH_1 to _4: 300, 950, 1600, 2300 - TEST_ASSERT_EQUAL(boss.maxHealth, 300, "The Juggernaut doesn't start at its one-hunter health") + boss.boss_hostile = TRUE // Only hunters on its grudge list (or hunting its bounty) count. TEST_ASSERT(!boss.boss_engage(first), "A hunter who never touched it joined the posse") TEST_ASSERT(posse_member(boss, first), "The first hunter didn't join the posse") - TEST_ASSERT_EQUAL(boss.maxHealth, 300, "One hunter raised the health") + TEST_ASSERT_EQUAL(boss.boss_reinforcements_owed, 0, "One hunter brought in a companion") TEST_ASSERT(!boss.boss_engage(first), "The same hunter joined twice") - // It sizes up the bigger posse in its kit's own words (BUG-2: "_posse" had no lines) + TEST_ASSERT_EQUAL(boss.maxHealth, 100, "The posse changed the boss's health") + + // The second hunter owes one companion, and it sizes them up in its kit's own words (BUG-2). var/datum/component/bounty_identity_voice/voice = boss.LoadComponent(/datum/component/bounty_identity_voice) voice.line_cooldown = 0 voice.last_line = null TEST_ASSERT(posse_member(boss, second), "The second hunter didn't join") - TEST_ASSERT_EQUAL(boss.maxHealth, 950, "Two hunters didn't raise the health") + TEST_ASSERT_EQUAL(boss.boss_reinforcements_owed, 1, "Two hunters didn't call in a companion") + TEST_ASSERT_NOTNULL(boss.boss_reinforce_timer, "The companion owed wasn't scheduled") TEST_ASSERT(voice.last_line in bounty_identity_strings("lines")["juggernaut_posse"]["any"], "Sizing up two hunters, the Juggernaut said [voice.last_line || "nothing"]") - TEST_ASSERT_EQUAL(boss.health, 950, "A fresh boss's raise didn't lift current health") // Someone with no mind isn't a hunter. var/mob/living/carbon/human/consistent/bystander = allocate(/mob/living/carbon/human/consistent, spot(4, 3)) boss.body_add_grudge(bystander) TEST_ASSERT(!boss.boss_engage(bystander), "A mindless bystander joined the posse") + TEST_ASSERT_EQUAL(boss.boss_reinforcements_owed, 1, "A mindless bystander called in a companion") - // Tired, a raise keeps its share of health: it is never healed out of its capture window. - boss.adjustBruteLoss(boss.maxHealth * 0.7, forced = TRUE) - TEST_ASSERT(boss.boss_tired, "The boss didn't tire") - var/share = boss.health / boss.maxHealth + // One per hunter beyond the first, up to BOUNTY_BOSS_REINFORCEMENTS_MAX (3). TEST_ASSERT(posse_member(boss, third), "The third hunter didn't join") - TEST_ASSERT_EQUAL(boss.maxHealth, 1600, "Three hunters didn't raise max health") - TEST_ASSERT(abs(boss.health / boss.maxHealth - share) < 0.01, "A tired boss's raise healed it from [share] to [boss.health / boss.maxHealth]") - TEST_ASSERT(boss.boss_tired, "A raise healed the boss out of being tired") - - // Downed, a newcomer waits; they count when it gets up, capped at the 4+ value. - boss.downed = TRUE - TEST_ASSERT(posse_member(boss, fourth), "The fourth hunter wasn't noted while it was down") - TEST_ASSERT(posse_member(boss, fifth), "The fifth hunter wasn't noted while it was down") - TEST_ASSERT_EQUAL(boss.maxHealth, 1600, "A downed boss's health rose") - boss.downed = FALSE - share = boss.health / boss.maxHealth - SEND_SIGNAL(boss, "bounty_criminal_recovered") // COMSIG_BOUNTY_CRIMINAL_RECOVERED - TEST_ASSERT_EQUAL(boss.maxHealth, 2300, "Hunters who joined while it was down didn't count when it got up") - TEST_ASSERT(abs(boss.health / boss.maxHealth - share) < 0.01, "Getting up with a bigger posse healed it") - - // Never lowered. + TEST_ASSERT_EQUAL(boss.boss_reinforcements_owed, 2, "Three hunters didn't call in two companions") + TEST_ASSERT(posse_member(boss, fourth), "The fourth hunter didn't join") + TEST_ASSERT(posse_member(boss, fifth), "The fifth hunter didn't join") + TEST_ASSERT_EQUAL(boss.boss_reinforcements_owed, 3, "Five hunters called in more than three companions") + + // Each one called is a real human NPC queued through the spawn queue, joined to the boss. + var/datum/human_npc_order/order = boss.boss_send_reinforcement(spot(4, 0)) + TEST_ASSERT(istype(order, /datum/human_npc_order), "Calling a companion in queued no human NPC") + TEST_ASSERT_EQUAL(boss.boss_reinforcements_sent, 1, "The companion called in wasn't counted") + TEST_ASSERT_EQUAL(boss.boss_reinforcements_owed, 2, "The companion called in is still owed") + // Cancelled here, so no body turns up after the test. + qdel(order) + + // Companions already sent count: a posse that shrinks and grows again owes nothing new. + boss.boss_reinforcements_owed = 0 + boss.boss_reinforcements_sent = 3 boss.boss_engaged.Cut() - boss.boss_engage(first) - TEST_ASSERT_EQUAL(boss.maxHealth, 2300, "A smaller posse lowered the health") + posse_member(boss, first) + posse_member(boss, second) + TEST_ASSERT_EQUAL(boss.boss_reinforcements_owed, 0, "Companions already sent were called in again") + + // They come in a way off, on open ground (who can see the spot is read from players with clients, and tests have none). + var/turf/arrival = boss.boss_reinforcement_spot() + if(arrival) + TEST_ASSERT(get_dist(arrival, boss) >= 5, "A companion would come in [get_dist(arrival, boss)] tiles from the boss") // BOUNTY_BOSS_REINFORCE_MIN_DIST + TEST_ASSERT(!arrival.is_blocked_turf(), "A companion would come in on a blocked tile") + + // Dead, it calls nobody. + boss.boss_reinforcements_owed = 1 + boss.boss_schedule_reinforcement() + boss.death() + TEST_ASSERT_NULL(boss.boss_reinforce_timer, "A dead boss still calls in companions") + TEST_ASSERT_EQUAL(boss.boss_reinforcements_owed, 0, "A dead boss still owes companions") // Confronted: it turns on whoever confronted it. - var/mob/living/basic/bounty_criminal/boss/juggernaut/other = allocate(/mob/living/basic/bounty_criminal/boss/juggernaut, spot(0, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/other = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(0, 2)) other.on_confronted(first) TEST_ASSERT(other.boss_hostile, "A confronted boss didn't turn hostile") TEST_ASSERT(other.body_has_grudge(first), "A confronted boss has no grudge against who confronted it") TEST_ASSERT_EQUAL(other.ai_controller?.blackboard[BB_BASIC_MOB_CURRENT_TARGET], first, "A confronted boss isn't going after who confronted it") +// ===== WORN OUT AND THE STIMULANT: REAL STATE, REAL PENS (CB-2, CB-4, CR-4) ===== + +/datum/unit_test/voidcrew_bounty_boss/stamina + +/datum/unit_test/voidcrew_bounty_boss/stamina/Run() + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(0, 0)) + var/mob/living/carbon/human/consistent/hunter = hunter_at(spot(3, 0)) + var/datum/ai_controller/controller = boss.ai_controller + boss.body_add_grudge(hunter) + boss.boss_turn_hostile(hunter) + TEST_ASSERT(boss.boss_hostile, "Test fixture: the boss didn't turn hostile") + + // Stamina works on it from the first hit (CB-2): no fresh immunity. + boss.apply_damage(30, STAMINA) + TEST_ASSERT(boss.getStaminaLoss() >= 30, "A fresh boss shrugged off stamina damage") + + // The fight starting, it injects a real stimulant it carries. + var/datum/ai_planning_subtree/bounty_boss_stimulant/stimulant = new + TEST_ASSERT_EQUAL(stimulant.SelectBehaviors(controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "The boss didn't reach for its stimulant as its fight started") + TEST_ASSERT_EQUAL(boss.boss_stimulants_used, 1, "The boss didn't count its first stimulant") + var/datum/ai_behavior/human_npc_treat_self/treat = GET_AI_BEHAVIOR(/datum/ai_behavior/human_npc_treat_self) + TEST_ASSERT(controller.current_behaviors[treat], "The boss didn't plan to use its stimulant") + var/finished = FALSE + for(var/step in 1 to 10) + ready_hands(boss) + var/result = treat.perform(1, controller, "human_npc_treat_item") // BB_HUMAN_NPC_TREAT_ITEM + TEST_ASSERT(!(result & AI_BEHAVIOR_FAILED), "Using the stimulant failed at step [step]") + if(result & AI_BEHAVIOR_SUCCEEDED) + finished = TRUE + break + TEST_ASSERT(finished, "The boss never finished using its stimulant") + TEST_ASSERT(boss.reagents.has_reagent(/datum/reagent/medicine/ephedrine), "The stimulant isn't in the boss's blood") + TEST_ASSERT_NOTNULL(bounty_ai_find_injector(boss, /obj/item/reagent_containers/hypospray/medipen/stimpack), "The boss has no second stimulant left for its second wind") + treat.finish_action(controller, TRUE, "human_npc_treat_item") + TEST_ASSERT(!boss.boss_wants_stimulant(), "The boss wants a second stimulant before its second wind") + + // Worn out is its real stamina (over half its pool): it says so, shows the hunters, and falls back. + boss.setStaminaLoss(0) + boss.reagents.clear_reagents() + boss.adjustStaminaLoss(70) + TEST_ASSERT(boss.boss_is_worn_out(), "A boss at [boss.getStaminaLoss()] stamina loss isn't worn out") + controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) + var/datum/ai_planning_subtree/bounty_boss_worn_out/worn = new + TEST_ASSERT_EQUAL(worn.SelectBehaviors(controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "A worn-out boss didn't fall back") + TEST_ASSERT(boss.boss_worn_out, "The boss didn't wear out") + TEST_ASSERT_EQUAL(boss.body_last_alert, "worn out", "Wearing out showed [boss.body_last_alert || "nothing"] over the boss") + TEST_ASSERT(boss.boss_fallback_until > world.time, "A worn-out boss has no fall back") + TEST_ASSERT(!boss.boss_can_use_ability(), "A boss falling back can still start an ability") + + // The fall back over and still worn out: its second wind is due, the second pen with its "recover" line. + boss.boss_fallback_until = world.time - 1 + worn.SelectBehaviors(controller, 1) + TEST_ASSERT(boss.boss_second_wind_due, "The boss's second wind isn't due after its fall back") + TEST_ASSERT(boss.boss_wants_stimulant(), "The boss doesn't want its second stimulant") + controller.clear_blackboard_key("human_npc_treat_item") + TEST_ASSERT_EQUAL(stimulant.SelectBehaviors(controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "The boss didn't take its second wind") + TEST_ASSERT_EQUAL(boss.boss_stimulants_used, 2, "The boss didn't count its second stimulant") + TEST_ASSERT(!boss.boss_second_wind_due, "The second wind is still due after it was taken") + + // Its stamina back, it is no longer worn out. + boss.setStaminaLoss(0) + worn.SelectBehaviors(controller, 1) + TEST_ASSERT(!boss.boss_worn_out, "A boss with its stamina back is still worn out") + + // Real health counts too: under 40% of a person's. + bounty_test_hurt_to(boss, 35) + TEST_ASSERT(boss.boss_is_worn_out(), "A boss at [boss.health] health isn't worn out") + // ===== MECHS (H2) ===== /datum/unit_test/voidcrew_bounty_boss/mechs /datum/unit_test/voidcrew_bounty_boss/mechs/Run() - var/mob/living/basic/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/basic/bounty_criminal/boss/juggernaut, spot(0, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(0, 0)) var/mob/living/carbon/human/consistent/pilot = hunter_at(spot(1, 0)) var/obj/vehicle/sealed/mecha/ripley/mech = mech_with(spot(1, 0), pilot) // A mech with a hunter in it is a target; the pilot is reached through it. TEST_ASSERT(boss.boss_valid_target(mech), "A hunter's mech isn't a target") TEST_ASSERT(!boss.boss_valid_target(pilot), "The boss goes for a pilot through the mech's hull") + TEST_ASSERT(!boss.boss_effect_hits(pilot), "The boss's fire and blasts reach a pilot through the hull") + TEST_ASSERT(boss.boss_effect_hits(mech), "The boss's fire and blasts skip a hunter's mech") TEST_ASSERT_EQUAL(boss.boss_target_for(pilot), mech, "The boss doesn't go for the pilot's mech") - var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(/datum/targeting_strategy/basic/bounty_boss) + var/datum/targeting_strategy/strategy = GET_TARGETING_STRATEGY(/datum/targeting_strategy/basic/human_npc/bounty_boss) TEST_ASSERT(strategy.can_attack(boss, mech, 9), "The boss's targeting ignores a hunter's mech") // The mech's blows count as the pilot's: the pilot joins the posse, and the boss turns on the mech. @@ -614,20 +711,15 @@ TEST_ASSERT_EQUAL(boss.boss_revenge_target(), mech, "The boss doesn't turn on the mech that hit it") // Mech gunfire counts too. - var/mob/living/basic/bounty_criminal/boss/juggernaut/shot_at = allocate(/mob/living/basic/bounty_criminal/boss/juggernaut, spot(0, 3)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/shot_at = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(0, 3)) var/obj/projectile/bullet/gunfire = new(get_turf(mech)) gunfire.firer = mech SEND_SIGNAL(shot_at, COMSIG_PROJECTILE_PREHIT, gunfire) qdel(gunfire) TEST_ASSERT(shot_at.boss_engaged[REF(pilot)], "Mech gunfire didn't put the pilot in the posse") - // Its fists land on the hull. - var/integrity = mech.get_integrity() - TEST_ASSERT(boss.melee_attack(mech, ignore_cooldown = TRUE), "The boss didn't swing at a mech") - TEST_ASSERT(mech.get_integrity() < integrity, "The boss's fists did nothing to a mech") - // The slam hits a mech next to it. - integrity = mech.get_integrity() + var/integrity = mech.get_integrity() var/datum/action/cooldown/mob_cooldown/bounty_boss/slam/slam = ability_of(boss, /datum/action/cooldown/mob_cooldown/bounty_boss/slam) TEST_ASSERT(slam.worth_using(mech), "The slam isn't worth using on a mech beside it") TEST_ASSERT(slam.Trigger(target = mech), "The slam didn't start on a mech") @@ -635,7 +727,7 @@ TEST_ASSERT(mech.get_integrity() < integrity, "The slam didn't hurt the mech") // The charge slams into a mech instead of bouncing off it. - var/mob/living/basic/bounty_criminal/boss/juggernaut/charger = allocate(/mob/living/basic/bounty_criminal/boss/juggernaut, spot(0, 2)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/charger = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(0, 2)) mech.forceMove(spot(3, 2)) integrity = mech.get_integrity() var/datum/action/cooldown/mob_cooldown/bounty_boss/charge/charge = ability_of(charger, /datum/action/cooldown/mob_cooldown/bounty_boss/charge) @@ -648,15 +740,15 @@ break charge.charge_step(serial) TEST_ASSERT(mech.get_integrity() < integrity, "The charge didn't hurt the mech") - TEST_ASSERT(charger.boss_busy != "stagger", "The charge bounced off a mech") + TEST_ASSERT(!charger.IsKnockdown(), "The charge bounced off a mech") -// ===== THE JUGGERNAUT'S CHARGE (M1) ===== +// ===== THE JUGGERNAUT'S CHARGE (M1, CB-6) ===== /datum/unit_test/voidcrew_bounty_boss/charge /datum/unit_test/voidcrew_bounty_boss/charge/Run() // Through a table. - var/mob/living/basic/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/basic/bounty_criminal/boss/juggernaut, spot(0, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(0, 0)) var/obj/structure/table/table = allocate(/obj/structure/table, spot(1, 0)) var/mob/living/carbon/human/consistent/victim = hunter_at(spot(3, 0)) var/datum/action/cooldown/mob_cooldown/bounty_boss/charge/charge = ability_of(boss, /datum/action/cooldown/mob_cooldown/bounty_boss/charge) @@ -673,11 +765,12 @@ charge.charge_step(serial) TEST_ASSERT(QDELETED(table), "The charge didn't smash the table in its way") TEST_ASSERT(victim.getBruteLoss() > 0, "The charge didn't hit its target") + TEST_ASSERT(victim.IsKnockdown(), "The charge didn't knock its target down") TEST_ASSERT_NULL(boss.boss_busy, "The boss is still charging") TEST_ASSERT_EQUAL(get_dist(boss, victim), 1, "The charge didn't end at its target") // Through a plain window and its grille, without bouncing. - var/mob/living/basic/bounty_criminal/boss/juggernaut/second = allocate(/mob/living/basic/bounty_criminal/boss/juggernaut, spot(0, 3)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/second = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(0, 3)) var/obj/structure/grille/grille = allocate(/obj/structure/grille, spot(1, 3)) var/obj/structure/window/fulltile/pane = allocate(/obj/structure/window/fulltile, spot(1, 3)) var/mob/living/carbon/human/consistent/behind = hunter_at(spot(3, 3)) @@ -691,45 +784,169 @@ window_charge.charge_step(serial) TEST_ASSERT(QDELETED(pane), "The charge didn't smash the plain window") TEST_ASSERT(QDELETED(grille), "The charge didn't smash the grille under the window") - TEST_ASSERT(second.boss_busy != "stagger", "The charge bounced off a plain window") + TEST_ASSERT(!second.IsKnockdown(), "The charge bounced off a plain window") TEST_ASSERT(behind.getBruteLoss() > 0, "The charge through a window didn't reach its target") -// ===== THE HEAVY'S ROUNDS (M5) ===== + // Into a reinforced wall: it hurts, and it puts the Juggernaut down where it can be cuffed (CB-6). + var/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/wall_runner = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut, spot(0, 1)) + var/mob/living/carbon/human/consistent/beyond = hunter_at(spot(4, 1)) + change_turf(spot(2, 1), /turf/closed/wall/r_wall) + var/datum/action/cooldown/mob_cooldown/bounty_boss/charge/wall_charge = ability_of(wall_runner, /datum/action/cooldown/mob_cooldown/bounty_boss/charge) + TEST_ASSERT(wall_charge.Trigger(target = beyond), "The charge at the wall didn't start") + TEST_ASSERT(wall_charge.finish_windup(wall_charge.pending_serial), "The charge at the wall didn't go") + serial = wall_runner.boss_busy_serial + for(var/i in 1 to 8) + if(wall_runner.boss_busy != "charge") + break + wall_charge.charge_step(serial) + TEST_ASSERT(isclosedturf(spot(2, 1)), "The charge broke a reinforced wall") + TEST_ASSERT(wall_runner.getBruteLoss() > 0, "Running into the wall didn't hurt the Juggernaut") + TEST_ASSERT(wall_runner.IsKnockdown(), "Running into the wall didn't knock the Juggernaut down") + TEST_ASSERT(!wall_runner.body_can_answer_cuffs(), "A Juggernaut dazed by a wall could still fight off the cuffs") + TEST_ASSERT(!wall_runner.boss_can_act(), "A Juggernaut dazed by a wall can still act") + TEST_ASSERT(abs(wall_runner.physiology.brute_mod - 0.6) < 0.01, "Running into the wall changed how much damage it takes") + +// ===== THE HEAVY'S GUN: REAL ROUNDS, REAL BELTS, A FUMBLE (CB-13) ===== + +/datum/unit_test/voidcrew_bounty_boss/heavy + +/datum/unit_test/voidcrew_bounty_boss/heavy/Run() + var/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/heavy = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/heavy, spot(0, 0)) + var/mob/living/carbon/human/consistent/target = hunter_at(spot(4, 0)) + var/obj/item/gun/ballistic/automatic/l6_saw/gun = heavy.boss_gun() + TEST_ASSERT_NOTNULL(gun, "The Heavy holds no gun") + var/datum/action/cooldown/mob_cooldown/bounty_boss/burst/burst = ability_of(heavy, /datum/action/cooldown/mob_cooldown/bounty_boss/burst) + TEST_ASSERT(burst.worth_using(target), "The Heavy won't open up on someone four tiles off") + + // A hit while it aims spoils the burst. + TEST_ASSERT(burst.Trigger(target = target), "The burst didn't start") + var/serial = burst.pending_serial + heavy.apply_damage(20, BRUTE) + TEST_ASSERT_NULL(heavy.boss_busy, "A hit didn't spoil the Heavy's aim") + TEST_ASSERT(!burst.finish_windup(serial), "A spoiled burst still fired") + + // Aimed in peace, it pulls the real gun's trigger: a real round leaves its belt. + ready(heavy) + ready_hands(heavy) + var/rounds = gun.get_ammo() + TEST_ASSERT(burst.Trigger(target = target), "The burst didn't start again") + // Starting the ability is a click (tg's 0.6 s ability click cooldown), and its 0.7 s wind-up outlasts + // that; the test ends the wind-up at once, so it lets the cooldown go by hand. + ready_hands(heavy) + TEST_ASSERT(burst.finish_windup(burst.pending_serial), "The burst didn't fire when its wind-up ended") + TEST_ASSERT(gun.get_ammo() < rounds, "The burst fired no round from the Heavy's gun") + burst.end_burst(heavy.boss_busy_serial) + + // Its belt run dry, it changes it from its bag the way a player does. + QDEL_NULL(gun.chambered) + gun.magazine.stored_ammo.Cut() + gun.update_appearance() + TEST_ASSERT(!gun.can_shoot(), "Test fixture: the Heavy's gun still fires") + var/datum/ai_controller/controller = heavy.ai_controller + heavy.boss_hostile = TRUE + TEST_ASSERT(heavy.boss_gear_plan(controller), "The Heavy didn't plan to change its belt") + var/datum/ai_behavior/bounty_heavy_reload/reload = GET_AI_BEHAVIOR(/datum/ai_behavior/bounty_heavy_reload) + reload.setup(controller) + var/finished = FALSE + for(var/step in 1 to 12) + ready_hands(heavy) + var/result = reload.perform(1, controller) + TEST_ASSERT(!(result & AI_BEHAVIOR_FAILED), "Changing the belt failed at step [step]") + if(result & AI_BEHAVIOR_SUCCEEDED) + finished = TRUE + break + TEST_ASSERT(finished, "The Heavy never finished changing its belt") + TEST_ASSERT(gun.can_shoot(), "The Heavy's gun doesn't fire after a belt change") + TEST_ASSERT(!gun.cover_open, "The Heavy left its gun's cover open") + TEST_ASSERT(gun.magazine?.ammo_count() > 0, "The new belt is empty") + TEST_ASSERT_EQUAL(carried(heavy, /obj/item/ammo_box/magazine/m7mm) - (gun.magazine ? 1 : 0), 0, "The spare box wasn't the one that went in") + + // Barricade: a real barrier grenade, armed and thrown in front of it (CB-26). + var/datum/action/cooldown/mob_cooldown/bounty_boss/barricade/barricade = ability_of(heavy, /datum/action/cooldown/mob_cooldown/bounty_boss/barricade) + ready(heavy) + ready_hands(heavy) + TEST_ASSERT_EQUAL(length(GLOB.bounty_boss_barricades), 0, "Barricades were standing before the test") + TEST_ASSERT(barricade.worth_using(target), "The Heavy won't put up a barricade") + TEST_ASSERT(barricade.Trigger(target = target), "The barricade didn't start") + TEST_ASSERT(barricade.finish_windup(barricade.pending_serial), "The barricade wasn't thrown") + TEST_ASSERT_EQUAL(carried(heavy, /obj/item/grenade/barrier/bounty_boss), 1, "The Heavy didn't throw one of its barrier grenades") + var/obj/item/grenade/barrier/bounty_boss/thrown + for(var/obj/item/grenade/barrier/bounty_boss/loose in range(2, heavy)) + if(!heavy.is_holding(loose)) + thrown = loose + TEST_ASSERT_NOTNULL(thrown, "The thrown barrier grenade is nowhere near the Heavy") + TEST_ASSERT(thrown.active, "The Heavy threw its barrier grenade without pulling the pin") + thrown.forceMove(spot(1, 0)) + thrown.detonate() + var/obj/structure/barricade/security/bounty_boss/barrier = locate() in spot(1, 0) + TEST_ASSERT_NOTNULL(barrier, "The barrier grenade made no barrier") + TEST_ASSERT(barrier in GLOB.bounty_boss_barricades, "The barricade isn't counted") + TEST_ASSERT_EQUAL(length(barricade.barriers), 1, "The Heavy doesn't count the barrier it threw") + barrier.fold_away() + TEST_ASSERT(QDELETED(barrier), "The barricade didn't fold away") + TEST_ASSERT_EQUAL(length(GLOB.bounty_boss_barricades), 0, "A folded barricade is still counted") -/datum/unit_test/voidcrew_bounty_boss/heavy_rounds + // The barricade cap. + var/list/made = list() + for(var/i in 1 to 9) + made += new /obj/structure/barricade/security/bounty_boss(spot(i % 5, 4)) + TEST_ASSERT_EQUAL(length(GLOB.bounty_boss_barricades), 8, "The barricade cap didn't hold") // BOUNTY_BOSS_BARRICADE_CAP + for(var/obj/structure/barricade/security/bounty_boss/extra as anything in made) + if(!QDELETED(extra)) + qdel(extra) + TEST_ASSERT_EQUAL(length(GLOB.bounty_boss_barricades), 0, "Deleted barricades are still counted") -/datum/unit_test/voidcrew_bounty_boss/heavy_rounds/Run() - var/mob/living/basic/bounty_criminal/boss/heavy/heavy = allocate(/mob/living/basic/bounty_criminal/boss/heavy, spot(0, 0)) - var/obj/projectile/bullet/bounty_boss_heavy/heavy_round = new(spot(0, 0)) - heavy_round.firer = heavy - var/obj/structure/window/fulltile/inside = allocate(/obj/structure/window/fulltile, spot(2, 2)) - TEST_ASSERT_EQUAL(heavy_round.get_demolition_modifier(inside), 0.25, "The Heavy's rounds don't chip an interior window") // BOUNTY_HEAVY_BURST_DEMOLITION - var/obj/structure/window/fulltile/outside = allocate(/obj/structure/window/fulltile, spot(4, 2)) - change_turf(spot(4, 3), /turf/open/space/basic) - TEST_ASSERT_EQUAL(heavy_round.get_demolition_modifier(outside), 0, "The Heavy's rounds damage a window onto space") - var/obj/machinery/door/airlock/door = allocate(/obj/machinery/door/airlock, spot(2, 4)) - TEST_ASSERT_EQUAL(heavy_round.get_demolition_modifier(door), 0, "The Heavy's rounds break doors") - var/mob/living/carbon/human/consistent/pilot = hunter_at(spot(1, 1)) - var/obj/vehicle/sealed/mecha/ripley/mech = mech_with(spot(1, 1), pilot) - TEST_ASSERT_EQUAL(heavy_round.get_demolition_modifier(mech), 1, "The Heavy's rounds go easy on mechs") - qdel(heavy_round) + // Barricades a boss keeps: a new one folds up its oldest. + var/list/mine = list() + for(var/i in 1 to 3) + var/obj/structure/barricade/security/bounty_boss/one = new(spot(i, 3)) + mine += one + barricade.barriers += WEAKREF(one) + barricade.prune_barriers() + TEST_ASSERT(QDELETED(mine[1]), "The Heavy's oldest barricade stayed past its limit") // BOUNTY_BOSS_BARRICADES_PER_BOSS + TEST_ASSERT_EQUAL(length(barricade.barriers), 2, "The Heavy keeps the wrong number of barricades") + for(var/obj/structure/barricade/security/bounty_boss/kept as anything in mine) + if(!QDELETED(kept)) + qdel(kept) -// ===== THE GHOST ===== +// ===== THE GHOST: A REAL KNIFE, REAL CHROME, A SHIMMER THAT IS ONLY A LOOK (CB-9, CB-12) ===== /datum/unit_test/voidcrew_bounty_boss/ghost /datum/unit_test/voidcrew_bounty_boss/ghost/Run() - var/mob/living/basic/bounty_criminal/boss/ghost/ghost = allocate(/mob/living/basic/bounty_criminal/boss/ghost, spot(0, 0)) + var/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/ghost = allocate(/mob/living/carbon/human/npc/bounty_criminal/boss/ghost, spot(0, 0)) TEST_ASSERT(ghost.boss_cloak(), "The Ghost didn't cloak") + TEST_ASSERT(ghost.alpha < 255 || ghost.get_filter("bounty_ghost_shimmer"), "The Ghost's shimmer doesn't show") ghost.apply_damage(5, BRUTE) - TEST_ASSERT(!ghost.boss_cloaked, "A hit didn't break the Ghost's cloak") + TEST_ASSERT(!ghost.boss_cloaked, "A hit didn't break the Ghost's shimmer") TEST_ASSERT(ghost.boss_cloak(), "The Ghost didn't cloak again") SEND_SIGNAL(ghost, COMSIG_MOB_FLASHED) - TEST_ASSERT(!ghost.boss_cloaked, "A flash didn't break the Ghost's cloak") + TEST_ASSERT(!ghost.boss_cloaked, "A flash didn't break the Ghost's shimmer") - // Its cuts bleed, and a couple of them make it break off. + // Its dash ends in a real knife attack, the knife's own damage, wounds and bleeding (CB-9). var/mob/living/carbon/human/consistent/victim = hunter_at(spot(1, 0)) - ghost.boss_cut(victim) - TEST_ASSERT(victim.has_status_effect(/datum/status_effect/bounty_boss_bleed), "The Ghost's cut didn't bleed") - ghost.boss_cut(victim) - TEST_ASSERT(ghost.boss_breakoff_until > world.time, "The Ghost didn't break off after two cuts") // BOUNTY_GHOST_CUTS_BEFORE_BREAKOFF + var/datum/action/cooldown/mob_cooldown/bounty_boss/dash/dash = ability_of(ghost, /datum/action/cooldown/mob_cooldown/bounty_boss/dash) + TEST_ASSERT(!dash.cut_at_end(victim), "The Ghost cut with a knife it hadn't drawn") + var/obj/item/knife/combat/knife = locate() in ghost.get_all_contents_type(/obj/item/knife/combat) + TEST_ASSERT(human_npc_take_in_hand(ghost, knife), "The Ghost couldn't draw its knife") + ready_hands(ghost) + TEST_ASSERT(dash.cut_at_end(victim), "The Ghost's dash didn't end in a cut") + TEST_ASSERT(victim.getBruteLoss() > 0, "The Ghost's knife didn't hurt the hunter") + TEST_ASSERT_EQUAL(ghost.boss_cuts, 1, "The Ghost's cut wasn't a blow from its knife") + + // A couple of cuts and it breaks off (BOUNTY_GHOST_CUTS_BEFORE_BREAKOFF). + ready_hands(ghost) + TEST_ASSERT(dash.cut_at_end(victim), "The Ghost's second cut didn't land") + TEST_ASSERT(ghost.boss_breakoff_until > world.time, "The Ghost didn't break off after two cuts") + + // The cut at the end of a dash lands on whoever it dashed at, down or not (CB-11). + TEST_ASSERT(put_in_crit(victim), "Test fixture: the hunter isn't down") + var/before = victim.getBruteLoss() + ready_hands(ghost) + TEST_ASSERT(dash.cut_at_end(victim), "The Ghost's cut skipped a downed hunter") + TEST_ASSERT(victim.getBruteLoss() > before, "The Ghost's knife didn't hurt a downed hunter") + + // The dash fires its Cascade lattice: real chrome, with its own window and crash. + TEST_ASSERT(ghost.boss_surge(), "The Ghost's Cascade lattice didn't fire") + TEST_ASSERT(ghost.has_status_effect(/datum/status_effect/cyberware_cascade_window), "The Cascade window didn't open") + TEST_ASSERT(!ghost.boss_surge(), "The Cascade lattice fired twice in one cycle") diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_criminal.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_criminal.dm index 06fbd1ad671..d377808e5c6 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_criminal.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_criminal.dm @@ -1,9 +1,12 @@ /** - * Bounty hunting: P2 body's tests, for voidcrew/modules/bounties/bounty_criminal.dm and bounty_restraints.dm. + * Bounty hunting: P2 body's tests, for voidcrew/modules/bounties/bounty_criminal.dm, bounty_restraints.dm, + * bounty_outfits.dm and bounty_ai_human.dm. * - * Owner: P2 body. Do not edit this file outside that package. Fork defines are included after the - * tests, so a test uses the literal value with a comment naming the define. Every test drives the - * body's procs directly with the mob in place; none relies on the AI walking anywhere. + * A criminal is a real human NPC (voidcrew/modules/human_npcs/): its crit, stamina, cuffs and death are + * tg's. These tests drive tg's own procs on the body (apply_damage/adjustBruteLoss, Knockdown, Paralyze, + * adjustStaminaLoss, tg handcuffs, death, revive) and check that the bounty rules read them. Fork + * defines are included after the tests, so a test uses the literal value with a comment naming the + * define. None relies on the AI walking anywhere (the AI is off with no player on the level). */ /// Holds the helpers the body tests share @@ -11,6 +14,8 @@ abstract_type = /datum/unit_test/voidcrew_bounty_criminal /// How many times each bounty signal was sent in the test var/list/signal_counts + /// The user each restraint signal carried, last first + var/list/restraint_users /// Turfs moved into a test area, and the area each came from var/list/original_areas /// Areas made for the test @@ -54,451 +59,284 @@ SIGNAL_HANDLER LAZYINITLIST(signal_counts) signal_counts["restrained"] += 1 + LAZYINITLIST(restraint_users) + restraint_users.Insert(1, list(list(user))) /datum/unit_test/voidcrew_bounty_criminal/proc/on_unrestrained(datum/source, mob/user) SIGNAL_HANDLER LAZYINITLIST(signal_counts) signal_counts["unrestrained"] += 1 + LAZYINITLIST(restraint_users) + restraint_users.Insert(1, list(list(user))) /// How many times `signal_name` was counted /datum/unit_test/voidcrew_bounty_criminal/proc/signal_count(signal_name) return LAZYACCESS(signal_counts, signal_name) || 0 +/// The user the last restraint signal carried +/datum/unit_test/voidcrew_bounty_criminal/proc/last_restraint_user() + if(!length(restraint_users)) + return null + var/list/entry = restraint_users[1] + return entry[1] + +/// Listens to every bounty body signal on `criminal` +/datum/unit_test/voidcrew_bounty_criminal/proc/listen_to(mob/living/carbon/human/npc/bounty_criminal/criminal) + RegisterSignal(criminal, "bounty_criminal_downed", PROC_REF(on_downed)) // COMSIG_BOUNTY_CRIMINAL_DOWNED + RegisterSignal(criminal, "bounty_criminal_recovered", PROC_REF(on_recovered)) // COMSIG_BOUNTY_CRIMINAL_RECOVERED + RegisterSignal(criminal, "bounty_criminal_restrained", PROC_REF(on_restrained)) // COMSIG_BOUNTY_CRIMINAL_RESTRAINED + RegisterSignal(criminal, "bounty_criminal_unrestrained", PROC_REF(on_unrestrained)) // COMSIG_BOUNTY_CRIMINAL_UNRESTRAINED + +/// Puts real tg handcuffs on `criminal`, as `user` would (tg's apply_cuffs(), without the do_after) +/datum/unit_test/voidcrew_bounty_criminal/proc/cuff(mob/living/carbon/criminal, mob/living/user) + var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs) + cuffs.apply_cuffs(criminal, user || allocate(/mob/living/carbon/human/consistent), dispense = TRUE) + return criminal.handcuffed + /// Everything examining `criminal` shows `user`, as one text -/datum/unit_test/voidcrew_bounty_criminal/proc/examine_text(mob/living/basic/bounty_criminal/criminal, mob/user) +/datum/unit_test/voidcrew_bounty_criminal/proc/examine_text(mob/living/carbon/human/npc/bounty_criminal/criminal, mob/user) return jointext(criminal.examine(user), "\n") -// ===== THE MERCY RULE ===== +/** + * Real brute on `body`'s chest, no wound, until its health is just under `target_health`: the bounty + * tests' beating. Spread brute (adjustBruteLoss) won't do, because tg counts a limb's damage at three + * quarters toward health, and a body's toughness, species and limbs change how much of a hit it takes, + * so each hit is sized by how much the one before took off (the first is small, to learn that without + * overshooting). Healing it back with adjustBruteLoss(-x) gives x health back, as only the chest is hurt. + * Returns its health after. + */ +/datum/unit_test/proc/bounty_test_hurt_to(mob/living/carbon/body, target_health) + var/taken = 1 + for(var/hit in 1 to 10) + var/excess = body.health - target_health + if(excess <= 0 || body.stat == DEAD) + break + var/amount = (excess + 0.5) / taken + if(hit == 1) + amount = min(amount, 10) + var/before = body.health + body.apply_damage(amount, BRUTE, BODY_ZONE_CHEST, wound_bonus = CANT_WOUND) + var/dropped = before - body.health + if(dropped <= 0) + break + taken = dropped / amount + return body.health -/datum/unit_test/voidcrew_bounty_criminal_mercy - parent_type = /datum/unit_test/voidcrew_bounty_criminal +// ===== THE BODY IS A PERSON'S ===== -/datum/unit_test/voidcrew_bounty_criminal_mercy/Run() - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) - // BOUNTY_NORMAL_HEALTH_WANTED 180; BOUNTY_DOWNED_BELOW 25: the line is 45 - TEST_ASSERT_EQUAL(criminal.maxHealth, 180, "A normal criminal has the wrong health") - TEST_ASSERT(!criminal.is_downed(), "A fresh criminal is downed") - criminal.adjustBruteLoss(500) - TEST_ASSERT_EQUAL(criminal.stat, CONSCIOUS, "One big hit killed a criminal on its feet") - TEST_ASSERT_EQUAL(criminal.health, 44, "A big hit on a criminal on its feet did not stop 1 under the downed line") - TEST_ASSERT(criminal.is_downed(), "A criminal at the downed line is not downed") - TEST_ASSERT_EQUAL(criminal.capture_state(), "downed", "A downed criminal's capture state is wrong") // BOUNTY_STATE_DOWNED - // Down, the next hit can kill: that is a choice. - criminal.adjustBruteLoss(500) - TEST_ASSERT_EQUAL(criminal.stat, DEAD, "A hit on a downed criminal could not kill it") - TEST_ASSERT_EQUAL(criminal.capture_state(), "dead", "A dead criminal's capture state is wrong") // BOUNTY_STATE_DEAD - TEST_ASSERT(!QDELETED(criminal), "A dead criminal's body was deleted") - - // Stamina crit counts as standing for the mercy rule. - var/mob/living/basic/bounty_criminal/meek/runner = allocate(__IMPLIED_TYPE__) - runner.adjustStaminaLoss(200) - TEST_ASSERT(runner.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "A meek criminal did not stamina crit") - runner.adjustBruteLoss(500) - // BOUNTY_MEEK_HEALTH 120: the line is 30 - TEST_ASSERT_EQUAL(runner.stat, CONSCIOUS, "A big hit killed a criminal in stamina crit") - TEST_ASSERT_EQUAL(runner.health, 29, "A big hit on a criminal in stamina crit did not stop 1 under the downed line") - - // Small hits add up to the same line and no further. - var/mob/living/basic/bounty_criminal/normal/chipped = allocate(__IMPLIED_TYPE__) - for(var/i in 1 to 30) - chipped.adjustBruteLoss(7) - if(chipped.is_downed()) - break - TEST_ASSERT(chipped.is_downed(), "Small hits never downed a criminal") - TEST_ASSERT(chipped.health > 0 && chipped.health <= 45, "Small hits left a downed criminal at [chipped.health]") - - // Fire and heat burn it like a suited person (BOUNTY_CRIMINAL_MAX_TEMP 1500, BOUNTY_CRIMINAL_BURN_DAMAGE 3 a second), but not past the mercy line. - var/mob/living/basic/bounty_criminal/normal/burning = allocate(__IMPLIED_TYPE__) - burning.bodytemperature = 3000 - burning.Life(2) - TEST_ASSERT(burning.health < 180, "Heat did not hurt a criminal") - burning.adjustBruteLoss(burning.health - 46) - TEST_ASSERT_EQUAL(burning.health, 46, "The burning criminal was not brought near the line") - burning.bodytemperature = 3000 - burning.Life(2) - TEST_ASSERT_EQUAL(burning.stat, CONSCIOUS, "Heat killed a criminal on its feet") - TEST_ASSERT_EQUAL(burning.health, 44, "Heat took a criminal on its feet past the downed line") - -// ===== DOWNED AND GETTING UP ===== - -/datum/unit_test/voidcrew_bounty_criminal_recovery +/// No stand-in body: a person's health and stamina, tg crit and death, revival works, no fire or vacuum immunity. +/datum/unit_test/voidcrew_bounty_criminal_body parent_type = /datum/unit_test/voidcrew_bounty_criminal -/datum/unit_test/voidcrew_bounty_criminal_recovery/Run() - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) - RegisterSignal(criminal, "bounty_criminal_downed", TYPE_PROC_REF(/datum/unit_test/voidcrew_bounty_criminal, on_downed)) // COMSIG_BOUNTY_CRIMINAL_DOWNED - RegisterSignal(criminal, "bounty_criminal_recovered", TYPE_PROC_REF(/datum/unit_test/voidcrew_bounty_criminal, on_recovered)) // COMSIG_BOUNTY_CRIMINAL_RECOVERED - var/mob/living/carbon/human/consistent/hunter = allocate(__IMPLIED_TYPE__, get_step(run_loc_floor_bottom_left, EAST)) - - criminal.adjustBruteLoss(500) - TEST_ASSERT_EQUAL(signal_count("downed"), 1, "Going down did not send the downed signal once") - TEST_ASSERT(HAS_TRAIT(criminal, TRAIT_FLOORED), "A downed criminal is not on the floor") - TEST_ASSERT(HAS_TRAIT(criminal, TRAIT_INCAPACITATED), "A downed criminal is not incapacitated") - TEST_ASSERT(HAS_TRAIT(criminal, "bounty_held"), "A downed criminal's AI may still plan") // TRAIT_BOUNTY_HELD - TEST_ASSERT(HAS_TRAIT(criminal, TRAIT_AI_PAUSED), "A downed criminal's AI is not paused") - TEST_ASSERT(!criminal.may_attack(hunter), "A downed criminal may still attack") - TEST_ASSERT_NOTNULL(criminal.body_recovery_timer, "A downed criminal has no recovery clock") - - // Healing raises its health, not its state. - criminal.adjustBruteLoss(-500) - TEST_ASSERT_EQUAL(criminal.health, 180, "A downed criminal could not be healed") - TEST_ASSERT(criminal.is_downed(), "Healing stood a downed criminal up") - - // A stamina hit starts the clock over. - var/first_clock = criminal.body_recovery_timer - criminal.adjustStaminaLoss(10) - TEST_ASSERT(criminal.body_recovery_timer && criminal.body_recovery_timer != first_clock, "A stamina hit did not restart a downed criminal's recovery") - - // Cuffed, it stays down when its time comes, and gets up once the cuffs are off. - TEST_ASSERT(criminal.body_apply_cuffs(allocate(/obj/item/restraints/handcuffs)), "A downed criminal could not be cuffed") - criminal.body_stir() - TEST_ASSERT(criminal.is_downed(), "A cuffed, downed criminal started getting up") - TEST_ASSERT(!criminal.body_stirring, "A cuffed, downed criminal is stirring") - TEST_ASSERT(!criminal.body_stand_up(), "A cuffed, downed criminal got up") - TEST_ASSERT(criminal.body_recovery_due, "A cuffed criminal's recovery did not wait for the cuffs") - TEST_ASSERT_EQUAL(criminal.capture_state(), "downed", "A cuffed, downed criminal is not downed") // BOUNTY_STATE_DOWNED - // A baton on it now starts the clock over: uncuffed, it doesn't jump up at once (L4). - criminal.adjustStaminaLoss(10) - TEST_ASSERT(!criminal.body_recovery_due, "A stamina hit left a cuffed criminal's recovery due") - var/restarted_clock = criminal.body_recovery_timer - criminal.body_remove_cuffs() - TEST_ASSERT(!criminal.body_stirring, "An uncuffed criminal stirred at once after a stamina hit restarted its clock") - TEST_ASSERT_EQUAL(criminal.body_recovery_timer, restarted_clock, "Uncuffing threw away a restarted recovery clock") - // Its time comes again, cuffed: it waits, then stirs once the cuffs are off. - TEST_ASSERT(criminal.body_apply_cuffs(allocate(/obj/item/restraints/handcuffs)), "The downed criminal could not be cuffed again") - criminal.body_stir() - TEST_ASSERT(criminal.body_recovery_due, "A cuffed criminal's recovery did not wait for the cuffs the second time") - criminal.body_remove_cuffs() - TEST_ASSERT(criminal.body_stirring, "A downed criminal whose time had come did not stir once uncuffed") - TEST_ASSERT(criminal.body_stand_up(), "A stirring criminal could not get up") - TEST_ASSERT(!criminal.is_downed(), "A criminal that got up is still downed") - TEST_ASSERT_EQUAL(signal_count("recovered"), 1, "Getting up did not send the recovered signal once") - TEST_ASSERT_EQUAL(criminal.health, 180, "A criminal healed while down did not get up with its health") - TEST_ASSERT(!HAS_TRAIT(criminal, TRAIT_FLOORED), "A criminal that got up is still on the floor") - TEST_ASSERT(!HAS_TRAIT(criminal, "bounty_held"), "A criminal that got up is still held") // TRAIT_BOUNTY_HELD - TEST_ASSERT(!HAS_TRAIT(criminal, TRAIT_AI_PAUSED), "A criminal that got up still has its AI paused") - TEST_ASSERT(criminal.may_attack(hunter), "A criminal that got up may not fight") - - // Left alone, it gets up at the recovery line. - var/mob/living/basic/bounty_criminal/normal/other = allocate(__IMPLIED_TYPE__) - other.adjustBruteLoss(500) - other.body_stir() - TEST_ASSERT(other.body_stirring, "A downed criminal did not stir when its time came") - TEST_ASSERT(other.body_stand_up(), "A downed criminal did not get up") - // BOUNTY_RECOVER_TO 35: 63 of 180 - TEST_ASSERT_EQUAL(other.health, 63, "A criminal got up with the wrong health") - - // Only mini-bosses rally: stamina does nothing to one that just got up, until the rally ends. - TEST_ASSERT(!other.body_is_rallying(), "A normal criminal rallies") - var/mob/living/basic/bounty_criminal/boss/juggernaut/brute = allocate(__IMPLIED_TYPE__) - brute.adjustBruteLoss(brute.maxHealth * 2) - TEST_ASSERT(brute.is_downed(), "A mini-boss was not downed") - TEST_ASSERT(brute.body_stand_up(), "A downed mini-boss did not get up") - TEST_ASSERT(brute.body_is_rallying(), "A mini-boss that got up is not rallying") - TEST_ASSERT_NOTNULL(brute.body_rally_timer, "A rallying mini-boss has no end to its rally") - var/stamina_before = brute.getStaminaLoss() - brute.adjustStaminaLoss(50) - TEST_ASSERT_EQUAL(brute.getStaminaLoss(), stamina_before, "A rallying mini-boss took stamina damage") - brute.body_end_rally() - TEST_ASSERT(!brute.body_is_rallying(), "A mini-boss's rally did not end") - - // BOUNTY_RECOVER_TIME_MEEK, _NORMAL, _BOSS (60 SECONDS, 75 SECONDS, 45 SECONDS) - var/mob/living/basic/bounty_criminal/meek/runner = allocate(__IMPLIED_TYPE__) - TEST_ASSERT_EQUAL(runner.body_recovery_time(), 600, "A meek criminal's recovery time is wrong") - TEST_ASSERT_EQUAL(other.body_recovery_time(), 750, "A normal criminal's recovery time is wrong") - TEST_ASSERT_EQUAL(brute.body_recovery_time(), 450, "A mini-boss's recovery time is wrong") - -// ===== WORST STATE AND THE STATE ORDER ===== +/datum/unit_test/voidcrew_bounty_criminal_body/Run() + for(var/criminal_type in list(/mob/living/carbon/human/npc/bounty_criminal/meek, /mob/living/carbon/human/npc/bounty_criminal/normal, /mob/living/carbon/human/npc/bounty_criminal/decoy)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = allocate(criminal_type) + TEST_ASSERT(ishuman(criminal), "[criminal_type] is not a human") + TEST_ASSERT_EQUAL(criminal.maxHealth, 100, "[criminal_type] has a stand-in health pool") + TEST_ASSERT_EQUAL(criminal.max_stamina, 120, "[criminal_type] has a stand-in stamina pool") + TEST_ASSERT(!HAS_TRAIT(criminal, TRAIT_NOFIRE) && !HAS_TRAIT(criminal, TRAIT_RESISTCOLD) && !HAS_TRAIT(criminal, TRAIT_RESISTLOWPRESSURE), "[criminal_type] is immune to fire, cold or vacuum") + TEST_ASSERT(!HAS_TRAIT(criminal, TRAIT_GODMODE), "[criminal_type] starts in godmode") + TEST_ASSERT_EQUAL(criminal.ai_controller?.blackboard[BB_TARGET_MINIMUM_STAT], CONSCIOUS, "[criminal_type] would attack someone in crit") // HUMAN_NPC_SPARES_DOWNED + + // tg crit: a hit that takes it past 0 health puts it in soft crit, nothing holds it up. Chest brute + // counts in full toward health (a limb's counts three quarters), and a Petty human takes a person's. + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) + criminal.apply_damage(90, BRUTE, BODY_ZONE_CHEST, wound_bonus = CANT_WOUND) + TEST_ASSERT_EQUAL(criminal.stat, CONSCIOUS, "90 brute put a criminal down") + criminal.apply_damage(20, BRUTE, BODY_ZONE_CHEST, wound_bonus = CANT_WOUND) + TEST_ASSERT(HAS_TRAIT(criminal, TRAIT_CRITICAL_CONDITION), "A criminal at -10 health is not in crit") + TEST_ASSERT_EQUAL(criminal.stat, SOFT_CRIT, "A criminal at -10 health is not in soft crit") + TEST_ASSERT(criminal.health < 0, "A hit on a criminal was clipped to keep it standing") + + // Healed out of crit, it stands the tg way; nothing else heals it. + criminal.adjustBruteLoss(-30) + TEST_ASSERT_EQUAL(criminal.stat, CONSCIOUS, "A criminal healed out of crit is still down") + TEST_ASSERT_EQUAL(criminal.health, 20, "Something besides the heal changed the criminal's health") + + // It dies, and can be brought back like anyone. + criminal.death() + TEST_ASSERT_EQUAL(criminal.stat, DEAD, "The criminal did not die") + TEST_ASSERT(criminal.can_be_revived(), "A dead criminal can't be revived") + criminal.revive(HEAL_ALL) + TEST_ASSERT_EQUAL(criminal.stat, CONSCIOUS, "A revived criminal is still dead") + + // Stamina is a person's: a pool of 120, and tg's stamcrit once 100 of it is gone (maxHealth less the crit line). + var/mob/living/carbon/human/npc/bounty_criminal/meek/runner = allocate(__IMPLIED_TYPE__) + runner.adjustStaminaLoss(90) + TEST_ASSERT(!runner.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "90 stamina damage stamcritted a meek criminal") + runner.adjustStaminaLoss(20) + TEST_ASSERT(runner.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "110 stamina damage did not stamcrit a meek criminal") + + // Anyone can grab a free one; it isn't too heavy to move. + var/mob/living/carbon/human/npc/bounty_criminal/normal/free = allocate(__IMPLIED_TYPE__) + var/mob/living/carbon/human/consistent/grabber = allocate(__IMPLIED_TYPE__, get_step(run_loc_floor_bottom_left, EAST)) + grabber.start_pulling(free) + TEST_ASSERT_EQUAL(grabber.pulling, free, "A free criminal could not be grabbed") + grabber.stop_pulling() + + // Its kit is locked to it and not loot (D3), its toughness is its tier's (npc_damage_taken), never its health. + var/datum/bounty_record/wanted = new + wanted.archetype = "normal" // BOUNTY_ARCHETYPE_NORMAL + wanted.tier = 2 // BOUNTY_TIER_WANTED + var/mob/living/carbon/human/npc/bounty_criminal/normal/tough = spawn_bounty_criminal(wanted, run_loc_floor_bottom_left, null) + TEST_ASSERT_EQUAL(tough.maxHealth, 100, "A Wanted criminal has more health than a person") + TEST_ASSERT_EQUAL(tough.npc_damage_taken, 0.9, "A Wanted criminal takes the wrong damage") // BOUNTY_TOUGHNESS_WANTED + TEST_ASSERT(istype(tough.wear_suit, /obj/item/clothing/suit/armor/vest), "A Wanted criminal wears no armour vest") + TEST_ASSERT(human_npc_gear_locked(tough.wear_suit), "A Wanted criminal's vest is not locked to it") + qdel(tough) + +// ===== CAPTURE STATE ===== /datum/unit_test/voidcrew_bounty_criminal_states parent_type = /datum/unit_test/voidcrew_bounty_criminal /datum/unit_test/voidcrew_bounty_criminal_states/Run() - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) + var/mob/living/carbon/human/consistent/hunter = allocate(__IMPLIED_TYPE__, get_step(run_loc_floor_bottom_left, NORTH)) + listen_to(criminal) TEST_ASSERT_EQUAL(criminal.capture_state(), "free", "A fresh criminal is not free") // BOUNTY_STATE_FREE - TEST_ASSERT_EQUAL(criminal.worst_state, "free", "A fresh criminal's worst state is not free") - // Knocked down is stunned; the worst state holds after it stands. + // Knocked down, stunned, paralysed (*surrender is one), stamcritted or asleep is stunned; up again it is free. criminal.Knockdown(5 SECONDS) TEST_ASSERT_EQUAL(criminal.capture_state(), "stunned", "A knocked-down criminal is not stunned") // BOUNTY_STATE_STUNNED - TEST_ASSERT_EQUAL(criminal.worst_state, "stunned", "Being stunned did not reach the worst state") criminal.SetKnockdown(0) TEST_ASSERT_EQUAL(criminal.capture_state(), "free", "A criminal back on its feet is not free") - TEST_ASSERT_EQUAL(criminal.worst_state, "stunned", "The worst state got better") - - // Stamina crit and surrender are stunned too. - criminal.adjustStaminaLoss(300) + criminal.Paralyze(5 SECONDS) + TEST_ASSERT_EQUAL(criminal.capture_state(), "stunned", "A paralysed criminal is not stunned") + criminal.SetParalyzed(0) + criminal.adjustStaminaLoss(200) TEST_ASSERT_EQUAL(criminal.capture_state(), "stunned", "A criminal in stamina crit is not stunned") criminal.setStaminaLoss(0) + criminal.remove_status_effect(/datum/status_effect/incapacitating/stamcrit) TEST_ASSERT_EQUAL(criminal.capture_state(), "free", "A criminal out of stamina crit is not free") - ADD_TRAIT(criminal, "bounty_surrendered", "bounty") // TRAIT_BOUNTY_SURRENDERED, BOUNTY_TRAIT - TEST_ASSERT_EQUAL(criminal.capture_state(), "stunned", "A surrendered criminal is not stunned") - TEST_ASSERT(!criminal.may_attack(allocate(/mob/living/carbon/human/consistent)), "A surrendered criminal may still attack") - - // Restrained comes before stunned. - TEST_ASSERT(criminal.body_apply_cuffs(allocate(/obj/item/restraints/handcuffs)), "A surrendered criminal could not be cuffed") - TEST_ASSERT_EQUAL(criminal.capture_state(), "restrained", "A cuffed, surrendered criminal is not restrained") // BOUNTY_STATE_RESTRAINED - REMOVE_TRAIT(criminal, "bounty_surrendered", "bounty") - TEST_ASSERT_EQUAL(criminal.capture_state(), "restrained", "A cuffed criminal is not restrained") - - // Downed comes before restrained, and once downed the worst state never goes back up. - criminal.adjustBruteLoss(500) - TEST_ASSERT_EQUAL(criminal.capture_state(), "downed", "A cuffed, downed criminal is not downed") - TEST_ASSERT_EQUAL(criminal.worst_state, "downed", "Being downed did not reach the worst state") - criminal.body_remove_cuffs() - criminal.body_stand_up() - TEST_ASSERT(!criminal.is_downed(), "The criminal did not get up") - TEST_ASSERT_EQUAL(criminal.capture_state(), "free", "A criminal that got up is not free") - TEST_ASSERT_EQUAL(criminal.worst_state, "downed", "The worst state got better after getting up") - criminal.Knockdown(5 SECONDS) - TEST_ASSERT(criminal.body_apply_cuffs(allocate(/obj/item/restraints/handcuffs)), "The criminal could not be cuffed again") - TEST_ASSERT_EQUAL(criminal.worst_state, "downed", "Cuffing after a down improved the worst state") - - // Dead comes before everything, and the cuffs drop. + criminal.Sleeping(5 SECONDS) + TEST_ASSERT_EQUAL(criminal.capture_state(), "stunned", "A sleeping criminal is not stunned") + criminal.SetSleeping(0) + TEST_ASSERT_EQUAL(criminal.capture_state(), "free", "A criminal woken up is not free") + + // Cuffed with real tg handcuffs is restrained; the restraint signal names the cuffer it last reached for. + criminal.body_cuffer_ref = WEAKREF(hunter) + criminal.body_cuffed_at = world.time + TEST_ASSERT_NOTNULL(cuff(criminal, hunter), "Real handcuffs did not go on a criminal") + TEST_ASSERT_EQUAL(criminal.capture_state(), "restrained", "A cuffed criminal is not restrained") // BOUNTY_STATE_RESTRAINED + TEST_ASSERT_EQUAL(signal_count("restrained"), 1, "Cuffing sent [signal_count("restrained")] restraint signals") + TEST_ASSERT_EQUAL(last_restraint_user(), hunter, "The restraint signal didn't name the cuffer") + TEST_ASSERT(!criminal.may_attack(hunter), "A cuffed criminal may attack") + + // In crit comes before cuffed, and getting out of crit is the tg way: healing. + bounty_test_hurt_to(criminal, -10) + TEST_ASSERT_EQUAL(criminal.capture_state(), "downed", "A cuffed criminal in crit is not downed") // BOUNTY_STATE_DOWNED + TEST_ASSERT_EQUAL(signal_count("downed"), 1, "Going into crit sent [signal_count("downed")] downed signals") + // (Getting up from the stamina crit above already sent one recovered signal.) + var/recovered_before = signal_count("recovered") + criminal.adjustBruteLoss(-50) + TEST_ASSERT_EQUAL(criminal.capture_state(), "restrained", "A cuffed criminal healed out of crit is not restrained") + TEST_ASSERT_EQUAL(signal_count("recovered") - recovered_before, 1, "Leaving crit sent [signal_count("recovered") - recovered_before] recovered signals") + + // Uncuffed by someone else: the signal carries a non-null user (it didn't free itself). + criminal.uncuff() + TEST_ASSERT_EQUAL(signal_count("unrestrained"), 1, "Uncuffing sent [signal_count("unrestrained")] signals") + TEST_ASSERT_NOTNULL(last_restraint_user(), "Taken out of its cuffs by someone, it counted as freeing itself") + TEST_ASSERT_EQUAL(criminal.capture_state(), "free", "An uncuffed criminal is not free") + // Worked out of them itself (tg's cuff_resist() started): the signal carries null. + cuff(criminal, hunter) + SEND_SIGNAL(criminal, COMSIG_MOB_REMOVING_CUFFS, criminal.handcuffed) + criminal.uncuff() + TEST_ASSERT_NULL(last_restraint_user(), "A criminal that worked its cuffs off didn't count as freeing itself") + + // Dead comes before everything. criminal.death() - TEST_ASSERT_EQUAL(criminal.capture_state(), "dead", "A dead criminal is not dead") - TEST_ASSERT_EQUAL(criminal.worst_state, "dead", "Dying did not reach the worst state") - TEST_ASSERT(!criminal.is_restrained(), "A dead criminal kept its cuffs") - TEST_ASSERT_NOTNULL(locate(/obj/item/restraints/handcuffs) in criminal.loc, "A dead criminal's cuffs did not drop") + TEST_ASSERT_EQUAL(criminal.capture_state(), "dead", "A dead criminal is not dead") // BOUNTY_STATE_DEAD TEST_ASSERT(!criminal.is_downed(), "A dead criminal counts as downed") - // A copy respawned after its site reloaded keeps the old worst state, and it never gets better (M4). - var/mob/living/basic/bounty_criminal/normal/respawned = allocate(__IMPLIED_TYPE__) - TEST_ASSERT_EQUAL(respawned.body_restore_worst_state("downed"), "downed", "A respawned criminal did not take its old worst state") - TEST_ASSERT_EQUAL(respawned.body_restore_worst_state("stunned"), "downed", "Restoring a better state improved the worst state") - TEST_ASSERT_EQUAL(respawned.body_restore_worst_state("free"), "downed", "Restoring free improved the worst state") - TEST_ASSERT_EQUAL(respawned.body_restore_worst_state(null), "downed", "Restoring nothing changed the worst state") - respawned.Knockdown(5 SECONDS) - TEST_ASSERT_EQUAL(respawned.worst_state, "downed", "Stunning a respawned criminal improved its worst state") - TEST_ASSERT_EQUAL(respawned.body_restore_worst_state("dead"), "dead", "Restoring dead did not make the worst state dead") + // Revived and brought in alive, it is judged by its condition then, not by having died. + criminal.revive(HEAL_ALL) + TEST_ASSERT_EQUAL(criminal.capture_state(), "free", "A revived criminal is not free") + cuff(criminal, hunter) + TEST_ASSERT_EQUAL(criminal.capture_state(), "restrained", "A revived, cuffed criminal is not restrained") -// ===== RESTRAINTS ===== +// ===== CUFFS ===== +/// A reach for a free criminal's wrists: it steps away and runs or fights. Paralysed, stamcritted or in crit, it can't. /datum/unit_test/voidcrew_bounty_criminal_cuffs parent_type = /datum/unit_test/voidcrew_bounty_criminal /datum/unit_test/voidcrew_bounty_criminal_cuffs/Run() - var/mob/living/carbon/human/consistent/hunter = allocate(__IMPLIED_TYPE__, get_step(run_loc_floor_bottom_left, EAST)) - for(var/cuff_type in list(/obj/item/restraints/handcuffs, /obj/item/restraints/handcuffs/cable, /obj/item/restraints/handcuffs/cable/zipties)) - signal_counts = null - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) - RegisterSignal(criminal, "bounty_criminal_restrained", TYPE_PROC_REF(/datum/unit_test/voidcrew_bounty_criminal, on_restrained)) // COMSIG_BOUNTY_CRIMINAL_RESTRAINED - RegisterSignal(criminal, "bounty_criminal_unrestrained", TYPE_PROC_REF(/datum/unit_test/voidcrew_bounty_criminal, on_unrestrained)) // COMSIG_BOUNTY_CRIMINAL_UNRESTRAINED - var/obj/item/restraints/handcuffs/cuffs = allocate(cuff_type) - - // On its feet and free: refused, and it holds a grudge against whoever tried. - TEST_ASSERT_EQUAL(criminal.body_cuff_refusal(hunter, cuffs), "[criminal.p_they()] pull[criminal.p_s()] away!", "[cuff_type] could go on a criminal standing free") - TEST_ASSERT_EQUAL(criminal.item_interaction(hunter, cuffs), ITEM_INTERACT_BLOCKING, "Using [cuff_type] on a criminal standing free was not refused") - TEST_ASSERT(criminal.body_has_grudge(hunter), "Reaching for a free criminal's wrists did not put the hunter on its grudge list") - TEST_ASSERT(!criminal.is_restrained(), "A refused cuffing restrained the criminal") - - // Knocked down: they go on, and hold it. - criminal.Knockdown(5 SECONDS) - TEST_ASSERT_NULL(criminal.body_cuff_refusal(hunter, cuffs), "[cuff_type] could not go on a knocked-down criminal") - TEST_ASSERT(criminal.body_apply_cuffs(cuffs), "[cuff_type] did not go on") - TEST_ASSERT(criminal.is_restrained(), "[cuff_type] went on but the criminal is not restrained") - TEST_ASSERT_EQUAL(criminal.restraints.loc, criminal, "[cuff_type] are not in the criminal's contents") - if(ispath(cuff_type, /obj/item/restraints/handcuffs/cable/zipties)) - TEST_ASSERT(istype(criminal.restraints, /obj/item/restraints/handcuffs/cable/zipties/used), "Zipties went on as [criminal.restraints.type], not a used pair") - TEST_ASSERT_EQUAL(signal_count("restrained"), 1, "Cuffing with [cuff_type] did not send the restrained signal once") - TEST_ASSERT(HAS_TRAIT(criminal, TRAIT_IMMOBILIZED), "A restrained criminal can move") - TEST_ASSERT(HAS_TRAIT(criminal, "bounty_held"), "A restrained criminal's AI may still plan") // TRAIT_BOUNTY_HELD - TEST_ASSERT(HAS_TRAIT(criminal, TRAIT_AI_PAUSED), "A restrained criminal's AI is not paused") - criminal.SetKnockdown(0) - TEST_ASSERT_EQUAL(criminal.capture_state(), "restrained", "A criminal in [cuff_type] is not restrained") // BOUNTY_STATE_RESTRAINED - TEST_ASSERT(!criminal.may_attack(hunter), "A restrained criminal may still attack") - TEST_ASSERT(!criminal.early_melee_attack(hunter), "A restrained criminal threw a punch") - TEST_ASSERT_EQUAL(criminal.body_cuff_refusal(hunter, allocate(/obj/item/restraints/handcuffs)), "already cuffed", "A restrained criminal could be cuffed twice") - TEST_ASSERT(findtext(examine_text(criminal, hunter), "restrained with"), "Examining a restrained criminal does not say so") - - // Off again: they drop, and it is free. - var/obj/item/restraints/handcuffs/dropped = criminal.body_remove_cuffs() - TEST_ASSERT(!criminal.is_restrained(), "Taking [cuff_type] off left the criminal restrained") - TEST_ASSERT_EQUAL(dropped?.loc, criminal.loc, "[cuff_type] did not drop where the criminal is") - TEST_ASSERT(!HAS_TRAIT(criminal, TRAIT_IMMOBILIZED), "A criminal out of [cuff_type] still can't move") - TEST_ASSERT(!HAS_TRAIT(criminal, "bounty_held"), "A criminal out of [cuff_type] is still held") - TEST_ASSERT_EQUAL(signal_count("unrestrained"), 1, "Taking [cuff_type] off did not send the unrestrained signal once") - TEST_ASSERT_EQUAL(criminal.capture_state(), "free", "A criminal out of [cuff_type] is not free") - - // Cuffs taken out of it some other way still free it. - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) - criminal.Knockdown(5 SECONDS) - TEST_ASSERT(criminal.body_apply_cuffs(allocate(/obj/item/restraints/handcuffs)), "The criminal could not be cuffed") - criminal.restraints.forceMove(run_loc_floor_bottom_left) - TEST_ASSERT_NULL(criminal.restraints, "Cuffs moved out of a criminal are still its restraints") - TEST_ASSERT(!HAS_TRAIT(criminal, TRAIT_IMMOBILIZED), "A criminal whose cuffs were taken still can't move") - - // Used zipties are no use; a dead criminal takes no cuffs. - TEST_ASSERT_EQUAL(criminal.body_cuff_refusal(hunter, allocate(/obj/item/restraints/handcuffs/cable/zipties/used)), "used up", "Used zipties could go on") - criminal.death() - TEST_ASSERT_EQUAL(criminal.body_cuff_refusal(hunter, allocate(/obj/item/restraints/handcuffs)), "can't cuff [criminal.p_them()]", "A dead criminal could be cuffed") - - // A surrendered one can be cuffed on its feet. - var/mob/living/basic/bounty_criminal/normal/quitter = allocate(__IMPLIED_TYPE__) - ADD_TRAIT(quitter, "bounty_surrendered", "bounty") // TRAIT_BOUNTY_SURRENDERED, BOUNTY_TRAIT - TEST_ASSERT_NULL(quitter.body_cuff_refusal(hunter, allocate(/obj/item/restraints/handcuffs)), "A surrendered criminal could not be cuffed") - - // Joke zipties stay joke zipties once worn, and slip like them (L5; BOUNTY_FAKE_CUFF_SLIP 5 SECONDS). - TEST_ASSERT(quitter.body_apply_cuffs(allocate(/obj/item/restraints/handcuffs/cable/zipties/fake)), "Fake zipties did not go on") - TEST_ASSERT(istype(quitter.restraints, /obj/item/restraints/handcuffs/cable/zipties/fake/used), "Fake zipties went on as [quitter.restraints?.type]") - TEST_ASSERT_EQUAL(quitter.body_slip_time(), 50, "Fake zipties hold as long as real ones") - TEST_ASSERT_EQUAL(quitter.body_cuff_refusal(hunter, allocate(/obj/item/restraints/handcuffs/cable/zipties/fake/used)), "already cuffed", "Used fake zipties were not refused") - quitter.body_remove_cuffs() - TEST_ASSERT_EQUAL(quitter.body_cuff_refusal(hunter, allocate(/obj/item/restraints/handcuffs/cable/zipties/fake/used)), "used up", "Used fake zipties could go on") - - // A fulton never goes on a criminal (M2). - TEST_ASSERT_EQUAL(quitter.item_interaction(hunter, allocate(/obj/item/extraction_pack)), ITEM_INTERACT_BLOCKING, "A fulton could go on a criminal") - -// ===== SLIPPING ===== - -/datum/unit_test/voidcrew_bounty_criminal_slipping - parent_type = /datum/unit_test/voidcrew_bounty_criminal - -/datum/unit_test/voidcrew_bounty_criminal_slipping/Run() - // Cable restraints slip (BOUNTY_CABLE_SLIP 3 MINUTES), with a struggle first. - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) - criminal.Knockdown(5 SECONDS) - TEST_ASSERT(criminal.body_apply_cuffs(allocate(/obj/item/restraints/handcuffs/cable)), "Cable restraints did not go on") - TEST_ASSERT_EQUAL(criminal.body_slip_time(), 1800, "Cable restraints slip at the wrong time") - TEST_ASSERT_NOTNULL(criminal.body_slip_timer, "Cable restraints have no slip clock") - TEST_ASSERT_NOTNULL(criminal.body_slip_warn_timer, "Cable restraints have no struggle before they slip") - criminal.body_slip_warning() - TEST_ASSERT(criminal.is_restrained(), "The struggle took the cable restraints off") - TEST_ASSERT(criminal.body_slip_cuffs(), "The criminal did not slip its cable restraints") - TEST_ASSERT(!criminal.is_restrained(), "A criminal that slipped its restraints is still restrained") - TEST_ASSERT_NOTNULL(locate(/obj/item/restraints/handcuffs/cable) in criminal.loc, "Slipped cable restraints did not drop") - TEST_ASSERT_NULL(criminal.body_slip_timer, "A slip clock is left after slipping") - - // Zipties hold longer (BOUNTY_ZIPTIE_SLIP 5 MINUTES); handcuffs never slip. - var/mob/living/basic/bounty_criminal/normal/tied = allocate(__IMPLIED_TYPE__) - tied.Knockdown(5 SECONDS) - TEST_ASSERT(tied.body_apply_cuffs(allocate(/obj/item/restraints/handcuffs/cable/zipties)), "Zipties did not go on") - TEST_ASSERT_EQUAL(tied.body_slip_time(), 3000, "Zipties slip at the wrong time") - var/mob/living/basic/bounty_criminal/normal/cuffed = allocate(__IMPLIED_TYPE__) - cuffed.Knockdown(5 SECONDS) - TEST_ASSERT(cuffed.body_apply_cuffs(allocate(/obj/item/restraints/handcuffs)), "Handcuffs did not go on") - TEST_ASSERT_EQUAL(cuffed.body_slip_time(), 0, "Handcuffs slip") - TEST_ASSERT_NULL(cuffed.body_slip_timer, "Handcuffs have a slip clock") - - // A mini-boss snaps cable in half the time (BOUNTY_BOSS_SLIP_MULT 0.5), and the cable is gone. - var/mob/living/basic/bounty_criminal/boss/juggernaut/brute = allocate(__IMPLIED_TYPE__) - TEST_ASSERT(brute.body_apply_cuffs(allocate(/obj/item/restraints/handcuffs/cable)), "Cable restraints did not go on a mini-boss") - TEST_ASSERT_EQUAL(brute.body_slip_time(), 900, "A mini-boss slips cable at the wrong time") - var/obj/item/restraints/handcuffs/cable/snapped = brute.restraints - TEST_ASSERT(brute.body_slip_cuffs(), "A mini-boss did not snap its cable restraints") - TEST_ASSERT(!brute.is_restrained(), "A mini-boss that snapped its restraints is still restrained") - TEST_ASSERT(QDELETED(snapped), "Snapped cable restraints dropped whole") - -// ===== DRAGGING ===== - -/datum/unit_test/voidcrew_bounty_criminal_drag - parent_type = /datum/unit_test/voidcrew_bounty_criminal - -/datum/unit_test/voidcrew_bounty_criminal_drag/Run() - var/mob/living/carbon/human/consistent/hunter = allocate(__IMPLIED_TYPE__, get_step(run_loc_floor_bottom_left, EAST)) - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) - - // Free and on its feet, it pulls away. - hunter.start_pulling(criminal) - TEST_ASSERT_NULL(hunter.pulling, "A free criminal on its feet could be pulled") - - // In stamina crit it can be dragged, and it shakes the hand off once it is up. - criminal.adjustStaminaLoss(300) - hunter.start_pulling(criminal) - TEST_ASSERT_EQUAL(hunter.pulling, criminal, "A criminal in stamina crit could not be pulled") + var/turf/here = run_loc_floor_bottom_left + var/turf/cuffer_spot = get_step(here, WEST) || get_step(here, SOUTH) || get_step(here, NORTH) + if(isnull(cuffer_spot) || cuffer_spot.is_blocked_turf()) + cuffer_spot = get_step(here, NORTH) + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__, get_step(here, NORTHEAST)) + var/turf/start = get_turf(criminal) + var/mob/living/carbon/human/consistent/cuffer = allocate(__IMPLIED_TYPE__, here) + + // Free and on its feet: it can answer, puts the cuffer on its grudge list and steps away. + TEST_ASSERT(criminal.body_can_answer_cuffs(), "A free criminal can't answer a reach for its wrists") + criminal.body_on_cuff_attempt(cuffer) + TEST_ASSERT(criminal.body_has_grudge(cuffer), "Reaching for a criminal's wrists didn't make it hold a grudge") + criminal.body_answer_cuffs(WEAKREF(cuffer)) + TEST_ASSERT(get_turf(criminal) != start, "A free criminal didn't step away from the cuffs") + TEST_ASSERT(get_dist(criminal, cuffer) >= get_dist(start, cuffer), "A free criminal stepped toward the cuffs") + + // Paralysed (as by *surrender), stamcritted or in crit, it can't do anything about them. + criminal.Paralyze(20 SECONDS) + TEST_ASSERT(!criminal.body_can_answer_cuffs(), "A paralysed criminal can still answer a reach for its wrists") + criminal.SetParalyzed(0) + criminal.adjustStaminaLoss(200) + TEST_ASSERT(!criminal.body_can_answer_cuffs(), "A stamcritted criminal can still answer a reach for its wrists") criminal.setStaminaLoss(0) - TEST_ASSERT_NULL(hunter.pulling, "A criminal back on its feet is still being pulled") - - // Restrained, it can be dragged on its feet. - criminal.Knockdown(5 SECONDS) - TEST_ASSERT(criminal.body_apply_cuffs(allocate(/obj/item/restraints/handcuffs)), "The criminal could not be cuffed") - criminal.SetKnockdown(0) - hunter.start_pulling(criminal) - TEST_ASSERT_EQUAL(hunter.pulling, criminal, "A restrained criminal could not be pulled") - hunter.stop_pulling() - criminal.body_remove_cuffs() - - // Blending in, a stunned one still shakes off any hand; a downed one does not (AR-C7). - criminal.blended = TRUE - criminal.Knockdown(5 SECONDS) - hunter.start_pulling(criminal) - TEST_ASSERT_NULL(hunter.pulling, "A stunned criminal blending in could be pulled") - criminal.SetKnockdown(0) - criminal.adjustBruteLoss(500) - TEST_ASSERT(criminal.is_downed(), "The criminal was not downed") - hunter.start_pulling(criminal) - TEST_ASSERT_EQUAL(hunter.pulling, criminal, "A downed criminal blending in could not be pulled") - hunter.stop_pulling() - - // Dead, it can be dragged. - criminal.blended = FALSE - criminal.death() - hunter.start_pulling(criminal) - TEST_ASSERT_EQUAL(hunter.pulling, criminal, "A dead criminal could not be pulled") - hunter.stop_pulling() - -// ===== CARRYING ===== - -/// On the floor and draggable, it goes over a hunter's shoulders and comes along; it squirms off once it gets up or comes round -/datum/unit_test/voidcrew_bounty_criminal_carry - parent_type = /datum/unit_test/voidcrew_bounty_criminal - -/datum/unit_test/voidcrew_bounty_criminal_carry/Run() - var/turf/start = get_step(run_loc_floor_bottom_left, EAST) - var/mob/living/carbon/human/consistent/hunter = allocate(__IMPLIED_TYPE__, start) - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__, start) - - // On its feet, nobody lifts it. - TEST_ASSERT(!hunter.can_be_firemanned(criminal), "A criminal on its feet could be carried") - - // Down, it goes over the shoulders and comes along. - criminal.adjustBruteLoss(500) - TEST_ASSERT(criminal.is_downed(), "The criminal was not downed") - TEST_ASSERT(hunter.can_be_firemanned(criminal), "A downed criminal could not be carried") - TEST_ASSERT(hunter.buckle_mob(criminal, TRUE, TRUE, CARRIER_NEEDS_ARM), "A downed criminal could not be lifted") - TEST_ASSERT_EQUAL(criminal.buckled, hunter, "The downed criminal is not on the hunter's shoulders") - var/turf/ahead = get_step(start, NORTH) - hunter.Move(ahead, NORTH) - TEST_ASSERT_EQUAL(get_turf(hunter), ahead, "The hunter could not walk with the criminal on their shoulders") - TEST_ASSERT_EQUAL(get_turf(criminal), ahead, "The carried criminal did not come along") - TEST_ASSERT(criminal.is_downed(), "Being carried stood the criminal up") - - // Getting up, it squirms off. - TEST_ASSERT(criminal.body_stand_up(), "The criminal could not get up") - TEST_ASSERT_NULL(criminal.buckled, "A criminal that got up stayed on the hunter's shoulders") - TEST_ASSERT(!hunter.has_buckled_mobs(), "The hunter still carries a criminal that got up") - - // Knocked down, it can be carried until it comes round. - criminal.Knockdown(10 SECONDS) - TEST_ASSERT(hunter.can_be_firemanned(criminal), "A knocked down criminal could not be carried") - TEST_ASSERT(hunter.buckle_mob(criminal, TRUE, TRUE, CARRIER_NEEDS_ARM), "A knocked down criminal could not be lifted") - criminal.SetKnockdown(0) - TEST_ASSERT_NULL(criminal.buckled, "A criminal that came round stayed on the hunter's shoulders") - - // Dead, it can be carried. - criminal.death() - TEST_ASSERT(hunter.can_be_firemanned(criminal), "A dead criminal could not be carried") + criminal.remove_status_effect(/datum/status_effect/incapacitating/stamcrit) + bounty_test_hurt_to(criminal, -10) + TEST_ASSERT(!criminal.body_can_answer_cuffs(), "A criminal in crit can still answer a reach for its wrists") + criminal.adjustBruteLoss(-110) + + // The cuff signal never refuses tg's cuffs. + TEST_ASSERT(!(SEND_SIGNAL(criminal, COMSIG_CARBON_CUFF_ATTEMPTED, cuffer) & COMSIG_CARBON_CUFF_PREVENT), "A criminal refused tg's cuffs") + TEST_ASSERT_EQUAL(criminal.body_cuffer_ref?.resolve(), cuffer, "The cuff signal didn't note the cuffer") + + // A fulton never goes on one. + var/obj/item/extraction_pack/fulton = allocate(__IMPLIED_TYPE__) + TEST_ASSERT_EQUAL(criminal.item_interaction(cuffer, fulton), ITEM_INTERACT_BLOCKING, "A fulton could go on a criminal") + + // A cuffed criminal's AI works at its cuffs, the player's way (tg's resist). + var/datum/ai_planning_subtree/bounty_escape_captivity/escape = new + cuff(criminal, cuffer) + escape.SelectBehaviors(criminal.ai_controller, 1) + TEST_ASSERT(locate(/datum/ai_behavior/resist) in criminal.ai_controller.planned_behaviors, "A cuffed criminal doesn't work at its cuffs") + // The controller's own planning starts each pass on an empty plan; a subtree called by hand doesn't + criminal.ai_controller.CancelActions() + criminal.ai_controller.planned_behaviors.Cut() + // ...but a criminal sitting down or hiding in a locker by choice doesn't fight its way out of the chair or the locker. + criminal.uncuff() + var/obj/structure/chair/seat = allocate(__IMPLIED_TYPE__, get_turf(criminal)) + seat.buckle_mob(criminal, force = TRUE) + escape.SelectBehaviors(criminal.ai_controller, 1) + TEST_ASSERT(!(locate(/datum/ai_behavior/resist) in criminal.ai_controller.planned_behaviors), "A criminal fights its way out of a chair it sat on") + seat.unbuckle_mob(criminal, force = TRUE) + var/obj/structure/closet/locker = allocate(__IMPLIED_TYPE__, get_turf(criminal)) + criminal.forceMove(locker) + criminal.hidden = TRUE + escape.SelectBehaviors(criminal.ai_controller, 1) + TEST_ASSERT(!(locate(/datum/ai_behavior/resist) in criminal.ai_controller.planned_behaviors), "A criminal hiding in a locker fights its way out of it") + criminal.hidden = FALSE + criminal.forceMove(get_turf(locker)) + qdel(escape) -// ===== DEATH ===== +// ===== DEATH AND PROOF ===== /datum/unit_test/voidcrew_bounty_criminal_death parent_type = /datum/unit_test/voidcrew_bounty_criminal /datum/unit_test/voidcrew_bounty_criminal_death/Run() - // No revive, not even an admin's. - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) - criminal.death() - TEST_ASSERT(!criminal.can_be_revived(), "A dead criminal can be revived") - criminal.revive(ADMIN_HEAL_ALL) - TEST_ASSERT_EQUAL(criminal.stat, DEAD, "A dead criminal came back") - // Its body is the proof: a death that leaves the body leaves no tag; gibbing the body leaves one. var/list/postings = list() var/datum/criminal_bounty/gib_posting = new postings += gib_posting - var/mob/living/basic/bounty_criminal/normal/gibbed = allocate(__IMPLIED_TYPE__) + var/mob/living/carbon/human/npc/bounty_criminal/normal/gibbed = allocate(__IMPLIED_TYPE__) gibbed.posting_ref = WEAKREF(gib_posting) gibbed.death() + TEST_ASSERT(!QDELETED(gibbed), "A dead criminal's body did not stay") + TEST_ASSERT(!(gibbed in SShuman_npcs.corpses), "A wanted criminal's body is on the corpse sweep") TEST_ASSERT(!gibbed.body_proof_dropped, "A dead criminal whose body stays asked for proof") TEST_ASSERT_NULL(proof_for(gib_posting), "A dead criminal whose body stays left a tag") gibbed.gib() @@ -508,7 +346,7 @@ // Gibbed alive, it dies first, and leaves a tag. var/datum/criminal_bounty/blast_posting = new postings += blast_posting - var/mob/living/basic/bounty_criminal/normal/blown_up = allocate(__IMPLIED_TYPE__) + var/mob/living/carbon/human/npc/bounty_criminal/normal/blown_up = allocate(__IMPLIED_TYPE__) blown_up.posting_ref = WEAKREF(blast_posting) blown_up.gib() TEST_ASSERT_NOTNULL(proof_for(blast_posting), "A criminal gibbed alive left no tag") @@ -517,14 +355,14 @@ var/obj/effect/abstract/chasm_storage/depths = allocate(__IMPLIED_TYPE__) var/datum/criminal_bounty/fall_posting = new postings += fall_posting - var/mob/living/basic/bounty_criminal/normal/faller = allocate(__IMPLIED_TYPE__) + var/mob/living/carbon/human/npc/bounty_criminal/normal/faller = allocate(__IMPLIED_TYPE__) faller.posting_ref = WEAKREF(fall_posting) faller.forceMove(depths) faller.death(TRUE) TEST_ASSERT_NOTNULL(proof_for(fall_posting), "A criminal that fell into a chasm left no tag") var/datum/criminal_bounty/corpse_posting = new postings += corpse_posting - var/mob/living/basic/bounty_criminal/normal/corpse = allocate(__IMPLIED_TYPE__) + var/mob/living/carbon/human/npc/bounty_criminal/normal/corpse = allocate(__IMPLIED_TYPE__) corpse.posting_ref = WEAKREF(corpse_posting) corpse.death() TEST_ASSERT_NULL(proof_for(corpse_posting), "A body on the floor left a tag") @@ -534,7 +372,7 @@ // Deleted alive (a despawning ship, a stray delete), it was never killed: no proof (M5). var/datum/criminal_bounty/vanish_posting = new postings += vanish_posting - var/mob/living/basic/bounty_criminal/normal/vanished = allocate(__IMPLIED_TYPE__) + var/mob/living/carbon/human/npc/bounty_criminal/normal/vanished = allocate(__IMPLIED_TYPE__) vanished.posting_ref = WEAKREF(vanish_posting) qdel(vanished) TEST_ASSERT(!vanished.body_proof_dropped, "A live criminal deleted asked for proof") @@ -543,13 +381,13 @@ // Removed on purpose, by P5's mark (the pad, closing, relisting, its site unloading) or ours: no proof. var/datum/criminal_bounty/pad_posting = new postings += pad_posting - var/mob/living/basic/bounty_criminal/normal/beamed = allocate(__IMPLIED_TYPE__) + var/mob/living/carbon/human/npc/bounty_criminal/normal/beamed = allocate(__IMPLIED_TYPE__) beamed.posting_ref = WEAKREF(pad_posting) beamed.death() ADD_TRAIT(beamed, "bounty_removed", "bounty") // TRAIT_BOUNTY_REMOVED, BOUNTY_TRAIT qdel(beamed) TEST_ASSERT_NULL(proof_for(pad_posting), "A criminal the pad removed left a tag") - var/mob/living/basic/bounty_criminal/normal/unloaded = allocate(__IMPLIED_TYPE__) + var/mob/living/carbon/human/npc/bounty_criminal/normal/unloaded = allocate(__IMPLIED_TYPE__) unloaded.posting_ref = WEAKREF(pad_posting) unloaded.death() unloaded.body_mark_removed() @@ -560,7 +398,7 @@ var/datum/criminal_bounty/closed_posting = new postings += closed_posting closed_posting.status = "closed" // BOUNTY_POSTING_CLOSED - var/mob/living/basic/bounty_criminal/normal/late = allocate(__IMPLIED_TYPE__) + var/mob/living/carbon/human/npc/bounty_criminal/normal/late = allocate(__IMPLIED_TYPE__) late.posting_ref = WEAKREF(closed_posting) late.gib() TEST_ASSERT(!late.body_proof_dropped, "A criminal gibbed after its posting closed asked for proof") @@ -572,116 +410,30 @@ posting.status = "closed" // BOUNTY_POSTING_CLOSED QDEL_LIST(postings) -// ===== THE AUTOMATED DAMAGE FLOOR ===== - -/datum/unit_test/voidcrew_bounty_criminal_automated - parent_type = /datum/unit_test/voidcrew_bounty_criminal - -/datum/unit_test/voidcrew_bounty_criminal_automated/Run() - var/turf/here = run_loc_floor_bottom_left - var/list/site = list(here.x - 2, here.y - 2, here.x + 4, here.y + 4, here.z) - - // An explosion with nobody near is automated too: it stops at the floor (BOUNTY_AUTOMATED_FLOOR 40: 72 of 180). - var/mob/living/basic/bounty_criminal/normal/unwatched = allocate(__IMPLIED_TYPE__) - unwatched.site_bounds = site - unwatched.ex_act(EXPLODE_HEAVY) - unwatched.ex_act(EXPLODE_HEAVY) - TEST_ASSERT_EQUAL(unwatched.health, 72, "An explosion nobody set took a criminal on its site past the floor") - - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) - criminal.site_bounds = site - var/datum/component/bounty_body/ledger = criminal.GetComponent(/datum/component/bounty_body) - TEST_ASSERT_NOTNULL(ledger, "A criminal has no damage ledger") - - // Nobody's mind behind it: it stops at the floor, on its feet. - criminal.adjustBruteLoss(500) - TEST_ASSERT_EQUAL(criminal.health, 72, "Automated damage took a criminal on its site past the floor") - TEST_ASSERT(!criminal.is_downed(), "Automated damage downed a criminal on its site") - - // A player's hit: only the mercy rule. - var/mob/living/carbon/human/consistent/hunter = allocate(__IMPLIED_TYPE__, get_step(here, EAST)) - hunter.mind_initialize() - ledger.note_attacker(hunter) - TEST_ASSERT(ledger.player_hit_now(), "A hunter with a mind did not count as a player") - TEST_ASSERT(criminal.body_has_grudge(hunter), "An attacker did not go on the grudge list") - criminal.adjustBruteLoss(500) - TEST_ASSERT_EQUAL(criminal.health, 44, "A player's hit on a criminal on its site did not stop at the downed line") - TEST_ASSERT(criminal.is_downed(), "A player's hit did not down the criminal") - - // Down on its site, nothing automated finishes it off. - ledger.player_hit_at = -1 - criminal.adjustBruteLoss(500) - TEST_ASSERT_EQUAL(criminal.stat, CONSCIOUS, "Automated damage killed a downed criminal on its site") - - // A shot is its firer's, and a mech's shot its pilot's, though relay_attackers only reports mobs (M1). - var/mob/living/basic/bounty_criminal/normal/target = allocate(__IMPLIED_TYPE__) - target.site_bounds = site - var/datum/component/bounty_body/target_ledger = target.GetComponent(/datum/component/bounty_body) - var/obj/projectile/bullet/shot = allocate(__IMPLIED_TYPE__) - shot.firer = hunter - SEND_SIGNAL(target, COMSIG_PROJECTILE_PREHIT, shot) - TEST_ASSERT(target_ledger.player_hit_now(), "A hunter's shot did not count as a player's") - target_ledger.player_hit_at = -1 - var/mob/living/carbon/human/consistent/pilot = allocate(__IMPLIED_TYPE__, get_step(get_step(here, EAST), EAST)) - pilot.mind_initialize() - var/obj/vehicle/sealed/mecha/ripley/mech = allocate(__IMPLIED_TYPE__, get_step(get_step(here, NORTH), NORTH)) - mech.add_occupant(pilot, VEHICLE_CONTROL_DRIVE) - shot.firer = mech - SEND_SIGNAL(target, COMSIG_PROJECTILE_PREHIT, shot) - TEST_ASSERT(target_ledger.player_hit_now(), "A mech's shot did not count as its pilot's") - TEST_ASSERT(target.body_has_grudge(pilot), "A mech's pilot did not go on the grudge list") - mech.remove_occupant(pilot) - target_ledger.player_hit_at = -1 - - // An explosion with someone near counts as theirs: only the mercy rule. Three heavy blasts (60 each) reach the line. - target.ex_act(EXPLODE_HEAVY) - target.ex_act(EXPLODE_HEAVY) - target.ex_act(EXPLODE_HEAVY) - TEST_ASSERT_EQUAL(target.health, 44, "An explosion beside a hunter was held at the automated floor") - TEST_ASSERT(target.is_downed(), "An explosion beside a hunter did not down the criminal") - - // Its own side's blows miss it while it is down. - var/mob/living/basic/bounty_criminal/normal/downed_off_site = allocate(__IMPLIED_TYPE__) - downed_off_site.adjustBruteLoss(500) - var/datum/component/bounty_body/other_ledger = downed_off_site.GetComponent(/datum/component/bounty_body) - other_ledger.note_attacker(allocate(/mob/living/basic/bounty_companion)) - downed_off_site.adjustBruteLoss(10) - TEST_ASSERT_EQUAL(downed_off_site.health, 44, "A companion's blow hurt a downed criminal") - - // Off its site, automated damage gets the mercy rule only. - var/mob/living/basic/bounty_criminal/normal/stray = allocate(__IMPLIED_TYPE__) - stray.site_bounds = list(here.x + 5, here.y + 5, here.x + 6, here.y + 6, here.z) - stray.adjustBruteLoss(500) - TEST_ASSERT_EQUAL(stray.health, 44, "Automated damage off its site did not stop at the downed line") - -// ===== THE LEASH AND WHO IT FIGHTS ===== +// ===== THE LEASH ===== /datum/unit_test/voidcrew_bounty_criminal_leash parent_type = /datum/unit_test/voidcrew_bounty_criminal /datum/unit_test/voidcrew_bounty_criminal_leash/Run() - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) var/turf/here = get_turf(criminal) var/turf/east = get_step(here, EAST) var/turf/north = get_step(here, NORTH) TEST_ASSERT(criminal.leash_ok(north), "A criminal with no site may not go somewhere") TEST_ASSERT(!criminal.leash_ok(null), "A criminal may go nowhere") - // Leashed to its tile and the one east. + // Leashed to its tile and the one east: its AI's steps keep to it. criminal.site_bounds = list(here.x, here.y, here.x + 1, here.y, here.z) TEST_ASSERT(criminal.leash_ok(east), "A tile on the site is off the leash") TEST_ASSERT(!criminal.leash_ok(north), "A tile off the site is on the leash") - criminal.Move(north, NORTH) - TEST_ASSERT_EQUAL(criminal.loc, here, "A criminal walked off its site") - criminal.Move(east, EAST) - TEST_ASSERT_EQUAL(criminal.loc, east, "A criminal could not walk on its site") - criminal.Move(here, WEST) - TEST_ASSERT_EQUAL(criminal.loc, here, "A criminal could not walk back") + TEST_ASSERT(!criminal.body_move_allowed(north), "A criminal's own step may leave its site") + TEST_ASSERT(criminal.body_move_allowed(east), "A criminal's own step may not cross its site") // On its site it may fight anyone on their feet, and never someone down. var/mob/living/carbon/human/consistent/hunter = allocate(__IMPLIED_TYPE__, north) TEST_ASSERT(criminal.may_attack(hunter), "A criminal on its site may not fight a hunter") - var/mob/living/basic/bounty_criminal/normal/friend = allocate(__IMPLIED_TYPE__, east) + var/mob/living/carbon/human/npc/bounty_criminal/normal/friend = allocate(__IMPLIED_TYPE__, east) TEST_ASSERT(!criminal.may_attack(friend), "A criminal may fight another criminal") TEST_ASSERT(!criminal.may_attack(criminal), "A criminal may fight itself") var/obj/structure/table/table = allocate(__IMPLIED_TYPE__, east) @@ -697,17 +449,14 @@ criminal.body_add_grudge(hunter) TEST_ASSERT(criminal.may_attack(hunter), "A criminal off its site may not fight someone it holds a grudge against") - // Off its site, it walks anywhere (back toward its site, say); dragged, it goes anywhere. - hunter.forceMove(get_step(north, NORTH)) - criminal.Move(north, NORTH) - TEST_ASSERT_EQUAL(criminal.loc, north, "A criminal already off its site could not move") + // Off its site, it may walk anywhere (back toward its site, say); its body is never held: dragged, it goes anywhere. + TEST_ASSERT(criminal.body_move_allowed(north), "A criminal already off its site could not move") criminal.site_bounds = list(here.x, here.y, here.x, here.y, here.z) - criminal.forceMove(here) - criminal.Knockdown(5 SECONDS) var/mob/living/carbon/human/consistent/dragger = allocate(__IMPLIED_TYPE__, east) dragger.start_pulling(criminal) - TEST_ASSERT_EQUAL(dragger.pulling, criminal, "A knocked-down criminal could not be pulled") + TEST_ASSERT_EQUAL(dragger.pulling, criminal, "A free criminal could not be pulled") TEST_ASSERT(criminal.body_move_allowed(north), "A dragged criminal was held to its leash") + dragger.stop_pulling() // No environment damage off its site, or near a dock strip. TEST_ASSERT(!criminal.environment_damage_allowed(north), "Environment damage allowed off its site") @@ -715,24 +464,11 @@ TEST_ASSERT(!criminal.environment_damage_allowed(here), "Environment damage allowed beside the dock strip") // Teleports, polymorph and type changes are refused. - var/mob/living/basic/bounty_criminal/meek/runner = allocate(__IMPLIED_TYPE__) + var/mob/living/carbon/human/npc/bounty_criminal/meek/runner = allocate(__IMPLIED_TYPE__) TEST_ASSERT(!do_teleport(runner, east, no_effects = TRUE, forced = TRUE), "A criminal was teleported") TEST_ASSERT_EQUAL(runner.loc, here, "A criminal moved when teleported") TEST_ASSERT(SEND_SIGNAL(runner, COMSIG_LIVING_PRE_WABBAJACKED, null) & STOP_WABBAJACK, "A criminal could be polymorphed") TEST_ASSERT(SEND_SIGNAL(runner, COMSIG_PRE_MOB_CHANGED_TYPE) & COMPONENT_BLOCK_MOB_CHANGE, "A criminal could change type") - TEST_ASSERT_EQUAL(runner.sentience_type, 0, "A criminal can be given sentience") // BOUNTY_CRIMINAL_NO_SENTIENCE - - // A sprinting meek criminal ducks shots, but not straight after one got through (BOUNTY_MEEK_DODGE 50). - TEST_ASSERT_EQUAL(runner.body_dodge_chance(), 0, "A meek criminal ducks shots when not sprinting") - ADD_TRAIT(runner, "bounty_sprinting", "bounty") // TRAIT_BOUNTY_SPRINTING, BOUNTY_TRAIT - TEST_ASSERT_EQUAL(runner.body_dodge_chance(), 50, "A sprinting meek criminal does not duck shots") - runner.body_last_shot_at = world.time - TEST_ASSERT_EQUAL(runner.body_dodge_chance(), 0, "A meek criminal ducks the shot after one hit it") - runner.body_last_shot_at = -1 - runner.Knockdown(5 SECONDS) - TEST_ASSERT_EQUAL(runner.body_dodge_chance(), 0, "A knocked-down meek criminal ducks shots") - ADD_TRAIT(friend, "bounty_sprinting", "bounty") - TEST_ASSERT_EQUAL(friend.body_dodge_chance(), 0, "A normal criminal ducks shots") // ===== SHIPS, OUTPOSTS AND DOCK STRIPS INSIDE ITS SITE ===== @@ -753,42 +489,33 @@ var/list/site = list(here.x, here.y, here.x + 4, here.y + 4, here.z) // A ship or outpost inside the site's rectangle is not its site, and it doesn't walk onto one (H1). - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) criminal.site_bounds = site TEST_ASSERT(criminal.body_on_site(here), "Plain ground inside its site is not its site") TEST_ASSERT(!criminal.body_on_site(east), "A landed ship inside its site's rectangle counts as its site") TEST_ASSERT(!criminal.leash_ok(east), "A landed ship inside its site is on its leash") TEST_ASSERT(!criminal.leash_ok(north), "A player outpost inside its site is on its leash") - criminal.Move(east, EAST) - TEST_ASSERT_EQUAL(criminal.loc, here, "A criminal walked onto a ship inside its site") + TEST_ASSERT(!criminal.body_move_allowed(east), "A criminal may walk onto a ship inside its site") - // Aboard that ship it fights only its grudge list, and the automated floor doesn't hold it there. - var/mob/living/basic/bounty_criminal/normal/stowaway = allocate(__IMPLIED_TYPE__, north_east) + // Aboard that ship it fights only its grudge list. + var/mob/living/carbon/human/npc/bounty_criminal/normal/stowaway = allocate(__IMPLIED_TYPE__, north_east) stowaway.site_bounds = site var/mob/living/carbon/human/consistent/crew = allocate(__IMPLIED_TYPE__, two_north) TEST_ASSERT(!stowaway.may_attack(crew), "A criminal aboard a ship inside its site may fight anyone") stowaway.body_add_grudge(crew) TEST_ASSERT(stowaway.may_attack(crew), "A criminal aboard a ship may not fight someone it holds a grudge against") - stowaway.adjustBruteLoss(500) - TEST_ASSERT_EQUAL(stowaway.health, 44, "The automated floor held a criminal aboard a ship") qdel(stowaway) // Off its leash aboard ship A, it walks about that ship and back to its site, never on into // ship B or the player outpost (M3). criminal.forceMove(east) - criminal.Move(north_east, NORTH) - TEST_ASSERT_EQUAL(criminal.loc, north_east, "A criminal aboard a ship could not walk about it") - criminal.Move(north, WEST) - TEST_ASSERT_EQUAL(criminal.loc, north_east, "A criminal walked from a ship into a player outpost") - criminal.forceMove(east) - criminal.Move(far_east, EAST) - TEST_ASSERT_EQUAL(criminal.loc, east, "A criminal walked from one ship on into another") - criminal.Move(here, WEST) - TEST_ASSERT_EQUAL(criminal.loc, here, "A criminal aboard a ship could not walk back onto its site") + TEST_ASSERT(criminal.body_move_allowed(north_east), "A criminal aboard a ship could not walk about it") + TEST_ASSERT(!criminal.body_move_allowed(north), "A criminal may walk from a ship into a player outpost") + TEST_ASSERT(!criminal.body_move_allowed(far_east), "A criminal may walk from one ship on into another") + TEST_ASSERT(criminal.body_move_allowed(here), "A criminal aboard a ship could not walk back onto its site") // A scripted walk goes where it is sent. ADD_TRAIT(criminal, "bounty_scripted_move", "test") // TRAIT_BOUNTY_SCRIPTED_MOVE - criminal.Move(east, EAST) - TEST_ASSERT_EQUAL(criminal.loc, east, "A scripted walk was held to the leash") + TEST_ASSERT(criminal.body_move_allowed(far_east), "A scripted walk was held to the leash") REMOVE_TRAIT(criminal, "bounty_scripted_move", "test") criminal.forceMove(here) @@ -799,7 +526,7 @@ TEST_ASSERT(criminal.leash_ok(two_north), "Ground above the dock strip is off its leash") criminal.body_dock_top_y = null - // Whatever holds it can't be teleported, and lets go when it gets out (M2). + // Whatever holds it can't be teleported, and lets go when it gets out (M2). A carrier is a person, not a box. var/obj/structure/closet/locker = allocate(__IMPLIED_TYPE__, two_north) criminal.forceMove(locker) TEST_ASSERT(HAS_TRAIT(locker, TRAIT_NO_TELEPORT), "A locker holding a criminal can be teleported") @@ -815,24 +542,24 @@ /datum/unit_test/voidcrew_bounty_criminal_turrets/Run() var/turf/here = run_loc_floor_bottom_left - // Away from a trader outpost, a free criminal with an AI that hunts people is judged like any creature... - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) - new /datum/ai_controller/basic_controller/simple/simple_hostile(criminal) - TEST_ASSERT(istype(criminal.ai_controller, /datum/ai_controller/basic_controller/simple/simple_hostile), "The criminal did not take the hostile AI") - TEST_ASSERT(is_hostile_creature(criminal), "A free, hunting criminal away from a trader outpost is never a turret's") - // ...but no turret shoots one that is down, stunned or cuffed: a crew's turrets don't finish off its catch. + // Away from a trader outpost, no turret shoots a criminal in crit, stunned or cuffed (tg's states), + // so a crew's turrets don't finish off its catch; a free one is judged like any creature. + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) + TEST_ASSERT(!bounty_turret_ignores(criminal, FALSE), "Turrets leave a free criminal alone") criminal.Knockdown(5 SECONDS) + TEST_ASSERT(bounty_turret_ignores(criminal, FALSE), "A turret would shoot a stunned criminal") TEST_ASSERT(!is_hostile_creature(criminal), "A turret would shoot a stunned criminal") criminal.SetKnockdown(0) - TEST_ASSERT(criminal.body_apply_cuffs(allocate(/obj/item/restraints/handcuffs)), "The criminal could not be cuffed") - TEST_ASSERT(!is_hostile_creature(criminal), "A turret would shoot a cuffed criminal") - criminal.body_remove_cuffs() + cuff(criminal) + TEST_ASSERT(bounty_turret_ignores(criminal, FALSE), "A turret would shoot a cuffed criminal") + criminal.uncuff() + bounty_test_hurt_to(criminal, -10) + TEST_ASSERT(bounty_turret_ignores(criminal, FALSE), "A turret would shoot a criminal in crit") + criminal.adjustBruteLoss(-110) // At a trader outpost, criminals, decoys and companions are all left to the hunters. - var/mob/living/basic/bounty_criminal/decoy/decoy = allocate(__IMPLIED_TYPE__) - new /datum/ai_controller/basic_controller/simple/simple_hostile(decoy) - var/mob/living/basic/bounty_companion/companion = allocate(__IMPLIED_TYPE__) - new /datum/ai_controller/basic_controller/simple/simple_hostile(companion) + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = allocate(__IMPLIED_TYPE__) + var/mob/living/carbon/human/npc/bounty_companion/companion = allocate(__IMPLIED_TYPE__) TEST_ASSERT(bounty_turret_ignores(criminal, TRUE), "Trader-outpost turrets would shoot a criminal") TEST_ASSERT(bounty_turret_ignores(decoy, TRUE), "Trader-outpost turrets would shoot a decoy") TEST_ASSERT(bounty_turret_ignores(companion, TRUE), "Trader-outpost turrets would shoot a companion") @@ -843,7 +570,7 @@ criminal.forceMove(concourse) TEST_ASSERT(!is_hostile_creature(criminal), "A turret in a trader outpost's concourse would shoot a free criminal") -// ===== SPAWNING, EXAMINE AND MAKING THEM WITH NO ARGUMENTS ===== +// ===== SPAWNING, OUTFITS AND EXAMINE ===== /datum/unit_test/voidcrew_bounty_criminal_spawn parent_type = /datum/unit_test/voidcrew_bounty_criminal @@ -852,87 +579,75 @@ var/mob/living/carbon/human/consistent/hunter = allocate(__IMPLIED_TYPE__, get_step(run_loc_floor_bottom_left, EAST)) // Every criminal type comes up and goes away with no arguments, and its body procs don't runtime. - for(var/criminal_type in typesof(/mob/living/basic/bounty_criminal)) - var/mob/living/basic/bounty_criminal/criminal = allocate(criminal_type) + for(var/criminal_type in typesof(/mob/living/carbon/human/npc/bounty_criminal)) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = allocate(criminal_type) TEST_ASSERT(!QDELETED(criminal), "[criminal_type] was deleted as it was made") TEST_ASSERT_EQUAL(criminal.capture_state(), "free", "A fresh [criminal_type] is not free") - TEST_ASSERT_EQUAL(criminal.max_stamina, 100, "[criminal_type] has the wrong stamina pool") // BOUNTY_CRIMINAL_MAX_STAMINA TEST_ASSERT(!criminal.may_attack(null), "[criminal_type] may attack nothing") TEST_ASSERT(criminal.leash_ok(get_turf(criminal)), "[criminal_type] with no site is off its leash where it stands") TEST_ASSERT(length(criminal.examine(hunter)), "Examining [criminal_type] shows nothing") TEST_ASSERT(!criminal.body_leaves_proof(), "[criminal_type] with no posting would leave proof") + TEST_ASSERT(!criminal.hv_can_execute(), "[criminal_type] can land an execution") // With no record: a normal criminal. var/list/spawned = list() - var/mob/living/basic/bounty_criminal/plain = spawn_bounty_criminal(null, run_loc_floor_bottom_left, null) + var/mob/living/carbon/human/npc/bounty_criminal/plain = spawn_bounty_criminal(null, run_loc_floor_bottom_left, null) spawned += plain - TEST_ASSERT(istype(plain, /mob/living/basic/bounty_criminal/normal), "A criminal with no record is [plain?.type]") + TEST_ASSERT(istype(plain, /mob/living/carbon/human/npc/bounty_criminal/normal), "A criminal with no record is [plain?.type]") TEST_ASSERT_NULL(spawn_bounty_criminal(null, null, null), "A criminal spawned nowhere") - // Meek: its name, its health, and the planet-sweep protection while wanted. + // Meek: its record, posting, name and face, and the planet-sweep protection while wanted. var/datum/bounty_record/meek_record = new meek_record.archetype = "meek" // BOUNTY_ARCHETYPE_MEEK meek_record.name = "Tess Harlow" meek_record.gender = FEMALE var/datum/criminal_bounty/posting = new - var/mob/living/basic/bounty_criminal/meek/runner = spawn_bounty_criminal(meek_record, run_loc_floor_bottom_left, posting) + var/mob/living/carbon/human/npc/bounty_criminal/meek/runner = spawn_bounty_criminal(meek_record, run_loc_floor_bottom_left, posting) spawned += runner TEST_ASSERT(istype(runner), "A meek record spawned [runner?.type]") TEST_ASSERT_EQUAL(runner.record, meek_record, "A spawned criminal lost its record") TEST_ASSERT_EQUAL(runner.posting(), posting, "A spawned criminal lost its posting") TEST_ASSERT_EQUAL(runner.real_name, "Tess Harlow", "A spawned criminal lost its name") - TEST_ASSERT_EQUAL(runner.gender, FEMALE, "A spawned criminal lost its gender") - TEST_ASSERT_EQUAL(runner.maxHealth, 120, "A meek criminal has the wrong health") // BOUNTY_MEEK_HEALTH + TEST_ASSERT_EQUAL(runner.npc_damage_taken, 1, "A meek criminal takes more or less than a person's damage") // BOUNTY_TOUGHNESS_PETTY TEST_ASSERT(HAS_TRAIT(runner, "mission_field_mob"), "A wanted criminal is not kept from the planet sweep") // TRAIT_MISSION_FIELD_MOB - // BOUNTY_MEEK_STAMINA 90 on a pool of 100: three 30-point disabler shots - runner.adjustStaminaLoss(30) - runner.adjustStaminaLoss(30) - TEST_ASSERT(!runner.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "Two disabler shots stamina-crit a meek criminal") - runner.adjustStaminaLoss(30) - TEST_ASSERT(runner.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "Three disabler shots did not stamina-crit a meek criminal") - - // Normal: health by tier and style (BOUNTY_NORMAL_HEALTH_PETTY 140 x BOUNTY_STYLE_HEALTH_BRAWLER 1.2), pace by style. - var/datum/bounty_record/brawler_record = new - brawler_record.archetype = "normal" // BOUNTY_ARCHETYPE_NORMAL - brawler_record.tier = 1 // BOUNTY_TIER_PETTY - brawler_record.style = "brawler" // BOUNTY_STYLE_BRAWLER - var/mob/living/basic/bounty_criminal/normal/brawler = spawn_bounty_criminal(brawler_record, run_loc_floor_bottom_left, null) - spawned += brawler - TEST_ASSERT_EQUAL(brawler.maxHealth, 168, "A petty brawler has the wrong health") - TEST_ASSERT_EQUAL(brawler.health, 168, "A petty brawler did not start at full health") - TEST_ASSERT_EQUAL(brawler.speed, 1.25, "A brawler has the wrong pace") // BOUNTY_BODY_NORMAL_SPEED_MELEE - TEST_ASSERT(!HAS_TRAIT(brawler, "mission_field_mob"), "A criminal with no posting is kept from the planet sweep") - var/datum/bounty_record/gunman_record = new - gunman_record.archetype = "normal" - gunman_record.tier = 3 // BOUNTY_TIER_MOST_WANTED - gunman_record.style = "pistol" // BOUNTY_STYLE_PISTOL - var/mob/living/basic/bounty_criminal/normal/gunman = spawn_bounty_criminal(gunman_record, run_loc_floor_bottom_left, null) - spawned += gunman - // BOUNTY_NORMAL_HEALTH_MOST 220 x BOUNTY_STYLE_HEALTH_PISTOL 0.9 - TEST_ASSERT_EQUAL(gunman.maxHealth, 198, "A Most Wanted gunman has the wrong health") - TEST_ASSERT_EQUAL(gunman.speed, 1.4, "A gunman has the wrong pace") // BOUNTY_BODY_NORMAL_SPEED_RANGED + + // Toughness by tier is armour and npc_damage_taken: Most Wanted wear a vest and a helmet. + var/datum/bounty_record/most_record = new + most_record.archetype = "normal" // BOUNTY_ARCHETYPE_NORMAL + most_record.tier = 3 // BOUNTY_TIER_MOST_WANTED + var/mob/living/carbon/human/npc/bounty_criminal/normal/most = spawn_bounty_criminal(most_record, run_loc_floor_bottom_left, null) + spawned += most + TEST_ASSERT_EQUAL(most.npc_damage_taken, 0.8, "A Most Wanted criminal takes the wrong damage") // BOUNTY_TOUGHNESS_MOST_WANTED + TEST_ASSERT(istype(most.wear_suit, /obj/item/clothing/suit/armor/vest), "A Most Wanted criminal wears no vest") + TEST_ASSERT(istype(most.head, /obj/item/clothing/head/helmet), "A Most Wanted criminal wears no helmet") + TEST_ASSERT(!HAS_TRAIT(most, "mission_field_mob"), "A criminal with no posting is kept from the planet sweep") + var/datum/bounty_record/petty_record = new + petty_record.archetype = "normal" + petty_record.tier = 1 // BOUNTY_TIER_PETTY + var/mob/living/carbon/human/npc/bounty_criminal/normal/petty = spawn_bounty_criminal(petty_record, run_loc_floor_bottom_left, null) + spawned += petty + TEST_ASSERT(!istype(petty.wear_suit, /obj/item/clothing/suit/armor), "A petty criminal wears armour") // Mini-bosses by kit; never at a trader outpost, where a normal criminal stands in. var/datum/bounty_record/boss_record = new boss_record.archetype = "boss" // BOUNTY_ARCHETYPE_BOSS boss_record.kit = "ghost" // BOUNTY_KIT_GHOST - TEST_ASSERT_EQUAL(bounty_criminal_type(boss_record, null), /mob/living/basic/bounty_criminal/boss/ghost, "A ghost record is the wrong type") + TEST_ASSERT_EQUAL(bounty_criminal_type(boss_record, null), /mob/living/carbon/human/npc/bounty_criminal/boss/ghost, "A ghost record is the wrong type") var/datum/criminal_bounty/outpost_posting = new outpost_posting.placement_kind = "trader_outpost" // BOUNTY_PLACEMENT_TRADER_OUTPOST - TEST_ASSERT_EQUAL(bounty_criminal_type(boss_record, outpost_posting), /mob/living/basic/bounty_criminal/normal, "A mini-boss was placed at a trader outpost") - - // Examine: how hurt, and that it is down, never whether it gets back up; blending in, one layout only. - var/mob/living/basic/bounty_criminal/normal/examined = allocate(__IMPLIED_TYPE__) - TEST_ASSERT(findtext(examine_text(examined, hunter), "unhurt"), "Examining an unhurt criminal does not say so") - examined.adjustBruteLoss(500) - var/downed_text = examine_text(examined, hunter) - var/down_line = "[examined.p_They()] [examined.p_are()] down." - TEST_ASSERT(findtextEx(downed_text, down_line), "Examining a downed criminal does not say it is down: [downed_text]") - TEST_ASSERT(!findtext(downed_text, "get back up") && !findtext(downed_text, "while cuffed"), "Examining a downed criminal explains its recovery: [downed_text]") + TEST_ASSERT_EQUAL(bounty_criminal_type(boss_record, outpost_posting), /mob/living/carbon/human/npc/bounty_criminal/normal, "A mini-boss was placed at a trader outpost") + + // Examine: its features, and that it gave up while it lies there; never a health line of its own. + var/mob/living/carbon/human/npc/bounty_criminal/normal/examined = allocate(__IMPLIED_TYPE__) + TEST_ASSERT(!findtext(examine_text(examined, hunter), "unhurt"), "Examining a criminal shows the old health line") + examined.npc_surrendering = TRUE + examined.Paralyze(5 SECONDS) + var/given_up = "[examined.p_They()] [examined.p_have()] given up." + TEST_ASSERT(findtextEx(examine_text(examined, hunter), given_up), "Examining a criminal that gave up doesn't say so") examined.blended = TRUE - TEST_ASSERT(!findtextEx(examine_text(examined, hunter), down_line), "Examining a criminal blending in shows more than a decoy's layout") + TEST_ASSERT(!findtextEx(examine_text(examined, hunter), given_up), "Examining a criminal blending in shows more than a decoy's layout") - for(var/mob/living/basic/bounty_criminal/criminal as anything in spawned) + for(var/mob/living/carbon/human/npc/bounty_criminal/criminal as anything in spawned) qdel(criminal) // Marked closed first: deleting an open posting runs close(), which deletes it again (P5) posting.status = "closed" // BOUNTY_POSTING_CLOSED @@ -940,12 +655,55 @@ qdel(posting) qdel(outpost_posting) +// ===== SELF-TREATMENT ===== + +/// Hurt and unthreatened, it uses a real item it carries on itself (N6): a medipen, or a bruise pack on its worst limb. +/datum/unit_test/voidcrew_bounty_criminal_treat_self + parent_type = /datum/unit_test/voidcrew_bounty_criminal + +/datum/unit_test/voidcrew_bounty_criminal_treat_self/Run() + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) + var/datum/ai_controller/controller = criminal.ai_controller + var/datum/ai_planning_subtree/bounty_treat_self/treat = new + // Only what the test gives it: whatever treatment its outfit carried goes, and it has pockets. + for(var/obj/item/carried as anything in criminal.get_all_contents_type(/obj/item)) + if(istype(carried, /obj/item/stack/medical) || istype(carried, /obj/item/reagent_containers/hypospray/medipen) || carried == criminal.l_store || carried == criminal.r_store) + criminal.temporarilyRemoveItemFromInventory(carried, force = TRUE) + qdel(carried) + if(!criminal.w_uniform) + criminal.equip_to_slot_or_del(new /obj/item/clothing/under/pants/jeans(criminal), ITEM_SLOT_ICLOTHING) + // Unhurt, nothing to do. + treat.SelectBehaviors(controller, 1) + TEST_ASSERT(!controller.blackboard_key_exists("human_npc_treat_item"), "An unhurt criminal treats itself") + // Hurt with a bruise pack in its pocket: it picks the pack, and its worst limb. + criminal.apply_damage(40, BRUTE, BODY_ZONE_L_ARM) + var/obj/item/stack/medical/bruise_pack/pack = new(criminal) + criminal.equip_to_slot_or_del(pack, ITEM_SLOT_LPOCKET) + TEST_ASSERT_EQUAL(bounty_ai_find_medical_stack(criminal), pack, "A hurt criminal can't find its bruise pack") + TEST_ASSERT_EQUAL(bounty_ai_worst_limb(criminal), BODY_ZONE_L_ARM, "The worst limb is not the hurt arm") + treat.SelectBehaviors(controller, 1) + TEST_ASSERT_EQUAL(controller.blackboard["human_npc_treat_item"], pack, "A hurt criminal didn't reach for its bruise pack") + controller.CancelActions() + controller.clear_blackboard_key("human_npc_treat_item") + // A medipen comes first; a stimulant pen is never a treatment. + var/obj/item/reagent_containers/hypospray/medipen/stimpack/stim = new(criminal) + criminal.equip_to_slot_or_del(stim, ITEM_SLOT_RPOCKET) + TEST_ASSERT_NULL(bounty_ai_find_medipen(criminal), "A stimulant pen counts as a treatment") + TEST_ASSERT_EQUAL(bounty_ai_find_injector(criminal, /obj/item/reagent_containers/hypospray/medipen/stimpack), stim, "The stimulant pen isn't found as an injector") + // With a target to fight, it doesn't stop to patch up. + var/mob/living/carbon/human/consistent/hunter = allocate(__IMPLIED_TYPE__, get_step(run_loc_floor_bottom_left, EAST)) + controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) + controller.clear_blackboard_key("human_npc_next_treat") + treat.SelectBehaviors(controller, 1) + TEST_ASSERT(!controller.blackboard_key_exists("human_npc_treat_item"), "A criminal in a fight stops to treat itself") + qdel(treat) + // ===== MOMENT LINES ===== /** - * The capture's moment lines always land (BUG-1): going down and being cuffed are said past the bark - * cooldown, and once each, never a second time by the AI. No balloon says what the pay dropped to - * (2026-09-26: the world doesn't explain the rules). + * The capture's moment lines always land (BUG-1): going into crit and being cuffed are said past the + * bark cooldown, once each. No balloon says what the pay dropped to (2026-09-26: the world doesn't + * explain the rules). */ /datum/unit_test/voidcrew_bounty_criminal_moments parent_type = /datum/unit_test/voidcrew_bounty_criminal @@ -965,43 +723,26 @@ /datum/unit_test/voidcrew_bounty_criminal_moments/Run() var/list/lines = bounty_identity_strings("lines") - var/list/postings = list() var/datum/criminal_bounty/posting = new - postings += posting // With no record, they use the shared lines only. - var/mob/living/basic/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) + var/mob/living/carbon/human/npc/bounty_criminal/normal/criminal = allocate(__IMPLIED_TYPE__) criminal.posting_ref = WEAKREF(posting) RegisterSignal(criminal, COMSIG_MOB_SAY, PROC_REF(on_say)) var/datum/component/bounty_identity_voice/voice = criminal.LoadComponent(/datum/component/bounty_identity_voice) - // They just said something ("hurt"): the cooldown is running. + // They just said something: the cooldown is running. COOLDOWN_START(voice, line_cooldown, 8 SECONDS) // BOUNTY_SAY_COOLDOWN - criminal.adjustBruteLoss(500) - TEST_ASSERT(criminal.is_downed(), "The criminal did not go down") - TEST_ASSERT_EQUAL(heard_from(lines["downed"]["any"]), 1, "Going down inside the cooldown, they said [heard_from(lines["downed"]["any"])] downed lines, not 1") - // No balloon says what the catch is worth now: the receipt does, after (2026-09-26) + bounty_test_hurt_to(criminal, -10) + TEST_ASSERT(criminal.is_downed(), "The criminal did not go into crit") + TEST_ASSERT_EQUAL(heard_from(lines["downed"]["any"]), 1, "Going into crit inside the cooldown, they said [heard_from(lines["downed"]["any"])] downed lines, not 1") TEST_ASSERT_NULL(criminal.body_last_alert, "Going down showed [criminal.body_last_alert] over them") - // Cuffed two seconds later, well inside the cooldown of the downed line - TEST_ASSERT(criminal.body_apply_cuffs(allocate(/obj/item/restraints/handcuffs)), "The downed criminal could not be cuffed") + // Cuffed a moment later, inside the cooldown of the downed line. + cuff(criminal) TEST_ASSERT_EQUAL(heard_from(lines["cuffed"]["any"]), 1, "Cuffed inside the cooldown, they said [heard_from(lines["cuffed"]["any"])] cuffed lines, not 1") // Killed: still no balloon about the pay. - criminal.adjustBruteLoss(500) - TEST_ASSERT_EQUAL(criminal.stat, DEAD, "A hit on a downed criminal did not kill it") + criminal.death() TEST_ASSERT_NULL(criminal.body_last_alert, "Dying showed [criminal.body_last_alert] over them") - // With the cooldown over, going down is still said once: the AI no longer says it too. - heard.Cut() - var/mob/living/basic/bounty_criminal/normal/twice = allocate(__IMPLIED_TYPE__) - twice.posting_ref = WEAKREF(posting) - RegisterSignal(twice, COMSIG_MOB_SAY, PROC_REF(on_say)) - twice.adjustBruteLoss(500) - TEST_ASSERT_EQUAL(heard_from(lines["downed"]["any"]), 1, "Going down, they said [heard_from(lines["downed"]["any"])] downed lines, not 1") - TEST_ASSERT(twice.body_stand_up(), "The downed criminal could not get up") - twice.adjustBruteLoss(500) - TEST_ASSERT(twice.is_downed(), "The criminal did not go down a second time") - TEST_ASSERT_NULL(twice.body_last_alert, "Going down showed [twice.body_last_alert] over them") - // Marked closed first: deleting an open posting runs close(), which deletes it again (P5) - for(var/datum/criminal_bounty/each_posting as anything in postings) - each_posting.status = "closed" // BOUNTY_POSTING_CLOSED - QDEL_LIST(postings) + posting.status = "closed" // BOUNTY_POSTING_CLOSED + qdel(posting) diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_identity.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_identity.dm index bac6750e9c8..adbd19969e3 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_identity.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_identity.dm @@ -475,7 +475,7 @@ // Each archetype speaks its own lines and the shared ones, never another's. for(var/archetype in list("meek", "normal", "boss")) // BOUNTY_ARCHETYPE_* - var/mob/living/basic/bounty_criminal/criminal = allocate(/mob/living/basic/bounty_criminal/normal) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = allocate(/mob/living/carbon/human/npc/bounty_criminal/normal) criminal.record = generate_bounty_record(archetype == "boss" ? 3 : 2, archetype, "planet") TEST_ASSERT_EQUAL(criminal.identity_voice(), archetype, "A [archetype] criminal doesn't talk like one") var/list/allowed = pool_of(lines, "hurt", archetype) @@ -487,14 +487,14 @@ TEST_ASSERT(own_heard, "A [archetype] criminal never used its own lines") // Blended in, a fugitive talks like its decoys; a decoy never names a crime, blended or not. - var/mob/living/basic/bounty_criminal/fugitive = allocate(/mob/living/basic/bounty_criminal/meek) + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = allocate(/mob/living/carbon/human/npc/bounty_criminal/meek) fugitive.record = generate_bounty_record(1, "meek", "trader_outpost") fugitive.blended = TRUE TEST_ASSERT_NULL(fugitive.identity_voice(), "A blended fugitive talks differently from its decoys") TEST_ASSERT_EQUAL(fugitive.identity_line_values()?["{crime}"], fugitive.record.crime, "A fugitive doesn't know its own crime") for(var/line in sample(fugitive, "hurt", 20)) TEST_ASSERT(line in lines["hurt"]["any"], "A blended fugitive said a voiced line: [line]") - var/mob/living/basic/bounty_criminal/decoy/decoy = allocate(/mob/living/basic/bounty_criminal/decoy) + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = allocate(/mob/living/carbon/human/npc/bounty_criminal/decoy) decoy.record = make_decoy_record(fugitive.record, 1) TEST_ASSERT_NULL(decoy.identity_voice(), "A decoy speaks in an archetype's voice") TEST_ASSERT_NULL(decoy.identity_line_values(), "A decoy fills in a crime") @@ -502,6 +502,6 @@ TEST_ASSERT(!findtext(line, decoy.record.crime) && !findtext(line, fugitive.record.crime), "A decoy owned up to a crime: [line]") // A Most Wanted criminal never tosses off its crime. - var/mob/living/basic/bounty_criminal/boss = allocate(/mob/living/basic/bounty_criminal/normal) + var/mob/living/carbon/human/npc/bounty_criminal/boss = allocate(/mob/living/carbon/human/npc/bounty_criminal/normal) boss.record = generate_bounty_record(3, "boss", "planet") TEST_ASSERT_NULL(boss.identity_line_values(), "A Most Wanted criminal fills in its crime") diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_kingpin.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_kingpin.dm index 38987d06347..59b600500ff 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_kingpin.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_kingpin.dm @@ -5,11 +5,13 @@ * Owner: P9 kingpin. Do not edit this file outside that package. Fork defines are included after * the tests, so a test uses the literal value with a comment naming the define. * - * The tests drive the kingpin's procs directly: the lounge is built in the test room (a sofa, the - * coffee table, a few goon posts), the talk is picked by option rather than through the radial, and - * the shootout's clock is moved by hand rather than waited out. Before and after each test the - * board's clock is stopped, every kingpin and goon is deleted (a posting that closes no longer takes - * him away), every posting is closed and SSbounty_kingpin forgets the round's kingpin. + * The kingpin and his goons are real humans (the human NPC base). The tests drive the kingpin's procs + * directly: the lounge is built in the test room (a sofa, the coffee table, a few goon posts), the + * talk is picked by option rather than through the radial, and the shootout's clock is moved by hand + * rather than waited out. Hurts are real damage (crit is tg's crit), cuffs are real cuffs in the cuff + * slot, shots are real trigger pulls of the guns in their hands. Before and after each test the + * board's clock is stopped, every kingpin and goon is deleted, every posting is closed and + * SSbounty_kingpin forgets the round's kingpin. */ // ===== FIXTURES ===== @@ -55,9 +57,9 @@ /// Deletes every kingpin in the world and his goons (with him goes his crew and the job he holds) /datum/unit_test/voidcrew_bounty_kingpin/proc/kingpin_test_clear_crews() for(var/datum/bounty_kingpin_crew/crew as anything in GLOB.bounty_kingpin_crews.Copy()) - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in crew.goons()) + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in crew.goons()) qdel(goon) - var/mob/living/basic/bounty_criminal/kingpin/kingpin = crew.kingpin() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = crew.kingpin() if(kingpin) qdel(kingpin) else @@ -96,9 +98,9 @@ /** * The lounge in the test room: the sofa at (2,0) facing north, the coffee table across (1-3,1), - * the kingpin on the sofa, and `goon_count` goons (up to 4) at the room's edges. The talk spot is - * (2,2). With `posting` he is wanted on it (on its record); with none he sits on no posting, on a - * record of his own, as the round starts him. + * the kingpin on the sofa, and `goon_count` goons (up to 4) at the room's edges, built at once. The + * talk spot is (2,2). With `posting` he is wanted on it (on its record); with none he sits on no + * posting, on a record of his own, as the round starts him. */ /datum/unit_test/voidcrew_bounty_kingpin/proc/kingpin_test_lounge(datum/criminal_bounty/kingpin/posting, goon_count = 2) var/turf/seat = kingpin_test_spot(2, 0) @@ -112,7 +114,7 @@ for(var/i in 1 to min(goon_count, length(spots))) posts += list(list(spots[i], weapons[i])) var/datum/bounty_record/record = posting ? posting.record : bounty_kingpin_make_record() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = bounty_kingpin_setup(seat, posts, record) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = bounty_kingpin_setup(seat, posts, record, TRUE) posting?.board_adopt_criminal(kingpin, null, null, null) return kingpin @@ -127,7 +129,7 @@ * Gives `kingpin` a job to hold: a plain mission standing in for his Drug Run, whose making depends on * the round's planets. He makes no other after it is taken. */ -/datum/unit_test/voidcrew_bounty_kingpin/proc/kingpin_test_job(mob/living/basic/bounty_criminal/kingpin/kingpin) +/datum/unit_test/voidcrew_bounty_kingpin/proc/kingpin_test_job(mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin) var/datum/mission/job = allocate(/datum/mission) kingpin.kingpin_crew.crew_job_retry_at = world.time + 1 HOURS kingpin.kingpin_crew.hold_job(job) @@ -140,6 +142,37 @@ count += voucher.amount return count +/// Puts `body` in tg's crit for real: brute past the crit line (soft crit, health -10 for a person) +/datum/unit_test/voidcrew_bounty_kingpin/proc/kingpin_test_down(mob/living/carbon/human/body) + bounty_test_hurt_to(body, -10) + return HAS_TRAIT(body, TRAIT_CRITICAL_CONDITION) + +/// Real handcuffs in `body`'s cuff slot. Returns TRUE if they went on. +/datum/unit_test/voidcrew_bounty_kingpin/proc/kingpin_test_cuff(mob/living/carbon/human/body) + var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs, get_turf(body)) + return body.equip_to_slot_if_possible(cuffs, ITEM_SLOT_HANDCUFFED) && HAS_TRAIT(body, TRAIT_RESTRAINED) + +/// Live rounds in `gun`: its magazine (a revolver's cylinder holds its chamber), and a chambered round +/datum/unit_test/voidcrew_bounty_kingpin/proc/kingpin_test_live_rounds(obj/item/gun/ballistic/gun) + . = human_npc_live_rounds(gun.magazine) + if(gun.bolt_type != BOLT_TYPE_NO_BOLT && gun.chambered?.loaded_projectile) + .++ + +/// Runs `behavior_type` (a reload) on `npc`'s controller step by step, the waits between steps skipped. TRUE if it finished. +/datum/unit_test/voidcrew_bounty_kingpin/proc/kingpin_test_run_reload(mob/living/carbon/human/npc, behavior_type, steps = 40) + var/datum/ai_controller/controller = npc.ai_controller + var/datum/ai_behavior/reload = GET_AI_BEHAVIOR(behavior_type) + if(!reload.setup(controller)) + return FALSE + for(var/step in 1 to steps) + npc.next_click = 0 + npc.next_move = 0 + var/result = reload.perform(1, controller) + if(result & AI_BEHAVIOR_FAILED) + return FALSE + if(result & AI_BEHAVIOR_SUCCEEDED) + return TRUE + return FALSE /datum/unit_test/voidcrew_bounty_kingpin/New() . = ..() @@ -149,53 +182,55 @@ kingpin_test_end() return ..() -// ===== PAY ===== +// ===== PAY (CB-28) ===== -/// Wanted dead or alive: restrained, stunned or downed pays in full with the vouchers; dead pays 80% (spec 15) +/// Wanted dead or alive, on his condition at the pad: cuffed, stunned or in crit pays in full with the vouchers; dead pays 80% /datum/unit_test/voidcrew_bounty_kingpin/shares /datum/unit_test/voidcrew_bounty_kingpin/shares/Run() var/datum/criminal_bounty/kingpin/posting = kingpin_test_posting() // BOUNTY_KINGPIN_PAY_ALIVE 100, BOUNTY_KINGPIN_PAY_DEAD 80 - TEST_ASSERT_EQUAL(posting.board_share_for("dead", "dead"), 80, "A dead kingpin doesn't pay 80%") - TEST_ASSERT_EQUAL(posting.board_share_for("downed", "downed"), 100, "A downed kingpin doesn't pay in full") - TEST_ASSERT_EQUAL(posting.board_share_for("restrained", "downed"), 100, "A cuffed kingpin who was downed doesn't pay in full") - TEST_ASSERT_EQUAL(posting.board_share_for("restrained", "restrained"), 100, "A cuffed kingpin doesn't pay in full") - TEST_ASSERT_EQUAL(posting.board_share_for("stunned", "stunned"), 100, "A stunned kingpin doesn't pay in full") - TEST_ASSERT_EQUAL(posting.board_share_for("free", "free"), 0, "A kingpin standing free pays something") - // What the pad pays: full, downed (full) and dead (80% of 1000 cr and 2 vouchers at 1200: 2720) - var/list/full_pay = posting.board_payout(posting.board_share_for("restrained", "restrained")) - var/list/downed_pay = posting.board_payout(posting.board_share_for("downed", "downed")) - var/list/dead_pay = posting.board_payout(posting.board_share_for("dead", "dead")) + TEST_ASSERT_EQUAL(posting.board_share_for("dead"), 80, "A dead kingpin doesn't pay 80%") + TEST_ASSERT_EQUAL(posting.board_share_for("downed"), 100, "A kingpin in crit doesn't pay in full") + TEST_ASSERT_EQUAL(posting.board_share_for("restrained"), 100, "A cuffed kingpin doesn't pay in full") + TEST_ASSERT_EQUAL(posting.board_share_for("stunned"), 100, "A stunned kingpin doesn't pay in full") + TEST_ASSERT_EQUAL(posting.board_share_for("free"), 0, "A kingpin standing free pays something") + // What the pad pays: full, in crit (full) and dead (80% of 1000 cr and 2 vouchers at 1200: 2720) + var/list/full_pay = posting.board_payout(posting.board_share_for("restrained")) + var/list/downed_pay = posting.board_payout(posting.board_share_for("downed")) + var/list/dead_pay = posting.board_payout(posting.board_share_for("dead")) TEST_ASSERT_EQUAL(full_pay[1], 1000, "The full pay is wrong") - TEST_ASSERT_EQUAL(downed_pay[1], 1000, "The downed pay isn't full pay") + TEST_ASSERT_EQUAL(downed_pay[1], 1000, "The pay for a kingpin in crit isn't full pay") TEST_ASSERT_EQUAL(dead_pay[1], 2720, "The dead pay is wrong") TEST_ASSERT_EQUAL(posting.board_terms(), "Wanted dead or alive", "The card doesn't say dead or alive") posting.close("admin") - // Through the pad: downed, cuffed and dead, each on its own posting + // Through the pad, his real condition read at the press: in crit, cuffed, stunned and dead, each on its own posting var/turf/pad_turf = kingpin_test_spot(4, 4) var/obj/machinery/mission_pad/pad = allocate(/obj/machinery/mission_pad, pad_turf) var/obj/structure/overmap/ship/ship = kingpin_test_ship() var/list/cases = list( list("downed", 1000, 2), list("restrained", 1000, 2), + list("stunned", 1000, 2), list("dead", 2720, 0), ) for(var/list/pay_case as anything in cases) var/datum/criminal_bounty/kingpin/case_posting = kingpin_test_posting() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(case_posting, 0) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(case_posting, 0) kingpin.buckled?.unbuckle_mob(kingpin, force = TRUE) kingpin.forceMove(pad_turf) switch(pay_case[1]) if("downed") - kingpin.body_go_down() + TEST_ASSERT(kingpin_test_down(kingpin), "The kingpin didn't go into crit") if("restrained") - var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs, pad_turf) - TEST_ASSERT(kingpin.body_apply_cuffs(cuffs), "The kingpin couldn't be cuffed") + TEST_ASSERT(kingpin_test_cuff(kingpin), "The kingpin couldn't be cuffed") + if("stunned") + kingpin.Paralyze(20 SECONDS) if("dead") kingpin.death() var/state = kingpin.capture_state() + TEST_ASSERT_EQUAL(state, pay_case[1], "The kingpin reads [state] at the pad, not [pay_case[1]]") var/balance_before = ship.ship_account.account_balance var/vouchers_before = kingpin_test_vouchers(pad_turf) var/list/paid = case_posting.board_claim(ship, pad, kingpin, state) @@ -217,7 +252,7 @@ /datum/unit_test/voidcrew_bounty_kingpin/talk/Run() var/datum/criminal_bounty/kingpin/posting = kingpin_test_posting() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 1) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 1) var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew TEST_ASSERT_NOTNULL(crew, "The kingpin has no crew") TEST_ASSERT(istype(kingpin.buckled, /obj/structure/chair/sofa), "The kingpin isn't sitting on the sofa") @@ -263,12 +298,12 @@ TEST_ASSERT(!crew.is_hunter(taker), "The crew treats someone who works for him as a hunter") TEST_ASSERT(!crew.valid_target(taker), "The goons would shoot someone who works for him") - // The pad refuses him from that ship, even with him subdued on it + // The pad refuses him from that ship, even with him subdued on it (given up: tg's *surrender) var/turf/pad_turf = kingpin_test_spot(4, 4) var/obj/machinery/mission_pad/pad = allocate(/obj/machinery/mission_pad, pad_turf) kingpin.buckled?.unbuckle_mob(kingpin, force = TRUE) kingpin.forceMove(pad_turf) - kingpin.kingpin_surrender() + TEST_ASSERT(kingpin.npc_surrender(), "The kingpin wouldn't give up") TEST_ASSERT_EQUAL(kingpin.capture_state(), "stunned", "A kingpin who gave up doesn't read stunned") // BOUNTY_STATE_STUNNED TEST_ASSERT_EQUAL(posting.turn_in(pad, ship, taker), "your crew works for him", "The pad took the kingpin from the ship that works for him") TEST_ASSERT(posting.is_open() && !QDELETED(kingpin), "Refusing the bound ship touched the bounty") @@ -285,7 +320,7 @@ /datum/unit_test/voidcrew_bounty_kingpin/work_refusals /datum/unit_test/voidcrew_bounty_kingpin/work_refusals/Run() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(null, 1) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(null, 1) var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew // No real Drug Run is made here: the round's planets decide whether one can be crew.crew_job_retry_at = world.time + 1 HOURS @@ -329,20 +364,24 @@ // ===== THE SHOOTOUT STARTS ===== -/// A warrant gets his line and no fight; "We're here for you" starts it: the draw, the coffee table over, the hunter and their crew marked. An attack on a goon starts it too, a shove doesn't. +/// A warrant gets his line and no fight; "We're here for you" starts it: the draw (real guns into hands), the coffee table over, the hunter and their crew marked. An attack on a goon starts it too, a shove doesn't. /datum/unit_test/voidcrew_bounty_kingpin/confront /datum/unit_test/voidcrew_bounty_kingpin/confront/Run() var/datum/criminal_bounty/kingpin/posting = kingpin_test_posting() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 2) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 2) var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew var/obj/structure/overmap/ship/ship = kingpin_test_ship() var/mob/living/carbon/human/hunter = kingpin_test_person(kingpin_test_spot(2, 2), ship) var/mob/living/carbon/human/shipmate = kingpin_test_person(kingpin_test_spot(3, 3), ship) var/mob/living/carbon/human/bystander = kingpin_test_person(kingpin_test_spot(1, 3), null) TEST_ASSERT(!posting.board_clock_held(), "A calm kingpin's clock was held") + // At ease, the guns are carried, not held + TEST_ASSERT_NULL(human_npc_held_gun(kingpin), "The kingpin sits with a gun in his hand") + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in crew.goons()) + TEST_ASSERT_NULL(human_npc_held_gun(goon), "[goon] stands at ease with a gun in hand") - // Shown a warrant or reached for: his line, and nothing more + // Shown a warrant: his line, and nothing more kingpin.kingpin_confronted(hunter) TEST_ASSERT_EQUAL(crew.crew_state, "calm", "A warrant started a shootout") // BOUNTY_KINGPIN_CALM TEST_ASSERT(!crew.is_hunter(hunter), "A warrant made someone a hunter") @@ -357,55 +396,67 @@ var/obj/structure/table/table = ref.resolve() TEST_ASSERT(table?.is_flipped, "He didn't kick the coffee table over") TEST_ASSERT_EQUAL(table.dir, NORTH, "The coffee table went over the wrong way") - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in crew.goons()) - TEST_ASSERT(goon.goon_armed, "[goon] didn't reach for their gun") + TEST_ASSERT(istype(human_npc_held_gun(kingpin), /obj/item/gun/ballistic/revolver), "The kingpin didn't draw his revolver") + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in crew.goons()) + TEST_ASSERT(istype(human_npc_held_gun(goon), /obj/item/gun/ballistic), "[goon] didn't draw a real gun") + TEST_ASSERT(goon.ai_controller.blackboard["bounty_kingpin_armed"], "[goon]'s AI doesn't know the guns are out") // BB_BOUNTY_KINGPIN_ARMED TEST_ASSERT(posting.board_clock_held(), "The clock runs during a shootout") TEST_ASSERT(!kingpin.kingpin_can_talk(), "He'll still talk mid-shootout") TEST_ASSERT_EQUAL(kingpin.kingpin_work_refusal(shipmate), "no_work_hostile", "The crew that came for him could still get his work") + // It's over: the guns go back where they came from, on the body + crew.stand_down() + TEST_ASSERT_NULL(human_npc_held_gun(kingpin), "The kingpin kept his revolver out after standing down") + TEST_ASSERT(locate(/obj/item/gun/ballistic/revolver) in kingpin.get_all_contents(), "The kingpin's revolver went somewhere off his body") posting.close("admin") // An attack on a goon starts it too; a shove does not kingpin_test_clear_lounge() var/datum/criminal_bounty/kingpin/second_posting = kingpin_test_posting() - var/mob/living/basic/bounty_criminal/kingpin/second_kingpin = kingpin_test_lounge(second_posting, 2) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/second_kingpin = kingpin_test_lounge(second_posting, 2) var/datum/bounty_kingpin_crew/second_crew = second_kingpin.kingpin_crew var/list/second_goons = second_crew.goons() - var/mob/living/basic/bounty_kingpin_goon/goon = second_goons[1] + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = second_goons[1] SEND_SIGNAL(goon, COMSIG_ATOM_WAS_ATTACKED, bystander, ATTACKER_SHOVING) TEST_ASSERT_EQUAL(second_crew.crew_state, "calm", "A shove started a shootout") SEND_SIGNAL(goon, COMSIG_ATOM_WAS_ATTACKED, bystander, ATTACKER_DAMAGING_ATTACK) TEST_ASSERT_EQUAL(second_crew.crew_state, "drawing", "Hitting a goon didn't start the shootout") TEST_ASSERT(second_crew.is_hunter(bystander), "The one who hit a goon isn't a hunter") -// ===== THE TELEGRAPH ===== +// ===== THE TELEGRAPH, AND REAL SHOTS ===== -/// Nobody in his crew fires during the draw; the first shots come after it, spread over a second, at most two goons on one hunter +/** + * Nobody in his crew fires during the draw; the first shots come after it, spread over half a second, + * at most two goons on one hunter. A shot is a real trigger pull: the round leaves the gun in hand. + * His aim is the infrared line, and a hit spoils it. Nobody is shot through: a bystander in the line + * holds the shot. Nobody shoots a hunter who is down. + */ /datum/unit_test/voidcrew_bounty_kingpin/telegraph /datum/unit_test/voidcrew_bounty_kingpin/telegraph/Run() var/datum/criminal_bounty/kingpin/posting = kingpin_test_posting() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 4) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 4) var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew var/list/goons = crew.goons() TEST_ASSERT_EQUAL(length(goons), 4, "The lounge doesn't have its four goons") var/mob/living/carbon/human/hunter = kingpin_test_person(kingpin_test_spot(2, 2), null) - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in goons) + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in goons) TEST_ASSERT(bounty_kingpin_clear_shot(goon, hunter), "[goon] has no line on the talk spot") TEST_ASSERT(crew.start_shootout(hunter, TRUE), "The shootout didn't start") - // Their guns are the real ones: his .357 holds its cylinder, the goons' pistols the Stechkin's magazine - var/obj/item/ammo_box/magazine/internal/cylinder/cylinder = /obj/item/ammo_box/magazine/internal/cylinder - TEST_ASSERT_EQUAL(kingpin.kingpin_rounds, initial(cylinder.max_ammo), "The kingpin's revolver doesn't hold a .357 cylinder") - var/obj/item/ammo_box/magazine/m9mm_aps/pistol_magazine = /obj/item/ammo_box/magazine/m9mm_aps - TEST_ASSERT_EQUAL(bounty_kingpin_goon_mag("pistol"), initial(pistol_magazine.max_ammo), "A goon's pistol doesn't hold a Stechkin magazine") // BOUNTY_GOON_WEAPON_PISTOL - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in goons) - TEST_ASSERT_EQUAL(goon.goon_rounds, bounty_kingpin_goon_mag(goon.goon_weapon), "[goon] drew with a gun that isn't full") var/draw_ends = crew.crew_draw_ends_at TEST_ASSERT_EQUAL(draw_ends, world.time + 6, "The draw isn't 0.6 seconds") // BOUNTY_KINGPIN_TELEGRAPH + // Their guns are the real ones, loaded: his .357's cylinder, the Stechkin's magazine + var/obj/item/gun/ballistic/revolver/revolver = human_npc_held_gun(kingpin) + TEST_ASSERT(istype(revolver), "The kingpin has no revolver in hand") + TEST_ASSERT_EQUAL(kingpin_test_live_rounds(revolver), 7, "The kingpin's revolver isn't a full .357 cylinder") + var/mob/living/carbon/human/npc/bounty_kingpin_goon/pistol_goon = goons[1] + var/obj/item/gun/ballistic/automatic/pistol/aps/pistol = human_npc_held_gun(pistol_goon) + TEST_ASSERT(istype(pistol), "The pistol goon didn't draw a Stechkin") + TEST_ASSERT_EQUAL(human_npc_live_rounds(pistol.magazine), pistol.magazine.max_ammo, "The pistol goon drew with a gun that isn't full") // During the draw: not a shot, not an aim crew.process(0.2) crew.fight_tick() - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in goons) + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in goons) TEST_ASSERT(!crew.goon_try_attack(goon, hunter), "[goon] fired during the draw") TEST_ASSERT(goon.goon_next_fire_at >= draw_ends, "[goon] may fire before the draw ends") TEST_ASSERT_EQUAL(crew.crew_shots, 0, "The crew fired during the draw") @@ -413,7 +464,7 @@ TEST_ASSERT(kingpin.kingpin_next_aim_at >= draw_ends, "The kingpin may aim before the draw ends") // A goon hit while drawing fumbles: his first shot waits a second past the draw (BOUNTY_KINGPIN_FUMBLE) - var/mob/living/basic/bounty_kingpin_goon/fumbler = goons[1] + var/mob/living/carbon/human/npc/bounty_kingpin_goon/fumbler = goons[2] crew.member_attacked(fumbler, list(hunter)) TEST_ASSERT_EQUAL(fumbler.goon_fumbled_until, draw_ends + 10, "A goon hit while drawing didn't fumble") @@ -422,7 +473,7 @@ crew.process(0.2) TEST_ASSERT_EQUAL(crew.crew_state, "fighting", "The fight didn't start after the draw") // BOUNTY_KINGPIN_FIGHTING var/list/times = list() - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in goons) + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in goons) TEST_ASSERT(goon.goon_next_fire_at >= world.time, "[goon]'s first shot comes before the draw ended") if(goon != fumbler) // BOUNTY_KINGPIN_FIRST_SHOT_SPREAD half a second @@ -437,150 +488,244 @@ TEST_ASSERT(crew.goons_on(hunter, null) <= 2, "[crew.goons_on(hunter, null)] goons drew on one hunter in the opening volley") TEST_ASSERT(crew.goons_on(hunter, null) >= 1, "No goon drew on the hunter") - // Nobody shoots anyone who is down + // Nobody shoots anyone who is down (CB-11: target choice only) TEST_ASSERT(crew.valid_target(hunter), "The crew wouldn't shoot a hunter on their feet") var/mob/living/carbon/human/downed_hunter = kingpin_test_person(kingpin_test_spot(3, 3), null) crew.add_hunter(downed_hunter) - downed_hunter.set_stat(SOFT_CRIT) - TEST_ASSERT(!crew.valid_target(downed_hunter), "The crew would shoot a hunter who is down") - -// ===== OUTPOST SECURITY ===== - -/** - * During the shootout a hunter's stray shot, just after firing at his crew, takes no outpost strike: - * three of them leave the turret holding fire, where three strikes mark anyone else. Hits away from - * the fight still count, PvP still counts, and strikes count again after it (L1, L11). - */ -/datum/unit_test/voidcrew_bounty_kingpin/security - -/datum/unit_test/voidcrew_bounty_kingpin/security/Run() - var/obj/structure/overmap/trader_outpost/outpost = allocate(/obj/structure/overmap/trader_outpost) - outpost.outpost_template = allocate(/datum/map_template/trader_outpost) - outpost.outpost_template.width = 5 - outpost.outpost_template.height = 5 - outpost.template_bottom_left = run_loc_floor_bottom_left - var/obj/machinery/porta_turret/outpost/turret = allocate(/obj/machinery/porta_turret/outpost, kingpin_test_spot(4, 4)) - turret.outpost = outpost - + TEST_ASSERT(kingpin_test_down(downed_hunter), "The test hunter didn't go into crit") + TEST_ASSERT(!crew.valid_target(downed_hunter), "The crew would shoot a hunter in crit") + TEST_ASSERT(!(downed_hunter in crew.live_hunters()), "A hunter in crit is among those the crew picks from") + + // Nobody is shot through: a bystander between a goon and his hunter holds his shot + var/mob/living/carbon/human/npc/bounty_kingpin_goon/shotgun_goon = goons[3] + var/mob/living/carbon/human/close_hunter = kingpin_test_person(kingpin_test_spot(2, 2), null) + TEST_ASSERT(!crew.line_blocked(shotgun_goon, close_hunter), "The line from the shotgun goon to the talk spot is blocked in an empty room") + var/mob/living/carbon/human/bystander = kingpin_test_person(kingpin_test_spot(1, 2), null) + TEST_ASSERT(crew.line_blocked(shotgun_goon, close_hunter), "A bystander in the line doesn't hold the shot") + TEST_ASSERT(crew.line_blocked(kingpin, close_hunter) == FALSE, "The kingpin's line over his kicked table is blocked") + qdel(bystander) + qdel(close_hunter) + + // A goon's shot is a real trigger pull: a shell leaves his shotgun (point blank, a single shot) + var/obj/item/gun/ballistic/shotgun = human_npc_held_gun(shotgun_goon) + TEST_ASSERT(istype(shotgun, /obj/item/gun/ballistic/shotgun/automatic/combat), "The shotgun goon didn't draw a combat shotgun") + var/mob/living/carbon/human/target = kingpin_test_person(kingpin_test_spot(1, 3), null) + crew.add_hunter(target) + var/shells_before = kingpin_test_live_rounds(shotgun) + var/pulls_before = crew.crew_shots + shotgun_goon.goon_cancel_windup() + shotgun_goon.next_click = 0 + shotgun_goon.next_move = 0 + crew.goon_finish_windup(WEAKREF(shotgun_goon), WEAKREF(target)) + TEST_ASSERT_EQUAL(crew.crew_shots, pulls_before + 1, "The shotgun goon didn't pull his trigger") + TEST_ASSERT(kingpin_test_live_rounds(shotgun) < shells_before, "No shell left the shotgun goon's gun") + + // His aim: the line, and a hit spoils it + kingpin.kingpin_next_aim_at = 0 + TEST_ASSERT(kingpin.kingpin_start_aim(hunter), "He didn't aim") + TEST_ASSERT(kingpin.kingpin_aim_timer && kingpin.kingpin_aim_beam, "His aim has no line") + crew.member_attacked(kingpin, list(hunter)) + TEST_ASSERT_NULL(kingpin.kingpin_aim_timer, "A hit didn't spoil his aim") + // Aimed again, he pulls the trigger: a round leaves his revolver + TEST_ASSERT(kingpin.kingpin_start_aim(hunter), "He didn't aim again") + var/rounds_before = kingpin_test_live_rounds(revolver) + kingpin.next_click = 0 + kingpin.next_move = 0 + TEST_ASSERT(kingpin.kingpin_fire(), "He didn't pull the trigger") + TEST_ASSERT(kingpin_test_live_rounds(revolver) < rounds_before, "No round left his revolver") + +// ===== HIS RELOAD ===== + +/// His revolver is reloaded the player's way: a speedloader from his holster or pocket into the cylinder, the empty dropped. A goon's shotgun is fed shell by shell from his bandolier and racked. +/datum/unit_test/voidcrew_bounty_kingpin/reload + +/datum/unit_test/voidcrew_bounty_kingpin/reload/Run() var/datum/criminal_bounty/kingpin/posting = kingpin_test_posting() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 2) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 3) var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew - var/list/goons = crew.goons() - var/mob/living/basic/bounty_kingpin_goon/goon = goons[1] + var/obj/item/gun/ballistic/revolver/revolver = bounty_kingpin_draw_gun(kingpin) + TEST_ASSERT(istype(revolver), "The kingpin couldn't draw his revolver") + revolver.can_misfire = FALSE + var/list/loaders = list() + for(var/obj/item/ammo_box/a357/loader in kingpin.get_all_contents()) + loaders += loader + TEST_ASSERT_EQUAL(length(loaders), 3, "The kingpin doesn't carry three speedloaders") // two in the holster, one in a pocket + // Fired dry: every round in the cylinder spent + var/obj/item/ammo_box/magazine/cylinder = revolver.magazine + for(var/i in 1 to length(cylinder.stored_ammo)) + var/obj/item/ammo_casing/casing = cylinder.stored_ammo[i] + if(ispath(casing)) + casing = new casing(cylinder) + cylinder.stored_ammo[i] = casing + if(casing) + QDEL_NULL(casing.loaded_projectile) + TEST_ASSERT(!revolver.can_shoot(), "Test fixture: the revolver can still fire") + TEST_ASSERT(human_npc_can_reload(kingpin, revolver), "The kingpin can't find a speedloader for his revolver") + TEST_ASSERT(kingpin_test_run_reload(kingpin, /datum/ai_behavior/human_npc_reload/bounty_kingpin_crew), "The kingpin's reload never finished") + TEST_ASSERT(revolver.can_shoot(), "The reload left his revolver unable to fire") + TEST_ASSERT_EQUAL(kingpin_test_live_rounds(revolver), 7, "The reload didn't fill the cylinder") + var/live_loaders = 0 + for(var/obj/item/ammo_box/a357/loader in kingpin.get_all_contents()) + if(human_npc_live_rounds(loader)) + live_loaders++ + TEST_ASSERT_EQUAL(live_loaders, 2, "The reload didn't use up one speedloader") + TEST_ASSERT(istype(kingpin.buckled, /obj/structure/chair/sofa), "He left his sofa to reload") + + // The shotgun goon: shell by shell from the bandolier, then racked + var/mob/living/carbon/human/npc/bounty_kingpin_goon/shotgun_goon + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in crew.goons()) + if(goon.goon_weapon == "shotgun") // BOUNTY_GOON_WEAPON_SHOTGUN + shotgun_goon = goon + TEST_ASSERT_NOTNULL(shotgun_goon, "The lounge has no shotgun goon") + var/obj/item/gun/ballistic/shotgun = bounty_kingpin_draw_gun(shotgun_goon) + TEST_ASSERT(istype(shotgun), "The shotgun goon couldn't draw his shotgun") + var/obj/item/ammo_box/magazine/tube = shotgun.magazine + TEST_ASSERT(istype(tube.stored_ammo[1], /obj/item/ammo_casing/shotgun/buckshot) || ispath(tube.stored_ammo[1], /obj/item/ammo_casing/shotgun/buckshot), "The goons' shotgun isn't loaded with buckshot") + var/obj/item/ammo_casing/round = tube.get_round() + while(round) + qdel(round) + round = tube.get_round() + QDEL_NULL(shotgun.chambered) + TEST_ASSERT(!shotgun.can_shoot(), "Test fixture: the shotgun can still fire") + TEST_ASSERT(kingpin_test_run_reload(shotgun_goon, /datum/ai_behavior/human_npc_reload/bounty_kingpin_crew), "The shotgun goon's reload never finished") + TEST_ASSERT(shotgun.can_shoot(), "The reload left the shotgun unable to fire") + TEST_ASSERT(kingpin_test_live_rounds(shotgun) > 1, "The shotgun was fed only one shell") + +// ===== GIVING UP (CB-14) ===== + +/// He gives up only once his crew is down and he is badly hurt, with a hunter in sight: the revolver holstered, tg's *surrender, then tg's cuffs on his sofa. A reach for his wrists while he can still move gets a grudge, not a step away. +/datum/unit_test/voidcrew_bounty_kingpin/surrender + +/datum/unit_test/voidcrew_bounty_kingpin/surrender/Run() + var/datum/criminal_bounty/kingpin/posting = kingpin_test_posting() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 1) + var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew + var/turf/seat = get_turf(kingpin) var/mob/living/carbon/human/hunter = kingpin_test_person(kingpin_test_spot(2, 2), null) - var/mob/living/carbon/human/idle_hunter = kingpin_test_person(kingpin_test_spot(1, 3), null) - var/mob/living/carbon/human/brawler = kingpin_test_person(kingpin_test_spot(1, 2), null) - var/mob/living/carbon/human/victim = kingpin_test_person(kingpin_test_spot(3, 2), null) - var/mob/living/carbon/human/bystander = kingpin_test_person(kingpin_test_spot(3, 3), null) - TEST_ASSERT_EQUAL(get_trader_outpost_for_turf(crew.crew_seat), outpost, "The test lounge isn't at the test outpost") - - crew.start_shootout(hunter, TRUE) - crew.add_hunter(idle_hunter) - crew.add_hunter(brawler) - TEST_ASSERT(crew.is_fighting(), "The shootout didn't start") - // The hunter and the brawler have just shot at a goon - crew.member_attacked(goon, list(hunter, brawler)) - TEST_ASSERT(crew.engaged(hunter), "A hunter who just shot a goon isn't counted in the fight") - TEST_ASSERT(!crew.engaged(idle_hunter), "A hunter who fired at nobody is counted in the fight") - - // Three stray hits into outpost property: no strike, and the turret holds fire (three would mark them) - for(var/i in 1 to 3) - outpost.aggressor_strike_times -= hunter.mind - outpost.register_aggression(hunter) - TEST_ASSERT_NULL(outpost.aggressor_strikes[hunter.mind], "A hunter's stray shot during the shootout got a property strike") - TEST_ASSERT(!outpost.is_marked_aggressor(hunter.mind), "A hunter was marked for stray shots during the shootout") - TEST_ASSERT(!turret.valid_target(hunter), "The turret turned on a hunter during the shootout") - // The same three hits from someone not in the fight mark them, and the turret fires - for(var/i in 1 to 3) - outpost.aggressor_strike_times -= bystander.mind - outpost.register_aggression(bystander) - TEST_ASSERT(outpost.is_marked_aggressor(bystander.mind), "Three strikes didn't mark a bystander during the shootout") - TEST_ASSERT(turret.valid_target(bystander), "The turret held fire on a marked bystander") - // A hunter who hasn't been shooting at his crew gets their strike - outpost.register_aggression(idle_hunter) - TEST_ASSERT_EQUAL(outpost.aggressor_strikes[idle_hunter.mind], 1, "A hunter not firing at his crew was excused a strike") - // PvP enforcement stays: a hunter who hits a person gets the strike - outpost.register_pvp_aggression(victim, brawler) - TEST_ASSERT_EQUAL(outpost.aggressor_strikes[brawler.mind], 1, "A hunter's PvP hit didn't count during the shootout") - // The turret leaves his crew alone: the goons share its faction, P2 exempts the kingpin - TEST_ASSERT(turret.in_faction(goon), "The goons don't share the turrets' faction") - TEST_ASSERT(!turret.valid_target(goon), "The turret would shoot a goon") - TEST_ASSERT(bounty_turret_ignores(kingpin, TRUE), "Trader-outpost turrets don't leave the kingpin alone") - - // After it, a hunter's property hit counts again - crew.stand_down() - TEST_ASSERT(!crew.is_fighting(), "The crew didn't stand down") - outpost.aggressor_strike_times -= hunter.mind - outpost.register_aggression(hunter) - TEST_ASSERT_EQUAL(outpost.aggressor_strikes[hunter.mind], 1, "A hunter's property strike didn't count outside the shootout") + // Reached for while he can move: he holds it against them, and stays on his sofa + SEND_SIGNAL(kingpin, COMSIG_CARBON_CUFF_ATTEMPTED, hunter) + TEST_ASSERT(kingpin.body_has_grudge(hunter), "A reach for his wrists didn't put them on his grudge list") + TEST_ASSERT_EQUAL(get_turf(kingpin), seat, "A reach for his wrists moved him off his seat") + TEST_ASSERT(istype(kingpin.buckled, /obj/structure/chair/sofa), "A reach for his wrists got him off his sofa") + + var/datum/human_npc_surrender/rules = kingpin.npc_surrender_rules() + TEST_ASSERT(istype(rules, /datum/human_npc_surrender/bounty_kingpin), "The kingpin has no surrender rules of his own") + // Through real damage: down to 35 of a person's 100 (BOUNTY_KINGPIN_SURRENDER_BELOW 40) + bounty_test_hurt_to(kingpin, 35) + TEST_ASSERT(kingpin.health <= kingpin.maxHealth * 0.4 && !kingpin.is_downed(), "The test kingpin isn't hurt below 40% and still up ([kingpin.health])") + TEST_ASSERT(!rules.hurt_enough(kingpin), "He'd give up with a goon still standing") + var/list/goons = crew.goons() + var/mob/living/carbon/human/npc/bounty_kingpin_goon/last_goon = goons[1] + last_goon.death() + TEST_ASSERT(crew.crew_down(), "His crew isn't down with every goon dead") + TEST_ASSERT(rules.hurt_enough(kingpin), "He wouldn't think of giving up, hurt below 40% with his crew down") + // Who he gives up to: the hunters in sight; the 60% / 25% rolls (BOUNTY_KINGPIN_SURRENDER_FIRST, _LATER) + crew.start_shootout(hunter, FALSE) + var/list/hostiles = rules.hostiles_near(kingpin) + TEST_ASSERT(hunter in hostiles, "He doesn't see the hunter at the table") + TEST_ASSERT(rules.should_consider(kingpin, hostiles, list()), "He wouldn't consider giving up to the hunter") + TEST_ASSERT_EQUAL(rules.odds(kingpin, hostiles, list(), TRUE), 60, "His first roll isn't 60%") + TEST_ASSERT_EQUAL(rules.odds(kingpin, hostiles, list(), FALSE), 25, "His later rolls aren't 25%") + TEST_ASSERT(!rules.flees, "He would run from his sofa after giving up") + + // He gives up: revolver holstered, hands up, tg's *surrender (a real paralysis) + TEST_ASSERT(istype(human_npc_held_gun(kingpin), /obj/item/gun/ballistic/revolver), "He didn't draw his revolver for the fight") + TEST_ASSERT(kingpin.npc_surrender(), "He didn't give up") + TEST_ASSERT(kingpin.IsParalyzed(), "Giving up isn't tg's surrender") + TEST_ASSERT_NULL(human_npc_held_gun(kingpin), "He gave up with his revolver in hand") + TEST_ASSERT(locate(/obj/item/gun/ballistic/revolver) in kingpin.get_all_contents(), "His revolver left his body when he gave up") + TEST_ASSERT_EQUAL(kingpin.capture_state(), "stunned", "Given up, he doesn't read stunned") // BOUNTY_STATE_STUNNED + TEST_ASSERT(!kingpin.kingpin_able(), "Given up, he can still shoot") + TEST_ASSERT(!kingpin.kingpin_start_aim(hunter), "Given up, he took aim") + + // Lying there, he can't answer a reach for his wrists, and tg's cuffs go on, on his sofa + SEND_SIGNAL(kingpin, COMSIG_CARBON_CUFF_ATTEMPTED, hunter) + TEST_ASSERT(kingpin_test_cuff(kingpin), "The cuffs wouldn't go on a kingpin who gave up") + TEST_ASSERT_EQUAL(kingpin.capture_state(), "restrained", "Cuffed, he doesn't read restrained") // BOUNTY_STATE_RESTRAINED + TEST_ASSERT(istype(kingpin.buckled, /obj/structure/chair/sofa), "Cuffed, he came off his sofa") // ===== THE GOONS ===== -/// Goons drop no guns, their bodies fade, and half of those left run once he falls +/// Goons are real people in vests with real guns and spares carried, not held; their gear stays on them; their bodies stay for the corpse sweep; half of those left walk out once he falls, for real /datum/unit_test/voidcrew_bounty_kingpin/goons /datum/unit_test/voidcrew_bounty_kingpin/goons/Run() var/datum/criminal_bounty/kingpin/posting = kingpin_test_posting() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 4) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 4) var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew var/list/goons = crew.goons() TEST_ASSERT_EQUAL(length(goons), 4, "The lounge doesn't have its four goons") - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in goons) - TEST_ASSERT(goon.health == 150 && goon.maxHealth == 150, "[goon] doesn't have 150 health") // BOUNTY_GOON_HEALTH + var/list/guns = list( + "pistol" = /obj/item/gun/ballistic/automatic/pistol/aps, + "smg" = /obj/item/gun/ballistic/automatic/mini_uzi, + "shotgun" = /obj/item/gun/ballistic/shotgun/automatic/combat, + ) + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in goons) + TEST_ASSERT(goon.health == goon.maxHealth && goon.maxHealth == 100, "[goon] isn't a person's health") // no health pools TEST_ASSERT(FACTION_TURRET in goon.faction, "[goon] isn't left alone by the turrets") - TEST_ASSERT(!length(goon.contents), "[goon] carries something") - - // A dead goon drops nothing, and fades after a minute - var/mob/living/basic/bounty_kingpin_goon/dead_goon = goons[4] + TEST_ASSERT(istype(goon.wear_suit, /obj/item/clothing/suit/armor/vest), "[goon] wears no armour vest") + TEST_ASSERT_NULL(human_npc_held_gun(goon), "[goon] holds a gun at ease") + var/obj/item/gun/carried = bounty_kingpin_carried_gun(goon) + TEST_ASSERT(istype(carried, guns[goon.goon_weapon]), "[goon] doesn't carry a [goon.goon_weapon]") + TEST_ASSERT(carried.can_shoot(), "[goon]'s [carried] isn't loaded") + TEST_ASSERT(human_npc_find_ammo(goon, carried), "[goon] carries no spare ammunition for [carried]") + + // A dead goon drops nothing of his kit, and his body stays for the corpse sweep + var/mob/living/carbon/human/npc/bounty_kingpin_goon/dead_goon = goons[4] var/turf/body_turf = get_turf(dead_goon) dead_goon.death() TEST_ASSERT(!(locate(/obj/item/gun) in body_turf), "A goon dropped a gun") - TEST_ASSERT(!length(dead_goon.contents), "A dead goon holds something") - TEST_ASSERT(dead_goon.goon_fade_timer, "A dead goon's body won't fade") - var/fade_in = timeleft(dead_goon.goon_fade_timer) - TEST_ASSERT(fade_in > 590 && fade_in <= 600, "A goon's body fades in [fade_in] deciseconds, not a minute") // BOUNTY_GOON_FADE - dead_goon.goon_fade_out() - var/deadline = world.time + 5 SECONDS - UNTIL(QDELETED(dead_goon) || world.time > deadline) - TEST_ASSERT(QDELETED(dead_goon), "A goon's body didn't fade away") - - // He falls mid-fight: half the goons left run (BOUNTY_GOON_FLEE_ON_BOSS 50), the most hurt first + TEST_ASSERT(bounty_kingpin_carried_gun(dead_goon), "A dead goon's gun left his body") + TEST_ASSERT(!QDELETED(dead_goon), "A dead goon's body went at once") + TEST_ASSERT(dead_goon.npc_corpse_lifetime > 0, "A dead goon's body is left out of the corpse sweep") + + // He falls mid-fight: half the goons left run (BOUNTY_GOON_FLEE_ON_BOSS 50), the most hurt first, walking out var/mob/living/carbon/human/hunter = kingpin_test_person(kingpin_test_spot(2, 2), null) crew.start_shootout(hunter, TRUE) - var/mob/living/basic/bounty_kingpin_goon/hurt_goon = goons[2] + var/mob/living/carbon/human/npc/bounty_kingpin_goon/hurt_goon = goons[2] hurt_goon.adjustBruteLoss(40) TEST_ASSERT_EQUAL(length(crew.standing_goons()), 3, "Three goons aren't left standing") - kingpin.body_go_down() + TEST_ASSERT(kingpin_test_down(kingpin), "The kingpin didn't go into crit") var/fled = 0 - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in goons - dead_goon) + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in goons - dead_goon) if(goon.goon_fleeing) fled++ TEST_ASSERT_EQUAL(fled, 1, "[fled] of three goons ran when he fell, not one") // floor(3 * 50 / 100) TEST_ASSERT(hurt_goon.goon_fleeing, "The most hurt goon didn't run first") + TEST_ASSERT_NOTNULL(hurt_goon.npc_exit, "The running goon isn't walking out") + TEST_ASSERT(hurt_goon in SShuman_npcs.leavers, "The running goon isn't among the NPCs walking out") + TEST_ASSERT(!HAS_TRAIT(hurt_goon, TRAIT_GODMODE), "The running goon can't be hurt") + TEST_ASSERT(!hurt_goon.goon_able(), "The running goon still fights") TEST_ASSERT(!crew.crew_down(), "The crew is down with goons still standing") - // He surrenders only once his crew is down - kingpin_test_clear_lounge() - var/datum/criminal_bounty/kingpin/second_posting = kingpin_test_posting() - var/mob/living/basic/bounty_criminal/kingpin/boss = kingpin_test_lounge(second_posting, 1) - var/list/boss_goons = boss.kingpin_crew.goons() - var/mob/living/basic/bounty_kingpin_goon/last_goon = boss_goons[1] - // Through adjustBruteLoss(), as a hit would: setBruteLoss() from full health never updates `health` - boss.adjustBruteLoss(boss.maxHealth * 0.65) - TEST_ASSERT(boss.health <= boss.maxHealth * 0.4 && !boss.downed, "The test kingpin isn't hurt below 40% and still up ([boss.health])") - for(var/i in 1 to 20) - boss.kingpin_next_surrender_roll = 0 - boss.kingpin_consider_surrender(boss.maxHealth) - TEST_ASSERT(!HAS_TRAIT(boss, "bounty_surrendered"), "He surrendered with a goon still standing") // TRAIT_BOUNTY_SURRENDERED - last_goon.death() - TEST_ASSERT(boss.kingpin_crew.crew_down(), "His crew isn't down with every goon dead") - for(var/i in 1 to 40) - if(HAS_TRAIT(boss, "bounty_surrendered")) // TRAIT_BOUNTY_SURRENDERED - break - boss.kingpin_next_surrender_roll = 0 - boss.kingpin_consider_surrender(boss.maxHealth) - TEST_ASSERT(HAS_TRAIT(boss, "bounty_surrendered"), "He never surrendered with his crew down and hurt below 40%") // TRAIT_BOUNTY_SURRENDERED +// ===== CB-22: GRABS ===== + +/// Anyone may drag a goon; he resists any hold by someone outside the crew, and a body can be dragged anywhere +/datum/unit_test/voidcrew_bounty_kingpin/grabs + +/datum/unit_test/voidcrew_bounty_kingpin/grabs/Run() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(null, 2) + var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew + var/list/goons = crew.goons() + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = goons[2] + var/mob/living/carbon/human/grabber = kingpin_test_person(get_step(goon, WEST), null) + grabber.start_pulling(goon) + TEST_ASSERT_EQUAL(goon.pulledby, grabber, "A living goon can't be pulled") + // His AI answers: it resists the hold + var/datum/ai_planning_subtree/bounty_kingpin_goon_grabbed/subtree = allocate(/datum/ai_planning_subtree/bounty_kingpin_goon_grabbed) + TEST_ASSERT_EQUAL(subtree.SelectBehaviors(goon.ai_controller, 1), SUBTREE_RETURN_FINISH_PLANNING, "A held goon's AI doesn't plan to break free") + TEST_ASSERT(goon.ai_controller.current_behaviors[GET_AI_BEHAVIOR(/datum/ai_behavior/resist)], "A held goon's AI doesn't resist") + // And the resist is tg's: a pull breaks + goon.next_move = 0 + goon.execute_resist() + TEST_ASSERT_NULL(goon.pulledby, "Resisting didn't break a pull") + // A body can be dragged anywhere + var/mob/living/carbon/human/npc/bounty_kingpin_goon/dead_goon = goons[1] + dead_goon.death() + var/mob/living/carbon/human/dragger = kingpin_test_person(get_step(dead_goon, NORTH) || get_turf(dead_goon), null) + dragger.start_pulling(dead_goon) + TEST_ASSERT_EQUAL(dead_goon.pulledby, dragger, "A dead goon can't be dragged") // ===== THE CLOCK AND THE CADENCE ===== @@ -602,7 +747,7 @@ var/datum/criminal_bounty/kingpin/posting = kingpin_test_posting() TEST_ASSERT_EQUAL(bounty_kingpin_open_posting(), posting, "The open kingpin posting isn't found") TEST_ASSERT(istext(SSbounty_kingpin.kingpin_post_refusal(90 MINUTES, 8)), "A second kingpin posting could go up while one is open") - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 1) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 1) SSbounty_kingpin.kingpin_track(kingpin) TEST_ASSERT_NULL(SSbounty_kingpin.kingpin_post(), "A second kingpin posting went up") // BOUNTY_KINGPIN_EXPIRY 60 minutes @@ -639,13 +784,13 @@ /datum/unit_test/voidcrew_bounty_kingpin/adopt /datum/unit_test/voidcrew_bounty_kingpin/adopt/Run() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(null, 2) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(null, 2) var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew SSbounty_kingpin.kingpin_track(kingpin) TEST_ASSERT_NULL(kingpin.posting(), "The kingpin sat down on a posting") TEST_ASSERT_NULL(bounty_kingpin_open_posting(), "A kingpin posting is up before he was posted") var/list/goons = crew.goons() - var/mob/living/basic/bounty_kingpin_goon/dead_goon = goons[1] + var/mob/living/carbon/human/npc/bounty_kingpin_goon/dead_goon = goons[1] var/turf/dead_post = dead_goon.goon_post dead_goon.death() @@ -657,8 +802,8 @@ TEST_ASSERT_EQUAL(length(GLOB.bounty_kingpin_crews), 1, "Posting him put a second kingpin in the world") TEST_ASSERT(!posting.board_arm(), "His posting tried to spawn someone") // The dead goon's post has a new goon - var/mob/living/basic/bounty_kingpin_goon/new_goon - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in crew.standing_goons()) + var/mob/living/carbon/human/npc/bounty_kingpin_goon/new_goon + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in crew.standing_goons()) if(goon.goon_post == dead_post) new_goon = goon TEST_ASSERT_NOTNULL(new_goon, "His dead goon's post wasn't filled when he went on the board") @@ -671,16 +816,15 @@ /datum/unit_test/voidcrew_bounty_kingpin/expired /datum/unit_test/voidcrew_bounty_kingpin/expired/Run() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(null, 1) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(null, 1) var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew SSbounty_kingpin.kingpin_track(kingpin) var/datum/criminal_bounty/kingpin/posting = SSbounty_kingpin.kingpin_post() TEST_ASSERT_NOTNULL(posting, "The seated kingpin couldn't be posted") - // Downed and cuffed by his sofa as the clock runs out + // In crit and cuffed by his sofa as the clock runs out kingpin.buckled?.unbuckle_mob(kingpin, force = TRUE) - kingpin.body_go_down() - var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs, get_turf(kingpin)) - TEST_ASSERT(kingpin.body_apply_cuffs(cuffs), "The kingpin couldn't be cuffed") + TEST_ASSERT(kingpin_test_down(kingpin), "The kingpin didn't go into crit") + TEST_ASSERT(kingpin_test_cuff(kingpin), "The kingpin couldn't be cuffed") TEST_ASSERT_EQUAL(crew.crew_state, "calm", "Cuffing him with nobody about started a shootout") // BOUNTY_KINGPIN_CALM posting.close("expired") // BOUNTY_CLOSE_EXPIRED @@ -688,7 +832,7 @@ TEST_ASSERT(!QDELETED(kingpin) && kingpin.stat != DEAD, "The kingpin went with his expired posting") TEST_ASSERT_NULL(kingpin.posting(), "The kingpin is still on the closed posting") TEST_ASSERT_EQUAL(kingpin.kingpin_crew, crew, "His crew went with the posting") - TEST_ASSERT(!QDELETED(crew) && length(crew.standing_goons()) == 1, "His goon left with the posting") + TEST_ASSERT(!QDELETED(crew) && length(crew.present_goons()) == 1, "His goon left with the posting") TEST_ASSERT(!kingpin.is_restrained(), "His people left him cuffed") TEST_ASSERT(!SSbounty_kingpin.kingpin_gone, "An expired posting counted him gone for the round") TEST_ASSERT_EQUAL(SSbounty_kingpin.kingpin(), kingpin, "The round lost track of its kingpin") @@ -699,11 +843,16 @@ TEST_ASSERT_EQUAL(next.criminal(), kingpin, "The next posting didn't adopt him again") TEST_ASSERT_EQUAL(next.record.status, "wanted", "His record isn't wanted again") // BOUNTY_RECORD_WANTED -/// Killed before he is on the board, he is gone for the round with nothing to claim: no posting goes up, his body fades, and nothing seats or posts him again, the admin panel included +/** + * Killed before he is on the board, he is gone for the round with nothing to claim: no posting goes + * up, his body is an ordinary corpse the corpse sweep may take once nobody is near, and nothing seats + * or posts him again, the admin panel included. Killed on an open posting, the sweep leaves his body + * for the pad. + */ /datum/unit_test/voidcrew_bounty_kingpin/death /datum/unit_test/voidcrew_bounty_kingpin/death/Run() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(null, 1) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(null, 1) SSbounty_kingpin.kingpin_track(kingpin) TEST_ASSERT_NULL(bounty_kingpin_open_posting(), "A kingpin posting is up before he died") kingpin.death() @@ -721,63 +870,60 @@ TEST_ASSERT_NULL(panel.admin_run_post_action(operator, action), "The panel posted a kingpin who is gone for the round") TEST_ASSERT(findtext(panel.error, "gone"), "The panel's refusal doesn't say he's gone: [panel.error]") - // Nothing to claim: the body fades, as a goon's does (BOUNTY_GOON_FADE a minute) - TEST_ASSERT(kingpin.kingpin_fade_timer, "His unclaimable body won't fade") - var/fade_in = timeleft(kingpin.kingpin_fade_timer) - TEST_ASSERT(fade_in > 590 && fade_in <= 600, "His body fades in [fade_in] deciseconds, not a minute") - kingpin.kingpin_fade_out() - var/deadline = world.time + 5 SECONDS - UNTIL(QDELETED(kingpin) || world.time > deadline) - TEST_ASSERT(QDELETED(kingpin), "His unclaimable body didn't fade away") + // Nothing to claim: an ordinary corpse, for the corpse sweep once its time is up and nobody is near + TEST_ASSERT(kingpin.npc_corpse_lifetime > 0, "His unclaimable body is left out of the corpse sweep") + TEST_ASSERT(!kingpin.npc_corpse_expired(), "His body would go the moment he died") + kingpin.npc_died_at = world.time - kingpin.npc_corpse_lifetime - 1 + TEST_ASSERT(kingpin.npc_corpse_expired(), "His unclaimable body would never be cleaned up") -/// Killed in their seats, he and his goons fall out of them and lie flat. A body taken out of a chair lies flat, and so does him downed on his sofa once he's taken off it. + // Killed on an open posting: his body is the proof, and the sweep leaves it for the pad + SSbounty_kingpin.kingpin_reset() + kingpin_test_clear_lounge() + var/datum/criminal_bounty/kingpin/posting = kingpin_test_posting() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/wanted = kingpin_test_lounge(posting, 0) + wanted.death() + TEST_ASSERT_EQUAL(wanted.capture_state(), "dead", "His body doesn't read dead") // BOUNTY_STATE_DEAD + wanted.npc_died_at = world.time - wanted.npc_corpse_lifetime - 1 + TEST_ASSERT(!wanted.npc_corpse_expired(), "The corpse sweep would take the body an open posting pays for") + +/// Killed in their seats, he and his goons fall out of them and lie down. In crit on his sofa he stays in it; taken off it, he lies down. /datum/unit_test/voidcrew_bounty_kingpin/seated_bodies /datum/unit_test/voidcrew_bounty_kingpin/seated_bodies/Run() // A chair at the first goon post (4,0), so his goon sits in it var/obj/structure/chair/chair = allocate(/obj/structure/chair, kingpin_test_spot(4, 0)) - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(null, 1) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(null, 1) TEST_ASSERT(istype(kingpin.buckled, /obj/structure/chair/sofa), "The kingpin isn't sitting on the sofa") var/list/goons = kingpin.kingpin_crew.goons() - var/mob/living/basic/bounty_kingpin_goon/goon = goons[1] + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = goons[1] TEST_ASSERT_EQUAL(goon.buckled, chair, "The goon didn't sit in the chair at his post") - // Killed in his chair, a goon falls out of it and lies flat + // Killed in his chair, a goon falls out of it and lies down goon.death() TEST_ASSERT_NULL(goon.buckled, "The dead goon is still sitting in his chair") TEST_ASSERT_EQUAL(goon.body_position, LYING_DOWN, "The dead goon isn't lying down") - TEST_ASSERT(goon.lying_angle, "The dead goon is lying down but drawn standing up") - - // Sat back in the chair, the body sits up; taken out of it again, it lies flat - TEST_ASSERT(chair.buckle_mob(goon, force = TRUE), "The dead goon couldn't be sat back in the chair") - TEST_ASSERT_EQUAL(goon.body_position, STANDING_UP, "The chair didn't sit the dead goon up") - chair.unbuckle_mob(goon, force = TRUE) - TEST_ASSERT_EQUAL(goon.body_position, LYING_DOWN, "The dead goon taken out of the chair isn't lying down") - TEST_ASSERT(goon.lying_angle, "The dead goon taken out of the chair is drawn standing up") - // Killed on his sofa, he falls off it and lies flat + // Killed on his sofa, he falls off it and lies down kingpin.death() TEST_ASSERT_NULL(kingpin.buckled, "The dead kingpin is still sitting on his sofa") TEST_ASSERT_EQUAL(kingpin.body_position, LYING_DOWN, "The dead kingpin isn't lying down") - TEST_ASSERT(kingpin.lying_angle, "The dead kingpin is lying down but drawn standing up") - // Downed on his sofa he stays in it; taken off it, he lies flat + // In crit on his sofa he stays in it; taken off it, he lies down SSbounty_kingpin.kingpin_reset() kingpin_test_clear_lounge() - var/mob/living/basic/bounty_criminal/kingpin/downed = kingpin_test_lounge(null, 0) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/downed = kingpin_test_lounge(null, 0) var/obj/structure/chair/sofa = downed.buckled TEST_ASSERT(istype(sofa, /obj/structure/chair/sofa), "The second kingpin isn't sitting on the sofa") - downed.body_go_down() - TEST_ASSERT_EQUAL(downed.buckled, sofa, "Downed, the kingpin came off his sofa") + TEST_ASSERT(kingpin_test_down(downed), "The second kingpin didn't go into crit") + TEST_ASSERT_EQUAL(downed.buckled, sofa, "In crit, the kingpin came off his sofa") sofa.unbuckle_mob(downed, force = TRUE) - TEST_ASSERT_EQUAL(downed.body_position, LYING_DOWN, "The downed kingpin taken off his sofa isn't lying down") - TEST_ASSERT(downed.lying_angle, "The downed kingpin taken off his sofa is drawn standing up") + TEST_ASSERT_EQUAL(downed.body_position, LYING_DOWN, "The kingpin in crit taken off his sofa isn't lying down") /// A shootout puts nobody on the board; when his posting goes up it adopts him wherever he is, so a crew that grabbed him early can bring him in; withdrawn while he's held away, it takes him, and he's gone /datum/unit_test/voidcrew_bounty_kingpin/grabbed /datum/unit_test/voidcrew_bounty_kingpin/grabbed/Run() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(null, 1) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(null, 1) var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew SSbounty_kingpin.kingpin_track(kingpin) var/mob/living/carbon/human/hunter = kingpin_test_person(kingpin_test_spot(2, 2), null) @@ -789,9 +935,9 @@ crew.stand_down() crew.crew_hunters.Cut() - // Grabbed early: downed and shut in a locker, away from his lounge, and still nothing on the board + // Grabbed early: in crit and shut in a locker, away from his lounge, and still nothing on the board kingpin.buckled?.unbuckle_mob(kingpin, force = TRUE) - kingpin.body_go_down() + TEST_ASSERT(kingpin_test_down(kingpin), "The kingpin didn't go into crit") var/obj/structure/closet/locker = allocate(/obj/structure/closet, kingpin_test_spot(4, 4)) kingpin.forceMove(locker) crew.process(0.2) @@ -820,7 +966,7 @@ TEST_ASSERT_EQUAL(initial(run.weight), 0, "Drug runs roll at random") TEST_ASSERT_EQUAL(initial(run.mission_limit), 1, "More than one drug run can run at once") // His jobs are posted with the black market's shop, so Vex's counter takes the product - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(null, 0) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(null, 0) var/datum/outpost_shop/shop = kingpin.kingpin_crew.crew_shop() TEST_ASSERT(istype(shop, /datum/outpost_shop/black_market), "His jobs aren't posted with the black market's shop") @@ -830,8 +976,9 @@ * The black market's lounge: the seat on the corp sofa, no table of his own in front of it (he lost * his coffee table, and no lounge table stands at any of his six goon posts either), six goon posts * and the refuge. SSbounty_kingpin seats him and his crew there on no posting, as it does at the start - * of the round: the barkeep is the bar's own, the crew's way out is the refuge, never the hangar lift - * (M3, M4, M5), and his posting is at that outpost. + * of the round, his goons arriving through the human NPC spawn queue: the barkeep is the bar's own, + * the crew's way out is the refuge, never the hangar lift (M3, M4, M5), and his posting is at that + * outpost. */ /datum/unit_test/voidcrew_bounty_kingpin/map @@ -867,7 +1014,7 @@ TEST_ASSERT_EQUAL(weapons["smg"], 1, "The lounge doesn't have one SMG post") // The round seats him: his own record, on no posting, one kingpin only - var/mob/living/basic/bounty_criminal/kingpin/kingpin = SSbounty_kingpin.kingpin_seat(outpost) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = SSbounty_kingpin.kingpin_seat(outpost) TEST_ASSERT_NOTNULL(kingpin, "The subsystem didn't seat the kingpin in the lounge") TEST_ASSERT_EQUAL(SSbounty_kingpin.kingpin(), kingpin, "The subsystem didn't keep track of the kingpin it seated") TEST_ASSERT_EQUAL(get_turf(kingpin), seat_turf, "The kingpin didn't sit down at his seat") @@ -880,8 +1027,17 @@ TEST_ASSERT_EQUAL(length(GLOB.bounty_kingpin_crews), 1, "The lounge has more than one kingpin") var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew TEST_ASSERT(istype(kingpin.buckled, /obj/structure/chair/sofa), "The kingpin isn't on the sofa") - TEST_ASSERT_EQUAL(length(crew.goons()), 6, "The kingpin doesn't have six goons") TEST_ASSERT_EQUAL(length(crew.crew_posts), 6, "The crew doesn't know its six posts") + // His goons come a body at a time through the spawn queue, dressed for the zone. The test's black + // market is on no star map, so no zone can be read for it and their orders would wait a minute for + // one (HUMAN_NPC_ZONE_WAIT) before settling on green; the test gives them that answer straight away. + TEST_ASSERT_EQUAL(length(crew.crew_pending), 6, "The kingpin's six goons weren't queued") + for(var/turf/post as anything in crew.crew_pending) + var/datum/human_npc_order/goon_order = crew.crew_pending[post] + goon_order?.context?.on_zone_resolved(1) // ZONE_GREEN + var/deadline = world.time + 30 SECONDS + UNTIL(length(crew.goons()) >= 6 || world.time > deadline) + TEST_ASSERT_EQUAL(length(crew.goons()), 6, "The kingpin doesn't have six goons") TEST_ASSERT_EQUAL(crew.crew_outpost(), outpost, "The crew doesn't know the outpost its lounge is in") // He has no coffee table any more, and no lounge table stands at any of his goon posts either TEST_ASSERT_EQUAL(length(crew.crew_coffee_table), 0, "The crew found a coffee table that isn't there") @@ -896,7 +1052,7 @@ TEST_ASSERT_NOTNULL(turret, "No lounge turret near the sofa") var/mob/living/carbon/human/hunter = kingpin_test_person(crew.talk_spot(), null) crew.start_shootout(hunter, TRUE) - for(var/mob/living/basic/bounty_kingpin_goon/goon as anything in crew.goons()) + for(var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon as anything in crew.goons()) TEST_ASSERT(turret.in_faction(goon), "The lounge turret doesn't count [goon] as its own") TEST_ASSERT(bounty_turret_ignores(kingpin, TRUE), "The lounge turret doesn't leave the kingpin alone") TEST_ASSERT(barkeep.transform ~= standing, "The shootout changed how the barkeep looks") @@ -923,10 +1079,10 @@ /datum/unit_test/voidcrew_bounty_kingpin/mech/Run() var/datum/criminal_bounty/kingpin/posting = kingpin_test_posting() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 2) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 2) var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew var/list/goons = crew.goons() - var/mob/living/basic/bounty_kingpin_goon/goon = goons[1] + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = goons[1] var/mob/living/carbon/human/consistent/pilot = kingpin_test_person(kingpin_test_spot(1, 4), null) var/obj/vehicle/sealed/mecha/ripley/mech = allocate(/obj/vehicle/sealed/mecha/ripley, kingpin_test_spot(1, 4)) mech.mob_enter(pilot, silent = TRUE) @@ -947,10 +1103,10 @@ // Any damage to a calm crew: the nearest person in sight who isn't a guest is taken for the attacker kingpin_test_clear_lounge() var/datum/criminal_bounty/kingpin/second_posting = kingpin_test_posting() - var/mob/living/basic/bounty_criminal/kingpin/second = kingpin_test_lounge(second_posting, 2) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/second = kingpin_test_lounge(second_posting, 2) var/datum/bounty_kingpin_crew/second_crew = second.kingpin_crew var/list/second_goons = second_crew.goons() - var/mob/living/basic/bounty_kingpin_goon/hurt_goon = second_goons[2] + var/mob/living/carbon/human/npc/bounty_kingpin_goon/hurt_goon = second_goons[2] var/mob/living/carbon/human/culprit = kingpin_test_person(kingpin_test_spot(3, 2), null) TEST_ASSERT_EQUAL(second_crew.crew_state, "calm", "The second crew isn't calm") // BOUNTY_KINGPIN_CALM hurt_goon.adjustBruteLoss(10) @@ -963,9 +1119,9 @@ second_posting.close("admin") kingpin_test_clear_lounge() var/datum/criminal_bounty/kingpin/third_posting = kingpin_test_posting() - var/mob/living/basic/bounty_criminal/kingpin/third = kingpin_test_lounge(third_posting, 1) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/third = kingpin_test_lounge(third_posting, 1) var/list/third_goons = third.kingpin_crew.goons() - var/mob/living/basic/bounty_criminal/normal/rival = allocate(/mob/living/basic/bounty_criminal/normal, kingpin_test_spot(3, 3)) + var/mob/living/carbon/human/npc/bounty_criminal/normal/rival = allocate(/mob/living/carbon/human/npc/bounty_criminal/normal, kingpin_test_spot(3, 3)) SEND_SIGNAL(third_goons[1], COMSIG_ATOM_WAS_ATTACKED, rival, ATTACKER_DAMAGING_ATTACK) TEST_ASSERT_EQUAL(third.kingpin_crew.crew_state, "calm", "Another criminal's punch started a shootout with nobody to shoot") @@ -979,7 +1135,7 @@ var/obj/structure/table/wood/post_table = allocate(/obj/structure/table/wood, kingpin_test_spot(0, 3)) post_table.AddElement(/datum/element/outpost_property) var/datum/criminal_bounty/kingpin/posting = kingpin_test_posting() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 3) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 3) var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew TEST_ASSERT(WEAKREF(post_table) in crew.crew_tables, "The crew doesn't mind the table at a goon's post") TEST_ASSERT(!(post_table.resistance_flags & INDESTRUCTIBLE), "A lounge table can't be shot to pieces while he's in") @@ -1014,22 +1170,6 @@ qdel(kingpin) TEST_ASSERT(replacement.resistance_flags & INDESTRUCTIBLE, "A lounge table stayed breakable after he was gone") -// ===== M1: GOON STAMINA ===== - -/// Five disabler hits stamcrit a goon: a stun, not just a slowdown -/datum/unit_test/voidcrew_bounty_kingpin/stamina - -/datum/unit_test/voidcrew_bounty_kingpin/stamina/Run() - var/mob/living/basic/bounty_kingpin_goon/goon = allocate(/mob/living/basic/bounty_kingpin_goon, kingpin_test_spot(2, 2)) - TEST_ASSERT_EQUAL(goon.max_stamina, 100, "A goon's stamina pool isn't 100") // BOUNTY_GOON_MAX_STAMINA - // 30-point disabler hits against BOUNTY_GOON_HEALTH 150: 20 points each - for(var/hit in 1 to 4) - goon.adjustStaminaLoss(30) - TEST_ASSERT(goon.goon_able(), "Four disabler hits stunned a goon") - goon.adjustStaminaLoss(30) - TEST_ASSERT(goon.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "Five disabler hits didn't stamcrit a goon") - TEST_ASSERT(!goon.goon_able(), "A stamcrit goon can still fight") - // ===== M2: A CALM CREW STILL WATCHES ===== /// After a stand-down, a known hunter in sight, cuffing him or dragging him starts the fight again, through the draw @@ -1037,7 +1177,7 @@ /datum/unit_test/voidcrew_bounty_kingpin/watch/Run() var/datum/criminal_bounty/kingpin/posting = kingpin_test_posting() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 2) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 2) var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew var/mob/living/carbon/human/hunter = kingpin_test_person(kingpin_test_spot(2, 2), null) crew.start_shootout(hunter, TRUE) @@ -1048,14 +1188,13 @@ crew.calm_tick() TEST_ASSERT_EQUAL(crew.crew_state, "drawing", "A known hunter in sight didn't restart the fight") // BOUNTY_KINGPIN_DRAWING - // Cuffing him while his crew is at ease is an attack by the cuffer + // Cuffing him while his crew is at ease is an attack by the cuffer: tg's reach for his wrists, then the cuffs crew.stand_down() var/mob/living/carbon/human/cuffer = kingpin_test_person(kingpin_test_spot(3, 2), null) kingpin.buckled?.unbuckle_mob(kingpin, force = TRUE) - kingpin.body_go_down() - var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs, kingpin_test_spot(3, 2)) - cuffer.put_in_hands(cuffs) - TEST_ASSERT(kingpin.body_apply_cuffs(cuffs, cuffer), "The downed kingpin couldn't be cuffed") + TEST_ASSERT(kingpin_test_down(kingpin), "The kingpin didn't go into crit") + SEND_SIGNAL(kingpin, COMSIG_CARBON_CUFF_ATTEMPTED, cuffer) + TEST_ASSERT(kingpin_test_cuff(kingpin), "The kingpin in crit couldn't be cuffed") TEST_ASSERT_EQUAL(crew.crew_state, "drawing", "Cuffing him while his crew watched didn't start the fight") TEST_ASSERT(crew.is_hunter(cuffer), "The one who cuffed him isn't a hunter") // Cuffed on his sofa, his goons stay with him @@ -1071,6 +1210,77 @@ TEST_ASSERT_EQUAL(crew.crew_state, "drawing", "Dragging him off didn't start the fight") TEST_ASSERT(crew.is_hunter(dragger), "The one dragging him isn't a hunter") +// ===== OUTPOST SECURITY ===== + +/** + * During the shootout a hunter's stray shot, just after firing at his crew, takes no outpost strike: + * three of them leave the turret holding fire, where three strikes mark anyone else. Hits away from + * the fight still count, PvP still counts, and strikes count again after it (L1, L11). + */ +/datum/unit_test/voidcrew_bounty_kingpin/security + +/datum/unit_test/voidcrew_bounty_kingpin/security/Run() + var/obj/structure/overmap/trader_outpost/outpost = allocate(/obj/structure/overmap/trader_outpost) + outpost.outpost_template = allocate(/datum/map_template/trader_outpost) + outpost.outpost_template.width = 5 + outpost.outpost_template.height = 5 + outpost.template_bottom_left = run_loc_floor_bottom_left + var/obj/machinery/porta_turret/outpost/turret = allocate(/obj/machinery/porta_turret/outpost, kingpin_test_spot(4, 4)) + turret.outpost = outpost + + var/datum/criminal_bounty/kingpin/posting = kingpin_test_posting() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 2) + var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew + var/list/goons = crew.goons() + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = goons[1] + var/mob/living/carbon/human/hunter = kingpin_test_person(kingpin_test_spot(2, 2), null) + var/mob/living/carbon/human/idle_hunter = kingpin_test_person(kingpin_test_spot(1, 3), null) + var/mob/living/carbon/human/brawler = kingpin_test_person(kingpin_test_spot(1, 2), null) + var/mob/living/carbon/human/victim = kingpin_test_person(kingpin_test_spot(3, 2), null) + var/mob/living/carbon/human/bystander = kingpin_test_person(kingpin_test_spot(3, 3), null) + TEST_ASSERT_EQUAL(get_trader_outpost_for_turf(crew.crew_seat), outpost, "The test lounge isn't at the test outpost") + + crew.start_shootout(hunter, TRUE) + crew.add_hunter(idle_hunter) + crew.add_hunter(brawler) + TEST_ASSERT(crew.is_fighting(), "The shootout didn't start") + // The hunter and the brawler have just shot at a goon + crew.member_attacked(goon, list(hunter, brawler)) + TEST_ASSERT(crew.engaged(hunter), "A hunter who just shot a goon isn't counted in the fight") + TEST_ASSERT(!crew.engaged(idle_hunter), "A hunter who fired at nobody is counted in the fight") + + // Three stray hits into outpost property: no strike, and the turret holds fire (three would mark them) + for(var/i in 1 to 3) + outpost.aggressor_strike_times -= hunter.mind + outpost.register_aggression(hunter) + TEST_ASSERT_NULL(outpost.aggressor_strikes[hunter.mind], "A hunter's stray shot during the shootout got a property strike") + TEST_ASSERT(!outpost.is_marked_aggressor(hunter.mind), "A hunter was marked for stray shots during the shootout") + TEST_ASSERT(!turret.valid_target(hunter), "The turret turned on a hunter during the shootout") + // The same three hits from someone not in the fight mark them, and the turret fires + for(var/i in 1 to 3) + outpost.aggressor_strike_times -= bystander.mind + outpost.register_aggression(bystander) + TEST_ASSERT(outpost.is_marked_aggressor(bystander.mind), "Three strikes didn't mark a bystander during the shootout") + TEST_ASSERT(turret.valid_target(bystander), "The turret held fire on a marked bystander") + // A hunter who hasn't been shooting at his crew gets their strike + outpost.register_aggression(idle_hunter) + TEST_ASSERT_EQUAL(outpost.aggressor_strikes[idle_hunter.mind], 1, "A hunter not firing at his crew was excused a strike") + // PvP enforcement stays: a hunter who hits a person gets the strike + outpost.register_pvp_aggression(victim, brawler) + TEST_ASSERT_EQUAL(outpost.aggressor_strikes[brawler.mind], 1, "A hunter's PvP hit didn't count during the shootout") + + // The turret leaves his crew alone: the goons share its faction, P2 exempts the kingpin + TEST_ASSERT(turret.in_faction(goon), "The goons don't share the turrets' faction") + TEST_ASSERT(!turret.valid_target(goon), "The turret would shoot a goon") + TEST_ASSERT(bounty_turret_ignores(kingpin, TRUE), "Trader-outpost turrets don't leave the kingpin alone") + + // After it, a hunter's property hit counts again + crew.stand_down() + TEST_ASSERT(!crew.is_fighting(), "The crew didn't stand down") + outpost.aggressor_strike_times -= hunter.mind + outpost.register_aggression(hunter) + TEST_ASSERT_EQUAL(outpost.aggressor_strikes[hunter.mind], 1, "A hunter's property strike didn't count outside the shootout") + // ===== THE LOW ONES ===== /// A hunter in a locker is not shot at (L2); a crewmate of anyone who fought gets no work (L3); a new character of a player who works for him is still bound (L4) @@ -1078,7 +1288,7 @@ /datum/unit_test/voidcrew_bounty_kingpin/lows/Run() var/datum/criminal_bounty/kingpin/posting = kingpin_test_posting() - var/mob/living/basic/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 1) + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 1) var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew var/obj/structure/overmap/ship/fighting_ship = kingpin_test_ship() var/mob/living/carbon/human/fighter = kingpin_test_person(kingpin_test_spot(3, 3), fighting_ship) diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_lair_mafia.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_lair_mafia.dm index e65a8e136fb..46a8a2a6eff 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_lair_mafia.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_lair_mafia.dm @@ -3,8 +3,9 @@ * * Owner: P12 mafia mobs. Do not edit this file outside that package. Fork defines are included after the * tests, so a test uses the literal value with a comment naming the define. The tests call the mobs' procs directly - * with them already in place. Only rocket_flight (a rocket really flying to its marker) and ring_path (the lair's - * grace period between the mech and the don) wait; none waits on an AI walk. + * with them already in place. The goons, the lieutenants and the don are real human NPCs; the don's mech is a mob of + * its own (owner call OC-5). Only rocket_flight (a rocket really flying to its marker), fire (a real gun's burst) and + * ring_path (the lair's grace period between the mech and the don) wait; none waits on an AI walk. */ /// Shared helpers; not a test itself @@ -41,6 +42,12 @@ fake_clients += hunter return hunter +/// One of the club's people at `where`, with its AI off: the test drives it +/datum/unit_test/voidcrew_bounty_lair_mafia/proc/member_at(member_type, turf/where) + var/mob/living/carbon/human/npc/bounty_mafia/member = allocate(member_type, where) + member.ai_controller?.set_ai_status(AI_STATUS_OFF) + return member + /// Clears what the club leaves behind in the test room: shots in flight, corpses, wrecks, rings /datum/unit_test/voidcrew_bounty_lair_mafia/proc/clear_room() for(var/turf/spot as anything in block(run_loc_floor_bottom_left, run_loc_floor_top_right)) @@ -57,7 +64,7 @@ if(!(stray_item in allocated)) qdel(stray_item) -// ===== THE ROCKET VOLLEY: MARKERS FIRST, NEVER explosion() ===== +// ===== THE ROCKET VOLLEY: MARKERS FIRST, THEN TG'S LIGHT BLAST ON WHOEVER STANDS THERE, NEVER explosion() ===== /datum/unit_test/voidcrew_bounty_lair_mafia/rockets @@ -87,23 +94,38 @@ TEST_ASSERT(!istype(rocket, /obj/projectile/bullet/rocket), "The launch fired tg's rocket") TEST_ASSERT_EQUAL(rocket.rocket_target, get_turf(hunter), "The rocket isn't aimed at the marker") - // The projectile and its scripted detonation share one red boss factor. + // The burst: tg's light blast on the hunter standing on the marker (damage, and a knockdown by their bomb armour) var/turf/marker_turf = get_turf(hunter) var/list/volley = rocket.rocket_volley var/list/hit = rocket.rocket_detonate(marker_turf) TEST_ASSERT(hunter in hit, "The rocket missed the hunter standing on the marker") var/first = hunter.getBruteLoss() - TEST_ASSERT_EQUAL(first, 84, "The rocket lost or doubled its red boss damage factor") // BOUNTY_MECH_ROCKET_DAMAGE * 1.2 - TEST_ASSERT(hunter.IsKnockdown(), "The rocket didn't knock the hunter down") + TEST_ASSERT(first > 0, "The rocket's blast didn't hurt the hunter on its marker") + TEST_ASSERT(hunter.IsKnockdown(), "The rocket's blast didn't knock the hunter down") TEST_ASSERT(QDELETED(rocket), "The rocket outlived its burst") var/obj/projectile/bullet/bounty_mafia_rocket/second = new(spot(1, 2)) second.rocket_volley = volley second.rocket_detonate(marker_turf) TEST_ASSERT_EQUAL(hunter.getBruteLoss(), first, "A second rocket of one volley hit the same hunter") + // The blast hits whoever stands there, whatever their state: a hunter already down takes it too (CB-10, CB-11) + var/mob/living/carbon/human/consistent/downed = hunter_at(spot(3, 4)) + // Suffocation, not brute: brute lands on one random limb, which caps it + downed.adjustOxyLoss(150) + TEST_ASSERT(downed.stat != CONSCIOUS, "Test fixture: the second hunter didn't go down") + var/downed_before = downed.getBruteLoss() + var/obj/projectile/bullet/bounty_mafia_rocket/on_the_floor = new(spot(1, 4)) + TEST_ASSERT(downed in on_the_floor.rocket_detonate(get_turf(downed)), "A rocket's burst skipped a hunter who is down") + TEST_ASSERT(downed.getBruteLoss() > downed_before, "A rocket's burst didn't hurt a hunter who is down") + + // A burst picks no sides: one of the club standing on a marker takes it as well + var/mob/living/carbon/human/npc/bounty_mafia/goon = member_at(/mob/living/carbon/human/npc/bounty_mafia, spot(2, 0)) + var/obj/projectile/bullet/bounty_mafia_rocket/friendly = new(spot(1, 0)) + TEST_ASSERT(goon in friendly.rocket_detonate(get_turf(goon)), "A rocket's burst skipped one of the club") + // A marker the hunter stepped off hurts nobody var/obj/projectile/bullet/bounty_mafia_rocket/empty = new(spot(1, 2)) - TEST_ASSERT(!length(empty.rocket_detonate(spot(2, 4))), "A rocket on an empty marker hit someone") + TEST_ASSERT(!length(empty.rocket_detonate(spot(2, 3))), "A rocket on an empty marker hit someone") // ===== A ROCKET IN FLIGHT: THROUGH PEOPLE TO ITS MARKER, NO EXPLOSION, NOTHING BROKEN OUTSIDE THE GARAGE ===== @@ -153,7 +175,7 @@ var/landed_brute = watch_flight(rockets[1], target, timeline) var/seen = "Hits: [length(target_hits) ? target_hits.Join("; ") : "none"]. Brute by tenth of a second: [timeline.Join(", ")]" TEST_ASSERT(QDELETED(rockets[1]), "The rocket never reached its marker. [seen]") - TEST_ASSERT_EQUAL(landed_brute, 70, "The rocket didn't hit the hunter on its marker. [seen]") // BOUNTY_MECH_ROCKET_DAMAGE + TEST_ASSERT(landed_brute > 0, "The rocket didn't hurt the hunter on its marker. [seen]") TEST_ASSERT_EQUAL(target.getBruteLoss(), landed_brute, "The hunter's brute changed after the rocket burst. [seen]") TEST_ASSERT_EQUAL(bystander.getBruteLoss(), 0, "The rocket hit someone it flew past on the way") // explosion() would have gone off, and flattened the table beside the marker @@ -204,7 +226,7 @@ TEST_ASSERT(mech.mech_holds_grudge(pilot), "The mech holds no grudge against an exosuit's pilot") LAZYREMOVE(suit.occupants, pilot) -// ===== THE LMG: A RED CONE FIRST ===== +// ===== THE LMG: A RED CONE FIRST, REAL ROUNDS THAT HIT WHOEVER IS IN THE WAY ===== /datum/unit_test/voidcrew_bounty_lair_mafia/lmg @@ -233,6 +255,7 @@ TEST_ASSERT(!mech.mech_start_rockets(list(hunter)), "A volley started during the burst") var/obj/projectile/round = mech.mech_lmg_round(fire_serial) TEST_ASSERT(round && round.range <= mech.mech_lmg_range + 1, "A machine gun round flies past its cone") + TEST_ASSERT(round && !length(round.ignored_factions), "The machine gun's rounds pass through the club's own people") // Cut short: nothing more fires, and the cone goes mech.mech_interrupt() @@ -241,7 +264,7 @@ TEST_ASSERT_NULL(mech.mech_lmg_round(fire_serial), "A round fired after the burst was cut short") clear_room() - // Never at someone who is down + // It never picks someone who is down to aim at mech.mech_next_ability_at = 0 // Suffocation, not brute: brute lands on one random limb, which caps it hunter.adjustOxyLoss(150) @@ -249,7 +272,7 @@ TEST_ASSERT(!mech.mech_start_lmg(hunter), "The machine gun spun up on a downed hunter") TEST_ASSERT(!mech.mech_start_rockets(list(hunter)), "The volley locked on to a downed hunter") -// ===== THE STOMP THROWS YOU BACK; THE CLUB'S GUNS ARE REAL ===== +// ===== THE STOMP THROWS YOU BACK ===== /datum/unit_test/voidcrew_bounty_lair_mafia/stomp @@ -267,18 +290,114 @@ hunter.throwing.finalize() clear_room() - // The club's guns are the real ones: a gunman's magazine is the Stechkin's, and Tommy's the Thompson's drum - var/mob/living/basic/trooper/russian/mafia/pistol/gunman = allocate(/mob/living/basic/trooper/russian/mafia/pistol, spot(4, 4)) - var/obj/item/ammo_box/magazine/m9mm_aps/pistol_magazine = /obj/item/ammo_box/magazine/m9mm_aps - TEST_ASSERT_EQUAL(gunman.mafia_gun.magazine, initial(pistol_magazine.max_ammo), "The gunman's magazine isn't the Stechkin's") - var/mob/living/basic/trooper/russian/mafia/lieutenant/tommy/tommy = allocate(/mob/living/basic/trooper/russian/mafia/lieutenant/tommy, spot(3, 4)) - var/obj/item/ammo_box/magazine/tommygunm45/drum = /obj/item/ammo_box/magazine/tommygunm45 - TEST_ASSERT_EQUAL(tommy.mafia_gun.magazine, initial(drum.max_ammo), "Tommy's magazine isn't the Thompson's drum") - // The knife man's blade is a kitchen knife's - var/mob/living/basic/trooper/russian/mafia/knife_man = allocate(/mob/living/basic/trooper/russian/mafia, spot(2, 4)) - var/obj/item/knife/kitchen/knife = /obj/item/knife/kitchen - TEST_ASSERT_EQUAL(knife_man.melee_damage_upper, initial(knife.force), "The knife man doesn't hit like a kitchen knife") - TEST_ASSERT_EQUAL(knife_man.sharpness, SHARP_EDGED, "The knife man's blows aren't edged") +// ===== THE CLUB'S PEOPLE: REAL BODIES, REAL CLOTHES, REAL GUNS ===== + +/datum/unit_test/voidcrew_bounty_lair_mafia/kit + +/datum/unit_test/voidcrew_bounty_lair_mafia/kit/Run() + // type -> list(the gun in hand, its magazine, spares carried) + var/list/gunmen = list( + /mob/living/carbon/human/npc/bounty_mafia/pistol = list(/obj/item/gun/ballistic/automatic/pistol/aps, /obj/item/ammo_box/magazine/m9mm_aps, 2), + /mob/living/carbon/human/npc/bounty_mafia/smg = list(/obj/item/gun/ballistic/automatic/mini_uzi, /obj/item/ammo_box/magazine/uzim9mm, 2), + /mob/living/carbon/human/npc/bounty_mafia/lieutenant/tommy = list(/obj/item/gun/ballistic/automatic/tommygun, /obj/item/ammo_box/magazine/tommygunm45, 2), + /mob/living/carbon/human/npc/bounty_mafia/don = list(/obj/item/gun/ballistic/automatic/pistol/deagle/gold, /obj/item/ammo_box/magazine/m50, 2), + ) + var/dx = 0 + for(var/member_type in gunmen) + var/list/kit = gunmen[member_type] + var/mob/living/carbon/human/npc/bounty_mafia/member = member_at(member_type, spot(dx++, 4)) + var/obj/item/gun/ballistic/gun = locate(kit[1]) in member.held_items + TEST_ASSERT_NOTNULL(gun, "[member_type] doesn't hold a [kit[1]]") + TEST_ASSERT(gun?.can_shoot(), "[member_type]'s gun isn't loaded") + TEST_ASSERT(HAS_TRAIT(gun, "human_npc_gear"), "[member_type]'s gun isn't locked to them, so it would be loot") // TRAIT_HUMAN_NPC_GEAR + var/spares = 0 + for(var/obj/item/ammo_box/magazine/magazine in member.get_all_contents()) + if(istype(magazine, kit[2]) && magazine != gun?.magazine) + spares++ + TEST_ASSERT_EQUAL(spares, kit[3], "[member_type] carries [spares] spare magazines, not [kit[3]]") + TEST_ASSERT_NOTNULL(member.w_uniform, "[member_type] isn't dressed") + TEST_ASSERT_EQUAL(member.gender, MALE, "[member_type] isn't one of the club's men") + TEST_ASSERT("bounty_mafia" in member.faction, "[member_type] isn't of the club") // BOUNTY_MAFIA_FACTION + TEST_ASSERT_EQUAL(member.maxHealth, 100, "[member_type]'s health isn't a person's") // MAX_LIVING_HEALTH + TEST_ASSERT_NULL(member.npc_surrender, "[member_type] can give up") + TEST_ASSERT_EQUAL(member.npc_target_stat, CONSCIOUS, "[member_type] would go after a hunter who is down") // HUMAN_NPC_SPARES_DOWNED + + // The knife man holds a kitchen knife; Brute holds nothing and fights with his fists, in a bulletproof vest + var/mob/living/carbon/human/npc/bounty_mafia/knife_man = member_at(/mob/living/carbon/human/npc/bounty_mafia, spot(0, 2)) + TEST_ASSERT_NOTNULL(locate(/obj/item/knife/kitchen) in knife_man.held_items, "The knife man has no kitchen knife") + var/mob/living/carbon/human/npc/bounty_mafia/lieutenant/brute/brute = member_at(/mob/living/carbon/human/npc/bounty_mafia/lieutenant/brute, spot(1, 2)) + TEST_ASSERT(!length(brute.get_all_contents_type(/obj/item/gun)), "Brute carries a gun") + TEST_ASSERT(istype(brute.wear_suit, /obj/item/clothing/suit/armor/vest/russian), "Brute has no armour on") + + // Ranks and toughness: through their bodies and what they wear, never their health + var/mob/living/carbon/human/npc/bounty_mafia/lieutenant/tommy/tommy = member_at(/mob/living/carbon/human/npc/bounty_mafia/lieutenant/tommy, spot(2, 2)) + TEST_ASSERT(istype(tommy.wear_suit, /obj/item/clothing/suit/toggle/jacket/det_trench/noir), "Tommy's long coat isn't his armoured one") + for(var/mob/living/carbon/human/npc/bounty_mafia/lieutenant/lieutenant as anything in list(tommy, brute)) + TEST_ASSERT_EQUAL(lieutenant.npc_rank, 1, "[lieutenant] isn't an elite") // HUMAN_NPC_RANK_ELITE + TEST_ASSERT(abs(lieutenant.physiology.brute_mod - 0.8) < 0.01, "[lieutenant] takes [lieutenant.physiology.brute_mod] of brute, not 0.8") // BOUNTY_LIEUTENANT_DAMAGE_TAKEN + TEST_ASSERT(abs(lieutenant.physiology.burn_mod - 0.8) < 0.01, "[lieutenant] takes [lieutenant.physiology.burn_mod] of burn, not 0.8") + TEST_ASSERT_EQUAL(lieutenant.maxHealth, 100, "[lieutenant]'s health isn't a person's") // MAX_LIVING_HEALTH + var/mob/living/carbon/human/npc/bounty_mafia/don/don = member_at(/mob/living/carbon/human/npc/bounty_mafia/don, spot(3, 2)) + TEST_ASSERT_EQUAL(don.npc_rank, 2, "The don isn't a boss") // HUMAN_NPC_RANK_BOSS + TEST_ASSERT(abs(don.physiology.brute_mod - 0.6) < 0.01, "The don takes [don.physiology.brute_mod] of brute, not 0.6") // BOUNTY_DON_DAMAGE_TAKEN + TEST_ASSERT_EQUAL(knife_man.npc_rank, 0, "A goon is an elite") // HUMAN_NPC_RANK_REGULAR + // Nobody in the club executes anyone (OC-9: no deliberate executions are built yet) + for(var/mob/living/carbon/human/npc/bounty_mafia/member as anything in list(knife_man, brute, tommy, don)) + TEST_ASSERT(!member.hv_can_execute(), "[member] can execute") + +// ===== FIRING THE REAL GUN: PULLS, THE AIM, THE FLINCH, THE RELOAD ===== + +/datum/unit_test/voidcrew_bounty_lair_mafia/fire + +/datum/unit_test/voidcrew_bounty_lair_mafia/fire/Run() + var/mob/living/carbon/human/consistent/hunter = hunter_at(spot(4, 0)) + var/mob/living/carbon/human/npc/bounty_mafia/pistol/gunman = member_at(/mob/living/carbon/human/npc/bounty_mafia/pistol, spot(0, 0)) + var/datum/ai_controller/controller = gunman.ai_controller + var/obj/item/gun/ballistic/gun = locate(/obj/item/gun/ballistic/automatic/pistol/aps) in gunman.held_items + TEST_ASSERT_NOTNULL(gun, "Test fixture: the gunman holds no Stechkin") + gun.can_misfire = FALSE + controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) + var/datum/ai_behavior/bounty_mafia_fire/fire = GET_AI_BEHAVIOR(/datum/ai_behavior/bounty_mafia_fire) + + // A pistol volley: no aim, one pull of the real gun (its three-round burst), then a pause before the next + var/rounds_before = gun.get_ammo() + TEST_ASSERT(fire.setup(controller, BB_BASIC_MOB_CURRENT_TARGET), "The gunman's volley didn't start") + TEST_ASSERT(!gunman.mafia_aim_until, "The pistol aims before it fires") + var/flags = fire.perform(0.1, controller, BB_BASIC_MOB_CURRENT_TARGET) + TEST_ASSERT(flags & AI_BEHAVIOR_SUCCEEDED, "The pistol volley wasn't one pull") + fire.finish_action(controller, TRUE, BB_BASIC_MOB_CURRENT_TARGET) + TEST_ASSERT(gunman.mafia_next_volley_at >= world.time + 8, "The gunman has no pause between volleys") // BOUNTY_MOBSTER_PISTOL_COOLDOWN + TEST_ASSERT(!fire.setup(controller, BB_BASIC_MOB_CURRENT_TARGET), "The gunman started a volley before his pause was over") + sleep(0.5 SECONDS) + TEST_ASSERT(gun.get_ammo() < rounds_before, "The pull didn't fire the gunman's Stechkin") + clear_room() + + // The Uzi spins up first ("aiming!"), and a hit then spoils the aim: nothing fires, and the next try waits + var/mob/living/carbon/human/npc/bounty_mafia/smg/enforcer = member_at(/mob/living/carbon/human/npc/bounty_mafia/smg, spot(0, 2)) + var/datum/ai_controller/enforcer_ai = enforcer.ai_controller + var/obj/item/gun/ballistic/uzi = locate(/obj/item/gun/ballistic/automatic/mini_uzi) in enforcer.held_items + enforcer_ai.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) + var/uzi_rounds = uzi.get_ammo() + TEST_ASSERT(fire.setup(enforcer_ai, BB_BASIC_MOB_CURRENT_TARGET), "The enforcer's volley didn't start") + TEST_ASSERT(enforcer.mafia_aim_until > world.time, "The Uzi didn't spin up first") + TEST_ASSERT(fire.perform(0.1, enforcer_ai, BB_BASIC_MOB_CURRENT_TARGET) & AI_BEHAVIOR_DELAY, "The enforcer didn't wait out his aim") + TEST_ASSERT_EQUAL(uzi.get_ammo(), uzi_rounds, "The Uzi fired during its spin-up") + enforcer.apply_damage(5, BRUTE, BODY_ZONE_CHEST) + TEST_ASSERT(enforcer.mafia_aim_spoiled, "A hit during the spin-up didn't spoil the aim") + TEST_ASSERT(fire.perform(0.1, enforcer_ai, BB_BASIC_MOB_CURRENT_TARGET) & AI_BEHAVIOR_FAILED, "A spoiled aim still fired") + fire.finish_action(enforcer_ai, FALSE, BB_BASIC_MOB_CURRENT_TARGET) + TEST_ASSERT(enforcer.mafia_next_volley_at >= world.time + 9, "A spoiled aim didn't cost the enforcer a second") // BOUNTY_MOBSTER_FUMBLE + TEST_ASSERT_EQUAL(uzi.get_ammo(), uzi_rounds, "The Uzi fired after its aim was spoiled") + + // Dry: the next move is the player's reload from his pockets, with the club's sound and maybe a line + var/obj/item/ammo_box/magazine/spent = gun.magazine + spent.stored_ammo.Cut() + QDEL_NULL(gun.chambered) + TEST_ASSERT(!gun.can_shoot(), "Test fixture: the Stechkin still fires") + gunman.mafia_next_volley_at = 0 + TEST_ASSERT(gunman.mafia_plan_attack(controller, hunter), "A dry gunman had nothing to do") + TEST_ASSERT(controller.current_behaviors[GET_AI_BEHAVIOR(/datum/ai_behavior/human_npc_reload/bounty_mafia)], "A dry gunman didn't reload") + controller.CancelActions() // ===== POSSE HEALTH ===== @@ -346,7 +465,7 @@ TEST_ASSERT(mech.mech_engaged[REF(ion_shooter)], "An ion shooter didn't join the posse") TEST_ASSERT(mech.mech_holds_grudge(ion_shooter), "The mech holds no grudge against an ion shooter") -// ===== THE RESET ===== +// ===== THE RESET: A MACHINE'S REPAIR ARMS ===== /datum/unit_test/voidcrew_bounty_lair_mafia/reset @@ -393,17 +512,18 @@ TEST_ASSERT(!mech.mech_ability_ready(sniper), "The mech would fire at a sniper it can't see") // The don out of the wreck keeps the mech's grudges, and takes on a sniper of his own - var/mob/living/basic/bounty_lair_boss/mafia_don/don = mech.mech_eject() + var/mob/living/carbon/human/npc/bounty_mafia/don/don = mech.mech_eject() TEST_ASSERT_NOTNULL(don, "The don didn't climb out") allocated += don - TEST_ASSERT(don.don_target_ok(sniper), "The don forgot who broke his mech") + don.ai_controller?.set_ai_status(AI_STATUS_OFF) + TEST_ASSERT(don.mafia_target_ok(sniper), "The don forgot who broke his mech") var/mob/living/carbon/human/consistent/second_sniper = hunter_at(far_spot(22)) - TEST_ASSERT(!don.don_target_ok(second_sniper), "The don may go after someone past his sight who never hurt him") - don.don_on_attacked(null, second_sniper, 4) // ATTACKER_DAMAGING_ATTACK - TEST_ASSERT(don.don_target_ok(second_sniper), "The don doesn't answer a sniper who hurt him") + TEST_ASSERT(!don.mafia_target_ok(second_sniper), "The don may go after someone past his sight who never hurt him") + SEND_SIGNAL(don, COMSIG_ATOM_WAS_ATTACKED, second_sniper, 4) // ATTACKER_DAMAGING_ATTACK + TEST_ASSERT(don.mafia_target_ok(second_sniper), "The don doesn't answer a sniper who hurt him") clear_room() -// ===== PHASE TWO: THE WRECK, THE DON, THE RING ===== +// ===== PHASE TWO: THE WRECK, THE DON, HIS CUFFS AND THE RING ===== /datum/unit_test/voidcrew_bounty_lair_mafia/phase_two var/list/ejected = list() @@ -435,34 +555,60 @@ TEST_ASSERT_NOTNULL(wreck, "The mech left no wreck") TEST_ASSERT(!istype(wreck, /obj/structure/mecha_wreckage), "The wreck can be salvaged") TEST_ASSERT(wreck.density, "The wreck is no cover") - var/mob/living/basic/bounty_lair_boss/mafia_don/don = locate() in range(1, where) + var/mob/living/carbon/human/npc/bounty_mafia/don/don = locate() in range(1, where) TEST_ASSERT_NOTNULL(don, "The don didn't climb out") allocated += don - TEST_ASSERT(!ispath(don.type, /mob/living/basic/boss), "The don is a megafauna boss") + don.ai_controller?.set_ai_status(AI_STATUS_OFF) TEST_ASSERT(don in ejected, "The mech didn't announce the don") TEST_ASSERT_EQUAL(don.posting_ref?.resolve(), posting, "The don didn't keep the mech's posting") - TEST_ASSERT_EQUAL(don.name, "Viktor Sokolov", "The don isn't named for his posting") - TEST_ASSERT_EQUAL(don.maxHealth, 325, "The don lost the mech's selected boss profile") // BOUNTY_DON_HEALTH - TEST_ASSERT_EQUAL(don.don_busy, "stagger", "The don isn't dazed as he climbs out") + TEST_ASSERT_EQUAL(don.real_name, "Viktor Sokolov", "The don isn't named for his posting") + TEST_ASSERT(don.don_dazed_until > world.time, "The don isn't getting his bearings as he climbs out") TEST_ASSERT_EQUAL(don.don_wreck_ref?.resolve(), wreck, "The don doesn't know his wreck") - - // Kill-only: the cuffs are refused - var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs, get_turf(hunter)) - TEST_ASSERT_EQUAL(don.item_interaction(hunter, cuffs), ITEM_INTERACT_BLOCKING, "The don could be cuffed") - - // His death drops the ring, with the posting and its record on it + TEST_ASSERT_NOTNULL(locate(/obj/item/gun/ballistic/automatic/pistol/deagle/gold) in don.held_items, "The don climbed out without his gold pistol") + TEST_ASSERT(get_area(don) == get_area(wreck), "The don climbed out of his arena") + + // He never gives up, and the cuffs aren't refused: the cuffer is his target, and while he can move he steps away + TEST_ASSERT_NULL(don.npc_surrender, "The don can give up") + TEST_ASSERT(!(SEND_SIGNAL(don, COMSIG_CARBON_CUFF_ATTEMPTED, hunter) & COMSIG_CARBON_CUFF_PREVENT), "The don refused the cuffs outright") + TEST_ASSERT_EQUAL(don.ai_controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET], hunter, "The don didn't turn on the hunter cuffing him") + TEST_ASSERT(hunter.weak_reference && (hunter.weak_reference in don.don_grudge), "The don holds no grudge against the hunter cuffing him") + hunter.forceMove(get_step(get_turf(don), get_dir(don, wreck) || EAST)) + var/turf/before_step = get_turf(don) + if(don.Adjacent(hunter) && don.mafia_dodge_cuffs(WEAKREF(hunter))) + TEST_ASSERT(get_turf(don) != before_step, "The don stepped away from the cuffs without moving") + // Paralysed (or down), he can't, and the cuffs go on + don.Paralyze(10 SECONDS) + TEST_ASSERT(!don.mafia_can_answer_cuffs(), "A paralysed don can still answer the cuffs") + var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs) + TEST_ASSERT(don.equip_to_slot_if_possible(cuffs, ITEM_SLOT_HANDCUFFED), "The don can't be cuffed") + TEST_ASSERT(HAS_TRAIT(don, TRAIT_RESTRAINED), "The cuffed don isn't restrained") + don.SetParalyzed(0) + + // His death: he dies in place, in his clothes, and the ring drops, with the posting and its record on it var/turf/don_spot = get_turf(don) don.death() - TEST_ASSERT(QDELETED(don), "The don outlived his death") + TEST_ASSERT(!QDELETED(don), "The don's body went with his death") + TEST_ASSERT_NOTNULL(don.w_uniform, "The don's body isn't dressed") var/obj/item/bounty_proof/trophy/mafia_don/ring = locate() in don_spot TEST_ASSERT_NOTNULL(ring, "The don dropped no ring") TEST_ASSERT_EQUAL(ring.posting_ref?.resolve(), posting, "The ring doesn't carry the posting") TEST_ASSERT_EQUAL(ring.record, posting.record, "The ring doesn't carry the record") TEST_ASSERT_EQUAL(ring.icon_state, "signet_ring", "The ring doesn't look like a ring") + for(var/obj/item/gun/gun in don_spot) + TEST_FAIL("The don's death dropped [gun]") + + // Brought back and killed again, he drops no second ring + don.revive(HEAL_ALL) + TEST_ASSERT(don.stat != DEAD, "Test fixture: the don couldn't be revived") + don.death() + var/rings = 0 + for(var/obj/item/bounty_proof/trophy/mafia_don/dropped in range(2, don_spot)) + rings++ + TEST_ASSERT_EQUAL(rings, 1, "The don dropped [rings] rings over two deaths, not one") // Wanted on nothing (an admin spawn), he goes by the name on Club Volga's card - var/mob/living/basic/bounty_lair_boss/mafia_don/stray = allocate(/mob/living/basic/bounty_lair_boss/mafia_don, spot(4, 4)) - TEST_ASSERT_EQUAL(stray.name, "Arkady Sokolov", "A don with no posting has no name") // BOUNTY_DON_NAME + var/mob/living/carbon/human/npc/bounty_mafia/don/stray = member_at(/mob/living/carbon/human/npc/bounty_mafia/don, spot(4, 4)) + TEST_ASSERT_EQUAL(stray.real_name, "Arkady Sokolov", "A don with no posting has no name") // BOUNTY_DON_NAME // ===== LIEUTENANTS ===== @@ -475,26 +621,38 @@ /datum/unit_test/voidcrew_bounty_lair_mafia/lieutenants/Run() // Two plain gatekeepers in one room: one of each - var/mob/living/basic/trooper/russian/mafia/lieutenant/first = allocate(/mob/living/basic/trooper/russian/mafia/lieutenant, spot(1, 1)) - var/mob/living/basic/trooper/russian/mafia/lieutenant/second = allocate(/mob/living/basic/trooper/russian/mafia/lieutenant, spot(3, 1)) + var/mob/living/carbon/human/npc/bounty_mafia/lieutenant/first = member_at(/mob/living/carbon/human/npc/bounty_mafia/lieutenant, spot(1, 1)) + var/mob/living/carbon/human/npc/bounty_mafia/lieutenant/second = member_at(/mob/living/carbon/human/npc/bounty_mafia/lieutenant, spot(3, 1)) TEST_ASSERT_EQUAL(first.mafia_lieutenant_role, "tommy", "The first lieutenant isn't Tommy") // BOUNTY_LIEUTENANT_TOMMY TEST_ASSERT_EQUAL(second.mafia_lieutenant_role, "brute", "The second lieutenant isn't Brute") // BOUNTY_LIEUTENANT_BRUTE - TEST_ASSERT_EQUAL(first.maxHealth, 350, "Tommy's health is wrong") // BOUNTY_LIEUTENANT_TOMMY_HEALTH - TEST_ASSERT_EQUAL(second.maxHealth, 400, "Brute's health is wrong") // BOUNTY_LIEUTENANT_BRUTE_HEALTH - TEST_ASSERT(istype(first.mafia_gun, /datum/bounty_mafia_gun/tommy), "Tommy has no Tommy gun") - TEST_ASSERT_NULL(second.mafia_gun, "Brute has a gun") - for(var/mob/living/basic/trooper/russian/mafia/lieutenant/lieutenant as anything in list(first, second)) - TEST_ASSERT_EQUAL(lieutenant.damage_coeff[BRUTE], 0.8, "[lieutenant] takes full brute") // BOUNTY_LIEUTENANT_DAMAGE_MOD - TEST_ASSERT_EQUAL(lieutenant.damage_coeff[BURN], 0.8, "[lieutenant] takes full burn") + TEST_ASSERT_EQUAL(first.real_name, "Tommy", "Tommy isn't called Tommy") + TEST_ASSERT_EQUAL(second.real_name, "Brute", "Brute isn't called Brute") + TEST_ASSERT_NOTNULL(locate(/obj/item/gun/ballistic/automatic/tommygun) in first.held_items, "Tommy has no Thompson") + TEST_ASSERT(first.mafia_windup > 0, "Tommy's gun doesn't come up before it fires") + TEST_ASSERT(!second.get_active_held_item() && !second.get_inactive_held_item(), "Brute holds something") + + // Brute's landed punch now and then knocks the hunter off their feet: tg's Knockdown, and only his own punches + var/mob/living/carbon/human/consistent/victim = hunter_at(spot(4, 1)) + second.mafia_punch_knockdown_chance = 100 + var/mob/living/carbon/human/consistent/bystander = hunter_at(spot(4, 3)) + second.mafia_on_punch_landed(victim, bystander, 5, BRUTE, null, 0, FALSE, NONE) + TEST_ASSERT(!victim.IsKnockdown(), "Someone else's punch knocked the hunter down for Brute") + second.mafia_on_punch_landed(victim, second, 5, BRUTE, null, 0, FALSE, NONE) + TEST_ASSERT(victim.IsKnockdown(), "Brute's landed punch didn't knock the hunter down") + TEST_ASSERT(victim.AmountKnockdown() <= 10, "Brute's knockdown lasts more than a second") // BOUNTY_LIEUTENANT_BRUTE_KNOCKDOWN + TEST_ASSERT_EQUAL(second.mafia_melee_behavior(), /datum/ai_behavior/basic_melee_attack/human_npc/bounty_mafia_brute, "Brute's fists don't listen for a landed punch") + + // Their deaths send the ordinary death signal (P10 opens the gate on it), and their bodies stay where they fell + for(var/mob/living/carbon/human/npc/bounty_mafia/lieutenant/lieutenant as anything in list(first, second)) RegisterSignal(lieutenant, COMSIG_LIVING_DEATH, PROC_REF(on_death)) - - // Their deaths send the ordinary death signal (P10 opens the gate on it) first.death() second.death() TEST_ASSERT_EQUAL(deaths, 2, "A lieutenant's death didn't send COMSIG_LIVING_DEATH") - TEST_ASSERT(QDELETED(first) && QDELETED(second), "A lieutenant outlived his death") + TEST_ASSERT(!QDELETED(first) && !QDELETED(second), "A lieutenant's body went with his death") + for(var/obj/item/gun/gun in spot(1, 1)) + TEST_FAIL("Tommy's death dropped [gun]") -// ===== THE ROOM SPAWNER ===== +// ===== THE ROOM SPAWNER: A ROOM'S PEOPLE ARE QUEUED ===== /datum/unit_test/voidcrew_bounty_lair_mafia/zone_mobs @@ -504,44 +662,51 @@ for(var/list/table in list(probe.mobs_green, probe.mobs_yellow, probe.mobs_red)) TEST_ASSERT(length(table), "A mafia zone table is empty") for(var/entry in table) - TEST_ASSERT(ispath(entry, /mob/living/basic/trooper/russian/mafia), "[entry] isn't a club goon") - TEST_ASSERT(!ispath(entry, /mob/living/basic/trooper/russian/mafia/lieutenant), "[entry] is a lieutenant, which only the gate has") - TEST_ASSERT(!ispath(entry, /mob/living/basic/boss), "[entry] is a megafauna") + TEST_ASSERT(ispath(entry, /mob/living/carbon/human/npc/bounty_mafia), "[entry] isn't one of the club's people") + TEST_ASSERT(!ispath(entry, /mob/living/carbon/human/npc/bounty_mafia/lieutenant), "[entry] is a lieutenant, which only the gate has") + TEST_ASSERT(!ispath(entry, /mob/living/carbon/human/npc/bounty_mafia/don), "[entry] is the don") for(var/list/count_range in list(probe.count_green, probe.count_yellow, probe.count_red)) TEST_ASSERT(count_range[1] == 1 && count_range[2] == 2, "A mafia marker spawns outside 1-2 goons") // P11's rooms get their own crews var/list/casino = bounty_mafia_room_crew("/area/ruin/space/has_grav/powered/mafia_club/casino") TEST_ASSERT_NOTNULL(casino, "The casino has no crew") - TEST_ASSERT_EQUAL(casino[/mob/living/basic/trooper/russian/mafia/pistol], 2, "The casino's pistols are wrong") - TEST_ASSERT_EQUAL(casino[/mob/living/basic/trooper/russian/mafia], 2, "The casino's knives are wrong") - TEST_ASSERT_EQUAL(casino[/mob/living/basic/trooper/russian/mafia/smg], 1, "The casino's SMGs are wrong") + TEST_ASSERT_EQUAL(casino[/mob/living/carbon/human/npc/bounty_mafia/pistol], 2, "The casino's pistols are wrong") + TEST_ASSERT_EQUAL(casino[/mob/living/carbon/human/npc/bounty_mafia], 2, "The casino's knives are wrong") + TEST_ASSERT_EQUAL(casino[/mob/living/carbon/human/npc/bounty_mafia/smg], 1, "The casino's SMGs are wrong") var/list/office = bounty_mafia_room_crew("/area/ruin/space/has_grav/powered/mafia_club/back_office") TEST_ASSERT_EQUAL(length(office), 1, "The back office's crew is wrong") TEST_ASSERT_NULL(bounty_mafia_room_crew("/area/ruin/space/has_grav/powered/mafia_club/garage"), "The arena gets goons") TEST_ASSERT_NULL(bounty_mafia_room_crew(/area/misc/testroom), "A room outside the club gets a club crew") - // Anywhere else, the zone table: 1-2 goons, all on its own floor + // Anywhere else, the zone table: 1-2 goons, queued (never built in the marker's tick), then on its own floor probe.forceMove(spot(2, 2)) - probe.do_spawn(2) // ZONE_YELLOW - var/count = 0 var/area/room = get_area(probe) - for(var/mob/living/basic/trooper/russian/mafia/goon in range(4, probe)) + var/list/orders = probe.do_spawn(2) // ZONE_YELLOW + TEST_ASSERT(length(orders) >= 1 && length(orders) <= 2, "The marker queued [length(orders)] goons, not 1-2") + for(var/datum/human_npc_order/order as anything in orders) + TEST_ASSERT(!order.done && isnull(order.spawned_ref), "The marker built a goon at once instead of queueing it") + TEST_ASSERT(order in SShuman_npcs.queue, "A goon's order isn't in the queue") + for(var/mob/living/carbon/human/npc/bounty_mafia/early in range(4, probe)) + TEST_FAIL("[early] was built in the marker's own tick") + for(var/datum/human_npc_order/order as anything in orders) + var/mob/living/carbon/human/npc/bounty_mafia/goon = order.fulfil() + TEST_ASSERT(istype(goon, /mob/living/carbon/human/npc/bounty_mafia), "A queued goon built [goon || "nothing"]") + if(!goon) + continue allocated += goon - count++ - TEST_ASSERT(!istype(goon, /mob/living/basic/trooper/russian/mafia/lieutenant), "The marker spawned a lieutenant") + goon.ai_controller?.set_ai_status(AI_STATUS_OFF) + TEST_ASSERT(!istype(goon, /mob/living/carbon/human/npc/bounty_mafia/lieutenant), "The marker spawned a lieutenant") TEST_ASSERT_EQUAL(get_area(goon), room, "A goon spawned outside the marker's room") - TEST_ASSERT(count >= 1 && count <= 2, "The marker spawned [count] goons, not 1-2") + TEST_ASSERT_EQUAL(goon.mafia_home_ref?.resolve(), room, "A queued goon didn't take its room as home") qdel(probe) -// ===== GOONS: THE SHOUT, THE DOORWAY, THE DOWNED, NO GUNS ===== +// ===== GOONS: THE SHOUT, THE DOORWAY, THE DOWNED, HOLDS AND CUFFS, COVER, BODIES ===== /datum/unit_test/voidcrew_bounty_lair_mafia/goons /datum/unit_test/voidcrew_bounty_lair_mafia/goons/Run() - var/mob/living/basic/trooper/russian/mafia/pistol/gunman = allocate(/mob/living/basic/trooper/russian/mafia/pistol, spot(0, 0)) - TEST_ASSERT_EQUAL(gunman.maxHealth, 120, "The gunman's health is wrong") // BOUNTY_MOBSTER_PISTOL_HEALTH - TEST_ASSERT(gunman.speed < 1.5, "The gunman can't keep up with a running player") + var/mob/living/carbon/human/npc/bounty_mafia/pistol/gunman = member_at(/mob/living/carbon/human/npc/bounty_mafia/pistol, spot(0, 0)) var/mob/living/carbon/human/consistent/hunter = hunter_at(spot(4, 0), as_client = TRUE) TEST_ASSERT(!gunman.mafia_is_ready(), "The gunman is ready before seeing anyone") @@ -550,23 +715,25 @@ var/datum/bounty_mafia_room/room = gunman.mafia_room() TEST_ASSERT(room?.alerted, "Spotting a hunter didn't alert the room") TEST_ASSERT(gunman.mafia_ready_at >= world.time + 5, "The shout gives less than half a second") // BOUNTY_MOBSTER_ALERT - TEST_ASSERT(!gunman.mafia_attack(hunter), "The gunman shot before his shout was over") + TEST_ASSERT(!gunman.mafia_is_ready(), "The gunman may shoot before his shout is over") gunman.mafia_ready_at = world.time - TEST_ASSERT(gunman.mafia_attack(hunter), "The gunman didn't shoot after his shout") - TEST_ASSERT(!gunman.mafia_gun.ready(), "The pistol has no cooldown") - clear_room() + TEST_ASSERT(gunman.mafia_is_ready(), "The gunman may not shoot after his shout") + TEST_ASSERT(gunman.mafia_plan_attack(gunman.ai_controller, hunter), "The gunman with a line had nothing to do") + TEST_ASSERT(gunman.ai_controller.current_behaviors[GET_AI_BEHAVIOR(/datum/ai_behavior/bounty_mafia_fire)], "The gunman with a line didn't open fire") + gunman.ai_controller.CancelActions() - // Never the downed + // Never the downed: a hunter in crit is nobody's target, however close (CB-11: only the choice spares them) // Suffocation, not brute: brute lands on one random limb, which caps it hunter.adjustOxyLoss(150) TEST_ASSERT(hunter.stat != CONSCIOUS, "The hunter didn't go down") TEST_ASSERT(!gunman.mafia_target_ok(hunter), "A goon may go after a downed hunter") + TEST_ASSERT_NULL(gunman.mafia_find_target(), "A goon picked a downed hunter as its target") hunter.fully_heal(HEAL_ALL) TEST_ASSERT(gunman.mafia_target_ok(hunter), "The healed hunter isn't fair game again") // At most two of a room on one hunter in a doorway - var/mob/living/basic/trooper/russian/mafia/pistol/second = allocate(/mob/living/basic/trooper/russian/mafia/pistol, spot(0, 1)) - var/mob/living/basic/trooper/russian/mafia/pistol/third = allocate(/mob/living/basic/trooper/russian/mafia/pistol, spot(0, 2)) + var/mob/living/carbon/human/npc/bounty_mafia/pistol/second = member_at(/mob/living/carbon/human/npc/bounty_mafia/pistol, spot(0, 1)) + var/mob/living/carbon/human/npc/bounty_mafia/pistol/third = member_at(/mob/living/carbon/human/npc/bounty_mafia/pistol, spot(0, 2)) gunman.ai_controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) second.ai_controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) TEST_ASSERT(third.mafia_room_has_space(hunter), "The doorway cap applies to a hunter out in the open") @@ -574,7 +741,7 @@ TEST_ASSERT(third.mafia_in_doorway(hunter), "A hunter on a door tile isn't in a doorway") TEST_ASSERT(!third.mafia_room_has_space(hunter), "A third goon went after a hunter in a doorway") // Shooting the held-back goon doesn't pull it in over the cap - third.mafia_on_attacked(null, hunter, 4) // ATTACKER_DAMAGING_ATTACK + SEND_SIGNAL(third, COMSIG_ATOM_WAS_ATTACKED, hunter, 4) // ATTACKER_DAMAGING_ATTACK TEST_ASSERT(third.ai_controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] != hunter, "Shooting a held-back goon took it past the doorway cap") // And a third goon that somehow has them drops them third.ai_controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) @@ -586,29 +753,43 @@ TEST_ASSERT(SEND_SIGNAL(second, COMSIG_LIVING_PRE_WABBAJACKED, "random") & STOP_WABBAJACK, "A goon can be polymorphed") TEST_ASSERT(SEND_SIGNAL(second, COMSIG_PRE_MOB_CHANGED_TYPE) & COMPONENT_BLOCK_MOB_CHANGE, "A goon's type can be changed") - // A grabbed goon fights back: its grabber is its target, and it breaks free + // A grabbed goon fights back: its grabber is its target at once, and its AI resists the hold the tg way + var/datum/ai_planning_subtree/bounty_escape_captivity/bounty_mafia/break_free = new var/datum/ai_planning_subtree/bounty_mafia_goon/mind = new - var/mob/living/basic/trooper/russian/mafia/knife = allocate(/mob/living/basic/trooper/russian/mafia, spot(3, 3)) + var/mob/living/carbon/human/npc/bounty_mafia/knife = member_at(/mob/living/carbon/human/npc/bounty_mafia, spot(3, 3)) var/mob/living/carbon/human/consistent/grabber = hunter_at(spot(4, 3)) grabber.start_pulling(knife) TEST_ASSERT_EQUAL(knife.pulledby, grabber, "The test hunter couldn't grab the goon") - mind.SelectBehaviors(knife.ai_controller, 0.5) TEST_ASSERT_EQUAL(knife.ai_controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET], grabber, "A grabbed goon didn't turn on its grabber") + TEST_ASSERT_EQUAL(break_free.SelectBehaviors(knife.ai_controller, 0.5), SUBTREE_RETURN_FINISH_PLANNING, "A grabbed goon didn't put breaking free first") TEST_ASSERT(knife.ai_controller.current_behaviors[GET_AI_BEHAVIOR(/datum/ai_behavior/resist)], "A grabbed goon didn't try to break free") - grabber.stop_pulling() knife.ai_controller.CancelActions() + // Dragged, it goes: nothing holds it in its room while someone else moves it + TEST_ASSERT(knife.mafia_leash_allows(spot(4, 4)), "A dragged goon's room held it") + grabber.stop_pulling() // Dragged out of its room, it still fights whoever it can reach, and only walks back once they're gone knife.mafia_ready_at = world.time knife.mafia_home_ref = WEAKREF(GLOB.areas_by_type[/area/space]) TEST_ASSERT(!knife.mafia_at_home(), "The goon isn't out of its room") mind.SelectBehaviors(knife.ai_controller, 0.5) - TEST_ASSERT(knife.ai_controller.current_behaviors[GET_AI_BEHAVIOR(/datum/ai_behavior/bounty_mafia_goon_attack)], "A goon out of its room didn't fight the hunter next to it") + TEST_ASSERT(knife.ai_controller.current_behaviors[GET_AI_BEHAVIOR(/datum/ai_behavior/basic_melee_attack/human_npc)], "A goon out of its room didn't fight the hunter next to it") knife.ai_controller.CancelActions() knife.mafia_home_ref = WEAKREF(get_area(knife)) + // Someone starting to cuff a goon who can still move: it turns on them and steps away, a real step; paralysed, it can't + TEST_ASSERT(!(SEND_SIGNAL(knife, COMSIG_CARBON_CUFF_ATTEMPTED, grabber) & COMSIG_CARBON_CUFF_PREVENT), "A goon refused the cuffs outright") + TEST_ASSERT_EQUAL(knife.ai_controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET], grabber, "A goon didn't turn on the hunter cuffing it") + var/turf/cuffed_at = get_turf(knife) + TEST_ASSERT(knife.mafia_dodge_cuffs(WEAKREF(grabber)), "A free goon didn't step away from the cuffs") + TEST_ASSERT(get_turf(knife) != cuffed_at, "The goon's step away from the cuffs went nowhere") + knife.forceMove(cuffed_at) + knife.Paralyze(10 SECONDS) + TEST_ASSERT(!knife.mafia_dodge_cuffs(WEAKREF(grabber)), "A paralysed goon stepped away from the cuffs") + knife.SetParalyzed(0) + // A gunman in an alerted room kicks a table over, on its side toward the hunter - var/mob/living/basic/trooper/russian/mafia/pistol/fourth = allocate(/mob/living/basic/trooper/russian/mafia/pistol, spot(1, 4)) + var/mob/living/carbon/human/npc/bounty_mafia/pistol/fourth = member_at(/mob/living/carbon/human/npc/bounty_mafia/pistol, spot(1, 4)) var/obj/structure/table/wood/table = allocate(/obj/structure/table/wood, spot(2, 4)) var/mob/living/carbon/human/consistent/across = hunter_at(spot(4, 4)) TEST_ASSERT_EQUAL(fourth.mafia_take_cover(across), table, "A gunman didn't take the table beside him for cover") @@ -624,19 +805,17 @@ TEST_ASSERT_EQUAL(knife.mafia_exit_toward(hunter), get_turf(exit_door), "A goon doesn't know its room's door") clear_room() - // They leave no gun behind: the corpse wears club clothes, and that's all - for(var/goon_type in list(/mob/living/basic/trooper/russian/mafia, /mob/living/basic/trooper/russian/mafia/pistol, /mob/living/basic/trooper/russian/mafia/smg, /mob/living/basic/trooper/russian/mafia/lieutenant/tommy)) + // They die in place in their club clothes, and their guns stay locked on them: none lies on the floor + for(var/goon_type in list(/mob/living/carbon/human/npc/bounty_mafia, /mob/living/carbon/human/npc/bounty_mafia/pistol, /mob/living/carbon/human/npc/bounty_mafia/smg, /mob/living/carbon/human/npc/bounty_mafia/lieutenant/tommy)) var/turf/where = spot(2, 3) - var/mob/living/basic/trooper/russian/mafia/goon = allocate(goon_type, where) + var/mob/living/carbon/human/npc/bounty_mafia/goon = member_at(goon_type, where) goon.death() - TEST_ASSERT(QDELETED(goon), "[goon_type] outlived its death") - var/mob/living/carbon/human/corpse = locate() in where - TEST_ASSERT_NOTNULL(corpse, "[goon_type] left no corpse") - TEST_ASSERT_NOTNULL(corpse.w_uniform, "[goon_type]'s corpse isn't dressed") + TEST_ASSERT(!QDELETED(goon), "[goon_type]'s body went with its death") + TEST_ASSERT_EQUAL(get_turf(goon), where, "[goon_type]'s body moved when it died") + TEST_ASSERT_NOTNULL(goon.w_uniform, "[goon_type]'s body isn't dressed") for(var/obj/item/gun/gun in where) TEST_FAIL("[goon_type] dropped [gun]") - for(var/obj/item/gun/gun in corpse.get_all_contents()) - TEST_FAIL("[goon_type]'s corpse has [gun]") + qdel(goon) clear_room() // ===== THE RING, THE REAL WAY: THROUGH P10'S LAIR AND ITS TROPHY CALL ===== @@ -709,13 +888,15 @@ TEST_ASSERT(abs(keeper.maxHealth - 115) < 0.001, "Lair gatekeeper used the ordinary profile") TEST_ASSERT_EQUAL(mech.posting_ref?.resolve(), posting, "The mech isn't wanted on the lair's bounty") - // The mech breaks: the lair takes the don on as he climbs out, and the fight goes on past its grace + // The mech breaks: the lair takes the don, a person, on as he climbs out, and the fight goes on past its grace var/turf/wreck_spot = get_turf(mech) mech.death() - var/mob/living/basic/bounty_lair_boss/mafia_don/don = locate() in range(1, wreck_spot) + var/mob/living/carbon/human/npc/bounty_mafia/don/don = locate() in range(1, wreck_spot) TEST_ASSERT_NOTNULL(don, "The don didn't climb out") allocated += don + don.ai_controller?.set_ai_status(AI_STATUS_OFF) TEST_ASSERT(don.weak_reference && (don.weak_reference in fake_lair.lair_bosses), "The lair didn't take on the don") + TEST_ASSERT_EQUAL(bounty_kill_posting_of(don), posting, "The don on foot isn't wanted on the lair's bounty") sleep(6 SECONDS) // BOUNTY_LAIR_TROPHY_GRACE 5 seconds TEST_ASSERT(!fake_lair.lair_boss_killed, "The lair called the fight over with the don standing") TEST_ASSERT_NULL(posting.board_proof(), "A trophy dropped with the don standing") @@ -727,7 +908,11 @@ sleep(6 SECONDS) // BOUNTY_LAIR_TROPHY_GRACE 5 seconds TEST_ASSERT(fake_lair.lair_boss_killed, "The lair didn't call the fight over after the don died") TEST_ASSERT_EQUAL(posting.board_proof(), ring, "The bounty's proof changed after the don died") + // Brought back and killed again, nothing more drops + don.revive(HEAL_ALL) + don.death() var/rings = 0 for(var/obj/item/bounty_proof/trophy/trophy in range(6, origin)) rings++ TEST_ASSERT_EQUAL(rings, 1, "The kill left [rings] trophies, not one") + TEST_ASSERT_EQUAL(posting.board_proof(), ring, "A second death changed the bounty's proof") diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_lair_maps.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_lair_maps.dm index 22619b20d03..c89eb9c0c7a 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_lair_maps.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_lair_maps.dm @@ -15,6 +15,17 @@ var/datum/turf_reservation/reserve /datum/unit_test/voidcrew_bounty_lair_maps/Destroy() + // The club's markers queue its people (spawn_human_npc()): none of them is built into the block once it's given back + if(reserve) + var/list/block_turfs = list() + for(var/turf/tile as anything in reserve.reserved_turfs) + block_turfs[tile] = TRUE + for(var/datum/human_npc_order/order as anything in SShuman_npcs.queue.Copy()) + if(block_turfs[order.where]) + qdel(order) + for(var/turf/tile as anything in reserve.reserved_turfs) + for(var/mob/living/carbon/human/npc/bounty_mafia/member in tile) + qdel(member) QDEL_NULL(reserve) return ..() @@ -84,7 +95,7 @@ // The gatekeepers: two lieutenants, outside the garage TEST_ASSERT_EQUAL(length(gatekeepers), 2, "The club should hold two gatekeeper landmarks") for(var/obj/effect/landmark/bounty_lair_gatekeeper/keeper as anything in gatekeepers) - TEST_ASSERT_EQUAL(keeper.gatekeeper_type, /mob/living/basic/trooper/russian/mafia/lieutenant, "A gatekeeper landmark is not set to the lieutenant") + TEST_ASSERT_EQUAL(keeper.gatekeeper_type, /mob/living/carbon/human/npc/bounty_mafia/lieutenant, "A gatekeeper landmark is not set to the lieutenant") TEST_ASSERT(istype(get_area(keeper), /area/ruin/space/has_grav/powered/mafia_club/back_office), "A gatekeeper landmark is not in the back office, in front of the garage door") // The garage door: three closed, indestructible blast doors, the club's only poddoors diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_lairs.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_lairs.dm index cce14cf88e3..c85a9988ffe 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_lairs.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_lairs.dm @@ -82,6 +82,20 @@ lair.loaded = TRUE return lair +/** + * Calls off every person still queued to be built inside `footprint` (spawn_human_npc()), and deletes the club's people + * already built there: a lair the test tears down must not have bodies built into it afterwards. + */ +/datum/unit_test/voidcrew_bounty_lairs/proc/test_clear_people(datum/map_footprint/footprint) + if(!footprint) + return + for(var/datum/human_npc_order/order as anything in SShuman_npcs.queue.Copy()) + if(order.where && footprint.contains_turf(order.where)) + qdel(order) + for(var/mob/living/carbon/human/npc/bounty_mafia/member as anything in GLOB.mob_living_list) + if(istype(member) && footprint.contains_turf(get_turf(member))) + qdel(member) + /// Sends the load signal to `lair` and waits for it to finish linking /datum/unit_test/voidcrew_bounty_lairs/proc/test_link(obj/structure/overmap/space_ruin/bounty_lair/lair) SEND_SIGNAL(lair, "voidcrew_planet_loaded", TRUE) // COMSIG_VOIDCREW_PLANET_LOADED @@ -101,10 +115,10 @@ var/obj/structure/overmap/ship/ship = board_test_ship() var/datum/criminal_bounty/kill_only/posting = test_posting(5000, 3) - // Dead or nothing: no capture state pays + // Dead or nothing: no capture state pays, the state read at the pad being the only thing it looks at for(var/state in list("restrained", "stunned", "downed", "free")) // BOUNTY_STATE_* - TEST_ASSERT_EQUAL(posting.board_share_for(state, state), 0, "A kill-only bounty pays for a [state] boss") - TEST_ASSERT_EQUAL(posting.board_share_for("dead", "dead"), 100, "A kill-only bounty doesn't pay in full on the kill") // BOUNTY_STATE_DEAD + TEST_ASSERT_EQUAL(posting.board_share_for(state), 0, "A kill-only bounty pays for a [state] boss") + TEST_ASSERT_EQUAL(posting.board_share_for("dead"), 100, "A kill-only bounty doesn't pay in full on the kill") // BOUNTY_STATE_DEAD // The card says wanted dead, with the full value as its one figure; the warrant says WANTED: DEAD var/list/card = posting.board_ui_entry(ship, pad) @@ -123,6 +137,16 @@ var/list/preview = posting.board_pad_preview(ship, pad) TEST_ASSERT(!preview[1], "The card offers to turn in a body") + // Nor the don on foot, a person: wanted on it, cuffed on the pad or dead on it, he is never what pays + var/mob/living/carbon/human/npc/bounty_mafia/don/person = allocate(/mob/living/carbon/human/npc/bounty_mafia/don, pad_turf) + person.ai_controller?.set_ai_status(AI_STATUS_OFF) + person.posting_ref = WEAKREF(posting) + TEST_ASSERT_EQUAL(bounty_kill_posting_of(person), posting, "The don on foot isn't wanted on his bounty") + var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs) + TEST_ASSERT(person.equip_to_slot_if_possible(cuffs, ITEM_SLOT_HANDCUFFED), "Test fixture: the don could not be cuffed") + TEST_ASSERT(istext(posting.board_target_refusal(pad, found)), "The pad took the don cuffed on it") + qdel(person) + // The trophy drops where the boss fell, bound to the bounty, and there is only ever one var/obj/item/bounty_proof/trophy/trophy = posting.kill_drop_trophy(aside) TEST_ASSERT_NOTNULL(trophy, "The kill dropped no trophy") @@ -373,6 +397,55 @@ TEST_ASSERT(!lair.mission_locked, "Closing the bounty didn't unlock its lair") TEST_ASSERT_NULL(lair.posting_ref, "The released lair still points at its bounty") +/** + * Gatekeepers that are people are queued, never built in one tick: until each is built it holds the gate, once built + * it is watched like any gatekeeper, and an order that never builds a body (cancelled) stops holding it. + */ +/datum/unit_test/voidcrew_bounty_lairs/queued_gatekeepers + +/datum/unit_test/voidcrew_bounty_lairs/queued_gatekeepers/Run() + var/turf/origin = run_loc_floor_bottom_left + var/datum/criminal_bounty/kill_only/lair/posting = test_posting(5000, 3, /datum/criminal_bounty/kill_only/lair) + var/obj/structure/overmap/space_ruin/bounty_lair/lair = test_fake_lair(posting, 3) + for(var/offset in 0 to 1) + var/obj/effect/landmark/bounty_lair_gatekeeper/keeper_mark = new(locate(origin.x + offset, origin.y + 2, origin.z)) + keeper_mark.gatekeeper_type = /mob/living/carbon/human/npc/bounty_mafia/lieutenant + lair_test_made += keeper_mark + var/obj/machinery/door/poddoor/gate = allocate(/obj/machinery/door/poddoor, locate(origin.x + 2, origin.y, origin.z)) + gate.id = "bounty_lair_gate" // BOUNTY_LAIR_GATE_ID + + TEST_ASSERT(test_link(lair), "The lair never finished linking") + TEST_ASSERT_EQUAL(length(lair.lair_gatekeepers), 0, "A gatekeeper who is a person was built at the link, not queued") + TEST_ASSERT_EQUAL(lair.lair_pending_gatekeeper_count(), 2, "The two queued gatekeepers aren't on their way") + TEST_ASSERT(!lair.lair_gate_open, "The gate opened while its gatekeepers were still on their way") + TEST_ASSERT(!lair.lair_check_gate(), "The gate opened on a check while its gatekeepers were still on their way") + + // The first is built: it holds the gate, kept to its room, and its order is done + var/list/keys = lair.lair_pending_gatekeepers.Copy() + var/datum/human_npc_order/first_order = lair.lair_pending_gatekeepers[keys[1]] + var/datum/human_npc_order/second_order = lair.lair_pending_gatekeepers[keys[2]] + var/mob/living/carbon/human/npc/bounty_mafia/lieutenant/keeper = first_order.fulfil() + TEST_ASSERT(istype(keeper), "The queued gatekeeper built [keeper || "nothing"]") + allocated += keeper + keeper.ai_controller?.set_ai_status(AI_STATUS_OFF) + TEST_ASSERT(keeper.weak_reference && (keeper.weak_reference in lair.lair_gatekeepers), "The built gatekeeper isn't watched") + TEST_ASSERT_EQUAL(lair.lair_pending_gatekeeper_count(), 1, "The built gatekeeper is still counted as on its way") + + // The second is called off: it stops holding the gate, but the first still does + qdel(second_order) + TEST_ASSERT(!lair.lair_check_gate(), "The gate opened with its built gatekeeper standing") + TEST_ASSERT_EQUAL(lair.lair_pending_gatekeeper_count(), 0, "A cancelled gatekeeper is still counted as on its way") + + // The built one dies in place: the gate opens + keeper.death() + TEST_ASSERT(lair.lair_gate_open, "The gate didn't open when the last gatekeeper died") + TEST_ASSERT(!QDELETED(keeper), "The dead gatekeeper's body went") + + // Gone (faked footprint dropped first: it holds no slot) + lair.footprint = null + lair.loaded = FALSE + posting.close("admin") // BOUNTY_CLOSE_ADMIN + /// The boss's next phase takes over from it; a boss deleted alive (an admin) ends the bounty instead of paying out /datum/unit_test/voidcrew_bounty_lairs/phases @@ -458,6 +531,26 @@ var/deadline = world.time + 5 SECONDS UNTIL(!goon.throwing || world.time >= deadline) TEST_ASSERT(get_area(goon) != leash_test_home, "A thrown mob was held in its room") + goon.forceMove(locate(origin.x + 1, origin.y + 3, origin.z)) + + // Buckled to something someone moves (a wheeled chair, a carrier's shoulders), it goes with it + var/mob/living/carbon/human/consistent/seated = allocate(/mob/living/carbon/human/consistent, home_spot) + seated.AddElement(/datum/element/bounty_lair_room_leash, leash_test_home.type) + var/obj/structure/chair/office/chair = allocate(/obj/structure/chair/office, home_spot) + TEST_ASSERT(chair.buckle_mob(seated, force = TRUE), "Test fixture: the leashed person couldn't be buckled") + chair.Move(door_spot, EAST) + TEST_ASSERT_EQUAL(get_turf(seated), door_spot, "A leashed person buckled to a chair held the chair in their room") + chair.unbuckle_mob(seated) + seated.forceMove(locate(origin.x + 2, origin.y + 3, origin.z)) + qdel(chair) + + // Shoved out of its room, it goes: the push is the shover's move (a leash that held it would knock it down instead) + var/mob/living/carbon/human/consistent/shoved = allocate(/mob/living/carbon/human/consistent, home_spot) + shoved.AddElement(/datum/element/bounty_lair_room_leash, leash_test_home.type) + var/mob/living/carbon/human/consistent/shover = allocate(/mob/living/carbon/human/consistent, locate(origin.x, origin.y + 1, origin.z)) + shover.disarm(shoved) + TEST_ASSERT_EQUAL(get_turf(shoved), door_spot, "A shove couldn't push a leashed person out of their room") + TEST_ASSERT(!shoved.IsKnockdown(), "A shove at a room's door knocked a leashed person down as if into a wall") /// Where a trophy lands: on the floor it fell on, the nearest floor reached past a hole, and never in space or outside its lair /datum/unit_test/voidcrew_bounty_lairs/trophy_spot @@ -512,7 +605,14 @@ sleep(1) TEST_ASSERT_EQUAL(test_count(/mob/living/basic/bounty_lair_boss/mafia_mech, lair.footprint), 1, "Loading the club again spawned a second mech") - // The gate: two lieutenants, three closed doors that open when both are dead + // The gate: two lieutenants, queued as people (never built in one tick), holding it from the start; three closed + // doors that open when both are dead + TEST_ASSERT(!lair.lair_gate_open, "The garage opened before its lieutenants were built") + TEST_ASSERT_EQUAL(length(lair.lair_gatekeepers) + lair.lair_pending_gatekeeper_count(), 2, "Club Volga should have two gatekeepers, built or on their way") + for(var/key in lair.lair_pending_gatekeepers.Copy()) + var/datum/human_npc_order/order = lair.lair_pending_gatekeepers[key] + order?.fulfil() + TEST_ASSERT_EQUAL(lair.lair_pending_gatekeeper_count(), 0, "A lieutenant is still on its way after its order was built") TEST_ASSERT_EQUAL(length(lair.lair_gatekeepers), 2, "Club Volga should have two gatekeepers") TEST_ASSERT_EQUAL(length(lair.lair_gate_doors), 3, "Club Volga's gate should be three doors") var/list/gate_doors = list() @@ -526,11 +626,16 @@ keeper.ai_controller?.set_ai_status(AI_STATUS_OFF) keepers += keeper var/mob/living/first_keeper = keepers[1] - TEST_ASSERT(istype(first_keeper, /mob/living/basic/trooper/russian/mafia/lieutenant), "The gatekeepers aren't the lieutenants") + var/mob/living/second_keeper = keepers[2] + TEST_ASSERT(istype(first_keeper, /mob/living/carbon/human/npc/bounty_mafia/lieutenant), "The gatekeepers aren't the lieutenants") TEST_ASSERT(istype(get_area(first_keeper), /area/ruin/space/has_grav/powered/mafia_club/back_office), "A lieutenant isn't in the back office") + var/list/roles = list() + for(var/mob/living/carbon/human/npc/bounty_mafia/lieutenant/lieutenant as anything in keepers) + roles |= lieutenant.mafia_lieutenant_role + TEST_ASSERT(("tommy" in roles) && ("brute" in roles), "The gate isn't held by one Tommy and one Brute") // BOUNTY_LIEUTENANT_TOMMY, _BRUTE first_keeper.death() TEST_ASSERT(!lair.lair_gate_open, "The garage opened with a lieutenant still standing") - var/mob/living/second_keeper = keepers[2] + TEST_ASSERT(!QDELETED(first_keeper), "A dead lieutenant's body went") second_keeper.death() TEST_ASSERT(lair.lair_gate_open, "The garage didn't open when both lieutenants died") sleep(3 SECONDS) @@ -539,6 +644,7 @@ // Closed: torn down once empty, and nothing replaces it (a rare ruin never respawns) TEST_ASSERT(lair.rare, "The club is not rare, so tearing it down would spawn a replacement") + test_clear_people(lair.footprint) posting.close("admin") // BOUNTY_CLOSE_ADMIN deadline = world.time + 2 MINUTES UNTIL(QDELETED(lair) || world.time >= deadline) diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_outpost.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_outpost.dm index eae403b3226..562af32cb1c 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_outpost.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_outpost.dm @@ -4,17 +4,31 @@ * Owner: P6 outposts. Do not edit this file outside that package. Fork defines are included after * the tests, so a test uses the literal value with a comment naming the define. * - * The tests make a trader outpost out of the test room (its hangar lift in the top right corner) - * and drive the procs directly. They pin what the other packages give back where it matters (a - * test fugitive that records being confronted, a test posting that records being relisted). + * The fugitive and its decoys are real human NPCs. The tests make a trader outpost out of the test room + * (its hangar lift in the top right corner) and drive the procs directly. They pin what the other + * packages give back where it matters (a test fugitive that records being confronted, a test posting + * that records being relisted). Nothing here sleeps while someone is leaving: the human NPC + * subsystem sweeps leavers on its own every second, and a test that wants a sweep makes it itself. */ +/// What a fugitive wears before it changes into the zone's clothes: armour, a helmet, a mask, gloves, +/// boots, and a medipen in a pocket +/datum/outfit/bounty_outpost_test_criminal + name = "Outpost test criminal" + uniform = /obj/item/clothing/under/color/black + suit = /obj/item/clothing/suit/armor/vest + head = /obj/item/clothing/head/helmet + mask = /obj/item/clothing/mask/surgical + gloves = /obj/item/clothing/gloves/color/black + shoes = /obj/item/clothing/shoes/jackboots + l_pocket = /obj/item/reagent_containers/hypospray/medipen + /// A fugitive that remembers who confronted it -/mob/living/basic/bounty_criminal/meek/outpost_test +/mob/living/carbon/human/npc/bounty_criminal/meek/outpost_test /// Whoever on_confronted() was last called with var/confronted_by -/mob/living/basic/bounty_criminal/meek/outpost_test/on_confronted(mob/user) +/mob/living/carbon/human/npc/bounty_criminal/meek/outpost_test/on_confronted(mob/user) confronted_by = user return ..() @@ -37,6 +51,10 @@ var/list/outpost_test_minds = list() /datum/unit_test/voidcrew_bounty_outpost/Destroy() + // The decoys come out of the spawn queue, not out of allocate(): they go with their posting + for(var/datum/criminal_bounty/posting in allocated) + for(var/mob/living/decoy as anything in posting.outpost_forget_decoys()) + qdel(decoy) GLOB.criminal_bounties -= allocated // A mind or a team left pointing at an allocated ship would keep it from being deleted for(var/datum/mind/mind as anything in outpost_test_minds) @@ -58,16 +76,30 @@ new_outpost.lobby_alcove_turfs = list(run_loc_floor_top_right) return new_outpost -/// An open trader-outpost posting at `outpost` with its fugitive standing at `where` -/datum/unit_test/voidcrew_bounty_outpost/proc/make_posting(turf/where, fugitive_type = /mob/living/basic/bounty_criminal/meek/outpost_test) - var/datum/bounty_record/record = generate_bounty_record(1, "meek", "trader_outpost") // BOUNTY_TIER_PETTY, BOUNTY_ARCHETYPE_MEEK, BOUNTY_PLACEMENT_TRADER_OUTPOST +/// A criminal of `fugitive_type` for `record` at `where`, built now in the test criminal's clothes, with the record's face +/datum/unit_test/voidcrew_bounty_outpost/proc/make_fugitive(fugitive_type, turf/where, datum/bounty_record/record) + var/datum/human_npc_order/order = spawn_human_npc(fugitive_type, where || run_loc_floor_bottom_left, look = record, outfit = /datum/outfit/bounty_outpost_test_criminal, name = record.name, immediate = TRUE) + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = order?.spawned_ref?.resolve() + qdel(order) + if(fugitive) + allocated += fugitive + fugitive.record = record + return fugitive + +/// An open trader-outpost posting at `outpost` with its fugitive standing at `where`. `features` and `species`, if given, are the record's instead of rolled ones. +/datum/unit_test/voidcrew_bounty_outpost/proc/make_posting(turf/where, fugitive_type = /mob/living/carbon/human/npc/bounty_criminal/meek/outpost_test, list/features, species) + var/datum/bounty_record/record = generate_bounty_record(1, "meek", "trader_outpost", species) // BOUNTY_TIER_PETTY, BOUNTY_ARCHETYPE_MEEK, BOUNTY_PLACEMENT_TRADER_OUTPOST + if(features) + record.features = features.Copy() var/datum/criminal_bounty/outpost_test/posting = allocate(/datum/criminal_bounty/outpost_test) posting.record = record posting.placement_kind = "trader_outpost" // BOUNTY_PLACEMENT_TRADER_OUTPOST posting.site_ref = WEAKREF(outpost) posting.value = 1234 - var/mob/living/basic/bounty_criminal/fugitive = allocate(fugitive_type, where || run_loc_floor_bottom_left) - fugitive.record = record + // The real board ticks every posting in GLOB.criminal_bounties: with no time left it would close this + // one as expired at its next tick, and its decoys would walk out (and vanish, with no player there) + posting.expires_at = world.time + 1 HOURS + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = make_fugitive(fugitive_type, where, record) fugitive.posting_ref = WEAKREF(posting) posting.criminal_ref = WEAKREF(fugitive) GLOB.criminal_bounties += posting @@ -91,19 +123,38 @@ /datum/unit_test/voidcrew_bounty_outpost/proc/decoys_of(datum/criminal_bounty/posting) . = list() for(var/datum/weakref/decoy_ref as anything in posting.decoys) - var/mob/living/basic/bounty_criminal/decoy/decoy = decoy_ref?.resolve() + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = decoy_ref?.resolve() if(decoy) . += decoy -/// A mob's examine as plain text, with its own feature lines taken out -/datum/unit_test/voidcrew_bounty_outpost/proc/plain_examine(mob/living/basic/bounty_criminal/patron, mob/viewer) +/** + * A mob's examine as plain text without its features: their lines, and the lines for the glasses and + * scarf it wears for its Eyewear and Clothing features (bounty_wear_features()). Features are the + * clues, made to differ between a fugitive and a decoy that doesn't share them; the rest is what the + * game makes the same (AR-C6). An item's line is found by the item's own examine title, as tg's examine + * writes it ("some sunglasses"; "[item]" would read "the sunglasses" and never match). + */ +/datum/unit_test/voidcrew_bounty_outpost/proc/plain_examine(mob/living/carbon/human/npc/bounty_criminal/patron, mob/viewer) var/list/features = list() for(var/line in patron.record?.feature_lines()) features += trim(STRIP_HTML_FULL("[line]", MAX_MESSAGE_LEN)) + var/list/feature_titles = list() + var/list/kinds = patron.record?.features + if(LAZYACCESS(kinds, "glasses") && patron.glasses) // BOUNTY_FEATURE_GLASSES + feature_titles += trim(STRIP_HTML_FULL(patron.glasses.examine_title(viewer), MAX_MESSAGE_LEN)) + if(LAZYACCESS(kinds, "clothing") && patron.wear_neck) // BOUNTY_FEATURE_CLOTHING + feature_titles += trim(STRIP_HTML_FULL(patron.wear_neck.examine_title(viewer), MAX_MESSAGE_LEN)) var/list/lines = list() for(var/line in patron.examine(viewer)) var/plain = trim(STRIP_HTML_FULL("[line]", MAX_MESSAGE_LEN)) - if(!(plain in features)) + if(plain in features) + continue + var/feature_item_line = FALSE + for(var/title in feature_titles) + if(length(title) && findtext(plain, title)) + feature_item_line = TRUE + break + if(!feature_item_line) lines += plain return lines.Join(" | ") @@ -115,14 +166,18 @@ shared++ return shared +/// Whether `walker` is on its way out: tracked as a leaver, with an exit its AI knows (the key is BB_HUMAN_NPC_EXIT) +/datum/unit_test/voidcrew_bounty_outpost/proc/is_leaving(mob/living/carbon/human/npc/walker) + return (walker in SShuman_npcs.leavers) && !isnull(walker.npc_exit) && walker.ai_controller?.blackboard["human_npc_exit"] == walker.npc_exit + /// Setting up: the fugitive blends in, three decoys share one or two of its features, and an outpost takes at most two fugitives and never a mini-boss /datum/unit_test/voidcrew_bounty_outpost/blend /datum/unit_test/voidcrew_bounty_outpost/blend/Run() outpost = make_outpost() var/datum/criminal_bounty/outpost_test/posting = make_posting() - var/mob/living/basic/bounty_criminal/fugitive = posting.criminal() - TEST_ASSERT(posting.setup_outpost_blend(), "A trader-outpost posting could not be set up to blend in") + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = posting.criminal() + TEST_ASSERT(posting.setup_outpost_blend(TRUE), "A trader-outpost posting could not be set up to blend in") TEST_ASSERT(fugitive.blended, "The fugitive is not blending in") var/list/decoys = decoys_of(posting) @@ -133,7 +188,8 @@ TEST_ASSERT(shared >= 1 && shared <= 2, "A decoy was made to share [shared] features, not one or two") if(length(wanted_features)) TEST_ASSERT(shared < length(wanted_features), "A decoy was made to share all [length(wanted_features)] of the fugitive's features") - for(var/mob/living/basic/bounty_criminal/decoy/decoy as anything in decoys) + for(var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy as anything in decoys) + TEST_ASSERT(ishuman(decoy), "A decoy is not a person") TEST_ASSERT(decoy.blended, "A decoy is not blending in") TEST_ASSERT(decoy.record && decoy.record != posting.record, "A decoy has no record of its own") TEST_ASSERT_NULL(decoy.posting_ref, "A decoy is linked to the posting as if it were the criminal") @@ -147,24 +203,51 @@ // At most two fugitives at one outpost, and never a mini-boss (AR-C9) var/datum/criminal_bounty/outpost_test/second = make_posting(run_loc_floor_bottom_left) - TEST_ASSERT(second.setup_outpost_blend(), "A second fugitive was refused at the outpost") + TEST_ASSERT(second.setup_outpost_blend(TRUE), "A second fugitive was refused at the outpost") var/datum/criminal_bounty/outpost_test/third = make_posting(run_loc_floor_bottom_left) - TEST_ASSERT(!third.setup_outpost_blend(), "A third fugitive was let into one outpost") - var/datum/criminal_bounty/outpost_test/boss_posting = make_posting(run_loc_floor_bottom_left, /mob/living/basic/bounty_criminal/boss) + TEST_ASSERT(!third.setup_outpost_blend(TRUE), "A third fugitive was let into one outpost") + var/datum/criminal_bounty/outpost_test/boss_posting = make_posting(run_loc_floor_bottom_left, /mob/living/carbon/human/npc/bounty_criminal/boss) boss_posting.record.archetype = "boss" // BOUNTY_ARCHETYPE_BOSS second.status = "closed" // BOUNTY_POSTING_CLOSED: the outpost has room again - TEST_ASSERT(!boss_posting.setup_outpost_blend(), "A mini-boss was set up at a trader outpost") - TEST_ASSERT(third.setup_outpost_blend(), "A closed posting still counted against the outpost's fugitives") + TEST_ASSERT(!boss_posting.setup_outpost_blend(TRUE), "A mini-boss was set up at a trader outpost") + TEST_ASSERT(third.setup_outpost_blend(TRUE), "A closed posting still counted against the outpost's fugitives") // A record whose mugshot is already out keeps the face everyone has seen (M3) var/datum/criminal_bounty/outpost_test/published = make_posting(run_loc_floor_bottom_left) third.status = "closed" // BOUNTY_POSTING_CLOSED published.record.old_look = null published.record.mugshot = "published" - TEST_ASSERT(published.setup_outpost_blend(), "A relisted posting could not be set up") + TEST_ASSERT(published.setup_outpost_blend(TRUE), "A relisted posting could not be set up") TEST_ASSERT_NULL(published.record.old_look, "A published face was given an invented past") TEST_ASSERT_EQUAL(published.record.mugshot, "published", "A published mugshot was thrown away") +/// Decoys are human NPCs, so they come out of the spawn queue: the posting counts them while they wait, a closed posting cancels the ones not built, and the ones built join it +/datum/unit_test/voidcrew_bounty_outpost/queue + +/datum/unit_test/voidcrew_bounty_outpost/queue/Run() + outpost = make_outpost() + var/datum/criminal_bounty/outpost_test/posting = make_posting() + TEST_ASSERT(posting.setup_outpost_blend(), "A trader-outpost posting could not be set up to blend in") + TEST_ASSERT_EQUAL(length(posting.outpost_decoy_orders), 3, "The decoys were not put in the spawn queue") // BOUNTY_DECOY_COUNT + TEST_ASSERT_EQUAL(length(decoys_of(posting)), 0, "The decoys were built at once, not queued") + SShuman_npcs.process_spawns(10) + var/list/decoys = decoys_of(posting) + TEST_ASSERT_EQUAL(length(decoys), 3, "The queued decoys did not join the posting once built") + for(var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy as anything in decoys) + TEST_ASSERT(decoy.blended, "A queued decoy is not blending in") + TEST_ASSERT_EQUAL(decoy.name, bounty_outpost_display_name(outpost), "A queued decoy does not go by the outpost's name for its crowd") + + // Closed before they are built: nobody is built + var/datum/criminal_bounty/outpost_test/closing = make_posting(run_loc_floor_bottom_left) + TEST_ASSERT(closing.setup_outpost_blend(), "The second posting could not be set up to blend in") + TEST_ASSERT_EQUAL(length(closing.outpost_decoy_orders), 3, "The second posting's decoys were not queued") + var/queued_before = length(SShuman_npcs.queue) + closing.outpost_release_site() + TEST_ASSERT_EQUAL(length(closing.outpost_decoy_orders), 0, "A released posting kept its queued decoys") + TEST_ASSERT_EQUAL(length(SShuman_npcs.queue), queued_before - 3, "A released posting left its decoys in the spawn queue") + SShuman_npcs.process_spawns(10) + TEST_ASSERT_EQUAL(length(decoys_of(closing)), 0, "Decoys were built for a posting that had let them go") + /// Only customers' floor: a fugitive placed behind a counter moves out onto the concourse, and the decoys come from the same floor (M5) /datum/unit_test/voidcrew_bounty_outpost/public_floor @@ -175,47 +258,144 @@ for(var/x in run_loc_floor_bottom_left.x to run_loc_floor_top_right.x) allocate(/obj/structure/table, locate(x, counter_y, run_loc_floor_bottom_left.z)) var/datum/criminal_bounty/outpost_test/posting = make_posting(run_loc_floor_bottom_left) - var/mob/living/basic/bounty_criminal/fugitive = posting.criminal() + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = posting.criminal() var/list/floor = bounty_outpost_public_floor(outpost) TEST_ASSERT(!(run_loc_floor_bottom_left in floor), "Floor behind the counter counts as the customers'") - TEST_ASSERT(posting.setup_outpost_blend(), "The posting could not be set up to blend in") + TEST_ASSERT(posting.setup_outpost_blend(TRUE), "The posting could not be set up to blend in") TEST_ASSERT(fugitive.y > counter_y, "The fugitive stayed behind the counter") - for(var/mob/living/basic/bounty_criminal/decoy/decoy as anything in decoys_of(posting)) + for(var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy as anything in decoys_of(posting)) TEST_ASSERT(decoy.y > counter_y, "A decoy spawned behind the counter") // P5 places fugitives with the same picker var/turf/spot = bounty_outpost_spawn_spot(outpost) TEST_ASSERT(spot && (spot in floor) && !(spot in outpost.lobby_alcove_turfs), "The spawn picker gave [spot], not the customers' floor") -/// The fugitive and its decoys look alike to a player: the same generic name, never the alias, and the same examine, body, speed and time down -/datum/unit_test/voidcrew_bounty_outpost/names +/// The fugitive and its decoys look alike to a player: the same species, build, skin, eyes, clothes, generic name and description, never the alias, and the same toughness and pace; and the fugitive's own armour and kit are gone from sight, not on the floor +/datum/unit_test/voidcrew_bounty_outpost/look_alikes -/datum/unit_test/voidcrew_bounty_outpost/names/Run() +/datum/unit_test/voidcrew_bounty_outpost/look_alikes/Run() outpost = make_outpost(/obj/structure/overmap/trader_outpost/outfitter) outpost.lobby_alcove_turfs = list(run_loc_floor_top_right) - var/datum/criminal_bounty/outpost_test/posting = make_posting() - var/mob/living/basic/bounty_criminal/fugitive = posting.criminal() - TEST_ASSERT(posting.setup_outpost_blend(), "The posting could not be set up to blend in") + // A human (a plasmaman is below), and its features are set, not rolled: worn ones (glasses, a scarf) + // and one that is only words, so every run has worn feature items on the fugitive, and on whichever + // decoys share or roll them. Which ones the decoys share stays random; nothing below depends on it. + var/list/features = list( + "glasses" = "sunglasses", // BOUNTY_FEATURE_GLASSES + "clothing" = "a red scarf", // BOUNTY_FEATURE_CLOTHING + "scar" = "a scar across the chin", // BOUNTY_FEATURE_SCAR + ) + var/datum/criminal_bounty/outpost_test/posting = make_posting(features = features, species = /datum/species/human) + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = posting.criminal() + // Tougher than a person, so the decoys have something to match + fugitive.set_npc_toughness(0.8) + TEST_ASSERT_NOTNULL(fugitive.wear_suit, "Test fixture: the fugitive wears no armour") + TEST_ASSERT_NOTNULL(fugitive.head, "Test fixture: the fugitive wears no helmet") + TEST_ASSERT(istype(fugitive.glasses, /obj/item/clothing/glasses/sunglasses), "Test fixture: the fugitive doesn't wear its sunglasses") + TEST_ASSERT(istype(fugitive.wear_neck, /obj/item/clothing/neck/scarf/red), "Test fixture: the fugitive doesn't wear its scarf") + // A meek criminal's fanny pack, with its spare magazine, as its holdout style gives it + var/obj/item/storage/belt/fannypack/pack = new(fugitive) + new /obj/item/ammo_box/magazine/m9mm(pack) + TEST_ASSERT(fugitive.equip_to_slot_or_del(pack, ITEM_SLOT_BELT), "Test fixture: the fugitive's fanny pack didn't go on") + // Only features go on the eyes and the neck: none of the crowds' clothes puts anything there + for(var/datum/outfit/crowd as anything in list(/datum/outfit/bounty_outpost_patron, /datum/outfit/bounty_outpost_dockhand, /datum/outfit/bounty_outpost_spacer)) + TEST_ASSERT(!initial(crowd.glasses) && !initial(crowd.neck), "[crowd] puts something on the eyes or the neck") + TEST_ASSERT(posting.setup_outpost_blend(TRUE), "The posting could not be set up to blend in") var/list/decoys = decoys_of(posting) TEST_ASSERT(length(decoys), "No decoys to compare with") - var/mob/living/basic/bounty_criminal/decoy/decoy = decoys[1] + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = decoys[1] + // Names and descriptions TEST_ASSERT_EQUAL(fugitive.name, "dockhand", "The fugitive at the outfitter is not called a dockhand") TEST_ASSERT_EQUAL(decoy.name, fugitive.name, "A decoy's name differs from the fugitive's") TEST_ASSERT_EQUAL(decoy.real_name, fugitive.real_name, "A decoy's voice name differs from the fugitive's") TEST_ASSERT(fugitive.name != posting.record.name && fugitive.name != posting.record.alias, "The fugitive shows its name or alias") TEST_ASSERT_EQUAL(decoy.desc, fugitive.desc, "A decoy's description differs from the fugitive's") - TEST_ASSERT_EQUAL(decoy.maxHealth, fugitive.maxHealth, "A decoy's health differs from the fugitive's") - TEST_ASSERT_EQUAL(decoy.move_resist, fugitive.move_resist, "A decoy's move resistance differs from the fugitive's") + + // The same build and face, whatever features were changed + TEST_ASSERT_EQUAL(decoy.dna.species.type, fugitive.dna.species.type, "A decoy is another species") + TEST_ASSERT_EQUAL(decoy.gender, fugitive.gender, "A decoy is another sex") + TEST_ASSERT_EQUAL(decoy.physique, fugitive.physique, "A decoy has another build") + // Skin tone only where the species has one: the rest are drawn in their body colour, and their unused + // skin_tone var is whatever tg rolled when the body was made. + if(bounty_species_uses_skin_tones(fugitive.dna.species.type)) + TEST_ASSERT_EQUAL(decoy.skin_tone, fugitive.skin_tone, "A decoy has another skin tone") + TEST_ASSERT_EQUAL(decoy.eye_color_left, fugitive.eye_color_left, "A decoy has other eyes") + TEST_ASSERT_EQUAL(decoy.eye_color_right, fugitive.eye_color_right, "A decoy has other eyes") + + // The same clothes, and no hat or mask on either: hair is a clue + TEST_ASSERT(istype(fugitive.w_uniform, /obj/item/clothing/under/rank/cargo/tech), "The fugitive did not change into the zone's uniform") + TEST_ASSERT(istype(fugitive.wear_suit, /obj/item/clothing/suit/hazardvest), "The fugitive did not change into the zone's coat") + TEST_ASSERT(istype(fugitive.gloves, /obj/item/clothing/gloves/fingerless), "The fugitive did not change into the zone's gloves") + TEST_ASSERT(istype(fugitive.shoes, /obj/item/clothing/shoes/workboots), "The fugitive did not change into the zone's boots") + TEST_ASSERT_NULL(fugitive.head, "The fugitive kept its helmet on") + TEST_ASSERT_NULL(fugitive.wear_mask, "The fugitive kept its mask on") + TEST_ASSERT_EQUAL(decoy.w_uniform?.type, fugitive.w_uniform?.type, "A decoy wears another uniform") + TEST_ASSERT_EQUAL(decoy.wear_suit?.type, fugitive.wear_suit?.type, "A decoy wears another coat") + TEST_ASSERT_EQUAL(decoy.gloves?.type, fugitive.gloves?.type, "A decoy wears other gloves") + TEST_ASSERT_EQUAL(decoy.shoes?.type, fugitive.shoes?.type, "A decoy wears other boots") + TEST_ASSERT_NULL(decoy.head, "A decoy wears a hat") + TEST_ASSERT_NULL(decoy.wear_mask, "A decoy wears a mask") + for(var/obj/item/clothes as anything in list(fugitive.w_uniform, fugitive.wear_suit, fugitive.gloves, fugitive.shoes)) + TEST_ASSERT(human_npc_gear_locked(clothes), "[clothes] is not locked to the body like the rest of its kit") + // What it wore is deleted, not dropped for someone to pick up; what was in its pocket stays + TEST_ASSERT_NULL(locate(/obj/item/clothing/suit/armor/vest) in fugitive.loc, "The fugitive's armour was left on the floor") + TEST_ASSERT_NULL(locate(/obj/item/clothing/head/helmet) in fugitive.loc, "The fugitive's helmet was left on the floor") + TEST_ASSERT(istype(fugitive.l_store, /obj/item/reagent_containers/hypospray/medipen), "The fugitive's pocket was emptied when it changed clothes") + // A decoy is nobody's fighter: no weapon, nothing in its hands + TEST_ASSERT_NULL(locate(/obj/item/gun) in decoy.get_all_contents(), "A decoy carries a gun") + TEST_ASSERT_NULL(decoy.get_active_held_item(), "A decoy holds something") + TEST_ASSERT_NULL(decoy.get_inactive_held_item(), "A decoy holds something") + // The fugitive keeps its fanny pack, and every decoy wears one like it, empty (outpost_match_kit()) + TEST_ASSERT_EQUAL(fugitive.belt, pack, "Changing clothes took the fugitive's fanny pack") + for(var/mob/living/carbon/human/npc/bounty_criminal/decoy/each as anything in decoys) + TEST_ASSERT_EQUAL(each.belt?.type, fugitive.belt?.type, "A decoy wears another belt from the fugitive's") + TEST_ASSERT_EQUAL(each.back?.type, fugitive.back?.type, "A decoy wears another bag from the fugitive's") + TEST_ASSERT(!length(each.belt?.contents), "A decoy's fanny pack has something in it") + TEST_ASSERT(human_npc_gear_locked(each.belt), "A decoy's fanny pack isn't locked to its body") + + // The same toughness and pace, through the body and never through a stand-in + TEST_ASSERT_EQUAL(fugitive.npc_damage_taken, 0.8, "Test fixture: the fugitive's toughness did not take") + TEST_ASSERT_EQUAL(decoy.npc_damage_taken, fugitive.npc_damage_taken, "A decoy is not as tough as the fugitive") + TEST_ASSERT_EQUAL(decoy.physiology.brute_mod, fugitive.physiology.brute_mod, "A decoy takes other brute damage from the fugitive") + TEST_ASSERT_EQUAL(decoy.physiology.burn_mod, fugitive.physiology.burn_mod, "A decoy takes other burn damage from the fugitive") + TEST_ASSERT_EQUAL(decoy.maxHealth, 100, "A decoy's max health was changed") + TEST_ASSERT_EQUAL(decoy.move_intent, fugitive.move_intent, "A decoy walks differently from the fugitive") TEST_ASSERT_EQUAL(decoy.cached_multiplicative_slowdown, fugitive.cached_multiplicative_slowdown, "A decoy's speed differs from the fugitive's") - TEST_ASSERT_EQUAL(decoy.stamina_regen_time, fugitive.stamina_regen_time, "A decoy's stamina crit lasts a different time from the fugitive's") - TEST_ASSERT_EQUAL(decoy.max_stamina_slowdown, fugitive.max_stamina_slowdown, "A decoy slows on stamina damage differently from the fugitive") - TEST_ASSERT_EQUAL(decoy.damage_coeff[STAMINA], fugitive.damage_coeff[STAMINA], "A decoy takes stamina damage differently from the fugitive") - TEST_ASSERT_EQUAL(decoy.body_recovery_time(), fugitive.body_recovery_time(), "A decoy stays down for a different time from the fugitive") + var/mob/living/carbon/human/person = allocate(/mob/living/carbon/human/consistent) + TEST_ASSERT_EQUAL(decoy.move_resist, person.move_resist, "A decoy is harder to move than a person") + TEST_ASSERT_EQUAL(fugitive.move_resist, person.move_resist, "A fugitive blending in is harder to move than a person") - // Examine: the same plain text once each one's own feature lines are taken out - decoy.gender = fugitive.gender + // Examine: the same plain text for every decoy once each one's own features are taken out var/mob/living/carbon/human/viewer = make_hunter() - TEST_ASSERT_EQUAL(plain_examine(decoy, viewer), plain_examine(fugitive, viewer), "A decoy examines differently from the fugitive") + var/fugitive_examine = plain_examine(fugitive, viewer) + TEST_ASSERT(!findtext(fugitive_examine, "sunglasses") && !findtext(fugitive_examine, "scarf"), "The fugitive's worn features weren't taken out of its examine: [fugitive_examine]") + TEST_ASSERT(findtext(fugitive_examine, "fannypack"), "The fugitive's fanny pack isn't in its examine: [fugitive_examine]") + for(var/mob/living/carbon/human/npc/bounty_criminal/decoy/each as anything in decoys) + TEST_ASSERT_EQUAL(plain_examine(each, viewer), fugitive_examine, "A decoy examines differently from the fugitive") + + // A plasmaman keeps what it can't live without (its envirosuit, helmet and gloves) under the zone's + // coat and boots, and its decoys, plasmamen too, are dressed over the same + var/datum/criminal_bounty/outpost_test/plasma_posting = make_posting(species = /datum/species/plasmaman) + var/mob/living/carbon/human/npc/bounty_criminal/plasma = plasma_posting.criminal() + TEST_ASSERT(plasma_posting.setup_outpost_blend(TRUE), "A plasmaman's posting could not be set up to blend in") + TEST_ASSERT(istype(plasma.w_uniform, /obj/item/clothing/under/plasmaman), "A plasmaman fugitive took off its envirosuit to blend in") + TEST_ASSERT(istype(plasma.head, /obj/item/clothing/head/helmet/space/plasmaman), "A plasmaman fugitive took off its helmet to blend in") + TEST_ASSERT(istype(plasma.wear_suit, /obj/item/clothing/suit/hazardvest), "A plasmaman fugitive did not put on the zone's coat") + var/list/plasma_decoys = decoys_of(plasma_posting) + TEST_ASSERT(length(plasma_decoys), "No decoys for the plasmaman") + for(var/mob/living/carbon/human/npc/bounty_criminal/decoy/each as anything in plasma_decoys) + TEST_ASSERT_EQUAL(each.dna.species.type, /datum/species/plasmaman, "A plasmaman's decoy is another species") + TEST_ASSERT_EQUAL(each.w_uniform?.type, plasma.w_uniform?.type, "A plasmaman's decoy wears another envirosuit") + TEST_ASSERT_EQUAL(each.head?.type, plasma.head?.type, "A plasmaman's decoy wears another helmet") + TEST_ASSERT_EQUAL(each.wear_suit?.type, plasma.wear_suit?.type, "A plasmaman's decoy wears another coat") + TEST_ASSERT_EQUAL(each.gloves?.type, plasma.gloves?.type, "A plasmaman's decoy wears other gloves") + TEST_ASSERT_EQUAL(each.shoes?.type, plasma.shoes?.type, "A plasmaman's decoy wears other boots") + + // A decoy made any other way still dresses as a customer, never as a criminal + var/mob/living/carbon/human/npc/bounty_criminal/decoy/stray = allocate(/mob/living/carbon/human/npc/bounty_criminal/decoy) + TEST_ASSERT(istype(stray.w_uniform, /obj/item/clothing/under/costume/buttondown/slacks) || istype(stray.w_uniform, /obj/item/clothing/under/rank/cargo/tech) || istype(stray.w_uniform, /obj/item/clothing/under/pants/jeans), "A decoy built outside the outpost's code is not dressed as a patron") + TEST_ASSERT_NULL(locate(/obj/item/gun) in stray.get_all_contents(), "A decoy built outside the outpost's code carries a gun") + TEST_ASSERT_NULL(stray.get_active_held_item(), "A decoy built outside the outpost's code holds something") + TEST_ASSERT(stray.npc_corpse_lifetime > 0, "A dead decoy would lie there for good: nobody's posting cleans it up") // The other zones' names TEST_ASSERT_EQUAL(bounty_outpost_display_name(allocate(/obj/structure/overmap/trader_outpost/general)), "patron", "Halcyon's crowd is not patrons") @@ -227,8 +407,8 @@ /datum/unit_test/voidcrew_bounty_outpost/warrant/Run() outpost = make_outpost() var/datum/criminal_bounty/outpost_test/posting = make_posting() - var/mob/living/basic/bounty_criminal/meek/outpost_test/fugitive = posting.criminal() - TEST_ASSERT(posting.setup_outpost_blend(), "The posting could not be set up to blend in") + var/mob/living/carbon/human/npc/bounty_criminal/meek/outpost_test/fugitive = posting.criminal() + TEST_ASSERT(posting.setup_outpost_blend(TRUE), "The posting could not be set up to blend in") var/list/decoys = decoys_of(posting) TEST_ASSERT(length(decoys) >= 2, "Too few decoys to test with") var/obj/structure/overmap/ship/ship = allocate(/obj/structure/overmap/ship) @@ -243,7 +423,7 @@ TEST_ASSERT_EQUAL(posting.outpost_warrant_wait(hunter), 0, "Showing the warrant to a shopper started the wait") // A decoy: it protests, and the alert rises - var/mob/living/basic/bounty_criminal/decoy/decoy = decoys[1] + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = decoys[1] warrant.show_warrant(decoy, hunter) TEST_ASSERT_EQUAL(posting.alert, 1, "A wrong warrant did not raise the alert") TEST_ASSERT(decoy.blended, "A decoy stopped blending in after a wrong warrant") @@ -272,92 +452,172 @@ warrant.show_warrant(decoys[2], hunter) TEST_ASSERT_EQUAL(posting.alert, 1, "An out-of-date warrant raised the alert") -/// Cuffs reached for on someone blending in cost exactly what a punch costs, and a decoy confronted any other way raises the alert (C1) +/// Restraints reached for on someone blending in cost exactly what a punch costs: the decoy's wrists are a strike and the alert and it backs away, the fugitive's end its act. Down or held, the cuffs go on. A decoy confronted any other way raises the alert too (C1) /datum/unit_test/voidcrew_bounty_outpost/cuffs /datum/unit_test/voidcrew_bounty_outpost/cuffs/Run() outpost = make_outpost() var/datum/criminal_bounty/outpost_test/posting = make_posting() - var/mob/living/basic/bounty_criminal/meek/outpost_test/fugitive = posting.criminal() - TEST_ASSERT(posting.setup_outpost_blend(), "The posting could not be set up to blend in") + var/mob/living/carbon/human/npc/bounty_criminal/meek/outpost_test/fugitive = posting.criminal() + TEST_ASSERT(posting.setup_outpost_blend(TRUE), "The posting could not be set up to blend in") var/list/decoys = decoys_of(posting) TEST_ASSERT(length(decoys) >= 2, "Too few decoys to test with") - var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs) - // A decoy's wrists: a strike and the alert, the cuffs don't go on, and it doesn't just protest for free + // A decoy's wrists, the way tg's cuffs reach for them: a strike and the alert, and the cuffs don't go on var/mob/living/carbon/human/cuffer = make_hunter() - var/mob/living/basic/bounty_criminal/decoy/decoy = decoys[1] - cuffs.melee_attack_chain(cuffer, decoy, list()) + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = decoys[1] + SEND_SIGNAL(decoy, COMSIG_CARBON_CUFF_ATTEMPTED, cuffer) TEST_ASSERT_EQUAL(outpost.aggressor_strikes[cuffer.mind], 1, "Cuffs on a decoy were not an outpost strike, as a punch is") TEST_ASSERT_EQUAL(posting.alert, 1, "Cuffs on a decoy did not raise the alert, as a punch does") TEST_ASSERT(!decoy.is_restrained(), "A decoy on its feet was cuffed") TEST_ASSERT(decoy.blended, "A decoy stopped blending in") - // The fugitive's wrists: the act is over, as for a punch, and nothing is charged + // The fugitive's wrists: the act is over, as for a punch, and nothing is charged. The body then + // steps away and runs or fights (BOUNTY_CUFF_REACTION_DELAY, half a second, later). var/mob/living/carbon/human/other_cuffer = make_hunter() - cuffs.melee_attack_chain(other_cuffer, fugitive, list()) + SEND_SIGNAL(fugitive, COMSIG_CARBON_CUFF_ATTEMPTED, other_cuffer) TEST_ASSERT(!fugitive.blended, "Cuffs on the fugitive did not end its act") - TEST_ASSERT_EQUAL(fugitive.confronted_by, other_cuffer, "Cuffs on the fugitive did not confront it") TEST_ASSERT(fugitive.body_has_grudge(other_cuffer), "The fugitive holds no grudge against whoever reached for its wrists") TEST_ASSERT_NULL(outpost.aggressor_strikes[other_cuffer.mind], "Reaching for the fugitive's wrists was an outpost strike") TEST_ASSERT_EQUAL(posting.alert, 1, "Reaching for the fugitive's wrists raised the alert") + sleep(10) + TEST_ASSERT_EQUAL(fugitive.confronted_by, other_cuffer, "The fugitive did not answer the reach for its wrists") + + // The component answers the body's signal: standing and free, a decoy takes the reaction over (COMSIG_BOUNTY_CUFF_REACHED, COMPONENT_BOUNTY_CUFF_HANDLED) + var/mob/living/carbon/human/third_cuffer = make_hunter() + var/answer = SEND_SIGNAL(decoys[2], "bounty_cuff_reached", third_cuffer) + TEST_ASSERT(answer & 1, "A free decoy's reaction to cuffs was left to the body, which would take it for a wrong warrant") + // An exposed fugitive has nothing left to hide: the alert may rise, but nobody slips away + TEST_ASSERT_EQUAL(posting.alert, 2, "A second decoy's wrists did not raise the alert") + TEST_ASSERT_NULL(posting.relisted_for, "An exposed fugitive slipped away") + TEST_ASSERT(!is_leaving(fugitive), "An exposed fugitive set off for the lift") + + // A decoy that can't answer (knocked out, say) is cuffed as anyone is, and it still costs the same + var/datum/criminal_bounty/outpost_test/helpless_posting = make_posting(run_loc_floor_bottom_left) + TEST_ASSERT(helpless_posting.setup_outpost_blend(TRUE), "The second posting could not be set up to blend in") + var/mob/living/carbon/human/npc/bounty_criminal/decoy/helpless = decoys_of(helpless_posting)[1] + helpless.Paralyze(10 SECONDS) + var/mob/living/carbon/human/fourth_cuffer = make_hunter() + var/helpless_answer = SEND_SIGNAL(helpless, "bounty_cuff_reached", fourth_cuffer) + TEST_ASSERT(!(helpless_answer & 1), "A decoy that could do nothing about it took the reaction over") + TEST_ASSERT_EQUAL(outpost.aggressor_strikes[fourth_cuffer.mind], 1, "Cuffs on a helpless decoy were free") + TEST_ASSERT_EQUAL(helpless_posting.alert, 1, "Cuffs on a helpless decoy did not raise the alert") + helpless_posting.status = "closed" // BOUNTY_POSTING_CLOSED: the outpost has room again + + // Someone with no mind behind them never counts + var/datum/criminal_bounty/outpost_test/mindless_posting = make_posting(run_loc_floor_bottom_left) + TEST_ASSERT(mindless_posting.setup_outpost_blend(TRUE), "The third posting could not be set up to blend in") + var/mob/living/carbon/human/npc/bounty_criminal/decoy/untouched = decoys_of(mindless_posting)[1] + var/mob/living/carbon/human/robot = allocate(/mob/living/carbon/human/consistent) + SEND_SIGNAL(untouched, "bounty_cuff_reached", robot) + TEST_ASSERT_EQUAL(mindless_posting.alert, 0, "A mindless reach for a decoy's wrists raised the alert") + mindless_posting.status = "closed" // BOUNTY_POSTING_CLOSED // Any other way of confronting a decoy is a wrong accusation var/datum/criminal_bounty/outpost_test/next = make_posting(run_loc_floor_bottom_left) - TEST_ASSERT(next.setup_outpost_blend(), "The second posting could not be set up to blend in") + TEST_ASSERT(next.setup_outpost_blend(TRUE), "The fourth posting could not be set up to blend in") var/list/next_decoys = decoys_of(next) - TEST_ASSERT(length(next_decoys), "No decoys at the second posting") - var/mob/living/basic/bounty_criminal/decoy/next_decoy = next_decoys[1] + TEST_ASSERT(length(next_decoys), "No decoys at the fourth posting") + var/mob/living/carbon/human/npc/bounty_criminal/decoy/next_decoy = next_decoys[1] next_decoy.on_confronted(make_hunter()) TEST_ASSERT_EQUAL(next.alert, 1, "Confronting a decoy another way cost nothing") -/// Two alerts: the fugitive and its decoys walk out and the bounty relists; an exposed fugitive stays +/// Two alerts: the decoys leave, and the fugitive walks out for real, still the posting's until it has gone; the bounty relists when it does. A fugitive caught on the way stays the posting's. An exposed fugitive stays /datum/unit_test/voidcrew_bounty_outpost/alert /datum/unit_test/voidcrew_bounty_outpost/alert/Run() outpost = make_outpost() var/datum/criminal_bounty/outpost_test/posting = make_posting() - var/mob/living/basic/bounty_criminal/fugitive = posting.criminal() - TEST_ASSERT(posting.setup_outpost_blend(), "The posting could not be set up to blend in") + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = posting.criminal() + TEST_ASSERT(posting.setup_outpost_blend(TRUE), "The posting could not be set up to blend in") var/list/decoys = decoys_of(posting) TEST_ASSERT(posting.raise_alert("a test"), "The alert did not rise") TEST_ASSERT_EQUAL(posting.alert, 1, "The first alert did not count") TEST_ASSERT_NULL(posting.relisted_for, "The bounty relisted at the first alert") - TEST_ASSERT(posting.raise_alert("a test"), "The alert did not rise a second time") - TEST_ASSERT_NOTNULL(posting.relisted_for, "Two alerts did not relist the bounty") // BOUNTY_OUTPOST_ALERT_SLIP + TEST_ASSERT(posting.raise_alert("a test"), "The alert did not rise a second time") // BOUNTY_OUTPOST_ALERT_SLIP + TEST_ASSERT_EQUAL(length(posting.decoys), 0, "The posting kept its decoys") + TEST_ASSERT(is_leaving(fugitive), "The fugitive did not set off for the lift") + TEST_ASSERT_EQUAL(fugitive.npc_exit, run_loc_floor_top_right, "The fugitive set off for somewhere other than the hangar lift") + for(var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy as anything in decoys) + TEST_ASSERT(is_leaving(decoy), "A decoy did not leave with the fugitive") + // Still the posting's, and nobody's immortal on the way + TEST_ASSERT_NULL(posting.relisted_for, "The bounty relisted before the fugitive had gone") + TEST_ASSERT_EQUAL(posting.criminal(), fugitive, "The posting let go of a fugitive that was still walking out") + TEST_ASSERT_EQUAL(fugitive.posting(), posting, "A fugitive on its way out is no longer the posting's") + TEST_ASSERT(!HAS_TRAIT(fugitive, TRAIT_GODMODE), "The fugitive can't be hurt on its way out") + var/health_before = fugitive.health + fugitive.adjustBruteLoss(10) + TEST_ASSERT(fugitive.health < health_before, "A shot at the fugitive on its way out did nothing") + // A third alert while it walks starts nothing new + posting.raise_alert("a test") + TEST_ASSERT_NULL(posting.relisted_for, "A third alert relisted the bounty") + + // It reaches the lift, or nobody can see it: it goes, and the bounty relists + SShuman_npcs.sweep_leavers() + TEST_ASSERT(QDELETED(fugitive), "The fugitive was still there once it had left") + TEST_ASSERT_NOTNULL(posting.relisted_for, "The bounty did not relist once the fugitive had gone") + posting.status = "closed" // BOUNTY_POSTING_CLOSED: the outpost has room again TEST_ASSERT_NULL(posting.criminal(), "The posting kept hold of a fugitive that slipped away") - TEST_ASSERT_NULL(fugitive.posting_ref, "A fugitive that slipped away still points at the posting") - TEST_ASSERT_EQUAL(length(posting.decoys), 0, "The posting kept hold of its decoys") - TEST_ASSERT(fugitive.GetComponent(/datum/component/bounty_outpost_exit), "The fugitive did not leave") - for(var/mob/living/basic/bounty_criminal/decoy/decoy as anything in decoys) - TEST_ASSERT(decoy.GetComponent(/datum/component/bounty_outpost_exit), "A decoy did not leave with the fugitive") + for(var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy as anything in decoys) + TEST_ASSERT(QDELETED(decoy), "A decoy was still there once it had left") + + // Caught on the way: cuffed, the fugitive stays, and it is still the posting's, so it can be turned in + var/datum/criminal_bounty/outpost_test/caught = make_posting(run_loc_floor_bottom_left) + var/mob/living/carbon/human/npc/bounty_criminal/caught_fugitive = caught.criminal() + TEST_ASSERT(caught.setup_outpost_blend(TRUE), "The second posting could not be set up to blend in") + caught.raise_alert("a test") + caught.raise_alert("a test") + TEST_ASSERT(is_leaving(caught_fugitive), "The second fugitive did not set off for the lift") + var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs) + TEST_ASSERT(caught_fugitive.equip_to_slot_if_possible(cuffs, ITEM_SLOT_HANDCUFFED), "Test fixture: the fugitive could not be cuffed") + SShuman_npcs.sweep_leavers() + TEST_ASSERT(!QDELETED(caught_fugitive), "A cuffed fugitive walked out of the outpost") + TEST_ASSERT_NULL(caught.relisted_for, "The bounty relisted with its fugitive still there in cuffs") + TEST_ASSERT_EQUAL(caught.criminal(), caught_fugitive, "The posting lost a fugitive that was caught on its way out") + TEST_ASSERT_EQUAL(caught_fugitive.capture_state(), "restrained", "A fugitive caught on its way out does not pay as caught") // BOUNTY_STATE_RESTRAINED + // Down, not cuffed: also stays + caught_fugitive.uncuff() + caught_fugitive.adjustOxyLoss(110) + SShuman_npcs.sweep_leavers() + TEST_ASSERT(!QDELETED(caught_fugitive), "A fugitive in crit walked out of the outpost") + TEST_ASSERT_EQUAL(caught_fugitive.capture_state(), "downed", "A fugitive in crit does not pay as downed") // BOUNTY_STATE_DOWNED + // On its feet and free again, it finishes the walk and the bounty relists + caught_fugitive.setOxyLoss(0) + caught_fugitive.updatehealth() + SShuman_npcs.sweep_leavers() + TEST_ASSERT(QDELETED(caught_fugitive), "A fugitive on its feet and free did not leave") + TEST_ASSERT_NOTNULL(caught.relisted_for, "The bounty did not relist when the second fugitive left") + caught.status = "closed" // BOUNTY_POSTING_CLOSED // Once exposed, the chase is on: no more slipping away var/datum/criminal_bounty/outpost_test/exposed = make_posting(run_loc_floor_bottom_left) - var/mob/living/basic/bounty_criminal/exposed_fugitive = exposed.criminal() - TEST_ASSERT(exposed.setup_outpost_blend(), "The second posting could not be set up to blend in") + var/mob/living/carbon/human/npc/bounty_criminal/exposed_fugitive = exposed.criminal() + TEST_ASSERT(exposed.setup_outpost_blend(TRUE), "The third posting could not be set up to blend in") exposed.outpost_confront(exposed_fugitive, make_hunter()) exposed.raise_alert("a test") exposed.raise_alert("a test") + SShuman_npcs.sweep_leavers() TEST_ASSERT_NULL(exposed.relisted_for, "An exposed fugitive slipped away") TEST_ASSERT_EQUAL(exposed.criminal(), exposed_fugitive, "An exposed fugitive was let go") + TEST_ASSERT(!is_leaving(exposed_fugitive), "An exposed fugitive set off for the lift") // Only trader-outpost postings have an alert var/datum/criminal_bounty/outpost_test/planet = make_posting(run_loc_floor_bottom_left) planet.placement_kind = "planet" // BOUNTY_PLACEMENT_PLANET TEST_ASSERT(!planet.raise_alert("a test"), "A planet bounty's alert rose") -/// A deliberate hit on a decoy is an outpost strike and raises the alert; hitting the fugitive only exposes it +/// A deliberate hit on a decoy is an outpost strike and raises the alert; hitting the fugitive only exposes it. A shot hits whoever it hits /datum/unit_test/voidcrew_bounty_outpost/decoy_hit /datum/unit_test/voidcrew_bounty_outpost/decoy_hit/Run() outpost = make_outpost() var/datum/criminal_bounty/outpost_test/posting = make_posting() - TEST_ASSERT(posting.setup_outpost_blend(), "The posting could not be set up to blend in") + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = posting.criminal() + TEST_ASSERT(posting.setup_outpost_blend(TRUE), "The posting could not be set up to blend in") var/list/decoys = decoys_of(posting) TEST_ASSERT(length(decoys) >= 2, "Too few decoys to test with") - var/mob/living/basic/bounty_criminal/decoy/decoy = decoys[1] + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = decoys[1] // Someone with no mind behind them never counts var/mob/living/carbon/human/npc = allocate(/mob/living/carbon/human/consistent) @@ -377,25 +637,30 @@ TEST_ASSERT_EQUAL(outpost.aggressor_strikes[hunter.mind], 1, "Punching a decoy was not an outpost strike") TEST_ASSERT_EQUAL(posting.alert, 1, "Punching a decoy did not raise the alert") - // A shot aimed at a decoy counts; a shot at someone else passes through it + // A shot at someone else hits whoever it hits: it goes through nobody, and it is nobody's strike var/mob/living/carbon/human/shooter = make_hunter() var/obj/projectile/bullet/stray = allocate(/obj/projectile/bullet) stray.firer = shooter stray.original = hunter - var/mob/living/basic/bounty_criminal/decoy/other_decoy = decoys[2] - TEST_ASSERT(SEND_SIGNAL(other_decoy, COMSIG_PROJECTILE_PREHIT, stray) & PROJECTILE_INTERRUPT_HIT_PHASE, "A shot at someone else hit a decoy") - TEST_ASSERT_EQUAL(posting.alert, 1, "A stray shot through a decoy raised the alert") + var/mob/living/carbon/human/npc/bounty_criminal/decoy/other_decoy = decoys[2] + TEST_ASSERT(!(SEND_SIGNAL(other_decoy, COMSIG_PROJECTILE_PREHIT, stray) & PROJECTILE_INTERRUPT_HIT_PHASE), "A shot at someone else passed through a decoy") + TEST_ASSERT(!(SEND_SIGNAL(other_decoy, COMSIG_PROJECTILE_PREHIT, stray) & PROJECTILE_INTERRUPT_HIT), "A shot at someone else was stopped by a decoy") + TEST_ASSERT_EQUAL(posting.alert, 1, "A stray shot that landed on a decoy raised the alert") + TEST_ASSERT_NULL(outpost.aggressor_strikes[shooter.mind], "A stray shot that landed on a decoy was an outpost strike") + // One aimed at it counts, and the second alert sends the fugitive off var/obj/projectile/bullet/aimed = allocate(/obj/projectile/bullet) aimed.firer = shooter aimed.original = other_decoy TEST_ASSERT(!(SEND_SIGNAL(other_decoy, COMSIG_PROJECTILE_PREHIT, aimed) & PROJECTILE_INTERRUPT_HIT_PHASE), "A shot aimed at a decoy passed through it") TEST_ASSERT_EQUAL(outpost.aggressor_strikes[shooter.mind], 1, "Shooting a decoy was not an outpost strike") - TEST_ASSERT_NOTNULL(posting.relisted_for, "Two hits on decoys did not send the fugitive away") + TEST_ASSERT(is_leaving(fugitive), "Two hits on decoys did not send the fugitive off") + SShuman_npcs.sweep_leavers() + TEST_ASSERT_NOTNULL(posting.relisted_for, "Two hits on decoys did not relist the bounty once the fugitive had gone") // Hitting the (next) fugitive exposes it: no strike, no alert var/datum/criminal_bounty/outpost_test/next = make_posting(run_loc_floor_bottom_left) - var/mob/living/basic/bounty_criminal/next_fugitive = next.criminal() - TEST_ASSERT(next.setup_outpost_blend(), "The second posting could not be set up to blend in") + var/mob/living/carbon/human/npc/bounty_criminal/next_fugitive = next.criminal() + TEST_ASSERT(next.setup_outpost_blend(TRUE), "The second posting could not be set up to blend in") var/mob/living/carbon/human/brawler = make_hunter() brawler.combat_mode = TRUE next_fugitive.attack_hand(brawler, list()) @@ -410,11 +675,12 @@ /datum/unit_test/voidcrew_bounty_outpost/thrown/Run() outpost = make_outpost() var/datum/criminal_bounty/outpost_test/posting = make_posting() - TEST_ASSERT(posting.setup_outpost_blend(), "The posting could not be set up to blend in") + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = posting.criminal() + TEST_ASSERT(posting.setup_outpost_blend(TRUE), "The posting could not be set up to blend in") var/list/decoys = decoys_of(posting) TEST_ASSERT(length(decoys) >= 2, "Too few decoys to test with") - var/mob/living/basic/bounty_criminal/decoy/decoy = decoys[1] - var/mob/living/basic/bounty_criminal/decoy/other_decoy = decoys[2] + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = decoys[1] + var/mob/living/carbon/human/npc/bounty_criminal/decoy/other_decoy = decoys[2] var/obj/item/storage/toolbox/toolbox = allocate(/obj/item/storage/toolbox) TEST_ASSERT(toolbox.throwforce > 0, "The toolbox is too light to test with") @@ -438,23 +704,28 @@ var/mob/living/carbon/human/pilot = make_hunter() SEND_SIGNAL(other_decoy, COMSIG_ATOM_ATTACK_MECH, null, pilot, 0) TEST_ASSERT_EQUAL(outpost.aggressor_strikes[pilot.mind], 1, "A mech punching a decoy was not a strike for its pilot") - TEST_ASSERT_NOTNULL(posting.relisted_for, "Two hits on decoys did not send the fugitive away") + TEST_ASSERT(is_leaving(fugitive), "Two hits on decoys did not send the fugitive off") -/// While blending in nobody can pull them, the lift never carries them, and the turrets leave them alone; the fugitive's shots at the outpost reach only its grudge list, and hurting a bystander ends the turrets' leave + // A decoy that is already walking out: a hit is still the hitter's strike, but no further alert + var/mob/living/carbon/human/late = make_hunter() + var/datum/thrownthing/late_throw = new(toolbox, other_decoy, NORTH, 7, 1, late) + SEND_SIGNAL(other_decoy, COMSIG_ATOM_PREHITBY, toolbox, late_throw) + qdel(late_throw) + TEST_ASSERT_EQUAL(outpost.aggressor_strikes[late.mind], 1, "A hit on a decoy walking out was free") + +/// While blending in the turrets leave them alone and the lift never carries them; a hand on them is a hand on a person; the fugitive's shots and blows at the outpost are judged by who they hit, and hurting a bystander ends the turrets' leave /datum/unit_test/voidcrew_bounty_outpost/security /datum/unit_test/voidcrew_bounty_outpost/security/Run() outpost = make_outpost() var/datum/criminal_bounty/outpost_test/posting = make_posting() - var/mob/living/basic/bounty_criminal/fugitive = posting.criminal() - TEST_ASSERT(posting.setup_outpost_blend(), "The posting could not be set up to blend in") + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = posting.criminal() + TEST_ASSERT(posting.setup_outpost_blend(TRUE), "The posting could not be set up to blend in") var/list/decoys = decoys_of(posting) TEST_ASSERT(length(decoys), "No decoys to test with") - var/mob/living/basic/bounty_criminal/decoy/decoy = decoys[1] + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = decoys[1] var/mob/living/carbon/human/hunter = make_hunter() - TEST_ASSERT(!decoy.can_be_pulled(hunter, MOVE_FORCE_OVERPOWERING), "A decoy can be pulled") - TEST_ASSERT(!fugitive.can_be_pulled(hunter, MOVE_FORCE_OVERPOWERING), "The fugitive can be pulled while blending in") TEST_ASSERT(!decoy.may_attack(hunter), "A decoy may attack someone") // The hangar lift carries whoever stands on it: they never step onto it (L8) @@ -472,23 +743,69 @@ TEST_ASSERT(!turret.valid_target(decoy), "The outpost turrets target a decoy") TEST_ASSERT(!turret.valid_target(fugitive), "The outpost turrets target a fugitive blending in") - // The fugitive's own shots pass through anyone who hasn't crossed it + // The fugitive's shots go where they go: one that lands on a person on its grudge list is the chase, one that lands on anyone else is not var/mob/living/carbon/human/bystander = make_hunter() - var/obj/projectile/bullet/shot = allocate(/obj/projectile/bullet) - SEND_SIGNAL(fugitive, COMSIG_PROJECTILE_FIRER_BEFORE_FIRE, shot, fugitive, hunter) - TEST_ASSERT(SEND_SIGNAL(shot, COMSIG_PROJECTILE_SELF_PREHIT, bystander) & PROJECTILE_INTERRUPT_HIT_PHASE, "The fugitive's shot hit a bystander") - fugitive.body_add_grudge(hunter) - TEST_ASSERT(!(SEND_SIGNAL(shot, COMSIG_PROJECTILE_SELF_PREHIT, hunter) & PROJECTILE_INTERRUPT_HIT_PHASE), "The fugitive's shot passed through someone on its grudge list") - - // Exposed and fighting those who came for it, the turrets still leave it to the hunters (AR-C8) posting.outpost_confront(fugitive, hunter) TEST_ASSERT(!turret.in_faction(fugitive), "An exposed fugitive is still in the turrets' faction") - SEND_SIGNAL(fugitive, COMSIG_HOSTILE_POST_ATTACKINGTARGET, hunter, TRUE) + var/obj/projectile/bullet/shot = allocate(/obj/projectile/bullet) + SEND_SIGNAL(fugitive, COMSIG_PROJECTILE_FIRER_BEFORE_FIRE, shot, fugitive, hunter) + TEST_ASSERT(!(SEND_SIGNAL(shot, COMSIG_PROJECTILE_SELF_PREHIT, bystander) & PROJECTILE_INTERRUPT_HIT_PHASE), "The fugitive's shot passed through a bystander") + SEND_SIGNAL(shot, COMSIG_PROJECTILE_SELF_ON_HIT, fugitive, hunter, 0, null, 0, FALSE) TEST_ASSERT(!fugitive.outpost_turret_target(), "Fighting its grudge list made the fugitive a turret target") - // Hurting someone who never crossed it ends that - SEND_SIGNAL(fugitive, COMSIG_HOSTILE_POST_ATTACKINGTARGET, bystander, TRUE) - TEST_ASSERT(fugitive.outpost_turret_target(), "The fugitive hurt a bystander and the turrets still leave it be") + // Hurting someone who never crossed it ends the turrets' leave + SEND_SIGNAL(shot, COMSIG_PROJECTILE_SELF_ON_HIT, fugitive, bystander, 0, null, 0, FALSE) + TEST_ASSERT(fugitive.outpost_turret_target(), "The fugitive hurt a bystander with a shot and the turrets still leave it be") TEST_ASSERT(!decoy.outpost_turret_target(), "A decoy is a turret target") + // But not once the hunters have it: stunned, cuffed, in crit or dead (tg's states) + fugitive.Paralyze(10 SECONDS) + TEST_ASSERT(!fugitive.outpost_turret_target(), "The turrets fire on a fugitive the hunters have already put down") + fugitive.SetParalyzed(0) + TEST_ASSERT(fugitive.outpost_turret_target(), "A fugitive on its feet again is not a turret target") + + // Its blows count the same: a punch at a bystander + var/datum/criminal_bounty/outpost_test/next = make_posting(run_loc_floor_bottom_left) + var/mob/living/carbon/human/npc/bounty_criminal/next_fugitive = next.criminal() + TEST_ASSERT(next.setup_outpost_blend(TRUE), "The second posting could not be set up to blend in") + next.outpost_confront(next_fugitive, hunter) + SEND_SIGNAL(next_fugitive, COMSIG_LIVING_UNARMED_ATTACK, hunter, TRUE, list()) + TEST_ASSERT(!next_fugitive.outpost_turret_target(), "Punching someone on its grudge list made the fugitive a turret target") + SEND_SIGNAL(next_fugitive, COMSIG_LIVING_UNARMED_ATTACK, bystander, TRUE, list()) + TEST_ASSERT(next_fugitive.outpost_turret_target(), "The fugitive punched a bystander and the turrets still leave it be") + +/// A hand on someone blending in is a hand on a person: they can be grabbed like anyone, and it is no hit. Standing or down, the fugitive and a decoy alike +/datum/unit_test/voidcrew_bounty_outpost/grab + +/datum/unit_test/voidcrew_bounty_outpost/grab/Run() + outpost = make_outpost() + var/datum/criminal_bounty/outpost_test/posting = make_posting() + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = posting.criminal() + TEST_ASSERT(posting.setup_outpost_blend(TRUE), "The posting could not be set up to blend in") + var/list/decoys = decoys_of(posting) + TEST_ASSERT(length(decoys), "No decoys to test with") + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = decoys[1] + var/mob/living/carbon/human/hunter = make_hunter() + + hunter.forceMove(get_step(decoy, EAST)) + TEST_ASSERT(hunter.start_pulling(decoy), "A decoy blending in could not be grabbed") + TEST_ASSERT_EQUAL(decoy.pulledby, hunter, "A grabbed decoy is not pulled") + TEST_ASSERT_EQUAL(posting.alert, 0, "Grabbing a decoy raised the alert") + TEST_ASSERT(decoy.blended, "Grabbing a decoy ended its act") + hunter.stop_pulling() + + hunter.forceMove(get_step(fugitive, EAST)) + TEST_ASSERT(hunter.start_pulling(fugitive), "The fugitive blending in could not be grabbed") + TEST_ASSERT_EQUAL(fugitive.pulledby, hunter, "The grabbed fugitive is not pulled") + TEST_ASSERT(fugitive.blended, "Grabbing the fugitive gave it away") + hunter.stop_pulling() + + // Walking out is no different: it can be grabbed, and held, it does not get away + posting.raise_alert("a test") + posting.raise_alert("a test") + TEST_ASSERT(is_leaving(decoy), "Test fixture: the decoy did not leave") + hunter.forceMove(get_step(decoy, EAST)) + TEST_ASSERT(hunter.start_pulling(decoy), "A decoy walking out could not be grabbed") + TEST_ASSERT(!decoy.npc_may_vanish(), "A decoy in the hunter's grip walked off the map") + hunter.stop_pulling() /// Traders give a different clue each, once per ship, and only to a ship hunting the fugitive there; a place is never told as true after it has changed /datum/unit_test/voidcrew_bounty_outpost/clues @@ -496,7 +813,7 @@ /datum/unit_test/voidcrew_bounty_outpost/clues/Run() outpost = make_outpost() var/datum/criminal_bounty/outpost_test/posting = make_posting(run_loc_floor_bottom_left) - var/mob/living/basic/bounty_criminal/fugitive = posting.criminal() + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = posting.criminal() // A haircut since the mugshot, so the hair clue is in the pool whatever P1 makes. Both looks keep // the record's species: a look with none can't name a decoy. var/datum/bounty_look/now = new @@ -511,7 +828,7 @@ then.hair_color = "#e0c060" posting.record.look = now posting.record.old_look = then - TEST_ASSERT(posting.setup_outpost_blend(), "The posting could not be set up to blend in") + TEST_ASSERT(posting.setup_outpost_blend(TRUE), "The posting could not be set up to blend in") var/list/decoys = decoys_of(posting) TEST_ASSERT_EQUAL(length(decoys), 3, "The fugitive did not get three decoys") // No lift nearby for this, and one person to a corner, so where each stands picks them out @@ -522,7 +839,7 @@ locate(run_loc_floor_top_right.x, run_loc_floor_bottom_left.y, run_loc_floor_bottom_left.z), ) for(var/index in 1 to 3) - var/mob/living/basic/bounty_criminal/decoy/decoy = decoys[index] + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = decoys[index] decoy.forceMove(corners[index]) var/list/traders = list() @@ -635,75 +952,87 @@ board.ui_data(reader) TEST_ASSERT_EQUAL(board.outpost_static_signature, bounty_public_board_signature(), "The board did not notice what it shows") -/// When the posting closes the decoys and an uncaught fugitive walk out to the lift and fade; a walk never outlives its walker, and an unreachable lift means fading in place -/datum/unit_test/voidcrew_bounty_outpost/cleanup +/** + * When the posting closes the decoys and an uncaught fugitive walk out for real, through the human NPC + * base's walk out: tracked, with an exit their AI knows and the planning step to walk it, and no godmode + * (they can be hurt, and a shot goes through no one). Anyone down, cuffed, or dead stays where they fall; + * the rest go when nobody can see them; a lift behind a counter just means they go when nobody is looking. + */ +/datum/unit_test/voidcrew_bounty_outpost/walk_out -/datum/unit_test/voidcrew_bounty_outpost/cleanup/Run() +/datum/unit_test/voidcrew_bounty_outpost/walk_out/Run() outpost = make_outpost() // Closing for real (P5's close() tells P6 before it removes anyone) var/datum/criminal_bounty/outpost_test/posting = make_posting() - var/mob/living/basic/bounty_criminal/fugitive = posting.criminal() - TEST_ASSERT(posting.setup_outpost_blend(), "The posting could not be set up to blend in") - var/list/leaving = decoys_of(posting) + fugitive - TEST_ASSERT_EQUAL(length(leaving), 4, "Expected the fugitive and three decoys") + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = posting.criminal() + TEST_ASSERT(posting.setup_outpost_blend(TRUE), "The posting could not be set up to blend in") + var/list/decoys = decoys_of(posting) + TEST_ASSERT_EQUAL(length(decoys), 3, "Expected the fugitive and three decoys") + var/mob/living/carbon/human/npc/bounty_criminal/decoy/dead_decoy = decoys[1] + var/mob/living/carbon/human/npc/bounty_criminal/decoy/downed_decoy = decoys[2] + var/mob/living/carbon/human/npc/bounty_criminal/decoy/free_decoy = decoys[3] + dead_decoy.death() + TEST_ASSERT(dead_decoy in SShuman_npcs.corpses, "A dead decoy is nobody's to clean up: the corpse sweep does not know it") posting.close("expired") // BOUNTY_CLOSE_EXPIRED - var/list/walks = list() - for(var/mob/living/walker as anything in leaving) - if(QDELETED(walker)) - continue - var/datum/component/bounty_outpost_exit/exit = walker.GetComponent(/datum/component/bounty_outpost_exit) - TEST_ASSERT(exit, "[walker] neither left nor was removed when the posting closed") - TEST_ASSERT(HAS_TRAIT(walker, TRAIT_GODMODE), "[walker] can be hurt on the way out") - if(exit.walk_loop) - walks += exit.walk_loop - TEST_ASSERT(length(walks), "Nobody set off for the lift they can reach") - // One is deleted mid-walk: its walk goes with it, and the pathfinder is never asked about it again - var/mob/living/deleted_walker = leaving[1] - var/datum/component/bounty_outpost_exit/deleted_exit = deleted_walker.GetComponent(/datum/component/bounty_outpost_exit) - var/datum/move_loop/deleted_walk = deleted_exit?.walk_loop - qdel(deleted_walker) - TEST_ASSERT(!deleted_walk || QDELETED(deleted_walk), "A walk outlived its walker") - // The rest fade (their walk would take a few seconds more) - for(var/mob/living/walker as anything in leaving) - if(QDELETED(walker)) - continue - var/datum/component/bounty_outpost_exit/exit = walker.GetComponent(/datum/component/bounty_outpost_exit) - exit?.fade_out() - TEST_ASSERT(!exit?.walk_loop, "[walker] kept walking while fading") - var/deadline = world.time + 5 SECONDS - UNTIL(world.time > deadline || !length(leaving - get_all_qdeleted(leaving))) - for(var/mob/living/walker as anything in leaving) - TEST_ASSERT(QDELETED(walker), "[walker] was still there after the posting closed") - - // Behind a counter the lift can't be reached: they fade where they stand, with no walk at all + + var/datum/ai_planning_subtree/walk_out = GLOB.ai_subtrees[/datum/ai_planning_subtree/human_npc_walk_out] + var/mob/living/carbon/human/person = allocate(/mob/living/carbon/human/consistent) + for(var/mob/living/carbon/human/npc/walker as anything in list(fugitive, downed_decoy, free_decoy)) + TEST_ASSERT(is_leaving(walker), "[walker] did not set off for the lift when the posting closed") + TEST_ASSERT_EQUAL(walker.npc_exit, run_loc_floor_top_right, "[walker] set off for somewhere other than the hangar lift") + TEST_ASSERT(!HAS_TRAIT(walker, TRAIT_GODMODE), "[walker] can't be hurt on the way out") + TEST_ASSERT_EQUAL(walker.move_resist, person.move_resist, "[walker] can't be moved on the way out") + TEST_ASSERT(walk_out in walker.ai_controller.planning_subtrees, "[walker]'s AI has no step that walks it out") // PHASE D CORE REQUEST: every bounty controller lists /datum/ai_planning_subtree/human_npc_walk_out, after the gate and before the activity + var/health_before = walker.health + walker.adjustBruteLoss(10) + TEST_ASSERT(walker.health < health_before, "A blow to [walker] on its way out did nothing") + // Shots hit whoever they hit, walking out or not + var/obj/projectile/bullet/shot = allocate(/obj/projectile/bullet) + shot.firer = make_hunter() + shot.original = walker + TEST_ASSERT_EQUAL(SEND_SIGNAL(walker, COMSIG_PROJECTILE_PREHIT, shot), 0, "[walker] on its way out lets shots through") + TEST_ASSERT(!is_leaving(dead_decoy), "A dead decoy set off for the lift") + TEST_ASSERT_NULL(dead_decoy.npc_exit, "A dead decoy has somewhere to walk to") + + // Downed and cuffed ones stay; the one on its feet goes when nobody can see it + downed_decoy.adjustOxyLoss(110) + var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs) + TEST_ASSERT(fugitive.equip_to_slot_if_possible(cuffs, ITEM_SLOT_HANDCUFFED), "Test fixture: the fugitive could not be cuffed") + SShuman_npcs.sweep_leavers() + TEST_ASSERT(QDELETED(free_decoy), "A decoy on its feet and out of sight was still there after the sweep") + TEST_ASSERT(!QDELETED(downed_decoy), "A decoy in crit was deleted on its way out") + TEST_ASSERT(!QDELETED(fugitive), "A cuffed fugitive was deleted on its way out") + TEST_ASSERT(!QDELETED(dead_decoy), "A dead decoy was deleted at once instead of by the corpse sweep") + // The posting is closed: nothing relists, and the cuffed fugitive was let go of + TEST_ASSERT_NULL(posting.relisted_for, "A closed posting relisted") + TEST_ASSERT_NULL(fugitive.posting_ref, "A fugitive the posting closed on is still linked to it") + + // Behind a counter the lift can't be reached: they still set off for it, and go when nobody is looking var/counter_y = run_loc_floor_bottom_left.y + 2 for(var/x in run_loc_floor_bottom_left.x to run_loc_floor_top_right.x) allocate(/obj/structure/table, locate(x, counter_y, run_loc_floor_bottom_left.z)) var/datum/criminal_bounty/outpost_test/released = make_posting(locate(run_loc_floor_bottom_left.x, run_loc_floor_top_right.y, run_loc_floor_bottom_left.z)) - TEST_ASSERT(released.setup_outpost_blend(), "The second posting could not be set up to blend in") + TEST_ASSERT(released.setup_outpost_blend(TRUE), "The second posting could not be set up to blend in") var/list/walkers = decoys_of(released) + released.criminal() - var/mob/living/stranded = walkers[1] + var/mob/living/carbon/human/npc/stranded = walkers[1] stranded.forceMove(run_loc_floor_bottom_left) released.outpost_release_site() TEST_ASSERT_EQUAL(length(released.decoys), 0, "The posting kept its decoys") TEST_ASSERT_NULL(released.criminal(), "The posting kept its fugitive") - var/datum/component/bounty_outpost_exit/stranded_exit = stranded.GetComponent(/datum/component/bounty_outpost_exit) - TEST_ASSERT(stranded_exit?.fading && !stranded_exit.walk_loop, "Someone who can't reach the lift set off for it") - for(var/mob/living/walker as anything in walkers) - var/datum/component/bounty_outpost_exit/exit = walker.GetComponent(/datum/component/bounty_outpost_exit) - TEST_ASSERT(exit, "[walker] did not leave") - exit.fade_out() - deadline = world.time + 5 SECONDS - UNTIL(world.time > deadline || !length(walkers - get_all_qdeleted(walkers))) - for(var/mob/living/walker as anything in walkers) + TEST_ASSERT(is_leaving(stranded), "Someone who can't reach the lift did not set off for it") + SShuman_npcs.sweep_leavers() + for(var/mob/living/carbon/human/npc/walker as anything in walkers) TEST_ASSERT(QDELETED(walker), "[walker] was still there after walking out") -/// Everything in `things` that has been deleted -/datum/unit_test/voidcrew_bounty_outpost/cleanup/proc/get_all_qdeleted(list/things) - . = list() - for(var/datum/thing as anything in things) - if(QDELETED(thing)) - . += thing + // A decoy sitting at the bar gets up to go + var/datum/criminal_bounty/outpost_test/seated = make_posting(run_loc_floor_bottom_left) + TEST_ASSERT(seated.setup_outpost_blend(TRUE), "The third posting could not be set up to blend in") + var/mob/living/carbon/human/npc/bounty_criminal/decoy/sitter = decoys_of(seated)[1] + var/obj/structure/chair/stool/bar/stool = allocate(/obj/structure/chair/stool/bar, get_turf(sitter)) + TEST_ASSERT(sitter.ai_sit_on(stool), "Test fixture: the decoy would not sit") + seated.outpost_release_site() + TEST_ASSERT(!sitter.buckled, "A decoy stayed in its seat when it was meant to leave") + TEST_ASSERT(is_leaving(sitter), "A decoy that got up did not set off") /// Each trader outpost map has one wanted board, on a wall of its concourse /datum/unit_test/voidcrew_bounty_outpost_maps @@ -732,45 +1061,14 @@ TEST_ASSERT_EQUAL(length(bounty_outpost_spawn_spots(outpost, 4)), 4, "[outpost_type] has no room for a fugitive and three decoys") qdel(outpost) -/// P2's drag rule holds while blending in: anyone down or cuffed can be dragged, the fugitive and its decoys alike (AR-C6); standing, nobody can -/datum/unit_test/voidcrew_bounty_outpost/drag - -/datum/unit_test/voidcrew_bounty_outpost/drag/Run() - outpost = make_outpost() - var/datum/criminal_bounty/outpost_test/posting = make_posting() - var/mob/living/basic/bounty_criminal/fugitive = posting.criminal() - TEST_ASSERT(posting.setup_outpost_blend(), "The posting could not be set up to blend in") - var/list/decoys = decoys_of(posting) - TEST_ASSERT(length(decoys), "No decoys to test with") - var/mob/living/basic/bounty_criminal/decoy/decoy = decoys[1] - var/mob/living/carbon/human/hunter = make_hunter() - - TEST_ASSERT(!fugitive.can_be_pulled(hunter, MOVE_FORCE_OVERPOWERING), "A standing fugitive blending in can be pulled") - TEST_ASSERT(!decoy.can_be_pulled(hunter, MOVE_FORCE_OVERPOWERING), "A standing decoy can be pulled") - // Down (a blast, say) while still blending in: both drag, so the drag gives nobody away - fugitive.downed = TRUE - decoy.downed = TRUE - TEST_ASSERT(fugitive.blended, "The fugitive stopped blending in without being hit") - TEST_ASSERT(fugitive.can_be_pulled(hunter, MOVE_FORCE_OVERPOWERING), "A downed fugitive blending in can't be dragged") - TEST_ASSERT(decoy.can_be_pulled(hunter, MOVE_FORCE_OVERPOWERING), "A downed decoy can't be dragged, so the fugitive stands out") - fugitive.downed = FALSE - decoy.downed = FALSE - // Walking out, never - var/datum/component/bounty_outpost_blend/blend = fugitive.GetComponent(/datum/component/bounty_outpost_blend) - blend.leaving = TRUE - fugitive.downed = TRUE - TEST_ASSERT(!fugitive.can_be_pulled(hunter, MOVE_FORCE_OVERPOWERING), "Someone walking out can be pulled") - fugitive.downed = FALSE - blend.leaving = FALSE - /// The right warrant: the nearest trader in sight calls out /datum/unit_test/voidcrew_bounty_outpost/room_reacts /datum/unit_test/voidcrew_bounty_outpost/room_reacts/Run() outpost = make_outpost() var/datum/criminal_bounty/outpost_test/posting = make_posting(run_loc_floor_bottom_left) - var/mob/living/basic/bounty_criminal/fugitive = posting.criminal() - TEST_ASSERT(posting.setup_outpost_blend(), "The posting could not be set up to blend in") + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = posting.criminal() + TEST_ASSERT(posting.setup_outpost_blend(TRUE), "The posting could not be set up to blend in") fugitive.forceMove(run_loc_floor_bottom_left) TEST_ASSERT_NULL(posting.outpost_trader_reacts(fugitive), "A trader reacted with no trader there") var/mob/living/basic/outpost_trader/far = allocate(/mob/living/basic/outpost_trader, run_loc_floor_top_right) diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_seams.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_seams.dm index 334a3c795fb..67be1367faf 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_seams.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_seams.dm @@ -10,7 +10,7 @@ /datum/unit_test/voidcrew_bounty_seams/Run() // Every criminal, decoy, companion and bounty object, made with no arguments. - for(var/type in typesof(/mob/living/basic/bounty_criminal, /mob/living/basic/bounty_companion, /obj/effect/bounty_sighting, /obj/item/paper/bounty_warrant, /obj/structure/bounty_wanted_board)) + for(var/type in typesof(/mob/living/carbon/human/npc/bounty_criminal, /mob/living/carbon/human/npc/bounty_companion, /obj/effect/bounty_sighting, /obj/item/paper/bounty_warrant, /obj/structure/bounty_wanted_board)) var/atom/thing = allocate(type) TEST_ASSERT(!QDELETED(thing), "[type] was deleted as it was made") diff --git a/voidcrew/modules/unit_tests/voidcrew_npc_zone_profiles.dm b/voidcrew/modules/unit_tests/voidcrew_npc_zone_profiles.dm index 742e3a0b459..fc17329ad1e 100644 --- a/voidcrew/modules/unit_tests/voidcrew_npc_zone_profiles.dm +++ b/voidcrew/modules/unit_tests/voidcrew_npc_zone_profiles.dm @@ -134,8 +134,8 @@ /mob/living/simple_animal/hostile/asteroid/elite, /mob/living/basic/boss, /mob/living/basic/trooper/pirate/faction/boss, - /mob/living/basic/bounty_criminal/boss, - /mob/living/basic/bounty_criminal/kingpin, + /mob/living/carbon/human/npc/bounty_criminal/boss, + /mob/living/carbon/human/npc/bounty_criminal/kingpin, /mob/living/basic/bounty_lair_boss, /mob/living/basic/lich, /mob/living/basic/hoarfrost_matriarch, @@ -587,111 +587,22 @@ controller.clear_target() /datum/unit_test/voidcrew_npc_zone_bounty_routes/Run() + // Bounty NPCs are real humans (human NPC migration, phase D): a zone never touches their health or + // their blows. Harder zones dress them in better armour instead (bounty_outfits.dm). var/turf/location = run_loc_floor_bottom_left var/datum/bounty_record/record = allocate(/datum/bounty_record) record.tier = 2 // BOUNTY_TIER_WANTED record.style = "brawler" - var/mob/living/basic/bounty_criminal/criminal = spawn_bounty_criminal(record, location, null) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = spawn_bounty_criminal(record, location, null) allocated += criminal - var/raw_health = criminal.body_tier_health() - criminal.npc_spawn_context.on_zone_resolved(3) - TEST_ASSERT(abs(criminal.maxHealth - raw_health * 1.8) < 0.001, "Criminal route finalized before body_setup") - criminal.setBruteLoss(criminal.maxHealth / 2) - var/mob/living/basic/bounty_criminal/decoy/decoy = allocate(/mob/living/basic/bounty_criminal/decoy, location) + criminal.npc_spawn_context?.on_zone_resolved(3) + TEST_ASSERT_EQUAL(criminal.maxHealth, 100, "A human criminal's health was zone-scaled") + TEST_ASSERT(!criminal.npc_zone_applied, "A human criminal took a zone profile") + var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy = allocate(/mob/living/carbon/human/npc/bounty_criminal/decoy, location) decoy.body_match(criminal) decoy.body_match(criminal) - TEST_ASSERT_EQUAL(decoy.npc_spawn_context.source_id, criminal.npc_spawn_context.source_id, "Decoy lost the fugitive source") - TEST_ASSERT_EQUAL(decoy.maxHealth, criminal.maxHealth, "Repeated body_match multiplied copied health") - TEST_ASSERT(abs(decoy.health / decoy.maxHealth - criminal.health / criminal.maxHealth) < 0.001, "Decoy copy changed health fraction") - var/mob/living/carbon/human/consistent/admin = allocate(/mob/living/carbon/human/consistent, run_loc_floor_top_right) - var/datum/bounty_admin_panel/unit_test/panel = allocate(/datum/bounty_admin_panel/unit_test, admin) - var/mob/living/basic/bounty_criminal/decoy/admin_decoy = panel.admin_spawn_decoy(admin, criminal) - TEST_ASSERT_NOTNULL(admin_decoy, "Admin decoy fixture failed") - allocated += admin_decoy - TEST_ASSERT_EQUAL(admin_decoy.maxHealth, criminal.maxHealth, "Admin decoy route stacked the copied pool") - var/datum/bounty_real_weapon/knife = bounty_real_weapon(/obj/item/knife/combat) - knife.apply_melee(criminal) - knife.apply_melee(criminal) - TEST_ASSERT(abs(criminal.melee_damage_upper - knife.force_high * 1.35) < 0.001, "Bounty weapon replacement stacked or lost the profile") - var/mob/living/basic/bounty_criminal/kingpin/kingpin = bounty_kingpin_setup(location, list(), null) - allocated += kingpin - kingpin.npc_spawn_context.on_zone_resolved(2) - TEST_ASSERT_EQUAL(kingpin.npc_zone_role, "boss", "The neutral lounge kingpin missed its explicit boss profile") - var/mob/living/basic/bounty_kingpin_goon/goon = kingpin.kingpin_crew.spawn_goon(run_loc_floor_top_right) - allocated += goon - TEST_ASSERT_EQUAL(goon.npc_spawn_context.zone_type, 2, "Replacement goon lost its kingpin's site band") - TEST_ASSERT_EQUAL(goon.npc_zone_role, "ordinary", "Goon inherited the kingpin's boss role") - TEST_ASSERT(abs(goon.maxHealth - goon.npc_zone_original_max_health * 1.35) < 0.001, "Replacement goon did not finalize") - kingpin.exempt_npc_zone() - var/mob/living/basic/bounty_kingpin_goon/owned_goon = kingpin.kingpin_crew.spawn_goon(location) - allocated += owned_goon - TEST_ASSERT(!owned_goon.npc_zone_applied && owned_goon.npc_zone_exempt, "Player ownership did not propagate to goons") - -/datum/unit_test/voidcrew_npc_zone_bounty_damage/Run() - var/turf/location = run_loc_floor_bottom_left - var/datum/npc_spawn_context/context = allocate(/datum/npc_spawn_context, src, 3, "boss") - var/mob/living/basic/bounty_criminal/boss/boss = spawn_npc_in_zone(/mob/living/basic/bounty_criminal/boss/juggernaut, location, context) - allocated += boss - var/mob/living/basic/npc_zone_test/victim = allocate(/mob/living/basic/npc_zone_test, run_loc_floor_top_right) - boss.boss_hit(victim, 10) - TEST_ASSERT_EQUAL(victim.getBruteLoss(), 12, "Raw boss ability escaped scaling") - boss.boss_hit(victim, 12, already_scaled = TRUE) - TEST_ASSERT_EQUAL(victim.getBruteLoss(), 24, "Scaled melee input multiplied twice") - var/list/table = boss.boss_health_table() - boss.boss_engaged = list("first" = TRUE, "second" = TRUE) - boss.boss_apply_posse_health(FALSE) - TEST_ASSERT(abs(boss.maxHealth - table[2] * 1.3) < 0.001, "Posse health lost the boss factor") - var/obj/effect/bounty_boss_explosive/explosive = allocate(/obj/effect/bounty_boss_explosive, location, boss) - var/obj/effect/bounty_boss_fire_pool/pool = allocate(/obj/effect/bounty_boss_fire_pool, location, list(location), 5 SECONDS, boss) - var/factor = boss.get_npc_zone_damage_factor() - qdel(boss) - TEST_ASSERT_EQUAL(explosive.damage_factor, factor, "Delayed explosive lost its creator's factor") - TEST_ASSERT_EQUAL(pool.damage_factor, factor, "Delayed fire lost its creator's factor") - victim.setMaxHealth(1000) - victim.updatehealth() - victim.mind_initialize() - victim.forceMove(location) - var/before_blast = victim.getBruteLoss() - var/raw_blast = explosive.damage - explosive.detonate() - TEST_ASSERT(abs(victim.getBruteLoss() - before_blast - raw_blast * factor) < 0.001, "Orphaned explosive fallback lost or doubled its captured factor") - var/before_fire = victim.getBruteLoss() - pool.scorch(10) - TEST_ASSERT(abs(victim.getBruteLoss() - before_fire - 10 * factor) < 0.001, "Orphaned fire pool lost its captured factor") - var/datum/status_effect/bounty_boss_burning/burning = victim.apply_status_effect(/datum/status_effect/bounty_boss_burning, factor) - // scorch already applied the refreshable effect. - burning = victim.has_status_effect(/datum/status_effect/bounty_boss_burning) - var/before = victim.getBruteLoss() - burning.tick(1) - TEST_ASSERT(abs(victim.getBruteLoss() - before - 3 * factor) < 0.001, "Lingering fire did not retain its numeric factor") // BOUNTY_BOSS_BURNING_DAMAGE - -/// Exercise the mafia override in a real club room, which bypasses base marker spawning. -/datum/unit_test/voidcrew_npc_zone_mafia_room - var/turf/room_floor - var/area/original_area - -/datum/unit_test/voidcrew_npc_zone_mafia_room/Destroy() - if(room_floor && original_area) - room_floor.change_area(get_area(room_floor), original_area) - return ..() - -/datum/unit_test/voidcrew_npc_zone_mafia_room/Run() - room_floor = run_loc_floor_bottom_left - original_area = get_area(room_floor) - var/area/ruin/space/has_grav/powered/mafia_club/casino/room = allocate(/area/ruin/space/has_grav/powered/mafia_club/casino) - room_floor.change_area(original_area, room) - var/obj/effect/zone_mobs/mafia/marker = allocate(/obj/effect/zone_mobs/mafia) - marker.forceMove(room_floor) - marker.do_spawn(3) - var/count = 0 - var/list/roster = bounty_mafia_room_crew(room.type) - for(var/mob/living/basic/trooper/russian/mafia/goon in room_floor) - allocated += goon - count++ - TEST_ASSERT(roster[goon.type], "Custom mafia marker escaped its existing room roster") - TEST_ASSERT_EQUAL(goon.npc_zone_role, "ordinary", "Custom mafia room output missed finalization") - TEST_ASSERT(abs(goon.maxHealth - goon.npc_zone_original_max_health * 1.8) < 0.001, "Custom mafia room output missed the selected factor") - TEST_ASSERT(count >= 1 && count <= 2, "Custom mafia marker escaped the 1-2 output budget") + TEST_ASSERT_EQUAL(decoy.maxHealth, 100, "Matching a decoy to its fugitive changed its health") + TEST_ASSERT_EQUAL(decoy.npc_damage_taken, criminal.npc_damage_taken, "A decoy isn't as tough as its fugitive") /// Field-route fixtures suppress offer generation, retaining the real spawn/tracking paths. /datum/mission/npc_zone_test/generate_mission_details() diff --git a/voidcrew/modules/unit_tests/voidcrew_outpost_npc_looks.dm b/voidcrew/modules/unit_tests/voidcrew_outpost_npc_looks.dm index 1ad2ac15fc1..db7a3326605 100644 --- a/voidcrew/modules/unit_tests/voidcrew_outpost_npc_looks.dm +++ b/voidcrew/modules/unit_tests/voidcrew_outpost_npc_looks.dm @@ -115,7 +115,6 @@ UNTIL(held_look_has_icon(npc, initial(mop_type.righthand_file)) || world.time > deadline) TEST_ASSERT_EQUAL(npc.held_visual, /obj/item/mop, "Holding a mop did not set held_visual") TEST_ASSERT(held_look_has_icon(npc, initial(mop_type.righthand_file)), "Holding a mop left no custodial right-hand overlay") - TEST_ASSERT_NULL(locate(/obj/effect/abstract/bounty_held) in npc.vis_contents, "An ambient NPC still carries the old pasted-icon holder") npc.set_held(null) deadline = world.time + 5 SECONDS UNTIL(!held_look_has_icon(npc, initial(mop_type.righthand_file)) || world.time > deadline) diff --git a/voidcrew/modules/unit_tests/voidcrew_outpost_prison_bounty.dm b/voidcrew/modules/unit_tests/voidcrew_outpost_prison_bounty.dm index 476543914c7..68fc806969b 100644 --- a/voidcrew/modules/unit_tests/voidcrew_outpost_prison_bounty.dm +++ b/voidcrew/modules/unit_tests/voidcrew_outpost_prison_bounty.dm @@ -1032,7 +1032,7 @@ TEST_ASSERT(marked(spot), "The fire patch is not marked at [spot.x],[spot.y]") TEST_ASSERT(get_turf(warden) in move.patch, "The fire patch misses the warden beside the bunk") TEST_ASSERT_EQUAL(warden.getFireLoss(), 0, "The warden burned before the match was thrown") - TEST_ASSERT(!warden.has_status_effect(/datum/status_effect/bounty_boss_burning), "The warden was alight before the match was thrown") + TEST_ASSERT(!warden.on_fire, "The warden was alight before the match was thrown") // A prisoner in the patch too: it goes up, the warden burns, the prisoner doesn't. var/mob/living/basic/outpost_prisoner/cellmate = kept_prisoner(prison, prison_spot(home, 2, 14)) @@ -1044,8 +1044,8 @@ TEST_ASSERT(get_dist(spot, bunk) <= 1, "The fire burns at [spot.x],[spot.y], past the tiles beside the bunk") TEST_ASSERT(prison.in_cell_block(spot), "The fire burns outside the cell block") TEST_ASSERT(warden.getFireLoss() > 0, "The burning bunk did not burn the warden beside it") - TEST_ASSERT(warden.has_status_effect(/datum/status_effect/bounty_boss_burning), "The burning bunk did not set the warden alight") - TEST_ASSERT(!cellmate.has_status_effect(/datum/status_effect/bounty_boss_burning), "The burning bunk set a prisoner alight") + TEST_ASSERT(warden.on_fire, "The burning bunk did not set the warden alight") // tg fire stacks (human NPC phase D, CB-8) + TEST_ASSERT(!cellmate.on_fire, "The burning bunk set a prisoner alight") TEST_ASSERT_EQUAL(cellmate.health, cellmate_health, "The burning bunk hurt a prisoner") // Not again inside the cooldown (PRISON_BOSS_FIRE_COOLDOWN). diff --git a/voidcrew/modules/unit_tests/voidcrew_zone_identity.dm b/voidcrew/modules/unit_tests/voidcrew_zone_identity.dm index 5c2c7c53431..409ead1de8b 100644 --- a/voidcrew/modules/unit_tests/voidcrew_zone_identity.dm +++ b/voidcrew/modules/unit_tests/voidcrew_zone_identity.dm @@ -188,12 +188,12 @@ var/obj/machinery/mission_pad/pad = allocate(/obj/machinery/mission_pad, deck) var/datum/criminal_bounty/posting = board_test_posting(2) // BOUNTY_TIER_WANTED var/datum/bounty_record/record = posting.record - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, field) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, field) TEST_ASSERT(istext(posting.turn_in(pad, ship)), "A criminal absent from the pad was accepted") TEST_ASSERT_EQUAL(crew.reputation, 0, "A refused turn-in earned reputation") var/list/card = posting.board_ui_entry(ship, pad) TEST_ASSERT_EQUAL(card["reputation_gain"], 2, "The wanted card lost what it is worth") - criminal.body_go_down() + criminal.adjustBruteLoss(110) // into tg crit TEST_ASSERT_EQUAL(record.board_work_zone, 2, "Capture did not bind its actual field band") TEST_ASSERT_EQUAL(crew.reputation, 0, "Capture earned reputation before a paying turn-in") criminal.forceMove(deck) @@ -234,7 +234,7 @@ var/turf/field = make_zone_turf(locate(home.x + band, home.y, home.z), band) for(var/index in 1 to 3) var/datum/criminal_bounty/posting = board_test_posting(3) // BOUNTY_TIER_MOST_WANTED - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, field) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, field) criminal.death() TEST_ASSERT_EQUAL(posting.record.board_work_zone, band, "Death did not bind its field band") criminal.forceMove(deck) @@ -253,8 +253,8 @@ tier_posting.record.status = "escaped" TEST_ASSERT_EQUAL(tier_posting.board_claim_zone_work(ship), 0, "An escaped prisoner earned reputation") TEST_ASSERT(!tier_posting.record.board_reputation_claimed, "An unpaid escape consumed a reputation claim") - var/mob/living/basic/bounty_criminal/admin_spawn = allocate(/mob/living/basic/bounty_criminal, home) - admin_spawn.body_go_down() + var/mob/living/carbon/human/npc/bounty_criminal/admin_spawn = allocate(/mob/living/carbon/human/npc/bounty_criminal, home) + admin_spawn.adjustBruteLoss(110) // into tg crit TEST_ASSERT_NULL(admin_spawn.posting(), "An admin spawn acquired a posting") TEST_ASSERT_EQUAL(crew.reputation, 20, "An admin spawn earned reputation") @@ -265,8 +265,8 @@ var/obj/structure/overmap/ship/ship = paid_ship(deck, home) var/obj/machinery/mission_pad/pad = allocate(/obj/machinery/mission_pad, deck) var/datum/criminal_bounty/posting = board_test_posting(2, null, 1000, 0, "normal") - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, field) - criminal.ai_surrender() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, field) + criminal.npc_surrender() // tg *surrender TEST_ASSERT_EQUAL(posting.record.board_work_zone, 2, "Surrender did not bind the field band") criminal.forceMove(deck) TEST_ASSERT(islist(posting.turn_in(pad, ship)), "An uncuffed surrendered criminal was not paid") @@ -276,8 +276,8 @@ var/turf/field = make_zone_turf(run_loc_floor_bottom_left, 2) var/datum/criminal_bounty/posting = board_test_posting(2) var/datum/bounty_record/record = posting.record - var/mob/living/basic/bounty_criminal/criminal = board_test_criminal(posting, field) - criminal.body_go_down() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, field) + criminal.adjustBruteLoss(110) // into tg crit TEST_ASSERT_EQUAL(record.board_work_zone, 2, "The first sighting did not bind its capture band") TEST_ASSERT(posting.relist("slipped away"), "The escape did not start relisting") TEST_ASSERT_NULL(record.board_work_zone, "An escaped sighting kept its old work band") diff --git a/wiki/content/bounty-hunting.md b/wiki/content/bounty-hunting.md index 1b77b7de862..1d9966e2f51 100644 --- a/wiki/content/bounty-hunting.md +++ b/wiki/content/bounty-hunting.md @@ -5,7 +5,7 @@ order: 2.5 blurb: Hunt wanted criminals from your mission board, bring them to your mission pad alive for full pay, and send them on to outpost prisons. --- -Wanted criminals hide out on planets, in ruins, aboard pirate ships and among the patrons of trader outposts. Take a bounty from your ship's mission board, find the criminal, subdue them and bring them to your ship's mission pad. They pay the most when they arrive stunned or cuffed and were never downed. Pay works like [missions](missions.md): credits go to the ship account and vouchers appear on the pad. A criminal caught alive goes on to serve time in a player outpost's [prison wing](prison-wing.md). +Wanted criminals hide out on planets, in ruins, aboard pirate ships and among the patrons of trader outposts. Take a bounty from your ship's mission board, find the criminal, subdue them and bring them to your ship's mission pad. They pay the most when they arrive stunned or cuffed. Pay works like [missions](missions.md): credits go to the ship account and vouchers appear on the pad. A criminal caught alive goes on to serve time in a player outpost's [prison wing](prison-wing.md). ## The bounty board @@ -23,7 +23,7 @@ Each card is a wanted poster: - the mugshot, name, species, sex and alias. "Old photo" under the mugshot means it shows how they used to look (a trader-outpost fugitive); - how they're wanted and what for: **Wanted alive**, **Wanted dead or alive** (the kingpin) or **Wanted dead** (lairs and the lich); - where they were last seen, and the zone; -- the reward: the full pay, in credits and vouchers. The card doesn't show what a downed or dead catch pays; see [the pad and turning in](#the-pad-and-turning-in); +- the reward: the full pay, in credits and vouchers. The card doesn't show what a catch in critical condition or dead pays; see [the pad and turning in](#the-pad-and-turning-in); - the time left. The card doesn't say what kind of criminal it is, or how they fight. [The three kinds of criminal](#the-three-kinds-of-criminal) below does. A private offer shows no mugshot until you accept it. @@ -47,7 +47,7 @@ The reward is fixed when the bounty is posted. It depends on the tier and the zo | Public bounty | 45 minutes. The clock stops while a crew hunts it, for up to 30 minutes of each crew's hunt. | | Private offer | 20 minutes to accept it, then 30 minutes to bring them in. | -Successful paid criminal turn-ins earn [reputation](zone-reputation.md): Petty counts as easy, Wanted as medium, and Most Wanted or a boss as hard. Alive, downed and dead settlements count. The criminal's first capture or death fixes the zone; moving them to another pad does not change it. Lair and other kill-only trophies count as hard. The poster shows what it is worth to your crew, and the turn-in notice says what you got. +Successful paid criminal turn-ins earn [reputation](zone-reputation.md): Petty counts as easy, Wanted as medium, and Most Wanted or a boss as hard. Alive, critical and dead settlements count. The criminal's first capture or death fixes the zone; moving them to another pad does not change it. Lair and other kill-only trophies count as hard. The poster shows what it is worth to your crew, and the turn-in notice says what you got. ## Taking a bounty @@ -71,7 +71,7 @@ A criminal appears once their site is loaded, away from any players. What they'r Tap a handheld GPS on the mission board, or press **Link Mission Beacons** while wearing a MODsuit with a GPS module. This links the sighting beacon (tagged WANTED) of every bounty your ship hunts. The beacon moves every 2 minutes to a spot within 5 tiles of the criminal, and stays put while they are hiding. There's no beacon at trader outposts. -If you leave and the site unloads, the criminal goes with it. They're back the next time it loads, fully healed and out of any cuffs. They still count as the worst state they ever reached, so one you downed never pays full afterwards. +If you leave and the site unloads, the criminal goes with it. They're back the next time it loads, unhurt and out of any cuffs. One who was dead when the site unloaded comes back as their evidence tag. Meek and normal criminals notice anyone within 6 tiles holding a weapon, cuffs or a warrant, and a meek one also notices anyone running at them. Walk up with empty hands. Mini-bosses go for any hunter they see. @@ -81,11 +81,11 @@ Meek and normal criminals notice anyone within 6 tiles holding a weapon, cuffs o About 70% of Petty criminals and 30% of Wanted ones are meek. They never start a fight. -- They sprint faster than you can run, and duck about half the shots fired at them while sprinting. After about 8 seconds of sprinting they're winded and slow down. -- They hide in a locker or crate, pose as a potted plant, or stand still on a dark tile. Opening the locker, bumping into them, examining them from the next tile, hurting them, or lighting up their dark spot finds them. They shove you back a tile and run again. +- They run as fast as you do, faster for a while once they jab the stimpack they carry. A reflex implant makes the odd shot miss while they're moving. They tire like anyone. +- They hide in a locker or crate, pose as a potted plant, or stand still on a dark tile. Opening the locker, bumping into them, examining them from the next tile, hurting them, or lighting up their dark spot finds them. They shove you and run again. - After a minute and a half in hiding they start to fidget: a rustle or a shake every 20 seconds. If nobody is around for a few minutes, they come out. -- Cornered, they shout and aim a small pistol for half a second, then fire eight quick shots. A stamina hit during the aim makes them fumble it. -- 120 base health before [zone scaling](threats-and-elites.md). Three disabler shots stun one. +- Cornered, they shout, pull a small pistol out of a pocket, aim for half a second and empty it at you. A hit during the aim makes them fumble it. +- They're as tough as anyone. Four disabler shots stun one. **Bring:** a disabler or other ranged stun, a flashlight, cuffs, and someone to block the exits. @@ -97,49 +97,50 @@ About 70% of Petty criminals and 30% of Wanted ones are meek. They never start a About 70% of Wanted criminals and 30% of Petty ones are normal. A Wanted criminal on a pirate ship is always normal. - They notice anyone holding a weapon, cuffs or a warrant within 6 tiles. Cuffs or a warrant and they stop and watch you. A weapon out and they fight. -- Each has one fighting style: fists (tougher, and harder to stun), a knife (cuts that bleed), a pistol (keeps its distance and empties a 15-round magazine before reloading), a shotgun loaded with buckshot (close range, reloads after four shells), a baseball bat (knocks you back) or thrown bottles. Wanted criminals carry a combat knife, a metal bat or a combat shotgun instead. Their weapons use the real item's damage, increased by the spawn zone. Their displayed weapon does not guarantee a loot drop. -- They may have up to two companions who fight beside them. Companions pay nothing. They may run when badly hurt or when their criminal goes down, and give up for good once stunned. -- Below 40% health, with two hunters nearby who can see them, they may give up and put their hands up. Someone who has given up counts as stunned: cuff them for full pay. Stop hitting them, because they can still be downed. -- Badly hurt with nobody around, they break off and retreat. They never heal. +- Each has one fighting style, with a real weapon they carry and draw when the fight starts: fists (and shoves), a knife, a machine pistol with a spare magazine, a pump shotgun with buckshot, a baseball bat or thrown bottles. Wanted criminals carry a combat knife or a semi-automatic shotgun instead. Their guns run dry and they reload them like you do. +- Wanted criminals wear an armour vest, and Most Wanted a vest and a helmet. Nothing a criminal carries can be taken: it goes with the body. +- They may have up to two companions who fight beside them. Companions pay nothing. They may run when badly hurt or when their criminal goes down, and when they come round from a stun they may give up or run. +- Badly hurt, with two hunters nearby who can see them, they may give up: they put their weapon away, put their hands on their head and lie down for 20 seconds. Cuff them then for full pay. If nobody does, they get up and decide again. +- Badly hurt with nobody around, they break off, sit down and patch themselves up with what they carry. **Bring:** a partner, stun weapons, armour and cuffs. ### Mini-bosses -Every Most Wanted criminal is a mini-boss with one of five kits. Bosses and their companions also use the [zone health and damage profile](threats-and-elites.md). The board's **Other crews hunting** line excludes your own active hunt. +Every Most Wanted criminal is a mini-boss with one of five kits. The board's **Other crews hunting** line excludes your own active hunt. -- Their health grows with the number of hunters who can see them when the fight starts, and with anyone who hurts them later. -- Every ability winds up first, with a sound and a mark on the floor. Move out of the mark. +- They wear their kit's armour and take hits better than most people. +- Every hunter after the first brings one more of their crew, who turns up from somewhere out of sight. +- Every ability winds up first, with a sound and a mark on the floor. Move out of the mark. Fire, blasts and blades hurt whoever is standing there, down or not. - They break tables, chairs, windows and grilles, and up to two interior walls or doors in a fight. -- While fresh they ignore stuns and stamina damage completely. -- Below 40% health they are **worn out**: "breathing hard and slowing down". They move slower, use their abilities less often, and stun weapons work on them. About five disabler shots stun one (six for the Heavy). -- They go down at 25% health. Between 40% and 25% is your window to stun and cuff them for full pay. -- After getting up from being downed, they shrug off stamina damage for 20 seconds. +- At the start of a fight they jab a stimulant: for a while they shrug off batons and get up from stuns quickly. They carry a second for later. +- Badly hurt or out of breath they're **worn out**: "breathing hard and slowing down", and they fall back for a moment. That's the time to stun and cuff them. | Kit | Looks like | What it does | How to handle it | |---|---|---|---| -| Juggernaut | An armoured criminal in riot plates | Charges along a line after a roar, smashing what's in the way. Slams the floor around it when you're close. Resists damage. | Step off the charge line. If it charges into something it can't break, it reels for 2 seconds and takes extra damage. | -| Pyromaniac | A scorched criminal in a fire suit | Sweeps a cone of fire 3 tiles long and throws molotovs that leave burning floor. Fire can't hurt it. | Stay more than 3 tiles away and off burning floor. Use lasers or bullets, not fire. | +| Juggernaut | A giant in riot plates | Charges along a line after a roar, smashing what's in the way. Slams the floor around it when you're close. | Step off the charge line. If it charges into something it can't break, it hurts itself and falls down for a few seconds. | +| Pyromaniac | A scorched criminal in a fire suit | Sweeps a cone of fire 3 tiles long and throws molotovs that leave burning floor. Its fire suit keeps the flames off it. | Stay more than 3 tiles away and off burning floor. If you catch fire, stop, drop and roll, or use an extinguisher. | | Demolitionist | A criminal in a hard hat with a grenade bandolier | Keeps 4 to 6 tiles away and throws grenades with a blinking fuse. Blows holes in interior walls and doors to reach you behind cover. | Close the distance, and move off the blinking ring. | -| Ghost | A hooded criminal with a long knife | Fast. Dashes in with cuts that bleed, cloaks into a shimmer, dodges shots while moving, and backs off after two cuts. | A flash or a hit breaks the cloak. Shoot it when it stops moving. | -| Heavy | A heavily armed criminal with a belt-fed gun | Heavy armour, slow. Shows a laser sight and a red cone, then fires a burst into it. Drops a barricade that stops half your shots. | Get out of the red cone before it fires. Go around the barricade. | +| Ghost | A hooded criminal with a combat knife | Fast. Dashes in with knife cuts that bleed, cloaks into a shimmer, and backs off after two cuts. Its implants make shots miss now and then while it moves, much more often during its burst of speed. | A flash or a hit breaks the cloak, and an EMP ends the burst. Shoot it when it stops moving. | +| Heavy | A heavily armed criminal with a belt-fed gun | Heavy armour, slow. Shows a laser sight and a red cone, then fires a burst into it. Throws barrier grenades that open into a barricade. | Get out of the red cone before it fires. Go around the barricade. | !!! warning "Worn out means switch to stuns" - Once a mini-boss is worn out, stop using lethal weapons. A few more hits put it under 25%, and a downed criminal only pays 60%. + A mini-boss in critical condition only pays 60% on the pad. Once it's worn out, stun it and cuff it, or patch it up before you turn it in. ## Taking them alive -- **Downed.** At 25% health a criminal collapses. A hit on one still standing can't take them past that line, so one shot never kills them. A downed criminal can still be killed. -- **They get back up.** Meek criminals after 60 seconds, normal ones after 75, mini-bosses after 45. They groan and try to rise for the last 10 seconds. Cuffed, they stay down. A stamina hit on a downed criminal starts their clock over. -- **Cuffs** only go on a criminal who is downed, stunned or has given up, and take 2 seconds. Reaching for a free one's wrists sets them off: a meek one runs and a normal one fights. -- **Restraints.** Handcuffs hold for good. Cable restraints slip after 3 minutes and zipties after 5, with a visible struggle for the last 20 seconds. Mini-bosses snap them in half the time. -- **Dragging.** You can pull a criminal who is downed, stunned, cuffed or dead. A free one pulls away. -- **Carrying.** A criminal lying on the floor who could be dragged can also be carried over your shoulders: grab them aggressively, then drag them onto yourself. They squirm off once they come round or get up. -- **No shortcuts.** Criminals can't be teleported. Transporters won't beam a locker, crate or bag with one inside, fultons won't attach to them, and a bluespace body bag won't fold with a live one in it. Carry them to your ship. -- Turrets, traps, fire and wildlife on their site can't take a criminal below 40% health. +Criminals are people. They bleed, break bones, fall into critical condition and die the way you do, and medicine, cuffs and stuns work on them the way they work on you. -!!! tip "Bring cuffs" - A stun wears off about 10 seconds after the last stamina hit (12 for a meek criminal). Cuffing takes 2. Have the cuffs in hand before you stun them. +- **Critical condition.** Hurt badly enough, a criminal collapses in critical condition, and stays down until someone treats them. Left alone they can bleed out or stop breathing, like anyone. +- **Stuns.** Batons, disablers, flashes, shoves, sedatives and anything else that stuns a person stuns a criminal. Armour and stimulants make some of them harder to put down. +- **Cuffs** are ordinary cuffs: four seconds, on anyone who stays still for them. A criminal on their feet sees you reach for their wrists and steps away, then runs or fights. Stun them first, or wait until they give up. +- **Getting out.** A cuffed criminal works at the cuffs: about a minute for handcuffs, 45 seconds for zipties and 30 for cable restraints. Dragging them breaks their concentration. +- **Dragging and carrying** work as on anyone. A criminal who can still move pulls free of a grab or squirms off your shoulders. +- **No shortcuts.** Criminals can't be teleported. Transporters won't beam a locker, crate or bag with a living one inside, fultons won't attach to them, and a bluespace body bag won't fold while someone alive is struggling inside. Carry them to your ship. +- **Patching up.** Some criminals carry bandages or medipens and use them when nobody is shooting at them. + +!!! tip "Bring cuffs and a stun" + A stun only lasts a little while. Have the cuffs in hand before you stun them. ## The pad and turning in @@ -147,20 +148,20 @@ Every Most Wanted criminal is a mini-boss with one of five kits. Bosses and thei - The pad must be bolted down and aboard your ship. - The pad says who is on it and what state they're in ("On the pad: Tess Harlow, restrained."), and why it won't take them if it won't. It never says what they'll pay. - Press **Turn In** on their card. If it's greyed out, its tooltip says why. -- The pad beams them away over 3 seconds. Credits go to the ship account. Vouchers appear on the pad. Your ship's notice says what state they were in and what was paid. +- The pad beams them away over 3 seconds. Credits go to the ship account. Vouchers appear on the pad, and so do your cuffs. Your ship's notice says what state they were in and what was paid. -Pay follows the **worst** state the criminal ever reached: +Pay follows the state they're in **on the pad** when you press Turn In: | State | Pays | |---|---| -| Stunned, given up or cuffed, and never downed | The full reward, with vouchers | -| Downed at any point, even if cuffed or back on their feet since | 60% | +| Stunned, given up or cuffed | The full reward, with vouchers | +| In critical condition | 60% | | Dead, or their evidence tag | 25% | | Standing and free | Refused | -Below full pay you get no vouchers. Instead, each voucher counts as 1,200 cr before the percentage is taken, and it's all paid in credits. For example, a Wanted criminal worth 1,400 cr and a voucher pays 1,560 cr downed and 650 cr dead. +What happened before doesn't count: a criminal you put in critical condition, patched up and cuffed pays in full. Below full pay you get no vouchers. Instead, each voucher counts as 1,200 cr before the percentage is taken, and it's all paid in credits. For example, a Wanted criminal worth 1,400 cr and a voucher pays 1,560 cr in critical condition and 650 cr dead. -A dead criminal can't be revived. If the body is destroyed (gibbed, dusted, or lost in lava or a chasm), an **evidence tag** turns up nearby. It pays the dead share. If nothing at all is left, the bounty lists again somewhere else 5 minutes later. +A dead criminal can be revived like anyone, and then pays for the state they're in. If the body is destroyed (gibbed, dusted, or lost in lava or a chasm), an **evidence tag** turns up nearby. It pays the dead share. If nothing at all is left, the bounty lists again somewhere else 5 minutes later. A bounty pays once. ## Trader outposts @@ -173,9 +174,9 @@ Guns, disablers included, don't get past the outpost's checkpoint unless you buy - Examine a patron to see their distinguishing features: hair, a scar, a tattoo, a scarf, a limp, glasses, a missing ear. Each look-alike shares one or two of the fugitive's features, never all of them. The warrant lists all of them but one. - **Ask the traders.** While your ship hunts the bounty, every trader, the barkeep included, has an **Ask about the wanted person** option. Each gives your ship one clue, and each trader a different one: where the fugitive was seen, how their hair looks now, one of their features, or one patron who isn't them. - **Show the warrant** to the one you think it is. The right person drops the act: a meek one runs, a normal one fights. Anyone else protests and shows you a docking pass. Your ship can show a warrant once every 30 seconds. -- **The alert.** Showing the warrant to the wrong patron raises the alert. So does hitting a look-alike on purpose: a punch, a shove, a baton, a thrown item, a shot aimed at them, or reaching for their wrists with cuffs. Hitting a look-alike is also an outpost strike. At two alerts, the fugitive and the look-alikes walk out to the hangar and leave, and the bounty lists at a different trader outpost 5 minutes later. +- **The alert.** Showing the warrant to the wrong patron raises the alert. So does hitting a look-alike on purpose: a punch, a shove, a baton, a thrown item, a shot aimed at them, or reaching for their wrists with cuffs. Hitting a look-alike is also an outpost strike. At two alerts, the fugitive and the look-alikes walk out to the hangar and leave, and the bounty lists at a different trader outpost 5 minutes later. Stop the fugitive before they reach the lift and they're still yours to take. - Hitting the right patron on purpose exposes them, the same as the warrant. -- While they blend in, nobody can pull them, and shots aimed at someone else pass through them. The outpost's turrets leave them alone. An exposed fugitive only fights the people who came for it. If it hurts a bystander, the turrets can fire on it. +- Shots hit whoever is in the way, look-alikes included, and hitting a look-alike is an outpost strike. The outpost's turrets leave the patrons alone. An exposed fugitive only fights the people who came for it. If it hurts a bystander, the turrets can fire on it. ## Pirate ships @@ -198,14 +199,14 @@ A crime boss holds court in the lounge at the Undertow Exchange from the start o - The first posting comes at least 45 minutes into the round, with three or more active crews. The next comes 60 to 90 minutes after the last one ends. - He can only be turned in while he's on the board, wherever he is when it goes up. Kill him before that and there's nothing to claim. - He stays on the board for 60 minutes, and the clock stops during a shootout. If time runs out while he's in his lounge, he stays there. -- Alive, he pays 6,500–9,100 cr and 2 vouchers, and downed counts as alive. Dead, he pays 80%, all in credits. +- Alive, he pays 6,500–9,100 cr and 2 vouchers, and critical condition counts as alive. Dead, he pays 80%, all in credits. - Once he's turned in or killed, he's gone for the rest of the round. **The shootout.** "We're here for you.", or any attack on him or a goon, starts it. - The goons reach for their guns for about half a second before anyone fires. No more than two of them draw on one hunter at once. Three carry pistols, two shotguns and one an SMG. They stay near the sofa, and never shoot anyone who is down. -- He never leaves the sofa. Before each shot he aims his .357 revolver at someone with a red line for half a second. He reloads after seven shots. -- Once his goons are down and he's below 40% health, he may give up. He goes down at 25% and gets up after 60 seconds unless cuffed. Five disabler hits in quick succession stun him. +- He never leaves the sofa. Before each shot he aims his .357 revolver at someone with a red line for half a second, and a hit spoils his aim. He reloads with a speedloader. +- Once his goons are down and he's badly hurt, he may give up. He wears an armoured coat, and his goons wear armour vests. - When he falls, half the goons left run for it. - The outpost's turrets stay out of it. Fighting his crew earns no outpost strikes, but hitting other players still does. @@ -225,8 +226,8 @@ A mob nightclub run by Arkady Sokolov, placed in the Contested or Lawless Zone f - The staff room off the main floor has two rechargers, a first aid locker and no goons. The counting room's vault has a loot cache. - Two lieutenants hold the back office: **Tommy** with a Tommy gun, and **Brute**, whose punches can knock you down. Kill both and the garage door opens. - The don waits in the garage in his Mauler. Its health grows with the number of hunters. Its rocket volley marks the floor under each hunter it can see, then fires one rocket at each mark, so get behind a pillar. Its machine gun shows a red cone first. Up close it stomps, throwing you back. An EMP stalls it for 2 seconds. It comes after anyone who hurts it, so you can't pick it off from out of its sight. If nobody fights it for a minute, it goes back to full health. -- When the mech breaks, the don climbs out and fights on foot with his gold Desert Eagle from behind the wreck. He can't be cuffed. His **gold signet ring** is the trophy. -- Nobody in the club shoots a hunter who is down. +- When the mech breaks, the don climbs out and fights on foot with his gold Desert Eagle from behind the wreck. He never gives up, and cuffing him pays nothing: his **gold signet ring** is the trophy. +- Nobody in the club shoots a hunter who is down, but a rocket hits whoever stands under it. ### The lich @@ -266,11 +267,11 @@ The warden's console has a **Bounty prisoners** setting: **All**, **No Most Want **Why is Turn In greyed out?** The criminal has to be on the pad's own tile, not in a locker or bag. The pad has to be bolted down and aboard your ship. A criminal standing free is refused. -**Why did we only get 60%?** They were downed at some point. Pay follows the worst state they ever reached. +**Why did we only get 60%?** They were in critical condition on the pad. Treat them first: a criminal patched up and cuffed pays in full. -**They got up and ran off.** Downed criminals recover unless cuffed. Cuff them as soon as they're down, or stun them before they go down. +**They got out of the cuffs and ran off.** Criminals work at their cuffs when nobody's dragging them. Keep hold of them on the way to the pad. -**They vanished when we left the planet.** The site unloaded. They'll be back, fully healed, the next time it loads. +**They vanished when we left the planet.** The site unloaded. They'll be back, unhurt, the next time it loads. **We abandoned a bounty. Can we still turn them in?** Yes, if it's still up and you bring them to your pad. You just can't hunt it again. From 9cf573307cb1eb85136a5c450eaa3ccface4d306 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sun, 15 Nov 2026 17:25:34 -0800 Subject: [PATCH 04/13] Mission waves arrive by drop pod or dig out of the ground Defender waves from missions no longer appear out of nowhere beside the crew. Pirates and robots drop in by supply pod, one pod per mob, and the Syndicate uses its own pod; bugs, wildlife, asteroid fauna, undead and cult dig up out of the ground, the tile shaking before the mob rises. Arrivals scatter up to 4 tiles away and never land on a tile someone is standing on. Covers survey pylon calibration, both Hot Extraction alarm waves, the Field Expedition ambush and claim-beacon defense. Mapped ruin guards still spawn instantly. --- tgstation.dme | 1 + voidcrew/_DEFINES/missions.dm | 7 ++ voidcrew/modules/loot/themes/expedition.dm | 2 + voidcrew/modules/loot/themes/occult.dm | 2 + voidcrew/modules/loot/themes/research.dm | 1 + voidcrew/modules/loot/themes/syndicate.dm | 1 + voidcrew/modules/loot/zone_mobs.dm | 23 ++++- voidcrew/modules/loot/zone_mobs_arrival.dm | 84 +++++++++++++++++++ .../missions/missions/field_expedition.dm | 2 +- .../missions/missions/recovery_variants.dm | 4 +- .../modules/missions/objectives/site_ops.dm | 4 +- 11 files changed, 123 insertions(+), 8 deletions(-) create mode 100644 voidcrew/modules/loot/zone_mobs_arrival.dm diff --git a/tgstation.dme b/tgstation.dme index c15906369fe..1548a110bbe 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7315,6 +7315,7 @@ #include "voidcrew\modules\loot\loot_guns.dm" #include "voidcrew\modules\loot\zone_loot.dm" #include "voidcrew\modules\loot\zone_mobs.dm" +#include "voidcrew\modules\loot\zone_mobs_arrival.dm" #include "voidcrew\modules\loot\zone_resolution.dm" #include "voidcrew\modules\loot\themes\_theme.dm" #include "voidcrew\modules\loot\themes\armory.dm" diff --git a/voidcrew/_DEFINES/missions.dm b/voidcrew/_DEFINES/missions.dm index 5f3388d0b53..add1428d01a 100644 --- a/voidcrew/_DEFINES/missions.dm +++ b/voidcrew/_DEFINES/missions.dm @@ -97,3 +97,10 @@ /obj/effect/zone_mobs/undead = 3,\ /obj/effect/zone_mobs/bug = 3,\ ) + +/// zone_mobs wave arrivals: a drop pod lands the mob +#define ZONE_MOBS_ARRIVE_POD "pod" +/// zone_mobs wave arrivals: the mob digs up out of the ground +#define ZONE_MOBS_ARRIVE_EMERGE "emerge" +/// How far a wave's arrivals scatter from the spot that called them +#define ZONE_MOBS_WAVE_SCATTER 4 diff --git a/voidcrew/modules/loot/themes/expedition.dm b/voidcrew/modules/loot/themes/expedition.dm index 9bd98aee396..998f18b4288 100644 --- a/voidcrew/modules/loot/themes/expedition.dm +++ b/voidcrew/modules/loot/themes/expedition.dm @@ -117,6 +117,7 @@ /// Planet fauna: territorial wildlife around and inside surface ruins. /obj/effect/zone_mobs/wildlife name = "zone mob spawner (wildlife)" + wave_arrival = ZONE_MOBS_ARRIVE_EMERGE mobs_green = list( /mob/living/basic/mining/bileworm = 8, /mob/living/basic/mining/lobstrosity = 6, @@ -160,6 +161,7 @@ /// asteroid ruin, everything in these tables survives space. /obj/effect/zone_mobs/asteroid name = "zone mob spawner (asteroid)" + wave_arrival = ZONE_MOBS_ARRIVE_EMERGE mobs_green = list( /mob/living/basic/mining/goldgrub = 8, /mob/living/basic/mining/hivelord = 6, diff --git a/voidcrew/modules/loot/themes/occult.dm b/voidcrew/modules/loot/themes/occult.dm index e9e98726474..2bbfab11449 100644 --- a/voidcrew/modules/loot/themes/occult.dm +++ b/voidcrew/modules/loot/themes/occult.dm @@ -118,6 +118,7 @@ /// Cult remnants: constructs still bound to a dead master's wards. /obj/effect/zone_mobs/cult name = "zone mob spawner (cult)" + wave_arrival = ZONE_MOBS_ARRIVE_EMERGE mobs_green = list( /mob/living/basic/construct/proteon/hostile = 10, ) @@ -146,6 +147,7 @@ /// The restless dead: graves, derelicts, plague sites. /obj/effect/zone_mobs/undead name = "zone mob spawner (undead)" + wave_arrival = ZONE_MOBS_ARRIVE_EMERGE mobs_green = list( /mob/living/basic/skeleton = 10, /mob/living/basic/zombie = 6, diff --git a/voidcrew/modules/loot/themes/research.dm b/voidcrew/modules/loot/themes/research.dm index 0d1b04cd1cb..5ab110ccda4 100644 --- a/voidcrew/modules/loot/themes/research.dm +++ b/voidcrew/modules/loot/themes/research.dm @@ -120,6 +120,7 @@ /// Infested nests: giant spiders. Webs sold separately. /obj/effect/zone_mobs/bug name = "zone mob spawner (bug)" + wave_arrival = ZONE_MOBS_ARRIVE_EMERGE mobs_green = list( /mob/living/basic/spider/giant/nurse = 8, /mob/living/basic/spider/giant = 6, diff --git a/voidcrew/modules/loot/themes/syndicate.dm b/voidcrew/modules/loot/themes/syndicate.dm index 2de7274da42..9c1ceb469a7 100644 --- a/voidcrew/modules/loot/themes/syndicate.dm +++ b/voidcrew/modules/loot/themes/syndicate.dm @@ -101,6 +101,7 @@ /// Syndicate holdouts: operatives left guarding whatever the base was for. /obj/effect/zone_mobs/syndicate name = "zone mob spawner (syndicate)" + wave_pod_style = /datum/pod_style/syndicate mobs_green = list( /mob/living/basic/trooper/syndicate/melee = 14, ) diff --git a/voidcrew/modules/loot/zone_mobs.dm b/voidcrew/modules/loot/zone_mobs.dm index d84add286aa..bc2b62e4edc 100644 --- a/voidcrew/modules/loot/zone_mobs.dm +++ b/voidcrew/modules/loot/zone_mobs.dm @@ -51,13 +51,24 @@ var/npc_role = "auto" /// How far spawns scatter from the marker var/scatter_radius = 2 + /// How a runtime wave gets on scene: ZONE_MOBS_ARRIVE_POD or ZONE_MOBS_ARRIVE_EMERGE + var/wave_arrival = ZONE_MOBS_ARRIVE_POD + /// Pod look for ZONE_MOBS_ARRIVE_POD waves + var/datum/pod_style/wave_pod_style = /datum/pod_style + /// Set for runtime waves: the pack shows up on screen instead of appearing in place + var/wave = FALSE /** * Runtime spawns (mission waves) can pass a count override: * new /obj/effect/zone_mobs/pirate(T, list(1, 2)) guarantees 1-2 spawns in * every band, regardless of the theme's defaults. + * Pass wave = TRUE when players may be watching: the pack drops in by pod or + * digs out of the ground (wave_arrival) instead of appearing next to them. */ -/obj/effect/zone_mobs/Initialize(mapload, list/count_override) +/obj/effect/zone_mobs/Initialize(mapload, list/count_override, wave = FALSE) + src.wave = wave + if(wave) + scatter_radius = max(scatter_radius, ZONE_MOBS_WAVE_SCATTER) if(npc_role == "auto" && npc_zone_boss_type(type)) npc_role = "boss" if(islist(count_override) && length(count_override) >= 2) @@ -107,7 +118,12 @@ continue var/turf/spot = length(open_turfs) ? pick_n_take(open_turfs) : get_turf(src) var/datum/npc_spawn_context/context = new(src, zone_type, npc_role) - spawn_npc_in_zone_or_queue(mob_path, spot, context) + if(!wave) + spawn_npc_in_zone_or_queue(mob_path, spot, context) + else if(wave_arrival == ZONE_MOBS_ARRIVE_EMERGE) + zone_mobs_emerge(mob_path, spot, context) + else + zone_mobs_pod_drop(mob_path, spot, context, wave_pod_style) /** * Open, unblocked turfs around the marker the pack can scatter onto. @@ -115,7 +131,8 @@ /obj/effect/zone_mobs/proc/get_scatter_turfs() var/list/result = list() for(var/turf/open/tile in RANGE_TURFS(scatter_radius, src)) - if(tile.is_blocked_turf(exclude_mobs = TRUE)) + // A wave never lands a pod or digs up under someone's feet + if(tile.is_blocked_turf(exclude_mobs = !wave)) continue result += tile return result diff --git a/voidcrew/modules/loot/zone_mobs_arrival.dm b/voidcrew/modules/loot/zone_mobs_arrival.dm new file mode 100644 index 00000000000..689d9694b36 --- /dev/null +++ b/voidcrew/modules/loot/zone_mobs_arrival.dm @@ -0,0 +1,84 @@ +/** + * # Zone Mob Wave Arrivals + * + * Runtime waves (new /obj/effect/zone_mobs/(T, count, TRUE)) are called + * in while players are standing right there, so the pack has to visibly get + * there instead of appearing beside them. Crews drop in by pod; beasts, bugs + * and the dead dig up out of the ground after a short rumble. + */ + +/// How long the ground shakes before something digs out of it +#define ZONE_MOBS_EMERGE_TIME (2.5 SECONDS) +/// How far below the tile an emerging mob starts +#define ZONE_MOBS_EMERGE_DEPTH 16 + +/** + * Loads one mob into a pod and drops it on the spot. The pod shows its usual + * landing marker, does no damage or explosion, opens, then leaves, so it never + * stays behind as free furniture. + */ +/proc/zone_mobs_pod_drop(mob_path, turf/spot, datum/npc_spawn_context/context, datum/pod_style/style = /datum/pod_style) + // A human NPC is built by the spawn queue (human_npc_spawning.dm), then goes in its pod the same tick + if(ispath(mob_path, /mob/living/carbon/human/npc)) + spawn_human_npc(mob_path, spot, CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(zone_mobs_pod_send), spot, style), context = context) + return + var/obj/structure/closet/supplypod/podspawn/pod = new(null, style) + spawn_npc_in_zone(mob_path, pod, context) + new /obj/effect/pod_landingzone(spot, pod) + +/// Puts a human NPC the spawn queue has just built into a pod and drops it on the spot. +/proc/zone_mobs_pod_send(turf/spot, datum/pod_style/style, mob/living/body) + if(QDELETED(body)) + return + var/obj/structure/closet/supplypod/podspawn/pod = new(null, style) + body.forceMove(pod) + new /obj/effect/pod_landingzone(spot, pod) + +/** + * The ground rumbles, then the mob climbs out of it and leaves rubble behind. + */ +/proc/zone_mobs_emerge(mob_path, turf/spot, datum/npc_spawn_context/context) + new /obj/effect/temp_visual/zone_mobs_emerge(spot) + playsound(spot, 'sound/effects/break_stone.ogg', 50, TRUE) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(zone_mobs_emerge_finish), mob_path, spot, context), ZONE_MOBS_EMERGE_TIME) + +/proc/zone_mobs_emerge_finish(mob_path, turf/spot, datum/npc_spawn_context/context) + if(!spot) + return + playsound(spot, 'sound/effects/shovel_dig.ogg', 60, TRUE) + new /obj/effect/decal/cleanable/rubble(spot) + // A human NPC is built by the spawn queue (human_npc_spawning.dm) and climbs out as it appears + if(ispath(mob_path, /mob/living/carbon/human/npc)) + spawn_human_npc(mob_path, spot, CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(zone_mobs_emerge_rise)), context = context) + return + zone_mobs_emerge_rise(spawn_npc_in_zone(mob_path, spot, context)) + +/// The mob rises out of the ground it was just made on. +/proc/zone_mobs_emerge_rise(mob/living/body) + if(!isliving(body) || QDELETED(body)) + return + // Parallel and relative so a mob's own idle animation (floating, bobbing) survives + var/final_alpha = body.alpha + body.alpha = 0 + body.pixel_z -= ZONE_MOBS_EMERGE_DEPTH + animate(body, pixel_z = ZONE_MOBS_EMERGE_DEPTH, time = 0.6 SECONDS, easing = QUAD_EASING | EASE_OUT, flags = ANIMATION_RELATIVE | ANIMATION_PARALLEL) + animate(body, alpha = final_alpha, time = 0.4 SECONDS, flags = ANIMATION_PARALLEL) + +/// The shaking dirt that gives away something digging up +/obj/effect/temp_visual/zone_mobs_emerge + name = "shifting ground" + icon = 'icons/obj/debris.dmi' + icon_state = "rubble_bounce" + layer = ABOVE_OPEN_TURF_LAYER + plane = FLOOR_PLANE + randomdir = FALSE + duration = ZONE_MOBS_EMERGE_TIME + +/obj/effect/temp_visual/zone_mobs_emerge/Initialize(mapload) + . = ..() + animate(src, pixel_x = 1, time = 0.5, loop = -1) + animate(pixel_x = -1, time = 1) + animate(pixel_x = 0, time = 0.5) + +#undef ZONE_MOBS_EMERGE_TIME +#undef ZONE_MOBS_EMERGE_DEPTH diff --git a/voidcrew/modules/missions/missions/field_expedition.dm b/voidcrew/modules/missions/missions/field_expedition.dm index 81fd90250d9..5ca8eaec4e4 100644 --- a/voidcrew/modules/missions/missions/field_expedition.dm +++ b/voidcrew/modules/missions/missions/field_expedition.dm @@ -64,7 +64,7 @@ UnregisterSignal(source, COMSIG_ITEM_PICKUP) if(failed || completed || !wave_theme || !prob(ambush_chance)) return - new wave_theme(get_turf(taker), list(1, 2)) + new wave_theme(get_turf(taker), list(1, 2), TRUE) servant?.ship_notify("[name]: ground team disturbed something at the crash site.", "MISSION UPDATE", SHIP_NOTIFY_WARNING, 'voidcrew/sound/notify2.ogg', 50) /datum/mission/field_expedition/update_text() diff --git a/voidcrew/modules/missions/missions/recovery_variants.dm b/voidcrew/modules/missions/missions/recovery_variants.dm index 7a38e0c38bc..2a53a981637 100644 --- a/voidcrew/modules/missions/missions/recovery_variants.dm +++ b/voidcrew/modules/missions/missions/recovery_variants.dm @@ -189,7 +189,7 @@ return alarm_tripped = TRUE var/turf/site = get_turf(cargo) - new wave_theme(site, list(1, 2)) + new wave_theme(site, list(1, 2), TRUE) second_wave_timer = addtimer(CALLBACK(src, PROC_REF(second_wave), site), EXTRACTION_SECOND_WAVE_DELAY, TIMER_STOPPABLE) servant?.ship_notify("[name]: site security alarm triggered.", "MISSION UPDATE", SHIP_NOTIFY_WARNING, 'voidcrew/sound/notify2.ogg', 50) @@ -197,7 +197,7 @@ second_wave_timer = null if(failed || completed || !site) return - new wave_theme(site, list(1, 2)) + new wave_theme(site, list(1, 2), TRUE) /** * # Anchored Recovery Cargo diff --git a/voidcrew/modules/missions/objectives/site_ops.dm b/voidcrew/modules/missions/objectives/site_ops.dm index 0689c21430e..a77f06b6a49 100644 --- a/voidcrew/modules/missions/objectives/site_ops.dm +++ b/voidcrew/modules/missions/objectives/site_ops.dm @@ -163,7 +163,7 @@ points_done++ // Calibration is loud. Something heard it. if(wave_theme) - new wave_theme(get_turf(pylon), list(1, 2)) + new wave_theme(get_turf(pylon), list(1, 2), TRUE) // The finished pylon stays as a breadcrumb but stops being the objective mission.forget_quest_atom(pylon) @@ -555,7 +555,7 @@ // Periodic company if(wave_theme && beacon.next_wave_at <= world.time) beacon.next_wave_at = world.time + wave_interval - new wave_theme(get_turf(beacon), list(1, 2)) + new wave_theme(get_turf(beacon), list(1, 2), TRUE) notify_crew("Claim jumpers inbound on the beacon!", type = SHIP_NOTIFY_WARNING, sound = 'voidcrew/sound/notify2.ogg') /// The clock ran out with the beacon alive: print the deed From 969585a16fa8dc4aa50e78d854381354ea7b2096 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sun, 15 Nov 2026 17:38:07 -0800 Subject: [PATCH 05/13] NPC shots pass over their own side; a grabbed NPC shields against its own side A projectile fired by a mob nobody is playing ignores mobs that share the shooter's factions (tg's ignored_factions), except the mob it was aimed at. Covers guns, shotgun pellets, basic mob ranged attacks and simple mob Shoot(). The neutral faction is left out, a reflected or parried shot stops sparing the NPC's side, and players' shots are unchanged. The mafia lair machine keeps hitting its own people. An NPC held in an aggressive grab by someone of another side is hit by its own side's fire, so a grabbed NPC works as a shield. A passive pull, a hostage on the floor, a corpse and an NPC held by its own side are still passed over. --- tgstation.dme | 1 + .../projectiles/projectile_npc_allies.dm | 54 +++++++++ .../modules/bounties/bounty_lair_mafia.dm | 2 + voidcrew/modules/unit_tests/_unit_tests.dm | 1 + .../voidcrew_npc_fire_over_allies.dm | 114 ++++++++++++++++++ 5 files changed, 172 insertions(+) create mode 100644 voidcrew/edits/modules/projectiles/projectile_npc_allies.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_npc_fire_over_allies.dm diff --git a/tgstation.dme b/tgstation.dme index 2555f50033e..dc6f667d9f2 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -6927,6 +6927,7 @@ #include "voidcrew\edits\modules\power\supermatter_anomalies.dm" #include "voidcrew\edits\modules\power\turbine\turbine.dm" #include "voidcrew\edits\modules\projectiles\boxes_magazines\_box_magazine.dm" +#include "voidcrew\edits\modules\projectiles\projectile_npc_allies.dm" #include "voidcrew\edits\modules\research\designs.dm" #include "voidcrew\edits\modules\research\designs\comp_board_designs.dm" #include "voidcrew\edits\modules\research\designs\machine_designs.dm" diff --git a/voidcrew/edits/modules/projectiles/projectile_npc_allies.dm b/voidcrew/edits/modules/projectiles/projectile_npc_allies.dm new file mode 100644 index 00000000000..840f3821b9d --- /dev/null +++ b/voidcrew/edits/modules/projectiles/projectile_npc_allies.dm @@ -0,0 +1,54 @@ +// Voidcrew extension to code/modules/projectiles/projectile.dm: NPCs shoot past their own side. + +/obj/projectile + /// Set before fire() to keep an NPC's shot hitting its own side in the way (the mafia lair's machine). + var/npc_shot_hits_allies = FALSE + /// The NPC whose side this shot passes over. A shot reflected or parried by someone else stops passing over them. + var/datum/weakref/npc_side_shooter + +/** + * A shot fired by an NPC (a mob nobody is playing) passes over anyone on its side, as tg's turrets already + * do, through tg's own ignored_factions check in can_hit_target(). The mob it was aimed at is always hit, + * whichever side it is on. Every NPC fires through here: human NPCs' guns (casing to projectile, shotgun + * pellets included), basic mobs' ranged_attacks and simple mobs' Shoot(). + * + * A player's shots are unchanged. The shared "neutral" faction is left out, so an NPC never shoots + * through bystanders just because nobody gave them a side. + */ +/obj/projectile/fire(fire_angle, atom/direct_target) + if(isnull(ignored_factions) && !npc_shot_hits_allies && ismob(firer)) + var/mob/firer_mob = firer + if(!firer_mob.ckey && length(firer_mob.faction)) + var/list/sides = firer_mob.faction - FACTION_NEUTRAL + if(length(sides)) + ignored_factions = sides + npc_side_shooter = WEAKREF(firer_mob) + return ..() + +// A reflected, parried or deflected shot takes a new firer: it stops sparing the NPC's side. +// An ally held by the other side is a shield, not an ally: the shot can hit them (see npc_shot_shield()). +/obj/projectile/can_hit_target(atom/target, direct_target = FALSE, ignore_loc = FALSE, cross_failed = FALSE) + if(npc_side_shooter && firer && firer.weak_reference != npc_side_shooter) + npc_side_shooter = null + ignored_factions = null + if(npc_side_shooter && npc_shot_shield(target)) + var/list/sides = ignored_factions + ignored_factions = null + . = ..() + ignored_factions = sides + return . + return ..() + +/** + * Whether `target` is one of the NPC's side held in an aggressive grab or tighter by a living mob that is + * not on that side. tg's grab states are the only test: a passive pull (dragging a body or a cuffed + * prisoner) is not a shield. tg's own rules still pass over a held body that is dead or lying helpless. + */ +/obj/projectile/proc/npc_shot_shield(atom/target) + if(!isliving(target) || !length(ignored_factions)) + return FALSE + var/mob/living/held = target + var/mob/living/holder = held.pulledby + if(!isliving(holder) || holder.grab_state < GRAB_AGGRESSIVE) + return FALSE + return faction_check(held.faction, ignored_factions) && !faction_check(holder.faction, ignored_factions) diff --git a/voidcrew/modules/bounties/bounty_lair_mafia.dm b/voidcrew/modules/bounties/bounty_lair_mafia.dm index 822e2d3d63c..c1abcd257e8 100644 --- a/voidcrew/modules/bounties/bounty_lair_mafia.dm +++ b/voidcrew/modules/bounties/bounty_lair_mafia.dm @@ -1785,6 +1785,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) rocket.rocket_area_ref = mech_home_ref rocket.firer = src rocket.fired_from = src + rocket.npc_shot_hits_allies = TRUE rocket.range = get_dist(start, spot) + 3 rocket.maximum_range = rocket.range rocket.aim_projectile(spot, src) @@ -1857,6 +1858,7 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) bullet.maximum_range = max_range bullet.firer = src bullet.fired_from = src + bullet.npc_shot_hits_allies = TRUE bullet.spread = spread bullet.aim_projectile(target, src, null, weapon.shot_spread()) if(QDELETED(bullet)) diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index 8e83525fd59..4f773f7620e 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -129,6 +129,7 @@ #include "voidcrew_nanite_sync.dm" #include "voidcrew_npc_boarding_docking.dm" #include "voidcrew_npc_disarm.dm" +#include "voidcrew_npc_fire_over_allies.dm" #include "voidcrew_npc_zone_profiles.dm" #include "voidcrew_ore_balance.dm" #include "voidcrew_outpost_admin.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_npc_fire_over_allies.dm b/voidcrew/modules/unit_tests/voidcrew_npc_fire_over_allies.dm new file mode 100644 index 00000000000..5f647869d82 --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_npc_fire_over_allies.dm @@ -0,0 +1,114 @@ +// NPC shots pass over their own side (voidcrew/edits/modules/projectiles/projectile_npc_allies.dm). +// A mob nobody plays (no ckey) is an NPC; a mob with a ckey is a player. + +/datum/unit_test/voidcrew_npc_fire_over_allies + +/datum/unit_test/voidcrew_npc_fire_over_allies/Run() + var/turf/start = run_loc_floor_bottom_left + var/mob/living/carbon/human/consistent/shooter = allocate(/mob/living/carbon/human/consistent, start) + var/mob/living/carbon/human/consistent/ally = allocate(/mob/living/carbon/human/consistent, locate(start.x + 2, start.y, start.z)) + var/mob/living/carbon/human/consistent/target = allocate(/mob/living/carbon/human/consistent, locate(start.x + 4, start.y, start.z)) + shooter.faction = list("npc_fire_test_side") + ally.faction = list("npc_fire_test_side") + target.faction = list("npc_fire_test_other") + + // An NPC's bullet flies past its ally and hits the player behind + var/obj/item/ammo_casing/c38/round = allocate(/obj/item/ammo_casing/c38) + TEST_ASSERT(round.fire_casing(target, shooter, null, 0, TRUE, BODY_ZONE_CHEST, 0, shooter), "The NPC's round didn't fire") + wait_for_hit(target) + TEST_ASSERT(target.getBruteLoss() > 0, "The NPC's bullet never reached the target behind its ally") + TEST_ASSERT_EQUAL(ally.getBruteLoss(), 0, "The NPC's bullet hit its own ally on the way") + + // Buckshot: every pellet flies past the ally + target.fully_heal() + var/obj/item/ammo_casing/shotgun/buckshot/shell = allocate(/obj/item/ammo_casing/shotgun/buckshot) + shell.variance = 0 + TEST_ASSERT(shell.fire_casing(target, shooter, null, 0, TRUE, BODY_ZONE_CHEST, 0, shooter), "The NPC's shell didn't fire") + wait_for_hit(target) + TEST_ASSERT(target.getBruteLoss() > 0, "The NPC's buckshot never reached the target behind its ally") + TEST_ASSERT_EQUAL(ally.getBruteLoss(), 0, "The NPC's buckshot hit its own ally on the way") + wait_for_quiet() + ally.fully_heal() + target.fully_heal() + + // Aimed at its ally, it hits its ally + var/obj/item/ammo_casing/c38/aimed = allocate(/obj/item/ammo_casing/c38) + TEST_ASSERT(aimed.fire_casing(ally, shooter, null, 0, TRUE, BODY_ZONE_CHEST, 0, shooter), "The NPC's aimed round didn't fire") + wait_for_hit(ally) + TEST_ASSERT(ally.getBruteLoss() > 0, "An NPC's shot aimed at its own ally passed over it") + + // A player on the same side still hits the ally in the way + ally.fully_heal() + target.fully_heal() + shooter.key = "NpcFireOverAlliesTestKey" + var/obj/item/ammo_casing/c38/player_round = allocate(/obj/item/ammo_casing/c38) + TEST_ASSERT(player_round.fire_casing(target, shooter, null, 0, TRUE, BODY_ZONE_CHEST, 0, shooter), "The player's round didn't fire") + wait_for_hit(ally) + shooter.key = null + TEST_ASSERT(ally.getBruteLoss() > 0, "A player's bullet passed over the ally in the way") + TEST_ASSERT_EQUAL(target.getBruteLoss(), 0, "A player's bullet went through the ally in the way") + + // A shot someone else turns around stops sparing the NPC's side + var/obj/projectile/bullet/c38/turned = allocate(/obj/projectile/bullet/c38, locate(start.x + 1, start.y, start.z)) + turned.impacted = list() + turned.ignored_factions = shooter.faction.Copy() + turned.npc_side_shooter = WEAKREF(shooter) + turned.firer = shooter + TEST_ASSERT(!turned.can_hit_target(ally, FALSE, TRUE), "Test fixture: the NPC's shot would hit its ally") + turned.firer = target + TEST_ASSERT(turned.can_hit_target(ally, FALSE, TRUE), "A reflected NPC shot still passes over the NPC's side") + turned.firer = null + + // An ally held by the NPC's enemy is a shield: the shot hits them + wait_for_quiet() + var/mob/living/carbon/human/consistent/holder = allocate(/mob/living/carbon/human/consistent, locate(start.x + 2, start.y + 1, start.z)) + holder.faction = list("npc_fire_test_other") + ally.fully_heal() + target.fully_heal() + TEST_ASSERT(holder.start_pulling(ally, supress_message = TRUE), "Test fixture: the enemy couldn't grab the ally") + holder.setGrabState(GRAB_AGGRESSIVE) + TEST_ASSERT_EQUAL(ally.body_position, STANDING_UP, "Test fixture: the held ally isn't standing") + var/obj/item/ammo_casing/c38/shield_round = allocate(/obj/item/ammo_casing/c38) + TEST_ASSERT(shield_round.fire_casing(target, shooter, null, 0, TRUE, BODY_ZONE_CHEST, 0, shooter), "The NPC's round at the shield didn't fire") + wait_for_hit(ally) + TEST_ASSERT(ally.getBruteLoss() > 0, "The NPC's bullet passed over its ally held by the enemy") + TEST_ASSERT_EQUAL(target.getBruteLoss(), 0, "The NPC's bullet went through its ally held by the enemy") + + // Only dragged along (a passive pull), the ally is still passed over + ally.fully_heal() + holder.setGrabState(GRAB_PASSIVE) + var/obj/item/ammo_casing/c38/pulled_round = allocate(/obj/item/ammo_casing/c38) + TEST_ASSERT(pulled_round.fire_casing(target, shooter, null, 0, TRUE, BODY_ZONE_CHEST, 0, shooter), "The NPC's round past the dragged ally didn't fire") + wait_for_hit(target) + TEST_ASSERT(target.getBruteLoss() > 0, "The NPC's bullet never passed its ally dragged by the enemy") + TEST_ASSERT_EQUAL(ally.getBruteLoss(), 0, "The NPC's bullet hit its ally only dragged by the enemy") + + // Held by someone on its own side, the ally is still passed over + target.fully_heal() + holder.faction = list("npc_fire_test_side") + holder.setGrabState(GRAB_AGGRESSIVE) + var/obj/item/ammo_casing/c38/friendly_round = allocate(/obj/item/ammo_casing/c38) + TEST_ASSERT(friendly_round.fire_casing(target, shooter, null, 0, TRUE, BODY_ZONE_CHEST, 0, shooter), "The NPC's round past the friendly-held ally didn't fire") + wait_for_hit(target) + TEST_ASSERT(target.getBruteLoss() > 0, "The NPC's bullet never passed its ally held by its own side") + TEST_ASSERT_EQUAL(ally.getBruteLoss(), 0, "The NPC's bullet hit its ally held by its own side") + holder.stop_pulling() + +/// Waits up to two seconds for `victim` to take brute damage. +/datum/unit_test/voidcrew_npc_fire_over_allies/proc/wait_for_hit(mob/living/victim) + for(var/i in 1 to 20) + if(victim.getBruteLoss() > 0) + return + sleep(0.1 SECONDS) + +/// Waits up to three seconds for every shot in the test room to land, so a late pellet can't hit the next check. +/datum/unit_test/voidcrew_npc_fire_over_allies/proc/wait_for_quiet() + for(var/i in 1 to 30) + var/flying = FALSE + for(var/turf/spot as anything in block(run_loc_floor_bottom_left, run_loc_floor_top_right)) + if(locate(/obj/projectile) in spot) + flying = TRUE + break + if(!flying) + return + sleep(0.1 SECONDS) From ce0fdc3301ef21313df93a943d13848f75fb30e4 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sun, 15 Nov 2026 18:24:22 -0800 Subject: [PATCH 06/13] Bounty targets: plain guards, space suits, holstered guns, slower pistols - Criminals hide only aboard an ordinary pirate crew's ship, never a themed crew's, so their guards are ordinary pirates. Companions come from the same species mix as criminals and wear rough clothes picked by site. - At space ruins and on planets where the air would kill them, criminals and companions arrive in space suits: soft suits for Petty and meek criminals and companions, work MODsuits for Wanted criminals, and a MODsuit that matches its kit for each mini-boss. Their own suit can't be taken off them. A hunter can put a suit of their own on a downed, cuffed or stunned catch through the strip menu, and gets it back at the turn-in pad. - Two new fighting styles: a WT-550 that fires bursts of four, and a .38 revolver with a speedloader. - Guns stay holstered, on the belt or slung on the back until a fight; drawing one shows, and the first shot comes a moment later. - Bounty pistols fire single shots, two a second, in strings of six with a pause between: criminals, companions, the kingpin's goons, Club Volga's gunmen and the don. - An outpost fugitive carries only weapons it can hide, and the look-alikes wear the same holster, pouch or bag. --- tgstation.dme | 1 + voidcrew/_DEFINES/bounties.dm | 4 +- voidcrew/_DEFINES/bounty_ai.dm | 36 +- voidcrew/_DEFINES/bounty_criminals.dm | 5 + voidcrew/_DEFINES/bounty_kingpin.dm | 5 +- voidcrew/_DEFINES/bounty_lairs.dm | 23 +- voidcrew/modules/bounties/bounty_admin.dm | 2 + voidcrew/modules/bounties/bounty_boss_kits.dm | 32 +- .../modules/bounties/bounty_companions.dm | 115 +++- voidcrew/modules/bounties/bounty_criminal.dm | 14 +- voidcrew/modules/bounties/bounty_identity.dm | 34 +- voidcrew/modules/bounties/bounty_kingpin.dm | 21 +- .../modules/bounties/bounty_lair_mafia.dm | 12 +- voidcrew/modules/bounties/bounty_outfits.dm | 19 +- voidcrew/modules/bounties/bounty_placement.dm | 4 +- voidcrew/modules/bounties/bounty_posting.dm | 6 +- voidcrew/modules/bounties/bounty_styles.dm | 278 +++++++- voidcrew/modules/bounties/bounty_suits.dm | 273 ++++++++ voidcrew/modules/bounties/bounty_turn_in.dm | 6 +- voidcrew/modules/unit_tests/_unit_tests.dm | 2 + .../unit_tests/voidcrew_bounty_guns.dm | 598 ++++++++++++++++++ .../unit_tests/voidcrew_bounty_identity.dm | 2 +- .../unit_tests/voidcrew_bounty_lair_mafia.dm | 11 +- .../unit_tests/voidcrew_bounty_suits.dm | 253 ++++++++ wiki/content/bounty-hunting.md | 15 +- 25 files changed, 1701 insertions(+), 70 deletions(-) create mode 100644 voidcrew/modules/bounties/bounty_suits.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_bounty_guns.dm create mode 100644 voidcrew/modules/unit_tests/voidcrew_bounty_suits.dm diff --git a/tgstation.dme b/tgstation.dme index 2555f50033e..76898e6c6dc 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7118,6 +7118,7 @@ #include "voidcrew\modules\bounties\bounty_posting.dm" #include "voidcrew\modules\bounties\bounty_restraints.dm" #include "voidcrew\modules\bounties\bounty_styles.dm" +#include "voidcrew\modules\bounties\bounty_suits.dm" #include "voidcrew\modules\bounties\bounty_turn_in.dm" #include "voidcrew\modules\bounties\bounty_types.dm" #include "voidcrew\modules\bounties\bounty_weapons.dm" diff --git a/voidcrew/_DEFINES/bounties.dm b/voidcrew/_DEFINES/bounties.dm index d6c49b1626f..7eb625ce9a0 100644 --- a/voidcrew/_DEFINES/bounties.dm +++ b/voidcrew/_DEFINES/bounties.dm @@ -28,12 +28,14 @@ #define BOUNTY_ARCHETYPE_BOSS "boss" // ===== FIGHTING STYLES ===== -// A normal criminal fights in one of the first six; a meek one always carries the holdout. +// A normal criminal fights in one of the first eight; a meek one always carries the holdout. #define BOUNTY_STYLE_BRAWLER "brawler" #define BOUNTY_STYLE_KNIFE "knife" #define BOUNTY_STYLE_PISTOL "pistol" #define BOUNTY_STYLE_SHOTGUN "shotgun" +#define BOUNTY_STYLE_SMG "smg" +#define BOUNTY_STYLE_REVOLVER "revolver" #define BOUNTY_STYLE_CLUB "club" #define BOUNTY_STYLE_BOTTLE "bottle" #define BOUNTY_STYLE_HOLDOUT "holdout" diff --git a/voidcrew/_DEFINES/bounty_ai.dm b/voidcrew/_DEFINES/bounty_ai.dm index 42fcfcbb112..ed0c93adcae 100644 --- a/voidcrew/_DEFINES/bounty_ai.dm +++ b/voidcrew/_DEFINES/bounty_ai.dm @@ -51,6 +51,13 @@ #define BB_BOUNTY_NEXT_SHOT "bb_bounty_next_shot" /// world.time a ranged fighter may next step back from someone too close #define BB_BOUNTY_BACKSTEP_AT "bb_bounty_backstep_at" +/// Trigger pulls still to come in the burst under way (a burst is that many separate pulls, bounty_styles.dm) +#define BB_BOUNTY_BURST_LEFT "bb_bounty_burst_left" +/// world.time their style's gun last came out of its holster, off their back or out of a bag (the draw) +#define BB_BOUNTY_DRAWN_AT "bb_bounty_drawn_at" +/// Shots fired in the pistol's current string, and the magazine they came from (a new one starts the count again) +#define BB_BOUNTY_STRING_SHOTS "bb_bounty_string_shots" +#define BB_BOUNTY_STRING_MAGAZINE "bb_bounty_string_magazine" // ===== ACTIVITY STEPS ===== @@ -202,8 +209,17 @@ /// Chance a brawler's blow is a real shove instead of a punch #define BOUNTY_BRAWLER_SHOVE_CHANCE 20 -/// Between trigger pulls (each pull of the Stechkin is its own burst) -#define BOUNTY_PISTOL_INTERVAL (0.8 SECONDS) +/// Getting a holstered or slung gun out at the start of a fight: the line, then at least this long before the first shot +#define BOUNTY_DRAW_TIME (0.6 SECONDS) +/// A burst whose next pull is this late was cut off (the AI stopped meanwhile): what is left of it never fires +#define BOUNTY_BURST_STALE (0.5 SECONDS) + +/// Between trigger pulls: the Stechkin set to single shots with its own fire selector, twice a second +#define BOUNTY_PISTOL_INTERVAL (0.5 SECONDS) +/// Every bounty pistol (criminals, companions, the kingpin's goons, Club Volga's mobsters and the don) fires strings of this many shots... +#define BOUNTY_PISTOL_STRING_SHOTS 6 +/// ...with this pause on top of the interval before the next string. A reload after an empty magazine is separate. +#define BOUNTY_PISTOL_STRING_PAUSE (1.5 SECONDS) /// Keeps about this far away #define BOUNTY_PISTOL_RANGE 5 #define BOUNTY_PISTOL_MIN_RANGE 3 @@ -212,6 +228,22 @@ /// Shots further apart than this start a new string #define BOUNTY_PISTOL_STRING_GAP (3 SECONDS) +/// The WT-550 at every tier: a burst is this many trigger pulls... +#define BOUNTY_SMG_BURST 4 +/// ...this far apart, the gun's own full-auto rate +#define BOUNTY_SMG_BURST_GAP (0.3 SECONDS) +/// From a burst's last round to the next burst's spin-up +#define BOUNTY_SMG_INTERVAL (0.5 SECONDS) +/// The gun brought up level before each burst +#define BOUNTY_SMG_WINDUP (0.3 SECONDS) +#define BOUNTY_SMG_MIN_RANGE 2 + +/// A .38 revolver: one heavy shot a second, six in the cylinder, a speedloader to reload +#define BOUNTY_REVOLVER_INTERVAL (1 SECONDS) +#define BOUNTY_REVOLVER_MIN_RANGE 3 +/// The hammer thumbed back before the first shot of a string +#define BOUNTY_REVOLVER_WINDUP (0.3 SECONDS) + #define BOUNTY_SHOTGUN_INTERVAL (1.2 SECONDS) #define BOUNTY_SHOTGUN_RANGE 2 /// The pump before each blast diff --git a/voidcrew/_DEFINES/bounty_criminals.dm b/voidcrew/_DEFINES/bounty_criminals.dm index 696d2484b10..bf663b5999e 100644 --- a/voidcrew/_DEFINES/bounty_criminals.dm +++ b/voidcrew/_DEFINES/bounty_criminals.dm @@ -46,3 +46,8 @@ #define BOUNTY_TREAT_SELF_COOLDOWN (20 SECONDS) /// Blackboard key: the medical stack it is using on itself has been clicked on it once this go (bounty_ai_human.dm) #define BB_BOUNTY_TREAT_APPLIED "bounty_treat_applied" + +// ===== SUITS (bounty_suits.dm) ===== + +/// Open tiles of a planet site, picked at random, whose air is read when a criminal is made there: any one that would hurt a person dresses it for that +#define BOUNTY_SITE_AIR_SAMPLES 6 diff --git a/voidcrew/_DEFINES/bounty_kingpin.dm b/voidcrew/_DEFINES/bounty_kingpin.dm index 07912939809..e87faf04ce7 100644 --- a/voidcrew/_DEFINES/bounty_kingpin.dm +++ b/voidcrew/_DEFINES/bounty_kingpin.dm @@ -86,8 +86,9 @@ #define BOUNTY_GOON_SHOTGUN_AMMO /obj/item/ammo_casing/shotgun/buckshot #define BOUNTY_GOON_SHOTGUN_SHELLS 8 -/// Between two trigger pulls of a goon's pistol (each pull is the Stechkin's own three-round burst) -#define BOUNTY_GOON_PISTOL_COOLDOWN (1 SECONDS) +/// Between two trigger pulls of a goon's pistol: the Stechkin set to single shots with its own selector, in strings of +/// BOUNTY_PISTOL_STRING_SHOTS with BOUNTY_PISTOL_STRING_PAUSE on top between them, as every bounty pistol fires +#define BOUNTY_GOON_PISTOL_COOLDOWN (0.5 SECONDS) /// Trigger pulls in a burst (each pull is the Uzi's own two-round burst), and the gap between them #define BOUNTY_GOON_SMG_BURST 2 diff --git a/voidcrew/_DEFINES/bounty_lairs.dm b/voidcrew/_DEFINES/bounty_lairs.dm index c4776e75f22..be54e560c2f 100644 --- a/voidcrew/_DEFINES/bounty_lairs.dm +++ b/voidcrew/_DEFINES/bounty_lairs.dm @@ -86,15 +86,20 @@ #define BB_BOUNTY_MAFIA_MOVE_TO "BB_bounty_mafia_move_to" // ----- mobsters ----- -// A volley is one aim (if the gun has one), then VOLLEY pulls of the trigger VOLLEY_GAP apart, then COOLDOWN before -// the next. The gun's own burst and fire rate apply to every pull: a Stechkin pull is its three-round burst. +// A volley is one aim (if the gun has one), then VOLLEY pulls of the trigger VOLLEY_GAP apart, then a pause before +// the next. The gun's own burst and fire rate apply to every pull: an Uzi pull is its two-round burst. A pistol's +// volley is a string of single shots, as every bounty pistol fires: the Stechkin is set to single fire with its own +// selector, BOUNTY_PISTOL_STRING_SHOTS shots BOUNTY_PISTOL_INTERVAL apart, then BOUNTY_PISTOL_STRING_PAUSE on top. #define BOUNTY_MOBSTER_KNIFE /obj/item/knife/kitchen #define BOUNTY_MOBSTER_PISTOL_GUN /obj/item/gun/ballistic/automatic/pistol/aps #define BOUNTY_MOBSTER_PISTOL_MAGAZINE /obj/item/ammo_box/magazine/m9mm_aps -#define BOUNTY_MOBSTER_PISTOL_VOLLEY 1 -#define BOUNTY_MOBSTER_PISTOL_VOLLEY_GAP (0.3 SECONDS) +#define BOUNTY_MOBSTER_PISTOL_VOLLEY BOUNTY_PISTOL_STRING_SHOTS +#define BOUNTY_MOBSTER_PISTOL_VOLLEY_GAP BOUNTY_PISTOL_INTERVAL +/// From a string's last shot to the next string's first +#define BOUNTY_MOBSTER_PISTOL_STRING_PAUSE (BOUNTY_PISTOL_INTERVAL + BOUNTY_PISTOL_STRING_PAUSE) +/// Between the human NPC base's own shots for a club member (an elite firing wild from the floor) #define BOUNTY_MOBSTER_PISTOL_COOLDOWN (0.8 SECONDS) #define BOUNTY_MOBSTER_SMG_GUN /obj/item/gun/ballistic/automatic/mini_uzi @@ -211,10 +216,14 @@ /// His gold pistol, and the magazines he carries for it #define BOUNTY_DON_GUN /obj/item/gun/ballistic/automatic/pistol/deagle/gold #define BOUNTY_DON_MAGAZINE /obj/item/ammo_box/magazine/m50 -/// He raises the pistol this long before the first volley of each magazine +/// He raises the pistol this long before the first string of each magazine #define BOUNTY_DON_RAISE (0.2 SECONDS) -#define BOUNTY_DON_VOLLEY 2 -#define BOUNTY_DON_VOLLEY_GAP (0.25 SECONDS) +/// Strings of single shots, as every bounty pistol fires (the gold Desert Eagle has no burst) +#define BOUNTY_DON_VOLLEY BOUNTY_PISTOL_STRING_SHOTS +#define BOUNTY_DON_VOLLEY_GAP BOUNTY_PISTOL_INTERVAL +/// From a string's last shot to the next string's first +#define BOUNTY_DON_STRING_PAUSE (BOUNTY_PISTOL_INTERVAL + BOUNTY_PISTOL_STRING_PAUSE) +/// Between the human NPC base's own shots for him (firing wild from the floor) #define BOUNTY_DON_COOLDOWN (0.5 SECONDS) /// Climbing out of the wreck, he takes this long to get his bearings before he acts #define BOUNTY_DON_EJECT_STAGGER (2 SECONDS) diff --git a/voidcrew/modules/bounties/bounty_admin.dm b/voidcrew/modules/bounties/bounty_admin.dm index 3ba9fa629c4..5eb5acc9183 100644 --- a/voidcrew/modules/bounties/bounty_admin.dm +++ b/voidcrew/modules/bounties/bounty_admin.dm @@ -551,6 +551,8 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a "Knife" = BOUNTY_STYLE_KNIFE, "Pistol" = BOUNTY_STYLE_PISTOL, "Shotgun" = BOUNTY_STYLE_SHOTGUN, + "SMG" = BOUNTY_STYLE_SMG, + "Revolver" = BOUNTY_STYLE_REVOLVER, "Club" = BOUNTY_STYLE_CLUB, "Bottle thrower" = BOUNTY_STYLE_BOTTLE, ) diff --git a/voidcrew/modules/bounties/bounty_boss_kits.dm b/voidcrew/modules/bounties/bounty_boss_kits.dm index 471bf1922e7..3e6d485036f 100644 --- a/voidcrew/modules/bounties/bounty_boss_kits.dm +++ b/voidcrew/modules/bounties/bounty_boss_kits.dm @@ -27,6 +27,10 @@ * real rounds into a cone (a hit while it aims spoils the shot); throws real barrier grenades for * cover (CB-26); changes its own belts. Slow. * + * Where the air would kill it, each kit seals up in its own space suit, in the armour class of what it + * wears in good air (bounty_sealed_gear(), bounty_suits.dm): the Juggernaut and the Heavy in armoured + * ones, the Pyromaniac, the Demolitionist and the Ghost in soft ones. + * * The shared vars are declared in bounty_types.dm and nowhere else; a var only P4 uses goes here * with a `boss_` prefix, or on the /boss subtypes. */ @@ -51,7 +55,13 @@ return boss_supplies(bounty_outfit_instance(/datum/outfit/bounty_boss/juggernaut)) /mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/boss_gear_text() - return "Riot plates cover [p_them()] from neck to boots." + if(istype(wear_suit, /obj/item/clothing/suit/armor/riot)) + return "Riot plates cover [p_them()] from neck to boots." + return "[p_They()] [p_are()] built like a door." + +// Out where the air kills: a black and red space suit, as heavy as its riot plates +/mob/living/carbon/human/npc/bounty_criminal/boss/juggernaut/bounty_sealed_gear() + return list(/obj/item/clothing/suit/space/syndicate/black/red, /obj/item/clothing/head/helmet/space/syndicate/black/red) /datum/outfit/bounty_boss/juggernaut name = "Bounty mini-boss: Juggernaut" @@ -305,7 +315,13 @@ return boss_supplies(bounty_outfit_instance(/datum/outfit/bounty_boss/pyromaniac)) /mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/boss_gear_text() - return "[p_Their()] fire suit is scorched black." + if(istype(wear_suit, /obj/item/clothing/suit/utility/fire)) + return "[p_Their()] fire suit is scorched black." + return "[p_They()] reek[p_s()] of fuel." + +// Out where the air kills: an EVA suit, as light as its fire suit. Nothing burns in vacuum. +/mob/living/carbon/human/npc/bounty_criminal/boss/pyromaniac/bounty_sealed_gear() + return list(/obj/item/clothing/suit/space/eva, /obj/item/clothing/head/helmet/space/eva) // The firefighter suit and helmet are what keep its own fire off it (tg's thermal protection, CB-7). The torch // doesn't holster, so it is in hand from the start. @@ -449,6 +465,10 @@ /mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist/boss_gear_text() return "A bandolier of grenades is slung across [p_their()] chest." +// Out where the air kills: a plain grey space suit over its work clothes +/mob/living/carbon/human/npc/bounty_criminal/boss/demolitionist/bounty_sealed_gear() + return list(/obj/item/clothing/suit/space, /obj/item/clothing/head/helmet/space) + /** * It keeps BOUNTY_DEMOLITIONIST_KEEP_MIN to _MAX tiles from its target while it has something it * could throw from there. It fights hand to hand when someone is right on it, or when nothing is @@ -797,6 +817,10 @@ /mob/living/carbon/human/npc/bounty_criminal/boss/ghost/boss_gear_text() return "[p_They()] move[p_s()] quick and light, and the knife is never still." +// Out where the air kills: a dark red voidsuit, no more armour than its hood +/mob/living/carbon/human/npc/bounty_criminal/boss/ghost/bounty_sealed_gear() + return list(/obj/item/clothing/suit/space/nasavoid, /obj/item/clothing/head/helmet/space/nasavoid) + // The hood goes up as the outfit is put on (tg's hooded suits do that). The knife rides in a pocket until the fight starts. /datum/outfit/bounty_boss/ghost name = "Bounty mini-boss: Ghost" @@ -1024,6 +1048,10 @@ /mob/living/carbon/human/npc/bounty_criminal/boss/heavy/boss_gear_text() return "[p_They()] [p_are()] in heavy armour." +// Out where the air kills: a black space suit as heavy as its SWAT armour, under its own SWAT helmet, which already holds pressure +/mob/living/carbon/human/npc/bounty_criminal/boss/heavy/bounty_sealed_gear() + return list(/obj/item/clothing/suit/space/syndicate/black, null) + // The L6 has no sling and won't holster, so it is in hand from the start, its other hand free to fire it. // A spare box rides in the bag; a barrier grenade in each pocket. /datum/outfit/bounty_boss/heavy diff --git a/voidcrew/modules/bounties/bounty_companions.dm b/voidcrew/modules/bounties/bounty_companions.dm index 3637824a3cd..af7be6123ef 100644 --- a/voidcrew/modules/bounties/bounty_companions.dm +++ b/voidcrew/modules/bounties/bounty_companions.dm @@ -17,6 +17,12 @@ * They are not bounties, pay nothing and drop nothing (their kit is locked to them, D3). P5 deletes * them when the posting closes; deleting one at any time is safe. * + * Who they are (A1): people of every species criminals come from (GLOB.bounty_species_weights), in rough + * clothes picked by their criminal's site (bounty_company_clothes()), and dressed for what their criminal + * was dressed for, so they are sealed up wherever it is (bounty_suits.dm). They are made with their + * criminal's spawn context (/datum/npc_spawn_context/bounty_company), which is how they know all that + * before they are dressed. + * * The shared vars are declared in bounty_types.dm and nowhere else (leader_ref); the rest here * have an `ai_` prefix. */ @@ -52,6 +58,22 @@ var/ai_next_idle_think = 0 /// world.time of their next word in the conversation var/ai_next_reply = 0 + /// BOUNTY_PLACEMENT_* of their criminal's site, known as they are made (Initialize()), or null + var/company_site_kind + /// The /datum/outfit their rough clothes came from (bounty_site_clothes()), or null for their plain ones + var/company_clothes + +/mob/living/carbon/human/npc/bounty_companion/Initialize(mapload, datum/human_npc_order/order) + // Before the base dresses them: where their criminal is, and what it was dressed for, so they are too + var/datum/npc_spawn_context/bounty_company/company = order?.context + var/mob/living/carbon/human/npc/bounty_criminal/leader = istype(company) ? company.company_leader_ref?.resolve() : null + if(!QDELETED(leader)) + company_site_kind = leader.posting()?.placement_kind + npc_always_site |= leader.npc_site + else + npc_always_site |= bounty_site_dress_for(order?.context) + company_site_kind ||= bounty_site_kind_of(order?.context) + return ..() /mob/living/carbon/human/npc/bounty_companion/Destroy() ai_let_go() @@ -76,9 +98,73 @@ BOUNTY_STYLE_PISTOL = 1, BOUNTY_STYLE_BOTTLE = 1, BOUNTY_STYLE_SHOTGUN = 1, + BOUNTY_STYLE_SMG = 1, + BOUNTY_STYLE_REVOLVER = 1, )) return bounty_fighter_outfit(BOUNTY_ARCHETYPE_NORMAL, zone, BOUNTY_TIER_PETTY, ai_style, FALSE, /obj/item/stack/medical/bruise_pack) +// Someone of any species a criminal can be, with a face from the criminals' own look builder and a name of their species +/mob/living/carbon/human/npc/bounty_companion/npc_apply_random_look() + var/species = bounty_company_species() + npc_apply_bounty_look(bounty_roll_look(species, pick(MALE, FEMALE))) + real_name = generate_random_name_species_based(gender, TRUE, dna.species.type) + name = real_name + +/// A species for a companion, weighted as for criminals (GLOB.bounty_species_weights) +/proc/bounty_company_species() + return pick_weight(GLOB.bounty_species_weights) + +// Their plain clothes give way to rough ones picked by their criminal's site +/mob/living/carbon/human/npc/bounty_companion/bounty_site_clothes(outfit) + var/list/choices = bounty_company_clothes(company_site_kind) + if(!length(choices) || isnull(outfit)) + return outfit + company_clothes = pick_weight(choices) + return bounty_wear_clothes_of(outfit, company_clothes) + +/** + * Rough clothes for a criminal's company at a site of `site_kind` (BOUNTY_PLACEMENT_*), each a /datum/outfit + * typepath => weight, so no two crews look alike; null where they keep their plain clothes for the zone. + * Only the clothes are taken from these (bounty_wear_clothes_of()), never what they carry. + */ +/proc/bounty_company_clothes(site_kind) + switch(site_kind) + if(BOUNTY_PLACEMENT_NPC_SHIP) + return list( + /datum/outfit/outpost_off_duty_pirate = 1, + /datum/outfit/bounty_criminal/hauler = 1, + /datum/outfit/bounty_criminal/tough = 1, + /datum/outfit/bounty_criminal/drifter = 1, + ) + if(BOUNTY_PLACEMENT_PLANET, BOUNTY_PLACEMENT_RUIN) + return list( + /datum/outfit/hermit/survivor = 2, + /datum/outfit/bounty_criminal/spacer = 1, + /datum/outfit/bounty_criminal/hauler = 1, + /datum/outfit/bounty_criminal/drifter = 1, + /datum/outfit/bounty_criminal/tough = 1, + ) + return null + +/** + * `outfit` (a typepath or an instance) in the clothes of `clothes_type`: its uniform, suit, hat, mask, + * glasses, gloves, shoes and neck, empty where that outfit leaves them empty. Weapons, bags, belts, pockets + * and anything in hand stay as they were. Returns an instance (one passed in is changed in place). + */ +/proc/bounty_wear_clothes_of(outfit, datum/outfit/clothes_type) + var/datum/outfit/dressed = ispath(outfit, /datum/outfit) ? new outfit() : outfit + if(!istype(dressed) || !ispath(clothes_type, /datum/outfit)) + return outfit + dressed.uniform = initial(clothes_type.uniform) + dressed.suit = initial(clothes_type.suit) + dressed.head = initial(clothes_type.head) + dressed.mask = initial(clothes_type.mask) + dressed.glasses = initial(clothes_type.glasses) + dressed.gloves = initial(clothes_type.gloves) + dressed.shoes = initial(clothes_type.shoes) + dressed.neck = initial(clothes_type.neck) + return dressed + /// Their criminal, if still around /mob/living/carbon/human/npc/bounty_companion/proc/ai_leader() var/mob/living/carbon/human/npc/bounty_criminal/leader = leader_ref?.resolve() @@ -361,13 +447,38 @@ * Queues one companion for `leader` at `where` (the human NPC spawn queue: never a room of humans in * one tick), who joins them as it is made: their faction, their side, their posting's list. Then * `on_spawned` is called with it. If the criminal is gone by then, the companion is not kept. - * `immediate` builds it now (tests, admin tools). Returns the spawn order (qdel() cancels it). + * `immediate` builds it now (tests, admin tools). Returns the spawn order (qdel() cancels it). It is + * made with its criminal's spawn context, so it is dressed for where they are. */ /proc/bounty_spawn_companion(mob/living/carbon/human/npc/bounty_criminal/leader, turf/where, datum/callback/on_spawned, immediate = FALSE) where = get_turf(where) if(QDELETED(leader) || !where) return null - return spawn_human_npc(/mob/living/carbon/human/npc/bounty_companion, where, CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(bounty_companion_spawned), WEAKREF(leader), on_spawned), immediate = immediate) + var/datum/npc_spawn_context/bounty_company/company = new(leader, null, "ordinary") + company.company_leader_ref = WEAKREF(leader) + return spawn_human_npc(/mob/living/carbon/human/npc/bounty_companion, where, CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(bounty_companion_spawned), WEAKREF(leader), on_spawned), context = company, immediate = immediate) + +/** + * A companion's spawn context: its criminal's own (the site, zone and source it inherits from the + * criminal it is made from), and which criminal that is, for the companion to read as it is dressed. + */ +/datum/npc_spawn_context/bounty_company + /// Weakref to the criminal the companion is made for + var/datum/weakref/company_leader_ref + +/datum/npc_spawn_context/bounty_company/Destroy() + company_leader_ref = null + return ..() + +/** + * Whether a criminal may hide aboard `npc_ship` (board_pick_npc_ship()): a crew of ordinary people, the + * grey tide's salvagers, Interdyne's rogue researchers or a crew with no faction. Never a themed crew's + * (skeletons, geodes, lizard nobles, knights, customs and the like). + */ +/proc/bounty_ship_hides_criminals(obj/structure/overmap/ship/npc/pirate/npc_ship) + if(!istype(npc_ship)) + return FALSE + return !npc_ship.pirate_faction || (npc_ship.pirate_faction in list("grey", "interdyne")) /// A queued companion is made: it joins its criminal, or goes if its criminal is gone /proc/bounty_companion_spawned(datum/weakref/leader_ref, datum/callback/on_spawned, mob/living/carbon/human/npc/bounty_companion/companion) diff --git a/voidcrew/modules/bounties/bounty_criminal.dm b/voidcrew/modules/bounties/bounty_criminal.dm index 0ed97caf93f..e9849f8b481 100644 --- a/voidcrew/modules/bounties/bounty_criminal.dm +++ b/voidcrew/modules/bounties/bounty_criminal.dm @@ -66,6 +66,8 @@ // Who it is must be known before the base dresses it: the outfit table reads the record (bounty_outfits.dm). if(istype(order?.look, /datum/bounty_record)) record = order.look + // So must where it is: at a space ruin, or on a planet with air that would hurt it, it is dressed for that wherever it stands (bounty_suits.dm) + npc_always_site |= bounty_site_dress_for(order?.context) . = ..() add_traits(list(TRAIT_NO_TELEPORT, TRAIT_NOMOBSWAP), BOUNTY_BODY_TRAIT) AddComponent(/datum/component/bounty_body) @@ -610,7 +612,9 @@ * - who has been attacking it (tg's relay_attackers, an item's attackby, a projectile's firer, a mech's * or a vehicle's pilot) goes on its grudge list; * - teleports, polymorph and type changes are refused; - * - any change of tg state that capture_state() reads tells the body (body_state_changed()). + * - any change of tg state that capture_state() reads tells the body (body_state_changed()); + * - a hunter reaching through the strip menu with a pressure suit or helmet for a slot its own locked piece + * fills may put theirs on instead (bounty_suits.dm, suits_strip_reach()). */ /datum/component/bounty_body dupe_mode = COMPONENT_DUPE_UNIQUE @@ -639,6 +643,7 @@ ), PROC_REF(on_state_signal)) // A stun's traits land before the stun is on its list, so the trait handlers alone would miss it. RegisterSignals(criminal, list(COMSIG_LIVING_STATUS_APPLIED, COMSIG_LIVING_STATUS_REMOVED), PROC_REF(on_state_signal)) + RegisterSignal(criminal, COMSIG_BEING_STRIPPED, PROC_REF(on_being_stripped)) /datum/component/bounty_body/UnregisterFromParent() UnregisterSignal(parent, list( @@ -657,6 +662,7 @@ SIGNAL_REMOVETRAIT(TRAIT_INCAPACITATED), COMSIG_LIVING_STATUS_APPLIED, COMSIG_LIVING_STATUS_REMOVED, + COMSIG_BEING_STRIPPED, )) /// `attacker` went for it: they go on its grudge list (a vehicle's pilots for a vehicle) @@ -712,6 +718,12 @@ if(!QDELING(criminal)) criminal.body_state_changed() +/// Someone reaches for a piece of it through the strip menu: a hunter's pressure suit may go on in place of its own (bounty_suits.dm) +/datum/component/bounty_body/proc/on_being_stripped(datum/source, mob/user, obj/item/item) + SIGNAL_HANDLER + var/mob/living/carbon/human/npc/bounty_criminal/criminal = parent + return criminal.suits_strip_reach(user, item) + // ===== TURRETS AND PLAYERS ===== /** diff --git a/voidcrew/modules/bounties/bounty_identity.dm b/voidcrew/modules/bounties/bounty_identity.dm index 66cce89380d..8ed130ed47b 100644 --- a/voidcrew/modules/bounties/bounty_identity.dm +++ b/voidcrew/modules/bounties/bounty_identity.dm @@ -47,6 +47,8 @@ GLOBAL_LIST_INIT(bounty_species_weights, list( * * - No archetype: rolled from the tier (spec section 2). * - A mini-boss is never placed at a trader outpost (D-A8): there it becomes a normal criminal. + * - A trader-outpost fugitive fights only in a style whose weapon it can hide while it passes as a + * customer (bounty_roll_style()). * - At a trader outpost the record also gets an old look for its mugshot (make_old_look(), AR-C1). * - `species` forces a species (tests, admins); otherwise it is rolled from the pool. * @@ -70,7 +72,7 @@ GLOBAL_LIST_INIT(bounty_species_weights, list( if(BOUNTY_ARCHETYPE_MEEK) record.style = BOUNTY_STYLE_HOLDOUT if(BOUNTY_ARCHETYPE_NORMAL) - record.style = bounty_roll_style() + record.style = bounty_roll_style(concealed = (placement_kind == BOUNTY_PLACEMENT_TRADER_OUTPOST)) if(BOUNTY_ARCHETYPE_BOSS) record.kit = bounty_roll_kit() record.alias = bounty_roll_alias(record) @@ -90,17 +92,29 @@ GLOBAL_LIST_INIT(bounty_species_weights, list( return prob(BOUNTY_WANTED_MEEK_CHANCE) ? BOUNTY_ARCHETYPE_MEEK : BOUNTY_ARCHETYPE_NORMAL return prob(BOUNTY_PETTY_MEEK_CHANCE) ? BOUNTY_ARCHETYPE_MEEK : BOUNTY_ARCHETYPE_NORMAL -/// A fighting style for a normal criminal, weighted -/proc/bounty_roll_style() +/** + * A fighting style for a normal criminal, weighted. `concealed`: only the styles whose weapon nobody sees + * while it is carried (the style's concealable), for a fugitive passing as a customer at a trader outpost. + */ +/proc/bounty_roll_style(concealed = FALSE) var/static/list/weights = list( - BOUNTY_STYLE_BRAWLER = 20, - BOUNTY_STYLE_PISTOL = 20, - BOUNTY_STYLE_KNIFE = 18, - BOUNTY_STYLE_CLUB = 15, - BOUNTY_STYLE_BOTTLE = 15, - BOUNTY_STYLE_SHOTGUN = 12, + BOUNTY_STYLE_BRAWLER = 18, + BOUNTY_STYLE_PISTOL = 14, + BOUNTY_STYLE_KNIFE = 16, + BOUNTY_STYLE_CLUB = 14, + BOUNTY_STYLE_BOTTLE = 12, + BOUNTY_STYLE_SHOTGUN = 10, + BOUNTY_STYLE_SMG = 8, + BOUNTY_STYLE_REVOLVER = 8, ) - return pick_weight(weights) + if(!concealed) + return pick_weight(weights) + var/list/hidden = list() + for(var/key in weights) + var/datum/bounty_style/style = GLOB.bounty_styles[key] + if(style?.concealable) + hidden[key] = weights[key] + return length(hidden) ? pick_weight(hidden) : BOUNTY_STYLE_BRAWLER /// A mini-boss kit, weighted /proc/bounty_roll_kit() diff --git a/voidcrew/modules/bounties/bounty_kingpin.dm b/voidcrew/modules/bounties/bounty_kingpin.dm index d0ff11992c1..21d3a97b198 100644 --- a/voidcrew/modules/bounties/bounty_kingpin.dm +++ b/voidcrew/modules/bounties/bounty_kingpin.dm @@ -801,6 +801,9 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) var/goon_fleeing = FALSE /// Weakref to the chair at their post, if they sit var/datum/weakref/goon_chair_ref + /// Pistol shots in the current string, and a weakref to the magazine they came from (a new one starts the count again) + var/goon_string_shots = 0 + var/datum/weakref/goon_string_magazine /mob/living/carbon/human/npc/bounty_kingpin_goon/pistol @@ -866,6 +869,17 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) return FALSE return !HAS_TRAIT(src, TRAIT_INCAPACITATED) && !HAS_TRAIT(src, TRAIT_FLOORED) +/// Counts a pistol shot just fired from `pistol` towards his string. TRUE when it ends one with rounds still in the gun. +/mob/living/carbon/human/npc/bounty_kingpin_goon/proc/goon_string_shot(obj/item/gun/ballistic/pistol) + if(!istype(pistol) || !pistol.magazine) + return FALSE + goon_string_shots = goon_string_magazine?.resolve() == pistol.magazine ? goon_string_shots + 1 : 1 + goon_string_magazine = WEAKREF(pistol.magazine) + if(goon_string_shots < BOUNTY_PISTOL_STRING_SHOTS || bounty_gun_live_rounds(pistol) <= 0) + return FALSE + goon_string_shots = 0 + return TRUE + /// Drops a burst or a blast that was winding up /mob/living/carbon/human/npc/bounty_kingpin_goon/proc/goon_cancel_windup() if(goon_windup_timer) @@ -2246,8 +2260,13 @@ GLOBAL_LIST_EMPTY(bounty_kingpin_marks) goon.visible_message(span_warning("[goon] pumps [goon.p_their()] shotgun."), vision_distance = COMBAT_MESSAGE_RANGE) goon.goon_windup_timer = addtimer(CALLBACK(src, PROC_REF(goon_finish_windup), WEAKREF(goon), WEAKREF(target)), BOUNTY_GOON_SHOTGUN_WINDUP, TIMER_STOPPABLE | TIMER_DELETE_ME) else + // Single shots off the Stechkin's own selector, in strings with a pause between them; an empty magazine reloads instead + var/obj/item/gun/ballistic/pistol = human_npc_loaded_gun(goon) + bounty_gun_single_fire(goon, pistol) goon.goon_next_fire_at = world.time + BOUNTY_GOON_PISTOL_COOLDOWN - goon_fire(goon, target) + var/rounds = bounty_gun_live_rounds(pistol) + if(goon_fire(goon, target) && bounty_gun_live_rounds(pistol) < rounds && goon.goon_string_shot(pistol)) + goon.goon_next_fire_at += BOUNTY_PISTOL_STRING_PAUSE return TRUE /// The wind-up is done: the SMG's burst or the shotgun's blast, if he still can and still sees them diff --git a/voidcrew/modules/bounties/bounty_lair_mafia.dm b/voidcrew/modules/bounties/bounty_lair_mafia.dm index 822e2d3d63c..074f6c205ab 100644 --- a/voidcrew/modules/bounties/bounty_lair_mafia.dm +++ b/voidcrew/modules/bounties/bounty_lair_mafia.dm @@ -471,7 +471,9 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) var/mafia_volley = BOUNTY_MOBSTER_PISTOL_VOLLEY var/mafia_volley_gap = BOUNTY_MOBSTER_PISTOL_VOLLEY_GAP /// From the end of one volley to the start of the next - var/mafia_cooldown = BOUNTY_MOBSTER_PISTOL_COOLDOWN + var/mafia_cooldown = BOUNTY_MOBSTER_PISTOL_STRING_PAUSE + /// Its gun is set to single shots with its own fire selector before it fires (a pistol: a string of single shots) + var/mafia_single_fire = FALSE /// What it says as it reloads ("[voice]_[context]"), how often, and the sound of its hand going for a magazine var/mafia_reload_context = "reload" var/mafia_reload_chance = 35 @@ -894,11 +896,12 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) if(mafia_reload_context && prob(mafia_reload_chance)) mafia_bark(mafia_reload_context) -/// A gunman with a Stechkin +/// A gunman with a Stechkin, fired a single shot at a time /mob/living/carbon/human/npc/bounty_mafia/pistol npc_name = "mobster gunman" npc_look = /obj/effect/mob_spawn/corpse/human/bounty_mafia/pistol npc_outfit = /datum/outfit/bounty_mafia_goon/pistol/armed + mafia_single_fire = TRUE /// An enforcer with an Uzi that spins up before each volley /mob/living/carbon/human/npc/bounty_mafia/smg @@ -2015,7 +2018,8 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) mafia_windup_sound = 'sound/items/weapons/gun/pistol/rack_small.ogg' mafia_volley = BOUNTY_DON_VOLLEY mafia_volley_gap = BOUNTY_DON_VOLLEY_GAP - mafia_cooldown = BOUNTY_DON_COOLDOWN + mafia_cooldown = BOUNTY_DON_STRING_PAUSE + mafia_single_fire = TRUE mafia_reload_chance = 50 /// The wreck he hides behind (/obj/structure/bounty_mafia_wreck) var/datum/weakref/don_wreck_ref @@ -2259,6 +2263,8 @@ GLOBAL_LIST_EMPTY(bounty_mafia_rooms) return AI_BEHAVIOR_DELAY if(!human_npc_ready_item(shooter, gun)) return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_FAILED + if(shooter.mafia_single_fire) + bounty_gun_single_fire(shooter, gun) shooter.zone_selected = human_npc_pick_aim_zone() controller.ai_interact(target = target, combat_mode = TRUE) shooter.mafia_volley_left-- diff --git a/voidcrew/modules/bounties/bounty_outfits.dm b/voidcrew/modules/bounties/bounty_outfits.dm index cb8ff1c6da0..3eff08fd633 100644 --- a/voidcrew/modules/bounties/bounty_outfits.dm +++ b/voidcrew/modules/bounties/bounty_outfits.dm @@ -10,12 +10,16 @@ * armour on real slots, locked to the body (D3), so it protects by tg's armour rules and never drops. * Their weapons are carried, not held, until the fight starts, with real spare ammunition; their * self-treatment items are real (N6). The human NPC base adds a sealed suit and air in vacuum, a mask in - * bad air and warm clothes in the cold, on top of whatever is picked here (human_npc_outfits.dm). + * bad air and warm clothes in the cold, on top of whatever is picked here (human_npc_outfits.dm). In + * vacuum the suit it seals up in is its own family's, in the armour class of what it wears in good air + * (bounty_suits.dm). */ /** * The outfit table of every bounty human: it asks the NPC being dressed (bounty_build_outfit()), so - * the choice can read its record, its tier, its style and its kit. Set as npc_outfit_table. + * the choice can read its record, its tier, its style and its kit. Set as npc_outfit_table. Then the + * clothes for its site go on (bounty_site_clothes(), companions), and its own sealed suit if it is about + * to be sealed up for vacuum (bounty_seal_outfit()); the plain EVA layer is only the fallback. */ /datum/human_npc_outfit_table/bounty vacuum_layer = /datum/human_npc_layer/eva @@ -23,7 +27,9 @@ /datum/human_npc_outfit_table/bounty/pick_outfit(mob/living/carbon/human/npc/npc, zone) if(!ishumannpc(npc)) return null - return npc.bounty_build_outfit(zone || ZONE_GREEN) + var/outfit = npc.bounty_build_outfit(zone || ZONE_GREEN) + outfit = npc.bounty_site_clothes(outfit) + return bounty_seal_outfit(npc, outfit, src) /** * What a bounty human wears in `zone` (ZONE_*): a /datum/outfit typepath, or an instance made for it @@ -32,6 +38,13 @@ /mob/living/carbon/human/npc/proc/bounty_build_outfit(zone) return null +/** + * `outfit` (from bounty_build_outfit()) in the clothes it wears for where it is, or as it is. Companions + * swap their plain clothes for rough ones picked by their criminal's site (bounty_companions.dm). + */ +/mob/living/carbon/human/npc/proc/bounty_site_clothes(outfit) + return outfit + /// A fresh outfit of `base_type`, to add weapons, armour and kit to before it is worn /proc/bounty_outfit_instance(base_type) if(!ispath(base_type, /datum/outfit)) diff --git a/voidcrew/modules/bounties/bounty_placement.dm b/voidcrew/modules/bounties/bounty_placement.dm index 2ee253fc2cf..6e28641c1ca 100644 --- a/voidcrew/modules/bounties/bounty_placement.dm +++ b/voidcrew/modules/bounties/bounty_placement.dm @@ -125,11 +125,11 @@ best += ruin return board_pick_tiered(best, good, any) -/// An NPC pirate ship with its crew aboard, not claimed, not abandoned, holding no other bounty +/// A plain NPC pirate ship with its crew aboard, not claimed, not abandoned, holding no other bounty. Never a themed crew's (bounty_ship_hides_criminals()): a criminal hides among ordinary pirates. /datum/controller/subsystem/criminal_bounties/proc/board_pick_npc_ship(zone, obj/structure/overmap/exclude) var/list/candidates = list() for(var/obj/structure/overmap/ship/npc/pirate/npc_ship in SSnpc_ships?.active_ships) - if(QDELETED(npc_ship) || npc_ship == exclude) + if(QDELETED(npc_ship) || npc_ship == exclude || !bounty_ship_hides_criminals(npc_ship)) continue if(npc_ship.player_controlled || npc_ship.abandoned || npc_ship.spawner_resolved || !npc_ship.crew_ever_spawned) continue diff --git a/voidcrew/modules/bounties/bounty_posting.dm b/voidcrew/modules/bounties/bounty_posting.dm index 3fe62e1ed42..9da2acf8d26 100644 --- a/voidcrew/modules/bounties/bounty_posting.dm +++ b/voidcrew/modules/bounties/bounty_posting.dm @@ -382,12 +382,12 @@ var/turf/spot = get_turf(leaving) if(spot && leaving.stat != DEAD) new /obj/effect/temp_visual/transporter_flash/departure(spot) - // Its locked kit goes with it (D3); whatever on it isn't its own (papers, a key, a crew's cuffs) stays behind. + // Its locked kit goes with it (D3); whatever on it isn't its own (papers, a key, a crew's cuffs, a suit a + // crew put on it) stays behind, as at the pad (bounty_return_crew_items(), bounty_suits.dm). if(ishumannpc(leaving) && spot) var/mob/living/carbon/human/npc/body = leaving body.npc_drop_not_gear() - for(var/obj/item/restraints/worn in list(body.handcuffed, body.legcuffed)) - body.transferItemToLoc(worn, spot, force = TRUE) + bounty_return_crew_items(body, spot) qdel(leaving) // ===== RELISTING ===== diff --git a/voidcrew/modules/bounties/bounty_styles.dm b/voidcrew/modules/bounties/bounty_styles.dm index d590d9812d0..d8e81df3fd2 100644 --- a/voidcrew/modules/bounties/bounty_styles.dm +++ b/voidcrew/modules/bounties/bounty_styles.dm @@ -10,9 +10,15 @@ * - knife: a knife from a pocket (Wanted and above: a combat knife). Its cuts and bleeding are the * knife's own; * - club: a baseball bat in hand (Wanted and above: the metal bat). It knocks people back as tg's bat does; - * - pistol: a Stechkin from a shoulder holster, a spare magazine in a pocket, reloaded the player's way; + * - pistol: a Stechkin from a shoulder holster, set to single shots with its own fire selector, a spare + * magazine in a pocket, reloaded the player's way. Strings of BOUNTY_PISTOL_STRING_SHOTS, then a pause; * - shotgun: a pump shotgun on the back with buckshot (Wanted and above: a semi-automatic combat * shotgun), shells on a bandolier, loaded into the tube shell by shell; + * - SMG: a WT-550 worn on the belt at every tier, a spare magazine in a pocket. A burst is + * BOUNTY_SMG_BURST separate trigger pulls at the gun's own full-auto rate, so it stops the moment + * they can't shoot or the target is gone; + * - revolver: a .38 in a shoulder holster, a speedloader in a pocket. A dry cylinder is reloaded the + * player's way: the speedloader clicked into it pushes the spent casings out; * - bottle: beer bottles from a satchel, thrown one at a time with a real throw (tg's bottle smashes on * whoever it hits); out of bottles, they fight with their fists; * - holdout: a meek criminal's little Makarov, a pocket gun, and a spare magazine in a fanny pack (the @@ -23,6 +29,10 @@ * throw, the telegraph before it (a hit during it fumbles the attack), the reload, and the distance they * keep. Gear is locked to the body (D3): it never drops and is never loot; bottles are consumables, so a * thrown one leaves the hand and breaks. + * + * A gun that comes out of its holster, off their back or out of a bag at the start of a fight comes + * with a line and the holster's sound, and the draw is the telegraph for the first shot: at least + * BOUNTY_DRAW_TIME after it, fumbled by a hit in between (/datum/ai_behavior/human_npc_draw/bounty). */ /// Every fighting style by key (BOUNTY_STYLE_*), one datum each @@ -51,8 +61,14 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) return FALSE controller.set_blackboard_key(BB_BOUNTY_STYLE, key) bounty_ai_clear_windup(controller) + controller.clear_blackboard_key(BB_BOUNTY_BURST_LEFT) return TRUE +/// Whether style `key` (BOUNTY_STYLE_*) fights with a gun +/proc/bounty_style_is_gun(key) + var/datum/bounty_style/style = GLOB.bounty_styles[key] + return !!style && ispath(style.weapon, /obj/item/gun) + /// Whether a pawn is in a fight it can take part in: a criminal fighting, or a companion that has not broken /proc/bounty_ai_fighting(mob/living/fighter) if(istype(fighter, /mob/living/carbon/human/npc/bounty_criminal)) @@ -87,6 +103,58 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) var/obj/item/gun/ballistic/ballistic = gun return pumps && istype(ballistic) && human_npc_gun_needs_rack(ballistic) +/// Live rounds in a ballistic gun: its magazine (a revolver's cylinder holds its chamber) and a chambered round. Null for anything else. +/proc/bounty_gun_live_rounds(obj/item/gun/ballistic/gun) + if(!istype(gun)) + return null + . = gun.magazine ? human_npc_live_rounds(gun.magazine) : 0 + if(gun.chambered?.loaded_projectile && (!gun.magazine || !(gun.chambered in gun.magazine.stored_ammo))) + .++ + +/** + * Sets `gun` to single shots with its own fire selector, the way `user` would: their fire-mode button + * on the gun, or the selector itself while the button isn't theirs. A Stechkin fires three-round + * bursts until it is switched. Returns TRUE if the gun fires one round a pull now. + */ +/proc/bounty_gun_single_fire(mob/living/user, obj/item/gun/ballistic/gun) + if(!istype(gun)) + return FALSE + if(gun.burst_size <= 1) + return TRUE + // A gun with no selector only fires its burst + if(!gun.burst_fire_selection) + return FALSE + // The selector's click and its note go to whoever flips it, not to whoever's turn it is + var/mob/old_usr = usr + usr = user + for(var/datum/action/item_action/toggle_firemode/selector in gun.actions) + if(selector.owner == user) + selector.Trigger(user) + break + if(gun.burst_size > 1 && gun.burst_fire_selection) + gun.burst_select() + usr = old_usr + return gun.burst_size <= 1 + +/** + * Counts a shot just fired from `gun` towards a string of `string_length` on `controller`'s blackboard. A + * new magazine (a reload) starts the count again. TRUE when the shot ends a string with rounds still in + * the gun; an empty one is reloaded instead. + */ +/proc/bounty_ai_string_done(datum/ai_controller/controller, obj/item/gun/ballistic/gun, string_length) + if(!istype(gun) || string_length <= 0 || !gun.magazine) + return FALSE + var/shots = 1 + if(controller.blackboard[BB_BOUNTY_STRING_MAGAZINE] == gun.magazine) + shots += controller.blackboard[BB_BOUNTY_STRING_SHOTS] + else + controller.set_blackboard_key(BB_BOUNTY_STRING_MAGAZINE, gun.magazine) + if(shots >= string_length && bounty_gun_live_rounds(gun) > 0) + controller.set_blackboard_key(BB_BOUNTY_STRING_SHOTS, 0) + return TRUE + controller.set_blackboard_key(BB_BOUNTY_STRING_SHOTS, shots) + return FALSE + /// Empties the hand that isn't holding `keep`, for a gun that needs both: puts what's there away, and lets go of a spent shell or a spent magazine /proc/bounty_ai_free_other_hand(mob/living/carbon/body, obj/item/keep) for(var/obj/item/held in body.held_items) @@ -184,8 +252,24 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) var/windup_sound /// The telegraph works a pump: a spent shell in the chamber doesn't need a reload var/pumps = FALSE + /// Only the first shot of a string needs the telegraph (the gun raised, the hammer back); the draw counts as one + var/windup_per_string = FALSE /// Chance a blow is a shove instead var/shove_chance = 0 + /// A gun kept in a holster, on the back or in a bag until a fight: what people see as it comes out (on_drawn()) + var/draw_message + /// The gun is set to single shots with its own fire selector before it fires + var/single_fire = FALSE + /// Trigger pulls in one burst, burst_gap apart (1: a pull at a time). Each pull is its own step of bounty_shoot. + var/burst = 1 + var/burst_gap = 0 + /// Shots in a string, then string_pause on top of the interval before the next (0: no strings) + var/string_shots = 0 + var/string_pause = 0 + /// Its weapon goes where nobody sees it while they pass as a customer: a pocket, a holster or a bag under + /// a coat (decoys wear the same holster or bag, outpost_match_kit()). A gun on the belt or the back, or + /// a bat in hand, gives them away, so a trader-outpost fugitive never fights this way (bounty_roll_style()). + var/concealable = TRUE /** * Puts this style's weapon and spares on `outfit` (an instance), the heavier weapon if `heavy`. The @@ -198,6 +282,54 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) /datum/bounty_style/proc/weapon_for(heavy) return (heavy && heavy_weapon) || weapon +/// Trigger pulls in one burst for `fighter` +/datum/bounty_style/proc/burst_length(mob/living/carbon/fighter) + return burst + +/// Shots in one string for `fighter`, 0 for none +/datum/bounty_style/proc/string_length(mob/living/carbon/fighter) + return string_shots + +/// Whether a burst is under way. One whose next pull is long overdue was cut off (the AI stopped meanwhile), and is forgotten. +/datum/bounty_style/proc/burst_under_way(datum/ai_controller/controller) + if(!controller.blackboard[BB_BOUNTY_BURST_LEFT]) + return FALSE + if(world.time > controller.blackboard[BB_BOUNTY_NEXT_SHOT] + BOUNTY_BURST_STALE) + end_burst(controller) + return FALSE + return TRUE + +/// Whatever is left of a burst never fires: the next one starts with its own telegraph +/datum/bounty_style/proc/end_burst(datum/ai_controller/controller) + controller.clear_blackboard_key(BB_BOUNTY_BURST_LEFT) + +/** + * `weapon`, this style's own, just came into `fighter`'s hand out of `drawn_from` (a holster, a bag, or + * the body itself for a slot). The selector is set, and a gun that was put away comes out with the + * line and the holster's sound: the draw is the telegraph for the first shot, BOUNTY_DRAW_TIME later, + * and a hit in between fumbles it. + */ +/datum/bounty_style/proc/on_drawn(mob/living/carbon/fighter, datum/ai_controller/controller, obj/item/weapon, atom/drawn_from) + if(single_fire) + bounty_gun_single_fire(fighter, weapon) + if(!draw_message) + return + var/now = world.time + end_burst(controller) + controller.set_blackboard_key(BB_BOUNTY_DRAWN_AT, now) + controller.set_blackboard_key(BB_BOUNTY_NEXT_SHOT, now + BOUNTY_DRAW_TIME) + controller.set_blackboard_key(BB_BOUNTY_WINDUP_UNTIL, now + BOUNTY_DRAW_TIME) + controller.set_blackboard_key(BB_BOUNTY_WINDUP_FROM, now) + controller.set_blackboard_key(BB_BOUNTY_WINDUP_STAMINA, fighter.getStaminaLoss()) + var/atom/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(target) + fighter.face_atom(target) + fighter.visible_message(span_warning(replacetext(draw_message, "%USER", "[fighter]")), vision_distance = COMBAT_MESSAGE_RANGE) + var/obj/item/container = drawn_from + var/open_sound = istype(container) ? container.atom_storage?.open_sound : null + if(open_sound) + playsound(fighter, open_sound, 50, TRUE) + /// The ranged weapon in `fighter`'s hand that is ready to use, or null: a loaded (or pumpable) gun, a bottle /datum/bounty_style/proc/ready_in_hand(mob/living/carbon/fighter) if(!ranged) @@ -220,7 +352,13 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) /// Whether this shot needs the telegraph first /datum/bounty_style/proc/needs_windup(datum/ai_controller/controller) - return windup > 0 + if(windup <= 0) + return FALSE + if(!windup_per_string) + return TRUE + // Raised by the last shot, or by the draw, recently enough: the string goes on + var/raised_at = max(controller.blackboard[BB_BOUNTY_LAST_SHOT], controller.blackboard[BB_BOUNTY_DRAWN_AT]) + return !raised_at || world.time - raised_at > BOUNTY_PISTOL_STRING_GAP /// The telegraph: what they say, show and sound like before the shot /datum/bounty_style/proc/telegraph(mob/living/carbon/fighter, atom/target, obj/item/weapon) @@ -274,8 +412,38 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) bounty_ai_free_other_hand(fighter, gun) if(!human_npc_ready_item(fighter, gun)) return FALSE + if(single_fire) + bounty_gun_single_fire(fighter, gun) fighter.zone_selected = human_npc_pick_aim_zone() - return controller.ai_interact(target = target, combat_mode = TRUE) + var/rounds = bounty_gun_live_rounds(gun) + if(!controller.ai_interact(target = target, combat_mode = TRUE)) + return FALSE + // Only a round that went counts: a click the gun refused (its fire delay, an empty chamber) is no shot + return isnull(rounds) || bounty_gun_live_rounds(gun) < rounds + +/** + * One pull of the trigger (or one throw) at `target`, then the clock for the next: the burst's next + * pull burst_gap away while one is under way, else the style's interval, with string_pause on top after + * the last shot of a string. Returns TRUE if a round went. + */ +/datum/bounty_style/proc/pull(mob/living/carbon/fighter, datum/ai_controller/controller, atom/target, obj/item/weapon) + var/fired = attack(fighter, controller, target, weapon) + var/now = world.time + if(fired) + controller.set_blackboard_key(BB_BOUNTY_LAST_SHOT, now) + var/pulls = burst_length(fighter) + if(fired && pulls > 1) + var/left = (controller.blackboard[BB_BOUNTY_BURST_LEFT] || pulls) - 1 + if(left > 0 && ready_in_hand(fighter)) + controller.set_blackboard_key(BB_BOUNTY_BURST_LEFT, left) + controller.set_blackboard_key(BB_BOUNTY_NEXT_SHOT, now + burst_gap) + return TRUE + end_burst(controller) + var/next = now + interval + if(fired && bounty_ai_string_done(controller, weapon, string_length(fighter))) + next += string_pause + controller.set_blackboard_key(BB_BOUNTY_NEXT_SHOT, next) + return fired /// Bare fists: a person's punch, and now and then a shove /datum/bounty_style/brawler @@ -298,11 +466,12 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) weapon = /obj/item/melee/baseball_bat heavy_weapon = /obj/item/melee/baseball_bat/ablative weapon_type = /obj/item/melee/baseball_bat + concealable = FALSE /datum/bounty_style/club/equip(datum/outfit/outfit, heavy = FALSE) outfit.r_hand = weapon_for(heavy) -/// A Stechkin in a shoulder holster, a spare magazine in a pocket +/// A Stechkin in a shoulder holster, a spare magazine in a pocket: single shots twice a second, in strings /datum/bounty_style/pistol key = BOUNTY_STYLE_PISTOL ranged = TRUE @@ -311,8 +480,13 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) interval = BOUNTY_PISTOL_INTERVAL min_range = BOUNTY_PISTOL_MIN_RANGE windup = BOUNTY_PISTOL_WINDUP + windup_per_string = TRUE windup_message = "%USER raises a pistol." windup_sound = 'sound/items/weapons/gun/pistol/rack_small.ogg' + draw_message = "%USER pulls out a pistol!" + single_fire = TRUE + string_shots = BOUNTY_PISTOL_STRING_SHOTS + string_pause = BOUNTY_PISTOL_STRING_PAUSE /datum/bounty_style/pistol/equip(datum/outfit/outfit, heavy = FALSE) var/obj/item/gun/ballistic/gun_type = weapon_for(heavy) @@ -321,10 +495,49 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) LAZYADDASSOC(outfit.belt_contents, gun_type, 1) bounty_outfit_carry(outfit, initial(gun_type.accepted_magazine_type)) -/// Only the first shot of a string needs the gun raised -/datum/bounty_style/pistol/needs_windup(datum/ai_controller/controller) - var/last_shot = controller.blackboard[BB_BOUNTY_LAST_SHOT] - return !last_shot || world.time - last_shot > BOUNTY_PISTOL_STRING_GAP +/** + * A WT-550 worn on the belt, at every tier, and a spare magazine in a pocket. Brought up level before + * each burst; a burst is BOUNTY_SMG_BURST trigger pulls at the gun's own full-auto rate. + */ +/datum/bounty_style/smg + key = BOUNTY_STYLE_SMG + ranged = TRUE + weapon = /obj/item/gun/ballistic/automatic/wt550 + weapon_type = /obj/item/gun/ballistic/automatic/wt550 + interval = BOUNTY_SMG_INTERVAL + min_range = BOUNTY_SMG_MIN_RANGE + windup = BOUNTY_SMG_WINDUP + windup_sound = 'sound/items/weapons/gun/smg/smgrack.ogg' + draw_message = "%USER pulls out an SMG!" + burst = BOUNTY_SMG_BURST + burst_gap = BOUNTY_SMG_BURST_GAP + concealable = FALSE + +/datum/bounty_style/smg/equip(datum/outfit/outfit, heavy = FALSE) + var/obj/item/gun/ballistic/gun_type = weapon_for(heavy) + outfit.belt = gun_type + outfit.belt_contents = null + bounty_outfit_carry(outfit, initial(gun_type.accepted_magazine_type)) + +/// A .38 revolver in a shoulder holster, a speedloader in a pocket: one heavy shot a second +/datum/bounty_style/revolver + key = BOUNTY_STYLE_REVOLVER + ranged = TRUE + weapon = /obj/item/gun/ballistic/revolver/c38 + weapon_type = /obj/item/gun/ballistic/revolver/c38 + interval = BOUNTY_REVOLVER_INTERVAL + min_range = BOUNTY_REVOLVER_MIN_RANGE + windup = BOUNTY_REVOLVER_WINDUP + windup_per_string = TRUE + windup_message = "%USER thumbs back the hammer." + windup_sound = 'sound/items/weapons/gun/general/ballistic_click.ogg' + draw_message = "%USER pulls out a revolver!" + +/datum/bounty_style/revolver/equip(datum/outfit/outfit, heavy = FALSE) + outfit.belt = /obj/item/storage/belt/holster + outfit.belt_contents = null + LAZYADDASSOC(outfit.belt_contents, weapon_for(heavy), 1) + bounty_outfit_carry(outfit, /obj/item/ammo_box/c38) /// Buckshot: a pump shotgun on the back, shells on a bandolier. The pump is the telegraph before each blast. /datum/bounty_style/shotgun @@ -339,6 +552,8 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) windup_message = "%USER pumps the shotgun." windup_sound = 'sound/items/weapons/gun/shotgun/rack.ogg' pumps = TRUE + draw_message = "%USER unslings a shotgun!" + concealable = FALSE /datum/bounty_style/shotgun/equip(datum/outfit/outfit, heavy = FALSE) outfit.back = weapon_for(heavy) @@ -346,6 +561,13 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) outfit.belt_contents = null LAZYADDASSOC(outfit.belt_contents, /obj/item/ammo_casing/shotgun/buckshot, BOUNTY_SHOTGUN_SHELLS) +/// Off the back, the pump is worked as it comes up if nothing is chambered: the draw is the first blast's telegraph +/datum/bounty_style/shotgun/on_drawn(mob/living/carbon/fighter, datum/ai_controller/controller, obj/item/weapon, atom/drawn_from) + . = ..() + var/obj/item/gun/ballistic/gun = weapon + if(istype(gun) && human_npc_gun_needs_rack(gun) && human_npc_ready_item(fighter, gun)) + gun.attack_self(fighter) + /// The pump is real: a spent shell in the chamber is worked out by hand, which makes the rack's own sound /datum/bounty_style/shotgun/telegraph(mob/living/carbon/fighter, atom/target, obj/item/weapon) fighter.face_atom(target) @@ -500,9 +722,27 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) if(!to_draw) return controller.set_blackboard_key(BB_HUMAN_NPC_DRAW_ITEM, to_draw) - controller.queue_behavior(/datum/ai_behavior/human_npc_draw, BB_HUMAN_NPC_DRAW_ITEM) + controller.queue_behavior(/datum/ai_behavior/human_npc_draw/bounty, BB_HUMAN_NPC_DRAW_ITEM) return SUBTREE_RETURN_FINISH_PLANNING +/** + * The human NPC base's draw. When what comes into the hand is their style's own weapon, the style + * answers it (on_drawn()): a holstered or slung gun comes out with a line, and the first shot waits. + */ +/datum/ai_behavior/human_npc_draw/bounty + +/datum/ai_behavior/human_npc_draw/bounty/perform(seconds_per_tick, datum/ai_controller/controller, item_key) + var/mob/living/carbon/npc = controller.pawn + var/obj/item/weapon = controller.blackboard[item_key] + var/atom/drawn_from = weapon?.loc + var/held_before = !QDELETED(weapon) && npc.is_holding(weapon) + . = ..() + if(held_before || QDELETED(weapon) || !npc.is_holding(weapon)) + return + var/datum/bounty_style/style = bounty_ai_style(npc) + if(style?.weapon_type && istype(weapon, style.weapon_type)) + style.on_drawn(npc, controller, weapon, drawn_from) + /** * The human NPC base's reload, for a gun loaded through its tube (a shotgun): every shell it can fit, * one at a time, then the pump. @@ -558,8 +798,9 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) /** * Shoots (or throws) at the target from the style's distance: closes in while it can't see them, steps * back from anyone inside the style's min_range, steps aside for anyone it may not hit in its line, - * telegraphs, then pulls the trigger (or throws) once per the style's interval. Planning carries on - * meanwhile, so a new target, a retreat or a call for help is picked up mid-fight. + * telegraphs, then pulls the trigger (or throws) once per the style's interval; a burst is that many + * pulls burst_gap apart, each one checked like the first. Planning carries on meanwhile, so a new + * target, a retreat or a call for help is picked up mid-fight. */ /datum/ai_behavior/bounty_shoot // Often enough that a style fires at its own pace and its wind-up is never stretched @@ -588,27 +829,30 @@ GLOBAL_LIST_INIT(bounty_styles, init_bounty_styles()) if(!weapon || HAS_TRAIT(fighter, TRAIT_HANDS_BLOCKED)) // Dry or empty-handed: the arm subtree reloads or draws, or they fight with their fists return AI_BEHAVIOR_INSTANT | AI_BEHAVIOR_SUCCEEDED + // Every round of a burst is a pull of its own, asked for again here: anything above that stops it stops the burst + var/bursting = style.burst_under_way(controller) if(!can_see(fighter, target, required_distance)) + style.end_burst(controller) return AI_BEHAVIOR_INSTANT var/winding = !!controller.blackboard[BB_BOUNTY_WINDUP_UNTIL] - if(style.min_range && get_dist(fighter, target) < style.min_range && !winding) + if(style.min_range && get_dist(fighter, target) < style.min_range && !winding && !bursting) bounty_ai_back_off(controller, fighter, target) if(bounty_ai_line_blocked(fighter, target)) + style.end_burst(controller) bounty_ai_sidestep(fighter, target) return AI_BEHAVIOR_DELAY if(!winding && world.time < controller.blackboard[BB_BOUNTY_NEXT_SHOT]) return AI_BEHAVIOR_DELAY - if(!style.windup_step(fighter, controller, target, weapon)) + if(!bursting && !style.windup_step(fighter, controller, target, weapon)) return AI_BEHAVIOR_DELAY - if(style.attack(fighter, controller, target, weapon)) - controller.set_blackboard_key(BB_BOUNTY_LAST_SHOT, world.time) - controller.set_blackboard_key(BB_BOUNTY_NEXT_SHOT, world.time + style.interval) + style.pull(fighter, controller, target, weapon) return AI_BEHAVIOR_DELAY -/// A wind-up cut short never carries over: the next shot telegraphs again +/// A wind-up or a burst cut short never carries over: the next shot telegraphs again /datum/ai_behavior/bounty_shoot/finish_action(datum/ai_controller/controller, succeeded, target_key, targeting_strategy_key) . = ..() bounty_ai_clear_windup(controller) + controller.clear_blackboard_key(BB_BOUNTY_BURST_LEFT) /// The shotgun closes in to BOUNTY_SHOTGUN_RANGE /datum/ai_behavior/bounty_shoot/close diff --git a/voidcrew/modules/bounties/bounty_suits.dm b/voidcrew/modules/bounties/bounty_suits.dm new file mode 100644 index 00000000000..48f3d798efd --- /dev/null +++ b/voidcrew/modules/bounties/bounty_suits.dm @@ -0,0 +1,273 @@ +/** + * # Bounty hunting: suits where the air kills, and the crew's things at the pad + * + * Owner: A1 company and suits. Criminals and companions are real human NPCs, so they breathe, freeze and + * suffocate as anyone does (human_npc.dm); the human NPC base dresses them for the air where they are made + * (human_npc_outfits.dm). This file adds the bounty's rules on top: + * + * - Where they are dressed for. At a space ruin, vacuum is a door away, so a criminal there is always + * dressed for it; on a planet, so is one whose site has air that would hurt a person on any of a few + * tiles read at random, not only on its own (bounty_site_dress_for()). Companions are dressed for what + * their criminal was (bounty_companions.dm). + * - What they seal up in (bounty_vacuum_gear()): a suit in the armour class of what they wear in good air, + * so the vacuum neither strips nor gives armour. Petty and meek criminals and companions wear a soft + * suit; a Wanted or Most Wanted criminal, who wears an armour vest, an armoured space suit; a mini-boss + * its kit's own (bounty_boss_kits.dm). It is real gear, locked to them like the rest (D3, + * human_npc_gear.dm): it can't be stripped and never becomes loot. + * - Suiting up a catch. A hunter can put their own pressure suit or helmet on a criminal that is down, + * cuffed, stunned or dead, through the strip menu: it goes on in place of the locked piece in that slot, + * which is gone, taking as long as taking one off a person and putting the other on. It is the hunter's + * and can come off again like on anyone. An empty slot takes one the ordinary way. + * - The pad gives the crew back everything they put on the body (bounty_return_crew_items()). + */ + +/// Soft suits, for those who wear no armour, each list(suit, helmet) +GLOBAL_LIST_INIT(bounty_soft_suits, list( + list(/obj/item/clothing/suit/space/eva, /obj/item/clothing/head/helmet/space/eva), + list(/obj/item/clothing/suit/space, /obj/item/clothing/head/helmet/space), + list(/obj/item/clothing/suit/space/nasavoid, /obj/item/clothing/head/helmet/space/nasavoid), +)) + +/// Armoured space suits, for those who wear an armour vest, each list(suit, helmet) +GLOBAL_LIST_INIT(bounty_armoured_suits, list( + list(/obj/item/clothing/suit/space/syndicate/black, /obj/item/clothing/head/helmet/space/syndicate/black), + list(/obj/item/clothing/suit/space/syndicate/black/green, /obj/item/clothing/head/helmet/space/syndicate/black/green), + list(/obj/item/clothing/suit/space/syndicate/black/blue, /obj/item/clothing/head/helmet/space/syndicate/black/blue), + list(/obj/item/clothing/suit/space/syndicate/black/orange, /obj/item/clothing/head/helmet/space/syndicate/black/orange), +)) + +// ===== WHERE THEY ARE DRESSED FOR ===== + +/** + * The BOUNTY_PLACEMENT_* kind of the site a spawn context was made for (the overmap object it names: + * spawn_bounty_criminal() makes the criminal's from its site, and companions inherit it), or null. + */ +/proc/bounty_site_kind_of(datum/npc_spawn_context/context) + var/source_type = context?.source_type + if(ispath(source_type, /obj/structure/overmap/planet)) + return BOUNTY_PLACEMENT_PLANET + if(ispath(source_type, /obj/structure/overmap/space_ruin)) + return BOUNTY_PLACEMENT_RUIN + if(ispath(source_type, /obj/structure/overmap/ship/npc/pirate)) + return BOUNTY_PLACEMENT_NPC_SHIP + if(ispath(source_type, /obj/structure/overmap/trader_outpost)) + return BOUNTY_PLACEMENT_TRADER_OUTPOST + return null + +/** + * HUMAN_NPC_SITE_* flags a bounty NPC made for `context`'s site is dressed for whatever the air on its own + * tile: vacuum at a space ruin, and on a planet whatever a few of its tiles' air asks of a person + * (bounty_planet_site()). The human NPC base adds the spawn tile's own. NONE anywhere else. + */ +/proc/bounty_site_dress_for(datum/npc_spawn_context/context) + switch(bounty_site_kind_of(context)) + if(BOUNTY_PLACEMENT_RUIN) + return HUMAN_NPC_SITE_VACUUM + if(BOUNTY_PLACEMENT_PLANET) + return bounty_planet_site(locate(context.source_id)) + return NONE + +/** + * What the air of `planet`'s site asks of a person (HUMAN_NPC_SITE_* flags), read on + * BOUNTY_SITE_AIR_SAMPLES open tiles picked at random within its footprint: a criminal in a sealed ruin + * on a planet whose air would kill it still has to go out in it. + */ +/proc/bounty_planet_site(obj/structure/overmap/planet/planet) + . = NONE + if(!istype(planet) || QDELETED(planet)) + return + var/list/bounds = bounty_site_bounds(planet) + if(length(bounds) < 5) + return + for(var/i in 1 to BOUNTY_SITE_AIR_SAMPLES) + var/turf/open/sample = locate(rand(bounds[1], bounds[3]), rand(bounds[2], bounds[4]), bounds[5]) + if(!istype(sample) || is_space_or_openspace(sample)) + continue + . |= human_npc_site_at(sample) + +/// Whether the human NPC base will seal `npc` up as it dresses it (npc_fit_outfit_to_site()): its site asks for it, and its species isn't proof against both vacuum and its cold +/proc/bounty_dressing_sealed(mob/living/carbon/human/npc/npc, datum/human_npc_outfit_table/table) + var/site = human_npc_site_at(get_turf(npc)) | npc.npc_always_site | table?.always_site + if(!(site & HUMAN_NPC_SITE_VACUUM)) + return FALSE + return !(HAS_TRAIT(npc, TRAIT_RESISTLOWPRESSURE) && HAS_TRAIT(npc, TRAIT_RESISTCOLD)) + +// ===== WHAT THEY SEAL UP IN ===== + +/mob/living/carbon/human/npc + /// The sealed suit and helmet it was given for vacuum, list(suit, helmet), once it has been dressed in them (bounty_vacuum_gear()) + var/list/suits_vacuum_gear + +/** + * The suit and helmet a bounty NPC seals up in where the air would kill it: list(suit, helmet) typepaths, + * a null helmet keeping its own (already sealed). Null for the human NPC base's plain EVA layer. Each + * family overrides it; a random pick is fine, as it is asked once per body (bounty_vacuum_gear()). + */ +/mob/living/carbon/human/npc/proc/bounty_sealed_gear() + return null + +/// A soft suit or an armoured one for a criminal of `tier` (BOUNTY_TIER_*): armoured for those who wear an armour vest (bounty_add_tier_armour()) +/proc/bounty_tier_sealed_gear(tier) + if(isnull(tier) || tier == BOUNTY_TIER_PETTY) + return pick(GLOB.bounty_soft_suits) + return pick(GLOB.bounty_armoured_suits) + +/mob/living/carbon/human/npc/bounty_criminal/normal/bounty_sealed_gear() + return bounty_tier_sealed_gear(record?.tier) + +/mob/living/carbon/human/npc/bounty_criminal/meek/bounty_sealed_gear() + return bounty_tier_sealed_gear(record?.tier) + +// A mini-boss's kit sets its own (bounty_boss_kits.dm); one with none wears plain clothes, so a soft suit +/mob/living/carbon/human/npc/bounty_criminal/boss/bounty_sealed_gear() + return pick(GLOB.bounty_soft_suits) + +/mob/living/carbon/human/npc/bounty_companion/bounty_sealed_gear() + return pick(GLOB.bounty_soft_suits) + +/** + * The sealed suit and helmet `npc` wears where the air would kill it (bounty_sealed_gear()), the same + * every time it is asked: list(suit, helmet), or null for the plain EVA layer. Anything that changes a + * bounty NPC's clothes later (the chrome exposure, a blend) leaves these pieces alone. + */ +/proc/bounty_vacuum_gear(mob/living/carbon/human/npc/npc) + if(!ishumannpc(npc)) + return null + if(isnull(npc.suits_vacuum_gear)) + var/list/gear = npc.bounty_sealed_gear() + npc.suits_vacuum_gear = islist(gear) ? gear.Copy() : list() + return length(npc.suits_vacuum_gear) ? npc.suits_vacuum_gear : null + +/** + * `outfit` (a typepath or an instance) with `npc`'s own sealed suit and helmet on, if it is about to be + * sealed up for vacuum (bounty_dressing_sealed()): the human NPC base then finds it sealed, and only adds + * the air tank. Anything the old suit held moves to the backpack, as the base's layers do. Returns the + * outfit unchanged when nothing is needed, else an instance (one passed in is changed in place). + */ +/proc/bounty_seal_outfit(mob/living/carbon/human/npc/npc, outfit, datum/human_npc_outfit_table/table) + if(isnull(outfit) || !bounty_dressing_sealed(npc, table)) + return outfit + var/list/gear = bounty_vacuum_gear(npc) + if(length(gear) < 2 || !ispath(gear[1], /obj/item/clothing/suit)) + return outfit + var/datum/outfit/dressed = ispath(outfit, /datum/outfit) ? new outfit() : outfit + if(!istype(dressed)) + return outfit + if(dressed.suit_store) + if(dressed.back) + LAZYADDASSOC(dressed.backpack_contents, dressed.suit_store, 1) + dressed.suit_store = null + dressed.suit = gear[1] + var/obj/item/clothing/own_head = dressed.head + if(ispath(gear[2], /obj/item/clothing/head)) + dressed.head = gear[2] + else if(!ispath(own_head, /obj/item/clothing) || !(initial(own_head.clothing_flags) & STOPSPRESSUREDAMAGE) || !initial(own_head.min_cold_protection_temperature) || initial(own_head.min_cold_protection_temperature) > SPACE_HELM_MIN_TEMP_PROTECT) + dressed.head = /obj/item/clothing/head/helmet/space + return dressed + +// ===== SUITING UP A CATCH ===== + +/// Whether `garment` is a pressure suit or helmet `user` could put on someone in `slot` (ITEM_SLOT_OCLOTHING or ITEM_SLOT_HEAD) +/proc/bounty_pressure_garment_for(obj/item/clothing/garment, slot) + if(!istype(garment) || QDELETED(garment) || !(garment.clothing_flags & STOPSPRESSUREDAMAGE) || !(garment.slot_flags & slot)) + return FALSE + if(HAS_TRAIT(garment, TRAIT_NODROP) || (garment.item_flags & ABSTRACT)) + return FALSE + switch(slot) + if(ITEM_SLOT_OCLOTHING) + return istype(garment, /obj/item/clothing/suit) + if(ITEM_SLOT_HEAD) + return istype(garment, /obj/item/clothing/head) + return FALSE + +/** + * The pressure suit or helmet `user` holds ready to put on it in place of `worn`, one of its own locked + * pieces in the suit or head slot, or null when this isn't that (any other reach goes to tg's strip menu + * as it is). A hood belongs to its suit, and goes with it. + */ +/mob/living/carbon/human/npc/bounty_criminal/proc/suits_garment_offered(mob/user, obj/item/worn) + if(!ismob(user) || !istype(worn) || worn.loc != src || !human_npc_gear_locked(worn)) + return null + if(istype(worn, /obj/item/clothing/head/hooded)) + return null + var/slot = get_slot_by_item(worn) + if(slot != ITEM_SLOT_OCLOTHING && slot != ITEM_SLOT_HEAD) + return null + var/obj/item/clothing/garment = user.get_active_held_item() + return bounty_pressure_garment_for(garment, slot) ? garment : null + +/** + * The bounty_body component's strip hook (bounty_criminal.dm): `user` reaches for `worn` through the strip + * menu. With a pressure suit or helmet in hand for a slot its own locked piece fills, on a criminal that is + * down, cuffed, stunned or dead, the hunter starts putting theirs on (suits_put_on()); on one that is free, + * it pulls away. Returns COMPONENT_CANT_STRIP when it takes the reach over, so tg's strip doesn't go on to + * refuse the locked piece, else NONE. + */ +/mob/living/carbon/human/npc/bounty_criminal/proc/suits_strip_reach(mob/user, obj/item/worn) + var/obj/item/clothing/garment = suits_garment_offered(user, worn) + if(!garment) + return NONE + if(capture_state() == BOUNTY_STATE_FREE) + balloon_alert(user, "[p_they()] pull[p_s()] away!") + return COMPONENT_CANT_STRIP + INVOKE_ASYNC(src, PROC_REF(suits_put_on), user, worn, garment) + return COMPONENT_CANT_STRIP + +/** + * `user` puts `garment` on it in place of `worn`: as long as taking the one off a person and putting the + * other on (`worn`'s strip delay and `garment`'s equip delay), standing beside it. Sleeps. Returns TRUE if + * it went on. + */ +/mob/living/carbon/human/npc/bounty_criminal/proc/suits_put_on(mob/user, obj/item/worn, obj/item/clothing/garment) + garment.item_start_equip(src, garment, user) + if(!do_after(user, worn.strip_delay + garment.equip_delay_other, src, interaction_key = REF(garment))) + return FALSE + return suits_swap_now(user, worn, garment) + +/** + * Puts `garment`, from `user`'s hands, on it in place of `worn`, now: the locked piece is gone (it never + * leaves the body as loot), and the garment is the hunter's, an ordinary item that can come off again. + * Only while it is still the same reach: `worn` in its slot, `garment` in the hunter's hand, the hunter + * beside it, and it down, cuffed, stunned or dead. Returns TRUE if it went on. Doesn't sleep. + */ +/mob/living/carbon/human/npc/bounty_criminal/proc/suits_swap_now(mob/user, obj/item/worn, obj/item/clothing/garment) + if(QDELETED(src) || QDELETED(user) || !user.Adjacent(src)) + return FALSE + if(suits_garment_offered(user, worn) != garment || capture_state() == BOUNTY_STATE_FREE) + return FALSE + var/slot = get_slot_by_item(worn) + // One that wouldn't fit them (their species, their shape) leaves their own piece on + if(!can_equip(garment, slot, disable_warning = TRUE, bypass_equip_delay_self = TRUE, ignore_equipped = TRUE)) + return FALSE + if(!user.temporarilyRemoveItemFromInventory(garment)) + return FALSE + qdel(worn) + if(!equip_to_slot_if_possible(garment, slot, disable_warning = TRUE, bypass_equip_delay_self = TRUE)) + user.put_in_hands(garment) + return FALSE + finish_equip_mob(garment, src, user) + return TRUE + +// ===== THE CREW'S THINGS ===== + +/// Whether `item`, directly on a bounty NPC's body, is something the crew put there: not its own locked gear or consumables, and not part of the body (limbs, organs, implants). A hood goes with its suit. +/proc/bounty_crew_item(obj/item/item) + if(!istype(item) || QDELETED(item) || (item.item_flags & ABSTRACT)) + return FALSE + if(isbodypart(item) || isorgan(item) || istype(item, /obj/item/implant) || istype(item, /obj/item/clothing/head/hooded)) + return FALSE + return !HAS_TRAIT(item, TRAIT_HUMAN_NPC_GEAR) && !HAS_TRAIT(item, TRAIT_HUMAN_NPC_CONSUMABLE) + +/** + * Puts down at `spot` everything the crew put on `body`: their cuffs, a suit and helmet, an air tank in its + * suit storage, whatever else. Its own gear goes with it (D3). Returns what was put down. + */ +/proc/bounty_return_crew_items(mob/living/carbon/human/npc/body, turf/spot) + . = list() + if(QDELETED(body) || !isturf(spot)) + return + for(var/obj/item/item in body.contents.Copy()) + if(item.loc != body || !bounty_crew_item(item)) + continue + if(body.transferItemToLoc(item, spot, force = TRUE)) + . += item diff --git a/voidcrew/modules/bounties/bounty_turn_in.dm b/voidcrew/modules/bounties/bounty_turn_in.dm index 422892a428f..2fa9980ba99 100644 --- a/voidcrew/modules/bounties/bounty_turn_in.dm +++ b/voidcrew/modules/bounties/bounty_turn_in.dm @@ -374,10 +374,8 @@ /mob/living/carbon/human/npc/bounty_criminal/proc/board_finish_beam_out() var/turf/spot = get_turf(src) npc_drop_not_gear() - // The crew's restraints stay with the crew: they are theirs, not the criminal's. - if(spot) - for(var/obj/item/restraints/worn in list(handcuffed, legcuffed)) - transferItemToLoc(worn, spot, force = TRUE) + // What the crew put on them stays with the crew: their restraints, and any suit, helmet or tank they put on for the trip (bounty_suits.dm) + bounty_return_crew_items(src, spot) if(spot) new /obj/effect/temp_visual/transporter_flash/departure(spot) transporter_sparks(spot) diff --git a/voidcrew/modules/unit_tests/_unit_tests.dm b/voidcrew/modules/unit_tests/_unit_tests.dm index 8e83525fd59..6c619916745 100644 --- a/voidcrew/modules/unit_tests/_unit_tests.dm +++ b/voidcrew/modules/unit_tests/_unit_tests.dm @@ -46,6 +46,7 @@ #include "voidcrew_bounty_board.dm" #include "voidcrew_bounty_bosses.dm" #include "voidcrew_bounty_criminal.dm" +#include "voidcrew_bounty_guns.dm" #include "voidcrew_bounty_identity.dm" #include "voidcrew_bounty_kingpin.dm" #include "voidcrew_bounty_lair_mafia.dm" @@ -53,6 +54,7 @@ #include "voidcrew_bounty_lairs.dm" #include "voidcrew_bounty_outpost.dm" #include "voidcrew_bounty_seams.dm" +#include "voidcrew_bounty_suits.dm" #include "voidcrew_camera_scope.dm" #include "voidcrew_cargo_cart.dm" #include "voidcrew_cargo_docking.dm" diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_guns.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_guns.dm new file mode 100644 index 00000000000..cae6833206c --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_guns.dm @@ -0,0 +1,598 @@ +/** + * Bounty hunting: the guns, for voidcrew/modules/bounties/bounty_styles.dm and the pistols of the kingpin's + * goons and Club Volga. Every bounty gun is a real one fired through the body's own hands: an SMG burst is + * four separate trigger pulls of a WT-550, and stops the moment the shooter can't shoot or the target is + * gone; a holstered gun comes out with a line and holds the first shot; the Stechkin is set to single shots + * with its own fire selector and fired in strings by criminals, goons, mobsters and the don; a dry revolver + * is reloaded from a speedloader; a blended fugitive's holster is worn by its decoys too. + * + * The tests drive the behaviours and procs directly (a test world has no clients, so the AI is off) and + * skip the waits between pulls by moving the clock, not by sleeping through them. They sleep a tick + * between real shots only because a gun's fire delay is a timer. Fork defines are included after the + * tests, so a test uses the literal value with a comment naming the define. + */ + +/** + * Waits for the guns `fighter` holds to be ready for the next pull: a tick at least, and until each one's + * fire delay is over (it is a timer, and a busy test world runs timers late). Gives up after 2 seconds. + */ +/proc/bounty_guns_test_wait(mob/living/carbon/fighter) + sleep(1) + for(var/wait in 1 to 20) + var/busy = FALSE + for(var/obj/item/gun/gun in fighter?.held_items) + if(gun.fire_cd || gun.firing_burst) + busy = TRUE + if(!busy) + return + sleep(1) + +/// The criminals' guns, in the bounty AI tests' room with their helpers (make_criminal(), carried()) +/datum/unit_test/voidcrew_bounty_guns + parent_type = /datum/unit_test/voidcrew_bounty_ai + abstract_type = /datum/unit_test/voidcrew_bounty_guns + +/// A person at `where` whom `criminal` is out to get: on its grudge list and its target +/datum/unit_test/voidcrew_bounty_guns/proc/make_target(mob/living/carbon/human/npc/bounty_criminal/criminal, turf/where) + var/mob/living/carbon/human/consistent/hunter = allocate(/mob/living/carbon/human/consistent, where) + criminal.ai_add_grudge(hunter) + criminal.ai_controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) + return hunter + +/// One step of `fighter`'s shooting behaviour, with the click delays a test can't wait out cleared +/datum/unit_test/voidcrew_bounty_guns/proc/shoot_step(mob/living/carbon/human/npc/fighter) + var/datum/bounty_style/style = bounty_ai_style(fighter) + var/datum/ai_behavior/shoot = GET_AI_BEHAVIOR(style.ranged_behavior) + fighter.next_move = 0 + fighter.next_click = 0 + return shoot.perform(0.1, fighter.ai_controller, BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETING_STRATEGY) + +/// What the controller does when the shooting behaviour stops: its finish_action() +/datum/unit_test/voidcrew_bounty_guns/proc/shoot_stopped(mob/living/carbon/human/npc/fighter) + var/datum/bounty_style/style = bounty_ai_style(fighter) + var/datum/ai_behavior/shoot = GET_AI_BEHAVIOR(style.ranged_behavior) + shoot.finish_action(fighter.ai_controller, FALSE, BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETING_STRATEGY) + +/// The next pull is due now: a tick for the gun's fire delay, the target patched up, the wait skipped +/datum/unit_test/voidcrew_bounty_guns/proc/next_pull(mob/living/carbon/human/npc/fighter, mob/living/carbon/human/target) + bounty_guns_test_wait(fighter) + target?.fully_heal(HEAL_ALL) + fighter.ai_controller.set_blackboard_key("bb_bounty_next_shot", world.time) // BB_BOUNTY_NEXT_SHOT + +/// `fighter` draws its style's gun through the draw behaviour the arm subtree queues. Returns the gun, in hand. +/datum/unit_test/voidcrew_bounty_guns/proc/draw_gun(mob/living/carbon/human/npc/fighter) + var/datum/bounty_style/style = bounty_ai_style(fighter) + var/obj/item/gun/gun = style?.carried_ranged(fighter) + TEST_ASSERT_NOTNULL(gun, "Test fixture: [fighter] has no gun to draw") + var/datum/ai_controller/controller = fighter.ai_controller + controller.set_blackboard_key("human_npc_draw_item", gun) // BB_HUMAN_NPC_DRAW_ITEM + var/datum/ai_behavior/draw = GET_AI_BEHAVIOR(/datum/ai_behavior/human_npc_draw/bounty) + TEST_ASSERT(draw.perform(0.1, controller, "human_npc_draw_item") & AI_BEHAVIOR_SUCCEEDED, "[fighter] didn't draw [gun]") + draw.finish_action(controller, TRUE, "human_npc_draw_item") + TEST_ASSERT(fighter.is_holding(gun), "[gun] didn't come into [fighter]'s hand") + return gun + +/// Runs `behavior_type` (a reload) on `npc` step by step, the waits between steps skipped. TRUE if it finished. +/datum/unit_test/voidcrew_bounty_guns/proc/run_reload(mob/living/carbon/human/npc/npc, behavior_type, steps = 40) + var/datum/ai_controller/controller = npc.ai_controller + var/datum/ai_behavior/reload = GET_AI_BEHAVIOR(behavior_type) + if(!reload.setup(controller)) + return FALSE + for(var/step in 1 to steps) + npc.next_click = 0 + npc.next_move = 0 + var/result = reload.perform(1, controller) + if(result & AI_BEHAVIOR_FAILED) + reload.finish_action(controller, FALSE) + return FALSE + if(result & AI_BEHAVIOR_SUCCEEDED) + reload.finish_action(controller, TRUE) + return TRUE + return FALSE + +/** + * A burst of `fighter`'s under way at `target`: the spin-up skipped and the first pull made. Returns the + * rounds left in `gun`. + */ +/datum/unit_test/voidcrew_bounty_guns/proc/start_burst(mob/living/carbon/human/npc/fighter, mob/living/carbon/human/target, obj/item/gun/ballistic/gun) + var/datum/ai_controller/controller = fighter.ai_controller + shoot_step(fighter) + controller.set_blackboard_key("bb_bounty_windup_until", world.time) // BB_BOUNTY_WINDUP_UNTIL + shoot_step(fighter) + TEST_ASSERT(controller.blackboard["bb_bounty_burst_left"], "Test fixture: [fighter]'s burst didn't start") // BB_BOUNTY_BURST_LEFT + next_pull(fighter, target) + return bounty_gun_live_rounds(gun) + +// ===== THE KIT AND THE ROLLS ===== + +/** + * The WT-550 at every tier, worn on the belt with a spare magazine in a pocket; the .38 in a shoulder + * holster with a speedloader; both carried, not held, until a fight. Both are rolled for criminals and + * companions, and offered in the Bounty Panel. + */ +/datum/unit_test/voidcrew_bounty_guns/kit + +/datum/unit_test/voidcrew_bounty_guns/kit/Run() + for(var/tier in list(1, 2)) // BOUNTY_TIER_PETTY, BOUNTY_TIER_WANTED + var/mob/living/carbon/human/npc/bounty_criminal/normal/gunner = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(tier, 0), "smg", tier) // BOUNTY_STYLE_SMG + var/obj/item/gun/ballistic/automatic/wt550/smg = gunner.belt + TEST_ASSERT(istype(smg), "A tier [tier] SMG criminal has no WT-550 on the belt") + TEST_ASSERT(!gunner.is_holding(smg), "The WT-550 is in hand before the fight") + TEST_ASSERT(istype(gunner.r_store, /obj/item/ammo_box/magazine/wt550m9) || istype(gunner.l_store, /obj/item/ammo_box/magazine/wt550m9), "The SMG criminal has no spare magazine in a pocket") + TEST_ASSERT_NOTNULL(carried(gunner, /obj/item/stack/medical/bruise_pack), "The SMG criminal carries nothing to treat themselves with") + TEST_ASSERT_EQUAL(smg.burst_size, 1, "The WT-550 fires more than a round a pull") + TEST_ASSERT_EQUAL(bounty_ai_style(gunner)?.carried_ranged(gunner), smg, "The SMG style would not draw the WT-550 off the belt") + + var/mob/living/carbon/human/npc/bounty_criminal/normal/shooter = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(3, 0), "revolver") // BOUNTY_STYLE_REVOLVER + var/obj/item/gun/ballistic/revolver/c38/revolver = carried(shooter, /obj/item/gun/ballistic/revolver/c38) + TEST_ASSERT_NOTNULL(revolver, "The revolver criminal carries no .38") + TEST_ASSERT(istype(revolver.loc, /obj/item/storage/belt/holster), "The .38 isn't in a holster") + TEST_ASSERT(istype(shooter.r_store, /obj/item/ammo_box/c38) || istype(shooter.l_store, /obj/item/ammo_box/c38), "The revolver criminal has no speedloader in a pocket") + TEST_ASSERT_NOTNULL(carried(shooter, /obj/item/stack/medical/bruise_pack), "The revolver criminal carries nothing to treat themselves with") + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(revolver), 6, "The .38 isn't loaded with six") + + // Rolled for criminals and companions, offered to admins + var/list/rolled = list() + for(var/i in 1 to 400) + rolled[bounty_roll_style()] = TRUE + TEST_ASSERT(rolled["smg"] && rolled["revolver"], "A criminal never rolls the SMG or the revolver") // BOUNTY_STYLE_SMG, BOUNTY_STYLE_REVOLVER + var/mob/living/carbon/human/npc/bounty_companion/buddy = allocate(/mob/living/carbon/human/npc/bounty_companion, tile(4, 0)) + var/list/companion_styles = list() + for(var/i in 1 to 300) + buddy.ai_style = null + qdel(buddy.bounty_build_outfit(1)) // ZONE_GREEN + companion_styles[buddy.ai_style] = TRUE + TEST_ASSERT(companion_styles["smg"] && companion_styles["revolver"], "A companion never rolls the SMG or the revolver") + var/datum/bounty_admin_panel/panel = allocate(/datum/bounty_admin_panel) + var/list/choices = panel.style_choices() + TEST_ASSERT_EQUAL(choices["SMG"], "smg", "The Bounty Panel doesn't offer the SMG") + TEST_ASSERT_EQUAL(choices["Revolver"], "revolver", "The Bounty Panel doesn't offer the revolver") + + // Which styles fight with a gun + for(var/key in list("pistol", "shotgun", "smg", "revolver", "holdout")) + TEST_ASSERT(bounty_style_is_gun(key), "The [key] style doesn't count as a gun") + for(var/key in list("brawler", "knife", "club", "bottle", "nonsense")) + TEST_ASSERT(!bounty_style_is_gun(key), "The [key] style counts as a gun") + +// ===== THE SMG'S BURST ===== + +/** + * A burst is four trigger pulls of the real WT-550 at its own full-auto rate, after the gun is brought up + * level, and each pull is asked for again: it stops the moment the shooter is stamina-crit, cuffed, + * knocked down or dead, or the target goes down, and what is left of a burst the AI was stopped in the + * middle of never fires. + */ +/datum/unit_test/voidcrew_bounty_guns/smg_burst + +/datum/unit_test/voidcrew_bounty_guns/smg_burst/Run() + var/mob/living/carbon/human/npc/bounty_criminal/normal/gunner = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(0, 2), "smg") // BOUNTY_STYLE_SMG + var/mob/living/carbon/human/target = make_target(gunner, tile(4, 2)) + var/obj/item/gun/ballistic/automatic/wt550/gun = gunner.belt + TEST_ASSERT(human_npc_take_in_hand(gunner, gun), "The WT-550 can't be drawn off the belt") + var/datum/ai_controller/controller = gunner.ai_controller + var/rounds = bounty_gun_live_rounds(gun) + + // Brought up level first: no round yet + shoot_step(gunner) + TEST_ASSERT(controller.blackboard["bb_bounty_windup_until"] > world.time, "The SMG didn't come up level before the burst") // BB_BOUNTY_WINDUP_UNTIL + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(gun), rounds, "A round went before the SMG was up") + controller.set_blackboard_key("bb_bounty_windup_until", world.time) // BB_BOUNTY_WINDUP_UNTIL + + // Four pulls, a single round each, the gun's own rate apart + for(var/pull in 1 to 4) + shoot_step(gunner) + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(gun), rounds - pull, "After pull [pull] of the burst [rounds - bounty_gun_live_rounds(gun)] rounds had gone") + if(pull == 4) + break + TEST_ASSERT_EQUAL(controller.blackboard["bb_bounty_burst_left"], 4 - pull, "The burst lost count after pull [pull]") // BB_BOUNTY_BURST_LEFT, BOUNTY_SMG_BURST + TEST_ASSERT_EQUAL(controller.blackboard["bb_bounty_next_shot"], world.time + 3, "The burst's next pull isn't 0.3 seconds on") // BB_BOUNTY_NEXT_SHOT, BOUNTY_SMG_BURST_GAP + next_pull(gunner, target) + TEST_ASSERT_NULL(controller.blackboard["bb_bounty_burst_left"], "The burst didn't end after four pulls") // BB_BOUNTY_BURST_LEFT + TEST_ASSERT_EQUAL(controller.blackboard["bb_bounty_next_shot"], world.time + 5, "After a burst, the next one isn't half a second off") // BOUNTY_SMG_INTERVAL + // The next burst is brought up level again + next_pull(gunner, target) + shoot_step(gunner) + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(gun), rounds - 4, "A fifth round went without the SMG brought up again") + TEST_ASSERT(controller.blackboard["bb_bounty_windup_until"] > world.time, "The next burst didn't start with the SMG brought up") + shoot_stopped(gunner) + + // Cut off by anything that stops the shooter, or the target going down + var/list/stoppers = list("stamina crit", "cuffs", "knockdown", "death", "target down", "AI stopped") + for(var/i in 1 to length(stoppers)) + var/stopper = stoppers[i] + var/mob/living/carbon/human/npc/bounty_criminal/normal/shooter = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(0, i % 5), "smg") // BOUNTY_STYLE_SMG + var/mob/living/carbon/human/mark = make_target(shooter, tile(4, i % 5)) + var/obj/item/gun/ballistic/automatic/wt550/smg = shooter.belt + TEST_ASSERT(human_npc_take_in_hand(shooter, smg), "Test fixture: the WT-550 can't be drawn") + var/left = start_burst(shooter, mark, smg) + switch(stopper) + if("stamina crit") + shooter.adjustStaminaLoss(200) + TEST_ASSERT(shooter.has_status_effect(/datum/status_effect/incapacitating/stamcrit), "Test fixture: no stamina crit") + if("cuffs") + var/obj/item/restraints/handcuffs/cuffs = allocate(/obj/item/restraints/handcuffs, get_turf(shooter)) + TEST_ASSERT(shooter.equip_to_slot_if_possible(cuffs, ITEM_SLOT_HANDCUFFED) && HAS_TRAIT(shooter, TRAIT_RESTRAINED), "Test fixture: the cuffs didn't go on") + if("knockdown") + shooter.Knockdown(3 SECONDS) + TEST_ASSERT(HAS_TRAIT(shooter, TRAIT_FLOORED), "Test fixture: not knocked down") + if("death") + shooter.death() + if("target down") + bounty_test_hurt_to(mark, -10) + TEST_ASSERT(mark.stat >= SOFT_CRIT, "Test fixture: the target didn't go down") + if("AI stopped") + // The next pull came due long ago: the AI was off in between (asleep, say), and the burst was cut off + shooter.ai_controller.set_blackboard_key("bb_bounty_next_shot", world.time - 6) // BB_BOUNTY_NEXT_SHOT, past BOUNTY_BURST_STALE + for(var/try_pull in 1 to 3) + shoot_step(shooter) + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(smg), left, "The burst went on after [stopper]") + if(stopper == "AI stopped") + TEST_ASSERT(shooter.ai_controller.blackboard["bb_bounty_windup_until"], "A burst cut off by the AI stopping didn't start over with the SMG brought up") + shoot_stopped(shooter) + TEST_ASSERT_NULL(shooter.ai_controller.blackboard["bb_bounty_burst_left"], "After [stopper], the rest of the burst is still to come") // BB_BOUNTY_BURST_LEFT + +// ===== THE DRAW ===== + +/** + * Every gun style that keeps its gun put away comes out with a line. The draw is the first shot's + * telegraph: at least 0.6 seconds, even if the telegraph itself is dropped, and the pistol isn't raised + * a second time on top of it. The Stechkin comes out switched to single shots by its own selector. A hit + * during the draw fumbles the first shot. + */ +/datum/unit_test/voidcrew_bounty_guns/draw + +/datum/unit_test/voidcrew_bounty_guns/draw/Run() + for(var/key in list("pistol", "shotgun", "smg", "revolver")) // BOUNTY_STYLE_* + var/datum/bounty_style/style = GLOB.bounty_styles[key] + TEST_ASSERT(length(style?.draw_message), "The [key] style draws its gun without a word") + + var/mob/living/carbon/human/npc/bounty_criminal/normal/gunner = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(0, 2), "pistol") // BOUNTY_STYLE_PISTOL + var/mob/living/carbon/human/target = make_target(gunner, tile(4, 2)) + var/obj/item/gun/ballistic/automatic/pistol/aps/stechkin = carried(gunner, /obj/item/gun/ballistic/automatic/pistol/aps) + TEST_ASSERT_EQUAL(stechkin?.burst_size, 3, "Test fixture: the Stechkin isn't on its three-round burst before the draw") + var/datum/ai_controller/controller = gunner.ai_controller + var/drawn_at = world.time + TEST_ASSERT_EQUAL(draw_gun(gunner), stechkin, "The pistol criminal drew something else") + TEST_ASSERT_EQUAL(controller.blackboard["bb_bounty_drawn_at"], drawn_at, "The draw wasn't the pistol's") // BB_BOUNTY_DRAWN_AT + + // Its own selector, set to single shots + TEST_ASSERT_EQUAL(stechkin.burst_size, 1, "The drawn Stechkin still fires bursts") + TEST_ASSERT(!stechkin.burst_fire_selection, "The Stechkin's selector isn't on single shots") + + // The first shot waits out the draw + TEST_ASSERT(controller.blackboard["bb_bounty_windup_until"] >= drawn_at + 6, "The first shot can come less than 0.6 seconds after the draw") // BB_BOUNTY_WINDUP_UNTIL, BOUNTY_DRAW_TIME + TEST_ASSERT(controller.blackboard["bb_bounty_next_shot"] >= drawn_at + 6, "Nothing holds the first shot once the draw's telegraph is gone") // BB_BOUNTY_NEXT_SHOT, BOUNTY_DRAW_TIME + var/rounds = bounty_gun_live_rounds(stechkin) + shoot_step(gunner) + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(stechkin), rounds, "A shot went during the draw") + // Its telegraph dropped (the shooting cut short and planned again): the clock still holds the shot + bounty_ai_clear_windup(controller) + shoot_step(gunner) + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(stechkin), rounds, "A shot went during the draw once its telegraph was dropped") + // The draw done: one round at once, the pistol not raised again + controller.set_blackboard_key("bb_bounty_next_shot", world.time) // BB_BOUNTY_NEXT_SHOT + shoot_step(gunner) + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(stechkin), rounds - 1, "The first shot after the draw wasn't a single round, or didn't go") + TEST_ASSERT_NULL(controller.blackboard["bb_bounty_windup_until"], "The pistol was raised again after the draw") + shoot_stopped(gunner) + + // A hit during the draw fumbles the first shot + var/mob/living/carbon/human/npc/bounty_criminal/normal/slinger = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(0, 4), "revolver") // BOUNTY_STYLE_REVOLVER + make_target(slinger, tile(4, 4)) + var/obj/item/gun/ballistic/revolver/c38/revolver = draw_gun(slinger) + var/datum/ai_controller/slinger_ai = slinger.ai_controller + var/cylinder = bounty_gun_live_rounds(revolver) + slinger_ai.set_blackboard_key("bb_bounty_hit_at", world.time) // BB_BOUNTY_HIT_AT + slinger_ai.set_blackboard_key("bb_bounty_windup_until", world.time) // BB_BOUNTY_WINDUP_UNTIL + shoot_step(slinger) + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(revolver), cylinder, "A hit during the draw didn't spoil the first shot") + TEST_ASSERT(slinger_ai.blackboard["bb_bounty_next_shot"] >= world.time + 10, "A fumbled draw didn't hold the next shot back") // BOUNTY_FUMBLE_PAUSE + shoot_stopped(slinger) + target.fully_heal(HEAL_ALL) + +// ===== PISTOL STRINGS ===== + +/** + * The criminal's pistol: single shots half a second apart, six to a string, then a second and a half on + * top before the next string, which needs no new raise. An empty magazine is reloaded the player's way + * and the strings start over with the fresh one. + */ +/datum/unit_test/voidcrew_bounty_guns/pistol_strings + +/datum/unit_test/voidcrew_bounty_guns/pistol_strings/Run() + var/mob/living/carbon/human/npc/bounty_criminal/normal/gunner = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(0, 2), "pistol") // BOUNTY_STYLE_PISTOL + var/mob/living/carbon/human/target = make_target(gunner, tile(4, 2)) + var/obj/item/gun/ballistic/automatic/pistol/aps/stechkin = draw_gun(gunner) + var/datum/ai_controller/controller = gunner.ai_controller + controller.set_blackboard_key("bb_bounty_windup_until", world.time) // BB_BOUNTY_WINDUP_UNTIL + controller.set_blackboard_key("bb_bounty_next_shot", world.time) // BB_BOUNTY_NEXT_SHOT + // Fifteen in the magazine and one in the chamber + var/full = bounty_gun_live_rounds(stechkin) + TEST_ASSERT(full >= 13, "Test fixture: the Stechkin holds only [full]") + + // The whole magazine: a pause after every 6th shot, none after the last (that is the reload) + for(var/shot in 1 to full) + shoot_step(gunner) + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(stechkin), full - shot, "Shot [shot] wasn't a single round") + var/wait = controller.blackboard["bb_bounty_next_shot"] - world.time // BB_BOUNTY_NEXT_SHOT + if(!(shot % 6) && shot < full) // BOUNTY_PISTOL_STRING_SHOTS + TEST_ASSERT_EQUAL(wait, 20, "After the [shot]th shot, the next string isn't 2 seconds off") // BOUNTY_PISTOL_INTERVAL + BOUNTY_PISTOL_STRING_PAUSE + else + TEST_ASSERT_EQUAL(wait, 5, "Shot [shot + 1] isn't half a second after shot [shot]") // BOUNTY_PISTOL_INTERVAL + if(shot == 7) + TEST_ASSERT_NULL(controller.blackboard["bb_bounty_windup_until"], "The pistol was raised again for its second string") + next_pull(gunner, target) + if(shot == 6) + // The pause is waited out, not skipped: the last shot and the draw two seconds back + controller.set_blackboard_key("bb_bounty_last_shot", world.time - 20) // BB_BOUNTY_LAST_SHOT + controller.set_blackboard_key("bb_bounty_drawn_at", world.time - 30) // BB_BOUNTY_DRAWN_AT + TEST_ASSERT(!stechkin.can_shoot(), "Test fixture: the Stechkin still fires after [full]") + var/datum/bounty_style/style = bounty_ai_style(gunner) + TEST_ASSERT_NULL(style.ready_in_hand(gunner), "A dry Stechkin counts as ready") + + // The player's reload from the spare in a pocket; the strings start over with it + TEST_ASSERT(human_npc_can_reload(gunner, stechkin), "The dry Stechkin can't be reloaded from the spare magazine") + TEST_ASSERT(run_reload(gunner, /datum/ai_behavior/human_npc_reload), "The dry Stechkin wasn't reloaded") + TEST_ASSERT(stechkin.can_shoot(), "The reloaded Stechkin doesn't fire") + TEST_ASSERT_EQUAL(stechkin.burst_size, 1, "The reload put the Stechkin back on bursts") + var/fresh = bounty_gun_live_rounds(stechkin) + controller.set_blackboard_key("bb_bounty_next_shot", world.time) // BB_BOUNTY_NEXT_SHOT + controller.set_blackboard_key("bb_bounty_windup_until", world.time) // BB_BOUNTY_WINDUP_UNTIL + for(var/shot in 1 to 6) + shoot_step(gunner) + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(stechkin), fresh - shot, "Shot [shot] of the new magazine wasn't a single round") + var/wait = controller.blackboard["bb_bounty_next_shot"] - world.time // BB_BOUNTY_NEXT_SHOT + TEST_ASSERT_EQUAL(wait, shot == 6 ? 20 : 5, "The new magazine's first string isn't six shots and a pause") + next_pull(gunner, target) + shoot_stopped(gunner) + +// ===== THE REVOLVER'S RELOAD ===== + +/** + * Six shots leave six spent casings in the .38's cylinder. The reload the arm subtree picks for it clicks + * the speedloader from the pocket into the cylinder, the player's way: the spent casings fall out, six + * live rounds go in, and the empty speedloader is let go of. + */ +/datum/unit_test/voidcrew_bounty_guns/revolver_reload + +/datum/unit_test/voidcrew_bounty_guns/revolver_reload/Run() + var/mob/living/carbon/human/npc/bounty_criminal/normal/slinger = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(0, 2), "revolver") // BOUNTY_STYLE_REVOLVER + var/mob/living/carbon/human/target = make_target(slinger, tile(4, 2)) + var/obj/item/gun/ballistic/revolver/c38/revolver = carried(slinger, /obj/item/gun/ballistic/revolver/c38) + TEST_ASSERT(human_npc_take_in_hand(slinger, revolver), "The .38 can't be drawn") + var/datum/bounty_style/style = bounty_ai_style(slinger) + var/datum/ai_controller/controller = slinger.ai_controller + for(var/shot in 1 to 6) + slinger.next_move = 0 + slinger.next_click = 0 + TEST_ASSERT(style.attack(slinger, controller, target, revolver), "Shot [shot] of the cylinder didn't go") + bounty_guns_test_wait(slinger) + target.fully_heal(HEAL_ALL) + TEST_ASSERT(!revolver.can_shoot(), "Test fixture: the .38 still fires after six") + TEST_ASSERT_EQUAL(length(revolver.magazine.ammo_list()), 6, "The spent casings didn't stay in the cylinder") + TEST_ASSERT_NULL(style.ready_in_hand(slinger), "A dry revolver counts as ready") + TEST_ASSERT(human_npc_can_reload(slinger, revolver), "A dry revolver with a speedloader in a pocket can't be reloaded") + TEST_ASSERT(revolver.internal_magazine, "Test fixture: the arm subtree wouldn't pick the cylinder reload for the .38") + + TEST_ASSERT(run_reload(slinger, /datum/ai_behavior/human_npc_reload/bounty_tube), "The dry revolver wasn't reloaded") + TEST_ASSERT(revolver.can_shoot(), "The reloaded revolver doesn't fire") + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(revolver), 6, "The cylinder isn't six live rounds") + var/spent = 0 + for(var/obj/item/ammo_casing/casing in get_turf(slinger)) + if(!casing.loaded_projectile) + spent++ + TEST_ASSERT_EQUAL(spent, 6, "[spent] spent casings fell out of the cylinder, not six") + for(var/obj/item/ammo_box/c38/loader in slinger.held_items) + TEST_FAIL("The empty speedloader is still in [slinger]'s hand") + TEST_ASSERT(style.ready_in_hand(slinger) == revolver, "The reloaded revolver isn't ready to fire") + +// ===== THE KINGPIN'S GOONS ===== + +/// A goon's Stechkin: switched to single shots with its own selector, half a second apart, six to a string, then the pause +/datum/unit_test/voidcrew_bounty_guns_goon + parent_type = /datum/unit_test/voidcrew_bounty_kingpin + +/datum/unit_test/voidcrew_bounty_guns_goon/Run() + var/datum/criminal_bounty/kingpin/posting = kingpin_test_posting() + var/mob/living/carbon/human/npc/bounty_criminal/kingpin/kingpin = kingpin_test_lounge(posting, 1) + var/datum/bounty_kingpin_crew/crew = kingpin.kingpin_crew + // Its clock is moved by hand here: no fight ticks of its own while the shots are counted + STOP_PROCESSING(SSfastprocess, crew) + var/list/goons = crew.goons() + var/mob/living/carbon/human/npc/bounty_kingpin_goon/goon = goons[1] + TEST_ASSERT_EQUAL(goon?.goon_weapon, "pistol", "Test fixture: the lounge's first goon isn't the pistol goon") // BOUNTY_GOON_WEAPON_PISTOL + var/mob/living/carbon/human/hunter = kingpin_test_person(kingpin_test_spot(2, 2), null) + TEST_ASSERT(crew.start_shootout(hunter, TRUE), "The shootout didn't start") + var/obj/item/gun/ballistic/automatic/pistol/aps/stechkin = human_npc_held_gun(goon) + TEST_ASSERT(istype(stechkin), "The pistol goon didn't draw a Stechkin") + crew.crew_draw_ends_at = world.time + crew.process(0.2) + TEST_ASSERT_EQUAL(crew.crew_state, "fighting", "The fight didn't start after the draw") // BOUNTY_KINGPIN_FIGHTING + // The kingpin's own aims are another test's: keep him out of this one + kingpin.kingpin_next_aim_at = world.time + 1 HOURS + kingpin.kingpin_cancel_aim() + + var/full = bounty_gun_live_rounds(stechkin) + for(var/shot in 1 to 7) + goon.goon_next_fire_at = 0 + goon.goon_fumbled_until = 0 + goon.next_move = 0 + goon.next_click = 0 + TEST_ASSERT(crew.goon_try_attack(goon, hunter), "The goon didn't take shot [shot]") + TEST_ASSERT_EQUAL(stechkin.burst_size, 1, "The goon's Stechkin fires bursts") + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(stechkin), full - shot, "The goon's shot [shot] wasn't a single round") + var/wait = goon.goon_next_fire_at - world.time + TEST_ASSERT_EQUAL(wait, shot == 6 ? 20 : 5, "After the goon's shot [shot], the next is [wait / 10] seconds off") // BOUNTY_GOON_PISTOL_COOLDOWN, + BOUNTY_PISTOL_STRING_PAUSE + bounty_guns_test_wait(goon) + hunter.fully_heal(HEAL_ALL) + +// ===== CLUB VOLGA ===== + +/** + * A mobster gunman's volley is a string: his Stechkin switched to single shots with its own selector, six + * pulls half a second apart, then two seconds to the next. The don fires his gold Desert Eagle the same + * way, after he raises it once a magazine. + */ +/datum/unit_test/voidcrew_bounty_guns_club + parent_type = /datum/unit_test/voidcrew_bounty_lair_mafia + +/datum/unit_test/voidcrew_bounty_guns_club/Run() + var/datum/ai_behavior/bounty_mafia_fire/fire = GET_AI_BEHAVIOR(/datum/ai_behavior/bounty_mafia_fire) + var/row = 0 + for(var/member_type in list(/mob/living/carbon/human/npc/bounty_mafia/pistol, /mob/living/carbon/human/npc/bounty_mafia/don)) + var/mob/living/carbon/human/consistent/hunter = hunter_at(spot(4, row)) + var/mob/living/carbon/human/npc/bounty_mafia/shooter = member_at(member_type, spot(0, row)) + row += 4 + var/datum/ai_controller/controller = shooter.ai_controller + var/obj/item/gun/ballistic/gun = human_npc_loaded_gun(shooter) + TEST_ASSERT(istype(gun), "Test fixture: [shooter] holds no loaded gun") + gun.can_misfire = FALSE + controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) + TEST_ASSERT(fire.setup(controller, BB_BASIC_MOB_CURRENT_TARGET), "[shooter]'s volley didn't start") + if(shooter.mafia_aim_until) + // The don raises his pistol once a magazine first + TEST_ASSERT(istype(shooter, /mob/living/carbon/human/npc/bounty_mafia/don), "[shooter] aims before a pistol string") + shooter.mafia_aim_until = world.time + var/full = bounty_gun_live_rounds(gun) + for(var/shot in 1 to 6) + shooter.mafia_next_pull_at = 0 + shooter.next_move = 0 + shooter.next_click = 0 + var/flags = fire.perform(0.1, controller, BB_BASIC_MOB_CURRENT_TARGET) + TEST_ASSERT_EQUAL(gun.burst_size, 1, "[shooter]'s pistol fires bursts") + TEST_ASSERT_EQUAL(bounty_gun_live_rounds(gun), full - shot, "[shooter]'s shot [shot] wasn't a single round") + if(shot < 6) + TEST_ASSERT(!(flags & AI_BEHAVIOR_SUCCEEDED), "[shooter]'s string ended after [shot] shots") + TEST_ASSERT_EQUAL(shooter.mafia_next_pull_at - world.time, 5, "[shooter]'s shots aren't half a second apart") // BOUNTY_PISTOL_INTERVAL + bounty_guns_test_wait(shooter) + hunter.fully_heal(HEAL_ALL) + continue + TEST_ASSERT(flags & AI_BEHAVIOR_SUCCEEDED, "[shooter]'s string didn't end after six shots") // BOUNTY_PISTOL_STRING_SHOTS + fire.finish_action(controller, TRUE, BB_BASIC_MOB_CURRENT_TARGET) + TEST_ASSERT_EQUAL(shooter.mafia_next_volley_at - world.time, 20, "[shooter]'s next string isn't 2 seconds off") // BOUNTY_PISTOL_INTERVAL + BOUNTY_PISTOL_STRING_PAUSE + TEST_ASSERT(!fire.setup(controller, BB_BASIC_MOB_CURRENT_TARGET), "[shooter] started a string before his pause was over") + sleep(2) + clear_room() + +// ===== BLENDING IN ===== + +/** + * A fugitive blending in at a trader outpost keeps its holster or fanny pack on under the patron's coat; + * its decoys wear an empty one of the same kind, so what a pistol, revolver or meek fugitive carries in + * plain sight examines like its decoys. The decoys still carry no gun. A knife sits in a pocket and + * bottles in a satchel the decoys wear too. A fugitive there never rolls a style whose weapon shows (an + * SMG on the belt, a shotgun on the back, a bat in hand). (The rest of the look-alike examine is + * voidcrew_bounty_outpost/look_alikes.) + */ +/datum/unit_test/voidcrew_bounty_guns_blend + parent_type = /datum/unit_test/voidcrew_bounty_outpost + +/// The lines of `patron`'s examine that tell what it carries where people can see: its belt, its back and its hands +/datum/unit_test/voidcrew_bounty_guns_blend/proc/carry_lines(mob/living/carbon/human/patron, mob/viewer) + var/list/lines = list() + for(var/line in patron.examine(viewer)) + var/plain = trim(STRIP_HTML_FULL("[line]", MAX_MESSAGE_LEN)) + if(findtext(plain, "waist") || findtext(plain, " back.") || findtext(plain, "holding")) + lines += plain + return lines.Join(" | ") + +/datum/unit_test/voidcrew_bounty_guns_blend/Run() + outpost = make_outpost(/obj/structure/overmap/trader_outpost/outfitter) + outpost.lobby_alcove_turfs = list(run_loc_floor_top_right) + var/mob/living/carbon/human/viewer = make_hunter() + + // Only styles whose weapon is out of sight, for a fugitive passing as a customer: the roll, and the + // records a trader-outpost posting makes (BOUNTY_TIER_WANTED, BOUNTY_ARCHETYPE_NORMAL, BOUNTY_PLACEMENT_TRADER_OUTPOST) + var/list/hidden_rolls = list() + for(var/i in 1 to 300) + hidden_rolls[bounty_roll_style(concealed = TRUE)] = TRUE + for(var/i in 1 to 30) + var/datum/bounty_record/rolled = generate_bounty_record(2, "normal", "trader_outpost") + hidden_rolls[rolled.style] = TRUE + TEST_ASSERT(!hidden_rolls["smg"] && !hidden_rolls["shotgun"] && !hidden_rolls["club"], "A fugitive passing as a customer fights with an SMG, a shotgun or a bat") // BOUNTY_STYLE_SMG, BOUNTY_STYLE_SHOTGUN, BOUNTY_STYLE_CLUB + TEST_ASSERT(hidden_rolls["brawler"] && hidden_rolls["knife"] && hidden_rolls["pistol"] && hidden_rolls["revolver"] && hidden_rolls["bottle"], "A fugitive passing as a customer never fights in some style it could hide") + + var/list/cases = list( + list("normal", "pistol", /mob/living/carbon/human/npc/bounty_criminal/normal), // BOUNTY_ARCHETYPE_NORMAL, BOUNTY_STYLE_PISTOL + list("normal", "revolver", /mob/living/carbon/human/npc/bounty_criminal/normal), // BOUNTY_STYLE_REVOLVER + list("meek", "holdout", /mob/living/carbon/human/npc/bounty_criminal/meek), // BOUNTY_ARCHETYPE_MEEK, BOUNTY_STYLE_HOLDOUT + list("normal", "knife", /mob/living/carbon/human/npc/bounty_criminal/normal), // BOUNTY_STYLE_KNIFE + list("normal", "brawler", /mob/living/carbon/human/npc/bounty_criminal/normal), // BOUNTY_STYLE_BRAWLER + list("normal", "bottle", /mob/living/carbon/human/npc/bounty_criminal/normal), // BOUNTY_STYLE_BOTTLE + ) + + for(var/list/spec as anything in cases) + var/datum/bounty_record/record = generate_bounty_record(1, spec[1], "trader_outpost", /datum/species/human) // BOUNTY_TIER_PETTY, BOUNTY_PLACEMENT_TRADER_OUTPOST + record.style = spec[2] + // Dressed as production dresses it: the bounty outfit table, its style's gun and its holster + var/datum/human_npc_order/order = spawn_human_npc(spec[3], run_loc_floor_bottom_left, look = record, name = record.name, immediate = TRUE) + var/mob/living/carbon/human/npc/bounty_criminal/fugitive = order?.spawned_ref?.resolve() + qdel(order) + TEST_ASSERT_NOTNULL(fugitive, "Test fixture: no [spec[2]] fugitive was made") + allocated += fugitive + fugitive.record = record + if(spec[2] in list("pistol", "revolver", "holdout")) + TEST_ASSERT(istype(fugitive.belt, /obj/item/storage), "Test fixture: the [spec[2]] fugitive wears no holster or pouch") + var/datum/criminal_bounty/outpost_test/posting = allocate(/datum/criminal_bounty/outpost_test) + posting.record = record + posting.placement_kind = "trader_outpost" // BOUNTY_PLACEMENT_TRADER_OUTPOST + posting.site_ref = WEAKREF(outpost) + posting.value = 1234 + fugitive.posting_ref = WEAKREF(posting) + posting.criminal_ref = WEAKREF(fugitive) + GLOB.criminal_bounties += posting + TEST_ASSERT(posting.setup_outpost_blend(TRUE), "The [spec[2]] fugitive's posting could not be set up to blend in") + var/list/decoys = decoys_of(posting) + TEST_ASSERT(length(decoys), "The [spec[2]] fugitive has no decoys") + var/fugitive_carry = carry_lines(fugitive, viewer) + if(fugitive.belt) + TEST_ASSERT(findtext(fugitive_carry, "waist"), "Test fixture: the [spec[2]] fugitive's belt doesn't show") + TEST_ASSERT(!fugitive.get_active_held_item() && !fugitive.get_inactive_held_item(), "The [spec[2]] fugitive holds something while it passes as a customer") + for(var/mob/living/carbon/human/npc/bounty_criminal/decoy/decoy as anything in decoys) + TEST_ASSERT_EQUAL(decoy.belt?.type, fugitive.belt?.type, "A decoy of the [spec[2]] fugitive wears another belt") + TEST_ASSERT_EQUAL(decoy.back?.type, fugitive.back?.type, "A decoy of the [spec[2]] fugitive wears another bag") + if(decoy.belt) + TEST_ASSERT(human_npc_gear_locked(decoy.belt), "A decoy's [decoy.belt] isn't locked to it") + TEST_ASSERT(!length(decoy.belt.contents), "A decoy's [decoy.belt] has something in it") + TEST_ASSERT_NULL(locate(/obj/item/gun) in decoy.get_all_contents(), "A decoy carries a gun") + TEST_ASSERT_EQUAL(carry_lines(decoy, viewer), fugitive_carry, "A decoy carries something else in plain sight than the [spec[2]] fugitive") +#ifdef BOUNTY_GUN_RENDERS + var/mob/living/carbon/human/npc/bounty_criminal/decoy/first_decoy = decoys[1] + for(var/facing in list(SOUTH, EAST)) + fugitive.setDir(facing) + first_decoy.setDir(facing) + fcopy(getFlatIcon(fugitive, facing, no_anim = TRUE), "data/bounty_gun_renders/blend_[spec[2]]_fugitive_[dir2text(facing)].png") + fcopy(getFlatIcon(first_decoy, facing, no_anim = TRUE), "data/bounty_gun_renders/blend_[spec[2]]_decoy_[dir2text(facing)].png") +#endif + for(var/datum/weakref/decoy_ref as anything in posting.decoys) + qdel(decoy_ref?.resolve()) + posting.decoys = list() + GLOB.criminal_bounties -= posting + qdel(fugitive) + +#ifdef BOUNTY_GUN_RENDERS +/** + * Not a check: renders the gun styles on real criminals, holstered and drawn, facing south and east, to + * data/bounty_gun_renders/. Compile with -DBOUNTY_GUN_RENDERS to run it. + */ +/datum/unit_test/voidcrew_bounty_guns/renders + +/datum/unit_test/voidcrew_bounty_guns/renders/Run() + var/list/specs = list( + list("pistol", /obj/item/gun/ballistic/automatic/pistol/aps), + list("smg", /obj/item/gun/ballistic/automatic/wt550), + list("revolver", /obj/item/gun/ballistic/revolver/c38), + ) + var/column = 0 + for(var/list/spec as anything in specs) + var/mob/living/carbon/human/npc/bounty_criminal/normal/gunner = make_criminal(/mob/living/carbon/human/npc/bounty_criminal/normal, tile(column, 2), spec[1]) + column++ + var/obj/item/gun/gun = carried(gunner, spec[2]) + for(var/facing in list(SOUTH, EAST)) + gunner.setDir(facing) + fcopy(getFlatIcon(gunner, facing, no_anim = TRUE), "data/bounty_gun_renders/[spec[1]]_holstered_[dir2text(facing)].png") + TEST_ASSERT(human_npc_take_in_hand(gunner, gun), "[spec[1]]: the gun can't be drawn") + for(var/facing in list(SOUTH, EAST)) + gunner.setDir(facing) + fcopy(getFlatIcon(gunner, facing, no_anim = TRUE), "data/bounty_gun_renders/[spec[1]]_drawn_[dir2text(facing)].png") +#endif diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_identity.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_identity.dm index adbd19969e3..8bbbc927a63 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_identity.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_identity.dm @@ -9,7 +9,7 @@ /datum/unit_test/voidcrew_bounty_identity_records /datum/unit_test/voidcrew_bounty_identity_records/Run() - var/list/styles = list("brawler", "knife", "pistol", "shotgun", "club", "bottle") // BOUNTY_STYLE_*, normal + var/list/styles = list("brawler", "knife", "pistol", "shotgun", "smg", "revolver", "club", "bottle") // BOUNTY_STYLE_*, normal var/list/kits = list("juggernaut", "pyromaniac", "demolitionist", "ghost", "heavy") // BOUNTY_KIT_* var/list/labels = bounty_feature_labels() // BOUNTY_TIER_*, BOUNTY_ARCHETYPE_*, BOUNTY_PLACEMENT_* diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_lair_mafia.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_lair_mafia.dm index 46a8a2a6eff..f69ea337eb4 100644 --- a/voidcrew/modules/unit_tests/voidcrew_bounty_lair_mafia.dm +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_lair_mafia.dm @@ -359,14 +359,17 @@ controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, hunter) var/datum/ai_behavior/bounty_mafia_fire/fire = GET_AI_BEHAVIOR(/datum/ai_behavior/bounty_mafia_fire) - // A pistol volley: no aim, one pull of the real gun (its three-round burst), then a pause before the next + // A pistol volley: no aim, a string of single pulls of the real gun (voidcrew_bounty_guns_club counts them), then a pause before the next var/rounds_before = gun.get_ammo() TEST_ASSERT(fire.setup(controller, BB_BASIC_MOB_CURRENT_TARGET), "The gunman's volley didn't start") TEST_ASSERT(!gunman.mafia_aim_until, "The pistol aims before it fires") - var/flags = fire.perform(0.1, controller, BB_BASIC_MOB_CURRENT_TARGET) - TEST_ASSERT(flags & AI_BEHAVIOR_SUCCEEDED, "The pistol volley wasn't one pull") + var/flags = NONE + for(var/pull in 1 to 6) // BOUNTY_MOBSTER_PISTOL_VOLLEY + gunman.mafia_next_pull_at = 0 + flags = fire.perform(0.1, controller, BB_BASIC_MOB_CURRENT_TARGET) + TEST_ASSERT(flags & AI_BEHAVIOR_SUCCEEDED, "The pistol volley wasn't a string of six pulls") fire.finish_action(controller, TRUE, BB_BASIC_MOB_CURRENT_TARGET) - TEST_ASSERT(gunman.mafia_next_volley_at >= world.time + 8, "The gunman has no pause between volleys") // BOUNTY_MOBSTER_PISTOL_COOLDOWN + TEST_ASSERT(gunman.mafia_next_volley_at >= world.time + 20, "The gunman has no pause between volleys") // BOUNTY_MOBSTER_PISTOL_STRING_PAUSE TEST_ASSERT(!fire.setup(controller, BB_BASIC_MOB_CURRENT_TARGET), "The gunman started a volley before his pause was over") sleep(0.5 SECONDS) TEST_ASSERT(gun.get_ammo() < rounds_before, "The pull didn't fire the gunman's Stechkin") diff --git a/voidcrew/modules/unit_tests/voidcrew_bounty_suits.dm b/voidcrew/modules/unit_tests/voidcrew_bounty_suits.dm new file mode 100644 index 00000000000..f2aeb4bdc3c --- /dev/null +++ b/voidcrew/modules/unit_tests/voidcrew_bounty_suits.dm @@ -0,0 +1,253 @@ +/** + * Bounty hunting: suits and company (voidcrew/modules/bounties/bounty_suits.dm, the company parts of + * bounty_companions.dm, the kits' vacuum gear in bounty_boss_kits.dm, the pad in bounty_turn_in.dm). + * + * Criminals and companions are real human NPCs: these tests read what they really wear, and drive tg's + * own strip menu and inventory. Fork defines are included after the tests, so a test uses the literal + * value with a comment naming the define. A site is stood in for by a spawn context naming its type, as + * spawn_bounty_criminal() makes one from the overmap object; no ruin or planet is loaded. + */ + +/// Holds the helpers the suit tests share +/datum/unit_test/voidcrew_bounty_suits + abstract_type = /datum/unit_test/voidcrew_bounty_suits + +/// A spawn context as one made for a site of `site_type` (an overmap typepath), without the site itself +/datum/unit_test/voidcrew_bounty_suits/proc/site_context(site_type) + var/datum/npc_spawn_context/context = new(run_loc_floor_bottom_left, 1, "ordinary") // ZONE_GREEN + context.source_type = site_type + context.source_id = null + return context + +/** + * A human criminal of `archetype` and `tier` (the mini-boss of `kit` for a boss), made on the test floor + * as one wanted at a site of `site_type` (null: no site), its AI off + */ +/datum/unit_test/voidcrew_bounty_suits/proc/new_criminal(archetype = "normal", tier = 1, kit, site_type) + var/datum/bounty_record/record = generate_bounty_record(tier, archetype, "planet", /datum/species/human) // BOUNTY_PLACEMENT_PLANET + record.archetype = archetype + if(kit) + record.kit = kit + var/datum/npc_spawn_context/context = site_type ? site_context(site_type) : null + var/datum/human_npc_order/order = spawn_human_npc(bounty_criminal_type(record, null), run_loc_floor_bottom_left, look = record, name = record.name, context = context, immediate = TRUE) + var/mob/living/carbon/human/npc/bounty_criminal/criminal = order?.spawned_ref?.resolve() + qdel(order) + if(QDELETED(criminal)) + return null + criminal.body_setup(record, null) + criminal.ai_controller?.set_ai_status(AI_STATUS_OFF) + allocated += criminal + return criminal + +/// Whether `item` is in the armoured class: melee or bullet armour of 30 or more (an armour vest has 35 and 30) +/datum/unit_test/voidcrew_bounty_suits/proc/armoured(obj/item/item) + return !isnull(item) && max(item.get_armor_rating(MELEE), item.get_armor_rating(BULLET)) >= 30 + +/// Checks `npc` is sealed up for vacuum in real, locked gear: a pressure suit and helmet that keep out the cold of space, and a tank it can breathe +/datum/unit_test/voidcrew_bounty_suits/proc/check_sealed(mob/living/carbon/human/npc/npc, label) + var/obj/item/clothing/suit = npc.wear_suit + var/obj/item/clothing/helmet = npc.head + TEST_ASSERT(istype(suit) && (suit.clothing_flags & STOPSPRESSUREDAMAGE), "[label] wears no pressure suit ([suit?.type])") + TEST_ASSERT(istype(helmet) && (helmet.clothing_flags & STOPSPRESSUREDAMAGE), "[label] wears no pressure helmet ([helmet?.type])") + TEST_ASSERT(suit.min_cold_protection_temperature <= 2 && helmet.min_cold_protection_temperature <= 2, "[label]'s [suit] and [helmet] don't keep out the cold of space") // SPACE_SUIT_MIN_TEMP_PROTECT, SPACE_HELM_MIN_TEMP_PROTECT + TEST_ASSERT(istype(npc.s_store, /obj/item/tank/internals), "[label] carries no tank in its suit") + TEST_ASSERT(npc.can_breathe_internals(), "[label] has nothing to breathe its tank through") + TEST_ASSERT(human_npc_gear_locked(suit) && human_npc_gear_locked(helmet), "[label]'s suit isn't locked to it") + +// ===== WHERE THEY ARE DRESSED FOR ===== + +/// At a space ruin a criminal and its companions arrive sealed up even on a tile with good air: a soft suit for a Petty one, an armoured one for a Wanted one +/datum/unit_test/voidcrew_bounty_suits/ruin + +/datum/unit_test/voidcrew_bounty_suits/ruin/Run() + TEST_ASSERT_EQUAL(human_npc_site_at(run_loc_floor_bottom_left), 0, "Test fixture: the test room's air counts as hostile") + TEST_ASSERT_EQUAL(bounty_site_dress_for(site_context(/obj/structure/overmap/space_ruin)), 1, "A space ruin doesn't dress a criminal for vacuum") // HUMAN_NPC_SITE_VACUUM + TEST_ASSERT_EQUAL(bounty_site_dress_for(site_context(/obj/structure/overmap/ship/npc/pirate)), 0, "A pirate ship dresses a criminal for vacuum") + TEST_ASSERT_EQUAL(bounty_site_dress_for(null), 0, "No site dresses a criminal for vacuum") + TEST_ASSERT_EQUAL(bounty_site_kind_of(site_context(/obj/structure/overmap/space_ruin)), "ruin", "A space ruin's context isn't a ruin's") // BOUNTY_PLACEMENT_RUIN + TEST_ASSERT_EQUAL(bounty_site_kind_of(site_context(/obj/structure/overmap/ship/npc/pirate)), "npc_ship", "A pirate ship's context isn't a pirate ship's") // BOUNTY_PLACEMENT_NPC_SHIP + + var/mob/living/carbon/human/npc/bounty_criminal/petty = new_criminal("normal", 1, null, /obj/structure/overmap/space_ruin) // BOUNTY_TIER_PETTY + TEST_ASSERT_NOTNULL(petty, "No Petty criminal was made") + check_sealed(petty, "A Petty criminal at a space ruin") + TEST_ASSERT(!armoured(petty.wear_suit), "A Petty criminal's soft suit is armoured ([petty.wear_suit.type])") + TEST_ASSERT(petty.npc_site & 1, "A Petty criminal at a space ruin wasn't dressed for vacuum") // HUMAN_NPC_SITE_VACUUM + + var/mob/living/carbon/human/npc/bounty_criminal/wanted = new_criminal("normal", 2, null, /obj/structure/overmap/space_ruin) // BOUNTY_TIER_WANTED + check_sealed(wanted, "A Wanted criminal at a space ruin") + TEST_ASSERT(armoured(wanted.wear_suit) && armoured(wanted.head), "A Wanted criminal's space suit ([wanted.wear_suit.type]) is softer than the vest it wears in good air") + + // The same criminal in a room with good air and no site is in its clothes and vest + var/mob/living/carbon/human/npc/bounty_criminal/at_home = new_criminal("normal", 2) + TEST_ASSERT(istype(at_home.wear_suit, /obj/item/clothing/suit/armor/vest), "A Wanted criminal with good air and no site isn't in its vest ([at_home.wear_suit?.type])") + TEST_ASSERT(!(at_home.npc_site & 1), "A criminal with good air and no site was dressed for vacuum") // HUMAN_NPC_SITE_VACUUM + + // Its companions are sealed up as their criminal is, in soft suits + var/list/buddies = petty.spawn_companions(2, immediate = TRUE) + TEST_ASSERT(length(buddies), "No companion spawned") + for(var/mob/living/carbon/human/npc/bounty_companion/buddy as anything in buddies) + allocated += buddy + check_sealed(buddy, "A companion of a criminal at a space ruin") + TEST_ASSERT(!armoured(buddy.wear_suit), "A companion's soft suit is armoured ([buddy.wear_suit.type])") + TEST_ASSERT_EQUAL(buddy.company_site_kind, "ruin", "A companion doesn't know its criminal is at a ruin") // BOUNTY_PLACEMENT_RUIN + +/// Each mini-boss kit seals up in a suit of its own armour class: what protects it in good air protects it in vacuum about as well +/datum/unit_test/voidcrew_bounty_suits/kits + +/datum/unit_test/voidcrew_bounty_suits/kits/Run() + for(var/kit in list("juggernaut", "pyromaniac", "demolitionist", "ghost", "heavy")) // BOUNTY_KIT_* + var/mob/living/carbon/human/npc/bounty_criminal/boss/in_air = new_criminal("boss", 3, kit) // BOUNTY_TIER_MOST_WANTED + var/mob/living/carbon/human/npc/bounty_criminal/boss/in_vacuum = new_criminal("boss", 3, kit, /obj/structure/overmap/space_ruin) + TEST_ASSERT(istype(in_air) && istype(in_vacuum), "No [kit] was made") + TEST_ASSERT_EQUAL(in_vacuum.boss_kit, kit, "Test fixture: the [kit] came out as a [in_vacuum.boss_kit]") + check_sealed(in_vacuum, "The [kit] at a space ruin") + TEST_ASSERT_EQUAL(armoured(in_vacuum.wear_suit), armoured(in_air.wear_suit), "The [kit]'s space suit ([in_vacuum.wear_suit.type]) isn't in the armour class of its own suit ([in_air.wear_suit?.type])") + TEST_ASSERT_EQUAL(armoured(in_vacuum.head), armoured(in_air.head), "The [kit]'s space helmet ([in_vacuum.head.type]) isn't in the armour class of its own headgear ([in_air.head?.type])") + TEST_ASSERT(in_vacuum.boss_gear_text(), "The [kit] in its space suit has no gear line on examine") + var/list/gear = bounty_vacuum_gear(in_vacuum) + TEST_ASSERT(length(gear) == 2 && istype(in_vacuum.wear_suit, gear[1]), "The [kit] doesn't wear the suit it was given for vacuum") + if(kit == "heavy") + TEST_ASSERT(istype(in_vacuum.head, /obj/item/clothing/head/helmet/swat), "The Heavy lost its SWAT helmet in vacuum") + qdel(in_air) + qdel(in_vacuum) + +// ===== SUITING UP A CATCH ===== + +/** + * A hunter can put their own space suit and helmet on a cuffed criminal in place of its own locked vest + * and helmet, which are gone; it pulls away while free; the suit comes off again through tg's strip menu; + * and the pad leaves the crew's things behind while the criminal's own go with it, as does the board when + * it takes a criminal away. + */ +/datum/unit_test/voidcrew_bounty_suits/suit_up + +/datum/unit_test/voidcrew_bounty_suits/suit_up/Run() + var/mob/living/carbon/human/npc/bounty_criminal/criminal = new_criminal("normal", 3) // BOUNTY_TIER_MOST_WANTED: a vest and a helmet + // Whatever else it rolled (anything that bares its torso), it wears a locked suit for this test to reach for + if(!criminal.wear_suit && criminal.equip_to_slot_or_del(new /obj/item/clothing/suit/armor/vest(criminal), ITEM_SLOT_OCLOTHING)) + criminal.npc_lock_item(criminal.wear_suit) + var/obj/item/jacket = criminal.wear_suit + var/obj/item/hat = criminal.head + TEST_ASSERT(human_npc_gear_locked(jacket) && human_npc_gear_locked(hat), "Test fixture: the criminal's vest and helmet aren't locked to it") + var/mob/living/carbon/human/consistent/hunter = allocate(/mob/living/carbon/human/consistent, get_step(run_loc_floor_bottom_left, EAST)) + var/obj/item/clothing/suit/space/suit = allocate(/obj/item/clothing/suit/space) + var/obj/item/clothing/head/helmet/space/helmet = allocate(/obj/item/clothing/head/helmet/space) + var/obj/item/clothing/suit/jacket/leather/coat = allocate(/obj/item/clothing/suit/jacket/leather) + + // Not a pressure suit: the strip menu is tg's, which can't take the locked vest + hunter.put_in_active_hand(coat) + TEST_ASSERT_NULL(criminal.suits_garment_offered(hunter, jacket), "A leather jacket was taken for a pressure suit") + TEST_ASSERT(!(SEND_SIGNAL(criminal, COMSIG_BEING_STRIPPED, hunter, jacket) & COMPONENT_CANT_STRIP), "The strip hook took over a reach with a leather jacket") + qdel(coat) + hunter.put_in_active_hand(suit) + TEST_ASSERT_EQUAL(criminal.suits_garment_offered(hunter, jacket), suit, "A space suit in hand wasn't offered for the vest") + + // Free, it pulls away: the hook takes the reach, and nothing changes + TEST_ASSERT_EQUAL(criminal.capture_state(), "free", "Test fixture: the criminal isn't free") // BOUNTY_STATE_FREE + TEST_ASSERT(SEND_SIGNAL(criminal, COMSIG_BEING_STRIPPED, hunter, jacket) & COMPONENT_CANT_STRIP, "The strip hook left a reach for the locked vest to tg") + TEST_ASSERT(!criminal.suits_swap_now(hunter, jacket, suit), "A space suit went on a free criminal") + TEST_ASSERT_EQUAL(criminal.wear_suit, jacket, "A free criminal lost its vest") + + // Cuffed, the hunter's suit goes on in its place, and the vest is gone rather than loot + board_test_cuff(criminal) + TEST_ASSERT_EQUAL(criminal.capture_state(), "restrained", "Test fixture: the cuffed criminal isn't restrained") // BOUNTY_STATE_RESTRAINED + TEST_ASSERT(criminal.suits_swap_now(hunter, jacket, suit), "A space suit wouldn't go on a cuffed criminal") + TEST_ASSERT_EQUAL(criminal.wear_suit, suit, "The hunter's suit isn't on the criminal") + TEST_ASSERT(QDELETED(jacket), "The criminal's own vest is still about") + TEST_ASSERT(!human_npc_gear_locked(suit), "The hunter's suit was locked to the criminal") + hunter.put_in_active_hand(helmet) + TEST_ASSERT(criminal.suits_swap_now(hunter, hat, helmet), "A space helmet wouldn't go on a cuffed criminal") + TEST_ASSERT_EQUAL(criminal.head, helmet, "The hunter's helmet isn't on the criminal") + TEST_ASSERT(QDELETED(hat), "The criminal's own helmet is still about") + + // The hunter's suit is an ordinary item on it: tg's strip menu shows it and would take it off again + var/datum/strippable_item/suit_slot = GLOB.strippable_human_items[STRIPPABLE_ITEM_SUIT] + TEST_ASSERT_EQUAL(suit_slot.get_item(criminal), suit, "The strip menu doesn't see the hunter's suit") + TEST_ASSERT(suit_slot.try_unequip(criminal, hunter), "The strip menu won't take the hunter's suit off again") + + // A tank in its suit storage, then the pad: the crew's things are left there, the criminal's own go with it + var/obj/item/tank/internals/oxygen/tank = allocate(/obj/item/tank/internals/oxygen) + TEST_ASSERT(criminal.equip_to_slot_if_possible(tank, ITEM_SLOT_SUITSTORE, disable_warning = TRUE), "Test fixture: a tank wouldn't go in the hunter's suit") + var/obj/item/cuffs = criminal.handcuffed + var/obj/item/own_uniform = criminal.w_uniform + TEST_ASSERT(human_npc_gear_locked(own_uniform), "Test fixture: the criminal's clothes aren't locked to it") + var/turf/pad_spot = get_turf(criminal) + criminal.board_finish_beam_out() + TEST_ASSERT(QDELETED(criminal), "The pad didn't take the criminal") + for(var/obj/item/crew_item as anything in list(suit, helmet, tank, cuffs)) + TEST_ASSERT(!QDELETED(crew_item) && crew_item.loc == pad_spot, "The pad didn't leave the crew's [crew_item] behind") + TEST_ASSERT(QDELETED(own_uniform), "The criminal's own clothes were left on the pad") + + // Taken away by the board instead (a relist, the clock running out): the crew's things are left there too + criminal = new_criminal("normal", 1) // BOUNTY_TIER_PETTY + if(!criminal.wear_suit && criminal.equip_to_slot_or_del(new /obj/item/clothing/suit/jacket/leather(criminal), ITEM_SLOT_OCLOTHING)) + criminal.npc_lock_item(criminal.wear_suit) + TEST_ASSERT(human_npc_gear_locked(criminal.wear_suit), "Test fixture: the second criminal wears no locked suit") + board_test_cuff(criminal) + cuffs = criminal.handcuffed + hunter.put_in_active_hand(suit) + TEST_ASSERT(criminal.suits_swap_now(hunter, criminal.wear_suit, suit), "A space suit wouldn't go on a second cuffed criminal") + var/datum/criminal_bounty/posting = allocate(/datum/criminal_bounty) + posting.board_dispose_mob(criminal) + TEST_ASSERT(QDELETED(criminal), "The board didn't take the criminal away") + TEST_ASSERT(!QDELETED(suit) && suit.loc == pad_spot, "The board took the crew's suit away with the criminal") + TEST_ASSERT(!QDELETED(cuffs) && cuffs.loc == pad_spot, "The board took the crew's cuffs away with the criminal") + +// ===== COMPANY ===== + +/// Criminals hide only aboard plain pirate crews' ships, never a themed crew's +/datum/unit_test/voidcrew_bounty_suits/plain_pirates + +/datum/unit_test/voidcrew_bounty_suits/plain_pirates/Run() + var/obj/structure/overmap/ship/npc/pirate/pirate = allocate(/obj/structure/overmap/ship/npc/pirate) + // Already resolved, so deleting the test hull doesn't make the pirate pool spawn a replacement + pirate.spawner_resolved = TRUE + TEST_ASSERT(bounty_ship_hides_criminals(pirate), "A plain pirate ship won't hide a criminal") + pirate.pirate_faction = "skeleton" + TEST_ASSERT(!bounty_ship_hides_criminals(pirate), "A skeleton crew's ship hides a criminal") + pirate.pirate_faction = null + TEST_ASSERT(!bounty_ship_hides_criminals(null), "Nothing hides a criminal") + // Crews of ordinary people hide one; themed crews never do + for(var/faction in list("grey", "interdyne")) + pirate.pirate_faction = faction + TEST_ASSERT(bounty_ship_hides_criminals(pirate), "A [faction] crew's ship won't hide a criminal") + for(var/faction in list("silverscale", "skeleton", "lustrous", "irs", "medieval", "nt_patrol")) + pirate.pirate_faction = faction + TEST_ASSERT(!bounty_ship_hides_criminals(pirate), "A [faction] crew's ship hides a criminal") + // The spawner's grey and Interdyne ships carry the factions the board looks for + TEST_ASSERT_EQUAL(initial(/obj/structure/overmap/ship/npc/pirate/grey::pirate_faction), "grey", "The grey ship's crew changed name") + TEST_ASSERT_EQUAL(initial(/obj/structure/overmap/ship/npc/pirate/interdyne::pirate_faction), "interdyne", "The Interdyne ship's crew changed name") + +/// Companions are people of the criminals' species mix, in rough clothes picked by their criminal's site, and never carry what those clothes came with +/datum/unit_test/voidcrew_bounty_suits/company + +/datum/unit_test/voidcrew_bounty_suits/company/Run() + var/list/species_seen = list() + for(var/i in 1 to 60) + var/species = bounty_company_species() + TEST_ASSERT(species in GLOB.bounty_species_weights, "A companion rolled [species], which no criminal can be") + species_seen |= species + TEST_ASSERT(length(species_seen) > 1, "Sixty companions were all [species_seen[1]]") + + var/mob/living/carbon/human/npc/bounty_criminal/leader = new_criminal("normal", 1) + var/datum/criminal_bounty/posting = new + posting.placement_kind = "planet" // BOUNTY_PLACEMENT_PLANET + leader.posting_ref = WEAKREF(posting) + for(var/site_kind in list("planet", "npc_ship")) // BOUNTY_PLACEMENT_PLANET, BOUNTY_PLACEMENT_NPC_SHIP + posting.placement_kind = site_kind + var/list/buddies = leader.spawn_companions(2, immediate = TRUE) + TEST_ASSERT(length(buddies), "No companion spawned at a [site_kind]") + for(var/mob/living/carbon/human/npc/bounty_companion/buddy as anything in buddies) + TEST_ASSERT(buddy.dna.species.type in GLOB.bounty_species_weights, "A companion is a [buddy.dna.species.type], which no criminal can be") + TEST_ASSERT(length(buddy.real_name) && buddy.real_name != initial(buddy.name), "A companion has no name of their own ([buddy.real_name])") + TEST_ASSERT_EQUAL(buddy.company_site_kind, site_kind, "A companion doesn't know its criminal's site") + TEST_ASSERT(buddy.company_clothes in bounty_company_clothes(site_kind), "A companion at a [site_kind] wears [buddy.company_clothes]") + var/datum/outfit/clothes = buddy.company_clothes + var/suit_type = initial(clothes.suit) + if(suit_type) + TEST_ASSERT(istype(buddy.wear_suit, suit_type), "A companion in [clothes]'s clothes wears [buddy.wear_suit?.type], not [suit_type]") + TEST_ASSERT(!(locate(/obj/item/claymore/cutlass) in buddy.get_all_contents()), "A companion carries the off-duty pirate's cutlass") + TEST_ASSERT(!(locate(/obj/item/flashlight/glowstick) in buddy.get_all_contents()), "A companion carries the hermit's glowstick") + qdel(buddy) + leader.posting_ref = null + qdel(posting) diff --git a/wiki/content/bounty-hunting.md b/wiki/content/bounty-hunting.md index 1d9966e2f51..0bf64a28862 100644 --- a/wiki/content/bounty-hunting.md +++ b/wiki/content/bounty-hunting.md @@ -97,9 +97,11 @@ About 70% of Petty criminals and 30% of Wanted ones are meek. They never start a About 70% of Wanted criminals and 30% of Petty ones are normal. A Wanted criminal on a pirate ship is always normal. - They notice anyone holding a weapon, cuffs or a warrant within 6 tiles. Cuffs or a warrant and they stop and watch you. A weapon out and they fight. -- Each has one fighting style, with a real weapon they carry and draw when the fight starts: fists (and shoves), a knife, a machine pistol with a spare magazine, a pump shotgun with buckshot, a baseball bat or thrown bottles. Wanted criminals carry a combat knife or a semi-automatic shotgun instead. Their guns run dry and they reload them like you do. +- Each has one fighting style, with a real weapon they carry and draw when the fight starts: fists (and shoves), a knife, a machine pistol with a spare magazine, a WT-550 with a spare magazine, a .38 revolver with a speedloader, a pump shotgun with buckshot, a baseball bat or thrown bottles. Wanted criminals carry a combat knife or a semi-automatic shotgun instead. Their guns run dry and they reload them like you do. +- Guns stay in a holster, on the belt or slung on the back until the fight. You see one drawn, and the first shot comes a moment later; hit them while they draw and they fumble it. +- Their pistols fire single shots, two a second, in strings of six with a short pause between. So do the kingpin's goons and Club Volga's gunmen. The WT-550 fires bursts of four, and a burst stops as soon as the shooter goes down or loses you. - Wanted criminals wear an armour vest, and Most Wanted a vest and a helmet. Nothing a criminal carries can be taken: it goes with the body. -- They may have up to two companions who fight beside them. Companions pay nothing. They may run when badly hurt or when their criminal goes down, and when they come round from a stun they may give up or run. +- They may have up to two companions who fight beside them. Companions can be of any species and wear rough clothes for where they are. Companions pay nothing. They may run when badly hurt or when their criminal goes down, and when they come round from a stun they may give up or run. - Badly hurt, with two hunters nearby who can see them, they may give up: they put their weapon away, put their hands on their head and lie down for 20 seconds. Cuff them then for full pay. If nobody does, they get up and decide again. - Badly hurt with nobody around, they break off, sit down and patch themselves up with what they carry. @@ -119,7 +121,7 @@ Every Most Wanted criminal is a mini-boss with one of five kits. The board's **O | Kit | Looks like | What it does | How to handle it | |---|---|---|---| | Juggernaut | A giant in riot plates | Charges along a line after a roar, smashing what's in the way. Slams the floor around it when you're close. | Step off the charge line. If it charges into something it can't break, it hurts itself and falls down for a few seconds. | -| Pyromaniac | A scorched criminal in a fire suit | Sweeps a cone of fire 3 tiles long and throws molotovs that leave burning floor. Its fire suit keeps the flames off it. | Stay more than 3 tiles away and off burning floor. If you catch fire, stop, drop and roll, or use an extinguisher. | +| Pyromaniac | A scorched criminal in a fire suit | Sweeps a cone of fire 3 tiles long and throws molotovs that leave burning floor. Its fire suit keeps the flames off it; the space suit it wears where the air kills doesn't. | Stay more than 3 tiles away and off burning floor. If you catch fire, stop, drop and roll, or use an extinguisher. | | Demolitionist | A criminal in a hard hat with a grenade bandolier | Keeps 4 to 6 tiles away and throws grenades with a blinking fuse. Blows holes in interior walls and doors to reach you behind cover. | Close the distance, and move off the blinking ring. | | Ghost | A hooded criminal with a combat knife | Fast. Dashes in with knife cuts that bleed, cloaks into a shimmer, and backs off after two cuts. Its implants make shots miss now and then while it moves, much more often during its burst of speed. | A flash or a hit breaks the cloak, and an EMP ends the burst. Shoot it when it stops moving. | | Heavy | A heavily armed criminal with a belt-fed gun | Heavy armour, slow. Shows a laser sight and a red cone, then fires a burst into it. Throws barrier grenades that open into a barricade. | Get out of the red cone before it fires. Go around the barricade. | @@ -138,6 +140,8 @@ Criminals are people. They bleed, break bones, fall into critical condition and - **Dragging and carrying** work as on anyone. A criminal who can still move pulls free of a grab or squirms off your shoulders. - **No shortcuts.** Criminals can't be teleported. Transporters won't beam a locker, crate or bag with a living one inside, fultons won't attach to them, and a bluespace body bag won't fold while someone alive is struggling inside. Carry them to your ship. - **Patching up.** Some criminals carry bandages or medipens and use them when nobody is shooting at them. +- **Space suits.** At space ruins, and on planets where the air would kill them, criminals and their companions arrive in space suits: soft ones for Petty criminals and companions, armoured ones for Wanted criminals, and each mini-boss its own. A criminal's suit can't be taken off them, like the rest of their gear. Out of a suit where the air kills, they suffocate and freeze like anyone. +- **Suiting up a catch.** To carry a criminal across vacuum, put your own space suit and helmet on them through the strip menu once they're down, cuffed or stunned. Yours goes on in place of theirs, and can come off again. !!! tip "Bring cuffs and a stun" A stun only lasts a little while. Have the cuffs in hand before you stun them. @@ -148,7 +152,7 @@ Criminals are people. They bleed, break bones, fall into critical condition and - The pad must be bolted down and aboard your ship. - The pad says who is on it and what state they're in ("On the pad: Tess Harlow, restrained."), and why it won't take them if it won't. It never says what they'll pay. - Press **Turn In** on their card. If it's greyed out, its tooltip says why. -- The pad beams them away over 3 seconds. Credits go to the ship account. Vouchers appear on the pad, and so do your cuffs. Your ship's notice says what state they were in and what was paid. +- The pad beams them away over 3 seconds. Credits go to the ship account. Vouchers appear on the pad, and so does everything of yours you put on them: cuffs, a suit, a tank. Your ship's notice says what state they were in and what was paid. Pay follows the state they're in **on the pad** when you press Turn In: @@ -171,6 +175,7 @@ Guns, disablers included, don't get past the outpost's checkpoint unless you buy - The fugitive and three **look-alikes** wear the same clothes and go by the same name: "patron" at Waystation Halcyon, "dockhand" at Quartermain Depot and "spacer" at the Undertow Exchange. They have the same species, sex, skin and eyes. - The mugshot on the card is old. Their hair has changed since, and the old hair doesn't match anyone there now. +- Nothing they carry gives them away. A fugitive here never has a shotgun, an SMG or a bat, and the look-alikes wear the same holster, pouch or bag. - Examine a patron to see their distinguishing features: hair, a scar, a tattoo, a scarf, a limp, glasses, a missing ear. Each look-alike shares one or two of the fugitive's features, never all of them. The warrant lists all of them but one. - **Ask the traders.** While your ship hunts the bounty, every trader, the barkeep included, has an **Ask about the wanted person** option. Each gives your ship one clue, and each trader a different one: where the fugitive was seen, how their hair looks now, one of their features, or one patron who isn't them. - **Show the warrant** to the one you think it is. The right person drops the act: a meek one runs, a normal one fights. Anyone else protests and shows you a docking pass. Your ship can show a warrant once every 30 seconds. @@ -180,7 +185,7 @@ Guns, disablers included, don't get past the outpost's checkpoint unless you buy ## Pirate ships -- Wanted and Most Wanted criminals can hide aboard a pirate ship, one per ship. They're never meek there. +- Wanted and Most Wanted criminals can hide aboard an ordinary pirate crew's ship, one per ship, never a themed crew's. They're never meek there. - The card says "Somewhere aboard the" ship, and your helm waypoint follows the ship. - They keep away from the helm, chatting with the crew or going through lockers. The pirates treat them as one of their own. - This is separate from the pirate captain's own bounty (see [Pirates & NPC Ships](pirates-and-npc-ships.md)). You can collect both. From 375d5887d30854a8f2376a7a518504a196ca3825 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Mon, 16 Nov 2026 01:22:32 -0800 Subject: [PATCH 07/13] Zone event route test: count the people a loan queues The hijack loan's infiltrators are human NPCs, sent for through the human NPC queue rather than spawned at once, so the test counts the queued orders and checks their delivery context. --- voidcrew/modules/unit_tests/voidcrew_npc_zone_profiles.dm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/voidcrew/modules/unit_tests/voidcrew_npc_zone_profiles.dm b/voidcrew/modules/unit_tests/voidcrew_npc_zone_profiles.dm index 742e3a0b459..0c6ed76cd2e 100644 --- a/voidcrew/modules/unit_tests/voidcrew_npc_zone_profiles.dm +++ b/voidcrew/modules/unit_tests/voidcrew_npc_zone_profiles.dm @@ -939,8 +939,16 @@ for(var/loan_type in list(/datum/voidcrew_shuttle_loan/syndiehijacking, /datum/voidcrew_shuttle_loan/lots_of_bees, /datum/voidcrew_shuttle_loan/russian_party, /datum/voidcrew_shuttle_loan/spider_gift)) token.current_zone = red var/datum/voidcrew_shuttle_loan/loan = allocate(loan_type) + var/list/queued_before = SShuman_npcs.queue.Copy() loan.spawn_items(cargo) var/hostiles = 0 + // People (human NPCs) are queued, a body a tick: their orders carry the same delivery context. + for(var/datum/human_npc_order/order as anything in SShuman_npcs.queue - queued_before) + hostiles++ + TEST_ASSERT_EQUAL(order.context?.zone_type, 3, "[loan_type] queued a person against the cargo bay") + TEST_ASSERT_EQUAL(order.context?.source_id, REF(cargo), "[loan_type] queued a person without its delivery identity") + TEST_ASSERT_EQUAL(order.context?.role, "ordinary", "[loan_type] queued a person without its encounter role") + qdel(order) for(var/turf/tile as anything in cargo.test_turfs) for(var/mob/living/body in tile) if(!isbasicmob(body) && !isanimal(body)) From d2bc42f2d7ad43e505b0999783c1754ecfe6997a Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Mon, 16 Nov 2026 02:04:01 -0800 Subject: [PATCH 08/13] Zone bounty tests: put the criminal in crit with a chest hit Brute spread over every limb counts for less than its total toward a human's health, so 110 of it left the criminal standing and no capture was bound. --- voidcrew/modules/unit_tests/voidcrew_zone_identity.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/voidcrew/modules/unit_tests/voidcrew_zone_identity.dm b/voidcrew/modules/unit_tests/voidcrew_zone_identity.dm index 409ead1de8b..392909873e1 100644 --- a/voidcrew/modules/unit_tests/voidcrew_zone_identity.dm +++ b/voidcrew/modules/unit_tests/voidcrew_zone_identity.dm @@ -193,7 +193,7 @@ TEST_ASSERT_EQUAL(crew.reputation, 0, "A refused turn-in earned reputation") var/list/card = posting.board_ui_entry(ship, pad) TEST_ASSERT_EQUAL(card["reputation_gain"], 2, "The wanted card lost what it is worth") - criminal.adjustBruteLoss(110) // into tg crit + criminal.apply_damage(110, BRUTE, BODY_ZONE_CHEST, wound_bonus = CANT_WOUND) // into tg crit TEST_ASSERT_EQUAL(record.board_work_zone, 2, "Capture did not bind its actual field band") TEST_ASSERT_EQUAL(crew.reputation, 0, "Capture earned reputation before a paying turn-in") criminal.forceMove(deck) @@ -254,7 +254,7 @@ TEST_ASSERT_EQUAL(tier_posting.board_claim_zone_work(ship), 0, "An escaped prisoner earned reputation") TEST_ASSERT(!tier_posting.record.board_reputation_claimed, "An unpaid escape consumed a reputation claim") var/mob/living/carbon/human/npc/bounty_criminal/admin_spawn = allocate(/mob/living/carbon/human/npc/bounty_criminal, home) - admin_spawn.adjustBruteLoss(110) // into tg crit + admin_spawn.apply_damage(110, BRUTE, BODY_ZONE_CHEST, wound_bonus = CANT_WOUND) // into tg crit TEST_ASSERT_NULL(admin_spawn.posting(), "An admin spawn acquired a posting") TEST_ASSERT_EQUAL(crew.reputation, 20, "An admin spawn earned reputation") @@ -277,7 +277,7 @@ var/datum/criminal_bounty/posting = board_test_posting(2) var/datum/bounty_record/record = posting.record var/mob/living/carbon/human/npc/bounty_criminal/criminal = board_test_criminal(posting, field) - criminal.adjustBruteLoss(110) // into tg crit + criminal.apply_damage(110, BRUTE, BODY_ZONE_CHEST, wound_bonus = CANT_WOUND) // into tg crit TEST_ASSERT_EQUAL(record.board_work_zone, 2, "The first sighting did not bind its capture band") TEST_ASSERT(posting.relist("slipped away"), "The escape did not start relisting") TEST_ASSERT_NULL(record.board_work_zone, "An escaped sighting kept its old work band") From 4638b2bec95c1c41ad3d5690ac902f901c5d51e0 Mon Sep 17 00:00:00 2001 From: Jackriip <97582790+Jackriip@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:36:56 -0800 Subject: [PATCH 09/13] Prison inmates, guards and experiment subjects are people The prison wing's NPCs are now human NPCs (/mob/living/carbon/human/npc): real human bodies with tg's own crit, wounds, cuffs, medicine and death. - Inmates, the guards and their routine, and Kessler's visiting agents and researcher. A guard who is beaten down beams out and comes back. - Experiment subjects turn on their own body: the hulk, the nightmare and the fly person bleed, go into crit and can be cuffed, drugged and revived. Kessler's team darts a living one and takes it away. - Guards get out of the line of stun fire and go back to their routine. - A prisoner who breaks out walks the outpost's patrol path as a person and fights with their fists. - The basic-mob prisoner and guard types are removed, with the bounty cuff and damage multipliers they carried. --- tgstation.dme | 4 + .../_DEFINES/outpost_prison_boss_moves.dm | 5 +- voidcrew/_DEFINES/outpost_prison_bounty.dm | 22 +- .../_DEFINES/outpost_prison_changeling.dm | 2 + .../_DEFINES/outpost_prison_conditions.dm | 3 - .../_DEFINES/outpost_prison_experiments.dm | 83 +- voidcrew/_DEFINES/outpost_prison_guards.dm | 22 +- voidcrew/_DEFINES/outpost_prison_needs.dm | 6 +- voidcrew/_DEFINES/outpost_prison_trouble.dm | 35 +- voidcrew/_HELPERS/hostile_creatures.dm | 11 +- voidcrew/modules/bounties/bounty_admin.dm | 2 +- .../modules/npc_ships/code/outpost_patrol.dm | 27 +- .../player_outposts/outpost_admin_prison.dm | 55 +- .../player_outposts/outpost_npc_looks.dm | 86 +- .../outpost_prison_ambience.dm | 42 +- .../outpost_prison_boss_moves.dm | 192 ++- .../player_outposts/outpost_prison_bounty.dm | 110 +- .../player_outposts/outpost_prison_breach.dm | 198 +++ .../outpost_prison_breakout.dm | 20 +- .../player_outposts/outpost_prison_capture.dm | 229 ++- .../outpost_prison_changeling.dm | 107 +- .../outpost_prison_conditions.dm | 32 +- .../outpost_prison_containment.dm | 49 +- .../outpost_prison_contraband.dm | 96 +- .../player_outposts/outpost_prison_core.dm | 76 +- .../outpost_prison_creatures.dm | 1275 +---------------- .../outpost_prison_dialogue.dm | 46 +- .../player_outposts/outpost_prison_doors.dm | 2 +- .../player_outposts/outpost_prison_economy.dm | 34 +- .../outpost_prison_experiment_forms.dm | 1256 ++++++++++++++++ .../outpost_prison_experiments.dm | 356 +++-- .../player_outposts/outpost_prison_extras.dm | 22 +- .../outpost_prison_fixtures.dm | 4 +- .../outpost_prison_guard_combat_sense.dm | 30 + .../outpost_prison_guard_routine.dm | 196 ++- .../player_outposts/outpost_prison_guards.dm | 515 ++++--- .../player_outposts/outpost_prison_horror.dm | 26 +- .../outpost_prison_incidents.dm | 84 +- .../player_outposts/outpost_prison_leads.dm | 52 +- .../player_outposts/outpost_prison_life.dm | 110 +- .../player_outposts/outpost_prison_mail.dm | 56 +- .../outpost_prison_npc_bodies.dm | 120 ++ .../player_outposts/outpost_prison_panic.dm | 62 +- .../outpost_prison_pastimes.dm | 130 +- .../outpost_prison_prisoner.dm | 541 +++---- .../outpost_prison_researcher.dm | 245 ++-- .../player_outposts/outpost_prison_riot.dm | 198 ++- .../player_outposts/outpost_prison_routine.dm | 66 +- .../outpost_prison_security.dm | 87 +- .../player_outposts/outpost_prison_serum.dm | 8 +- .../player_outposts/outpost_prison_social.dm | 34 +- .../player_outposts/outpost_prison_trouble.dm | 398 +++-- .../player_outposts/outpost_prison_warden.dm | 6 +- .../outpost_prison_warden_tools.dm | 96 +- .../outpost_prison_wing_events.dm | 4 +- .../unit_tests/voidcrew_bounty_admin.dm | 2 +- .../unit_tests/voidcrew_bounty_seams.dm | 7 +- .../unit_tests/voidcrew_npc_zone_profiles.dm | 2 +- .../unit_tests/voidcrew_outpost_npc_looks.dm | 15 - .../unit_tests/voidcrew_outpost_patrol.dm | 15 +- .../voidcrew_outpost_prison_admin.dm | 54 +- .../voidcrew_outpost_prison_bounty.dm | 164 +-- .../voidcrew_outpost_prison_breakout.dm | 22 +- .../voidcrew_outpost_prison_built_turrets.dm | 62 +- .../voidcrew_outpost_prison_capture.dm | 173 ++- .../voidcrew_outpost_prison_changeling.dm | 22 +- .../voidcrew_outpost_prison_conditions.dm | 38 +- .../voidcrew_outpost_prison_containment.dm | 71 +- .../voidcrew_outpost_prison_contraband.dm | 40 +- .../voidcrew_outpost_prison_dialogue.dm | 10 +- .../voidcrew_outpost_prison_economy.dm | 60 +- .../voidcrew_outpost_prison_events.dm | 45 +- .../voidcrew_outpost_prison_experiments.dm | 532 ++++--- .../voidcrew_outpost_prison_extension.dm | 12 +- .../voidcrew_outpost_prison_extras.dm | 2 +- .../voidcrew_outpost_prison_guards.dm | 176 ++- .../voidcrew_outpost_prison_helpers.dm | 45 +- .../voidcrew_outpost_prison_leads.dm | 24 +- .../voidcrew_outpost_prison_life.dm | 68 +- .../voidcrew_outpost_prison_needs.dm | 96 +- .../voidcrew_outpost_prison_panic.dm | 30 +- .../voidcrew_outpost_prison_security.dm | 8 +- .../voidcrew_outpost_prison_social.dm | 102 +- .../voidcrew_outpost_prison_staff.dm | 2 +- .../voidcrew_outpost_prison_trouble.dm | 362 ++--- wiki/content/prison-wing.md | 10 +- 86 files changed, 5453 insertions(+), 4391 deletions(-) create mode 100644 voidcrew/modules/player_outposts/outpost_prison_breach.dm create mode 100644 voidcrew/modules/player_outposts/outpost_prison_experiment_forms.dm create mode 100644 voidcrew/modules/player_outposts/outpost_prison_guard_combat_sense.dm create mode 100644 voidcrew/modules/player_outposts/outpost_prison_npc_bodies.dm diff --git a/tgstation.dme b/tgstation.dme index 2555f50033e..7c88c7e4848 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -7564,6 +7564,7 @@ #include "voidcrew\modules\player_outposts\outpost_prison_ambience.dm" #include "voidcrew\modules\player_outposts\outpost_prison_boss_moves.dm" #include "voidcrew\modules\player_outposts\outpost_prison_bounty.dm" +#include "voidcrew\modules\player_outposts\outpost_prison_breach.dm" #include "voidcrew\modules\player_outposts\outpost_prison_breakout.dm" #include "voidcrew\modules\player_outposts\outpost_prison_capture.dm" #include "voidcrew\modules\player_outposts\outpost_prison_changeling.dm" @@ -7575,10 +7576,12 @@ #include "voidcrew\modules\player_outposts\outpost_prison_dialogue.dm" #include "voidcrew\modules\player_outposts\outpost_prison_doors.dm" #include "voidcrew\modules\player_outposts\outpost_prison_economy.dm" +#include "voidcrew\modules\player_outposts\outpost_prison_experiment_forms.dm" #include "voidcrew\modules\player_outposts\outpost_prison_experiments.dm" #include "voidcrew\modules\player_outposts\outpost_prison_extension.dm" #include "voidcrew\modules\player_outposts\outpost_prison_extras.dm" #include "voidcrew\modules\player_outposts\outpost_prison_fixtures.dm" +#include "voidcrew\modules\player_outposts\outpost_prison_guard_combat_sense.dm" #include "voidcrew\modules\player_outposts\outpost_prison_guard_routine.dm" #include "voidcrew\modules\player_outposts\outpost_prison_guards.dm" #include "voidcrew\modules\player_outposts\outpost_prison_horror.dm" @@ -7586,6 +7589,7 @@ #include "voidcrew\modules\player_outposts\outpost_prison_leads.dm" #include "voidcrew\modules\player_outposts\outpost_prison_life.dm" #include "voidcrew\modules\player_outposts\outpost_prison_mail.dm" +#include "voidcrew\modules\player_outposts\outpost_prison_npc_bodies.dm" #include "voidcrew\modules\player_outposts\outpost_prison_panic.dm" #include "voidcrew\modules\player_outposts\outpost_prison_pastimes.dm" #include "voidcrew\modules\player_outposts\outpost_prison_prisoner.dm" diff --git a/voidcrew/_DEFINES/outpost_prison_boss_moves.dm b/voidcrew/_DEFINES/outpost_prison_boss_moves.dm index 906ab86a8cd..82ad61d7f76 100644 --- a/voidcrew/_DEFINES/outpost_prison_boss_moves.dm +++ b/voidcrew/_DEFINES/outpost_prison_boss_moves.dm @@ -59,13 +59,12 @@ /// Cuffed this long before they start on the cuffs #define PRISON_BOSS_SLIP_DELAY (3 SECONDS) -/// Working at the cuffs +/// The telegraph before they work at the cuffs (tg breakout time follows) #define PRISON_BOSS_SLIP_TIME (5 SECONDS) /// Stopped before they were free: they may try again after this #define PRISON_BOSS_SLIP_RETRY (15 SECONDS) -/// The shimmer afterwards (field cloak: 6 seconds, half of all hits miss) +/// The shimmer afterwards: a look only; a Ghost dodges with real chrome #define PRISON_BOSS_SHIMMER_TIME (6 SECONDS) -#define PRISON_BOSS_SHIMMER_MISS 50 #define PRISON_BOSS_SHIMMER_ALPHA 90 // ===== HEAVY: A BARRICADE ===== diff --git a/voidcrew/_DEFINES/outpost_prison_bounty.dm b/voidcrew/_DEFINES/outpost_prison_bounty.dm index 96787c78a25..053ff4c8ba6 100644 --- a/voidcrew/_DEFINES/outpost_prison_bounty.dm +++ b/voidcrew/_DEFINES/outpost_prison_bounty.dm @@ -43,23 +43,15 @@ // ===== BODY ===== -/// A bounty prisoner's health, by tier. The stamina pool follows it. -#define BOUNTY_PRISONER_HEALTH_PETTY 100 -#define BOUNTY_PRISONER_HEALTH_WANTED 120 -#define BOUNTY_PRISONER_HEALTH_MOST_WANTED 150 +/// How much of a blow a bounty prisoner takes, by tier (human NPC npc_damage_taken, through physiology; defaults PR-16) +#define BOUNTY_PRISONER_DAMAGE_TAKEN_PETTY 1 +#define BOUNTY_PRISONER_DAMAGE_TAKEN_WANTED 0.9 +#define BOUNTY_PRISONER_DAMAGE_TAKEN_MOST_WANTED 0.8 /// A bounty prisoner arrives hurt as they were caught, but with at least this percent of their health (spec 12.3 C11): downed deliveries otherwise crash wings. #define BOUNTY_PRISONER_MIN_ARRIVAL_HEALTH 50 // ===== DANGER, BY TIER ===== -/// Multiplier on their punches -#define BOUNTY_PRISON_PUNCH_MULT_PETTY 1 -#define BOUNTY_PRISON_PUNCH_MULT_WANTED 1.25 -#define BOUNTY_PRISON_PUNCH_MULT_MOST_WANTED 1.5 -/// Multiplier on their shiv blows -#define BOUNTY_PRISON_SHIV_MULT_PETTY 1 -#define BOUNTY_PRISON_SHIV_MULT_WANTED 1.15 -#define BOUNTY_PRISON_SHIV_MULT_MOST_WANTED 1.3 /// Multiplier on their mood losses #define BOUNTY_PRISON_MOOD_SCALE_PETTY 1 #define BOUNTY_PRISON_MOOD_SCALE_WANTED 1.1 @@ -76,10 +68,6 @@ #define BOUNTY_PRISON_BREAKOUT_MULT_PETTY 1 #define BOUNTY_PRISON_BREAKOUT_MULT_WANTED 1.25 #define BOUNTY_PRISON_BREAKOUT_MULT_MOST_WANTED 1.5 -/// Multiplier on how long cuffing them takes -#define BOUNTY_PRISON_CUFF_MULT_PETTY 1 -#define BOUNTY_PRISON_CUFF_MULT_WANTED 1 -#define BOUNTY_PRISON_CUFF_MULT_MOST_WANTED 1 /// How much likelier a Wanted or Most Wanted prisoner who is not meek is to hit back when hit (like a grumpy one) #define BOUNTY_PRISON_HIT_BACK_MULT_WANTED 1.5 #define BOUNTY_PRISON_HIT_BACK_MULT_MOST_WANTED 1.5 @@ -112,5 +100,3 @@ #define BOUNTY_PRISON_MEEK_DART_STEP 2 /// Steps a dart takes at most, waits for the door to swing open or for someone to get out of the way included, before they give up on it #define BOUNTY_PRISON_MEEK_DART_STEPS 10 -/// Their speed while loose (others keep their own, 2) -#define BOUNTY_PRISON_MEEK_LOOSE_SPEED 1.6 diff --git a/voidcrew/_DEFINES/outpost_prison_changeling.dm b/voidcrew/_DEFINES/outpost_prison_changeling.dm index 85ef0049b44..09f9a24ca23 100644 --- a/voidcrew/_DEFINES/outpost_prison_changeling.dm +++ b/voidcrew/_DEFINES/outpost_prison_changeling.dm @@ -20,6 +20,8 @@ #define OUTPOST_CHANGELING_EARLY_BURST 3 /// Seconds a host may spend out of the cell block before the specimen is lost #define OUTPOST_CHANGELING_HOST_LOST_AFTER 60 +/// A host with a body, down on their bunk, is knocked flat this long by each heave of the specimen +#define OUTPOST_CHANGELING_HOST_KNOCKDOWN (6 SECONDS) /// The host's sentence is held at least this long, so they are not released mid-incubation #define OUTPOST_CHANGELING_HOST_SENTENCE_HOLD 600 diff --git a/voidcrew/_DEFINES/outpost_prison_conditions.dm b/voidcrew/_DEFINES/outpost_prison_conditions.dm index c60ed91ded9..257ee6f7797 100644 --- a/voidcrew/_DEFINES/outpost_prison_conditions.dm +++ b/voidcrew/_DEFINES/outpost_prison_conditions.dm @@ -66,9 +66,6 @@ #define PRISON_RAT_AFTER (3 MINUTES) #define PRISON_RAT_CHANCE 20 #define PRISON_RAT_MAX 2 -/// Brute per 5 seconds on unsafe air, never below PRISON_AIR_HEALTH_FLOOR percent health -#define PRISON_AIR_DAMAGE 1 -#define PRISON_AIR_HEALTH_FLOOR 30 /// Unsafe air: pressure (kPa), temperature (K) and plasma (mol) limits #define PRISON_AIR_PRESSURE_MIN 60 #define PRISON_AIR_PRESSURE_MAX 150 diff --git a/voidcrew/_DEFINES/outpost_prison_experiments.dm b/voidcrew/_DEFINES/outpost_prison_experiments.dm index 44cc40a73c0..32cf9e414f1 100644 --- a/voidcrew/_DEFINES/outpost_prison_experiments.dm +++ b/voidcrew/_DEFINES/outpost_prison_experiments.dm @@ -131,74 +131,50 @@ /// How long a rioter who runs has to get away before they riot on #define OUTPOST_PANIC_RETREAT_TIME (15 SECONDS) -// ----- Creatures: health grows with the crew on the level when they appear ----- -/// Most extra players counted -#define OUTPOST_EXPERIMENT_EXTRA_PLAYERS_MAX 3 +// ----- The serum's forms (outpost_prison_experiment_forms.dm) ----- +// The subject's own body changed by tg's genes and species. Their toughness is physiology +// (npc_damage_taken: brute and burn taken as a multiple of a person's), never health, and never +// scaled by who is on the level. -// Hulk -#define OUTPOST_HULK_HEALTH 350 -#define OUTPOST_HULK_HEALTH_PER_PLAYER 100 -#define OUTPOST_HULK_SPEED 1.8 -#define OUTPOST_HULK_EXHAUSTED_SPEED 2.5 -#define OUTPOST_HULK_PUNCH_MIN 18 -#define OUTPOST_HULK_PUNCH_MAX 22 -#define OUTPOST_HULK_PUNCH_COOLDOWN (1.5 SECONDS) -/// Percent chance a punch throws its target OUTPOST_HULK_THROW_RANGE tiles +/// How Kessler finds a creature it comes for (outpost_experiment_down_state()): dead; alive on the +/// floor and held (cuffed or asleep), which pays the subdued rate; or on the floor or held but not both +#define OUTPOST_EXPERIMENT_DOWN_DEAD "dead" +#define OUTPOST_EXPERIMENT_DOWN_SUBDUED "subdued" +#define OUTPOST_EXPERIMENT_DOWN_DOWN "down" +/// Units of chloral hydrate in a Kessler agent's dart (owner ruling OC-3) +#define OUTPOST_KESSLER_DART_DOSE 15 + +// Hulk: tg's hulk gene and gigantism +#define OUTPOST_HULK_DAMAGE_TAKEN 0.6 +/// Percent chance a punch that lands throws someone OUTPOST_HULK_THROW_RANGE tiles; a standing prisoner is knocked down instead #define OUTPOST_HULK_THROW_CHANCE 25 #define OUTPOST_HULK_THROW_RANGE 2 +#define OUTPOST_HULK_KNOCKDOWN (2 SECONDS) /// The charge: wind-up, range, damage, knockdown, cooldown #define OUTPOST_HULK_CHARGE_WINDUP (1.5 SECONDS) #define OUTPOST_HULK_CHARGE_RANGE 6 #define OUTPOST_HULK_CHARGE_DAMAGE 20 #define OUTPOST_HULK_CHARGE_KNOCKDOWN (2 SECONDS) #define OUTPOST_HULK_CHARGE_COOLDOWN (12 SECONDS) -/// Charging into a wall with nobody caught: stunned this long, taking this much more damage meanwhile +/// Charging into a wall with nobody caught: stunned this long #define OUTPOST_HULK_WALL_STUN (2 SECONDS) -#define OUTPOST_HULK_WALL_VULNERABLE 1.25 -/// Tearing through an interior wall, and forcing a door -#define OUTPOST_HULK_TEAR_TIME (3 SECONDS) +/// Forcing a door #define OUTPOST_HULK_DOOR_TIME (4 SECONDS) -/// Worn down to this percent of health, it stops charging and a baton or disabler can put it down -#define OUTPOST_HULK_EXHAUSTED_AT 25 -/// Stamina it can take once exhausted: two baton hits or four disabler shots -#define OUTPOST_HULK_STAMINA 110 -// Nightmare -#define OUTPOST_NIGHTMARE_HEALTH 225 -#define OUTPOST_NIGHTMARE_HEALTH_PER_PLAYER 75 -#define OUTPOST_NIGHTMARE_DARK_SPEED 1.5 -#define OUTPOST_NIGHTMARE_LIGHT_SPEED 2.5 -#define OUTPOST_NIGHTMARE_DAMAGE 20 -#define OUTPOST_NIGHTMARE_ATTACK_COOLDOWN (1.2 SECONDS) +// Nightmare: tg's nightmare species and organs +#define OUTPOST_NIGHTMARE_DAMAGE_TAKEN 0.8 #define OUTPOST_NIGHTMARE_ARMOUR_PENETRATION 20 -/// Percent chance a hit burns out a flashlight the target holds (never flares or glowsticks) -#define OUTPOST_NIGHTMARE_BURNOUT_CHANCE 35 -/// Light level below which it is in the dark (SHADOW_SPECIES_LIGHT_THRESHOLD) -#define OUTPOST_NIGHTMARE_DARK 0.2 -/// Health per second: regained in the dark, lost in the light -#define OUTPOST_NIGHTMARE_REGEN 2 -#define OUTPOST_NIGHTMARE_BURN 2 -/// Percent of shots it sidesteps in the dark -#define OUTPOST_NIGHTMARE_DODGE 60 /// The shadow jaunt: cooldown, the ripple that warns of it, what it does #define OUTPOST_NIGHTMARE_JAUNT_COOLDOWN (12 SECONDS) #define OUTPOST_NIGHTMARE_JAUNT_RIPPLE (1 SECONDS) #define OUTPOST_NIGHTMARE_JAUNT_DAMAGE 25 #define OUTPOST_NIGHTMARE_JAUNT_KNOCKDOWN (1 SECONDS) -/// A handheld flash: burn and stagger -#define OUTPOST_NIGHTMARE_FLASH_DAMAGE 20 -#define OUTPOST_NIGHTMARE_FLASH_STAGGER (2 SECONDS) /// Seconds it spends breaking the lights first, ignoring people who leave it alone #define OUTPOST_NIGHTMARE_OPENING_MIN 30 #define OUTPOST_NIGHTMARE_OPENING_MAX 45 -// Fly person -#define OUTPOST_FLY_HEALTH 60 -/// Its move delay: faster than a running person (1.5) -#define OUTPOST_FLY_SPEED 0.7 -/// Percent of shots it jinks out of the way of while flying freely (not knocked down, held or subdued) -#define OUTPOST_FLY_DODGE 40 -#define OUTPOST_FLY_BITE 5 +// Fly person: tg's fly species and a Slipwire implant +#define OUTPOST_FLY_DAMAGE_TAKEN 1 /// It darts away from anyone this close #define OUTPOST_FLY_FLEE_RANGE 3 /// Its darts: tiles, the pause between random ones, and how long one may take before it gives up on it @@ -209,16 +185,6 @@ #define OUTPOST_FLY_DART_TIMEOUT (1.5 SECONDS) /// How long it keeps away from whoever last hit it #define OUTPOST_FLY_FLIT_TIME (3 SECONDS) -/// Trait source for its flight -#define OUTPOST_FLY_TRAIT "outpost_fly" -/// Seconds between throwing up, and the percent chance it gets someone beside it -#define OUTPOST_FLY_VOMIT_MIN 6 -#define OUTPOST_FLY_VOMIT_MAX 10 -#define OUTPOST_FLY_VOMIT_ON_CHANCE 25 -/// A flyswatter hits it this many times harder, as it does tg's fly people -#define OUTPOST_FLY_SWATTER_MULT 30 -/// Stamina it can take: two baton hits -#define OUTPOST_FLY_STAMINA 100 // ----- Trait sources and timings shared by the experiment files ----- /// Seconds a creature may chase its current target with no progress (not closer, not adjacent) @@ -236,5 +202,10 @@ #define OUTPOST_KESSLER_TEAM_TIME (5 SECONDS) /// How long a Kessler beam takes, in and out #define OUTPOST_KESSLER_BEAM_TIME (3 SECONDS) +/// From a real hit on Kessler staff to Kessler's beam taking them out ("I'm leaving!") +#define OUTPOST_KESSLER_ASSAULT_BEAM_DELAY (2 SECONDS) +/// Seconds before Kessler sends anyone again after its researcher was killed on a visit +#define OUTPOST_KESSLER_KILLED_WAIT_MIN (90 * 60) +#define OUTPOST_KESSLER_KILLED_WAIT_MAX (120 * 60) /// The creatures' sentience type: it matches no potion, lazarus injector or ghost role (the spec's SENTIENCE_NONE) #define OUTPOST_EXPERIMENT_NO_SENTIENCE 0 diff --git a/voidcrew/_DEFINES/outpost_prison_guards.dm b/voidcrew/_DEFINES/outpost_prison_guards.dm index e5018024dee..b73c94b41f4 100644 --- a/voidcrew/_DEFINES/outpost_prison_guards.dm +++ b/voidcrew/_DEFINES/outpost_prison_guards.dm @@ -10,15 +10,16 @@ #define OUTPOST_GUARD_WAGE 2 /// Wages skipped in a row (the treasury could not cover them) before the guards walk off #define OUTPOST_GUARD_UNPAID_LEAVE 2 -#define OUTPOST_GUARD_HEALTH 120 -/// Health at which a guard goes down (godmode, lying) instead of taking more damage -#define OUTPOST_GUARD_DOWN_AT 30 -/// From going down to beaming out +/// From going into crit to the corrections service's medevac of the body #define OUTPOST_GUARD_RECALL_DELAY (10 SECONDS) +/// From a guard's death to the corrections service collecting the body +#define OUTPOST_GUARD_BODY_COLLECT_DELAY (60 SECONDS) +/// A guard whose baton went flat is back with a charged one after this +#define OUTPOST_GUARD_SHIFT_SWAP_TIME (1 MINUTES) +/// A guard with this much brute and burn damage or more patches up from the office first-aid kit when nothing is going on +#define OUTPOST_GUARD_TREAT_ABOVE 20 /// A downed or recalled guard comes back free after this, if still hired and a member is home #define OUTPOST_GUARD_RETURN_TIME (10 MINUTES) -/// Stamina damage per baton strike: prisoners crit at 100, so three strikes -#define OUTPOST_GUARD_BATON_STAMINA 35 #define OUTPOST_GUARD_BATON_COOLDOWN (2 SECONDS) /// Percent chance a guard arriving at an argument ends it with words #define OUTPOST_GUARD_TALKDOWN_CHANCE 60 @@ -56,11 +57,6 @@ #define OUTPOST_GUARD_SPAT_VIEW 7 /// How close to a member in the cell block a guard stays during a riot #define OUTPOST_GUARD_FOLLOW_RANGE 2 -/// Health a guard gets back per minute while not in a riot and not down -#define OUTPOST_GUARD_HEAL_PER_MINUTE 12 -/// Movement: an unhurried walk on routine, a hurry on a response (basic mob speed) -#define OUTPOST_GUARD_SPEED_WALK 2 -#define OUTPOST_GUARD_SPEED_HURRY 1 /// How long a prisoner is left alone after a guard checked on them or they greeted a guard #define OUTPOST_GUARD_CHECK_ON_GAP (5 MINUTES) @@ -97,5 +93,5 @@ /// Trait source for the beam holding a guard still #define OUTPOST_GUARD_BEAM_TRAIT "outpost_guard_beam" -/// Trait source for a guard lying down, out of it -#define OUTPOST_GUARD_DOWN_TRAIT "outpost_guard_down" +/// Trait source for what a guard on their feet refuses (lockers, bags) +#define OUTPOST_GUARD_UPRIGHT_TRAIT "outpost_guard_upright" diff --git a/voidcrew/_DEFINES/outpost_prison_needs.dm b/voidcrew/_DEFINES/outpost_prison_needs.dm index a75776cdf87..fc0e603b607 100644 --- a/voidcrew/_DEFINES/outpost_prison_needs.dm +++ b/voidcrew/_DEFINES/outpost_prison_needs.dm @@ -17,8 +17,6 @@ #define PRISONER_INJURED_BELOW 90 /// Below this health percent an untreated prisoner leaves the odd drip of blood #define PRISONER_BLEED_BELOW 50 -/// How long stamina crit holds after the last stamina hit, long enough to drag one to a cell -#define PRISONER_STAMCRIT_TIME (20 SECONDS) /// Percent chance per minute that a prisoner drops some mess #define OUTPOST_PRISON_MESS_CHANCE 4 /// Pause between spontaneous prisoner lines anywhere in one wing (deciseconds) @@ -37,7 +35,7 @@ #define PRISONER_MOOD_CLEAN_UNIFORM 8 #define PRISONER_MOOD_TREATED 8 -// Where a prisoner is in their stay (/mob/living/basic/outpost_prisoner/var/phase) +// Where a prisoner is in their stay (/mob/living/carbon/human/npc/outpost_prisoner/var/phase) /// Being beamed into their cell #define PRISONER_ARRIVING "arriving" /// In the wing, serving their sentence @@ -45,7 +43,7 @@ /// Being beamed out, released or collected #define PRISONER_LEAVING "leaving" -// What /mob/living/basic/outpost_prisoner/proc/try_reach() found +// What /mob/living/carbon/human/npc/outpost_prisoner/proc/try_reach() found #define PRISONER_REACH_FAILED 0 #define PRISONER_REACH_OK 1 /// Their side of a serving hatch is opening diff --git a/voidcrew/_DEFINES/outpost_prison_trouble.dm b/voidcrew/_DEFINES/outpost_prison_trouble.dm index f8a4942d809..7b102d3be93 100644 --- a/voidcrew/_DEFINES/outpost_prison_trouble.dm +++ b/voidcrew/_DEFINES/outpost_prison_trouble.dm @@ -77,22 +77,6 @@ #define PRISONER_THREAT_COOLDOWN 20 /// Seconds a decided swing waits for them to close in before it is dropped #define PRISONER_SWING_TIMEOUT 6 -/// Brute damage of a punch at staff: blunt, and it never wounds -#define PRISONER_PUNCH_MIN 5 -#define PRISONER_PUNCH_MAX 8 -/// Brute damage of a shiv at staff or anyone else who is not a prisoner (tg's glass shiv is force 8). -/// Each blow is a stab or a slash, so it can leave a puncture or a cut that bleeds. -#define PRISONER_SHIV_MIN 10 -#define PRISONER_SHIV_MAX 15 -/// The shiv's wounding, as tg's glass shiv has it in someone's hand. Four blows in five land on the -/// chest, which resists wounds; the rest on an arm, a leg or now and then the head (tg's -/// attack_zone_randomiser). On a bare body about two blows in five wound. An armour vest takes a -/// third off chest blows and stops nearly every wound there, leaving about one in five. -#define PRISONER_SHIV_WOUND_BONUS 5 -#define PRISONER_SHIV_EXPOSED_WOUND_BONUS 15 -/// Brute damage of a shiv at another prisoner (a stabbing, outpost_prison_incidents.dm), never a killing blow -#define PRISONER_STAB_MIN 7 -#define PRISONER_STAB_MAX 10 // A player's blow on a prisoner on their feet: they hit back, or back off /// Seconds they go after the attacker before letting it drop @@ -139,10 +123,7 @@ #define PRISONER_FIGHT_COOLDOWN 300 /// Seconds between any two fights in the wing #define PRISON_FIGHT_GAP 180 -/// Brute of a blow in a fight between prisoners -#define PRISONER_FIGHT_HIT_MIN 3 -#define PRISONER_FIGHT_HIT_MAX 6 -/// Health percent at which a fighter yields, and seconds they stay down +/// Health percent at which a losing fighter gives up, and seconds they then stay lying down by choice #define PRISONER_FIGHT_YIELD 40 #define PRISONER_FIGHT_YIELD_TIME 20 /// Below this mood two prisoners near each other may argue without blows, at most once per PRISON_SPAT_GAP in the wing @@ -152,11 +133,8 @@ #define PRISON_SPAT_CHANCE 8 // Beaten down -/// At or below this health percent a prisoner collapses -#define PRISONER_BEATEN_BELOW 15 -/// Seconds they lie beaten, unless treated above PRISONER_RECOVER_ABOVE percent first -#define PRISONER_BEATEN_TIME 120 -#define PRISONER_RECOVER_ABOVE 40 +/// How long something that slams a prisoner on their feet to the floor knocks them down (collapse(), a real tg Knockdown) +#define PRISONER_COLLAPSE_KNOCKDOWN (4 SECONDS) // Riots /// Below these moods each personality joins a riot; if nobody does, the unhappiest starts it alone. @@ -223,8 +201,6 @@ #define PRISON_LOOSE_PING_2 60 /// Mood of a recaptured prisoner #define PRISONER_RECAPTURED_MOOD 35 -/// Damage a loose prisoner does to doors and machines per blow (normal airlocks shrug off under 21) -#define PRISONER_LOOSE_OBJ_DAMAGE 25 // Lock-in /// Confined this many seconds at mood PRISONER_WRECK_MOOD or less, a prisoner wrecks the cell; the bolts shear PRISONER_WRECK_TIME seconds later @@ -233,8 +209,7 @@ #define PRISONER_WRECK_TIME 180 // Cuffs (outpost_prison_capture.dm) -/// Seconds cuffing takes: a prisoner who is down, and one on their feet and out of trouble -#define PRISONER_CUFF_TIME_DOWN (2 SECONDS) +/// How long a prisoner holds still for tg's cuffing (its handcuffs take 4 seconds) #define PRISONER_CUFF_TIME_STANDING (4 SECONDS) /// Seconds taking the cuffs off takes #define PRISONER_UNCUFF_TIME (2 SECONDS) @@ -252,7 +227,7 @@ /// Seconds out of a cell, on their feet and uncuffed, before a prisoner who owes lockdown riots again #define PRISON_LOCKDOWN_GRACE 30 -// What trouble a prisoner is in (/mob/living/basic/outpost_prisoner/var/trouble); null is none +// What trouble a prisoner is in (/mob/living/carbon/human/npc/outpost_prisoner/var/trouble); null is none #define PRISONER_TROUBLE_FIGHT "fight" #define PRISONER_TROUBLE_RIOT "riot" /// Rioting after the riot turned into a breakout: going for the exits diff --git a/voidcrew/_HELPERS/hostile_creatures.dm b/voidcrew/_HELPERS/hostile_creatures.dm index 30e616a1de2..0561a69e0c2 100644 --- a/voidcrew/_HELPERS/hostile_creatures.dm +++ b/voidcrew/_HELPERS/hostile_creatures.dm @@ -65,14 +65,15 @@ GLOBAL_LIST_INIT(turret_retaliating_subtrees, typecacheof(list( * GLOB.ai_subtrees, so this is a handful of list lookups. */ /proc/is_hostile_creature(mob/living/creature) + // Prison experiment creatures (outpost_prison_experiment_forms.dm, outpost_prison_horror.dm): fair game + // anywhere while up, like the headslug, whose stock AI already reads as hostile. Their custom AI does + // not. First: a body the serum took is still a prisoner's body. + if(is_outpost_experiment_creature(creature)) + return is_outpost_experiment_turret_target(creature) // Outpost prisoners (outpost_prison_*.dm): left alone inside their wing, rioting or not; // once loose outside it they are fair game. Turrets players build use outpost_prison_security.dm instead. - if(istype(creature, /mob/living/basic/outpost_prisoner)) + if(istype(creature, /mob/living/carbon/human/npc/outpost_prisoner)) return is_loose_outpost_prisoner(creature) - // Prison experiment creatures (outpost_prison_creatures.dm): fair game anywhere, like the - // headslug, whose stock AI already reads as hostile. Their custom AI does not. - if(istype(creature, /mob/living/basic/outpost_experiment)) - return is_outpost_experiment_turret_target(creature) // Bounty criminals, decoys and companions (voidcrew/modules/bounties/bounty_criminal.dm), real human bodies: // trader-outpost turrets leave them to the hunters, and no turret shoots a criminal already in crit, // stunned or cuffed (tg's states). diff --git a/voidcrew/modules/bounties/bounty_admin.dm b/voidcrew/modules/bounties/bounty_admin.dm index 3ba9fa629c4..3fe28acdb79 100644 --- a/voidcrew/modules/bounties/bounty_admin.dm +++ b/voidcrew/modules/bounties/bounty_admin.dm @@ -1195,7 +1195,7 @@ ADMIN_VERB(bounty_panel, R_ADMIN, "Bounty Panel", "Spawn, post, give out, list a return refuse(user, "That prison is gone.") if(!prison.free_slots()) return refuse(user, "[prison_name(prison)] has no free cell.") - var/mob/living/basic/outpost_prisoner/prisoner = prison.bounty_admit_record(record) + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = prison.bounty_admit_record(record) if(QDELETED(prisoner)) return refuse(user, "[prison_name(prison)] took nobody: no cell there has room for an arrival.") log_action(user, "admit bounty record [record.name] ([record_kind(record)]) into cell [prisoner.cell?.number] of [prison_name(prison)]") diff --git a/voidcrew/modules/npc_ships/code/outpost_patrol.dm b/voidcrew/modules/npc_ships/code/outpost_patrol.dm index ad94f58fb8d..fe3ab37194a 100644 --- a/voidcrew/modules/npc_ships/code/outpost_patrol.dm +++ b/voidcrew/modules/npc_ships/code/outpost_patrol.dm @@ -163,7 +163,7 @@ GLOBAL_LIST_EMPTY(outpost_patrol_caches) * was doing is cancelled first; the old controller and its blackboard are deleted. Returns the new * controller, or null if it could not take the mob. */ -/proc/swap_basic_ai_controller(mob/living/basic/pawn, controller_type) +/proc/swap_basic_ai_controller(mob/living/pawn, controller_type) if(QDELETED(pawn) || !ispath(controller_type, /datum/ai_controller)) return null var/datum/ai_controller/old_controller = pawn.ai_controller @@ -185,7 +185,7 @@ GLOBAL_LIST_EMPTY(outpost_patrol_caches) /// Whether a breakout controller leaves `target` alone: prisoners, and anyone else breaking out /proc/is_outpost_breakout_ally(mob/living/target) - if(istype(target, /mob/living/basic/outpost_prisoner)) + if(istype(target, /mob/living/carbon/human/npc/outpost_prisoner)) return TRUE return istype(target?.ai_controller, /datum/ai_controller/basic_controller/outpost_breakout) @@ -571,16 +571,16 @@ GLOBAL_LIST_EMPTY(outpost_patrol_caches) // ===== BREAKOUT AI ===== /** - * Someone who broke out of an outpost prison. Walks the outpost's patrol path, opens or smashes the - * doors on the way, searches lockers, and fights anyone who is not a prisoner with its own melee. + * Someone who broke out of an outpost prison. Walks the outpost's patrol path, opens the doors on the + * way that open for them, searches lockers, and fights anyone who is not a prisoner with their fists. * Swapped onto a prisoner with swap_basic_ai_controller(), then given a path with * assign_mob_to_outpost_patrol(). Without a path it wanders and still fights. */ /datum/ai_controller/basic_controller/outpost_breakout blackboard = list( BB_TARGETING_STRATEGY = /datum/targeting_strategy/basic/outpost_breakout, - // People are beaten down, not finished off - BB_TARGET_MINIMUM_STAT = SOFT_CRIT, + // People are beaten down, not finished off: nobody in crit is hit (defaults 1.13) + BB_TARGET_MINIMUM_STAT = HUMAN_NPC_SPARES_DOWNED, ) ai_movement = /datum/ai_movement/jps idle_behavior = /datum/idle_behavior/idle_random_walk @@ -664,19 +664,16 @@ GLOBAL_LIST_EMPTY(outpost_patrol_caches) /datum/ai_behavior/attack_obstructions/trooper/include_mobs/outpost_breakout -/datum/ai_behavior/attack_obstructions/trooper/include_mobs/outpost_breakout/attack_in_direction(datum/ai_controller/controller, mob/living/basic/basic_mob, direction) - var/turf/next_step = get_step(basic_mob, direction) +// A runner is a real human body (outpost_prison_prisoner.dm): it throws punches at whoever is in its way +// through its own hands, and walks round what fists can't move. +/datum/ai_behavior/attack_obstructions/trooper/include_mobs/outpost_breakout/attack_in_direction(datum/ai_controller/controller, mob/living/runner, direction) + var/turf/next_step = get_step(runner, direction) if(!next_step?.is_blocked_turf(exclude_mobs = FALSE, source_atom = controller.pawn)) return FALSE for(var/mob/living/blocking_mob in next_step) - if(blocking_mob == basic_mob || is_outpost_breakout_ally(blocking_mob)) + if(blocking_mob == runner || is_outpost_breakout_ally(blocking_mob)) continue - basic_mob.melee_attack(blocking_mob) - return TRUE - for(var/obj/object as anything in next_step.contents) - if(!can_smash_object(basic_mob, object)) - continue - basic_mob.melee_attack(object) + controller.ai_interact(blocking_mob, combat_mode = TRUE) return TRUE return FALSE diff --git a/voidcrew/modules/player_outposts/outpost_admin_prison.dm b/voidcrew/modules/player_outposts/outpost_admin_prison.dm index 11ebecc5d59..841fb028771 100644 --- a/voidcrew/modules/player_outposts/outpost_admin_prison.dm +++ b/voidcrew/modules/player_outposts/outpost_admin_prison.dm @@ -94,7 +94,7 @@ GLOBAL_LIST_INIT(outpost_admin_prison_crew_modes, list("auto" = null, "home" = T record(user, home, "[open ? "open" : "close"] prison intake") if("prison_spawn") // Forced: an admin spawn ignores the cell's ready time and a running experiment - var/mob/living/basic/outpost_prisoner/arrival = prison.admit_next(TRUE) + var/mob/living/carbon/human/npc/outpost_prisoner/arrival = prison.admit_next(TRUE) if(!arrival) error = "No free cell." return @@ -108,7 +108,7 @@ GLOBAL_LIST_INIT(outpost_admin_prison_crew_modes, list("auto" = null, "home" = T return record(user, home, "fill [count] prison cell\s") if("prison_release", "prison_kill", "prison_remove", "prison_set", "prison_fight", "prison_breakout", "prison_wreck") - var/mob/living/basic/outpost_prisoner/prisoner = locate(params["ref"]) in prison.prisoners + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = locate(params["ref"]) in prison.prisoners if(QDELETED(prisoner)) error = "That prisoner is gone." return @@ -126,7 +126,7 @@ GLOBAL_LIST_INIT(outpost_admin_prison_crew_modes, list("auto" = null, "home" = T if(!prisoner.can_join_riot() || prisoner.trouble) error = "That prisoner can't fight now." return - var/mob/living/basic/outpost_prisoner/partner = prison.nearest_fight_partner(prisoner) + var/mob/living/carbon/human/npc/outpost_prisoner/partner = prison.nearest_fight_partner(prisoner) if(!partner) error = "No other prisoner can fight." return @@ -284,7 +284,7 @@ GLOBAL_LIST_INIT(outpost_admin_prison_crew_modes, list("auto" = null, "home" = T if(!istext(form) || !(form in list("hulk", "fly", "nightmare", "changeling"))) error = "Invalid experiment form." return - var/mob/living/basic/outpost_prisoner/subject = locate(params["ref"]) in prison.prisoners + var/mob/living/carbon/human/npc/outpost_prisoner/subject = locate(params["ref"]) in prison.prisoners if(QDELETED(subject)) error = "That prisoner is gone." return @@ -418,7 +418,7 @@ GLOBAL_LIST_INIT(outpost_admin_prison_crew_modes, list("auto" = null, "home" = T for(var/datum/outpost_prison_cell/cell as anything in cells) cell_rows += list(list("number" = cell.number, "occupant_ref" = cell.occupant ? REF(cell.occupant) : null)) var/list/prisoner_rows = list() - for(var/mob/living/basic/outpost_prisoner/prisoner as anything in roster_order()) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner as anything in roster_order()) prisoner_rows += list(list( "ref" = REF(prisoner), "name" = prisoner.real_name, @@ -440,7 +440,7 @@ GLOBAL_LIST_INIT(outpost_admin_prison_crew_modes, list("auto" = null, "home" = T "mood" = round(prisoner.mood), "state" = prisoner.trouble_state(), "loose_left" = prisoner.loose_seconds_shown(), - "cuffed" = !!prisoner.cuffs, + "cuffed" = !!prisoner.handcuffed, "lockdown_left" = max(0, round(prisoner.lockdown_left)), )) var/list/trouble_block = trouble_payload() @@ -519,11 +519,11 @@ GLOBAL_LIST_INIT(outpost_admin_prison_crew_modes, list("auto" = null, "home" = T return null /// Where their care falls between no pay and full pay, 0 to 1 (section 1's G(care)) -/mob/living/basic/outpost_prisoner/proc/admin_care_grade() +/mob/living/carbon/human/npc/outpost_prisoner/proc/admin_care_grade() return clamp((care() - OUTPOST_PRISON_GRADE_FLOOR) / (OUTPOST_PRISON_GRADE_FULL - OUTPOST_PRISON_GRADE_FLOOR), 0, 1) /// What they are up to, in a few words -/mob/living/basic/outpost_prisoner/proc/admin_activity_text() +/mob/living/carbon/human/npc/outpost_prisoner/proc/admin_activity_text() if(stat == DEAD) return "dead" if(phase == PRISONER_ARRIVING) @@ -532,9 +532,9 @@ GLOBAL_LIST_INIT(outpost_admin_prison_crew_modes, list("auto" = null, "home" = T return "beaming out" if(pulledby) return "being dragged" - if(beaten_left > 0) - return "beaten ([round(beaten_left)] s)" - if(cuffs) + if(beaten) + return HAS_TRAIT(src, TRAIT_CRITICAL_CONDITION) ? "beaten, in crit" : "beaten" + if(handcuffed) if(trouble == PRISONER_TROUBLE_LOOSE) return "cuffed, loose" return is_rioting() ? "cuffed, rioting" : "cuffed" @@ -559,18 +559,17 @@ GLOBAL_LIST_INIT(outpost_admin_prison_crew_modes, list("auto" = null, "home" = T return text /// Sets one of a prisoner's values. Returns FALSE if it can't take it. -/datum/outpost_prison/proc/admin_set(mob/living/basic/outpost_prisoner/prisoner, field, value) +/datum/outpost_prison/proc/admin_set(mob/living/carbon/human/npc/outpost_prisoner/prisoner, field, value) switch(field) if("hunger") prisoner.set_hunger(clamp(value, 0, 100)) if("grime") prisoner.set_uniform_grime(clamp(value, 0, 100)) if("health") - // 1 to 100 percent; killing has its own button. + // 1 to 100 percent; killing has its own button. Bruising over the limbs, measured as it lands. if(prisoner.stat == DEAD) return FALSE - var/target_loss = prisoner.maxHealth * (100 - clamp(value, 1, 100)) / 100 - prisoner.adjustBruteLoss(target_loss - prisoner.getBruteLoss(), forced = TRUE) + outpost_prison_set_health(prisoner, prisoner.maxHealth * clamp(value, 1, 100) / 100) if("sentence") if(prisoner.stat == DEAD || prisoner.phase != PRISONER_PRESENT) return FALSE @@ -598,7 +597,7 @@ GLOBAL_LIST_INIT(outpost_admin_prison_crew_modes, list("auto" = null, "home" = T /// Applies one change to every living prisoner. Returns how many. /datum/outpost_prison/proc/admin_all(what) var/count = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.stat == DEAD || prisoner.phase == PRISONER_LEAVING) continue count++ @@ -612,13 +611,11 @@ GLOBAL_LIST_INIT(outpost_admin_prison_crew_modes, list("auto" = null, "home" = T if("clean") prisoner.set_uniform_grime(0) if("hurt") - // A real hit, so they bleed, never a killing one. - var/damage = min(30, prisoner.health - 1) - if(damage > 0) - prisoner.apply_damage(damage, BRUTE) + // A real hit on one limb, so they bruise and may bleed (defaults PR-27). + prisoner.apply_damage(30, BRUTE, pick(BODY_ZONE_CHEST, BODY_ZONE_L_ARM, BODY_ZONE_R_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG)) if("heal") - prisoner.adjustBruteLoss(-prisoner.getBruteLoss(), forced = TRUE) - prisoner.setStaminaLoss(0) + // tg's own full heal of the body (damage, wounds, blood), cuffs and the rest left as they are. + prisoner.fully_heal(HEAL_DAMAGE | HEAL_WOUNDS | HEAL_BLOOD | HEAL_LIMBS | HEAL_ORGANS) if("enrage") // Low enough to threaten staff, fight, and riot once it has held for half a minute. prisoner.set_mood(10) @@ -636,7 +633,7 @@ GLOBAL_LIST_INIT(outpost_admin_prison_crew_modes, list("auto" = null, "home" = T end_fight(brawl) if(riot_active) end_riot() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.stat == DEAD || prisoner.phase == PRISONER_LEAVING) continue prisoner.cancel_threat() @@ -651,10 +648,10 @@ GLOBAL_LIST_INIT(outpost_admin_prison_crew_modes, list("auto" = null, "home" = T return count /// The nearest other prisoner who could fight, for the admin fight button -/datum/outpost_prison/proc/nearest_fight_partner(mob/living/basic/outpost_prisoner/prisoner) - var/mob/living/basic/outpost_prisoner/nearest +/datum/outpost_prison/proc/nearest_fight_partner(mob/living/carbon/human/npc/outpost_prisoner/prisoner) + var/mob/living/carbon/human/npc/outpost_prisoner/nearest var/nearest_distance = INFINITY - for(var/mob/living/basic/outpost_prisoner/other in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/other in prisoners) if(other == prisoner || !other.can_join_riot() || other.trouble) continue var/distance = get_dist(prisoner, other) @@ -664,10 +661,10 @@ GLOBAL_LIST_INIT(outpost_admin_prison_crew_modes, list("auto" = null, "home" = T return nearest /// What the admin panel shows as their state -/mob/living/basic/outpost_prisoner/proc/trouble_state() +/mob/living/carbon/human/npc/outpost_prisoner/proc/trouble_state() if(trouble == PRISONER_TROUBLE_LOOSE) return "loose" - if(beaten_left > 0) + if(beaten) return "beaten" // is_rioting() covers a breakout too; the panel tells them apart, as admin_activity_text() does if(trouble == PRISONER_TROUBLE_BREAKOUT) @@ -680,7 +677,7 @@ GLOBAL_LIST_INIT(outpost_admin_prison_crew_modes, list("auto" = null, "home" = T return trouble || "normal" /// Seconds left loose, shown only while they are out of the cell block -/mob/living/basic/outpost_prisoner/proc/loose_seconds_shown() +/mob/living/carbon/human/npc/outpost_prisoner/proc/loose_seconds_shown() if(trouble != PRISONER_TROUBLE_LOOSE || stat == DEAD || prison?.in_cell_block(src)) return null return max(0, round(loose_left)) diff --git a/voidcrew/modules/player_outposts/outpost_npc_looks.dm b/voidcrew/modules/player_outposts/outpost_npc_looks.dm index d31bce7a67e..288938ffd8a 100644 --- a/voidcrew/modules/player_outposts/outpost_npc_looks.dm +++ b/voidcrew/modules/player_outposts/outpost_npc_looks.dm @@ -1,8 +1,13 @@ /** * # Outpost NPC looks * - * Human-looking basic mobs on outposts (prisoners, guards, and ambient NPCs) wear an outfit on - * a human body. tg's set_dynamic_human_appearance() builds that body on a fixed, bald, pale dummy + * Two kinds of look live here. + * + * Faces for real bodies (/datum/outpost_npc_look, at the bottom of the file): ambient NPCs are real + * human bodies and wear one randomly rolled face for life; what they hold is a real item in hand. + * + * Dressed appearances for the basic mobs that still copy a picture of a person onto themselves + * (the rest of the file): they wear an outfit on a human body. tg's set_dynamic_human_appearance() builds that body on a fixed, bald, pale dummy * and caches one appearance per outfit, so everyone in the same outfit has the same face and a * male body whatever their gender. * @@ -193,6 +198,83 @@ GLOBAL_LIST_EMPTY(outpost_npc_looks) return style_name return null +// ========================================================================= +// FACES FOR REAL BODIES +// ========================================================================= + +/** + * One person's face, kept as the features a real human body needs to look like them: gender and + * physique, skin tone, hair and facial hair (styles and colours) and eye colour. Ambient NPCs are + * human bodies (voidcrew/modules/ambient_npcs/); each rolls one of these when it is made and wears + * it for life, so the same person shows idle, holding a mop, welding, and dead. Strays keep theirs + * across visits (stray_identity()), so the same person comes back. The appearance cache above is + * for the basic mobs that still copy a dressed look onto themselves (bounty companions and goons). + */ +/datum/outpost_npc_look + /// MALE or FEMALE (also the body's physique) + var/gender = MALE + var/skin_tone = "caucasian1" + var/hairstyle = "Bald" + var/hair_color = "#000000" + var/facial_hairstyle = "Shaved" + var/facial_hair_color = "#000000" + var/eye_color = "#000000" + +/// A random person of `gender` (MALE or FEMALE; anything else is male), rolled the way randomize_human_normie() rolls one +/proc/new_outpost_npc_person(gender = MALE) + var/datum/outpost_npc_look/person = new + person.gender = gender == FEMALE ? FEMALE : MALE + person.skin_tone = pick(GLOB.skin_tones) + person.hairstyle = outpost_npc_hairstyle(person.gender) || "Bald" + if(person.gender == MALE && prob(OUTPOST_NPC_FACIAL_HAIR_CHANCE)) + person.facial_hairstyle = outpost_npc_facial_hairstyle() || "Shaved" + person.hair_color = random_hair_color() + person.facial_hair_color = person.hair_color + person.eye_color = random_eye_color() + return person + +/// The face `body` wears now, as a look that can be put on another body +/proc/outpost_npc_look_of(mob/living/carbon/human/body) + var/datum/outpost_npc_look/person = new + person.gender = body.gender == FEMALE ? FEMALE : MALE + person.skin_tone = body.skin_tone + person.hairstyle = body.hairstyle + person.hair_color = body.hair_color + person.facial_hairstyle = body.facial_hairstyle + person.facial_hair_color = body.facial_hair_color + person.eye_color = body.eye_color_left + return person + +/// A copy, so two bodies never share one look datum +/datum/outpost_npc_look/proc/copy() + var/datum/outpost_npc_look/twin = new + twin.gender = gender + twin.skin_tone = skin_tone + twin.hairstyle = hairstyle + twin.hair_color = hair_color + twin.facial_hairstyle = facial_hairstyle + twin.facial_hair_color = facial_hair_color + twin.eye_color = eye_color + return twin + +/// Puts this face on `body`, undressed parts bare (no underwear), and redraws it +/datum/outpost_npc_look/proc/apply_to(mob/living/carbon/human/body) + if(QDELETED(body)) + return + body.gender = gender + body.physique = gender + body.skin_tone = skin_tone + body.set_hairstyle(hairstyle, update = FALSE) + body.set_haircolor(hair_color, update = FALSE) + body.set_facial_hairstyle(facial_hairstyle, update = FALSE) + body.set_facial_haircolor(facial_hair_color, update = FALSE) + body.set_eye_color(eye_color) + body.underwear = "Nude" + body.undershirt = "Nude" + body.socks = "Nude" + // Without is_creating the limbs keep the skin tone they were made with + body.update_body(is_creating = TRUE) + #undef OUTPOST_NPC_LOOK_COUNT #undef OUTPOST_NPC_FACIAL_HAIR_CHANCE #undef OUTPOST_NPC_HELD_LOOKS_MAX diff --git a/voidcrew/modules/player_outposts/outpost_prison_ambience.dm b/voidcrew/modules/player_outposts/outpost_prison_ambience.dm index b85a6cd7f75..d6756ea9640 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_ambience.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_ambience.dm @@ -23,7 +23,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_examine_placeholders, list("{They}", "{they}", // ===== THE PRISONER ===== -/mob/living/basic/outpost_prisoner +/mob/living/carbon/human/npc/outpost_prisoner /// Picks their examine line within a mood band, so looking twice reads the same var/ambience_examine_seed = 0 /// Running after they turned to look at staff coming in, after humming, and after a whisper in a huddle @@ -32,14 +32,14 @@ GLOBAL_LIST_INIT(outpost_prisoner_examine_placeholders, list("{They}", "{they}", COOLDOWN_DECLARE(ambience_huddle_cooldown) /// Hooks up the prisoner's side of the ambience; called from setup_extras(). Nothing needs hooking: the prison drives it from its tick, and examine is the override below. -/mob/living/basic/outpost_prisoner/proc/setup_ambience() +/mob/living/carbon/human/npc/outpost_prisoner/proc/setup_ambience() return /** * Their mood in words, by band and personality, and one line on how they are kept when something * shows (hurt, a dirty jumpsuit, shut in, due out), then every package's own lines. Never a number. */ -/mob/living/basic/outpost_prisoner/examine(mob/user) +/mob/living/carbon/human/npc/outpost_prisoner/examine(mob/user) . = ..() if(stat == DEAD || phase != PRISONER_PRESENT) return @@ -54,7 +54,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_examine_placeholders, list("{They}", "{they}", . += span_notice(line) /// A closer look: what they are in for, their cell, roughly how long they have left, and their birthday until the yard has had the cake -/mob/living/basic/outpost_prisoner/examine_more(mob/user) +/mob/living/carbon/human/npc/outpost_prisoner/examine_more(mob/user) . = ..() if(stat == DEAD || !prison) return @@ -69,14 +69,14 @@ GLOBAL_LIST_INIT(outpost_prisoner_examine_placeholders, list("{They}", "{they}", . += span_notice("It's [p_their()] birthday today.") /// "a few minutes" or "about 25 minutes": their sentence left, rounded to OUTPOST_PRISONER_EXAMINE_ROUND_MINUTES -/mob/living/basic/outpost_prisoner/proc/sentence_examine_text() +/mob/living/carbon/human/npc/outpost_prisoner/proc/sentence_examine_text() var/minutes = sentence_left / 60 if(minutes < OUTPOST_PRISONER_EXAMINE_ROUND_MINUTES) return "a few minutes" return "about [round(minutes, OUTPOST_PRISONER_EXAMINE_ROUND_MINUTES)] minutes" /// The "examine" key for their mood: the bands match the angry, threat, climb and tidy lines -/mob/living/basic/outpost_prisoner/proc/mood_examine_band() +/mob/living/carbon/human/npc/outpost_prisoner/proc/mood_examine_band() if(mood < PRISONER_THREAT_ANGRY_MOOD) return "mood_0" if(mood < PRISONER_THREAT_MOOD) @@ -88,7 +88,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_examine_placeholders, list("{They}", "{they}", return "mood_75" /// A line on their mood, filled in, or null. Their own personality's lines come up more often than the shared ones. -/mob/living/basic/outpost_prisoner/proc/mood_examine_line() +/mob/living/carbon/human/npc/outpost_prisoner/proc/mood_examine_line() var/list/bands = outpost_prisoner_extra_dialogue("outpost_prison_security.json", "examine") var/list/band = bands[mood_examine_band()] if(!islist(band)) @@ -105,7 +105,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_examine_placeholders, list("{They}", "{they}", return fill_examine_line(pool[(ambience_examine_seed % length(pool)) + 1]) /// Fills an examine line's pronouns ({They}, {their}, ...) and verb endings ({s}, {es}) for them -/mob/living/basic/outpost_prisoner/proc/fill_examine_line(line) +/mob/living/carbon/human/npc/outpost_prisoner/proc/fill_examine_line(line) if(!istext(line)) return null line = replacetextEx(line, "{They}", p_They()) @@ -118,7 +118,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_examine_placeholders, list("{They}", "{they}", return line /// One line on how they are kept, the most pressing first, or null when nothing shows -/mob/living/basic/outpost_prisoner/proc/state_examine_line() +/mob/living/carbon/human/npc/outpost_prisoner/proc/state_examine_line() var/health_percent = health_factor() if(health_percent < PRISONER_BLEED_BELOW) return "[p_They()] look[p_s()] badly hurt." @@ -190,7 +190,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_examine_placeholders, list("{They}", "{they}", /// Whether another prisoner is too close to `tile` to sulk there /datum/prisoner_activity/sulk/proc/sulk_company_near(turf/tile) - for(var/mob/living/basic/outpost_prisoner/other in prisoner.prison.prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/other in prisoner.prison.prisoners) if(other != prisoner && get_dist(other, tile) <= OUTPOST_PRISONER_SULK_ALONE_RANGE) return TRUE return FALSE @@ -242,7 +242,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_examine_placeholders, list("{They}", "{they}", * wing); TRUE drops it. Small talk, remarks to staff, conversations and chatter about what they * are doing go quiet; complaints and threats about the wing still get said. */ -/datum/outpost_prison/proc/speech_hushed(mob/living/basic/outpost_prisoner/speaker, context) +/datum/outpost_prison/proc/speech_hushed(mob/living/carbon/human/npc/outpost_prisoner/speaker, context) if(stage != PRISON_STAGE_RESTLESS) return FALSE var/static/list/always_hushed = list("idle", "staff_near", "conversation") @@ -289,7 +289,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_examine_placeholders, list("{They}", "{they}", var/spoken = FALSE var/emotes = 0 var/reacted = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in shuffle(prisoners)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in shuffle(prisoners)) if(!prisoner.ai_running() || !prisoner.routine_allowed() || prisoner.activity?.sleeping) continue if(!COOLDOWN_FINISHED(prisoner, ambience_notice_cooldown)) @@ -322,12 +322,12 @@ GLOBAL_LIST_INIT(outpost_prisoner_examine_placeholders, list("{They}", "{they}", return reacted /// A chat they are in waits a moment while they look over -/datum/outpost_prison/proc/pause_chat_for_notice(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/pause_chat_for_notice(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/datum/prisoner_activity/chat/talk = prisoner.activity if(!istype(talk)) return if(istype(talk, /datum/prisoner_activity/chat/listen)) - var/mob/living/basic/outpost_prisoner/talker = talk.chat_partner() + var/mob/living/carbon/human/npc/outpost_prisoner/talker = talk.chat_partner() talk = talker?.activity if(!istype(talk) || istype(talk, /datum/prisoner_activity/chat/listen)) return @@ -338,7 +338,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_examine_placeholders, list("{They}", "{they}", /// Content prisoners now and then hum; while the wing is restless, the ones gathered in the yard whisper among themselves /datum/outpost_prison/proc/yard_sounds_tick(seconds) var/huddling = stage == PRISON_STAGE_RESTLESS && !riot_imminent && !riot_active - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.phase != PRISONER_PRESENT || prisoner.stat != CONSCIOUS || !prisoner.ai_running()) continue if(huddling && istype(prisoner.activity, /datum/prisoner_activity/gather)) @@ -352,7 +352,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_examine_placeholders, list("{They}", "{they}", * A content cheerful, chatty or quiet prisoner, awake and free, hums to themself, at most once per * OUTPOST_PRISONER_HUM_COOLDOWN. Returns TRUE if they did. */ -/datum/outpost_prison/proc/try_hum(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/try_hum(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/static/list/hummers = list("cheerful", "chatty", "quiet") if(prisoner.mood < OUTPOST_PRISONER_HUM_MOOD || !(prisoner.personality in hummers)) return FALSE @@ -364,7 +364,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_examine_placeholders, list("{They}", "{they}", return TRUE /// A gathered prisoner whispers a huddle line, at most once per OUTPOST_PRISONER_HUDDLE_GAP. Returns TRUE if they did. -/datum/outpost_prison/proc/try_huddle(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/try_huddle(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(!COOLDOWN_FINISHED(prisoner, ambience_huddle_cooldown)) return FALSE var/line = prisoner.pick_line("huddle") @@ -404,7 +404,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_examine_placeholders, list("{They}", "{they}", ambience_chant_beats++ var/list/gathered = list() var/list/slammers = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in shuffle(prisoners)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in shuffle(prisoners)) var/datum/prisoner_activity/gather/gathering = prisoner.activity if(!istype(gathering) || !gathering.started || gathering.spot || !prisoner.ai_running() || !prisoner.routine_allowed()) continue @@ -421,12 +421,12 @@ GLOBAL_LIST_INIT(outpost_prisoner_examine_placeholders, list("{They}", "{they}", if(!(ambience_chant_beats % OUTPOST_PRISON_CHANT_LINE_EVERY)) var/list/voices = length(slammers) ? slammers : gathered if(length(voices)) - var/mob/living/basic/outpost_prisoner/voice = pick(voices) + var/mob/living/carbon/human/npc/outpost_prisoner/voice = pick(voices) voice.say_context("riot_chant") return slammers /// A mess table or a door beside `prisoner` to slam on, or null -/datum/outpost_prison/proc/chant_surface(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/chant_surface(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/turf/here = get_turf(prisoner) for(var/direction in GLOB.cardinals) var/turf/beside = get_step(here, direction) @@ -450,7 +450,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_examine_placeholders, list("{They}", "{they}", return 0 ambience_roared = TRUE var/roared = 0 - for(var/mob/living/basic/outpost_prisoner/rioter in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/rioter in prisoners) if(!rioter.is_rioting() || rioter.stat != CONSCIOUS || rioter.phase != PRISONER_PRESENT || !rioter.ai_running()) continue if(rioter.say_context("riot_roar")) diff --git a/voidcrew/modules/player_outposts/outpost_prison_boss_moves.dm b/voidcrew/modules/player_outposts/outpost_prison_boss_moves.dm index 3e259912edc..918d96de83f 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_boss_moves.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_boss_moves.dm @@ -49,11 +49,11 @@ /// Weakrefs to guards the kingpin paid off, until they are back at work var/list/boss_bribed_guards = list() -/mob/living/basic/outpost_prisoner +/mob/living/carbon/human/npc/outpost_prisoner /// Their riot move, made the first time a riot needs it (boss_move_datum()), or null var/datum/prison_boss_move/boss_move -/mob/living/basic/outpost_prison_guard +/mob/living/carbon/human/npc/outpost_prison_guard /// world.time until which they stay out of a riot, paid off by the kingpin var/prison_bribed_until = 0 @@ -88,7 +88,7 @@ boss_bribes_tick() if(!trouble_enabled || !riot_active) return - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) var/datum/prison_boss_move/move = prisoner.boss_move_datum() if(!move) continue @@ -96,7 +96,7 @@ move.try_start() /// A prisoner is leaving the roster (extras_prisoner_leaving()): their move stops -/datum/outpost_prison/proc/boss_moves_prisoner_leaving(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/boss_moves_prisoner_leaving(mob/living/carbon/human/npc/outpost_prisoner/prisoner) QDEL_NULL(prisoner.boss_move) /// The prison is being deleted (extras_destroy()) @@ -108,25 +108,25 @@ * cell, past the riot's wind-up, awake and on their feet, not held, climbing or batoned, with a member * of the wing home and someone on the level. Uncuffed, or cuffed if `cuffed`. */ -/datum/outpost_prison/proc/boss_riot_ok(mob/living/basic/outpost_prisoner/prisoner, cuffed = FALSE) +/datum/outpost_prison/proc/boss_riot_ok(mob/living/carbon/human/npc/outpost_prisoner/prisoner, cuffed = FALSE) if(!trouble_enabled || !riot_active || riot_windup_left > 0 || !crew_home()) return FALSE if(QDELETED(prisoner) || prisoner.prison != src || prisoner.stat != CONSCIOUS || !prisoner.riot_at_large()) return FALSE if(!in_cell_block(prisoner) || !isturf(prisoner.loc) || !prisoner.ai_running()) return FALSE - if(prisoner.is_down() || prisoner.pulledby || prisoner.climb_ref || prisoner.beaten_left > 0 || prisoner.surrendered_to_turret() || world.time < prisoner.baton_stop_until) + if(prisoner.is_down() || prisoner.pulledby || prisoner.climb_ref || prisoner.is_beaten() || prisoner.surrendered_to_turret() || world.time < prisoner.baton_stop_until) return FALSE - return cuffed ? !!prisoner.cuffs : !prisoner.cuffs + return cuffed ? !!prisoner.handcuffed : !prisoner.handcuffed /// Whether a move of `prisoner`'s may land on `person`: awake staff the riot goes for, in the cell block where `prisoner` can get at them -/datum/outpost_prison/proc/boss_may_hit(mob/living/basic/outpost_prisoner/prisoner, mob/living/person) +/datum/outpost_prison/proc/boss_may_hit(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/person) if(QDELETED(person) || person == prisoner || !is_outpost_prison_staff(person)) return FALSE return in_cell_block(person) && !!prisoner.reachable?[get_turf(person)] /// The nearest staff a move of `prisoner`'s may land on (boss_may_hit()) within `range` and in sight, or null -/datum/outpost_prison/proc/boss_nearest_staff(mob/living/basic/outpost_prisoner/prisoner, range = PRISON_BOSS_SIGHT) +/datum/outpost_prison/proc/boss_nearest_staff(mob/living/carbon/human/npc/outpost_prisoner/prisoner, range = PRISON_BOSS_SIGHT) var/mob/living/nearest var/nearest_distance = INFINITY for(var/mob/living/person in view(range, prisoner)) @@ -151,7 +151,7 @@ // ===== THE PRISONER'S SIDE ===== /// Their riot move, made the first time it is asked for; null for anyone without one (bounty_boss_move_type()) -/mob/living/basic/outpost_prisoner/proc/boss_move_datum() +/mob/living/carbon/human/npc/outpost_prisoner/proc/boss_move_datum() if(boss_move) return boss_move var/move_type = bounty_boss_move_type(bounty_record) @@ -161,7 +161,7 @@ return boss_move /// Whether they are winding up or in the middle of their move (or reeling from it), so they hold still (trouble_target()) -/mob/living/basic/outpost_prisoner/proc/boss_move_busy() +/mob/living/carbon/human/npc/outpost_prisoner/proc/boss_move_busy() return !!boss_move && boss_move.busy_until > world.time // ===== A MOVE ===== @@ -174,7 +174,7 @@ * call finish_windup(pending_serial) instead of waiting. */ /datum/prison_boss_move - /// The prisoner whose move it is (/mob/living/basic/outpost_prisoner) + /// The prisoner whose move it is (/mob/living/carbon/human/npc/outpost_prisoner) var/datum/weakref/prisoner_ref /// How long it winds up, telegraphing, before anything happens var/windup = 1 SECONDS @@ -196,7 +196,7 @@ /// Weakrefs to the wind-up's marks still showing var/list/telegraphs -/datum/prison_boss_move/New(mob/living/basic/outpost_prisoner/owner) +/datum/prison_boss_move/New(mob/living/carbon/human/npc/outpost_prisoner/owner) . = ..() prisoner_ref = WEAKREF(owner) @@ -207,18 +207,18 @@ /// The prisoner, while they exist /datum/prison_boss_move/proc/owner() - var/mob/living/basic/outpost_prisoner/prisoner = prisoner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = prisoner_ref?.resolve() return QDELETED(prisoner) ? null : prisoner /// Every tick of a riot, before try_start(): anything the move keeps track of -/datum/prison_boss_move/proc/observe(mob/living/basic/outpost_prisoner/prisoner) +/datum/prison_boss_move/proc/observe(mob/living/carbon/human/npc/outpost_prisoner/prisoner) return /// Starts the move if it is ready, the boss may use it and there is something to use it on. Returns TRUE if it started. /datum/prison_boss_move/proc/try_start() if(pending_serial || world.time < busy_until || world.time < ready_at) return FALSE - var/mob/living/basic/outpost_prisoner/prisoner = owner() + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = owner() var/datum/outpost_prison/prison = prisoner?.prison if(!prison || (once_per_riot && used_in_riot == prison.boss_riot_serial)) return FALSE @@ -243,14 +243,14 @@ return TRUE /// Whether the boss is still free to finish the wind-up under way -/datum/prison_boss_move/proc/may_finish(mob/living/basic/outpost_prisoner/prisoner) +/datum/prison_boss_move/proc/may_finish(mob/living/carbon/human/npc/outpost_prisoner/prisoner) return !!prisoner?.prison?.boss_riot_ok(prisoner, needs_cuffs) /// During the wind-up: stopped if the boss is no longer free to finish it (knocked down, dragged, cuffed, out of the riot) /datum/prison_boss_move/proc/watch_windup(serial) if(!serial || serial != pending_serial) return FALSE - var/mob/living/basic/outpost_prisoner/prisoner = owner() + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = owner() if(!may_finish(prisoner)) cancel() interrupted(prisoner) @@ -266,7 +266,7 @@ if(!serial || serial != pending_serial) return FALSE var/atom/target = pending_target?.resolve() - var/mob/living/basic/outpost_prisoner/prisoner = owner() + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = owner() if(!may_finish(prisoner)) cancel() interrupted(prisoner) @@ -288,24 +288,24 @@ pending_target = null busy_until = 0 clear_telegraphs() - var/mob/living/basic/outpost_prisoner/prisoner = owner() + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = owner() if(prisoner) REMOVE_TRAIT(prisoner, TRAIT_IMMOBILIZED, PRISON_BOSS_MOVE_TRAIT) /// What the move goes for now, or null: a member of staff, or a thing near them -/datum/prison_boss_move/proc/find_target(mob/living/basic/outpost_prisoner/prisoner) +/datum/prison_boss_move/proc/find_target(mob/living/carbon/human/npc/outpost_prisoner/prisoner) return null /// Shows everyone what is coming, with a sound and a line -/datum/prison_boss_move/proc/telegraph(mob/living/basic/outpost_prisoner/prisoner, atom/target) +/datum/prison_boss_move/proc/telegraph(mob/living/carbon/human/npc/outpost_prisoner/prisoner, atom/target) return /// Does it. `target` may be gone by now. Returns TRUE if anything happened. -/datum/prison_boss_move/proc/effect(mob/living/basic/outpost_prisoner/prisoner, atom/target) +/datum/prison_boss_move/proc/effect(mob/living/carbon/human/npc/outpost_prisoner/prisoner, atom/target) return FALSE /// The wind-up was stopped before it finished -/datum/prison_boss_move/proc/interrupted(mob/living/basic/outpost_prisoner/prisoner) +/datum/prison_boss_move/proc/interrupted(mob/living/carbon/human/npc/outpost_prisoner/prisoner) return /// Marks `turfs` for the wind-up, with the field kits' floor marks @@ -340,7 +340,7 @@ return ..() /// The nearest staff in sight, PRISON_BOSS_CHARGE_MIN_RANGE to _RANGE tiles off, on a line he could run clear to them -/datum/prison_boss_move/charge/find_target(mob/living/basic/outpost_prisoner/prisoner) +/datum/prison_boss_move/charge/find_target(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/datum/outpost_prison/prison = prisoner.prison var/mob/living/best var/best_distance = INFINITY @@ -359,7 +359,7 @@ * The line from the boss toward `target`, PRISON_BOSS_CHARGE_RANGE tiles long: it stops at the first * wall, and never runs past the cell block's edge. */ -/datum/prison_boss_move/charge/proc/charge_line(mob/living/basic/outpost_prisoner/prisoner, atom/target) +/datum/prison_boss_move/charge/proc/charge_line(mob/living/carbon/human/npc/outpost_prisoner/prisoner, atom/target) . = list() var/datum/outpost_prison/prison = prisoner.prison var/turf/origin = get_turf(prisoner) @@ -382,7 +382,7 @@ break /// Whether the line toward `person` reaches them with nothing solid and nobody else before them -/datum/prison_boss_move/charge/proc/clear_run_to(mob/living/basic/outpost_prisoner/prisoner, mob/living/person) +/datum/prison_boss_move/charge/proc/clear_run_to(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/person) var/turf/aim = get_turf(person) for(var/turf/spot as anything in charge_line(prisoner, person)) if(spot == aim) @@ -392,14 +392,14 @@ return FALSE /// Whether a charge can run onto `spot`: in the cell block, ground the boss could walk, nothing solid on it -/datum/outpost_prison/proc/boss_run_tile_ok(mob/living/basic/outpost_prisoner/prisoner, turf/spot) +/datum/outpost_prison/proc/boss_run_tile_ok(mob/living/carbon/human/npc/outpost_prisoner/prisoner, turf/spot) if(!spot || spot.z != prisoner.z || isclosedturf(spot) || !in_cell_block(spot) || !prisoner.walkable?[spot]) return FALSE if(isgroundlessturf(spot) || islava(spot) || ischasm(spot)) return FALSE return !spot.is_blocked_turf(exclude_mobs = TRUE) -/datum/prison_boss_move/charge/telegraph(mob/living/basic/outpost_prisoner/prisoner, atom/target) +/datum/prison_boss_move/charge/telegraph(mob/living/carbon/human/npc/outpost_prisoner/prisoner, atom/target) path = charge_line(prisoner, target) prisoner.visible_message(span_boldwarning("[prisoner] drops [prisoner.p_their()] shoulder and lowers [prisoner.p_their()] head!")) playsound(prisoner, 'sound/mobs/non-humanoids/gorilla/gorilla.ogg', 60, TRUE) @@ -407,7 +407,7 @@ mark_turfs(path, "#c8a060") prisoner.say_context("boss_move_charge") -/datum/prison_boss_move/charge/effect(mob/living/basic/outpost_prisoner/prisoner, atom/target) +/datum/prison_boss_move/charge/effect(mob/living/carbon/human/npc/outpost_prisoner/prisoner, atom/target) if(!length(path) || get_dist(prisoner, path[1]) > 1) path = null return FALSE @@ -427,7 +427,7 @@ * slams into it and reels. Nothing is broken, and he never leaves the cell block. */ /datum/prison_boss_move/charge/proc/charge_step(serial) - var/mob/living/basic/outpost_prisoner/prisoner = owner() + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = owner() var/datum/outpost_prison/prison = prisoner?.prison if(!serial || serial != charge_serial || !prison || !prison.boss_riot_ok(prisoner)) end_charge() @@ -452,7 +452,7 @@ addtimer(CALLBACK(src, PROC_REF(charge_step), serial), PRISON_BOSS_CHARGE_STEP, TIMER_DELETE_ME) /// Knocks `person` off their feet: brute through melee armour and a knockdown (a guard, who can't be knocked down, takes the blow) -/datum/prison_boss_move/charge/proc/slam_into(mob/living/basic/outpost_prisoner/prisoner, mob/living/person) +/datum/prison_boss_move/charge/proc/slam_into(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/person) prisoner.face_atom(person) prisoner.do_attack_animation(person, ATTACK_EFFECT_SMASH) person.visible_message(span_danger("[prisoner] slams into [person]!"), span_userdanger("[prisoner] slams into you!")) @@ -463,7 +463,7 @@ log_combat(prisoner, person, "shoulder-charged") /// Ran into something solid on `spot`: stopped dead, reeling for PRISON_BOSS_CHARGE_REEL. It takes no harm. -/datum/prison_boss_move/charge/proc/bounce(mob/living/basic/outpost_prisoner/prisoner, turf/spot) +/datum/prison_boss_move/charge/proc/bounce(mob/living/carbon/human/npc/outpost_prisoner/prisoner, turf/spot) end_charge() if(prisoner.stat != CONSCIOUS) return @@ -502,7 +502,7 @@ return ..() /// A bunk within PRISON_BOSS_FIRE_RANGE tiles, in sight with nothing in the way, with staff standing where it would burn -/datum/prison_boss_move/bed_fire/find_target(mob/living/basic/outpost_prisoner/prisoner) +/datum/prison_boss_move/bed_fire/find_target(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(fire_ref?.resolve()) return null var/datum/outpost_prison/prison = prisoner.prison @@ -533,14 +533,14 @@ continue . += beside -/datum/prison_boss_move/bed_fire/telegraph(mob/living/basic/outpost_prisoner/prisoner, atom/target) +/datum/prison_boss_move/bed_fire/telegraph(mob/living/carbon/human/npc/outpost_prisoner/prisoner, atom/target) patch = prisoner.prison.boss_fire_patch(target) prisoner.visible_message(span_boldwarning("[prisoner] strikes a match and eyes [target].")) playsound(prisoner, 'sound/items/match_strike.ogg', 60, TRUE) mark_turfs(patch, "#ff5a1f", "target_circle") prisoner.say_context("boss_move_fire") -/datum/prison_boss_move/bed_fire/effect(mob/living/basic/outpost_prisoner/prisoner, atom/target) +/datum/prison_boss_move/bed_fire/effect(mob/living/carbon/human/npc/outpost_prisoner/prisoner, atom/target) var/obj/structure/bed/bunk = target var/list/burning = patch patch = null @@ -618,7 +618,7 @@ * The way out of the cell block he is breaking now, beside him, once the riot's blows have been at it * (note_exit_attacked()): a staff door, a serving hatch not yet open, or a window. Never anything else. */ -/datum/prison_boss_move/rigged_charge/find_target(mob/living/basic/outpost_prisoner/prisoner) +/datum/prison_boss_move/rigged_charge/find_target(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/datum/outpost_prison/prison = prisoner.prison var/obj/target = prisoner.riot_target_ref?.resolve() if(!isobj(target) || !prison.is_exit_blocker(target) || !prisoner.within_reach(target)) @@ -630,13 +630,13 @@ return null return target -/datum/prison_boss_move/rigged_charge/telegraph(mob/living/basic/outpost_prisoner/prisoner, atom/target) +/datum/prison_boss_move/rigged_charge/telegraph(mob/living/carbon/human/npc/outpost_prisoner/prisoner, atom/target) prisoner.visible_message(span_boldwarning("[prisoner] crouches by [target] and packs something against it.")) playsound(prisoner, 'sound/machines/click.ogg', 60, TRUE) mark_turfs(list(get_turf(target)), COLOR_RED) prisoner.say_context("boss_move_rig") -/datum/prison_boss_move/rigged_charge/effect(mob/living/basic/outpost_prisoner/prisoner, atom/target) +/datum/prison_boss_move/rigged_charge/effect(mob/living/carbon/human/npc/outpost_prisoner/prisoner, atom/target) var/datum/outpost_prison/prison = prisoner.prison if(QDELETED(target) || !prison.is_exit_blocker(target)) return FALSE @@ -746,48 +746,56 @@ /// world.time they were first seen cuffed this time, 0 while they are not var/cuffed_at = 0 -/datum/prison_boss_move/slip_cuffs/observe(mob/living/basic/outpost_prisoner/prisoner) - if(!prisoner.cuffs) +/datum/prison_boss_move/slip_cuffs/observe(mob/living/carbon/human/npc/outpost_prisoner/prisoner) + if(!prisoner.handcuffed) cuffed_at = 0 else if(!cuffed_at) cuffed_at = world.time /// Their cuffs, once they have worn them PRISON_BOSS_SLIP_DELAY, with staff in sight to get away from -/datum/prison_boss_move/slip_cuffs/find_target(mob/living/basic/outpost_prisoner/prisoner) - if(!prisoner.cuffs || !cuffed_at || world.time - cuffed_at < PRISON_BOSS_SLIP_DELAY) +/datum/prison_boss_move/slip_cuffs/find_target(mob/living/carbon/human/npc/outpost_prisoner/prisoner) + if(!prisoner.handcuffed || !cuffed_at || world.time - cuffed_at < PRISON_BOSS_SLIP_DELAY) return null if(!prisoner.prison.boss_nearest_staff(prisoner)) return null - return prisoner.cuffs + return prisoner.handcuffed -/datum/prison_boss_move/slip_cuffs/may_finish(mob/living/basic/outpost_prisoner/prisoner) - return ..() && prisoner.cuffs == pending_target?.resolve() +/datum/prison_boss_move/slip_cuffs/may_finish(mob/living/carbon/human/npc/outpost_prisoner/prisoner) + return ..() && prisoner.handcuffed == pending_target?.resolve() -/datum/prison_boss_move/slip_cuffs/telegraph(mob/living/basic/outpost_prisoner/prisoner, atom/target) +/datum/prison_boss_move/slip_cuffs/telegraph(mob/living/carbon/human/npc/outpost_prisoner/prisoner, atom/target) prisoner.visible_message(span_boldwarning("[prisoner] starts twisting at [target], working a hand loose.")) playsound(prisoner, 'sound/items/weapons/handcuffs.ogg', 40, TRUE) prisoner.Shake(1, 0, windup) prisoner.say_context("boss_move_slip") -/datum/prison_boss_move/slip_cuffs/interrupted(mob/living/basic/outpost_prisoner/prisoner) - if(prisoner?.stat == CONSCIOUS && prisoner.cuffs) - prisoner.visible_message(span_notice("[prisoner] loses [prisoner.p_their()] grip on [prisoner.cuffs].")) +/datum/prison_boss_move/slip_cuffs/interrupted(mob/living/carbon/human/npc/outpost_prisoner/prisoner) + if(prisoner?.stat == CONSCIOUS && prisoner.handcuffed) + prisoner.visible_message(span_notice("[prisoner] loses [prisoner.p_their()] grip on [prisoner.handcuffed].")) -/datum/prison_boss_move/slip_cuffs/effect(mob/living/basic/outpost_prisoner/prisoner, atom/target) - var/obj/item/restraints/handcuffs/worn = prisoner.cuffs +/** + * After the telegraph, they work at the cuffs the way anyone does (tg's cuff_resist(): the cuffs' own + * breakout time, broken by being moved or knocked down). Out of them, they slip away in a shimmer. + */ +/datum/prison_boss_move/slip_cuffs/effect(mob/living/carbon/human/npc/outpost_prisoner/prisoner, atom/target) + var/obj/item/restraints/handcuffs/worn = prisoner.handcuffed if(!worn || worn != target) return FALSE - // Without a user they drop where they stand: the same cuffs, on the floor - prisoner.remove_cuffs() + INVOKE_ASYNC(src, PROC_REF(work_free), prisoner, worn) + return TRUE + +/datum/prison_boss_move/slip_cuffs/proc/work_free(mob/living/carbon/human/npc/outpost_prisoner/prisoner, obj/item/restraints/handcuffs/worn) + prisoner.cuff_resist(worn) + if(QDELETED(prisoner) || prisoner.handcuffed == worn || prisoner.stat != CONSCIOUS) + return prisoner.visible_message(span_danger("[prisoner] slips out of [worn]!")) playsound(prisoner, 'sound/effects/magic/smoke.ogg', 40, TRUE) prisoner.apply_status_effect(/datum/status_effect/prison_boss_shimmer) - return TRUE /** - * The shimmer after a Ghost slips their cuffs, as the field cloak: faint and blurred for - * PRISON_BOSS_SHIMMER_TIME, and PRISON_BOSS_SHIMMER_MISS percent of blows, throws and shots miss. A hit - * that lands or a flash ends it. + * The shimmer after a Ghost slips their cuffs: faint and blurred for PRISON_BOSS_SHIMMER_TIME, a look + * and nothing more. A Ghost's dodging is their real chrome (a Slipwire shunt, outpost_prison_bounty.dm; + * owner ruling OC-6), which works with the shimmer or without it. A hit that lands or a flash ends it. */ /datum/status_effect/prison_boss_shimmer id = "prison_boss_shimmer" @@ -797,48 +805,24 @@ alert_type = null /// Broken by a hit or a flash, which says so itself var/broken = FALSE - /// The miss message shows at most every second, so a burst of fire doesn't flood chat - COOLDOWN_DECLARE(miss_message_cooldown) /datum/status_effect/prison_boss_shimmer/on_apply() if(owner.stat != CONSCIOUS) return FALSE animate(owner, alpha = PRISON_BOSS_SHIMMER_ALPHA, time = 0.3 SECONDS) owner.add_filter("prison_boss_shimmer", 2, list("type" = "blur", "size" = 1)) - RegisterSignal(owner, COMSIG_LIVING_CHECK_BLOCK, PROC_REF(on_check_block)) - RegisterSignal(owner, COMSIG_PROJECTILE_PREHIT, PROC_REF(on_prehit)) RegisterSignal(owner, COMSIG_MOB_AFTER_APPLY_DAMAGE, PROC_REF(on_damaged)) RegisterSignal(owner, COMSIG_MOB_FLASHED, PROC_REF(on_flashed)) owner.visible_message(span_warning("[owner] fades into a faint shimmer!")) return TRUE /datum/status_effect/prison_boss_shimmer/on_remove() - UnregisterSignal(owner, list(COMSIG_LIVING_CHECK_BLOCK, COMSIG_PROJECTILE_PREHIT, COMSIG_MOB_AFTER_APPLY_DAMAGE, COMSIG_MOB_FLASHED)) + UnregisterSignal(owner, list(COMSIG_MOB_AFTER_APPLY_DAMAGE, COMSIG_MOB_FLASHED)) animate(owner, alpha = 255, time = 0.3 SECONDS) owner.remove_filter("prison_boss_shimmer") if(!broken && owner.stat != DEAD) owner.visible_message(span_notice("The shimmer around [owner] fades.")) -/datum/status_effect/prison_boss_shimmer/proc/miss_message(message) - if(!COOLDOWN_FINISHED(src, miss_message_cooldown)) - return - COOLDOWN_START(src, miss_message_cooldown, 1 SECONDS) - owner.visible_message(message) - -/datum/status_effect/prison_boss_shimmer/proc/on_check_block(mob/living/source, atom/hit_by, damage, attack_text, attack_type, armour_penetration, damage_type) - SIGNAL_HANDLER - if(owner.stat != CONSCIOUS || !prob(PRISON_BOSS_SHIMMER_MISS)) - return NONE - miss_message(span_warning("[attack_text] passes through the shimmer where [owner] was!")) - return SUCCESSFUL_BLOCK - -/datum/status_effect/prison_boss_shimmer/proc/on_prehit(mob/living/source, obj/projectile/shot) - SIGNAL_HANDLER - if(shot.firer == owner || owner.stat != CONSCIOUS || !prob(PRISON_BOSS_SHIMMER_MISS)) - return NONE - miss_message(span_warning("[shot] passes through the shimmer around [owner]!")) - return PROJECTILE_INTERRUPT_HIT_PHASE - /datum/status_effect/prison_boss_shimmer/proc/on_damaged(mob/living/source, damage, damagetype) SIGNAL_HANDLER if(damage <= 0 || broken) @@ -879,7 +863,7 @@ * The nearest table beside him that tg lets be flipped, to go over toward the nearest staff in sight; * failing that, a locker beside him to shove into the doorway of a staff door staff are coming through. */ -/datum/prison_boss_move/barricade/find_target(mob/living/basic/outpost_prisoner/prisoner) +/datum/prison_boss_move/barricade/find_target(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/datum/outpost_prison/prison = prisoner.prison var/mob/living/nearest = prison.boss_staff_about(prisoner, PRISON_BOSS_BARRICADE_SIGHT) if(!nearest) @@ -905,7 +889,7 @@ return null /// The nearest awake staff in sight within `range` anywhere in the wing, the office included: who a barricade is against -/datum/outpost_prison/proc/boss_staff_about(mob/living/basic/outpost_prisoner/prisoner, range) +/datum/outpost_prison/proc/boss_staff_about(mob/living/carbon/human/npc/outpost_prisoner/prisoner, range) var/mob/living/nearest var/nearest_distance = INFINITY for(var/mob/living/person in view(range, prisoner)) @@ -941,7 +925,7 @@ return FALSE /// The tile straight in front of the staff door on `door_tile`, on the yard side, that `prisoner` can walk and nothing stands on, or null -/datum/outpost_prison/proc/boss_doorway_front(turf/door_tile, mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/boss_doorway_front(turf/door_tile, mob/living/carbon/human/npc/outpost_prisoner/prisoner) for(var/direction in GLOB.cardinals) var/turf/front = get_step(door_tile, direction) if(!front || !cell_block[front] || isclosedturf(front) || !prisoner.walkable?[front] || front.is_blocked_turf()) @@ -950,7 +934,7 @@ return null /// Whether a heavy may shove `locker`: a shut locker or crate, loose on the floor, in the cell block where `prisoner` can get at it, and not outpost property -/datum/outpost_prison/proc/boss_locker_shovable(obj/structure/closet/locker, mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/boss_locker_shovable(obj/structure/closet/locker, mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(QDELETED(locker) || locker.anchored || !locker.density || !isturf(locker.loc)) return FALSE if((locker.resistance_flags & INDESTRUCTIBLE) || HAS_TRAIT(locker, TRAIT_OUTPOST_PROPERTY)) @@ -961,7 +945,7 @@ /datum/outpost_prison/proc/boss_shove_tile_ok(turf/spot) return spot && cell_block[spot] && !isclosedturf(spot) && prisoner_can_stand(spot) && !spot.is_blocked_turf() -/datum/prison_boss_move/barricade/telegraph(mob/living/basic/outpost_prisoner/prisoner, atom/target) +/datum/prison_boss_move/barricade/telegraph(mob/living/carbon/human/npc/outpost_prisoner/prisoner, atom/target) if(shove_to) shove_ref = WEAKREF(target) prisoner.visible_message(span_boldwarning("[prisoner] puts [prisoner.p_their()] shoulder to [target].")) @@ -973,7 +957,7 @@ mark_turfs(list(get_turf(target)), "#c0c0c0") prisoner.say_context("boss_move_barricade") -/datum/prison_boss_move/barricade/effect(mob/living/basic/outpost_prisoner/prisoner, atom/target) +/datum/prison_boss_move/barricade/effect(mob/living/carbon/human/npc/outpost_prisoner/prisoner, atom/target) var/datum/outpost_prison/prison = prisoner.prison if(shove_to) var/obj/structure/closet/locker = target @@ -1000,7 +984,7 @@ * It stops in the doorway, at anything or anyone in the way, or when the heavy can't follow. */ /datum/prison_boss_move/barricade/proc/shove_step(serial) - var/mob/living/basic/outpost_prisoner/prisoner = owner() + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = owner() var/datum/outpost_prison/prison = prisoner?.prison var/obj/structure/closet/locker = shove_ref?.resolve() if(!serial || serial != shove_serial || !prison || !prison.boss_riot_ok(prisoner) || QDELETED(locker) || !shove_to) @@ -1042,9 +1026,9 @@ boss_riot_serial++ if(forced_riot || !crew_home()) return joining - var/mob/living/basic/outpost_prisoner/kingpin - for(var/mob/living/basic/outpost_prisoner/prisoner as anything in joining) - if(prisoner.bounty_record?.archetype != BOUNTY_ARCHETYPE_KINGPIN || prisoner.stat != CONSCIOUS || prisoner.cuffs) + var/mob/living/carbon/human/npc/outpost_prisoner/kingpin + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner as anything in joining) + if(prisoner.bounty_record?.archetype != BOUNTY_ARCHETYPE_KINGPIN || prisoner.stat != CONSCIOUS || prisoner.handcuffed) continue if(!in_cell_block(prisoner) || prisoner.is_confined() || !prisoner.ai_running()) continue @@ -1053,7 +1037,7 @@ if(!kingpin) return joining var/list/swayed = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if((prisoner in joining) || !prisoner.can_join_riot()) continue if(prisoner.mood < prisoner.riot_join_mood() + PRISON_BOSS_WORD_BONUS) @@ -1070,11 +1054,11 @@ once_per_riot = TRUE /// The nearest of the wing's own NPC guards in sight and on duty, never a player -/datum/prison_boss_move/bribe/find_target(mob/living/basic/outpost_prisoner/prisoner) +/datum/prison_boss_move/bribe/find_target(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/datum/outpost_prison/prison = prisoner.prison - var/mob/living/basic/outpost_prison_guard/best + var/mob/living/carbon/human/npc/outpost_prison_guard/best var/best_distance = INFINITY - for(var/mob/living/basic/outpost_prison_guard/guard in view(PRISON_BOSS_BRIBE_RANGE, prisoner)) + for(var/mob/living/carbon/human/npc/outpost_prison_guard/guard in view(PRISON_BOSS_BRIBE_RANGE, prisoner)) var/distance = get_dist(prisoner, guard) if(distance < best_distance && prison.boss_bribable(guard)) best = guard @@ -1082,20 +1066,20 @@ return best /// Whether the kingpin may pay off `guard`: one of this wing's guards, on duty, not already paid, and nobody's playing them -/datum/outpost_prison/proc/boss_bribable(mob/living/basic/outpost_prison_guard/guard) +/datum/outpost_prison/proc/boss_bribable(mob/living/carbon/human/npc/outpost_prison_guard/guard) if(!istype(guard) || QDELETED(guard) || guard.prison != src || !guard.on_duty()) return FALSE return isnull(guard.mind) && isnull(guard.client) -/datum/prison_boss_move/bribe/telegraph(mob/living/basic/outpost_prisoner/prisoner, atom/target) +/datum/prison_boss_move/bribe/telegraph(mob/living/carbon/human/npc/outpost_prisoner/prisoner, atom/target) prisoner.visible_message(span_boldwarning("[prisoner] catches [target]'s eye and taps [prisoner.p_their()] pocket.")) playsound(prisoner, 'sound/items/coinflip.ogg', 50, TRUE) mark_turfs(list(get_turf(target)), "#e0c050", "target_circle") prisoner.say_context("boss_move_bribe") -/datum/prison_boss_move/bribe/effect(mob/living/basic/outpost_prisoner/prisoner, atom/target) +/datum/prison_boss_move/bribe/effect(mob/living/carbon/human/npc/outpost_prisoner/prisoner, atom/target) var/datum/outpost_prison/prison = prisoner.prison - var/mob/living/basic/outpost_prison_guard/guard = target + var/mob/living/carbon/human/npc/outpost_prison_guard/guard = target if(!prison.boss_bribable(guard) || get_dist(prisoner, guard) > PRISON_BOSS_BRIBE_RANGE || !(guard in view(PRISON_BOSS_BRIBE_RANGE, prisoner))) return FALSE prison.boss_bribe_guard(guard) @@ -1106,7 +1090,7 @@ * no riot response, no baton, and rioters leave them be), standing back in the office's far corner. * boss_bribes_tick() sends them back to work. */ -/datum/outpost_prison/proc/boss_bribe_guard(mob/living/basic/outpost_prison_guard/guard) +/datum/outpost_prison/proc/boss_bribe_guard(mob/living/carbon/human/npc/outpost_prison_guard/guard) guard.prison_bribed_until = world.time + PRISON_BOSS_BRIBE_TIME guard.end_response() guard.set_baton(FALSE) @@ -1121,7 +1105,7 @@ /// Paid-off guards whose time is up go back to work /datum/outpost_prison/proc/boss_bribes_tick() for(var/datum/weakref/ref as anything in boss_bribed_guards.Copy()) - var/mob/living/basic/outpost_prison_guard/guard = ref.resolve() + var/mob/living/carbon/human/npc/outpost_prison_guard/guard = ref.resolve() if(QDELETED(guard)) boss_bribed_guards -= ref continue @@ -1134,7 +1118,7 @@ guard.visible_message(span_notice("[guard] squares [guard.p_their()] shoulders and gets back to work.")) /// Whether the kingpin has them standing back from the riot (on_duty()) -/mob/living/basic/outpost_prison_guard/proc/boss_bribed() +/mob/living/carbon/human/npc/outpost_prison_guard/proc/boss_bribed() return prison_bribed_until > world.time /** diff --git a/voidcrew/modules/player_outposts/outpost_prison_bounty.dm b/voidcrew/modules/player_outposts/outpost_prison_bounty.dm index e631f2e1154..3c62ec816ee 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_bounty.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_bounty.dm @@ -81,7 +81,7 @@ /// For tests: whether a meek prisoner watching the staff door darts when it opens (TRUE or FALSE) instead of rolling for it var/prison_bounty_forced_dart -/mob/living/basic/outpost_prisoner +/mob/living/carbon/human/npc/outpost_prisoner /// Running after a bounty prisoner called out someone off the ship that caught them (bounty_extra_speech()) COOLDOWN_DECLARE(prison_captor_line_cooldown) @@ -333,7 +333,7 @@ GLOBAL_VAR(bounty_pool_timer) /// Living bounty prisoners on the roster who are not leaving, of `tier` when given /datum/outpost_prison/proc/bounty_prisoner_count(tier) . = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(!prisoner.bounty_record || prisoner.stat == DEAD || prisoner.phase == PRISONER_LEAVING) continue if(tier && prisoner.bounty_record.tier != tier) @@ -445,7 +445,7 @@ GLOBAL_VAR(bounty_pool_timer) continue bounty_pool_remove(record) record.status = BOUNTY_RECORD_IMPRISONED - var/mob/living/basic/outpost_prisoner/prisoner = new(spot, record) + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = new(spot, record) admit(prisoner, cell) prisoner.beam_in() start_arrival_gap(soonest_lane()) @@ -456,17 +456,17 @@ GLOBAL_VAR(bounty_pool_timer) // ===== A PRISONER FROM A RECORD ===== /** - * Before the prisoner's Initialize() calls ..(): the body their record says (gender, and health by - * tier), so tg sizes max_stamina from the right maxHealth. A record still in the pool leaves it now, - * before they exist. + * Before the prisoner's Initialize() calls ..(): a record still in the pool leaves it now, before they + * exist, and a tougher criminal takes less from a blow (npc_damage_taken by tier, through physiology, + * defaults PR-16). Their face and gender come from the record through the human NPC base. */ -/mob/living/basic/outpost_prisoner/proc/apply_bounty_body(datum/bounty_record/record) +/mob/living/carbon/human/npc/outpost_prisoner/proc/apply_bounty_body(datum/bounty_record/record) if(record in GLOB.bounty_prisoner_pool) bounty_pool_remove(record) - if(record.gender == MALE || record.gender == FEMALE) - gender = record.gender - maxHealth = bounty_by_tier(record.tier, BOUNTY_PRISONER_HEALTH_PETTY, BOUNTY_PRISONER_HEALTH_WANTED, BOUNTY_PRISONER_HEALTH_MOST_WANTED) - health = maxHealth + npc_damage_taken = bounty_by_tier(record.tier, BOUNTY_PRISONER_DAMAGE_TAKEN_PETTY, BOUNTY_PRISONER_DAMAGE_TAKEN_WANTED, BOUNTY_PRISONER_DAMAGE_TAKEN_MOST_WANTED) + // The Ghost's dodging is real chrome (owner ruling OC-6): a Slipwire shunt, which burns out to scrap if they die. + if(record.archetype == BOUNTY_ARCHETYPE_BOSS && record.kit == BOUNTY_KIT_GHOST) + npc_cyberware = list(/obj/item/organ/cyberimp/cyberware/slipwire) /** * At the end of the prisoner's Initialize(), before their look is built: who their record says @@ -478,12 +478,11 @@ GLOBAL_VAR(bounty_pool_timer) * yard hears BOUNTY_PRISON_MOST_WANTED_YARD_CRIME, as a Most Wanted criminal never names theirs in * its own lines (BUG-12); the console and examine still read the record's. */ -/mob/living/basic/outpost_prisoner/proc/apply_bounty_record(datum/bounty_record/record) +/mob/living/carbon/human/npc/outpost_prisoner/proc/apply_bounty_record(datum/bounty_record/record) if(record.gender == MALE || record.gender == FEMALE) gender = record.gender if(length(record.name)) - real_name = record.name - name = real_name + fully_replace_character_name(real_name, record.name) var/plain_crime = bounty_plain_crime(record.crime) if(record.tier == BOUNTY_TIER_MOST_WANTED) crime = BOUNTY_PRISON_MOST_WANTED_YARD_CRIME @@ -492,9 +491,8 @@ GLOBAL_VAR(bounty_pool_timer) var/list/personalities = bounty_archetype_personalities(record.archetype) if(length(personalities)) personality = pick(personalities) - // The plain jumpsuit: the glasses and beanie variants would hide their hair or fake their eyewear - outfit_path = /datum/outfit/outpost_prisoner - // As hurt as they were caught, but never below BOUNTY_PRISONER_MIN_ARRIVAL_HEALTH percent + // As hurt as they were caught, but never below BOUNTY_PRISONER_MIN_ARRIVAL_HEALTH percent: real + // damage spread over their limbs when they beam in (beam_in()) arrival_brute = round(maxHealth * clamp(record.hurt_fraction || 0, 0, 1 - BOUNTY_PRISONER_MIN_ARRIVAL_HEALTH / 100)) record.status = BOUNTY_RECORD_IMPRISONED @@ -535,7 +533,7 @@ GLOBAL_VAR(bounty_pool_timer) * nothing (a release is followed by forget(), for one). A closed record never returns to the pool * (bounty_pool_add() refuses it). Returns TRUE if this call closed it. */ -/proc/close_bounty_record(mob/living/basic/outpost_prisoner/prisoner, status) +/proc/close_bounty_record(mob/living/carbon/human/npc/outpost_prisoner/prisoner, status) var/datum/bounty_record/record = prisoner?.bounty_record if(!record || record.status != BOUNTY_RECORD_IMPRISONED) return FALSE @@ -544,13 +542,13 @@ GLOBAL_VAR(bounty_pool_timer) return TRUE /// Why Kessler's experiments refuse `prisoner`, or null: a bounty prisoner's identity would be lost -/proc/bounty_experiment_refusal(mob/living/basic/outpost_prisoner/prisoner) +/proc/bounty_experiment_refusal(mob/living/carbon/human/npc/outpost_prisoner/prisoner) return prisoner?.bounty_record ? "Kessler won't touch a bounty prisoner." : null // ===== PAY ===== /// What `prisoner` earns the treasury (stipend, pay rate and release bonus) as a multiple of an ordinary prisoner's: x1.5, x2 or x2.5 by tier -/datum/outpost_prison/proc/bounty_pay_mult(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/bounty_pay_mult(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/datum/bounty_record/record = prisoner?.bounty_record if(!record) return 1 @@ -558,54 +556,40 @@ GLOBAL_VAR(bounty_pool_timer) // ===== DANGER ===== -/// Multiplier on their punches and shiv blows (update_melee() and strike()), by tier and by what they hit with -/mob/living/basic/outpost_prisoner/proc/bounty_damage_mult() - if(!bounty_record) - return 1 - if(has_shiv()) - return bounty_by_tier(bounty_record.tier, BOUNTY_PRISON_SHIV_MULT_PETTY, BOUNTY_PRISON_SHIV_MULT_WANTED, BOUNTY_PRISON_SHIV_MULT_MOST_WANTED) - return bounty_by_tier(bounty_record.tier, BOUNTY_PRISON_PUNCH_MULT_PETTY, BOUNTY_PRISON_PUNCH_MULT_WANTED, BOUNTY_PRISON_PUNCH_MULT_MOST_WANTED) - /// Multiplier on their mood losses (mood_scale()) -/mob/living/basic/outpost_prisoner/proc/bounty_mood_scale() +/mob/living/carbon/human/npc/outpost_prisoner/proc/bounty_mood_scale() if(!bounty_record) return 1 return bounty_by_tier(bounty_record.tier, BOUNTY_PRISON_MOOD_SCALE_PETTY, BOUNTY_PRISON_MOOD_SCALE_WANTED, BOUNTY_PRISON_MOOD_SCALE_MOST_WANTED) /// Mood points added to the line below which they square up to staff (threat_mood_for() and threat_mood_ceiling()) -/mob/living/basic/outpost_prisoner/proc/bounty_threat_bonus() +/mob/living/carbon/human/npc/outpost_prisoner/proc/bounty_threat_bonus() if(!bounty_record) return 0 return bounty_by_tier(bounty_record.tier, BOUNTY_PRISON_THREAT_BONUS_PETTY, BOUNTY_PRISON_THREAT_BONUS_WANTED, BOUNTY_PRISON_THREAT_BONUS_MOST_WANTED) /// Mood points added to the line below which they join a riot (riot_join_bonus()) -/mob/living/basic/outpost_prisoner/proc/bounty_riot_bonus() +/mob/living/carbon/human/npc/outpost_prisoner/proc/bounty_riot_bonus() if(!bounty_record) return 0 return bounty_by_tier(bounty_record.tier, BOUNTY_PRISON_RIOT_BONUS_PETTY, BOUNTY_PRISON_RIOT_BONUS_WANTED, BOUNTY_PRISON_RIOT_BONUS_MOST_WANTED) /// Multiplier on the damage their blows do to the wing's ways out (hit_exit()) -/mob/living/basic/outpost_prisoner/proc/bounty_breakout_mult() +/mob/living/carbon/human/npc/outpost_prisoner/proc/bounty_breakout_mult() if(!bounty_record) return 1 return bounty_by_tier(bounty_record.tier, BOUNTY_PRISON_BREAKOUT_MULT_PETTY, BOUNTY_PRISON_BREAKOUT_MULT_WANTED, BOUNTY_PRISON_BREAKOUT_MULT_MOST_WANTED) -/// Multiplier on how long cuffing them takes (cuff_time()) -/mob/living/basic/outpost_prisoner/proc/bounty_cuff_mult() - if(!bounty_record) - return 1 - return bounty_by_tier(bounty_record.tier, BOUNTY_PRISON_CUFF_MULT_PETTY, BOUNTY_PRISON_CUFF_MULT_WANTED, BOUNTY_PRISON_CUFF_MULT_MOST_WANTED) - /// Whether they were a meek criminal: they back off, go over hatches and slip out of doors -/mob/living/basic/outpost_prisoner/proc/bounty_is_meek() +/mob/living/carbon/human/npc/outpost_prisoner/proc/bounty_is_meek() return bounty_record?.archetype == BOUNTY_ARCHETYPE_MEEK /// Multiplier on how likely they are to back off when a player hits them: twice as likely for a meek bounty prisoner (hit_reaction(), through bounty_hit_reaction_weights()) -/mob/living/basic/outpost_prisoner/proc/bounty_back_off_mult() +/mob/living/carbon/human/npc/outpost_prisoner/proc/bounty_back_off_mult() return bounty_is_meek() ? BOUNTY_PRISON_MEEK_BACK_OFF_MULT : 1 /// Multiplier on how likely they are to hit back when a player hits them: a Wanted or Most Wanted prisoner who is not meek hits back like a grumpy one (hit_reaction(), through bounty_hit_reaction_weights()) -/mob/living/basic/outpost_prisoner/proc/bounty_hit_back_mult() +/mob/living/carbon/human/npc/outpost_prisoner/proc/bounty_hit_back_mult() if(!bounty_record || bounty_is_meek()) return 1 return bounty_by_tier(bounty_record.tier, 1, BOUNTY_PRISON_HIT_BACK_MULT_WANTED, BOUNTY_PRISON_HIT_BACK_MULT_MOST_WANTED) @@ -614,38 +598,30 @@ GLOBAL_VAR(bounty_pool_timer) * A calm prisoner's hit-back and back-off weights (outpost_prisoner_hit_reaction_weights()'s list, * which is theirs to change), scaled for a bounty prisoner. Returns the same list. hit_reaction() rolls on it. */ -/mob/living/basic/outpost_prisoner/proc/bounty_hit_reaction_weights(list/weights) +/mob/living/carbon/human/npc/outpost_prisoner/proc/bounty_hit_reaction_weights(list/weights) if(!bounty_record || !islist(weights)) return weights weights[PRISONER_HIT_FIGHT] = max(1, round(weights[PRISONER_HIT_FIGHT] * bounty_hit_back_mult())) weights[PRISONER_HIT_COWER] = max(1, round(weights[PRISONER_HIT_COWER] * bounty_back_off_mult())) return weights -/// Their speed while loose, or null for the usual: a meek bounty prisoner runs faster than the others (go_loose()) -/mob/living/basic/outpost_prisoner/proc/bounty_loose_speed() - return bounty_is_meek() ? BOUNTY_PRISON_MEEK_LOOSE_SPEED : null - -/// The speed they go back to when not running from anything: a loose meek bounty prisoner keeps their loose speed (update_flee_speed(), back_in_custody()) -/mob/living/basic/outpost_prisoner/proc/bounty_base_speed() - if(trouble == PRISONER_TROUBLE_LOOSE) - var/loose_speed = bounty_loose_speed() - if(loose_speed) - return loose_speed - return initial(speed) +/// Whether they run rather than walk when not running from anything: a runner runs (go_loose(), update_flee_speed(), back_in_custody()) +/mob/living/carbon/human/npc/outpost_prisoner/proc/bounty_base_speed() + return trouble == PRISONER_TROUBLE_LOOSE /// How long going over a serving hatch takes them, or null for the usual: a meek bounty prisoner is quicker (start_climb()) -/mob/living/basic/outpost_prisoner/proc/bounty_climb_time() +/mob/living/carbon/human/npc/outpost_prisoner/proc/bounty_climb_time() return bounty_is_meek() ? BOUNTY_PRISON_MEEK_CLIMB_TIME : null /// Multiplier on their weight as the wildcard "snap" prisoner: a Most Wanted ringleader's is doubled (pick_snapper()) -/mob/living/basic/outpost_prisoner/proc/bounty_snap_weight_mult() +/mob/living/carbon/human/npc/outpost_prisoner/proc/bounty_snap_weight_mult() return bounty_record?.tier == BOUNTY_TIER_MOST_WANTED ? BOUNTY_PRISON_RINGLEADER_SNAP_MULT : 1 /// `rioters` with any Most Wanted first, so a ringleader is among the first to shout when a riot starts (start_riot()). Returns a new list. /proc/bounty_ringleaders_first(list/rioters) var/list/leaders = list() var/list/others = list() - for(var/mob/living/basic/outpost_prisoner/rioter as anything in rioters) + for(var/mob/living/carbon/human/npc/outpost_prisoner/rioter as anything in rioters) if(rioter.bounty_record?.tier == BOUNTY_TIER_MOST_WANTED) leaders += rioter else @@ -654,10 +630,10 @@ GLOBAL_VAR(bounty_pool_timer) /// An awake, uncuffed Most Wanted prisoner out in the yard, not shut in a cell, who stirs the others up, or null /datum/outpost_prison/proc/bounty_ringleader() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.bounty_record?.tier != BOUNTY_TIER_MOST_WANTED || !counts_for_tension(prisoner)) continue - if(prisoner.stat != CONSCIOUS || prisoner.cuffs || !in_cell_block(prisoner) || prisoner.is_confined()) + if(prisoner.stat != CONSCIOUS || prisoner.handcuffed || !in_cell_block(prisoner) || prisoner.is_confined()) continue return prisoner return null @@ -670,7 +646,7 @@ GLOBAL_VAR(bounty_pool_timer) /datum/outpost_prison/proc/bounty_restless_causes() if(BOUNTY_PRISON_RINGLEADER_TENSION <= 0) return list() - var/mob/living/basic/outpost_prisoner/ringleader = bounty_ringleader() + var/mob/living/carbon/human/npc/outpost_prisoner/ringleader = bounty_ringleader() return ringleader ? list("[ringleader.real_name] stirring them up") : list() // ===== MEEK BOUNTY PRISONERS: HATCHES AND DOORS ===== @@ -906,7 +882,7 @@ GLOBAL_VAR(bounty_pool_timer) return best /// Whether they are a meek bounty prisoner in a mood to watch the staff door for their chance, with a member of the wing home (nothing new starts in an empty wing) -/mob/living/basic/outpost_prisoner/proc/bounty_may_watch_door() +/mob/living/carbon/human/npc/outpost_prisoner/proc/bounty_may_watch_door() return bounty_is_meek() && mood < BOUNTY_PRISON_MEEK_DART_MOOD && !!prison?.trouble_enabled && prison.crew_home() // ===== CONSOLES ===== @@ -916,7 +892,7 @@ GLOBAL_VAR(bounty_pool_timer) * "wanted for" line and whether they are Most Wanted, the one tier a wanted poster names. Petty and * Wanted show nothing more, and no pay multiplier. */ -/datum/outpost_prison/proc/bounty_roster_badge(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/bounty_roster_badge(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/datum/bounty_record/record = prisoner?.bounty_record if(!record) return null @@ -932,7 +908,7 @@ GLOBAL_VAR(bounty_pool_timer) * since the yard's "In for ..." leaves it out (BUG-12): "Most Wanted, for smuggling. The crew of the * Meridian brought him in." */ -/datum/outpost_prison/proc/bounty_examine(mob/living/basic/outpost_prisoner/prisoner, mob/user) +/datum/outpost_prison/proc/bounty_examine(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/user) var/datum/bounty_record/record = prisoner?.bounty_record if(!record) return null @@ -955,7 +931,7 @@ GLOBAL_VAR(bounty_pool_timer) * Values for their lines that name the ship that caught them, list("{place}" = "Meridian"), or null * for an ordinary prisoner or a record with no captor. The lines say "the {place}". */ -/mob/living/basic/outpost_prisoner/proc/bounty_captor_values() +/mob/living/carbon/human/npc/outpost_prisoner/proc/bounty_captor_values() if(!length(bounty_record?.captor_name)) return null return list("{place}" = bounty_record.captor_name) @@ -965,12 +941,12 @@ GLOBAL_VAR(bounty_pool_timer) * the Meridian crew sends people."), in place of the usual hello. Returns TRUE if they said it. * finish_beam_in() calls it before its own arrival lines. */ -/mob/living/basic/outpost_prisoner/proc/bounty_arrival_speech() +/mob/living/carbon/human/npc/outpost_prisoner/proc/bounty_arrival_speech() var/list/values = bounty_captor_values() return values ? say_context_with("bounty_arrival", values) : FALSE /// Someone awake off the ship that caught them, within BOUNTY_PRISON_CAPTOR_VIEW tiles and in sight, or null -/mob/living/basic/outpost_prisoner/proc/bounty_captor_in_view() +/mob/living/carbon/human/npc/outpost_prisoner/proc/bounty_captor_in_view() var/obj/structure/overmap/ship/captor_ship = bounty_record?.captor_ship?.resolve() if(QDELETED(captor_ship)) return null @@ -985,7 +961,7 @@ GLOBAL_VAR(bounty_pool_timer) * Rolled at `chance` percent, and at most once every BOUNTY_PRISON_CAPTOR_LINE_GAP each; the sight * check runs only once the roll comes up. Returns list(context, null, values), or null. */ -/datum/outpost_prison/proc/bounty_extra_speech(mob/living/basic/outpost_prisoner/prisoner, chance = BOUNTY_PRISON_CAPTOR_LINE_CHANCE) +/datum/outpost_prison/proc/bounty_extra_speech(mob/living/carbon/human/npc/outpost_prisoner/prisoner, chance = BOUNTY_PRISON_CAPTOR_LINE_CHANCE) var/list/values = prisoner?.bounty_captor_values() if(!values || !COOLDOWN_FINISHED(prisoner, prison_captor_line_cooldown) || !prob(chance)) return null @@ -1079,7 +1055,7 @@ GLOBAL_VAR(bounty_pool_timer) var/datum/bounty_record/record = bounty_pool_find(params?["id"]) if(!record) return list("error" = "That record is no longer in the pool.") - var/mob/living/basic/outpost_prisoner/arrival = bounty_admit_record(record) + var/mob/living/carbon/human/npc/outpost_prisoner/arrival = bounty_admit_record(record) if(!arrival) return list("error" = "No free cell.") return "admit bounty prisoner [arrival.real_name] ([bounty_tier_name(record.tier)]) into cell [arrival.cell?.number]" diff --git a/voidcrew/modules/player_outposts/outpost_prison_breach.dm b/voidcrew/modules/player_outposts/outpost_prison_breach.dm new file mode 100644 index 00000000000..5c4fd7fcdd7 --- /dev/null +++ b/voidcrew/modules/player_outposts/outpost_prison_breach.dm @@ -0,0 +1,198 @@ +/** + * # Prison breaches: emergency air + * + * Prisoners breathe like anyone (they are real human bodies): a breach, a fire or a plasma leak in the + * cell block suffocates, freezes and burns them the way it does the crew. Owner ruling Q3: the cell + * block has emergency lockers of breath masks and air tanks, and a prisoner on bad air who isn't busy + * making trouble goes and gets one, puts the mask on, and breathes from the tank (the human NPC base + * opens a worn tank while the air is bad). The wing gets one locker per PRISON_EMERGENCY_LOCKER_TILES + * floor tiles of its cell block when the corrections service lays it out, against a yard wall. + * + * Nothing here heals or shields anyone: a prisoner who can't reach a locker, or finds it emptied, + * suffocates. + */ + +/// Floor tiles of cell block per emergency locker +#define PRISON_EMERGENCY_LOCKER_TILES 60 +/// How often a prisoner on bad air may try again for a locker after failing to get to one +#define PRISON_EMERGENCY_RETRY (15 SECONDS) + +/// The cell block's emergency locker: breath masks and air tanks, the same every time +/obj/structure/closet/emcloset/outpost_prison + name = "emergency locker" + desc = "Breath masks and air tanks for the cell block, for when the air goes bad." + anchored = TRUE + +/obj/structure/closet/emcloset/outpost_prison/Initialize(mapload) + . = ..() + AddElement(/datum/element/outpost_property) + +// Stocked when it is placed, not on first opening (tg's closets fill lazily), so a prisoner can tell from +// the yard which locker still has air in it (emergency_locker_for()). +/obj/structure/closet/emcloset/outpost_prison/populate_contents_immediate() + . = ..() + for(var/i in 1 to 4) + new /obj/item/clothing/mask/breath(src) + new /obj/item/tank/internals/emergency_oxygen(src) + +/obj/structure/closet/emcloset/outpost_prison/PopulateContents() + return + +/datum/outpost_prison + /// The emergency lockers the wing's cell block has (weakrefs) + var/list/emergency_lockers = list() + +/** + * Makes sure the cell block has its emergency lockers: one per PRISON_EMERGENCY_LOCKER_TILES of floor, + * counting any already standing there (mapped or placed), each new one against a yard wall away from the + * others. Called when the cell block is worked out. + */ +/datum/outpost_prison/proc/ensure_emergency_lockers() + if(!length(cell_block)) + return + var/list/standing = list() + var/floor = 0 + for(var/turf/tile as anything in cell_block) + if(isclosedturf(tile)) + continue + floor++ + for(var/obj/structure/closet/emcloset/locker in tile) + standing += locker + emergency_lockers.Cut() + for(var/obj/structure/closet/emcloset/locker as anything in standing) + emergency_lockers += WEAKREF(locker) + var/wanted = max(1, round(floor / PRISON_EMERGENCY_LOCKER_TILES)) + while(length(standing) < wanted) + var/turf/spot = emergency_locker_spot(standing) + if(!spot) + return + var/obj/structure/closet/emcloset/outpost_prison/locker = new(spot) + standing += locker + emergency_lockers += WEAKREF(locker) + +/// A yard tile against a wall, in no cell, with nothing on it and no door beside it, furthest from `others` +/datum/outpost_prison/proc/emergency_locker_spot(list/others) + var/turf/best + var/best_distance = -1 + for(var/turf/open/tile in cell_block) + if(cell_at(tile) || tile.is_blocked_turf(TRUE) || length(tile.contents)) + continue + var/against_wall = FALSE + var/by_door = FALSE + for(var/direction in GLOB.cardinals) + var/turf/beside = get_step(tile, direction) + if(isclosedturf(beside)) + against_wall = TRUE + if(locate(/obj/machinery/door) in beside) + by_door = TRUE + if(!against_wall || by_door) + continue + var/nearest = INFINITY + for(var/atom/other as anything in others) + nearest = min(nearest, get_dist(other, tile)) + if(nearest > best_distance) + best = tile + best_distance = nearest + return best + +/// The nearest emergency locker `prisoner` can walk to that still has a mask and a tank in it +/datum/outpost_prison/proc/emergency_locker_for(mob/living/carbon/human/npc/outpost_prisoner/prisoner) + var/obj/structure/closet/best + var/best_distance = INFINITY + for(var/datum/weakref/locker_ref as anything in emergency_lockers) + var/obj/structure/closet/locker = locker_ref.resolve() + if(QDELETED(locker) || !prisoner.approach_turf(locker)) + continue + // A locker nobody has opened yet (tg fills them on first opening) is worth a look. + if(locker.contents_initialized || locker.opened) + var/atom/inside = locker.opened ? get_turf(locker) : locker + if(!(locate(/obj/item/clothing/mask/breath) in inside) && !(locate(/obj/item/clothing/mask/gas) in inside)) + continue + if(!(locate(/obj/item/tank/internals) in inside)) + continue + var/distance = get_dist(prisoner, locker) + if(distance < best_distance) + best = locker + best_distance = distance + return best + +/mob/living/carbon/human/npc/outpost_prisoner + /// world.time they may next go for an emergency locker + var/next_emergency_try = 0 + +/// Whether they wear a mask they could breathe a tank through, and carry a tank +/mob/living/carbon/human/npc/outpost_prisoner/proc/has_emergency_air() + if(!can_breathe_internals()) + return FALSE + for(var/obj/item/tank/internals/tank in get_equipped_items(INCLUDE_POCKETS | INCLUDE_HELD)) + return TRUE + return FALSE + +/** + * The air where they stand is bad (air_tick()). Wearing a mask and a tank, they breathe from it. + * Otherwise, unless they are busy with trouble, they go for the nearest emergency locker. + */ +/mob/living/carbon/human/npc/outpost_prisoner/proc/on_bad_air() + if(stat != CONSCIOUS) + return + if(has_emergency_air()) + if(!internal) + npc_open_internals() + return + if(world.time < next_emergency_try || istype(activity, /datum/prisoner_activity/emergency_air) || !routine_allowed()) + return + var/datum/prisoner_activity/emergency_air/dash = new(src) + if(!dash.setup()) + qdel(dash) + next_emergency_try = world.time + PRISON_EMERGENCY_RETRY + return + start_activity(dash) + +/// To the emergency locker: open it, take a mask and a tank, put them on and breathe +/datum/prisoner_activity/emergency_air + name = "getting emergency air" + interruptible = FALSE + min_duration = 3 SECONDS + max_duration = 3 SECONDS + var/datum/weakref/locker_ref + +/datum/prisoner_activity/emergency_air/setup() + var/obj/structure/closet/locker = prisoner.prison?.emergency_locker_for(prisoner) + if(!locker) + return FALSE + locker_ref = WEAKREF(locker) + spot = prisoner.approach_turf(locker) + return !!spot + +/datum/prisoner_activity/emergency_air/begin() + . = ..() + var/obj/structure/closet/locker = locker_ref?.resolve() + if(QDELETED(locker) || get_dist(prisoner, locker) > 1) + return + prisoner.face_atom(locker) + if(!locker.opened) + locker.open(prisoner) + var/turf/inside = get_turf(locker) + var/obj/item/clothing/mask/mask = locate(/obj/item/clothing/mask/breath) in inside + mask ||= locate(/obj/item/clothing/mask/gas) in inside + var/obj/item/tank/internals/tank = locate(/obj/item/tank/internals) in inside + if(!mask || !tank) + return + prisoner.visible_message(span_notice("[prisoner] grabs [mask] and [tank] out of [locker].")) + if(prisoner.wear_mask && !prisoner.can_breathe_internals()) + prisoner.dropItemToGround(prisoner.wear_mask) + if(!prisoner.wear_mask) + mask.forceMove(prisoner) + if(!prisoner.equip_to_slot_if_possible(mask, ITEM_SLOT_MASK, disable_warning = TRUE)) + mask.forceMove(inside) + tank.forceMove(prisoner) + if(!prisoner.equip_to_slot_if_possible(tank, ITEM_SLOT_BELT, disable_warning = TRUE) && !prisoner.equip_to_slot_if_possible(tank, ITEM_SLOT_LPOCKET, disable_warning = TRUE) && !prisoner.equip_to_slot_if_possible(tank, ITEM_SLOT_RPOCKET, disable_warning = TRUE) && !prisoner.put_in_hands(tank)) + tank.forceMove(inside) + prisoner.npc_open_internals() + +/datum/prisoner_activity/emergency_air/Destroy() + locker_ref = null + return ..() + +#undef PRISON_EMERGENCY_LOCKER_TILES +#undef PRISON_EMERGENCY_RETRY diff --git a/voidcrew/modules/player_outposts/outpost_prison_breakout.dm b/voidcrew/modules/player_outposts/outpost_prison_breakout.dm index a54a098ff3f..9d6cc54d253 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_breakout.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_breakout.dm @@ -80,7 +80,7 @@ * The ways out a rioter can get at, exit tile = its blocker: tiles on the cell block's edge beside * ground they can walk, whose blocker they have not given up on for now. */ -/datum/outpost_prison/proc/exit_tiles(mob/living/basic/outpost_prisoner/rioter) +/datum/outpost_prison/proc/exit_tiles(mob/living/carbon/human/npc/outpost_prisoner/rioter) var/list/exits = list() for(var/turf/tile as anything in rioter.reachable) if(rioter.walkable?[tile] || !is_exit_tile(tile)) @@ -96,9 +96,9 @@ return istype(blocker, /obj/structure/table/reinforced/prison_hatch) ? 1 : PRISON_RIOT_EXIT_CROWD /// How many rioters other than `except`, on their feet, are working at the way out on `tile` -/datum/outpost_prison/proc/rioters_at_exit(turf/tile, mob/living/basic/outpost_prisoner/except) +/datum/outpost_prison/proc/rioters_at_exit(turf/tile, mob/living/carbon/human/npc/outpost_prisoner/except) var/count = 0 - for(var/mob/living/basic/outpost_prisoner/other in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/other in prisoners) if(other == except || !other.is_rioting() || !other.trouble_can_act()) continue var/atom/target = other.riot_target_ref?.resolve() @@ -112,7 +112,7 @@ * farther than a door. One with no room left (exit_room()) is passed over unless `crowded_ok`. * Null if none will do. */ -/datum/outpost_prison/proc/choose_exit(mob/living/basic/outpost_prisoner/rioter, list/exits, crowded_ok = FALSE) +/datum/outpost_prison/proc/choose_exit(mob/living/carbon/human/npc/outpost_prisoner/rioter, list/exits, crowded_ok = FALSE) var/turf/best var/best_score = INFINITY for(var/turf/tile as anything in exits) @@ -148,7 +148,7 @@ * A fixture for a rioter to smash: one within PRISON_RIOT_DETOUR_RANGE tiles of `near` if there is * one, else any they can reach, or null with `near_only`. */ -/datum/outpost_prison/proc/pick_fixture(mob/living/basic/outpost_prisoner/rioter, turf/near, near_only = FALSE) +/datum/outpost_prison/proc/pick_fixture(mob/living/carbon/human/npc/outpost_prisoner/rioter, turf/near, near_only = FALSE) var/list/found = list() var/list/close = list() for(var/turf/tile as anything in rioter.reachable) @@ -173,7 +173,7 @@ * at, the wing's fixtures. Breaking out, they go for the ways out, crowded or not, and never stop * for a fixture on the way. */ -/datum/outpost_prison/proc/pick_smash_target(mob/living/basic/outpost_prisoner/rioter) +/datum/outpost_prison/proc/pick_smash_target(mob/living/carbon/human/npc/outpost_prisoner/rioter) var/atom/priority = priority_smash_target(rioter) if(priority) return priority @@ -192,7 +192,7 @@ return pick_fixture(rioter) /// Whether a rioter can make for `tile` to get out: walkable for them, in the wing, outside the cell block, and not given up on -/datum/outpost_prison/proc/escape_spot_ok(turf/tile, mob/living/basic/outpost_prisoner/rioter) +/datum/outpost_prison/proc/escape_spot_ok(turf/tile, mob/living/carbon/human/npc/outpost_prisoner/rioter) return isturf(tile) && tile.loc == wing && !cell_block[tile] && rioter.walkable?[tile] && LAZYACCESS(rioter.riot_skips, REF(tile)) <= world.time /** @@ -200,7 +200,7 @@ * can walk to, keeping the one they chose while it still works, and preferring one nobody stands on. * Null with nobody home, so the rioters stay in the yard, and in a wing with no cells. */ -/datum/outpost_prison/proc/escape_spot(mob/living/basic/outpost_prisoner/rioter) +/datum/outpost_prison/proc/escape_spot(mob/living/carbon/human/npc/outpost_prisoner/rioter) if(!length(cell_block) || !length(rioter.walkable) || !crew_home()) return null var/turf/chosen = rioter.riot_target_ref?.resolve() @@ -233,7 +233,7 @@ * each way out this riot is announced; with nobody home it only booms. When the way gives, everyone's * reach is worked out again so the rioters see the gap. Returns TRUE. */ -/datum/outpost_prison/proc/hit_exit(mob/living/basic/outpost_prisoner/rioter, obj/target) +/datum/outpost_prison/proc/hit_exit(mob/living/carbon/human/npc/outpost_prisoner/rioter, obj/target) var/turf/tile = get_turf(target) rioter.trouble_line("riot_break_door", fallback = "riot") if(!crew_home()) @@ -300,7 +300,7 @@ * hatch is forced open (force_open()). With the office side already open or gone, the yard side opens * for them, or takes the blow if it cannot open. Returns TRUE if the office side gave. */ -/obj/structure/table/reinforced/prison_hatch/proc/take_rioter_blow(mob/living/basic/outpost_prisoner/rioter) +/obj/structure/table/reinforced/prison_hatch/proc/take_rioter_blow(mob/living/carbon/human/npc/outpost_prisoner/rioter) playsound(src, 'sound/effects/glass/glassbash.ogg', 50, TRUE) var/obj/machinery/door/window/staff_door = staff_windoor() if(staff_door?.density) diff --git a/voidcrew/modules/player_outposts/outpost_prison_capture.dm b/voidcrew/modules/player_outposts/outpost_prison_capture.dm index db9a890e563..75db2b47b69 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_capture.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_capture.dm @@ -1,18 +1,17 @@ /** * # Prison capture: cuffs and lockdown * - * Cuffs. A member of the wing can put any handcuffs, cable restraints or zipties on a prisoner. - * One who is down takes PRISONER_CUFF_TIME_DOWN; one on their feet takes PRISONER_CUFF_TIME_STANDING, - * holding still meanwhile, and only while making no trouble: rioters, runners, fighters, anyone - * threatening staff and anyone wrecking their cell must be put down first. Cuffed, they drop what - * they hold and do nothing but stand or sit where they are and complain: no blows, threats, - * fights, climbing, smashing, eating or activities, and a runner's loose clock waits. Anyone can - * drag them, and a member can take them through the wing's staff doors (outpost_prisoner_escorted()). - * Cuffs kept on past PRISONER_CUFFED_GRACE sour them and stop their pay like a lock-in, unless it - * is for good reason: the wing is in protective custody, or they owe lockdown. A member takes the - * cuffs off from the talk menu ("Uncuff"), or with an empty hand while they are down: real cuffs go - * to the member's hand, cable and zipties are cut away. - * The cuffs drop to the floor when the prisoner dies, beams out or is deleted. + * Cuffs are tg's own handcuffs, cable restraints and zipties, put on through tg's cuffing (4 seconds, + * its sounds and messages). Only a member of the wing may cuff a prisoner (COMSIG_CARBON_CUFF_ATTEMPTED). + * Anyone making trouble on their feet (a rioter, a runner, a fighter, anyone squaring up to staff or + * climbing out) won't hold still: they step out of the cuffer's reach, which breaks the cuffing, so + * they get put down first. Cuffed, they can walk, as anyone can, but they choose to stand or sit where + * they are and complain: no blows, threats, fights, climbing, smashing, eating or activities, and a + * runner's loose clock waits. Anyone can drag them, and a member can take them through the wing's staff + * doors (outpost_prisoner_escorted()). Cuffs kept on past PRISONER_CUFFED_GRACE sour them and stop + * their pay like a lock-in, unless it is for good reason: the wing is in protective custody, or they owe + * lockdown. A member takes the cuffs off from the talk menu ("Uncuff"), or through the strip menu like + * anyone's: real cuffs go to the member's hand, cable and zipties are cut away. A body keeps its cuffs. * * Lockdown. A rioter shut in a cell, and a runner caught after getting out during a riot, owes * PRISON_RIOT_LOCKDOWN_TIME of lockdown. It counts down only while they are shut in a cell, and @@ -25,12 +24,7 @@ * outpost_prison_riot.dm). Only the ones shut in a cell owe lockdown. */ -/// Trait source for the cuffs holding a prisoner still -#define PRISONER_CUFFS_TRAIT "outpost_prisoner_cuffs" - -/mob/living/basic/outpost_prisoner - /// The cuffs on them, held in their contents - var/obj/item/restraints/handcuffs/cuffs +/mob/living/carbon/human/npc/outpost_prisoner /// Seconds cuffed without good reason; falls PRISONER_LOCKED_IN_RECOVERY seconds a second once uncuffed var/cuffed_seconds = 0 /// Someone is putting cuffs on them or taking them off @@ -46,199 +40,143 @@ // ===== CUFFING ===== -/// Why `user` can't put `restraints` on them now, as a balloon alert, or null if they can -/mob/living/basic/outpost_prisoner/proc/cuff_refusal(mob/living/user, obj/item/restraints/handcuffs/restraints) +/// Why `user` can't put cuffs on them now, as a balloon alert, or null if they can +/mob/living/carbon/human/npc/outpost_prisoner/proc/cuff_refusal(mob/living/user) if(!prison || !prison.is_member(user)) return "members only" if(stat == DEAD || phase != PRISONER_PRESENT) return "can't cuff [p_them()]" - if(cuffs) - return "already cuffed" - if(istype(restraints, /obj/item/restraints/handcuffs/cable/zipties/used)) - return "used up" - // On their feet only when they are making no trouble; rioters and runners go down first. - if(!is_down() && (trouble || threat_ref || swing_ref || climb_ref)) - return "won't hold still" return null -/// How long cuffing them takes: quicker when they are down -/mob/living/basic/outpost_prisoner/proc/cuff_time() - return (is_down() ? PRISONER_CUFF_TIME_DOWN : PRISONER_CUFF_TIME_STANDING) * bounty_cuff_mult() - -/// Cuffs used on them (from the item interaction signal): refused with a balloon alert, or put on in the background -/mob/living/basic/outpost_prisoner/proc/on_cuffs_used(mob/living/user, obj/item/restraints/handcuffs/restraints) - var/refusal = cuff_refusal(user, restraints) - if(!refusal && cuff_work) - refusal = "already busy" - if(refusal) - balloon_alert(user, refusal) - return ITEM_INTERACT_BLOCKING - INVOKE_ASYNC(src, PROC_REF(cuff_by), user, restraints) - return ITEM_INTERACT_SUCCESS +/// Making trouble on their feet: they won't stand still for the cuffs +/mob/living/carbon/human/npc/outpost_prisoner/proc/fights_the_cuffs() + return !is_down() && (trouble || threat_ref || swing_ref || climb_ref) /** - * `user` puts `restraints` on them over cuff_time(), with tg's cuff sounds. They hold still - * meanwhile (in_trouble() counts it, so their routine waits). Returns TRUE if they are cuffed. Sleeps. + * Someone starts cuffing them with tg's cuffs. Not a member: refused. Making trouble on their feet: + * they pull away out of reach, which breaks tg's cuffing do_after. Otherwise they hold still, and their + * routine waits while the cuffs go on. */ -/mob/living/basic/outpost_prisoner/proc/cuff_by(mob/living/user, obj/item/restraints/handcuffs/restraints) - if(cuff_work || cuff_refusal(user, restraints)) - return FALSE +/mob/living/carbon/human/npc/outpost_prisoner/proc/on_cuff_attempt(datum/source, mob/living/user) + SIGNAL_HANDLER + var/refusal = cuff_refusal(user) + if(refusal) + balloon_alert(user, refusal) + return COMSIG_CARBON_CUFF_PREVENT + if(fights_the_cuffs() && !HAS_TRAIT(src, TRAIT_IMMOBILIZED)) + INVOKE_ASYNC(src, PROC_REF(pull_away_from), user) + return NONE cuff_work = TRUE ai_controller?.CancelActions() - user.visible_message(span_danger("[user] is trying to put [restraints] on [src]!"), span_danger("You try to put [restraints] on [src].")) - playsound(src, restraints.cuffsound, 30, TRUE, -2) - var/done = do_after(user, cuff_time(), target = src, timed_action_flags = IGNORE_SLOWDOWNS) - cuff_work = FALSE - if(QDELETED(src)) - return FALSE - // A borg's cuffs are part of its module: it dispenses a pair, as tg's cuffs do for borgs. - var/dispense = iscyborg(user) - if(!done || QDELETED(restraints) || (restraints.loc != user && !dispense) || cuff_refusal(user, restraints)) - balloon_alert(user, "failed to cuff!") - return FALSE - var/success_sound = restraints.cuffsuccesssound - if(!apply_cuffs(restraints, user, dispense)) - balloon_alert(user, "failed to cuff!") - return FALSE - playsound(src, success_sound, 30, TRUE, -2) - user.visible_message(span_notice("[user] handcuffs [src]."), span_notice("You handcuff [src].")) - log_combat(user, src, "handcuffed") - return TRUE + addtimer(VARSET_CALLBACK(src, cuff_work, FALSE), PRISONER_CUFF_TIME_STANDING + 1 SECONDS, TIMER_UNIQUE | TIMER_OVERRIDE) + return NONE + +/// A step out of `user`'s reach, as anyone twists away from someone with cuffs +/mob/living/carbon/human/npc/outpost_prisoner/proc/pull_away_from(mob/living/user) + if(QDELETED(src) || QDELETED(user) || stat != CONSCIOUS) + return + step_away(src, user) /** - * Puts `restraints` on them at once; zipties become their used pair, as on people. `user`, if - * any, gives them up from their hands, unless `dispense` (a borg), which puts on a new pair of the - * same kind instead. What they hold drops and whatever they were up to stops. Returns TRUE if they - * are cuffed. + * Cuffs went on: what they were up to stops. Called once the cuffs are on (the restrained trait + * handler, outpost_prison_prisoner.dm); their line comes from npc_bark(). */ -/mob/living/basic/outpost_prisoner/proc/apply_cuffs(obj/item/restraints/handcuffs/restraints, mob/living/user, dispense = FALSE) - if(cuffs || QDELETED(restraints) || stat == DEAD) - return FALSE - var/obj/item/restraints/handcuffs/worn = restraints - if(dispense) - var/dispensed_path = restraints.trashtype || restraints.type - worn = new dispensed_path(src) - else - if(user && !user.temporarilyRemoveItemFromInventory(restraints)) - return FALSE - if(restraints.trashtype) - var/trash_path = restraints.trashtype - worn = new trash_path(src) - qdel(restraints) - else - restraints.forceMove(src) - if(QDELETED(worn) || worn.loc != src) - return FALSE - cuffs = worn - ADD_TRAIT(src, TRAIT_IMMOBILIZED, PRISONER_CUFFS_TRAIT) - if(has_shiv()) - drop_shiv() - else - drop_held_item() +/mob/living/carbon/human/npc/outpost_prisoner/proc/on_cuffed() + cuff_work = FALSE end_activity() cancel_threat() stop_climb(fell = TRUE) // The breakout AI too: a caught runner stays put until walked home. ai_controller?.CancelActions() - // Draggable now: whatever trouble they were in stops (on_downed()). - update_drag_resistance() - update_appearance(UPDATE_OVERLAYS) update_bubble() - if(stat == CONSCIOUS) - say_context("cuffed") - return TRUE // ===== UNCUFFING ===== /** - * A member takes the cuffs off by hand, over PRISONER_UNCUFF_TIME. Returns TRUE if + * A member takes the cuffs off by hand from the talk menu, over PRISONER_UNCUFF_TIME. Returns TRUE if * they came off. Sleeps. */ -/mob/living/basic/outpost_prisoner/proc/uncuff_by(mob/living/user) - if(!cuffs || cuff_work) +/mob/living/carbon/human/npc/outpost_prisoner/proc/uncuff_by(mob/living/user) + var/obj/item/restraints/handcuffs/worn = handcuffed + if(!worn || cuff_work) return FALSE cuff_work = TRUE - user.visible_message(span_notice("[user] starts taking [cuffs] off [src]."), span_notice("You start taking [cuffs] off [src].")) + user.visible_message(span_notice("[user] starts taking [worn] off [src]."), span_notice("You start taking [worn] off [src].")) var/done = do_after(user, PRISONER_UNCUFF_TIME, target = src) cuff_work = FALSE - if(!done || QDELETED(src) || !cuffs || !prison?.is_member(user)) + if(!done || QDELETED(src) || handcuffed != worn || !prison?.is_member(user)) return FALSE - var/cut = istype(cuffs, /obj/item/restraints/handcuffs/cable) - user.visible_message(span_notice("[user] [cut ? "cuts" : "takes"] [cuffs] off [src]."), span_notice("You [cut ? "cut" : "take"] [cuffs] off [src].")) + var/cut = istype(worn, /obj/item/restraints/handcuffs/cable) + user.visible_message(span_notice("[user] [cut ? "cuts" : "takes"] [worn] off [src]."), span_notice("You [cut ? "cut" : "take"] [worn] off [src].")) remove_cuffs(user) - if(stat == CONSCIOUS) - say_context("cuffs_off") return TRUE /** - * Takes their cuffs off. With `user`, real cuffs go to their hands (or the floor) and cable - * restraints and zipties are cut away; without, the cuffs drop where they are. Returns the cuffs - * still about, or null. + * Takes their cuffs off through tg's uncuff(). With `user`, real cuffs go to their hands (or the floor) + * and cable restraints and zipties are cut away; without, the cuffs drop where they are. Returns the + * cuffs still about, or null. */ -/mob/living/basic/outpost_prisoner/proc/remove_cuffs(mob/living/user) - var/obj/item/restraints/handcuffs/worn = cuffs +/mob/living/carbon/human/npc/outpost_prisoner/proc/remove_cuffs(mob/living/user) + var/obj/item/restraints/handcuffs/worn = handcuffed if(!worn) return null - // Cleared first, so Exited() leaves the rest to this proc. - cuffs = null + uncuff() + if(QDELETED(worn)) + return null if(user && istype(worn, /obj/item/restraints/handcuffs/cable)) qdel(worn) - worn = null - else - worn.forceMove(drop_location()) - if(user) - user.put_in_hands(worn) - uncuffed() + return null + user?.put_in_hands(worn) return worn /// The cuffs are off, however they came off -/mob/living/basic/outpost_prisoner/proc/uncuffed() - REMOVE_TRAIT(src, TRAIT_IMMOBILIZED, PRISONER_CUFFS_TRAIT) +/mob/living/carbon/human/npc/outpost_prisoner/proc/uncuffed() if(QDELETED(src)) return - update_drag_resistance() - update_appearance(UPDATE_OVERLAYS) prison?.refresh_prisoner_reach(src) -// ===== CUFFED ===== +/// Cuffs on or off (tg's TRAIT_RESTRAINED) +/mob/living/carbon/human/npc/outpost_prisoner/proc/on_restraint_changed() + if(QDELETED(src)) + return + if(handcuffed) + INVOKE_ASYNC(src, PROC_REF(on_cuffed)) + else + INVOKE_ASYNC(src, PROC_REF(uncuffed)) -// Cuffed hands throw no punches, whatever their AI wants. -/mob/living/basic/outpost_prisoner/early_melee_attack(atom/target, list/modifiers, ignore_cooldown = FALSE) - if(cuffs) - return FALSE - return ..() +// ===== CUFFED ===== /// Whether their cuffs are souring them and stopping their pay: on past PRISONER_CUFFED_GRACE, and not for good reason -/mob/living/basic/outpost_prisoner/proc/cuffs_souring() +/mob/living/carbon/human/npc/outpost_prisoner/proc/cuffs_souring() return cuffed_seconds > PRISONER_CUFFED_GRACE && !prison?.restraint_justified(src) /// Whether restraining a prisoner is for good reason right now, so it costs them nothing: protective custody, or lockdown they owe -/datum/outpost_prison/proc/restraint_justified(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/restraint_justified(mob/living/carbon/human/npc/outpost_prisoner/prisoner) return prisoner.lockdown_left > 0 || protective_custody() /** * Advances a prisoner's cuffed clock by `seconds`: up while cuffed without good reason, and down * PRISONER_LOCKED_IN_RECOVERY seconds a second once the cuffs are off, like the lock-in clock. */ -/datum/outpost_prison/proc/update_cuffed(mob/living/basic/outpost_prisoner/prisoner, seconds) - if(prisoner.cuffs) +/datum/outpost_prison/proc/update_cuffed(mob/living/carbon/human/npc/outpost_prisoner/prisoner, seconds) + if(prisoner.handcuffed) if(!restraint_justified(prisoner)) prisoner.cuffed_seconds += seconds return prisoner.cuffed_seconds = max(0, prisoner.cuffed_seconds - PRISONER_LOCKED_IN_RECOVERY * seconds) -/// Cuffed, they plan nothing: no routine, no trouble, no patrol, no doors. First on both prisoner controllers. +/// Cuffed, they choose to plan nothing: no routine, no trouble, no patrol, no doors. First on both prisoner controllers. /datum/ai_planning_subtree/outpost_prisoner_cuffed /datum/ai_planning_subtree/outpost_prisoner_cuffed/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/outpost_prisoner/prisoner = controller.pawn - if(istype(prisoner) && prisoner.cuffs) + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = controller.pawn + if(istype(prisoner) && prisoner.handcuffed) return SUBTREE_RETURN_FINISH_PLANNING // ===== LOCKDOWN ===== /// They owe PRISON_RIOT_LOCKDOWN_TIME of lockdown from now. `quiet` leaves the line to the caller. -/datum/outpost_prison/proc/start_lockdown(mob/living/basic/outpost_prisoner/prisoner, quiet = FALSE) +/datum/outpost_prison/proc/start_lockdown(mob/living/carbon/human/npc/outpost_prisoner/prisoner, quiet = FALSE) prisoner.lockdown_left = PRISON_RIOT_LOCKDOWN_TIME prisoner.lockdown_out = 0 add_log("[prisoner.real_name] is on lockdown.") @@ -251,7 +189,7 @@ * out early. Down, cuffed or loose, the grace waits, and so does it while the cell they were serving * in is still bolted: they got out through a hole, and nobody let them out. */ -/datum/outpost_prison/proc/lockdown_tick(mob/living/basic/outpost_prisoner/prisoner, seconds) +/datum/outpost_prison/proc/lockdown_tick(mob/living/carbon/human/npc/outpost_prisoner/prisoner, seconds) if(prisoner.lockdown_left <= 0) prisoner.lockdown_out = 0 prisoner.lockdown_cell_ref = null @@ -274,7 +212,7 @@ let_out_early(prisoner) /// Served: the warden's log notes it once, and the prisoner says so. The usual lock-in rules apply again. -/datum/outpost_prison/proc/lockdown_served(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/lockdown_served(mob/living/carbon/human/npc/outpost_prisoner/prisoner) prisoner.lockdown_left = 0 prisoner.lockdown_out = 0 prisoner.lockdown_cell_ref = null @@ -286,7 +224,7 @@ * Let out before the lockdown was served: logged once, and they riot again, joining a riot * that is on or starting one whatever the quiet after the last. Returns TRUE if they are rioting. */ -/datum/outpost_prison/proc/let_out_early(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/let_out_early(mob/living/carbon/human/npc/outpost_prisoner/prisoner) prisoner.lockdown_left = 0 prisoner.lockdown_out = 0 add_log("[prisoner.real_name] was let out before their lockdown was up.") @@ -309,12 +247,10 @@ // ===== WHERE STAFF LOOK ===== -/mob/living/basic/outpost_prisoner/examine(mob/user) +/mob/living/carbon/human/npc/outpost_prisoner/examine(mob/user) . = ..() if(stat == DEAD) return - if(cuffs) - . += span_warning("[p_They()] [p_are()] handcuffed.") if(lockdown_left > 0) . += span_notice("On lockdown for [outpost_prison_lockdown_text(lockdown_left)].") @@ -324,7 +260,7 @@ var/datum/outpost_prison_cell/cell = prison?.cell_by_number(cell_number) if(!cell) return - for(var/mob/living/basic/outpost_prisoner/prisoner in prison.prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prison.prisoners) if(prisoner.lockdown_left <= 0 || prisoner.stat == DEAD || prisoner.phase != PRISONER_PRESENT) continue var/inside = cell.contains(prisoner) @@ -335,4 +271,3 @@ line += " [prisoner.p_They()] [prisoner.p_are()] not in the cell." . += span_notice(line) -#undef PRISONER_CUFFS_TRAIT diff --git a/voidcrew/modules/player_outposts/outpost_prison_changeling.dm b/voidcrew/modules/player_outposts/outpost_prison_changeling.dm index c621aff305f..ab3137d6a6f 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_changeling.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_changeling.dm @@ -71,7 +71,7 @@ * calls this once the host has eaten the tainted food. Returns the event, or null if it cannot * start (a dead host, someone else's prisoner, or a changeling already running in the wing). */ -/proc/outpost_changeling_infect(mob/living/basic/outpost_prisoner/host, datum/outpost_prison/prison) +/proc/outpost_changeling_infect(mob/living/carbon/human/npc/outpost_prisoner/host, datum/outpost_prison/prison) if(QDELETED(host) || QDELETED(prison) || host.stat == DEAD || host.prison != prison) return null if(prison.active_changeling && prison.active_changeling.stage != "done") @@ -89,7 +89,7 @@ /// Why it ended, once it has var/end_reason var/datum/outpost_prison/prison - var/mob/living/basic/outpost_prisoner/host + var/mob/living/carbon/human/npc/outpost_prisoner/host var/mob/living/basic/headslug/beakless/outpost/slug var/mob/living/basic/outpost_experiment/horror/horror /// The vent the slug is in, or the one that is giving way @@ -141,7 +141,7 @@ /// Prisoners whose deaths are watched while a creature is loose var/list/watched_prisoners = list() -/datum/outpost_changeling_event/New(mob/living/basic/outpost_prisoner/new_host, datum/outpost_prison/new_prison) +/datum/outpost_changeling_event/New(mob/living/carbon/human/npc/outpost_prisoner/new_host, datum/outpost_prison/new_prison) . = ..() prison = new_prison prison.active_changeling = src @@ -256,21 +256,41 @@ // ===== THE HOST ===== -/datum/outpost_changeling_event/proc/link_host(mob/living/basic/outpost_prisoner/new_host) +/datum/outpost_changeling_event/proc/link_host(mob/living/carbon/human/npc/outpost_prisoner/new_host) host = new_host host.experiment_subject = TRUE host.update_bubble() RegisterSignal(host, COMSIG_LIVING_DEATH, PROC_REF(on_host_death)) RegisterSignal(host, COMSIG_QDELETING, PROC_REF(on_host_deleted)) + // EX-8: the specimen is a real thing in their chest, which surgery can cut out. + var/obj/item/organ/body_egg/outpost_specimen/specimen = new() + specimen.event_ref = WEAKREF(src) + if(!specimen.Insert(new_host, special = TRUE)) + qdel(specimen) + +/// The specimen in the host, if there is one +/datum/outpost_changeling_event/proc/host_specimen() + if(QDELETED(host)) + return null + return locate(/obj/item/organ/body_egg/outpost_specimen) in host.organs + +/// Takes the specimen out of the host for good, as the burst or the end of the experiment does +/datum/outpost_changeling_event/proc/remove_specimen() + var/obj/item/organ/body_egg/outpost_specimen/specimen = host_specimen() + if(!specimen) + return + specimen.event_ref = null + specimen.Remove(specimen.owner, special = TRUE) + qdel(specimen) /// Lets go of the host: signals off and back on their feet. `cured` also ends their part in the experiment. /datum/outpost_changeling_event/proc/release_host(cured = FALSE) if(!host) return - var/mob/living/basic/outpost_prisoner/was_host = host + remove_specimen() + var/mob/living/carbon/human/npc/outpost_prisoner/was_host = host host = null UnregisterSignal(was_host, list(COMSIG_LIVING_DEATH, COMSIG_QDELETING)) - was_host.remove_traits(list(TRAIT_FLOORED, TRAIT_INCAPACITATED, TRAIT_IMMOBILIZED), CHANGELING_HOST_TRAIT) if(istype(was_host.activity, /datum/prisoner_activity/changeling_bed)) was_host.end_activity() if(cured && !QDELETED(was_host)) @@ -319,7 +339,7 @@ if(!said_pain && incubation_elapsed >= OUTPOST_CHANGELING_TELL_PAIN) said_pain = TRUE INVOKE_ASYNC(host, TYPE_PROC_REF(/atom, manual_emote), "rubs [host.p_their()] stomach and winces.") - INVOKE_ASYNC(host, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context), "experiment_dose") + INVOKE_ASYNC(host, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context), "experiment_dose") prison.add_log("[host.real_name] complains of stomach pain.") return if(!said_retch && incubation_elapsed >= OUTPOST_CHANGELING_TELL_RETCH) @@ -368,25 +388,33 @@ heave_left = rand(3, 5) heave() -/// The host goes down, on their bunk if they got there: groaning, and draggable +/** + * The host goes down, on their bunk if they got there: groaning, and draggable. They lie down the way + * anyone sick does, and the heaves keep knocking them flat (heave()). + */ /datum/outpost_changeling_event/proc/host_lie_down() if(host_down || QDELETED(host)) return host_down = TRUE - host.add_traits(list(TRAIT_FLOORED, TRAIT_INCAPACITATED, TRAIT_IMMOBILIZED), CHANGELING_HOST_TRAIT) + host.set_resting(TRUE, silent = TRUE) + host.Knockdown(OUTPOST_CHANGELING_HOST_KNOCKDOWN) host.visible_message(span_warning("[host] curls up, groaning, arms wrapped around [host.p_their()] belly.")) -/// The host's belly heaves; now and then a neighbour notices +/// The host's belly heaves, and they are sick and knocked flat by it; now and then a neighbour notices /datum/outpost_changeling_event/proc/heave() host.Shake(1, 0, 0.6 SECONDS) playsound(host, 'sound/effects/meatslap.ogg', 15, TRUE, -2) + if(host.stat != DEAD) + if(prob(40)) + host.vomit(VOMIT_CATEGORY_KNOCKDOWN, lost_nutrition = 0) + host.Knockdown(OUTPOST_CHANGELING_HOST_KNOCKDOWN) if(prob(50)) host.visible_message(span_warning("Something moves under [host]'s jumpsuit. [host.p_Their()] belly heaves.")) else INVOKE_ASYNC(host, TYPE_PROC_REF(/atom, manual_emote), pick("groans.", "moans.", "whimpers.")) if(!prob(30)) return - for(var/mob/living/basic/outpost_prisoner/neighbour in shuffle(prison.prisoners)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/neighbour in shuffle(prison.prisoners)) if(neighbour == host || neighbour.stat != CONSCIOUS || neighbour.phase != PRISONER_PRESENT || !(host in view(6, neighbour))) continue INVOKE_ASYNC(neighbour, TYPE_PROC_REF(/atom, manual_emote), pick("stares at [host].", "backs away from [host].", "covers [neighbour.p_their()] mouth.", "calls out to [host]. No answer.")) @@ -427,7 +455,7 @@ if(!spot) lose_specimen("the host is gone") return FALSE - var/mob/living/basic/outpost_prisoner/victim = host + var/mob/living/carbon/human/npc/outpost_prisoner/victim = host release_host() stage = "burst" early_burst_left = 0 @@ -495,7 +523,7 @@ /// Prisoners who saw it scream /datum/outpost_changeling_event/proc/scream_near(turf/spot) var/screamed = 0 - for(var/mob/living/basic/outpost_prisoner/witness in view(7, spot)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/witness in view(7, spot)) if(witness.stat != CONSCIOUS || witness.phase != PRISONER_PRESENT || witness.can_be_dragged()) continue INVOKE_ASYNC(witness, TYPE_PROC_REF(/atom, manual_emote), pick("screams!", "shrieks and scrambles back!", "yells in horror!")) @@ -656,13 +684,13 @@ if(level < 2 || !prison.wing_can_speak()) return FALSE var/context = level >= 3 ? "creature_panic" : "vent_noise" - for(var/mob/living/basic/outpost_prisoner/listener in shuffle(prison.prisoners)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/listener in shuffle(prison.prisoners)) if(listener.stat != CONSCIOUS || listener.phase != PRISONER_PRESENT || listener.can_be_dragged() || !listener.ai_running()) continue if(get_dist(listener, vent) > 7) continue prison.note_speech() - INVOKE_ASYNC(listener, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context), context) + INVOKE_ASYNC(listener, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context), context) return TRUE return FALSE @@ -813,13 +841,13 @@ /datum/outpost_changeling_event/proc/horror_remark(context) if(QDELETED(horror) || QDELETED(prison) || !prison.wing_can_speak()) return FALSE - for(var/mob/living/basic/outpost_prisoner/witness in shuffle(prison.prisoners)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/witness in shuffle(prison.prisoners)) if(witness.stat != CONSCIOUS || witness.phase != PRISONER_PRESENT || witness.can_be_dragged() || !witness.ai_running()) continue if(!(horror in view(7, witness))) continue prison.note_speech() - INVOKE_ASYNC(witness, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context), context) + INVOKE_ASYNC(witness, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context), context) return TRUE return FALSE @@ -909,7 +937,7 @@ /datum/outpost_changeling_event/proc/panic_prisoners() panicked = TRUE var/shouts = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prison.prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prison.prisoners) if(prisoner == host || !prisoner.routine_allowed() || prisoner.is_confined()) continue if(istype(prisoner.activity, /datum/prisoner_activity/flee_creature) || istype(prisoner.activity, /datum/prisoner_activity/creature_panic)) @@ -921,11 +949,11 @@ prisoner.start_activity(flee) if(shouts < 2 && prisoner.ai_running()) shouts++ - INVOKE_ASYNC(prisoner, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context), "creature_panic") + INVOKE_ASYNC(prisoner, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context), "creature_panic") /// Watches the prisoners' deaths while a creature is loose /datum/outpost_changeling_event/proc/watch_prisoners() - for(var/mob/living/basic/outpost_prisoner/prisoner in prison.prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prison.prisoners) if(prisoner.stat == DEAD || watched_prisoners[prisoner]) continue watched_prisoners[prisoner] = TRUE @@ -933,7 +961,7 @@ RegisterSignal(prisoner, COMSIG_QDELETING, PROC_REF(on_watched_prisoner_deleted)) /datum/outpost_changeling_event/proc/unwatch_prisoners() - for(var/mob/living/basic/outpost_prisoner/prisoner as anything in watched_prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner as anything in watched_prisoners) UnregisterSignal(prisoner, list(COMSIG_LIVING_DEATH, COMSIG_QDELETING)) watched_prisoners.Cut() @@ -943,7 +971,7 @@ watched_prisoners -= source /// A prisoner died while a creature was loose: the creature's kill if it was beside them -/datum/outpost_changeling_event/proc/on_prisoner_died(mob/living/basic/outpost_prisoner/victim, gibbed) +/datum/outpost_changeling_event/proc/on_prisoner_died(mob/living/carbon/human/npc/outpost_prisoner/victim, gibbed) SIGNAL_HANDLER var/mob/living/creature = current_creature() note_death(victim, creature && get_dist(creature, victim) <= 2) @@ -962,7 +990,7 @@ var/turf/spot = get_turf(victim) if(!spot) return TRUE - for(var/mob/living/basic/outpost_prisoner/witness in view(7, spot)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/witness in view(7, spot)) if(witness == victim || witness.stat != CONSCIOUS || witness.phase != PRISONER_PRESENT) continue witnesses |= WEAKREF(witness) @@ -978,7 +1006,7 @@ if(QDELETED(prison)) return for(var/datum/weakref/ref as anything in witnesses) - var/mob/living/basic/outpost_prisoner/witness = ref.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/witness = ref.resolve() if(QDELETED(witness) || witness.stat == DEAD || !(witness in prison.prisoners)) continue witness.adjust_mood(-OUTPOST_CHANGELING_WITNESS_MOOD) @@ -1421,3 +1449,34 @@ #undef CHANGELING_HOST_TRAIT #undef HEADSLUG_VENT_TRAIT #undef BB_OUTPOST_HEADSLUG_VENT + +// ===== THE SPECIMEN IN A BODY ===== + +/** + * The specimen growing in a host with a body (EX-8): a real organ in the chest, as tg's alien embryo is. + * The event's clock grows it and bursts the host; the organ is what is there to find on a scanner or cut + * out in surgery. Cut out, it dies, and the experiment loses its specimen. + */ +/obj/item/organ/body_egg/outpost_specimen + name = "Kessler specimen" + desc = "A small, wet, curled-up thing that never stops moving." + icon_state = "innards" + /// The changeling event it is part of + var/datum/weakref/event_ref + +/obj/item/organ/body_egg/outpost_specimen/Destroy() + event_ref = null + return ..() + +/obj/item/organ/body_egg/outpost_specimen/on_mob_remove(mob/living/carbon/egg_owner, special, movement_flags) + . = ..() + // The event's own removals (the burst, the end of the experiment) are special. + if(special) + return + var/datum/outpost_changeling_event/event = event_ref?.resolve() + event_ref = null + // Cut out: it dies outside a body, and the specimen is lost. + if(event) + INVOKE_ASYNC(event, TYPE_PROC_REF(/datum/outpost_changeling_event, lose_specimen), "the specimen was cut out") + visible_message(span_warning("[src] shudders and goes still.")) + QDEL_IN(src, 1) diff --git a/voidcrew/modules/player_outposts/outpost_prison_conditions.dm b/voidcrew/modules/player_outposts/outpost_prison_conditions.dm index 287e720cf6f..46ce61e5564 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_conditions.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_conditions.dm @@ -24,9 +24,7 @@ /// How often mess, air and rats are refreshed, in seconds #define PRISON_MESS_REFRESH_SECONDS 5 -/// Seconds per step of damage from bad air -#define PRISON_AIR_STEP_SECONDS 5 -/// Percent chance a prisoner hurt by bad air says so +/// Percent chance a prisoner on bad air says so, each check #define PRISON_AIR_LINE_CHANCE 15 /// Mess weight by type (see PRISON_MESS_WEIGHT_*); types not listed are not mess @@ -530,7 +528,7 @@ GLOBAL_LIST_INIT(outpost_prison_furniture_types, zebra_typecacheof(list( /datum/outpost_prison/proc/check_battery() var/battery = battery_percent() if(!isnull(battery) && !isnull(last_battery) && last_battery >= PRISON_BATTERY_WARNING && battery < PRISON_BATTERY_WARNING) - var/mob/living/basic/outpost_prisoner/speaker = pick_conditions_speaker() + var/mob/living/carbon/human/npc/outpost_prisoner/speaker = pick_conditions_speaker() if(speaker?.say_context("lights_flicker")) note_speech() last_battery = battery @@ -572,7 +570,7 @@ GLOBAL_LIST_INIT(outpost_prison_furniture_types, zebra_typecacheof(list( * no power costs in proportion; a clean, lit, powered wing is a small comfort; and a dark cell of * their own costs a little more. */ -/mob/living/basic/outpost_prisoner/proc/wing_mood_per_minute() +/mob/living/carbon/human/npc/outpost_prisoner/proc/wing_mood_per_minute() var/loss = 0 var/gain = 0 if(prison && trouble != PRISONER_TROUBLE_LOOSE) @@ -587,20 +585,18 @@ GLOBAL_LIST_INIT(outpost_prison_furniture_types, zebra_typecacheof(list( // ===== AIR ===== -/// Prisoners on bad air lose a little health every PRISON_AIR_STEP_SECONDS, never below PRISON_AIR_HEALTH_FLOOR percent +/** + * Bad air is tg's own: prisoners breathe like anyone, and a breach, a fire or a plasma leak hurts them + * the way it hurts the crew. Each check, a prisoner on bad air may say so, and goes for a mask and a tank + * from the cell block's emergency locker (outpost_prison_breach.dm); once they wear one, they breathe + * from it while the air is bad. + */ /datum/outpost_prison/proc/air_tick(seconds) - var/steps = max(1, round(seconds / PRISON_AIR_STEP_SECONDS)) - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.phase != PRISONER_PRESENT || prisoner.stat == DEAD || !outpost_prison_unsafe_air(prisoner.loc?.return_air())) continue - var/hurt = FALSE - for(var/i in 1 to steps) - var/above_floor = prisoner.health - prisoner.maxHealth * PRISON_AIR_HEALTH_FLOOR / 100 - if(above_floor <= 0) - break - prisoner.adjustBruteLoss(min(PRISON_AIR_DAMAGE, above_floor)) - hurt = TRUE - if(hurt && prisoner.stat == CONSCIOUS && prob(PRISON_AIR_LINE_CHANCE) && wing_can_speak() && prisoner.say_context("no_air")) + prisoner.on_bad_air() + if(prisoner.stat == CONSCIOUS && prob(PRISON_AIR_LINE_CHANCE) && wing_can_speak() && prisoner.say_context("no_air")) note_speech() /// Whether air is too thin, too thick, too hot, too cold or too full of plasma to live in @@ -652,7 +648,7 @@ GLOBAL_LIST_INIT(outpost_prison_furniture_types, zebra_typecacheof(list( var/mob/living/basic/mouse/rat = new(spot) rat_refs += WEAKREF(rat) log_game("PLAYER OUTPOST PRISON: a rat turned up in the prison wing at '[outpost?.name]'") - for(var/mob/living/basic/outpost_prisoner/prisoner in view(7, spot)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in view(7, spot)) if(prisoner.prison == src && prisoner.stat == CONSCIOUS && prisoner.say_context("rat")) note_speech() break @@ -661,7 +657,7 @@ GLOBAL_LIST_INIT(outpost_prison_furniture_types, zebra_typecacheof(list( /// Someone in the wing to remark on its state /datum/outpost_prison/proc/pick_conditions_speaker() var/list/candidates = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.phase == PRISONER_PRESENT && prisoner.stat == CONSCIOUS && prisoner.trouble != PRISONER_TROUBLE_LOOSE) candidates += prisoner return length(candidates) ? pick(candidates) : null diff --git a/voidcrew/modules/player_outposts/outpost_prison_containment.dm b/voidcrew/modules/player_outposts/outpost_prison_containment.dm index 077e9c53675..2e9538328ab 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_containment.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_containment.dm @@ -116,7 +116,7 @@ * pulled by a member of the wing who may use the door. Visitors let in may use the door, but * never take a prisoner with them, so nobody but the wing's own people can drag one off the outpost. */ -/proc/outpost_prisoner_escorted(atom/door, mob/living/basic/outpost_prisoner/prisoner) +/proc/outpost_prisoner_escorted(atom/door, mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(!istype(prisoner) || !prisoner.can_be_dragged()) return FALSE var/mob/living/puller = prisoner.pulledby @@ -165,7 +165,7 @@ /// Refreshes where every prisoner can walk and reach. The prisoners share one look at each tile. /datum/outpost_prison/proc/refresh_reach() var/list/standable = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) refresh_prisoner_reach(prisoner, standable) /** @@ -174,7 +174,7 @@ * seen through the office windows is not. `standable` (turf = whether a prisoner can stand there) * is shared by every prisoner in one refresh, so each tile is looked at once. */ -/datum/outpost_prison/proc/refresh_prisoner_reach(mob/living/basic/outpost_prisoner/prisoner, list/standable) +/datum/outpost_prison/proc/refresh_prisoner_reach(mob/living/carbon/human/npc/outpost_prisoner/prisoner, list/standable) var/list/walked = list() var/list/reach = list() var/turf/start = get_turf(prisoner) @@ -244,6 +244,8 @@ if(!found[tile] && !isclosedturf(tile)) staff_ground[tile] = TRUE record_layout() + // Masks and tanks for a breach (outpost_prison_breach.dm) + ensure_emergency_lockers() /** * Whether the cell block flood carries on through a tile. Only the wing's structure stops it: @@ -413,49 +415,52 @@ /** * Hooks up what keeps a prisoner contained; called from Initialize(). Teleports fail, forced ones - * included (drop pods, quantum pads); polymorph and type changes fail; and a dead prisoner stays - * dead: anything that tries to bring them back gets the body collected at once instead. - * TRAIT_NO_TRANSFORM would stop polymorph too, but it also stops their AI moving them. + * included (drop pods, quantum pads); polymorph and type changes fail. A dead prisoner can be brought + * back like anyone (on_revived()). TRAIT_NO_TRANSFORM would stop polymorph too, but it also stops their + * AI moving them. */ -/mob/living/basic/outpost_prisoner/proc/setup_containment() +/mob/living/carbon/human/npc/outpost_prisoner/proc/setup_containment() RegisterSignal(src, COMSIG_MOVABLE_TELEPORTING, PROC_REF(refuse_teleport)) RegisterSignal(src, COMSIG_LIVING_PRE_WABBAJACKED, PROC_REF(refuse_polymorph)) RegisterSignal(src, COMSIG_PRE_MOB_CHANGED_TYPE, PROC_REF(refuse_type_change)) - RegisterSignal(src, COMSIG_LIVING_REVIVE, PROC_REF(on_revive_attempt)) + RegisterSignal(src, COMSIG_LIVING_REVIVE, PROC_REF(on_revived)) -/mob/living/basic/outpost_prisoner/proc/refuse_teleport(datum/source, atom/destination, channel) +/mob/living/carbon/human/npc/outpost_prisoner/proc/refuse_teleport(datum/source, atom/destination, channel) SIGNAL_HANDLER if(isturf(loc)) visible_message(span_notice("[src] flickers for a moment, but stays where [p_they()] [p_are()].")) return TRUE -/mob/living/basic/outpost_prisoner/proc/refuse_polymorph(datum/source, what_to_randomize) +/mob/living/carbon/human/npc/outpost_prisoner/proc/refuse_polymorph(datum/source, what_to_randomize) SIGNAL_HANDLER visible_message(span_notice("[src] shimmers for a moment, then looks the same as before.")) return STOP_WABBAJACK -/mob/living/basic/outpost_prisoner/proc/refuse_type_change(datum/source) +/mob/living/carbon/human/npc/outpost_prisoner/proc/refuse_type_change(datum/source) SIGNAL_HANDLER return COMPONENT_BLOCK_MOB_CHANGE -/// The dead stay dead: the corrections service has already logged the death, whether or not the body is still in the cell block -/mob/living/basic/outpost_prisoner/can_be_revived() - if(died_at || (prison && phase == PRISONER_PRESENT)) - return FALSE - return ..() - -/// Someone tried to bring a dead prisoner back -/mob/living/basic/outpost_prisoner/proc/on_revive_attempt(datum/source, full_heal_flags) +/** + * Brought back (a defibrillator, strange reagent: tg's revival works on them as on anyone). Still on the + * roster, they are the same inmate again: the death stays on the books (its record closed, the yard's + * blame not taken back) and the log says so. Revived after their body left the roster, the corrections + * service takes them back off the outpost. + */ +/mob/living/carbon/human/npc/outpost_prisoner/proc/on_revived(datum/source, full_heal_flags) SIGNAL_HANDLER - if(stat != DEAD || !prison || phase != PRISONER_PRESENT) + if(prison && phase == PRISONER_PRESENT) + if(died_at) + prison.add_log("[real_name] was revived. The corrections service has already logged the death.") + died_at = 0 return - prison.add_log("Someone tried to revive [real_name]. The corrections service has already logged the death.") + if(phase != PRISONER_LEAVING) + INVOKE_ASYNC(src, PROC_REF(beam_out)) /** * Whether they are shut in their cell: standing in a cell with its door bolted shut, or with * nowhere to walk but the cell and its doorway (a welded, walled-in or unpowered door). */ -/mob/living/basic/outpost_prisoner/proc/is_confined() +/mob/living/carbon/human/npc/outpost_prisoner/proc/is_confined() var/datum/outpost_prison_cell/holding = prison?.cell_at(get_turf(src)) if(!holding) return FALSE diff --git a/voidcrew/modules/player_outposts/outpost_prison_contraband.dm b/voidcrew/modules/player_outposts/outpost_prison_contraband.dm index b61ff885838..98cb3a30eb6 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_contraband.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_contraband.dm @@ -39,7 +39,7 @@ /// world.time a search of this cell last cost its owner mood var/searched_at = 0 -/mob/living/basic/outpost_prisoner +/mob/living/carbon/human/npc/outpost_prisoner /// Seconds their mood has stayed low enough to make a shiv, and to brew pruno var/contraband_shiv_sour = 0 var/contraband_brew_sour = 0 @@ -62,12 +62,12 @@ // ===== THE PRISONER'S SIDE ===== /// Hooks up the prisoner's side of contraband and mail (the letter hand-over); called from setup_extras() -/mob/living/basic/outpost_prisoner/proc/setup_contraband() +/mob/living/carbon/human/npc/outpost_prisoner/proc/setup_contraband() // An element, since the prisoner's own handler for item use already takes the signal (outpost_prison_mail.dm) AddElement(/datum/element/outpost_prison_mail_handover) /// The sour clocks, the drink wearing off and the drunk's sway -/mob/living/basic/outpost_prisoner/proc/contraband_counters(seconds) +/mob/living/carbon/human/npc/outpost_prisoner/proc/contraband_counters(seconds) // Each sour clock counts while mood is under its line, holds just above it, and resets once they cheer up if(mood >= OUTPOST_CONTRABAND_SOUR_RESET) contraband_shiv_sour = 0 @@ -87,19 +87,19 @@ if(stat == CONSCIOUS && isturf(loc) && !buckled) Shake(1, 0, 0.5 SECONDS) -/mob/living/basic/outpost_prisoner/proc/contraband_drunk() +/mob/living/carbon/human/npc/outpost_prisoner/proc/contraband_drunk() return contraband_drunk_left > 0 /// Whether they have been sour long enough to make a shiv, and their cell has none -/mob/living/basic/outpost_prisoner/proc/contraband_can_make_shiv() +/mob/living/carbon/human/npc/outpost_prisoner/proc/contraband_can_make_shiv() return cell && !cell.stash_shiv && contraband_shiv_sour >= OUTPOST_CONTRABAND_SOUR_TIME /// Whether they have been grumbling long enough to brew, and their cell's cistern has no pruno -/mob/living/basic/outpost_prisoner/proc/contraband_can_brew() +/mob/living/carbon/human/npc/outpost_prisoner/proc/contraband_can_brew() return cell && contraband_brew_sour >= OUTPOST_CONTRABAND_BREW_SOUR_TIME && !prison?.contraband_pruno(cell) /// Hides `thing` (a razor blade or yeast from the mail) on them until they can stash it. FALSE if they already carry something. -/mob/living/basic/outpost_prisoner/proc/contraband_carry(obj/item/thing) +/mob/living/carbon/human/npc/outpost_prisoner/proc/contraband_carry(obj/item/thing) if(QDELETED(thing) || carried_contraband) return FALSE thing.forceMove(src) @@ -110,12 +110,12 @@ return TRUE /// Forgets what they carried, leaving the item wherever it is -/mob/living/basic/outpost_prisoner/proc/contraband_clear_carried() +/mob/living/carbon/human/npc/outpost_prisoner/proc/contraband_clear_carried() if(carried_contraband) UnregisterSignal(carried_contraband, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING)) carried_contraband = null -/mob/living/basic/outpost_prisoner/proc/on_carried_contraband_moved(obj/item/source) +/mob/living/carbon/human/npc/outpost_prisoner/proc/on_carried_contraband_moved(obj/item/source) SIGNAL_HANDLER if(source != carried_contraband) UnregisterSignal(source, list(COMSIG_MOVABLE_MOVED, COMSIG_QDELETING)) @@ -124,7 +124,7 @@ contraband_clear_carried() /// A new arrival finds what the last occupant left and says so, if it is still there -/mob/living/basic/outpost_prisoner/proc/contraband_remark_inherited() +/mob/living/carbon/human/npc/outpost_prisoner/proc/contraband_remark_inherited() if(stat != CONSCIOUS || phase != PRISONER_PRESENT || !cell || in_trouble()) return FALSE if(!cell.stash_shiv && !prison?.contraband_pruno(cell)) @@ -139,7 +139,7 @@ /// Sour clocks, shiv making, brewing and drinking, and the cells' beds and toilets /datum/outpost_prison/proc/contraband_tick(seconds) - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.phase != PRISONER_PRESENT || prisoner.stat == DEAD) continue prisoner.contraband_counters(seconds) @@ -151,12 +151,12 @@ return contraband_clock = 0 contraband_hook_fixtures() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.phase != PRISONER_PRESENT || prisoner.stat != CONSCIOUS) continue // Nobody on the level: whatever came in the mail is stashed wherever they are, unless they are cuffed if(prisoner.carried_contraband && !prisoner.ai_running()) - if(!prisoner.cuffs) + if(!prisoner.handcuffed) contraband_stash_carried(prisoner) continue contraband_try_start(prisoner) @@ -166,7 +166,7 @@ * they are free, nothing more pressing has them busy and no staff are in sight. Returns the * activity started, or null. */ -/datum/outpost_prison/proc/contraband_try_start(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/contraband_try_start(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(!prisoner.ai_running() || !prisoner.routine_allowed() || !prisoner.cell) return null var/datum/prisoner_activity/current = prisoner.activity @@ -188,14 +188,14 @@ return stash /// Staff (on-duty guards included) who can see `prisoner`, or null -/datum/outpost_prison/proc/contraband_watcher(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/contraband_watcher(mob/living/carbon/human/npc/outpost_prisoner/prisoner) for(var/mob/living/person in view(OUTPOST_CONTRABAND_WATCH_RANGE, prisoner)) if(is_outpost_prison_staff(person)) return person return null /// Caught at it: they stop, deny it, and have to sour all over again before the next try -/datum/outpost_prison/proc/contraband_caught(mob/living/basic/outpost_prisoner/prisoner, mob/living/watcher, shiv = TRUE) +/datum/outpost_prison/proc/contraband_caught(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/watcher, shiv = TRUE) if(shiv) prisoner.contraband_shiv_sour = 0 else @@ -268,7 +268,7 @@ return TRUE /// A prisoner drinks the pruno in their cell's cistern: a lift, then a while drunk. Returns TRUE if they drank. -/datum/outpost_prison/proc/contraband_drink(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/contraband_drink(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/obj/item/reagent_containers/cup/glass/bottle/pruno/bag = contraband_pruno(prisoner?.cell) if(!outpost_prison_pruno_ready(bag)) return FALSE @@ -281,7 +281,7 @@ return TRUE /// Home and unwatched, with the AI running: whatever came in the mail goes into hiding -/datum/outpost_prison/proc/contraband_try_stash_carried(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/contraband_try_stash_carried(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(!prisoner.cell?.contains(prisoner) || !prisoner.routine_allowed() || contraband_watcher(prisoner)) return FALSE return contraband_stash_carried(prisoner) @@ -291,7 +291,7 @@ * the cistern. A cell that already has that stash, or no room for it, leaves them carrying it. * Returns TRUE if it was stashed. */ -/datum/outpost_prison/proc/contraband_stash_carried(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/contraband_stash_carried(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/obj/item/thing = prisoner.carried_contraband var/datum/outpost_prison_cell/home = prisoner.cell if(!thing || thing.loc != prisoner || !home) @@ -366,7 +366,7 @@ return COMPONENT_CANCEL_ATTACK_CHAIN if(source.has_buckled_mobs()) // A prisoner lying on it can be told to get up from the talk menu, or shaken awake; the balloon only says who is in the way. - var/mob/living/basic/outpost_prisoner/lying = locate() in source.buckled_mobs + var/mob/living/carbon/human/npc/outpost_prisoner/lying = locate() in source.buckled_mobs source.balloon_alert(user, lying?.activity?.sleeping ? "someone's asleep on it" : "someone's lying on it") return COMPONENT_CANCEL_ATTACK_CHAIN INVOKE_ASYNC(src, PROC_REF(contraband_search_mattress), user, source) @@ -388,7 +388,7 @@ return null if(QDELETED(src) || QDELETED(bed) || QDELETED(user) || cell_at(get_turf(bed)) != cell) return null - var/mob/living/basic/outpost_prisoner/owner = cell.occupant + var/mob/living/carbon/human/npc/outpost_prisoner/owner = cell.occupant if(cell.stash_shiv) cell.stash_shiv = FALSE var/obj/item/knife/shiv/shiv = new(get_turf(user)) @@ -457,7 +457,7 @@ to_chat(user, span_notice("There's nothing in the cistern.")) else to_chat(user, span_notice("You find [english_list(found)] in the cistern.")) - var/mob/living/basic/outpost_prisoner/owner = cell.occupant + var/mob/living/carbon/human/npc/outpost_prisoner/owner = cell.occupant if(!caught) contraband_search_came_up_empty(owner, user, cell) return "empty" @@ -477,11 +477,11 @@ return TRUE /// Whether a cell's owner is there to take it: present, awake and not loose -/datum/outpost_prison/proc/contraband_owner_home(mob/living/basic/outpost_prisoner/owner) +/datum/outpost_prison/proc/contraband_owner_home(mob/living/carbon/human/npc/outpost_prisoner/owner) return !QDELETED(owner) && (owner in prisoners) && owner.stat == CONSCIOUS && owner.phase == PRISONER_PRESENT && owner.trouble != PRISONER_TROUBLE_LOOSE /// Something was found in `owner`'s cell by `finder`: they deny it and lose a little mood -/datum/outpost_prison/proc/contraband_owner_caught(mob/living/basic/outpost_prisoner/owner, mob/living/finder, datum/outpost_prison_cell/cell) +/datum/outpost_prison/proc/contraband_owner_caught(mob/living/carbon/human/npc/outpost_prisoner/owner, mob/living/finder, datum/outpost_prison_cell/cell) if(!contraband_owner_home(owner)) return FALSE if(contraband_search_costs(cell)) @@ -493,12 +493,12 @@ return TRUE /// A search of `owner`'s cell found nothing: the owner and anyone watching take it badly. An empty cell costs nothing. -/datum/outpost_prison/proc/contraband_search_came_up_empty(mob/living/basic/outpost_prisoner/owner, mob/living/searcher, datum/outpost_prison_cell/cell) +/datum/outpost_prison/proc/contraband_search_came_up_empty(mob/living/carbon/human/npc/outpost_prisoner/owner, mob/living/searcher, datum/outpost_prison_cell/cell) if(!contraband_owner_home(owner)) return FALSE if(contraband_search_costs(cell)) owner.adjust_mood(-OUTPOST_CONTRABAND_EMPTY_MOOD) - for(var/mob/living/basic/outpost_prisoner/onlooker in view(OUTPOST_CONTRABAND_WATCH_RANGE, searcher)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/onlooker in view(OUTPOST_CONTRABAND_WATCH_RANGE, searcher)) if(onlooker == owner || !(onlooker in prisoners) || onlooker.stat != CONSCIOUS || onlooker.phase != PRISONER_PRESENT) continue onlooker.adjust_mood(-OUTPOST_CONTRABAND_ONLOOKER_MOOD) @@ -530,13 +530,13 @@ // ===== THE PAT-DOWN ===== /// The pat-down choice for the talk menu: name -> image. Hands on the wall, or held still in cuffs. -/datum/outpost_prison/proc/contraband_talk_choices(mob/living/basic/outpost_prisoner/prisoner, mob/living/user) +/datum/outpost_prison/proc/contraband_talk_choices(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/user) if(!prisoner || !user || !is_member(user)) return list() return list((CONTRABAND_PATDOWN_CHOICE) = image(icon = 'voidcrew/icons/hud/radial.dmi', icon_state = "radial_search")) /// Runs a talk menu choice of this package; TRUE if it was one. May sleep. -/datum/outpost_prison/proc/contraband_talk_act(mob/living/basic/outpost_prisoner/prisoner, mob/living/user, choice) +/datum/outpost_prison/proc/contraband_talk_act(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/user, choice) if(choice != CONTRABAND_PATDOWN_CHOICE) return FALSE contraband_pat_down(prisoner, user) @@ -549,12 +549,12 @@ * in it: rioting, loose or sour, they hold still and are searched, unless someone is already * talking to them or working on their cuffs. Returns "found", "empty" or null. Sleeps. */ -/datum/outpost_prison/proc/contraband_pat_down(mob/living/basic/outpost_prisoner/prisoner, mob/living/user) +/datum/outpost_prison/proc/contraband_pat_down(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/user) if(QDELETED(prisoner) || QDELETED(user) || !is_member(user) || !(prisoner in prisoners)) return null if(prisoner.stat != CONSCIOUS || prisoner.phase != PRISONER_PRESENT) return null - if(prisoner.cuffs) + if(prisoner.handcuffed) if(prisoner.talking || prisoner.cuff_work) prisoner.balloon_alert(user, "busy") return null @@ -571,7 +571,7 @@ prisoner.talking = TRUE prisoner.end_activity() prisoner.stand_up() - if(prisoner.cuffs) + if(prisoner.handcuffed) // Their hands are cuffed already; nothing for them to put on the wall prisoner.face_atom(user) prisoner.manual_emote("stands still to be searched.") @@ -612,11 +612,11 @@ prisoner.say_context("patdown_empty") if(contraband_roll(OUTPOST_CONTRABAND_PATDOWN_ONLOOKER_CHANCE)) var/list/onlookers = list() - for(var/mob/living/basic/outpost_prisoner/onlooker in view(OUTPOST_CONTRABAND_ONLOOKER_RANGE, prisoner)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/onlooker in view(OUTPOST_CONTRABAND_ONLOOKER_RANGE, prisoner)) if(onlooker != prisoner && (onlooker in prisoners) && onlooker.stat == CONSCIOUS && onlooker.phase == PRISONER_PRESENT && !onlooker.in_trouble()) onlookers += onlooker if(length(onlookers)) - var/mob/living/basic/outpost_prisoner/speaker = pick(onlookers) + var/mob/living/carbon/human/npc/outpost_prisoner/speaker = pick(onlookers) speaker.face_atom(user) speaker.say_context("patdown_onlooker", prisoner) note_staff_event(user, prisoner, "patdown_empty") @@ -637,35 +637,35 @@ return contraband_tension() > 0 ? "word of a shiv" : null /// How much higher `prisoner`'s riot line is (a shiv under their mattress, and some bounty prisoners: outpost_prison_bounty.dm) -/datum/outpost_prison/proc/riot_join_bonus(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/riot_join_bonus(mob/living/carbon/human/npc/outpost_prisoner/prisoner) return (prisoner?.cell?.stash_shiv ? OUTPOST_CONTRABAND_RIOT_JOIN_BONUS : 0) + (prisoner ? prisoner.bounty_riot_bonus() : 0) /** * A rioter draws the shiv from their cell's stash instead of a new one; TRUE if they did. Only * start_rioting() calls this: a stash never arms a threat or a fight (decision 8). */ -/datum/outpost_prison/proc/draw_stashed_shiv(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/draw_stashed_shiv(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/datum/outpost_prison_cell/home = prisoner?.cell if(!home?.stash_shiv || prisoner.has_shiv()) return FALSE home.stash_shiv = FALSE prisoner.drop_held_item() - var/obj/item/knife/shiv/shiv = new(prisoner) - prisoner.held_item = shiv - prisoner.update_melee() - prisoner.update_appearance(UPDATE_OVERLAYS) + // The stash comes out into their hand, a real shiv like any other. + var/obj/item/knife/shiv/shiv = new(prisoner.drop_location()) + if(!prisoner.take_item(shiv)) + return FALSE prisoner.manual_emote("pulls out a shiv [prisoner.p_they()] had been saving.") return TRUE /// Multiplier on the chance these two start a fight: either one drunk -/datum/outpost_prison/proc/contraband_fight_mult(mob/living/basic/outpost_prisoner/one, mob/living/basic/outpost_prisoner/two) +/datum/outpost_prison/proc/contraband_fight_mult(mob/living/carbon/human/npc/outpost_prisoner/one, mob/living/carbon/human/npc/outpost_prisoner/two) if(one?.contraband_drunk() || two?.contraband_drunk()) return OUTPOST_CONTRABAND_DRUNK_FIGHT_MULT return 1 /// Multiplier on the wing's chance of a spat: anyone drunk /datum/outpost_prison/proc/contraband_spat_mult() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.phase == PRISONER_PRESENT && prisoner.stat == CONSCIOUS && prisoner.contraband_drunk()) return OUTPOST_CONTRABAND_DRUNK_SPAT_MULT return 1 @@ -673,13 +673,13 @@ // ===== SPEECH AND EXAMINE ===== /// A drunk line `prisoner` wants to say now, as list(context, other), or null -/datum/outpost_prison/proc/contraband_extra_speech(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/contraband_extra_speech(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(prisoner?.contraband_drunk() && prob(50)) return list("drunk", null) return null /// The tells for examine: a hand kept in a pocket, a drunk's sway; or null -/datum/outpost_prison/proc/contraband_examine(mob/living/basic/outpost_prisoner/prisoner, mob/user) +/datum/outpost_prison/proc/contraband_examine(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/user) if(!prisoner || prisoner.stat == DEAD) return null var/list/tells = list() @@ -699,22 +699,22 @@ UnregisterSignal(thing, list(COMSIG_ATOM_ATTACK_HAND, COMSIG_ATOM_ATTACK_HAND_SECONDARY, COMSIG_ATOM_EXITED)) contraband_hooked.Cut() // Prisoners deleted with the prison never pass through forget() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) var/obj/item/thing = prisoner.carried_contraband prisoner.contraband_clear_carried() qdel(thing) /// A new arrival: half the time they notice what the last occupant left, a little after they arrive -/datum/outpost_prison/proc/contraband_prisoner_admitted(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/contraband_prisoner_admitted(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/datum/outpost_prison_cell/home = prisoner?.cell if(!home || (!home.stash_shiv && !contraband_pruno(home))) return if(!contraband_roll(OUTPOST_CONTRABAND_INHERIT_CHANCE)) return - addtimer(CALLBACK(prisoner, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, contraband_remark_inherited)), OUTPOST_CONTRABAND_INHERIT_DELAY) + addtimer(CALLBACK(prisoner, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, contraband_remark_inherited)), OUTPOST_CONTRABAND_INHERIT_DELAY) /// A prisoner is leaving: what they carry goes with them. Their cell's stash stays for the next. -/datum/outpost_prison/proc/contraband_prisoner_leaving(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/contraband_prisoner_leaving(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/obj/item/thing = prisoner.carried_contraband prisoner.contraband_clear_carried() qdel(thing) @@ -734,7 +734,7 @@ )) var/list/drunk = list() var/list/carrying = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.contraband_drunk()) drunk += REF(prisoner) if(prisoner.carried_contraband) diff --git a/voidcrew/modules/player_outposts/outpost_prison_core.dm b/voidcrew/modules/player_outposts/outpost_prison_core.dm index 91f70cae088..82ab99026dc 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_core.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_core.dm @@ -47,7 +47,7 @@ GLOBAL_LIST_EMPTY(outpost_prisons) var/datum/outpost_upgrade/prison/upgrade var/obj/structure/overmap/dynamic/player_outpost/outpost var/area/voidcrew/player_outpost/prison/wing - var/list/mob/living/basic/outpost_prisoner/prisoners = list() + var/list/mob/living/carbon/human/npc/outpost_prisoner/prisoners = list() /// The wing's cells, in number order var/list/datum/outpost_prison_cell/cells = list() /// Prisoners the wing holds at once: one per cell, at most OUTPOST_PRISON_MAX_CAPACITY @@ -108,7 +108,7 @@ GLOBAL_LIST_EMPTY(outpost_prisons) wing.prison = null var/list/leaving = prisoners prisoners = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in leaving) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in leaving) close_bounty_record(prisoner, BOUNTY_RECORD_CLOSED) prisoner.prison = null prisoner.cell = null @@ -325,7 +325,7 @@ GLOBAL_LIST_EMPTY(outpost_prisons) if(supply_clock < PRISON_SUPPLY_REFRESH_SECONDS) return supply_clock = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) prisoner.fend_for_self() prisoner.check_sick_call() check_hatch_shortage() @@ -358,7 +358,7 @@ GLOBAL_LIST_EMPTY(outpost_prisons) dirty_suits++ // How long it lasts at the usual rates, for the prisoners here (or a full wing while intake is open). var/eaters = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.phase != PRISONER_ARRIVING && prisoner.stat != DEAD && prisoner.trouble != PRISONER_TROUBLE_LOOSE) eaters++ if(!eaters && intake_open) @@ -389,7 +389,7 @@ GLOBAL_LIST_EMPTY(outpost_prisons) var/list/all_hatches = hatches() if(!length(all_hatches)) return - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.stat != CONSCIOUS || prisoner.phase != PRISONER_PRESENT || prisoner.trouble) continue var/reaches_hatch = FALSE @@ -442,7 +442,7 @@ GLOBAL_LIST_EMPTY(outpost_prisons) * hatch, a table, a cell, the floor), or a cleaner uniform off a serving hatch when `want_uniform` * is set. Anything another prisoner is already fetching is left alone. */ -/datum/outpost_prison/proc/find_supply(mob/living/basic/outpost_prisoner/prisoner, want_uniform = FALSE) +/datum/outpost_prison/proc/find_supply(mob/living/carbon/human/npc/outpost_prisoner/prisoner, want_uniform = FALSE) if(!prisoner.reachable) refresh_prisoner_reach(prisoner) var/obj/item/best @@ -514,14 +514,14 @@ GLOBAL_LIST_EMPTY(outpost_prisons) if(user) note_staff_stock(user) // Whoever wants it drops what they were idling at and comes over. - for(var/mob/living/basic/outpost_prisoner/wanting in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/wanting in prisoners) var/datum/prisoner_activity/idle = wanting.activity if(!wanting.ai_running() || !idle?.leisure || !idle.interruptible || idle.sleeping) continue if((food && wanting.wants_food()) || (suits && wanting.wants_clean_uniform())) wanting.end_activity() - var/mob/living/basic/outpost_prisoner/thanker - for(var/mob/living/basic/outpost_prisoner/waiting in prisoners) + var/mob/living/carbon/human/npc/outpost_prisoner/thanker + for(var/mob/living/carbon/human/npc/outpost_prisoner/waiting in prisoners) var/datum/prisoner_activity/hatch_wait/wait = waiting.activity if(!istype(wait) || wait.hatch_ref?.resolve() != hatch) continue @@ -529,11 +529,11 @@ GLOBAL_LIST_EMPTY(outpost_prisons) thanker = waiting if(user) waiting.note_carer(user) - INVOKE_ASYNC(waiting, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, thank), (food && waiting.wants_food()) ? "thanks_food" : "thanks_uniform") + INVOKE_ASYNC(waiting, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, thank), (food && waiting.wants_food()) ? "thanks_food" : "thanks_uniform") break if(!COOLDOWN_FINISHED(src, hatch_call_cooldown)) return null - for(var/mob/living/basic/outpost_prisoner/crier as anything in shuffle(prisoners)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/crier as anything in shuffle(prisoners)) if(crier == thanker || crier.stat != CONSCIOUS || crier.phase != PRISONER_PRESENT || crier.in_trouble() || crier.activity?.sleeping) continue var/context @@ -545,7 +545,7 @@ GLOBAL_LIST_EMPTY(outpost_prisons) continue COOLDOWN_START(src, hatch_call_cooldown, OUTPOST_PRISON_HATCH_CALL_GAP) note_speech() - INVOKE_ASYNC(crier, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context), context) + INVOKE_ASYNC(crier, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context), context) return crier return null @@ -554,15 +554,15 @@ GLOBAL_LIST_EMPTY(outpost_prisons) * PRISONER_SHARED_MEAL_WINDOW makes a shared meal: each of them cheers up a little, once, and one * of them says so. Returns the prisoners who got the lift. */ -/datum/outpost_prison/proc/note_table_meal(mob/living/basic/outpost_prisoner/eater) - for(var/mob/living/basic/outpost_prisoner/earlier as anything in table_eaters.Copy()) +/datum/outpost_prison/proc/note_table_meal(mob/living/carbon/human/npc/outpost_prisoner/eater) + for(var/mob/living/carbon/human/npc/outpost_prisoner/earlier as anything in table_eaters.Copy()) if(QDELETED(earlier) || !(earlier in prisoners) || world.time - table_eaters[earlier] > PRISONER_SHARED_MEAL_WINDOW) table_eaters -= earlier table_eaters[eater] = world.time var/list/lifted = list() if(length(table_eaters) < PRISONER_SHARED_MEAL_COUNT) return lifted - for(var/mob/living/basic/outpost_prisoner/diner as anything in table_eaters) + for(var/mob/living/carbon/human/npc/outpost_prisoner/diner as anything in table_eaters) if(diner.shared_meal_at && world.time - diner.shared_meal_at <= PRISONER_SHARED_MEAL_WINDOW) continue diner.shared_meal_at = world.time @@ -572,8 +572,8 @@ GLOBAL_LIST_EMPTY(outpost_prisons) note_shared_meal(lifted) if(length(lifted) && COOLDOWN_FINISHED(src, mess_hall_cooldown)) COOLDOWN_START(src, mess_hall_cooldown, OUTPOST_PRISON_MESS_HALL_GAP) - var/mob/living/basic/outpost_prisoner/speaker = pick(lifted) - INVOKE_ASYNC(speaker, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context), "mess_hall") + var/mob/living/carbon/human/npc/outpost_prisoner/speaker = pick(lifted) + INVOKE_ASYNC(speaker, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context), "mess_hall") return lifted /** @@ -584,22 +584,22 @@ GLOBAL_LIST_EMPTY(outpost_prisons) if(!is_member(shooter) || !COOLDOWN_FINISHED(src, staff_basket_cooldown)) return FALSE var/list/players = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.stat == CONSCIOUS && prisoner.phase == PRISONER_PRESENT && istype(prisoner.activity, /datum/prisoner_activity/basketball)) players += prisoner if(length(players) < 2) return FALSE COOLDOWN_START(src, staff_basket_cooldown, OUTPOST_PRISON_STAFF_BASKET_GAP) note_staff_basket(shooter) - for(var/mob/living/basic/outpost_prisoner/player as anything in players) + for(var/mob/living/carbon/human/npc/outpost_prisoner/player as anything in players) player.adjust_mood(PRISONER_MOOD_STAFF_BASKET) player.face_atom(hoop) - var/mob/living/basic/outpost_prisoner/cheering = pick(players) + var/mob/living/carbon/human/npc/outpost_prisoner/cheering = pick(players) INVOKE_ASYNC(cheering, TYPE_PROC_REF(/atom, manual_emote), pick("whistles.", "claps.", "cheers.")) return TRUE /// The nearest trash bin the prisoner can reach -/datum/outpost_prison/proc/find_bin(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/find_bin(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(!prisoner.reachable) refresh_prisoner_reach(prisoner) var/obj/structure/closet/crate/bin/best @@ -613,7 +613,7 @@ GLOBAL_LIST_EMPTY(outpost_prisons) return best /// The nearest litter lying where the prisoner may walk, off the serving hatches and out of other cells -/datum/outpost_prison/proc/find_litter(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/find_litter(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(!prisoner.walkable) refresh_prisoner_reach(prisoner) var/obj/item/trash/best @@ -631,7 +631,7 @@ GLOBAL_LIST_EMPTY(outpost_prisons) return best /// A basketball the prisoner can get at: their own, loose within reach, or in another player's hands -/datum/outpost_prison/proc/find_ball(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/find_ball(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(istype(prisoner.held_item, /obj/item/toy/basketball)) return prisoner.held_item if(!prisoner.reachable) @@ -640,13 +640,13 @@ GLOBAL_LIST_EMPTY(outpost_prisons) var/obj/item/toy/basketball/ball = locate() in spot if(ball) return ball - for(var/mob/living/basic/outpost_prisoner/other in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/other in prisoners) if(istype(other.held_item, /obj/item/toy/basketball) && prisoner.walkable?[get_turf(other)]) return other.held_item return null /// The nearest book lying about within reach, not on a shelf -/datum/outpost_prison/proc/find_loose_book(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/find_loose_book(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(!prisoner.reachable) refresh_prisoner_reach(prisoner) var/obj/item/book/best @@ -681,8 +681,8 @@ GLOBAL_LIST_EMPTY(outpost_prisons) return FALSE /// Whether a prisoner other than `except` is doing an activity of this type -/datum/outpost_prison/proc/anyone_doing(activity_type, mob/living/basic/outpost_prisoner/except) - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) +/datum/outpost_prison/proc/anyone_doing(activity_type, mob/living/carbon/human/npc/outpost_prisoner/except) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner != except && istype(prisoner.activity, activity_type)) return TRUE return FALSE @@ -690,7 +690,7 @@ GLOBAL_LIST_EMPTY(outpost_prisons) // ===== CLAIMS ===== /// Reserves `thing` for `prisoner`. FALSE if someone else is using it. -/datum/outpost_prison/proc/claim(atom/thing, mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/claim(atom/thing, mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(claimed_by_other(thing, prisoner)) return FALSE claims[REF(thing)] = prisoner @@ -698,13 +698,13 @@ GLOBAL_LIST_EMPTY(outpost_prisons) /// The prisoner using `thing`, if any /datum/outpost_prison/proc/claimant(atom/thing) - var/mob/living/basic/outpost_prisoner/holder = claims[REF(thing)] + var/mob/living/carbon/human/npc/outpost_prisoner/holder = claims[REF(thing)] if(QDELETED(holder) || !holder.activity) return null return holder -/datum/outpost_prison/proc/claimed_by_other(atom/thing, mob/living/basic/outpost_prisoner/prisoner) - var/mob/living/basic/outpost_prisoner/holder = claimant(thing) +/datum/outpost_prison/proc/claimed_by_other(atom/thing, mob/living/carbon/human/npc/outpost_prisoner/prisoner) + var/mob/living/carbon/human/npc/outpost_prisoner/holder = claimant(thing) return holder && holder != prisoner // ===== SPEECH ===== @@ -722,10 +722,9 @@ GLOBAL_LIST_EMPTY(outpost_prisons) if(QDELETED(outpost) || !wing) return tick(seconds_per_tick) - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.phase != PRISONER_PRESENT) continue - prisoner.maybe_drip(seconds_per_tick) if(prisoner.stat != CONSCIOUS) continue if(prisoner.trouble != PRISONER_TROUBLE_LOOSE && SPT_PROB(OUTPOST_PRISON_MESS_CHANCE / 60, seconds_per_tick)) @@ -747,7 +746,7 @@ GLOBAL_LIST_EMPTY(outpost_prisons) conditions_tick(seconds) containment_tick(seconds) supply_tick(seconds) - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners.Copy()) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners.Copy()) if(QDELETED(prisoner) || prisoner.phase != PRISONER_PRESENT) continue if(prisoner.stat == DEAD) @@ -778,7 +777,7 @@ GLOBAL_LIST_EMPTY(outpost_prisons) // ===== COMINGS AND GOINGS ===== /// Drops a prisoner from the roster and their cell, and starts refilling it -/datum/outpost_prison/proc/forget(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/forget(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(!(prisoner in prisoners)) return // Whatever else closed their bounty record first decided how it ended (outpost_prison_bounty.dm). @@ -797,6 +796,11 @@ GLOBAL_LIST_EMPTY(outpost_prisons) emptied.occupant = null prisoner.cell = null prisoner.prison = null + // Off the roster, a body is like any human NPC's: cleaned up once it has lain unwatched for a while + // (human_npc_spawning.dm), unless someone is dragging, carrying or watching it. + if(prisoner.stat == DEAD && !QDELETED(prisoner)) + prisoner.npc_corpse_lifetime = HUMAN_NPC_CORPSE_LIFETIME + SShuman_npcs.track_corpse(prisoner) for(var/key in claims.Copy()) if(claims[key] == prisoner) claims -= key @@ -823,7 +827,7 @@ GLOBAL_LIST_EMPTY(outpost_prisons) var/list/turfs var/list/turf_set /// The prisoner who owns it - var/mob/living/basic/outpost_prisoner/occupant + var/mob/living/carbon/human/npc/outpost_prisoner/occupant /// world.time from which the cell may take a new arrival var/ready_at = 0 diff --git a/voidcrew/modules/player_outposts/outpost_prison_creatures.dm b/voidcrew/modules/player_outposts/outpost_prison_creatures.dm index 1a127916052..56161b68613 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_creatures.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_creatures.dm @@ -1,59 +1,21 @@ /** - * # Experiment creatures + * # Experiment creatures: the tells, and the changeling's horror's base * - * What a serum turns a prisoner into, with tg's looks and mechanics where tg has them: - * - The hulk: a green, swollen prisoner (tg's hulk skin). Punches hard, charges with a 1.5 second - * wind-up and a line on the floor, stuns itself on a wall, tears through interior walls (tg's - * wall_tearer, limited to the outpost's inside) and forces doors. It knocks prisoners flat but - * never kills them. Worn down to a quarter it is exhausted, and a baton or disabler puts it down - * alive for a bigger bonus. - * - The fly person: tg's fly species, flying. It zips about the wing in short random darts, darts - * away from anyone close and from whoever just hit it, and jinks out of the way of some shots while - * it flies freely. Cornered, it bites. It eats whatever food it finds and throws up every few - * seconds. A flyswatter hits it thirty times harder, as it does tg's fly people; a baton knocks it - * to the floor for a moment, and stamina weapons slow it down and then put it down alive. - * - The nightmare: tg's nightmare with its light eater. It spends its first half minute breaking - * the lights, then hunts prisoners in the dark. It heals and dodges in the dark and burns in the - * light, jaunts beside a target through the dark after a warning ripple, and a flash burns it. - * Before the change, the dosed prisoner shows the form's tells (outpost_experiment_tell()). Put - * down, alive or dead, a creature lies on the floor where everyone can see it (show_down()), a - * subdued one twitching, until Kessler's team beams in for it (kessler_collect()). - * - * All of them are basic mobs under /mob/living/basic/outpost_experiment, never megafauna, with no - * sentience, no need for air, and no way to be boxed, teleported, polymorphed or revived. They - * only break the outpost's interior (outpost_experiment_can_smash()). Their AI runs only while - * someone is on the level, like everything else in the wing. + * The serum's forms (the hulk, the fly person and the nightmare) are the subject's own body changed by + * tg's biology: outpost_prison_experiment_forms.dm. This file keeps what the serum shows before it takes + * (outpost_experiment_tell()), the forms' ability hit, and the basic mob the + * changeling's horror is filed under (outpost_prison_horror.dm), which stays a monster (owner ruling OC-4): + * a basic mob, never megafauna, with no sentience, no need for air, and no way to be boxed, teleported or + * polymorphed. It only breaks the outpost's interior (outpost_experiment_can_smash()). */ -/// The creature a serum form becomes -/proc/outpost_experiment_creature_type(form) - switch(form) - if("hulk") - return /mob/living/basic/outpost_experiment/hulk - if("fly") - return /mob/living/basic/outpost_experiment/fly - if("nightmare") - return /mob/living/basic/outpost_experiment/nightmare - return null - -/// Living players on level `z` beyond the first, up to OUTPOST_EXPERIMENT_EXTRA_PLAYERS_MAX, for a creature's health -/proc/outpost_experiment_extra_players(z) - if(!z || z > length(SSmobs.clients_by_zlevel)) - return 0 - var/count = 0 - for(var/mob/living/person as anything in SSmobs.clients_by_zlevel[z]) - if(QDELETED(person) || person.stat == DEAD || !person.client || is_outpost_prisoner(person) || is_outpost_experiment_mob(person)) - continue - count++ - return clamp(count - 1, 0, OUTPOST_EXPERIMENT_EXTRA_PLAYERS_MAX) - // ===== TELLS ===== /** * One tell of what the serum is turning `subject` into, `progress` (0 to 1) through the last * OUTPOST_EXPERIMENT_TELLS seconds. Plain to see, so the crew can fetch the right tool. */ -/proc/outpost_experiment_tell(form, mob/living/basic/outpost_prisoner/subject, progress) +/proc/outpost_experiment_tell(form, mob/living/carbon/human/npc/outpost_prisoner/subject, progress) if(QDELETED(subject) || subject.stat != CONSCIOUS) return subject.Shake(1, 1, 0.5 SECONDS) @@ -86,8 +48,20 @@ subject.manual_emote(pick("flinches away from the light.", "whispers to nobody.", "shades [subject.p_their()] eyes.", "stands very still in the dark.")) playsound(subject, pick('sound/effects/hallucinations/i_see_you1.ogg', 'sound/effects/hallucinations/behind_you1.ogg'), 20, TRUE) +/** + * One of a creature's ability hits on `victim` (the hulk's charge, the nightmare's lunge out of the dark): + * at a body zone, through the armour on it, and able to wound like any other blow of its kind. A blunt hit + * when `sharpness` is NONE. Returns the damage dealt. + */ +/proc/outpost_experiment_ability_hit(mob/living/victim, damage, sharpness = NONE, armour_penetration = 0, zone, atom/attacker) + if(QDELETED(victim)) + return 0 + zone ||= victim.get_random_valid_zone(BODY_ZONE_CHEST) + var/blocked = victim.run_armor_check(zone, MELEE, armour_penetration = armour_penetration) + return victim.apply_damage(damage, BRUTE, zone, blocked, sharpness = sharpness, attack_direction = attacker ? get_dir(attacker, victim) : null) + /// Takes the tells off a subject the serum never finished with -/proc/outpost_experiment_clear_tells(mob/living/basic/outpost_prisoner/subject) +/proc/outpost_experiment_clear_tells(mob/living/carbon/human/npc/outpost_prisoner/subject) if(QDELETED(subject)) return subject.remove_atom_colour(TEMPORARY_COLOUR_PRIORITY) @@ -95,9 +69,9 @@ if(subject.current_size != RESIZE_DEFAULT_SIZE) subject.update_transform(RESIZE_DEFAULT_SIZE / subject.current_size) -// ===== THE CREATURE ===== +// ===== THE HORROR'S BASE ===== -/// What a prisoner turned into. Kept at home and out of players' hands; see the file header. +/// What the changeling's specimen grows into is filed under this: kept at home and out of players' hands. /mob/living/basic/outpost_experiment name = "experiment" desc = "What a prisoner turned into." @@ -117,21 +91,15 @@ unsuitable_heat_damage = 0 damage_coeff = list(BRUTE = 1, BURN = 1, TOX = 0, STAMINA = 0, OXY = 0) environment_smash = ENVIRONMENT_SMASH_NONE - ai_controller = /datum/ai_controller/basic_controller/outpost_experiment // tg's human deathgasp death_message = "seizes up and falls limp, their eyes dead and lifeless..." - // Knocked down, subdued or dead, it lies on the floor like a person. + // Knocked down or dead, it lies on the floor like a person. mobility_flags = MOBILITY_FLAGS_REST_CAPABLE_DEFAULT rotate_on_lying = TRUE - /// What the log calls it: "a hulk" + /// What the log calls it var/form_name = "a creature" - /// What everyone sees when it is subdued, after its name - var/subdued_message = "collapses, spent." /// A tell on examine, if any: something anyone watching it would notice var/win_hint - /// Health with one player on the level, and per extra player - var/base_health = 100 - var/health_per_player = 0 /// Dialogue context it says now and then, and seconds to the next line var/line_context var/line_left = 10 @@ -139,31 +107,15 @@ var/datum/outpost_prison/prison /// The prisoner's personality, for its lines var/personality - /// Put down alive - var/subdued = FALSE /// Its footsteps: the footstep element's sound set, volume multiplier and extra range var/footstep_kind = FOOTSTEP_MOB_SHOE var/footstep_volume = 0.5 var/footstep_range = -8 - /// The target it is chasing now, the closest it has gotten to it, where it last stood, and when it last - /// got anywhere: to notice it is stuck (track_reach()) - var/datum/weakref/chase_target_ref - var/chase_best_distance = 0 - var/turf/chase_last_turf - var/chase_progress_time = 0 - /// Targets it has given up on reaching -> world.time it may try them again (find_light(), choose_target()) - var/list/unreachable_until -/mob/living/basic/outpost_experiment/Initialize(mapload, datum/outpost_prison/owner, mob/living/basic/outpost_prisoner/subject) - if(subject) - gender = subject.gender +/mob/living/basic/outpost_experiment/Initialize(mapload, datum/outpost_prison/owner) . = ..() prison = owner damage_coeff = damage_coeff.Copy() - if(subject) - personality = subject.personality - real_name = subject.real_name - name = real_name ADD_TRAIT(src, TRAIT_NO_CONTAINMENT, INNATE_TRAIT) ADD_TRAIT(src, TRAIT_NO_STORAGE_INSERT, INNATE_TRAIT) RegisterSignal(src, COMSIG_MOVABLE_TELEPORTING, PROC_REF(refuse_teleport)) @@ -171,22 +123,15 @@ RegisterSignal(src, COMSIG_PRE_MOB_CHANGED_TYPE, PROC_REF(refuse_type_change)) AddComponent(/datum/component/experiment_damage_ledger) AddElement(/datum/element/footstep, footstep_type = footstep_kind, volume = footstep_volume, e_range = footstep_range) - var/turf/here = get_turf(src) - var/full_health = base_health + health_per_player * outpost_experiment_extra_players(here?.z) - maxHealth = full_health - health = full_health - build_look(subject?.outfit_path || /datum/outfit/outpost_prisoner) + build_look() /mob/living/basic/outpost_experiment/Destroy() prison = null - chase_target_ref = null - chase_last_turf = null - unreachable_until = null return ..() -/// Puts on its look, from the prisoner's outfit +/// Puts on its look /mob/living/basic/outpost_experiment/proc/build_look(outfit_path) - apply_dynamic_human_appearance(src, outfit_path, /datum/species/human) + return /mob/living/basic/outpost_experiment/proc/refuse_teleport(datum/source, atom/destination, channel) SIGNAL_HANDLER @@ -203,56 +148,45 @@ SIGNAL_HANDLER return COMPONENT_BLOCK_MOB_CHANGE -/// Kessler has already written it off: nothing brings it back -/mob/living/basic/outpost_experiment/can_be_revived() - return FALSE - /// Down for good, its body can be dragged about until Kessler collects it /mob/living/basic/outpost_experiment/death(gibbed) . = ..() move_resist = MOVE_RESIST_DEFAULT if(. && !gibbed && !QDELETED(src)) - show_down(FALSE) + balloon_alert_to_viewers("dead") /mob/living/basic/outpost_experiment/examine(mob/user) . = ..() - if(HAS_TRAIT_FROM(src, TRAIT_GODMODE, OUTPOST_KESSLER_TRAIT)) + if(HAS_TRAIT_FROM(src, TRAIT_IMMOBILIZED, OUTPOST_KESSLER_TRAIT)) . += span_notice("Kessler Biolabs is taking [p_them()] away.") - else if(subdued || stat == DEAD) + else if(stat == DEAD) . += span_notice("[p_They()] [p_are()] down. Kessler Biolabs will collect [p_them()] shortly.") else if(win_hint) . += span_notice(win_hint) -/** - * Put down: everyone in sight is told, with a balloon over it. `subdued` is alive (the death - * message has already said the rest); it lies there twitching until Kessler collects it (Life()). - */ -/mob/living/basic/outpost_experiment/proc/show_down(subdued) - if(subdued) - visible_message(span_danger("[src] [subdued_message]")) - balloon_alert_to_viewers(subdued ? "subdued" : "dead") - -/// Twitches on the floor, subdued, waiting for Kessler -/mob/living/basic/outpost_experiment/proc/down_twitch() - Shake(1, 0, 0.4 SECONDS) - if(prob(30)) - manual_emote(pick("twitches.", "groans.", "stirs weakly.")) - /// Health it still had, which a gib or dust takes without it counting as damage on its ledger /mob/living/basic/outpost_experiment/proc/unspent_health() return health /** * Interim turret rule (outpost_prison_riot.dm): outpost turrets shoot a creature wherever it is, - * until it is dead, subdued or in Kessler's hands. Turret damage is not the crew's, so a turret - * kill pays no containment bonus. + * until it is dead or Kessler's beam has it. Turret damage is not the crew's, so a turret kill pays + * no containment bonus. */ /mob/living/basic/outpost_experiment/proc/turret_target() - return stat != DEAD && !subdued && !HAS_TRAIT(src, TRAIT_GODMODE) + return stat != DEAD && !HAS_TRAIT_FROM(src, TRAIT_IMMOBILIZED, OUTPOST_KESSLER_TRAIT) +/** + * Whether outpost turrets shoot `creature`, an experiment's creature: the horror by its own rule; a body the + * serum took while it is up and fighting (not down for Kessler, not being beamed away). + */ /proc/is_outpost_experiment_turret_target(mob/living/creature) var/mob/living/basic/outpost_experiment/experiment_creature = creature - return istype(experiment_creature) && experiment_creature.turret_target() + if(istype(experiment_creature)) + return experiment_creature.turret_target() + if(!creature?.GetComponent(/datum/component/outpost_experiment_form)) + return FALSE + return !outpost_experiment_down_state(creature) && !HAS_TRAIT_FROM(creature, TRAIT_IMMOBILIZED, OUTPOST_KESSLER_TRAIT) /// Whether its AI runs: only while someone is on the level /mob/living/basic/outpost_experiment/proc/awake() @@ -260,11 +194,7 @@ /mob/living/basic/outpost_experiment/Life(seconds_per_tick = SSMOBS_DT, times_fired) . = ..() - if(subdued && stat != DEAD && !HAS_TRAIT_FROM(src, TRAIT_GODMODE, OUTPOST_KESSLER_TRAIT) && !QDELETED(src)) - if(prob(60)) - down_twitch() - return - if(stat == DEAD || subdued || HAS_TRAIT(src, TRAIT_GODMODE) || !awake()) + if(stat == DEAD || HAS_TRAIT_FROM(src, TRAIT_IMMOBILIZED, OUTPOST_KESSLER_TRAIT) || !awake()) return creature_life(seconds_per_tick) if(!line_context) @@ -279,1118 +209,3 @@ /// Each second while awake: what it does besides fighting /mob/living/basic/outpost_experiment/proc/creature_life(seconds_per_tick) return - -/** - * Worn out on stamina: down alive on the floor, held there, and the containment bonus for a live - * one. Kessler's team comes for it OUTPOST_EXPERIMENT_PICKUP seconds later. - */ -/mob/living/basic/outpost_experiment/proc/subdue() - if(subdued || stat == DEAD) - return FALSE - subdued = TRUE - move_resist = MOVE_RESIST_DEFAULT - ADD_TRAIT(src, TRAIT_INCAPACITATED, OUTPOST_KESSLER_TRAIT) - ADD_TRAIT(src, TRAIT_IMMOBILIZED, OUTPOST_KESSLER_TRAIT) - ADD_TRAIT(src, TRAIT_FLOORED, OUTPOST_KESSLER_TRAIT) - ai_controller?.CancelActions() - show_down(TRUE) - prison?.experiment_creature_down(src, subdued = TRUE) - return TRUE - -/mob/living/basic/outpost_experiment/received_stamina_damage(current_level, amount_actual, amount) - . = ..() - if(has_status_effect(/datum/status_effect/incapacitating/stamcrit)) - subdue() - -// ----- targets ----- - -/// Whether it goes after `target`. By default only its victims (is_victim()); the fly adds food, the nightmare lights. -/mob/living/basic/outpost_experiment/proc/can_target(atom/target) - return is_victim(target) - -/// People, borgs and prisoners, never its own kind or Kessler's staff -/mob/living/basic/outpost_experiment/proc/is_victim(atom/target) - var/mob/living/victim = target - if(!istype(victim) || victim == src || victim.stat == DEAD) - return FALSE - if(is_outpost_experiment_mob(victim) || HAS_TRAIT(victim, TRAIT_GODMODE)) - return FALSE - if(is_outpost_prisoner(victim)) - var/mob/living/basic/outpost_prisoner/prisoner = victim - if(prisoner.phase != PRISONER_PRESENT || !may_hit_prisoner(prisoner)) - return FALSE - return !blocked_by_cell(prisoner) - return ishuman(victim) || issilicon(victim) || !isnull(victim.mind) - -/// Whether it hits this prisoner -/mob/living/basic/outpost_experiment/proc/may_hit_prisoner(mob/living/basic/outpost_prisoner/prisoner) - return TRUE - -/// How much less it wants a target than its distance says; prisoners and people may count differently -/mob/living/basic/outpost_experiment/proc/target_penalty(mob/living/target) - return 0 - -/** - * Its target now: whoever hurt it lately, else the nearest it wants in sight. While nobody from the - * wing is home it fights back but hunts nobody, as the horror does (crew_about()), so a loose - * creature is never a trap left for visitors. - */ -/mob/living/basic/outpost_experiment/proc/choose_target() - var/datum/component/experiment_damage_ledger/ledger = GetComponent(/datum/component/experiment_damage_ledger) - var/mob/living/attacker = ledger?.recent_player() - if(attacker && can_target(attacker) && get_dist(src, attacker) <= 9 && can_see(src, attacker, 9) && !target_unreachable(attacker)) - return attacker - if(prison && !prison.crew_home()) - return null - var/mob/living/best - var/best_score = INFINITY - for(var/mob/living/candidate in range(7, src)) - if(!can_target(candidate) || !can_see(src, candidate, 7) || target_unreachable(candidate)) - continue - var/score = get_dist(src, candidate) + target_penalty(candidate) - if(score < best_score) - best = candidate - best_score = score - return best - -/** - * Its AI's first thought each plan: picks the target and may queue something of its own. Returns - * SUBTREE_RETURN_FINISH_PLANNING when that is all it does this plan. - */ -/mob/living/basic/outpost_experiment/proc/ai_think(datum/ai_controller/controller) - var/atom/target = choose_target() - if(target) - controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, target) - else - controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) - return null - -// ----- reach ----- - -/// Whether nothing shut stops it: the hulk smashes through walls and doors, so a bolted cell or a target it can't get to never is out of its reach -/mob/living/basic/outpost_experiment/proc/smashes_through() - return FALSE - -/// Whether it is mid-jaunt or otherwise between motives right now, and should not be judged on progress -/mob/living/basic/outpost_experiment/proc/chasing_paused() - return FALSE - -/// Whether a bolted cell keeps `prisoner` away from it: shut and locked, and it is not inside with them -/mob/living/basic/outpost_experiment/proc/blocked_by_cell(mob/living/basic/outpost_prisoner/prisoner) - if(smashes_through()) - return FALSE - var/datum/outpost_prison_cell/holding = prison?.cell_at(get_turf(prisoner)) - return holding && holding.is_bolted() && !holding.contains(src) - -/** - * Notes whether it is getting anywhere with `controller`'s current target: closer, beside it (Adjacent(), - * which a shut window or door fails even at a tile's distance), or at least on the move, so a target - * that runs is chased rather than given up on. OUTPOST_EXPERIMENT_STUCK_TIME standing still and apart - * writes the target off as unreachable for OUTPOST_EXPERIMENT_UNREACHABLE_TIME; find_light() and - * choose_target() skip anything on that list. Distance and Adjacent() only: no pathfinding call. - */ -/mob/living/basic/outpost_experiment/proc/track_reach(datum/ai_controller/controller) - if(smashes_through() || chasing_paused()) - return - var/atom/movable/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] - if(QDELETED(target)) - chase_target_ref = null - return - if(chase_target_ref?.resolve() != target) - chase_target_ref = WEAKREF(target) - chase_best_distance = get_dist(src, target) - chase_last_turf = loc - chase_progress_time = world.time - return - if(Adjacent(target) || loc != chase_last_turf) - chase_last_turf = loc - chase_progress_time = world.time - return - var/distance = get_dist(src, target) - if(distance < chase_best_distance) - chase_best_distance = distance - chase_progress_time = world.time - return - if(world.time - chase_progress_time < OUTPOST_EXPERIMENT_STUCK_TIME) - return - mark_unreachable(target) - chase_target_ref = null - -/// Whether it gave up on reaching `target` recently -/mob/living/basic/outpost_experiment/proc/target_unreachable(atom/target) - if(!length(unreachable_until)) - return FALSE - var/datum/weakref/ref = WEAKREF(target) - var/until = unreachable_until[ref] - if(!until) - return FALSE - if(until > world.time) - return TRUE - unreachable_until -= ref - return FALSE - -/// Writes `target` off for OUTPOST_EXPERIMENT_UNREACHABLE_TIME: something is stopping it getting there -/mob/living/basic/outpost_experiment/proc/mark_unreachable(atom/target) - LAZYSET(unreachable_until, WEAKREF(target), world.time + OUTPOST_EXPERIMENT_UNREACHABLE_TIME) - prune_unreachable() - -/// Drops expired entries, then the oldest ones if it somehow grew past OUTPOST_EXPERIMENT_UNREACHABLE_MAX -/mob/living/basic/outpost_experiment/proc/prune_unreachable() - for(var/datum/weakref/ref as anything in unreachable_until.Copy()) - if(unreachable_until[ref] <= world.time) - unreachable_until -= ref - while(length(unreachable_until) > OUTPOST_EXPERIMENT_UNREACHABLE_MAX) - var/datum/weakref/oldest - for(var/datum/weakref/ref as anything in unreachable_until) - oldest = ref - break - unreachable_until -= oldest - -// ----- breaking things ----- - -/// Whether it may break `thing` out of its way. Only the hulk does. -/mob/living/basic/outpost_experiment/proc/can_break(atom/thing) - return FALSE - -/// Breaks `thing` out of its way -/mob/living/basic/outpost_experiment/proc/break_obstacle(atom/thing) - return FALSE - -// ===== HULK ===== - -/mob/living/basic/outpost_experiment/hulk - desc = "A prisoner swollen into a green giant, still in the rags of a jumpsuit." - form_name = "a hulk" - mob_size = MOB_SIZE_LARGE - footstep_kind = FOOTSTEP_MOB_HEAVY - footstep_volume = 1 - footstep_range = -4 - status_flags = NONE - base_health = OUTPOST_HULK_HEALTH - health_per_player = OUTPOST_HULK_HEALTH_PER_PLAYER - speed = OUTPOST_HULK_SPEED - melee_damage_lower = OUTPOST_HULK_PUNCH_MIN - melee_damage_upper = OUTPOST_HULK_PUNCH_MAX - melee_attack_cooldown = OUTPOST_HULK_PUNCH_COOLDOWN - obj_damage = 60 - environment_smash = ENVIRONMENT_SMASH_STRUCTURES - attack_verb_continuous = "smashes" - attack_verb_simple = "smash" - attack_sound = 'sound/effects/meteorimpact.ogg' - attack_vis_effect = ATTACK_EFFECT_SMASH - max_stamina = OUTPOST_HULK_STAMINA - line_context = "hulk" - /// Worn down: slower, no charge, and batons work - var/exhausted = FALSE - /// Its charge - var/datum/action/cooldown/mob_cooldown/charge/basic_charge/outpost_hulk/charge - -/mob/living/basic/outpost_experiment/hulk/Initialize(mapload, datum/outpost_prison/owner, mob/living/basic/outpost_prisoner/subject) - . = ..() - update_transform(1.25) - charge = new(src) - charge.Grant(src) - ai_controller?.set_blackboard_key(BB_TARGETED_ACTION, charge) - AddElement(/datum/element/wall_tearer/outpost_interior, allow_reinforced = FALSE, tear_time = OUTPOST_HULK_TEAR_TIME) - RegisterSignal(src, COMSIG_LIVING_HEALTH_UPDATE, PROC_REF(check_exhausted)) - playsound(src, 'sound/mobs/non-humanoids/gorilla/gorilla.ogg', 80, TRUE) - visible_message(span_danger("[src] swells, splits [p_their()] jumpsuit and roars!")) - -/mob/living/basic/outpost_experiment/hulk/Destroy() - QDEL_NULL(charge) - return ..() - -/mob/living/basic/outpost_experiment/hulk/build_look(outfit_path) - INVOKE_ASYNC(GLOBAL_PROC, GLOBAL_PROC_REF(outpost_hulk_look), src, outfit_path) - -/// Players first, then prisoners still on their feet -/mob/living/basic/outpost_experiment/hulk/target_penalty(mob/living/target) - return is_outpost_prisoner(target) ? 3 : 0 - -/// Only prisoners still standing: it knocks them flat and leaves them -/mob/living/basic/outpost_experiment/hulk/may_hit_prisoner(mob/living/basic/outpost_prisoner/prisoner) - return !prisoner.can_be_dragged() && prisoner.beaten_left <= 0 - -/// It tears through walls and forces doors, so a bolted cell and a blocked path never stop it -/mob/living/basic/outpost_experiment/hulk/smashes_through() - return TRUE - -/mob/living/basic/outpost_experiment/hulk/ai_think(datum/ai_controller/controller) - . = ..() - var/mob/living/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] - if(exhausted || !isliving(target) || !charge?.IsAvailable()) - return - var/distance = get_dist(src, target) - if(distance < 2 || distance > OUTPOST_HULK_CHARGE_RANGE || !can_see(src, target, OUTPOST_HULK_CHARGE_RANGE)) - return - controller.queue_behavior(/datum/ai_behavior/targeted_mob_ability, BB_TARGETED_ACTION, BB_BASIC_MOB_CURRENT_TARGET) - return SUBTREE_RETURN_FINISH_PLANNING - -/// A punch; a prisoner is knocked flat instead, and a person may go flying -/mob/living/basic/outpost_experiment/hulk/melee_attack(atom/target, list/modifiers, ignore_cooldown = FALSE) - if(is_outpost_prisoner(target)) - if(!early_melee_attack(target, modifiers, ignore_cooldown)) - return FALSE - do_attack_animation(target, ATTACK_EFFECT_SMASH) - playsound(target, 'sound/items/weapons/punch1.ogg', 60, TRUE) - knock_down_prisoner(target) - return TRUE - . = ..() - if(!. || !isliving(target) || !prob(OUTPOST_HULK_THROW_CHANCE)) - return - var/mob/living/victim = target - if(victim.stat == DEAD || victim.anchored || victim.move_resist >= MOVE_FORCE_OVERPOWERING) - return - victim.visible_message(span_danger("[src] sends [victim] flying!")) - victim.throw_at(get_ranged_target_turf(victim, get_dir(src, victim), OUTPOST_HULK_THROW_RANGE), OUTPOST_HULK_THROW_RANGE, 1, src) - -/// Knocks a prisoner into the beaten state: hurt, flat on the floor, never killed -/mob/living/basic/outpost_experiment/hulk/proc/knock_down_prisoner(mob/living/basic/outpost_prisoner/prisoner) - if(QDELETED(prisoner) || prisoner.stat == DEAD) - return FALSE - var/damage = min(rand(OUTPOST_HULK_PUNCH_MIN, OUTPOST_HULK_PUNCH_MAX), max(0, prisoner.health - 1)) - if(damage > 0) - prisoner.apply_damage(damage, BRUTE) - prisoner.visible_message(span_danger("[src] knocks [prisoner] flat!")) - if(prisoner.stat == CONSCIOUS && prisoner.beaten_left <= 0) - prisoner.collapse() - return TRUE - -/// Worn down to OUTPOST_HULK_EXHAUSTED_AT percent: slower, no more charging, and stamina weapons work -/mob/living/basic/outpost_experiment/hulk/proc/check_exhausted(datum/source) - SIGNAL_HANDLER - if(exhausted || stat == DEAD || health > maxHealth * OUTPOST_HULK_EXHAUSTED_AT / 100) - return - exhausted = TRUE - set_varspeed(OUTPOST_HULK_EXHAUSTED_SPEED) - damage_coeff[STAMINA] = 1 - status_flags |= CANSTUN | CANKNOCKDOWN - charge?.disable() - visible_message(span_warning("[src] staggers, heaving for breath. [p_They()] look[p_s()] spent.")) - -/// Charged into a wall: stunned, and hit harder for a moment -/mob/living/basic/outpost_experiment/hulk/proc/stagger_on_wall() - Stun(OUTPOST_HULK_WALL_STUN, ignore_canstun = TRUE) - damage_coeff[BRUTE] = OUTPOST_HULK_WALL_VULNERABLE - damage_coeff[BURN] = OUTPOST_HULK_WALL_VULNERABLE - addtimer(CALLBACK(src, PROC_REF(recover_from_wall)), OUTPOST_HULK_WALL_STUN, TIMER_UNIQUE | TIMER_OVERRIDE | TIMER_DELETE_ME) - -/mob/living/basic/outpost_experiment/hulk/proc/recover_from_wall() - damage_coeff[BRUTE] = 1 - damage_coeff[BURN] = 1 - -/// Interior walls, windows, grilles, tables, chairs and doors, never the hatch counters or anything protected -/mob/living/basic/outpost_experiment/hulk/can_break(atom/thing) - if(QDELETED(thing) || !outpost_experiment_can_smash(thing, prison)) - return FALSE - if(isturf(thing)) - return iswallturf(thing) && !istype(thing, /turf/closed/wall/r_wall) && !isindestructiblewall(thing) - var/obj/object = thing - if(!istype(object) || (object.resistance_flags & INDESTRUCTIBLE) || HAS_TRAIT(object, TRAIT_OUTPOST_PROPERTY)) - return FALSE - if(istype(object, /obj/structure/table/reinforced/prison_hatch)) - return FALSE - return istype(object, /obj/structure/window) || istype(object, /obj/structure/grille) || istype(object, /obj/structure/table) \ - || istype(object, /obj/structure/chair) || istype(object, /obj/machinery/door) - -/mob/living/basic/outpost_experiment/hulk/break_obstacle(atom/thing) - if(!can_break(thing)) - return FALSE - if(isturf(thing)) - // The wall tearer takes it from here, in three pulls. - melee_attack(thing) - return TRUE - if(istype(thing, /obj/machinery/door/airlock)) - INVOKE_ASYNC(src, PROC_REF(force_door), thing) - return TRUE - smash(thing) - return TRUE - -/// Batters a door until it gives: bolts sheared, weld broken, forced open -/mob/living/basic/outpost_experiment/hulk/proc/force_door(obj/machinery/door/airlock/door) - if(DOING_INTERACTION_WITH_TARGET(src, door) || !door.density) - return FALSE - visible_message(span_danger("[src] batters at [door]!")) - playsound(door, 'sound/effects/bang.ogg', 70, TRUE) - door.Shake(2, 2, 0.5 SECONDS) - if(!do_after(src, OUTPOST_HULK_DOOR_TIME, target = door) || QDELETED(door) || !can_break(door)) - return FALSE - if(door.locked) - door.unbolt() - if(door.welded) - door.welded = FALSE - door.update_appearance() - door.visible_message(span_danger("[src] forces [door] open!")) - playsound(door, 'sound/machines/airlock/airlock_alien_prying.ogg', 80, TRUE) - INVOKE_ASYNC(door, TYPE_PROC_REF(/obj/machinery/door, open), BYPASS_DOOR_CHECKS) - prison?.refresh_reach() - return TRUE - -/// Puts something through: windows shatter, tables fold, chairs splinter, window doors break -/mob/living/basic/outpost_experiment/hulk/proc/smash(obj/thing) - if(QDELETED(thing)) - return FALSE - do_attack_animation(thing, ATTACK_EFFECT_SMASH) - visible_message(span_danger("[src] smashes [thing]!")) - playsound(thing, istype(thing, /obj/structure/window) ? 'sound/effects/glass/glassbr1.ogg' : 'sound/effects/woodhit.ogg', 70, TRUE) - thing.take_damage(thing.get_integrity(), BRUTE, MELEE, FALSE, get_dir(thing, src)) - return TRUE - -/// tg's hulk skin on the prisoner's own clothes, cached per outfit -/proc/outpost_hulk_look(mob/living/basic/outpost_experiment/hulk/hulk, outfit_path) - var/static/list/looks = list() - var/key = "[outfit_path]" - var/mutable_appearance/look = looks[key] - if(!look) - var/mob/living/carbon/human/dummy/consistent/dummy = new() - dummy.set_species(/datum/species/human) - dummy.stat = DEAD - dummy.underwear = "Nude" - dummy.undershirt = "Nude" - dummy.socks = "Nude" - if(outfit_path) - dummy.equipOutfit(outfit_path, visuals_only = TRUE) - for(var/obj/item/bodypart/part as anything in dummy.bodyparts) - part.add_color_override(COLOR_DARK_LIME, LIMB_COLOR_HULK) - dummy.update_body_parts() - look = new(dummy.appearance) - looks[key] = look - qdel(dummy) - if(QDELETED(hulk)) - return - hulk.icon = 'icons/mob/human/human.dmi' - hulk.icon_state = "" - hulk.appearance_flags |= KEEP_TOGETHER - hulk.copy_overlays(look, cut_old = TRUE) - -/// The hulk's charge: a roar, a stamp and a line on the floor, then six tiles of it -/datum/action/cooldown/mob_cooldown/charge/basic_charge/outpost_hulk - name = "Charge" - desc = "Put your head down and run through whatever is in the way." - cooldown_time = OUTPOST_HULK_CHARGE_COOLDOWN - charge_delay = OUTPOST_HULK_CHARGE_WINDUP - charge_distance = OUTPOST_HULK_CHARGE_RANGE - charge_past = 1 - charge_damage = OUTPOST_HULK_CHARGE_DAMAGE - destroy_objects = FALSE - shake_duration = OUTPOST_HULK_CHARGE_WINDUP - recoil_duration = OUTPOST_HULK_WALL_STUN - knockdown_duration = OUTPOST_HULK_CHARGE_KNOCKDOWN - -/datum/action/cooldown/mob_cooldown/charge/basic_charge/outpost_hulk/do_charge_indicator(atom/charger, atom/charge_target) - . = ..() - playsound(charger, 'sound/mobs/non-humanoids/gorilla/gorilla.ogg', 80, TRUE) - charger.visible_message(span_danger("[charger] roars and stamps, lowering [charger.p_their()] head!")) - var/direction = get_dir(charger, charge_target) - var/turf/step_turf = get_turf(charger) - for(var/i in 1 to charge_distance) - step_turf = get_step(step_turf, direction) - if(!step_turf || isclosedturf(step_turf)) - break - new /obj/effect/temp_visual/telegraphing/outpost_hulk_charge(step_turf) - -/datum/action/cooldown/mob_cooldown/charge/basic_charge/outpost_hulk/on_bump(atom/movable/source, atom/target) - var/mob/living/basic/outpost_experiment/hulk/hulk = source - if(istype(hulk) && isobj(target) && target.density && !istype(target, /obj/machinery/door/airlock) && hulk.can_break(target)) - INVOKE_ASYNC(hulk, TYPE_PROC_REF(/mob/living/basic/outpost_experiment/hulk, smash), target) - return - return ..() - -/datum/action/cooldown/mob_cooldown/charge/basic_charge/outpost_hulk/on_moved(atom/source) - . = ..() - var/mob/living/basic/outpost_experiment/hulk/hulk = source - if(!istype(hulk)) - return - for(var/obj/structure/chair/chair in get_turf(hulk)) - if(hulk.can_break(chair)) - INVOKE_ASYNC(hulk, TYPE_PROC_REF(/mob/living/basic/outpost_experiment/hulk, smash), chair) - -/datum/action/cooldown/mob_cooldown/charge/basic_charge/outpost_hulk/hit_target(atom/movable/source, atom/target, damage_dealt) - var/mob/living/basic/outpost_experiment/hulk/hulk = source - if(is_outpost_prisoner(target)) - hulk?.knock_down_prisoner(target) - return - if(isliving(target)) - var/mob/living/victim = target - victim.apply_damage(damage_dealt, BRUTE, wound_bonus = CANT_WOUND) - playsound(get_turf(victim), 'sound/effects/meteorimpact.ogg', 80, TRUE) - return ..() - hulk?.visible_message(span_danger("[hulk] slams into [target] and reels!")) - playsound(get_turf(source), 'sound/effects/bang.ogg', 80, TRUE) - hulk?.stagger_on_wall() - -/// The floor in the charge's path, for the length of the wind-up -/obj/effect/temp_visual/telegraphing/outpost_hulk_charge - duration = OUTPOST_HULK_CHARGE_WINDUP - color = "#9ae05a" - -/// tg's wall tearer, for walls inside the outpost only -/datum/element/wall_tearer/outpost_interior - -/datum/element/wall_tearer/outpost_interior/validate_target(atom/target, mob/living/tearer) - . = ..() - if(. != TRUE) - return - var/mob/living/basic/outpost_experiment/hulk/hulk = tearer - if(!istype(hulk) || !hulk.can_break(target)) - target.balloon_alert(tearer, "it won't give!") - return -1 - -// ===== FLY PERSON ===== - -/mob/living/basic/outpost_experiment/fly - desc = "A prisoner turned into something like a fly: bulging eyes, a proboscis, and a buzz you can hear across the room." - form_name = "a fly person" - base_health = OUTPOST_FLY_HEALTH - speed = OUTPOST_FLY_SPEED - melee_damage_lower = OUTPOST_FLY_BITE - melee_damage_upper = OUTPOST_FLY_BITE - melee_attack_cooldown = 1.5 SECONDS - attack_verb_continuous = "bites" - attack_verb_simple = "bite" - attack_sound = 'sound/items/weapons/bite.ogg' - attack_vis_effect = ATTACK_EFFECT_BITE - damage_coeff = list(BRUTE = 1, BURN = 1, TOX = 0, STAMINA = 1, OXY = 0) - status_flags = CANPUSH | CANSTUN | CANKNOCKDOWN - max_stamina = OUTPOST_FLY_STAMINA - line_context = "fly" - ai_controller = /datum/ai_controller/basic_controller/outpost_experiment/fly - death_message = "drops out of the air and goes still." - subdued_message = "drops out of the air, stunned." - win_hint = "It never lands for long." - /// Seconds to its next heave - var/vomit_left = OUTPOST_FLY_VOMIT_MIN - /// REF() of prisoners who watched it throw up -> world.time - var/list/disgusted = list() - /// world.time of its next random dart, and by when the dart under way must be over - var/next_dart = 0 - var/dart_until = 0 - /// Whoever hit it last, whom it keeps away from until flit_until - var/datum/weakref/flit_from_ref - var/flit_until = 0 - -/mob/living/basic/outpost_experiment/fly/Initialize(mapload, datum/outpost_prison/owner, mob/living/basic/outpost_prisoner/subject) - . = ..() - RegisterSignal(src, COMSIG_MOB_APPLY_DAMAGE_MODIFIERS, PROC_REF(swatter_weakness)) - RegisterSignal(src, COMSIG_PROJECTILE_PREHIT, PROC_REF(dodge)) - RegisterSignal(src, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_attacked)) - ADD_TRAIT(src, TRAIT_MOVE_FLYING, OUTPOST_FLY_TRAIT) - playsound(src, 'sound/mobs/non-humanoids/bee/bee_swarm.ogg', 60, TRUE) - visible_message(span_danger("[src] folds up, splits open and unfolds as something with wings!")) - -/mob/living/basic/outpost_experiment/fly/Destroy() - flit_from_ref = null - return ..() - -/mob/living/basic/outpost_experiment/fly/build_look(outfit_path) - apply_dynamic_human_appearance(src, outfit_path, /datum/species/fly) - -/// On the floor (knocked down, subdued or dead) it is not flying -/mob/living/basic/outpost_experiment/fly/on_lying_down(new_lying_angle) - . = ..() - REMOVE_TRAIT(src, TRAIT_MOVE_FLYING, OUTPOST_FLY_TRAIT) - -/// Back up, it takes off again -/mob/living/basic/outpost_experiment/fly/on_standing_up() - . = ..() - if(stat == CONSCIOUS && !subdued) - ADD_TRAIT(src, TRAIT_MOVE_FLYING, OUTPOST_FLY_TRAIT) - -/mob/living/basic/outpost_experiment/fly/down_twitch() - Shake(1, 0, 0.4 SECONDS) - playsound(src, 'sound/mobs/non-humanoids/bee/bee.ogg', 15, TRUE) - if(prob(40)) - manual_emote(pick("buzzes weakly.", "twitches [p_their()] wings.", "twitches.")) - -/// tg's fly people take thirty times the damage from a flyswatter -/mob/living/basic/outpost_experiment/fly/proc/swatter_weakness(datum/source, list/damage_mods, damage_amount, damagetype, def_zone, sharpness, attack_direction, obj/item/attacking_item) - SIGNAL_HANDLER - if(istype(attacking_item, /obj/item/melee/flyswatter)) - damage_mods += OUTPOST_FLY_SWATTER_MULT - -/// In the air and free to move: not knocked down, stunned, held, pulled, subdued or being taken away -/mob/living/basic/outpost_experiment/fly/proc/flying_freely() - if(stat != CONSCIOUS || subdued || !isturf(loc) || pulledby || buckled || body_position != STANDING_UP) - return FALSE - return !HAS_TRAIT(src, TRAIT_IMMOBILIZED) && !HAS_TRAIT(src, TRAIT_INCAPACITATED) && !HAS_TRAIT(src, TRAIT_GODMODE) - -/// Jinks out of the way of some shots while it flies freely -/mob/living/basic/outpost_experiment/fly/proc/dodge(datum/source, obj/projectile/shot) - SIGNAL_HANDLER - if(!flying_freely() || !prob(OUTPOST_FLY_DODGE)) - return NONE - visible_message(span_warning("[src] jinks out of the way of [shot]!")) - playsound(src, 'sound/mobs/non-humanoids/bee/bee.ogg', 30, TRUE) - return PROJECTILE_INTERRUPT_HIT_PHASE - -/// Hit while flying: it flits away from whoever did it, and keeps away from them for a few seconds -/mob/living/basic/outpost_experiment/fly/proc/on_attacked(datum/source, atom/attacker, attack_flags) - SIGNAL_HANDLER - if(!attacker || attacker == src || !flying_freely()) - return - flit_from_ref = WEAKREF(attacker) - flit_until = world.time + OUTPOST_FLY_FLIT_TIME - // Once the blow is over, not in the middle of it. - addtimer(CALLBACK(src, PROC_REF(flit)), 1, TIMER_UNIQUE | TIMER_OVERRIDE | TIMER_DELETE_ME) - -/// Whoever hit it within OUTPOST_FLY_FLIT_TIME, if still near enough to keep away from -/mob/living/basic/outpost_experiment/fly/proc/flit_threat() - if(world.time > flit_until) - return null - var/atom/movable/attacker = flit_from_ref?.resolve() - if(QDELETED(attacker) || attacker.z != z || get_dist(src, attacker) > OUTPOST_FLY_DART_MAX + OUTPOST_FLY_FLEE_RANGE) - return null - return attacker - -/// Darts away from whoever just hit it, at once rather than at its next thought. Returns TRUE if it went. -/mob/living/basic/outpost_experiment/fly/proc/flit() - var/atom/attacker = flit_threat() - if(!attacker || !flying_freely() || !ai_controller || !awake()) - return FALSE - var/turf/spot = dart_spot(attacker) - if(!spot) - return FALSE - ai_controller.CancelActions() - ai_controller.queue_behavior(/datum/ai_behavior/outpost_fly_dart/away, spot) - return TRUE - -/// It goes for food and bites only when cornered: its "targets" are meals, and people it cannot get away from -/mob/living/basic/outpost_experiment/fly/can_target(atom/target) - if(istype(target, /obj/item/food)) - return isturf(target.loc) - return ..() - -/// Whoever is closest within OUTPOST_FLY_FLEE_RANGE, to keep away from -/mob/living/basic/outpost_experiment/fly/proc/nearest_threat() - var/mob/living/nearest - var/nearest_distance = INFINITY - for(var/mob/living/person in range(OUTPOST_FLY_FLEE_RANGE, src)) - if(person == src || !is_victim(person)) - continue - var/distance = get_dist(src, person) - if(distance < nearest_distance) - nearest = person - nearest_distance = distance - return nearest - -/** - * Somewhere to dart to: an open tile OUTPOST_FLY_DART_MIN to OUTPOST_FLY_DART_MAX tiles off, in a - * clear line, on ground it keeps to (may_dart_to()). Away from `threat`, only somewhere farther - * from it than it is now, and out of its OUTPOST_FLY_FLEE_RANGE if it can. Null if there is - * nowhere: cornered. - */ -/mob/living/basic/outpost_experiment/fly/proc/dart_spot(atom/threat) - var/turf/here = get_turf(src) - if(!here) - return null - var/threat_distance = threat ? get_dist(here, threat) : 0 - var/list/spots = list() - var/list/clear_spots = list() - for(var/turf/open/tile in RANGE_TURFS(OUTPOST_FLY_DART_MAX, here)) - if(get_dist(here, tile) < OUTPOST_FLY_DART_MIN) - continue - var/from_threat = threat ? get_dist(tile, threat) : INFINITY - if(from_threat <= threat_distance || !may_dart_to(tile) || !clear_line(here, tile)) - continue - spots += tile - if(from_threat > OUTPOST_FLY_FLEE_RANGE) - clear_spots += tile - if(length(clear_spots)) - return pick(clear_spots) - return length(spots) ? pick(spots) : null - -/** - * Whether it keeps to `tile`: free and safe, and in the wing (its cell block, while it is in - * there) like the other creatures. Got out of the wing, it darts about the room it is in. - */ -/mob/living/basic/outpost_experiment/fly/proc/may_dart_to(turf/tile) - if(isspaceturf(tile) || isopenspaceturf(tile) || tile.is_blocked_turf(FALSE, src) || !tile.can_cross_safely(src)) - return FALSE - var/turf/here = get_turf(src) - if(prison?.wing && here.loc == prison.wing) - return tile.loc == prison.wing && (!prison.in_cell_block(here) || prison.in_cell_block(tile)) - return tile.loc == here.loc - -/// Whether it can fly straight from `start` to `finish`: nothing solid or opaque in the way -/mob/living/basic/outpost_experiment/fly/proc/clear_line(turf/start, turf/finish) - for(var/turf/step as anything in get_line(start, finish)) - if(step == start) - continue - if(step.opacity || step.is_blocked_turf(TRUE, src)) - return FALSE - return TRUE - -/** - * Keeps moving: darts away from anyone close or who just hit it, and bites only when cornered - * with someone at it. Otherwise it goes for food in sight, or darts about at random with short - * pauses. It hovers (outpost_fly_hover) rather than planning nothing, so it notices people at once. - */ -/mob/living/basic/outpost_experiment/fly/ai_think(datum/ai_controller/controller) - if(!flying_freely()) - controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) - controller.queue_behavior(/datum/ai_behavior/outpost_fly_hover) - return SUBTREE_RETURN_FINISH_PLANNING - var/atom/threat = flit_threat() || nearest_threat() - if(threat) - var/turf/away = dart_spot(threat) - if(away) - controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) - controller.queue_behavior(/datum/ai_behavior/outpost_fly_dart/away, away) - return SUBTREE_RETURN_FINISH_PLANNING - // Nowhere farther to go: it bites whoever is at it. - var/mob/living/at_it = threat - if(istype(at_it) && Adjacent(at_it) && can_target(at_it)) - controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, at_it) - return null - controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) - controller.queue_behavior(/datum/ai_behavior/outpost_fly_hover) - return SUBTREE_RETURN_FINISH_PLANNING - var/obj/item/food/meal = find_meal() - if(meal) - controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, meal) - return null - controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) - var/turf/spot = world.time >= next_dart ? dart_spot() : null - if(spot) - controller.queue_behavior(/datum/ai_behavior/outpost_fly_dart, spot) - return SUBTREE_RETURN_FINISH_PLANNING - if(world.time >= next_dart) - next_dart = world.time + rand(OUTPOST_FLY_DART_GAP_MIN, OUTPOST_FLY_DART_GAP_MAX) - controller.queue_behavior(/datum/ai_behavior/outpost_fly_hover) - return SUBTREE_RETURN_FINISH_PLANNING - -/// The nearest food in sight: a serving hatch, a table or the floor -/mob/living/basic/outpost_experiment/fly/proc/find_meal() - var/obj/item/food/best - var/best_distance = INFINITY - for(var/obj/item/food/meal in range(5, src)) - if(!isturf(meal.loc) || !can_see(src, meal, 5)) - continue - var/distance = get_dist(src, meal) - if(distance < best_distance) - best = meal - best_distance = distance - return best - -/mob/living/basic/outpost_experiment/fly/melee_attack(atom/target, list/modifiers, ignore_cooldown = FALSE) - var/obj/item/food/meal = target - if(istype(meal)) - if(!early_melee_attack(target, modifiers, ignore_cooldown)) - return FALSE - visible_message(span_warning("[src] slurps up [meal].")) - playsound(src, 'sound/items/eatfood.ogg', 40, TRUE) - if(isturf(meal.loc)) - new /obj/effect/decal/cleanable/food/crumbs(meal.loc) - qdel(meal) - return TRUE - return ..() - -/// It throws up every few seconds, now and then over someone beside it; prisoners who see it lose a little mood -/mob/living/basic/outpost_experiment/fly/creature_life(seconds_per_tick) - vomit_left -= seconds_per_tick - if(vomit_left > 0 || !isturf(loc)) - return - vomit_left = rand(OUTPOST_FLY_VOMIT_MIN, OUTPOST_FLY_VOMIT_MAX) - throw_up() - -/mob/living/basic/outpost_experiment/fly/proc/throw_up() - var/turf/spot = loc - var/list/beside = list() - for(var/mob/living/person in orange(1, src)) - if(is_victim(person)) - beside += person - if(length(beside) && prob(OUTPOST_FLY_VOMIT_ON_CHANCE)) - var/mob/living/unlucky = pick(beside) - spot = get_turf(unlucky) - visible_message(span_danger("[src] throws up all over [unlucky]!")) - else - visible_message(span_warning("[src] throws up.")) - playsound(src, 'sound/mobs/humanoids/human/gag_vomit/crack_vomit.ogg', 50, TRUE) - if(isopenturf(spot)) - new /obj/effect/decal/cleanable/vomit(spot) - for(var/mob/living/basic/outpost_prisoner/watcher in viewers(5, src)) - if(watcher.stat != CONSCIOUS || LAZYACCESS(disgusted, REF(watcher)) > world.time) - continue - LAZYSET(disgusted, REF(watcher), world.time + OUTPOST_EXPERIMENT_FLY_DISGUST_GAP) - watcher.adjust_mood(-OUTPOST_EXPERIMENT_FLY_DISGUST_MOOD) - return spot - -// ===== NIGHTMARE ===== - -/mob/living/basic/outpost_experiment/nightmare - desc = "A shape like a person cut out of the dark, with a long blade where one arm should be." - form_name = "a nightmare" - footstep_kind = FOOTSTEP_MOB_BAREFOOT - footstep_volume = 0.3 - base_health = OUTPOST_NIGHTMARE_HEALTH - health_per_player = OUTPOST_NIGHTMARE_HEALTH_PER_PLAYER - speed = OUTPOST_NIGHTMARE_DARK_SPEED - melee_damage_lower = OUTPOST_NIGHTMARE_DAMAGE - melee_damage_upper = OUTPOST_NIGHTMARE_DAMAGE - melee_attack_cooldown = OUTPOST_NIGHTMARE_ATTACK_COOLDOWN - armour_penetration = OUTPOST_NIGHTMARE_ARMOUR_PENETRATION - attack_verb_continuous = "slashes" - attack_verb_simple = "slash" - attack_sound = 'sound/items/weapons/bladeslice.ogg' - attack_vis_effect = ATTACK_EFFECT_SLASH - sharpness = SHARP_EDGED - lighting_cutoff = LIGHTING_CUTOFF_HIGH - /// Seconds left of breaking the lights before it hunts - var/opening_left = OUTPOST_NIGHTMARE_OPENING_MIN - /// Mid jaunt: gone into the dark, about to come out beside someone - var/jaunting = FALSE - /// Where it will come out, and at whom - var/turf/jaunt_spot - var/datum/weakref/jaunt_target_ref - /// Its last light reading was dark - var/in_shadow = TRUE - COOLDOWN_DECLARE(jaunt_cooldown) - -/mob/living/basic/outpost_experiment/nightmare/Initialize(mapload, datum/outpost_prison/owner, mob/living/basic/outpost_prisoner/subject) - . = ..() - opening_left = rand(OUTPOST_NIGHTMARE_OPENING_MIN, OUTPOST_NIGHTMARE_OPENING_MAX) - RegisterSignal(src, COMSIG_PROJECTILE_PREHIT, PROC_REF(dodge)) - RegisterSignal(src, COMSIG_ATOM_ATTACKBY, PROC_REF(on_attackby)) - playsound(src, 'sound/effects/hallucinations/wail.ogg', 60, TRUE) - visible_message(span_danger("The light seems to drain out of [src], and something else stands where [p_they()] stood.")) - -/mob/living/basic/outpost_experiment/nightmare/Destroy() - jaunt_spot = null - return ..() - -/mob/living/basic/outpost_experiment/nightmare/build_look(outfit_path) - apply_dynamic_human_appearance(src, /datum/outfit/outpost_experiment_nightmare, /datum/species/shadow/nightmare) - -/// Whether the tile it stands on is dark -/mob/living/basic/outpost_experiment/nightmare/proc/in_dark(turf/tile = get_turf(src)) - return tile && tile.get_lumcount() < OUTPOST_NIGHTMARE_DARK - -/// Each second: heal in the dark and move fast, burn in the light and move slow; the opening runs down -/mob/living/basic/outpost_experiment/nightmare/creature_life(seconds_per_tick) - if(opening_left > 0) - opening_left -= seconds_per_tick - in_shadow = in_dark() - set_varspeed(in_shadow ? OUTPOST_NIGHTMARE_DARK_SPEED : OUTPOST_NIGHTMARE_LIGHT_SPEED) - if(in_shadow) - if(health < maxHealth) - adjustBruteLoss(-OUTPOST_NIGHTMARE_REGEN * seconds_per_tick) - return - if(jaunting) - cancel_jaunt() - var/burn = OUTPOST_NIGHTMARE_BURN * seconds_per_tick - adjustFireLoss(burn) - // The crew's lights are their weapon. - var/datum/component/experiment_damage_ledger/ledger = GetComponent(/datum/component/experiment_damage_ledger) - ledger?.add_damage(burn, TRUE) - if(prob(20)) - visible_message(span_warning("[src] smokes and shrinks from the light.")) - -/// Whether it is still breaking the lights: for its first half minute, until it is hurt, or until there are none -/mob/living/basic/outpost_experiment/nightmare/proc/in_opening() - if(opening_left <= 0) - return FALSE - var/datum/component/experiment_damage_ledger/ledger = GetComponent(/datum/component/experiment_damage_ledger) - if(ledger && (ledger.player_damage + ledger.other_damage + ledger.pending) > 0) - opening_left = 0 - return FALSE - return TRUE - -/// Prisoners first, standing or down; it finishes what it starts -/mob/living/basic/outpost_experiment/nightmare/target_penalty(mob/living/target) - return is_outpost_prisoner(target) ? -3 : 0 - -/// Mid-jaunt it is immobile by design, not stuck -/mob/living/basic/outpost_experiment/nightmare/chasing_paused() - return jaunting - -/// Lights, during the opening -/mob/living/basic/outpost_experiment/nightmare/can_target(atom/target) - if(istype(target, /obj/machinery/light)) - var/obj/machinery/light/fixture = target - return fixture.status != LIGHT_BROKEN && fixture.status != LIGHT_EMPTY - return ..() - -/// The nearest working light in sight -/mob/living/basic/outpost_experiment/nightmare/proc/find_light() - var/obj/machinery/light/best - var/best_distance = INFINITY - for(var/obj/machinery/light/fixture in range(9, src)) - if(!can_target(fixture) || !can_see(src, fixture, 9) || target_unreachable(fixture)) - continue - var/distance = get_dist(src, fixture) - if(distance < best_distance) - best = fixture - best_distance = distance - return best - -/mob/living/basic/outpost_experiment/nightmare/ai_think(datum/ai_controller/controller) - if(jaunting) - controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) - return SUBTREE_RETURN_FINISH_PLANNING - if(in_opening()) - var/obj/machinery/light/fixture = find_light() - if(fixture) - controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, fixture) - return null - opening_left = 0 - . = ..() - var/mob/living/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] - if(!isliving(target) || get_dist(src, target) <= 1) - return - var/turf/spot = jaunt_spot_near(target) - if(!spot) - return - start_jaunt(target, spot) - return SUBTREE_RETURN_FINISH_PLANNING - -/// A light eater hit; a light is simply put out, and a flashlight in the victim's hands may burn out for good -/mob/living/basic/outpost_experiment/nightmare/melee_attack(atom/target, list/modifiers, ignore_cooldown = FALSE) - var/obj/machinery/light/fixture = target - if(istype(fixture)) - if(!early_melee_attack(target, modifiers, ignore_cooldown)) - return FALSE - do_attack_animation(fixture, ATTACK_EFFECT_SLASH) - if(fixture.status == LIGHT_OK || fixture.status == LIGHT_BURNED) - fixture.visible_message(span_danger("[src] cuts through [fixture], and it goes dark.")) - fixture.break_light_tube() - return TRUE - . = ..() - if(. && isliving(target)) - eat_held_light(target) - -/// OUTPOST_NIGHTMARE_BURNOUT_CHANCE to put out a flashlight `victim` holds for good; never a flare or glowstick -/mob/living/basic/outpost_experiment/nightmare/proc/eat_held_light(mob/living/victim) - if(!prob(OUTPOST_NIGHTMARE_BURNOUT_CHANCE)) - return null - for(var/obj/item/flashlight/light in victim.held_items) - if(istype(light, /obj/item/flashlight/flare) || istype(light, /obj/item/flashlight/glowstick) || !light.light_on) - continue - if(SEND_SIGNAL(light, COMSIG_LIGHT_EATER_ACT, src) & COMPONENT_BLOCK_LIGHT_EATER) - continue - light.AddElement(/datum/element/light_eaten) - victim.visible_message(span_danger("[src]'s blade passes through [light], and it dies in [victim]'s hand.")) - return light - return null - -/// Sidesteps most shots in the dark -/mob/living/basic/outpost_experiment/nightmare/proc/dodge(datum/source, obj/projectile/shot) - SIGNAL_HANDLER - if(stat != CONSCIOUS || !in_dark() || !prob(OUTPOST_NIGHTMARE_DODGE)) - return NONE - visible_message(span_warning("[src] melts aside from [shot]!")) - return PROJECTILE_INTERRUPT_HIT_PHASE - -/// A handheld flash burns it, staggers it and throws it out of a jaunt -/mob/living/basic/outpost_experiment/nightmare/proc/on_attackby(datum/source, obj/item/attacking_item, mob/living/user, list/modifiers, list/attack_modifiers) - SIGNAL_HANDLER - var/obj/item/assembly/flash/flash = attacking_item - if(!istype(flash) || stat == DEAD || flash.burnt_out || world.time < flash.last_trigger + flash.cooldown) - return NONE - INVOKE_ASYNC(flash, TYPE_PROC_REF(/obj/item/assembly/flash, try_use_flash), user) - INVOKE_ASYNC(src, PROC_REF(flashed), user) - return COMPONENT_NO_AFTERATTACK - -/mob/living/basic/outpost_experiment/nightmare/proc/flashed(mob/living/user) - var/datum/component/experiment_damage_ledger/ledger = GetComponent(/datum/component/experiment_damage_ledger) - ledger?.note_attacker(user) - cancel_jaunt() - visible_message(span_danger("[src] shrieks and recoils from the flash!")) - apply_damage(OUTPOST_NIGHTMARE_FLASH_DAMAGE, BURN) - Stun(OUTPOST_NIGHTMARE_FLASH_STAGGER, ignore_canstun = TRUE) - -/// A dark tile beside `target` it could jaunt to, if the jaunt is ready and it stands in the dark -/mob/living/basic/outpost_experiment/nightmare/proc/jaunt_spot_near(mob/living/target) - if(jaunting || !COOLDOWN_FINISHED(src, jaunt_cooldown) || !in_dark()) - return null - var/list/spots = list() - for(var/turf/open/tile in orange(1, target)) - if(tile.is_blocked_turf(TRUE) || !in_dark(tile) || !prison?.outpost_holds(tile)) - continue - spots += tile - return length(spots) ? pick(spots) : null - -/// Fades into the dark; a ripple and a whisper warn where it will come out, OUTPOST_NIGHTMARE_JAUNT_RIPPLE later -/mob/living/basic/outpost_experiment/nightmare/proc/start_jaunt(mob/living/target, turf/spot) - jaunting = TRUE - jaunt_spot = spot - jaunt_target_ref = WEAKREF(target) - COOLDOWN_START(src, jaunt_cooldown, OUTPOST_NIGHTMARE_JAUNT_COOLDOWN) - ADD_TRAIT(src, TRAIT_IMMOBILIZED, REF(src)) - ai_controller?.CancelActions() - animate(src, alpha = 0, time = 0.3 SECONDS) - new /obj/effect/temp_visual/telegraphing/outpost_shadow_ripple(spot) - playsound(spot, pick('sound/effects/hallucinations/behind_you1.ogg', 'sound/effects/hallucinations/behind_you2.ogg', 'sound/effects/hallucinations/i_see_you2.ogg'), 35, TRUE) - addtimer(CALLBACK(src, PROC_REF(finish_jaunt)), OUTPOST_NIGHTMARE_JAUNT_RIPPLE, TIMER_DELETE_ME) - -/// Comes out beside the target, if the spot is still dark, and strikes -/mob/living/basic/outpost_experiment/nightmare/proc/finish_jaunt() - if(!jaunting) - return FALSE - var/turf/spot = jaunt_spot - var/mob/living/target = jaunt_target_ref?.resolve() - end_jaunt() - if(stat == DEAD || !spot || !in_dark(spot) || spot.is_blocked_turf(TRUE)) - return FALSE - forceMove(spot) - if(!target || !Adjacent(target) || !can_target(target)) - return TRUE - face_atom(target) - do_attack_animation(target, ATTACK_EFFECT_SLASH) - playsound(target, 'sound/items/weapons/bladeslice.ogg', 60, TRUE) - target.visible_message(span_danger("[src] lunges out of the dark at [target]!"), span_userdanger("[src] lunges out of the dark at you!")) - target.apply_damage(OUTPOST_NIGHTMARE_JAUNT_DAMAGE, BRUTE, wound_bonus = CANT_WOUND) - target.Knockdown(OUTPOST_NIGHTMARE_JAUNT_KNOCKDOWN) - return TRUE - -/// Thrown out of a jaunt (light, a flash): back where it went in -/mob/living/basic/outpost_experiment/nightmare/proc/cancel_jaunt() - if(!jaunting) - return - end_jaunt() - visible_message(span_warning("[src] is forced out of the shadows!")) - -/mob/living/basic/outpost_experiment/nightmare/proc/end_jaunt() - jaunting = FALSE - jaunt_spot = null - jaunt_target_ref = null - REMOVE_TRAIT(src, TRAIT_IMMOBILIZED, REF(src)) - animate(src, alpha = 255, time = 0.2 SECONDS) - -/// Where the nightmare will come out of the dark -/obj/effect/temp_visual/telegraphing/outpost_shadow_ripple - icon = 'icons/mob/telegraphing/telegraph.dmi' - icon_state = "target_circle" - color = "#2a0a3a" - light_range = 0 - duration = OUTPOST_NIGHTMARE_JAUNT_RIPPLE - -/// The nightmare's look: tg's light eater in hand -/datum/outfit/outpost_experiment_nightmare - name = "Prison experiment nightmare" - r_hand = /obj/item/light_eater - -// ===== AI ===== - -/// Chases what the creature's own ai_think() picks, breaks what it may out of the way, and fights -/datum/ai_controller/basic_controller/outpost_experiment - blackboard = list( - BB_TARGETING_STRATEGY = /datum/targeting_strategy/outpost_experiment, - BB_TARGET_MINIMUM_STAT = HARD_CRIT, - ) - ai_movement = /datum/ai_movement/jps - idle_behavior = /datum/idle_behavior/idle_random_walk - planning_subtrees = list( - /datum/ai_planning_subtree/outpost_experiment_think, - /datum/ai_planning_subtree/attack_obstacle_in_path/outpost_experiment, - /datum/ai_planning_subtree/basic_melee_attack_subtree, - ) - -/// The fly person moves only in its own darts: no aimless steps, which would also crawl it about while knocked down -/datum/ai_controller/basic_controller/outpost_experiment/fly - idle_behavior = null - -/// The fly person's darts: straight hops that start at once -/datum/ai_movement/basic_avoidance/outpost_fly - move_flags = MOVEMENT_LOOP_START_FAST - -/** - * A fly person's dart to the turf it picked (dart_spot()): done when it gets there, given up after - * OUTPOST_FLY_DART_TIMEOUT. Planning goes on meanwhile, so a dart away from someone can cut a - * random one short. A random dart is followed by a short pause. - */ -/datum/ai_behavior/outpost_fly_dart - required_distance = 0 - action_cooldown = 0 - behavior_flags = AI_BEHAVIOR_REQUIRE_MOVEMENT | AI_BEHAVIOR_MOVE_AND_PERFORM | AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION - -/datum/ai_behavior/outpost_fly_dart/setup(datum/ai_controller/controller, turf/destination) - var/mob/living/basic/outpost_experiment/fly/fly = controller.pawn - if(!istype(fly) || !isturf(destination) || destination.z != fly.z) - return FALSE - fly.dart_until = world.time + OUTPOST_FLY_DART_TIMEOUT - set_movement_target(controller, destination, /datum/ai_movement/basic_avoidance/outpost_fly) - return ..() - -/datum/ai_behavior/outpost_fly_dart/perform(seconds_per_tick, datum/ai_controller/controller, turf/destination) - var/mob/living/basic/outpost_experiment/fly/fly = controller.pawn - if(!istype(fly) || world.time >= fly.dart_until) - return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED - if(get_turf(fly) == destination) - return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED - return AI_BEHAVIOR_DELAY - -/datum/ai_behavior/outpost_fly_dart/finish_action(datum/ai_controller/controller, succeeded, turf/destination) - // A dart that took over from this one has set its own movement; leave that be. - var/moving_for_us = controller.movement_target_source == type - . = ..() - if(moving_for_us) - controller.change_ai_movement_type(initial(controller.ai_movement)) - var/mob/living/basic/outpost_experiment/fly/fly = controller.pawn - if(istype(fly)) - fly.next_dart = world.time + pause_after() - -/// How long it hangs in the air after this dart before the next random one -/datum/ai_behavior/outpost_fly_dart/proc/pause_after() - return rand(OUTPOST_FLY_DART_GAP_MIN, OUTPOST_FLY_DART_GAP_MAX) - -/// Away from someone: no pause after it -/datum/ai_behavior/outpost_fly_dart/away - -/datum/ai_behavior/outpost_fly_dart/away/pause_after() - return 0 - -/// The fly person hanging in the air between darts. Planning goes on, so it notices anyone coming at once. -/datum/ai_behavior/outpost_fly_hover - action_cooldown = 0 - behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION - -/datum/ai_behavior/outpost_fly_hover/perform(seconds_per_tick, datum/ai_controller/controller) - var/mob/living/basic/outpost_experiment/fly/fly = controller.pawn - if(!istype(fly) || world.time >= fly.next_dart) - return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED - return AI_BEHAVIOR_DELAY - -/// The creature decides what it is after -/datum/ai_planning_subtree/outpost_experiment_think - -/datum/ai_planning_subtree/outpost_experiment_think/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/outpost_experiment/creature = controller.pawn - if(!istype(creature) || creature.subdued) - return SUBTREE_RETURN_FINISH_PLANNING - creature.track_reach(controller) - return creature.ai_think(controller) - -/// Only what the creature may break -/datum/ai_planning_subtree/attack_obstacle_in_path/outpost_experiment - attack_behaviour = /datum/ai_behavior/attack_obstructions/outpost_experiment - -/datum/ai_behavior/attack_obstructions/outpost_experiment - -/datum/ai_behavior/attack_obstructions/outpost_experiment/attack_in_direction(datum/ai_controller/controller, mob/living/basic/basic_mob, direction) - var/mob/living/basic/outpost_experiment/creature = basic_mob - if(!istype(creature)) - return FALSE - var/turf/next_step = get_step(basic_mob, direction) - if(!next_step?.is_blocked_turf(exclude_mobs = TRUE, source_atom = basic_mob)) - return FALSE - for(var/obj/object in next_step) - if(!object.density || object.IsObscured() || !creature.can_break(object)) - continue - return creature.break_obstacle(object) - if(isclosedturf(next_step) && creature.can_break(next_step)) - return creature.break_obstacle(next_step) - return FALSE - -/// A creature's targets are whatever its can_target() says, in reach on its level -/datum/targeting_strategy/outpost_experiment - -/datum/targeting_strategy/outpost_experiment/can_attack(mob/living/living_mob, atom/target, vision_range) - var/mob/living/basic/outpost_experiment/creature = living_mob - if(!istype(creature) || QDELETED(target) || !isturf(creature.loc)) - return FALSE - var/turf/target_turf = get_turf(target) - if(!target_turf || target_turf.z != creature.z) - return FALSE - if(vision_range && get_dist(creature, target) > vision_range) - return FALSE - return creature.can_target(target) diff --git a/voidcrew/modules/player_outposts/outpost_prison_dialogue.dm b/voidcrew/modules/player_outposts/outpost_prison_dialogue.dm index 6b4665a7f4b..c4231e4e93b 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_dialogue.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_dialogue.dm @@ -33,7 +33,7 @@ return islist(entry) ? entry : list() /// Scales a prisoner's pause between spontaneous lines -/mob/living/basic/outpost_prisoner/proc/speech_pace() +/mob/living/carbon/human/npc/outpost_prisoner/proc/speech_pace() switch(personality) if("chatty") return 0.6 @@ -46,7 +46,7 @@ return 1 /// Their sentence left in words, for {time_left} -/mob/living/basic/outpost_prisoner/proc/time_left_text() +/mob/living/carbon/human/npc/outpost_prisoner/proc/time_left_text() var/seconds = max(0, round(sentence_left)) var/minutes = round(seconds / 60 + 0.5) if(minutes >= 2) @@ -56,7 +56,7 @@ return "[max(seconds, 1)] seconds" /// Fills a line's placeholders for this speaker, talking to `other` -/mob/living/basic/outpost_prisoner/proc/fill_line(line, mob/living/basic/outpost_prisoner/other) +/mob/living/carbon/human/npc/outpost_prisoner/proc/fill_line(line, mob/living/carbon/human/npc/outpost_prisoner/other) line = replacetext(line, "{name}", speech_name()) line = replacetext(line, "{other}", other ? other.speech_name() : "pal") line = replacetext(line, "{crime}", crime) @@ -70,7 +70,7 @@ * A line for `context`, filled in, or null when the file has none that fits. Personality lines * come up more often than the shared ones; lines naming {other} need someone to talk to. */ -/mob/living/basic/outpost_prisoner/proc/pick_line(context, mob/living/basic/outpost_prisoner/other) +/mob/living/carbon/human/npc/outpost_prisoner/proc/pick_line(context, mob/living/carbon/human/npc/outpost_prisoner/other) // The main file first, then the extras' files (outpost_prison_extras.dm) var/list/by_personality = outpost_prisoner_context_lines(context) if(!islist(by_personality)) @@ -86,7 +86,7 @@ return fill_line(pick(usable), other) /// The lines of `pool` they can say now: not the last thing they said, naming nobody when alone, and no extra placeholder they have no value for -/mob/living/basic/outpost_prisoner/proc/usable_lines(list/pool, mob/living/basic/outpost_prisoner/other) +/mob/living/carbon/human/npc/outpost_prisoner/proc/usable_lines(list/pool, mob/living/carbon/human/npc/outpost_prisoner/other) var/list/usable = list() for(var/line in pool) if(!istext(line) || line == last_line || (!other && findtext(line, "{other}"))) @@ -97,7 +97,7 @@ return usable /// Whether `line` names an extra placeholder ({staff}, {place}, ...) that extra_line_values has no value for -/mob/living/basic/outpost_prisoner/proc/missing_extra_value(line) +/mob/living/carbon/human/npc/outpost_prisoner/proc/missing_extra_value(line) for(var/placeholder in GLOB.outpost_prisoner_extra_placeholders) if(findtext(line, placeholder) && isnull(LAZYACCESS(extra_line_values, placeholder))) return TRUE @@ -107,11 +107,11 @@ * Whether they may say anything now: awake and all the way here. Never while beaming in or out, * when they are invisible or only half there. */ -/mob/living/basic/outpost_prisoner/proc/may_speak() +/mob/living/carbon/human/npc/outpost_prisoner/proc/may_speak() return !QDELETED(src) && stat == CONSCIOUS && phase == PRISONER_PRESENT /// Says a line for `context`. Returns TRUE if they said something. -/mob/living/basic/outpost_prisoner/proc/say_context(context, mob/living/basic/outpost_prisoner/other) +/mob/living/carbon/human/npc/outpost_prisoner/proc/say_context(context, mob/living/carbon/human/npc/outpost_prisoner/other) if(!may_speak()) return FALSE var/line = pick_line(context, other) @@ -122,7 +122,7 @@ return TRUE /// Thanks whoever fed, clothed or treated them, no more than every 20 seconds -/mob/living/basic/outpost_prisoner/proc/thank(context) +/mob/living/carbon/human/npc/outpost_prisoner/proc/thank(context) if(phase != PRISONER_PRESENT || !COOLDOWN_FINISHED(src, thanks_cooldown)) return FALSE if(!say_context(context)) @@ -134,7 +134,7 @@ * Opens a two-person exchange with `partner`, who answers a few seconds later with one of the * opener's replies. Returns TRUE if it started. */ -/mob/living/basic/outpost_prisoner/proc/start_conversation(mob/living/basic/outpost_prisoner/partner) +/mob/living/carbon/human/npc/outpost_prisoner/proc/start_conversation(mob/living/carbon/human/npc/outpost_prisoner/partner) if(!may_speak() || QDELETED(partner) || !partner.may_speak()) return FALSE var/list/conversations = outpost_prisoner_dialogue("conversations") @@ -153,8 +153,8 @@ return TRUE /// The second half of a conversation -/mob/living/basic/outpost_prisoner/proc/reply_in_conversation(line, datum/weakref/opener_ref) - var/mob/living/basic/outpost_prisoner/opener = opener_ref?.resolve() +/mob/living/carbon/human/npc/outpost_prisoner/proc/reply_in_conversation(line, datum/weakref/opener_ref) + var/mob/living/carbon/human/npc/outpost_prisoner/opener = opener_ref?.resolve() if(!may_speak() || QDELETED(opener) || get_dist(src, opener) > 5) return FALSE face_atom(opener) @@ -163,15 +163,15 @@ return TRUE /// Whether a member of staff (see is_outpost_prison_staff()) is in sight, borgs included -/mob/living/basic/outpost_prisoner/proc/staff_in_view() +/mob/living/carbon/human/npc/outpost_prisoner/proc/staff_in_view() for(var/mob/living/person in view(5, src)) if(is_outpost_prison_staff(person)) return TRUE return FALSE /// Another prisoner close by, to talk at -/mob/living/basic/outpost_prisoner/proc/nearby_prisoner() - for(var/mob/living/basic/outpost_prisoner/other in view(3, src)) +/mob/living/carbon/human/npc/outpost_prisoner/proc/nearby_prisoner() + for(var/mob/living/carbon/human/npc/outpost_prisoner/other in view(3, src)) if(other != src && other.stat == CONSCIOUS && other.phase == PRISONER_PRESENT) return other return null @@ -180,18 +180,18 @@ * What to talk about now, as list(context, other), most pressing first: cuffs, trouble, lockdown, * being locked in, needs, the state of the wing, staff in sight, what they are doing, then small talk. */ -/mob/living/basic/outpost_prisoner/proc/pick_speech() +/mob/living/carbon/human/npc/outpost_prisoner/proc/pick_speech() if(activity?.sleeping) return prob(25) ? list("sleeping", null) : null // Cuffed, they complain about it (outpost_prison_capture.dm). - if(cuffs && prob(50)) + if(handcuffed && prob(50)) return list("cuffed", null) // Trouble has its own lines, said as it happens (outpost_prison_trouble.dm). if(trouble == PRISONER_TROUBLE_LOOSE) return prob(50) ? list("breakout", null) : null if(is_rioting()) return list("riot", null) - if(trouble || beaten_left > 0 || threat_ref || climb_ref) + if(trouble || beaten || threat_ref || climb_ref) return null // Running from a creature, they shout about that instead (outpost_prison_panic.dm). if(is_panicking()) @@ -230,7 +230,7 @@ return extra if(prob(30) && staff_in_view()) return list("staff_near", null) - var/mob/living/basic/outpost_prisoner/partner = activity?.chat_partner() + var/mob/living/carbon/human/npc/outpost_prisoner/partner = activity?.chat_partner() if(activity?.context && prob(60)) return list(activity.context, partner) return list("idle", partner || nearby_prisoner()) @@ -239,7 +239,7 @@ * Called about once a second by the prison. Most seconds they say nothing; once their own and * the wing's cooldowns are up there is a small chance each second. */ -/mob/living/basic/outpost_prisoner/proc/speech_tick() +/mob/living/carbon/human/npc/outpost_prisoner/proc/speech_tick() if(stat != CONSCIOUS || phase != PRISONER_PRESENT || !prison) return FALSE if(!said_release_soon && sentence_left <= 90) @@ -290,7 +290,7 @@ return 1 /// A piece of mess on the worst tile of the cell block's floor they can see nearby, or null -/mob/living/basic/outpost_prisoner/proc/worst_mess_in_view() +/mob/living/carbon/human/npc/outpost_prisoner/proc/worst_mess_in_view() var/list/tile_load = list() var/atom/movable/worst var/worst_load = 0 @@ -308,7 +308,7 @@ return worst /// The nearest light in the wing they can see that gives no light, or null -/mob/living/basic/outpost_prisoner/proc/dead_light_in_view() +/mob/living/carbon/human/npc/outpost_prisoner/proc/dead_light_in_view() var/obj/machinery/light/nearest var/nearest_distance = INFINITY for(var/obj/machinery/light/fixture in view(PRISONER_POINT_RANGE, src)) @@ -326,7 +326,7 @@ * After a dirty_prison or dark line, with staff in sight, points at what they mean: the worst mess * or the dead light near them. Returns what they pointed at, or null. */ -/mob/living/basic/outpost_prisoner/proc/show_complaint(context) +/mob/living/carbon/human/npc/outpost_prisoner/proc/show_complaint(context) if(context != "dirty_prison" && context != "dark") return null if(stat != CONSCIOUS || !isturf(loc) || !staff_in_view()) diff --git a/voidcrew/modules/player_outposts/outpost_prison_doors.dm b/voidcrew/modules/player_outposts/outpost_prison_doors.dm index d9005801156..0e49bf6ef6f 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_doors.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_doors.dm @@ -101,7 +101,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/door/window/brigdoor/outpost_prison_s /// Whether `thing` is a loose prisoner: out of the cell block and on the run /proc/outpost_prisoner_loose(atom/thing) - var/mob/living/basic/outpost_prisoner/prisoner = thing + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = thing return istype(prisoner) && prisoner.trouble == PRISONER_TROUBLE_LOOSE /obj/machinery/door/airlock/security/prison_staff/glass diff --git a/voidcrew/modules/player_outposts/outpost_prison_economy.dm b/voidcrew/modules/player_outposts/outpost_prison_economy.dm index 501f1c0c41d..f8ee9c662f0 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_economy.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_economy.dm @@ -61,7 +61,7 @@ * long enough to stop paying. Not while it is for their own safety, or they are hiding in their own * cell from a creature (outpost_prison_panic.dm), or for lockdown they owe. */ -/datum/outpost_prison/proc/confined_unpaid(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/confined_unpaid(mob/living/carbon/human/npc/outpost_prisoner/prisoner) return (prisoner.locked_in_seconds > OUTPOST_PRISON_CONFINED_PAY_AFTER && !protective_custody() && !prisoner.sheltering_from_creature()) || prisoner.cuffs_souring() /** @@ -69,7 +69,7 @@ * Nothing while they are dead, arriving or leaving, not earning (fighting, rioting, loose and the * like), or confined to their cell too long. */ -/datum/outpost_prison/proc/pay_factor(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/pay_factor(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(QDELETED(prisoner) || prisoner.stat == DEAD || prisoner.phase != PRISONER_PRESENT || !prisoner.earning_pay()) return 0 if(confined_unpaid(prisoner)) @@ -77,7 +77,7 @@ return care_grade(prisoner.care()) * conditions_pay_factor() /// A prisoner served `served` seconds of their sentence: their stipend for it, and the seconds served and kept for the release bonus -/datum/outpost_prison/proc/accrue_pay(mob/living/basic/outpost_prisoner/prisoner, served) +/datum/outpost_prison/proc/accrue_pay(mob/living/carbon/human/npc/outpost_prisoner/prisoner, served) var/factor = pay_factor(prisoner) pay_owed += OUTPOST_PRISON_BASE_PAY * bounty_pay_mult(prisoner) * factor * served / 60 prisoner.served_seconds += served @@ -116,13 +116,13 @@ return 0 /// What a prisoner earns the treasury per minute right now -/datum/outpost_prison/proc/prisoner_pay_rate(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/prisoner_pay_rate(mob/living/carbon/human/npc/outpost_prisoner/prisoner) return OUTPOST_PRISON_BASE_PAY * bounty_pay_mult(prisoner) * pay_factor(prisoner) /// What every prisoner earns the treasury per minute right now /datum/outpost_prison/proc/pay_rate() var/total = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) total += prisoner_pay_rate(prisoner) return total @@ -201,8 +201,8 @@ /datum/outpost_prison/proc/incident_ongoing() if(riot_active) return TRUE - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) - if(prisoner.phase == PRISONER_PRESENT && prisoner.stat != DEAD && (prisoner.is_rioting() || (prisoner.trouble == PRISONER_TROUBLE_LOOSE && !prisoner.cuffs))) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) + if(prisoner.phase == PRISONER_PRESENT && prisoner.stat != DEAD && (prisoner.is_rioting() || (prisoner.trouble == PRISONER_TROUBLE_LOOSE && !prisoner.handcuffed))) return TRUE return FALSE @@ -213,7 +213,7 @@ * OUTPOST_PRISON_LOST_TO_SUSPEND lost within OUTPOST_PRISON_LOST_WINDOW, the corrections service * suspends transfers until a manager reopens intake. */ -/datum/outpost_prison/proc/note_prisoner_lost(mob/living/basic/outpost_prisoner/prisoner, reason) +/datum/outpost_prison/proc/note_prisoner_lost(mob/living/carbon/human/npc/outpost_prisoner/prisoner, reason) lost_log += world.time var/lost = lost_recently() log_game("PLAYER OUTPOST PRISON: '[outpost?.name]' lost [prisoner?.real_name || "a prisoner"] ([reason || "lost"]), [lost] lost recently") @@ -401,7 +401,7 @@ if(!spot) continue // An ordinary arrival may be a caught bounty criminal from the pool; the admin panel's never is (outpost_prison_bounty.dm). - var/mob/living/basic/outpost_prisoner/prisoner = new(spot, forced ? null : bounty_pool_take(src)) + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = new(spot, forced ? null : bounty_pool_take(src)) admit(prisoner, cell) prisoner.beam_in() start_arrival_gap(lane || soonest_lane()) @@ -410,7 +410,7 @@ return null /// Books a prisoner into a cell (the first free one when none is given), in the mood the yard puts newcomers in -/datum/outpost_prison/proc/admit(mob/living/basic/outpost_prisoner/prisoner, datum/outpost_prison_cell/into) +/datum/outpost_prison/proc/admit(mob/living/carbon/human/npc/outpost_prisoner/prisoner, datum/outpost_prison_cell/into) if(!into) for(var/datum/outpost_prison_cell/cell as anything in cells) if(!cell.occupant) @@ -435,7 +435,7 @@ * After a tick of a prisoner's sentence: released once it has run out, and sent back to their * cell in its last OUTPOST_PRISON_RELEASE_WALK seconds. */ -/datum/outpost_prison/proc/check_release(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/check_release(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(prisoner.sentence_left <= 0) release(prisoner) else if(prisoner.sentence_left <= OUTPOST_PRISON_RELEASE_WALK && !istype(prisoner.activity, /datum/prisoner_activity/go_home) && !prisoner.in_trouble()) @@ -443,7 +443,7 @@ prisoner.end_activity() /// Sentence served: pays the release bonus and beams the prisoner out of wherever they stand -/datum/outpost_prison/proc/release(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/release(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(prisoner.phase != PRISONER_PRESENT || prisoner.stat == DEAD) return 0 var/average = prisoner.served_seconds ? prisoner.kept_seconds / prisoner.served_seconds : 0 @@ -461,7 +461,7 @@ * A prisoner died. Nobody comes for the body (body_tick()): it keeps its cell until staff carry it * out of the cell block. A death blamed on staff costs no fine, but the yard takes it hard (blame_death()). */ -/datum/outpost_prison/proc/on_prisoner_death(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/on_prisoner_death(mob/living/carbon/human/npc/outpost_prisoner/prisoner) add_log("[prisoner.real_name] died.") close_bounty_record(prisoner, BOUNTY_RECORD_DEAD) prisoner.died_at = world.time @@ -478,7 +478,7 @@ * it leaves the roster, and its cell waits a refill. An experiment under way that still needs it, * a specimen host about to burst, keeps it on the roster wherever it is. */ -/datum/outpost_prison/proc/body_tick(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/body_tick(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(in_cell_block(prisoner) || held_for_experiment(prisoner)) return add_log("[prisoner.real_name]'s body is out of the cell block.") @@ -487,7 +487,7 @@ /// Prisoners' bodies lying in the cell block, which nobody comes for /datum/outpost_prison/proc/bodies_in_cell_block() . = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.stat == DEAD && prisoner.phase == PRISONER_PRESENT && in_cell_block(prisoner)) .++ @@ -512,7 +512,7 @@ */ /datum/outpost_prison/proc/on_outpost_abandoned() var/out_of_hand = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.phase == PRISONER_PRESENT && prisoner.stat != DEAD && (prisoner.is_rioting() || prisoner.trouble == PRISONER_TROUBLE_LOOSE)) out_of_hand++ if(out_of_hand) @@ -524,7 +524,7 @@ lost_log.Cut() pay_owed = 0 var/transferred = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners.Copy()) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners.Copy()) if(QDELETED(prisoner) || prisoner.phase == PRISONER_LEAVING) continue close_bounty_record(prisoner, BOUNTY_RECORD_CLOSED) diff --git a/voidcrew/modules/player_outposts/outpost_prison_experiment_forms.dm b/voidcrew/modules/player_outposts/outpost_prison_experiment_forms.dm new file mode 100644 index 00000000000..102eb718f16 --- /dev/null +++ b/voidcrew/modules/player_outposts/outpost_prison_experiment_forms.dm @@ -0,0 +1,1256 @@ +/** + * # What the serum makes of a prisoner + * + * The serum (outpost_prison_experiments.dm) works on the subject's own body, with tg's own biology + * (human NPC migration, phase E2; owner defaults EX-1 to EX-15): + * - The hulk: tg's hulk gene (it shrugs off stuns and shoves, punches walls down and people about, and + * loses it when the body drops into crit) and tg's gigantism for its size. It charges with a roar and a + * line on the floor, staggers when it hits a wall, forces doors, smashes furniture in its way and knocks + * standing prisoners flat. Beaten into crit it is an ordinary person again, and batons and cuffs work. + * - The fly person: tg's fly species (a flyswatter does thirty times the damage, and it throws up what it + * eats). It darts about the wing, away from anyone close and from whoever just hit it, hits back only + * when cornered, and goes for any food it sees. Its sidestep is a Slipwire implant (owner ruling OC-6), + * which burns out with it like any NPC's chrome. + * - The nightmare: tg's nightmare species and organs (it heals and slips shots in the dark, burns in the + * light, a flash sears it, its light eater breaks lights and puts out torches). It spends its first + * half minute breaking the lights, then hunts prisoners, sinking into the dark and coming out beside one + * after a warning ripple. + * + * The body stays a body: wounds, blood, crit, cuffs, stamina, sedatives, death and revival are tg's. Its + * toughness is physiology (npc_damage_taken), never health, and never scaled by who is about. Its hits on + * people go through armour and wound like anyone's (EX-7). Kessler's team collects it only once it is down + * (outpost_experiment_down_state()), and pays by the state it finds it in. + * + * The form is a component on the prisoner's own body (human NPC phase E1): the serum turns the inmate, who + * leaves the prison's roster (transform_subject(), outpost_prisoner/proc/stand_down_for_experiment()) but + * keeps their name, face, wounds and blood. + */ + +/// Trait source for what the form puts on a body +#define OUTPOST_EXPERIMENT_FORM_TRAIT "outpost_experiment_form" +/// Blackboard key of the food a fly person is going for +#define BB_OUTPOST_FLY_MEAL "BB_outpost_fly_meal" + +// ===== TURNING ===== + +/// The form component for a serum form, or null +/proc/outpost_experiment_form_type(form) + switch(form) + if("hulk") + return /datum/component/outpost_experiment_form/hulk + if("fly") + return /datum/component/outpost_experiment_form/fly + if("nightmare") + return /datum/component/outpost_experiment_form/nightmare + return null + +/// What a creature is: a serum form ("hulk", "fly", "nightmare"), the changeling's "horror" or "headslug", or null +/proc/outpost_experiment_form_name(mob/living/creature) + if(!isliving(creature)) + return null + var/datum/component/outpost_experiment_form/form = creature.GetComponent(/datum/component/outpost_experiment_form) + if(form) + return form.form + if(istype(creature, /mob/living/basic/outpost_experiment/horror)) + return "horror" + if(istype(creature, /mob/living/basic/headslug)) + return "headslug" + return null + +/// Whether `creature` is an experiment's creature: a body the serum took, or the changeling's horror +/proc/is_outpost_experiment_creature(mob/living/creature) + if(!isliving(creature)) + return FALSE + return istype(creature, /mob/living/basic/outpost_experiment) || !!creature.GetComponent(/datum/component/outpost_experiment_form) + +/** + * Turns `body` into serum `form` for `prison` where it stands. Returns the form, or null if it didn't take. + * `personality` is the prisoner's, for its lines. + */ +/proc/outpost_experiment_turn(mob/living/carbon/human/body, form, datum/outpost_prison/prison, personality) + var/form_type = outpost_experiment_form_type(form) + if(!form_type || !ishuman(body) || QDELETED(body) || body.stat == DEAD) + return null + // One form to a body. + if(body.GetComponent(/datum/component/outpost_experiment_form)) + return null + var/datum/component/outpost_experiment_form/turned = body.AddComponent(form_type, prison, personality) + if(!istype(turned)) + return null + turned.change_body() + return turned + +// ===== THE FORM ===== + +/** + * A serum form on a body: its biology, its mind (an AI) and its side, what it says and does now and then, + * and how it chooses whom to go for. See the file header. + */ +/datum/component/outpost_experiment_form + dupe_mode = COMPONENT_DUPE_UNIQUE + /// "hulk", "fly" or "nightmare" + var/form + /// What the log calls it: "a hulk" + var/form_name = "a creature" + /// Brute and burn damage it takes as a multiple of a person's (physiology, npc_damage_taken) + var/damage_taken = 1 + /// The AI it thinks with + var/controller_type = /datum/ai_controller/basic_controller/human_npc/outpost_experiment + /// Dialogue context it says now and then, and seconds to the next line + var/line_context + var/line_left = 10 + /// A tell on examine: something anyone watching it would notice + var/win_hint + /// What everyone sees when it goes down alive, after its name + var/down_message = "collapses, spent." + /// Emotes it gives now and then lying there alive, waiting for Kessler + var/list/down_emotes = list("twitches.", "groans.", "stirs weakly.") + /// The prison it came from + var/datum/outpost_prison/prison + /// The prisoner's personality, for its lines + var/personality + /// The body has changed (change_body()) + var/changed = FALSE + /// The target it is chasing now, the closest it has got to it, where it last stood, and when it last got + /// anywhere: to notice it is stuck (track_reach()) + var/datum/weakref/chase_target_ref + var/chase_best_distance = 0 + var/turf/chase_last_turf + var/chase_progress_time = 0 + /// Targets it has given up on reaching -> world.time it may try them again + var/list/unreachable_until + +/datum/component/outpost_experiment_form/Initialize(datum/outpost_prison/owner, personality) + if(!ishuman(parent)) + return COMPONENT_INCOMPATIBLE + prison = owner + src.personality = personality + +/datum/component/outpost_experiment_form/RegisterWithParent() + var/mob/living/carbon/human/body = parent + body.add_traits(list(TRAIT_OUTPOST_EXPERIMENT, TRAIT_NO_CONTAINMENT, TRAIT_NO_STORAGE_INSERT), OUTPOST_EXPERIMENT_FORM_TRAIT) + RegisterSignal(body, COMSIG_MOVABLE_TELEPORTING, PROC_REF(refuse_teleport)) + RegisterSignal(body, COMSIG_LIVING_PRE_WABBAJACKED, PROC_REF(refuse_polymorph)) + RegisterSignal(body, COMSIG_PRE_MOB_CHANGED_TYPE, PROC_REF(refuse_type_change)) + RegisterSignal(body, COMSIG_LIVING_LIFE, PROC_REF(on_life)) + RegisterSignal(body, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine)) + +/datum/component/outpost_experiment_form/UnregisterFromParent() + var/mob/living/carbon/human/body = parent + body.remove_traits(list(TRAIT_OUTPOST_EXPERIMENT, TRAIT_NO_CONTAINMENT, TRAIT_NO_STORAGE_INSERT), OUTPOST_EXPERIMENT_FORM_TRAIT) + UnregisterSignal(body, list(COMSIG_MOVABLE_TELEPORTING, COMSIG_LIVING_PRE_WABBAJACKED, COMSIG_PRE_MOB_CHANGED_TYPE, COMSIG_LIVING_LIFE, COMSIG_ATOM_EXAMINE)) + +/datum/component/outpost_experiment_form/Destroy(force) + prison = null + chase_target_ref = null + chase_last_turf = null + unreachable_until = null + return ..() + +/** + * The change: the tells come off, the body takes the form's biology (change_biology()), its side, its + * toughness and its AI, and everyone in sight sees it happen. Once. + */ +/datum/component/outpost_experiment_form/proc/change_body() + if(changed) + return + changed = TRUE + var/mob/living/carbon/human/body = parent + outpost_experiment_clear_tells(body) + var/old_name = body.real_name + change_biology(body) + // A species can rename the body (nightmares do); it is still the prisoner. + if(body.real_name != old_name) + body.fully_replace_character_name(body.real_name, old_name) + body.faction = list(FACTION_OUTPOST_EXPERIMENT) + if(ishumannpc(body)) + var/mob/living/carbon/human/npc/npc = body + npc.set_npc_toughness(damage_taken) + QDEL_NULL(body.ai_controller) + var/datum/ai_controller/brain = new controller_type(body) + setup_controller(brain) + announce_change(body) + +/// What the form does to the body's biology. Each form's own. +/datum/component/outpost_experiment_form/proc/change_biology(mob/living/carbon/human/body) + return + +/// Readies a new AI for the form: its abilities' blackboard keys +/datum/component/outpost_experiment_form/proc/setup_controller(datum/ai_controller/brain) + return + +/// What everyone in sight sees as the serum takes +/datum/component/outpost_experiment_form/proc/announce_change(mob/living/carbon/human/body) + return + +/datum/component/outpost_experiment_form/proc/refuse_teleport(datum/source, atom/destination, channel) + SIGNAL_HANDLER + var/mob/living/body = parent + if(isturf(body.loc)) + body.visible_message(span_notice("[body] flickers for a moment, but stays where [body.p_they()] [body.p_are()].")) + return TRUE + +/datum/component/outpost_experiment_form/proc/refuse_polymorph(datum/source, what_to_randomize) + SIGNAL_HANDLER + var/mob/living/body = parent + body.visible_message(span_notice("[body] shimmers for a moment, then looks the same as before.")) + return STOP_WABBAJACK + +/datum/component/outpost_experiment_form/proc/refuse_type_change(datum/source) + SIGNAL_HANDLER + return COMPONENT_BLOCK_MOB_CHANGE + +/datum/component/outpost_experiment_form/proc/on_examine(datum/source, mob/user, list/examine_list) + SIGNAL_HANDLER + var/mob/living/body = parent + if(HAS_TRAIT_FROM(body, TRAIT_IMMOBILIZED, OUTPOST_KESSLER_TRAIT)) + examine_list += span_notice("Kessler Biolabs is taking [body.p_them()] away.") + else if(prison?.experiment_awaiting_pickup(body)) + examine_list += span_notice("[body.p_They()] [body.p_are()] down. Kessler Biolabs will collect [body.p_them()] shortly.") + else if(win_hint && body.stat == CONSCIOUS) + examine_list += span_notice(win_hint) + +/// Whether its AI runs: only while someone is on the level, like everything else in the wing +/datum/component/outpost_experiment_form/proc/awake() + var/mob/living/body = parent + return body.ai_controller?.ai_status == AI_STATUS_ON + +/// Each Life() tick while someone is about: its own doings and a line now and then while it is up, a twitch while it lies waiting for Kessler +/datum/component/outpost_experiment_form/proc/on_life(mob/living/carbon/human/body, seconds_per_tick, times_fired) + SIGNAL_HANDLER + if(body.stat == DEAD || HAS_TRAIT_FROM(body, TRAIT_IMMOBILIZED, OUTPOST_KESSLER_TRAIT)) + return + if(prison?.experiment_awaiting_pickup(body)) + if(prob(60)) + down_twitch(body) + return + if(body.stat != CONSCIOUS || !awake()) + return + form_life(body, seconds_per_tick) + if(!line_context) + return + line_left -= seconds_per_tick + if(line_left > 0) + return + line_left = rand(15, 25) + var/line = outpost_experiment_line(line_context, personality) + if(line) + INVOKE_ASYNC(body, TYPE_PROC_REF(/atom/movable, say), line) + +/// Each Life() tick while it is up: what it does besides fighting +/datum/component/outpost_experiment_form/proc/form_life(mob/living/carbon/human/body, seconds_per_tick) + return + +/// Lying there alive, waiting for Kessler +/datum/component/outpost_experiment_form/proc/down_twitch(mob/living/carbon/human/body) + body.Shake(1, 0, 0.4 SECONDS) + if(prob(30)) + INVOKE_ASYNC(body, TYPE_PROC_REF(/atom, manual_emote), pick(down_emotes)) + +/// Makes the hand it fights with the active one, before a blow at `target` +/datum/component/outpost_experiment_form/proc/ready_to_hit(atom/target) + return human_npc_ready_empty_hand(parent) + +// ----- whom it goes for ----- + +/// Whether it goes after `target`. By default only its victims (is_victim()); the fly adds food, the nightmare lights. +/datum/component/outpost_experiment_form/proc/can_target(atom/target) + return is_victim(target) + +/// People, borgs and prisoners, never its own kind or Kessler's staff +/datum/component/outpost_experiment_form/proc/is_victim(atom/target) + var/mob/living/victim = target + if(!istype(victim) || victim == parent || victim.stat == DEAD) + return FALSE + if(is_outpost_experiment_mob(victim) || HAS_TRAIT(victim, TRAIT_GODMODE)) + return FALSE + if(is_outpost_prisoner(victim)) + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = victim + if(prisoner.phase != PRISONER_PRESENT || !may_hit_prisoner(prisoner)) + return FALSE + return !blocked_by_cell(prisoner) + return ishuman(victim) || issilicon(victim) || !isnull(victim.mind) + +/// Whether it hits this prisoner +/datum/component/outpost_experiment_form/proc/may_hit_prisoner(mob/living/prisoner) + return TRUE + +/// How much less it wants a target than its distance says; prisoners and people may count differently +/datum/component/outpost_experiment_form/proc/target_penalty(mob/living/target) + return 0 + +/** + * Its target now: whoever hurt it lately, else the nearest it wants in sight. While nobody from the + * wing is home it fights back but hunts nobody, so a loose creature is never a trap left for visitors. + */ +/datum/component/outpost_experiment_form/proc/choose_target() + var/mob/living/body = parent + var/datum/component/experiment_damage_ledger/ledger = body.GetComponent(/datum/component/experiment_damage_ledger) + var/mob/living/attacker = ledger?.recent_player() + if(attacker && can_target(attacker) && get_dist(body, attacker) <= 9 && can_see(body, attacker, 9) && !target_unreachable(attacker)) + return attacker + if(prison && !prison.crew_home()) + return null + var/mob/living/best + var/best_score = INFINITY + for(var/mob/living/candidate in range(7, body)) + if(!can_target(candidate) || !can_see(body, candidate, 7) || target_unreachable(candidate)) + continue + var/score = get_dist(body, candidate) + target_penalty(candidate) + if(score < best_score) + best = candidate + best_score = score + return best + +/** + * Its AI's first thought each plan: picks the target and may queue something of its own. Returns + * SUBTREE_RETURN_FINISH_PLANNING when that is all it does this plan. + */ +/datum/component/outpost_experiment_form/proc/ai_think(datum/ai_controller/controller) + var/atom/target = choose_target() + if(target) + controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, target) + else + controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + return null + +// ----- reach ----- + +/// Whether nothing shut stops it: the hulk goes through walls and doors, so a bolted cell never keeps it out +/datum/component/outpost_experiment_form/proc/smashes_through() + return FALSE + +/// Whether it is between moves by design (mid-jaunt), and should not be judged on progress +/datum/component/outpost_experiment_form/proc/chasing_paused() + return FALSE + +/// Whether a bolted cell keeps `prisoner` away from it: shut and locked, and it is not inside with them +/datum/component/outpost_experiment_form/proc/blocked_by_cell(mob/living/prisoner) + if(smashes_through()) + return FALSE + var/datum/outpost_prison_cell/holding = prison?.cell_at(get_turf(prisoner)) + return holding && holding.is_bolted() && !holding.contains(parent) + +/** + * Notes whether it is getting anywhere with `controller`'s current target: closer, beside it, or at least + * on the move. OUTPOST_EXPERIMENT_STUCK_TIME standing still and apart writes the target off as unreachable + * for OUTPOST_EXPERIMENT_UNREACHABLE_TIME. Distance and Adjacent() only: no pathfinding call. + */ +/datum/component/outpost_experiment_form/proc/track_reach(datum/ai_controller/controller) + if(smashes_through() || chasing_paused()) + return + var/mob/living/body = parent + var/atom/movable/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(QDELETED(target)) + chase_target_ref = null + return + if(chase_target_ref?.resolve() != target) + chase_target_ref = WEAKREF(target) + chase_best_distance = get_dist(body, target) + chase_last_turf = body.loc + chase_progress_time = world.time + return + if(body.Adjacent(target) || body.loc != chase_last_turf) + chase_last_turf = body.loc + chase_progress_time = world.time + return + var/distance = get_dist(body, target) + if(distance < chase_best_distance) + chase_best_distance = distance + chase_progress_time = world.time + return + if(world.time - chase_progress_time < OUTPOST_EXPERIMENT_STUCK_TIME) + return + mark_unreachable(target) + chase_target_ref = null + +/// Whether it gave up on reaching `target` recently +/datum/component/outpost_experiment_form/proc/target_unreachable(atom/target) + if(!length(unreachable_until)) + return FALSE + var/datum/weakref/ref = WEAKREF(target) + var/until = unreachable_until[ref] + if(!until) + return FALSE + if(until > world.time) + return TRUE + unreachable_until -= ref + return FALSE + +/// Writes `target` off for OUTPOST_EXPERIMENT_UNREACHABLE_TIME +/datum/component/outpost_experiment_form/proc/mark_unreachable(atom/target) + LAZYSET(unreachable_until, WEAKREF(target), world.time + OUTPOST_EXPERIMENT_UNREACHABLE_TIME) + for(var/datum/weakref/ref as anything in unreachable_until.Copy()) + if(unreachable_until[ref] <= world.time) + unreachable_until -= ref + while(length(unreachable_until) > OUTPOST_EXPERIMENT_UNREACHABLE_MAX) + unreachable_until.Cut(1, 2) + +// ----- breaking things ----- + +/// Whether it may break `thing` out of its way. Only the hulk does. +/datum/component/outpost_experiment_form/proc/can_break(atom/thing) + return FALSE + +/// Breaks `thing` out of its way. Returns TRUE if it set about it. +/datum/component/outpost_experiment_form/proc/break_obstacle(atom/thing, datum/ai_controller/controller) + return FALSE + +// ===== HULK ===== + +/datum/component/outpost_experiment_form/hulk + form = "hulk" + form_name = "a hulk" + damage_taken = OUTPOST_HULK_DAMAGE_TAKEN + line_context = "hulk" + /// Its charge + var/datum/action/cooldown/mob_cooldown/charge/basic_charge/outpost_hulk/charge + +/datum/component/outpost_experiment_form/hulk/Destroy(force) + QDEL_NULL(charge) + return ..() + +/datum/component/outpost_experiment_form/hulk/UnregisterFromParent() + UnregisterSignal(parent, list(COMSIG_LIVING_EARLY_UNARMED_ATTACK, SIGNAL_REMOVETRAIT(TRAIT_HULK))) + return ..() + +/datum/component/outpost_experiment_form/hulk/change_biology(mob/living/carbon/human/body) + // tg's hulk gene takes only on a human body: the serum makes one of whatever it finds. + if(body.dna.species.id != SPECIES_HUMAN) + body.set_species(/datum/species/human) + // Before the gene: handlers of one signal run in the order they were registered, and on_punch() must + // see the target's health before the gene's own handler lands the blow. + RegisterSignal(body, COMSIG_LIVING_EARLY_UNARMED_ATTACK, PROC_REF(on_punch)) + body.dna.add_mutation(/datum/mutation/hulk, MUTATION_SOURCE_MUTATOR) + body.dna.add_mutation(/datum/mutation/gigantism, MUTATION_SOURCE_MUTATOR) + charge = new(body) + charge.Grant(body) + RegisterSignal(body, SIGNAL_REMOVETRAIT(TRAIT_HULK), PROC_REF(on_hulk_lost)) + +/datum/component/outpost_experiment_form/hulk/setup_controller(datum/ai_controller/brain) + brain.set_blackboard_key(BB_TARGETED_ACTION, charge) + +/datum/component/outpost_experiment_form/hulk/announce_change(mob/living/carbon/human/body) + playsound(body, 'sound/mobs/non-humanoids/gorilla/gorilla.ogg', 80, TRUE) + body.visible_message(span_danger("[body] swells until [body.p_their()] jumpsuit strains at the seams, and roars!")) + +/// Players first, then prisoners still on their feet +/datum/component/outpost_experiment_form/hulk/target_penalty(mob/living/target) + return is_outpost_prisoner(target) ? 3 : 0 + +/// Only prisoners still standing: it knocks them flat and leaves them +/datum/component/outpost_experiment_form/hulk/may_hit_prisoner(mob/living/prisoner) + return prisoner.stat == CONSCIOUS && prisoner.body_position == STANDING_UP + +/// While it is a hulk it goes through walls and forces doors, so a bolted cell never stops it +/datum/component/outpost_experiment_form/hulk/smashes_through() + return HAS_TRAIT(parent, TRAIT_HULK) + +/datum/component/outpost_experiment_form/hulk/ai_think(datum/ai_controller/controller) + . = ..() + var/mob/living/body = parent + var/mob/living/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(!HAS_TRAIT(body, TRAIT_HULK) || !isliving(target) || !charge?.IsAvailable()) + return + var/distance = get_dist(body, target) + if(distance < 2 || distance > OUTPOST_HULK_CHARGE_RANGE || !can_see(body, target, OUTPOST_HULK_CHARGE_RANGE)) + return + controller.queue_behavior(/datum/ai_behavior/targeted_mob_ability, BB_TARGETED_ACTION, BB_BASIC_MOB_CURRENT_TARGET) + return SUBTREE_RETURN_FINISH_PLANNING + +/// A hulk punch is tg's (the gene answers this signal too); what it did to the target shows a tick later +/datum/component/outpost_experiment_form/hulk/proc/on_punch(mob/living/carbon/human/source, atom/target, proximity, list/modifiers) + SIGNAL_HANDLER + if(!source.combat_mode || !proximity || !isliving(target) || target == source || !HAS_TRAIT(source, TRAIT_HULK)) + return NONE + var/mob/living/victim = target + addtimer(CALLBACK(src, PROC_REF(after_punch), WEAKREF(victim), victim.health), 0, TIMER_DELETE_ME) + return NONE + +/// A blow that landed: a standing prisoner goes down, and anyone else may go flying +/datum/component/outpost_experiment_form/hulk/proc/after_punch(datum/weakref/victim_ref, health_before) + var/mob/living/carbon/human/body = parent + var/mob/living/victim = victim_ref?.resolve() + if(QDELETED(victim) || QDELETED(body) || victim.stat == DEAD || victim.health >= health_before) + return + if(is_outpost_prisoner(victim)) + if(victim.body_position != STANDING_UP) + return + victim.visible_message(span_danger("[body] knocks [victim] flat!")) + playsound(victim, 'sound/items/weapons/punch1.ogg', 60, TRUE) + victim.Knockdown(OUTPOST_HULK_KNOCKDOWN) + return + if(!prob(OUTPOST_HULK_THROW_CHANCE) || victim.anchored || victim.buckled || victim.move_resist >= MOVE_FORCE_OVERPOWERING) + return + victim.visible_message(span_danger("[body] sends [victim] flying!")) + victim.throw_at(get_ranged_target_turf(victim, get_dir(body, victim), OUTPOST_HULK_THROW_RANGE), OUTPOST_HULK_THROW_RANGE, 1, body) + +/// Down into crit, the gene let go of it (tg's hulk): it is an ordinary person again +/datum/component/outpost_experiment_form/hulk/proc/on_hulk_lost(mob/living/carbon/human/source) + SIGNAL_HANDLER + if(source.stat == DEAD) + return + source.visible_message(span_warning("[source] staggers, heaving for breath. [source.p_They()] look[source.p_s()] spent.")) + +/// Charged into a wall with nobody caught: stunned a moment, the way any charger is +/datum/component/outpost_experiment_form/hulk/proc/stagger_on_wall() + var/mob/living/body = parent + body.Stun(OUTPOST_HULK_WALL_STUN, ignore_canstun = TRUE) + +/// Interior walls, windows, grilles, tables, chairs and doors, never the hatch counters or anything protected +/datum/component/outpost_experiment_form/hulk/can_break(atom/thing) + if(!HAS_TRAIT(parent, TRAIT_HULK) || QDELETED(thing) || !outpost_experiment_can_smash(thing, prison)) + return FALSE + if(isturf(thing)) + return iswallturf(thing) && !istype(thing, /turf/closed/wall/r_wall) && !isindestructiblewall(thing) + var/obj/object = thing + if(!istype(object) || (object.resistance_flags & INDESTRUCTIBLE) || HAS_TRAIT(object, TRAIT_OUTPOST_PROPERTY)) + return FALSE + if(istype(object, /obj/structure/table/reinforced/prison_hatch)) + return FALSE + return istype(object, /obj/structure/window) || istype(object, /obj/structure/grille) || istype(object, /obj/structure/table) \ + || istype(object, /obj/structure/chair) || istype(object, /obj/machinery/door) + +/datum/component/outpost_experiment_form/hulk/break_obstacle(atom/thing, datum/ai_controller/controller) + if(!can_break(thing)) + return FALSE + if(istype(thing, /obj/machinery/door/airlock)) + INVOKE_ASYNC(src, PROC_REF(force_door), thing) + return TRUE + if(isturf(thing)) + // tg's hulk smash: a few blows bring an interior wall down, and hurt the arm doing it. + if(!human_npc_ready_empty_hand(parent)) + return FALSE + controller.ai_interact(target = thing, combat_mode = TRUE) + return TRUE + smash(thing) + return TRUE + +/// Batters a door until it gives: bolts sheared, weld broken, forced open +/datum/component/outpost_experiment_form/hulk/proc/force_door(obj/machinery/door/airlock/door) + var/mob/living/body = parent + if(DOING_INTERACTION_WITH_TARGET(body, door) || !door.density) + return FALSE + body.visible_message(span_danger("[body] batters at [door]!")) + playsound(door, 'sound/effects/bang.ogg', 70, TRUE) + door.Shake(2, 2, 0.5 SECONDS) + if(!do_after(body, OUTPOST_HULK_DOOR_TIME, target = door) || QDELETED(door) || !can_break(door)) + return FALSE + if(door.locked) + door.unbolt() + if(door.welded) + door.welded = FALSE + door.update_appearance() + door.visible_message(span_danger("[body] forces [door] open!")) + playsound(door, 'sound/machines/airlock/airlock_alien_prying.ogg', 80, TRUE) + INVOKE_ASYNC(door, TYPE_PROC_REF(/obj/machinery/door, open), BYPASS_DOOR_CHECKS) + prison?.refresh_reach() + return TRUE + +/// Puts something through: windows shatter, tables fold, chairs splinter, window doors break +/datum/component/outpost_experiment_form/hulk/proc/smash(obj/thing) + if(QDELETED(thing)) + return FALSE + var/mob/living/body = parent + body.do_attack_animation(thing, ATTACK_EFFECT_SMASH) + body.visible_message(span_danger("[body] smashes [thing]!")) + playsound(thing, istype(thing, /obj/structure/window) ? 'sound/effects/glass/glassbr1.ogg' : 'sound/effects/woodhit.ogg', 70, TRUE) + thing.take_damage(thing.get_integrity(), BRUTE, MELEE, FALSE, get_dir(thing, body)) + return TRUE + +/// The hulk's charge: a roar, a stamp and a line on the floor, then six tiles of it +/datum/action/cooldown/mob_cooldown/charge/basic_charge/outpost_hulk + name = "Charge" + desc = "Put your head down and run through whatever is in the way." + cooldown_time = OUTPOST_HULK_CHARGE_COOLDOWN + charge_delay = OUTPOST_HULK_CHARGE_WINDUP + charge_distance = OUTPOST_HULK_CHARGE_RANGE + charge_past = 1 + charge_damage = OUTPOST_HULK_CHARGE_DAMAGE + destroy_objects = FALSE + shake_duration = OUTPOST_HULK_CHARGE_WINDUP + recoil_duration = OUTPOST_HULK_WALL_STUN + knockdown_duration = OUTPOST_HULK_CHARGE_KNOCKDOWN + +/datum/action/cooldown/mob_cooldown/charge/basic_charge/outpost_hulk/do_charge_indicator(atom/charger, atom/charge_target) + . = ..() + playsound(charger, 'sound/mobs/non-humanoids/gorilla/gorilla.ogg', 80, TRUE) + charger.visible_message(span_danger("[charger] roars and stamps, lowering [charger.p_their()] head!")) + var/direction = get_dir(charger, charge_target) + var/turf/step_turf = get_turf(charger) + for(var/i in 1 to charge_distance) + step_turf = get_step(step_turf, direction) + if(!step_turf || isclosedturf(step_turf)) + break + new /obj/effect/temp_visual/telegraphing/outpost_hulk_charge(step_turf) + +/// The hulk's form, if `charger` is a hulk +/datum/action/cooldown/mob_cooldown/charge/basic_charge/outpost_hulk/proc/hulk_form(atom/movable/charger) + return charger.GetComponent(/datum/component/outpost_experiment_form/hulk) + +/datum/action/cooldown/mob_cooldown/charge/basic_charge/outpost_hulk/on_bump(atom/movable/source, atom/target) + var/datum/component/outpost_experiment_form/hulk/hulk = hulk_form(source) + if(hulk && isobj(target) && target.density && !istype(target, /obj/machinery/door/airlock) && hulk.can_break(target)) + INVOKE_ASYNC(hulk, TYPE_PROC_REF(/datum/component/outpost_experiment_form/hulk, smash), target) + return + return ..() + +/datum/action/cooldown/mob_cooldown/charge/basic_charge/outpost_hulk/on_moved(atom/source) + . = ..() + var/datum/component/outpost_experiment_form/hulk/hulk = hulk_form(source) + if(!hulk) + return + for(var/obj/structure/chair/chair in get_turf(source)) + if(hulk.can_break(chair)) + INVOKE_ASYNC(hulk, TYPE_PROC_REF(/datum/component/outpost_experiment_form/hulk, smash), chair) + +/datum/action/cooldown/mob_cooldown/charge/basic_charge/outpost_hulk/hit_target(atom/movable/source, atom/target, damage_dealt) + var/datum/component/outpost_experiment_form/hulk/hulk = hulk_form(source) + if(isliving(target)) + var/mob/living/victim = target + // A prisoner is bowled over; anyone else takes the full charge, through their armour (EX-7). + if(!is_outpost_prisoner(victim)) + outpost_experiment_ability_hit(victim, damage_dealt, attacker = source) + playsound(get_turf(victim), 'sound/effects/meteorimpact.ogg', 80, TRUE) + return ..() + source.visible_message(span_danger("[source] slams into [target] and reels!")) + playsound(get_turf(source), 'sound/effects/bang.ogg', 80, TRUE) + hulk?.stagger_on_wall() + +/// The floor in the charge's path, for the length of the wind-up +/obj/effect/temp_visual/telegraphing/outpost_hulk_charge + duration = OUTPOST_HULK_CHARGE_WINDUP + color = "#9ae05a" + +// ===== FLY PERSON ===== + +/datum/component/outpost_experiment_form/fly + form = "fly" + form_name = "a fly person" + damage_taken = OUTPOST_FLY_DAMAGE_TAKEN + line_context = "fly" + controller_type = /datum/ai_controller/basic_controller/human_npc/outpost_experiment/fly + win_hint = "It never stays still for long." + down_message = "drops to the floor, stunned." + down_emotes = list("buzzes weakly.", "twitches.", "trembles.") + /// world.time of its next random dart, and by when the dart under way must be over + var/next_dart = 0 + var/dart_until = 0 + /// Whoever hit it last, whom it keeps away from until flit_until + var/datum/weakref/flit_from_ref + var/flit_until = 0 + /// REF() of prisoners who watched it throw up -> world.time they may be put off again + var/list/disgusted + +/datum/component/outpost_experiment_form/fly/down_twitch(mob/living/carbon/human/body) + . = ..() + playsound(body, 'sound/mobs/non-humanoids/bee/bee.ogg', 15, TRUE) + +/datum/component/outpost_experiment_form/fly/Destroy(force) + flit_from_ref = null + disgusted = null + return ..() + +/datum/component/outpost_experiment_form/fly/UnregisterFromParent() + UnregisterSignal(parent, list(COMSIG_ATOM_WAS_ATTACKED, COMSIG_CARBON_VOMITED)) + return ..() + +/datum/component/outpost_experiment_form/fly/change_biology(mob/living/carbon/human/body) + body.set_species(/datum/species/fly) + // Its quickness is real chrome (owner ruling OC-6), which an EMP scrambles and death burns out. + if(ishumannpc(body)) + var/mob/living/carbon/human/npc/npc = body + npc.npc_install_cyberware(/obj/item/organ/cyberimp/cyberware/slipwire) + RegisterSignal(body, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_attacked)) + RegisterSignal(body, COMSIG_CARBON_VOMITED, PROC_REF(on_vomited)) + +/datum/component/outpost_experiment_form/fly/announce_change(mob/living/carbon/human/body) + playsound(body, 'sound/mobs/non-humanoids/bee/bee_swarm.ogg', 60, TRUE) + body.visible_message(span_danger("[body] folds up, splits open and unfolds into something with bulging eyes and a proboscis!")) + +/// On its feet and free to move: not down, held, cuffed, pulled, buckled or being taken away +/datum/component/outpost_experiment_form/fly/proc/free_to_dart() + var/mob/living/body = parent + if(body.stat != CONSCIOUS || !isturf(body.loc) || body.pulledby || body.buckled || body.body_position != STANDING_UP) + return FALSE + return !HAS_TRAIT(body, TRAIT_IMMOBILIZED) && !HAS_TRAIT(body, TRAIT_INCAPACITATED) && !HAS_TRAIT(body, TRAIT_RESTRAINED) + +/// Hit while it is free to move: it flits away from whoever did it, and keeps away from them for a few seconds +/datum/component/outpost_experiment_form/fly/proc/on_attacked(datum/source, atom/attacker, attack_flags) + SIGNAL_HANDLER + if(!attacker || attacker == parent || !free_to_dart()) + return + flit_from_ref = WEAKREF(attacker) + flit_until = world.time + OUTPOST_FLY_FLIT_TIME + // Once the blow is over, not in the middle of it. + addtimer(CALLBACK(src, PROC_REF(flit)), 1, TIMER_UNIQUE | TIMER_OVERRIDE | TIMER_DELETE_ME) + +/// Whoever hit it within OUTPOST_FLY_FLIT_TIME, if still near enough to keep away from +/datum/component/outpost_experiment_form/fly/proc/flit_threat() + if(world.time > flit_until) + return null + var/mob/living/body = parent + var/atom/movable/attacker = flit_from_ref?.resolve() + if(QDELETED(attacker) || attacker.z != body.z || get_dist(body, attacker) > OUTPOST_FLY_DART_MAX + OUTPOST_FLY_FLEE_RANGE) + return null + return attacker + +/// Darts away from whoever just hit it, at once rather than at its next thought. Returns TRUE if it went. +/datum/component/outpost_experiment_form/fly/proc/flit() + var/mob/living/body = parent + var/atom/attacker = flit_threat() + if(!attacker || !free_to_dart() || !body.ai_controller || !awake()) + return FALSE + var/turf/spot = dart_spot(attacker) + if(!spot) + return FALSE + body.ai_controller.CancelActions() + body.ai_controller.queue_behavior(/datum/ai_behavior/outpost_fly_dart/away, spot) + return TRUE + +/// It goes for food and hits only when cornered: its "targets" are meals, and people it cannot get away from +/datum/component/outpost_experiment_form/fly/can_target(atom/target) + if(istype(target, /obj/item/food)) + return isturf(target.loc) + return ..() + +/// Whoever is closest within OUTPOST_FLY_FLEE_RANGE, to keep away from +/datum/component/outpost_experiment_form/fly/proc/nearest_threat() + var/mob/living/body = parent + var/mob/living/nearest + var/nearest_distance = INFINITY + for(var/mob/living/person in range(OUTPOST_FLY_FLEE_RANGE, body)) + if(person == body || !is_victim(person)) + continue + var/distance = get_dist(body, person) + if(distance < nearest_distance) + nearest = person + nearest_distance = distance + return nearest + +/** + * Somewhere to dart to: an open tile OUTPOST_FLY_DART_MIN to OUTPOST_FLY_DART_MAX tiles off, in a clear + * line, on ground it keeps to (may_dart_to()). Away from `threat`, only somewhere farther from it than it + * is now, and out of its OUTPOST_FLY_FLEE_RANGE if it can. Null if there is nowhere: cornered. + */ +/datum/component/outpost_experiment_form/fly/proc/dart_spot(atom/threat) + var/turf/here = get_turf(parent) + if(!here) + return null + var/threat_distance = threat ? get_dist(here, threat) : 0 + var/list/spots = list() + var/list/clear_spots = list() + for(var/turf/open/tile in RANGE_TURFS(OUTPOST_FLY_DART_MAX, here)) + if(get_dist(here, tile) < OUTPOST_FLY_DART_MIN) + continue + var/from_threat = threat ? get_dist(tile, threat) : INFINITY + if(from_threat <= threat_distance || !may_dart_to(tile) || !clear_line(here, tile)) + continue + spots += tile + if(from_threat > OUTPOST_FLY_FLEE_RANGE) + clear_spots += tile + if(length(clear_spots)) + return pick(clear_spots) + return length(spots) ? pick(spots) : null + +/** + * Whether it keeps to `tile`: free and safe, and in the wing (its cell block, while it is in there). + * Got out of the wing, it darts about the room it is in. + */ +/datum/component/outpost_experiment_form/fly/proc/may_dart_to(turf/tile) + var/mob/living/body = parent + if(isspaceturf(tile) || isopenspaceturf(tile) || tile.is_blocked_turf(FALSE, body) || !tile.can_cross_safely(body)) + return FALSE + var/turf/here = get_turf(body) + if(prison?.wing && here.loc == prison.wing) + return tile.loc == prison.wing && (!prison.in_cell_block(here) || prison.in_cell_block(tile)) + return tile.loc == here.loc + +/// Whether it can go straight from `start` to `finish`: nothing solid or opaque in the way +/datum/component/outpost_experiment_form/fly/proc/clear_line(turf/start, turf/finish) + for(var/turf/step as anything in get_line(start, finish)) + if(step == start) + continue + if(step.opacity || step.is_blocked_turf(TRUE, parent)) + return FALSE + return TRUE + +/** + * Keeps moving: darts away from anyone close or who just hit it, and hits only when cornered with + * someone at it. Otherwise it goes for food in sight, or darts about at random with short pauses. It + * hovers (outpost_fly_hover) rather than planning nothing, so it notices people at once. + */ +/datum/component/outpost_experiment_form/fly/ai_think(datum/ai_controller/controller) + var/mob/living/body = parent + if(!free_to_dart()) + controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + return null + var/atom/threat = flit_threat() || nearest_threat() + if(threat) + var/turf/away = dart_spot(threat) + if(away) + controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + controller.queue_behavior(/datum/ai_behavior/outpost_fly_dart/away, away) + return SUBTREE_RETURN_FINISH_PLANNING + // Nowhere farther to go: it hits whoever is at it. + var/mob/living/at_it = threat + if(istype(at_it) && body.Adjacent(at_it) && can_target(at_it)) + controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, at_it) + return null + controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + controller.queue_behavior(/datum/ai_behavior/outpost_fly_hover) + return SUBTREE_RETURN_FINISH_PLANNING + controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + var/obj/item/food/meal = held_meal() || find_meal() + if(meal) + controller.set_blackboard_key(BB_OUTPOST_FLY_MEAL, meal) + controller.queue_behavior(/datum/ai_behavior/outpost_fly_eat, BB_OUTPOST_FLY_MEAL) + return SUBTREE_RETURN_FINISH_PLANNING + var/turf/spot = world.time >= next_dart ? dart_spot() : null + if(spot) + controller.queue_behavior(/datum/ai_behavior/outpost_fly_dart, spot) + return SUBTREE_RETURN_FINISH_PLANNING + if(world.time >= next_dart) + next_dart = world.time + rand(OUTPOST_FLY_DART_GAP_MIN, OUTPOST_FLY_DART_GAP_MAX) + controller.queue_behavior(/datum/ai_behavior/outpost_fly_hover) + return SUBTREE_RETURN_FINISH_PLANNING + +/// Food it has in hand already +/datum/component/outpost_experiment_form/fly/proc/held_meal() + var/mob/living/carbon/human/body = parent + for(var/obj/item/food/meal in body.held_items) + return meal + return null + +/// The nearest food in sight: a serving hatch, a table or the floor +/datum/component/outpost_experiment_form/fly/proc/find_meal() + var/mob/living/body = parent + var/obj/item/food/best + var/best_distance = INFINITY + for(var/obj/item/food/meal in range(5, body)) + if(!isturf(meal.loc) || !can_see(body, meal, 5) || target_unreachable(meal)) + continue + var/distance = get_dist(body, meal) + if(distance < best_distance) + best = meal + best_distance = distance + return best + +/** + * tg's fly stomach throws up what it eats (and the fly is a messy eater). Whoever it gets it on hears + * about it, and prisoners who see it lose a little mood, each at most once in a while. + */ +/datum/component/outpost_experiment_form/fly/proc/on_vomited(mob/living/carbon/source, distance, force) + SIGNAL_HANDLER + var/turf/ahead = get_step(source, source.dir) + var/mob/living/unlucky = ahead ? locate(/mob/living) in ahead : null + if(unlucky && unlucky != source) + source.visible_message(span_danger("[source] throws up all over [unlucky]!")) + for(var/mob/living/carbon/human/npc/outpost_prisoner/watcher in viewers(5, source)) + if(watcher.stat != CONSCIOUS || LAZYACCESS(disgusted, REF(watcher)) > world.time) + continue + LAZYSET(disgusted, REF(watcher), world.time + OUTPOST_EXPERIMENT_FLY_DISGUST_GAP) + watcher.adjust_mood(-OUTPOST_EXPERIMENT_FLY_DISGUST_MOOD) + +// ===== NIGHTMARE ===== + +/datum/component/outpost_experiment_form/nightmare + form = "nightmare" + form_name = "a nightmare" + damage_taken = OUTPOST_NIGHTMARE_DAMAGE_TAKEN + /// Seconds left of breaking the lights before it hunts + var/opening_left = OUTPOST_NIGHTMARE_OPENING_MIN + /// Mid jaunt: gone into the dark, about to come out beside someone + var/jaunting = FALSE + /// Where it will come out, and at whom + var/turf/jaunt_spot + var/datum/weakref/jaunt_target_ref + COOLDOWN_DECLARE(jaunt_cooldown) + +/datum/component/outpost_experiment_form/nightmare/Destroy(force) + jaunt_spot = null + jaunt_target_ref = null + return ..() + +/datum/component/outpost_experiment_form/nightmare/UnregisterFromParent() + if(jaunting) + end_jaunt() + UnregisterSignal(parent, COMSIG_MOB_FLASH_OVERRIDE_CHECK) + return ..() + +/datum/component/outpost_experiment_form/nightmare/change_biology(mob/living/carbon/human/body) + // tg's nightmare: its brain heals it and slips shots in the dark, its heart grows the light eater, and + // its shadow flesh burns in the light. It can wear nothing but a hat, so the jumpsuit falls off. + body.set_species(/datum/species/shadow/nightmare) + opening_left = rand(OUTPOST_NIGHTMARE_OPENING_MIN, OUTPOST_NIGHTMARE_OPENING_MAX) + RegisterSignal(body, COMSIG_MOB_FLASH_OVERRIDE_CHECK, PROC_REF(on_flashed)) + +/datum/component/outpost_experiment_form/nightmare/announce_change(mob/living/carbon/human/body) + playsound(body, 'sound/effects/hallucinations/wail.ogg', 60, TRUE) + body.visible_message(span_danger("The light seems to drain out of [body], and something else stands where [body.p_they()] stood.")) + +/// Whether `tile` (where it stands, by default) is dark +/datum/component/outpost_experiment_form/nightmare/proc/in_dark(turf/tile = get_turf(parent)) + return tile && tile.get_lumcount() < SHADOW_SPECIES_LIGHT_THRESHOLD + +/// The opening runs down; in the light a jaunt is cut short, and now and then it is seen to suffer +/datum/component/outpost_experiment_form/nightmare/form_life(mob/living/carbon/human/body, seconds_per_tick) + if(opening_left > 0) + opening_left -= seconds_per_tick + if(in_dark()) + return + if(jaunting) + cancel_jaunt() + if(prob(20)) + body.visible_message(span_warning("[body] smokes and shrinks from the light.")) + +/// Whether it is still breaking the lights: for its first half minute, until it is hurt, or until there are none +/datum/component/outpost_experiment_form/nightmare/proc/in_opening() + if(opening_left <= 0) + return FALSE + var/mob/living/body = parent + var/datum/component/experiment_damage_ledger/ledger = body.GetComponent(/datum/component/experiment_damage_ledger) + if(ledger && (ledger.player_damage + ledger.other_damage + ledger.pending) > 0) + opening_left = 0 + return FALSE + return TRUE + +/// Prisoners first, standing or down; it finishes what it starts +/datum/component/outpost_experiment_form/nightmare/target_penalty(mob/living/target) + return is_outpost_prisoner(target) ? -3 : 0 + +/datum/component/outpost_experiment_form/nightmare/chasing_paused() + return jaunting + +/// Lights, during the opening +/datum/component/outpost_experiment_form/nightmare/can_target(atom/target) + if(istype(target, /obj/machinery/light)) + var/obj/machinery/light/fixture = target + return fixture.status != LIGHT_BROKEN && fixture.status != LIGHT_EMPTY + return ..() + +/// It fights with tg's light eater, which breaks lights and puts out torches as it cuts +/datum/component/outpost_experiment_form/nightmare/ready_to_hit(atom/target) + var/mob/living/carbon/human/body = parent + for(var/obj/item/light_eater/blade in body.held_items) + return human_npc_ready_item(body, blade) + return ..() + +/// The nearest working light in sight +/datum/component/outpost_experiment_form/nightmare/proc/find_light() + var/mob/living/body = parent + var/obj/machinery/light/best + var/best_distance = INFINITY + for(var/obj/machinery/light/fixture in range(9, body)) + if(!can_target(fixture) || !can_see(body, fixture, 9) || target_unreachable(fixture)) + continue + var/distance = get_dist(body, fixture) + if(distance < best_distance) + best = fixture + best_distance = distance + return best + +/datum/component/outpost_experiment_form/nightmare/ai_think(datum/ai_controller/controller) + if(jaunting) + controller.clear_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET) + return SUBTREE_RETURN_FINISH_PLANNING + if(in_opening()) + var/obj/machinery/light/fixture = find_light() + if(fixture) + controller.set_blackboard_key(BB_BASIC_MOB_CURRENT_TARGET, fixture) + return null + opening_left = 0 + . = ..() + var/mob/living/target = controller.blackboard[BB_BASIC_MOB_CURRENT_TARGET] + if(!isliving(target) || get_dist(parent, target) <= 1) + return + var/turf/spot = jaunt_spot_near(target) + if(!spot) + return + start_jaunt(target, spot) + return SUBTREE_RETURN_FINISH_PLANNING + +/// A flash sears it (tg's shadow flesh) and throws it out of a jaunt +/datum/component/outpost_experiment_form/nightmare/proc/on_flashed(datum/source, mob/living/carbon/flashed, flash, deviation) + SIGNAL_HANDLER + if(jaunting) + cancel_jaunt() + return NONE + +/// A dark tile beside `target` it could come out on, if the jaunt is ready and it stands in the dark +/datum/component/outpost_experiment_form/nightmare/proc/jaunt_spot_near(mob/living/target) + if(jaunting || !COOLDOWN_FINISHED(src, jaunt_cooldown) || !in_dark()) + return null + var/list/spots = list() + for(var/turf/open/tile in orange(1, target)) + if(tile.is_blocked_turf(TRUE) || !in_dark(tile) || !prison?.outpost_holds(tile)) + continue + spots += tile + return length(spots) ? pick(spots) : null + +/// Sinks into the dark; a ripple and a whisper warn where it will come out, OUTPOST_NIGHTMARE_JAUNT_RIPPLE later +/datum/component/outpost_experiment_form/nightmare/proc/start_jaunt(mob/living/target, turf/spot) + var/mob/living/body = parent + jaunting = TRUE + jaunt_spot = spot + jaunt_target_ref = WEAKREF(target) + COOLDOWN_START(src, jaunt_cooldown, OUTPOST_NIGHTMARE_JAUNT_COOLDOWN) + ADD_TRAIT(body, TRAIT_IMMOBILIZED, OUTPOST_EXPERIMENT_FORM_TRAIT) + body.ai_controller?.CancelActions() + animate(body, alpha = 0, time = 0.3 SECONDS) + new /obj/effect/temp_visual/telegraphing/outpost_shadow_ripple(spot) + playsound(spot, pick('sound/effects/hallucinations/behind_you1.ogg', 'sound/effects/hallucinations/behind_you2.ogg', 'sound/effects/hallucinations/i_see_you2.ogg'), 35, TRUE) + addtimer(CALLBACK(src, PROC_REF(finish_jaunt)), OUTPOST_NIGHTMARE_JAUNT_RIPPLE, TIMER_DELETE_ME) + +/// Comes out beside the target, if the spot is still dark, and lunges: a blade through the armour on them (EX-7) +/datum/component/outpost_experiment_form/nightmare/proc/finish_jaunt() + if(!jaunting) + return FALSE + var/mob/living/body = parent + var/turf/spot = jaunt_spot + var/mob/living/target = jaunt_target_ref?.resolve() + end_jaunt() + if(body.stat != CONSCIOUS || !spot || !in_dark(spot) || spot.is_blocked_turf(TRUE)) + return FALSE + body.forceMove(spot) + if(!target || !body.Adjacent(target) || !can_target(target)) + return TRUE + body.face_atom(target) + body.do_attack_animation(target, ATTACK_EFFECT_SLASH) + playsound(target, 'sound/items/weapons/bladeslice.ogg', 60, TRUE) + target.visible_message(span_danger("[body] lunges out of the dark at [target]!"), span_userdanger("[body] lunges out of the dark at you!")) + outpost_experiment_ability_hit(target, OUTPOST_NIGHTMARE_JAUNT_DAMAGE, SHARP_EDGED, OUTPOST_NIGHTMARE_ARMOUR_PENETRATION, attacker = body) + target.Knockdown(OUTPOST_NIGHTMARE_JAUNT_KNOCKDOWN) + return TRUE + +/// Thrown out of a jaunt (light, a flash): back where it went in +/datum/component/outpost_experiment_form/nightmare/proc/cancel_jaunt() + if(!jaunting) + return + end_jaunt() + var/mob/living/body = parent + body.visible_message(span_warning("[body] is forced out of the shadows!")) + +/datum/component/outpost_experiment_form/nightmare/proc/end_jaunt() + var/mob/living/body = parent + jaunting = FALSE + jaunt_spot = null + jaunt_target_ref = null + REMOVE_TRAIT(body, TRAIT_IMMOBILIZED, OUTPOST_EXPERIMENT_FORM_TRAIT) + animate(body, alpha = 255, time = 0.2 SECONDS) + +/// Where the nightmare will come out of the dark +/obj/effect/temp_visual/telegraphing/outpost_shadow_ripple + icon = 'icons/mob/telegraphing/telegraph.dmi' + icon_state = "target_circle" + color = "#2a0a3a" + light_range = 0 + duration = OUTPOST_NIGHTMARE_JAUNT_RIPPLE + +// ===== AI ===== + +/** + * A creature's mind: tg's human NPC controller (soft crit, working at cuffs and grabs), then what its form + * wants (ai_think()), breaking what it may out of its way, and real blows with its hands or its blade. + */ +/datum/ai_controller/basic_controller/human_npc/outpost_experiment + blackboard = list( + BB_TARGETING_STRATEGY = /datum/targeting_strategy/outpost_experiment_form, + BB_TARGET_MINIMUM_STAT = HARD_CRIT, + ) + ai_movement = /datum/ai_movement/jps + idle_behavior = /datum/idle_behavior/idle_random_walk + planning_subtrees = list( + /datum/ai_planning_subtree/human_npc_soft_crit, + /datum/ai_planning_subtree/escape_captivity, + /datum/ai_planning_subtree/outpost_experiment_form_think, + /datum/ai_planning_subtree/attack_obstacle_in_path/outpost_experiment_form, + /datum/ai_planning_subtree/outpost_experiment_form_melee, + ) + +/// The fly person moves only in its own darts: no aimless steps +/datum/ai_controller/basic_controller/human_npc/outpost_experiment/fly + idle_behavior = null + +/// The creature's form decides what it is after +/datum/ai_planning_subtree/outpost_experiment_form_think + +/datum/ai_planning_subtree/outpost_experiment_form_think/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + var/mob/living/body = controller.pawn + var/datum/component/outpost_experiment_form/form = body.GetComponent(/datum/component/outpost_experiment_form) + if(!form || body.stat != CONSCIOUS) + return + form.track_reach(controller) + return form.ai_think(controller) + +/// Only what the form may break +/datum/ai_planning_subtree/attack_obstacle_in_path/outpost_experiment_form + attack_behaviour = /datum/ai_behavior/attack_obstructions/outpost_experiment_form + +/datum/ai_behavior/attack_obstructions/outpost_experiment_form + +/datum/ai_behavior/attack_obstructions/outpost_experiment_form/attack_in_direction(datum/ai_controller/controller, mob/living/basic/basic_mob, direction) + var/mob/living/body = controller.pawn + var/datum/component/outpost_experiment_form/form = body.GetComponent(/datum/component/outpost_experiment_form) + if(!form) + return FALSE + var/turf/next_step = get_step(body, direction) + if(!next_step?.is_blocked_turf(exclude_mobs = TRUE, source_atom = body)) + return FALSE + for(var/obj/object in next_step) + if(!object.density || object.IsObscured() || !form.can_break(object)) + continue + return form.break_obstacle(object, controller) + if(isclosedturf(next_step) && form.can_break(next_step)) + return form.break_obstacle(next_step, controller) + return FALSE + +/// With a target: walks up and hits it, with the hand or blade the form fights with +/datum/ai_planning_subtree/outpost_experiment_form_melee + +/datum/ai_planning_subtree/outpost_experiment_form_melee/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) + if(!controller.blackboard_key_exists(BB_BASIC_MOB_CURRENT_TARGET)) + return + controller.queue_behavior(/datum/ai_behavior/basic_melee_attack/outpost_experiment_form, BB_BASIC_MOB_CURRENT_TARGET, BB_TARGETING_STRATEGY, BB_BASIC_MOB_CURRENT_TARGET_HIDING_LOCATION) + return SUBTREE_RETURN_FINISH_PLANNING + +// tg's basic melee attack already clicks the target through ai_interact(); this readies the hand or blade first. +/datum/ai_behavior/basic_melee_attack/outpost_experiment_form + +/datum/ai_behavior/basic_melee_attack/outpost_experiment_form/perform(seconds_per_tick, datum/ai_controller/controller, target_key, targeting_strategy_key, hiding_location_key) + var/mob/living/carbon/body = controller.pawn + var/datum/component/outpost_experiment_form/form = body.GetComponent(/datum/component/outpost_experiment_form) + form?.ready_to_hit(controller.blackboard[target_key]) + body.zone_selected = human_npc_pick_aim_zone() + return ..() + +/// A creature's targets are whatever its form's can_target() says, in reach on its level +/datum/targeting_strategy/outpost_experiment_form + +/datum/targeting_strategy/outpost_experiment_form/can_attack(mob/living/living_mob, atom/target, vision_range) + var/datum/component/outpost_experiment_form/form = living_mob.GetComponent(/datum/component/outpost_experiment_form) + if(!form || QDELETED(target) || !isturf(living_mob.loc)) + return FALSE + var/turf/target_turf = get_turf(target) + if(!target_turf || target_turf.z != living_mob.z) + return FALSE + if(vision_range && get_dist(living_mob, target) > vision_range) + return FALSE + return form.can_target(target) + +/// The fly person's darts: straight runs that start at once +/datum/ai_movement/basic_avoidance/outpost_fly + move_flags = MOVEMENT_LOOP_START_FAST + +/** + * A fly person's dart to the turf it picked (dart_spot()): done when it gets there, given up after + * OUTPOST_FLY_DART_TIMEOUT. Planning goes on meanwhile, so a dart away from someone can cut a random one + * short. A random dart is followed by a short pause. + */ +/datum/ai_behavior/outpost_fly_dart + required_distance = 0 + action_cooldown = 0 + behavior_flags = AI_BEHAVIOR_REQUIRE_MOVEMENT | AI_BEHAVIOR_MOVE_AND_PERFORM | AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/outpost_fly_dart/setup(datum/ai_controller/controller, turf/destination) + var/mob/living/body = controller.pawn + var/datum/component/outpost_experiment_form/fly/fly = body.GetComponent(/datum/component/outpost_experiment_form/fly) + if(!fly || !isturf(destination) || destination.z != body.z) + return FALSE + fly.dart_until = world.time + OUTPOST_FLY_DART_TIMEOUT + set_movement_target(controller, destination, /datum/ai_movement/basic_avoidance/outpost_fly) + return ..() + +/datum/ai_behavior/outpost_fly_dart/perform(seconds_per_tick, datum/ai_controller/controller, turf/destination) + var/mob/living/body = controller.pawn + var/datum/component/outpost_experiment_form/fly/fly = body.GetComponent(/datum/component/outpost_experiment_form/fly) + if(!fly || world.time >= fly.dart_until) + return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED + if(get_turf(body) == destination) + return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED + return AI_BEHAVIOR_DELAY + +/datum/ai_behavior/outpost_fly_dart/finish_action(datum/ai_controller/controller, succeeded, turf/destination) + // A dart that took over from this one has set its own movement; leave that be. + var/moving_for_us = controller.movement_target_source == type + . = ..() + if(moving_for_us) + controller.change_ai_movement_type(initial(controller.ai_movement)) + var/mob/living/body = controller.pawn + var/datum/component/outpost_experiment_form/fly/fly = body?.GetComponent(/datum/component/outpost_experiment_form/fly) + if(fly) + fly.next_dart = world.time + pause_after() + +/// How long it waits after this dart before the next random one +/datum/ai_behavior/outpost_fly_dart/proc/pause_after() + return rand(OUTPOST_FLY_DART_GAP_MIN, OUTPOST_FLY_DART_GAP_MAX) + +/// Away from someone: no pause after it +/datum/ai_behavior/outpost_fly_dart/away + +/datum/ai_behavior/outpost_fly_dart/away/pause_after() + return 0 + +/// The fly person waiting between darts. Planning goes on, so it notices anyone coming at once. +/datum/ai_behavior/outpost_fly_hover + action_cooldown = 0 + behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/outpost_fly_hover/perform(seconds_per_tick, datum/ai_controller/controller) + var/mob/living/body = controller.pawn + var/datum/component/outpost_experiment_form/fly/fly = body.GetComponent(/datum/component/outpost_experiment_form/fly) + if(!fly || world.time >= fly.next_dart) + return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED + return AI_BEHAVIOR_DELAY + +/** + * The fly person eats: walks to the food, picks it up and eats it the way anyone does (tg's edible, with + * its do_after per bite); its fly stomach does the rest. Planning goes on, so a threat cuts it short. + */ +/datum/ai_behavior/outpost_fly_eat + action_cooldown = 1 SECONDS + required_distance = 1 + behavior_flags = AI_BEHAVIOR_REQUIRE_MOVEMENT | AI_BEHAVIOR_MOVE_AND_PERFORM | AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION + +/datum/ai_behavior/outpost_fly_eat/setup(datum/ai_controller/controller, meal_key) + var/obj/item/food/meal = controller.blackboard[meal_key] + if(QDELETED(meal)) + return FALSE + set_movement_target(controller, meal) + return ..() + +/datum/ai_behavior/outpost_fly_eat/perform(seconds_per_tick, datum/ai_controller/controller, meal_key) + var/mob/living/carbon/human/body = controller.pawn + var/obj/item/food/meal = controller.blackboard[meal_key] + if(QDELETED(meal)) + return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED + if(LAZYLEN(body.do_afters)) + return AI_BEHAVIOR_DELAY + if(body.is_holding(meal)) + if(!human_npc_ready_item(body, meal)) + return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED + // A bite: the food used on itself, out of combat mode, as a player eats. + controller.ai_interact(target = body, combat_mode = FALSE) + return AI_BEHAVIOR_DELAY + if(!isturf(meal.loc)) + return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED + if(!body.Adjacent(meal)) + return AI_BEHAVIOR_DELAY + if(!human_npc_ready_empty_hand(body)) + return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED + controller.ai_interact(target = meal, combat_mode = FALSE) + return AI_BEHAVIOR_DELAY + +/datum/ai_behavior/outpost_fly_eat/finish_action(datum/ai_controller/controller, succeeded, meal_key) + var/obj/item/food/meal = controller.blackboard[meal_key] + . = ..() + controller.clear_blackboard_key(meal_key) + if(succeeded || QDELETED(meal)) + return + // Couldn't get at it: written off a while, like a target it can't reach. + var/mob/living/body = controller.pawn + var/datum/component/outpost_experiment_form/fly/fly = body?.GetComponent(/datum/component/outpost_experiment_form/fly) + fly?.mark_unreachable(meal) + +#undef OUTPOST_EXPERIMENT_FORM_TRAIT +#undef BB_OUTPOST_FLY_MEAL diff --git a/voidcrew/modules/player_outposts/outpost_prison_experiments.dm b/voidcrew/modules/player_outposts/outpost_prison_experiments.dm index 2d06959b6db..94892810561 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_experiments.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_experiments.dm @@ -10,12 +10,17 @@ * - The serum, the specimen jar and the food it taints (outpost_prison_serum.dm) only work in a * member's hands, on this wing's prisoners, for 10 minutes, and never leave the level. * - A serum subject twitches for a minute, with the form's tells in the last 40 seconds, then - * turns into a hulk, a fly person or a nightmare (outpost_prison_creatures.dm). A specimen host - * goes to the changeling event (outpost_changeling_infect(), outpost_prison_changeling.dm). - * - The wing is paid a fee when a creature shows (experiment_creature_appeared()) and a bonus when - * it is put down (experiment_creature_down()) if the crew did half its damage or more - * (/datum/component/experiment_damage_ledger). Each is paid once per experiment. Put down, it - * lies there, "awaiting pickup" on the console, until Kessler's team beams in for it (kessler_collect()). + * their own body becomes a hulk, a fly person or a nightmare by tg's own genes and species + * (outpost_prison_experiment_forms.dm). A specimen host goes to the changeling event + * (outpost_changeling_infect(), outpost_prison_changeling.dm). + * - The wing is paid a fee when a creature shows (experiment_creature_appeared()). A creature that goes + * down (dead, or in crit, stamcrit, asleep or cuffed: outpost_experiment_down_state()) lies there, + * "awaiting pickup" on the console, until Kessler's team beams in for it (kessler_collect()), keeps it + * down with a real tranquilliser dart, and beams it away. The containment bonus is paid, if the crew + * did half its damage or more (/datum/component/experiment_damage_ledger), when it dies, or for one + * taken alive when Kessler has it, at the subdued rate if it was held. Each is paid once per + * experiment. One that gets back up before Kessler has it (revived, woken, out of its cuffs) is loose + * again. * - A creature stays until the crew puts it down or an admin ends the experiment. One that gets out * of the wing sets off the containment breach alarm. One taken off the outpost (onto a ship, say) * is recovered by Kessler at once, for a fee that becomes debt (experiment_recover()). The one @@ -29,7 +34,7 @@ * Every clock here counts only while a member of the wing is home (crew_home()). */ -/mob/living/basic/outpost_prisoner +/mob/living/carbon/human/npc/outpost_prisoner /// Dosed or carrying a specimen: their death is the experiment's, not staff's var/experiment_subject = FALSE @@ -37,7 +42,7 @@ /// The experiment under way, or just ended (the console shows the result for a while) var/datum/outpost_experiment/experiment /// The researcher, while visiting with an offer - var/mob/living/basic/outpost_kessler_staff/researcher/researcher + var/mob/living/carbon/human/npc/outpost_kessler_staff/researcher/researcher /// Crew-home seconds until the researcher is due; null before the first arrival and while an offer, item or experiment is out var/researcher_wait /// The researcher's visits have been scheduled: the wing has had its first arrival @@ -114,7 +119,7 @@ * bursts from the body. */ /datum/outpost_prison/proc/subject_tick(seconds, home) - var/mob/living/basic/outpost_prisoner/subject = experiment.subject() + var/mob/living/carbon/human/npc/outpost_prisoner/subject = experiment.subject() if(!subject || subject.prison != src || subject.phase != PRISONER_PRESENT) experiment_failed("the subject is gone") return FALSE @@ -134,14 +139,14 @@ /datum/outpost_prison/proc/experiment_paused() if(!experiment_active() || !crew_home()) return TRUE - var/mob/living/basic/outpost_prisoner/subject = experiment.subject() + var/mob/living/carbon/human/npc/outpost_prisoner/subject = experiment.subject() return subject && subject.stat != DEAD && (get_area(subject) != wing || !in_cell_block(subject)) /// A minute of twitching, then the change. The form's tells show in the last OUTPOST_EXPERIMENT_TELLS seconds. /datum/outpost_prison/proc/twitch_tick(seconds, home) if(!home) return - var/mob/living/basic/outpost_prisoner/subject = experiment.subject() + var/mob/living/carbon/human/npc/outpost_prisoner/subject = experiment.subject() experiment.twitch_left -= seconds experiment.stage = experiment.twitch_left > OUTPOST_EXPERIMENT_TELLS ? "dosed" : "twitching" if(experiment.twitch_left <= 0) @@ -162,21 +167,29 @@ else subject.say_context("experiment_dose") -/// The serum takes: the subject becomes the creature where they stand +/// The serum takes: the subject's body becomes the creature where they stand (outpost_prison_experiment_forms.dm) /datum/outpost_prison/proc/transform_subject() - var/mob/living/basic/outpost_prisoner/subject = experiment.subject() - var/creature_type = outpost_experiment_creature_type(experiment.form) + var/mob/living/carbon/human/npc/outpost_prisoner/subject = experiment.subject() var/turf/spot = get_turf(subject) - if(!subject || !creature_type || !spot) + if(!subject || !outpost_experiment_form_type(experiment.form) || !spot) experiment_failed("the serum did not take") return null - var/mob/living/basic/outpost_experiment/creature = new creature_type(spot, src, subject) - add_log("[subject.real_name] turned into [creature.form_name].") - log_game("PLAYER OUTPOST PRISON: [subject.real_name] turned into [creature.form_name] at '[outpost?.name]' [AREACOORD(spot)]") + var/subject_name = subject.real_name + var/personality = subject.personality experiment.subject_ref = null - qdel(subject) - experiment_creature_appeared(creature, experiment.form) - return creature + // The same body, no longer an inmate: off the roster (its cell waits a refill), the prisoner's own + // reactions off. The form brings its own mind, side and refusals. + subject.stand_down_for_experiment() + forget(subject) + var/mob/living/carbon/human/body = subject + var/datum/component/outpost_experiment_form/form = outpost_experiment_turn(body, experiment.form, src, personality) + if(!form) + experiment_failed("the serum did not take") + return null + add_log("[subject_name] turned into [form.form_name].") + log_game("PLAYER OUTPOST PRISON: [subject_name] turned into [form.form_name] at '[outpost?.name]' [AREACOORD(spot)]") + experiment_creature_appeared(body, experiment.form) + return body /** * The creatures and the leash. A creature off the outpost is recovered at once (for the fee only @@ -196,6 +209,10 @@ return var/out_of_wing = FALSE for(var/mob/living/creature as anything in live) + // A body the serum took is down when tg says so: crit, stamcrit, asleep, cuffed or dead. + if(outpost_experiment_down_state(creature)) + experiment_creature_down(creature) + continue if(!outpost_holds(creature)) // Its own move into space (on_moved()) usually got there first; this catches the rest. var/mob/living/basic/outpost_experiment/horror/spaced = creature @@ -208,6 +225,12 @@ return if(get_area(creature) != wing) out_of_wing = TRUE + // Down and waiting for Kessler, but dragged off the outpost: Kessler's beam takes it at once. + for(var/key in experiment.awaiting.Copy()) + var/datum/weakref/creature_ref = experiment.creature_refs[key] + var/mob/living/creature = creature_ref?.resolve() + if(!QDELETED(creature) && !outpost_holds(creature) && !HAS_TRAIT_FROM(creature, TRAIT_IMMOBILIZED, OUTPOST_KESSLER_TRAIT)) + kessler_finish_collect(creature_ref) if(out_of_wing && !experiment.breach_announced) experiment.breach_announced = TRUE add_log("An experiment creature got out of the wing.") @@ -230,7 +253,7 @@ * does the admin panel with `forced`, which skips the cell block rule. One experiment at a time, * on a living prisoner of this wing. Returns TRUE if it started. */ -/datum/outpost_prison/proc/start_experiment(form, mob/living/basic/outpost_prisoner/subject, forced = FALSE) +/datum/outpost_prison/proc/start_experiment(form, mob/living/carbon/human/npc/outpost_prisoner/subject, forced = FALSE) if(!(form in list("hulk", "fly", "nightmare", "changeling"))) return FALSE if(QDELETED(subject) || subject.prison != src || subject.phase != PRISONER_PRESENT || subject.stat == DEAD) @@ -262,7 +285,7 @@ experiment.stage = "dosed" experiment.twitch_left = OUTPOST_EXPERIMENT_TWITCH experiment.effect_left = rand(3, 5) - INVOKE_ASYNC(subject, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context), "experiment_dose") + INVOKE_ASYNC(subject, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context), "experiment_dose") return TRUE // ===== CREATURES AND PAY ===== @@ -290,7 +313,10 @@ experiment.creature_refs[key] = WEAKREF(creature) experiment.creature_kinds[key] = kind experiment.revealed = TRUE - creature.AddComponent(/datum/component/experiment_damage_ledger) + var/datum/component/experiment_damage_ledger/ledger = creature.AddComponent(/datum/component/experiment_damage_ledger) + // The crew's lights are their weapon against a nightmare: what the light burns is theirs. + if(kind == "nightmare" && istype(ledger)) + ledger.light_is_players = TRUE RegisterSignal(creature, COMSIG_LIVING_DEATH, PROC_REF(on_creature_death)) RegisterSignal(creature, COMSIG_QDELETING, PROC_REF(on_creature_deleted)) experiment.stage = kind == "horror" ? "horror" : "live" @@ -304,37 +330,87 @@ return TRUE /** - * A creature was put down: killed, or `subdued` alive (worn out on stamina). Pays the containment - * bonus, once per experiment, if players did at least OUTPOST_EXPERIMENT_PLAYER_SHARE of its - * damage. It lies there, and the console shows it awaiting pickup, until Kessler's team comes for - * it OUTPOST_EXPERIMENT_PICKUP seconds later. With no creature left the experiment is over. - * Returns TRUE if it counted. + * A creature went down (outpost_experiment_down_state()): dead, or a body the serum took in crit, + * stamcrit, asleep or cuffed. It lies there, and the console shows it awaiting pickup, until Kessler's + * team comes for it OUTPOST_EXPERIMENT_PICKUP seconds later (kessler_collect()). A dead one earns the + * containment bonus now (once per experiment, so reviving it earns nothing more); one down alive earns it + * when Kessler has it, by the state the team finds it in. With nothing left loose or down alive, the + * experiment is contained. Returns TRUE if it counted. */ -/datum/outpost_prison/proc/experiment_creature_down(mob/living/creature, subdued = FALSE) +/datum/outpost_prison/proc/experiment_creature_down(mob/living/creature) if(!experiment || !creature) return FALSE var/key = REF(creature) if(!experiment.creature_refs[key] || experiment.downed[key]) return FALSE + var/state = outpost_experiment_down_state(creature) || OUTPOST_EXPERIMENT_DOWN_DEAD experiment.downed[key] = TRUE - experiment.awaiting[key] = subdued ? "subdued" : "down" - var/kind = experiment.creature_kinds[key] - if(!experiment.bonus_done && !experiment.resolved) - experiment.bonus_done = TRUE - var/datum/component/experiment_damage_ledger/ledger = creature.GetComponent(/datum/component/experiment_damage_ledger) - var/share = ledger ? ledger.player_share() : 1 - if(share >= OUTPOST_EXPERIMENT_PLAYER_SHARE) - var/bonus = round(outpost_experiment_bonus(kind, subdued) * experiment.multiplier) - if(pay_treasury(bonus, "Kessler Biolabs containment bonus")) - experiment.bonus_paid = bonus - add_log("[creature.name] was [subdued ? "subdued" : "put down"]. Kessler Biolabs paid a [bonus] cr containment bonus.") - else - add_log("[creature.name] was [subdued ? "subdued" : "put down"]. Kessler Biolabs paid no bonus.") - addtimer(CALLBACK(src, PROC_REF(kessler_collect), WEAKREF(creature), FALSE), OUTPOST_EXPERIMENT_PICKUP SECONDS, TIMER_DELETE_ME) - if(!experiment.resolved && !length(experiment.live_creatures())) - resolve_experiment("contained") + experiment.awaiting[key] = state + if(state != OUTPOST_EXPERIMENT_DOWN_DEAD) + var/datum/component/outpost_experiment_form/form = creature.GetComponent(/datum/component/outpost_experiment_form) + creature.visible_message(span_danger("[creature] [form?.down_message || "collapses, spent."]")) + creature.balloon_alert_to_viewers(state) + else + if(ishuman(creature)) + creature.balloon_alert_to_viewers("dead") + pay_containment(creature) + addtimer(CALLBACK(src, PROC_REF(kessler_collect), WEAKREF(creature)), OUTPOST_EXPERIMENT_PICKUP SECONDS, TIMER_DELETE_ME) + experiment_check_contained() return TRUE +/// Contained: nothing of the experiment's is loose, or down alive waiting for Kessler (which could still get up) +/datum/outpost_prison/proc/experiment_check_contained() + if(!experiment || experiment.resolved || length(experiment.live_creatures())) + return FALSE + for(var/key in experiment.awaiting) + if(experiment.awaiting[key] != OUTPOST_EXPERIMENT_DOWN_DEAD) + return FALSE + resolve_experiment("contained") + return TRUE + +/// Whether `creature` lies down waiting for Kessler's team +/datum/outpost_prison/proc/experiment_awaiting_pickup(mob/living/creature) + if(!experiment) + return FALSE + return !!experiment.awaiting[REF(creature)] + +/** + * A creature that went down is back on its feet before Kessler had it (revived, woken, out of its + * cuffs): it is loose again, and the experiment goes on. One the experiment has already been settled + * for (contained, paid) is Kessler's: the beam takes it as it stands. + */ +/datum/outpost_prison/proc/experiment_creature_back_up(mob/living/creature) + if(!experiment) + return + var/key = REF(creature) + experiment.awaiting -= key + if(experiment.resolved) + kessler_take(creature) + return + experiment.downed -= key + add_log("[creature.name] got back up before Kessler Biolabs came for [creature.p_them()].") + +/** + * The containment bonus, once per experiment, for the creature Kessler is taking: if players did at least + * OUTPOST_EXPERIMENT_PLAYER_SHARE of its damage, at the subdued rate when it was taken alive and held. + */ +/datum/outpost_prison/proc/pay_containment(mob/living/creature) + var/key = REF(creature) + if(experiment.bonus_done || experiment.resolved) + return + experiment.bonus_done = TRUE + var/subdued = experiment.awaiting[key] == OUTPOST_EXPERIMENT_DOWN_SUBDUED + var/kind = experiment.creature_kinds[key] + var/datum/component/experiment_damage_ledger/ledger = creature.GetComponent(/datum/component/experiment_damage_ledger) + var/share = ledger ? ledger.player_share() : 1 + if(share < OUTPOST_EXPERIMENT_PLAYER_SHARE) + add_log("[creature.name] was [subdued ? "subdued" : "put down"]. Kessler Biolabs paid no bonus.") + return + var/bonus = round(outpost_experiment_bonus(kind, subdued) * experiment.multiplier) + if(pay_treasury(bonus, "Kessler Biolabs containment bonus")) + experiment.bonus_paid = bonus + add_log("[creature.name] was [subdued ? "subdued" : "put down"]. Kessler Biolabs paid a [bonus] cr containment bonus.") + /** * A tracked creature died: that is it put down. Gibbed or dusted (a bomb, a shuttle), it never took * the health it still had as damage, so that goes on its ledger as damage that was not the players'. @@ -342,14 +418,14 @@ */ /datum/outpost_prison/proc/on_creature_death(mob/living/creature, gibbed) SIGNAL_HANDLER - var/unspent = creature.health + var/unspent = max(0, creature.health) var/mob/living/basic/outpost_experiment/experiment_creature = creature if(istype(experiment_creature)) unspent = experiment_creature.unspent_health() if(gibbed && unspent > 0) var/datum/component/experiment_damage_ledger/ledger = creature.GetComponent(/datum/component/experiment_damage_ledger) ledger?.add_damage(unspent, FALSE) - INVOKE_ASYNC(src, PROC_REF(experiment_creature_down), creature, FALSE) + INVOKE_ASYNC(src, PROC_REF(experiment_creature_down), creature) /// A tracked creature is gone. A serum creature deleted before it was put down or recovered takes the experiment with it. /datum/outpost_prison/proc/on_creature_deleted(mob/living/creature) @@ -378,7 +454,8 @@ return FALSE for(var/mob/living/creature as anything in experiment.live_creatures()) experiment.downed[REF(creature)] = TRUE - kessler_collect(WEAKREF(creature), FALSE) + kessler_take(creature) + take_awaiting_creatures() add_log("The experiment failed: [reason].") log_game("PLAYER OUTPOST PRISON: experiment failed at '[outpost?.name]' ([reason])") resolve_experiment("failed") @@ -399,7 +476,8 @@ fee = max(fee, outpost_experiment_recovery_fee(experiment.creature_kinds[key])) names += creature.name experiment.downed[key] = TRUE - kessler_collect(WEAKREF(creature), TRUE) + outpost_kessler_team(creature, "kessler_recovery", tranquilise = FALSE) + kessler_take(creature) var/charged = 0 if(charge && fee > 0) charged = charge_fine(fee, "Kessler Biolabs recovery fee") @@ -450,8 +528,9 @@ qdel(creature) for(var/mob/living/creature as anything in experiment.live_creatures()) experiment.downed[REF(creature)] = TRUE - kessler_collect(WEAKREF(creature), FALSE) - var/mob/living/basic/outpost_prisoner/subject = experiment.subject() + kessler_take(creature) + take_awaiting_creatures() + var/mob/living/carbon/human/npc/outpost_prisoner/subject = experiment.subject() if(subject) subject.experiment_subject = FALSE outpost_experiment_clear_tells(subject) @@ -482,7 +561,7 @@ experiment.resolved = TRUE experiment.stage = outcome experiment.result_left = OUTPOST_EXPERIMENT_RESULT_SHOWN - var/mob/living/basic/outpost_prisoner/subject = experiment.subject() + var/mob/living/carbon/human/npc/outpost_prisoner/subject = experiment.subject() if(subject && subject.stat != DEAD) subject.experiment_subject = FALSE outpost_experiment_clear_tells(subject) @@ -492,7 +571,7 @@ // absorbed who was not a prisoner. Its witnesses join the experiment's, once each. if(!QDELETED(experiment.changeling)) for(var/datum/weakref/witness_ref as anything in experiment.changeling.witnesses) - var/mob/living/basic/outpost_prisoner/witness = witness_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/witness = witness_ref?.resolve() if(witness) experiment.witnesses[REF(witness)] = witness_ref #endif @@ -510,7 +589,7 @@ /datum/outpost_prison/proc/experiment_aftermath() for(var/key in experiment.witnesses) var/datum/weakref/witness_ref = experiment.witnesses[key] - var/mob/living/basic/outpost_prisoner/witness = witness_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/witness = witness_ref?.resolve() if(!witness || witness.prison != src || witness.stat == DEAD || witness.phase != PRISONER_PRESENT) continue witness.adjust_mood(-OUTPOST_EXPERIMENT_SAW_DEATH_MOOD) @@ -520,37 +599,138 @@ experiment.creature_kills = 0 /** - * Kessler takes a creature away: a team beams in around it, and OUTPOST_KESSLER_TEAM_TIME later - * the beam takes it. One that was put down is collected where it lies; one still on its feet (a - * `recovery` off the outpost, or an experiment called off) is tranquilised and drops first. It is - * held still and cannot be hurt meanwhile. + * Kessler's team comes for a creature that went down (experiment_creature_down()): two agents beam in + * around it, a living one gets a real chloral hydrate dart to keep it down (owner ruling OC-3), and + * OUTPOST_KESSLER_TEAM_TIME later, if it is still down, the containment bonus is paid and the beam takes + * it. The bonus goes by the state it was found in. One already back on its feet is loose again. */ -/datum/outpost_prison/proc/kessler_collect(datum/weakref/creature_ref, recovery = FALSE) +/datum/outpost_prison/proc/kessler_collect(datum/weakref/creature_ref) var/mob/living/creature = creature_ref?.resolve() - if(QDELETED(creature) || HAS_TRAIT_FROM(creature, TRAIT_GODMODE, OUTPOST_KESSLER_TRAIT)) + if(QDELETED(creature) || !experiment || HAS_TRAIT_FROM(creature, TRAIT_IMMOBILIZED, OUTPOST_KESSLER_TRAIT)) + return + var/key = REF(creature) + if(!experiment.awaiting[key]) + return + var/state = outpost_experiment_down_state(creature) + if(!state) + experiment_creature_back_up(creature) + return + experiment.awaiting[key] = state + outpost_kessler_team(creature, "kessler_collect", tranquilise = FALSE) + if(creature.stat != DEAD) + outpost_kessler_dart(creature) + addtimer(CALLBACK(src, PROC_REF(kessler_finish_collect), creature_ref), OUTPOST_KESSLER_TEAM_TIME, TIMER_DELETE_ME) + +/// The team's beam takes a creature still down, and Kessler pays for it if it hasn't yet. With nothing left loose or down alive, the experiment is contained. +/datum/outpost_prison/proc/kessler_finish_collect(datum/weakref/creature_ref) + var/mob/living/creature = creature_ref?.resolve() + if(QDELETED(creature) || !experiment || HAS_TRAIT_FROM(creature, TRAIT_IMMOBILIZED, OUTPOST_KESSLER_TRAIT)) + return + var/key = REF(creature) + if(!experiment.awaiting[key]) + return + if(!outpost_experiment_down_state(creature)) + experiment_creature_back_up(creature) return - var/already_down = creature.stat == DEAD || creature.body_position == LYING_DOWN - ADD_TRAIT(creature, TRAIT_GODMODE, OUTPOST_KESSLER_TRAIT) - ADD_TRAIT(creature, TRAIT_IMMOBILIZED, OUTPOST_KESSLER_TRAIT) - ADD_TRAIT(creature, TRAIT_INCAPACITATED, OUTPOST_KESSLER_TRAIT) - ADD_TRAIT(creature, TRAIT_HANDS_BLOCKED, OUTPOST_KESSLER_TRAIT) - ADD_TRAIT(creature, TRAIT_FLOORED, OUTPOST_KESSLER_TRAIT) - creature.ai_controller?.CancelActions() + pay_containment(creature) + add_log("Kessler Biolabs collected [creature.name].") + experiment.awaiting -= key + kessler_take(creature) + experiment_check_contained() + +/** + * Kessler's beam takes a creature away for good: held still and harmless for the beam, then gone. A + * transporter, never godmode (defaults 1.8): nothing that happens during it changes what was paid. The + * crew's restraints stay behind. + */ +/datum/outpost_prison/proc/kessler_take(mob/living/creature) + if(QDELETED(creature) || HAS_TRAIT_FROM(creature, TRAIT_IMMOBILIZED, OUTPOST_KESSLER_TRAIT)) + return + creature.add_traits(list(TRAIT_IMMOBILIZED, TRAIT_INCAPACITATED, TRAIT_HANDS_BLOCKED), OUTPOST_KESSLER_TRAIT) + creature.ai_controller?.set_ai_status(AI_STATUS_OFF) creature.pulledby?.stop_pulling() - if(recovery) - outpost_kessler_team(creature, "kessler_recovery", tranquilise = TRUE) - else - outpost_kessler_team(creature, "kessler_collect", tranquilise = !already_down) - if(already_down && !recovery) - add_log("Kessler Biolabs collected [creature.name].") - addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(outpost_kessler_beam_away), creature), OUTPOST_KESSLER_TEAM_TIME, TIMER_DELETE_ME) + creature.stop_pulling() + creature.buckled?.unbuckle_mob(creature, force = TRUE) + var/turf/spot = get_turf(creature) + if(spot) + creature.visible_message(span_notice("A transporter beam takes [creature] away.")) + playsound(spot, 'sound/effects/magic/teleport_diss.ogg', 40, TRUE) + new /obj/effect/temp_visual/transporter_beam(spot, OUTPOST_KESSLER_BEAM_TIME + 0.5 SECONDS) + transporter_dematerialise(creature, OUTPOST_KESSLER_BEAM_TIME) + addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(outpost_kessler_finish_take), WEAKREF(creature)), OUTPOST_KESSLER_BEAM_TIME, TIMER_DELETE_ME) + +/// Everything down and waiting for Kessler goes with the beam now, unpaid: the experiment is over before the team came +/datum/outpost_prison/proc/take_awaiting_creatures() + for(var/key in experiment.awaiting.Copy()) + var/datum/weakref/creature_ref = experiment.creature_refs[key] + experiment.awaiting -= key + kessler_take(creature_ref?.resolve()) + +/// The end of Kessler's beam: restraints the crew put on it stay, and the rest goes +/proc/outpost_kessler_finish_take(datum/weakref/creature_ref) + var/mob/living/creature = creature_ref?.resolve() + if(QDELETED(creature)) + return + var/turf/spot = get_turf(creature) + var/mob/living/carbon/held = creature + if(spot && istype(held)) + for(var/obj/item/restraints/worn in list(held.handcuffed, held.legcuffed)) + held.transferItemToLoc(worn, spot, force = TRUE) + if(spot) + new /obj/effect/temp_visual/transporter_flash/departure(spot) + transporter_sparks(spot) + playsound(spot, 'sound/effects/magic/teleport_app.ogg', 50, TRUE) + qdel(creature) + +/** + * A Kessler agent's tranquilliser: a real dart of chloral hydrate, fired from beside `creature`, which tg's + * reagent and the target's clothing decide the rest of. + */ +/proc/outpost_kessler_dart(mob/living/creature) + var/turf/target_turf = get_turf(creature) + if(!target_turf) + return null + var/turf/from = target_turf + for(var/turf/open/tile in shuffle(orange(1, target_turf))) + if(!tile.is_blocked_turf(TRUE)) + from = tile + break + var/obj/projectile/bullet/dart/dart = new(from) + dart.reagents.add_reagent(/datum/reagent/toxin/chloralhydrate, OUTPOST_KESSLER_DART_DOSE) + dart.original = creature + playsound(from, 'sound/items/syringeproj.ogg', 50, TRUE) + dart.aim_projectile(creature, from) + dart.fire(direct_target = creature) + return dart + +/** + * Whether a creature is down for Kessler, and how, by tg's own states: OUTPOST_EXPERIMENT_DOWN_DEAD; + * OUTPOST_EXPERIMENT_DOWN_SUBDUED for a body alive on the floor (crit, stamcrit, asleep) and held (cuffed + * or asleep); OUTPOST_EXPERIMENT_DOWN_DOWN for one on the floor or cuffed but not both. Null while it is + * up and free. The horror and the headslug, monsters, are down only once dead. + */ +/proc/outpost_experiment_down_state(mob/living/creature) + if(QDELETED(creature)) + return null + if(creature.stat == DEAD) + return OUTPOST_EXPERIMENT_DOWN_DEAD + if(!iscarbon(creature)) + return null + var/asleep = creature.stat == UNCONSCIOUS || creature.IsSleeping() || creature.IsUnconscious() + var/floored = asleep || creature.stat >= SOFT_CRIT || HAS_TRAIT_FROM(creature, TRAIT_INCAPACITATED, STAMINA) + var/held = asleep || HAS_TRAIT(creature, TRAIT_RESTRAINED) + if(floored && held) + return OUTPOST_EXPERIMENT_DOWN_SUBDUED + if(floored || held) + return OUTPOST_EXPERIMENT_DOWN_DOWN + return null // ===== PRISONERS ===== /// Prisoners who could be the researcher's subjects: in the wing, alive, not loose and not dosed already /datum/outpost_prison/proc/researcher_prisoner_count() var/count = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.phase == PRISONER_PRESENT && prisoner.stat != DEAD && prisoner.trouble != PRISONER_TROUBLE_LOOSE && !prisoner.experiment_subject) count++ return count @@ -560,7 +740,7 @@ * researcher says so. A changeling host dying is the changeling event's to handle. Anyone else a * creature (not staff) killed counts toward the aftermath, with everyone in sight of it a witness. */ -/datum/outpost_prison/on_prisoner_death(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/on_prisoner_death(mob/living/carbon/human/npc/outpost_prisoner/prisoner) . = ..() if(!experiment_active()) return @@ -575,12 +755,12 @@ if(!creature_live() || prisoner.death_blamed) return experiment.creature_kills++ - for(var/mob/living/basic/outpost_prisoner/witness in viewers(OUTPOST_EXPERIMENT_WITNESS_RANGE, get_turf(prisoner))) + for(var/mob/living/carbon/human/npc/outpost_prisoner/witness in viewers(OUTPOST_EXPERIMENT_WITNESS_RANGE, get_turf(prisoner))) if(witness != prisoner && witness.prison == src && witness.stat != DEAD) experiment.witnesses[REF(witness)] = WEAKREF(witness) /// A dosed subject earns nothing: their pay and release bonus are forfeit -/datum/outpost_prison/pay_factor(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/pay_factor(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(prisoner?.experiment_subject) return 0 return ..() @@ -592,7 +772,7 @@ * of the cell block stays on the roster (body_tick()). * Once the experiment is over the usual rules apply again. */ -/datum/outpost_prison/proc/held_for_experiment(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/held_for_experiment(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(!prisoner || !experiment_active()) return FALSE if(prisoner == experiment.subject()) @@ -604,12 +784,12 @@ return FALSE /// A dosed subject is not released at the end of their sentence -/datum/outpost_prison/check_release(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/check_release(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(held_for_experiment(prisoner)) return return ..() -/datum/outpost_prison/release(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/release(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(held_for_experiment(prisoner)) return 0 return ..() @@ -740,7 +920,7 @@ var/list/witnesses = list() var/creature_kills = 0 -/datum/outpost_experiment/New(datum/outpost_prison/owner, form, mob/living/basic/outpost_prisoner/subject) +/datum/outpost_experiment/New(datum/outpost_prison/owner, form, mob/living/carbon/human/npc/outpost_prisoner/subject) . = ..() prison = owner src.form = form @@ -972,6 +1152,9 @@ /// While set, the damage it takes is the players' whoever struck last: fire a player is credited /// with (the horror's take_fire_damage()). It is not a blow, so recent_player() keeps its time. var/crediting_players = FALSE + /// A nightmare's: burns it takes standing in the light, with nobody striking it, are the players' + /// (the crew's lights are their weapon) + var/light_is_players = FALSE /datum/component/experiment_damage_ledger/Initialize() if(!isliving(parent)) @@ -1021,6 +1204,11 @@ if(crediting_players) add_damage(damage, TRUE) return + if(light_is_players && damagetype == BURN && last_attack_time != world.time) + var/turf/lit = get_turf(parent) + if(lit && lit.get_lumcount() >= SHADOW_SPECIES_LIGHT_THRESHOLD) + add_damage(damage, TRUE) + return if(last_attack_time == world.time) if(!last_attack_prisoner) add_damage(damage, last_attack_player) @@ -1095,7 +1283,7 @@ return TRUE /// Starts a changeling event in `host`, a prisoner of `prison`, and returns it -/proc/outpost_changeling_infect(mob/living/basic/outpost_prisoner/host, datum/outpost_prison/prison) +/proc/outpost_changeling_infect(mob/living/carbon/human/npc/outpost_prisoner/host, datum/outpost_prison/prison) var/datum/outpost_changeling_event/event = new event.prison = prison event.host_ref = WEAKREF(host) diff --git a/voidcrew/modules/player_outposts/outpost_prison_extras.dm b/voidcrew/modules/player_outposts/outpost_prison_extras.dm index d0df5077f73..16f7f332f9c 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_extras.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_extras.dm @@ -61,14 +61,14 @@ GLOBAL_LIST_INIT(outpost_prisoner_extra_placeholders, list("{staff}", "{place}", // ===== THE PRISONER ===== -/mob/living/basic/outpost_prisoner +/mob/living/carbon/human/npc/outpost_prisoner /// Values for extra placeholders ("{staff}" = "Isaac") while one line is picked and said var/list/extra_line_values /// The last person or borg (never a machine) whose hit on them counted as staff's var/datum/weakref/last_staff_attacker_ref /// Hooks up every package's own handlers; called once from Initialize() -/mob/living/basic/outpost_prisoner/proc/setup_extras() +/mob/living/carbon/human/npc/outpost_prisoner/proc/setup_extras() setup_ambience() setup_warden_tools() setup_pastimes() @@ -78,13 +78,13 @@ GLOBAL_LIST_INIT(outpost_prisoner_extra_placeholders, list("{staff}", "{place}", * Says a line for `context` with values for extra placeholders, list("{place}" = "the Meridian"). * Lines naming a placeholder without a value are skipped. Returns TRUE if they said something. */ -/mob/living/basic/outpost_prisoner/proc/say_context_with(context, list/values, mob/living/basic/outpost_prisoner/other) +/mob/living/carbon/human/npc/outpost_prisoner/proc/say_context_with(context, list/values, mob/living/carbon/human/npc/outpost_prisoner/other) extra_line_values = values . = say_context(context, other) extra_line_values = null /// Says a line for `context` to `person`, filling {staff} with the name the yard knows them by -/mob/living/basic/outpost_prisoner/proc/say_to_staff(context, mob/person) +/mob/living/carbon/human/npc/outpost_prisoner/proc/say_to_staff(context, mob/person) var/staff_name = prison?.staff_greeting_name(person) return say_context_with(context, staff_name ? list("{staff}" = staff_name) : null) @@ -123,13 +123,13 @@ GLOBAL_LIST_INIT(outpost_prisoner_extra_placeholders, list("{staff}", "{place}", guards_abandon() /// A prisoner was booked in (admit()), with their cell and mood set -/datum/outpost_prison/proc/extras_prisoner_admitted(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/extras_prisoner_admitted(mob/living/carbon/human/npc/outpost_prisoner/prisoner) on_prisoner_admitted(prisoner) contraband_prisoner_admitted(prisoner) leads_prisoner_admitted(prisoner) /// A prisoner is leaving the roster (forget()), still holding their prison and cell -/datum/outpost_prison/proc/extras_prisoner_leaving(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/extras_prisoner_leaving(mob/living/carbon/human/npc/outpost_prisoner/prisoner) on_prisoner_leaving(prisoner) contraband_prisoner_leaving(prisoner) mail_prisoner_leaving(prisoner) @@ -146,7 +146,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_extra_placeholders, list("{staff}", "{place}", // ===== THE PRISON: SPEECH, EXAMINE AND THE TALK MENU ===== /// Something a package wants a prisoner to say now: list(context, other[, values]), or null -/datum/outpost_prison/proc/extra_speech(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/extra_speech(mob/living/carbon/human/npc/outpost_prisoner/prisoner) // A bounty prisoner who sees someone off the ship that caught them (outpost_prison_bounty.dm): rare and gated var/list/choice = bounty_extra_speech(prisoner) if(choice) @@ -163,7 +163,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_extra_placeholders, list("{staff}", "{place}", return leads_extra_speech(prisoner) /// Extra sentences for a prisoner's examine text, from every package that has one; XB's examine() shows them -/datum/outpost_prison/proc/examine_extra_lines(mob/living/basic/outpost_prisoner/prisoner, mob/user) +/datum/outpost_prison/proc/examine_extra_lines(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/user) var/list/lines = list() for(var/line in list(relationship_examine(prisoner), contraband_examine(prisoner, user), leads_examine(prisoner, user), wildcard_examine(prisoner), bounty_examine(prisoner, user))) if(istext(line) && length(line)) @@ -171,7 +171,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_extra_placeholders, list("{staff}", "{place}", return lines /// Extra choices for the talk menu (XC's radial): name -> image, from the packages that add one -/datum/outpost_prison/proc/talk_menu_extra_choices(mob/living/basic/outpost_prisoner/prisoner, mob/living/user) +/datum/outpost_prison/proc/talk_menu_extra_choices(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/user) var/list/choices = list() for(var/list/extra as anything in list(contraband_talk_choices(prisoner, user), leads_talk_choices(prisoner, user))) for(var/key in extra) @@ -179,7 +179,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_extra_placeholders, list("{staff}", "{place}", return choices /// Runs an extra talk menu choice; TRUE if a package handled it. May sleep (the menu is async). -/datum/outpost_prison/proc/talk_menu_extra_act(mob/living/basic/outpost_prisoner/prisoner, mob/living/user, choice) +/datum/outpost_prison/proc/talk_menu_extra_act(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/user, choice) if(contraband_talk_act(prisoner, user, choice)) return TRUE return leads_talk_act(prisoner, user, choice) @@ -187,7 +187,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_extra_placeholders, list("{staff}", "{place}", // ===== THE PRISON: TROUBLE ===== /// What the packages do to the chance two prisoners start a fight: a multiplier, 1 for no change -/datum/outpost_prison/proc/extras_fight_mult(mob/living/basic/outpost_prisoner/one, mob/living/basic/outpost_prisoner/two) +/datum/outpost_prison/proc/extras_fight_mult(mob/living/carbon/human/npc/outpost_prisoner/one, mob/living/carbon/human/npc/outpost_prisoner/two) return fight_chance_mult(one, two) * contraband_fight_mult(one, two) // ===== THE PRISON: CONSOLES ===== diff --git a/voidcrew/modules/player_outposts/outpost_prison_fixtures.dm b/voidcrew/modules/player_outposts/outpost_prison_fixtures.dm index 0ca544dd12f..a76de68e62c 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_fixtures.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_fixtures.dm @@ -10,7 +10,9 @@ /// Whether this is an outpost prisoner /proc/is_outpost_prisoner(atom/thing) - return istype(thing, /mob/living/basic/outpost_prisoner) + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = thing + // A body the serum turned is an experiment's creature now (outpost_prison_experiment_forms.dm) + return istype(prisoner) && !prisoner.experiment_turned // ===== UNIFORM ===== diff --git a/voidcrew/modules/player_outposts/outpost_prison_guard_combat_sense.dm b/voidcrew/modules/player_outposts/outpost_prison_guard_combat_sense.dm new file mode 100644 index 00000000000..91cb195988e --- /dev/null +++ b/voidcrew/modules/player_outposts/outpost_prison_guard_combat_sense.dm @@ -0,0 +1,30 @@ +/** + * Combat sense for a prison's NPC guards (voidcrew/modules/human_npcs/human_npc_combat_sense.dm). + * + * Guards never strike players and carry no stimulant, so theirs is the cover half only: on duty and shot + * with stun rounds by anyone but a fellow guard, a guard gets out of the line of fire, inside the wing, + * keeps down a moment, then goes back to whatever it was doing (its routine plans again). It never + * charges anyone (close_in_reach 0). The prison's own turrets aren't a threat it reacts to: only people + * and mechs are. + */ +/datum/npc_combat_sense/prison_guard + use_stims = FALSE + close_in_reach = 0 + +/mob/living/carbon/human/npc/outpost_prison_guard + npc_combat_sense = /datum/npc_combat_sense/prison_guard + +/datum/npc_combat_sense/prison_guard/can_act(mob/living/carbon/human/npc, datum/ai_controller/controller) + var/mob/living/carbon/human/npc/outpost_prison_guard/guard = npc + return istype(guard) && guard.on_duty() && ..() + +// Players share the guards' faction: only another guard's shot is friendly fire. +/datum/npc_combat_sense/prison_guard/allied(mob/living/carbon/human/npc, atom/shooter) + return is_outpost_prison_guard(shooter) + +/datum/npc_combat_sense/prison_guard/tile_ok(mob/living/carbon/human/npc, datum/ai_controller/controller, turf/tile) + if(!..()) + return FALSE + var/mob/living/carbon/human/npc/outpost_prison_guard/guard = npc + var/area/wing = istype(guard) ? guard.prison?.wing : null + return isnull(wing) || get_area(tile) == wing diff --git a/voidcrew/modules/player_outposts/outpost_prison_guard_routine.dm b/voidcrew/modules/player_outposts/outpost_prison_guard_routine.dm index a2fa01ac29f..096d8392a8e 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_guard_routine.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_guard_routine.dm @@ -2,8 +2,8 @@ * # Prison guards: routine * * Owner: XA (extras-plan.md 4.1). The guards' AI controller, their peaceful activities (post, - * rounds, watching the yard, a drink at the cooler, a chat, checking on a prisoner) and the - * response datum the dispatcher in outpost_prison_guards.dm hands out. + * rounds, watching the yard, a drink at the cooler, a chat, checking on a prisoner, patching + * themselves up) and the response datum the dispatcher in outpost_prison_guards.dm hands out. * * As with the prisoners' routine (outpost_prison_routine.dm), the AI only walks: to the goal of * the guard's response when there is one, else to their activity's. The dispatcher deals with @@ -86,7 +86,7 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) // ===== THE GUARD'S SIDE ===== /// Where their AI should walk them now, or null to stay put -/mob/living/basic/outpost_prison_guard/proc/walk_goal() +/mob/living/carbon/human/npc/outpost_prison_guard/proc/walk_goal() if(phase == OUTPOST_GUARD_DISMISSED) return (leave_spot && loc != leave_spot) ? leave_spot : null if(phase != OUTPOST_GUARD_PRESENT) @@ -98,7 +98,7 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) return (goal && !at_goal(goal)) ? goal : null /// A walk to `goal` failed: a response gets another try until it expires; an activity gets one more, then a rest -/mob/living/basic/outpost_prison_guard/proc/walk_failed(atom/goal) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/walk_failed(atom/goal) if(response || !activity || goal != activity.goal()) return if(++activity.failed_moves < 2) @@ -107,7 +107,7 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) end_activity(cancel_ai = FALSE) /// Ends what they are doing on routine -/mob/living/basic/outpost_prison_guard/proc/end_activity(cancel_ai = TRUE) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/end_activity(cancel_ai = TRUE) if(!activity) return var/datum/outpost_guard_activity/old = activity @@ -119,16 +119,16 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) ai_controller?.CancelActions() /// Starts `new_activity` in place of whatever they were doing on routine -/mob/living/basic/outpost_prison_guard/proc/start_activity(datum/outpost_guard_activity/new_activity) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/start_activity(datum/outpost_guard_activity/new_activity) end_activity() activity = new_activity return new_activity -/mob/living/basic/outpost_prison_guard/proc/activity_on_cooldown(activity_type) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/activity_on_cooldown(activity_type) return LAZYACCESS(activity_cooldowns, activity_type) > world.time /// Picks their next routine activity by weight. Returns it, already set up, or null. -/mob/living/basic/outpost_prison_guard/proc/choose_activity() +/mob/living/carbon/human/npc/outpost_prison_guard/proc/choose_activity() if(!prison || !on_duty()) return null var/list/candidates = list() @@ -161,7 +161,7 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) * A two-guard exchange: they open with a line from the file's guard_conversations, and `partner` * answers a few seconds later. Returns TRUE if it started. */ -/mob/living/basic/outpost_prison_guard/proc/start_guard_conversation(mob/living/basic/outpost_prison_guard/partner) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/start_guard_conversation(mob/living/carbon/human/npc/outpost_prison_guard/partner) if(!on_duty() || !partner?.on_duty()) return FALSE var/list/conversations = outpost_guard_dialogue("guard_conversations") @@ -179,8 +179,8 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) return TRUE /// The second half of a guards' exchange -/mob/living/basic/outpost_prison_guard/proc/reply_to_guard(line, datum/weakref/opener_ref) - var/mob/living/basic/outpost_prison_guard/opener = opener_ref?.resolve() +/mob/living/carbon/human/npc/outpost_prison_guard/proc/reply_to_guard(line, datum/weakref/opener_ref) + var/mob/living/carbon/human/npc/outpost_prison_guard/opener = opener_ref?.resolve() if(!on_duty() || !opener || get_dist(src, opener) > 5 || !istext(line)) return FALSE face_atom(opener) @@ -191,7 +191,9 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) // ===== AI ===== /datum/ai_controller/basic_controller/outpost_prison_guard - blackboard = list() + blackboard = list( + BB_TARGET_MINIMUM_STAT = HUMAN_NPC_SPARES_DOWNED, + ) ai_traits = PASSIVE_AI_FLAGS ai_movement = /datum/ai_movement/jps // The routine plans everything, idle time included. @@ -200,13 +202,17 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) can_idle = FALSE // No finding targets: guards only ever strike through the dispatcher (outpost_prison_guards.dm), // so turrets never read them as hostile. - planning_subtrees = list(/datum/ai_planning_subtree/outpost_prison_guard) + // Combat sense first: out of a line of stun fire before anything else (outpost_prison_guard_combat_sense.dm) + planning_subtrees = list( + /datum/ai_planning_subtree/npc_combat_sense, + /datum/ai_planning_subtree/outpost_prison_guard, + ) /// Walks to the response's goal, else the activity's, or ticks the activity once there /datum/ai_planning_subtree/outpost_prison_guard /datum/ai_planning_subtree/outpost_prison_guard/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/outpost_prison_guard/guard = controller.pawn + var/mob/living/carbon/human/npc/outpost_prison_guard/guard = controller.pawn if(!istype(guard) || guard.stat != CONSCIOUS || HAS_TRAIT(guard, TRAIT_IMMOBILIZED)) return if(guard.phase == OUTPOST_GUARD_DISMISSED || guard.response) @@ -235,7 +241,7 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) return SUBTREE_RETURN_FINISH_PLANNING /// Queues the walk to `goal`: onto a tile, or up beside a mob -/mob/living/basic/outpost_prison_guard/proc/queue_walk(datum/ai_controller/controller, atom/goal) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/queue_walk(datum/ai_controller/controller, atom/goal) controller.set_blackboard_key(BB_OUTPOST_GUARD_GOAL, goal) controller.queue_behavior(isturf(goal) ? /datum/ai_behavior/outpost_prison_guard_travel : /datum/ai_behavior/outpost_prison_guard_travel/approach, BB_OUTPOST_GUARD_GOAL) @@ -253,7 +259,7 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) set_movement_target(controller, goal) /datum/ai_behavior/outpost_prison_guard_travel/perform(seconds_per_tick, datum/ai_controller/controller, goal_key) - var/mob/living/basic/outpost_prison_guard/guard = controller.pawn + var/mob/living/carbon/human/npc/outpost_prison_guard/guard = controller.pawn var/atom/goal = controller.blackboard[goal_key] if(QDELETED(goal) || !istype(guard)) return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED @@ -269,7 +275,7 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) . = ..() controller.clear_blackboard_key(goal_key) if(!succeeded) - var/mob/living/basic/outpost_prison_guard/guard = controller.pawn + var/mob/living/carbon/human/npc/outpost_prison_guard/guard = controller.pawn if(istype(guard)) guard.walk_failed(goal) @@ -282,11 +288,11 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) action_cooldown = 1 SECONDS /datum/ai_behavior/outpost_prison_guard_activity/setup(datum/ai_controller/controller) - var/mob/living/basic/outpost_prison_guard/guard = controller.pawn + var/mob/living/carbon/human/npc/outpost_prison_guard/guard = controller.pawn return istype(guard) && !!guard.activity /datum/ai_behavior/outpost_prison_guard_activity/perform(seconds_per_tick, datum/ai_controller/controller) - var/mob/living/basic/outpost_prison_guard/guard = controller.pawn + var/mob/living/carbon/human/npc/outpost_prison_guard/guard = controller.pawn var/datum/outpost_guard_activity/doing = guard.activity if(!doing || guard.response || !guard.on_duty()) return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED @@ -320,14 +326,14 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) var/max_duration = 90 SECONDS /// Whether rounds or the other guard's chat may take its place var/interruptible = TRUE - var/mob/living/basic/outpost_prison_guard/guard + var/mob/living/carbon/human/npc/outpost_prison_guard/guard /// Where they are headed: a tile, or a mob to stand beside; null once there var/datum/weakref/goal_ref var/started = FALSE var/ends_at = 0 var/failed_moves = 0 -/datum/outpost_guard_activity/New(mob/living/basic/outpost_prison_guard/doer) +/datum/outpost_guard_activity/New(mob/living/carbon/human/npc/outpost_prison_guard/doer) . = ..() guard = doer @@ -377,7 +383,7 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) /// The other guard of the wing on the payroll, if any is here /datum/outpost_guard_activity/proc/other_guard() - for(var/mob/living/basic/outpost_prison_guard/other in guard.prison?.guard_mobs) + for(var/mob/living/carbon/human/npc/outpost_prison_guard/other in guard.prison?.guard_mobs) if(other != guard && other.on_duty()) return other return null @@ -534,8 +540,8 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) /datum/outpost_guard_activity/watch_yard/tick(seconds) var/obj/structure/hoop/hoop = hoop_ref?.resolve() - var/mob/living/basic/outpost_prisoner/player - for(var/mob/living/basic/outpost_prisoner/prisoner in guard.prison?.prisoners) + var/mob/living/carbon/human/npc/outpost_prisoner/player + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in guard.prison?.prisoners) if(istype(prisoner.activity, /datum/prisoner_activity/basketball) && prisoner.stat == CONSCIOUS) player = prisoner break @@ -600,7 +606,7 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) var/next_exchange = 0 /datum/outpost_guard_activity/chat/setup() - var/mob/living/basic/outpost_prison_guard/other = other_guard() + var/mob/living/carbon/human/npc/outpost_prison_guard/other = other_guard() if(!can_join(other)) return FALSE partner_ref = WEAKREF(other) @@ -608,13 +614,13 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) return TRUE /// Whether the other guard is free to talk -/datum/outpost_guard_activity/chat/proc/can_join(mob/living/basic/outpost_prison_guard/other) +/datum/outpost_guard_activity/chat/proc/can_join(mob/living/carbon/human/npc/outpost_prison_guard/other) if(!other?.on_duty() || !other.ai_running() || other.response) return FALSE return !other.activity || (other.activity.interruptible && !istype(other.activity, /datum/outpost_guard_activity/chat)) /datum/outpost_guard_activity/chat/arrive() - var/mob/living/basic/outpost_prison_guard/partner = partner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prison_guard/partner = partner_ref?.resolve() if(!partner || !guard.Adjacent(partner) || !can_join(partner)) return FALSE . = ..() @@ -624,7 +630,7 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) next_exchange = world.time + 1 SECONDS /datum/outpost_guard_activity/chat/tick(seconds) - var/mob/living/basic/outpost_prison_guard/partner = partner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prison_guard/partner = partner_ref?.resolve() var/datum/outpost_guard_activity/chat/listen/listening = partner?.activity if(!partner || !guard.Adjacent(partner) || !istype(listening) || listening.partner_ref?.resolve() != guard) return GUARD_ACTIVITY_DONE @@ -636,7 +642,7 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) return ..() /datum/outpost_guard_activity/chat/finish() - var/mob/living/basic/outpost_prison_guard/partner = partner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prison_guard/partner = partner_ref?.resolve() var/datum/outpost_guard_activity/chat/listen/listening = partner?.activity if(istype(listening) && listening.partner_ref?.resolve() == guard) partner.end_activity() @@ -647,7 +653,7 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) leisure = FALSE weight = 0 -/datum/outpost_guard_activity/chat/listen/New(mob/living/basic/outpost_prison_guard/doer, mob/living/basic/outpost_prison_guard/talker) +/datum/outpost_guard_activity/chat/listen/New(mob/living/carbon/human/npc/outpost_prison_guard/doer, mob/living/carbon/human/npc/outpost_prison_guard/talker) . = ..(doer) partner_ref = WEAKREF(talker) started = TRUE @@ -661,7 +667,7 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) return TRUE /datum/outpost_guard_activity/chat/listen/tick(seconds) - var/mob/living/basic/outpost_prison_guard/talker = partner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prison_guard/talker = partner_ref?.resolve() var/datum/outpost_guard_activity/chat/talking = talker?.activity if(!talker || !guard.Adjacent(talker) || !istype(talking) || talking.partner_ref?.resolve() != guard) return GUARD_ACTIVITY_DONE @@ -688,7 +694,7 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) /datum/outpost_guard_activity/check_on/setup() var/datum/outpost_prison/prison = guard.prison var/list/options = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prison.prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prison.prisoners) if(prisoner.phase != PRISONER_PRESENT || !prisoner.routine_allowed() || prisoner.activity?.sleeping || !prison.in_cell_block(prisoner)) continue if(prisoner.guard_noticed_at && world.time - prisoner.guard_noticed_at < OUTPOST_GUARD_CHECK_ON_GAP) @@ -698,7 +704,7 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) options += prisoner if(!length(options)) return FALSE - var/mob/living/basic/outpost_prisoner/chosen = pick(options) + var/mob/living/carbon/human/npc/outpost_prisoner/chosen = pick(options) prisoner_ref = WEAKREF(chosen) need = chosen.bubble chosen.guard_noticed_at = world.time @@ -707,7 +713,7 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) /datum/outpost_guard_activity/check_on/begin() . = ..() - var/mob/living/basic/outpost_prisoner/prisoner = prisoner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = prisoner_ref?.resolve() if(!prisoner) return guard.face_atom(prisoner) @@ -716,12 +722,132 @@ GLOBAL_LIST_INIT(outpost_guard_leisure, outpost_guard_leisure_types()) guard.prison?.note_speech() /datum/outpost_guard_activity/check_on/tick(seconds) - var/mob/living/basic/outpost_prisoner/prisoner = prisoner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = prisoner_ref?.resolve() if(!prisoner || !guard.Adjacent(prisoner)) return GUARD_ACTIVITY_DONE guard.face_atom(prisoner) return ..() +// ----- patching up ----- + +/** + * Hurt (OUTPOST_GUARD_TREAT_ABOVE brute and burn) with nothing going on: they treat themselves the way + * anyone does, with a bruise pack or suture on themselves (tg's medical stacks, their do_after and all). + * Their own pack first, else one from the wing's first-aid kit in the office, which the crew keeps stocked. + * Nothing heals them otherwise. + */ +/datum/outpost_guard_activity/patch_up + name = "patching up" + leisure = TRUE + weight = 0 + min_duration = 20 SECONDS + max_duration = 30 SECONDS + interruptible = FALSE + /// The first-aid kit they are going to, if they have nothing of their own + var/datum/weakref/kit_ref + +/datum/outpost_guard_activity/patch_up/get_weight() + if(!guard.needs_patching() || guard.prison?.riot_active) + return 0 + return 100 + +/datum/outpost_guard_activity/patch_up/setup() + if(guard.carried_treatment()) + return TRUE + var/obj/item/storage/medkit/kit = guard.prison?.guard_first_aid_kit() + if(!kit) + return FALSE + kit_ref = WEAKREF(kit) + set_goal(isturf(kit.loc) && guard.prison.guard_office_tile(kit.loc) ? kit.loc : guard.prison.guard_spot_beside(kit, guard)) + return !!goal() + +/datum/outpost_guard_activity/patch_up/begin() + . = ..() + var/obj/item/storage/medkit/kit = kit_ref?.resolve() + if(kit && !guard.carried_treatment() && get_dist(guard, kit) <= 1) + guard.take_treatment_from(kit) + INVOKE_ASYNC(guard, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prison_guard, treat_self)) + +/datum/outpost_guard_activity/patch_up/tick(seconds) + if(!guard.treating && !guard.needs_patching()) + return GUARD_ACTIVITY_DONE + if(!guard.treating && guard.carried_treatment()) + INVOKE_ASYNC(guard, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prison_guard, treat_self)) + return ..() + +/datum/outpost_guard_activity/patch_up/Destroy() + kit_ref = null + return ..() + +/mob/living/carbon/human/npc/outpost_prison_guard + /// Busy putting a dressing on themselves + var/treating = FALSE + +/// Hurt enough to stop and patch up +/mob/living/carbon/human/npc/outpost_prison_guard/proc/needs_patching() + return getBruteLoss() + getFireLoss() >= OUTPOST_GUARD_TREAT_ABOVE + +/// A bruise pack, suture, ointment or mesh they carry that would do some good now +/mob/living/carbon/human/npc/outpost_prison_guard/proc/carried_treatment() + for(var/obj/item/stack/medical/stack in get_all_contents_type(/obj/item/stack/medical)) + if(QDELETED(stack) || !stack.amount) + continue + if((stack.heal_brute && getBruteLoss()) || (stack.heal_burn && getFireLoss())) + return stack + return null + +/// Takes a pack out of the wing's first-aid kit into a free hand, as anyone would +/mob/living/carbon/human/npc/outpost_prison_guard/proc/take_treatment_from(obj/item/storage/medkit/kit) + for(var/obj/item/stack/medical/stack in kit) + if(!stack.amount || !((stack.heal_brute && getBruteLoss()) || (stack.heal_burn && getFireLoss()))) + continue + if(!put_in_hands(stack)) + return null + // Used up on them, never loot (human_npc_gear.dm) + npc_lock_item(stack) + return stack + return null + +/** + * Puts a dressing on themselves: a medical stack they carry, in a free hand, used on their own body + * through tg's medical code (the do_after, the limb it treats, the stack used up). Sleeps. + */ +/mob/living/carbon/human/npc/outpost_prison_guard/proc/treat_self() + if(treating || stat != CONSCIOUS || !needs_patching()) + return FALSE + var/obj/item/stack/medical/stack = carried_treatment() + if(!stack) + return FALSE + if(!is_holding(stack) && !human_npc_take_in_hand(src, stack)) + set_baton(FALSE) + if(!human_npc_take_in_hand(src, stack)) + return FALSE + if(!human_npc_ready_item(src, stack)) + return FALSE + treating = TRUE + stack.interact_with_atom(src, src) + treating = FALSE + if(!QDELETED(stack) && is_holding(stack)) + stack.equip_to_best_slot(src) + return TRUE + +/// The wing's first-aid kit in the office with something in it, if there is one +/datum/outpost_prison/proc/guard_first_aid_kit() + for(var/turf/tile as anything in staff_ground) + if(tile.loc != wing) + continue + for(var/obj/item/storage/medkit/kit in tile) + if(locate(/obj/item/stack/medical) in kit) + return kit + return null + +/// A free office tile beside `thing`, for a guard to stand at, or null +/datum/outpost_prison/proc/guard_spot_beside(atom/thing, mob/living/except) + for(var/turf/tile in orange(1, get_turf(thing))) + if(guard_office_tile(tile) && !guard_spot_taken(tile, except)) + return tile + return null + #undef GUARD_ACTIVITY_CONTINUE #undef GUARD_ACTIVITY_DONE #undef GUARD_ACTIVITY_MOVE diff --git a/voidcrew/modules/player_outposts/outpost_prison_guards.dm b/voidcrew/modules/player_outposts/outpost_prison_guards.dm index 17a559bba63..48f53e41c70 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_guards.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_guards.dm @@ -3,20 +3,27 @@ * * Owner: XA (extras-plan.md 4.1). NPC guards the wing's managers hire at the warden's console: * named people on the payroll who keep a peaceful routine, step in on spats, arguments, fights, - * threats and hatch climbs, hold the staff doors in a riot, go down instead of dying and come - * back free. Paid per minute while a member is home. Their routine and activities are in + * threats and hatch climbs, and hold the staff doors in a riot. Paid per minute while a member is home. Their routine and activities are in * outpost_prison_guard_routine.dm; numbers in voidcrew/_DEFINES/outpost_prison_guards.dm. * - * Each hired guard is a record on the prison (name, rank, personality, when they are back). The + * A guard is a real human body (voidcrew/modules/human_npcs/, owner ruling OC-2): stuns, stamina, + * batons, bleeding, crit and death work on them as on anyone, and nothing tops their health up. Hurt, + * they patch themselves up with the office first-aid kit (outpost_prison_guard_routine.dm). In crit + * for OUTPOST_GUARD_RECALL_DELAY the corrections service medevacs the real body; a dead guard's body + * is collected OUTPOST_GUARD_BODY_COLLECT_DELAY after they die. Either way their record waits + * OUTPOST_GUARD_RETURN_TIME, then sends them back (the same face, from the record). Their kit is + * locked to them (D3): it never becomes loot. + * + * Each hired guard is a record on the prison (name, rank, personality, face, when they are back). The * guard on the wing is a mob made from the record; when a guard goes down or is called away the * mob beams out and the record waits to send them back. A slot's wait belongs to the prison, so * dismissing a downed guard and hiring another does not skip it. * * Guards are security only: they never feed, clothe, treat, clean or light anything, so they * cannot raise pay. They never strike players, pets, bots or other NPCs, and they strike a - * prisoner only for violence under way (fighting, rioting, swinging, climbing out, loose) with a - * stun baton that does stamina damage and nothing else. The strike never goes through - * melee_attack(), so no hit is put down to staff. + * prisoner only for violence under way (fighting, rioting, swinging, climbing out, loose) with the + * real stun baton off their belt, through their own hands: tg's stamina, knockdown and cell charge. + * A prisoner never holds a guard's blow against staff (hit_by_staff()). * * The dispatcher (dispatch_guards()) runs every second from guards_tick() and only for guards whose * AI is running, which it is only while a player is on the level. Every response has a proc a test @@ -31,7 +38,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" /// Whether `thing` is one of a prison's NPC guards; with `on_duty`, only one present, arrived and not down /proc/is_outpost_prison_guard(atom/thing, on_duty = FALSE) - var/mob/living/basic/outpost_prison_guard/guard = thing + var/mob/living/carbon/human/npc/outpost_prison_guard/guard = thing if(!istype(guard)) return FALSE return !on_duty || guard.on_duty() @@ -42,34 +49,17 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" // ===== THE GUARD ===== -/mob/living/basic/outpost_prison_guard +/mob/living/carbon/human/npc/outpost_prison_guard name = "guard" desc = "A corrections officer on the prison wing's payroll." - icon = 'icons/mob/simple/simple_human.dmi' - unique_name = FALSE combat_mode = FALSE - mob_biotypes = MOB_ORGANIC | MOB_HUMANOID - // No sentience potions, no lazarus. - sentience_type = SENTIENCE_HUMANOID - maxHealth = OUTPOST_GUARD_HEALTH - health = OUTPOST_GUARD_HEALTH - speed = OUTPOST_GUARD_SPEED_WALK - // Nobody drags or shoves them about. - move_resist = MOVE_FORCE_VERY_STRONG - density = TRUE - basic_mob_flags = NONE - mobility_flags = MOBILITY_FLAGS_REST_CAPABLE_DEFAULT - rotate_on_lying = TRUE - // No stuns or knockdowns: a guard is up or down (go_down()), nothing between. - status_flags = NONE - damage_coeff = list(BRUTE = 1, BURN = 1, TOX = 0, STAMINA = 0, OXY = 0) - // A breach or a fire in the wing must not kill them. - unsuitable_atmos_damage = 0 - unsuitable_cold_damage = 0 - unsuitable_heat_damage = 0 - response_help_continuous = "pats" - response_help_simple = "pat" + faction = list(FACTION_NEUTRAL) ai_controller = /datum/ai_controller/basic_controller/outpost_prison_guard + npc_outfit = /datum/outfit/outpost_prison_guard + // They stop once a prisoner is down (defaults 1.13), and only ever go for prisoners. + npc_target_stat = HUMAN_NPC_SPARES_DOWNED + // The corrections service collects a guard's body (guards_tick()); the base never cleans it up. + npc_corpse_lifetime = 0 /// The prison that hired them var/datum/outpost_prison/prison @@ -91,10 +81,14 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" var/list/response_skips /// Whether the stun baton is out in their hand var/baton_out = FALSE + /// world.time they went down (crit) or died, for the medevac and the body's collection + var/down_since = 0 /// The last thing they said, so they don't repeat it at once var/last_line /// Down: seconds until they are beamed out var/down_left = 0 + /// Killed rather than downed: the body is collected, and the record's wait starts after + var/died_on_duty = FALSE /// Dismissed: seconds left to walk to the office before they beam out wherever they are var/dismiss_left = 0 /// Dismissed: where they walk to before beaming out @@ -107,10 +101,8 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" /// Between "Hey. Don't." lines COOLDOWN_DECLARE(warned_cooldown) -/mob/living/basic/outpost_prison_guard/Initialize(mapload) - gender = pick(MALE, FEMALE) - . = ..() - AddElement(/datum/element/footstep, footstep_type = FOOTSTEP_MOB_SHOE) +/mob/living/carbon/human/npc/outpost_prison_guard/Initialize(mapload) + . = ..(mapload) AddElement(/datum/element/relay_attackers) RegisterSignal(src, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_attacked)) // Nothing moves a guard but their own feet and the prison's beam. @@ -118,13 +110,12 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" RegisterSignal(src, COMSIG_LIVING_PRE_WABBAJACKED, PROC_REF(refuse_polymorph)) RegisterSignal(src, COMSIG_PRE_MOB_CHANGED_TYPE, PROC_REF(refuse_type_change)) RegisterSignal(src, COMSIG_MOUSEDROP_ONTO, PROC_REF(block_being_dragged)) - RegisterSignal(src, COMSIG_ATOM_CAN_BE_PULLED, PROC_REF(refuse_pull)) - ADD_TRAIT(src, TRAIT_NO_CONTAINMENT, INNATE_TRAIT) - ADD_TRAIT(src, TRAIT_NO_STORAGE_INSERT, INNATE_TRAIT) - // Next tick: spawn_guard() calls join() right after new, which sets the record's gender and face. - addtimer(CALLBACK(src, PROC_REF(guard_build_look)), 1) + // On their feet nobody boxes or bags them; down or dead they are a body like anyone's (set_guard_upright()). + // Anyone can drag a guard who is down. A guard on their feet shakes off anyone but the wing's members (guards_tick()). + set_guard_upright(TRUE) + set_prison_pace(hurry = FALSE) -/mob/living/basic/outpost_prison_guard/Destroy() +/mob/living/carbon/human/npc/outpost_prison_guard/Destroy() end_response(cancel_ai = FALSE) end_activity(cancel_ai = FALSE) if(record?.guard == src) @@ -138,120 +129,158 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" leave_spot = null return ..() -/// Dresses them as their own person in the guard's outfit (outpost_npc_looks.dm): the record's face and gender. Can sleep. -/mob/living/basic/outpost_prison_guard/proc/guard_build_look() - set_outpost_npc_look(src, /datum/outfit/outpost_prison_guard, gender, record ? record.look_number : 1) - if(QDELETED(src)) - return - update_appearance(UPDATE_OVERLAYS) - -/// Takes on the name, rank, gender and personality of the guard on the payroll -/mob/living/basic/outpost_prison_guard/proc/join(datum/outpost_prison/owner, datum/outpost_guard_record/hired) +/// Takes on the name, rank, face and personality of the guard on the payroll. The first one sent sets the record's face. +/mob/living/carbon/human/npc/outpost_prison_guard/proc/join(datum/outpost_prison/owner, datum/outpost_guard_record/hired) prison = owner record = hired hired.guard = src owner.guard_mobs |= src - gender = hired.gender + if(length(hired.look)) + outpost_prison_apply_look(src, hired.look) + else + hired.look = outpost_prison_save_look(src) + hired.gender = gender personality = hired.personality - real_name = hired.full_name() - name = real_name + fully_replace_character_name(real_name, hired.full_name()) -/// On the wing and on duty: arrived, not down, not dismissed, and not paid by the kingpin to stand back (outpost_prison_boss_moves.dm) -/mob/living/basic/outpost_prison_guard/proc/on_duty() - return !QDELETED(src) && phase == OUTPOST_GUARD_PRESENT && stat == CONSCIOUS && !boss_bribed() +/// On the wing and on duty: arrived, not down, cuffed or stunned, not dismissed, and not paid by the kingpin to stand back (outpost_prison_boss_moves.dm) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/on_duty() + return !QDELETED(src) && phase == OUTPOST_GUARD_PRESENT && stat == CONSCIOUS && !human_npc_out_of_fight(src) && !boss_bribed() /// Whether their AI is running, which it is only while someone is on the level to see them (see outpost_prison_ai_running()) -/mob/living/basic/outpost_prison_guard/proc/ai_running() +/mob/living/carbon/human/npc/outpost_prison_guard/proc/ai_running() return outpost_prison_ai_running(src) -/mob/living/basic/outpost_prison_guard/update_overlays() - . = ..() - if(!baton_out || phase == OUTPOST_GUARD_DOWN) - return - // The lit baton in hand, the way a security officer holds one, turning with them - var/mutable_appearance/baton = mutable_appearance('icons/mob/inhands/equipment/security_righthand.dmi', "stunbaton_active") - baton.plane = FLOAT_PLANE - baton.layer = FLOAT_LAYER - . += baton - -/// Draws or puts away the baton -/mob/living/basic/outpost_prison_guard/proc/set_baton(out) +/// Their stun baton, wherever on them it is +/mob/living/carbon/human/npc/outpost_prison_guard/proc/get_baton() + return locate(/obj/item/melee/baton/security) in get_all_contents() + +/// Draws the baton off the belt into a hand and switches it on, or puts it away again, as an officer does +/mob/living/carbon/human/npc/outpost_prison_guard/proc/set_baton(out) out = !!out - if(baton_out == out) + var/obj/item/melee/baton/security/baton = get_baton() + if(!baton) + baton_out = FALSE + return + if(out) + if(!is_holding(baton) && !human_npc_take_in_hand(src, baton)) + return + if(!baton.active && baton.cell?.charge >= baton.cell_hit_cost) + baton.attack_self(src) + baton_out = TRUE return - baton_out = out - update_appearance(UPDATE_OVERLAYS) + baton_out = FALSE + if(!is_holding(baton)) + return + if(baton.active) + baton.attack_self(src) + if(!equip_to_slot_if_possible(baton, ITEM_SLOT_BELT, disable_warning = TRUE)) + baton.equip_to_best_slot(src) // ===== REFUSALS ===== -/mob/living/basic/outpost_prison_guard/proc/refuse_teleport(datum/source, atom/destination, channel) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/refuse_teleport(datum/source, atom/destination, channel) SIGNAL_HANDLER if(isturf(loc)) visible_message(span_notice("[src] flickers for a moment, but stays where [p_they()] [p_are()].")) return TRUE -/mob/living/basic/outpost_prison_guard/proc/refuse_polymorph(datum/source, what_to_randomize) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/refuse_polymorph(datum/source, what_to_randomize) SIGNAL_HANDLER visible_message(span_notice("[src] shimmers for a moment, then looks the same as before.")) return STOP_WABBAJACK -/mob/living/basic/outpost_prison_guard/proc/refuse_type_change(datum/source) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/refuse_type_change(datum/source) SIGNAL_HANDLER return COMPONENT_BLOCK_MOB_CHANGE -/mob/living/basic/outpost_prison_guard/proc/block_being_dragged(atom/over, mob/user) - SIGNAL_HANDLER - return COMPONENT_CANCEL_MOUSEDROP_ONTO +/// On their feet they refuse lockers and bags; down or dead, a body can be bagged like anyone's +/mob/living/carbon/human/npc/outpost_prison_guard/proc/set_guard_upright(upright) + if(upright) + add_traits(list(TRAIT_NO_CONTAINMENT, TRAIT_NO_STORAGE_INSERT), OUTPOST_GUARD_UPRIGHT_TRAIT) + else + remove_traits(list(TRAIT_NO_CONTAINMENT, TRAIT_NO_STORAGE_INSERT), OUTPOST_GUARD_UPRIGHT_TRAIT) -/mob/living/basic/outpost_prison_guard/proc/refuse_pull(datum/source, mob/living/puller) +/// Not dragged onto things while on their feet +/mob/living/carbon/human/npc/outpost_prison_guard/proc/block_being_dragged(atom/over, mob/user) SIGNAL_HANDLER - return COMSIG_ATOM_CANT_PULL + return stat == CONSCIOUS && phase == OUTPOST_GUARD_PRESENT ? COMPONENT_CANCEL_MOUSEDROP_ONTO : NONE -// ===== HURT AND DOWN ===== +/// On their feet, a guard won't be led about by anyone but the wing's members: they resist it, as anyone resists a pull +/mob/living/carbon/human/npc/outpost_prison_guard/proc/shake_off_pull() + if(!pulledby || !on_duty() || world.time < next_move) + return + if(isliving(pulledby) && prison?.is_member(pulledby)) + return + execute_resist() + +// ===== HURT, DOWN AND DEAD ===== /** - * Damage never takes a guard below OUTPOST_GUARD_DOWN_AT: at that point they go down instead, - * and while down nothing hurts them (TRAIT_GODMODE). Forced damage is held to the same floor. + * Into crit: they go down. The corrections service medevacs the real body after + * OUTPOST_GUARD_RECALL_DELAY (guards_tick()); treated and back out of crit before then, they are back on duty. */ -/mob/living/basic/outpost_prison_guard/adjust_health(amount, updating_health = TRUE, forced = FALSE) - var/floor_loss = maxHealth - OUTPOST_GUARD_DOWN_AT - if(amount > 0) - if(phase == OUTPOST_GUARD_DOWN || phase == OUTPOST_GUARD_LEAVING || bruteloss >= floor_loss) - return 0 - amount = min(amount, floor_loss - bruteloss) +/mob/living/carbon/human/npc/outpost_prison_guard/npc_on_downed() . = ..() - if(bruteloss >= floor_loss && prison) - INVOKE_ASYNC(src, PROC_REF(go_down)) + go_down() -/// Guards never die: whatever would kill one puts them down instead -/mob/living/basic/outpost_prison_guard/death(gibbed) - if(!gibbed && prison && phase != OUTPOST_GUARD_LEAVING) - go_down() +/// Back out of crit before the medevac came: on their feet and on duty again +/mob/living/carbon/human/npc/outpost_prison_guard/npc_on_recovered() + . = ..() + if(phase != OUTPOST_GUARD_DOWN || died_on_duty || stat == DEAD || HAS_TRAIT(src, TRAIT_CRITICAL_CONDITION)) return - return ..() + phase = OUTPOST_GUARD_PRESENT + down_left = 0 + down_since = 0 + set_guard_upright(TRUE) + prison?.add_log("[real_name] is back on [p_their()] feet.") + +/// The prison's guards speak from their own file (say_guard()); a few of tg's changes map onto their lines. +/mob/living/carbon/human/npc/outpost_prison_guard/npc_bark(kind, force = FALSE) + switch(kind) + if(HUMAN_NPC_BARK_DOWNED) + return say_guard("downed") + return FALSE + +/mob/living/carbon/human/npc/outpost_prison_guard/death(gibbed) + var/was_alive = stat != DEAD + . = ..() + if(!was_alive || stat != DEAD) + return + died_on_duty = TRUE + set_guard_upright(FALSE) + if(phase == OUTPOST_GUARD_LEAVING || !prison) + return + end_response() + end_activity() + baton_out = FALSE + phase = OUTPOST_GUARD_DOWN + down_since = world.time + down_left = OUTPOST_GUARD_BODY_COLLECT_DELAY / (1 SECONDS) + prison.guard_killed(src) /** - * Down: lying there, nothing more can hurt them, and OUTPOST_GUARD_RECALL_DELAY later they are - * beamed out, to come back free OUTPOST_GUARD_RETURN_TIME after that (guards_tick()). + * Down in crit: lying there, and OUTPOST_GUARD_RECALL_DELAY later the corrections service medevacs the + * body, to send them back OUTPOST_GUARD_RETURN_TIME after that (guards_tick()). Nothing protects them + * meanwhile: they can bleed out, or be finished off. */ -/mob/living/basic/outpost_prison_guard/proc/go_down() +/mob/living/carbon/human/npc/outpost_prison_guard/proc/go_down() if(QDELETED(src) || phase == OUTPOST_GUARD_DOWN || phase == OUTPOST_GUARD_LEAVING) return FALSE var/was_leaving = phase == OUTPOST_GUARD_DISMISSED phase = OUTPOST_GUARD_DOWN end_response() end_activity() - set_baton(FALSE) - ADD_TRAIT(src, TRAIT_GODMODE, OUTPOST_GUARD_DOWN_TRAIT) - add_traits(list(TRAIT_FLOORED, TRAIT_IMMOBILIZED, TRAIT_INCAPACITATED), OUTPOST_GUARD_DOWN_TRAIT) + baton_out = FALSE + set_guard_upright(FALSE) + down_since = world.time down_left = was_leaving ? 0 : OUTPOST_GUARD_RECALL_DELAY / (1 SECONDS) visible_message(span_danger("[src] goes down!")) - say_guard("downed") prison?.add_log("[real_name] went down.") return TRUE /// Someone took a swing at them. Prisoners are the dispatcher's business; anyone else gets a warning and some room. -/mob/living/basic/outpost_prison_guard/proc/on_attacked(datum/source, atom/attacker, attack_flags) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/on_attacked(datum/source, atom/attacker, attack_flags) SIGNAL_HANDLER if(!(attack_flags & (ATTACKER_DAMAGING_ATTACK | ATTACKER_STAMINA_ATTACK | ATTACKER_SHOVING))) return @@ -260,7 +289,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" INVOKE_ASYNC(src, PROC_REF(warn_off), attacker) /// "Hey. Don't." and a step back. Guards never strike players. -/mob/living/basic/outpost_prison_guard/proc/warn_off(atom/attacker) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/warn_off(atom/attacker) if(!on_duty() || QDELETED(attacker)) return FALSE if(!COOLDOWN_FINISHED(src, warned_cooldown)) @@ -273,12 +302,6 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" log_combat(attacker, src, "attacked a prison guard") return TRUE -/// Healing slowly while nothing is going on -/mob/living/basic/outpost_prison_guard/proc/heal_tick(seconds) - if(phase != OUTPOST_GUARD_PRESENT || bruteloss <= 0 || prison?.riot_active) - return - adjust_health(-OUTPOST_GUARD_HEAL_PER_MINUTE * seconds / 60) - // ===== BEAMING IN AND OUT ===== /** @@ -286,7 +309,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" * the whole beam. They stay OUTPOST_GUARD_ARRIVING (held still, no routine, no responses, no * speech) until finish_beam_in() as the beam ends. */ -/mob/living/basic/outpost_prison_guard/proc/beam_in() +/mob/living/carbon/human/npc/outpost_prison_guard/proc/beam_in() phase = OUTPOST_GUARD_ARRIVING ADD_TRAIT(src, TRAIT_IMMOBILIZED, OUTPOST_GUARD_BEAM_TRAIT) var/turf/spot = get_turf(src) @@ -298,7 +321,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" addtimer(CALLBACK(src, PROC_REF(finish_beam_in)), OUTPOST_PRISON_BEAM_TIME) /// Fully there as the beam ends: the flash, and only now are they on duty, and say so -/mob/living/basic/outpost_prison_guard/proc/finish_beam_in() +/mob/living/carbon/human/npc/outpost_prison_guard/proc/finish_beam_in() if(phase != OUTPOST_GUARD_ARRIVING) return FALSE var/turf/spot = get_turf(src) @@ -318,7 +341,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" * Dematerialises them and deletes them at the end of the beam. Their record, if they are still on * the payroll, sends them back after `away_seconds` (guards_tick()). */ -/mob/living/basic/outpost_prison_guard/proc/beam_out(away_seconds = 0) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/beam_out(away_seconds = 0) if(phase == OUTPOST_GUARD_LEAVING) return FALSE phase = OUTPOST_GUARD_LEAVING @@ -339,7 +362,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" addtimer(CALLBACK(src, PROC_REF(finish_beam_out)), OUTPOST_PRISON_BEAM_TIME) return TRUE -/mob/living/basic/outpost_prison_guard/proc/finish_beam_out() +/mob/living/carbon/human/npc/outpost_prison_guard/proc/finish_beam_out() var/turf/spot = get_turf(src) if(spot) new /obj/effect/temp_visual/transporter_flash/departure(spot) @@ -348,7 +371,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" qdel(src) /// Called back from somewhere they should not be (off the wing's level, or out of the wing with nobody about) -/mob/living/basic/outpost_prison_guard/proc/recall(away_seconds = OUTPOST_GUARD_OFF_LEVEL_AWAY) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/recall(away_seconds = OUTPOST_GUARD_OFF_LEVEL_AWAY) if(phase != OUTPOST_GUARD_PRESENT) return FALSE say_guard("recalled") @@ -359,7 +382,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" * Off the payroll: they say `context`, walk back to the office and beam out there, or wherever * they are after OUTPOST_GUARD_DISMISS_WALK seconds. Down or arriving, they beam out at once. */ -/mob/living/basic/outpost_prison_guard/proc/leave(context = "dismissed") +/mob/living/carbon/human/npc/outpost_prison_guard/proc/leave(context = "dismissed") if(phase == OUTPOST_GUARD_LEAVING || phase == OUTPOST_GUARD_DISMISSED) return FALSE if(phase != OUTPOST_GUARD_PRESENT || stat != CONSCIOUS) @@ -368,7 +391,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" end_response() end_activity() set_baton(FALSE) - set_varspeed(OUTPOST_GUARD_SPEED_WALK) + set_prison_pace(hurry = FALSE) say_guard(context) dismiss_left = OUTPOST_GUARD_DISMISS_WALK leave_spot = prison?.guard_office_spot(src) @@ -377,7 +400,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" // ===== SPEECH ===== /// A line for `context` in their personality (or anyone's), with `values` filled in, or null -/mob/living/basic/outpost_prison_guard/proc/pick_guard_line(context, list/values) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/pick_guard_line(context, list/values) var/list/guard_lines = outpost_guard_dialogue("guard_lines") var/list/by_personality = guard_lines[context] if(!islist(by_personality)) @@ -396,7 +419,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" return line /// The lines of `pool` that are not the last thing they said and need no placeholder `values` lacks -/mob/living/basic/outpost_prison_guard/proc/usable_guard_lines(list/pool, list/values) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/usable_guard_lines(list/pool, list/values) var/list/usable = list() for(var/line in pool) if(!istext(line) || line == last_line) @@ -411,7 +434,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" return usable /// Says a line for `context`. Returns TRUE if they said something. Never while beaming in or out, invisible or half there. -/mob/living/basic/outpost_prison_guard/proc/say_guard(context, list/values) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/say_guard(context, list/values) if(QDELETED(src) || stat == DEAD || phase == OUTPOST_GUARD_ARRIVING || phase == OUTPOST_GUARD_LEAVING) return FALSE var/line = pick_guard_line(context, values) @@ -422,7 +445,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" return TRUE /// An idle line: waits for the wing to be quiet and for their own pause, and counts toward the wing's -/mob/living/basic/outpost_prison_guard/proc/idle_say(context, list/values) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/idle_say(context, list/values) if(!prison?.wing_can_speak() || !COOLDOWN_FINISHED(src, speech_cooldown)) return FALSE if(!say_guard(context, values)) @@ -438,7 +461,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" * and making violent trouble right now (rioting, breaking out, fighting with blows, swinging at * someone or having just struck someone, climbing out, or loose). Never a calm or downed prisoner. */ -/mob/living/basic/outpost_prison_guard/proc/may_strike(mob/living/basic/outpost_prisoner/prisoner) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/may_strike(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(!on_duty() || !is_outpost_prisoner(prisoner) || QDELETED(prisoner) || !prison || prisoner.prison != prison) return FALSE if(prisoner.stat != CONSCIOUS || prisoner.phase != PRISONER_PRESENT || prisoner.can_be_dragged() || !Adjacent(prisoner)) @@ -451,29 +474,47 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" return prisoner.guard_struck_recently() /** - * One stun baton strike: OUTPOST_GUARD_BATON_STAMINA stamina, their blows stop, and every prisoner - * who sees it loses a little mood. Not an attack in tg's sense (no relay_attackers, no - * hit_by_staff()), so it is never held against staff and never hurts. Returns TRUE if it landed. + * One strike with the real stun baton off their belt, through their own hands: tg's baton does its + * stamina damage and knockdown, against the prisoner's armour, off the cell's charge. Their blows stop, + * and every prisoner who sees it loses a little mood. A prisoner never holds a guard's blow against staff + * (hit_by_staff()). Returns TRUE if they swung. */ -/mob/living/basic/outpost_prison_guard/proc/strike(mob/living/basic/outpost_prisoner/prisoner) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/strike(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(!COOLDOWN_FINISHED(src, baton_cooldown) || !may_strike(prisoner)) return FALSE - COOLDOWN_START(src, baton_cooldown, OUTPOST_GUARD_BATON_COOLDOWN) + var/obj/item/melee/baton/security/baton = get_baton() + // A flat cell would make it a club, and guards never hurt anyone: they go to change it (baton_flat()). + if(!baton || !baton.cell || baton.cell.charge < baton.cell_hit_cost) + baton_flat() + return FALSE set_baton(TRUE) - face_atom(prisoner) - do_attack_animation(prisoner) - playsound(prisoner, 'sound/items/weapons/egloves.ogg', 50, TRUE) - prisoner.visible_message(span_danger("[src] strikes [prisoner] with a stun baton!"), span_userdanger("[src] strikes you with a stun baton!")) - prisoner.apply_damage(OUTPOST_GUARD_BATON_STAMINA, STAMINA) + // The baton recharges between stuns, as anyone's does. + if(!is_holding(baton) || !baton.active || !COOLDOWN_FINISHED(baton, cooldown_check)) + return FALSE + COOLDOWN_START(src, baton_cooldown, OUTPOST_GUARD_BATON_COOLDOWN) + if(!outpost_prison_npc_hit(src, prisoner, baton)) + return FALSE prisoner.stop_blows() prison.guard_strike_seen(prisoner, src) return TRUE +/** + * Their baton's cell is flat. The office recharger can't take a baton that is locked to its guard + * (human_npc_gear.dm), so the corrections service swaps the shift: they say so and beam out, and the + * record sends them back with a charged baton after OUTPOST_GUARD_SHIFT_SWAP_TIME. Their wages stop meanwhile. + */ +/mob/living/carbon/human/npc/outpost_prison_guard/proc/baton_flat() + if(phase != OUTPOST_GUARD_PRESENT || !prison) + return FALSE + say_guard("recalled") + prison.add_log("[real_name]'s baton went flat. [p_They()] went to swap shifts.") + return beam_out(OUTPOST_GUARD_SHIFT_SWAP_TIME / (1 SECONDS)) + /// Strikes a rioter beside them. Returns TRUE if they struck. -/mob/living/basic/outpost_prison_guard/proc/strike_adjacent_rioter() +/mob/living/carbon/human/npc/outpost_prison_guard/proc/strike_adjacent_rioter() if(!COOLDOWN_FINISHED(src, baton_cooldown)) return FALSE - for(var/mob/living/basic/outpost_prisoner/rioter in orange(1, src)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/rioter in orange(1, src)) if(rioter.is_rioting() && strike(rioter)) return TRUE return FALSE @@ -481,29 +522,29 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" // ===== RESPONSES ===== /// Sends them to deal with something, dropping their routine -/mob/living/basic/outpost_prison_guard/proc/give_response(kind, priority, key, atom/target, turf/spot) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/give_response(kind, priority, key, atom/target, turf/spot) end_response(cancel_ai = FALSE) end_activity(cancel_ai = FALSE) response = new(kind, key, priority, target, spot) response.expires_at = world.time + OUTPOST_GUARD_RESPONSE_TIMEOUT - set_varspeed(OUTPOST_GUARD_SPEED_HURRY) + set_prison_pace(hurry = TRUE) set_baton(TRUE) ai_controller?.CancelActions() return response /// Back to routine -/mob/living/basic/outpost_prison_guard/proc/end_response(cancel_ai = TRUE) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/end_response(cancel_ai = TRUE) if(!response) return QDEL_NULL(response) if(!QDELETED(src)) - set_varspeed(OUTPOST_GUARD_SPEED_WALK) + set_prison_pace(hurry = FALSE) set_baton(FALSE) if(cancel_ai) ai_controller?.CancelActions() /// Whether they gave up on an incident recently -/mob/living/basic/outpost_prison_guard/proc/skipping(key) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/skipping(key) return LAZYACCESS(response_skips, key) > world.time /** @@ -511,7 +552,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" * the AI walks them to) and, once there, acts. Called by the dispatcher every second. Returns * TRUE while the response goes on. */ -/mob/living/basic/outpost_prison_guard/proc/perform_response() +/mob/living/carbon/human/npc/outpost_prison_guard/proc/perform_response() var/datum/outpost_guard_response/job = response if(!job) return FALSE @@ -545,7 +586,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" return TRUE /// Whether they stand where a response wants them: beside a mob, or on a tile -/mob/living/basic/outpost_prison_guard/proc/at_goal(atom/goal) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/at_goal(atom/goal) if(!goal) return TRUE if(isturf(goal)) @@ -557,13 +598,13 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" * it down (the prison's guard_talkdown_chance); once blows fly, "Break it up!", then the baton on * the first fighter every OUTPOST_GUARD_BATON_COOLDOWN until the fight is over. */ -/mob/living/basic/outpost_prison_guard/proc/fight_response(datum/outpost_guard_response/job) - var/mob/living/basic/outpost_prisoner/fighter = job.target() +/mob/living/carbon/human/npc/outpost_prison_guard/proc/fight_response(datum/outpost_guard_response/job) + var/mob/living/carbon/human/npc/outpost_prisoner/fighter = job.target() var/datum/outpost_prison_fight/brawl = fighter?.fight if(QDELETED(brawl)) return TRUE - var/mob/living/basic/outpost_prisoner/other = brawl.opponent_of(fighter) - var/mob/living/basic/outpost_prisoner/beside = Adjacent(fighter) ? fighter : ((other && Adjacent(other)) ? other : null) + var/mob/living/carbon/human/npc/outpost_prisoner/other = brawl.opponent_of(fighter) + var/mob/living/carbon/human/npc/outpost_prisoner/beside = Adjacent(fighter) ? fighter : ((other && Adjacent(other)) ? other : null) if(!beside) job.set_goal(fighter) return FALSE @@ -595,8 +636,8 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" * decided to swing, or struck someone in the last OUTPOST_GUARD_STRUCK_RECENT, gets the baton * after the warning instead, until they stop. */ -/mob/living/basic/outpost_prison_guard/proc/threat_response(datum/outpost_guard_response/job) - var/mob/living/basic/outpost_prisoner/prisoner = job.target() +/mob/living/carbon/human/npc/outpost_prison_guard/proc/threat_response(datum/outpost_guard_response/job) + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = job.target() if(!prisoner || prisoner.stat != CONSCIOUS || prisoner.phase != PRISONER_PRESENT || prisoner.can_be_dragged() || prisoner.trouble) return TRUE var/violent = prisoner.swing_ref || prisoner.guard_struck_recently() @@ -622,8 +663,8 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" return FALSE /// A prisoner climbing over a serving hatch: to the hatch's office side, "Get down off that!", and down they slide -/mob/living/basic/outpost_prison_guard/proc/climb_response(datum/outpost_guard_response/job) - var/mob/living/basic/outpost_prisoner/climber = job.target() +/mob/living/carbon/human/npc/outpost_prison_guard/proc/climb_response(datum/outpost_guard_response/job) + var/mob/living/carbon/human/npc/outpost_prisoner/climber = job.target() var/obj/structure/table/reinforced/prison_hatch/hatch = climber?.climb_ref?.resolve() if(!hatch) return TRUE @@ -647,7 +688,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" * OUTPOST_GUARD_FOLLOW_RANGE of them and go for any rioter at them. Otherwise they hold the staff * door from the office. They baton any rioter beside them whatever they are doing. */ -/mob/living/basic/outpost_prison_guard/proc/riot_response(datum/outpost_guard_response/job) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/riot_response(datum/outpost_guard_response/job) if(!prison.riot_active) return TRUE job.reached = TRUE @@ -657,7 +698,9 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" job.spot = prison.guard_fallback_spot(src) say_guard("fallback") job.set_goal((job.spot && loc != job.spot) ? job.spot : null) - strike_adjacent_rioter() + if(!strike_adjacent_rioter() && (!job.spot || loc == job.spot)) + // Back in the corner, they patch themselves up from the office's first-aid kit (outpost_prison_guard_routine.dm). + INVOKE_ASYNC(src, PROC_REF(treat_self)) return FALSE var/mob/living/member = prison.guard_member_in_cell_block() if(member) @@ -665,7 +708,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" job.mode = "follow" job.spot = null say_guard("follow_member", list("{boss}" = prison.guard_boss_name(member))) - var/mob/living/basic/outpost_prisoner/attacker = prison.rioter_beside(member) + var/mob/living/carbon/human/npc/outpost_prisoner/attacker = prison.rioter_beside(member) if(attacker && !Adjacent(attacker)) job.set_goal(attacker) else if(get_dist(src, member) > OUTPOST_GUARD_FOLLOW_RANGE) @@ -690,7 +733,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" * cell block that the other guard is not holding, the tiles to its sides first so the doorway * itself stays clear for the crew. Sets it as their response's spot. Returns it, or null. */ -/mob/living/basic/outpost_prison_guard/proc/take_hold_position() +/mob/living/carbon/human/npc/outpost_prison_guard/proc/take_hold_position() if(!prison) return null for(var/turf/spot as anything in prison.guard_hold_spots()) @@ -705,7 +748,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" * it is dead, taken or shut in. They never strike the creatures. The rest of an experiment (the dose, * the incubation, the slug in the vents) is no reason to leave the yard to itself. */ -/mob/living/basic/outpost_prison_guard/proc/shelter_response(datum/outpost_guard_response/job) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/shelter_response(datum/outpost_guard_response/job) if(!prison.creature_out()) return TRUE job.reached = TRUE @@ -715,7 +758,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" return FALSE /// Wandered out of the wing: back to the office -/mob/living/basic/outpost_prison_guard/proc/leash_response(datum/outpost_guard_response/job) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/leash_response(datum/outpost_guard_response/job) if(get_area(src) == prison.wing) outside_seconds = 0 return TRUE @@ -728,14 +771,14 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" // ===== THE PRISONER'S SIDE ===== -/mob/living/basic/outpost_prisoner +/mob/living/carbon/human/npc/outpost_prisoner /// world.time a guard last checked on them, or they last said hello to a guard var/guard_noticed_at = 0 /// world.time they last lost mood seeing a guard's baton var/guard_onlooker_at = 0 /// Whether they struck someone (not another prisoner) in the last OUTPOST_GUARD_STRUCK_RECENT -/mob/living/basic/outpost_prisoner/proc/guard_struck_recently() +/mob/living/carbon/human/npc/outpost_prisoner/proc/guard_struck_recently() return struck_at && world.time - struck_at <= OUTPOST_GUARD_STRUCK_RECENT && !isnull(struck_ref?.resolve()) // ===== THE PAYROLL ===== @@ -744,28 +787,28 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" /datum/outpost_guard_record var/datum/outpost_prison/prison /// The guard on the wing now, if any - var/mob/living/basic/outpost_prison_guard/guard + var/mob/living/carbon/human/npc/outpost_prison_guard/guard /// "Officer" or "Sergeant" var/rank = "Officer" var/surname = "Hale" var/gender = MALE var/personality = "by_the_book" - /// Which face they have (set_outpost_npc_look()) - var/look_number = 1 + /// Their face, saved from the first body sent (outpost_prison_save_look()), so the same person comes back + var/list/look /// An admin's guard: no fee, no wage, not counted against guard_max() var/free = FALSE var/dismissed = FALSE /// Seconds until they are sent back while away (down, recalled); they come only while a member is home var/away_left = 0 /// What the guard is made as (tests use a subtype) - var/guard_type = /mob/living/basic/outpost_prison_guard + var/guard_type = /mob/living/carbon/human/npc/outpost_prison_guard /datum/outpost_guard_record/New(datum/outpost_prison/owner, rank, free = FALSE, guard_type) . = ..() prison = owner src.rank = rank src.free = free - if(ispath(guard_type, /mob/living/basic/outpost_prison_guard)) + if(ispath(guard_type, /mob/living/carbon/human/npc/outpost_prison_guard)) src.guard_type = guard_type gender = pick(MALE, FEMALE) if(length(GLOB.last_names)) @@ -773,7 +816,6 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" var/list/personalities = outpost_guard_dialogue("guard_personalities") if(length(personalities)) personality = pick(personalities) - look_number = random_outpost_npc_look_number() /datum/outpost_guard_record/Destroy() if(guard?.record == src) @@ -789,7 +831,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" /// Seconds before this slot could have a guard on the wing again: the down time and the return, or the time still away /datum/outpost_guard_record/proc/pending_wait() if(guard) - return guard.phase == OUTPOST_GUARD_DOWN ? guard.down_left + OUTPOST_GUARD_RETURN_TIME / (1 SECONDS) : 0 + return guard.phase == OUTPOST_GUARD_DOWN ? max(0, guard.down_left) + OUTPOST_GUARD_RETURN_TIME / (1 SECONDS) : 0 return max(0, away_left) /// What the console calls them: arriving, post, rounds, routine, responding, riot, down or away @@ -816,7 +858,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" /// Every guard on the payroll var/list/datum/outpost_guard_record/guard_records = list() /// Every guard mob of this prison, on the wing or leaving it - var/list/mob/living/basic/outpost_prison_guard/guard_mobs = list() + var/list/mob/living/carbon/human/npc/outpost_prison_guard/guard_mobs = list() /// Seconds each slot still waits for a dismissed guard's return, passed on to the next hire var/list/guard_slot_waits = list() /// Wages earned and not yet charged, in credits, and the seconds into the charging interval @@ -910,8 +952,12 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" var/turf/spot = guard_office_spot() if(!spot) return null + // Nobody is sent into an office with air nobody can breathe; the slot waits for it to be fixed. + if(outpost_prison_unsafe_air(spot.return_air())) + return null var/datum/npc_spawn_context/context = new(outpost, role = "exempt") - var/mob/living/basic/outpost_prison_guard/guard = spawn_npc_in_zone(record.guard_type, spot, context, FALSE) + // One at a time, as they are hired or sent back: no need for the human NPC spawn queue. + var/mob/living/carbon/human/npc/outpost_prison_guard/guard = spawn_npc_in_zone(record.guard_type, spot, context, FALSE) guard.join(src, record) context.finalize() record.away_left = 0 @@ -933,7 +979,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" guard_slot_waits += wait record.dismissed = TRUE guard_records -= record - var/mob/living/basic/outpost_prison_guard/guard = record.guard + var/mob/living/carbon/human/npc/outpost_prison_guard/guard = record.guard record.guard = null if(guard) guard.record = null @@ -967,20 +1013,26 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" record.away_left = max(0, record.away_left - seconds) if(record.away_left <= 0 && home) spawn_guard(record) - for(var/mob/living/basic/outpost_prison_guard/guard in guard_mobs.Copy()) + for(var/mob/living/carbon/human/npc/outpost_prison_guard/guard in guard_mobs.Copy()) if(QDELETED(guard)) continue switch(guard.phase) if(OUTPOST_GUARD_DOWN) guard.down_left -= seconds if(guard.down_left <= 0) - guard.beam_out(OUTPOST_GUARD_RETURN_TIME / (1 SECONDS)) + guard_medevac(guard) if(OUTPOST_GUARD_DISMISSED) guard.dismiss_left -= seconds if(guard.dismiss_left <= 0 || (guard.leave_spot && guard.loc == guard.leave_spot) || !guard.ai_running()) guard.beam_out() if(OUTPOST_GUARD_PRESENT) - guard.heal_tick(seconds) + guard.shake_off_pull() + // Bad air in the wing (a breach, a fire): guards carry no air of their own, so the corrections + // service calls them off it until the office is fit to stand in again (spawn_guard()). + if(guard.stat == CONSCIOUS && outpost_prison_unsafe_air(guard.loc?.return_air())) + guard.say_guard("recalled") + add_log("[guard.real_name] was called off the wing: bad air.") + guard.beam_out(OUTPOST_GUARD_SHIFT_SWAP_TIME / (1 SECONDS)) guard_rounds_tick(seconds) guard_check_clock += seconds if(guard_check_clock >= OUTPOST_GUARD_CHECK_SECONDS) @@ -990,6 +1042,38 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" guard_yard_chatter() dispatch_guards() +/** + * The corrections service takes a downed guard's real body away (a transport: the same beam as + * everyone's, with no heal), or a dead guard's body once it has lain for OUTPOST_GUARD_BODY_COLLECT_DELAY. + * Their wages stopped when they went down (guard_payroll()); their record sends them back after + * OUTPOST_GUARD_RETURN_TIME. The service locks on to its own staff wherever the body is: zipped in a bag, + * shut in a locker, carried off. Otherwise a body stashed out of sight would hold the slot for the rest + * of the round, and lie there for anyone to cut up. + */ +/datum/outpost_prison/proc/guard_medevac(mob/living/carbon/human/npc/outpost_prison_guard/guard) + if(QDELETED(guard) || guard.phase != OUTPOST_GUARD_DOWN) + return FALSE + if(!isturf(guard.loc)) + var/turf/out_of_it = get_turf(guard) + if(isnull(out_of_it)) + return FALSE + guard.forceMove(out_of_it) + guard.pulledby?.stop_pulling() + guard.buckled?.unbuckle_mob(guard, force = TRUE) + add_log(guard.stat == DEAD ? "The corrections service collected [guard.real_name]'s body." : "The corrections service took [guard.real_name] away for treatment.") + return guard.beam_out(OUTPOST_GUARD_RETURN_TIME / (1 SECONDS)) + +/** + * A guard was killed on duty. Logged with whoever last hurt them (the warden's log and the game log), + * and the yard hears of it. The slot waits out the body's collection and the return before anyone is sent. + */ +/datum/outpost_prison/proc/guard_killed(mob/living/carbon/human/npc/outpost_prison_guard/guard) + var/mob/killer = guard.lastattacker ? get_mob_by_ckey(guard.lastattackerckey) : null + add_log("[guard.real_name] was killed on duty.") + log_game("PLAYER OUTPOST PRISON: '[outpost?.name]': guard [guard.real_name] was killed[killer ? " (last hit by [key_name(killer)])" : ""]") + if(killer && !is_member(killer)) + announce("Prison wing: [guard.real_name] was killed on duty.", SHIP_NOTIFY_WARNING) + /** * Wages: OUTPOST_GUARD_WAGE a minute for each hired guard on the wing, only while a member is * home, charged every OUTPOST_PRISON_DEPOSIT_INTERVAL. @@ -1050,7 +1134,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" guard_rounds_left -= seconds if(guard_rounds_left > 0) return - for(var/mob/living/basic/outpost_prison_guard/guard in shuffle(guard_mobs)) + for(var/mob/living/carbon/human/npc/outpost_prison_guard/guard in shuffle(guard_mobs)) if(!guard.on_duty() || !guard.ai_running() || guard.response) continue if(guard.activity && (!guard.activity.interruptible || istype(guard.activity, /datum/outpost_guard_activity/rounds))) @@ -1069,7 +1153,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" */ /datum/outpost_prison/proc/guard_leash_check() var/z = wing_z() - for(var/mob/living/basic/outpost_prison_guard/guard in guard_mobs) + for(var/mob/living/carbon/human/npc/outpost_prison_guard/guard in guard_mobs) if(guard.phase != OUTPOST_GUARD_PRESENT) continue var/turf/here = get_turf(guard) @@ -1101,7 +1185,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" */ /datum/outpost_prison/proc/dispatch_guards() var/list/on_duty = list() - for(var/mob/living/basic/outpost_prison_guard/guard in guard_mobs) + for(var/mob/living/carbon/human/npc/outpost_prison_guard/guard in guard_mobs) if(guard.on_duty() && guard.ai_running()) on_duty += guard if(!riot_active) @@ -1112,7 +1196,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" if(!length(on_duty)) return if(creature_about) - for(var/mob/living/basic/outpost_prison_guard/guard as anything in on_duty) + for(var/mob/living/carbon/human/npc/outpost_prison_guard/guard as anything in on_duty) if(guard.response?.kind == "shelter") continue guard.give_response("shelter", OUTPOST_GUARD_PRIORITY_SHELTER, "shelter", null, guard_office_spot(guard)) @@ -1120,7 +1204,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" guard_shelter_called = TRUE guard.say_guard("creature_flee") else if(riot_active) - for(var/mob/living/basic/outpost_prison_guard/guard as anything in on_duty) + for(var/mob/living/carbon/human/npc/outpost_prison_guard/guard as anything in on_duty) if(guard.response?.kind == "riot") continue guard.give_response("riot", OUTPOST_GUARD_PRIORITY_RIOT, "riot", null, null) @@ -1129,7 +1213,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" assign_guard_incidents(on_duty) guard_stop_spat(on_duty) guard_watch_loose(on_duty) - for(var/mob/living/basic/outpost_prison_guard/guard as anything in on_duty) + for(var/mob/living/carbon/human/npc/outpost_prison_guard/guard as anything in on_duty) guard.perform_response() /** @@ -1139,7 +1223,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" */ /datum/outpost_prison/proc/guard_incidents() var/list/found = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.phase != PRISONER_PRESENT || prisoner.stat != CONSCIOUS || prisoner.can_be_dragged()) continue if(prisoner.climb_ref) @@ -1166,7 +1250,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" for(var/list/incident as anything in guard_incidents()) var/key = incident[1] var/handled = FALSE - for(var/mob/living/basic/outpost_prison_guard/guard as anything in on_duty) + for(var/mob/living/carbon/human/npc/outpost_prison_guard/guard as anything in on_duty) if(guard.response?.key == key) handled = TRUE // A fight's priority rises once blows fly. @@ -1174,15 +1258,15 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" break if(handled) continue - var/mob/living/basic/outpost_prisoner/prisoner = incident[4] + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = incident[4] var/atom/where = prisoner var/turf/spot if(incident[2] == "climb") var/obj/structure/table/reinforced/prison_hatch/hatch = prisoner.climb_ref?.resolve() spot = hatch?.staff_side_turf() where = spot || prisoner - var/mob/living/basic/outpost_prison_guard/best - for(var/mob/living/basic/outpost_prison_guard/guard as anything in on_duty) + var/mob/living/carbon/human/npc/outpost_prison_guard/best + for(var/mob/living/carbon/human/npc/outpost_prison_guard/guard as anything in on_duty) if(guard.response && guard.response.priority >= incident[3]) continue if(guard.skipping(key)) @@ -1195,13 +1279,13 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" /datum/outpost_prison/proc/guard_stop_spat(list/on_duty) if(spat_lines_left <= 0) return FALSE - var/mob/living/basic/outpost_prisoner/one = spat_first_ref?.resolve() - var/mob/living/basic/outpost_prisoner/two = spat_second_ref?.resolve() - for(var/mob/living/basic/outpost_prison_guard/guard as anything in on_duty) + var/mob/living/carbon/human/npc/outpost_prisoner/one = spat_first_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/two = spat_second_ref?.resolve() + for(var/mob/living/carbon/human/npc/outpost_prison_guard/guard as anything in on_duty) if(guard.response) continue var/list/seen = view(OUTPOST_GUARD_SPAT_VIEW, guard) - var/mob/living/basic/outpost_prisoner/speaker = (one && (one in seen)) ? one : ((two && (two in seen)) ? two : null) + var/mob/living/carbon/human/npc/outpost_prisoner/speaker = (one && (one in seen)) ? one : ((two && (two in seen)) ? two : null) if(!speaker) continue guard.face_atom(speaker) @@ -1213,19 +1297,19 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" /// Loose prisoners: one guard calls each one out, once, and any guard they come beside batons them. No chase. /datum/outpost_prison/proc/guard_watch_loose(list/on_duty) var/list/called = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.trouble != PRISONER_TROUBLE_LOOSE || prisoner.phase != PRISONER_PRESENT || prisoner.stat != CONSCIOUS) continue var/key = REF(prisoner) called[key] = TRUE if(!guard_loose_called[key]) // Said aloud, and noted in the warden's log - var/mob/living/basic/outpost_prison_guard/crier = pick(on_duty) + var/mob/living/carbon/human/npc/outpost_prison_guard/crier = pick(on_duty) if(crier.say_guard("loose_call", list("{place}" = get_area_name(prisoner)))) add_log("[crier.real_name]: \"[crier.last_line]\"") if(prisoner.can_be_dragged()) continue - for(var/mob/living/basic/outpost_prison_guard/guard as anything in on_duty) + for(var/mob/living/carbon/human/npc/outpost_prison_guard/guard as anything in on_duty) if(guard.strike(prisoner)) break guard_loose_called = called @@ -1241,18 +1325,18 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" var/list/first_names = list() var/list/full_names = list() var/list/places = list() - for(var/mob/living/basic/outpost_prisoner/runner as anything in runners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/runner as anything in runners) first_names += runner.speech_name() full_names += runner.real_name places |= get_area_name(runner) // Every line says where they were last seen var/list/values = list("{prisoner}" = english_list(first_names), "{place}" = english_list(places)) var/list/on_duty = list() - for(var/mob/living/basic/outpost_prison_guard/guard in guard_mobs) + for(var/mob/living/carbon/human/npc/outpost_prison_guard/guard in guard_mobs) if(guard.on_duty()) on_duty += guard if(length(on_duty)) - var/mob/living/basic/outpost_prison_guard/crier = pick(on_duty) + var/mob/living/carbon/human/npc/outpost_prison_guard/crier = pick(on_duty) if(crier.say_guard("loose_nearly", values)) add_log("[crier.real_name]: \"[crier.last_line]\"") announce("[crier.real_name]: \"[crier.last_line]\"", SHIP_NOTIFY_DANGER) @@ -1261,7 +1345,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" return TRUE /// The riot hold is called out once a riot: said aloud, and noted in the warden's log -/datum/outpost_prison/proc/announce_riot_hold(mob/living/basic/outpost_prison_guard/guard) +/datum/outpost_prison/proc/announce_riot_hold(mob/living/carbon/human/npc/outpost_prison_guard/guard) if(guard_riot_announced) return FALSE guard_riot_announced = TRUE @@ -1271,9 +1355,9 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" return TRUE /// Every prisoner who sees a baton strike loses OUTPOST_GUARD_ONLOOKER_MOOD, at most once per OUTPOST_GUARD_ONLOOKER_GAP each; one may say so -/datum/outpost_prison/proc/guard_strike_seen(mob/living/basic/outpost_prisoner/struck, mob/living/basic/outpost_prison_guard/guard) +/datum/outpost_prison/proc/guard_strike_seen(mob/living/carbon/human/npc/outpost_prisoner/struck, mob/living/carbon/human/npc/outpost_prison_guard/guard) var/list/watchers = list() - for(var/mob/living/basic/outpost_prisoner/onlooker in view(OUTPOST_GUARD_ONLOOKER_RANGE, struck)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/onlooker in view(OUTPOST_GUARD_ONLOOKER_RANGE, struck)) if(onlooker == struck || onlooker.prison != src || onlooker.stat != CONSCIOUS || onlooker.phase != PRISONER_PRESENT) continue if(onlooker.guard_onlooker_at && world.time - onlooker.guard_onlooker_at < OUTPOST_GUARD_ONLOOKER_GAP) @@ -1282,8 +1366,8 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" onlooker.adjust_mood(-OUTPOST_GUARD_ONLOOKER_MOOD) watchers += onlooker if(length(watchers) && prob(50)) - var/mob/living/basic/outpost_prisoner/speaker = pick(watchers) - INVOKE_ASYNC(speaker, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context_with), "guard_batoned", list("{staff}" = guard.real_name)) + var/mob/living/carbon/human/npc/outpost_prisoner/speaker = pick(watchers) + INVOKE_ASYNC(speaker, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context_with), "guard_batoned", list("{staff}" = guard.real_name)) return watchers // ===== MEMBERS, GREETINGS AND REPORTS ===== @@ -1310,7 +1394,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" /// A rioter on their feet beside `member`, if any /datum/outpost_prison/proc/rioter_beside(mob/living/member) - for(var/mob/living/basic/outpost_prisoner/rioter in orange(1, member)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/rioter in orange(1, member)) if(rioter.prison == src && rioter.is_rioting() && rioter.stat == CONSCIOUS && !rioter.can_be_dragged()) return rioter return null @@ -1335,7 +1419,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" var/list/causes = restless_causes() if(length(causes)) return list("report_restless", list("{cause}" = causes[1])) - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(counts_for_tension(prisoner) && ("hurt" in prisoner.bubble_needs())) return list("report_hurt", list("{prisoner}" = prisoner.speech_name())) var/list/dark = conditions_payload()["dark_cells"] @@ -1349,7 +1433,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" if(!length(members)) return for(var/mob/living/member as anything in members) - for(var/mob/living/basic/outpost_prison_guard/guard in guard_mobs) + for(var/mob/living/carbon/human/npc/outpost_prison_guard/guard in guard_mobs) if(!guard.on_duty() || guard.response || get_dist(guard, member) > OUTPOST_GUARD_REPORT_RANGE || !(member in view(OUTPOST_GUARD_REPORT_RANGE, guard))) continue if(guard.greet_member(member)) @@ -1359,7 +1443,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" * Greets `member` if it is time, else reports to them if it is time. Returns TRUE if they said * something. */ -/mob/living/basic/outpost_prison_guard/proc/greet_member(mob/living/member) +/mob/living/carbon/human/npc/outpost_prison_guard/proc/greet_member(mob/living/member) if(!prison || !on_duty()) return FALSE var/key = member.ckey || REF(member) @@ -1390,10 +1474,10 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" /datum/outpost_prison/proc/guard_yard_chatter() if(!wing_can_speak() || !prob(OUTPOST_GUARD_NOTICE_CHANCE)) return FALSE - for(var/mob/living/basic/outpost_prison_guard/guard in shuffle(guard_mobs)) + for(var/mob/living/carbon/human/npc/outpost_prison_guard/guard in shuffle(guard_mobs)) if(!guard.on_duty() || !guard.ai_running()) continue - for(var/mob/living/basic/outpost_prisoner/prisoner in view(OUTPOST_GUARD_NOTICE_RANGE, guard)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in view(OUTPOST_GUARD_NOTICE_RANGE, guard)) if(prisoner.prison != src || !prisoner.ai_running() || !prisoner.routine_allowed() || prisoner.activity?.sleeping) continue if(prisoner.guard_noticed_at && world.time - prisoner.guard_noticed_at < OUTPOST_GUARD_CHECK_ON_GAP) @@ -1431,7 +1515,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" for(var/mob/living/other in tile) if(other != except && other.density) return TRUE - for(var/mob/living/basic/outpost_prison_guard/guard in guard_mobs) + for(var/mob/living/carbon/human/npc/outpost_prison_guard/guard in guard_mobs) if(guard == except) continue if(guard.response?.spot == tile || guard.activity?.goal_turf() == tile) @@ -1547,7 +1631,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" /datum/outpost_prison/proc/guards_admin_payload() var/list/rows = list() for(var/datum/outpost_guard_record/record as anything in guard_records) - var/mob/living/basic/outpost_prison_guard/guard = record.guard + var/mob/living/carbon/human/npc/outpost_prison_guard/guard = record.guard var/status = record.status() if(status == "away" || status == "down") var/back = record.back_in() @@ -1581,10 +1665,11 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" if(action == "prison_guard_remove") dismiss_guard(record, "dismissed", forget_wait = TRUE) return "remove prison guard [guard_name]" - var/mob/living/basic/outpost_prison_guard/guard = record.guard + var/mob/living/carbon/human/npc/outpost_prison_guard/guard = record.guard if(!guard?.on_duty()) return list("error" = "That guard is not on duty.") - guard.adjust_health(guard.health - OUTPOST_GUARD_DOWN_AT) + // Real damage over their limbs, enough to put them in crit; tg's crit does the rest. + guard.take_overall_damage(brute = max(0, guard.health) + 5) if(guard.phase != OUTPOST_GUARD_DOWN) guard.go_down() return "put prison guard [guard_name] down" @@ -1593,7 +1678,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" // ===== LIFE AND DEATH OF THE PRISON ===== /datum/outpost_prison/proc/guards_destroy() - for(var/mob/living/basic/outpost_prison_guard/guard in guard_mobs.Copy()) + for(var/mob/living/carbon/human/npc/outpost_prison_guard/guard in guard_mobs.Copy()) if(QDELETED(guard)) continue guard.prison = null @@ -1611,7 +1696,7 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" /// The outpost was abandoned: every guard is dismissed, no refund, and beams out /datum/outpost_prison/proc/guards_abandon() for(var/datum/outpost_guard_record/record as anything in guard_records.Copy()) - var/mob/living/basic/outpost_prison_guard/guard = record.guard + var/mob/living/carbon/human/npc/outpost_prison_guard/guard = record.guard dismiss_guard(record, "dismissed", forget_wait = TRUE) guard?.beam_out() guard_slot_waits.Cut() @@ -1621,16 +1706,20 @@ GLOBAL_LIST_INIT(outpost_guard_placeholders, list("{boss}", "{count}", "{cause}" // ===== LOOK ===== /** - * A corrections officer: pale blue shirt and tie over navy trousers, a navy peaked police cap, - * black gloves and combat boots, and an earpiece. No red, no orange (that's the inmates), no - * armour; the stun baton is drawn in hand only when they use it (update_overlays()). + * A corrections officer: pale blue shirt and tie over navy trousers, a blue-trimmed vest and helmet, + * black gloves and combat boots, and an earpiece. No red, no orange (that's the inmates). The stun + * baton rides on the belt and is drawn only when they use it (set_baton()); a bruise pack in a pocket + * for their own scrapes. Locked to them (D3): none of it is ever loot. */ /datum/outfit/outpost_prison_guard name = "Outpost prison guard" uniform = /obj/item/clothing/under/rank/security/officer/blueshirt - head = /obj/item/clothing/head/hats/warden/police + suit = /obj/item/clothing/suit/armor/vest/blueshirt + head = /obj/item/clothing/head/helmet/blueshirt gloves = /obj/item/clothing/gloves/color/black shoes = /obj/item/clothing/shoes/jackboots ears = /obj/item/radio/headset + belt = /obj/item/melee/baton/security/loaded + r_pocket = /obj/item/stack/medical/bruise_pack #undef OUTPOST_GUARD_DIALOGUE_FILE diff --git a/voidcrew/modules/player_outposts/outpost_prison_horror.dm b/voidcrew/modules/player_outposts/outpost_prison_horror.dm index 9f977ec2bcc..afcc6265a0e 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_horror.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_horror.dm @@ -736,7 +736,7 @@ if(victim.stat != CONSCIOUS) return TRUE if(is_outpost_prisoner(victim)) - var/mob/living/basic/outpost_prisoner/prisoner = victim + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = victim return prisoner.can_be_dragged() return HAS_TRAIT_FROM(victim, TRAIT_INCAPACITATED, STAMINA) @@ -785,8 +785,8 @@ if(watcher.client) shake_camera(watcher, 3, 1) if(is_outpost_prisoner(victim)) - var/mob/living/basic/outpost_prisoner/prisoner = victim - INVOKE_ASYNC(prisoner, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context), "absorbed") + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = victim + INVOKE_ASYNC(prisoner, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context), "absorbed") addtimer(CALLBACK(src, PROC_REF(absorb_proboscis), serial), OUTPOST_HORROR_ABSORB_PROBOSCIS, TIMER_DELETE_ME) addtimer(CALLBACK(src, PROC_REF(absorb_drained), serial), OUTPOST_HORROR_ABSORB_TIME, TIMER_DELETE_ME) return TRUE @@ -836,16 +836,20 @@ set_busy("digest", OUTPOST_HORROR_DIGEST_TIME) return victim -/// Husked and dead +/// Dead and husked the way tg's changeling absorb leaves its victims: death, then tg's Drain() on a body /mob/living/basic/outpost_experiment/horror/proc/husk(mob/living/victim) victim.remove_atom_colour(TEMPORARY_COLOUR_PRIORITY) - victim.become_husk(CHANGELING_DRAIN) - if(!ishuman(victim)) - // A basic mob has no husk sprite: grey and dried out - victim.add_atom_colour(list(0.35,0.35,0.35,0, 0.35,0.35,0.35,0, 0.35,0.35,0.35,0, 0,0,0,1, -0.05,-0.05,-0.05,0), FIXED_COLOUR_PRIORITY) - victim.blood_volume = 0 if(victim.stat != DEAD) + victim.investigate_log("has died from being absorbed by an outpost prison horror.", INVESTIGATE_DEATHS) victim.death() + if(iscarbon(victim)) + var/mob/living/carbon/body = victim + body.Drain() + return + // A basic mob has no husk sprite: grey and dried out + victim.become_husk(CHANGELING_DRAIN) + victim.add_atom_colour(list(0.35,0.35,0.35,0, 0.35,0.35,0.35,0, 0.35,0.35,0.35,0, 0,0,0,1, -0.05,-0.05,-0.05,0), FIXED_COLOUR_PRIORITY) + victim.blood_volume = 0 /// Admins hear about every non-member it absorbs; the game log gets every absorb /mob/living/basic/outpost_experiment/horror/proc/log_absorb(mob/living/victim) @@ -1049,7 +1053,7 @@ /// Whether a prisoner is shut in a bolted cell, which it leaves for last /mob/living/basic/outpost_experiment/horror/proc/bolted_away(mob/living/target) - var/mob/living/basic/outpost_prisoner/prisoner = target + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = target return istype(prisoner) && prisoner.in_bolted_cell() /** @@ -1133,7 +1137,7 @@ best_distance = distance if(best) return best - for(var/mob/living/basic/outpost_prisoner/prisoner as anything in event?.prison?.prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner as anything in event?.prison?.prisoners) if(!valid_quarry(prisoner) || bolted_away(prisoner)) continue var/distance = get_dist(src, prisoner) diff --git a/voidcrew/modules/player_outposts/outpost_prison_incidents.dm b/voidcrew/modules/player_outposts/outpost_prison_incidents.dm index bf54e8e5320..93a95cd4f00 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_incidents.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_incidents.dm @@ -66,7 +66,7 @@ /// Prisoners who count for wildcards: present, alive, not loose, in the cell block /datum/outpost_prison/proc/wildcard_prisoner_count() var/count = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(counts_for_tension(prisoner) && in_cell_block(prisoner)) count++ return count @@ -146,7 +146,7 @@ /// The kinds and their weights: a stabbing is likelier while someone who could do it has a shiv stashed /datum/outpost_prison/proc/wildcard_kind_weights() var/stab_weight = PRISON_INCIDENT_WEIGHT_STAB - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.cell?.stash_shiv && wildcard_can_act(prisoner)) stab_weight *= PRISON_INCIDENT_STASH_KIND_MULT break @@ -171,7 +171,7 @@ * block, out of trouble and not busy with it, not shut in a cell, owing no lockdown, not an * experiment's subject, and not running from a creature */ -/datum/outpost_prison/proc/wildcard_can_act(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/wildcard_can_act(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(QDELETED(prisoner) || prisoner.prison != src || prisoner.phase != PRISONER_PRESENT || prisoner.stat != CONSCIOUS) return FALSE if(prisoner.in_trouble() || prisoner.can_be_dragged() || prisoner.pulledby || prisoner.experiment_subject || prisoner.lockdown_left > 0 || prisoner.is_panicking()) @@ -181,7 +181,7 @@ return in_cell_block(prisoner) && !prisoner.is_confined() /// Whether `prisoner` can be the one a stabbing is aimed at: as wildcard_can_act(), but asleep will do -/datum/outpost_prison/proc/wildcard_can_be_target(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/wildcard_can_be_target(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(QDELETED(prisoner) || prisoner.prison != src || prisoner.phase != PRISONER_PRESENT || prisoner.stat != CONSCIOUS) return FALSE if(prisoner.in_trouble() || prisoner.can_be_dragged() || prisoner.pulledby || prisoner.experiment_subject) @@ -189,7 +189,7 @@ return in_cell_block(prisoner) && !prisoner.is_confined() /// Whether `one` can walk to where `two` stands -/datum/outpost_prison/proc/wildcard_can_reach(mob/living/basic/outpost_prisoner/one, mob/living/basic/outpost_prisoner/two) +/datum/outpost_prison/proc/wildcard_can_reach(mob/living/carbon/human/npc/outpost_prisoner/one, mob/living/carbon/human/npc/outpost_prisoner/two) if(!one.walkable) refresh_prisoner_reach(one) return !!one.walkable?[get_turf(two)] @@ -218,11 +218,11 @@ var/list/weights = list() var/list/rival_pairs = list() var/list/rival_weights = list() - for(var/mob/living/basic/outpost_prisoner/attacker in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/attacker in prisoners) if(!wildcard_can_act(attacker)) continue var/weight = attacker.cell?.stash_shiv ? PRISON_INCIDENT_STASH_PICK_MULT : 1 - for(var/mob/living/basic/outpost_prisoner/victim in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/victim in prisoners) if(victim == attacker || !wildcard_can_be_target(victim) || !wildcard_can_reach(attacker, victim)) continue if(are_rivals(attacker, victim)) @@ -241,7 +241,7 @@ /datum/outpost_prison/proc/pick_snapper() var/list/options = list() var/list/weights = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(!wildcard_can_act(prisoner) || !prisoner.can_join_riot()) continue options += prisoner @@ -253,15 +253,15 @@ /// Who fights whom: list(one, two), rivals first, or null /datum/outpost_prison/proc/pick_fight_pair() var/list/able = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(wildcard_can_act(prisoner) && !prisoner.fight) able += prisoner var/list/pairs = list() var/list/rival_pairs = list() for(var/first_index in 1 to length(able) - 1) - var/mob/living/basic/outpost_prisoner/one = able[first_index] + var/mob/living/carbon/human/npc/outpost_prisoner/one = able[first_index] for(var/second_index in first_index + 1 to length(able)) - var/mob/living/basic/outpost_prisoner/two = able[second_index] + var/mob/living/carbon/human/npc/outpost_prisoner/two = able[second_index] if(!wildcard_can_reach(one, two)) continue if(are_rivals(one, two)) @@ -289,7 +289,7 @@ /// A snap: the tell, or with `skip_tell` the riot at once. Returns TRUE if it started. /datum/outpost_prison/proc/start_snap(skip_tell = FALSE) - var/mob/living/basic/outpost_prisoner/snapper = pick_snapper() + var/mob/living/carbon/human/npc/outpost_prisoner/snapper = pick_snapper() if(!snapper) return FALSE if(skip_tell) @@ -300,7 +300,7 @@ return TRUE /// `snapper` riots, alone unless others are unhappy enough to join. Returns TRUE if the riot started. -/datum/outpost_prison/proc/snap(mob/living/basic/outpost_prisoner/snapper) +/datum/outpost_prison/proc/snap(mob/living/carbon/human/npc/outpost_prisoner/snapper) if(!snapper?.can_join_riot()) return FALSE if(!start_riot("[snapper.real_name] snapped", forced = snapper, ignore_quiet = TRUE)) @@ -318,27 +318,27 @@ // ===== STOPPING ONE ===== /// Whether `prisoner` is working up to a stabbing or a snap right now -/datum/outpost_prison/proc/wildcard_brooding(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/wildcard_brooding(mob/living/carbon/human/npc/outpost_prisoner/prisoner) return !!prisoner && wildcard?.stage == WILDCARD_TELL && wildcard.actor() == prisoner /// The tell for examine, while `prisoner` works up to a stabbing or a snap; or null -/datum/outpost_prison/proc/wildcard_examine(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/wildcard_examine(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(!wildcard_brooding(prisoner)) return null if(wildcard.kind != "stab") return "Paces and mutters, fists clenched." - var/mob/living/basic/outpost_prisoner/target = wildcard.target() + var/mob/living/carbon/human/npc/outpost_prisoner/target = wildcard.target() var/stare = target ? "Keeps staring at [target.speech_name()]" : "Keeps staring at someone" return wildcard.last_tell_shown ? "[stare], one hand under [prisoner.p_their()] shirt." : "[stare]." /// A member talked `prisoner` down (talk_down()): a tell under way is called off. Returns TRUE if one was. -/datum/outpost_prison/proc/wildcard_talked_down(mob/living/basic/outpost_prisoner/prisoner, mob/living/user) +/datum/outpost_prison/proc/wildcard_talked_down(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/user) if(!wildcard_brooding(prisoner)) return FALSE return wildcard.stopped_by_staff(user, "talk") /// Staff batoned `prisoner` (a signal handler's call: nothing here sleeps): a tell under way is called off -/datum/outpost_prison/proc/wildcard_batoned(mob/living/basic/outpost_prisoner/prisoner, mob/living/user) +/datum/outpost_prison/proc/wildcard_batoned(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/user) if(!wildcard_brooding(prisoner)) return FALSE return wildcard.stopped_by_staff(user, "baton") @@ -346,7 +346,7 @@ // ===== COMINGS AND GOINGS ===== /// A prisoner is leaving the roster: a wildcard they are part of ends, and a stabber drops the shiv -/datum/outpost_prison/proc/wildcard_prisoner_leaving(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/wildcard_prisoner_leaving(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(!wildcard || (wildcard.actor() != prisoner && wildcard.target() != prisoner)) return if(wildcard.stage == WILDCARD_ATTACK && wildcard.actor() != prisoner) @@ -360,8 +360,8 @@ /// The admin panel's wildcard numbers, with the wing events' (outpost_prison_wing_events.dm) /datum/outpost_prison/proc/incidents_admin_payload() - var/mob/living/basic/outpost_prisoner/actor = wildcard?.actor() - var/mob/living/basic/outpost_prisoner/target = wildcard?.target() + var/mob/living/carbon/human/npc/outpost_prisoner/actor = wildcard?.actor() + var/mob/living/carbon/human/npc/outpost_prisoner/target = wildcard?.target() return list( "chance" = round(outpost_prison_wildcard_chance(tension), 0.1), "gap_left" = round(wildcard_gap_left), @@ -397,7 +397,7 @@ /// A stabbing's fight var/datum/weakref/fight_ref -/datum/outpost_prison_wildcard/New(datum/outpost_prison/owner, kind, mob/living/basic/outpost_prisoner/actor, mob/living/basic/outpost_prisoner/target) +/datum/outpost_prison_wildcard/New(datum/outpost_prison/owner, kind, mob/living/carbon/human/npc/outpost_prisoner/actor, mob/living/carbon/human/npc/outpost_prisoner/target) . = ..() prison = owner src.kind = kind @@ -406,7 +406,7 @@ tell_left = rand(PRISON_INCIDENT_TELL_MIN, PRISON_INCIDENT_TELL_MAX) /datum/outpost_prison_wildcard/Destroy() - var/mob/living/basic/outpost_prisoner/actor = actor() + var/mob/living/carbon/human/npc/outpost_prisoner/actor = actor() if(actor && is_tell_activity(actor.activity)) actor.end_activity() if(prison?.wildcard == src) @@ -425,13 +425,13 @@ return istype(activity, /datum/prisoner_activity/wildcard_shadow) || istype(activity, /datum/prisoner_activity/pace/wildcard) /// Whether a stabbing's victim is still there to go for -/datum/outpost_prison_wildcard/proc/target_ok(mob/living/basic/outpost_prisoner/target) +/datum/outpost_prison_wildcard/proc/target_ok(mob/living/carbon/human/npc/outpost_prisoner/target) return !QDELETED(target) && target.prison == prison && (target in prison.prisoners) && target.phase == PRISONER_PRESENT && target.stat != DEAD && target.trouble != PRISONER_TROUBLE_LOOSE && !target.is_rioting() /// The tell begins: a stare and the shadowing, or the pacing /datum/outpost_prison_wildcard/proc/begin_tell() - var/mob/living/basic/outpost_prisoner/actor = actor() - var/mob/living/basic/outpost_prisoner/target = target() + var/mob/living/carbon/human/npc/outpost_prisoner/actor = actor() + var/mob/living/carbon/human/npc/outpost_prisoner/target = target() if(!actor) return actor.end_activity() @@ -445,7 +445,7 @@ log_game("PLAYER OUTPOST PRISON: [actor.real_name] is working up to [kind == "stab" ? "stabbing [target?.real_name]" : "snapping"] at '[prison?.outpost?.name]'") /// Starts the tell's activity again if something ended it -/datum/outpost_prison_wildcard/proc/restart_activity(mob/living/basic/outpost_prisoner/actor) +/datum/outpost_prison_wildcard/proc/restart_activity(mob/living/carbon/human/npc/outpost_prisoner/actor) if(is_tell_activity(actor.activity) || !actor.routine_allowed()) return var/datum/prisoner_activity/tell_activity @@ -460,8 +460,8 @@ /// Advances the tell, or watches the attack until its fight is over /datum/outpost_prison_wildcard/proc/tick(seconds) - var/mob/living/basic/outpost_prisoner/actor = actor() - var/mob/living/basic/outpost_prisoner/target = target() + var/mob/living/carbon/human/npc/outpost_prisoner/actor = actor() + var/mob/living/carbon/human/npc/outpost_prisoner/target = target() if(stage == WILDCARD_ATTACK) var/datum/outpost_prison_fight/brawl = fight_ref?.resolve() if(!QDELETED(brawl) && actor?.fight == brawl) @@ -504,7 +504,7 @@ qdel(src) /// A stabbing's tell: the stare, a mutter, the hand under the shirt -/datum/outpost_prison_wildcard/proc/tell_stab(mob/living/basic/outpost_prisoner/actor, mob/living/basic/outpost_prisoner/target) +/datum/outpost_prison_wildcard/proc/tell_stab(mob/living/carbon/human/npc/outpost_prisoner/actor, mob/living/carbon/human/npc/outpost_prisoner/target) var/in_sight = (target in view(7, actor)) if(in_sight) actor.face_atom(target) @@ -516,7 +516,7 @@ actor.manual_emote("slips a hand under [actor.p_their()] shirt.") /// A snap's tell: muttering, a blow at the wall, then shouting -/datum/outpost_prison_wildcard/proc/tell_snap(mob/living/basic/outpost_prisoner/actor) +/datum/outpost_prison_wildcard/proc/tell_snap(mob/living/carbon/human/npc/outpost_prisoner/actor) if(!muttered && tell_elapsed >= PRISON_INCIDENT_MUTTER_AT) muttered = TRUE actor.say_context("incident_pacing") @@ -543,8 +543,8 @@ * victim, a fight past its argument. Returns TRUE if it started. */ /datum/outpost_prison_wildcard/proc/strike() - var/mob/living/basic/outpost_prisoner/actor = actor() - var/mob/living/basic/outpost_prisoner/target = target() + var/mob/living/carbon/human/npc/outpost_prisoner/actor = actor() + var/mob/living/carbon/human/npc/outpost_prisoner/target = target() // Nobody goes for a prisoner who is already down, or busy fighting someone else. if(QDELETED(actor) || actor.stat != CONSCIOUS || actor.trouble || actor.can_be_dragged() || !target_ok(target) || target.stat != CONSCIOUS || target.can_be_dragged() || target.fight) return FALSE @@ -553,9 +553,9 @@ if(is_tell_activity(actor.activity)) actor.end_activity() actor.stand_up() - if(!prison.draw_stashed_shiv(actor)) - actor.draw_shiv() - actor.manual_emote("pulls a shiv out from under [actor.p_their()] shirt!") + // A stabbing needs a blade: one stashed in their cell, or one they already carry. Nothing comes from nowhere. + if(!actor.has_shiv() && !prison.draw_stashed_shiv(actor)) + return FALSE var/datum/outpost_prison_fight/brawl = prison.start_fight(actor, target, "stab") if(!brawl) put_away_shiv(actor) @@ -570,13 +570,13 @@ return TRUE /// After a stabbing, the attacker lets go of the shiv, unless they are rioting or loose with it -/datum/outpost_prison_wildcard/proc/put_away_shiv(mob/living/basic/outpost_prisoner/actor) +/datum/outpost_prison_wildcard/proc/put_away_shiv(mob/living/carbon/human/npc/outpost_prisoner/actor) if(QDELETED(actor) || !actor.has_shiv() || actor.is_rioting() || actor.trouble == PRISONER_TROUBLE_LOOSE) return actor.drop_shiv() /// It came to nothing (the victim out of reach, the snapper shut in): they think better of it -/datum/outpost_prison_wildcard/proc/give_up(mob/living/basic/outpost_prisoner/actor) +/datum/outpost_prison_wildcard/proc/give_up(mob/living/carbon/human/npc/outpost_prisoner/actor) if(!QDELETED(actor) && actor.stat == CONSCIOUS) actor.say_context("incident_stopped") qdel(src) @@ -589,8 +589,8 @@ /datum/outpost_prison_wildcard/proc/stopped_by_staff(mob/living/user, how) if(stage != WILDCARD_TELL) return FALSE - var/mob/living/basic/outpost_prisoner/actor = actor() - var/mob/living/basic/outpost_prisoner/target = target() + var/mob/living/carbon/human/npc/outpost_prisoner/actor = actor() + var/mob/living/carbon/human/npc/outpost_prisoner/target = target() if(actor) actor.note_trouble_ended() var/what = kind == "stab" ? "went for [target?.real_name || "someone"]" : "snapped" @@ -599,7 +599,7 @@ prison?.add_log("[user?.name || "Someone"] talked [who] down before [actor.p_they()] [what].") else prison?.add_log(user ? "[user.name] stopped [who] before [actor.p_they()] [what]." : "[who] was stopped before [actor.p_they()] [what].") - INVOKE_ASYNC(actor, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context), "incident_stopped") + INVOKE_ASYNC(actor, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context), "incident_stopped") qdel(src) return TRUE @@ -613,7 +613,7 @@ interruptible = FALSE var/datum/weakref/target_ref -/datum/prisoner_activity/wildcard_shadow/New(mob/living/basic/outpost_prisoner/doer, mob/living/basic/outpost_prisoner/target) +/datum/prisoner_activity/wildcard_shadow/New(mob/living/carbon/human/npc/outpost_prisoner/doer, mob/living/carbon/human/npc/outpost_prisoner/target) . = ..() target_ref = target ? WEAKREF(target) : null diff --git a/voidcrew/modules/player_outposts/outpost_prison_leads.dm b/voidcrew/modules/player_outposts/outpost_prison_leads.dm index 2a77d84b737..ab38f2fd799 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_leads.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_leads.dm @@ -32,7 +32,7 @@ /// Lies given anywhere this round, so every lie's waypoint key is unique on any ship's helm GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) -/mob/living/basic/outpost_prisoner +/mob/living/carbon/human/npc/outpost_prisoner /// Knows where something is, until they tell it (leads_prisoner_admitted()) var/carries_lead = FALSE /// A member is putting a question about leads to them right now @@ -83,11 +83,11 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) // ===== CARRIERS ===== /// A prisoner was booked in: some carry a lead -/datum/outpost_prison/proc/leads_prisoner_admitted(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/leads_prisoner_admitted(mob/living/carbon/human/npc/outpost_prisoner/prisoner) prisoner.carries_lead = prob(OUTPOST_PRISON_LEAD_CHANCE) /// Their tips stay on the helms and in the tracking by name; a liar who has gone never owns up -/datum/outpost_prison/proc/leads_prisoner_leaving(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/leads_prisoner_leaving(mob/living/carbon/human/npc/outpost_prisoner/prisoner) prisoner.carries_lead = FALSE /// Whether the wing's gap between leads is over @@ -100,7 +100,7 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) return !!lead_test_roll return prob(chance) -/datum/outpost_prison/proc/lead_member_in_view(mob/living/basic/outpost_prisoner/prisoner, range) +/datum/outpost_prison/proc/lead_member_in_view(mob/living/carbon/human/npc/outpost_prisoner/prisoner, range) for(var/mob/living/person in view(range, prisoner)) if(person.stat == CONSCIOUS && is_member(person)) return TRUE @@ -109,7 +109,7 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) // ===== SPEECH AND EXAMINE ===== /// A carrier hints at what they know, while the wing is ready to give a lead and a member is near -/datum/outpost_prison/proc/leads_extra_speech(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/leads_extra_speech(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(!prisoner.carries_lead || !lead_ready()) return null if(!lead_member_in_view(prisoner, OUTPOST_PRISON_LEAD_HINT_RANGE) || !lead_roll(OUTPOST_PRISON_LEAD_HINT_CHANCE)) @@ -117,13 +117,13 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) return list("lead_hint", null) /// Nothing: mood (XB's examine) and the tells as they answer are what there is to read -/datum/outpost_prison/proc/leads_examine(mob/living/basic/outpost_prisoner/prisoner, mob/user) +/datum/outpost_prison/proc/leads_examine(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/user) return null // ===== THE TALK MENU ===== /// "Heard anything?" on every prisoner, and "About that tip" on those who saw a recent one given; members only -/datum/outpost_prison/proc/leads_talk_choices(mob/living/basic/outpost_prisoner/prisoner, mob/living/user) +/datum/outpost_prison/proc/leads_talk_choices(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/user) var/list/choices = list() if(!prisoner || !user || !is_member(user)) return choices @@ -133,7 +133,7 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) return choices /// Runs a talk menu choice of this package; TRUE if it was one. May sleep. -/datum/outpost_prison/proc/leads_talk_act(mob/living/basic/outpost_prisoner/prisoner, mob/living/user, choice) +/datum/outpost_prison/proc/leads_talk_act(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/user, choice) if(choice == LEAD_ASK_CHOICE) lead_ask(prisoner, user) return TRUE @@ -147,12 +147,12 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) return FALSE /// The newest tip `prisoner` can be asked about (lead_vouchable()), or null -/datum/outpost_prison/proc/lead_newest_vouchable(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/lead_newest_vouchable(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/list/vouchable = lead_vouchable(prisoner) return length(vouchable) ? vouchable[length(vouchable)] : null /// Open leads `prisoner` saw given, recent enough to ask about, that they did not give and have not answered for -/datum/outpost_prison/proc/lead_vouchable(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/lead_vouchable(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/list/found = list() var/datum/weakref/prisoner_ref = WEAKREF(prisoner) for(var/datum/outpost_prison_lead/lead as anything in open_leads) @@ -164,14 +164,14 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) return found /// Whether `user` may put a question to `prisoner` now; shows or says why not -/datum/outpost_prison/proc/lead_can_ask(mob/living/basic/outpost_prisoner/prisoner, mob/living/user) +/datum/outpost_prison/proc/lead_can_ask(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/user) if(QDELETED(prisoner) || QDELETED(user) || prisoner.prison != src || prisoner.phase != PRISONER_PRESENT || prisoner.stat != CONSCIOUS) return FALSE if(!is_member(user)) prisoner.balloon_alert(user, "not your prisoner") return FALSE // Not talking: the talk menu may hold that while it hands this question over. - if(prisoner.lead_questioned || prisoner.trouble || prisoner.fight || prisoner.threat_ref || prisoner.swing_ref || prisoner.climb_ref || prisoner.beaten_left > 0) + if(prisoner.lead_questioned || prisoner.trouble || prisoner.fight || prisoner.threat_ref || prisoner.swing_ref || prisoner.climb_ref || prisoner.is_beaten()) prisoner.balloon_alert(user, "they're busy") return FALSE if(!prisoner.will_listen()) @@ -182,7 +182,7 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) return TRUE /// A few seconds face to face, as a talk-down takes; FALSE if it was cut short or they stopped listening -/datum/outpost_prison/proc/lead_face_to_face(mob/living/basic/outpost_prisoner/prisoner, mob/living/user, self_message) +/datum/outpost_prison/proc/lead_face_to_face(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/user, self_message) prisoner.lead_questioned = TRUE // Put back as found: the talk menu may already hold it and clear it itself. var/was_talking = prisoner.talking @@ -204,7 +204,7 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) return TRUE /// "Heard anything?": the checks and the talk, then give_lead() for the asker's ship -/datum/outpost_prison/proc/lead_ask(mob/living/basic/outpost_prisoner/prisoner, mob/living/user) +/datum/outpost_prison/proc/lead_ask(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/user) if(!lead_can_ask(prisoner, user)) return FALSE if(!get_crew_ship(user)) @@ -226,7 +226,7 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) return TRUE /// "About that tip": the checks and the talk, then lead_vouch() -/datum/outpost_prison/proc/lead_ask_about(mob/living/basic/outpost_prisoner/prisoner, mob/living/user, datum/outpost_prison_lead/lead) +/datum/outpost_prison/proc/lead_ask_about(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/user, datum/outpost_prison_lead/lead) if(!lead_can_ask(prisoner, user)) return FALSE if(!(lead in lead_vouchable(prisoner))) @@ -240,7 +240,7 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) // ===== GIVING A LEAD ===== /// Whether `asker` hit `prisoner` unprovoked in the last OUTPOST_PRISON_LEAD_HIT_MEMORY -/datum/outpost_prison/proc/lead_hit_by(mob/living/basic/outpost_prisoner/prisoner, mob/asker) +/datum/outpost_prison/proc/lead_hit_by(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/asker) if(prisoner.last_hit_justified || !prisoner.last_staff_hit) return FALSE if(world.time - prisoner.last_staff_hit > OUTPOST_PRISON_LEAD_HIT_MEMORY) @@ -248,7 +248,7 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) return prisoner.last_staff_attacker_ref?.resolve() == asker /// Percent chance `prisoner` lies to `asker`: none when content, then by mood, the asker's name in the yard and personality -/datum/outpost_prison/proc/lead_lie_chance(mob/living/basic/outpost_prisoner/prisoner, mob/asker) +/datum/outpost_prison/proc/lead_lie_chance(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/asker) if(prisoner.mood >= OUTPOST_PRISON_LEAD_TRUE_MOOD) return 0 var/chance = prisoner.mood < OUTPOST_PRISON_LEAD_HOSTILE_MOOD ? OUTPOST_PRISON_LEAD_LIE_HOSTILE : OUTPOST_PRISON_LEAD_LIE_UNEASY @@ -272,7 +272,7 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) * lead_lie_chance(), which `force_lie` (tests) decides instead. Returns "invalid", "refuse_hit", * "refuse", "none", "nothing", "truth" or "lie". */ -/datum/outpost_prison/proc/give_lead(mob/living/basic/outpost_prisoner/prisoner, obj/structure/overmap/ship/ship, mob/living/asker, force_lie = null) +/datum/outpost_prison/proc/give_lead(mob/living/carbon/human/npc/outpost_prisoner/prisoner, obj/structure/overmap/ship/ship, mob/living/asker, force_lie = null) if(QDELETED(prisoner) || prisoner.prison != src || prisoner.phase != PRISONER_PRESENT || prisoner.stat != CONSCIOUS) return "invalid" if(QDELETED(ship) || QDELETED(asker)) @@ -326,7 +326,7 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) lead.ship_ref = WEAKREF(ship) lead.ship_name = ship.name lead.given_at = world.time - for(var/mob/living/basic/outpost_prisoner/other in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/other in prisoners) if(other != prisoner && other.phase == PRISONER_PRESENT) lead.witnesses += WEAKREF(other) @@ -347,7 +347,7 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) return lead.lie ? "lie" : "truth" /// A tell as they answer: an emote from the dialogue file's "tells", their personality's more often than the shared ones -/datum/outpost_prison/proc/lead_tell_emote(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/lead_tell_emote(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/list/tells = outpost_prisoner_extra_dialogue(LEAD_DIALOGUE_FILE, "tells") var/list/own = prisoner.personality ? tells[prisoner.personality] : null var/list/shared = tells["any"] @@ -477,13 +477,13 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) var/datum/outpost_prison_lead/lead = lead_ref?.resolve() if(!lead || !(lead in open_leads)) return FALSE - var/mob/living/basic/outpost_prisoner/teller = lead.teller_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/teller = lead.teller_ref?.resolve() var/mob/living/asker = lead.asker_ref?.resolve() if(QDELETED(teller) || QDELETED(asker) || teller.prison != src) return FALSE if(!lead_roll(OUTPOST_PRISON_LEAD_GOSSIP_CHANCE)) return FALSE - for(var/mob/living/basic/outpost_prisoner/other in shuffle(prisoners)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/other in shuffle(prisoners)) if(other == teller || other.stat != CONSCIOUS || other.phase != PRISONER_PRESENT || other.trouble || other.mood < OUTPOST_PRISON_LEAD_GOSSIP_MOOD) continue var/list/seen = view(OUTPOST_PRISON_LEAD_GOSSIP_RANGE, other) @@ -498,7 +498,7 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) * middling aren't sure, and the sour and anyone the asker hit refuse (they can be asked again * later). Returns "refuse_hit", "refuse", "unsure", "true" or "lie" (what they said the tip was). */ -/datum/outpost_prison/proc/lead_vouch(mob/living/basic/outpost_prisoner/prisoner, datum/outpost_prison_lead/lead, mob/living/asker) +/datum/outpost_prison/proc/lead_vouch(mob/living/carbon/human/npc/outpost_prisoner/prisoner, datum/outpost_prison_lead/lead, mob/living/asker) prisoner.face_atom(asker) if(lead_hit_by(prisoner, asker)) prisoner.say_context("lead_refuse_hit") @@ -550,7 +550,7 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) /// A caught liar still in the wing owns up once the asker comes within OUTPOST_PRISON_LEAD_CAUGHT_RANGE /datum/outpost_prison/proc/lead_caught_line(datum/outpost_prison_lead/lead) - var/mob/living/basic/outpost_prisoner/teller = lead.teller_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/teller = lead.teller_ref?.resolve() if(QDELETED(teller) || teller.prison != src) lead.caught_said = TRUE return FALSE @@ -574,7 +574,7 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) /// The admin panel's leads block: {ready_in, carriers: [ref], open: [{teller, ship, name, lie, exposed, age}]}; times in seconds /datum/outpost_prison/proc/leads_admin_payload() var/list/carriers = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.carries_lead) carriers += REF(prisoner) var/list/open = list() @@ -598,7 +598,7 @@ GLOBAL_VAR_INIT(outpost_prison_lead_lies, 0) if(action != "prison_lead") return null var/ref = params ? params["ref"] : null - var/mob/living/basic/outpost_prisoner/prisoner = istext(ref) ? (locate(ref) in prisoners) : null + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = istext(ref) ? (locate(ref) in prisoners) : null if(QDELETED(prisoner)) return list("error" = "No such prisoner.") prisoner.carries_lead = TRUE diff --git a/voidcrew/modules/player_outposts/outpost_prison_life.dm b/voidcrew/modules/player_outposts/outpost_prison_life.dm index 835bf41113c..a1d82660238 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_life.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_life.dm @@ -28,7 +28,7 @@ /// A friend of one of the fighters has had their one try at breaking it up var/breakup_tried = FALSE -/mob/living/basic/outpost_prisoner +/mob/living/carbon/human/npc/outpost_prisoner /// It is their birthday; `party_done` once the yard has had the cake var/has_birthday = FALSE var/party_done = FALSE @@ -38,19 +38,19 @@ // ===== AFFINITY ===== /// The key a pair of prisoners is kept under, the same whichever way round they come -/datum/outpost_prison/proc/affinity_key(mob/living/basic/outpost_prisoner/one, mob/living/basic/outpost_prisoner/two) +/datum/outpost_prison/proc/affinity_key(mob/living/carbon/human/npc/outpost_prisoner/one, mob/living/carbon/human/npc/outpost_prisoner/two) var/one_ref = REF(one) var/two_ref = REF(two) return (sorttext(one_ref, two_ref) > 0) ? "[one_ref]|[two_ref]" : "[two_ref]|[one_ref]" /// How two prisoners get on, -100 (rivals) to 100 (friends) -/datum/outpost_prison/proc/affinity(mob/living/basic/outpost_prisoner/one, mob/living/basic/outpost_prisoner/two) +/datum/outpost_prison/proc/affinity(mob/living/carbon/human/npc/outpost_prisoner/one, mob/living/carbon/human/npc/outpost_prisoner/two) if(!one || !two || one == two) return 0 return affinities[affinity_key(one, two)] || 0 /// Sets how two prisoners get on. A wing keeps at most PRISON_AFFINITY_MAX_PAIRS pairs: a new one pushes out the mildest. -/datum/outpost_prison/proc/set_affinity(mob/living/basic/outpost_prisoner/one, mob/living/basic/outpost_prisoner/two, value) +/datum/outpost_prison/proc/set_affinity(mob/living/carbon/human/npc/outpost_prisoner/one, mob/living/carbon/human/npc/outpost_prisoner/two, value) if(!one || !two || one == two) return 0 var/key = affinity_key(one, two) @@ -68,20 +68,20 @@ affinities[key] = value return value -/datum/outpost_prison/proc/adjust_affinity(mob/living/basic/outpost_prisoner/one, mob/living/basic/outpost_prisoner/two, amount) +/datum/outpost_prison/proc/adjust_affinity(mob/living/carbon/human/npc/outpost_prisoner/one, mob/living/carbon/human/npc/outpost_prisoner/two, amount) return set_affinity(one, two, affinity(one, two) + amount) -/datum/outpost_prison/proc/are_friends(mob/living/basic/outpost_prisoner/one, mob/living/basic/outpost_prisoner/two) +/datum/outpost_prison/proc/are_friends(mob/living/carbon/human/npc/outpost_prisoner/one, mob/living/carbon/human/npc/outpost_prisoner/two) return affinity(one, two) >= PRISON_AFFINITY_FRIEND -/datum/outpost_prison/proc/are_rivals(mob/living/basic/outpost_prisoner/one, mob/living/basic/outpost_prisoner/two) +/datum/outpost_prison/proc/are_rivals(mob/living/carbon/human/npc/outpost_prisoner/one, mob/living/carbon/human/npc/outpost_prisoner/two) return affinity(one, two) <= PRISON_AFFINITY_RIVAL /// The prisoner `prisoner` gets on with best, if a friend; with `worst`, the one they get on with worst, if a rival -/datum/outpost_prison/proc/closest_tie(mob/living/basic/outpost_prisoner/prisoner, worst = FALSE) - var/mob/living/basic/outpost_prisoner/found +/datum/outpost_prison/proc/closest_tie(mob/living/carbon/human/npc/outpost_prisoner/prisoner, worst = FALSE) + var/mob/living/carbon/human/npc/outpost_prisoner/found var/found_value = worst ? PRISON_AFFINITY_RIVAL : PRISON_AFFINITY_FRIEND - for(var/mob/living/basic/outpost_prisoner/other in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/other in prisoners) if(other == prisoner || other.stat == DEAD || other.phase == PRISONER_LEAVING) continue var/value = affinity(prisoner, other) @@ -93,12 +93,12 @@ return found /// Picks, removes from `options` and returns the prisoner `prisoner` goes to chat with, friends by preference -/datum/outpost_prison/proc/take_chat_partner(mob/living/basic/outpost_prisoner/prisoner, list/options) +/datum/outpost_prison/proc/take_chat_partner(mob/living/carbon/human/npc/outpost_prisoner/prisoner, list/options) if(!length(options)) return null var/list/weights = list() var/total = 0 - for(var/mob/living/basic/outpost_prisoner/other as anything in options) + for(var/mob/living/carbon/human/npc/outpost_prisoner/other as anything in options) var/weight = clamp(1 + affinity(prisoner, other) / 25, PRISON_CHAT_WEIGHT_MIN, PRISON_CHAT_WEIGHT_MAX) weights += weight total += weight @@ -106,7 +106,7 @@ for(var/index in 1 to length(options)) roll -= weights[index] if(roll <= 0) - var/mob/living/basic/outpost_prisoner/chosen = options[index] + var/mob/living/carbon/human/npc/outpost_prisoner/chosen = options[index] options.Cut(index, index + 1) return chosen return pick_n_take(options) @@ -114,7 +114,7 @@ // ===== WHAT CHANGES IT ===== /// A chat between two prisoners finished -/datum/outpost_prison/proc/note_chat(mob/living/basic/outpost_prisoner/one, mob/living/basic/outpost_prisoner/two) +/datum/outpost_prison/proc/note_chat(mob/living/carbon/human/npc/outpost_prisoner/one, mob/living/carbon/human/npc/outpost_prisoner/two) adjust_affinity(one, two, PRISON_AFFINITY_CHAT) /// Prisoners who shared a meal and got its lift: every pair of them @@ -123,16 +123,16 @@ for(var/second_index in first_index + 1 to length(diners)) adjust_affinity(diners[first_index], diners[second_index], PRISON_AFFINITY_SHARED_MEAL) -/datum/outpost_prison/proc/note_spat(mob/living/basic/outpost_prisoner/one, mob/living/basic/outpost_prisoner/two) +/datum/outpost_prison/proc/note_spat(mob/living/carbon/human/npc/outpost_prisoner/one, mob/living/carbon/human/npc/outpost_prisoner/two) adjust_affinity(one, two, PRISON_AFFINITY_SPAT) -/datum/outpost_prison/proc/note_fight(mob/living/basic/outpost_prisoner/one, mob/living/basic/outpost_prisoner/two) +/datum/outpost_prison/proc/note_fight(mob/living/carbon/human/npc/outpost_prisoner/one, mob/living/carbon/human/npc/outpost_prisoner/two) adjust_affinity(one, two, PRISON_AFFINITY_FIGHT) /// Each full minute two prisoners spend playing basketball together brings them a little closer /datum/outpost_prison/proc/coplay_tick(seconds) var/list/players = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.stat == CONSCIOUS && prisoner.phase == PRISONER_PRESENT && istype(prisoner.activity, /datum/prisoner_activity/basketball) && prisoner.activity.started) players += prisoner for(var/first_index in 1 to length(players) - 1) @@ -147,7 +147,7 @@ // ===== WHAT IT CHANGES ===== /// Rivals fight more readily, friends less -/datum/outpost_prison/proc/fight_chance_mult(mob/living/basic/outpost_prisoner/one, mob/living/basic/outpost_prisoner/two) +/datum/outpost_prison/proc/fight_chance_mult(mob/living/carbon/human/npc/outpost_prisoner/one, mob/living/carbon/human/npc/outpost_prisoner/two) if(are_rivals(one, two)) return PRISON_FIGHT_MULT_RIVAL if(are_friends(one, two)) @@ -155,7 +155,7 @@ return 1 /// A fight cause beyond food, ball and bed: an old grudge between two who can't stand each other -/datum/outpost_prison/proc/fight_cause_extra(mob/living/basic/outpost_prisoner/one, mob/living/basic/outpost_prisoner/two) +/datum/outpost_prison/proc/fight_cause_extra(mob/living/carbon/human/npc/outpost_prisoner/one, mob/living/carbon/human/npc/outpost_prisoner/two) if(affinity(one, two) <= PRISON_AFFINITY_GRUDGE) return "grudge" return null @@ -181,7 +181,7 @@ * The two-person conversation `speaker` opens with `partner`: friends and rivals mostly open with * one of their own (conversations_friendly, conversations_hostile), falling back to the main pool. */ -/datum/outpost_prison/proc/pick_conversation(mob/living/basic/outpost_prisoner/speaker, mob/living/basic/outpost_prisoner/partner) +/datum/outpost_prison/proc/pick_conversation(mob/living/carbon/human/npc/outpost_prisoner/speaker, mob/living/carbon/human/npc/outpost_prisoner/partner) var/value = affinity(speaker, partner) var/pool_key if(value >= PRISON_AFFINITY_FRIEND) @@ -197,9 +197,9 @@ return length(pool) ? pick(pool) : null /// "Seems to get on with Rosa." for examine, or null -/datum/outpost_prison/proc/relationship_examine(mob/living/basic/outpost_prisoner/prisoner) - var/mob/living/basic/outpost_prisoner/friend = closest_tie(prisoner) - var/mob/living/basic/outpost_prisoner/rival = closest_tie(prisoner, worst = TRUE) +/datum/outpost_prison/proc/relationship_examine(mob/living/carbon/human/npc/outpost_prisoner/prisoner) + var/mob/living/carbon/human/npc/outpost_prisoner/friend = closest_tie(prisoner) + var/mob/living/carbon/human/npc/outpost_prisoner/rival = closest_tie(prisoner, worst = TRUE) if(friend && rival) return "Seems to get on with [friend.speech_name()], and keeps away from [rival.speech_name()]." if(friend) @@ -209,8 +209,8 @@ return null /// The first name of `prisoner`'s worst rival in the wing, or null -/datum/outpost_prison/proc/worst_rival_name(mob/living/basic/outpost_prisoner/prisoner) - var/mob/living/basic/outpost_prisoner/rival = closest_tie(prisoner, worst = TRUE) +/datum/outpost_prison/proc/worst_rival_name(mob/living/carbon/human/npc/outpost_prisoner/prisoner) + var/mob/living/carbon/human/npc/outpost_prisoner/rival = closest_tie(prisoner, worst = TRUE) return rival?.speech_name() // ===== A FRIEND BREAKS IT UP ===== @@ -224,28 +224,28 @@ for(var/datum/outpost_prison_fight/brawl in fights.Copy()) if(brawl.fighting || brawl.breakup_tried) continue - for(var/mob/living/basic/outpost_prisoner/fighter as anything in list(brawl.first, brawl.second)) - var/mob/living/basic/outpost_prisoner/friend = peacemaker_for(fighter, brawl) + for(var/mob/living/carbon/human/npc/outpost_prisoner/fighter as anything in list(brawl.first, brawl.second)) + var/mob/living/carbon/human/npc/outpost_prisoner/friend = peacemaker_for(fighter, brawl) if(!friend) continue brawl.breakup_tried = TRUE var/chance = isnull(breakup_chance_override) ? PRISON_BREAKUP_CHANCE : breakup_chance_override if(!prob(chance)) break - var/mob/living/basic/outpost_prisoner/opponent = brawl.opponent_of(fighter) + var/mob/living/carbon/human/npc/outpost_prisoner/opponent = brawl.opponent_of(fighter) friend.face_atom(fighter) friend.manual_emote(opponent ? "steps in between [fighter] and [opponent]." : "puts a hand on [fighter]'s shoulder.") end_fight(brawl) add_log("[friend.real_name] talked [fighter.real_name] and [opponent?.real_name] out of a fight.") - INVOKE_ASYNC(friend, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context), "friend_breaks_up", fighter) + INVOKE_ASYNC(friend, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context), "friend_breaks_up", fighter) return friend return null /// A friend of `fighter` who could step in: close by, awake, in a good enough mood and out of trouble -/datum/outpost_prison/proc/peacemaker_for(mob/living/basic/outpost_prisoner/fighter, datum/outpost_prison_fight/brawl) +/datum/outpost_prison/proc/peacemaker_for(mob/living/carbon/human/npc/outpost_prisoner/fighter, datum/outpost_prison_fight/brawl) if(QDELETED(fighter)) return null - for(var/mob/living/basic/outpost_prisoner/other in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/other in prisoners) if(other == brawl.first || other == brawl.second || !are_friends(fighter, other)) continue // Down or cuffed, they can't step in between anyone @@ -258,13 +258,13 @@ // ===== ARRIVALS ===== /// A prisoner was booked in. Whether they know anyone inside, and their birthday, wait until they beam in. -/datum/outpost_prison/proc/on_prisoner_admitted(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/on_prisoner_admitted(mob/living/carbon/human/npc/outpost_prisoner/prisoner) // admit_next() beams them in straight after admit(); anyone booked in any other way stays put. addtimer(CALLBACK(src, PROC_REF(greet_arrival), WEAKREF(prisoner)), 1) /// An arrival beaming in through intake: a crewmate or a rival already inside, a birthday, marks on the wall /datum/outpost_prison/proc/greet_arrival(datum/weakref/prisoner_ref) - var/mob/living/basic/outpost_prisoner/prisoner = prisoner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = prisoner_ref?.resolve() if(!prisoner || prisoner.prison != src || prisoner.phase != PRISONER_ARRIVING) return FALSE roll_crew_tie(prisoner) @@ -279,9 +279,9 @@ * (-PRISON_CREW_TIE). `forced` is "friend" or "rival" to skip the roll. The arrival says so once * they have beamed in. Returns the other prisoner, or null. */ -/datum/outpost_prison/proc/roll_crew_tie(mob/living/basic/outpost_prisoner/prisoner, forced) +/datum/outpost_prison/proc/roll_crew_tie(mob/living/carbon/human/npc/outpost_prisoner/prisoner, forced) var/list/others = list() - for(var/mob/living/basic/outpost_prisoner/other in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/other in prisoners) if(other != prisoner && other.phase == PRISONER_PRESENT && other.stat != DEAD && other.trouble != PRISONER_TROUBLE_LOOSE) others += other if(!length(others)) @@ -294,7 +294,7 @@ tie = "rival" if(tie != "friend" && tie != "rival") return null - var/mob/living/basic/outpost_prisoner/other = pick(others) + var/mob/living/carbon/human/npc/outpost_prisoner/other = pick(others) set_affinity(prisoner, other, tie == "friend" ? PRISON_CREW_TIE : -PRISON_CREW_TIE) var/delay = (prisoner.phase == PRISONER_ARRIVING ? OUTPOST_PRISON_BEAM_TIME / (1 SECONDS) : 0) + PRISON_CREW_LINE_DELAY queue_life_line(prisoner, tie == "friend" ? "arrival_crew_friend" : "arrival_crew_rival", other, delay) @@ -305,7 +305,7 @@ return prob(PRISON_BIRTHDAY_CHANCE) /// It is their birthday: they say so once they are in, and the yard can throw them a party (outpost_prison_pastimes.dm) -/datum/outpost_prison/proc/give_birthday(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/give_birthday(mob/living/carbon/human/npc/outpost_prisoner/prisoner) prisoner.has_birthday = TRUE prisoner.party_done = FALSE var/delay = (prisoner.phase == PRISONER_ARRIVING ? OUTPOST_PRISON_BEAM_TIME / (1 SECONDS) : 0) + PRISON_BIRTHDAY_LINE_DELAY @@ -314,12 +314,12 @@ // ===== LINES DUE ===== /// Queues a line for `prisoner` to say to `other` in `seconds` -/datum/outpost_prison/proc/queue_life_line(mob/living/basic/outpost_prisoner/prisoner, context, mob/living/basic/outpost_prisoner/other, seconds) +/datum/outpost_prison/proc/queue_life_line(mob/living/carbon/human/npc/outpost_prisoner/prisoner, context, mob/living/carbon/human/npc/outpost_prisoner/other, seconds) LAZYADD(prisoner.life_lines, list(list(seconds, context, other ? WEAKREF(other) : null))) /// Counts down queued lines and says the ones that are due, once the speaker has beamed in /datum/outpost_prison/proc/life_lines_tick(seconds) - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(!length(prisoner.life_lines)) continue for(var/list/entry as anything in prisoner.life_lines.Copy()) @@ -330,7 +330,7 @@ if(prisoner.phase != PRISONER_PRESENT || prisoner.stat != CONSCIOUS) continue var/datum/weakref/other_ref = entry[3] - var/mob/living/basic/outpost_prisoner/other = other_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/other = other_ref?.resolve() if(other && other.stat == CONSCIOUS && (other in view(7, prisoner))) prisoner.face_atom(other) else @@ -339,10 +339,10 @@ /// Says a line for a prisoner who may have gone by now; for timers /datum/outpost_prison/proc/say_life_line(datum/weakref/speaker_ref, context, datum/weakref/other_ref) - var/mob/living/basic/outpost_prisoner/speaker = speaker_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/speaker = speaker_ref?.resolve() if(!speaker || speaker.stat != CONSCIOUS) return FALSE - var/mob/living/basic/outpost_prisoner/other = other_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/other = other_ref?.resolve() if(other) speaker.face_atom(other) return speaker.say_context(context, other) @@ -350,7 +350,7 @@ // ===== LEAVING ===== /// A prisoner is leaving the roster: their pairs go, and a party for them is off -/datum/outpost_prison/proc/on_prisoner_leaving(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/on_prisoner_leaving(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/prisoner_ref = REF(prisoner) for(var/key in affinities.Copy()) if(findtext(key, prisoner_ref)) @@ -368,7 +368,7 @@ * sight say goodbye, a second or so apart, and feel it; the leaver answers the first before the beam * takes them. Returns TRUE if any of that replaced the usual release line. */ -/datum/outpost_prison/proc/on_prisoner_releasing(mob/living/basic/outpost_prisoner/prisoner, average) +/datum/outpost_prison/proc/on_prisoner_releasing(mob/living/carbon/human/npc/outpost_prisoner/prisoner, average) var/spoke = FALSE if(average >= PRISON_RELEASE_THANKS_AVERAGE) var/mob/living/member = nearest_member_in_view(prisoner) @@ -381,7 +381,7 @@ else if(average <= PRISON_RELEASE_BITTER_AVERAGE) spoke = prisoner.say_context("release_bitter") var/list/friends = list() - for(var/mob/living/basic/outpost_prisoner/other in view(PRISON_FAREWELL_RANGE, prisoner)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/other in view(PRISON_FAREWELL_RANGE, prisoner)) if(other == prisoner || !(other in prisoners) || other.stat != CONSCIOUS || other.phase != PRISONER_PRESENT) continue if(are_friends(prisoner, other)) @@ -391,7 +391,7 @@ // The first goodbye and the leaver's answer come before the beam starts, since nobody talks while // beaming out; later friends call after them anyway, a second or two apart. var/delay = 0 - for(var/mob/living/basic/outpost_prisoner/friend as anything in friends) + for(var/mob/living/carbon/human/npc/outpost_prisoner/friend as anything in friends) friend.adjust_mood(-PRISON_FAREWELL_MOOD) friend.face_atom(prisoner) if(friend == friends[1]) @@ -403,7 +403,7 @@ return TRUE /// The nearest member of the wing awake in sight of `prisoner`, or null -/datum/outpost_prison/proc/nearest_member_in_view(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/nearest_member_in_view(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/mob/living/nearest var/nearest_distance = INFINITY for(var/mob/living/person in view(7, prisoner)) @@ -433,7 +433,7 @@ /// A birthday prisoner free to talk brings it up now and then, until they get their party /datum/outpost_prison/proc/birthday_chatter() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(!prisoner.has_birthday || prisoner.party_done || prisoner.stat != CONSCIOUS || prisoner.phase != PRISONER_PRESENT) continue if(!prisoner.ai_running() || prisoner.in_trouble() || prisoner.activity?.sleeping) @@ -459,8 +459,8 @@ var/list/refs = splittext(key, "|") if(length(refs) != 2) continue - var/mob/living/basic/outpost_prisoner/one = locate(refs[1]) in prisoners - var/mob/living/basic/outpost_prisoner/two = locate(refs[2]) in prisoners + var/mob/living/carbon/human/npc/outpost_prisoner/one = locate(refs[1]) in prisoners + var/mob/living/carbon/human/npc/outpost_prisoner/two = locate(refs[2]) in prisoners if(!one || !two) continue pairs += list(list( @@ -471,11 +471,11 @@ "affinity" = round(affinities[key]), )) var/list/birthdays = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.has_birthday && !prisoner.party_done) birthdays += REF(prisoner) var/scene - var/mob/living/basic/outpost_prisoner/host = party_host_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/host = party_host_ref?.resolve() if(party_stage && host) scene = party_stage == "waiting" ? "cake waiting for [host.real_name]" : "birthday party for [host.real_name]" return list( @@ -488,8 +488,8 @@ /datum/outpost_prison/proc/life_admin_act(action, list/params, mob/user) switch(action) if("prison_affinity") - var/mob/living/basic/outpost_prisoner/one = locate(params?["a_ref"]) in prisoners - var/mob/living/basic/outpost_prisoner/two = locate(params?["b_ref"]) in prisoners + var/mob/living/carbon/human/npc/outpost_prisoner/one = locate(params?["a_ref"]) in prisoners + var/mob/living/carbon/human/npc/outpost_prisoner/two = locate(params?["b_ref"]) in prisoners if(QDELETED(one) || QDELETED(two) || one == two) return list("error" = "Pick two different prisoners.") var/value = params["value"] @@ -500,7 +500,7 @@ set_affinity(one, two, value) return "set how [one.real_name] and [two.real_name] get on to [round(affinity(one, two))]" if("prison_birthday", "prison_party") - var/mob/living/basic/outpost_prisoner/prisoner = locate(params?["ref"]) in prisoners + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = locate(params?["ref"]) in prisoners if(QDELETED(prisoner) || prisoner.stat == DEAD || prisoner.phase != PRISONER_PRESENT) return list("error" = "Only a living prisoner in the wing.") if(action == "prison_birthday") diff --git a/voidcrew/modules/player_outposts/outpost_prison_mail.dm b/voidcrew/modules/player_outposts/outpost_prison_mail.dm index c71f90b36c9..3d666bed22b 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_mail.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_mail.dm @@ -41,7 +41,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( // ===== STATE ===== -/mob/living/basic/outpost_prisoner +/mob/living/carbon/human/npc/outpost_prisoner /// Whether a letter has come for them this stay; one each var/mail_had_letter = FALSE @@ -205,7 +205,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( return waiting /// The letter waiting for `prisoner`, if any -/datum/outpost_prison/proc/mail_waiting_for(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/mail_waiting_for(mob/living/carbon/human/npc/outpost_prisoner/prisoner) for(var/obj/item/paper/outpost_prison_letter/letter in mail_waiting_letters()) if(letter.letter_prisoner_ref?.resolve() == prisoner) return letter @@ -220,7 +220,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( /datum/outpost_prison/proc/mail_wave_recipients() var/present = 0 var/list/eligible = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.phase != PRISONER_PRESENT || prisoner.stat == DEAD) continue present++ @@ -251,7 +251,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( return 0 var/obj/structure/closet/supplypod/outpost_prison_mail/pod = new() var/obj/structure/closet/crate/mail/crate = new(pod) - for(var/mob/living/basic/outpost_prisoner/prisoner as anything in recipients) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner as anything in recipients) mail_make_letter(prisoner, null, null, crate) crate.update_appearance() RegisterSignal(crate, COMSIG_MOVABLE_MOVED, PROC_REF(mail_crate_moved)) @@ -472,7 +472,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( * waves (the admin panel's prison_mail): `kind` (by weight when not given), and for a contraband * letter `enclosure_type` (a razor blade or yeast by chance when not given). Returns the letter, or null. */ -/datum/outpost_prison/proc/mail_send(mob/living/basic/outpost_prisoner/prisoner, kind, enclosure_type) +/datum/outpost_prison/proc/mail_send(mob/living/carbon/human/npc/outpost_prisoner/prisoner, kind, enclosure_type) if(QDELETED(prisoner) || !(prisoner in prisoners)) return null var/turf/spot = mail_letter_drop_turf() @@ -492,7 +492,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( * not given), and for a contraband letter `enclosure_type` (a razor blade or yeast by chance when not * given). That is their one letter this stay. The caller tracks it (mail_letters). Returns the letter. */ -/datum/outpost_prison/proc/mail_make_letter(mob/living/basic/outpost_prisoner/prisoner, kind, enclosure_type, atom/destination) +/datum/outpost_prison/proc/mail_make_letter(mob/living/carbon/human/npc/outpost_prisoner/prisoner, kind, enclosure_type, atom/destination) if(!(kind in GLOB.outpost_prison_mail_kinds)) kind = pick_weight(GLOB.outpost_prison_mail_kinds) var/obj/item/mail/envelope/outpost_prison/envelope = new(destination) @@ -514,7 +514,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( return letter /// Writes a letter of `kind` to `prisoner` from the extras' templates -/datum/outpost_prison/proc/mail_write(obj/item/paper/outpost_prison_letter/letter, mob/living/basic/outpost_prisoner/prisoner, kind) +/datum/outpost_prison/proc/mail_write(obj/item/paper/outpost_prison_letter/letter, mob/living/carbon/human/npc/outpost_prisoner/prisoner, kind) var/list/by_kind = outpost_prisoner_extra_dialogue(MAIL_STRINGS_FILE, "letters") var/list/templates = by_kind[kind] var/list/senders = outpost_prisoner_extra_dialogue(MAIL_STRINGS_FILE, "senders") @@ -538,7 +538,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( /datum/outpost_prison/proc/mail_check() var/z = wing_z() for(var/obj/item/paper/outpost_prison_letter/letter in mail_waiting_letters()) - var/mob/living/basic/outpost_prisoner/addressee = letter.letter_prisoner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/addressee = letter.letter_prisoner_ref?.resolve() if(QDELETED(addressee) || !(addressee in prisoners)) mail_discard(letter) continue @@ -555,7 +555,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( if(QDELETED(letter)) return mail_letters -= WEAKREF(letter) - var/mob/living/basic/outpost_prisoner/addressee = letter.letter_prisoner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/addressee = letter.letter_prisoner_ref?.resolve() if(lost && !QDELETED(addressee) && (addressee in prisoners) && addressee.stat != DEAD) addressee.adjust_mood(-OUTPOST_MAIL_EXPIRED_MOOD) add_log("[addressee.real_name]'s mail was sent back.") @@ -564,7 +564,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( /// Someone opened a letter before its prisoner got it /datum/outpost_prison/proc/mail_opened(obj/item/paper/outpost_prison_letter/letter, mob/user) add_log("[user ? user.name : "Someone"] opened [letter.letter_addressee]'s mail.") - var/mob/living/basic/outpost_prisoner/addressee = letter.letter_prisoner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/addressee = letter.letter_prisoner_ref?.resolve() if(user && addressee) note_staff_event(user, addressee, "mail_opened") @@ -576,7 +576,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( * the level they read it where they stand if the hatch is in their reach, as fend_for_self() does * with food. Returns TRUE if they went for it or read it. */ -/datum/outpost_prison/proc/mail_collect_from_hatch(mob/living/basic/outpost_prisoner/addressee, obj/item/thing) +/datum/outpost_prison/proc/mail_collect_from_hatch(mob/living/carbon/human/npc/outpost_prisoner/addressee, obj/item/thing) if(addressee.stat != CONSCIOUS || addressee.phase != PRISONER_PRESENT || !isturf(thing.loc)) return FALSE if(addressee.ai_running()) @@ -591,7 +591,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( return FALSE addressee.start_activity(fetch) return TRUE - if(addressee.in_trouble() || addressee.cuffs) + if(addressee.in_trouble() || addressee.handcuffed) return FALSE if(!addressee.reachable) refresh_prisoner_reach(addressee) @@ -608,7 +608,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( if(!letter) only_mail = FALSE continue - var/mob/living/basic/outpost_prisoner/addressee = letter.letter_prisoner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/addressee = letter.letter_prisoner_ref?.resolve() if(!QDELETED(addressee) && (addressee in prisoners)) mail_collect_from_hatch(addressee, thing) return only_mail @@ -618,21 +618,21 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( * anyone else says it isn't theirs, and a prisoner who won't listen refuses it. Runs inside a * signal handler: never sleeps. Returns the item interaction result. */ -/datum/outpost_prison/proc/mail_hand_over(mob/living/basic/outpost_prisoner/prisoner, mob/living/user, obj/item/thing, obj/item/paper/outpost_prison_letter/letter) +/datum/outpost_prison/proc/mail_hand_over(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/user, obj/item/thing, obj/item/paper/outpost_prison_letter/letter) if(prisoner.stat != CONSCIOUS || prisoner.phase != PRISONER_PRESENT) return NONE if(letter.letter_prisoner_ref?.resolve() != prisoner) prisoner.balloon_alert(user, "not theirs") - INVOKE_ASYNC(prisoner, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context), "mail_not_mine") + INVOKE_ASYNC(prisoner, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context), "mail_not_mine") return ITEM_INTERACT_BLOCKING // Cuffed hands take nothing, as with food and uniforms (outpost_prison_capture.dm) - if(prisoner.cuffs) + if(prisoner.handcuffed) prisoner.balloon_alert(user, "cuffed") return ITEM_INTERACT_BLOCKING // Fighting, squaring up, climbing, lying beaten, or already busy with staff: they won't take it if(prisoner.in_trouble() || !prisoner.will_listen()) prisoner.balloon_alert(user, "not listening") - INVOKE_ASYNC(prisoner, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context), "talk_refuse") + INVOKE_ASYNC(prisoner, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context), "talk_refuse") return ITEM_INTERACT_BLOCKING if(!user.temporarilyRemoveItemFromInventory(thing)) return ITEM_INTERACT_BLOCKING @@ -649,7 +649,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( * unless `instant`, then the letter takes effect. Bad news sends them to sit in their cell a while. * Returns the kind read, or null. Sleeps unless `instant`. */ -/datum/outpost_prison/proc/mail_read(mob/living/basic/outpost_prisoner/prisoner, obj/item/thing, instant = FALSE) +/datum/outpost_prison/proc/mail_read(mob/living/carbon/human/npc/outpost_prisoner/prisoner, obj/item/thing, instant = FALSE) if(QDELETED(prisoner) || QDELETED(thing)) return null mail_reading_emote(prisoner, thing) @@ -667,7 +667,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( mail_start_mull(prisoner) return kind -/datum/outpost_prison/proc/mail_reading_emote(mob/living/basic/outpost_prisoner/prisoner, obj/item/thing) +/datum/outpost_prison/proc/mail_reading_emote(mob/living/carbon/human/npc/outpost_prisoner/prisoner, obj/item/thing) if(istype(thing, /obj/item/mail/envelope/outpost_prison)) prisoner.manual_emote("tears open the envelope and reads the letter.") playsound(prisoner, 'sound/items/poster/poster_ripped.ogg', 30, TRUE) @@ -681,7 +681,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( * sealed in with it is kept hidden (contraband, 4.14). The letter and its envelope are then gone * (they keep it). Never sleeps. Returns the kind, or null. */ -/datum/outpost_prison/proc/mail_finish_reading(mob/living/basic/outpost_prisoner/prisoner, obj/item/thing) +/datum/outpost_prison/proc/mail_finish_reading(mob/living/carbon/human/npc/outpost_prisoner/prisoner, obj/item/thing) var/obj/item/paper/outpost_prison_letter/letter = outpost_prison_letter_in(thing) if(!letter || QDELETED(prisoner)) return null @@ -705,7 +705,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( return kind /// Bad news: they go and sit in their cell's chair (or on its bed) for a while, if they can -/datum/outpost_prison/proc/mail_start_mull(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/mail_start_mull(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(QDELETED(prisoner) || !prisoner.ai_running() || !prisoner.routine_allowed()) return FALSE var/datum/prisoner_activity/mull_letter/mull = new(prisoner) @@ -718,7 +718,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( // ===== THE PRISON: SPEECH, CONSOLES, CLEAN-UP ===== /// "Any mail for me?", from a prisoner with a letter waiting and a member in sight, as list(context, other, values), or null -/datum/outpost_prison/proc/mail_extra_speech(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/mail_extra_speech(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(!mail_waiting_for(prisoner) || !contraband_roll(OUTPOST_MAIL_ASK_CHANCE)) return null for(var/mob/living/person in view(OUTPOST_MAIL_ASK_RANGE, prisoner)) @@ -729,7 +729,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( return null /// A prisoner is leaving: their undelivered letters go -/datum/outpost_prison/proc/mail_prisoner_leaving(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/mail_prisoner_leaving(mob/living/carbon/human/npc/outpost_prisoner/prisoner) for(var/obj/item/paper/outpost_prison_letter/letter in mail_waiting_letters()) if(letter.letter_prisoner_ref?.resolve() == prisoner) mail_discard(letter) @@ -743,7 +743,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( /datum/outpost_prison/proc/mail_admin_payload() var/list/rows = list() for(var/obj/item/paper/outpost_prison_letter/letter in mail_waiting_letters()) - var/mob/living/basic/outpost_prisoner/addressee = letter.letter_prisoner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/addressee = letter.letter_prisoner_ref?.resolve() rows += list(list( "ref" = REF(letter), "to_ref" = addressee ? REF(addressee) : null, @@ -769,7 +769,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( return "call a prison mail pod with [sent] letter\s" if(action != "prison_mail") return null - var/mob/living/basic/outpost_prisoner/prisoner = locate(params?["ref"]) in prisoners + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = locate(params?["ref"]) in prisoners if(QDELETED(prisoner)) return list("error" = "That prisoner is gone.") var/kind = params["kind"] @@ -791,7 +791,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( /datum/element/outpost_prison_mail_handover/Attach(datum/target) . = ..() - if(!istype(target, /mob/living/basic/outpost_prisoner)) + if(!istype(target, /mob/living/carbon/human/npc/outpost_prisoner)) return ELEMENT_INCOMPATIBLE RegisterSignal(target, COMSIG_ATOM_ITEM_INTERACTION, PROC_REF(on_item_interaction)) @@ -799,7 +799,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( UnregisterSignal(source, COMSIG_ATOM_ITEM_INTERACTION) return ..() -/datum/element/outpost_prison_mail_handover/proc/on_item_interaction(mob/living/basic/outpost_prisoner/source, mob/living/user, obj/item/tool, list/modifiers) +/datum/element/outpost_prison_mail_handover/proc/on_item_interaction(mob/living/carbon/human/npc/outpost_prisoner/source, mob/living/user, obj/item/tool, list/modifiers) SIGNAL_HANDLER if(!istype(user) || user.combat_mode || is_outpost_prisoner(user) || !source.prison) return NONE @@ -823,7 +823,7 @@ GLOBAL_LIST_INIT(outpost_prison_mail_kinds, list( var/read_for = 0 var/datum/weakref/seat_ref -/datum/prisoner_activity/fetch_mail/New(mob/living/basic/outpost_prisoner/doer, obj/item/thing) +/datum/prisoner_activity/fetch_mail/New(mob/living/carbon/human/npc/outpost_prisoner/doer, obj/item/thing) . = ..(doer) mail_ref = WEAKREF(thing) diff --git a/voidcrew/modules/player_outposts/outpost_prison_npc_bodies.dm b/voidcrew/modules/player_outposts/outpost_prison_npc_bodies.dm new file mode 100644 index 00000000000..c5e57d0bf43 --- /dev/null +++ b/voidcrew/modules/player_outposts/outpost_prison_npc_bodies.dm @@ -0,0 +1,120 @@ +/** + * # Prison NPC bodies + * + * Prisoners, guards and Kessler staff are real human bodies (voidcrew/modules/human_npcs/): they go + * down, bleed, stamcrit, get cuffed, die and come back through tg's own code. This file holds what the + * prison's own AI needs to use those bodies the way a person does: + * - outpost_prison_npc_hit(): a blow is a click with combat mode on, through the body's hands (a fist, + * a held shiv, a stun baton), so tg's damage, armour, wounds, knockdowns and logs apply. + * - Saved faces: a guard on the payroll is the same person each time the record sends them back + * (outpost_prison_save_look(), outpost_prison_apply_look()). + * - Bruising to a health: outpost_prison_bruise() and outpost_prison_set_health(), for a transfer's + * roughing up and the admin tools. + */ + +/// Brute in which a limb is bruised by outpost_prison_bruise(): a multiple of it on a limb (0.75 or 0.5 of +/// the body's health) comes to whole tenths of health +#define OUTPOST_PRISON_BRUISE_STEP 0.4 + +/** + * `hitter` strikes `target` beside it with `weapon` in hand (switched to the active hand), or a fist + * if `weapon` is null, the way a player clicks with combat mode on. The aim spreads over the body as + * other human NPCs' does. Returns TRUE if the blow was thrown: not if they can't swing yet, nor a second + * time in the same tick, which ClickOn() would ignore as it does a player's second click. + */ +/proc/outpost_prison_npc_hit(mob/living/carbon/human/hitter, atom/target, obj/item/weapon) + if(QDELETED(hitter) || QDELETED(target) || hitter.stat != CONSCIOUS || world.time < hitter.next_move || world.time <= hitter.next_click) + return FALSE + if(!hitter.Adjacent(target)) + return FALSE + if(weapon) + if(!human_npc_ready_item(hitter, weapon)) + return FALSE + else if(!human_npc_ready_empty_hand(hitter)) + return FALSE + hitter.face_atom(target) + hitter.zone_selected = human_npc_pick_aim_zone() + var/old_combat_mode = hitter.combat_mode + hitter.set_combat_mode(TRUE, silent = TRUE) + hitter.ClickOn(target) + hitter.set_combat_mode(old_combat_mode, silent = TRUE) + return TRUE + +/// What makes a face: the bits of a random person a guard record keeps, so the same guard comes back +/proc/outpost_prison_save_look(mob/living/carbon/human/person) + if(QDELETED(person)) + return null + return list( + "gender" = person.gender, + "skin_tone" = person.skin_tone, + "hairstyle" = person.hairstyle, + "hair_color" = person.hair_color, + "facial_hairstyle" = person.facial_hairstyle, + "facial_hair_color" = person.facial_hair_color, + "eye_color" = person.eye_color_left, + "real_name" = person.real_name, + ) + +/// Puts a face saved by outpost_prison_save_look() on `person` +/proc/outpost_prison_apply_look(mob/living/carbon/human/person, list/look) + if(QDELETED(person) || !length(look)) + return + person.gender = look["gender"] == FEMALE ? FEMALE : MALE + person.physique = person.gender + if(look["skin_tone"]) + person.skin_tone = look["skin_tone"] + person.set_hairstyle(look["hairstyle"] || "Bald", update = FALSE) + if(look["hair_color"]) + person.set_haircolor(look["hair_color"], update = FALSE) + person.set_facial_hairstyle(look["facial_hairstyle"] || "Shaved", update = FALSE) + if(look["facial_hair_color"]) + person.set_facial_haircolor(look["facial_hair_color"], update = FALSE) + if(look["eye_color"]) + person.set_eye_color(look["eye_color"]) + person.update_body(is_creating = TRUE) + +/** + * Bruises `body` until it has lost `health_loss` health: brute spread over its limbs, no wounds and no + * attacker, as a rough transfer leaves someone, with the chest taking what is left. Arms and legs count + * for less of a body's health than its head and chest (body_damage_coeff), so each limb's share is + * measured in health and bruised in steps of OUTPOST_PRISON_BRUISE_STEP brute, which come to whole + * tenths of health; the chest, which counts in full, then makes the loss exact. Returns the health it + * ended at. + */ +/proc/outpost_prison_bruise(mob/living/carbon/body, health_loss) + if(QDELETED(body) || health_loss <= 0) + return body?.health + var/target_health = body.health - health_loss + var/obj/item/bodypart/chest = body.get_bodypart(BODY_ZONE_CHEST) + var/list/parts = body.get_damageable_bodyparts() + if(length(parts)) + var/share = health_loss / length(parts) + for(var/obj/item/bodypart/part as anything in parts) + if(part == chest || part.body_damage_coeff <= 0) + continue + var/room = FLOOR(part.max_damage - part.get_damage(), OUTPOST_PRISON_BRUISE_STEP) + var/brute = min(round(share / part.body_damage_coeff, OUTPOST_PRISON_BRUISE_STEP), room) + if(brute > 0) + part.receive_damage(brute = brute, forced = TRUE, wound_bonus = CANT_WOUND, updating_health = FALSE) + body.updatehealth() + for(var/i in 1 to 5) + var/short = round(body.health - target_health, DAMAGE_PRECISION) + if(short <= 0 || !chest) + break + chest.receive_damage(brute = short, forced = TRUE, wound_bonus = CANT_WOUND) + body.update_damage_overlays() + return body.health + +/** + * Sets `body`'s health to `target_health` with brute alone: heals the brute it has, then bruises it + * down (outpost_prison_bruise()). Burns, toxins and lost air stay as they are, so a body with those + * can't be brought all the way up. For the admin tools. Returns the health it ended at. + */ +/proc/outpost_prison_set_health(mob/living/carbon/body, target_health) + if(QDELETED(body)) + return null + if(body.getBruteLoss() > 0) + body.heal_overall_damage(brute = body.getBruteLoss(), forced = TRUE) + return outpost_prison_bruise(body, body.health - target_health) + +#undef OUTPOST_PRISON_BRUISE_STEP diff --git a/voidcrew/modules/player_outposts/outpost_prison_panic.dm b/voidcrew/modules/player_outposts/outpost_prison_panic.dm index ea647506707..38b269d00bd 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_panic.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_panic.dm @@ -41,7 +41,7 @@ // ===== THE PRISONER ===== -/mob/living/basic/outpost_prisoner +/mob/living/carbon/human/npc/outpost_prisoner /// Seconds of fright left: full while a creature frightens them, counting down once none does. 0 when calm. var/creature_panic_left = 0 /// The creature that frightened them last @@ -61,11 +61,11 @@ var/running_scared = FALSE /// Whether a creature has them frightened -/mob/living/basic/outpost_prisoner/proc/is_panicking() +/mob/living/carbon/human/npc/outpost_prisoner/proc/is_panicking() return creature_panic_left > 0 /// The creature that frightened them last, while it lives -/mob/living/basic/outpost_prisoner/proc/panic_threat() +/mob/living/carbon/human/npc/outpost_prisoner/proc/panic_threat() var/mob/living/threat = panic_threat_ref?.resolve() if(QDELETED(threat) || threat.stat == DEAD) return null @@ -76,13 +76,13 @@ * (outpost_prison_changeling.dm): they asked for it, so the lock-in clock waits, and so does the * pay it stops (update_locked_in(), confined_unpaid()). */ -/mob/living/basic/outpost_prisoner/proc/sheltering_from_creature() +/mob/living/carbon/human/npc/outpost_prisoner/proc/sheltering_from_creature() if(!is_panicking() && !istype(activity, /datum/prisoner_activity/flee_creature)) return FALSE return !!cell?.contains(src) && is_confined() /// The creature they are going for, while they still are: a menace still, close, and not given up on -/mob/living/basic/outpost_prisoner/proc/creature_foe() +/mob/living/carbon/human/npc/outpost_prisoner/proc/creature_foe() if(!creature_foe_ref) return null var/mob/living/foe = creature_foe_ref.resolve() @@ -92,19 +92,19 @@ return foe /// They run while running from a creature, and walk otherwise -/mob/living/basic/outpost_prisoner/proc/update_flee_speed() +/mob/living/carbon/human/npc/outpost_prisoner/proc/update_flee_speed() var/wanted = stat != DEAD && (istype(activity, /datum/prisoner_activity/creature_panic) || (!!creature_retreat_spot && world.time < creature_retreat_until)) if(wanted == running_scared) return running_scared = wanted // A loose meek bounty prisoner keeps their pace (outpost_prison_bounty.dm). - set_varspeed(wanted ? OUTPOST_PANIC_FLEE_SPEED : bounty_base_speed()) + set_prison_pace(hurry = wanted || bounty_base_speed()) /** * A rioter running from a creature, planned from the trouble subtree: TRUE while they are on the * way. At the spot, out of time or no longer rioting, they stop and riot on. */ -/mob/living/basic/outpost_prisoner/proc/plan_creature_retreat(datum/ai_controller/controller) +/mob/living/carbon/human/npc/outpost_prisoner/proc/plan_creature_retreat(datum/ai_controller/controller) if(!creature_retreat_spot) return FALSE if(loc == creature_retreat_spot || world.time >= creature_retreat_until || !is_rioting()) @@ -115,7 +115,7 @@ controller.queue_behavior(/datum/ai_behavior/outpost_prisoner_creature_retreat) return TRUE -/mob/living/basic/outpost_prisoner/proc/finish_creature_retreat() +/mob/living/carbon/human/npc/outpost_prisoner/proc/finish_creature_retreat() creature_retreat_spot = null creature_retreat_until = 0 update_flee_speed() @@ -127,7 +127,7 @@ action_cooldown = 0.5 SECONDS /datum/ai_behavior/outpost_prisoner_creature_retreat/setup(datum/ai_controller/controller) - var/mob/living/basic/outpost_prisoner/prisoner = controller.pawn + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = controller.pawn var/turf/spot = prisoner?.creature_retreat_spot if(!spot) return FALSE @@ -136,7 +136,7 @@ return TRUE /datum/ai_behavior/outpost_prisoner_creature_retreat/perform(seconds_per_tick, datum/ai_controller/controller) - var/mob/living/basic/outpost_prisoner/prisoner = controller.pawn + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = controller.pawn if(!prisoner?.creature_retreat_spot || prisoner.loc != prisoner.creature_retreat_spot) return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED prisoner.finish_creature_retreat() @@ -146,7 +146,7 @@ . = ..() if(!succeeded) // No way through: they riot on from where they are. - var/mob/living/basic/outpost_prisoner/prisoner = controller.pawn + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = controller.pawn prisoner?.finish_creature_retreat() /** @@ -249,7 +249,7 @@ * everyone; otherwise it has to be within OUTPOST_PANIC_SIGHT_RANGE and in their sight, or within * OUTPOST_PANIC_DOWNED_RANGE for one that only frightens up close. */ -/datum/outpost_prison/proc/frightens(mob/living/basic/outpost_prisoner/prisoner, mob/living/creature, menace, loose) +/datum/outpost_prison/proc/frightens(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/creature, menace, loose) var/turf/here = get_turf(prisoner) var/turf/there = get_turf(creature) if(!here || !there || here.z != there.z) @@ -261,7 +261,7 @@ return get_dist(here, there) <= OUTPOST_PANIC_SIGHT_RANGE && can_see(here, there, OUTPOST_PANIC_SIGHT_RANGE) /// The nearest of `threats` (creature = menace) that frightens `prisoner`, or null. `loose` marks those loose in the cell block. -/datum/outpost_prison/proc/frightening_creature(mob/living/basic/outpost_prisoner/prisoner, list/threats, list/loose) +/datum/outpost_prison/proc/frightening_creature(mob/living/carbon/human/npc/outpost_prisoner/prisoner, list/threats, list/loose) var/mob/living/nearest var/nearest_distance = INFINITY for(var/mob/living/creature as anything in threats) @@ -276,7 +276,7 @@ // ===== THE PRISON'S TICK ===== /// Whether a creature can frighten `prisoner` now: present and awake in the wing's custody, not loose, and not the experiment's subject -/datum/outpost_prison/proc/can_panic(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/can_panic(mob/living/carbon/human/npc/outpost_prisoner/prisoner) return prisoner.prison == src && prisoner.phase == PRISONER_PRESENT && prisoner.stat == CONSCIOUS && !prisoner.experiment_subject && prisoner.trouble != PRISONER_TROUBLE_LOOSE /** @@ -289,7 +289,7 @@ for(var/mob/living/creature as anything in threats) loose[creature] = threats[creature] == CREATURE_MENACE_FULL && in_cell_block(creature) && !creature_shut_in(creature) var/shouts = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners.Copy()) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners.Copy()) if(QDELETED(prisoner)) continue if(!can_panic(prisoner)) @@ -317,7 +317,7 @@ * drops what they were doing (a wreck, squaring up to staff) and runs (start_panic()), or, already * running, rethinks the way (the panic's reconsider()). Returns TRUE if they shouted. */ -/datum/outpost_prison/proc/react_to_creature(mob/living/basic/outpost_prisoner/prisoner, mob/living/threat, seconds, may_shout) +/datum/outpost_prison/proc/react_to_creature(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/threat, seconds, may_shout) if(prisoner.can_be_dragged() || prisoner.pulledby) // Down, they neither run nor fight. prisoner.creature_foe_ref = null @@ -343,7 +343,7 @@ * `prisoner` breaks and runs (/datum/prisoner_activity/creature_panic), if their routine is free to. * `shout` has them say so. Returns TRUE if they shouted. */ -/datum/outpost_prison/proc/start_panic(mob/living/basic/outpost_prisoner/prisoner, shout = FALSE) +/datum/outpost_prison/proc/start_panic(mob/living/carbon/human/npc/outpost_prisoner/prisoner, shout = FALSE) if(prisoner.prison != src || prisoner.experiment_subject || !prisoner.routine_allowed()) return FALSE if(istype(prisoner.activity, /datum/prisoner_activity/creature_panic)) @@ -357,17 +357,17 @@ if(!shout || !prisoner.ai_running()) return FALSE prisoner.next_panic_line = world.time + OUTPOST_EXPERIMENT_PANIC_GAP * rand(4, 6) / 10 SECONDS - INVOKE_ASYNC(prisoner, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context), "creature_flee") + INVOKE_ASYNC(prisoner, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context), "creature_flee") return TRUE /// Still frightened with nothing in sight: they stay where they ran to, and go back to it if something else took them away -/datum/outpost_prison/proc/keep_hiding(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/keep_hiding(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(istype(prisoner.activity, /datum/prisoner_activity/creature_panic) || istype(prisoner.activity, /datum/prisoner_activity/flee_creature)) return start_panic(prisoner) /// Cuffed, down or held: nowhere to go, so they cower and shout now and then. Returns TRUE if they shouted. -/datum/outpost_prison/proc/cower_in_fright(mob/living/basic/outpost_prisoner/prisoner, may_shout) +/datum/outpost_prison/proc/cower_in_fright(mob/living/carbon/human/npc/outpost_prisoner/prisoner, may_shout) if(!may_shout && world.time < prisoner.next_panic_line) return FALSE prisoner.next_panic_line = world.time + OUTPOST_EXPERIMENT_PANIC_GAP * rand(8, 12) / 10 SECONDS @@ -377,11 +377,11 @@ if(!may_shout && !wing_can_speak()) return FALSE note_speech() - INVOKE_ASYNC(prisoner, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context), "creature_panic") + INVOKE_ASYNC(prisoner, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context), "creature_panic") return TRUE /// Nothing has frightened them for OUTPOST_PANIC_CALM_TIME, or they can no longer be frightened: back to their day -/datum/outpost_prison/proc/calm_from_panic(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/calm_from_panic(mob/living/carbon/human/npc/outpost_prisoner/prisoner) prisoner.creature_panic_left = 0 prisoner.panic_threat_ref = null prisoner.creature_reaction = null @@ -399,7 +399,7 @@ * mood and personality (outpost_prisoner_creature_fight_chance()). The roll holds for * OUTPOST_PANIC_ROLL_HOLD. Returns what they did. */ -/datum/outpost_prison/proc/creature_roll(mob/living/basic/outpost_prisoner/prisoner, mob/living/threat) +/datum/outpost_prison/proc/creature_roll(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/threat) if(prisoner.creature_reaction && world.time < prisoner.creature_reaction_until) return prisoner.creature_reaction var/reaction = forced_creature_reaction @@ -414,7 +414,7 @@ return reaction /// Goes at the creature, with their shiv if they have one. A fight they were in is forgotten. -/datum/outpost_prison/proc/stand_against_creature(mob/living/basic/outpost_prisoner/prisoner, mob/living/threat) +/datum/outpost_prison/proc/stand_against_creature(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/threat) if(prisoner.fight) end_fight(prisoner.fight) prisoner.cancel_threat() @@ -431,7 +431,7 @@ * (flee_spot()) and riot on from there, or back off where they stand with nowhere to go. Returns * TRUE if a rioter ran. */ -/datum/outpost_prison/proc/run_from_creature(mob/living/basic/outpost_prisoner/prisoner, mob/living/threat) +/datum/outpost_prison/proc/run_from_creature(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/threat) prisoner.creature_foe_ref = null if(!prisoner.is_rioting()) if(prisoner.fight) @@ -449,7 +449,7 @@ prisoner.creature_retreat_until = world.time + OUTPOST_PANIC_RETREAT_TIME prisoner.update_flee_speed() if(prisoner.ai_running() && prob(50)) - INVOKE_ASYNC(prisoner, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context), "creature_flee") + INVOKE_ASYNC(prisoner, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context), "creature_flee") return TRUE // ===== WHERE TO RUN ===== @@ -478,7 +478,7 @@ return steps /// Where they hide at home: their own cell's chair or bed (home_seat()), or failing that any free tile of their own cell they can walk to, or null -/datum/outpost_prison/proc/panic_home_spot(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/panic_home_spot(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/datum/outpost_prison_cell/home = prisoner.cell if(!home || !prisoner.walkable) return null @@ -496,7 +496,7 @@ * passes within OUTPOST_PANIC_PATH_MARGIN of it and no farther from it than they stand now. Once they * are inside the cell, only it coming in makes home unsafe. */ -/datum/outpost_prison/proc/home_is_safe(mob/living/basic/outpost_prisoner/prisoner, turf/home, mob/living/threat) +/datum/outpost_prison/proc/home_is_safe(mob/living/carbon/human/npc/outpost_prisoner/prisoner, turf/home, mob/living/threat) var/datum/outpost_prison_cell/own = prisoner.cell if(!own || !home) return FALSE @@ -533,7 +533,7 @@ * passing beside it that is farthest from it, out of its sight if any is, and not within * OUTPOST_PANIC_SPOT_MARGIN of it. Null when there is nowhere: they are cornered. */ -/datum/outpost_prison/proc/flee_spot(mob/living/basic/outpost_prisoner/prisoner, mob/living/threat) +/datum/outpost_prison/proc/flee_spot(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/living/threat) var/turf/here = get_turf(prisoner) var/turf/danger = get_turf(threat) if(!here || !danger || !length(prisoner.walkable)) @@ -718,7 +718,7 @@ /// What they shout: to be bolted in, on the way home or in it; to run, otherwise; about the dark, now and then, with a nightmare about /datum/prisoner_activity/creature_panic/proc/panic_line() var/mob/living/threat = prisoner.panic_threat() - var/nightmare = istype(threat, /mob/living/basic/outpost_experiment/nightmare) || (!threat && prisoner.prison?.experiment?.form == "nightmare") + var/nightmare = outpost_experiment_form_name(threat) == "nightmare" || (!threat && prisoner.prison?.experiment?.form == "nightmare") if(nightmare && prob(50)) return "nightmare_fear" return plan == "home" ? "creature_panic" : "creature_flee" diff --git a/voidcrew/modules/player_outposts/outpost_prison_pastimes.dm b/voidcrew/modules/player_outposts/outpost_prison_pastimes.dm index 52996783238..584decf82c2 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_pastimes.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_pastimes.dm @@ -70,7 +70,7 @@ /// Seconds since the last look for scrubbed marks var/mark_check_clock = 0 -/mob/living/basic/outpost_prisoner +/mob/living/carbon/human/npc/outpost_prisoner /// Between the lifts a card game gives them COOLDOWN_DECLARE(cards_mood_cooldown) /// Between the lifts a game of basketball with staff gives them @@ -83,7 +83,7 @@ /// Hooks up the prisoner's side of the pastimes; called from setup_extras(). Nothing to hook: the /// pastimes run from activities and the prison's clock. -/mob/living/basic/outpost_prisoner/proc/setup_pastimes() +/mob/living/carbon/human/npc/outpost_prisoner/proc/setup_pastimes() return /// Advances the party, the game with staff and the marks on the walls by `seconds` @@ -140,7 +140,7 @@ return found /// Whether `prisoner` could sit on `stool` now: they can walk there, and nobody else sits on it, stands on it or has it -/datum/outpost_prison/proc/stool_free_for(obj/structure/chair/stool, mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/stool_free_for(obj/structure/chair/stool, mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/turf/seat = get_turf(stool) if(QDELETED(stool) || !seat || !prisoner.walkable?[seat] || claimed_by_other(stool, prisoner)) return FALSE @@ -202,7 +202,7 @@ /// Whether members of the wing sitting at the table are dealt in var/deals_in_members = FALSE -/datum/prisoner_activity/table_game/New(mob/living/basic/outpost_prisoner/doer, datum/prisoner_activity/table_game/host_game) +/datum/prisoner_activity/table_game/New(mob/living/carbon/human/npc/outpost_prisoner/doer, datum/prisoner_activity/table_game/host_game) . = ..(doer) if(host_game) game_ref = WEAKREF(host_game) @@ -284,7 +284,7 @@ return best /// Whether `other` may be called over: free for leisure (the chat's rule), not hungry, and no rival of the host -/datum/prisoner_activity/table_game/proc/can_invite(mob/living/basic/outpost_prisoner/other) +/datum/prisoner_activity/table_game/proc/can_invite(mob/living/carbon/human/npc/outpost_prisoner/other) if(other == prisoner || QDELETED(other) || !other.routine_allowed() || !other.ai_running()) return FALSE var/datum/prisoner_activity/doing = other.activity @@ -303,7 +303,7 @@ free_stools++ if(!free_stools) return FALSE - for(var/mob/living/basic/outpost_prisoner/other in prison.prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/other in prison.prisoners) if(can_invite(other)) return TRUE return FALSE @@ -454,7 +454,7 @@ if(own && prisoner.buckled == own) seats += list(list(prisoner, own, prison.table_beside(own))) for(var/datum/weakref/joiner_ref as anything in joiner_refs) - var/mob/living/basic/outpost_prisoner/joiner = joiner_ref.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/joiner = joiner_ref.resolve() var/datum/prisoner_activity/table_game/seat = joiner?.activity if(!istype(seat) || seat.game_ref?.resolve() != src || !seat.started) continue @@ -491,7 +491,7 @@ var/datum/outpost_prison/prison = prisoner.prison var/list/live = list() for(var/datum/weakref/joiner_ref as anything in joiner_refs) - var/mob/living/basic/outpost_prisoner/joiner = joiner_ref.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/joiner = joiner_ref.resolve() var/datum/prisoner_activity/table_game/seat = joiner?.activity if(istype(seat) && seat.game_ref?.resolve() == src) live += joiner_ref @@ -500,14 +500,14 @@ if(room <= 0) return 0 var/list/candidates = list() - for(var/mob/living/basic/outpost_prisoner/other in shuffle(prison.prisoners)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/other in shuffle(prison.prisoners)) if(can_invite(other)) candidates += other - var/mob/living/basic/outpost_prisoner/first_called + var/mob/living/carbon/human/npc/outpost_prisoner/first_called var/came = 0 while(room > 0 && length(candidates)) - var/mob/living/basic/outpost_prisoner/best - for(var/mob/living/basic/outpost_prisoner/other as anything in candidates) + var/mob/living/carbon/human/npc/outpost_prisoner/best + for(var/mob/living/carbon/human/npc/outpost_prisoner/other as anything in candidates) if(!best || prison.affinity(prisoner, other) > prison.affinity(prisoner, best)) best = other candidates -= best @@ -523,7 +523,7 @@ return came /// Gives `other` a seat at this game and sends them to it. TRUE if they are coming. -/datum/prisoner_activity/table_game/proc/seat_joiner(mob/living/basic/outpost_prisoner/other) +/datum/prisoner_activity/table_game/proc/seat_joiner(mob/living/carbon/human/npc/outpost_prisoner/other) if(!seat_type || QDELETED(other)) return FALSE var/datum/prisoner_activity/table_game/seat = new seat_type(other, src) @@ -537,7 +537,7 @@ /// Sends everyone the host called over back to their own business /datum/prisoner_activity/table_game/proc/release_joiners() for(var/datum/weakref/joiner_ref as anything in joiner_refs) - var/mob/living/basic/outpost_prisoner/joiner = joiner_ref.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/joiner = joiner_ref.resolve() var/datum/prisoner_activity/table_game/seat = joiner?.activity if(istype(seat) && seat.game_ref?.resolve() == src) joiner.end_activity() @@ -738,7 +738,7 @@ /datum/prisoner_activity/cards/proc/reward_players(list/in_hand) var/datum/outpost_prison/prison = prisoner.prison for(var/mob/living/player as anything in in_hand) - var/mob/living/basic/outpost_prisoner/inmate = player + var/mob/living/carbon/human/npc/outpost_prisoner/inmate = player if(istype(inmate)) if(COOLDOWN_FINISHED(inmate, cards_mood_cooldown)) COOLDOWN_START(inmate, cards_mood_cooldown, PRISON_CARDS_MOOD_GAP) @@ -755,19 +755,19 @@ if(!prob(PRISON_CARDS_TALK_CHANCE)) return var/list/inmate_losers = list() - for(var/mob/living/basic/outpost_prisoner/loser in in_hand) + for(var/mob/living/carbon/human/npc/outpost_prisoner/loser in in_hand) if(loser != winner) inmate_losers += loser - var/mob/living/basic/outpost_prisoner/inmate_winner = is_outpost_prisoner(winner) ? winner : null + var/mob/living/carbon/human/npc/outpost_prisoner/inmate_winner = is_outpost_prisoner(winner) ? winner : null if(inmate_winner && (!length(inmate_losers) || prob(55))) - var/mob/living/basic/outpost_prisoner/beaten = length(inmate_losers) ? pick(inmate_losers) : null + var/mob/living/carbon/human/npc/outpost_prisoner/beaten = length(inmate_losers) ? pick(inmate_losers) : null if(beaten) inmate_winner.face_atom(beaten) inmate_winner.say_context("cards_win", beaten) return if(!length(inmate_losers)) return - var/mob/living/basic/outpost_prisoner/grumbler = pick(inmate_losers) + var/mob/living/carbon/human/npc/outpost_prisoner/grumbler = pick(inmate_losers) grumbler.face_atom(winner) if(inmate_winner) grumbler.say_context("cards_lose", inmate_winner) @@ -792,8 +792,8 @@ var/list/talkers = seated_prisoners() if(!length(talkers)) return - var/mob/living/basic/outpost_prisoner/speaker = pick(talkers) - var/mob/living/basic/outpost_prisoner/other = length(talkers) > 1 ? pick(talkers - speaker) : null + var/mob/living/carbon/human/npc/outpost_prisoner/speaker = pick(talkers) + var/mob/living/carbon/human/npc/outpost_prisoner/other = length(talkers) > 1 ? pick(talkers - speaker) : null if(speaker.say_context("cards", other)) prison.note_speech() @@ -807,7 +807,7 @@ return FALSE COOLDOWN_START(prison, cards_missing_cooldown, PRISON_CARDS_MISSING_GAP) var/list/talkers = seated_prisoners() - var/mob/living/basic/outpost_prisoner/speaker = length(talkers) ? pick(talkers) : prisoner + var/mob/living/carbon/human/npc/outpost_prisoner/speaker = length(talkers) ? pick(talkers) : prisoner return speaker.say_context("cards_missing") /datum/prisoner_activity/cards/end_game() @@ -815,7 +815,7 @@ /// The admin panel's card game: a prisoner free to play takes a deck to its table and calls others over. A log line, or null. /datum/outpost_prison/proc/admin_start_cards() - for(var/mob/living/basic/outpost_prisoner/host in shuffle(prisoners)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/host in shuffle(prisoners)) if(!host.ai_running() || !host.routine_allowed()) continue var/datum/prisoner_activity/doing = host.activity @@ -912,7 +912,7 @@ /// The prisoner rolling against the host, while they still sit at the table /datum/prisoner_activity/dice/proc/partner() - var/mob/living/basic/outpost_prisoner/other = partner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/other = partner_ref?.resolve() return (other && front_of(other)) ? other : null /datum/prisoner_activity/dice/play_step() @@ -923,7 +923,7 @@ return ACTIVITY_CONTINUE if(--roll_wait > 0) return ACTIVITY_CONTINUE - var/mob/living/basic/outpost_prisoner/roller = turn == 1 ? prisoner : partner() + var/mob/living/carbon/human/npc/outpost_prisoner/roller = turn == 1 ? prisoner : partner() if(rounds_left <= 0 || !roller || !roll_die(roller)) stage = "tidy" steps = 0 @@ -931,8 +931,8 @@ return ACTIVITY_CONTINUE /// Where `roller` rolls to: the table in front of the other player, else the table two tiles off -/datum/prisoner_activity/dice/proc/roll_target(mob/living/basic/outpost_prisoner/roller) - var/mob/living/basic/outpost_prisoner/other = roller == prisoner ? partner() : prisoner +/datum/prisoner_activity/dice/proc/roll_target(mob/living/carbon/human/npc/outpost_prisoner/roller) + var/mob/living/carbon/human/npc/outpost_prisoner/other = roller == prisoner ? partner() : prisoner var/turf/front = front_of(other) if(front && front != get_turf(roller)) return front @@ -942,7 +942,7 @@ return front_of(roller) /// `roller` picks up the die and rolls it across the table. TRUE if it is rolling. -/datum/prisoner_activity/dice/proc/roll_die(mob/living/basic/outpost_prisoner/roller) +/datum/prisoner_activity/dice/proc/roll_die(mob/living/carbon/human/npc/outpost_prisoner/roller) var/obj/item/dice/die = die_ref?.resolve() if(QDELETED(die)) return FALSE @@ -980,11 +980,11 @@ /// Both have rolled: the higher roll wins and usually says so. Returns the winner, or null for a draw. /datum/prisoner_activity/dice/proc/settle_round() last_winner_ref = null - var/mob/living/basic/outpost_prisoner/other = partner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/other = partner_ref?.resolve() if(!other || rolls[1] == rolls[2]) return null - var/mob/living/basic/outpost_prisoner/winner = rolls[1] > rolls[2] ? prisoner : other - var/mob/living/basic/outpost_prisoner/loser = winner == prisoner ? other : prisoner + var/mob/living/carbon/human/npc/outpost_prisoner/winner = rolls[1] > rolls[2] ? prisoner : other + var/mob/living/carbon/human/npc/outpost_prisoner/loser = winner == prisoner ? other : prisoner last_winner_ref = WEAKREF(winner) if(prob(70) && winner.stat == CONSCIOUS) winner.face_atom(loser) @@ -1034,7 +1034,7 @@ /// The prisoner whose birthday it is and who has not had their party, if any is in the wing /datum/outpost_prison/proc/birthday_host() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.has_birthday && !prisoner.party_done && prisoner.stat != DEAD && prisoner.phase == PRISONER_PRESENT) return prisoner return null @@ -1043,7 +1043,7 @@ * Keeps `cake` for `host`'s party: nobody eats it as a meal while it waits (reserved_supply()). * `giver` is whoever put it on the hatch or handed it over. Never sleeps. Returns TRUE if it is kept. */ -/datum/outpost_prison/proc/start_party(mob/living/basic/outpost_prisoner/host, obj/item/food/cake/cake, mob/living/giver) +/datum/outpost_prison/proc/start_party(mob/living/carbon/human/npc/outpost_prisoner/host, obj/item/food/cake/cake, mob/living/giver) if(party_stage || QDELETED(host) || !istype(cake) || QDELETED(cake)) return FALSE if(!host.has_birthday || host.party_done || host.stat == DEAD || host.phase != PRISONER_PRESENT || !(host in prisoners)) @@ -1059,7 +1059,7 @@ /// Sends the host to fetch the cake, once they are free. TRUE if they are on it. /datum/outpost_prison/proc/try_start_party_host() - var/mob/living/basic/outpost_prisoner/host = party_host_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/host = party_host_ref?.resolve() if(!host || party_stage != PARTY_WAITING || !party_cake()) return FALSE if(istype(host.activity, /datum/prisoner_activity/party_host)) @@ -1078,7 +1078,7 @@ return TRUE /// Whether `guest` would come over to the party: awake, free and not busy with a meal or a duty -/datum/outpost_prison/proc/party_guest_free(mob/living/basic/outpost_prisoner/guest) +/datum/outpost_prison/proc/party_guest_free(mob/living/carbon/human/npc/outpost_prisoner/guest) if(QDELETED(guest) || !guest.ai_running() || !guest.routine_allowed()) return FALSE var/datum/prisoner_activity/doing = guest.activity @@ -1093,7 +1093,7 @@ * Returns TRUE if it began. */ /datum/outpost_prison/proc/party_ready(turf/spot) - var/mob/living/basic/outpost_prisoner/host = party_host_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/host = party_host_ref?.resolve() if(party_stage != PARTY_WAITING || !host || !spot) return FALSE party_spot = spot @@ -1101,14 +1101,14 @@ party_stage_seconds = 0 party_scene_seconds = 0 party_guests = list() - for(var/mob/living/basic/outpost_prisoner/guest in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/guest in prisoners) if(guest != host) invite_party_guest(guest) host.manual_emote("waves everyone over.") return TRUE /// Calls `guest` over to the party. TRUE if they are coming. -/datum/outpost_prison/proc/invite_party_guest(mob/living/basic/outpost_prisoner/guest) +/datum/outpost_prison/proc/invite_party_guest(mob/living/carbon/human/npc/outpost_prisoner/guest) if(!party_spot || !party_guest_free(guest)) return FALSE var/datum/prisoner_activity/party_guest/coming = new(guest) @@ -1123,7 +1123,7 @@ /datum/outpost_prison/proc/present_guests(arrived_only = TRUE) var/list/found = list() for(var/datum/weakref/guest_ref as anything in party_guests) - var/mob/living/basic/outpost_prisoner/guest = guest_ref.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/guest = guest_ref.resolve() var/datum/prisoner_activity/party_guest/attending = guest?.activity if(!istype(attending) || guest.stat != CONSCIOUS || (arrived_only && !attending.started)) continue @@ -1139,7 +1139,7 @@ /datum/outpost_prison/proc/party_tick(seconds) if(!party_stage) return - var/mob/living/basic/outpost_prisoner/host = party_host_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/host = party_host_ref?.resolve() if(!host || !(host in prisoners) || host.stat == DEAD || host.phase != PRISONER_PRESENT) end_party() return @@ -1174,7 +1174,7 @@ /// The candles go out, and the guests cheer and clap /datum/outpost_prison/proc/blow_candles() - var/mob/living/basic/outpost_prisoner/host = party_host_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/host = party_host_ref?.resolve() var/obj/item/food/cake/cake = party_cake() if(!host || !cake) end_party() @@ -1184,7 +1184,7 @@ host.face_atom(cake) host.manual_emote("blows out the candles.") var/cheers = 0 - for(var/mob/living/basic/outpost_prisoner/guest as anything in shuffle(present_guests())) + for(var/mob/living/carbon/human/npc/outpost_prisoner/guest as anything in shuffle(present_guests())) guest.face_atom(cake) if(cheers < 2) addtimer(CALLBACK(src, PROC_REF(say_life_line), WEAKREF(guest), "birthday_party", WEAKREF(host)), (0.5 + 0.8 * cheers) SECONDS) @@ -1199,7 +1199,7 @@ * table. Crumbs are left behind. */ /datum/outpost_prison/proc/serve_party() - var/mob/living/basic/outpost_prisoner/host = party_host_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/host = party_host_ref?.resolve() var/obj/item/food/cake/cake = party_cake() var/turf/center = party_spot || get_turf(cake) if(!host || !cake || !center) @@ -1216,11 +1216,11 @@ host.visible_message(span_notice("[host] cuts [cake] and passes the slices round.")) qdel(cake) var/list/diners = list(host) - for(var/mob/living/basic/outpost_prisoner/guest as anything in present_guests()) + for(var/mob/living/carbon/human/npc/outpost_prisoner/guest as anything in present_guests()) if(get_dist(guest, center) <= PRISON_PARTY_REACH) diners += guest party_diners = list() - for(var/mob/living/basic/outpost_prisoner/diner as anything in diners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/diner as anything in diners) diner.drop_held_item() // Beside the table they take theirs off it; further round, the slice is passed along to them. // Nobody picks anything up from further off than they can reach (take_item()). @@ -1237,12 +1237,12 @@ /// Everyone eats their slice; the host thanks whoever brought the cake, and has had their party /datum/outpost_prison/proc/finish_party() - var/mob/living/basic/outpost_prisoner/host = party_host_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/host = party_host_ref?.resolve() var/fed = 0 for(var/list/entry as anything in party_diners) var/datum/weakref/diner_ref = entry[1] var/datum/weakref/slice_ref = entry[2] - var/mob/living/basic/outpost_prisoner/diner = diner_ref.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/diner = diner_ref.resolve() var/obj/item/food/slice = slice_ref.resolve() if(!diner || !slice || diner.held_item != slice || diner.stat != CONSCIOUS) continue @@ -1268,7 +1268,7 @@ * `diner` eats a slice of the birthday cake. It counts as a cooked meal however the cake was made * (a birthday cake is junk food to outpost_prisoner_food_tier()), as the build plan asks. */ -/datum/outpost_prison/proc/party_feed(mob/living/basic/outpost_prisoner/diner, obj/item/food/slice) +/datum/outpost_prison/proc/party_feed(mob/living/carbon/human/npc/outpost_prisoner/diner, obj/item/food/slice) if(outpost_prisoner_food_tier(slice) == "cooked") diner.eat_food(slice) return @@ -1289,7 +1289,7 @@ /// The party is over or off: everyone goes back to their day, and the cake (if uneaten) is ordinary food /datum/outpost_prison/proc/end_party() var/list/guests = party_guests - var/mob/living/basic/outpost_prisoner/host = party_host_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/host = party_host_ref?.resolve() clear_party_state() dismiss_party_guests(guests) if(host && istype(host.activity, /datum/prisoner_activity/party_host)) @@ -1297,7 +1297,7 @@ /datum/outpost_prison/proc/dismiss_party_guests(list/guests) for(var/datum/weakref/guest_ref as anything in guests) - var/mob/living/basic/outpost_prisoner/guest = guest_ref.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/guest = guest_ref.resolve() if(guest && istype(guest.activity, /datum/prisoner_activity/party_guest)) guest.end_activity() @@ -1314,7 +1314,7 @@ party_diners = list() /// Whether `thing` is the cake kept for a party, which nobody may eat as a meal -/datum/outpost_prison/proc/reserved_supply(obj/item/thing, mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/reserved_supply(obj/item/thing, mob/living/carbon/human/npc/outpost_prisoner/prisoner) return !!party_stage && !!thing && thing == party_cake() /** @@ -1322,7 +1322,7 @@ * eaten this way. A whole cake handed to the prisoner whose birthday it is starts their party: they * take it, and fetch it to a table once they are free. Runs in a signal handler: never sleeps. */ -/datum/outpost_prison/proc/pastime_pre_eat(mob/living/basic/outpost_prisoner/prisoner, atom/food, mob/living/feeder) +/datum/outpost_prison/proc/pastime_pre_eat(mob/living/carbon/human/npc/outpost_prisoner/prisoner, atom/food, mob/living/feeder) if(reserved_supply(food, prisoner)) // Handing the kept cake to the birthday prisoner saves them fetching it. if(party_stage == PARTY_WAITING && prisoner == party_host_ref?.resolve() && istype(feeder) && food.loc == feeder && !prisoner.held_item && feeder.temporarilyRemoveItemFromInventory(food)) @@ -1359,7 +1359,7 @@ if(!QDELETED(whole) && whole.loc == hatch?.loc) cake = whole break - var/mob/living/basic/outpost_prisoner/host = birthday_host() + var/mob/living/carbon/human/npc/outpost_prisoner/host = birthday_host() if(!cake || !host || !start_party(host, cake, user)) return FALSE INVOKE_ASYNC(src, PROC_REF(try_start_party_host)) @@ -1591,7 +1591,7 @@ /// The hoop a prisoner is shooting at now, or null when nobody is playing /datum/outpost_prison/proc/game_hoop() - for(var/mob/living/basic/outpost_prisoner/player in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/player in prisoners) var/datum/prisoner_activity/basketball/game = player.activity if(!istype(game) || !game.started || player.stat != CONSCIOUS) continue @@ -1603,7 +1603,7 @@ /// Prisoners playing basketball now /datum/outpost_prison/proc/basketball_players() var/list/players = list() - for(var/mob/living/basic/outpost_prisoner/player in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/player in prisoners) if(player.stat == CONSCIOUS && istype(player.activity, /datum/prisoner_activity/basketball) && player.activity.started) players += player return players @@ -1611,7 +1611,7 @@ /// Prisoners watching the game at `hoop` /datum/outpost_prison/proc/game_watchers(obj/structure/hoop/hoop) var/list/watchers = list() - for(var/mob/living/basic/outpost_prisoner/watcher in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/watcher in prisoners) var/datum/prisoner_activity/watch_game/watching = watcher.activity if(istype(watching) && watching.started && watcher.stat == CONSCIOUS && watching.hoop_ref?.resolve() == hoop) watchers += watcher @@ -1668,7 +1668,7 @@ /// Each prisoner playing now cheers up for playing with staff, at most every PRISON_STAFF_GAME_MOOD_GAP /datum/outpost_prison/proc/lift_staff_game_players() - for(var/mob/living/basic/outpost_prisoner/player as anything in basketball_players()) + for(var/mob/living/carbon/human/npc/outpost_prisoner/player as anything in basketball_players()) if(!COOLDOWN_FINISHED(player, staff_game_mood_cooldown)) continue COOLDOWN_START(player, staff_game_mood_cooldown, PRISON_STAFF_GAME_MOOD_GAP) @@ -1683,11 +1683,11 @@ return var/mob/living/shooter = shooter_ref?.resolve() var/list/watchers = game_watchers(hoop) - for(var/mob/living/basic/outpost_prisoner/watcher as anything in watchers) + for(var/mob/living/carbon/human/npc/outpost_prisoner/watcher as anything in watchers) watcher.face_atom(hoop) if(score_event) var/list/announcers = length(watchers) ? watchers : basketball_players() - var/mob/living/basic/outpost_prisoner/announcer = length(announcers) ? pick(announcers) : null + var/mob/living/carbon/human/npc/outpost_prisoner/announcer = length(announcers) ? pick(announcers) : null var/mob/living/staff = staff_ref?.resolve() switch(score_event) if("call") @@ -1698,7 +1698,7 @@ announcer?.say_to_staff("game_lost", staff) if(scored && length(watchers) && COOLDOWN_FINISHED(src, crowd_clap_cooldown)) COOLDOWN_START(src, crowd_clap_cooldown, PRISON_CROWD_CLAP_GAP) - for(var/mob/living/basic/outpost_prisoner/watcher as anything in watchers) + for(var/mob/living/carbon/human/npc/outpost_prisoner/watcher as anything in watchers) if(prob(70)) watcher.manual_emote("claps.") playsound(watcher, pick('sound/mobs/humanoids/human/clap/clap1.ogg', 'sound/mobs/humanoids/human/clap/clap2.ogg', 'sound/mobs/humanoids/human/clap/clap3.ogg'), 35, TRUE) @@ -1708,7 +1708,7 @@ if(!context) return COOLDOWN_START(src, crowd_line_cooldown, PRISON_CROWD_LINE_GAP) - var/mob/living/basic/outpost_prisoner/speaker = pick(watchers) + var/mob/living/carbon/human/npc/outpost_prisoner/speaker = pick(watchers) if(is_outpost_prisoner(shooter)) speaker.say_context(context, shooter) else if(shooter) @@ -1822,7 +1822,7 @@ return initials || "Someone" /// The crayon state for a prisoner's mark: their first initial, or a doodle -/proc/outpost_prisoner_mark_state(mob/living/basic/outpost_prisoner/prisoner) +/proc/outpost_prisoner_mark_state(mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/letter = lowertext(copytext(prisoner.real_name, 1, 2)) if(prob(PRISON_MARK_INITIAL_CHANCE) && length(letter) == 1 && text2ascii(letter) >= 97 && text2ascii(letter) <= 122) return letter @@ -1844,7 +1844,7 @@ * "R.D. was here." A cell keeps PRISON_CELL_MARKS_MAX marks; a new one replaces the oldest. * Crayon marks are not mess (outpost_prison_conditions.dm). Returns the mark, or null. */ -/datum/outpost_prison/proc/add_cell_mark(mob/living/basic/outpost_prisoner/prisoner, turf/wall) +/datum/outpost_prison/proc/add_cell_mark(mob/living/carbon/human/npc/outpost_prisoner/prisoner, turf/wall) var/datum/outpost_prison_cell/home = prisoner?.cell if(!home || !isclosedturf(wall)) return null @@ -1871,7 +1871,7 @@ /// A mark is going for a newer one: whoever made it no longer looks for it /datum/outpost_prison/proc/forget_wall_mark(obj/effect/decal/cleanable/crayon/mark) - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.wall_mark_ref?.resolve() == mark) prisoner.wall_mark_ref = null prisoner.wall_mark_spot = null @@ -1882,7 +1882,7 @@ */ /datum/outpost_prison/proc/check_scrubbed_marks() var/noticed = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(!prisoner.wall_mark_ref || prisoner.stat != CONSCIOUS || prisoner.phase != PRISONER_PRESENT) continue var/obj/effect/decal/cleanable/crayon/mark = prisoner.wall_mark_ref.resolve() diff --git a/voidcrew/modules/player_outposts/outpost_prison_prisoner.dm b/voidcrew/modules/player_outposts/outpost_prison_prisoner.dm index 369d99e208c..a3a2f07fa06 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_prisoner.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_prisoner.dm @@ -1,61 +1,51 @@ /** * # Outpost prisoner * - * An inmate of a player outpost's prison wing (outpost_prison_core.dm). Each prisoner owns one - * cell, beams into it on arrival and out of it on release, and fills the time in between with the - * routine in outpost_prison_routine.dm. They talk (outpost_prison_dialogue.dm), and when unhappy - * they threaten, fight, riot and escape (outpost_prison_trouble.dm, outpost_prison_riot.dm). + * An inmate of a player outpost's prison wing (outpost_prison_core.dm), and a real human body + * (voidcrew/modules/human_npcs/): they breathe, bleed, bruise, stamcrit, go into crit, die and can be + * revived through tg's own code, like anyone. Each prisoner owns one cell, beams into it on arrival + * and out of it on release, and fills the time in between with the routine in + * outpost_prison_routine.dm. They talk (outpost_prison_dialogue.dm), and when unhappy they threaten, + * fight, riot and escape (outpost_prison_trouble.dm, outpost_prison_riot.dm). * * Needs, on 0-100 scales: `hunger` falls over time and food restores it, by how good the food - * is; `uniform_grime` rises over time, three times as fast at sport, and a cleaner prison uniform - * resets it. Health does not come back on its own; brute medical stacks treat it. Arrivals come in - * hungry, a third in a stained uniform and a fifth roughed up in transfer. A thought bubble with - * the item they need shows when one needs attention, cycling when they need several. They bleed - * when hit, and drip while badly hurt. They take supplies only from a serving hatch or from a - * person's hand (outpost_prison_core.dm). + * is (the prison's own meter: human NPCs have tg's hunger off); `uniform_grime` rises over time, + * three times as fast at sport, shows on the real prison jumpsuit they wear, and a cleaner prison + * uniform resets it. Health does not come back on its own; treatment does. Arrivals come in hungry, a + * third in a stained uniform and a fifth roughed up in transfer (real limb damage). A thought bubble + * with the item they need shows when one needs attention, cycling when they need several. They take + * supplies only from a serving hatch or from a person's hand (outpost_prison_core.dm), into a real hand. * - * Awake, they cannot be dragged onto things or boxed, and only a calm one (calm_for_pull()) can be - * pulled, going along with it (outpost_prison_warden_tools.dm). Knocked down, in stamina crit, - * cuffed or dead, staff can drag them; stamina crit lasts PRISONER_STAMCRIT_TIME after the last - * hit. Cuffs and lockdown are in outpost_prison_capture.dm. + * Owner ruling OC-11: their jumpsuit, contraband and shivs are ordinary items, not locked to them, so + * they can be searched, stripped and disarmed like anyone. Awake and free they keep out of bags and + * lockers (a bluespace bag is a way out of the wing); down or dead they can be bagged. Anyone can + * pull them: a calm one goes along with it (outpost_prison_warden_tools.dm), one making trouble + * resists it, as anyone can. Cuffs (tg's) and lockdown are in outpost_prison_capture.dm. */ /// Trait source for the beam holding a prisoner still #define PRISONER_BEAM_TRAIT "outpost_prisoner_beam" /// Offset source for sitting on a bed edge #define PRISONER_SITTING_OFFSET "outpost_prisoner_sitting" +/// Trait source for what only an awake prisoner on their feet refuses (a bag, a locker) +#define PRISONER_AWAKE_TRAIT "outpost_prisoner_awake" -/mob/living/basic/outpost_prisoner +/mob/living/carbon/human/npc/outpost_prisoner name = "prisoner" desc = "An inmate of the outpost's prison wing." - icon = 'icons/mob/simple/simple_human.dmi' - unique_name = FALSE combat_mode = FALSE - mob_biotypes = MOB_ORGANIC | MOB_HUMANOID - sentience_type = SENTIENCE_HUMANOID - maxHealth = 100 - health = 100 - speed = 2 - // Heavy while awake, so nobody shoves them about; see update_drag_resistance(). - move_resist = MOVE_FORCE_VERY_STRONG - density = TRUE - basic_mob_flags = NONE - // tg's human deathgasp - death_message = "seizes up and falls limp, their eyes dead and lifeless..." - // They lie down on beds, when knocked down and when dead. - mobility_flags = MOBILITY_FLAGS_REST_CAPABLE_DEFAULT - rotate_on_lying = TRUE - blood_volume = BLOOD_VOLUME_NORMAL - // Batons knock them down, as they do people. - status_flags = CANPUSH | CANSTUN | CANKNOCKDOWN - stamina_regen_time = PRISONER_STAMCRIT_TIME - // No air needs yet: a breach must not kill the inmates. - unsuitable_atmos_damage = 0 - unsuitable_cold_damage = 0 - unsuitable_heat_damage = 0 - response_help_continuous = "pats" - response_help_simple = "pat" + faction = list(FACTION_NEUTRAL) ai_controller = /datum/ai_controller/basic_controller/outpost_prisoner + npc_outfit = /datum/outfit/outpost_prisoner + // Owner ruling OC-11: their jumpsuit, contraband and shivs are ordinary items, so shakedowns, + // confiscation and uniform swaps work. Searched and stripped like anyone. + npc_gear_locked = FALSE + // They stop once someone is down (defaults 1.13). + npc_target_stat = HUMAN_NPC_SPARES_DOWNED + // The prison owns the body: it lies in the cell block until carried out (outpost_prison_economy.dm). + npc_corpse_lifetime = 0 + // No air tank: the cell block's emergency lockers have the masks and tanks (outpost_prison_conditions.dm). + npc_internals = TRUE /// The prison holding them var/datum/outpost_prison/prison @@ -80,8 +70,6 @@ var/locked_in_seconds = 0 /// Outfit whose look they wear var/outfit_path - /// Which of the people wearing that outfit they look like (outpost_npc_looks.dm) - var/look_number = 1 /// The need their thought bubble is about, if any; see update_bubble() var/bubble /// The bubble that is up now, if one is; it pops up now and then rather than staying @@ -93,7 +81,7 @@ var/bubble_timer /// Which grime overlay they show: 0 none, 1 dirty, 2 filthy var/grime_stage = 0 - /// What they are carrying, held in their contents + /// What they are carrying in their hand for the prison's routine (take_item()), a real item in a real hand var/obj/item/held_item /// What they are holding a hand out for, one activity tick before they take it (see reach_for()) var/datum/weakref/reaching_ref @@ -117,7 +105,7 @@ var/well_fed_left = 0 /// Came in wearing a stained transfer uniform var/arrived_stained = FALSE - /// Brute damage they carry from transfer, applied when they beam in, and whether they came in hurt + /// Health they lose to a rough transfer, as bruising when they beam in, and whether they came in hurt var/arrival_brute = 0 var/arrived_hurt = FALSE /// Seconds the thought bubble has shown the current set of needs, for cycling through them @@ -129,6 +117,8 @@ var/last_cared_at = 0 /// world.time they last got the lift of a shared meal var/shared_meal_at = 0 + /// The serum turned them into an experiment's creature: off the roster, no longer treated as an inmate + var/experiment_turned = FALSE /// The criminal they were, when a bounty hunter caught them (outpost_prison_bounty.dm); null for an ordinary prisoner var/datum/bounty_record/bounty_record COOLDOWN_DECLARE(speech_cooldown) @@ -142,97 +132,135 @@ /// Running while what they last said is up over their head: no thought bubble (hush_bubble()) COOLDOWN_DECLARE(bubble_hush) -/mob/living/basic/outpost_prisoner/Initialize(mapload, datum/bounty_record/record) - gender = pick(MALE, FEMALE) - // A caught bounty criminal (admit_next()) keeps their body and who they were (outpost_prison_bounty.dm). +/** + * The second argument is a caught criminal's record (admit_next(), outpost_prison_bounty.dm), never a + * human NPC spawn order: a bounty prisoner keeps the face the record says they were caught with (the + * base dresses a /datum/bounty_record look). Anyone else is a random person in one of the prison's + * jumpsuits. Prisoners are made one at a time as they are admitted, so they don't go through the + * human NPC spawn queue. + */ +/mob/living/carbon/human/npc/outpost_prisoner/Initialize(mapload, datum/bounty_record/record) + if(!istype(record)) + record = null bounty_record = record if(record) apply_bounty_body(record) - . = ..() - real_name = generate_random_name_species_based(gender, TRUE, /datum/species/human) - name = real_name + npc_look = record + // The plain jumpsuit: the glasses and beanie variants would hide their hair or fake their eyewear + npc_outfit = /datum/outfit/outpost_prisoner + else + npc_outfit = pick(/datum/outfit/outpost_prisoner, /datum/outfit/outpost_prisoner/glasses, /datum/outfit/outpost_prisoner/beanie) + outfit_path = npc_outfit + . = ..(mapload) + // They stroll; a runner or a rioter breaks into a run (set_prison_pace()). + set_prison_pace(hurry = FALSE) roll_arrival() var/list/personalities = outpost_prisoner_dialogue("personalities") personality = length(personalities) ? pick(personalities) : "quiet" var/list/crimes = outpost_prisoner_dialogue("crimes") crime = length(crimes) ? pick(crimes) : "unpaid docking fees" - outfit_path = pick(/datum/outfit/outpost_prisoner, /datum/outfit/outpost_prisoner/glasses, /datum/outfit/outpost_prisoner/beanie) - look_number = random_outpost_npc_look_number() if(record) apply_bounty_record(record) - INVOKE_ASYNC(src, PROC_REF(build_look)) + uniform_grime_to_suit() // One shared list: element arguments are keyed by list reference. var/static/list/edible_types = list(/obj/item/food) AddElement(/datum/element/basic_eating, food_types = edible_types) - AddElement(/datum/element/footstep, footstep_type = FOOTSTEP_MOB_SHOE) RegisterSignal(src, COMSIG_MOB_PRE_EAT, PROC_REF(on_pre_eat)) RegisterSignal(src, COMSIG_MOB_ATE, PROC_REF(on_ate)) RegisterSignal(src, COMSIG_ATOM_ITEM_INTERACTION, PROC_REF(on_item_interaction)) + // Whatever lands in their hands by tg's own means (a catch, a hand-over) is what they hold too + RegisterSignal(src, COMSIG_MOB_EQUIPPED_ITEM, PROC_REF(on_equipped_item)) RegisterSignal(src, COMSIG_MOB_AFTER_APPLY_DAMAGE, PROC_REF(on_damaged)) RegisterSignal(src, COMSIG_LIVING_HEALTH_UPDATE, PROC_REF(on_health_update)) // Talking puts the thought bubble away (manual_emote() below covers the prison's own emotes). RegisterSignals(src, list(COMSIG_MOB_SAY, COMSIG_MOB_EMOTE), PROC_REF(on_speech)) - // Dragging only while they are down or cuffed (can_be_dragged()); pulling also while calm (pull_allowed()). - RegisterSignal(src, COMSIG_MOUSEDROP_ONTO, PROC_REF(block_being_dragged)) - RegisterSignal(src, COMSIG_ATOM_CAN_BE_PULLED, PROC_REF(check_pullable)) - // Changes to being down reach update_drag_resistance() through the living trait handlers - // overridden below; registering those trait signals here would replace living's own. - ADD_TRAIT(src, TRAIT_NO_CONTAINMENT, INNATE_TRAIT) - ADD_TRAIT(src, TRAIT_NO_STORAGE_INSERT, INNATE_TRAIT) + // Members only put cuffs on them (outpost_prison_capture.dm); tg's handcuffs do the rest. + RegisterSignal(src, COMSIG_CARBON_CUFF_ATTEMPTED, PROC_REF(on_cuff_attempt)) + // Cuffs going on and off, and going down and getting up (crit, stamcrit, knockdowns), reach + // update_drag_resistance() through the living trait handlers overridden below; registering those + // trait signals here would replace living's own. setup_trouble() setup_containment() setup_extras() last_health = health + update_drag_resistance() -/mob/living/basic/outpost_prisoner/Destroy() +/mob/living/carbon/human/npc/outpost_prisoner/Destroy() end_activity(cancel_ai = FALSE) clear_trouble() - if(held_item) - held_item.forceMove(drop_location()) - remove_cuffs() prison?.forget(src) prison = null cell = null walkable = null reachable = null + held_item = null deltimer(bubble_timer) if(thought) vis_contents -= thought QDEL_NULL(thought) return ..() -/mob/living/basic/outpost_prisoner/Exited(atom/movable/gone, direction) +/mob/living/carbon/human/npc/outpost_prisoner/Exited(atom/movable/gone, direction) . = ..() if(gone == held_item) held_item = null - update_appearance(UPDATE_OVERLAYS) - else if(gone == cuffs) - // Cuffs taken or destroyed some other way than remove_cuffs() - cuffs = null - uncuffed() - -/// Dresses them as their own person in their outfit, with a body to match their gender; a bounty prisoner keeps the face they were caught with (bounty_looks.dm). Can sleep. -/mob/living/basic/outpost_prisoner/proc/build_look() - if(bounty_record) - apply_bounty_look(src, bounty_record, outfit_path) - else - set_outpost_npc_look(src, outfit_path, gender, look_number) - if(QDELETED(src)) - return - update_appearance(UPDATE_OVERLAYS) + +/// Something went into their hands without take_item(): tg caught a thrown ball for them, or someone handed it over. They hold it now. +/mob/living/carbon/human/npc/outpost_prisoner/proc/on_equipped_item(datum/source, obj/item/equipped, slot) + SIGNAL_HANDLER + if(!held_item && (slot & ITEM_SLOT_HANDS)) + held_item = equipped + +/** + * The serum took them (outpost_prison_experiment_forms.dm): the same body, no longer an inmate. Whatever + * they were doing and whatever trouble they were in stops, their thought bubble goes, and the prisoner's + * own reactions (needs and treatment, cuffing rules, blame, turret rules, teleport and polymorph refusals) + * are switched off; the form brings its own. The caller takes them off the roster (forget()). + */ +/mob/living/carbon/human/npc/outpost_prisoner/proc/stand_down_for_experiment() + experiment_turned = TRUE + // The prison no longer owns the body: if Kessler never takes it, it goes like any NPC's + npc_corpse_lifetime = HUMAN_NPC_CORPSE_LIFETIME + end_activity(cancel_ai = FALSE) + clear_trouble() + bubble = null + if(popped_bubble) + fade_bubble() + UnregisterSignal(src, list( + COMSIG_MOB_PRE_EAT, + COMSIG_MOB_ATE, + COMSIG_ATOM_ITEM_INTERACTION, + COMSIG_MOB_AFTER_APPLY_DAMAGE, + COMSIG_LIVING_HEALTH_UPDATE, + COMSIG_MOB_SAY, + COMSIG_MOB_EMOTE, + COMSIG_CARBON_CUFF_ATTEMPTED, + COMSIG_ATOM_WAS_ATTACKED, + COMSIG_MOB_BATONED, + COMSIG_ATOM_BULLET_ACT, + COMSIG_MOVABLE_TELEPORTING, + COMSIG_LIVING_PRE_WABBAJACKED, + COMSIG_PRE_MOB_CHANGED_TYPE, + COMSIG_LIVING_REVIVE, + )) + +/// Walking pace, or a run for a runner, a rioter or someone fleeing, by the move intent a player uses. +/mob/living/carbon/human/npc/proc/set_prison_pace(hurry) + if((move_intent == MOVE_INTENT_RUN) != !!hurry) + toggle_move_intent() /** * How they come in: hungry, a third in a stained transfer uniform, a fifth roughed up in transfer. * The injury waits for beam_in(), so a prisoner made any other way (an admin, a test) starts whole. */ -/mob/living/basic/outpost_prisoner/proc/roll_arrival() +/mob/living/carbon/human/npc/outpost_prisoner/proc/roll_arrival() hunger = rand(PRISONER_ARRIVAL_HUNGER_MIN, PRISONER_ARRIVAL_HUNGER_MAX) arrived_stained = prob(PRISONER_STAINED_CHANCE) uniform_grime = arrived_stained ? rand(PRISONER_STAINED_GRIME_MIN, PRISONER_STAINED_GRIME_MAX) : rand(0, PRISONER_ARRIVAL_GRIME_MAX) arrival_brute = prob(PRISONER_HURT_ARRIVAL_CHANCE) ? round(maxHealth * (100 - rand(PRISONER_HURT_ARRIVAL_MIN, PRISONER_HURT_ARRIVAL_MAX)) / 100) : 0 /// Their first name, for dialogue. (Not called first_name(): inside it, that would call itself.) -/mob/living/basic/outpost_prisoner/proc/speech_name() +/mob/living/carbon/human/npc/outpost_prisoner/proc/speech_name() return first_name(real_name) // ===== BEAMING IN AND OUT ===== @@ -243,11 +271,11 @@ * PRISONER_ARRIVING, and so do nothing at all (no walking, routine, trouble, speech or thought * bubble), until finish_beam_in() as the beam ends. */ -/mob/living/basic/outpost_prisoner/proc/beam_in() +/mob/living/carbon/human/npc/outpost_prisoner/proc/beam_in() phase = PRISONER_ARRIVING if(arrival_brute > 0) - // Roughed up in transfer: no attacker, so no blame, no blood and no collapse. - adjustBruteLoss(arrival_brute) + // Roughed up in transfer: real bruising spread over their limbs, with no attacker, so no blame. + outpost_prison_bruise(src, arrival_brute) arrival_brute = 0 arrived_hurt = TRUE ADD_TRAIT(src, TRAIT_IMMOBILIZED, PRISONER_BEAM_TRAIT) @@ -264,7 +292,7 @@ addtimer(CALLBACK(src, PROC_REF(finish_beam_in)), OUTPOST_PRISON_BEAM_TIME) /// Fully there as the beam ends: the flash, and only now are they present, free to move, and say hello -/mob/living/basic/outpost_prisoner/proc/finish_beam_in() +/mob/living/carbon/human/npc/outpost_prisoner/proc/finish_beam_in() if(phase != PRISONER_ARRIVING) return var/turf/spot = get_turf(src) @@ -291,7 +319,7 @@ * Dematerialises them where they stand and deletes them at the end of the beam. From the start * they are PRISONER_LEAVING: held still, with no routine, trouble, speech or thought bubble. */ -/mob/living/basic/outpost_prisoner/proc/beam_out() +/mob/living/carbon/human/npc/outpost_prisoner/proc/beam_out() if(phase == PRISONER_LEAVING) return phase = PRISONER_LEAVING @@ -312,7 +340,7 @@ transporter_dematerialise(src, OUTPOST_PRISON_BEAM_TIME) addtimer(CALLBACK(src, PROC_REF(finish_beam_out)), OUTPOST_PRISON_BEAM_TIME) -/mob/living/basic/outpost_prisoner/proc/finish_beam_out() +/mob/living/carbon/human/npc/outpost_prisoner/proc/finish_beam_out() var/turf/spot = get_turf(src) if(spot) new /obj/effect/temp_visual/transporter_flash/departure(spot) @@ -321,7 +349,7 @@ qdel(src) /// What the warden's roster calls them: present, arriving, leaving or dead -/mob/living/basic/outpost_prisoner/proc/console_status() +/mob/living/carbon/human/npc/outpost_prisoner/proc/console_status() if(stat == DEAD) return "dead" if(phase == PRISONER_ARRIVING) @@ -330,75 +358,86 @@ return "leaving" return "present" -// ===== DRAGGING ===== +// ===== DOWN, CUFFED AND PULLED ===== -/// Whether they are down: knocked down, in stamina crit, beaten, out or dead -/mob/living/basic/outpost_prisoner/proc/is_down() - // Floored but not buckled is on the floor; a bed floors them too, and that doesn't count. - return stat != CONSCIOUS || HAS_TRAIT(src, TRAIT_INCAPACITATED) || (HAS_TRAIT(src, TRAIT_FLOORED) && !buckled) +/// Whether they are down: in crit, in stamina crit, knocked down, stunned, out cold, lying on the floor or dead (tg's own states) +/mob/living/carbon/human/npc/outpost_prisoner/proc/is_down() + if(stat != CONSCIOUS || HAS_TRAIT(src, TRAIT_INCAPACITATED)) + return TRUE + // On the floor but not on a bed: lying in bed is no more down than sitting in a chair. + return (HAS_TRAIT(src, TRAIT_FLOORED) || body_position == LYING_DOWN) && !buckled -/// Staff may drag them only while they are down or cuffed (outpost_prison_capture.dm) -/mob/living/basic/outpost_prisoner/proc/can_be_dragged() - return is_down() || !!cuffs +/// Down or in handcuffs: whatever trouble they were in stops, and staff can take them by the arm (outpost_prison_capture.dm) +/mob/living/carbon/human/npc/outpost_prisoner/proc/can_be_dragged() + return is_down() || !!handcuffed /** * Calm enough to go along with a pull: awake, present, and in no trouble of their own (rioting, * loose, fighting, wrecking, squaring up, swinging, climbing, beaten down or hitting back). * Someone talking to them or working on their cuffs does not count. */ -/mob/living/basic/outpost_prisoner/proc/calm_for_pull() - return stat == CONSCIOUS && phase == PRISONER_PRESENT && !trouble && !threat_ref && !swing_ref && !climb_ref && beaten_left <= 0 && !retaliating() +/mob/living/carbon/human/npc/outpost_prisoner/proc/calm_for_pull() + return stat == CONSCIOUS && phase == PRISONER_PRESENT && !trouble && !threat_ref && !swing_ref && !climb_ref && !retaliating() -/// Anyone may pull them while they are down or cuffed, or while they are calm -/mob/living/basic/outpost_prisoner/proc/pull_allowed() +/// Whether they go along with a pull, or let it be: down, cuffed or calm. Anyone else resists it the way a person does. +/mob/living/carbon/human/npc/outpost_prisoner/proc/pull_allowed() return can_be_dragged() || calm_for_pull() -/// Their move_resist: ordinary while they can be dragged or are going along with a pull, else too heavy to shove or pull -/mob/living/basic/outpost_prisoner/proc/pull_weight() - return (can_be_dragged() || (pulledby && calm_for_pull())) ? MOVE_RESIST_DEFAULT : MOVE_FORCE_VERY_STRONG +/mob/living/carbon/human/npc/outpost_prisoner/on_floored_trait_gain(datum/source) + . = ..() + update_drag_resistance() -/mob/living/basic/outpost_prisoner/proc/check_pullable(datum/source, mob/living/puller) - SIGNAL_HANDLER - return pull_allowed() ? NONE : COMSIG_ATOM_CANT_PULL +/mob/living/carbon/human/npc/outpost_prisoner/on_floored_trait_loss(datum/source) + . = ..() + update_drag_resistance() -// Calm, they go along with a pull however heavy they are against shoves; pull_weight() lightens them once it has hold. -/mob/living/basic/outpost_prisoner/can_be_pulled(user, force) - if(!can_be_dragged() && calm_for_pull()) - force = max(force, move_resist * MOVE_FORCE_PULL_RATIO) - return ..(user, force) +/mob/living/carbon/human/npc/outpost_prisoner/on_incapacitated_trait_gain(datum/source) + . = ..() + update_drag_resistance() -/mob/living/basic/outpost_prisoner/proc/block_being_dragged(atom/over, mob/user) - SIGNAL_HANDLER - return can_be_dragged() ? NONE : COMPONENT_CANCEL_MOUSEDROP_ONTO +/mob/living/carbon/human/npc/outpost_prisoner/on_incapacitated_trait_loss(datum/source) + . = ..() + update_drag_resistance() -/mob/living/basic/outpost_prisoner/on_floored_trait_gain(datum/source) +/mob/living/carbon/human/npc/outpost_prisoner/on_restrained_trait_gain(datum/source) . = ..() + on_restraint_changed() update_drag_resistance() -/mob/living/basic/outpost_prisoner/on_floored_trait_loss(datum/source) +/mob/living/carbon/human/npc/outpost_prisoner/on_restrained_trait_loss(datum/source) . = ..() + on_restraint_changed() update_drag_resistance() -/mob/living/basic/outpost_prisoner/on_incapacitated_trait_gain(datum/source) +/mob/living/carbon/human/npc/outpost_prisoner/set_stat(new_stat) . = ..() update_drag_resistance() -/mob/living/basic/outpost_prisoner/on_incapacitated_trait_loss(datum/source) +// Getting up takes a moment once a knockdown or stamina crit is over (tg's get_up()): they count as down +// until they are on their feet, so standing up (and lying down) is a change too. +/mob/living/carbon/human/npc/outpost_prisoner/on_standing_up() . = ..() update_drag_resistance() -/mob/living/basic/outpost_prisoner/set_stat(new_stat) +/mob/living/carbon/human/npc/outpost_prisoner/on_lying_down(new_lying_angle) . = ..() update_drag_resistance() -/// Heavy while awake and free, so nobody shoves them about; ordinary while they are down or cuffed, or calm and being pulled -/mob/living/basic/outpost_prisoner/proc/update_drag_resistance() +/** + * Going down, getting up, cuffs on and off. Awake and free they keep out of bags and lockers (a + * bluespace bag is a way out of the wing); down or dead they can be bagged like anyone. Down or cuffed, + * whatever they were doing and whatever trouble they were making stops. Up and free again, a rioter + * riots on. + */ +/mob/living/carbon/human/npc/outpost_prisoner/proc/update_drag_resistance() var/draggable = can_be_dragged() - move_resist = pull_weight() + if(stat == CONSCIOUS && !is_down()) + ADD_TRAIT(src, TRAIT_NO_STORAGE_INSERT, PRISONER_AWAKE_TRAIT) + ADD_TRAIT(src, TRAIT_NO_CONTAINMENT, PRISONER_AWAKE_TRAIT) + else + REMOVE_TRAIT(src, TRAIT_NO_STORAGE_INSERT, PRISONER_AWAKE_TRAIT) + REMOVE_TRAIT(src, TRAIT_NO_CONTAINMENT, PRISONER_AWAKE_TRAIT) if(!draggable) - // A calm prisoner goes along with a pull (outpost_prison_warden_tools.dm); anyone else shakes it off. - if(!calm_for_pull()) - pulledby?.stop_pulling() if(is_rioting() && stat == CONSCIOUS) // Up and free again: a rioter riots on until the riot is over. INVOKE_ASYNC(src, PROC_REF(back_to_rioting)) @@ -416,7 +455,7 @@ * Time passing: hunger falls (not while well fed after cooked food) and the uniform gets dirtier, * three times as fast at sport, where they sometimes get hurt. */ -/mob/living/basic/outpost_prisoner/proc/adjust_needs(seconds) +/mob/living/carbon/human/npc/outpost_prisoner/proc/adjust_needs(seconds) if(stat == DEAD) return var/hungry_seconds = seconds @@ -434,7 +473,7 @@ sport_injury() /// Shooting hoops or working out: sweaty, and now and then painful -/mob/living/basic/outpost_prisoner/proc/playing_sport() +/mob/living/carbon/human/npc/outpost_prisoner/proc/playing_sport() if(!activity?.started) return FALSE if(istype(activity, /datum/prisoner_activity/basketball)) @@ -443,49 +482,69 @@ return istype(workout) && workout.exercising /** - * Hurt at sport: a turned ankle or the ball in the face, PRISONER_SPORT_INJURY_MIN to _MAX brute, - * and they stop playing. No attacker, so no blame and no blood. Never while already badly hurt, - * and never enough to put them down. + * Hurt at sport, as anyone gets hurt at sport: a turned ankle (a real sprain on a leg), the ball in + * the face or a pulled back, PRISONER_SPORT_INJURY_MIN to _MAX brute on the limb it happened to, and + * they stop playing. No attacker, so no blame. Not while already badly hurt. */ -/mob/living/basic/outpost_prisoner/proc/sport_injury() +/mob/living/carbon/human/npc/outpost_prisoner/proc/sport_injury() if(stat != CONSCIOUS || health_factor() <= PRISONER_SPORT_INJURY_ABOVE) return FALSE - var/damage = min(rand(PRISONER_SPORT_INJURY_MIN, PRISONER_SPORT_INJURY_MAX), health - 1) - if(damage < 1) - return FALSE - if(istype(activity, /datum/prisoner_activity/basketball)) - manual_emote(pick("goes down clutching an ankle.", "takes the ball to the face.", "lands badly and hops off the court.")) + var/damage = rand(PRISONER_SPORT_INJURY_MIN, PRISONER_SPORT_INJURY_MAX) + var/ankle = prob(50) + var/zone = ankle ? pick(BODY_ZONE_L_LEG, BODY_ZONE_R_LEG) : (istype(activity, /datum/prisoner_activity/basketball) ? BODY_ZONE_HEAD : BODY_ZONE_CHEST) + if(ankle) + manual_emote(pick("goes down clutching an ankle.", "lands badly and hops off the court.")) + else if(istype(activity, /datum/prisoner_activity/basketball)) + manual_emote("takes the ball to the face.") else - manual_emote(pick("goes down clutching an ankle.", "pulls something and sits down hard.", "grabs at [p_their()] back mid push-up.")) - adjustBruteLoss(damage) + manual_emote(pick("pulls something and sits down hard.", "grabs at [p_their()] back mid push-up.")) + apply_damage(damage, BRUTE, zone, wound_bonus = CANT_WOUND) + if(ankle) + var/obj/item/bodypart/leg = get_bodypart(zone) + if(leg) + var/datum/wound/blunt/bone/moderate/sprain = new + sprain.apply_wound(leg) end_activity() return TRUE -/mob/living/basic/outpost_prisoner/proc/set_hunger(amount) +/mob/living/carbon/human/npc/outpost_prisoner/proc/set_hunger(amount) hunger = clamp(amount, 0, 100) update_bubble() -/mob/living/basic/outpost_prisoner/proc/set_uniform_grime(amount) +/mob/living/carbon/human/npc/outpost_prisoner/proc/set_uniform_grime(amount) uniform_grime = clamp(amount, 0, 100) + uniform_grime_to_suit() update_bubble() +/// The prison jumpsuit they wear, if it is one of the outpost's (a stripped or redressed prisoner may have none) +/mob/living/carbon/human/npc/outpost_prisoner/proc/worn_prison_uniform() + var/obj/item/clothing/under/rank/prisoner/outpost/suit = w_uniform + return istype(suit) ? suit : null + +/// Their grime shows on the real jumpsuit they wear, which keeps it when it comes off +/mob/living/carbon/human/npc/outpost_prisoner/proc/uniform_grime_to_suit() + var/obj/item/clothing/under/rank/prisoner/outpost/suit = worn_prison_uniform() + if(suit && suit.grime != uniform_grime) + suit.set_grime(uniform_grime) + update_worn_undersuit() + /// Fed, 0-100: full marks until they are hungry, then down to nothing once they are starving -/mob/living/basic/outpost_prisoner/proc/fed_factor() +/mob/living/carbon/human/npc/outpost_prisoner/proc/fed_factor() return clamp(100 * (hunger - PRISONER_HUNGER_STARVING) / (PRISONER_HUNGER_HUNGRY - PRISONER_HUNGER_STARVING), 0, 100) /// Clean, 0-100: full marks until the uniform is dirty, then down to nothing once it is filthy -/mob/living/basic/outpost_prisoner/proc/clean_factor() +/mob/living/carbon/human/npc/outpost_prisoner/proc/clean_factor() return clamp(100 * (PRISONER_GRIME_FILTHY - uniform_grime) / (PRISONER_GRIME_FILTHY - PRISONER_GRIME_DIRTY), 0, 100) -/mob/living/basic/outpost_prisoner/proc/health_factor() +/mob/living/carbon/human/npc/outpost_prisoner/proc/health_factor() return stat == DEAD ? 0 : clamp(100 * health / maxHealth, 0, 100) /// Care, 0-100: the mean of fed, clean and health -/mob/living/basic/outpost_prisoner/proc/care() +/mob/living/carbon/human/npc/outpost_prisoner/proc/care() return (fed_factor() + clean_factor() + health_factor()) / 3 /// What their needs do to their mood per minute: list(gain, loss), before personality -/mob/living/basic/outpost_prisoner/proc/needs_mood_per_minute() +/mob/living/carbon/human/npc/outpost_prisoner/proc/needs_mood_per_minute() var/loss = 0 if(hunger < PRISONER_HUNGER_STARVING) loss += PRISONER_MOOD_STARVING @@ -501,21 +560,21 @@ loss += PRISONER_MOOD_HURT * (PRISONER_HURT_MOOD_BELOW - health_percent) / PRISONER_HURT_MOOD_BELOW return list(0, loss) -/mob/living/basic/outpost_prisoner/proc/wants_food() +/mob/living/carbon/human/npc/outpost_prisoner/proc/wants_food() return stat == CONSCIOUS && hunger < PRISONER_HUNGER_SEEK && well_fed_left <= 0 -/mob/living/basic/outpost_prisoner/proc/wants_clean_uniform() +/mob/living/carbon/human/npc/outpost_prisoner/proc/wants_clean_uniform() return stat == CONSCIOUS && uniform_grime >= PRISONER_GRIME_DIRTY /// Whether they would take this off the floor or the hatch and change into it -/mob/living/basic/outpost_prisoner/proc/would_change_into(obj/item/thing) +/mob/living/carbon/human/npc/outpost_prisoner/proc/would_change_into(obj/item/thing) var/obj/item/clothing/under/rank/prisoner/outpost/fresh = thing return istype(fresh) && wants_clean_uniform() && fresh.grime < PRISONER_GRIME_DIRTY && fresh.grime < uniform_grime // ===== THOUGHT BUBBLE ===== /// The needs that want attention now, most urgent first: hungry, hurt, dirty -/mob/living/basic/outpost_prisoner/proc/bubble_needs() +/mob/living/carbon/human/npc/outpost_prisoner/proc/bubble_needs() var/list/needs = list() if(hunger < PRISONER_HUNGER_HUNGRY) needs += "hungry" @@ -530,7 +589,7 @@ * or loose (a shiv) and being an experiment's subject (a syringe) show on their own. Otherwise it * cycles through their needs every PRISONER_BUBBLE_CYCLE, most urgent first. */ -/mob/living/basic/outpost_prisoner/proc/wanted_bubble(list/needs) +/mob/living/carbon/human/npc/outpost_prisoner/proc/wanted_bubble(list/needs) if(stat == DEAD || phase != PRISONER_PRESENT) return null if(is_rioting() || trouble == PRISONER_TROUBLE_LOOSE) @@ -549,7 +608,7 @@ * starts at the most urgent. The bubble itself pops up now and then (see schedule_bubble()); a need that * has just come up, a riot or a dose pops it soon. */ -/mob/living/basic/outpost_prisoner/proc/update_bubble() +/mob/living/carbon/human/npc/outpost_prisoner/proc/update_bubble() var/list/needs = bubble_needs() var/needs_text = jointext(needs, ",") var/fresh = FALSE @@ -576,7 +635,7 @@ * Pops the bubble when it is due, but not while what they last said is still up over their head * (hush_bubble()). One that no longer holds fades early, and a riot takes over at once. */ -/mob/living/basic/outpost_prisoner/proc/schedule_bubble(list/needs, fresh) +/mob/living/carbon/human/npc/outpost_prisoner/proc/schedule_bubble(list/needs, fresh) if(popped_bubble && popped_bubble != bubble && (!(popped_bubble in needs) || bubble == "riot")) fade_bubble() if(!bubble) @@ -587,11 +646,11 @@ pop_bubble() /// They said or emoted something: see hush_bubble() -/mob/living/basic/outpost_prisoner/proc/on_speech(datum/source) +/mob/living/carbon/human/npc/outpost_prisoner/proc/on_speech(datum/source) SIGNAL_HANDLER hush_bubble() -/mob/living/basic/outpost_prisoner/manual_emote(text) +/mob/living/carbon/human/npc/outpost_prisoner/manual_emote(text) . = ..() if(.) hush_bubble() @@ -601,7 +660,7 @@ * sinks away out of the text's way, and none pops until the words are gone; then a need that * still holds comes back within PRISONER_BUBBLE_FRESH_DELAY. */ -/mob/living/basic/outpost_prisoner/proc/hush_bubble() +/mob/living/carbon/human/npc/outpost_prisoner/proc/hush_bubble() COOLDOWN_START(src, bubble_hush, PRISONER_BUBBLE_HUSH) if(!popped_bubble) return @@ -609,7 +668,7 @@ bubble_next_pop = min(bubble_next_pop, world.time + PRISONER_BUBBLE_HUSH + rand(0, PRISONER_BUBBLE_FRESH_DELAY)) /// Pops the bubble up with a little bounce; it bobs, then fades on its own -/mob/living/basic/outpost_prisoner/proc/pop_bubble() +/mob/living/carbon/human/npc/outpost_prisoner/proc/pop_bubble() if(!bubble || QDELETED(src)) return popped_bubble = bubble @@ -623,7 +682,7 @@ bubble_timer = addtimer(CALLBACK(src, PROC_REF(end_bubble)), PRISONER_BUBBLE_SHOW + PRISONER_BUBBLE_FADE, TIMER_STOPPABLE | TIMER_DELETE_ME) /// Fades the bubble out early, sinking with `sink` (see /obj/effect/abstract/outpost_thought/proc/fade()) -/mob/living/basic/outpost_prisoner/proc/fade_bubble(sink = FALSE) +/mob/living/carbon/human/npc/outpost_prisoner/proc/fade_bubble(sink = FALSE) popped_bubble = null if(!thought) return @@ -632,56 +691,22 @@ bubble_timer = addtimer(CALLBACK(src, PROC_REF(end_bubble)), PRISONER_BUBBLE_FADE, TIMER_STOPPABLE | TIMER_DELETE_ME) /// Takes the faded bubble down -/mob/living/basic/outpost_prisoner/proc/end_bubble() +/mob/living/carbon/human/npc/outpost_prisoner/proc/end_bubble() bubble_timer = null popped_bubble = null if(thought) vis_contents -= thought /// Takes any bubble down at once, with no fade: for when they beam in or out -/mob/living/basic/outpost_prisoner/proc/drop_bubble() +/mob/living/carbon/human/npc/outpost_prisoner/proc/drop_bubble() deltimer(bubble_timer) end_bubble() -/mob/living/basic/outpost_prisoner/update_overlays() +/mob/living/carbon/human/npc/outpost_prisoner/update_overlays() . = ..() - if(grime_stage) - var/mutable_appearance/grime = mutable_appearance('icons/effects/blood.dmi', "uniformblood") - grime.color = "#5a4630" - grime.alpha = grime_stage == 2 ? 200 : 130 - . += grime + // Their grime is on the jumpsuit itself (uniform_grime_to_suit()); filth draws flies. if(grime_stage == 2) . += mutable_appearance('icons/effects/effects.dmi', "fly-surrounding", ABOVE_MOB_LAYER) - if(cuffs) - // tg's own cuff overlay, as people wear it - . += mutable_appearance('icons/mob/simple/mob.dmi', "handcuff1") - if(held_item) - // In hand the way a player holds it, turning with them (npc_inhand_look() in bounty_ai.dm) - var/list/inhand = npc_inhand_look(held_item) - if(inhand) - var/mutable_appearance/carried = mutable_appearance(inhand[1], inhand[2]) - carried.plane = FLOAT_PLANE - carried.layer = FLOAT_LAYER - . += carried - else - // No in-hand sprite: the item itself, small, in the same hand whichever way they face - var/mutable_appearance/carried = new(held_item.appearance) - carried.plane = FLOAT_PLANE - carried.layer = FLOAT_LAYER - carried.dir = SOUTH - carried.pixel_x = 0 - carried.pixel_y = 0 - carried.pixel_w = ((dir & WEST) || dir == NORTH) ? -7 : 7 - carried.pixel_z = -4 - carried.transform = matrix().Scale(0.6) - . += carried - -/// Turning moves what they carry to the other side -/mob/living/basic/outpost_prisoner/setDir(newdir) - var/old_dir = dir - . = ..() - if(held_item && dir != old_dir) - update_appearance(UPDATE_OVERLAYS) /** * tg's thought bubble, as a point uses, with the needed item's own sprite inset. A prisoner's pops up @@ -775,7 +800,7 @@ * turn to it, lean in, and it visibly goes into their hand. With `announce`, the room is told what * they took and from where. Returns TRUE if they hold it. */ -/mob/living/basic/outpost_prisoner/proc/take_item(obj/item/thing, announce = FALSE) +/mob/living/carbon/human/npc/outpost_prisoner/proc/take_item(obj/item/thing, announce = FALSE) if(held_item || QDELETED(thing)) return FALSE if(thing.loc != src) @@ -793,15 +818,14 @@ var/obj/structure/table/reinforced/prison_hatch/hatch = locate() in from var/message = hatch ? "[src] takes [thing] off [hatch]." : "[src] picks up [thing]." visible_message(span_notice(message)) - thing.forceMove(src) - if(thing.loc != src) + // Into a real hand: tg draws it there, and anyone can knock it out of it. + if(!put_in_hands(thing)) return FALSE held_item = thing - update_appearance(UPDATE_OVERLAYS) return TRUE /// Leans towards `target` for a moment, as a hand goes out to it -/mob/living/basic/outpost_prisoner/proc/reach_animation(atom/target) +/mob/living/carbon/human/npc/outpost_prisoner/proc/reach_animation(atom/target) var/direction = get_dir(src, target) if(!direction) return @@ -811,18 +835,20 @@ animate(pixel_x = pixel_x - shift_x, pixel_y = pixel_y - shift_y, time = 2, easing = SINE_EASING, flags = ANIMATION_PARALLEL) /// Puts down whatever they carry, on `where` or their own tile -/mob/living/basic/outpost_prisoner/proc/drop_held_item(atom/where) +/mob/living/carbon/human/npc/outpost_prisoner/proc/drop_held_item(atom/where) if(!held_item) return null var/obj/item/dropped = held_item - dropped.forceMove(where || drop_location()) + if(!(where ? transferItemToLoc(dropped, where, force = TRUE) : dropItemToGround(dropped, force = TRUE))) + return null + held_item = null return dropped /** * Whether they can reach `thing` from where they stand. At a serving hatch they open their side * first: PRISONER_REACH_WAIT means it is opening. */ -/mob/living/basic/outpost_prisoner/proc/try_reach(obj/item/thing) +/mob/living/carbon/human/npc/outpost_prisoner/proc/try_reach(obj/item/thing) if(QDELETED(thing) || !isturf(thing.loc)) return PRISONER_REACH_FAILED if(thing.loc == loc) @@ -840,7 +866,7 @@ * first time it is in reach they turn to it and hold out a hand (PRISONER_REACH_WAIT), and only on * the next call, about a second later, is it PRISONER_REACH_OK to take it. */ -/mob/living/basic/outpost_prisoner/proc/reach_for(obj/item/thing) +/mob/living/carbon/human/npc/outpost_prisoner/proc/reach_for(obj/item/thing) var/result = try_reach(thing) if(result != PRISONER_REACH_OK) reaching_ref = null @@ -853,7 +879,7 @@ return PRISONER_REACH_WAIT /// Sits on a chair, stool or toilet, facing `facing` if given -/mob/living/basic/outpost_prisoner/proc/sit_on(obj/structure/seat, facing) +/mob/living/carbon/human/npc/outpost_prisoner/proc/sit_on(obj/structure/seat, facing) if(buckled != seat) if(loc != seat.loc) return FALSE @@ -865,7 +891,7 @@ return TRUE /// Gets up from whatever they sit or lie on -/mob/living/basic/outpost_prisoner/proc/stand_up() +/mob/living/carbon/human/npc/outpost_prisoner/proc/stand_up() remove_offsets(PRISONER_SITTING_OFFSET) buckled?.unbuckle_mob(src, force = TRUE) @@ -873,7 +899,7 @@ * Settles on the bed under them. There is no sitting pose for a bed, and a standing sprite shifted down * reads as someone standing on it, so they lie on it, awake. With no bed to lie on, they crouch. */ -/mob/living/basic/outpost_prisoner/proc/sit_on_edge(facing) +/mob/living/carbon/human/npc/outpost_prisoner/proc/sit_on_edge(facing) var/obj/structure/bed/bed = locate() in loc if(bed && buckled != bed) stand_up() @@ -884,7 +910,7 @@ setDir(facing) /// Whether they crouch where they are, as sit_on_edge() leaves them with no bed under them -/mob/living/basic/outpost_prisoner/proc/is_crouching() +/mob/living/carbon/human/npc/outpost_prisoner/proc/is_crouching() return !!has_offset(PRISONER_SITTING_OFFSET) /** @@ -893,7 +919,7 @@ * way it faces; `facing` is for the bed and the crouch. The bed is for lying down, so any sitting in * the cell goes to the chair first (home_seat()). */ -/mob/living/basic/outpost_prisoner/proc/sit_in_cell(facing) +/mob/living/carbon/human/npc/outpost_prisoner/proc/sit_in_cell(facing) var/obj/structure/chair/chair = locate() in loc if(chair && (buckled == chair || !chair.has_buckled_mobs()) && sit_on(chair)) return @@ -903,7 +929,7 @@ * Where they sit down in their own cell: its chair if they can use it (seat_usable()), else its bed * on the same terms, lying on it. Null if the cell has neither they can use. */ -/mob/living/basic/outpost_prisoner/proc/home_seat() +/mob/living/carbon/human/npc/outpost_prisoner/proc/home_seat() if(!cell) return null var/obj/structure/chair/chair = cell.chair() @@ -915,7 +941,7 @@ return null /// Whether they can walk to `seat` and use it: nobody else on its tile or in it, and nobody else has claimed it -/mob/living/basic/outpost_prisoner/proc/seat_usable(obj/structure/seat) +/mob/living/carbon/human/npc/outpost_prisoner/proc/seat_usable(obj/structure/seat) var/turf/tile = get_turf(seat) if(!tile || !walkable?[tile] || (tile != loc && tile_taken(tile))) return FALSE @@ -949,11 +975,9 @@ return "snack" return "poor" -/mob/living/basic/outpost_prisoner/proc/on_pre_eat(datum/source, atom/food, mob/living/feeder) +/mob/living/carbon/human/npc/outpost_prisoner/proc/on_pre_eat(datum/source, atom/food, mob/living/feeder) SIGNAL_HANDLER - if(cuffs) - if(feeder) - balloon_alert(feeder, "cuffed") + if(handcuffed && !feeder) return COMSIG_MOB_CANCEL_EAT if(prison?.pastime_pre_eat(src, food, feeder)) return COMSIG_MOB_CANCEL_EAT @@ -967,7 +991,7 @@ * Eats `meal`: hunger and mood by how good it is, and cooked food keeps them full for * PRISONER_WELL_FED_TIME. Returns the tier. */ -/mob/living/basic/outpost_prisoner/proc/eat_food(obj/item/food/meal) +/mob/living/carbon/human/npc/outpost_prisoner/proc/eat_food(obj/item/food/meal) var/tier = outpost_prisoner_food_tier(meal) switch(tier) if("ration") @@ -985,7 +1009,7 @@ return tier /// What they say about a meal: praise for cooking, a complaint about poor food, else thanks to whoever fed them -/mob/living/basic/outpost_prisoner/proc/react_to_food(tier, mob/living/feeder) +/mob/living/carbon/human/npc/outpost_prisoner/proc/react_to_food(tier, mob/living/feeder) switch(tier) if("cooked") if(thank("good_food") || !feeder) @@ -997,7 +1021,7 @@ thank("thanks_food") /// Fed by hand -/mob/living/basic/outpost_prisoner/proc/on_ate(datum/source, atom/food, mob/living/feeder) +/mob/living/carbon/human/npc/outpost_prisoner/proc/on_ate(datum/source, atom/food, mob/living/feeder) SIGNAL_HANDLER var/tier = eat_food(food) if(isturf(loc) && prob(50)) @@ -1011,7 +1035,7 @@ * `table_turf` is null when they ate standing up. Returns the wrapper when they mean to take it * to the bin, else null. */ -/mob/living/basic/outpost_prisoner/proc/finish_meal(obj/item/food/meal, turf/seat_turf, turf/table_turf) +/mob/living/carbon/human/npc/outpost_prisoner/proc/finish_meal(obj/item/food/meal, turf/seat_turf, turf/table_turf) if(QDELETED(meal)) return null var/tier = eat_food(meal) @@ -1030,7 +1054,7 @@ * unhappy one (below PRISONER_LITTER_MOOD) drops it on the floor; anyone else leaves it where * they ate. */ -/mob/living/basic/outpost_prisoner/proc/leave_meal_mess(obj/item/food/meal, turf/floor, turf/table_turf) +/mob/living/carbon/human/npc/outpost_prisoner/proc/leave_meal_mess(obj/item/food/meal, turf/floor, turf/table_turf) if(isopenturf(floor) && (!table_turf || prob(PRISONER_TABLE_CRUMB_CHANCE))) new /obj/effect/decal/cleanable/food/crumbs(floor) var/trash_type @@ -1057,7 +1081,7 @@ return trash /// Puts `trash` in `bin` (or the nearest bin in reach) straight away. Returns TRUE if it went in. -/mob/living/basic/outpost_prisoner/proc/bin_litter(obj/item/trash, obj/structure/closet/crate/bin/bin) +/mob/living/carbon/human/npc/outpost_prisoner/proc/bin_litter(obj/item/trash, obj/structure/closet/crate/bin/bin) if(QDELETED(trash)) return FALSE bin = bin || prison?.find_bin(src) @@ -1085,7 +1109,7 @@ return count < bin.storage_capacity /// Someone fed, clothed or treated them by hand -/mob/living/basic/outpost_prisoner/proc/note_carer(mob/living/carer) +/mob/living/carbon/human/npc/outpost_prisoner/proc/note_carer(mob/living/carer) if(!istype(carer) || is_outpost_prisoner(carer)) return last_carer_ref = WEAKREF(carer) @@ -1094,11 +1118,9 @@ // ===== UNIFORMS ===== -/// Cuffs go on them (outpost_prison_capture.dm); handed a cleaner prison uniform, they change and hand the old one back -/mob/living/basic/outpost_prisoner/proc/on_item_interaction(datum/source, mob/living/user, obj/item/tool, list/modifiers) +/// Treated by hand, they notice; handed a cleaner prison uniform, they change and hand the old one back. Cuffs are tg's own (outpost_prison_capture.dm). +/mob/living/carbon/human/npc/outpost_prisoner/proc/on_item_interaction(datum/source, mob/living/user, obj/item/tool, list/modifiers) SIGNAL_HANDLER - if(istype(tool, /obj/item/restraints/handcuffs)) - return on_cuffs_used(user, tool) if(istype(tool, /obj/item/stack/medical)) // Treatment only shows as health coming back once the dressing is on. COOLDOWN_START(src, treatment_window, 20 SECONDS) @@ -1108,7 +1130,7 @@ // Not while they beam in or out, invisible or half there. if(!istype(offered) || user.combat_mode || stat != CONSCIOUS || phase != PRISONER_PRESENT) return NONE - if(cuffs) + if(handcuffed) balloon_alert(user, "cuffed") return ITEM_INTERACT_BLOCKING if(offered.grime >= uniform_grime) @@ -1128,7 +1150,7 @@ * Picks up a cleaner uniform within arm's reach (their own tile or beside them) and changes, leaving * the old one in its place. They turn to it, lean in, and it visibly leaves the floor or the hatch. */ -/mob/living/basic/outpost_prisoner/proc/take_uniform(obj/item/clothing/under/rank/prisoner/outpost/fresh) +/mob/living/carbon/human/npc/outpost_prisoner/proc/take_uniform(obj/item/clothing/under/rank/prisoner/outpost/fresh) if(!would_change_into(fresh) || !isturf(fresh.loc) || !(fresh.loc == loc || Adjacent(fresh))) return FALSE var/turf/spot = fresh.loc @@ -1143,32 +1165,38 @@ return TRUE /** - * Changes into `fresh` and returns their old uniform, created at `drop_spot`. The clean one goes - * before the old one appears, so a swap on a full serving hatch never pushes it over capacity. + * Changes into `fresh`, the way anyone changes: the jumpsuit they wear comes off onto `drop_spot` + * and the clean one goes on. Returns the old one (null if what they wore wasn't a prison jumpsuit). */ -/mob/living/basic/outpost_prisoner/proc/swap_uniform(obj/item/clothing/under/rank/prisoner/outpost/fresh, atom/drop_spot) +/mob/living/carbon/human/npc/outpost_prisoner/proc/swap_uniform(obj/item/clothing/under/rank/prisoner/outpost/fresh, atom/drop_spot) var/fresh_grime = fresh.grime - var/old_grime = uniform_grime - qdel(fresh) - var/obj/item/clothing/under/rank/prisoner/outpost/old = new(drop_spot) - old.set_grime(old_grime) + // Off the counter before the old one goes down, so a swap on a full serving hatch never pushes it over capacity. + fresh.forceMove(src) + var/obj/item/clothing/under/rank/prisoner/outpost/old = worn_prison_uniform() + if(old) + old.set_grime(uniform_grime) + if(!transferItemToLoc(old, drop_spot, force = TRUE)) + return null + else if(w_uniform) + // Someone else's clothes: off they come, as they are + var/obj/item/other_clothes = w_uniform + if(!transferItemToLoc(other_clothes, drop_spot, force = TRUE)) + return null + if(!equip_to_slot_if_possible(fresh, ITEM_SLOT_ICLOTHING, disable_warning = TRUE)) + fresh.forceMove(drop_spot) set_uniform_grime(fresh_grime) adjust_mood(PRISONER_MOOD_CLEAN_UNIFORM) return old // ===== HURT AND TREATED ===== -/// Blood on the floor from any real brute hit -/mob/living/basic/outpost_prisoner/proc/on_damaged(datum/source, damage_dealt, damagetype) +/// A real hit that puts them down is a collapse (outpost_prison_trouble.dm). tg does the blood. +/mob/living/carbon/human/npc/outpost_prisoner/proc/on_damaged(datum/source, damage_dealt, damagetype) SIGNAL_HANDLER - if((damagetype == BRUTE || damagetype == BURN) && damage_dealt > 0) - // Low enough and they collapse (outpost_prison_trouble.dm). + if(damage_dealt > 0 && (damagetype == BRUTE || damagetype == BURN || damagetype == STAMINA)) INVOKE_ASYNC(src, PROC_REF(check_beaten)) - if(damagetype != BRUTE || damage_dealt < 3 || !isturf(loc)) - return - add_splatter_floor(loc, damage_dealt < 10) -/mob/living/basic/outpost_prisoner/proc/on_health_update(datum/source) +/mob/living/carbon/human/npc/outpost_prisoner/proc/on_health_update(datum/source) SIGNAL_HANDLER var/was = last_health last_health = health @@ -1178,15 +1206,6 @@ adjust_mood(PRISONER_MOOD_TREATED) INVOKE_ASYNC(src, PROC_REF(thank), "thanks_treatment") -/// Badly hurt and untreated: now and then a drop of blood -/mob/living/basic/outpost_prisoner/proc/maybe_drip(seconds) - if(stat == DEAD || !isturf(loc) || health_factor() >= PRISONER_BLEED_BELOW) - return FALSE - if(!SPT_PROB(3, seconds)) - return FALSE - add_splatter_floor(loc, small_drip = TRUE) - return TRUE - // ===== LEFT ALONE ===== /** @@ -1197,7 +1216,7 @@ * moments tg switches the AI off after a plan that queued nothing (ai_running()), they walk over * and take things by hand instead. */ -/mob/living/basic/outpost_prisoner/proc/fend_for_self() +/mob/living/carbon/human/npc/outpost_prisoner/proc/fend_for_self() if(!routine_allowed() || ai_running()) return if(wants_food()) @@ -1213,7 +1232,7 @@ swap_uniform(fresh, fresh.loc) /// Leaves some dirt or a wrapper where they stand -/mob/living/basic/outpost_prisoner/proc/make_mess() +/mob/living/carbon/human/npc/outpost_prisoner/proc/make_mess() var/turf/open/floor = loc if(!istype(floor)) return @@ -1223,13 +1242,12 @@ var/trash_type = pick(/obj/item/trash/candy, /obj/item/trash/chips, /obj/item/trash/raisins) new trash_type(floor) -/mob/living/basic/outpost_prisoner/death(gibbed) +/mob/living/carbon/human/npc/outpost_prisoner/death(gibbed) var/was_alive = stat != DEAD . = ..() + // The body keeps what it held and wore, cuffs too, as anyone's does. if(was_alive && stat == DEAD) end_activity() - drop_held_item() - remove_cuffs() prison?.on_prisoner_death(src) update_bubble() @@ -1237,7 +1255,7 @@ /datum/outfit/outpost_prisoner name = "Outpost prisoner" - uniform = /obj/item/clothing/under/rank/prisoner + uniform = /obj/item/clothing/under/rank/prisoner/outpost shoes = /obj/item/clothing/shoes/sneakers/orange /datum/outfit/outpost_prisoner/glasses @@ -1250,3 +1268,4 @@ #undef PRISONER_BEAM_TRAIT #undef PRISONER_SITTING_OFFSET +#undef PRISONER_AWAKE_TRAIT diff --git a/voidcrew/modules/player_outposts/outpost_prison_researcher.dm b/voidcrew/modules/player_outposts/outpost_prison_researcher.dm index 163c4718879..52fd2faa699 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_researcher.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_researcher.dm @@ -155,7 +155,7 @@ if(!spot) return null roll_offer() - var/mob/living/basic/outpost_kessler_staff/researcher/doctor = new(spot, src) + var/mob/living/carbon/human/npc/outpost_kessler_staff/researcher/doctor = new(spot, src) researcher = doctor researcher_stay = 0 pitch_left = OUTPOST_KESSLER_BEAM_TIME / (1 SECONDS) + 2 @@ -184,7 +184,7 @@ * checked again once it returns. Returns what they got: the item, TRUE for a decline, or FALSE. */ /datum/outpost_prison/proc/present_offer(mob/living/user) - var/mob/living/basic/outpost_kessler_staff/researcher/doctor = researcher + var/mob/living/carbon/human/npc/outpost_kessler_staff/researcher/doctor = researcher if(QDELETED(doctor) || doctor.leaving || doctor.beaming || !outpost?.can_manage(user)) return FALSE var/mob/holder = offer_claim?.resolve() @@ -217,7 +217,7 @@ * to 0, and the researcher leaves. Refused if the wing could not run it now. Returns the item. */ /datum/outpost_prison/proc/accept_offer(mob/living/user) - var/mob/living/basic/outpost_kessler_staff/researcher/doctor = researcher + var/mob/living/carbon/human/npc/outpost_kessler_staff/researcher/doctor = researcher if(QDELETED(doctor) || doctor.leaving || !outpost?.can_manage(user)) return FALSE var/needed = offer_kind == "specimen" ? 2 : 1 @@ -243,7 +243,7 @@ /// `user` turns the offer down: the next one pays more, and the researcher leaves /datum/outpost_prison/proc/decline_offer(mob/living/user) - var/mob/living/basic/outpost_kessler_staff/researcher/doctor = researcher + var/mob/living/carbon/human/npc/outpost_kessler_staff/researcher/doctor = researcher if(QDELETED(doctor) || doctor.leaving) return FALSE sweetener = min(sweetener + OUTPOST_EXPERIMENT_SWEETENER, OUTPOST_EXPERIMENT_SWEETENER_MAX) @@ -255,7 +255,7 @@ /// Nobody took the offer in time: the researcher leaves, and the next offer pays more /datum/outpost_prison/proc/researcher_lapse() - var/mob/living/basic/outpost_kessler_staff/researcher/doctor = researcher + var/mob/living/carbon/human/npc/outpost_kessler_staff/researcher/doctor = researcher if(QDELETED(doctor)) researcher = null return FALSE @@ -265,21 +265,37 @@ send_researcher_away(doctor) return TRUE -/// Someone hurt the researcher: gone at once, with no sweetener for the next visit +/** + * Someone hurt the researcher: "I'm leaving!", and the corporate beam takes them a couple of seconds + * later (OUTPOST_KESSLER_ASSAULT_BEAM_DELAY), with no sweetener for the next visit. The hit was real; + * the beam is only a way out. + */ /datum/outpost_prison/proc/researcher_assaulted() - var/mob/living/basic/outpost_kessler_staff/researcher/doctor = researcher + var/mob/living/carbon/human/npc/outpost_kessler_staff/researcher/doctor = researcher if(QDELETED(doctor)) return FALSE // Hit while still beaming in: they just go, without a word from thin air. - if(!doctor.beaming && !doctor.departing) + if(!doctor.beaming && !doctor.departing && doctor.stat == CONSCIOUS) doctor.say("I'm leaving!") add_log("[doctor.real_name] was attacked and left.") log_game("PLAYER OUTPOST PRISON: the Kessler researcher at '[outpost?.name]' was attacked and left") - send_researcher_away(doctor, 0) + send_researcher_away(doctor, OUTPOST_KESSLER_ASSAULT_BEAM_DELAY) return TRUE +/** + * The researcher was killed before Kessler's beam got them out. Kessler takes the body back, and + * doesn't come again for a long while (OUTPOST_KESSLER_KILLED_WAIT_MIN to _MAX). + */ +/datum/outpost_prison/proc/researcher_killed(mob/living/carbon/human/npc/outpost_kessler_staff/researcher/doctor, mob/killer) + add_log("[doctor.real_name] of Kessler Biolabs was killed. Kessler wants a word about that.") + log_game("PLAYER OUTPOST PRISON: the Kessler researcher at '[outpost?.name]' was killed[killer ? " (last hit by [key_name(killer)])" : ""]") + if(researcher == doctor) + researcher = null + offer_claim = null + researcher_wait = max(researcher_wait || 0, rand(OUTPOST_KESSLER_KILLED_WAIT_MIN, OUTPOST_KESSLER_KILLED_WAIT_MAX)) + /// The researcher leaves after `delay`; the next visit is 35-50 minutes off -/datum/outpost_prison/proc/send_researcher_away(mob/living/basic/outpost_kessler_staff/researcher/doctor, delay = 2 SECONDS) +/datum/outpost_prison/proc/send_researcher_away(mob/living/carbon/human/npc/outpost_kessler_staff/researcher/doctor, delay = 2 SECONDS) researcher = null offer_claim = null researcher_wait = rand(OUTPOST_EXPERIMENT_GAP_MIN, OUTPOST_EXPERIMENT_GAP_MAX) @@ -291,39 +307,28 @@ if(!spot) return null // Not the wing's researcher: nobody can take an offer from them, and they hold no reference to the prison. - var/mob/living/basic/outpost_kessler_staff/researcher/doctor = new(spot, null) + var/mob/living/carbon/human/npc/outpost_kessler_staff/researcher/doctor = new(spot, null) doctor.beam_in() // A second after they are all the way in, not while they are still knitting together. - addtimer(CALLBACK(doctor, TYPE_PROC_REF(/mob/living/basic/outpost_kessler_staff/researcher, refuse_wing)), OUTPOST_KESSLER_BEAM_TIME + 1 SECONDS, TIMER_DELETE_ME) + addtimer(CALLBACK(doctor, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_kessler_staff/researcher, refuse_wing)), OUTPOST_KESSLER_BEAM_TIME + 1 SECONDS, TIMER_DELETE_ME) add_log("[doctor.real_name] of Kessler Biolabs came, but would not work in the wing as it is.") return doctor // ===== KESSLER STAFF ===== -/// Someone from Kessler Biolabs: beams in and out, cannot be hurt, boxed, teleported or taken over -/mob/living/basic/outpost_kessler_staff +/** + * Someone from Kessler Biolabs, a real human body (owner ruling OC-3): they can be hurt, bled, cuffed + * and killed like anyone. The first real hit sends them away: "I'm leaving!" and Kessler's beam a + * couple of seconds later. Teleporters, polymorph and bluespace bags don't take them while they are + * alive. Their kit is locked to them (D3). They have no AI: they stand where they beamed in. + */ +/mob/living/carbon/human/npc/outpost_kessler_staff name = "Kessler Biolabs employee" desc = "Someone from Kessler Biolabs." - icon = 'icons/mob/simple/simple_human.dmi' - mob_biotypes = MOB_ORGANIC | MOB_HUMANOID - sentience_type = SENTIENCE_HUMANOID - basic_mob_flags = NONE - status_flags = NONE - move_resist = INFINITY - // tg's human deathgasp - death_message = "seizes up and falls limp, their eyes dead and lifeless..." - density = TRUE - maxHealth = 100 - health = 100 - damage_coeff = list(BRUTE = 1, BURN = 1, TOX = 0, STAMINA = 0, OXY = 0) - unsuitable_atmos_damage = 0 - unsuitable_cold_damage = 0 - unsuitable_heat_damage = 0 - speak_emote = list("says") - response_help_continuous = "taps" - response_help_simple = "tap" - /// What they wear - var/outfit = /datum/outfit/outpost_kessler_researcher + faction = list(FACTION_NEUTRAL) + ai_controller = null + npc_outfit = /datum/outfit/outpost_kessler_researcher + npc_target_stat = HUMAN_NPC_SPARES_DOWNED /// The prison they came to var/datum/outpost_prison/prison /// On the way out @@ -335,52 +340,78 @@ /// A line of dialogue to say once they have fully materialised, if any var/arrival_line -/mob/living/basic/outpost_kessler_staff/Initialize(mapload, datum/outpost_prison/owner) - gender = pick(MALE, FEMALE) - . = ..() - prison = owner - ADD_TRAIT(src, TRAIT_NO_CONTAINMENT, INNATE_TRAIT) - ADD_TRAIT(src, TRAIT_NO_STORAGE_INSERT, INNATE_TRAIT) +/** + * The second argument is the prison they come to (or null for a visit that isn't the wing's), never a + * human NPC spawn order. Made one at a time as they visit, so they don't go through the spawn queue. + */ +/mob/living/carbon/human/npc/outpost_kessler_staff/Initialize(mapload, datum/outpost_prison/owner) + . = ..(mapload) + prison = istype(owner) ? owner : null + ADD_TRAIT(src, TRAIT_NO_CONTAINMENT, OUTPOST_KESSLER_TRAIT) + ADD_TRAIT(src, TRAIT_NO_STORAGE_INSERT, OUTPOST_KESSLER_TRAIT) ADD_TRAIT(src, TRAIT_OUTPOST_EXPERIMENT, INNATE_TRAIT) - ADD_TRAIT(src, TRAIT_PUSHIMMUNE, INNATE_TRAIT) - AddElement(/datum/element/footstep, footstep_type = FOOTSTEP_MOB_SHOE) + AddElement(/datum/element/relay_attackers) + RegisterSignal(src, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_attacked)) + RegisterSignal(src, COMSIG_MOB_AFTER_APPLY_DAMAGE, PROC_REF(on_damaged)) RegisterSignal(src, COMSIG_MOVABLE_TELEPORTING, PROC_REF(refuse_teleport)) RegisterSignal(src, COMSIG_LIVING_PRE_WABBAJACKED, PROC_REF(refuse_polymorph)) RegisterSignal(src, COMSIG_PRE_MOB_CHANGED_TYPE, PROC_REF(refuse_type_change)) - apply_dynamic_human_appearance(src, outfit, /datum/species/human) -/mob/living/basic/outpost_kessler_staff/Destroy() +/mob/living/carbon/human/npc/outpost_kessler_staff/Destroy() if(prison?.researcher == src) prison.researcher = null prison.offer_claim = null prison = null return ..() -/// Nothing Kessler sends can be hurt: a blow makes them leave instead -/mob/living/basic/outpost_kessler_staff/adjust_health(amount, updating_health = TRUE, forced = FALSE) - if(amount > 0 && !forced) +/// A real blow from someone: they leave +/mob/living/carbon/human/npc/outpost_kessler_staff/proc/on_attacked(datum/source, atom/attacker, attack_flags) + SIGNAL_HANDLER + if(attack_flags & (ATTACKER_DAMAGING_ATTACK | ATTACKER_STAMINA_ATTACK)) INVOKE_ASYNC(src, PROC_REF(hurt_by_someone)) - return 0 - return ..() -/mob/living/basic/outpost_kessler_staff/proc/hurt_by_someone() - leave() +/// Hurt any other way (a fire, a blast, a stray shot): they leave too +/mob/living/carbon/human/npc/outpost_kessler_staff/proc/on_damaged(datum/source, damage_dealt, damagetype) + SIGNAL_HANDLER + if(damage_dealt > 0 && damagetype != OXY) + INVOKE_ASYNC(src, PROC_REF(hurt_by_someone)) + +/mob/living/carbon/human/npc/outpost_kessler_staff/proc/hurt_by_someone() + leave(OUTPOST_KESSLER_ASSAULT_BEAM_DELAY) + +/mob/living/carbon/human/npc/outpost_kessler_staff/death(gibbed) + var/datum/outpost_prison/visited = prison + var/was_alive = stat != DEAD + . = ..() + if(!was_alive || stat != DEAD) + return + REMOVE_TRAIT(src, TRAIT_NO_CONTAINMENT, OUTPOST_KESSLER_TRAIT) + REMOVE_TRAIT(src, TRAIT_NO_STORAGE_INSERT, OUTPOST_KESSLER_TRAIT) + killed_on_visit(visited) + // Kessler takes its own people back, alive or not. + leave(OUTPOST_KESSLER_ASSAULT_BEAM_DELAY) -/mob/living/basic/outpost_kessler_staff/proc/refuse_teleport(datum/source, atom/destination, channel) +/// Killed while visiting `visited` +/mob/living/carbon/human/npc/outpost_kessler_staff/proc/killed_on_visit(datum/outpost_prison/visited) + return + +/mob/living/carbon/human/npc/outpost_kessler_staff/proc/refuse_teleport(datum/source, atom/destination, channel) SIGNAL_HANDLER + if(stat == DEAD) + return FALSE return TRUE -/mob/living/basic/outpost_kessler_staff/proc/refuse_polymorph(datum/source, what_to_randomize) +/mob/living/carbon/human/npc/outpost_kessler_staff/proc/refuse_polymorph(datum/source, what_to_randomize) SIGNAL_HANDLER return STOP_WABBAJACK -/mob/living/basic/outpost_kessler_staff/proc/refuse_type_change(datum/source) +/mob/living/carbon/human/npc/outpost_kessler_staff/proc/refuse_type_change(datum/source) SIGNAL_HANDLER return COMPONENT_BLOCK_MOB_CHANGE -/// Says a line of `context` from the dialogue file. Never while beaming in or out, invisible or half there. -/mob/living/basic/outpost_kessler_staff/proc/say_line(context) - if(beaming || departing) +/// Says a line of `context` from the dialogue file. Never while beaming in or out, invisible or half there, or unable to talk. +/mob/living/carbon/human/npc/outpost_kessler_staff/proc/say_line(context) + if(beaming || departing || !human_npc_can_talk(src)) return null var/line = outpost_experiment_line(context) if(line) @@ -391,7 +422,7 @@ * Materialises where they stand: they knit together inside the transporter's column over the * whole beam. They stay `beaming` (held still, silent) until finish_beam_in() as the beam ends. */ -/mob/living/basic/outpost_kessler_staff/proc/beam_in() +/mob/living/carbon/human/npc/outpost_kessler_staff/proc/beam_in() beaming = TRUE ADD_TRAIT(src, TRAIT_IMMOBILIZED, OUTPOST_KESSLER_TRAIT) var/turf/spot = get_turf(src) @@ -404,7 +435,7 @@ addtimer(CALLBACK(src, PROC_REF(finish_beam_in)), OUTPOST_KESSLER_BEAM_TIME, TIMER_DELETE_ME) /// Fully there as the beam ends: the flash, and only now do they talk -/mob/living/basic/outpost_kessler_staff/proc/finish_beam_in() +/mob/living/carbon/human/npc/outpost_kessler_staff/proc/finish_beam_in() if(!beaming || departing) return var/turf/spot = get_turf(src) @@ -420,7 +451,7 @@ say_line(arrival_line) /// Leaves after `delay`: beams out and is gone -/mob/living/basic/outpost_kessler_staff/proc/leave(delay = 0) +/mob/living/carbon/human/npc/outpost_kessler_staff/proc/leave(delay = 0) if(leaving) return leaving = TRUE @@ -433,9 +464,13 @@ else beam_out() -/mob/living/basic/outpost_kessler_staff/proc/beam_out() +/mob/living/carbon/human/npc/outpost_kessler_staff/proc/beam_out() + if(departing || QDELETED(src)) + return beaming = FALSE departing = TRUE + pulledby?.stop_pulling() + buckled?.unbuckle_mob(src, force = TRUE) ADD_TRAIT(src, TRAIT_IMMOBILIZED, OUTPOST_KESSLER_TRAIT) var/turf/spot = get_turf(src) if(spot) @@ -444,7 +479,7 @@ transporter_dematerialise(src, OUTPOST_KESSLER_BEAM_TIME) addtimer(CALLBACK(src, PROC_REF(finish_beam_out)), OUTPOST_KESSLER_BEAM_TIME, TIMER_DELETE_ME) -/mob/living/basic/outpost_kessler_staff/proc/finish_beam_out() +/mob/living/carbon/human/npc/outpost_kessler_staff/proc/finish_beam_out() var/turf/spot = get_turf(src) if(spot) new /obj/effect/temp_visual/transporter_flash/departure(spot) @@ -454,34 +489,36 @@ // ----- the researcher ----- -/mob/living/basic/outpost_kessler_staff/researcher +/mob/living/carbon/human/npc/outpost_kessler_staff/researcher name = "researcher" desc = "A researcher from Kessler Biolabs, with a clipboard and a labcoat that has never seen a stain." - outfit = /datum/outfit/outpost_kessler_researcher + npc_outfit = /datum/outfit/outpost_kessler_researcher COOLDOWN_DECLARE(brush_off_cooldown) -/mob/living/basic/outpost_kessler_staff/researcher/Initialize(mapload, datum/outpost_prison/owner) +/mob/living/carbon/human/npc/outpost_kessler_staff/researcher/Initialize(mapload, datum/outpost_prison/owner) . = ..() - real_name = "Dr. [pick(GLOB.last_names)]" - name = real_name + fully_replace_character_name(real_name, "Dr. [pick(GLOB.last_names)]") RegisterSignal(src, COMSIG_ATOM_ATTACK_HAND, PROC_REF(on_hand)) -/mob/living/basic/outpost_kessler_staff/researcher/hurt_by_someone() - if(prison?.researcher == src) +/mob/living/carbon/human/npc/outpost_kessler_staff/researcher/hurt_by_someone() + if(prison?.researcher == src && !leaving) prison.researcher_assaulted() return - leave() + leave(OUTPOST_KESSLER_ASSAULT_BEAM_DELAY) + +/mob/living/carbon/human/npc/outpost_kessler_staff/researcher/killed_on_visit(datum/outpost_prison/visited) + visited?.researcher_killed(src, lastattackerckey ? get_mob_by_ckey(lastattackerckey) : null) -/// An empty hand, not in combat mode: a word with the researcher instead of a pat -/mob/living/basic/outpost_kessler_staff/researcher/proc/on_hand(datum/source, mob/living/user, list/modifiers) +/// An empty hand, not in combat mode: a word with the researcher instead of a pat. Down or out cold, tg's own help. +/mob/living/carbon/human/npc/outpost_kessler_staff/researcher/proc/on_hand(datum/source, mob/living/user, list/modifiers) SIGNAL_HANDLER - if(!istype(user) || user.combat_mode || LAZYACCESS(modifiers, RIGHT_CLICK)) + if(!istype(user) || user.combat_mode || LAZYACCESS(modifiers, RIGHT_CLICK) || stat != CONSCIOUS || on_fire) return NONE INVOKE_ASYNC(src, PROC_REF(talk_to), user) return COMPONENT_CANCEL_ATTACK_CHAIN /// Managers get the offer; everyone else gets told who the researcher deals with -/mob/living/basic/outpost_kessler_staff/researcher/proc/talk_to(mob/living/user) +/mob/living/carbon/human/npc/outpost_kessler_staff/researcher/proc/talk_to(mob/living/user) if(leaving || beaming || !prison || prison.researcher != src) return FALSE face_atom(user) @@ -493,17 +530,17 @@ return prison.present_offer(user) /// The offer card as a prompt: "Accept", "Decline", or null if it was closed -/mob/living/basic/outpost_kessler_staff/researcher/proc/ask_offer(mob/living/user, text, timeout) +/mob/living/carbon/human/npc/outpost_kessler_staff/researcher/proc/ask_offer(mob/living/user, text, timeout) return tgui_alert(user, text, "[real_name], Kessler Biolabs", list("Accept", "Decline"), timeout) /// A pitch to whoever is about, pushier after declines -/mob/living/basic/outpost_kessler_staff/researcher/proc/pitch(sweetened = FALSE) +/mob/living/carbon/human/npc/outpost_kessler_staff/researcher/proc/pitch(sweetened = FALSE) if(leaving || beaming) return null return say_line(sweetened ? "researcher_sweetened" : "researcher_offer") /// A short visit to a wing in no state for an experiment -/mob/living/basic/outpost_kessler_staff/researcher/proc/refuse_wing() +/mob/living/carbon/human/npc/outpost_kessler_staff/researcher/proc/refuse_wing() if(QDELETED(src) || leaving) return say_line("researcher_pigsty") @@ -511,15 +548,30 @@ // ----- the recovery team ----- -/mob/living/basic/outpost_kessler_staff/agent +/mob/living/carbon/human/npc/outpost_kessler_staff/agent name = "Kessler recovery agent" desc = "A Kessler Biolabs recovery agent in a hazmat suit, carrying a tranquilliser gun." - outfit = /datum/outfit/outpost_kessler_agent + npc_outfit = /datum/outfit/outpost_kessler_agent + +/// Fires the real chloral hydrate dart in its syringe gun at `target`, the way anyone fires one. Returns TRUE if it fired. +/mob/living/carbon/human/npc/outpost_kessler_staff/agent/proc/dart(mob/living/target) + if(QDELETED(target) || stat != CONSCIOUS || departing) + return FALSE + var/obj/item/gun/syringe/gun = locate() in held_items + if(!gun || !length(gun.syringes) || !human_npc_ready_item(src, gun)) + return FALSE + face_atom(target) + var/old_combat_mode = combat_mode + set_combat_mode(TRUE, silent = TRUE) + ClickOn(target) + set_combat_mode(old_combat_mode, silent = TRUE) + return TRUE /** * Two agents beam in around `creature`, one says a line of `context` once they are all the way in, - * and they all beam out after OUTPOST_KESSLER_TEAM_TIME. A creature still on its feet is - * `tranquilise`d; one already down is simply collected. + * and they all beam out after OUTPOST_KESSLER_TEAM_TIME. With `tranquilise`, the first agent fires the + * real chloral hydrate dart in its syringe gun at the creature once it is all the way in, to keep it + * down while they work (owner ruling OC-3: they collect only what is already down). */ /proc/outpost_kessler_team(mob/living/creature, context = "kessler_recovery", tranquilise = TRUE) var/turf/center = get_turf(creature) @@ -529,9 +581,9 @@ for(var/turf/open/tile in orange(1, center)) if(!tile.is_blocked_turf(TRUE) && !(locate(/mob/living) in tile)) spots += tile - var/mob/living/basic/outpost_kessler_staff/agent/speaker + var/mob/living/carbon/human/npc/outpost_kessler_staff/agent/speaker for(var/i in 1 to min(2, length(spots))) - var/mob/living/basic/outpost_kessler_staff/agent/agent = new(pick_n_take(spots), null) + var/mob/living/carbon/human/npc/outpost_kessler_staff/agent/agent = new(pick_n_take(spots), null) agent.face_atom(creature) agent.beam_in() agent.leave(OUTPOST_KESSLER_TEAM_TIME) @@ -543,21 +595,11 @@ if(tranquilise) creature.visible_message(span_warning("Kessler Biolabs agents beam in around [creature], and a tranquilliser dart drops [creature.p_them()].")) playsound(center, 'sound/items/syringeproj.ogg', 50, TRUE) + if(speaker) + addtimer(CALLBACK(speaker, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_kessler_staff/agent, dart), creature), OUTPOST_KESSLER_BEAM_TIME + 0.2 SECONDS, TIMER_DELETE_ME) else creature.visible_message(span_notice("Kessler Biolabs agents beam in to collect [creature].")) -/// Kessler's beam takes `target` away for good -/proc/outpost_kessler_beam_away(mob/living/target) - if(QDELETED(target)) - return - var/turf/spot = get_turf(target) - if(spot) - target.visible_message(span_notice("A transporter beam takes [target] away.")) - playsound(spot, 'sound/effects/magic/teleport_diss.ogg', 40, TRUE) - new /obj/effect/temp_visual/transporter_beam(spot, OUTPOST_KESSLER_BEAM_TIME + 0.5 SECONDS) - transporter_dematerialise(target, OUTPOST_KESSLER_BEAM_TIME) - QDEL_IN(target, OUTPOST_KESSLER_BEAM_TIME) - // ===== LOOKS ===== /datum/outfit/outpost_kessler_researcher @@ -578,3 +620,16 @@ gloves = /obj/item/clothing/gloves/latex shoes = /obj/item/clothing/shoes/sneakers/white r_hand = /obj/item/gun/syringe + +/datum/outfit/outpost_kessler_agent/post_equip(mob/living/carbon/human/agent, visuals_only = FALSE) + . = ..() + if(visuals_only) + return + var/obj/item/gun/syringe/gun = locate() in agent.held_items + if(!gun) + return + var/obj/item/reagent_containers/syringe/dart = new(gun) + dart.reagents.add_reagent(/datum/reagent/toxin/chloralhydrate, dart.volume) + dart.name = "tranquilliser syringe" + gun.syringes += dart + gun.update_appearance() diff --git a/voidcrew/modules/player_outposts/outpost_prison_riot.dm b/voidcrew/modules/player_outposts/outpost_prison_riot.dm index c531de4ec84..0468d022a1a 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_riot.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_riot.dm @@ -140,10 +140,10 @@ * mean mood, so a neglected wing sours its newcomers. `newcomer` is left out of the mean, as is * anyone who has not served a moment yet. */ -/datum/outpost_prison/proc/arrival_mood(mob/living/basic/outpost_prisoner/newcomer) +/datum/outpost_prison/proc/arrival_mood(mob/living/carbon/human/npc/outpost_prisoner/newcomer) var/total = 0 var/count = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner == newcomer || prisoner.served_seconds <= 0 || !counts_for_tension(prisoner)) continue total += prisoner.mood @@ -159,7 +159,7 @@ * PRISONER_LOCKED_IN_RECOVERY seconds a second, so letting them out for a moment does not reset it. * A rioter just shut in a cell is in custody, and owes lockdown for it (outpost_prison_capture.dm). */ -/datum/outpost_prison/proc/update_locked_in(mob/living/basic/outpost_prisoner/prisoner, seconds) +/datum/outpost_prison/proc/update_locked_in(mob/living/carbon/human/npc/outpost_prisoner/prisoner, seconds) var/confined = prisoner.is_confined() if(confined) if(!prisoner.was_confined && prisoner.is_rioting()) @@ -181,7 +181,7 @@ return riot_active || runners_at_large() > 0 /// A prisoner is let out after a long lock-in: some relief, and they say so -/datum/outpost_prison/proc/on_unbolted(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/on_unbolted(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(QDELETED(prisoner) || prisoner.stat != CONSCIOUS || prisoner.phase != PRISONER_PRESENT || prisoner.trouble) return FALSE prisoner.adjust_mood(PRISONER_MOOD_UNBOLTED) @@ -209,7 +209,7 @@ * Staff killed a prisoner. No fine: the cost is the worst spark there is, the pay and bonus they * forfeit, and a body to deal with (body_tick()). */ -/datum/outpost_prison/proc/blame_death(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/blame_death(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(prisoner.death_blamed) return FALSE prisoner.death_blamed = TRUE @@ -219,14 +219,14 @@ return trouble_event(PRISON_SPIKE_KILLED, "[prisoner.real_name] was killed by staff") /// Whether a prisoner's mood counts toward the wing's tension: present, alive and not loose -/datum/outpost_prison/proc/counts_for_tension(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/counts_for_tension(mob/living/carbon/human/npc/outpost_prisoner/prisoner) return prisoner.phase == PRISONER_PRESENT && prisoner.stat != DEAD && prisoner.trouble != PRISONER_TROUBLE_LOOSE /// 100 minus the mean mood of the prisoners in the cell block, plus the spike and any shivs hidden in the wing /datum/outpost_prison/proc/compute_tension() var/total = 0 var/count = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(!counts_for_tension(prisoner)) continue total += prisoner.mood @@ -289,7 +289,7 @@ var/hurt = 0 var/locked = 0 var/cuffed = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(!counts_for_tension(prisoner)) continue if(prisoner.hunger < PRISONER_HUNGER_HUNGRY) @@ -338,7 +338,7 @@ add_log("A riot is brewing in the yard.") announce("Prison wing: a riot is brewing.", SHIP_NOTIFY_DANGER) var/shouts = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(!prisoner.routine_allowed() || cell_at(get_turf(prisoner))) continue // Leisure makes way, so the gathering (three times as likely now) gets picked. @@ -355,7 +355,7 @@ /datum/outpost_prison/proc/trouble_tick(seconds) tension_spike = max(0, tension_spike - PRISON_SPIKE_DECAY * seconds) subdued_left = max(0, subdued_left - seconds) - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners.Copy()) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners.Copy()) if(QDELETED(prisoner) || prisoner.phase != PRISONER_PRESENT || prisoner.stat == DEAD) continue prisoner.trouble_counters(seconds) @@ -373,7 +373,7 @@ check_incident_over() /// A prisoner's own trouble timers -/mob/living/basic/outpost_prisoner/proc/trouble_counters(seconds) +/mob/living/carbon/human/npc/outpost_prisoner/proc/trouble_counters(seconds) threat_cooldown = max(0, threat_cooldown - seconds) fight_cooldown = max(0, fight_cooldown - seconds) if(swing_ref) @@ -382,10 +382,8 @@ if(swing_left <= 0 || !target || target.stat == DEAD) swing_ref = null swing_left = 0 - if(beaten_left > 0) - beaten_left -= seconds - if(beaten_left <= 0 || health_factor() > PRISONER_RECOVER_ABOVE) - recover() + // Down until they are up again, by tg's own clock (crit, stamina, the knockdown), or a yield's lie-down by choice + beaten_tick() if(climb_ref) climb_tick(seconds) @@ -396,7 +394,7 @@ * their AI runs, and never at someone who just helped them. A talk with staff holds the threat. */ /datum/outpost_prison/proc/threats_tick(seconds) - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) // Someone in trouble keeps a swing only while hitting back at a player (outpost_prison_trouble.dm). // Running from a creature, staff are the least of their worries (outpost_prison_panic.dm). if(prisoner.phase != PRISONER_PRESENT || (prisoner.trouble && !prisoner.retaliating()) || !prisoner.trouble_can_act() || !prisoner.ai_running() || !in_cell_block(prisoner) || prisoner.is_panicking()) @@ -427,8 +425,8 @@ /// Two prisoners squaring off: an argument, then blows until one yields /datum/outpost_prison_fight var/datum/outpost_prison/prison - var/mob/living/basic/outpost_prisoner/first - var/mob/living/basic/outpost_prisoner/second + var/mob/living/carbon/human/npc/outpost_prisoner/first + var/mob/living/carbon/human/npc/outpost_prisoner/second /// What it is about, for the argument's lines: "food", "ball", "bed" or "none" var/cause = "none" /// Past the argument: blows are being thrown @@ -440,7 +438,7 @@ /// Seconds it has lasted var/elapsed = 0 -/datum/outpost_prison_fight/New(datum/outpost_prison/owner, mob/living/basic/outpost_prisoner/one, mob/living/basic/outpost_prisoner/two, cause = "none") +/datum/outpost_prison_fight/New(datum/outpost_prison/owner, mob/living/carbon/human/npc/outpost_prisoner/one, mob/living/carbon/human/npc/outpost_prisoner/two, cause = "none") . = ..() prison = owner first = one @@ -457,7 +455,7 @@ prison = null return ..() -/datum/outpost_prison_fight/proc/opponent_of(mob/living/basic/outpost_prisoner/fighter) +/datum/outpost_prison_fight/proc/opponent_of(mob/living/carbon/human/npc/outpost_prisoner/fighter) if(fighter == first) return second if(fighter == second) @@ -465,7 +463,7 @@ return null /// Still up for it: awake, on their feet, in this fight -/datum/outpost_prison_fight/proc/fighter_ok(mob/living/basic/outpost_prisoner/fighter) +/datum/outpost_prison_fight/proc/fighter_ok(mob/living/carbon/human/npc/outpost_prisoner/fighter) return !QDELETED(fighter) && fighter.stat == CONSCIOUS && fighter.phase == PRISONER_PRESENT && fighter.fight == src && fighter.trouble == PRISONER_TROUBLE_FIGHT && !fighter.can_be_dragged() /// The argument, then the fight. FALSE once it is over. @@ -476,7 +474,7 @@ if(elapsed >= PRISONER_FIGHT_MAX_TIME) return FALSE if(fighting) - for(var/mob/living/basic/outpost_prisoner/fighter as anything in list(first, second)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/fighter as anything in list(first, second)) if(fighter.health_factor() <= PRISONER_FIGHT_YIELD) fighter.yield_fight() return FALSE @@ -485,8 +483,8 @@ line_left -= seconds if(line_left <= 0) line_left = 3 - var/mob/living/basic/outpost_prisoner/speaker = first_speaks ? first : second - var/mob/living/basic/outpost_prisoner/listener = opponent_of(speaker) + var/mob/living/carbon/human/npc/outpost_prisoner/speaker = first_speaks ? first : second + var/mob/living/carbon/human/npc/outpost_prisoner/listener = opponent_of(speaker) first_speaks = !first_speaks speaker.face_atom(listener) speaker.say_context_or("fight_argue_[cause]", "fight_argue", listener) @@ -494,17 +492,17 @@ fighting = TRUE first.manual_emote("goes for [second]!") // A scuffle on the floor is dirty work. - for(var/mob/living/basic/outpost_prisoner/fighter as anything in list(first, second)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/fighter as anything in list(first, second)) fighter.set_uniform_grime(fighter.uniform_grime + PRISONER_FIGHT_GRIME) return TRUE /// Starts a fight between two prisoners over `cause`, telling everyone in sight. Returns the fight, or null. -/datum/outpost_prison/proc/start_fight(mob/living/basic/outpost_prisoner/one, mob/living/basic/outpost_prisoner/two, cause = "none") +/datum/outpost_prison/proc/start_fight(mob/living/carbon/human/npc/outpost_prisoner/one, mob/living/carbon/human/npc/outpost_prisoner/two, cause = "none") if(!trouble_enabled || one == two || one.fight || two.fight || riot_active) return null var/datum/outpost_prison_fight/brawl = new(src, one, two, cause) fights += brawl - for(var/mob/living/basic/outpost_prisoner/fighter as anything in list(one, two)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/fighter as anything in list(one, two)) fighter.cancel_threat() fighter.end_activity() fighter.stand_up() @@ -513,7 +511,7 @@ one.face_atom(two) two.face_atom(one) add_tension_spike(PRISON_SPIKE_FIGHT) - for(var/mob/living/basic/outpost_prisoner/onlooker in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/onlooker in prisoners) if(onlooker == one || onlooker == two || onlooker.stat != CONSCIOUS || onlooker.phase != PRISONER_PRESENT) continue if((onlooker in view(7, one)) || (onlooker in view(7, two))) @@ -528,7 +526,7 @@ return fights -= brawl fight_gap_left = PRISON_FIGHT_GAP - for(var/mob/living/basic/outpost_prisoner/fighter as anything in list(brawl.first, brawl.second)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/fighter as anything in list(brawl.first, brawl.second)) if(QDELETED(fighter)) continue if(fighter.fight == brawl) @@ -541,15 +539,15 @@ qdel(brawl) /// Whether they are angry enough, free and able to start a fight, with someone around to see it, and no creature frightening them -/mob/living/basic/outpost_prisoner/proc/can_start_fight() +/mob/living/carbon/human/npc/outpost_prisoner/proc/can_start_fight() return prison && mood < PRISONER_FIGHT_MOOD && !in_trouble() && fight_cooldown <= 0 && trouble_can_act() && health_factor() > PRISONER_FIGHT_YIELD && !activity?.sleeping && ai_running() && prison.in_cell_block(src) && !is_panicking() /// Chasing the ball, or holding it -/mob/living/basic/outpost_prisoner/proc/after_ball() +/mob/living/carbon/human/npc/outpost_prisoner/proc/after_ball() return istype(activity, /datum/prisoner_activity/basketball) || istype(held_item, /obj/item/toy/basketball) /// What two prisoners would fight about: both hungry ("food"), both after the ball ("ball"), one in the other's cell ("bed"), or nothing ("none") -/datum/outpost_prison/proc/fight_cause(mob/living/basic/outpost_prisoner/one, mob/living/basic/outpost_prisoner/two) +/datum/outpost_prison/proc/fight_cause(mob/living/carbon/human/npc/outpost_prisoner/one, mob/living/carbon/human/npc/outpost_prisoner/two) if(one.hunger < PRISONER_HUNGER_HUNGRY && two.hunger < PRISONER_HUNGER_HUNGRY) return "food" if(one.after_ball() && two.after_ball()) @@ -585,14 +583,14 @@ if(!trouble_enabled || riot_active || subdued_left > 0 || length(fights) || fight_gap_left > 0) return null var/list/angry = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.phase == PRISONER_PRESENT && prisoner.can_start_fight()) angry += prisoner var/list/pairs = list() for(var/i in 1 to length(angry) - 1) - var/mob/living/basic/outpost_prisoner/one = angry[i] + var/mob/living/carbon/human/npc/outpost_prisoner/one = angry[i] for(var/j in i + 1 to length(angry)) - var/mob/living/basic/outpost_prisoner/two = angry[j] + var/mob/living/carbon/human/npc/outpost_prisoner/two = angry[j] if(get_dist(one, two) <= PRISONER_FIGHT_RANGE && one.walkable?[get_turf(two)]) pairs += list(list(one, two)) if(!length(pairs)) @@ -609,7 +607,7 @@ // ===== SPATS ===== /// Whether a prisoner is sour enough and free to argue, and no creature is frightening them -/datum/outpost_prison/proc/can_spat(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/can_spat(mob/living/carbon/human/npc/outpost_prisoner/prisoner) return prisoner.phase == PRISONER_PRESENT && prisoner.mood < PRISONER_SPAT_MOOD && !prisoner.in_trouble() && prisoner.trouble_can_act() && !prisoner.activity?.sleeping && prisoner.ai_running() && !prisoner.is_panicking() /** @@ -620,14 +618,14 @@ if(!trouble_enabled || riot_active || spat_lines_left > 0 || spat_gap_left > 0 || !prob(PRISON_SPAT_CHANCE * contraband_spat_mult())) return FALSE var/list/sour = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(can_spat(prisoner)) sour += prisoner var/list/pairs = list() for(var/i in 1 to length(sour) - 1) - var/mob/living/basic/outpost_prisoner/one = sour[i] + var/mob/living/carbon/human/npc/outpost_prisoner/one = sour[i] for(var/j in i + 1 to length(sour)) - var/mob/living/basic/outpost_prisoner/two = sour[j] + var/mob/living/carbon/human/npc/outpost_prisoner/two = sour[j] if(get_dist(one, two) <= PRISONER_FIGHT_RANGE && (two in view(PRISONER_FIGHT_RANGE, one))) pairs += list(list(one, two)) if(!length(pairs)) @@ -651,13 +649,13 @@ spat_line_left -= seconds if(spat_line_left > 0) return - var/mob/living/basic/outpost_prisoner/one = spat_first_ref?.resolve() - var/mob/living/basic/outpost_prisoner/two = spat_second_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/one = spat_first_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/two = spat_second_ref?.resolve() if(!one || !two || one.stat != CONSCIOUS || two.stat != CONSCIOUS || one.phase != PRISONER_PRESENT || two.phase != PRISONER_PRESENT || one.in_trouble() || two.in_trouble()) spat_lines_left = 0 return - var/mob/living/basic/outpost_prisoner/speaker = (spat_lines_said % 2) ? two : one - var/mob/living/basic/outpost_prisoner/listener = speaker == one ? two : one + var/mob/living/carbon/human/npc/outpost_prisoner/speaker = (spat_lines_said % 2) ? two : one + var/mob/living/carbon/human/npc/outpost_prisoner/listener = speaker == one ? two : one speaker.face_atom(listener) speaker.say_context("spat", listener) spat_lines_said++ @@ -667,7 +665,7 @@ // ===== RIOTS ===== /// Whether they are shut in a cell with its door bolted -/mob/living/basic/outpost_prisoner/proc/in_bolted_cell() +/mob/living/carbon/human/npc/outpost_prisoner/proc/in_bolted_cell() var/datum/outpost_prison_cell/holding = prison?.cell_at(get_turf(src)) return holding?.is_bolted() @@ -676,11 +674,11 @@ * door bolted open does not count). Down or cuffed, they are still at large, though the riot may * count them dealt with (riot_handled()). */ -/mob/living/basic/outpost_prisoner/proc/riot_at_large() +/mob/living/carbon/human/npc/outpost_prisoner/proc/riot_at_large() return phase == PRISONER_PRESENT && stat != DEAD && is_rioting() && !is_confined() /// A rioter at large and free to act: on their feet, uncuffed, and not given up at a turret's warning (outpost_prison_security.dm) -/mob/living/basic/outpost_prisoner/proc/riot_free() +/mob/living/carbon/human/npc/outpost_prisoner/proc/riot_free() return riot_at_large() && stat == CONSCIOUS && !can_be_dragged() && !surrendered_to_turret() /** @@ -689,10 +687,10 @@ * unable to act (in crit, stamina crit, collapsed or stunned). A knockdown they are straight back * up from is not enough. The riot is over once every rioter is (riot_tick()). */ -/mob/living/basic/outpost_prisoner/proc/riot_handled() +/mob/living/carbon/human/npc/outpost_prisoner/proc/riot_handled() if(QDELETED(src) || isnull(get_turf(src))) return TRUE - if(!riot_at_large() || cuffs) + if(!riot_at_large() || handcuffed) return TRUE return stat != CONSCIOUS || HAS_TRAIT(src, TRAIT_INCAPACITATED) @@ -700,11 +698,11 @@ * Whether they can join a riot now. Not from a cell they are shut in: a riot that nobody can take * out of a cell would be over as soon as it began, so they bang on the door and shout instead. */ -/mob/living/basic/outpost_prisoner/proc/can_join_riot() - return prison && stat == CONSCIOUS && phase == PRISONER_PRESENT && !can_be_dragged() && beaten_left <= 0 && !climb_ref && (!trouble || trouble == PRISONER_TROUBLE_FIGHT) && prison.in_cell_block(src) && !is_confined() +/mob/living/carbon/human/npc/outpost_prisoner/proc/can_join_riot() + return prison && stat == CONSCIOUS && phase == PRISONER_PRESENT && !can_be_dragged() && !beaten && !climb_ref && (!trouble || trouble == PRISONER_TROUBLE_FIGHT) && prison.in_cell_block(src) && !is_confined() /// Below this mood they join a riot, by personality, raised by a shiv under their mattress (outpost_prison_contraband.dm) -/mob/living/basic/outpost_prisoner/proc/riot_join_mood() +/mob/living/carbon/human/npc/outpost_prisoner/proc/riot_join_mood() var/line = PRISON_RIOT_JOIN_CHATTY switch(personality) if("grumpy") @@ -721,10 +719,10 @@ * Who joins a riot: everyone below their personality's line (everyone able, for an admin riot), * plus `forced`, else the unhappiest alone. */ -/datum/outpost_prison/proc/riot_candidates(everyone = FALSE, mob/living/basic/outpost_prisoner/forced) +/datum/outpost_prison/proc/riot_candidates(everyone = FALSE, mob/living/carbon/human/npc/outpost_prisoner/forced) var/list/joining = list() - var/mob/living/basic/outpost_prisoner/unhappiest - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + var/mob/living/carbon/human/npc/outpost_prisoner/unhappiest + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(!prisoner.can_join_riot()) continue if(everyone || prisoner == forced || prisoner.mood < prisoner.riot_join_mood()) @@ -741,7 +739,7 @@ * does. `ignore_quiet` starts it in the quiet after a riot too, for a prisoner let out of lockdown * early. An experiment under way stops nothing. */ -/datum/outpost_prison/proc/start_riot(reason, everyone = FALSE, mob/living/basic/outpost_prisoner/forced, ignore_quiet = FALSE, alone = FALSE) +/datum/outpost_prison/proc/start_riot(reason, everyone = FALSE, mob/living/carbon/human/npc/outpost_prisoner/forced, ignore_quiet = FALSE, alone = FALSE) if(!trouble_enabled || riot_active) return FALSE if(!everyone && subdued_left > 0 && !ignore_quiet) @@ -766,7 +764,7 @@ open_incident() var/shouts = 0 // A Most Wanted ringleader is among the first to shout (outpost_prison_bounty.dm). - for(var/mob/living/basic/outpost_prisoner/rioter as anything in bounty_ringleaders_first(joining)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/rioter as anything in bounty_ringleaders_first(joining)) rioter.start_rioting(shouts++ < 2) send_bystanders_home(joining) add_log("Riot in the yard: [length(joining)] prisoner\s.") @@ -777,7 +775,7 @@ return TRUE /// Joins the riot: a shiv out, everything else dropped -/mob/living/basic/outpost_prisoner/proc/start_rioting(shout = TRUE) +/mob/living/carbon/human/npc/outpost_prisoner/proc/start_rioting(shout = TRUE) cancel_threat() end_activity() stand_up() @@ -786,16 +784,15 @@ riot_target_ref = null riot_target_hits = 0 riot_victim_ref = null - // A shiv they hid in their cell is the one they draw (outpost_prison_contraband.dm). - if(!prison?.draw_stashed_shiv(src)) - draw_shiv() + // A shiv they hid in their cell is the one they draw (outpost_prison_contraband.dm); without one, their fists. + prison?.draw_stashed_shiv(src) update_bubble() if(shout) say_context("riot") /// Prisoners who stay out of a riot go back to their own cells and sit it out on the bed. Anyone running from a creature keeps running (outpost_prison_panic.dm). /datum/outpost_prison/proc/send_bystanders_home(list/rioters) - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if((prisoner in rioters) || prisoner.phase != PRISONER_PRESENT || !prisoner.routine_allowed() || prisoner.is_confined() || prisoner.is_panicking()) continue var/datum/prisoner_activity/hide/hide = new(prisoner) @@ -816,7 +813,7 @@ riot_windup_left = max(0, riot_windup_left - seconds) var/unhandled = 0 var/free = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.riot_handled()) continue unhandled++ @@ -862,7 +859,7 @@ riot_windup_left = 0 tension_spike = 0 subdued_left = PRISON_SUBDUED_TIME / (1 SECONDS) - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.is_rioting()) prisoner.calm_down() stage = outpost_prison_stage_for(compute_tension()) @@ -884,7 +881,7 @@ /// The riot went on too long: the rioters go all out for the exits, and each one's loose clock starts /datum/outpost_prison/proc/begin_breakout() breaking_out = TRUE - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) // Rioters who gave up at a turret's warning stay where they are (outpost_prison_security.dm) if(prisoner.trouble != PRISONER_TROUBLE_RIOT || prisoner.surrendered_to_turret()) continue @@ -901,7 +898,7 @@ * once a riot turns into a breakout. Anyone else in a riot already on carries on as before. Returns * TRUE if they are breaking out. */ -/datum/outpost_prison/proc/start_breakout(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/start_breakout(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(!trouble_enabled || QDELETED(prisoner) || !(prisoner in prisoners)) return FALSE if(!prisoner.is_rioting()) @@ -928,7 +925,7 @@ */ /datum/outpost_prison/proc/transfer_rioters() var/list/rioters = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.riot_at_large() && !held_for_experiment(prisoner)) rioters += prisoner if(!length(rioters)) @@ -937,7 +934,7 @@ return 0 open_incident() var/charged = 0 - for(var/mob/living/basic/outpost_prisoner/rioter as anything in rioters) + for(var/mob/living/carbon/human/npc/outpost_prisoner/rioter as anything in rioters) close_bounty_record(rioter, BOUNTY_RECORD_CLOSED) charged += charge_fine(OUTPOST_PRISON_TRANSFER_FEE, "Prisoner transfer: [rioter.real_name]", TRUE) note_prisoner_lost(rioter, "transferred") @@ -951,7 +948,7 @@ return length(rioters) /// A serving hatch left open on both sides that this prisoner can reach from the yard side -/datum/outpost_prison/proc/open_hatch_for(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/open_hatch_for(mob/living/carbon/human/npc/outpost_prisoner/prisoner) for(var/obj/structure/table/reinforced/prison_hatch/hatch in fixtures_of("hatch")) if(QDELETED(hatch) || !hatch.both_sides_open()) continue @@ -969,7 +966,7 @@ * were smashing for a few more blows, or a new target (pick_smash_target(), * outpost_prison_breakout.dm). Turret warnings are in outpost_prison_security.dm. */ -/mob/living/basic/outpost_prisoner/proc/riot_target() +/mob/living/carbon/human/npc/outpost_prisoner/proc/riot_target() if(!prison) return null if(prison.riot_windup_left > 0 || surrendered_to_turret() || is_confined()) @@ -1004,7 +1001,7 @@ return next /// The nearest member of staff in sight that they can get to, and that no more than PRISON_RIOT_MAX_ATTACKERS - 1 others are going for -/mob/living/basic/outpost_prisoner/proc/staff_in_reach() +/mob/living/carbon/human/npc/outpost_prisoner/proc/staff_in_reach() var/mob/living/nearest var/nearest_distance = INFINITY for(var/mob/living/person in view(7, src)) @@ -1020,9 +1017,9 @@ return nearest /// How many rioters other than `except` are going for `person` -/datum/outpost_prison/proc/attackers_on(mob/living/person, mob/living/basic/outpost_prisoner/except) +/datum/outpost_prison/proc/attackers_on(mob/living/person, mob/living/carbon/human/npc/outpost_prisoner/except) var/count = 0 - for(var/mob/living/basic/outpost_prisoner/other in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/other in prisoners) if(other == except || !other.is_rioting() || !other.trouble_can_act()) continue if(other.riot_victim_ref?.resolve() == person) @@ -1030,7 +1027,7 @@ return count /// Whether a rioter's target is still worth hitting -/datum/outpost_prison/proc/still_smashable(atom/target, mob/living/basic/outpost_prisoner/rioter) +/datum/outpost_prison/proc/still_smashable(atom/target, mob/living/carbon/human/npc/outpost_prisoner/rioter) if(QDELETED(target) || !rioter.reachable?[get_turf(target)] || LAZYACCESS(rioter.riot_skips, REF(target)) > world.time) return FALSE if(istype(target, /obj/machinery/light)) @@ -1078,7 +1075,7 @@ * wrecking their cells; wrecks under way go on. Nothing happens while their AI sleeps. */ /datum/outpost_prison/proc/wreck_tick(seconds) - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners.Copy()) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners.Copy()) if(QDELETED(prisoner) || prisoner.phase != PRISONER_PRESENT || prisoner.stat != CONSCIOUS) continue if(prisoner.trouble == PRISONER_TROUBLE_WRECK) @@ -1091,7 +1088,7 @@ * and gets dirty, and they hammer on the door. The warden's log says so. Also the admin panel's hook. * Returns TRUE if they started. */ -/datum/outpost_prison/proc/start_wreck(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/start_wreck(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(QDELETED(prisoner) || prisoner.prison != src || prisoner.phase != PRISONER_PRESENT || prisoner.stat != CONSCIOUS || prisoner.trouble) return FALSE var/datum/outpost_prison_cell/holding = cell_at(get_turf(prisoner)) @@ -1122,7 +1119,7 @@ return TRUE /// A wreck goes on: bangs on the door every few seconds, and after PRISONER_WRECK_TIME the bolts shear -/datum/outpost_prison/proc/wreck_step(mob/living/basic/outpost_prisoner/prisoner, seconds) +/datum/outpost_prison/proc/wreck_step(mob/living/carbon/human/npc/outpost_prisoner/prisoner, seconds) var/datum/outpost_prison_cell/holding = cell_at(get_turf(prisoner)) if(!holding || !prisoner.is_confined()) // Let out, or no longer in a cell: the wreck is over. @@ -1144,7 +1141,7 @@ shear_bolts(prisoner, holding) /// A wreck ends without the bolts shearing: let out, knocked down or gone -/datum/outpost_prison/proc/stop_wreck(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/stop_wreck(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(prisoner.trouble != PRISONER_TROUBLE_WRECK) return prisoner.trouble = null @@ -1153,7 +1150,7 @@ prisoner.update_bubble() /// The cell door gives, bolted or welded: out they come, and unless the wing is subdued they riot -/datum/outpost_prison/proc/shear_bolts(mob/living/basic/outpost_prisoner/prisoner, datum/outpost_prison_cell/holding) +/datum/outpost_prison/proc/shear_bolts(mob/living/carbon/human/npc/outpost_prisoner/prisoner, datum/outpost_prison_cell/holding) stop_wreck(prisoner) var/obj/machinery/door/airlock/door = holding.door() if(door && (door.locked || door.welded)) @@ -1199,7 +1196,7 @@ /// Prisoners on the patrol AI, still in the wing's custody /datum/outpost_prison/proc/loose_count() var/count = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.trouble == PRISONER_TROUBLE_LOOSE && prisoner.phase == PRISONER_PRESENT && prisoner.stat != DEAD) count++ return count @@ -1207,8 +1204,8 @@ /// Loose prisoners nobody has caught yet: not cuffed. Caught ones, left cuffed somewhere, keep no protective custody going. /datum/outpost_prison/proc/runners_at_large() var/count = 0 - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) - if(prisoner.trouble == PRISONER_TROUBLE_LOOSE && prisoner.phase == PRISONER_PRESENT && prisoner.stat != DEAD && !prisoner.cuffs) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) + if(prisoner.trouble == PRISONER_TROUBLE_LOOSE && prisoner.phase == PRISONER_PRESENT && prisoner.stat != DEAD && !prisoner.handcuffed) count++ return count @@ -1219,7 +1216,7 @@ */ /datum/outpost_prison/proc/alarm_state() var/list/sightings = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.trouble == PRISONER_TROUBLE_LOOSE && prisoner.phase == PRISONER_PRESENT && prisoner.stat != DEAD) sightings += "[prisoner.real_name] ([get_area_name(prisoner)])" var/loose_text @@ -1242,7 +1239,7 @@ /// The trouble block for the admin panel and tests: the stage, tension, the riot's clocks and who is on a loose clock where /datum/outpost_prison/proc/trouble_payload() var/list/loose = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners) if(prisoner.phase != PRISONER_PRESENT || prisoner.stat == DEAD || prisoner.loose_left <= 0) continue if(prisoner.trouble != PRISONER_TROUBLE_LOOSE && prisoner.trouble != PRISONER_TROUBLE_BREAKOUT) @@ -1269,7 +1266,7 @@ * or cuffed (can_be_dragged()). */ /datum/outpost_prison/proc/check_escapes(seconds) - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners.Copy()) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners.Copy()) if(QDELETED(prisoner) || prisoner.phase != PRISONER_PRESENT || prisoner.stat == DEAD) continue var/inside = in_cell_block(prisoner) @@ -1300,13 +1297,13 @@ /datum/outpost_prison/proc/loose_tick(seconds) var/list/still_loose = list() var/list/nearly_away = list() - for(var/mob/living/basic/outpost_prisoner/prisoner in prisoners.Copy()) + for(var/mob/living/carbon/human/npc/outpost_prisoner/prisoner in prisoners.Copy()) if(QDELETED(prisoner) || prisoner.phase != PRISONER_PRESENT || prisoner.stat == DEAD || prisoner.loose_left <= 0) continue if(prisoner.trouble != PRISONER_TROUBLE_LOOSE && prisoner.trouble != PRISONER_TROUBLE_BREAKOUT) prisoner.loose_left = 0 continue - if(prisoner.trouble == PRISONER_TROUBLE_LOOSE ? prisoner.cuffs : !prisoner.riot_free()) + if(prisoner.trouble == PRISONER_TROUBLE_LOOSE ? prisoner.handcuffed : !prisoner.riot_free()) continue if(prisoner.loose_left <= seconds && held_for_experiment(prisoner)) continue @@ -1327,7 +1324,7 @@ * Out of the cell block: loose on the outpost patrol AI, with their clock running. `breakout` * marks it as part of a breakout even if they were not rioting (the admin button). */ -/datum/outpost_prison/proc/prisoner_escaped(mob/living/basic/outpost_prisoner/prisoner, breakout = FALSE) +/datum/outpost_prison/proc/prisoner_escaped(mob/living/carbon/human/npc/outpost_prisoner/prisoner, breakout = FALSE) if(prisoner.trouble == PRISONER_TROUBLE_LOOSE) return FALSE var/from_riot = breakout || prisoner.is_rioting() @@ -1353,7 +1350,7 @@ return TRUE /// Goes loose: the outpost patrol AI takes over, and the clock starts, or carries on from the breakout -/mob/living/basic/outpost_prisoner/proc/go_loose() +/mob/living/carbon/human/npc/outpost_prisoner/proc/go_loose() end_activity() stand_up() stop_climb() @@ -1366,11 +1363,8 @@ trouble = PRISONER_TROUBLE_LOOSE if(loose_left <= 0) loose_left = OUTPOST_PRISON_LOOSE_TIME - // Wanted and Most Wanted bounty prisoners hit harder, and a meek one runs faster (outpost_prison_bounty.dm). - obj_damage = PRISONER_LOOSE_OBJ_DAMAGE * bounty_breakout_mult() - if(bounty_loose_speed()) - set_varspeed(bounty_base_speed()) - update_melee() + // A runner runs. + set_prison_pace(hurry = bounty_base_speed()) update_bubble() // The outpost patrol AI (voidcrew/modules/npc_ships/code/outpost_patrol.dm). Finding the doors // yields on a big outpost, and this runs in the prison's tick on SSprocessing. @@ -1378,7 +1372,7 @@ assign_mob_to_outpost_patrol_async(src, prison?.outpost) /// Back in the cell block, down or cuffed: in custody again, in a foul mood, and owing lockdown if they got out during a riot -/datum/outpost_prison/proc/recapture(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/recapture(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(prisoner.trouble != PRISONER_TROUBLE_LOOSE) return FALSE var/owes_lockdown = prisoner.escaped_rioting @@ -1391,21 +1385,17 @@ update_riot_lights() return TRUE -/mob/living/basic/outpost_prisoner/proc/back_in_custody() +/mob/living/carbon/human/npc/outpost_prisoner/proc/back_in_custody() clear_outpost_patrol(src) trouble = null loose_left = 0 escaped_rioting = FALSE note_trouble_ended() - obj_damage = initial(obj_damage) - // A meek bounty prisoner slows back down (outpost_prison_bounty.dm). - if(bounty_loose_speed()) - set_varspeed(bounty_base_speed()) + set_prison_pace(hurry = bounty_base_speed()) drop_shiv() set_mood(PRISONER_RECAPTURED_MOOD) swap_basic_ai_controller(src, /datum/ai_controller/basic_controller/outpost_prisoner) prison?.refresh_prisoner_reach(src) - update_melee() update_bubble() say_context("recaptured") @@ -1413,7 +1403,7 @@ * Out of time: gone for good, walls or no walls. No bonus; the treasury is fined * OUTPOST_PRISON_ESCAPE_FINE as part of the incident, and the corrections service counts them lost. */ -/datum/outpost_prison/proc/escaped_for_good(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/escaped_for_good(mob/living/carbon/human/npc/outpost_prisoner/prisoner) close_bounty_record(prisoner, BOUNTY_RECORD_ESCAPED) var/fine = charge_fine(OUTPOST_PRISON_ESCAPE_FINE, "Prison escape fine: [prisoner.real_name]", TRUE) note_prisoner_lost(prisoner, "escaped") @@ -1434,14 +1424,14 @@ * rioting or not, and treats a loose prisoner outside the wing as fair game until they are down, so * a runner is stopped rather than killed. Turrets players build follow outpost_prison_security.dm. */ -/mob/living/basic/outpost_prisoner/proc/turret_target() +/mob/living/carbon/human/npc/outpost_prisoner/proc/turret_target() if(stat == DEAD || trouble != PRISONER_TROUBLE_LOOSE || phase != PRISONER_PRESENT || can_be_dragged()) return FALSE return !prison || get_area(src) != prison.wing /proc/is_loose_outpost_prisoner(mob/living/creature) - var/mob/living/basic/outpost_prisoner/prisoner = creature - return istype(prisoner) && prisoner.turret_target() + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = creature + return istype(prisoner) && !prisoner.experiment_turned && prisoner.turret_target() // ===== SERVING HATCH ===== diff --git a/voidcrew/modules/player_outposts/outpost_prison_routine.dm b/voidcrew/modules/player_outposts/outpost_prison_routine.dm index 0732c7fa3e9..086d0a15b13 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_routine.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_routine.dm @@ -38,11 +38,11 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) // ===== PRISONER SIDE ===== /// Whether their routine may run now: not while down, cuffed, pulled, in trouble or held by the talk menu (outpost_prison_warden_tools.dm) -/mob/living/basic/outpost_prisoner/proc/routine_allowed() +/mob/living/carbon/human/npc/outpost_prisoner/proc/routine_allowed() return prison && stat == CONSCIOUS && phase == PRISONER_PRESENT && !can_be_dragged() && !pulledby && !in_trouble() && !held_by_talk_menu() /// Ends what they are doing, putting things down and getting up -/mob/living/basic/outpost_prisoner/proc/end_activity(cancel_ai = TRUE) +/mob/living/carbon/human/npc/outpost_prisoner/proc/end_activity(cancel_ai = TRUE) if(!activity) return var/datum/prisoner_activity/old = activity @@ -55,13 +55,13 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) ai_controller?.CancelActions() /// Starts `new_activity` in place of whatever they were doing -/mob/living/basic/outpost_prisoner/proc/start_activity(datum/prisoner_activity/new_activity) +/mob/living/carbon/human/npc/outpost_prisoner/proc/start_activity(datum/prisoner_activity/new_activity) end_activity() activity = new_activity return new_activity /// A walk failed: try once more, then give up on it for a while -/mob/living/basic/outpost_prisoner/proc/activity_move_failed() +/mob/living/carbon/human/npc/outpost_prisoner/proc/activity_move_failed() if(!activity) return if(++activity.failed_moves < 2) @@ -70,14 +70,14 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) end_activity(cancel_ai = FALSE) /// Whether they gave up on this kind of activity recently -/mob/living/basic/outpost_prisoner/proc/activity_on_cooldown(activity_type) +/mob/living/carbon/human/npc/outpost_prisoner/proc/activity_on_cooldown(activity_type) return LAZYACCESS(activity_cooldowns, activity_type) > world.time /** * Picks their next activity: duties and needs first (heading home at release, eating, changing, * calling for the hatch), then leisure by weight. Returns the activity, already set up. */ -/mob/living/basic/outpost_prisoner/proc/choose_activity() +/mob/living/carbon/human/npc/outpost_prisoner/proc/choose_activity() if(!prison) return null if(!walkable) @@ -131,7 +131,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) return null /// The nearest free tile beside `target` they can stand on, or its own tile when walkable -/mob/living/basic/outpost_prisoner/proc/approach_turf(atom/target) +/mob/living/carbon/human/npc/outpost_prisoner/proc/approach_turf(atom/target) var/turf/target_turf = get_turf(target) if(!target_turf || !walkable) return null @@ -150,19 +150,19 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) return best /// Somewhere to hang about: the yard, or their own cell, not someone else's -/mob/living/basic/outpost_prisoner/proc/may_loiter(turf/tile) +/mob/living/carbon/human/npc/outpost_prisoner/proc/may_loiter(turf/tile) var/datum/outpost_prison_cell/holder = prison?.cell_at(tile) return !holder || holder == cell || holder == prison.cell_at(get_turf(src)) /// Whether someone else stands on this tile -/mob/living/basic/outpost_prisoner/proc/tile_taken(turf/tile) +/mob/living/carbon/human/npc/outpost_prisoner/proc/tile_taken(turf/tile) for(var/mob/living/other in tile) if(other != src && other.density) return TRUE return FALSE /// Their bed if they can get to it, else any free bed they can -/mob/living/basic/outpost_prisoner/proc/find_bed() +/mob/living/carbon/human/npc/outpost_prisoner/proc/find_bed() var/obj/structure/bed/own = cell?.bed() if(own && walkable?[get_turf(own)] && !prison.claimed_by_other(own, src)) return own @@ -172,7 +172,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) return null /// A fixture of `category` they can walk up to and nobody else is using, own cell's first, never in another's cell -/mob/living/basic/outpost_prisoner/proc/find_fixture(category, stand_on = FALSE) +/mob/living/carbon/human/npc/outpost_prisoner/proc/find_fixture(category, stand_on = FALSE) var/list/options = list() for(var/atom/fixture as anything in prison.fixtures_of(category)) if(QDELETED(fixture) || prison.claimed_by_other(fixture, src)) @@ -189,7 +189,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) return pick(options) /// Whether `person` is a member of the wing awake in the cell block, close by, holding dressings -/mob/living/basic/outpost_prisoner/proc/is_medic(mob/living/person) +/mob/living/carbon/human/npc/outpost_prisoner/proc/is_medic(mob/living/person) if(!istype(person) || QDELETED(person) || person.stat != CONSCIOUS || is_outpost_prisoner(person)) return FALSE if(get_dist(src, person) > PRISONER_SICK_CALL_RANGE || !prison?.in_cell_block(person) || !prison.is_member(person)) @@ -197,7 +197,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) return !!person.is_holding_item_of_type(/obj/item/stack/medical) /// The nearest medic they can see and walk up to -/mob/living/basic/outpost_prisoner/proc/find_medic() +/mob/living/carbon/human/npc/outpost_prisoner/proc/find_medic() var/mob/living/best var/best_distance = INFINITY for(var/mob/living/person in view(PRISONER_SICK_CALL_RANGE, src)) @@ -213,13 +213,13 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) * Hurt, with a medic in sight: drops whatever idle thing they were doing and goes over. Called * every few seconds by the prison while anyone is on the level. Returns TRUE if they went. */ -/mob/living/basic/outpost_prisoner/proc/check_sick_call() +/mob/living/carbon/human/npc/outpost_prisoner/proc/check_sick_call() if(!ai_running()) return FALSE return start_sick_call() /// Starts a sick call if they are hurt, free and someone holding dressings is near. Returns TRUE if it started. -/mob/living/basic/outpost_prisoner/proc/start_sick_call() +/mob/living/carbon/human/npc/outpost_prisoner/proc/start_sick_call() if(!routine_allowed() || health_factor() >= PRISONER_INJURED_BELOW || !COOLDOWN_FINISHED(src, sick_call_cooldown)) return FALSE // A need, a duty or sleep comes first; anything idle can wait. @@ -236,7 +236,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) * A ball thrown at them: caught by anyone in a game, and by an idle prisoner when staff throw it, * who then starts shooting hoops. Returns TRUE if they caught it. */ -/mob/living/basic/outpost_prisoner/proc/try_catch_ball(atom/movable/thrown_thing, datum/thrownthing/throwing) +/mob/living/carbon/human/npc/outpost_prisoner/proc/try_catch_ball(atom/movable/thrown_thing, datum/thrownthing/throwing) var/obj/item/toy/basketball/ball = thrown_thing if(!istype(ball) || held_item || !routine_allowed() || activity?.sleeping) return FALSE @@ -257,7 +257,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) qdel(game) return TRUE -/mob/living/basic/outpost_prisoner/hitby(atom/movable/AM, skipcatch, hitpush = TRUE, blocked = FALSE, datum/thrownthing/throwingdatum) +/mob/living/carbon/human/npc/outpost_prisoner/hitby(atom/movable/AM, skipcatch, hitpush = TRUE, blocked = FALSE, datum/thrownthing/throwingdatum) if(try_catch_ball(AM, throwingdatum)) return TRUE return ..() @@ -284,7 +284,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) /datum/ai_planning_subtree/outpost_prisoner_routine /datum/ai_planning_subtree/outpost_prisoner_routine/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick) - var/mob/living/basic/outpost_prisoner/prisoner = controller.pawn + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = controller.pawn if(!istype(prisoner) || !prisoner.routine_allowed()) return var/datum/prisoner_activity/activity = prisoner.activity || prisoner.choose_activity() @@ -310,7 +310,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) action_cooldown = 0.5 SECONDS /datum/ai_behavior/outpost_prisoner_travel/setup(datum/ai_controller/controller) - var/mob/living/basic/outpost_prisoner/prisoner = controller.pawn + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = controller.pawn var/turf/spot = prisoner.activity?.spot if(!spot) return FALSE @@ -319,7 +319,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) return TRUE /datum/ai_behavior/outpost_prisoner_travel/perform(seconds_per_tick, datum/ai_controller/controller) - var/mob/living/basic/outpost_prisoner/prisoner = controller.pawn + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = controller.pawn var/datum/prisoner_activity/activity = prisoner.activity if(!activity || prisoner.loc != activity.spot) return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED @@ -330,7 +330,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) /datum/ai_behavior/outpost_prisoner_travel/finish_action(datum/ai_controller/controller, succeeded) . = ..() if(!succeeded) - var/mob/living/basic/outpost_prisoner/prisoner = controller.pawn + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = controller.pawn prisoner?.activity_move_failed() /// Ticks the activity about once a second until it wants to move or is done @@ -338,11 +338,11 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) action_cooldown = 1 SECONDS /datum/ai_behavior/outpost_prisoner_activity/setup(datum/ai_controller/controller) - var/mob/living/basic/outpost_prisoner/prisoner = controller.pawn + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = controller.pawn return !!prisoner.activity /datum/ai_behavior/outpost_prisoner_activity/perform(seconds_per_tick, datum/ai_controller/controller) - var/mob/living/basic/outpost_prisoner/prisoner = controller.pawn + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = controller.pawn var/datum/prisoner_activity/activity = prisoner.activity if(!activity || !prisoner.routine_allowed()) return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED @@ -381,7 +381,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) var/mood_activity = FALSE /// Asleep: no chatting, only sleep talk var/sleeping = FALSE - var/mob/living/basic/outpost_prisoner/prisoner + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner /// Where they are headed; null once there var/turf/spot /// When it ends, once started @@ -392,7 +392,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) /// REF() keys of what this activity has claimed in the prison var/list/claimed -/datum/prisoner_activity/New(mob/living/basic/outpost_prisoner/doer) +/datum/prisoner_activity/New(mob/living/carbon/human/npc/outpost_prisoner/doer) . = ..() prisoner = doer @@ -1062,13 +1062,13 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) /datum/prisoner_activity/chat/setup() var/list/options = list() - for(var/mob/living/basic/outpost_prisoner/other as anything in prisoner.prison.prisoners) + for(var/mob/living/carbon/human/npc/outpost_prisoner/other as anything in prisoner.prison.prisoners) if(other == prisoner || !can_join(other)) continue options += other while(length(options)) // Friends first (outpost_prison_life.dm); the pick comes out of options either way. - var/mob/living/basic/outpost_prisoner/other = prisoner.prison.take_chat_partner(prisoner, options) + var/mob/living/carbon/human/npc/outpost_prisoner/other = prisoner.prison.take_chat_partner(prisoner, options) var/turf/beside = prisoner.approach_turf(other) if(!beside) continue @@ -1078,7 +1078,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) return FALSE /// Whether `other` is free to talk -/datum/prisoner_activity/chat/proc/can_join(mob/living/basic/outpost_prisoner/other) +/datum/prisoner_activity/chat/proc/can_join(mob/living/carbon/human/npc/outpost_prisoner/other) if(QDELETED(other) || !other.routine_allowed() || other.activity?.sleeping) return FALSE if(other.activity && (!other.activity.interruptible || istype(other.activity, /datum/prisoner_activity/chat))) @@ -1086,7 +1086,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) return TRUE /datum/prisoner_activity/chat/arrive() - var/mob/living/basic/outpost_prisoner/partner = partner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/partner = partner_ref?.resolve() if(!partner || get_dist(prisoner, partner) > 1 || !can_join(partner)) return FALSE . = ..() @@ -1096,7 +1096,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) next_exchange = world.time + 1 SECONDS /datum/prisoner_activity/chat/tick(seconds) - var/mob/living/basic/outpost_prisoner/partner = partner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/partner = partner_ref?.resolve() if(!partner || get_dist(prisoner, partner) > 1 || partner.activity?.chat_partner() != prisoner) return ACTIVITY_DONE prisoner.face_atom(partner) @@ -1107,7 +1107,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) return ..() /datum/prisoner_activity/chat/finish() - var/mob/living/basic/outpost_prisoner/partner = partner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/partner = partner_ref?.resolve() if(partner && istype(partner.activity, /datum/prisoner_activity/chat/listen) && partner.activity.chat_partner() == prisoner) partner.end_activity() if(started && partner) @@ -1119,7 +1119,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) leisure = FALSE weight = 0 -/datum/prisoner_activity/chat/listen/New(mob/living/basic/outpost_prisoner/doer, mob/living/basic/outpost_prisoner/talker) +/datum/prisoner_activity/chat/listen/New(mob/living/carbon/human/npc/outpost_prisoner/doer, mob/living/carbon/human/npc/outpost_prisoner/talker) . = ..(doer) partner_ref = WEAKREF(talker) started = TRUE @@ -1133,7 +1133,7 @@ GLOBAL_LIST_INIT(outpost_prisoner_leisure, outpost_prisoner_leisure_types()) return TRUE /datum/prisoner_activity/chat/listen/tick(seconds) - var/mob/living/basic/outpost_prisoner/talker = partner_ref?.resolve() + var/mob/living/carbon/human/npc/outpost_prisoner/talker = partner_ref?.resolve() if(!talker || get_dist(prisoner, talker) > 1 || talker.activity?.chat_partner() != prisoner) return ACTIVITY_DONE prisoner.face_atom(talker) diff --git a/voidcrew/modules/player_outposts/outpost_prison_security.dm b/voidcrew/modules/player_outposts/outpost_prison_security.dm index 636154072b0..f8f5351b6e9 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_security.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_security.dm @@ -15,9 +15,9 @@ * A shot at a prisoner is always a stun shot: the turret's own if its gun has a stamina or * electrode setting that goes through glass, else a disabler beam, whatever the mode. Before the first shot at a prisoner * it has not warned lately, the turret warns them and holds fire for a moment, and the prisoner - * decides what to do about it (react_to_turret()). Its shots pass through anyone the rule spares, - * and a lethal shot passes through every prisoner. Rioters go for turrets they can reach before - * any fixture (priority_smash_target()). + * decides what to do about it (react_to_turret()). The rule is the turret's choice of target: a shot + * that goes wide lands on whoever is in the way, as anyone's would. Rioters go for turrets they can + * reach before any fixture (priority_smash_target()). * * On a player outpost a turret's controls, and a turret control panel's, answer only to the * outpost's members, as a hull turret's do there (ship_defense_turret.dm). @@ -39,10 +39,13 @@ /proc/outpost_prison_turret_verdict(mob/living/target, obj/machinery/porta_turret/turret) if(!isliving(target)) return OUTPOST_PRISON_TURRET_NOT_MINE + // A body the serum took is the creature now, whoever it was (outpost_prison_experiment_forms.dm) + if(is_outpost_experiment_creature(target)) + return (target.stat != DEAD && is_hostile_creature(target)) ? OUTPOST_PRISON_TURRET_SHOOT : OUTPOST_PRISON_TURRET_SPARE if(is_outpost_prisoner(target)) - var/mob/living/basic/outpost_prisoner/prisoner = target + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = target return prisoner.turret_verdict(turret) - if(is_outpost_prison_guard(target) || istype(target, /mob/living/basic/outpost_kessler_staff)) + if(is_outpost_prison_guard(target) || istype(target, /mob/living/carbon/human/npc/outpost_kessler_staff)) return OUTPOST_PRISON_TURRET_SPARE // The experiments' creatures (outpost_prison_creatures.dm, outpost_prison_changeling.dm): until dead, subdued or in Kessler's hands if(is_outpost_prison_mob(target) || is_outpost_experiment_mob(target)) @@ -58,7 +61,7 @@ var/obj/projectile/shot = projectile_type return initial(shot.damage_type) == STAMINA && initial(shot.damage) > 0 -/mob/living/basic/outpost_prisoner +/mob/living/carbon/human/npc/outpost_prisoner /// What they did about a turret's warning while rioting (OUTPOST_PRISON_TURRET_GIVE_UP, _BACK_OFF or _DEFY), the turret, and when that runs out var/turret_reaction var/datum/weakref/turret_reaction_ref @@ -68,7 +71,7 @@ var/turret_retreat_until = 0 /// A turret's verdict on them; see outpost_prison_turret_verdict() -/mob/living/basic/outpost_prisoner/proc/turret_verdict(obj/machinery/porta_turret/turret) +/mob/living/carbon/human/npc/outpost_prisoner/proc/turret_verdict(obj/machinery/porta_turret/turret) if(stat != CONSCIOUS || phase != PRISONER_PRESENT || can_be_dragged() || is_confined()) return OUTPOST_PRISON_TURRET_SPARE if(surrendered_to_turret() || backing_off_from_turret() || !turret_trouble()) @@ -76,21 +79,21 @@ return OUTPOST_PRISON_TURRET_SHOOT /// The trouble a turret answers: rioting or breaking out, loose, swinging at staff, climbing a hatch, or fighting past the argument. Threats, arguments and wrecking a cell are not. -/mob/living/basic/outpost_prisoner/proc/turret_trouble() +/mob/living/carbon/human/npc/outpost_prisoner/proc/turret_trouble() if(is_rioting() || trouble == PRISONER_TROUBLE_LOOSE || climb_ref || swing_ref?.resolve()) return TRUE return trouble == PRISONER_TROUBLE_FIGHT && fight?.fighting /// A rioter who gave up at a turret's warning: in the riot until staff bolt them in, but doing nothing -/mob/living/basic/outpost_prisoner/proc/surrendered_to_turret() +/mob/living/carbon/human/npc/outpost_prisoner/proc/surrendered_to_turret() return turret_reaction == OUTPOST_PRISON_TURRET_GIVE_UP && is_rioting() /// Walking away after backing off from a turret's warning -/mob/living/basic/outpost_prisoner/proc/backing_off_from_turret() +/mob/living/carbon/human/npc/outpost_prisoner/proc/backing_off_from_turret() return world.time < turret_retreat_until /// Forgets what a turret's warning made them do: a riot starting or ending clears it -/mob/living/basic/outpost_prisoner/proc/clear_turret_reaction() +/mob/living/carbon/human/npc/outpost_prisoner/proc/clear_turret_reaction() turret_reaction = null turret_reaction_ref = null turret_reaction_until = 0 @@ -156,7 +159,7 @@ update_appearance() /// Whether it may fire at `prisoner` now. The first time in a while it warns them instead, and holds fire for OUTPOST_PRISON_TURRET_WARN_TIME. -/obj/machinery/porta_turret/proc/prison_may_fire_at(mob/living/basic/outpost_prisoner/prisoner) +/obj/machinery/porta_turret/proc/prison_may_fire_at(mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(outpost_prison_turret_verdict(prisoner, src) != OUTPOST_PRISON_TURRET_SHOOT) return FALSE var/warned = LAZYACCESS(prison_warned_at, REF(prisoner)) @@ -169,7 +172,7 @@ return !(prisoner.is_rioting() && prisoner.prison?.riot_windup_left > 0) /// The warning: a red line on them, a triple beep and "Step away.", and they decide what to do about it. Returns what they did. -/obj/machinery/porta_turret/proc/warn_prisoner(mob/living/basic/outpost_prisoner/prisoner) +/obj/machinery/porta_turret/proc/warn_prisoner(mob/living/carbon/human/npc/outpost_prisoner/prisoner) for(var/key in prison_warned_at?.Copy()) if(world.time - prison_warned_at[key] >= OUTPOST_PRISON_TURRET_REWARN_TIME) LAZYREMOVE(prison_warned_at, key) @@ -180,24 +183,6 @@ say("Step away.") return prisoner.react_to_turret(src) -/// A turret following the prison's rules lands no shot on anyone the rule spares, and no lethal one on a prisoner -/obj/projectile/can_hit_target(atom/target, direct_target = FALSE, ignore_loc = FALSE, cross_failed = FALSE) - if(isliving(target) && istype(firer, /obj/machinery/porta_turret) && !outpost_prison_turret_shot_lands(src, target)) - return FALSE - return ..() - -/// Whether `shot`, fired by a turret, may land on `target` -/proc/outpost_prison_turret_shot_lands(obj/projectile/shot, mob/living/target) - var/obj/machinery/porta_turret/turret = shot.firer - if(!turret.uses_outpost_turret_rules()) - return TRUE - switch(outpost_prison_turret_verdict(target, turret)) - if(OUTPOST_PRISON_TURRET_NOT_MINE) - return TRUE - if(OUTPOST_PRISON_TURRET_SPARE) - return FALSE - return !is_outpost_prisoner(target) || outpost_prison_stun_projectile(shot.type) - // ===== THE WARNING, FROM THE PRISONER'S SIDE ===== /// Percent chance someone swinging at staff or fighting backs off at a turret's warning: likelier the better their mood, never certain either way @@ -235,7 +220,7 @@ * off (riot on out of the turret's sight), or defy it (go for the turret). * Loose prisoners run on the outpost patrol AI and take no notice. Returns what they did, or null. */ -/mob/living/basic/outpost_prisoner/proc/react_to_turret(obj/machinery/porta_turret/turret) +/mob/living/carbon/human/npc/outpost_prisoner/proc/react_to_turret(obj/machinery/porta_turret/turret) if(QDELETED(turret) || stat != CONSCIOUS || phase != PRISONER_PRESENT || can_be_dragged()) return null var/reaction @@ -269,24 +254,24 @@ return reaction /// Backing off with `chance` percent, else defying. The prison's forced_turret_reaction settles it instead, for tests. -/mob/living/basic/outpost_prisoner/proc/turret_roll(chance) +/mob/living/carbon/human/npc/outpost_prisoner/proc/turret_roll(chance) var/forced = prison?.forced_turret_reaction if(forced) return forced == OUTPOST_PRISON_TURRET_DEFY ? OUTPOST_PRISON_TURRET_DEFY : OUTPOST_PRISON_TURRET_BACK_OFF return prob(chance) ? OUTPOST_PRISON_TURRET_BACK_OFF : OUTPOST_PRISON_TURRET_DEFY -/mob/living/basic/outpost_prisoner/proc/set_turret_reaction(reaction, obj/machinery/porta_turret/turret, duration) +/mob/living/carbon/human/npc/outpost_prisoner/proc/set_turret_reaction(reaction, obj/machinery/porta_turret/turret, duration) turret_reaction = reaction turret_reaction_ref = WEAKREF(turret) turret_reaction_until = world.time + duration /// Heads for `spot`, if there is one; no turret shoots them for `duration` meanwhile -/mob/living/basic/outpost_prisoner/proc/start_turret_retreat(turf/spot, duration) +/mob/living/carbon/human/npc/outpost_prisoner/proc/start_turret_retreat(turf/spot, duration) turret_retreat_spot = spot turret_retreat_until = world.time + duration /// Swinging or fighting, and backing off: they drop it, step away from the turret and whoever they were going for, and don't square up again for the threat cooldown -/mob/living/basic/outpost_prisoner/proc/turret_stand_down(obj/machinery/porta_turret/turret) +/mob/living/carbon/human/npc/outpost_prisoner/proc/turret_stand_down(obj/machinery/porta_turret/turret) var/mob/living/other = swing_ref?.resolve() || fight?.opponent_of(src) cancel_threat() threat_cooldown = max(threat_cooldown, PRISONER_THREAT_COOLDOWN) @@ -297,7 +282,7 @@ start_turret_retreat(pick_turret_retreat(turret, FALSE, other), OUTPOST_PRISON_TURRET_RETREAT_TIME) /// A rioter who gives up: the shiv goes down and they walk back to their own cell. Bolted in, they are out of the riot, owing lockdown (outpost_prison_capture.dm). -/mob/living/basic/outpost_prisoner/proc/turret_give_up(obj/machinery/porta_turret/turret) +/mob/living/carbon/human/npc/outpost_prisoner/proc/turret_give_up(obj/machinery/porta_turret/turret) set_turret_reaction(OUTPOST_PRISON_TURRET_GIVE_UP, turret, 0) cancel_threat() drop_shiv() @@ -310,7 +295,7 @@ prison?.add_log("[real_name] gave up rioting at a turret's warning.") /// A rioter who backs off: still rioting, but out of the turret's sight, and leaving alone what it can see for a while -/mob/living/basic/outpost_prisoner/proc/turret_back_off_riot(obj/machinery/porta_turret/turret) +/mob/living/carbon/human/npc/outpost_prisoner/proc/turret_back_off_riot(obj/machinery/porta_turret/turret) set_turret_reaction(OUTPOST_PRISON_TURRET_BACK_OFF, turret, OUTPOST_PRISON_TURRET_AVOID_TIME) // The turret too: under its cover it does not show up in its own view LAZYSET(riot_skips, REF(turret), turret_reaction_until) @@ -324,13 +309,13 @@ start_turret_retreat(pick_turret_retreat(turret, TRUE), OUTPOST_PRISON_TURRET_RETREAT_TIME) /// A rioter who defies it: they go for the turret before anything else (riot_target()), and get shot on the way -/mob/living/basic/outpost_prisoner/proc/turret_defy(obj/machinery/porta_turret/turret) +/mob/living/carbon/human/npc/outpost_prisoner/proc/turret_defy(obj/machinery/porta_turret/turret) set_turret_reaction(OUTPOST_PRISON_TURRET_DEFY, turret, OUTPOST_PRISON_TURRET_DEFY_TIME) LAZYREMOVE(riot_skips, REF(turret)) ai_controller?.CancelActions() /// The turret a rioter defied, while they still mean to smash it and can get at it -/mob/living/basic/outpost_prisoner/proc/defied_turret() +/mob/living/carbon/human/npc/outpost_prisoner/proc/defied_turret() if(turret_reaction != OUTPOST_PRISON_TURRET_DEFY || world.time >= turret_reaction_until || !is_rioting()) return null var/obj/machinery/porta_turret/turret = turret_reaction_ref?.resolve() @@ -339,7 +324,7 @@ return turret /// Where a rioter who gave up waits: their cell's chair or bed (home_seat()), or any free tile of their own cell they can walk to -/mob/living/basic/outpost_prisoner/proc/own_cell_spot() +/mob/living/carbon/human/npc/outpost_prisoner/proc/own_cell_spot() if(!cell) return null var/obj/structure/seat = home_seat() @@ -355,7 +340,7 @@ * can walk to that it cannot see, or failing that the one farthest from it; anyone else a tile or * two away, as far as they can get from it and from `other`. Null if nowhere will do. */ -/mob/living/basic/outpost_prisoner/proc/pick_turret_retreat(obj/machinery/porta_turret/turret, out_of_sight = FALSE, mob/living/other) +/mob/living/carbon/human/npc/outpost_prisoner/proc/pick_turret_retreat(obj/machinery/porta_turret/turret, out_of_sight = FALSE, mob/living/other) if(!length(walkable)) return null var/turf/here = get_turf(src) @@ -387,7 +372,7 @@ * way. At the spot, or out of time, they stop; one who gave up and got to their cell's chair or * bed sits down (sit_in_cell()). */ -/mob/living/basic/outpost_prisoner/proc/plan_turret_retreat(datum/ai_controller/controller) +/mob/living/carbon/human/npc/outpost_prisoner/proc/plan_turret_retreat(datum/ai_controller/controller) if(!turret_retreat_spot) return FALSE if(loc == turret_retreat_spot || world.time >= turret_retreat_until) @@ -398,7 +383,7 @@ controller.queue_behavior(/datum/ai_behavior/outpost_prisoner_turret_retreat) return TRUE -/mob/living/basic/outpost_prisoner/proc/finish_turret_retreat() +/mob/living/carbon/human/npc/outpost_prisoner/proc/finish_turret_retreat() var/turf/spot = turret_retreat_spot turret_retreat_spot = null if(!surrendered_to_turret() || loc != spot || !cell?.contains(src) || !((locate(/obj/structure/chair) in loc) || (locate(/obj/structure/bed) in loc))) @@ -413,7 +398,7 @@ action_cooldown = 0.5 SECONDS /datum/ai_behavior/outpost_prisoner_turret_retreat/setup(datum/ai_controller/controller) - var/mob/living/basic/outpost_prisoner/prisoner = controller.pawn + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = controller.pawn var/turf/spot = prisoner?.turret_retreat_spot if(!spot) return FALSE @@ -422,7 +407,7 @@ return TRUE /datum/ai_behavior/outpost_prisoner_turret_retreat/perform(seconds_per_tick, datum/ai_controller/controller) - var/mob/living/basic/outpost_prisoner/prisoner = controller.pawn + var/mob/living/carbon/human/npc/outpost_prisoner/prisoner = controller.pawn if(!prisoner?.turret_retreat_spot || prisoner.loc != prisoner.turret_retreat_spot) return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED prisoner.finish_turret_retreat() @@ -442,7 +427,7 @@ * rules that they can reach and have not given up on, or null. A rioter newly going for one may * shout about it. */ -/datum/outpost_prison/proc/priority_smash_target(mob/living/basic/outpost_prisoner/rioter) +/datum/outpost_prison/proc/priority_smash_target(mob/living/carbon/human/npc/outpost_prisoner/rioter) if(!rioter?.reachable) return null var/obj/machinery/porta_turret/nearest @@ -457,21 +442,21 @@ nearest_distance = distance if(nearest && rioter.riot_target_ref?.resolve() != nearest && COOLDOWN_FINISHED(src, turret_smash_line_cooldown)) COOLDOWN_START(src, turret_smash_line_cooldown, OUTPOST_PRISON_TURRET_SMASH_LINE_GAP) - INVOKE_ASYNC(rioter, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context), "turret_smash") + INVOKE_ASYNC(rioter, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context), "turret_smash") return nearest /// A turret's shot is about to land on `target`: now and then someone watching says something -/datum/outpost_prison/proc/note_turret_hit(mob/living/basic/outpost_prisoner/target) +/datum/outpost_prison/proc/note_turret_hit(mob/living/carbon/human/npc/outpost_prisoner/target) if(!COOLDOWN_FINISHED(src, turret_hit_line_cooldown) || !prob(OUTPOST_PRISON_TURRET_HIT_LINE_CHANCE)) return FALSE - for(var/mob/living/basic/outpost_prisoner/onlooker in shuffle(prisoners)) + for(var/mob/living/carbon/human/npc/outpost_prisoner/onlooker in shuffle(prisoners)) if(onlooker == target || onlooker.stat != CONSCIOUS || onlooker.phase != PRISONER_PRESENT || !onlooker.ai_running() || onlooker.in_trouble()) continue if(get_dist(onlooker, target) > 7 || !(target in view(7, onlooker))) continue COOLDOWN_START(src, turret_hit_line_cooldown, OUTPOST_PRISON_TURRET_HIT_LINE_GAP) onlooker.face_atom(target) - INVOKE_ASYNC(onlooker, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, say_context), "turret_hit") + INVOKE_ASYNC(onlooker, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, say_context), "turret_hit") return TRUE return FALSE diff --git a/voidcrew/modules/player_outposts/outpost_prison_serum.dm b/voidcrew/modules/player_outposts/outpost_prison_serum.dm index eef2c4310ee..af179458ffa 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_serum.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_serum.dm @@ -55,7 +55,7 @@ /obj/item/outpost_experiment/serum/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers) if(!isliving(interacting_with)) return NONE - var/mob/living/basic/outpost_prisoner/subject = interacting_with + var/mob/living/carbon/human/npc/outpost_prisoner/subject = interacting_with var/error = dose_error(user, subject) if(error) balloon_alert(user, error) @@ -79,7 +79,7 @@ return ITEM_INTERACT_SUCCESS /// Why the serum cannot go into `subject` now, or null -/obj/item/outpost_experiment/serum/proc/dose_error(mob/living/user, mob/living/basic/outpost_prisoner/subject) +/obj/item/outpost_experiment/serum/proc/dose_error(mob/living/user, mob/living/carbon/human/npc/outpost_prisoner/subject) var/error = user_error(user) if(error) return error @@ -207,7 +207,7 @@ */ /datum/component/outpost_experiment_item/proc/eaten_by(mob/living/eater) var/datum/outpost_prison/prison = prison() - var/mob/living/basic/outpost_prisoner/host = eater + var/mob/living/carbon/human/npc/outpost_prisoner/host = eater if(istype(host) && prison && host.prison == prison && prison.start_experiment("changeling", host)) log_game("PLAYER OUTPOST PRISON: [host.real_name] ate food with a Kessler specimen in it at '[prison.outpost?.name]'") qdel(src) @@ -250,7 +250,7 @@ qdel(parent) /// A prisoner eats: food with the specimen in it takes them as its host -/mob/living/basic/outpost_prisoner/eat_food(obj/item/food/meal) +/mob/living/carbon/human/npc/outpost_prisoner/eat_food(obj/item/food/meal) var/datum/component/outpost_experiment_item/specimen = meal?.GetComponent(/datum/component/outpost_experiment_item) . = ..() if(specimen && !QDELETED(specimen)) diff --git a/voidcrew/modules/player_outposts/outpost_prison_social.dm b/voidcrew/modules/player_outposts/outpost_prison_social.dm index a22d32f11dd..00aa58585de 100644 --- a/voidcrew/modules/player_outposts/outpost_prison_social.dm +++ b/voidcrew/modules/player_outposts/outpost_prison_social.dm @@ -103,7 +103,7 @@ var/rep_greet_chance = PRISON_REP_GREET_CHANCE var/rep_word_chance = PRISON_REP_WORD_CHANCE -/mob/living/basic/outpost_prisoner +/mob/living/carbon/human/npc/outpost_prisoner /// Record key -> world.time they last greeted that person var/list/rep_greeted /// Record keys already thanked for bringing them mail this stay @@ -200,7 +200,7 @@ // note_staff_care() and note_staff_hit() run inside signal handlers: nothing here may sleep. /// `person` fed, clothed or treated `prisoner` by hand: once per prisoner per PRISON_REP_CARE_GAP -/datum/outpost_prison/proc/note_staff_care(mob/person, mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/note_staff_care(mob/person, mob/living/carbon/human/npc/outpost_prisoner/prisoner) if(!prisoner || !ismob(person)) return FALSE // note_carer() runs as a dressing is offered, so a dressing held to someone unhurt is not care. @@ -229,7 +229,7 @@ return TRUE /// `person` talked `prisoner` down -/datum/outpost_prison/proc/note_staff_talk(mob/person, mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/note_staff_talk(mob/person, mob/living/carbon/human/npc/outpost_prisoner/prisoner) return rep_adjust(person, PRISON_REP_TALK) /// `person` sank a shot while prisoners played @@ -243,7 +243,7 @@ return rep_adjust(person, min(amount, PRISON_REP_KINDNESS_MAX)) /// An unprovoked hit on `prisoner` that cost them mood (hit_by_staff() has already ruled out deserved ones) -/datum/outpost_prison/proc/note_staff_hit(atom/attacker, mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/note_staff_hit(atom/attacker, mob/living/carbon/human/npc/outpost_prisoner/prisoner) var/counted = FALSE for(var/mob/person in rep_people_behind(attacker)) if(rep_adjust(person, PRISON_REP_HIT)) @@ -254,7 +254,7 @@ * Staff got the blame for `prisoner`: `event` is "beaten" (an unprovoked beating down, on top of * the hits) or "killed" (the score goes to PRISON_REP_MIN). The blame goes to whoever last hit them. */ -/datum/outpost_prison/proc/note_staff_blamed(mob/living/basic/outpost_prisoner/prisoner, event) +/datum/outpost_prison/proc/note_staff_blamed(mob/living/carbon/human/npc/outpost_prisoner/prisoner, event) if(event != "beaten" && event != "killed") return FALSE var/atom/attacker = prisoner?.last_staff_attacker_ref?.resolve() @@ -277,7 +277,7 @@ * prisoner per stay), "mail_opened", "search_found", "search_empty", "patdown_found", * "patdown_empty". Events it does not know, and anyone who is not a member, are ignored. */ -/datum/outpost_prison/proc/note_staff_event(mob/person, mob/living/basic/outpost_prisoner/prisoner, event) +/datum/outpost_prison/proc/note_staff_event(mob/person, mob/living/carbon/human/npc/outpost_prisoner/prisoner, event) var/amount switch(event) if("mail_delivered") @@ -307,7 +307,7 @@ // ===== WHAT IT DOES ===== /// Below this mood `prisoner` squares up to `person`: lower for a fair member, higher for a brute, and higher for some bounty prisoners (outpost_prison_bounty.dm) -/datum/outpost_prison/proc/threat_mood_for(mob/living/basic/outpost_prisoner/prisoner, mob/person) +/datum/outpost_prison/proc/threat_mood_for(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/person) . = PRISONER_THREAT_MOOD switch(staff_label(person)) if("fair") @@ -317,29 +317,29 @@ . += prisoner ? prisoner.bounty_threat_bonus() : 0 /// The highest line threat_mood_for() can return (for `prisoner`, when given), so a prisoner above it looks for nobody -/datum/outpost_prison/proc/threat_mood_ceiling(mob/living/basic/outpost_prisoner/prisoner) +/datum/outpost_prison/proc/threat_mood_ceiling(mob/living/carbon/human/npc/outpost_prisoner/prisoner) return max(PRISONER_THREAT_MOOD, PRISON_REP_THREAT_BRUTE) + (prisoner ? prisoner.bounty_threat_bonus() : 0) /// The mood a talk-down from `person` gives `prisoner` -/datum/outpost_prison/proc/talk_mood_for(mob/living/basic/outpost_prisoner/prisoner, mob/person) +/datum/outpost_prison/proc/talk_mood_for(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/person) return staff_label(person) == "fair" ? PRISON_REP_TALK_MOOD_FAIR : PRISONER_MOOD_TALK /// Whether `prisoner` refuses to be talked down by `person`: a brute, below PRISON_REP_REFUSE_BRUTE_BELOW. It says so itself (async). -/datum/outpost_prison/proc/refuses_talk_from(mob/living/basic/outpost_prisoner/prisoner, mob/person) +/datum/outpost_prison/proc/refuses_talk_from(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/person) if(!prisoner || prisoner.mood >= PRISON_REP_REFUSE_BRUTE_BELOW || staff_label(person) != "brute") return FALSE prisoner.balloon_alert(person, "not listening") - INVOKE_ASYNC(prisoner, TYPE_PROC_REF(/mob/living/basic/outpost_prisoner, turn_away_brute), person) + INVOKE_ASYNC(prisoner, TYPE_PROC_REF(/mob/living/carbon/human/npc/outpost_prisoner, turn_away_brute), person) return TRUE /// Won't hear a word from a brute -/mob/living/basic/outpost_prisoner/proc/turn_away_brute(mob/person) +/mob/living/carbon/human/npc/outpost_prisoner/proc/turn_away_brute(mob/person) if(!QDELETED(person)) face_atom(person) say_to_staff("talk_refuse_brute", person) /// How far `person` seems to a rioter picking whom to go for: a brute nearer, a fair member farther -/datum/outpost_prison/proc/riot_victim_distance(mob/living/basic/outpost_prisoner/prisoner, mob/person, distance) +/datum/outpost_prison/proc/riot_victim_distance(mob/living/carbon/human/npc/outpost_prisoner/prisoner, mob/person, distance) switch(staff_label(person)) if("brute") return distance - PRISON_REP_RIOT_BRUTE_NEARER @@ -355,7 +355,7 @@ * PRISON_REP_GREET_RANGE tiles in view gets greet_